diff --git a/config/functions b/config/functions
index a982f29697..80185349b0 100644
--- a/config/functions
+++ b/config/functions
@@ -286,14 +286,15 @@ dashes="==========================="
exit 1
fi
- if [ ! -f $PROJECT_DIR/$PROJECT/linux/linux.$TARGET_ARCH.conf -a ! -f $HOME/.libreelec/projects/$PROJECT/linux/linux.$TARGET_ARCH.conf ]; then
+ if [ ! -f $PROJECT_DIR/$PROJECT/linux/linux.$TARGET_ARCH.conf -a ! -f $HOME/.libreelec/projects/$PROJECT/linux/linux.$TARGET_ARCH.conf ] &&
+ ! ls $PROJECT_DIR/$PROJECT/linux/*/linux.$TARGET_ARCH.conf &>/dev/null; then
check_arch="$check_arch\n $dashes$dashes$dashes"
check_arch="$check_arch\n ERROR: Architecture not found, use a valid Architecture"
check_arch="$check_arch\n for your project or create a new config"
check_arch="$check_arch\n $dashes$dashes$dashes"
check_arch="$check_arch\n\n Valid Architectures for your project: $PROJECT"
- for arch in $PROJECT_DIR/$PROJECT/linux/*.conf $HOME/.libreelec/projects/$PROJECT/linux/*.conf; do
+ for arch in $PROJECT_DIR/$PROJECT/linux/*.conf $HOME/.libreelec/projects/$PROJECT/linux/*.conf $PROJECT_DIR/$PROJECT/linux/*/linux.$TARGET_ARCH.conf; do
check_arch="$check_arch\n - $(basename $arch | cut -f2 -d".")"
done
echo -e $check_arch
diff --git a/packages/graphics/gpu-viv-bin-mx6q/package.mk b/packages/graphics/gpu-viv-bin-mx6q/package.mk
index 339e5de390..dde2f2ba9e 100644
--- a/packages/graphics/gpu-viv-bin-mx6q/package.mk
+++ b/packages/graphics/gpu-viv-bin-mx6q/package.mk
@@ -17,67 +17,48 @@
################################################################################
PKG_NAME="gpu-viv-bin-mx6q"
-PKG_VERSION="3.10.17-1.0.0-1"
+PKG_VERSION="3.10.17-1.0.2-hfp"
PKG_REV="1"
PKG_ARCH="arm"
PKG_LICENSE="nonfree"
PKG_SITE="http://www.freescale.com"
PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
-PKG_DEPENDS_TARGET="toolchain"
+PKG_DEPENDS_TARGET="toolchain gpu-viv-g2d"
PKG_PRIORITY="optional"
PKG_SECTION="graphics"
PKG_SHORTDESC="gpu-viv-bin-mx6q: OpenGL-ES and VIVANTE driver for imx6q"
PKG_LONGDESC="gpu-viv-bin-mx6q: OpenGL-ES and VIVANTE driver for imx6q"
-
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"
-if [ "$TARGET_FLOAT" = "softfp" -o "$TARGET_FLOAT" = "soft" ]; then
- FLOAT="softfp"
-elif [ "$TARGET_FLOAT" = "hard" ]; then
- FLOAT="hardfp"
-fi
-
make_target() {
: # nothing to make
}
makeinstall_target() {
mkdir -p $SYSROOT_PREFIX/usr/include
- cp -PRv $FLOAT/usr/include/* $SYSROOT_PREFIX/usr/include
+ cp -PRv usr/include/* $SYSROOT_PREFIX/usr/include
+
+ LIBS_COPY="usr/lib/libEGL-fb.so \
+ usr/lib/libEGL.so* \
+ usr/lib/libGLES_CL.so \
+ usr/lib/libGLES_CM.so \
+ usr/lib/libGLESv1_CL.so* \
+ usr/lib/libGLESv1_CM.so* \
+ usr/lib/libGLESv2-fb.so \
+ usr/lib/libGLESv2.so* \
+ usr/lib/libGLSLC.so* \
+ usr/lib/libGAL-fb.so \
+ usr/lib/libGAL.so* \
+ usr/lib/libVIVANTE-fb.so \
+ usr/lib/libVIVANTE.so* \
+ usr/lib/libOpenCL.so"
mkdir -p $SYSROOT_PREFIX/usr/lib
- cp -PRv $FLOAT/usr/lib/libEGL-fb.so \
- $FLOAT/usr/lib/libEGL.so* \
- $FLOAT/usr/lib/libGLES_CL.so \
- $FLOAT/usr/lib/libGLES_CM.so \
- $FLOAT/usr/lib/libGLESv1_CL.so* \
- $FLOAT/usr/lib/libGLESv1_CM.so* \
- $FLOAT/usr/lib/libGLESv2-fb.so \
- $FLOAT/usr/lib/libGLESv2.so* \
- $FLOAT/usr/lib/libGAL-fb.so \
- $FLOAT/usr/lib/libGAL.so* \
- $FLOAT/usr/lib/libVIVANTE-fb.so \
- $FLOAT/usr/lib/libVIVANTE.so* \
- $FLOAT/usr/lib/libOpenCL.so \
- $SYSROOT_PREFIX/usr/lib
+ cp -PRv $LIBS_COPY $SYSROOT_PREFIX/usr/lib
mkdir -p $INSTALL/usr/lib
- cp -PRv $FLOAT/usr/lib/libEGL-fb.so \
- $FLOAT/usr/lib/libEGL.so* \
- $FLOAT/usr/lib/libGLES_CL.so \
- $FLOAT/usr/lib/libGLES_CM.so \
- $FLOAT/usr/lib/libGLESv1_CL.so* \
- $FLOAT/usr/lib/libGLESv1_CM.so* \
- $FLOAT/usr/lib/libGLESv2-fb.so \
- $FLOAT/usr/lib/libGLESv2.so* \
- $FLOAT/usr/lib/libGLSLC.so* \
- $FLOAT/usr/lib/libGAL-fb.so \
- $FLOAT/usr/lib/libGAL.so* \
- $FLOAT/usr/lib/libVIVANTE-fb.so \
- $FLOAT/usr/lib/libVIVANTE.so* \
- $FLOAT/usr/lib/libOpenCL.so \
- $INSTALL/usr/lib
+ cp -PRv $LIBS_COPY $INSTALL/usr/lib
}
post_install() {
diff --git a/packages/graphics/imx-gpu-viv/package.mk b/packages/graphics/imx-gpu-viv/package.mk
new file mode 100644
index 0000000000..c2401165dc
--- /dev/null
+++ b/packages/graphics/imx-gpu-viv/package.mk
@@ -0,0 +1,71 @@
+################################################################################
+# This file is part of OpenELEC - http://www.openelec.tv
+# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
+#
+# OpenELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# OpenELEC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenELEC. If not, see .
+################################################################################
+
+PKG_NAME="imx-gpu-viv"
+PKG_VERSION="5.0.11.p4.5-hfp"
+PKG_REV="1"
+PKG_ARCH="arm"
+PKG_LICENSE="nonfree"
+PKG_SITE="http://www.freescale.com"
+PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
+PKG_DEPENDS_TARGET="toolchain"
+PKG_PRIORITY="optional"
+PKG_SECTION="graphics"
+PKG_SHORTDESC="imx-gpu-viv: OpenGL-ES and VIVANTE driver for imx6q"
+PKG_LONGDESC="imx-gpu-viv: OpenGL-ES and VIVANTE driver for imx6q"
+PKG_IS_ADDON="no"
+PKG_AUTORECONF="no"
+
+make_target() {
+ : # nothing to make
+}
+
+makeinstall_target() {
+ mkdir -p $SYSROOT_PREFIX/usr/include
+ cp -PRv gpu-core/usr/include/* $SYSROOT_PREFIX/usr/include
+ cp -PRv g2d/usr/include/* $SYSROOT_PREFIX/usr/include
+
+ LIBS_COPY="gpu-core/usr/lib/libEGL-fb.so \
+ gpu-core/usr/lib/libEGL.so* \
+ gpu-core/usr/lib/libGLES_CL.so* \
+ gpu-core/usr/lib/libGLES_CM.so* \
+ gpu-core/usr/lib/libGLESv1_CL.so* \
+ gpu-core/usr/lib/libGLESv1_CM.so* \
+ gpu-core/usr/lib/libGLESv2-fb.so \
+ gpu-core/usr/lib/libGLESv2.so* \
+ gpu-core/usr/lib/libGLSLC.so* \
+ gpu-core/usr/lib/libGAL-fb.so \
+ gpu-core/usr/lib/libGAL.so* \
+ gpu-core/usr/lib/libGAL_egl.fb.so \
+ gpu-core/usr/lib/libGAL_egl.so* \
+ gpu-core/usr/lib/libVIVANTE-fb.so \
+ gpu-core/usr/lib/libVIVANTE.so* \
+ gpu-core/usr/lib/libOpenCL.so \
+ gpu-core/usr/lib/libVSC.so \
+ g2d/usr/lib/libg2d*.so*"
+
+ mkdir -p $SYSROOT_PREFIX/usr/lib
+ cp -PRv $LIBS_COPY $SYSROOT_PREFIX/usr/lib
+
+ mkdir -p $INSTALL/usr/lib
+ cp -PRv $LIBS_COPY $INSTALL/usr/lib
+}
+
+post_install() {
+ enable_service unbind-console.service
+}
diff --git a/packages/graphics/imx-gpu-viv/system.d/unbind-console.service b/packages/graphics/imx-gpu-viv/system.d/unbind-console.service
new file mode 100644
index 0000000000..af5e5d44c4
--- /dev/null
+++ b/packages/graphics/imx-gpu-viv/system.d/unbind-console.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=unbind Framebuffer console
+
+ConditionPathExists=/sys/class/vtconsole/vtcon1/bind
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c 'echo 0 > /sys/class/vtconsole/vtcon1/bind'
+
+[Install]
+WantedBy=graphical.target
diff --git a/packages/linux/package.mk b/packages/linux/package.mk
index dfebdc6412..5e26cfd1ba 100644
--- a/packages/linux/package.mk
+++ b/packages/linux/package.mk
@@ -35,8 +35,11 @@ case "$LINUX" in
PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
;;
imx6)
- PKG_VERSION="cuboxi-3.14-ea83bda"
- PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
+ PKG_VERSION="3.14-mx6-sr"
+ PKG_COMMIT="4386797"
+ PKG_SOURCE_DIR="$PKG_NAME-$PKG_VERSION-$PKG_COMMIT"
+ PKG_SOURCE_NAME="$PKG_SOURCE_DIR.tar.xz"
+ PKG_URL="$DISTRO_SRC/$PKG_SOURCE_NAME"
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET imx6-status-led imx6-soc-fan"
;;
*)
@@ -55,8 +58,12 @@ if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
fi
post_patch() {
- if [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf ]; then
+ if [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf ]; then
+ KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf
+ elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf
+ elif [ -f $PKG_DIR/config/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf ]; then
+ KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf
else
KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_NAME.$TARGET_ARCH.conf
fi
diff --git a/packages/mediacenter/kodi/package.mk b/packages/mediacenter/kodi/package.mk
index dccc9459aa..47205e14cd 100644
--- a/packages/mediacenter/kodi/package.mk
+++ b/packages/mediacenter/kodi/package.mk
@@ -201,7 +201,6 @@ if [ ! "$KODIPLAYER_DRIVER" = default ]; then
KODI_CXXFLAGS="$KODI_CXXFLAGS $BCM2835_INCLUDES"
elif [ "$KODIPLAYER_DRIVER" = libfslvpuwrap ]; then
KODI_CODEC="--enable-codec=imxvpu"
- PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET gpu-viv-g2d"
elif [ "$KODIPLAYER_DRIVER" = libamcodec ]; then
KODI_CODEC="--enable-codec=amcodec"
else
diff --git a/projects/imx6/linux/linux.arm.conf b/projects/imx6/linux/3.14-mx6-sr/linux.arm.conf
similarity index 96%
rename from projects/imx6/linux/linux.arm.conf
rename to projects/imx6/linux/3.14-mx6-sr/linux.arm.conf
index fbe6f82a1e..be64eee02c 100644
--- a/projects/imx6/linux/linux.arm.conf
+++ b/projects/imx6/linux/3.14-mx6-sr/linux.arm.conf
@@ -1,6 +1,6 @@
#
# Automatically generated file; DO NOT EDIT.
-# Linux/arm 3.14.36 Kernel Configuration
+# Linux/arm 3.14.60 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_MIGHT_HAVE_PCI=y
@@ -9,7 +9,7 @@ CONFIG_HAVE_PROC_CPU=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_SUPPORT=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_ARCH_HAS_CPUFREQ=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
@@ -102,7 +102,7 @@ CONFIG_RCU_NOCB_CPU=y
# CONFIG_RCU_NOCB_CPU_NONE is not set
# CONFIG_RCU_NOCB_CPU_ZERO is not set
CONFIG_RCU_NOCB_CPU_ALL=y
-CONFIG_IKCONFIG=m
+CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=17
CONFIG_GENERIC_SCHED_CLOCK=y
@@ -272,7 +272,7 @@ CONFIG_INLINE_WRITE_UNLOCK=y
CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
CONFIG_MUTEX_SPIN_ON_OWNER=y
-# CONFIG_FREEZER is not set
+CONFIG_FREEZER=y
#
# System Type
@@ -339,7 +339,7 @@ CONFIG_ARCH_MXC=y
#
# Freescale i.MX support
#
-CONFIG_MXC_DEBUG_BOARD=y
+# CONFIG_MXC_DEBUG_BOARD is not set
CONFIG_HAVE_IMX_ANATOP=y
CONFIG_HAVE_IMX_GPC=y
CONFIG_HAVE_IMX_MMDC=y
@@ -357,8 +357,10 @@ CONFIG_HAVE_IMX_SRC=y
#
# CONFIG_SOC_IMX50 is not set
# CONFIG_SOC_IMX53 is not set
+CONFIG_SOC_IMX6=y
CONFIG_SOC_IMX6Q=y
-CONFIG_SOC_IMX6SL=y
+# CONFIG_SOC_IMX6SL is not set
+# CONFIG_SOC_IMX6SX is not set
# CONFIG_SOC_VF610 is not set
# CONFIG_ARCH_OMAP3 is not set
# CONFIG_ARCH_OMAP4 is not set
@@ -432,8 +434,6 @@ CONFIG_ARM_ERRATA_764369=y
CONFIG_ARM_ERRATA_775420=y
# CONFIG_ARM_ERRATA_798181 is not set
# CONFIG_ARM_ERRATA_773022 is not set
-CONFIG_ARM_ERRATA_794072=y
-CONFIG_ARM_ERRATA_761320=y
#
# Bus support
@@ -456,6 +456,7 @@ CONFIG_PCIE_DW=y
CONFIG_PCI_IMX6=y
# CONFIG_EP_MODE_IN_EP_RC_SYS is not set
# CONFIG_RC_MODE_IN_EP_RC_SYS is not set
+# CONFIG_PCI_HOST_GENERIC is not set
CONFIG_PCIEPORTBUS=y
CONFIG_PCIEAER=y
# CONFIG_PCIE_ECRC is not set
@@ -482,10 +483,10 @@ CONFIG_HAVE_ARM_SCU=y
CONFIG_HAVE_ARM_TWD=y
# CONFIG_MCPM is not set
# CONFIG_BIG_LITTLE is not set
-# CONFIG_VMSPLIT_3G is not set
-CONFIG_VMSPLIT_2G=y
+CONFIG_VMSPLIT_3G=y
+# CONFIG_VMSPLIT_2G is not set
# CONFIG_VMSPLIT_1G is not set
-CONFIG_PAGE_OFFSET=0x80000000
+CONFIG_PAGE_OFFSET=0xC0000000
CONFIG_NR_CPUS=4
CONFIG_HOTPLUG_CPU=y
# CONFIG_ARM_PSCI is not set
@@ -531,6 +532,7 @@ CONFIG_CLEANCACHE=y
CONFIG_FRONTSWAP=y
CONFIG_CMA=y
# CONFIG_CMA_DEBUG is not set
+# CONFIG_CMA_DEBUGFS is not set
CONFIG_CMA_AREAS=7
# CONFIG_ZBUD is not set
# CONFIG_ZSWAP is not set
@@ -556,6 +558,8 @@ CONFIG_CMDLINE="root=/dev/ram0 rdinit=/init noram usbcore.autosuspend=-1 coheren
# CONFIG_CMDLINE_FROM_BOOTLOADER is not set
CONFIG_CMDLINE_EXTEND=y
# CONFIG_CMDLINE_FORCE is not set
+CONFIG_KEXEC=y
+CONFIG_ATAGS_PROC=y
# CONFIG_CRASH_DUMP is not set
CONFIG_AUTO_ZRELADDR=y
@@ -574,8 +578,8 @@ CONFIG_CPU_FREQ_STAT=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
-CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
# CONFIG_CPU_FREQ_GOV_USERSPACE is not set
@@ -587,7 +591,7 @@ CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
#
# ARM CPU frequency scaling drivers
#
-CONFIG_ARM_IMX6_CPUFREQ=y
+CONFIG_ARM_IMX6Q_CPUFREQ=y
# CONFIG_ARM_KIRKWOOD_CPUFREQ is not set
#
@@ -622,16 +626,25 @@ CONFIG_COREDUMP=y
#
# Power management options
#
-# CONFIG_SUSPEND is not set
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_PM_SLEEP=y
+CONFIG_PM_SLEEP_SMP=y
+# CONFIG_PM_AUTOSLEEP is not set
+# CONFIG_PM_WAKELOCKS is not set
CONFIG_PM_RUNTIME=y
CONFIG_PM=y
-CONFIG_PM_DEBUG=y
-# CONFIG_PM_ADVANCED_DEBUG is not set
+# CONFIG_PM_DEBUG is not set
# CONFIG_APM_EMULATION is not set
CONFIG_ARCH_HAS_OPP=y
CONFIG_PM_OPP=y
CONFIG_PM_CLK=y
+CONFIG_PM_GENERIC_DOMAINS=y
# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set
+CONFIG_PM_GENERIC_DOMAINS_SLEEP=y
+CONFIG_PM_GENERIC_DOMAINS_RUNTIME=y
+CONFIG_PM_GENERIC_DOMAINS_OF=y
+CONFIG_CPU_PM=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARM_CPU_SUSPEND=y
CONFIG_NET=y
@@ -1000,10 +1013,9 @@ CONFIG_EXTRA_FIRMWARE_DIR="firmware"
# CONFIG_DEBUG_DEVRES is not set
# CONFIG_SYS_HYPERVISOR is not set
# CONFIG_GENERIC_CPU_DEVICES is not set
-# CONFIG_HAVE_CPU_AUTOPROBE is not set
CONFIG_SOC_BUS=y
CONFIG_REGMAP=y
-CONFIG_REGMAP_AC97=m
+CONFIG_REGMAP_AC97=y
CONFIG_REGMAP_I2C=y
CONFIG_REGMAP_SPI=y
CONFIG_REGMAP_MMIO=y
@@ -1091,7 +1103,6 @@ CONFIG_MTD_PHYSMAP_OF=y
CONFIG_MTD_DATAFLASH=y
# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
# CONFIG_MTD_DATAFLASH_OTP is not set
-CONFIG_MTD_M25P80=y
CONFIG_MTD_SST25L=y
# CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_PHRAM is not set
@@ -1124,6 +1135,7 @@ CONFIG_MTD_NAND_MXC=y
# LPDDR flash memory drivers
#
# CONFIG_MTD_LPDDR is not set
+# CONFIG_MTD_SPI_NOR is not set
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
@@ -1354,11 +1366,9 @@ CONFIG_ATA_BMDMA=y
# SATA SFF controllers with BMDMA
#
# CONFIG_ATA_PIIX is not set
-# CONFIG_SATA_HIGHBANK is not set
# CONFIG_SATA_MV is not set
# CONFIG_SATA_NV is not set
# CONFIG_SATA_PROMISE is not set
-# CONFIG_SATA_RCAR is not set
# CONFIG_SATA_SIL is not set
# CONFIG_SATA_SIS is not set
# CONFIG_SATA_SVW is not set
@@ -1371,14 +1381,10 @@ CONFIG_ATA_BMDMA=y
#
# CONFIG_PATA_ALI is not set
# CONFIG_PATA_AMD is not set
-# CONFIG_PATA_ARASAN_CF is not set
# CONFIG_PATA_ARTOP is not set
# CONFIG_PATA_ATIIXP is not set
# CONFIG_PATA_ATP867X is not set
# CONFIG_PATA_CMD64X is not set
-# CONFIG_PATA_CS5520 is not set
-# CONFIG_PATA_CS5530 is not set
-# CONFIG_PATA_CS5536 is not set
# CONFIG_PATA_CYPRESS is not set
# CONFIG_PATA_EFAR is not set
# CONFIG_PATA_HPT366 is not set
@@ -1399,7 +1405,6 @@ CONFIG_PATA_IMX=y
# CONFIG_PATA_PDC_OLD is not set
# CONFIG_PATA_RADISYS is not set
# CONFIG_PATA_RDC is not set
-# CONFIG_PATA_SC1200 is not set
# CONFIG_PATA_SCH is not set
# CONFIG_PATA_SERVERWORKS is not set
# CONFIG_PATA_SIL680 is not set
@@ -1701,8 +1706,10 @@ CONFIG_B43_HWRNG=y
CONFIG_BRCMUTIL=m
# CONFIG_BRCMSMAC is not set
CONFIG_BRCMFMAC=m
+CONFIG_BRCMFMAC_PROTO_BCDC=y
CONFIG_BRCMFMAC_SDIO=y
CONFIG_BRCMFMAC_USB=y
+# CONFIG_BRCMFMAC_PCIE is not set
# CONFIG_BRCM_TRACING is not set
# CONFIG_BRCMDBG is not set
# CONFIG_HOSTAP is not set
@@ -1833,7 +1840,9 @@ CONFIG_TOUCHSCREEN_ADS7846=m
# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set
# CONFIG_TOUCHSCREEN_EETI is not set
CONFIG_TOUCHSCREEN_EGALAX=m
+# CONFIG_TOUCHSCREEN_ELAN is not set
# CONFIG_TOUCHSCREEN_FUJITSU is not set
+# CONFIG_TOUCHSCREEN_GOODIX is not set
# CONFIG_TOUCHSCREEN_ILI210X is not set
# CONFIG_TOUCHSCREEN_GUNZE is not set
# CONFIG_TOUCHSCREEN_ELO is not set
@@ -1854,23 +1863,23 @@ CONFIG_TOUCHSCREEN_EGALAX=m
CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
# CONFIG_TOUCHSCREEN_MC13783 is not set
CONFIG_TOUCHSCREEN_USB_EGALAX=y
-# CONFIG_TOUCHSCREEN_USB_PANJIT is not set
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
CONFIG_TOUCHSCREEN_USB_3M=y
-# CONFIG_TOUCHSCREEN_USB_ITM is not set
-# CONFIG_TOUCHSCREEN_USB_ETURBO is not set
-# CONFIG_TOUCHSCREEN_USB_GUNZE is not set
-# CONFIG_TOUCHSCREEN_USB_DMC_TSC10 is not set
-# CONFIG_TOUCHSCREEN_USB_IRTOUCH is not set
-# CONFIG_TOUCHSCREEN_USB_IDEALTEK is not set
-# CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH is not set
-# CONFIG_TOUCHSCREEN_USB_GOTOP is not set
-# CONFIG_TOUCHSCREEN_USB_JASTEC is not set
-# CONFIG_TOUCHSCREEN_USB_ELO is not set
-# CONFIG_TOUCHSCREEN_USB_E2I is not set
-# CONFIG_TOUCHSCREEN_USB_ZYTRONIC is not set
-# CONFIG_TOUCHSCREEN_USB_ETT_TC45USB is not set
-# CONFIG_TOUCHSCREEN_USB_NEXIO is not set
-# CONFIG_TOUCHSCREEN_USB_EASYTOUCH is not set
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_TOUCHSCREEN_USB_JASTEC=y
+CONFIG_TOUCHSCREEN_USB_ELO=y
+CONFIG_TOUCHSCREEN_USB_E2I=y
+CONFIG_TOUCHSCREEN_USB_ZYTRONIC=y
+CONFIG_TOUCHSCREEN_USB_ETT_TC45USB=y
+CONFIG_TOUCHSCREEN_USB_NEXIO=y
+CONFIG_TOUCHSCREEN_USB_EASYTOUCH=y
# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
# CONFIG_TOUCHSCREEN_TSC_SERIO is not set
# CONFIG_TOUCHSCREEN_TSC2005 is not set
@@ -1902,6 +1911,7 @@ CONFIG_INPUT_UINPUT=y
# CONFIG_INPUT_ADXL34X is not set
# CONFIG_INPUT_IMS_PCU is not set
# CONFIG_INPUT_CMA3000 is not set
+# CONFIG_INPUT_ISL29023 is not set
#
# Hardware I/O ports
@@ -1916,6 +1926,7 @@ CONFIG_TTY=y
CONFIG_VT=y
CONFIG_CONSOLE_TRANSLATIONS=y
CONFIG_VT_CONSOLE=y
+CONFIG_VT_CONSOLE_SLEEP=y
CONFIG_HW_CONSOLE=y
CONFIG_VT_HW_CONSOLE_BINDING=y
CONFIG_UNIX98_PTYS=y
@@ -1957,6 +1968,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y
# CONFIG_SERIAL_ST_ASC is not set
# CONFIG_TTY_PRINTK is not set
CONFIG_FSL_OTP=y
+# CONFIG_FSL_OTP_WRITE_ENABLE is not set
# CONFIG_HVC_DCC is not set
# CONFIG_IPMI_HANDLER is not set
CONFIG_HW_RANDOM=y
@@ -2109,7 +2121,6 @@ CONFIG_PINCONF=y
# CONFIG_PINCTRL_CAPRI is not set
CONFIG_PINCTRL_IMX=y
CONFIG_PINCTRL_IMX6Q=y
-CONFIG_PINCTRL_IMX6SL=y
# CONFIG_PINCTRL_MSM8X74 is not set
# CONFIG_PINCTRL_SINGLE is not set
CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
@@ -2227,9 +2238,9 @@ CONFIG_POWER_SUPPLY=y
# CONFIG_CHARGER_SMB347 is not set
# CONFIG_IMX6_USB_CHARGER is not set
CONFIG_POWER_RESET=y
-# CONFIG_POWER_RESET_GPIO is not set
+CONFIG_POWER_RESET_GPIO=y
# CONFIG_POWER_RESET_RESTART is not set
-CONFIG_POWER_RESET_UDOO=y
+CONFIG_POWER_RESET_SNVS=y
# CONFIG_POWER_AVS is not set
CONFIG_HWMON=y
# CONFIG_HWMON_VID is not set
@@ -2267,7 +2278,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_G762 is not set
# CONFIG_SENSORS_GL518SM is not set
# CONFIG_SENSORS_GL520SM is not set
-# CONFIG_SENSORS_GPIO_FAN is not set
+CONFIG_SENSORS_GPIO_FAN=m
# CONFIG_SENSORS_HIH6130 is not set
# CONFIG_SENSORS_HTU21 is not set
# CONFIG_SENSORS_IT87 is not set
@@ -2297,6 +2308,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_MAX16065 is not set
# CONFIG_SENSORS_MAX1619 is not set
# CONFIG_SENSORS_MAX1668 is not set
+# CONFIG_SENSORS_MAX17135 is not set
# CONFIG_SENSORS_MAX197 is not set
# CONFIG_SENSORS_MAX6639 is not set
# CONFIG_SENSORS_MAX6642 is not set
@@ -2345,6 +2357,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_W83627EHF is not set
# CONFIG_SENSORS_MC13783_ADC is not set
# CONFIG_SENSORS_MAG3110 is not set
+# CONFIG_MXC_MMA8451 is not set
CONFIG_THERMAL=y
CONFIG_THERMAL_HWMON=y
CONFIG_THERMAL_OF=y
@@ -2405,6 +2418,7 @@ CONFIG_MFD_DA9052_I2C=y
# CONFIG_MFD_DA9055 is not set
# CONFIG_MFD_DA9063 is not set
CONFIG_MFD_MXC_HDMI=y
+# CONFIG_MFD_MXC_HDMI_ANDROID is not set
CONFIG_MFD_MC13XXX=m
CONFIG_MFD_MC13XXX_SPI=m
CONFIG_MFD_MC13XXX_I2C=m
@@ -2418,6 +2432,7 @@ CONFIG_MFD_MC13XXX_I2C=m
# CONFIG_MFD_88PM800 is not set
# CONFIG_MFD_88PM805 is not set
# CONFIG_MFD_88PM860X is not set
+# CONFIG_MFD_MAX17135 is not set
# CONFIG_MFD_MAX14577 is not set
# CONFIG_MFD_MAX77686 is not set
# CONFIG_MFD_MAX77693 is not set
@@ -2473,6 +2488,7 @@ CONFIG_MFD_SYSCON=y
# CONFIG_MFD_WM831X_SPI is not set
# CONFIG_MFD_WM8350_I2C is not set
# CONFIG_MFD_WM8994 is not set
+# CONFIG_MFD_TDA1997X is not set
# CONFIG_VEXPRESS_CONFIG is not set
CONFIG_REGULATOR=y
# CONFIG_REGULATOR_DEBUG is not set
@@ -2491,6 +2507,7 @@ CONFIG_REGULATOR_ANATOP=y
# CONFIG_REGULATOR_LP3972 is not set
# CONFIG_REGULATOR_LP872X is not set
# CONFIG_REGULATOR_LP8755 is not set
+# CONFIG_REGULATOR_LTC3676 is not set
# CONFIG_REGULATOR_MAX1586 is not set
# CONFIG_REGULATOR_MAX8649 is not set
# CONFIG_REGULATOR_MAX8660 is not set
@@ -2663,7 +2680,9 @@ CONFIG_V4L_PLATFORM_DRIVERS=y
# CONFIG_VIDEO_CAFE_CCIC is not set
# CONFIG_VIDEO_TIMBERDALE is not set
CONFIG_VIDEO_MXC_OUTPUT=y
+# CONFIG_VIDEO_MXC_CAPTURE is not set
CONFIG_VIDEO_MXC_IPU_OUTPUT=y
+# CONFIG_VIDEO_MXC_PXP_V4L2 is not set
# CONFIG_SOC_CAMERA is not set
# CONFIG_V4L_MEM2MEM_DRIVERS is not set
# CONFIG_V4L_TEST_DRIVERS is not set
@@ -2889,9 +2908,15 @@ CONFIG_DVB_SP2=m
#
CONFIG_VGA_ARB=y
CONFIG_VGA_ARB_MAX_GPUS=16
+
+#
+# Vivante GPU support
+#
+CONFIG_VIVANTE_GALCORE=y
# CONFIG_DRM is not set
# CONFIG_VGASTATE is not set
# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_VIDEOMODE_HELPERS=y
CONFIG_FB=y
# CONFIG_FIRMWARE_EDID is not set
# CONFIG_FB_DDC is not set
@@ -2916,7 +2941,6 @@ CONFIG_FB_MODE_HELPERS=y
#
# CONFIG_FB_CIRRUS is not set
# CONFIG_FB_PM2 is not set
-# CONFIG_FB_ARMHDLCD is not set
# CONFIG_FB_IMX is not set
# CONFIG_FB_CYBER2000 is not set
# CONFIG_FB_ASILIANT is not set
@@ -2947,20 +2971,39 @@ CONFIG_FB_MODE_HELPERS=y
# CONFIG_FB_UDL is not set
# CONFIG_FB_GOLDFISH is not set
# CONFIG_FB_VIRTUAL is not set
+CONFIG_FB_VIRTUAL_PHYMEM=y
# CONFIG_FB_METRONOME is not set
# CONFIG_FB_MB862XX is not set
# CONFIG_FB_MX3 is not set
# CONFIG_FB_BROADSHEET is not set
# CONFIG_FB_AUO_K190X is not set
+# CONFIG_FB_MXS is not set
# CONFIG_FB_SIMPLE is not set
# CONFIG_EXYNOS_VIDEO is not set
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+# CONFIG_BACKLIGHT_GENERIC is not set
+# CONFIG_BACKLIGHT_PWM is not set
+# CONFIG_BACKLIGHT_DA9052 is not set
+# CONFIG_BACKLIGHT_ADP8860 is not set
+# CONFIG_BACKLIGHT_ADP8870 is not set
+# CONFIG_BACKLIGHT_LM3630A is not set
+# CONFIG_BACKLIGHT_LM3639 is not set
+# CONFIG_BACKLIGHT_LP855X is not set
+CONFIG_BACKLIGHT_GPIO=y
+# CONFIG_BACKLIGHT_LV5207LP is not set
+# CONFIG_BACKLIGHT_BD6107 is not set
CONFIG_FB_MXC=y
CONFIG_FB_MXC_SYNC_PANEL=y
+# CONFIG_FB_MXC_TVOUT_ADV739X is not set
CONFIG_FB_MXC_LDB=y
# CONFIG_FB_MXC_MIPI_DSI is not set
CONFIG_FB_MXC_HDMI=y
CONFIG_FB_MXC_EDID=y
+# CONFIG_FB_MXC_EINK_PANEL is not set
+CONFIG_FB_MXC_DCIC=y
+# CONFIG_HANNSTAR_CABC is not set
#
# Console display driver support
@@ -3078,25 +3121,44 @@ CONFIG_SND_SOC_AC97_BUS=y
CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y
# CONFIG_SND_ATMEL_SOC is not set
# CONFIG_SND_DESIGNWARE_I2S is not set
-CONFIG_SND_SOC_FSL_SSI=m
-CONFIG_SND_SOC_FSL_SPDIF=m
+
+#
+# SoC Audio for Freescale CPUs
+#
+
+#
+# Common SoC Audio options for Freescale CPUs:
+#
CONFIG_SND_SOC_FSL_ASRC=y
+CONFIG_SND_SOC_FSL_SAI=y
+CONFIG_SND_SOC_FSL_SSI=y
+CONFIG_SND_SOC_FSL_SPDIF=y
+# CONFIG_SND_SOC_FSL_ESAI is not set
CONFIG_SND_SOC_FSL_HDMI=y
-CONFIG_SND_IMX_SOC=y
CONFIG_SND_SOC_IMX_PCM_DMA=y
+CONFIG_SND_SOC_IMX_AUDMUX=y
+CONFIG_SND_IMX_SOC=y
CONFIG_SND_SOC_IMX_HDMI_DMA=y
-CONFIG_SND_SOC_IMX_AUDMUX=m
+
+#
+# SoC Audio support for Freescale i.MX boards:
+#
# CONFIG_SND_SOC_IMX_CS42888 is not set
+# CONFIG_SND_SOC_IMX_WM8731 is not set
# CONFIG_SND_SOC_IMX_WM8962 is not set
-CONFIG_SND_SOC_IMX_SGTL5000=m
-CONFIG_SND_SOC_IMX_AC97_VT1613=m
-CONFIG_SND_SOC_IMX_SPDIF=m
-CONFIG_SND_SOC_IMX_HDMI=y
+CONFIG_SND_SOC_IMX_SGTL5000=y
+CONFIG_SND_SOC_IMX_AC97_VT1613=y
+# CONFIG_SND_SOC_IMX_MQS is not set
+CONFIG_SND_SOC_IMX_SPDIF=y
# CONFIG_SND_SOC_IMX_MC13783 is not set
+CONFIG_SND_SOC_IMX_HDMI=y
+# CONFIG_SND_SOC_IMX_SI476X is not set
+# CONFIG_SND_SOC_IMX_TDA1997X is not set
CONFIG_SND_SOC_I2C_AND_SPI=y
+# CONFIG_SND_SOC_CS42XX8_I2C is not set
CONFIG_SND_SOC_HDMI_CODEC=y
-CONFIG_SND_SOC_SGTL5000=m
-CONFIG_SND_SOC_VT1613=m
+CONFIG_SND_SOC_SGTL5000=y
+CONFIG_SND_SOC_VT1613=y
# CONFIG_SND_SIMPLE_CARD is not set
# CONFIG_SOUND_PRIME is not set
CONFIG_AC97_BUS=y
@@ -3209,6 +3271,7 @@ CONFIG_USB_DEFAULT_PERSIST=y
# CONFIG_USB_OTG is not set
# CONFIG_USB_OTG_WHITELIST is not set
# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_OTG_FSM is not set
CONFIG_USB_MON=m
# CONFIG_USB_WUSB_CBAF is not set
@@ -3222,7 +3285,6 @@ CONFIG_USB_EHCI_ROOT_HUB_TT=y
CONFIG_USB_EHCI_TT_NEWSCHED=y
CONFIG_USB_EHCI_PCI=y
# CONFIG_USB_EHCI_MXC is not set
-# CONFIG_USB_EHCI_HCD_SYNOPSYS is not set
# CONFIG_USB_EHCI_HCD_PLATFORM is not set
# CONFIG_USB_OXU210HP_HCD is not set
# CONFIG_USB_ISP116X_HCD is not set
@@ -3370,7 +3432,6 @@ CONFIG_USB_SERIAL_PL2303=m
# USB Physical Layer drivers
#
CONFIG_USB_PHY=y
-# CONFIG_USB_OTG_FSM is not set
# CONFIG_NOP_USB_XCEIV is not set
# CONFIG_AM335X_PHY_USB is not set
# CONFIG_SAMSUNG_USB2PHY is not set
@@ -3476,20 +3537,8 @@ CONFIG_MMC_SDHCI_ESDHC_IMX=y
# MXC support drivers
#
CONFIG_MXC_IPU=y
-
-#
-# MXC Vivante GPU support
-#
-CONFIG_MXC_GPU_VIV=y
-# CONFIG_MXC_GPU_VIV_V5 is not set
-CONFIG_MXC_GPU_VIV_V4=y
CONFIG_MXC_IPU_V3=y
-#
-# MXC Asynchronous Sample Rate Converter support
-#
-CONFIG_MXC_ASRC=y
-
#
# MXC VPU(Video Processing Unit) support
#
@@ -3700,7 +3749,9 @@ CONFIG_W35UND=m
# CONFIG_RTL8192U is not set
# CONFIG_RTLLIB is not set
CONFIG_R8712U=m
-# CONFIG_R8188EU is not set
+CONFIG_R8188EU=m
+CONFIG_88EU_AP_MODE=y
+# CONFIG_88EU_P2P is not set
# CONFIG_R8821AE is not set
CONFIG_RTS5139=m
# CONFIG_RTS5139_DEBUG is not set
@@ -4187,15 +4238,16 @@ CONFIG_CRYPTO=y
#
CONFIG_CRYPTO_ALGAPI=y
CONFIG_CRYPTO_ALGAPI2=y
-CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_AEAD=y
CONFIG_CRYPTO_AEAD2=y
CONFIG_CRYPTO_BLKCIPHER=y
CONFIG_CRYPTO_BLKCIPHER2=y
CONFIG_CRYPTO_HASH=y
CONFIG_CRYPTO_HASH2=y
-CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG=y
CONFIG_CRYPTO_RNG2=y
CONFIG_CRYPTO_PCOMP2=y
+# CONFIG_CRYPTO_CRYPTODEV is not set
CONFIG_CRYPTO_MANAGER=y
CONFIG_CRYPTO_MANAGER2=y
# CONFIG_CRYPTO_USER is not set
@@ -4205,7 +4257,7 @@ CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
# CONFIG_CRYPTO_PCRYPT is not set
CONFIG_CRYPTO_WORKQUEUE=y
# CONFIG_CRYPTO_CRYPTD is not set
-# CONFIG_CRYPTO_AUTHENC is not set
+CONFIG_CRYPTO_AUTHENC=y
# CONFIG_CRYPTO_TEST is not set
#
@@ -4291,7 +4343,22 @@ CONFIG_CRYPTO_LZO=m
# CONFIG_CRYPTO_ANSI_CPRNG is not set
# CONFIG_CRYPTO_USER_API_HASH is not set
# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
-# CONFIG_CRYPTO_HW is not set
+CONFIG_CRYPTO_HW=y
+# CONFIG_CRYPTO_DEV_HIFN_795X is not set
+CONFIG_CRYPTO_DEV_FSL_CAAM=y
+CONFIG_CRYPTO_DEV_FSL_CAAM_JR=y
+CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE=9
+# CONFIG_CRYPTO_DEV_FSL_CAAM_INTC is not set
+CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API=y
+CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API=y
+CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API=y
+# CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_TEST is not set
+CONFIG_CRYPTO_DEV_FSL_CAAM_SM=y
+CONFIG_CRYPTO_DEV_FSL_CAAM_SM_SLOTSIZE=7
+# CONFIG_CRYPTO_DEV_FSL_CAAM_SM_TEST is not set
+CONFIG_CRYPTO_DEV_FSL_CAAM_SECVIO=y
+# CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG is not set
+# CONFIG_CRYPTO_DEV_SAHARA is not set
# CONFIG_ASYMMETRIC_KEY_TYPE is not set
# CONFIG_BINARY_PRINTF is not set
diff --git a/projects/imx6/options b/projects/imx6/options
index 1161fc5e83..238abae5e8 100644
--- a/projects/imx6/options
+++ b/projects/imx6/options
@@ -54,15 +54,22 @@
# Kernel extra targets to build
KERNEL_UBOOT_EXTRA_TARGET="imx6q-cubox-i.dtb imx6dl-cubox-i.dtb"
KERNEL_UBOOT_EXTRA_TARGET="$KERNEL_UBOOT_EXTRA_TARGET imx6q-hummingboard.dtb imx6dl-hummingboard.dtb"
+ KERNEL_UBOOT_EXTRA_TARGET="$KERNEL_UBOOT_EXTRA_TARGET imx6q-hummingboard2.dtb imx6dl-hummingboard2.dtb"
KERNEL_UBOOT_EXTRA_TARGET="$KERNEL_UBOOT_EXTRA_TARGET imx6q-tbs2910.dtb"
KERNEL_UBOOT_EXTRA_TARGET="$KERNEL_UBOOT_EXTRA_TARGET imx6q-udoo.dtb imx6dl-udoo.dtb"
+ KERNEL_UBOOT_EXTRA_TARGET="$KERNEL_UBOOT_EXTRA_TARGET imx6q-udoo-15lvds.dtb imx6q-udoo-7lvds.dtb"
+ KERNEL_UBOOT_EXTRA_TARGET="$KERNEL_UBOOT_EXTRA_TARGET imx6dl-udoo-15lvds.dtb imx6dl-udoo-7lvds.dtb"
# Additional kernel make parameters (for example to specify the u-boot loadaddress)
KERNEL_MAKE_EXTRACMD=""
# Kernel to use. values can be:
# default: default mainline kernel
- LINUX="imx6"
+ if [ -z "$LINUX_VERSION" ]; then
+ LINUX="imx6"
+ else
+ LINUX="imx6-4.4-xbian"
+ fi
################################################################################
@@ -95,8 +102,12 @@
# OpenGL(X) implementation to use (no / mesa)
OPENGL="no"
- # OpenGL-ES implementation to use (no / bcm2835-driver / gpu-viv-bin-mx6q)
- OPENGLES="gpu-viv-bin-mx6q"
+ # OpenGL-ES implementation to use (no / bcm2835-driver / imx-gpu-viv)
+ if [ "$LINUX" = "imx6" ]; then
+ OPENGLES="imx-gpu-viv"
+ else
+ OPENGLES="gpu-viv-bin-mx6q"
+ fi
# include uvesafb support (yes / no)
UVESAFB_SUPPORT="no"
diff --git a/projects/imx6/patches/linux/999.01-LLVMLinux_use_static_inline_in_ARM_ftrace.h.patch b/projects/imx6/patches/linux/3.14-mx6-sr/999.01-LLVMLinux_use_static_inline_in_ARM_ftrace.h.patch
similarity index 100%
rename from projects/imx6/patches/linux/999.01-LLVMLinux_use_static_inline_in_ARM_ftrace.h.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/999.01-LLVMLinux_use_static_inline_in_ARM_ftrace.h.patch
diff --git a/projects/imx6/patches/linux/999.02-ARM-LLVMLinux-Change-extern-inline-to-static-inline.patch b/projects/imx6/patches/linux/3.14-mx6-sr/999.02-ARM-LLVMLinux-Change-extern-inline-to-static-inline.patch
similarity index 100%
rename from projects/imx6/patches/linux/999.02-ARM-LLVMLinux-Change-extern-inline-to-static-inline.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/999.02-ARM-LLVMLinux-Change-extern-inline-to-static-inline.patch
diff --git a/projects/imx6/patches/linux/linux-002-rename-sgtl5000-codec.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-002-rename-sgtl5000-codec.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-002-rename-sgtl5000-codec.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-002-rename-sgtl5000-codec.patch
diff --git a/projects/imx6/patches/linux/linux-003-no_dev_console.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-003-no_dev_console.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-003-no_dev_console.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-003-no_dev_console.patch
diff --git a/projects/imx6/patches/linux/linux-004-fix-build-with-gcc-5.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-004-fix-build-with-gcc-5.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-004-fix-build-with-gcc-5.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-004-fix-build-with-gcc-5.patch
diff --git a/projects/imx6/patches/linux/linux-007-config_cmdline.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-007-config_cmdline.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-007-config_cmdline.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-007-config_cmdline.patch
diff --git a/projects/imx6/patches/linux/linux-010_tivo_slide_pro.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-010_tivo_slide_pro.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-010_tivo_slide_pro.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-010_tivo_slide_pro.patch
diff --git a/projects/imx6/patches/linux/linux-051-ouya_controller_support.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-051-ouya_controller_support.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-051-ouya_controller_support.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-051-ouya_controller_support.patch
diff --git a/projects/imx6/patches/linux/linux-052-XBOX_remote_support.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-052-XBOX_remote_support.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-052-XBOX_remote_support.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-052-XBOX_remote_support.patch
diff --git a/projects/imx6/patches/linux/linux-053-spinelplus-remote-0.2.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-053-spinelplus-remote-0.2.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-053-spinelplus-remote-0.2.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-053-spinelplus-remote-0.2.patch
diff --git a/projects/imx6/patches/linux/linux-055-add_Formosa_eHome_Infrared_Receiver.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-055-add_Formosa_eHome_Infrared_Receiver.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-055-add_Formosa_eHome_Infrared_Receiver.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-055-add_Formosa_eHome_Infrared_Receiver.patch
diff --git a/projects/imx6/patches/linux/linux-056-add_Adaptec_eHome_Infrared_Receiver.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-056-add_Adaptec_eHome_Infrared_Receiver.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-056-add_Adaptec_eHome_Infrared_Receiver.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-056-add_Adaptec_eHome_Infrared_Receiver.patch
diff --git a/projects/imx6/patches/linux/linux-057-Removed-MCE-customer-code-restriction-in-rc6-decode.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-057-Removed-MCE-customer-code-restriction-in-rc6-decode.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-057-Removed-MCE-customer-code-restriction-in-rc6-decode.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-057-Removed-MCE-customer-code-restriction-in-rc6-decode.patch
diff --git a/projects/imx6/patches/linux/linux-057-add_SMK_Manufacturing_Inc_Infrared_Receiver.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-057-add_SMK_Manufacturing_Inc_Infrared_Receiver.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-057-add_SMK_Manufacturing_Inc_Infrared_Receiver.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-057-add_SMK_Manufacturing_Inc_Infrared_Receiver.patch
diff --git a/projects/imx6/patches/linux/linux-058.05-hid_sony-add_autorepeat_for_PS3_remotes.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-058.05-hid_sony-add_autorepeat_for_PS3_remotes.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-058.05-hid_sony-add_autorepeat_for_PS3_remotes.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-058.05-hid_sony-add_autorepeat_for_PS3_remotes.patch
diff --git a/projects/imx6/patches/linux/linux-058.06-hid_sony-add_SMK_link.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-058.06-hid_sony-add_SMK_link.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-058.06-hid_sony-add_SMK_link.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-058.06-hid_sony-add_SMK_link.patch
diff --git a/projects/imx6/patches/linux/linux-059-remove_some_xpad_pids-0.2.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-059-remove_some_xpad_pids-0.2.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-059-remove_some_xpad_pids-0.2.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-059-remove_some_xpad_pids-0.2.patch
diff --git a/projects/imx6/patches/linux/linux-060-add_AUGUST_DVB-T205.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-060-add_AUGUST_DVB-T205.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-060-add_AUGUST_DVB-T205.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-060-add_AUGUST_DVB-T205.patch
diff --git a/projects/imx6/patches/linux/linux-061-valve-xpad-rework.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-061-valve-xpad-rework.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-061-valve-xpad-rework.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-061-valve-xpad-rework.patch
diff --git a/projects/imx6/patches/linux/linux-062-imon_pad_ignore_diagonal.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-062-imon_pad_ignore_diagonal.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-062-imon_pad_ignore_diagonal.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-062-imon_pad_ignore_diagonal.patch
diff --git a/projects/imx6/patches/linux/linux-203-stb0899_enable_low_symbol_rate.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-203-stb0899_enable_low_symbol_rate.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-203-stb0899_enable_low_symbol_rate.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-203-stb0899_enable_low_symbol_rate.patch
diff --git a/projects/imx6/patches/linux/linux-210-dvbsky.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-210-dvbsky.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-210-dvbsky.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-210-dvbsky.patch
diff --git a/projects/imx6/patches/linux/linux-212-mantis_stb0899_faster_lock.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-212-mantis_stb0899_faster_lock.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-212-mantis_stb0899_faster_lock.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-212-mantis_stb0899_faster_lock.patch
diff --git a/projects/imx6/patches/linux/linux-222-stb0899_signal_quality.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-222-stb0899_signal_quality.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-222-stb0899_signal_quality.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-222-stb0899_signal_quality.patch
diff --git a/projects/imx6/patches/linux/linux-223-Fix-video-artifacts-with-tt-3600-s2-usb.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-223-Fix-video-artifacts-with-tt-3600-s2-usb.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-223-Fix-video-artifacts-with-tt-3600-s2-usb.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-223-Fix-video-artifacts-with-tt-3600-s2-usb.patch
diff --git a/projects/imx6/patches/linux/linux-224-geniatech-t220-dvb-t2-fix.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-224-geniatech-t220-dvb-t2-fix.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-224-geniatech-t220-dvb-t2-fix.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-224-geniatech-t220-dvb-t2-fix.patch
diff --git a/projects/imx6/patches/linux/linux-225-ct2-devices.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-225-ct2-devices.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-225-ct2-devices.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-225-ct2-devices.patch
diff --git a/projects/imx6/patches/linux/linux-226-pctv292e-devices.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-226-pctv292e-devices.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-226-pctv292e-devices.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-226-pctv292e-devices.patch
diff --git a/projects/imx6/patches/linux/linux-250-fix-dvbsky.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-250-fix-dvbsky.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-250-fix-dvbsky.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-250-fix-dvbsky.patch
diff --git a/projects/imx6/patches/linux/3.14-mx6-sr/linux-310-udoo-lvds-support.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-310-udoo-lvds-support.patch
new file mode 100644
index 0000000000..76105e569f
--- /dev/null
+++ b/projects/imx6/patches/linux/3.14-mx6-sr/linux-310-udoo-lvds-support.patch
@@ -0,0 +1,295 @@
+From 21ecd35bd9e5030a6b33a41dea3a2653609b09d7 Mon Sep 17 00:00:00 2001
+From: Peter Vicman
+Date: Thu, 24 Mar 2016 15:53:56 +0100
+Subject: [PATCH] dts: udoo: add both lvds displays
+
+---
+ arch/arm/boot/dts/Makefile | 4 +++
+ arch/arm/boot/dts/imx6dl-udoo-15lvds.dts | 54 +++++++++++++++++++++++++++++
+ arch/arm/boot/dts/imx6dl-udoo-7lvds.dts | 49 +++++++++++++++++++++++++++
+ arch/arm/boot/dts/imx6q-udoo-15lvds.dts | 58 ++++++++++++++++++++++++++++++++
+ arch/arm/boot/dts/imx6q-udoo-7lvds.dts | 53 +++++++++++++++++++++++++++++
+ arch/arm/boot/dts/imx6qdl-udoo.dtsi | 5 +--
+ 6 files changed, 221 insertions(+), 2 deletions(-)
+ create mode 100644 arch/arm/boot/dts/imx6dl-udoo-15lvds.dts
+ create mode 100644 arch/arm/boot/dts/imx6dl-udoo-7lvds.dts
+ create mode 100644 arch/arm/boot/dts/imx6q-udoo-15lvds.dts
+ create mode 100644 arch/arm/boot/dts/imx6q-udoo-7lvds.dts
+
+diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
+index 08ff98a..ffffb8c 100644
+--- a/arch/arm/boot/dts/Makefile
++++ b/arch/arm/boot/dts/Makefile
+@@ -167,6 +167,8 @@ dtb-$(CONFIG_ARCH_MXC) += \
+ imx6dl-sabresd-pf200.dtb \
+ imx6dl-sabresd-hdcp.dtb \
+ imx6dl-udoo.dtb \
++ imx6dl-udoo-7lvds.dtb \
++ imx6dl-udoo-15lvds.dtb \
+ imx6dl-sbc-fx6.dtb \
+ imx6dl-sbc-fx6m.dtb \
+ imx6dl-wandboard.dtb \
+@@ -192,6 +194,8 @@ dtb-$(CONFIG_ARCH_MXC) += \
+ imx6q-sbc-fx6m.dtb \
+ imx6q-sbc6x.dtb \
+ imx6q-udoo.dtb \
++ imx6q-udoo-7lvds.dtb \
++ imx6q-udoo-15lvds.dtb \
+ imx6q-wandboard.dtb \
+ imx6q-tbs2910.dtb \
+ imx6sl-evk.dtb \
+diff --git a/arch/arm/boot/dts/imx6dl-udoo-15lvds.dts b/arch/arm/boot/dts/imx6dl-udoo-15lvds.dts
+new file mode 100644
+index 0000000..ac189cc
+--- /dev/null
++++ b/arch/arm/boot/dts/imx6dl-udoo-15lvds.dts
+@@ -0,0 +1,54 @@
++/*
++ * Copyright 2013 Freescale Semiconductor, Inc.
++ *
++ * Author: Fabio Estevam
++ * Author: Ettore Chimenti
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ */
++
++/dts-v1/;
++#include "imx6dl.dtsi"
++#include "imx6qdl-udoo.dtsi"
++
++/ {
++ model = "Udoo i.MX6 Dual-lite Board";
++ compatible = "udoo,imx6dl-udoo", "fsl,imx6dl";
++
++ mxcfb2: fb@1 {
++ compatible = "fsl,mxc_sdc_fb";
++ disp_dev = "ldb";
++ interface_pix_fmt = "RGB24";
++ mode_str = "1360x768M@60";
++ default_bpp = <32>;
++ int_clk = <0>;
++ late_init = <1>;
++ status = "okay";
++ };
++
++ regulators {
++ reg_lcd0_pwr: regulator@1 {
++ status = "okay";
++ };
++
++ reg_lcd0_backlight: regulator@2 {
++ status = "okay";
++ };
++ };
++};
++
++&ldb {
++ status = "okay";
++
++ lvds-channel@0 {
++ status = "okay";
++ fsl,data-width = <24>;
++
++ display-timings {
++ native-mode = <&timing2>;
++ };
++ };
++};
+diff --git a/arch/arm/boot/dts/imx6dl-udoo-7lvds.dts b/arch/arm/boot/dts/imx6dl-udoo-7lvds.dts
+new file mode 100644
+index 0000000..da6ba4d
+--- /dev/null
++++ b/arch/arm/boot/dts/imx6dl-udoo-7lvds.dts
+@@ -0,0 +1,49 @@
++/*
++ * Copyright 2013 Freescale Semiconductor, Inc.
++ *
++ * Author: Fabio Estevam
++ * Author: Ettore Chimenti
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ */
++
++/dts-v1/;
++#include "imx6dl.dtsi"
++#include "imx6qdl-udoo.dtsi"
++
++/ {
++ model = "Udoo i.MX6 Dual-lite Board";
++ compatible = "udoo,imx6dl-udoo", "fsl,imx6dl";
++
++ mxcfb2: fb@1 {
++ compatible = "fsl,mxc_sdc_fb";
++ disp_dev = "ldb";
++ interface_pix_fmt = "RGB666";
++ mode_str = "800x480M@60";
++ default_bpp = <32>;
++ int_clk = <0>;
++ late_init = <0>;
++ status = "okay";
++ };
++
++ regulators {
++ reg_lcd0_pwr: regulator@1 {
++ status = "okay";
++ };
++
++ reg_lcd0_backlight: regulator@2 {
++ status = "okay";
++ };
++ };
++};
++
++&ldb {
++ status = "okay";
++
++ lvds-channel@0 {
++ status = "okay";
++ };
++};
+diff --git a/arch/arm/boot/dts/imx6q-udoo-15lvds.dts b/arch/arm/boot/dts/imx6q-udoo-15lvds.dts
+new file mode 100644
+index 0000000..35e7651
+--- /dev/null
++++ b/arch/arm/boot/dts/imx6q-udoo-15lvds.dts
+@@ -0,0 +1,58 @@
++/*
++ * Copyright 2013 Freescale Semiconductor, Inc.
++ *
++ * Author: Fabio Estevam
++ * Author: Ettore Chimenti
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ */
++
++/dts-v1/;
++#include "imx6q.dtsi"
++#include "imx6qdl-udoo.dtsi"
++
++/ {
++ model = "Udoo i.MX6 Quad Board";
++ compatible = "udoo,imx6q-udoo", "fsl,imx6q";
++
++ mxcfb2: fb@1 {
++ compatible = "fsl,mxc_sdc_fb";
++ disp_dev = "ldb";
++ interface_pix_fmt = "RGB24";
++ mode_str = "1360x768M@60";
++ default_bpp = <32>;
++ int_clk = <0>;
++ late_init = <1>;
++ status = "okay";
++ };
++
++ regulators {
++ reg_lcd0_pwr: regulator@1 {
++ status = "okay";
++ };
++
++ reg_lcd0_backlight: regulator@2 {
++ status = "okay";
++ };
++ };
++};
++
++&sata {
++ status = "okay";
++};
++
++&ldb {
++ status = "okay";
++
++ lvds-channel@0 {
++ status = "okay";
++ fsl,data-width = <24>;
++
++ display-timings {
++ native-mode = <&timing2>;
++ };
++ };
++};
+diff --git a/arch/arm/boot/dts/imx6q-udoo-7lvds.dts b/arch/arm/boot/dts/imx6q-udoo-7lvds.dts
+new file mode 100644
+index 0000000..e5f3125
+--- /dev/null
++++ b/arch/arm/boot/dts/imx6q-udoo-7lvds.dts
+@@ -0,0 +1,53 @@
++/*
++ * Copyright 2013 Freescale Semiconductor, Inc.
++ *
++ * Author: Fabio Estevam
++ * Author: Ettore Chimenti
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ */
++
++/dts-v1/;
++#include "imx6q.dtsi"
++#include "imx6qdl-udoo.dtsi"
++
++/ {
++ model = "Udoo i.MX6 Quad Board";
++ compatible = "udoo,imx6q-udoo", "fsl,imx6q";
++
++ mxcfb2: fb@1 {
++ compatible = "fsl,mxc_sdc_fb";
++ disp_dev = "ldb";
++ interface_pix_fmt = "RGB666";
++ mode_str = "800x480M@60";
++ default_bpp = <32>;
++ int_clk = <0>;
++ late_init = <0>;
++ status = "okay";
++ };
++
++ regulators {
++ reg_lcd0_pwr: regulator@1 {
++ status = "okay";
++ };
++
++ reg_lcd0_backlight: regulator@2 {
++ status = "okay";
++ };
++ };
++};
++
++&sata {
++ status = "okay";
++};
++
++&ldb {
++ status = "okay";
++
++ lvds-channel@0 {
++ status = "okay";
++ };
++};
+diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+index 2f6ec9a..7dca6db 100755
+--- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi
++++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+@@ -254,9 +254,10 @@
+ vsync-len = <2>;
+ };
+
+- timing2: 1366x768 { // 15.6" display
++ // IPU needs X and Y by modulo 8
++ timing2: 1360x768 { // 15.6" display
+ clock-frequency = <76000000>;
+- hactive = <1366>;
++ hactive = <1360>;
+ vactive = <768>;
+ hback-porch = <220>;
+ hfront-porch = <40>;
diff --git a/projects/imx6/patches/linux/linux-320-cuboxi_led_heartbeat.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-320-cuboxi_led_heartbeat.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-320-cuboxi_led_heartbeat.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-320-cuboxi_led_heartbeat.patch
diff --git a/projects/imx6/patches/linux/linux-704-Support-for-Ubiquiti-WifiStation.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-704-Support-for-Ubiquiti-WifiStation.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-704-Support-for-Ubiquiti-WifiStation.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-704-Support-for-Ubiquiti-WifiStation.patch
diff --git a/projects/imx6/patches/linux/linux-705-Support-for-Buffalo-WLI-UC-G300HP-V1.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-705-Support-for-Buffalo-WLI-UC-G300HP-V1.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-705-Support-for-Buffalo-WLI-UC-G300HP-V1.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-705-Support-for-Buffalo-WLI-UC-G300HP-V1.patch
diff --git a/projects/imx6/patches/linux/linux-706-Sitecom-N300.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-706-Sitecom-N300.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-706-Sitecom-N300.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-706-Sitecom-N300.patch
diff --git a/projects/imx6/patches/linux/linux-910.01-cec-upstream.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-910.01-cec-upstream.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-910.01-cec-upstream.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-910.01-cec-upstream.patch
diff --git a/projects/imx6/patches/linux/linux-910.02-cec-upstream.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-910.02-cec-upstream.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-910.02-cec-upstream.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-910.02-cec-upstream.patch
diff --git a/projects/imx6/patches/linux/linux-991.01-ptrace_fix.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-991.01-ptrace_fix.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-991.01-ptrace_fix.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-991.01-ptrace_fix.patch
diff --git a/projects/imx6/patches/linux/linux-995-CX24120-13Z_frontend.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-995-CX24120-13Z_frontend.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-995-CX24120-13Z_frontend.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-995-CX24120-13Z_frontend.patch
diff --git a/projects/imx6/patches/linux/linux-999-9-fritz-stick-1.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-999-9-fritz-stick-1.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-999-9-fritz-stick-1.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-999-9-fritz-stick-1.patch
diff --git a/projects/imx6/patches/linux/linux-999-9-fritz-stick-2.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-999-9-fritz-stick-2.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-999-9-fritz-stick-2.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-999-9-fritz-stick-2.patch
diff --git a/projects/imx6/patches/linux/linux-999.02-0001-pm-disable-async-suspend-resume-by-default.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-999.02-0001-pm-disable-async-suspend-resume-by-default.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-999.02-0001-pm-disable-async-suspend-resume-by-default.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-999.02-0001-pm-disable-async-suspend-resume-by-default.patch
diff --git a/projects/imx6/patches/linux/linux-999.03-0001-fix-mceusb.patch b/projects/imx6/patches/linux/3.14-mx6-sr/linux-999.03-0001-fix-mceusb.patch
similarity index 100%
rename from projects/imx6/patches/linux/linux-999.03-0001-fix-mceusb.patch
rename to projects/imx6/patches/linux/3.14-mx6-sr/linux-999.03-0001-fix-mceusb.patch
diff --git a/projects/imx6/patches/linux/999.03-rtl8712-avoid-lots-of-build-warnings.patch b/projects/imx6/patches/linux/999.03-rtl8712-avoid-lots-of-build-warnings.patch
deleted file mode 100644
index db4bd5fb74..0000000000
--- a/projects/imx6/patches/linux/999.03-rtl8712-avoid-lots-of-build-warnings.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
-index bc64f05..b1a0380 100644
---- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
-+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
-@@ -2250,7 +2250,7 @@ static inline void *ieee80211_priv(struct net_device *dev)
- return ((struct ieee80211_device *)netdev_priv(dev))->priv;
- }
-
--extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
-+static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
- {
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
-@@ -2266,7 +2266,7 @@ extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
- return 1;
- }
-
--extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
-+static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
- {
- /*
- * It is possible for both access points and our device to support
-@@ -2292,7 +2292,7 @@ extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mod
- return 0;
- }
-
--extern inline int ieee80211_get_hdrlen(u16 fc)
-+static inline int ieee80211_get_hdrlen(u16 fc)
- {
- int hdrlen = IEEE80211_3ADDR_LEN;
-
-@@ -2578,12 +2578,12 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
-
- extern const long ieee80211_wlan_frequencies[];
-
--extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
-+static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
- {
- ieee->scans++;
- }
-
--extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
-+static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
- {
- return ieee->scans;
- }
-diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h
-index da4000e..8269be8 100644
---- a/drivers/staging/rtl8712/ieee80211.h
-+++ b/drivers/staging/rtl8712/ieee80211.h
-@@ -734,7 +734,7 @@ enum ieee80211_state {
- #define IEEE_G (1<<2)
- #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
-
--extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
-+static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
- {
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
-@@ -748,7 +748,7 @@ extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
- return 1;
- }
-
--extern inline int ieee80211_get_hdrlen(u16 fc)
-+static inline int ieee80211_get_hdrlen(u16 fc)
- {
- int hdrlen = 24;
-
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.14-15.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.14-15.patch
deleted file mode 100644
index f1730277b6..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.14-15.patch
+++ /dev/null
@@ -1,893 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 230c7f694ab7..188523e9e880 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 14
-+SUBLEVEL = 15
- EXTRAVERSION =
- NAME = Remembering Coco
-
-@@ -639,6 +639,8 @@ KBUILD_CFLAGS += -fomit-frame-pointer
- endif
- endif
-
-+KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments)
-+
- ifdef CONFIG_DEBUG_INFO
- KBUILD_CFLAGS += -g
- KBUILD_AFLAGS += -Wa,--gdwarf-2
-diff --git a/arch/parisc/include/uapi/asm/signal.h b/arch/parisc/include/uapi/asm/signal.h
-index a2fa297196bc..f5645d6a89f2 100644
---- a/arch/parisc/include/uapi/asm/signal.h
-+++ b/arch/parisc/include/uapi/asm/signal.h
-@@ -69,8 +69,6 @@
- #define SA_NOMASK SA_NODEFER
- #define SA_ONESHOT SA_RESETHAND
-
--#define SA_RESTORER 0x04000000 /* obsolete -- ignored */
--
- #define MINSIGSTKSZ 2048
- #define SIGSTKSZ 8192
-
-diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
-index a48bc79a111f..184d305af3e7 100644
---- a/arch/s390/kernel/ptrace.c
-+++ b/arch/s390/kernel/ptrace.c
-@@ -323,9 +323,14 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
- unsigned long mask = PSW_MASK_USER;
-
- mask |= is_ri_task(child) ? PSW_MASK_RI : 0;
-- if ((data & ~mask) != PSW_USER_BITS)
-+ if ((data ^ PSW_USER_BITS) & ~mask)
-+ /* Invalid psw mask. */
-+ return -EINVAL;
-+ if ((data & PSW_MASK_ASC) == PSW_ASC_HOME)
-+ /* Invalid address-space-control bits */
- return -EINVAL;
- if ((data & PSW_MASK_EA) && !(data & PSW_MASK_BA))
-+ /* Invalid addressing mode bits */
- return -EINVAL;
- }
- *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data;
-@@ -661,9 +666,12 @@ static int __poke_user_compat(struct task_struct *child,
-
- mask |= is_ri_task(child) ? PSW32_MASK_RI : 0;
- /* Build a 64 bit psw mask from 31 bit mask. */
-- if ((tmp & ~mask) != PSW32_USER_BITS)
-+ if ((tmp ^ PSW32_USER_BITS) & ~mask)
- /* Invalid psw mask. */
- return -EINVAL;
-+ if ((data & PSW32_MASK_ASC) == PSW32_ASC_HOME)
-+ /* Invalid address-space-control bits */
-+ return -EINVAL;
- regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
- (regs->psw.mask & PSW_MASK_BA) |
- (__u64)(tmp & mask) << 32;
-diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
-index ec3b8ba68096..04da6c2194ba 100644
---- a/arch/x86/boot/header.S
-+++ b/arch/x86/boot/header.S
-@@ -91,10 +91,9 @@ bs_die:
-
- .section ".bsdata", "a"
- bugger_off_msg:
-- .ascii "Direct floppy boot is not supported. "
-- .ascii "Use a boot loader program instead.\r\n"
-+ .ascii "Use a boot loader.\r\n"
- .ascii "\n"
-- .ascii "Remove disk and press any key to reboot ...\r\n"
-+ .ascii "Remove disk and press any key to reboot...\r\n"
- .byte 0
-
- #ifdef CONFIG_EFI_STUB
-@@ -108,7 +107,7 @@ coff_header:
- #else
- .word 0x8664 # x86-64
- #endif
-- .word 3 # nr_sections
-+ .word 4 # nr_sections
- .long 0 # TimeDateStamp
- .long 0 # PointerToSymbolTable
- .long 1 # NumberOfSymbols
-@@ -250,6 +249,25 @@ section_table:
- .word 0 # NumberOfLineNumbers
- .long 0x60500020 # Characteristics (section flags)
-
-+ #
-+ # The offset & size fields are filled in by build.c.
-+ #
-+ .ascii ".bss"
-+ .byte 0
-+ .byte 0
-+ .byte 0
-+ .byte 0
-+ .long 0
-+ .long 0x0
-+ .long 0 # Size of initialized data
-+ # on disk
-+ .long 0x0
-+ .long 0 # PointerToRelocations
-+ .long 0 # PointerToLineNumbers
-+ .word 0 # NumberOfRelocations
-+ .word 0 # NumberOfLineNumbers
-+ .long 0xc8000080 # Characteristics (section flags)
-+
- #endif /* CONFIG_EFI_STUB */
-
- # Kernel attributes; used by setup. This is part 1 of the
-diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
-index 8e15b22391fc..3dafaeb9f549 100644
---- a/arch/x86/boot/tools/build.c
-+++ b/arch/x86/boot/tools/build.c
-@@ -142,7 +142,7 @@ static void usage(void)
-
- #ifdef CONFIG_EFI_STUB
-
--static void update_pecoff_section_header(char *section_name, u32 offset, u32 size)
-+static void update_pecoff_section_header_fields(char *section_name, u32 vma, u32 size, u32 datasz, u32 offset)
- {
- unsigned int pe_header;
- unsigned short num_sections;
-@@ -163,10 +163,10 @@ static void update_pecoff_section_header(char *section_name, u32 offset, u32 siz
- put_unaligned_le32(size, section + 0x8);
-
- /* section header vma field */
-- put_unaligned_le32(offset, section + 0xc);
-+ put_unaligned_le32(vma, section + 0xc);
-
- /* section header 'size of initialised data' field */
-- put_unaligned_le32(size, section + 0x10);
-+ put_unaligned_le32(datasz, section + 0x10);
-
- /* section header 'file offset' field */
- put_unaligned_le32(offset, section + 0x14);
-@@ -178,6 +178,11 @@ static void update_pecoff_section_header(char *section_name, u32 offset, u32 siz
- }
- }
-
-+static void update_pecoff_section_header(char *section_name, u32 offset, u32 size)
-+{
-+ update_pecoff_section_header_fields(section_name, offset, size, size, offset);
-+}
-+
- static void update_pecoff_setup_and_reloc(unsigned int size)
- {
- u32 setup_offset = 0x200;
-@@ -202,9 +207,6 @@ static void update_pecoff_text(unsigned int text_start, unsigned int file_sz)
-
- pe_header = get_unaligned_le32(&buf[0x3c]);
-
-- /* Size of image */
-- put_unaligned_le32(file_sz, &buf[pe_header + 0x50]);
--
- /*
- * Size of code: Subtract the size of the first sector (512 bytes)
- * which includes the header.
-@@ -219,6 +221,22 @@ static void update_pecoff_text(unsigned int text_start, unsigned int file_sz)
- update_pecoff_section_header(".text", text_start, text_sz);
- }
-
-+static void update_pecoff_bss(unsigned int file_sz, unsigned int init_sz)
-+{
-+ unsigned int pe_header;
-+ unsigned int bss_sz = init_sz - file_sz;
-+
-+ pe_header = get_unaligned_le32(&buf[0x3c]);
-+
-+ /* Size of uninitialized data */
-+ put_unaligned_le32(bss_sz, &buf[pe_header + 0x24]);
-+
-+ /* Size of image */
-+ put_unaligned_le32(init_sz, &buf[pe_header + 0x50]);
-+
-+ update_pecoff_section_header_fields(".bss", file_sz, bss_sz, 0, 0);
-+}
-+
- #endif /* CONFIG_EFI_STUB */
-
-
-@@ -270,6 +288,9 @@ int main(int argc, char ** argv)
- int fd;
- void *kernel;
- u32 crc = 0xffffffffUL;
-+#ifdef CONFIG_EFI_STUB
-+ unsigned int init_sz;
-+#endif
-
- /* Defaults for old kernel */
- #ifdef CONFIG_X86_32
-@@ -343,7 +364,9 @@ int main(int argc, char ** argv)
- put_unaligned_le32(sys_size, &buf[0x1f4]);
-
- #ifdef CONFIG_EFI_STUB
-- update_pecoff_text(setup_sectors * 512, sz + i + ((sys_size * 16) - sz));
-+ update_pecoff_text(setup_sectors * 512, i + (sys_size * 16));
-+ init_sz = get_unaligned_le32(&buf[0x260]);
-+ update_pecoff_bss(i + (sys_size * 16), init_sz);
-
- #ifdef CONFIG_X86_64 /* Yes, this is really how we defined it :( */
- efi_stub_entry -= 0x200;
-diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
-index 6491353cc9aa..c87810b1b557 100644
---- a/arch/x86/kernel/entry_32.S
-+++ b/arch/x86/kernel/entry_32.S
-@@ -433,8 +433,8 @@ sysenter_do_call:
- cmpl $(NR_syscalls), %eax
- jae sysenter_badsys
- call *sys_call_table(,%eax,4)
-- movl %eax,PT_EAX(%esp)
- sysenter_after_call:
-+ movl %eax,PT_EAX(%esp)
- LOCKDEP_SYS_EXIT
- DISABLE_INTERRUPTS(CLBR_ANY)
- TRACE_IRQS_OFF
-@@ -514,6 +514,7 @@ ENTRY(system_call)
- jae syscall_badsys
- syscall_call:
- call *sys_call_table(,%eax,4)
-+syscall_after_call:
- movl %eax,PT_EAX(%esp) # store the return value
- syscall_exit:
- LOCKDEP_SYS_EXIT
-@@ -683,12 +684,12 @@ syscall_fault:
- END(syscall_fault)
-
- syscall_badsys:
-- movl $-ENOSYS,PT_EAX(%esp)
-- jmp syscall_exit
-+ movl $-ENOSYS,%eax
-+ jmp syscall_after_call
- END(syscall_badsys)
-
- sysenter_badsys:
-- movl $-ENOSYS,PT_EAX(%esp)
-+ movl $-ENOSYS,%eax
- jmp sysenter_after_call
- END(syscall_badsys)
- CFI_ENDPROC
-diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
-index dd0dd2d4ceca..d8f80e733cf8 100644
---- a/block/blk-cgroup.c
-+++ b/block/blk-cgroup.c
-@@ -859,6 +859,13 @@ void blkcg_drain_queue(struct request_queue *q)
- {
- lockdep_assert_held(q->queue_lock);
-
-+ /*
-+ * @q could be exiting and already have destroyed all blkgs as
-+ * indicated by NULL root_blkg. If so, don't confuse policies.
-+ */
-+ if (!q->root_blkg)
-+ return;
-+
- blk_throtl_drain(q);
- }
-
-diff --git a/block/blk-tag.c b/block/blk-tag.c
-index 3f33d8672268..a185b86741e5 100644
---- a/block/blk-tag.c
-+++ b/block/blk-tag.c
-@@ -27,18 +27,15 @@ struct request *blk_queue_find_tag(struct request_queue *q, int tag)
- EXPORT_SYMBOL(blk_queue_find_tag);
-
- /**
-- * __blk_free_tags - release a given set of tag maintenance info
-+ * blk_free_tags - release a given set of tag maintenance info
- * @bqt: the tag map to free
- *
-- * Tries to free the specified @bqt. Returns true if it was
-- * actually freed and false if there are still references using it
-+ * Drop the reference count on @bqt and frees it when the last reference
-+ * is dropped.
- */
--static int __blk_free_tags(struct blk_queue_tag *bqt)
-+void blk_free_tags(struct blk_queue_tag *bqt)
- {
-- int retval;
--
-- retval = atomic_dec_and_test(&bqt->refcnt);
-- if (retval) {
-+ if (atomic_dec_and_test(&bqt->refcnt)) {
- BUG_ON(find_first_bit(bqt->tag_map, bqt->max_depth) <
- bqt->max_depth);
-
-@@ -50,9 +47,8 @@ static int __blk_free_tags(struct blk_queue_tag *bqt)
-
- kfree(bqt);
- }
--
-- return retval;
- }
-+EXPORT_SYMBOL(blk_free_tags);
-
- /**
- * __blk_queue_free_tags - release tag maintenance info
-@@ -69,28 +65,13 @@ void __blk_queue_free_tags(struct request_queue *q)
- if (!bqt)
- return;
-
-- __blk_free_tags(bqt);
-+ blk_free_tags(bqt);
-
- q->queue_tags = NULL;
- queue_flag_clear_unlocked(QUEUE_FLAG_QUEUED, q);
- }
-
- /**
-- * blk_free_tags - release a given set of tag maintenance info
-- * @bqt: the tag map to free
-- *
-- * For externally managed @bqt frees the map. Callers of this
-- * function must guarantee to have released all the queues that
-- * might have been using this tag map.
-- */
--void blk_free_tags(struct blk_queue_tag *bqt)
--{
-- if (unlikely(!__blk_free_tags(bqt)))
-- BUG();
--}
--EXPORT_SYMBOL(blk_free_tags);
--
--/**
- * blk_queue_free_tags - release tag maintenance info
- * @q: the request queue for the device
- *
-diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
-index fbd5a67cb773..a0926a6094b2 100644
---- a/block/compat_ioctl.c
-+++ b/block/compat_ioctl.c
-@@ -690,6 +690,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
- case BLKROSET:
- case BLKDISCARD:
- case BLKSECDISCARD:
-+ case BLKZEROOUT:
- /*
- * the ones below are implemented in blkdev_locked_ioctl,
- * but we call blkdev_ioctl, which gets the lock for us
-diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
-index 9aa42998d757..b54f8b3c7924 100644
---- a/drivers/ata/ahci.c
-+++ b/drivers/ata/ahci.c
-@@ -457,6 +457,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
-
- /* Promise */
- { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
-+ { PCI_VDEVICE(PROMISE, 0x3781), board_ahci }, /* FastTrak TX8660 ahci-mode */
-
- /* Asmedia */
- { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */
-diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
-index 62fda16c8377..f7616036663b 100644
---- a/drivers/ata/libata-core.c
-+++ b/drivers/ata/libata-core.c
-@@ -4787,6 +4787,10 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
- * ata_qc_new - Request an available ATA command, for queueing
- * @ap: target port
- *
-+ * Some ATA host controllers may implement a queue depth which is less
-+ * than ATA_MAX_QUEUE. So we shouldn't allocate a tag which is beyond
-+ * the hardware limitation.
-+ *
- * LOCKING:
- * None.
- */
-@@ -4794,14 +4798,15 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
- static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
- {
- struct ata_queued_cmd *qc = NULL;
-+ unsigned int max_queue = ap->host->n_tags;
- unsigned int i, tag;
-
- /* no command while frozen */
- if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
- return NULL;
-
-- for (i = 0; i < ATA_MAX_QUEUE; i++) {
-- tag = (i + ap->last_tag + 1) % ATA_MAX_QUEUE;
-+ for (i = 0, tag = ap->last_tag + 1; i < max_queue; i++, tag++) {
-+ tag = tag < max_queue ? tag : 0;
-
- /* the last tag is reserved for internal command. */
- if (tag == ATA_TAG_INTERNAL)
-@@ -6103,6 +6108,7 @@ void ata_host_init(struct ata_host *host, struct device *dev,
- {
- spin_lock_init(&host->lock);
- mutex_init(&host->eh_mutex);
-+ host->n_tags = ATA_MAX_QUEUE - 1;
- host->dev = dev;
- host->ops = ops;
- }
-@@ -6184,6 +6190,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
- {
- int i, rc;
-
-+ host->n_tags = clamp(sht->can_queue, 1, ATA_MAX_QUEUE - 1);
-+
- /* host must have been started */
- if (!(host->flags & ATA_HOST_STARTED)) {
- dev_err(host->dev, "BUG: trying to register unstarted host\n");
-diff --git a/drivers/base/platform.c b/drivers/base/platform.c
-index 3c51eb0bd659..9dbf4ef2b2a3 100644
---- a/drivers/base/platform.c
-+++ b/drivers/base/platform.c
-@@ -89,8 +89,13 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
- return dev->archdata.irqs[num];
- #else
- struct resource *r;
-- if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node)
-- return of_irq_get(dev->dev.of_node, num);
-+ if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
-+ int ret;
-+
-+ ret = of_irq_get(dev->dev.of_node, num);
-+ if (ret >= 0 || ret == -EPROBE_DEFER)
-+ return ret;
-+ }
-
- r = platform_get_resource(dev, IORESOURCE_IRQ, num);
-
-diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
-index 270f68a6b724..7164045c06e4 100644
---- a/drivers/gpu/drm/radeon/cik.c
-+++ b/drivers/gpu/drm/radeon/cik.c
-@@ -2219,6 +2219,7 @@ static void cik_tiling_mode_table_init(struct radeon_device *rdev)
- gb_tile_moden = 0;
- break;
- }
-+ rdev->config.cik.macrotile_mode_array[reg_offset] = gb_tile_moden;
- WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden);
- }
- } else if (num_pipe_configs == 8) {
-@@ -7270,6 +7271,7 @@ static inline u32 cik_get_ih_wptr(struct radeon_device *rdev)
- tmp = RREG32(IH_RB_CNTL);
- tmp |= IH_WPTR_OVERFLOW_CLEAR;
- WREG32(IH_RB_CNTL, tmp);
-+ wptr &= ~RB_OVERFLOW;
- }
- return (wptr & rdev->ih.ptr_mask);
- }
-diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
-index 64108dbc7d45..4b3c5f7ae63b 100644
---- a/drivers/gpu/drm/radeon/evergreen.c
-+++ b/drivers/gpu/drm/radeon/evergreen.c
-@@ -4763,6 +4763,7 @@ static u32 evergreen_get_ih_wptr(struct radeon_device *rdev)
- tmp = RREG32(IH_RB_CNTL);
- tmp |= IH_WPTR_OVERFLOW_CLEAR;
- WREG32(IH_RB_CNTL, tmp);
-+ wptr &= ~RB_OVERFLOW;
- }
- return (wptr & rdev->ih.ptr_mask);
- }
-diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
-index f28ab840cc23..788f602e8989 100644
---- a/drivers/gpu/drm/radeon/r600.c
-+++ b/drivers/gpu/drm/radeon/r600.c
-@@ -3795,6 +3795,7 @@ static u32 r600_get_ih_wptr(struct radeon_device *rdev)
- tmp = RREG32(IH_RB_CNTL);
- tmp |= IH_WPTR_OVERFLOW_CLEAR;
- WREG32(IH_RB_CNTL, tmp);
-+ wptr &= ~RB_OVERFLOW;
- }
- return (wptr & rdev->ih.ptr_mask);
- }
-diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
-index cb7508dc94f3..ea93393374df 100644
---- a/drivers/gpu/drm/radeon/si.c
-+++ b/drivers/gpu/drm/radeon/si.c
-@@ -6098,6 +6098,7 @@ static inline u32 si_get_ih_wptr(struct radeon_device *rdev)
- tmp = RREG32(IH_RB_CNTL);
- tmp |= IH_WPTR_OVERFLOW_CLEAR;
- WREG32(IH_RB_CNTL, tmp);
-+ wptr &= ~RB_OVERFLOW;
- }
- return (wptr & rdev->ih.ptr_mask);
- }
-diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c
-index efee4c59239f..34b9a601ad07 100644
---- a/drivers/hwmon/smsc47m192.c
-+++ b/drivers/hwmon/smsc47m192.c
-@@ -86,7 +86,7 @@ static inline u8 IN_TO_REG(unsigned long val, int n)
- */
- static inline s8 TEMP_TO_REG(int val)
- {
-- return clamp_val(SCALE(val, 1, 1000), -128000, 127000);
-+ return SCALE(clamp_val(val, -128000, 127000), 1, 1000);
- }
-
- static inline int TEMP_FROM_REG(s8 val)
-@@ -384,6 +384,8 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
- err = kstrtoul(buf, 10, &val);
- if (err)
- return err;
-+ if (val > 255)
-+ return -EINVAL;
-
- data->vrm = val;
- return count;
-diff --git a/drivers/input/input.c b/drivers/input/input.c
-index 1c4c0db05550..29ca0bb4f561 100644
---- a/drivers/input/input.c
-+++ b/drivers/input/input.c
-@@ -257,9 +257,10 @@ static int input_handle_abs_event(struct input_dev *dev,
- }
-
- static int input_get_disposition(struct input_dev *dev,
-- unsigned int type, unsigned int code, int value)
-+ unsigned int type, unsigned int code, int *pval)
- {
- int disposition = INPUT_IGNORE_EVENT;
-+ int value = *pval;
-
- switch (type) {
-
-@@ -357,6 +358,7 @@ static int input_get_disposition(struct input_dev *dev,
- break;
- }
-
-+ *pval = value;
- return disposition;
- }
-
-@@ -365,7 +367,7 @@ static void input_handle_event(struct input_dev *dev,
- {
- int disposition;
-
-- disposition = input_get_disposition(dev, type, code, value);
-+ disposition = input_get_disposition(dev, type, code, &value);
-
- if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event)
- dev->event(dev, type, code, value);
-diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
-index ec772d962f06..ef9e0b8a9aa7 100644
---- a/drivers/input/mouse/synaptics.c
-+++ b/drivers/input/mouse/synaptics.c
-@@ -132,7 +132,8 @@ static const struct min_max_quirk min_max_pnpid_table[] = {
- 1232, 5710, 1156, 4696
- },
- {
-- (const char * const []){"LEN0034", "LEN0036", "LEN2004", NULL},
-+ (const char * const []){"LEN0034", "LEN0036", "LEN2002",
-+ "LEN2004", NULL},
- 1024, 5112, 2024, 4832
- },
- {
-@@ -168,7 +169,7 @@ static const char * const topbuttonpad_pnp_ids[] = {
- "LEN0049",
- "LEN2000",
- "LEN2001", /* Edge E431 */
-- "LEN2002",
-+ "LEN2002", /* Edge E531 */
- "LEN2003",
- "LEN2004", /* L440 */
- "LEN2005",
-diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
-index 8ad3a57cf640..287b977862e2 100644
---- a/drivers/media/dvb-frontends/tda10071.c
-+++ b/drivers/media/dvb-frontends/tda10071.c
-@@ -667,6 +667,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe)
- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
- int ret, i;
- u8 mode, rolloff, pilot, inversion, div;
-+ fe_modulation_t modulation;
-
- dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d modulation=%d " \
- "frequency=%d symbol_rate=%d inversion=%d pilot=%d " \
-@@ -701,10 +702,13 @@ static int tda10071_set_frontend(struct dvb_frontend *fe)
-
- switch (c->delivery_system) {
- case SYS_DVBS:
-+ modulation = QPSK;
- rolloff = 0;
- pilot = 2;
- break;
- case SYS_DVBS2:
-+ modulation = c->modulation;
-+
- switch (c->rolloff) {
- case ROLLOFF_20:
- rolloff = 2;
-@@ -749,7 +753,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe)
-
- for (i = 0, mode = 0xff; i < ARRAY_SIZE(TDA10071_MODCOD); i++) {
- if (c->delivery_system == TDA10071_MODCOD[i].delivery_system &&
-- c->modulation == TDA10071_MODCOD[i].modulation &&
-+ modulation == TDA10071_MODCOD[i].modulation &&
- c->fec_inner == TDA10071_MODCOD[i].fec) {
- mode = TDA10071_MODCOD[i].val;
- dev_dbg(&priv->i2c->dev, "%s: mode found=%02x\n",
-diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
-index 0500c4175d5f..6bce01a674f9 100644
---- a/drivers/media/usb/hdpvr/hdpvr-video.c
-+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
-@@ -82,7 +82,7 @@ static void hdpvr_read_bulk_callback(struct urb *urb)
- }
-
- /*=========================================================================*/
--/* bufffer bits */
-+/* buffer bits */
-
- /* function expects dev->io_mutex to be hold by caller */
- int hdpvr_cancel_queue(struct hdpvr_device *dev)
-@@ -926,7 +926,7 @@ static int hdpvr_s_ctrl(struct v4l2_ctrl *ctrl)
- case V4L2_CID_MPEG_AUDIO_ENCODING:
- if (dev->flags & HDPVR_FLAG_AC3_CAP) {
- opt->audio_codec = ctrl->val;
-- return hdpvr_set_audio(dev, opt->audio_input,
-+ return hdpvr_set_audio(dev, opt->audio_input + 1,
- opt->audio_codec);
- }
- return 0;
-@@ -1198,7 +1198,7 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
- v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops,
- V4L2_CID_MPEG_AUDIO_ENCODING,
- ac3 ? V4L2_MPEG_AUDIO_ENCODING_AC3 : V4L2_MPEG_AUDIO_ENCODING_AAC,
-- 0x7, V4L2_MPEG_AUDIO_ENCODING_AAC);
-+ 0x7, ac3 ? dev->options.audio_codec : V4L2_MPEG_AUDIO_ENCODING_AAC);
- v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops,
- V4L2_CID_MPEG_VIDEO_ENCODING,
- V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC, 0x3,
-diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
-index a2e257970fec..78d99b137d91 100644
---- a/drivers/media/v4l2-core/v4l2-dv-timings.c
-+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
-@@ -595,10 +595,10 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait)
- aspect.denominator = 9;
- } else if (ratio == 34) {
- aspect.numerator = 4;
-- aspect.numerator = 3;
-+ aspect.denominator = 3;
- } else if (ratio == 68) {
- aspect.numerator = 15;
-- aspect.numerator = 9;
-+ aspect.denominator = 9;
- } else {
- aspect.numerator = hor_landscape + 99;
- aspect.denominator = 100;
-diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
-index 2872ece81f35..44333bd8f908 100644
---- a/drivers/parport/Kconfig
-+++ b/drivers/parport/Kconfig
-@@ -5,6 +5,12 @@
- # Parport configuration.
- #
-
-+config ARCH_MIGHT_HAVE_PC_PARPORT
-+ bool
-+ help
-+ Select this config option from the architecture Kconfig if
-+ the architecture might have PC parallel port hardware.
-+
- menuconfig PARPORT
- tristate "Parallel port support"
- depends on HAS_IOMEM
-@@ -31,12 +37,6 @@ menuconfig PARPORT
-
- If unsure, say Y.
-
--config ARCH_MIGHT_HAVE_PC_PARPORT
-- bool
-- help
-- Select this config option from the architecture Kconfig if
-- the architecture might have PC parallel port hardware.
--
- if PARPORT
-
- config PARPORT_PC
-diff --git a/drivers/staging/media/omap4iss/Kconfig b/drivers/staging/media/omap4iss/Kconfig
-index b9fe753969bd..15940f8fdd24 100644
---- a/drivers/staging/media/omap4iss/Kconfig
-+++ b/drivers/staging/media/omap4iss/Kconfig
-@@ -1,6 +1,6 @@
- config VIDEO_OMAP4
- bool "OMAP 4 Camera support"
-- depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4
-+ depends on VIDEO_V4L2=y && VIDEO_V4L2_SUBDEV_API && I2C=y && ARCH_OMAP4
- select VIDEOBUF2_DMA_CONTIG
- ---help---
- Driver for an OMAP 4 ISS controller.
-diff --git a/fs/coredump.c b/fs/coredump.c
-index 0b2528fb640e..a93f7e6ea4cf 100644
---- a/fs/coredump.c
-+++ b/fs/coredump.c
-@@ -306,7 +306,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
- if (unlikely(nr < 0))
- return nr;
-
-- tsk->flags = PF_DUMPCORE;
-+ tsk->flags |= PF_DUMPCORE;
- if (atomic_read(&mm->mm_users) == nr + 1)
- goto done;
- /*
-diff --git a/fs/namei.c b/fs/namei.c
-index 8274c8d39b03..bdea10963aa5 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -2247,9 +2247,10 @@ done:
- goto out;
- }
- path->dentry = dentry;
-- path->mnt = mntget(nd->path.mnt);
-+ path->mnt = nd->path.mnt;
- if (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW))
- return 1;
-+ mntget(path->mnt);
- follow_mount(path);
- error = 0;
- out:
-diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
-index 871d6eda8dba..8f854dde4150 100644
---- a/fs/nfs/nfs3acl.c
-+++ b/fs/nfs/nfs3acl.c
-@@ -247,3 +247,46 @@ const struct xattr_handler *nfs3_xattr_handlers[] = {
- &posix_acl_default_xattr_handler,
- NULL,
- };
-+
-+static int
-+nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data,
-+ size_t size, ssize_t *result)
-+{
-+ struct posix_acl *acl;
-+ char *p = data + *result;
-+
-+ acl = get_acl(inode, type);
-+ if (!acl)
-+ return 0;
-+
-+ posix_acl_release(acl);
-+
-+ *result += strlen(name);
-+ *result += 1;
-+ if (!size)
-+ return 0;
-+ if (*result > size)
-+ return -ERANGE;
-+
-+ strcpy(p, name);
-+ return 0;
-+}
-+
-+ssize_t
-+nfs3_listxattr(struct dentry *dentry, char *data, size_t size)
-+{
-+ struct inode *inode = dentry->d_inode;
-+ ssize_t result = 0;
-+ int error;
-+
-+ error = nfs3_list_one_acl(inode, ACL_TYPE_ACCESS,
-+ POSIX_ACL_XATTR_ACCESS, data, size, &result);
-+ if (error)
-+ return error;
-+
-+ error = nfs3_list_one_acl(inode, ACL_TYPE_DEFAULT,
-+ POSIX_ACL_XATTR_DEFAULT, data, size, &result);
-+ if (error)
-+ return error;
-+ return result;
-+}
-diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
-index a462ef0fb5d6..8a18b4a0a4ee 100644
---- a/fs/nfs/nfs3proc.c
-+++ b/fs/nfs/nfs3proc.c
-@@ -926,7 +926,7 @@ static const struct inode_operations nfs3_dir_inode_operations = {
- .getattr = nfs_getattr,
- .setattr = nfs_setattr,
- #ifdef CONFIG_NFS_V3_ACL
-- .listxattr = generic_listxattr,
-+ .listxattr = nfs3_listxattr,
- .getxattr = generic_getxattr,
- .setxattr = generic_setxattr,
- .removexattr = generic_removexattr,
-@@ -940,7 +940,7 @@ static const struct inode_operations nfs3_file_inode_operations = {
- .getattr = nfs_getattr,
- .setattr = nfs_setattr,
- #ifdef CONFIG_NFS_V3_ACL
-- .listxattr = generic_listxattr,
-+ .listxattr = nfs3_listxattr,
- .getxattr = generic_getxattr,
- .setxattr = generic_setxattr,
- .removexattr = generic_removexattr,
-diff --git a/include/linux/libata.h b/include/linux/libata.h
-index 3fee55e73e5e..e13b3aef0b0c 100644
---- a/include/linux/libata.h
-+++ b/include/linux/libata.h
-@@ -593,6 +593,7 @@ struct ata_host {
- struct device *dev;
- void __iomem * const *iomap;
- unsigned int n_ports;
-+ unsigned int n_tags; /* nr of NCQ tags */
- void *private_data;
- struct ata_port_operations *ops;
- unsigned long flags;
-diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
-index 7e259b2bdf44..71136720ffa1 100644
---- a/kernel/trace/trace.c
-+++ b/kernel/trace/trace.c
-@@ -811,7 +811,7 @@ static struct {
- { trace_clock_local, "local", 1 },
- { trace_clock_global, "global", 1 },
- { trace_clock_counter, "counter", 0 },
-- { trace_clock_jiffies, "uptime", 1 },
-+ { trace_clock_jiffies, "uptime", 0 },
- { trace_clock, "perf", 1 },
- ARCH_TRACE_CLOCKS
- };
-diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
-index 26dc348332b7..57b67b1f24d1 100644
---- a/kernel/trace/trace_clock.c
-+++ b/kernel/trace/trace_clock.c
-@@ -59,13 +59,14 @@ u64 notrace trace_clock(void)
-
- /*
- * trace_jiffy_clock(): Simply use jiffies as a clock counter.
-+ * Note that this use of jiffies_64 is not completely safe on
-+ * 32-bit systems. But the window is tiny, and the effect if
-+ * we are affected is that we will have an obviously bogus
-+ * timestamp on a trace event - i.e. not life threatening.
- */
- u64 notrace trace_clock_jiffies(void)
- {
-- u64 jiffy = jiffies - INITIAL_JIFFIES;
--
-- /* Return nsecs */
-- return (u64)jiffies_to_usecs(jiffy) * 1000ULL;
-+ return jiffies_64_to_clock_t(jiffies_64 - INITIAL_JIFFIES);
- }
-
- /*
-diff --git a/mm/hugetlb.c b/mm/hugetlb.c
-index 30dd6265a141..923f38e62bcf 100644
---- a/mm/hugetlb.c
-+++ b/mm/hugetlb.c
-@@ -2422,6 +2422,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
- } else {
- if (cow)
- huge_ptep_set_wrprotect(src, addr, src_pte);
-+ entry = huge_ptep_get(src_pte);
- ptepage = pte_page(entry);
- get_page(ptepage);
- page_dup_rmap(ptepage);
-diff --git a/mm/slab_common.c b/mm/slab_common.c
-index 1ec3c619ba04..f149e6724411 100644
---- a/mm/slab_common.c
-+++ b/mm/slab_common.c
-@@ -56,7 +56,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
- continue;
- }
-
--#if !defined(CONFIG_SLUB) || !defined(CONFIG_SLUB_DEBUG_ON)
-+#if !defined(CONFIG_SLUB)
- /*
- * For simplicity, we won't check this in the list of memcg
- * caches. We have control over memcg naming, and if there
-diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
-index 4fe2e6e2bc76..e6283464a8e6 100644
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -1450,18 +1450,17 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
- }
- CMD(start_p2p_device, START_P2P_DEVICE);
- CMD(set_mcast_rate, SET_MCAST_RATE);
-+#ifdef CONFIG_NL80211_TESTMODE
-+ CMD(testmode_cmd, TESTMODE);
-+#endif
- if (state->split) {
- CMD(crit_proto_start, CRIT_PROTOCOL_START);
- CMD(crit_proto_stop, CRIT_PROTOCOL_STOP);
- if (dev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)
- CMD(channel_switch, CHANNEL_SWITCH);
-+ CMD(set_qos_map, SET_QOS_MAP);
- }
-- CMD(set_qos_map, SET_QOS_MAP);
--
--#ifdef CONFIG_NL80211_TESTMODE
-- CMD(testmode_cmd, TESTMODE);
--#endif
--
-+ /* add into the if now */
- #undef CMD
-
- if (dev->ops->connect || dev->ops->auth) {
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.15-16.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.15-16.patch
deleted file mode 100644
index 346b103783..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.15-16.patch
+++ /dev/null
@@ -1,1740 +0,0 @@
-diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
-index c584a51add15..afe68ddbe6a4 100644
---- a/Documentation/x86/x86_64/mm.txt
-+++ b/Documentation/x86/x86_64/mm.txt
-@@ -12,6 +12,8 @@ ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space
- ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
- ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
- ... unused hole ...
-+ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks
-+... unused hole ...
- ffffffff80000000 - ffffffffa0000000 (=512 MB) kernel text mapping, from phys 0
- ffffffffa0000000 - ffffffffff5fffff (=1525 MB) module mapping space
- ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
-diff --git a/Makefile b/Makefile
-index 188523e9e880..8b22e24a2d8e 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 15
-+SUBLEVEL = 16
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
-index 5babba0a3a75..904dcf5973f3 100644
---- a/arch/arm/boot/dts/dra7-evm.dts
-+++ b/arch/arm/boot/dts/dra7-evm.dts
-@@ -182,6 +182,7 @@
- regulator-name = "ldo3";
- regulator-min-microvolt = <1800000>;
- regulator-max-microvolt = <1800000>;
-+ regulator-always-on;
- regulator-boot-on;
- };
-
-diff --git a/arch/arm/boot/dts/hi3620.dtsi b/arch/arm/boot/dts/hi3620.dtsi
-index ab1116d086be..83a5b8685bd9 100644
---- a/arch/arm/boot/dts/hi3620.dtsi
-+++ b/arch/arm/boot/dts/hi3620.dtsi
-@@ -73,7 +73,7 @@
-
- L2: l2-cache {
- compatible = "arm,pl310-cache";
-- reg = <0xfc10000 0x100000>;
-+ reg = <0x100000 0x100000>;
- interrupts = <0 15 4>;
- cache-unified;
- cache-level = <2>;
-diff --git a/arch/arm/crypto/aesbs-glue.c b/arch/arm/crypto/aesbs-glue.c
-index 4522366da759..15468fbbdea3 100644
---- a/arch/arm/crypto/aesbs-glue.c
-+++ b/arch/arm/crypto/aesbs-glue.c
-@@ -137,7 +137,7 @@ static int aesbs_cbc_encrypt(struct blkcipher_desc *desc,
- dst += AES_BLOCK_SIZE;
- } while (--blocks);
- }
-- err = blkcipher_walk_done(desc, &walk, 0);
-+ err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
- }
- return err;
- }
-@@ -158,7 +158,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc,
- bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
- walk.nbytes, &ctx->dec, walk.iv);
- kernel_neon_end();
-- err = blkcipher_walk_done(desc, &walk, 0);
-+ err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
- }
- while (walk.nbytes) {
- u32 blocks = walk.nbytes / AES_BLOCK_SIZE;
-@@ -182,7 +182,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc,
- dst += AES_BLOCK_SIZE;
- src += AES_BLOCK_SIZE;
- } while (--blocks);
-- err = blkcipher_walk_done(desc, &walk, 0);
-+ err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
- }
- return err;
- }
-@@ -268,7 +268,7 @@ static int aesbs_xts_encrypt(struct blkcipher_desc *desc,
- bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
- walk.nbytes, &ctx->enc, walk.iv);
- kernel_neon_end();
-- err = blkcipher_walk_done(desc, &walk, 0);
-+ err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
- }
- return err;
- }
-@@ -292,7 +292,7 @@ static int aesbs_xts_decrypt(struct blkcipher_desc *desc,
- bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr,
- walk.nbytes, &ctx->dec, walk.iv);
- kernel_neon_end();
-- err = blkcipher_walk_done(desc, &walk, 0);
-+ err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
- }
- return err;
- }
-diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c
-index 8e0e52eb76b5..d7a0ee898d24 100644
---- a/arch/arm/mm/idmap.c
-+++ b/arch/arm/mm/idmap.c
-@@ -25,6 +25,13 @@ static void idmap_add_pmd(pud_t *pud, unsigned long addr, unsigned long end,
- pr_warning("Failed to allocate identity pmd.\n");
- return;
- }
-+ /*
-+ * Copy the original PMD to ensure that the PMD entries for
-+ * the kernel image are preserved.
-+ */
-+ if (!pud_none(*pud))
-+ memcpy(pmd, pmd_offset(pud, 0),
-+ PTRS_PER_PMD * sizeof(pmd_t));
- pud_populate(&init_mm, pud, pmd);
- pmd += pmd_index(addr);
- } else
-diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
-index b68c6b22e1c8..f15c22e8bcd5 100644
---- a/arch/arm/mm/mmu.c
-+++ b/arch/arm/mm/mmu.c
-@@ -1436,8 +1436,8 @@ void __init early_paging_init(const struct machine_desc *mdesc,
- return;
-
- /* remap kernel code and data */
-- map_start = init_mm.start_code;
-- map_end = init_mm.brk;
-+ map_start = init_mm.start_code & PMD_MASK;
-+ map_end = ALIGN(init_mm.brk, PMD_SIZE);
-
- /* get a handle on things... */
- pgd0 = pgd_offset_k(0);
-@@ -1472,7 +1472,7 @@ void __init early_paging_init(const struct machine_desc *mdesc,
- }
-
- /* remap pmds for kernel mapping */
-- phys = __pa(map_start) & PMD_MASK;
-+ phys = __pa(map_start);
- do {
- *pmdk++ = __pmd(phys | pmdprot);
- phys += PMD_SIZE;
-diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
-index 7324107acb40..c718d9f25900 100644
---- a/arch/x86/Kconfig
-+++ b/arch/x86/Kconfig
-@@ -966,10 +966,27 @@ config VM86
- default y
- depends on X86_32
- ---help---
-- This option is required by programs like DOSEMU to run 16-bit legacy
-- code on X86 processors. It also may be needed by software like
-- XFree86 to initialize some video cards via BIOS. Disabling this
-- option saves about 6k.
-+ This option is required by programs like DOSEMU to run
-+ 16-bit real mode legacy code on x86 processors. It also may
-+ be needed by software like XFree86 to initialize some video
-+ cards via BIOS. Disabling this option saves about 6K.
-+
-+config X86_16BIT
-+ bool "Enable support for 16-bit segments" if EXPERT
-+ default y
-+ ---help---
-+ This option is required by programs like Wine to run 16-bit
-+ protected mode legacy code on x86 processors. Disabling
-+ this option saves about 300 bytes on i386, or around 6K text
-+ plus 16K runtime memory on x86-64,
-+
-+config X86_ESPFIX32
-+ def_bool y
-+ depends on X86_16BIT && X86_32
-+
-+config X86_ESPFIX64
-+ def_bool y
-+ depends on X86_16BIT && X86_64
-
- config TOSHIBA
- tristate "Toshiba Laptop support"
-diff --git a/arch/x86/include/asm/espfix.h b/arch/x86/include/asm/espfix.h
-new file mode 100644
-index 000000000000..99efebb2f69d
---- /dev/null
-+++ b/arch/x86/include/asm/espfix.h
-@@ -0,0 +1,16 @@
-+#ifndef _ASM_X86_ESPFIX_H
-+#define _ASM_X86_ESPFIX_H
-+
-+#ifdef CONFIG_X86_64
-+
-+#include
-+
-+DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_stack);
-+DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr);
-+
-+extern void init_espfix_bsp(void);
-+extern void init_espfix_ap(void);
-+
-+#endif /* CONFIG_X86_64 */
-+
-+#endif /* _ASM_X86_ESPFIX_H */
-diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
-index bba3cf88e624..0a8b519226b8 100644
---- a/arch/x86/include/asm/irqflags.h
-+++ b/arch/x86/include/asm/irqflags.h
-@@ -129,7 +129,7 @@ static inline notrace unsigned long arch_local_irq_save(void)
-
- #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */
-
--#define INTERRUPT_RETURN iretq
-+#define INTERRUPT_RETURN jmp native_iret
- #define USERGS_SYSRET64 \
- swapgs; \
- sysretq;
-diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
-index c883bf726398..7166e25ecb57 100644
---- a/arch/x86/include/asm/pgtable_64_types.h
-+++ b/arch/x86/include/asm/pgtable_64_types.h
-@@ -61,6 +61,8 @@ typedef struct { pteval_t pte; } pte_t;
- #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
- #define MODULES_END _AC(0xffffffffff000000, UL)
- #define MODULES_LEN (MODULES_END - MODULES_VADDR)
-+#define ESPFIX_PGD_ENTRY _AC(-2, UL)
-+#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
-
- #define EARLY_DYNAMIC_PAGE_TABLES 64
-
-diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
-index d62c9f809bc5..75b14ca135be 100644
---- a/arch/x86/include/asm/setup.h
-+++ b/arch/x86/include/asm/setup.h
-@@ -65,6 +65,8 @@ static inline void x86_ce4100_early_setup(void) { }
-
- #ifndef _SETUP
-
-+#include
-+
- /*
- * This is set up by the setup-routine at boot-time
- */
-diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
-index cb648c84b327..56bac868cb91 100644
---- a/arch/x86/kernel/Makefile
-+++ b/arch/x86/kernel/Makefile
-@@ -29,6 +29,7 @@ obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
- obj-y += syscall_$(BITS).o
- obj-$(CONFIG_X86_64) += vsyscall_64.o
- obj-$(CONFIG_X86_64) += vsyscall_emu_64.o
-+obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o
- obj-$(CONFIG_SYSFS) += ksysfs.o
- obj-y += bootflag.o e820.o
- obj-y += pci-dma.o quirks.o topology.o kdebugfs.o
-diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
-index c87810b1b557..c5a9cb94dee6 100644
---- a/arch/x86/kernel/entry_32.S
-+++ b/arch/x86/kernel/entry_32.S
-@@ -529,6 +529,7 @@ syscall_exit:
- restore_all:
- TRACE_IRQS_IRET
- restore_all_notrace:
-+#ifdef CONFIG_X86_ESPFIX32
- movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
- # Warning: PT_OLDSS(%esp) contains the wrong/random values if we
- # are returning to the kernel.
-@@ -539,6 +540,7 @@ restore_all_notrace:
- cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax
- CFI_REMEMBER_STATE
- je ldt_ss # returning to user-space with LDT SS
-+#endif
- restore_nocheck:
- RESTORE_REGS 4 # skip orig_eax/error_code
- irq_return:
-@@ -551,6 +553,7 @@ ENTRY(iret_exc)
- .previous
- _ASM_EXTABLE(irq_return,iret_exc)
-
-+#ifdef CONFIG_X86_ESPFIX32
- CFI_RESTORE_STATE
- ldt_ss:
- #ifdef CONFIG_PARAVIRT
-@@ -594,6 +597,7 @@ ldt_ss:
- lss (%esp), %esp /* switch to espfix segment */
- CFI_ADJUST_CFA_OFFSET -8
- jmp restore_nocheck
-+#endif
- CFI_ENDPROC
- ENDPROC(system_call)
-
-@@ -706,6 +710,7 @@ END(syscall_badsys)
- * the high word of the segment base from the GDT and swiches to the
- * normal stack and adjusts ESP with the matching offset.
- */
-+#ifdef CONFIG_X86_ESPFIX32
- /* fixup the stack */
- mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
- mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
-@@ -715,8 +720,10 @@ END(syscall_badsys)
- pushl_cfi %eax
- lss (%esp), %esp /* switch to the normal stack segment */
- CFI_ADJUST_CFA_OFFSET -8
-+#endif
- .endm
- .macro UNWIND_ESPFIX_STACK
-+#ifdef CONFIG_X86_ESPFIX32
- movl %ss, %eax
- /* see if on espfix stack */
- cmpw $__ESPFIX_SS, %ax
-@@ -727,6 +734,7 @@ END(syscall_badsys)
- /* switch to normal stack */
- FIXUP_ESPFIX_STACK
- 27:
-+#endif
- .endm
-
- /*
-@@ -1357,11 +1365,13 @@ END(debug)
- ENTRY(nmi)
- RING0_INT_FRAME
- ASM_CLAC
-+#ifdef CONFIG_X86_ESPFIX32
- pushl_cfi %eax
- movl %ss, %eax
- cmpw $__ESPFIX_SS, %ax
- popl_cfi %eax
- je nmi_espfix_stack
-+#endif
- cmpl $ia32_sysenter_target,(%esp)
- je nmi_stack_fixup
- pushl_cfi %eax
-@@ -1401,6 +1411,7 @@ nmi_debug_stack_check:
- FIX_STACK 24, nmi_stack_correct, 1
- jmp nmi_stack_correct
-
-+#ifdef CONFIG_X86_ESPFIX32
- nmi_espfix_stack:
- /* We have a RING0_INT_FRAME here.
- *
-@@ -1422,6 +1433,7 @@ nmi_espfix_stack:
- lss 12+4(%esp), %esp # back to espfix stack
- CFI_ADJUST_CFA_OFFSET -24
- jmp irq_return
-+#endif
- CFI_ENDPROC
- END(nmi)
-
-diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
-index 1e96c3628bf2..03cd2a8f6009 100644
---- a/arch/x86/kernel/entry_64.S
-+++ b/arch/x86/kernel/entry_64.S
-@@ -58,6 +58,7 @@
- #include
- #include
- #include
-+#include
- #include
-
- /* Avoid __ASSEMBLER__'ifying just for this. */
-@@ -1041,12 +1042,45 @@ restore_args:
-
- irq_return:
- INTERRUPT_RETURN
-- _ASM_EXTABLE(irq_return, bad_iret)
-
--#ifdef CONFIG_PARAVIRT
- ENTRY(native_iret)
-+ /*
-+ * Are we returning to a stack segment from the LDT? Note: in
-+ * 64-bit mode SS:RSP on the exception stack is always valid.
-+ */
-+#ifdef CONFIG_X86_ESPFIX64
-+ testb $4,(SS-RIP)(%rsp)
-+ jnz native_irq_return_ldt
-+#endif
-+
-+native_irq_return_iret:
- iretq
-- _ASM_EXTABLE(native_iret, bad_iret)
-+ _ASM_EXTABLE(native_irq_return_iret, bad_iret)
-+
-+#ifdef CONFIG_X86_ESPFIX64
-+native_irq_return_ldt:
-+ pushq_cfi %rax
-+ pushq_cfi %rdi
-+ SWAPGS
-+ movq PER_CPU_VAR(espfix_waddr),%rdi
-+ movq %rax,(0*8)(%rdi) /* RAX */
-+ movq (2*8)(%rsp),%rax /* RIP */
-+ movq %rax,(1*8)(%rdi)
-+ movq (3*8)(%rsp),%rax /* CS */
-+ movq %rax,(2*8)(%rdi)
-+ movq (4*8)(%rsp),%rax /* RFLAGS */
-+ movq %rax,(3*8)(%rdi)
-+ movq (6*8)(%rsp),%rax /* SS */
-+ movq %rax,(5*8)(%rdi)
-+ movq (5*8)(%rsp),%rax /* RSP */
-+ movq %rax,(4*8)(%rdi)
-+ andl $0xffff0000,%eax
-+ popq_cfi %rdi
-+ orq PER_CPU_VAR(espfix_stack),%rax
-+ SWAPGS
-+ movq %rax,%rsp
-+ popq_cfi %rax
-+ jmp native_irq_return_iret
- #endif
-
- .section .fixup,"ax"
-@@ -1110,9 +1144,40 @@ ENTRY(retint_kernel)
- call preempt_schedule_irq
- jmp exit_intr
- #endif
--
- CFI_ENDPROC
- END(common_interrupt)
-+
-+ /*
-+ * If IRET takes a fault on the espfix stack, then we
-+ * end up promoting it to a doublefault. In that case,
-+ * modify the stack to make it look like we just entered
-+ * the #GP handler from user space, similar to bad_iret.
-+ */
-+#ifdef CONFIG_X86_ESPFIX64
-+ ALIGN
-+__do_double_fault:
-+ XCPT_FRAME 1 RDI+8
-+ movq RSP(%rdi),%rax /* Trap on the espfix stack? */
-+ sarq $PGDIR_SHIFT,%rax
-+ cmpl $ESPFIX_PGD_ENTRY,%eax
-+ jne do_double_fault /* No, just deliver the fault */
-+ cmpl $__KERNEL_CS,CS(%rdi)
-+ jne do_double_fault
-+ movq RIP(%rdi),%rax
-+ cmpq $native_irq_return_iret,%rax
-+ jne do_double_fault /* This shouldn't happen... */
-+ movq PER_CPU_VAR(kernel_stack),%rax
-+ subq $(6*8-KERNEL_STACK_OFFSET),%rax /* Reset to original stack */
-+ movq %rax,RSP(%rdi)
-+ movq $0,(%rax) /* Missing (lost) #GP error code */
-+ movq $general_protection,RIP(%rdi)
-+ retq
-+ CFI_ENDPROC
-+END(__do_double_fault)
-+#else
-+# define __do_double_fault do_double_fault
-+#endif
-+
- /*
- * End of kprobes section
- */
-@@ -1314,7 +1379,7 @@ zeroentry overflow do_overflow
- zeroentry bounds do_bounds
- zeroentry invalid_op do_invalid_op
- zeroentry device_not_available do_device_not_available
--paranoiderrorentry double_fault do_double_fault
-+paranoiderrorentry double_fault __do_double_fault
- zeroentry coprocessor_segment_overrun do_coprocessor_segment_overrun
- errorentry invalid_TSS do_invalid_TSS
- errorentry segment_not_present do_segment_not_present
-@@ -1601,7 +1666,7 @@ error_sti:
- */
- error_kernelspace:
- incl %ebx
-- leaq irq_return(%rip),%rcx
-+ leaq native_irq_return_iret(%rip),%rcx
- cmpq %rcx,RIP+8(%rsp)
- je error_swapgs
- movl %ecx,%eax /* zero extend */
-diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c
-new file mode 100644
-index 000000000000..94d857fb1033
---- /dev/null
-+++ b/arch/x86/kernel/espfix_64.c
-@@ -0,0 +1,208 @@
-+/* ----------------------------------------------------------------------- *
-+ *
-+ * Copyright 2014 Intel Corporation; author: H. Peter Anvin
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms and conditions of the GNU General Public License,
-+ * version 2, as published by the Free Software Foundation.
-+ *
-+ * This program is distributed in the hope it will be useful, but WITHOUT
-+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-+ * more details.
-+ *
-+ * ----------------------------------------------------------------------- */
-+
-+/*
-+ * The IRET instruction, when returning to a 16-bit segment, only
-+ * restores the bottom 16 bits of the user space stack pointer. This
-+ * causes some 16-bit software to break, but it also leaks kernel state
-+ * to user space.
-+ *
-+ * This works around this by creating percpu "ministacks", each of which
-+ * is mapped 2^16 times 64K apart. When we detect that the return SS is
-+ * on the LDT, we copy the IRET frame to the ministack and use the
-+ * relevant alias to return to userspace. The ministacks are mapped
-+ * readonly, so if the IRET fault we promote #GP to #DF which is an IST
-+ * vector and thus has its own stack; we then do the fixup in the #DF
-+ * handler.
-+ *
-+ * This file sets up the ministacks and the related page tables. The
-+ * actual ministack invocation is in entry_64.S.
-+ */
-+
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+
-+/*
-+ * Note: we only need 6*8 = 48 bytes for the espfix stack, but round
-+ * it up to a cache line to avoid unnecessary sharing.
-+ */
-+#define ESPFIX_STACK_SIZE (8*8UL)
-+#define ESPFIX_STACKS_PER_PAGE (PAGE_SIZE/ESPFIX_STACK_SIZE)
-+
-+/* There is address space for how many espfix pages? */
-+#define ESPFIX_PAGE_SPACE (1UL << (PGDIR_SHIFT-PAGE_SHIFT-16))
-+
-+#define ESPFIX_MAX_CPUS (ESPFIX_STACKS_PER_PAGE * ESPFIX_PAGE_SPACE)
-+#if CONFIG_NR_CPUS > ESPFIX_MAX_CPUS
-+# error "Need more than one PGD for the ESPFIX hack"
-+#endif
-+
-+#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)
-+
-+/* This contains the *bottom* address of the espfix stack */
-+DEFINE_PER_CPU_READ_MOSTLY(unsigned long, espfix_stack);
-+DEFINE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr);
-+
-+/* Initialization mutex - should this be a spinlock? */
-+static DEFINE_MUTEX(espfix_init_mutex);
-+
-+/* Page allocation bitmap - each page serves ESPFIX_STACKS_PER_PAGE CPUs */
-+#define ESPFIX_MAX_PAGES DIV_ROUND_UP(CONFIG_NR_CPUS, ESPFIX_STACKS_PER_PAGE)
-+static void *espfix_pages[ESPFIX_MAX_PAGES];
-+
-+static __page_aligned_bss pud_t espfix_pud_page[PTRS_PER_PUD]
-+ __aligned(PAGE_SIZE);
-+
-+static unsigned int page_random, slot_random;
-+
-+/*
-+ * This returns the bottom address of the espfix stack for a specific CPU.
-+ * The math allows for a non-power-of-two ESPFIX_STACK_SIZE, in which case
-+ * we have to account for some amount of padding at the end of each page.
-+ */
-+static inline unsigned long espfix_base_addr(unsigned int cpu)
-+{
-+ unsigned long page, slot;
-+ unsigned long addr;
-+
-+ page = (cpu / ESPFIX_STACKS_PER_PAGE) ^ page_random;
-+ slot = (cpu + slot_random) % ESPFIX_STACKS_PER_PAGE;
-+ addr = (page << PAGE_SHIFT) + (slot * ESPFIX_STACK_SIZE);
-+ addr = (addr & 0xffffUL) | ((addr & ~0xffffUL) << 16);
-+ addr += ESPFIX_BASE_ADDR;
-+ return addr;
-+}
-+
-+#define PTE_STRIDE (65536/PAGE_SIZE)
-+#define ESPFIX_PTE_CLONES (PTRS_PER_PTE/PTE_STRIDE)
-+#define ESPFIX_PMD_CLONES PTRS_PER_PMD
-+#define ESPFIX_PUD_CLONES (65536/(ESPFIX_PTE_CLONES*ESPFIX_PMD_CLONES))
-+
-+#define PGTABLE_PROT ((_KERNPG_TABLE & ~_PAGE_RW) | _PAGE_NX)
-+
-+static void init_espfix_random(void)
-+{
-+ unsigned long rand;
-+
-+ /*
-+ * This is run before the entropy pools are initialized,
-+ * but this is hopefully better than nothing.
-+ */
-+ if (!arch_get_random_long(&rand)) {
-+ /* The constant is an arbitrary large prime */
-+ rdtscll(rand);
-+ rand *= 0xc345c6b72fd16123UL;
-+ }
-+
-+ slot_random = rand % ESPFIX_STACKS_PER_PAGE;
-+ page_random = (rand / ESPFIX_STACKS_PER_PAGE)
-+ & (ESPFIX_PAGE_SPACE - 1);
-+}
-+
-+void __init init_espfix_bsp(void)
-+{
-+ pgd_t *pgd_p;
-+ pteval_t ptemask;
-+
-+ ptemask = __supported_pte_mask;
-+
-+ /* Install the espfix pud into the kernel page directory */
-+ pgd_p = &init_level4_pgt[pgd_index(ESPFIX_BASE_ADDR)];
-+ pgd_populate(&init_mm, pgd_p, (pud_t *)espfix_pud_page);
-+
-+ /* Randomize the locations */
-+ init_espfix_random();
-+
-+ /* The rest is the same as for any other processor */
-+ init_espfix_ap();
-+}
-+
-+void init_espfix_ap(void)
-+{
-+ unsigned int cpu, page;
-+ unsigned long addr;
-+ pud_t pud, *pud_p;
-+ pmd_t pmd, *pmd_p;
-+ pte_t pte, *pte_p;
-+ int n;
-+ void *stack_page;
-+ pteval_t ptemask;
-+
-+ /* We only have to do this once... */
-+ if (likely(this_cpu_read(espfix_stack)))
-+ return; /* Already initialized */
-+
-+ cpu = smp_processor_id();
-+ addr = espfix_base_addr(cpu);
-+ page = cpu/ESPFIX_STACKS_PER_PAGE;
-+
-+ /* Did another CPU already set this up? */
-+ stack_page = ACCESS_ONCE(espfix_pages[page]);
-+ if (likely(stack_page))
-+ goto done;
-+
-+ mutex_lock(&espfix_init_mutex);
-+
-+ /* Did we race on the lock? */
-+ stack_page = ACCESS_ONCE(espfix_pages[page]);
-+ if (stack_page)
-+ goto unlock_done;
-+
-+ ptemask = __supported_pte_mask;
-+
-+ pud_p = &espfix_pud_page[pud_index(addr)];
-+ pud = *pud_p;
-+ if (!pud_present(pud)) {
-+ pmd_p = (pmd_t *)__get_free_page(PGALLOC_GFP);
-+ pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask));
-+ paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT);
-+ for (n = 0; n < ESPFIX_PUD_CLONES; n++)
-+ set_pud(&pud_p[n], pud);
-+ }
-+
-+ pmd_p = pmd_offset(&pud, addr);
-+ pmd = *pmd_p;
-+ if (!pmd_present(pmd)) {
-+ pte_p = (pte_t *)__get_free_page(PGALLOC_GFP);
-+ pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask));
-+ paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT);
-+ for (n = 0; n < ESPFIX_PMD_CLONES; n++)
-+ set_pmd(&pmd_p[n], pmd);
-+ }
-+
-+ pte_p = pte_offset_kernel(&pmd, addr);
-+ stack_page = (void *)__get_free_page(GFP_KERNEL);
-+ pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask));
-+ for (n = 0; n < ESPFIX_PTE_CLONES; n++)
-+ set_pte(&pte_p[n*PTE_STRIDE], pte);
-+
-+ /* Job is done for this CPU and any CPU which shares this page */
-+ ACCESS_ONCE(espfix_pages[page]) = stack_page;
-+
-+unlock_done:
-+ mutex_unlock(&espfix_init_mutex);
-+done:
-+ this_cpu_write(espfix_stack, addr);
-+ this_cpu_write(espfix_waddr, (unsigned long)stack_page
-+ + (addr & ~PAGE_MASK));
-+}
-diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
-index dcbbaa165bde..c37886d759cc 100644
---- a/arch/x86/kernel/ldt.c
-+++ b/arch/x86/kernel/ldt.c
-@@ -20,8 +20,6 @@
- #include
- #include
-
--int sysctl_ldt16 = 0;
--
- #ifdef CONFIG_SMP
- static void flush_ldt(void *current_mm)
- {
-@@ -231,16 +229,10 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
- }
- }
-
-- /*
-- * On x86-64 we do not support 16-bit segments due to
-- * IRET leaking the high bits of the kernel stack address.
-- */
--#ifdef CONFIG_X86_64
-- if (!ldt_info.seg_32bit && !sysctl_ldt16) {
-+ if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) {
- error = -EINVAL;
- goto out_unlock;
- }
--#endif
-
- fill_ldt(&ldt, &ldt_info);
- if (oldmode)
-diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c
-index 3f08f34f93eb..a1da6737ba5b 100644
---- a/arch/x86/kernel/paravirt_patch_64.c
-+++ b/arch/x86/kernel/paravirt_patch_64.c
-@@ -6,7 +6,6 @@ DEF_NATIVE(pv_irq_ops, irq_disable, "cli");
- DEF_NATIVE(pv_irq_ops, irq_enable, "sti");
- DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq");
- DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");
--DEF_NATIVE(pv_cpu_ops, iret, "iretq");
- DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax");
- DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax");
- DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3");
-@@ -50,7 +49,6 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
- PATCH_SITE(pv_irq_ops, save_fl);
- PATCH_SITE(pv_irq_ops, irq_enable);
- PATCH_SITE(pv_irq_ops, irq_disable);
-- PATCH_SITE(pv_cpu_ops, iret);
- PATCH_SITE(pv_cpu_ops, irq_enable_sysexit);
- PATCH_SITE(pv_cpu_ops, usergs_sysret32);
- PATCH_SITE(pv_cpu_ops, usergs_sysret64);
-diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
-index a32da804252e..395be6d8bbde 100644
---- a/arch/x86/kernel/smpboot.c
-+++ b/arch/x86/kernel/smpboot.c
-@@ -243,6 +243,13 @@ static void notrace start_secondary(void *unused)
- check_tsc_sync_target();
-
- /*
-+ * Enable the espfix hack for this CPU
-+ */
-+#ifdef CONFIG_X86_ESPFIX64
-+ init_espfix_ap();
-+#endif
-+
-+ /*
- * We need to hold vector_lock so there the set of online cpus
- * does not change while we are assigning vectors to cpus. Holding
- * this lock ensures we don't half assign or remove an irq from a cpu.
-diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
-index 0002a3a33081..3620928631ce 100644
---- a/arch/x86/mm/dump_pagetables.c
-+++ b/arch/x86/mm/dump_pagetables.c
-@@ -30,11 +30,13 @@ struct pg_state {
- unsigned long start_address;
- unsigned long current_address;
- const struct addr_marker *marker;
-+ unsigned long lines;
- };
-
- struct addr_marker {
- unsigned long start_address;
- const char *name;
-+ unsigned long max_lines;
- };
-
- /* indices for address_markers; keep sync'd w/ address_markers below */
-@@ -45,6 +47,7 @@ enum address_markers_idx {
- LOW_KERNEL_NR,
- VMALLOC_START_NR,
- VMEMMAP_START_NR,
-+ ESPFIX_START_NR,
- HIGH_KERNEL_NR,
- MODULES_VADDR_NR,
- MODULES_END_NR,
-@@ -67,6 +70,7 @@ static struct addr_marker address_markers[] = {
- { PAGE_OFFSET, "Low Kernel Mapping" },
- { VMALLOC_START, "vmalloc() Area" },
- { VMEMMAP_START, "Vmemmap" },
-+ { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
- { __START_KERNEL_map, "High Kernel Mapping" },
- { MODULES_VADDR, "Modules" },
- { MODULES_END, "End Modules" },
-@@ -163,7 +167,7 @@ static void note_page(struct seq_file *m, struct pg_state *st,
- pgprot_t new_prot, int level)
- {
- pgprotval_t prot, cur;
-- static const char units[] = "KMGTPE";
-+ static const char units[] = "BKMGTPE";
-
- /*
- * If we have a "break" in the series, we need to flush the state that
-@@ -178,6 +182,7 @@ static void note_page(struct seq_file *m, struct pg_state *st,
- st->current_prot = new_prot;
- st->level = level;
- st->marker = address_markers;
-+ st->lines = 0;
- seq_printf(m, "---[ %s ]---\n", st->marker->name);
- } else if (prot != cur || level != st->level ||
- st->current_address >= st->marker[1].start_address) {
-@@ -188,17 +193,21 @@ static void note_page(struct seq_file *m, struct pg_state *st,
- /*
- * Now print the actual finished series
- */
-- seq_printf(m, "0x%0*lx-0x%0*lx ",
-- width, st->start_address,
-- width, st->current_address);
--
-- delta = (st->current_address - st->start_address) >> 10;
-- while (!(delta & 1023) && unit[1]) {
-- delta >>= 10;
-- unit++;
-+ if (!st->marker->max_lines ||
-+ st->lines < st->marker->max_lines) {
-+ seq_printf(m, "0x%0*lx-0x%0*lx ",
-+ width, st->start_address,
-+ width, st->current_address);
-+
-+ delta = (st->current_address - st->start_address) >> 10;
-+ while (!(delta & 1023) && unit[1]) {
-+ delta >>= 10;
-+ unit++;
-+ }
-+ seq_printf(m, "%9lu%c ", delta, *unit);
-+ printk_prot(m, st->current_prot, st->level);
- }
-- seq_printf(m, "%9lu%c ", delta, *unit);
-- printk_prot(m, st->current_prot, st->level);
-+ st->lines++;
-
- /*
- * We print markers for special areas of address space,
-diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
-index f1d633a43f8e..d6bfb876cfb0 100644
---- a/arch/x86/vdso/vdso32-setup.c
-+++ b/arch/x86/vdso/vdso32-setup.c
-@@ -41,7 +41,6 @@ enum {
- #ifdef CONFIG_X86_64
- #define vdso_enabled sysctl_vsyscall32
- #define arch_setup_additional_pages syscall32_setup_pages
--extern int sysctl_ldt16;
- #endif
-
- /*
-@@ -381,13 +380,6 @@ static struct ctl_table abi_table2[] = {
- .mode = 0644,
- .proc_handler = proc_dointvec
- },
-- {
-- .procname = "ldt16",
-- .data = &sysctl_ldt16,
-- .maxlen = sizeof(int),
-- .mode = 0644,
-- .proc_handler = proc_dointvec
-- },
- {}
- };
-
-diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
-index 0982233b9b84..a6a72ce8630f 100644
---- a/arch/x86/xen/setup.c
-+++ b/arch/x86/xen/setup.c
-@@ -574,13 +574,7 @@ void xen_enable_syscall(void)
- }
- #endif /* CONFIG_X86_64 */
- }
--void xen_enable_nmi(void)
--{
--#ifdef CONFIG_X86_64
-- if (register_callback(CALLBACKTYPE_nmi, (char *)nmi))
-- BUG();
--#endif
--}
-+
- void __init xen_pvmmu_arch_setup(void)
- {
- HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
-@@ -595,7 +589,6 @@ void __init xen_pvmmu_arch_setup(void)
-
- xen_enable_sysenter();
- xen_enable_syscall();
-- xen_enable_nmi();
- }
-
- /* This function is not called for HVM domains */
-diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S
-index f9e1ec346e35..8453e6e39895 100644
---- a/arch/xtensa/kernel/vectors.S
-+++ b/arch/xtensa/kernel/vectors.S
-@@ -376,38 +376,42 @@ _DoubleExceptionVector_WindowOverflow:
- beqz a2, 1f # if at start of vector, don't restore
-
- addi a0, a0, -128
-- bbsi a0, 8, 1f # don't restore except for overflow 8 and 12
-- bbsi a0, 7, 2f
-+ bbsi.l a0, 8, 1f # don't restore except for overflow 8 and 12
-+
-+ /*
-+ * This fixup handler is for the extremely unlikely case where the
-+ * overflow handler's reference thru a0 gets a hardware TLB refill
-+ * that bumps out the (distinct, aliasing) TLB entry that mapped its
-+ * prior references thru a9/a13, and where our reference now thru
-+ * a9/a13 gets a 2nd-level miss exception (not hardware TLB refill).
-+ */
-+ movi a2, window_overflow_restore_a0_fixup
-+ s32i a2, a3, EXC_TABLE_FIXUP
-+ l32i a2, a3, EXC_TABLE_DOUBLE_SAVE
-+ xsr a3, excsave1
-+
-+ bbsi.l a0, 7, 2f
-
- /*
- * Restore a0 as saved by _WindowOverflow8().
-- *
-- * FIXME: we really need a fixup handler for this L32E,
-- * for the extremely unlikely case where the overflow handler's
-- * reference thru a0 gets a hardware TLB refill that bumps out
-- * the (distinct, aliasing) TLB entry that mapped its prior
-- * references thru a9, and where our reference now thru a9
-- * gets a 2nd-level miss exception (not hardware TLB refill).
- */
-
-- l32e a2, a9, -16
-- wsr a2, depc # replace the saved a0
-- j 1f
-+ l32e a0, a9, -16
-+ wsr a0, depc # replace the saved a0
-+ j 3f
-
- 2:
- /*
- * Restore a0 as saved by _WindowOverflow12().
-- *
-- * FIXME: we really need a fixup handler for this L32E,
-- * for the extremely unlikely case where the overflow handler's
-- * reference thru a0 gets a hardware TLB refill that bumps out
-- * the (distinct, aliasing) TLB entry that mapped its prior
-- * references thru a13, and where our reference now thru a13
-- * gets a 2nd-level miss exception (not hardware TLB refill).
- */
-
-- l32e a2, a13, -16
-- wsr a2, depc # replace the saved a0
-+ l32e a0, a13, -16
-+ wsr a0, depc # replace the saved a0
-+3:
-+ xsr a3, excsave1
-+ movi a0, 0
-+ s32i a0, a3, EXC_TABLE_FIXUP
-+ s32i a2, a3, EXC_TABLE_DOUBLE_SAVE
- 1:
- /*
- * Restore WindowBase while leaving all address registers restored.
-@@ -449,6 +453,7 @@ _DoubleExceptionVector_WindowOverflow:
-
- s32i a0, a2, PT_DEPC
-
-+_DoubleExceptionVector_handle_exception:
- addx4 a0, a0, a3
- l32i a0, a0, EXC_TABLE_FAST_USER
- xsr a3, excsave1
-@@ -464,11 +469,120 @@ _DoubleExceptionVector_WindowOverflow:
- rotw -3
- j 1b
-
-- .end literal_prefix
-
- ENDPROC(_DoubleExceptionVector)
-
- /*
-+ * Fixup handler for TLB miss in double exception handler for window owerflow.
-+ * We get here with windowbase set to the window that was being spilled and
-+ * a0 trashed. a0 bit 7 determines if this is a call8 (bit clear) or call12
-+ * (bit set) window.
-+ *
-+ * We do the following here:
-+ * - go to the original window retaining a0 value;
-+ * - set up exception stack to return back to appropriate a0 restore code
-+ * (we'll need to rotate window back and there's no place to save this
-+ * information, use different return address for that);
-+ * - handle the exception;
-+ * - go to the window that was being spilled;
-+ * - set up window_overflow_restore_a0_fixup as a fixup routine;
-+ * - reload a0;
-+ * - restore the original window;
-+ * - reset the default fixup routine;
-+ * - return to user. By the time we get to this fixup handler all information
-+ * about the conditions of the original double exception that happened in
-+ * the window overflow handler is lost, so we just return to userspace to
-+ * retry overflow from start.
-+ *
-+ * a0: value of depc, original value in depc
-+ * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE
-+ * a3: exctable, original value in excsave1
-+ */
-+
-+ENTRY(window_overflow_restore_a0_fixup)
-+
-+ rsr a0, ps
-+ extui a0, a0, PS_OWB_SHIFT, PS_OWB_WIDTH
-+ rsr a2, windowbase
-+ sub a0, a2, a0
-+ extui a0, a0, 0, 3
-+ l32i a2, a3, EXC_TABLE_DOUBLE_SAVE
-+ xsr a3, excsave1
-+
-+ _beqi a0, 1, .Lhandle_1
-+ _beqi a0, 3, .Lhandle_3
-+
-+ .macro overflow_fixup_handle_exception_pane n
-+
-+ rsr a0, depc
-+ rotw -\n
-+
-+ xsr a3, excsave1
-+ wsr a2, depc
-+ l32i a2, a3, EXC_TABLE_KSTK
-+ s32i a0, a2, PT_AREG0
-+
-+ movi a0, .Lrestore_\n
-+ s32i a0, a2, PT_DEPC
-+ rsr a0, exccause
-+ j _DoubleExceptionVector_handle_exception
-+
-+ .endm
-+
-+ overflow_fixup_handle_exception_pane 2
-+.Lhandle_1:
-+ overflow_fixup_handle_exception_pane 1
-+.Lhandle_3:
-+ overflow_fixup_handle_exception_pane 3
-+
-+ .macro overflow_fixup_restore_a0_pane n
-+
-+ rotw \n
-+ /* Need to preserve a0 value here to be able to handle exception
-+ * that may occur on a0 reload from stack. It may occur because
-+ * TLB miss handler may not be atomic and pointer to page table
-+ * may be lost before we get here. There are no free registers,
-+ * so we need to use EXC_TABLE_DOUBLE_SAVE area.
-+ */
-+ xsr a3, excsave1
-+ s32i a2, a3, EXC_TABLE_DOUBLE_SAVE
-+ movi a2, window_overflow_restore_a0_fixup
-+ s32i a2, a3, EXC_TABLE_FIXUP
-+ l32i a2, a3, EXC_TABLE_DOUBLE_SAVE
-+ xsr a3, excsave1
-+ bbsi.l a0, 7, 1f
-+ l32e a0, a9, -16
-+ j 2f
-+1:
-+ l32e a0, a13, -16
-+2:
-+ rotw -\n
-+
-+ .endm
-+
-+.Lrestore_2:
-+ overflow_fixup_restore_a0_pane 2
-+
-+.Lset_default_fixup:
-+ xsr a3, excsave1
-+ s32i a2, a3, EXC_TABLE_DOUBLE_SAVE
-+ movi a2, 0
-+ s32i a2, a3, EXC_TABLE_FIXUP
-+ l32i a2, a3, EXC_TABLE_DOUBLE_SAVE
-+ xsr a3, excsave1
-+ rfe
-+
-+.Lrestore_1:
-+ overflow_fixup_restore_a0_pane 1
-+ j .Lset_default_fixup
-+.Lrestore_3:
-+ overflow_fixup_restore_a0_pane 3
-+ j .Lset_default_fixup
-+
-+ENDPROC(window_overflow_restore_a0_fixup)
-+
-+ .end literal_prefix
-+/*
- * Debug interrupt vector
- *
- * There is not much space here, so simply jump to another handler.
-diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
-index ee32c0085dff..d16db6df86f8 100644
---- a/arch/xtensa/kernel/vmlinux.lds.S
-+++ b/arch/xtensa/kernel/vmlinux.lds.S
-@@ -269,13 +269,13 @@ SECTIONS
- .UserExceptionVector.literal)
- SECTION_VECTOR (_DoubleExceptionVector_literal,
- .DoubleExceptionVector.literal,
-- DOUBLEEXC_VECTOR_VADDR - 16,
-+ DOUBLEEXC_VECTOR_VADDR - 40,
- SIZEOF(.UserExceptionVector.text),
- .UserExceptionVector.text)
- SECTION_VECTOR (_DoubleExceptionVector_text,
- .DoubleExceptionVector.text,
- DOUBLEEXC_VECTOR_VADDR,
-- 32,
-+ 40,
- .DoubleExceptionVector.literal)
-
- . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
-diff --git a/crypto/af_alg.c b/crypto/af_alg.c
-index 966f893711b3..6a3ad8011585 100644
---- a/crypto/af_alg.c
-+++ b/crypto/af_alg.c
-@@ -21,6 +21,7 @@
- #include
- #include
- #include
-+#include
-
- struct alg_type_list {
- const struct af_alg_type *type;
-@@ -243,6 +244,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)
-
- sock_init_data(newsock, sk2);
- sock_graft(sk2, newsock);
-+ security_sk_clone(sk, sk2);
-
- err = type->accept(ask->private, sk2);
- if (err) {
-diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
-index 199b52b7c3e1..153f4b92cc05 100644
---- a/drivers/cpufreq/cpufreq.c
-+++ b/drivers/cpufreq/cpufreq.c
-@@ -1089,10 +1089,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
- * the creation of a brand new one. So we need to perform this update
- * by invoking update_policy_cpu().
- */
-- if (frozen && cpu != policy->cpu)
-+ if (frozen && cpu != policy->cpu) {
- update_policy_cpu(policy, cpu);
-- else
-+ WARN_ON(kobject_move(&policy->kobj, &dev->kobj));
-+ } else {
- policy->cpu = cpu;
-+ }
-
- policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
- cpumask_copy(policy->cpus, cpumask_of(cpu));
-diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
-index bfec313492b3..fe83d04784c8 100644
---- a/drivers/iio/accel/bma180.c
-+++ b/drivers/iio/accel/bma180.c
-@@ -68,13 +68,13 @@
- /* Defaults values */
- #define BMA180_DEF_PMODE 0
- #define BMA180_DEF_BW 20
--#define BMA180_DEF_SCALE 250
-+#define BMA180_DEF_SCALE 2452
-
- /* Available values for sysfs */
- #define BMA180_FLP_FREQ_AVAILABLE \
- "10 20 40 75 150 300"
- #define BMA180_SCALE_AVAILABLE \
-- "0.000130 0.000190 0.000250 0.000380 0.000500 0.000990 0.001980"
-+ "0.001275 0.001863 0.002452 0.003727 0.004903 0.009709 0.019417"
-
- struct bma180_data {
- struct i2c_client *client;
-@@ -94,7 +94,7 @@ enum bma180_axis {
- };
-
- static int bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */
--static int scale_table[] = { 130, 190, 250, 380, 500, 990, 1980 };
-+static int scale_table[] = { 1275, 1863, 2452, 3727, 4903, 9709, 19417 };
-
- static int bma180_get_acc_reg(struct bma180_data *data, enum bma180_axis axis)
- {
-@@ -376,6 +376,8 @@ static int bma180_write_raw(struct iio_dev *indio_dev,
- mutex_unlock(&data->mutex);
- return ret;
- case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
-+ if (val2)
-+ return -EINVAL;
- mutex_lock(&data->mutex);
- ret = bma180_set_bw(data, val);
- mutex_unlock(&data->mutex);
-diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
-index fe25042f056a..0f1d9b2ccdfa 100644
---- a/drivers/iio/industrialio-buffer.c
-+++ b/drivers/iio/industrialio-buffer.c
-@@ -953,7 +953,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
-
- /* Now we have the two masks, work from least sig and build up sizes */
- for_each_set_bit(out_ind,
-- indio_dev->active_scan_mask,
-+ buffer->scan_mask,
- indio_dev->masklength) {
- in_ind = find_next_bit(indio_dev->active_scan_mask,
- indio_dev->masklength,
-diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
-index 66c5d130c8c2..0e722c103562 100644
---- a/drivers/md/dm-bufio.c
-+++ b/drivers/md/dm-bufio.c
-@@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
- BUG_ON(block_size < 1 << SECTOR_SHIFT ||
- (block_size & (block_size - 1)));
-
-- c = kmalloc(sizeof(*c), GFP_KERNEL);
-+ c = kzalloc(sizeof(*c), GFP_KERNEL);
- if (!c) {
- r = -ENOMEM;
- goto bad_client;
-diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
-index c0ad90d91252..735e939a846d 100644
---- a/drivers/md/dm-cache-target.c
-+++ b/drivers/md/dm-cache-target.c
-@@ -231,7 +231,7 @@ struct cache {
- /*
- * cache_size entries, dirty if set
- */
-- dm_cblock_t nr_dirty;
-+ atomic_t nr_dirty;
- unsigned long *dirty_bitset;
-
- /*
-@@ -493,7 +493,7 @@ static bool is_dirty(struct cache *cache, dm_cblock_t b)
- static void set_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cblock)
- {
- if (!test_and_set_bit(from_cblock(cblock), cache->dirty_bitset)) {
-- cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) + 1);
-+ atomic_inc(&cache->nr_dirty);
- policy_set_dirty(cache->policy, oblock);
- }
- }
-@@ -502,8 +502,7 @@ static void clear_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cbl
- {
- if (test_and_clear_bit(from_cblock(cblock), cache->dirty_bitset)) {
- policy_clear_dirty(cache->policy, oblock);
-- cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) - 1);
-- if (!from_cblock(cache->nr_dirty))
-+ if (atomic_dec_return(&cache->nr_dirty) == 0)
- dm_table_event(cache->ti->table);
- }
- }
-@@ -2286,7 +2285,7 @@ static int cache_create(struct cache_args *ca, struct cache **result)
- atomic_set(&cache->quiescing_ack, 0);
-
- r = -ENOMEM;
-- cache->nr_dirty = 0;
-+ atomic_set(&cache->nr_dirty, 0);
- cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size));
- if (!cache->dirty_bitset) {
- *error = "could not allocate dirty bitset";
-@@ -2828,7 +2827,7 @@ static void cache_status(struct dm_target *ti, status_type_t type,
-
- residency = policy_residency(cache->policy);
-
-- DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %llu ",
-+ DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %lu ",
- (unsigned)(DM_CACHE_METADATA_BLOCK_SIZE >> SECTOR_SHIFT),
- (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata),
- (unsigned long long)nr_blocks_metadata,
-@@ -2841,7 +2840,7 @@ static void cache_status(struct dm_target *ti, status_type_t type,
- (unsigned) atomic_read(&cache->stats.write_miss),
- (unsigned) atomic_read(&cache->stats.demotion),
- (unsigned) atomic_read(&cache->stats.promotion),
-- (unsigned long long) from_cblock(cache->nr_dirty));
-+ (unsigned long) atomic_read(&cache->nr_dirty));
-
- if (writethrough_mode(&cache->features))
- DMEMIT("1 writethrough ");
-diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
-index 0526ddff977d..0fe7674ad100 100644
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -890,6 +890,15 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
-
- tx_info = IEEE80211_SKB_CB(skb);
- tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
-+
-+ /*
-+ * No aggregation session is running, but there may be frames
-+ * from a previous session or a failed attempt in the queue.
-+ * Send them out as normal data frames
-+ */
-+ if (!tid->active)
-+ tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
-+
- if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
- bf->bf_state.bf_type = 0;
- return bf;
-diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
-index c31aa07b3ba5..da1c6cb1a41e 100644
---- a/drivers/pnp/pnpacpi/core.c
-+++ b/drivers/pnp/pnpacpi/core.c
-@@ -339,8 +339,7 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)
- struct pnp_dev *pnp = _pnp;
-
- /* true means it matched */
-- return !acpi->physical_node_count
-- && compare_pnp_id(pnp->id, acpi_device_hid(acpi));
-+ return pnp->data == acpi;
- }
-
- static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)
-diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c
-index 91245f5dbe81..47257b6eea84 100644
---- a/drivers/rapidio/devices/tsi721_dma.c
-+++ b/drivers/rapidio/devices/tsi721_dma.c
-@@ -287,6 +287,12 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan)
- "desc %p not ACKed\n", tx_desc);
- }
-
-+ if (ret == NULL) {
-+ dev_dbg(bdma_chan->dchan.device->dev,
-+ "%s: unable to obtain tx descriptor\n", __func__);
-+ goto err_out;
-+ }
-+
- i = bdma_chan->wr_count_next % bdma_chan->bd_num;
- if (i == bdma_chan->bd_num - 1) {
- i = 0;
-@@ -297,7 +303,7 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan)
- tx_desc->txd.phys = bdma_chan->bd_phys +
- i * sizeof(struct tsi721_dma_desc);
- tx_desc->hw_desc = &((struct tsi721_dma_desc *)bdma_chan->bd_base)[i];
--
-+err_out:
- spin_unlock_bh(&bdma_chan->lock);
-
- return ret;
-diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
-index 62ec84b42e31..64e487a8bf59 100644
---- a/drivers/scsi/scsi_lib.c
-+++ b/drivers/scsi/scsi_lib.c
-@@ -831,6 +831,14 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
- scsi_next_command(cmd);
- return;
- }
-+ } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) {
-+ /*
-+ * Certain non BLOCK_PC requests are commands that don't
-+ * actually transfer anything (FLUSH), so cannot use
-+ * good_bytes != blk_rq_bytes(req) as the signal for an error.
-+ * This sets the error explicitly for the problem case.
-+ */
-+ error = __scsi_error_from_host_byte(cmd, result);
- }
-
- /* no bidi support for !REQ_TYPE_BLOCK_PC yet */
-diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c
-index d7efd0173a9a..7d7578872a84 100644
---- a/drivers/staging/vt6655/bssdb.c
-+++ b/drivers/staging/vt6655/bssdb.c
-@@ -983,7 +983,7 @@ start:
- pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));
- }
-
-- {
-+ if (pDevice->eCommandState == WLAN_ASSOCIATE_WAIT) {
- pDevice->byReAssocCount++;
- /* 10 sec timeout */
- if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) {
-diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
-index a952df1bf9d6..6f13f0e597f8 100644
---- a/drivers/staging/vt6655/device_main.c
-+++ b/drivers/staging/vt6655/device_main.c
-@@ -2430,6 +2430,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
- int handled = 0;
- unsigned char byData = 0;
- int ii = 0;
-+ unsigned long flags;
- // unsigned char byRSSI;
-
- MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
-@@ -2455,7 +2456,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
-
- handled = 1;
- MACvIntDisable(pDevice->PortOffset);
-- spin_lock_irq(&pDevice->lock);
-+
-+ spin_lock_irqsave(&pDevice->lock, flags);
-
- //Make sure current page is 0
- VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
-@@ -2696,7 +2698,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
- MACvSelectPage1(pDevice->PortOffset);
- }
-
-- spin_unlock_irq(&pDevice->lock);
-+ spin_unlock_irqrestore(&pDevice->lock, flags);
-+
- MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
-
- return IRQ_RETVAL(handled);
-diff --git a/include/dt-bindings/pinctrl/dra.h b/include/dt-bindings/pinctrl/dra.h
-index 002a2855c046..3d33794e4f3e 100644
---- a/include/dt-bindings/pinctrl/dra.h
-+++ b/include/dt-bindings/pinctrl/dra.h
-@@ -30,7 +30,8 @@
- #define MUX_MODE14 0xe
- #define MUX_MODE15 0xf
-
--#define PULL_ENA (1 << 16)
-+#define PULL_ENA (0 << 16)
-+#define PULL_DIS (1 << 16)
- #define PULL_UP (1 << 17)
- #define INPUT_EN (1 << 18)
- #define SLEWCONTROL (1 << 19)
-@@ -38,10 +39,10 @@
- #define WAKEUP_EVENT (1 << 25)
-
- /* Active pin states */
--#define PIN_OUTPUT 0
-+#define PIN_OUTPUT (0 | PULL_DIS)
- #define PIN_OUTPUT_PULLUP (PIN_OUTPUT | PULL_ENA | PULL_UP)
- #define PIN_OUTPUT_PULLDOWN (PIN_OUTPUT | PULL_ENA)
--#define PIN_INPUT INPUT_EN
-+#define PIN_INPUT (INPUT_EN | PULL_DIS)
- #define PIN_INPUT_SLEW (INPUT_EN | SLEWCONTROL)
- #define PIN_INPUT_PULLUP (PULL_ENA | INPUT_EN | PULL_UP)
- #define PIN_INPUT_PULLDOWN (PULL_ENA | INPUT_EN)
-diff --git a/include/linux/printk.h b/include/linux/printk.h
-index fa47e2708c01..cbf094f993f4 100644
---- a/include/linux/printk.h
-+++ b/include/linux/printk.h
-@@ -132,9 +132,9 @@ asmlinkage __printf(1, 2) __cold
- int printk(const char *fmt, ...);
-
- /*
-- * Special printk facility for scheduler use only, _DO_NOT_USE_ !
-+ * Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
- */
--__printf(1, 2) __cold int printk_sched(const char *fmt, ...);
-+__printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
-
- /*
- * Please don't use printk_ratelimit(), because it shares ratelimiting state
-@@ -169,7 +169,7 @@ int printk(const char *s, ...)
- return 0;
- }
- static inline __printf(1, 2) __cold
--int printk_sched(const char *s, ...)
-+int printk_deferred(const char *s, ...)
- {
- return 0;
- }
-diff --git a/init/main.c b/init/main.c
-index 9c7fd4c9249f..58c132d7de4b 100644
---- a/init/main.c
-+++ b/init/main.c
-@@ -617,6 +617,10 @@ asmlinkage void __init start_kernel(void)
- if (efi_enabled(EFI_RUNTIME_SERVICES))
- efi_enter_virtual_mode();
- #endif
-+#ifdef CONFIG_X86_ESPFIX64
-+ /* Should be run before the first non-init thread is created */
-+ init_espfix_bsp();
-+#endif
- thread_info_cache_init();
- cred_init();
- fork_init(totalram_pages);
-diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
-index 4dae9cbe9259..8c086e6049b9 100644
---- a/kernel/printk/printk.c
-+++ b/kernel/printk/printk.c
-@@ -2468,7 +2468,7 @@ void wake_up_klogd(void)
- preempt_enable();
- }
-
--int printk_sched(const char *fmt, ...)
-+int printk_deferred(const char *fmt, ...)
- {
- unsigned long flags;
- va_list args;
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 0aae0fcec026..515e212421c0 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -1322,7 +1322,7 @@ out:
- * leave kernel.
- */
- if (p->mm && printk_ratelimit()) {
-- printk_sched("process %d (%s) no longer affine to cpu%d\n",
-+ printk_deferred("process %d (%s) no longer affine to cpu%d\n",
- task_pid_nr(p), p->comm, cpu);
- }
- }
-diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
-index ce852643854b..37dac98c0749 100644
---- a/kernel/sched/deadline.c
-+++ b/kernel/sched/deadline.c
-@@ -329,7 +329,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,
-
- if (!lag_once) {
- lag_once = true;
-- printk_sched("sched: DL replenish lagged to much\n");
-+ printk_deferred("sched: DL replenish lagged to much\n");
- }
- dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline;
- dl_se->runtime = pi_se->dl_runtime;
-diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
-index 1999021042c7..27b8e836307f 100644
---- a/kernel/sched/rt.c
-+++ b/kernel/sched/rt.c
-@@ -837,7 +837,7 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
-
- if (!once) {
- once = true;
-- printk_sched("sched: RT throttling activated\n");
-+ printk_deferred("sched: RT throttling activated\n");
- }
- } else {
- /*
-diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
-index 086ad6043bcb..60ba1af801c3 100644
---- a/kernel/time/clockevents.c
-+++ b/kernel/time/clockevents.c
-@@ -146,7 +146,8 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev)
- {
- /* Nothing to do if we already reached the limit */
- if (dev->min_delta_ns >= MIN_DELTA_LIMIT) {
-- printk(KERN_WARNING "CE: Reprogramming failure. Giving up\n");
-+ printk_deferred(KERN_WARNING
-+ "CE: Reprogramming failure. Giving up\n");
- dev->next_event.tv64 = KTIME_MAX;
- return -ETIME;
- }
-@@ -159,9 +160,10 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev)
- if (dev->min_delta_ns > MIN_DELTA_LIMIT)
- dev->min_delta_ns = MIN_DELTA_LIMIT;
-
-- printk(KERN_WARNING "CE: %s increased min_delta_ns to %llu nsec\n",
-- dev->name ? dev->name : "?",
-- (unsigned long long) dev->min_delta_ns);
-+ printk_deferred(KERN_WARNING
-+ "CE: %s increased min_delta_ns to %llu nsec\n",
-+ dev->name ? dev->name : "?",
-+ (unsigned long long) dev->min_delta_ns);
- return 0;
- }
-
-diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
-index 4d23dc4d8139..313a662911b1 100644
---- a/kernel/time/sched_clock.c
-+++ b/kernel/time/sched_clock.c
-@@ -204,7 +204,8 @@ void __init sched_clock_postinit(void)
-
- static int sched_clock_suspend(void)
- {
-- sched_clock_poll(&sched_clock_timer);
-+ update_sched_clock();
-+ hrtimer_cancel(&sched_clock_timer);
- cd.suspended = true;
- return 0;
- }
-@@ -212,6 +213,7 @@ static int sched_clock_suspend(void)
- static void sched_clock_resume(void)
- {
- cd.epoch_cyc = read_sched_clock();
-+ hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL);
- cd.suspended = false;
- }
-
-diff --git a/lib/btree.c b/lib/btree.c
-index f9a484676cb6..4264871ea1a0 100644
---- a/lib/btree.c
-+++ b/lib/btree.c
-@@ -198,6 +198,7 @@ EXPORT_SYMBOL_GPL(btree_init);
-
- void btree_destroy(struct btree_head *head)
- {
-+ mempool_free(head->node, head->mempool);
- mempool_destroy(head->mempool);
- head->mempool = NULL;
- }
-diff --git a/mm/memcontrol.c b/mm/memcontrol.c
-index 5b6b0039f725..9b35da28b587 100644
---- a/mm/memcontrol.c
-+++ b/mm/memcontrol.c
-@@ -5670,8 +5670,12 @@ static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg)
- {
- struct mem_cgroup_eventfd_list *ev;
-
-+ spin_lock(&memcg_oom_lock);
-+
- list_for_each_entry(ev, &memcg->oom_notify, list)
- eventfd_signal(ev->eventfd, 1);
-+
-+ spin_unlock(&memcg_oom_lock);
- return 0;
- }
-
-diff --git a/mm/page-writeback.c b/mm/page-writeback.c
-index d013dba21429..9f45f87a5859 100644
---- a/mm/page-writeback.c
-+++ b/mm/page-writeback.c
-@@ -1324,9 +1324,9 @@ static inline void bdi_dirty_limits(struct backing_dev_info *bdi,
- *bdi_thresh = bdi_dirty_limit(bdi, dirty_thresh);
-
- if (bdi_bg_thresh)
-- *bdi_bg_thresh = div_u64((u64)*bdi_thresh *
-- background_thresh,
-- dirty_thresh);
-+ *bdi_bg_thresh = dirty_thresh ? div_u64((u64)*bdi_thresh *
-+ background_thresh,
-+ dirty_thresh) : 0;
-
- /*
- * In order to avoid the stacked BDI deadlock we need
-diff --git a/mm/page_alloc.c b/mm/page_alloc.c
-index 7e7f94755ab5..62e400d00e3f 100644
---- a/mm/page_alloc.c
-+++ b/mm/page_alloc.c
-@@ -2434,7 +2434,7 @@ static inline int
- gfp_to_alloc_flags(gfp_t gfp_mask)
- {
- int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET;
-- const gfp_t wait = gfp_mask & __GFP_WAIT;
-+ const bool atomic = !(gfp_mask & (__GFP_WAIT | __GFP_NO_KSWAPD));
-
- /* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */
- BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH);
-@@ -2443,20 +2443,20 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
- * The caller may dip into page reserves a bit more if the caller
- * cannot run direct reclaim, or if the caller has realtime scheduling
- * policy or is asking for __GFP_HIGH memory. GFP_ATOMIC requests will
-- * set both ALLOC_HARDER (!wait) and ALLOC_HIGH (__GFP_HIGH).
-+ * set both ALLOC_HARDER (atomic == true) and ALLOC_HIGH (__GFP_HIGH).
- */
- alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH);
-
-- if (!wait) {
-+ if (atomic) {
- /*
-- * Not worth trying to allocate harder for
-- * __GFP_NOMEMALLOC even if it can't schedule.
-+ * Not worth trying to allocate harder for __GFP_NOMEMALLOC even
-+ * if it can't schedule.
- */
-- if (!(gfp_mask & __GFP_NOMEMALLOC))
-+ if (!(gfp_mask & __GFP_NOMEMALLOC))
- alloc_flags |= ALLOC_HARDER;
- /*
-- * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc.
-- * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
-+ * Ignore cpuset mems for GFP_ATOMIC rather than fail, see the
-+ * comment for __cpuset_node_allowed_softwall().
- */
- alloc_flags &= ~ALLOC_CPUSET;
- } else if (unlikely(rt_task(current)) && !in_interrupt())
-diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
-index ec6606325cda..1e05bbde47ba 100644
---- a/net/l2tp/l2tp_ppp.c
-+++ b/net/l2tp/l2tp_ppp.c
-@@ -1368,7 +1368,7 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname,
- int err;
-
- if (level != SOL_PPPOL2TP)
-- return udp_prot.setsockopt(sk, level, optname, optval, optlen);
-+ return -EINVAL;
-
- if (optlen < sizeof(int))
- return -EINVAL;
-@@ -1494,7 +1494,7 @@ static int pppol2tp_getsockopt(struct socket *sock, int level, int optname,
- struct pppol2tp_session *ps;
-
- if (level != SOL_PPPOL2TP)
-- return udp_prot.getsockopt(sk, level, optname, optval, optlen);
-+ return -EINVAL;
-
- if (get_user(len, optlen))
- return -EFAULT;
-diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
-index c14c16a6d62d..e5a7ac2f3687 100644
---- a/net/mac80211/tx.c
-+++ b/net/mac80211/tx.c
-@@ -414,6 +414,9 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
- if (ieee80211_has_order(hdr->frame_control))
- return TX_CONTINUE;
-
-+ if (ieee80211_is_probe_req(hdr->frame_control))
-+ return TX_CONTINUE;
-+
- if (tx->local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
- info->hw_queue = tx->sdata->vif.cab_queue;
-
-@@ -464,6 +467,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
- {
- struct sta_info *sta = tx->sta;
- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
-+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
- struct ieee80211_local *local = tx->local;
-
- if (unlikely(!sta))
-@@ -474,6 +478,15 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
- !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {
- int ac = skb_get_queue_mapping(tx->skb);
-
-+ /* only deauth, disassoc and action are bufferable MMPDUs */
-+ if (ieee80211_is_mgmt(hdr->frame_control) &&
-+ !ieee80211_is_deauth(hdr->frame_control) &&
-+ !ieee80211_is_disassoc(hdr->frame_control) &&
-+ !ieee80211_is_action(hdr->frame_control)) {
-+ info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
-+ return TX_CONTINUE;
-+ }
-+
- ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n",
- sta->sta.addr, sta->sta.aid, ac);
- if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
-@@ -532,22 +545,8 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
- static ieee80211_tx_result debug_noinline
- ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx)
- {
-- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
-- struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
--
- if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED))
- return TX_CONTINUE;
--
-- /* only deauth, disassoc and action are bufferable MMPDUs */
-- if (ieee80211_is_mgmt(hdr->frame_control) &&
-- !ieee80211_is_deauth(hdr->frame_control) &&
-- !ieee80211_is_disassoc(hdr->frame_control) &&
-- !ieee80211_is_action(hdr->frame_control)) {
-- if (tx->flags & IEEE80211_TX_UNICAST)
-- info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
-- return TX_CONTINUE;
-- }
--
- if (tx->flags & IEEE80211_TX_UNICAST)
- return ieee80211_tx_h_unicast_ps_buf(tx);
- else
-diff --git a/net/wireless/trace.h b/net/wireless/trace.h
-index fbcc23edee54..b89eb3990f0a 100644
---- a/net/wireless/trace.h
-+++ b/net/wireless/trace.h
-@@ -2068,7 +2068,8 @@ TRACE_EVENT(cfg80211_michael_mic_failure,
- MAC_ASSIGN(addr, addr);
- __entry->key_type = key_type;
- __entry->key_id = key_id;
-- memcpy(__entry->tsc, tsc, 6);
-+ if (tsc)
-+ memcpy(__entry->tsc, tsc, 6);
- ),
- TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm",
- NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type,
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.16-17.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.16-17.patch
deleted file mode 100644
index 19c672077f..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.16-17.patch
+++ /dev/null
@@ -1,1765 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 8b22e24a2d8e..12aac0325888 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 16
-+SUBLEVEL = 17
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
-index 0f9e94537eee..1a49ffdf9da9 100644
---- a/arch/sparc/include/asm/pgtable_64.h
-+++ b/arch/sparc/include/asm/pgtable_64.h
-@@ -24,7 +24,8 @@
-
- /* The kernel image occupies 0x4000000 to 0x6000000 (4MB --> 96MB).
- * The page copy blockops can use 0x6000000 to 0x8000000.
-- * The TSB is mapped in the 0x8000000 to 0xa000000 range.
-+ * The 8K TSB is mapped in the 0x8000000 to 0x8400000 range.
-+ * The 4M TSB is mapped in the 0x8400000 to 0x8800000 range.
- * The PROM resides in an area spanning 0xf0000000 to 0x100000000.
- * The vmalloc area spans 0x100000000 to 0x200000000.
- * Since modules need to be in the lowest 32-bits of the address space,
-@@ -33,7 +34,8 @@
- * 0x400000000.
- */
- #define TLBTEMP_BASE _AC(0x0000000006000000,UL)
--#define TSBMAP_BASE _AC(0x0000000008000000,UL)
-+#define TSBMAP_8K_BASE _AC(0x0000000008000000,UL)
-+#define TSBMAP_4M_BASE _AC(0x0000000008400000,UL)
- #define MODULES_VADDR _AC(0x0000000010000000,UL)
- #define MODULES_LEN _AC(0x00000000e0000000,UL)
- #define MODULES_END _AC(0x00000000f0000000,UL)
-@@ -71,6 +73,23 @@
-
- #include
-
-+extern unsigned long sparc64_valid_addr_bitmap[];
-+
-+/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
-+static inline bool __kern_addr_valid(unsigned long paddr)
-+{
-+ if ((paddr >> MAX_PHYS_ADDRESS_BITS) != 0UL)
-+ return false;
-+ return test_bit(paddr >> ILOG2_4MB, sparc64_valid_addr_bitmap);
-+}
-+
-+static inline bool kern_addr_valid(unsigned long addr)
-+{
-+ unsigned long paddr = __pa(addr);
-+
-+ return __kern_addr_valid(paddr);
-+}
-+
- /* Entries per page directory level. */
- #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-3))
- #define PTRS_PER_PMD (1UL << PMD_BITS)
-@@ -79,9 +98,12 @@
- /* Kernel has a separate 44bit address space. */
- #define FIRST_USER_ADDRESS 0
-
--#define pte_ERROR(e) __builtin_trap()
--#define pmd_ERROR(e) __builtin_trap()
--#define pgd_ERROR(e) __builtin_trap()
-+#define pmd_ERROR(e) \
-+ pr_err("%s:%d: bad pmd %p(%016lx) seen at (%pS)\n", \
-+ __FILE__, __LINE__, &(e), pmd_val(e), __builtin_return_address(0))
-+#define pgd_ERROR(e) \
-+ pr_err("%s:%d: bad pgd %p(%016lx) seen at (%pS)\n", \
-+ __FILE__, __LINE__, &(e), pgd_val(e), __builtin_return_address(0))
-
- #endif /* !(__ASSEMBLY__) */
-
-@@ -258,8 +280,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t prot)
- {
- unsigned long mask, tmp;
-
-- /* SUN4U: 0x600307ffffffecb8 (negated == 0x9ffcf80000001347)
-- * SUN4V: 0x30ffffffffffee17 (negated == 0xcf000000000011e8)
-+ /* SUN4U: 0x630107ffffffec38 (negated == 0x9cfef800000013c7)
-+ * SUN4V: 0x33ffffffffffee07 (negated == 0xcc000000000011f8)
- *
- * Even if we use negation tricks the result is still a 6
- * instruction sequence, so don't try to play fancy and just
-@@ -289,10 +311,10 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t prot)
- " .previous\n"
- : "=r" (mask), "=r" (tmp)
- : "i" (_PAGE_PADDR_4U | _PAGE_MODIFIED_4U | _PAGE_ACCESSED_4U |
-- _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_E_4U | _PAGE_PRESENT_4U |
-+ _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_E_4U |
- _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4U),
- "i" (_PAGE_PADDR_4V | _PAGE_MODIFIED_4V | _PAGE_ACCESSED_4V |
-- _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_E_4V | _PAGE_PRESENT_4V |
-+ _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_E_4V |
- _PAGE_SPECIAL | _PAGE_PMD_HUGE | _PAGE_SZALL_4V));
-
- return __pte((pte_val(pte) & mask) | (pgprot_val(prot) & ~mask));
-@@ -633,7 +655,7 @@ static inline unsigned long pmd_large(pmd_t pmd)
- {
- pte_t pte = __pte(pmd_val(pmd));
-
-- return (pte_val(pte) & _PAGE_PMD_HUGE) && pte_present(pte);
-+ return pte_val(pte) & _PAGE_PMD_HUGE;
- }
-
- #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-@@ -719,20 +741,6 @@ static inline pmd_t pmd_mkwrite(pmd_t pmd)
- return __pmd(pte_val(pte));
- }
-
--static inline pmd_t pmd_mknotpresent(pmd_t pmd)
--{
-- unsigned long mask;
--
-- if (tlb_type == hypervisor)
-- mask = _PAGE_PRESENT_4V;
-- else
-- mask = _PAGE_PRESENT_4U;
--
-- pmd_val(pmd) &= ~mask;
--
-- return pmd;
--}
--
- static inline pmd_t pmd_mksplitting(pmd_t pmd)
- {
- pte_t pte = __pte(pmd_val(pmd));
-@@ -757,6 +765,20 @@ static inline int pmd_present(pmd_t pmd)
-
- #define pmd_none(pmd) (!pmd_val(pmd))
-
-+/* pmd_bad() is only called on non-trans-huge PMDs. Our encoding is
-+ * very simple, it's just the physical address. PTE tables are of
-+ * size PAGE_SIZE so make sure the sub-PAGE_SIZE bits are clear and
-+ * the top bits outside of the range of any physical address size we
-+ * support are clear as well. We also validate the physical itself.
-+ */
-+#define pmd_bad(pmd) ((pmd_val(pmd) & ~PAGE_MASK) || \
-+ !__kern_addr_valid(pmd_val(pmd)))
-+
-+#define pud_none(pud) (!pud_val(pud))
-+
-+#define pud_bad(pud) ((pud_val(pud) & ~PAGE_MASK) || \
-+ !__kern_addr_valid(pud_val(pud)))
-+
- #ifdef CONFIG_TRANSPARENT_HUGEPAGE
- extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
- pmd_t *pmdp, pmd_t pmd);
-@@ -790,10 +812,7 @@ static inline unsigned long __pmd_page(pmd_t pmd)
- #define pud_page_vaddr(pud) \
- ((unsigned long) __va(pud_val(pud)))
- #define pud_page(pud) virt_to_page((void *)pud_page_vaddr(pud))
--#define pmd_bad(pmd) (0)
- #define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0UL)
--#define pud_none(pud) (!pud_val(pud))
--#define pud_bad(pud) (0)
- #define pud_present(pud) (pud_val(pud) != 0U)
- #define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
-
-@@ -893,6 +912,10 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
- extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
- pmd_t *pmd);
-
-+#define __HAVE_ARCH_PMDP_INVALIDATE
-+extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
-+ pmd_t *pmdp);
-+
- #define __HAVE_ARCH_PGTABLE_DEPOSIT
- extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
- pgtable_t pgtable);
-@@ -919,18 +942,6 @@ extern unsigned long pte_file(pte_t);
- extern pte_t pgoff_to_pte(unsigned long);
- #define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL)
-
--extern unsigned long sparc64_valid_addr_bitmap[];
--
--/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
--static inline bool kern_addr_valid(unsigned long addr)
--{
-- unsigned long paddr = __pa(addr);
--
-- if ((paddr >> 41UL) != 0UL)
-- return false;
-- return test_bit(paddr >> 22, sparc64_valid_addr_bitmap);
--}
--
- extern int page_in_phys_avail(unsigned long paddr);
-
- /*
-diff --git a/arch/sparc/include/asm/tlbflush_64.h b/arch/sparc/include/asm/tlbflush_64.h
-index 3c3c89f52643..7f9bab26a499 100644
---- a/arch/sparc/include/asm/tlbflush_64.h
-+++ b/arch/sparc/include/asm/tlbflush_64.h
-@@ -34,6 +34,8 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
- {
- }
-
-+void flush_tlb_kernel_range(unsigned long start, unsigned long end);
-+
- #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
-
- extern void flush_tlb_pending(void);
-@@ -48,11 +50,6 @@ extern void __flush_tlb_kernel_range(unsigned long start, unsigned long end);
-
- #ifndef CONFIG_SMP
-
--#define flush_tlb_kernel_range(start,end) \
--do { flush_tsb_kernel_range(start,end); \
-- __flush_tlb_kernel_range(start,end); \
--} while (0)
--
- static inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr)
- {
- __flush_tlb_page(CTX_HWBITS(mm->context), vaddr);
-@@ -63,11 +60,6 @@ static inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vad
- extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
- extern void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr);
-
--#define flush_tlb_kernel_range(start, end) \
--do { flush_tsb_kernel_range(start,end); \
-- smp_flush_tlb_kernel_range(start, end); \
--} while (0)
--
- #define global_flush_tlb_page(mm, vaddr) \
- smp_flush_tlb_page(mm, vaddr)
-
-diff --git a/arch/sparc/include/asm/tsb.h b/arch/sparc/include/asm/tsb.h
-index 2230f80d9fe3..90916f955cac 100644
---- a/arch/sparc/include/asm/tsb.h
-+++ b/arch/sparc/include/asm/tsb.h
-@@ -171,7 +171,8 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- andcc REG1, REG2, %g0; \
- be,pt %xcc, 700f; \
- sethi %hi(4 * 1024 * 1024), REG2; \
-- andn REG1, REG2, REG1; \
-+ brgez,pn REG1, FAIL_LABEL; \
-+ andn REG1, REG2, REG1; \
- and VADDR, REG2, REG2; \
- brlz,pt REG1, PTE_LABEL; \
- or REG1, REG2, REG1; \
-diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
-index 26b706a1867d..452f04fe8da6 100644
---- a/arch/sparc/kernel/head_64.S
-+++ b/arch/sparc/kernel/head_64.S
-@@ -282,8 +282,8 @@ sun4v_chip_type:
- stx %l2, [%l4 + 0x0]
- ldx [%sp + 2047 + 128 + 0x50], %l3 ! physaddr low
- /* 4MB align */
-- srlx %l3, 22, %l3
-- sllx %l3, 22, %l3
-+ srlx %l3, ILOG2_4MB, %l3
-+ sllx %l3, ILOG2_4MB, %l3
- stx %l3, [%l4 + 0x8]
-
- /* Leave service as-is, "call-method" */
-diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
-index 542e96ac4d39..605d49204580 100644
---- a/arch/sparc/kernel/ktlb.S
-+++ b/arch/sparc/kernel/ktlb.S
-@@ -277,7 +277,7 @@ kvmap_dtlb_load:
- #ifdef CONFIG_SPARSEMEM_VMEMMAP
- kvmap_vmemmap:
- sub %g4, %g5, %g5
-- srlx %g5, 22, %g5
-+ srlx %g5, ILOG2_4MB, %g5
- sethi %hi(vmemmap_table), %g1
- sllx %g5, 3, %g5
- or %g1, %lo(vmemmap_table), %g1
-diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c
-index e01d75d40329..66dacd56bb10 100644
---- a/arch/sparc/kernel/ldc.c
-+++ b/arch/sparc/kernel/ldc.c
-@@ -1336,7 +1336,7 @@ int ldc_connect(struct ldc_channel *lp)
- if (!(lp->flags & LDC_FLAG_ALLOCED_QUEUES) ||
- !(lp->flags & LDC_FLAG_REGISTERED_QUEUES) ||
- lp->hs_state != LDC_HS_OPEN)
-- err = -EINVAL;
-+ err = ((lp->hs_state > LDC_HS_OPEN) ? 0 : -EINVAL);
- else
- err = start_handshake(lp);
-
-diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
-index b085311dcd0e..8416d7fadcce 100644
---- a/arch/sparc/kernel/smp_64.c
-+++ b/arch/sparc/kernel/smp_64.c
-@@ -151,7 +151,7 @@ void cpu_panic(void)
- #define NUM_ROUNDS 64 /* magic value */
- #define NUM_ITERS 5 /* likewise */
-
--static DEFINE_SPINLOCK(itc_sync_lock);
-+static DEFINE_RAW_SPINLOCK(itc_sync_lock);
- static unsigned long go[SLAVE + 1];
-
- #define DEBUG_TICK_SYNC 0
-@@ -259,7 +259,7 @@ static void smp_synchronize_one_tick(int cpu)
- go[MASTER] = 0;
- membar_safe("#StoreLoad");
-
-- spin_lock_irqsave(&itc_sync_lock, flags);
-+ raw_spin_lock_irqsave(&itc_sync_lock, flags);
- {
- for (i = 0; i < NUM_ROUNDS*NUM_ITERS; i++) {
- while (!go[MASTER])
-@@ -270,7 +270,7 @@ static void smp_synchronize_one_tick(int cpu)
- membar_safe("#StoreLoad");
- }
- }
-- spin_unlock_irqrestore(&itc_sync_lock, flags);
-+ raw_spin_unlock_irqrestore(&itc_sync_lock, flags);
- }
-
- #if defined(CONFIG_SUN_LDOMS) && defined(CONFIG_HOTPLUG_CPU)
-diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S
-index f7c72b6efc27..d066eb18650c 100644
---- a/arch/sparc/kernel/sys32.S
-+++ b/arch/sparc/kernel/sys32.S
-@@ -44,7 +44,7 @@ SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1)
- SIGN1(sys32_io_submit, compat_sys_io_submit, %o1)
- SIGN1(sys32_mq_open, compat_sys_mq_open, %o1)
- SIGN1(sys32_select, compat_sys_select, %o0)
--SIGN3(sys32_futex, compat_sys_futex, %o1, %o2, %o5)
-+SIGN1(sys32_futex, compat_sys_futex, %o1)
- SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0)
- SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0)
- SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
-diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
-index 3c1a7cb31579..35ab8b60d256 100644
---- a/arch/sparc/kernel/unaligned_64.c
-+++ b/arch/sparc/kernel/unaligned_64.c
-@@ -166,17 +166,23 @@ static unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs)
- unsigned long compute_effective_address(struct pt_regs *regs,
- unsigned int insn, unsigned int rd)
- {
-+ int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
- unsigned int rs1 = (insn >> 14) & 0x1f;
- unsigned int rs2 = insn & 0x1f;
-- int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
-+ unsigned long addr;
-
- if (insn & 0x2000) {
- maybe_flush_windows(rs1, 0, rd, from_kernel);
-- return (fetch_reg(rs1, regs) + sign_extend_imm13(insn));
-+ addr = (fetch_reg(rs1, regs) + sign_extend_imm13(insn));
- } else {
- maybe_flush_windows(rs1, rs2, rd, from_kernel);
-- return (fetch_reg(rs1, regs) + fetch_reg(rs2, regs));
-+ addr = (fetch_reg(rs1, regs) + fetch_reg(rs2, regs));
- }
-+
-+ if (!from_kernel && test_thread_flag(TIF_32BIT))
-+ addr &= 0xffffffff;
-+
-+ return addr;
- }
-
- /* This is just to make gcc think die_if_kernel does return... */
-diff --git a/arch/sparc/lib/NG2memcpy.S b/arch/sparc/lib/NG2memcpy.S
-index 2c20ad63ddbf..30eee6e8a81b 100644
---- a/arch/sparc/lib/NG2memcpy.S
-+++ b/arch/sparc/lib/NG2memcpy.S
-@@ -236,6 +236,7 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
- */
- VISEntryHalf
-
-+ membar #Sync
- alignaddr %o1, %g0, %g0
-
- add %o1, (64 - 1), %o4
-diff --git a/arch/sparc/math-emu/math_32.c b/arch/sparc/math-emu/math_32.c
-index aa4d55b0bdf0..5ce8f2f64604 100644
---- a/arch/sparc/math-emu/math_32.c
-+++ b/arch/sparc/math-emu/math_32.c
-@@ -499,7 +499,7 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
- case 0: fsr = *pfsr;
- if (IR == -1) IR = 2;
- /* fcc is always fcc0 */
-- fsr &= ~0xc00; fsr |= (IR << 10); break;
-+ fsr &= ~0xc00; fsr |= (IR << 10);
- *pfsr = fsr;
- break;
- case 1: rd->s = IR; break;
-diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
-index 69bb818fdd79..4ced3fc66130 100644
---- a/arch/sparc/mm/fault_64.c
-+++ b/arch/sparc/mm/fault_64.c
-@@ -96,38 +96,51 @@ static unsigned int get_user_insn(unsigned long tpc)
- pte_t *ptep, pte;
- unsigned long pa;
- u32 insn = 0;
-- unsigned long pstate;
-
-- if (pgd_none(*pgdp))
-- goto outret;
-+ if (pgd_none(*pgdp) || unlikely(pgd_bad(*pgdp)))
-+ goto out;
- pudp = pud_offset(pgdp, tpc);
-- if (pud_none(*pudp))
-- goto outret;
-- pmdp = pmd_offset(pudp, tpc);
-- if (pmd_none(*pmdp))
-- goto outret;
-+ if (pud_none(*pudp) || unlikely(pud_bad(*pudp)))
-+ goto out;
-
- /* This disables preemption for us as well. */
-- __asm__ __volatile__("rdpr %%pstate, %0" : "=r" (pstate));
-- __asm__ __volatile__("wrpr %0, %1, %%pstate"
-- : : "r" (pstate), "i" (PSTATE_IE));
-- ptep = pte_offset_map(pmdp, tpc);
-- pte = *ptep;
-- if (!pte_present(pte))
-- goto out;
-+ local_irq_disable();
-+
-+ pmdp = pmd_offset(pudp, tpc);
-+ if (pmd_none(*pmdp) || unlikely(pmd_bad(*pmdp)))
-+ goto out_irq_enable;
-
-- pa = (pte_pfn(pte) << PAGE_SHIFT);
-- pa += (tpc & ~PAGE_MASK);
-+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-+ if (pmd_trans_huge(*pmdp)) {
-+ if (pmd_trans_splitting(*pmdp))
-+ goto out_irq_enable;
-
-- /* Use phys bypass so we don't pollute dtlb/dcache. */
-- __asm__ __volatile__("lduwa [%1] %2, %0"
-- : "=r" (insn)
-- : "r" (pa), "i" (ASI_PHYS_USE_EC));
-+ pa = pmd_pfn(*pmdp) << PAGE_SHIFT;
-+ pa += tpc & ~HPAGE_MASK;
-
-+ /* Use phys bypass so we don't pollute dtlb/dcache. */
-+ __asm__ __volatile__("lduwa [%1] %2, %0"
-+ : "=r" (insn)
-+ : "r" (pa), "i" (ASI_PHYS_USE_EC));
-+ } else
-+#endif
-+ {
-+ ptep = pte_offset_map(pmdp, tpc);
-+ pte = *ptep;
-+ if (pte_present(pte)) {
-+ pa = (pte_pfn(pte) << PAGE_SHIFT);
-+ pa += (tpc & ~PAGE_MASK);
-+
-+ /* Use phys bypass so we don't pollute dtlb/dcache. */
-+ __asm__ __volatile__("lduwa [%1] %2, %0"
-+ : "=r" (insn)
-+ : "r" (pa), "i" (ASI_PHYS_USE_EC));
-+ }
-+ pte_unmap(ptep);
-+ }
-+out_irq_enable:
-+ local_irq_enable();
- out:
-- pte_unmap(ptep);
-- __asm__ __volatile__("wrpr %0, 0x0, %%pstate" : : "r" (pstate));
--outret:
- return insn;
- }
-
-@@ -153,7 +166,8 @@ show_signal_msg(struct pt_regs *regs, int sig, int code,
- }
-
- static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
-- unsigned int insn, int fault_code)
-+ unsigned long fault_addr, unsigned int insn,
-+ int fault_code)
- {
- unsigned long addr;
- siginfo_t info;
-@@ -161,10 +175,18 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
- info.si_code = code;
- info.si_signo = sig;
- info.si_errno = 0;
-- if (fault_code & FAULT_CODE_ITLB)
-+ if (fault_code & FAULT_CODE_ITLB) {
- addr = regs->tpc;
-- else
-- addr = compute_effective_address(regs, insn, 0);
-+ } else {
-+ /* If we were able to probe the faulting instruction, use it
-+ * to compute a precise fault address. Otherwise use the fault
-+ * time provided address which may only have page granularity.
-+ */
-+ if (insn)
-+ addr = compute_effective_address(regs, insn, 0);
-+ else
-+ addr = fault_addr;
-+ }
- info.si_addr = (void __user *) addr;
- info.si_trapno = 0;
-
-@@ -239,7 +261,7 @@ static void __kprobes do_kernel_fault(struct pt_regs *regs, int si_code,
- /* The si_code was set to make clear whether
- * this was a SEGV_MAPERR or SEGV_ACCERR fault.
- */
-- do_fault_siginfo(si_code, SIGSEGV, regs, insn, fault_code);
-+ do_fault_siginfo(si_code, SIGSEGV, regs, address, insn, fault_code);
- return;
- }
-
-@@ -259,18 +281,6 @@ static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
- show_regs(regs);
- }
-
--static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
-- unsigned long addr)
--{
-- static int times;
--
-- if (times++ < 10)
-- printk(KERN_ERR "FAULT[%s:%d]: 32-bit process "
-- "reports 64-bit fault address [%lx]\n",
-- current->comm, current->pid, addr);
-- show_regs(regs);
--}
--
- asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
- {
- enum ctx_state prev_state = exception_enter();
-@@ -300,10 +310,8 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
- goto intr_or_no_mm;
- }
- }
-- if (unlikely((address >> 32) != 0)) {
-- bogus_32bit_fault_address(regs, address);
-+ if (unlikely((address >> 32) != 0))
- goto intr_or_no_mm;
-- }
- }
-
- if (regs->tstate & TSTATE_PRIV) {
-@@ -525,7 +533,7 @@ do_sigbus:
- * Send a sigbus, regardless of whether we were in kernel
- * or user mode.
- */
-- do_fault_siginfo(BUS_ADRERR, SIGBUS, regs, insn, fault_code);
-+ do_fault_siginfo(BUS_ADRERR, SIGBUS, regs, address, insn, fault_code);
-
- /* Kernel mode? Handle exceptions or die */
- if (regs->tstate & TSTATE_PRIV)
-diff --git a/arch/sparc/mm/gup.c b/arch/sparc/mm/gup.c
-index c4d3da68b800..1aed0432c64b 100644
---- a/arch/sparc/mm/gup.c
-+++ b/arch/sparc/mm/gup.c
-@@ -73,7 +73,7 @@ static int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
- struct page *head, *page, *tail;
- int refs;
-
-- if (!pmd_large(pmd))
-+ if (!(pmd_val(pmd) & _PAGE_VALID))
- return 0;
-
- if (write && !pmd_write(pmd))
-diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
-index eafbc65c9c47..96862241b342 100644
---- a/arch/sparc/mm/init_64.c
-+++ b/arch/sparc/mm/init_64.c
-@@ -350,6 +350,10 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *
-
- mm = vma->vm_mm;
-
-+ /* Don't insert a non-valid PTE into the TSB, we'll deadlock. */
-+ if (!pte_accessible(mm, pte))
-+ return;
-+
- spin_lock_irqsave(&mm->context.lock, flags);
-
- #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
-@@ -588,7 +592,7 @@ static void __init remap_kernel(void)
- int i, tlb_ent = sparc64_highest_locked_tlbent();
-
- tte_vaddr = (unsigned long) KERNBASE;
-- phys_page = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
-+ phys_page = (prom_boot_mapping_phys_low >> ILOG2_4MB) << ILOG2_4MB;
- tte_data = kern_large_tte(phys_page);
-
- kern_locked_tte_data = tte_data;
-@@ -1881,7 +1885,7 @@ void __init paging_init(void)
-
- BUILD_BUG_ON(NR_CPUS > 4096);
-
-- kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
-+ kern_base = (prom_boot_mapping_phys_low >> ILOG2_4MB) << ILOG2_4MB;
- kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
-
- /* Invalidate both kernel TSBs. */
-@@ -1937,7 +1941,7 @@ void __init paging_init(void)
- shift = kern_base + PAGE_OFFSET - ((unsigned long)KERNBASE);
-
- real_end = (unsigned long)_end;
-- num_kernel_image_mappings = DIV_ROUND_UP(real_end - KERNBASE, 1 << 22);
-+ num_kernel_image_mappings = DIV_ROUND_UP(real_end - KERNBASE, 1 << ILOG2_4MB);
- printk("Kernel: Using %d locked TLB entries for main kernel image.\n",
- num_kernel_image_mappings);
-
-@@ -2094,7 +2098,7 @@ static void __init setup_valid_addr_bitmap_from_pavail(unsigned long *bitmap)
-
- if (new_start <= old_start &&
- new_end >= (old_start + PAGE_SIZE)) {
-- set_bit(old_start >> 22, bitmap);
-+ set_bit(old_start >> ILOG2_4MB, bitmap);
- goto do_next_page;
- }
- }
-@@ -2143,7 +2147,7 @@ void __init mem_init(void)
- addr = PAGE_OFFSET + kern_base;
- last = PAGE_ALIGN(kern_size) + addr;
- while (addr < last) {
-- set_bit(__pa(addr) >> 22, sparc64_valid_addr_bitmap);
-+ set_bit(__pa(addr) >> ILOG2_4MB, sparc64_valid_addr_bitmap);
- addr += PAGE_SIZE;
- }
-
-@@ -2267,7 +2271,7 @@ int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend,
- void *block;
-
- if (!(*vmem_pp & _PAGE_VALID)) {
-- block = vmemmap_alloc_block(1UL << 22, node);
-+ block = vmemmap_alloc_block(1UL << ILOG2_4MB, node);
- if (!block)
- return -ENOMEM;
-
-@@ -2614,6 +2618,10 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
-
- pte = pmd_val(entry);
-
-+ /* Don't insert a non-valid PMD into the TSB, we'll deadlock. */
-+ if (!(pte & _PAGE_VALID))
-+ return;
-+
- /* We are fabricating 8MB pages using 4MB real hw pages. */
- pte |= (addr & (1UL << REAL_HPAGE_SHIFT));
-
-@@ -2694,3 +2702,26 @@ void hugetlb_setup(struct pt_regs *regs)
- }
- }
- #endif
-+
-+#ifdef CONFIG_SMP
-+#define do_flush_tlb_kernel_range smp_flush_tlb_kernel_range
-+#else
-+#define do_flush_tlb_kernel_range __flush_tlb_kernel_range
-+#endif
-+
-+void flush_tlb_kernel_range(unsigned long start, unsigned long end)
-+{
-+ if (start < HI_OBP_ADDRESS && end > LOW_OBP_ADDRESS) {
-+ if (start < LOW_OBP_ADDRESS) {
-+ flush_tsb_kernel_range(start, LOW_OBP_ADDRESS);
-+ do_flush_tlb_kernel_range(start, LOW_OBP_ADDRESS);
-+ }
-+ if (end > HI_OBP_ADDRESS) {
-+ flush_tsb_kernel_range(end, HI_OBP_ADDRESS);
-+ do_flush_tlb_kernel_range(end, HI_OBP_ADDRESS);
-+ }
-+ } else {
-+ flush_tsb_kernel_range(start, end);
-+ do_flush_tlb_kernel_range(start, end);
-+ }
-+}
-diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
-index b12cb5e72812..b89aba217e3b 100644
---- a/arch/sparc/mm/tlb.c
-+++ b/arch/sparc/mm/tlb.c
-@@ -134,7 +134,7 @@ no_cache_flush:
-
- #ifdef CONFIG_TRANSPARENT_HUGEPAGE
- static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr,
-- pmd_t pmd, bool exec)
-+ pmd_t pmd)
- {
- unsigned long end;
- pte_t *pte;
-@@ -142,8 +142,11 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr,
- pte = pte_offset_map(&pmd, vaddr);
- end = vaddr + HPAGE_SIZE;
- while (vaddr < end) {
-- if (pte_val(*pte) & _PAGE_VALID)
-+ if (pte_val(*pte) & _PAGE_VALID) {
-+ bool exec = pte_exec(*pte);
-+
- tlb_batch_add_one(mm, vaddr, exec);
-+ }
- pte++;
- vaddr += PAGE_SIZE;
- }
-@@ -177,19 +180,30 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
- }
-
- if (!pmd_none(orig)) {
-- pte_t orig_pte = __pte(pmd_val(orig));
-- bool exec = pte_exec(orig_pte);
--
- addr &= HPAGE_MASK;
- if (pmd_trans_huge(orig)) {
-+ pte_t orig_pte = __pte(pmd_val(orig));
-+ bool exec = pte_exec(orig_pte);
-+
- tlb_batch_add_one(mm, addr, exec);
- tlb_batch_add_one(mm, addr + REAL_HPAGE_SIZE, exec);
- } else {
-- tlb_batch_pmd_scan(mm, addr, orig, exec);
-+ tlb_batch_pmd_scan(mm, addr, orig);
- }
- }
- }
-
-+void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
-+ pmd_t *pmdp)
-+{
-+ pmd_t entry = *pmdp;
-+
-+ pmd_val(entry) &= ~_PAGE_VALID;
-+
-+ set_pmd_at(vma->vm_mm, address, pmdp, entry);
-+ flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
-+}
-+
- void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
- pgtable_t pgtable)
- {
-diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c
-index f5d506fdddad..fe19b81acc09 100644
---- a/arch/sparc/mm/tsb.c
-+++ b/arch/sparc/mm/tsb.c
-@@ -133,7 +133,19 @@ static void setup_tsb_params(struct mm_struct *mm, unsigned long tsb_idx, unsign
- mm->context.tsb_block[tsb_idx].tsb_nentries =
- tsb_bytes / sizeof(struct tsb);
-
-- base = TSBMAP_BASE;
-+ switch (tsb_idx) {
-+ case MM_TSB_BASE:
-+ base = TSBMAP_8K_BASE;
-+ break;
-+#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
-+ case MM_TSB_HUGE:
-+ base = TSBMAP_4M_BASE;
-+ break;
-+#endif
-+ default:
-+ BUG();
-+ }
-+
- tte = pgprot_val(PAGE_KERNEL_LOCKED);
- tsb_paddr = __pa(mm->context.tsb_block[tsb_idx].tsb);
- BUG_ON(tsb_paddr & (tsb_bytes - 1UL));
-diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
-index 391f29ef6d2e..1fbeaa9dd202 100644
---- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
-+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
-@@ -337,6 +337,7 @@ struct sw_tx_bd {
- u8 flags;
- /* Set on the first BD descriptor when there is a split BD */
- #define BNX2X_TSO_SPLIT_BD (1<<0)
-+#define BNX2X_HAS_SECOND_PBD (1<<1)
- };
-
- struct sw_rx_page {
-diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
-index 5ed512473b12..afa4a1f63270 100644
---- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
-+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
-@@ -223,6 +223,12 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
- --nbd;
- bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
-
-+ if (tx_buf->flags & BNX2X_HAS_SECOND_PBD) {
-+ /* Skip second parse bd... */
-+ --nbd;
-+ bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
-+ }
-+
- /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */
- if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) {
- tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd;
-@@ -3868,6 +3874,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
- /* set encapsulation flag in start BD */
- SET_FLAG(tx_start_bd->general_data,
- ETH_TX_START_BD_TUNNEL_EXIST, 1);
-+
-+ tx_buf->flags |= BNX2X_HAS_SECOND_PBD;
-+
- nbd++;
- } else if (xmit_type & XMIT_CSUM) {
- /* Set PBD in checksum offload case w/o encapsulation */
-diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
-index 4ad1187e82fb..669eeb4eb247 100644
---- a/drivers/net/ethernet/brocade/bna/bnad.c
-+++ b/drivers/net/ethernet/brocade/bna/bnad.c
-@@ -600,9 +600,9 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget)
- prefetch(bnad->netdev);
-
- cq = ccb->sw_q;
-- cmpl = &cq[ccb->producer_index];
-
- while (packets < budget) {
-+ cmpl = &cq[ccb->producer_index];
- if (!cmpl->valid)
- break;
- /* The 'valid' field is set by the adapter, only after writing
-diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
-index 5adecc5f52b7..7f1abb7c18f2 100644
---- a/drivers/net/macvlan.c
-+++ b/drivers/net/macvlan.c
-@@ -548,6 +548,7 @@ static int macvlan_init(struct net_device *dev)
- (lowerdev->state & MACVLAN_STATE_MASK);
- dev->features = lowerdev->features & MACVLAN_FEATURES;
- dev->features |= ALWAYS_ON_FEATURES;
-+ dev->vlan_features = lowerdev->vlan_features & MACVLAN_FEATURES;
- dev->gso_max_size = lowerdev->gso_max_size;
- dev->iflink = lowerdev->ifindex;
- dev->hard_header_len = lowerdev->hard_header_len;
-diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
-index 365375408904..25f74191a788 100644
---- a/drivers/net/phy/phy_device.c
-+++ b/drivers/net/phy/phy_device.c
-@@ -353,7 +353,7 @@ int phy_device_register(struct phy_device *phydev)
- phydev->bus->phy_map[phydev->addr] = phydev;
-
- /* Run all of the fixups for this PHY */
-- err = phy_init_hw(phydev);
-+ err = phy_scan_fixups(phydev);
- if (err) {
- pr_err("PHY %d failed to initialize\n", phydev->addr);
- goto out;
-diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
-index 01805319e1e0..1aff970be33e 100644
---- a/drivers/net/ppp/pptp.c
-+++ b/drivers/net/ppp/pptp.c
-@@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
- nf_reset(skb);
-
- skb->ip_summed = CHECKSUM_NONE;
-- ip_select_ident(skb, &rt->dst, NULL);
-+ ip_select_ident(skb, NULL);
- ip_send_check(iph);
-
- ip_local_out(skb);
-diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
-index 160e7510aca6..0787b9756165 100644
---- a/drivers/sbus/char/bbc_envctrl.c
-+++ b/drivers/sbus/char/bbc_envctrl.c
-@@ -452,6 +452,9 @@ static void attach_one_temp(struct bbc_i2c_bus *bp, struct platform_device *op,
- if (!tp)
- return;
-
-+ INIT_LIST_HEAD(&tp->bp_list);
-+ INIT_LIST_HEAD(&tp->glob_list);
-+
- tp->client = bbc_i2c_attach(bp, op);
- if (!tp->client) {
- kfree(tp);
-@@ -497,6 +500,9 @@ static void attach_one_fan(struct bbc_i2c_bus *bp, struct platform_device *op,
- if (!fp)
- return;
-
-+ INIT_LIST_HEAD(&fp->bp_list);
-+ INIT_LIST_HEAD(&fp->glob_list);
-+
- fp->client = bbc_i2c_attach(bp, op);
- if (!fp->client) {
- kfree(fp);
-diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
-index c7763e482eb2..812b5f0361b6 100644
---- a/drivers/sbus/char/bbc_i2c.c
-+++ b/drivers/sbus/char/bbc_i2c.c
-@@ -300,13 +300,18 @@ static struct bbc_i2c_bus * attach_one_i2c(struct platform_device *op, int index
- if (!bp)
- return NULL;
-
-+ INIT_LIST_HEAD(&bp->temps);
-+ INIT_LIST_HEAD(&bp->fans);
-+
- bp->i2c_control_regs = of_ioremap(&op->resource[0], 0, 0x2, "bbc_i2c_regs");
- if (!bp->i2c_control_regs)
- goto fail;
-
-- bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel");
-- if (!bp->i2c_bussel_reg)
-- goto fail;
-+ if (op->num_resources == 2) {
-+ bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel");
-+ if (!bp->i2c_bussel_reg)
-+ goto fail;
-+ }
-
- bp->waiting = 0;
- init_waitqueue_head(&bp->wq);
-diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
-index 80a58eca785b..e8f77606561b 100644
---- a/drivers/tty/serial/sunsab.c
-+++ b/drivers/tty/serial/sunsab.c
-@@ -157,6 +157,15 @@ receive_chars(struct uart_sunsab_port *up,
- (up->port.line == up->port.cons->index))
- saw_console_brk = 1;
-
-+ if (count == 0) {
-+ if (unlikely(stat->sreg.isr1 & SAB82532_ISR1_BRK)) {
-+ stat->sreg.isr0 &= ~(SAB82532_ISR0_PERR |
-+ SAB82532_ISR0_FERR);
-+ up->port.icount.brk++;
-+ uart_handle_break(&up->port);
-+ }
-+ }
-+
- for (i = 0; i < count; i++) {
- unsigned char ch = buf[i], flag;
-
-diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
-index b0f4ef77fa70..bf9781e9fd92 100644
---- a/fs/xfs/xfs_log.h
-+++ b/fs/xfs/xfs_log.h
-@@ -24,7 +24,8 @@ struct xfs_log_vec {
- struct xfs_log_iovec *lv_iovecp; /* iovec array */
- struct xfs_log_item *lv_item; /* owner */
- char *lv_buf; /* formatted buffer */
-- int lv_buf_len; /* size of formatted buffer */
-+ int lv_bytes; /* accounted space in buffer */
-+ int lv_buf_len; /* aligned size of buffer */
- int lv_size; /* size of allocated lv */
- };
-
-@@ -52,15 +53,21 @@ xlog_prepare_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
- return vec->i_addr;
- }
-
-+/*
-+ * We need to make sure the next buffer is naturally aligned for the biggest
-+ * basic data type we put into it. We already accounted for this padding when
-+ * sizing the buffer.
-+ *
-+ * However, this padding does not get written into the log, and hence we have to
-+ * track the space used by the log vectors separately to prevent log space hangs
-+ * due to inaccurate accounting (i.e. a leak) of the used log space through the
-+ * CIL context ticket.
-+ */
- static inline void
- xlog_finish_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec *vec, int len)
- {
-- /*
-- * We need to make sure the next buffer is naturally aligned for the
-- * biggest basic data type we put into it. We already accounted for
-- * this when sizing the buffer.
-- */
- lv->lv_buf_len += round_up(len, sizeof(uint64_t));
-+ lv->lv_bytes += len;
- vec->i_len = len;
- }
-
-diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
-index 4ef6fdbced78..bcfbaae4702c 100644
---- a/fs/xfs/xfs_log_cil.c
-+++ b/fs/xfs/xfs_log_cil.c
-@@ -97,7 +97,7 @@ xfs_cil_prepare_item(
- {
- /* Account for the new LV being passed in */
- if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED) {
-- *diff_len += lv->lv_buf_len;
-+ *diff_len += lv->lv_bytes;
- *diff_iovecs += lv->lv_niovecs;
- }
-
-@@ -111,7 +111,7 @@ xfs_cil_prepare_item(
- else if (old_lv != lv) {
- ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
-
-- *diff_len -= old_lv->lv_buf_len;
-+ *diff_len -= old_lv->lv_bytes;
- *diff_iovecs -= old_lv->lv_niovecs;
- kmem_free(old_lv);
- }
-@@ -239,7 +239,7 @@ xlog_cil_insert_format_items(
- * that the space reservation accounting is correct.
- */
- *diff_iovecs -= lv->lv_niovecs;
-- *diff_len -= lv->lv_buf_len;
-+ *diff_len -= lv->lv_bytes;
- } else {
- /* allocate new data chunk */
- lv = kmem_zalloc(buf_size, KM_SLEEP|KM_NOFS);
-@@ -259,6 +259,7 @@ xlog_cil_insert_format_items(
-
- /* The allocated data region lies beyond the iovec region */
- lv->lv_buf_len = 0;
-+ lv->lv_bytes = 0;
- lv->lv_buf = (char *)lv + buf_size - nbytes;
- ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
-
-diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
-index 058271bde27a..823ec7bb9c67 100644
---- a/include/net/inetpeer.h
-+++ b/include/net/inetpeer.h
-@@ -41,14 +41,13 @@ struct inet_peer {
- struct rcu_head gc_rcu;
- };
- /*
-- * Once inet_peer is queued for deletion (refcnt == -1), following fields
-- * are not available: rid, ip_id_count
-+ * Once inet_peer is queued for deletion (refcnt == -1), following field
-+ * is not available: rid
- * We can share memory with rcu_head to help keep inet_peer small.
- */
- union {
- struct {
- atomic_t rid; /* Frag reception counter */
-- atomic_t ip_id_count; /* IP ID for the next packet */
- };
- struct rcu_head rcu;
- struct inet_peer *gc_next;
-@@ -165,7 +164,7 @@ bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout);
- void inetpeer_invalidate_tree(struct inet_peer_base *);
-
- /*
-- * temporary check to make sure we dont access rid, ip_id_count, tcp_ts,
-+ * temporary check to make sure we dont access rid, tcp_ts,
- * tcp_ts_stamp if no refcount is taken on inet_peer
- */
- static inline void inet_peer_refcheck(const struct inet_peer *p)
-@@ -173,13 +172,4 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
- WARN_ON_ONCE(atomic_read(&p->refcnt) <= 0);
- }
-
--
--/* can be called with or without local BH being disabled */
--static inline int inet_getid(struct inet_peer *p, int more)
--{
-- more++;
-- inet_peer_refcheck(p);
-- return atomic_add_return(more, &p->ip_id_count) - more;
--}
--
- #endif /* _NET_INETPEER_H */
-diff --git a/include/net/ip.h b/include/net/ip.h
-index 23be0fd37937..937f19681426 100644
---- a/include/net/ip.h
-+++ b/include/net/ip.h
-@@ -297,9 +297,10 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
- }
- }
-
--void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
-+u32 ip_idents_reserve(u32 hash, int segs);
-+void __ip_select_ident(struct iphdr *iph, int segs);
-
--static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk)
-+static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, int segs)
- {
- struct iphdr *iph = ip_hdr(skb);
-
-@@ -309,24 +310,20 @@ static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, s
- * does not change, they drop every other packet in
- * a TCP stream using header compression.
- */
-- iph->id = (sk && inet_sk(sk)->inet_daddr) ?
-- htons(inet_sk(sk)->inet_id++) : 0;
-- } else
-- __ip_select_ident(iph, dst, 0);
--}
--
--static inline void ip_select_ident_more(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk, int more)
--{
-- struct iphdr *iph = ip_hdr(skb);
--
-- if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
- if (sk && inet_sk(sk)->inet_daddr) {
- iph->id = htons(inet_sk(sk)->inet_id);
-- inet_sk(sk)->inet_id += 1 + more;
-- } else
-+ inet_sk(sk)->inet_id += segs;
-+ } else {
- iph->id = 0;
-- } else
-- __ip_select_ident(iph, dst, more);
-+ }
-+ } else {
-+ __ip_select_ident(iph, segs);
-+ }
-+}
-+
-+static inline void ip_select_ident(struct sk_buff *skb, struct sock *sk)
-+{
-+ ip_select_ident_segs(skb, sk, 1);
- }
-
- /*
-diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
-index e77c10405d51..7b9ec5837496 100644
---- a/include/net/ip_tunnels.h
-+++ b/include/net/ip_tunnels.h
-@@ -40,6 +40,7 @@ struct ip_tunnel_prl_entry {
-
- struct ip_tunnel_dst {
- struct dst_entry __rcu *dst;
-+ __be32 saddr;
- };
-
- struct ip_tunnel {
-diff --git a/include/net/ipv6.h b/include/net/ipv6.h
-index 4f541f11ce63..9ac65781d44b 100644
---- a/include/net/ipv6.h
-+++ b/include/net/ipv6.h
-@@ -660,8 +660,6 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
- return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
- }
-
--void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt);
--
- int ip6_dst_hoplimit(struct dst_entry *dst);
-
- /*
-diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
-index f257486f17be..3f36d45b714a 100644
---- a/include/net/secure_seq.h
-+++ b/include/net/secure_seq.h
-@@ -3,8 +3,6 @@
-
- #include
-
--__u32 secure_ip_id(__be32 daddr);
--__u32 secure_ipv6_id(const __be32 daddr[4]);
- u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
- u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
- __be16 dport);
-diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
-index cc1cfd60c094..c46387a46535 100644
---- a/net/batman-adv/fragmentation.c
-+++ b/net/batman-adv/fragmentation.c
-@@ -128,6 +128,7 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
- {
- struct batadv_frag_table_entry *chain;
- struct batadv_frag_list_entry *frag_entry_new = NULL, *frag_entry_curr;
-+ struct batadv_frag_list_entry *frag_entry_last = NULL;
- struct batadv_frag_packet *frag_packet;
- uint8_t bucket;
- uint16_t seqno, hdr_size = sizeof(struct batadv_frag_packet);
-@@ -180,11 +181,14 @@ static bool batadv_frag_insert_packet(struct batadv_orig_node *orig_node,
- ret = true;
- goto out;
- }
-+
-+ /* store current entry because it could be the last in list */
-+ frag_entry_last = frag_entry_curr;
- }
-
-- /* Reached the end of the list, so insert after 'frag_entry_curr'. */
-- if (likely(frag_entry_curr)) {
-- hlist_add_after(&frag_entry_curr->list, &frag_entry_new->list);
-+ /* Reached the end of the list, so insert after 'frag_entry_last'. */
-+ if (likely(frag_entry_last)) {
-+ hlist_add_after(&frag_entry_last->list, &frag_entry_new->list);
- chain->size += skb->len - hdr_size;
- chain->timestamp = jiffies;
- ret = true;
-diff --git a/net/compat.c b/net/compat.c
-index f50161fb812e..cbc1a2a26587 100644
---- a/net/compat.c
-+++ b/net/compat.c
-@@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
- {
- int tot_len;
-
-- if (kern_msg->msg_namelen) {
-+ if (kern_msg->msg_name && kern_msg->msg_namelen) {
- if (mode == VERIFY_READ) {
- int err = move_addr_to_kernel(kern_msg->msg_name,
- kern_msg->msg_namelen,
-@@ -93,10 +93,11 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
- if (err < 0)
- return err;
- }
-- if (kern_msg->msg_name)
-- kern_msg->msg_name = kern_address;
-- } else
-+ kern_msg->msg_name = kern_address;
-+ } else {
- kern_msg->msg_name = NULL;
-+ kern_msg->msg_namelen = 0;
-+ }
-
- tot_len = iov_from_user_compat_to_kern(kern_iov,
- (struct compat_iovec __user *)kern_msg->msg_iov,
-diff --git a/net/core/iovec.c b/net/core/iovec.c
-index b61869429f4c..26dc0062652f 100644
---- a/net/core/iovec.c
-+++ b/net/core/iovec.c
-@@ -39,7 +39,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
- {
- int size, ct, err;
-
-- if (m->msg_namelen) {
-+ if (m->msg_name && m->msg_namelen) {
- if (mode == VERIFY_READ) {
- void __user *namep;
- namep = (void __user __force *) m->msg_name;
-@@ -48,10 +48,10 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
- if (err < 0)
- return err;
- }
-- if (m->msg_name)
-- m->msg_name = address;
-+ m->msg_name = address;
- } else {
- m->msg_name = NULL;
-+ m->msg_namelen = 0;
- }
-
- size = m->msg_iovlen * sizeof(struct iovec);
-@@ -107,6 +107,10 @@ EXPORT_SYMBOL(memcpy_toiovecend);
- int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
- int offset, int len)
- {
-+ /* No data? Done! */
-+ if (len == 0)
-+ return 0;
-+
- /* Skip over the finished iovecs */
- while (offset >= iov->iov_len) {
- offset -= iov->iov_len;
-diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
-index 897da56f3aff..ba71212f0251 100644
---- a/net/core/secure_seq.c
-+++ b/net/core/secure_seq.c
-@@ -85,31 +85,6 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral);
- #endif
-
- #ifdef CONFIG_INET
--__u32 secure_ip_id(__be32 daddr)
--{
-- u32 hash[MD5_DIGEST_WORDS];
--
-- net_secret_init();
-- hash[0] = (__force __u32) daddr;
-- hash[1] = net_secret[13];
-- hash[2] = net_secret[14];
-- hash[3] = net_secret[15];
--
-- md5_transform(hash, net_secret);
--
-- return hash[0];
--}
--
--__u32 secure_ipv6_id(const __be32 daddr[4])
--{
-- __u32 hash[4];
--
-- net_secret_init();
-- memcpy(hash, daddr, 16);
-- md5_transform(hash, net_secret);
--
-- return hash[0];
--}
-
- __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
- __be16 sport, __be16 dport)
-diff --git a/net/core/skbuff.c b/net/core/skbuff.c
-index 7f2e1fce706e..8f6391bbf509 100644
---- a/net/core/skbuff.c
-+++ b/net/core/skbuff.c
-@@ -2968,9 +2968,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
- tail = nskb;
-
- __copy_skb_header(nskb, head_skb);
-- nskb->mac_len = head_skb->mac_len;
-
- skb_headers_offset_update(nskb, skb_headroom(nskb) - headroom);
-+ skb_reset_mac_len(nskb);
-
- skb_copy_from_linear_data_offset(head_skb, -tnl_hlen,
- nskb->data - tnl_hlen,
-diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
-index 9db3b877fcaf..0ffcd4d64e0a 100644
---- a/net/ipv4/igmp.c
-+++ b/net/ipv4/igmp.c
-@@ -369,7 +369,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
- pip->saddr = fl4.saddr;
- pip->protocol = IPPROTO_IGMP;
- pip->tot_len = 0; /* filled in later */
-- ip_select_ident(skb, &rt->dst, NULL);
-+ ip_select_ident(skb, NULL);
- ((u8 *)&pip[1])[0] = IPOPT_RA;
- ((u8 *)&pip[1])[1] = 4;
- ((u8 *)&pip[1])[2] = 0;
-@@ -714,7 +714,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
- iph->daddr = dst;
- iph->saddr = fl4.saddr;
- iph->protocol = IPPROTO_IGMP;
-- ip_select_ident(skb, &rt->dst, NULL);
-+ ip_select_ident(skb, NULL);
- ((u8 *)&iph[1])[0] = IPOPT_RA;
- ((u8 *)&iph[1])[1] = 4;
- ((u8 *)&iph[1])[2] = 0;
-diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
-index 48f424465112..bf2cb4a4714b 100644
---- a/net/ipv4/inetpeer.c
-+++ b/net/ipv4/inetpeer.c
-@@ -26,20 +26,7 @@
- * Theory of operations.
- * We keep one entry for each peer IP address. The nodes contains long-living
- * information about the peer which doesn't depend on routes.
-- * At this moment this information consists only of ID field for the next
-- * outgoing IP packet. This field is incremented with each packet as encoded
-- * in inet_getid() function (include/net/inetpeer.h).
-- * At the moment of writing this notes identifier of IP packets is generated
-- * to be unpredictable using this code only for packets subjected
-- * (actually or potentially) to defragmentation. I.e. DF packets less than
-- * PMTU in size when local fragmentation is disabled use a constant ID and do
-- * not use this code (see ip_select_ident() in include/net/ip.h).
- *
-- * Route cache entries hold references to our nodes.
-- * New cache entries get references via lookup by destination IP address in
-- * the avl tree. The reference is grabbed only when it's needed i.e. only
-- * when we try to output IP packet which needs an unpredictable ID (see
-- * __ip_select_ident() in net/ipv4/route.c).
- * Nodes are removed only when reference counter goes to 0.
- * When it's happened the node may be removed when a sufficient amount of
- * time has been passed since its last use. The less-recently-used entry can
-@@ -62,7 +49,6 @@
- * refcnt: atomically against modifications on other CPU;
- * usually under some other lock to prevent node disappearing
- * daddr: unchangeable
-- * ip_id_count: atomic value (no lock needed)
- */
-
- static struct kmem_cache *peer_cachep __read_mostly;
-@@ -497,10 +483,6 @@ relookup:
- p->daddr = *daddr;
- atomic_set(&p->refcnt, 1);
- atomic_set(&p->rid, 0);
-- atomic_set(&p->ip_id_count,
-- (daddr->family == AF_INET) ?
-- secure_ip_id(daddr->addr.a4) :
-- secure_ipv6_id(daddr->addr.a6));
- p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
- p->rate_tokens = 0;
- /* 60*HZ is arbitrary, but chosen enough high so that the first
-diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
-index 73c6b63bba74..ed88d781248f 100644
---- a/net/ipv4/ip_output.c
-+++ b/net/ipv4/ip_output.c
-@@ -148,7 +148,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
- iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
- iph->saddr = saddr;
- iph->protocol = sk->sk_protocol;
-- ip_select_ident(skb, &rt->dst, sk);
-+ ip_select_ident(skb, sk);
-
- if (opt && opt->opt.optlen) {
- iph->ihl += opt->opt.optlen>>2;
-@@ -386,8 +386,7 @@ packet_routed:
- ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
- }
-
-- ip_select_ident_more(skb, &rt->dst, sk,
-- (skb_shinfo(skb)->gso_segs ?: 1) - 1);
-+ ip_select_ident_segs(skb, sk, skb_shinfo(skb)->gso_segs ?: 1);
-
- skb->priority = sk->sk_priority;
- skb->mark = sk->sk_mark;
-@@ -1338,7 +1337,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
- iph->ttl = ttl;
- iph->protocol = sk->sk_protocol;
- ip_copy_addrs(iph, fl4);
-- ip_select_ident(skb, &rt->dst, sk);
-+ ip_select_ident(skb, sk);
-
- if (opt) {
- iph->ihl += opt->optlen>>2;
-diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
-index 62cd9e0ae35b..0a4af0920af3 100644
---- a/net/ipv4/ip_tunnel.c
-+++ b/net/ipv4/ip_tunnel.c
-@@ -69,23 +69,25 @@ static unsigned int ip_tunnel_hash(__be32 key, __be32 remote)
- }
-
- static void __tunnel_dst_set(struct ip_tunnel_dst *idst,
-- struct dst_entry *dst)
-+ struct dst_entry *dst, __be32 saddr)
- {
- struct dst_entry *old_dst;
-
- dst_clone(dst);
- old_dst = xchg((__force struct dst_entry **)&idst->dst, dst);
- dst_release(old_dst);
-+ idst->saddr = saddr;
- }
-
--static void tunnel_dst_set(struct ip_tunnel *t, struct dst_entry *dst)
-+static void tunnel_dst_set(struct ip_tunnel *t,
-+ struct dst_entry *dst, __be32 saddr)
- {
-- __tunnel_dst_set(this_cpu_ptr(t->dst_cache), dst);
-+ __tunnel_dst_set(this_cpu_ptr(t->dst_cache), dst, saddr);
- }
-
- static void tunnel_dst_reset(struct ip_tunnel *t)
- {
-- tunnel_dst_set(t, NULL);
-+ tunnel_dst_set(t, NULL, 0);
- }
-
- void ip_tunnel_dst_reset_all(struct ip_tunnel *t)
-@@ -93,20 +95,25 @@ void ip_tunnel_dst_reset_all(struct ip_tunnel *t)
- int i;
-
- for_each_possible_cpu(i)
-- __tunnel_dst_set(per_cpu_ptr(t->dst_cache, i), NULL);
-+ __tunnel_dst_set(per_cpu_ptr(t->dst_cache, i), NULL, 0);
- }
- EXPORT_SYMBOL(ip_tunnel_dst_reset_all);
-
--static struct rtable *tunnel_rtable_get(struct ip_tunnel *t, u32 cookie)
-+static struct rtable *tunnel_rtable_get(struct ip_tunnel *t,
-+ u32 cookie, __be32 *saddr)
- {
-+ struct ip_tunnel_dst *idst;
- struct dst_entry *dst;
-
- rcu_read_lock();
-- dst = rcu_dereference(this_cpu_ptr(t->dst_cache)->dst);
-+ idst = this_cpu_ptr(t->dst_cache);
-+ dst = rcu_dereference(idst->dst);
- if (dst && !atomic_inc_not_zero(&dst->__refcnt))
- dst = NULL;
- if (dst) {
-- if (dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
-+ if (!dst->obsolete || dst->ops->check(dst, cookie)) {
-+ *saddr = idst->saddr;
-+ } else {
- tunnel_dst_reset(t);
- dst_release(dst);
- dst = NULL;
-@@ -362,7 +369,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
-
- if (!IS_ERR(rt)) {
- tdev = rt->dst.dev;
-- tunnel_dst_set(tunnel, &rt->dst);
-+ tunnel_dst_set(tunnel, &rt->dst, fl4.saddr);
- ip_rt_put(rt);
- }
- if (dev->type != ARPHRD_ETHER)
-@@ -606,7 +613,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
- init_tunnel_flow(&fl4, protocol, dst, tnl_params->saddr,
- tunnel->parms.o_key, RT_TOS(tos), tunnel->parms.link);
-
-- rt = connected ? tunnel_rtable_get(tunnel, 0) : NULL;
-+ rt = connected ? tunnel_rtable_get(tunnel, 0, &fl4.saddr) : NULL;
-
- if (!rt) {
- rt = ip_route_output_key(tunnel->net, &fl4);
-@@ -616,7 +623,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
- goto tx_error;
- }
- if (connected)
-- tunnel_dst_set(tunnel, &rt->dst);
-+ tunnel_dst_set(tunnel, &rt->dst, fl4.saddr);
- }
-
- if (rt->dst.dev == dev) {
-diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
-index 8d69626f2206..65b664d30fa1 100644
---- a/net/ipv4/ip_tunnel_core.c
-+++ b/net/ipv4/ip_tunnel_core.c
-@@ -74,7 +74,7 @@ int iptunnel_xmit(struct rtable *rt, struct sk_buff *skb,
- iph->daddr = dst;
- iph->saddr = src;
- iph->ttl = ttl;
-- __ip_select_ident(iph, &rt->dst, (skb_shinfo(skb)->gso_segs ?: 1) - 1);
-+ __ip_select_ident(iph, skb_shinfo(skb)->gso_segs ?: 1);
-
- err = ip_local_out(skb);
- if (unlikely(net_xmit_eval(err)))
-diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
-index 28863570dd60..1149fc2290e2 100644
---- a/net/ipv4/ipmr.c
-+++ b/net/ipv4/ipmr.c
-@@ -1663,7 +1663,7 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
- iph->protocol = IPPROTO_IPIP;
- iph->ihl = 5;
- iph->tot_len = htons(skb->len);
-- ip_select_ident(skb, skb_dst(skb), NULL);
-+ ip_select_ident(skb, NULL);
- ip_send_check(iph);
-
- memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
-diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
-index c04518f4850a..11c8d81fdc59 100644
---- a/net/ipv4/raw.c
-+++ b/net/ipv4/raw.c
-@@ -389,7 +389,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
- iph->check = 0;
- iph->tot_len = htons(length);
- if (!iph->id)
-- ip_select_ident(skb, &rt->dst, NULL);
-+ ip_select_ident(skb, NULL);
-
- iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
- }
-diff --git a/net/ipv4/route.c b/net/ipv4/route.c
-index 031553f8a306..ca5a01ed8ed6 100644
---- a/net/ipv4/route.c
-+++ b/net/ipv4/route.c
-@@ -89,6 +89,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -462,39 +463,45 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
- return neigh_create(&arp_tbl, pkey, dev);
- }
-
--/*
-- * Peer allocation may fail only in serious out-of-memory conditions. However
-- * we still can generate some output.
-- * Random ID selection looks a bit dangerous because we have no chances to
-- * select ID being unique in a reasonable period of time.
-- * But broken packet identifier may be better than no packet at all.
-+#define IP_IDENTS_SZ 2048u
-+struct ip_ident_bucket {
-+ atomic_t id;
-+ u32 stamp32;
-+};
-+
-+static struct ip_ident_bucket *ip_idents __read_mostly;
-+
-+/* In order to protect privacy, we add a perturbation to identifiers
-+ * if one generator is seldom used. This makes hard for an attacker
-+ * to infer how many packets were sent between two points in time.
- */
--static void ip_select_fb_ident(struct iphdr *iph)
-+u32 ip_idents_reserve(u32 hash, int segs)
- {
-- static DEFINE_SPINLOCK(ip_fb_id_lock);
-- static u32 ip_fallback_id;
-- u32 salt;
-+ struct ip_ident_bucket *bucket = ip_idents + hash % IP_IDENTS_SZ;
-+ u32 old = ACCESS_ONCE(bucket->stamp32);
-+ u32 now = (u32)jiffies;
-+ u32 delta = 0;
-+
-+ if (old != now && cmpxchg(&bucket->stamp32, old, now) == old)
-+ delta = prandom_u32_max(now - old);
-
-- spin_lock_bh(&ip_fb_id_lock);
-- salt = secure_ip_id((__force __be32)ip_fallback_id ^ iph->daddr);
-- iph->id = htons(salt & 0xFFFF);
-- ip_fallback_id = salt;
-- spin_unlock_bh(&ip_fb_id_lock);
-+ return atomic_add_return(segs + delta, &bucket->id) - segs;
- }
-+EXPORT_SYMBOL(ip_idents_reserve);
-
--void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
-+void __ip_select_ident(struct iphdr *iph, int segs)
- {
-- struct net *net = dev_net(dst->dev);
-- struct inet_peer *peer;
-+ static u32 ip_idents_hashrnd __read_mostly;
-+ u32 hash, id;
-
-- peer = inet_getpeer_v4(net->ipv4.peers, iph->daddr, 1);
-- if (peer) {
-- iph->id = htons(inet_getid(peer, more));
-- inet_putpeer(peer);
-- return;
-- }
-+ net_get_random_once(&ip_idents_hashrnd, sizeof(ip_idents_hashrnd));
-
-- ip_select_fb_ident(iph);
-+ hash = jhash_3words((__force u32)iph->daddr,
-+ (__force u32)iph->saddr,
-+ iph->protocol,
-+ ip_idents_hashrnd);
-+ id = ip_idents_reserve(hash, segs);
-+ iph->id = htons(id);
- }
- EXPORT_SYMBOL(__ip_select_ident);
-
-@@ -2718,6 +2725,12 @@ int __init ip_rt_init(void)
- {
- int rc = 0;
-
-+ ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
-+ if (!ip_idents)
-+ panic("IP: failed to allocate ip_idents\n");
-+
-+ prandom_bytes(ip_idents, IP_IDENTS_SZ * sizeof(*ip_idents));
-+
- #ifdef CONFIG_IP_ROUTE_CLASSID
- ip_rt_acct = __alloc_percpu(256 * sizeof(struct ip_rt_acct), __alignof__(struct ip_rt_acct));
- if (!ip_rt_acct)
-diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
-index 06cae62bf208..6b1a5fd60598 100644
---- a/net/ipv4/tcp_vegas.c
-+++ b/net/ipv4/tcp_vegas.c
-@@ -219,7 +219,8 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 acked,
- * This is:
- * (actual rate in segments) * baseRTT
- */
-- target_cwnd = tp->snd_cwnd * vegas->baseRTT / rtt;
-+ target_cwnd = (u64)tp->snd_cwnd * vegas->baseRTT;
-+ do_div(target_cwnd, rtt);
-
- /* Calculate the difference between the window we had,
- * and the window we would like to have. This quantity
-diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
-index 326475a94865..603ad498e18a 100644
---- a/net/ipv4/tcp_veno.c
-+++ b/net/ipv4/tcp_veno.c
-@@ -145,7 +145,7 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 acked,
-
- rtt = veno->minrtt;
-
-- target_cwnd = (tp->snd_cwnd * veno->basertt);
-+ target_cwnd = (u64)tp->snd_cwnd * veno->basertt;
- target_cwnd <<= V_PARAM_SHIFT;
- do_div(target_cwnd, rtt);
-
-diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
-index 31b18152528f..1f564a1487a3 100644
---- a/net/ipv4/xfrm4_mode_tunnel.c
-+++ b/net/ipv4/xfrm4_mode_tunnel.c
-@@ -117,12 +117,12 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
-
- top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
- 0 : (XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF));
-- ip_select_ident(skb, dst->child, NULL);
-
- top_iph->ttl = ip4_dst_hoplimit(dst->child);
-
- top_iph->saddr = x->props.saddr.a4;
- top_iph->daddr = x->id.daddr.a4;
-+ ip_select_ident(skb, NULL);
-
- return 0;
- }
-diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
-index a62b610307ec..073e5a6fc631 100644
---- a/net/ipv6/ip6_output.c
-+++ b/net/ipv6/ip6_output.c
-@@ -537,6 +537,20 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
- skb_copy_secmark(to, from);
- }
-
-+static void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
-+{
-+ static u32 ip6_idents_hashrnd __read_mostly;
-+ u32 hash, id;
-+
-+ net_get_random_once(&ip6_idents_hashrnd, sizeof(ip6_idents_hashrnd));
-+
-+ hash = __ipv6_addr_jhash(&rt->rt6i_dst.addr, ip6_idents_hashrnd);
-+ hash = __ipv6_addr_jhash(&rt->rt6i_src.addr, hash);
-+
-+ id = ip_idents_reserve(hash, 1);
-+ fhdr->identification = htonl(id);
-+}
-+
- int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
- {
- struct sk_buff *frag;
-diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
-index b31a01263185..798eb0f79078 100644
---- a/net/ipv6/output_core.c
-+++ b/net/ipv6/output_core.c
-@@ -7,29 +7,6 @@
- #include
- #include
-
--void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
--{
-- static atomic_t ipv6_fragmentation_id;
-- int ident;
--
--#if IS_ENABLED(CONFIG_IPV6)
-- if (rt && !(rt->dst.flags & DST_NOPEER)) {
-- struct inet_peer *peer;
-- struct net *net;
--
-- net = dev_net(rt->dst.dev);
-- peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, 1);
-- if (peer) {
-- fhdr->identification = htonl(inet_getid(peer, 0));
-- inet_putpeer(peer);
-- return;
-- }
-- }
--#endif
-- ident = atomic_inc_return(&ipv6_fragmentation_id);
-- fhdr->identification = htonl(ident);
--}
--EXPORT_SYMBOL(ipv6_select_ident);
-
- int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
- {
-diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
-index c47444e4cf8c..7f0e1cf2d7e8 100644
---- a/net/netfilter/ipvs/ip_vs_xmit.c
-+++ b/net/netfilter/ipvs/ip_vs_xmit.c
-@@ -883,7 +883,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
- iph->daddr = cp->daddr.ip;
- iph->saddr = saddr;
- iph->ttl = old_iph->ttl;
-- ip_select_ident(skb, &rt->dst, NULL);
-+ ip_select_ident(skb, NULL);
-
- /* Another hack: avoid icmp_send in ip_fragment */
- skb->local_df = 1;
-diff --git a/net/sctp/associola.c b/net/sctp/associola.c
-index a4d570126f5d..5d97d8fe4be7 100644
---- a/net/sctp/associola.c
-+++ b/net/sctp/associola.c
-@@ -1151,6 +1151,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
- asoc->c = new->c;
- asoc->peer.rwnd = new->peer.rwnd;
- asoc->peer.sack_needed = new->peer.sack_needed;
-+ asoc->peer.auth_capable = new->peer.auth_capable;
- asoc->peer.i = new->peer.i;
- sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL,
- asoc->peer.i.initial_tsn, GFP_ATOMIC);
-diff --git a/net/sctp/output.c b/net/sctp/output.c
-index 0f4d15fc2627..8267b06c3646 100644
---- a/net/sctp/output.c
-+++ b/net/sctp/output.c
-@@ -599,7 +599,7 @@ out:
- return err;
- no_route:
- kfree_skb(nskb);
-- IP_INC_STATS_BH(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
-+ IP_INC_STATS(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
-
- /* FIXME: Returning the 'err' will effect all the associations
- * associated with a socket, although only one of the paths of the
-diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
-index b10d04fa3933..3bea4ddc699d 100644
---- a/net/xfrm/xfrm_user.c
-+++ b/net/xfrm/xfrm_user.c
-@@ -176,9 +176,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
- attrs[XFRMA_ALG_AEAD] ||
- attrs[XFRMA_ALG_CRYPT] ||
- attrs[XFRMA_ALG_COMP] ||
-- attrs[XFRMA_TFCPAD] ||
-- (ntohl(p->id.spi) >= 0x10000))
--
-+ attrs[XFRMA_TFCPAD])
- goto out;
- break;
-
-@@ -206,7 +204,8 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
- attrs[XFRMA_ALG_AUTH] ||
- attrs[XFRMA_ALG_AUTH_TRUNC] ||
- attrs[XFRMA_ALG_CRYPT] ||
-- attrs[XFRMA_TFCPAD])
-+ attrs[XFRMA_TFCPAD] ||
-+ (ntohl(p->id.spi) >= 0x10000))
- goto out;
- break;
-
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.17-18.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.17-18.patch
deleted file mode 100644
index 077896b312..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.17-18.patch
+++ /dev/null
@@ -1,3331 +0,0 @@
-diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
-index b8dd0df76952..0fd40b15e2d5 100644
---- a/Documentation/sound/alsa/ALSA-Configuration.txt
-+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
-@@ -2026,8 +2026,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
- -------------------
-
- Module for sound cards based on the Asus AV66/AV100/AV200 chips,
-- i.e., Xonar D1, DX, D2, D2X, DS, Essence ST (Deluxe), Essence STX,
-- HDAV1.3 (Deluxe), and HDAV1.3 Slim.
-+ i.e., Xonar D1, DX, D2, D2X, DS, DSX, Essence ST (Deluxe),
-+ Essence STX (II), HDAV1.3 (Deluxe), and HDAV1.3 Slim.
-
- This module supports autoprobe and multiple cards.
-
-diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt
-index b0714d8f678a..8dfb6a5f427d 100644
---- a/Documentation/stable_kernel_rules.txt
-+++ b/Documentation/stable_kernel_rules.txt
-@@ -29,6 +29,9 @@ Rules on what kind of patches are accepted, and which ones are not, into the
-
- Procedure for submitting patches to the -stable tree:
-
-+ - If the patch covers files in net/ or drivers/net please follow netdev stable
-+ submission guidelines as described in
-+ Documentation/networking/netdev-FAQ.txt
- - Send the patch, after verifying that it follows the above rules, to
- stable@vger.kernel.org. You must note the upstream commit ID in the
- changelog of your submission, as well as the kernel version you wish
-diff --git a/Makefile b/Makefile
-index 12aac0325888..05279d4f44c9 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 17
-+SUBLEVEL = 18
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
-index c6bd4d986c29..8775681df7ed 100644
---- a/arch/arm/boot/dts/am4372.dtsi
-+++ b/arch/arm/boot/dts/am4372.dtsi
-@@ -161,9 +161,6 @@
- ti,hwmods = "mailbox";
- ti,mbox-num-users = <4>;
- ti,mbox-num-fifos = <8>;
-- ti,mbox-names = "wkup_m3";
-- ti,mbox-data = <0 0 0 0>;
-- status = "disabled";
- };
-
- timer1: timer@44e31000 {
-diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
-index 43876245fc57..21ca0cebcab0 100644
---- a/arch/arm/include/asm/unistd.h
-+++ b/arch/arm/include/asm/unistd.h
-@@ -15,7 +15,17 @@
-
- #include
-
-+/*
-+ * This may need to be greater than __NR_last_syscall+1 in order to
-+ * account for the padding in the syscall table
-+ */
- #define __NR_syscalls (384)
-+
-+/*
-+ * *NOTE*: This is a ghost syscall private to the kernel. Only the
-+ * __kuser_cmpxchg code in entry-armv.S should be aware of its
-+ * existence. Don't ever use this from user code.
-+ */
- #define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0)
-
- #define __ARCH_WANT_STAT64
-diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
-index fb5584d0cc05..c3776331f407 100644
---- a/arch/arm/include/uapi/asm/unistd.h
-+++ b/arch/arm/include/uapi/asm/unistd.h
-@@ -410,11 +410,6 @@
- #define __NR_sched_getattr (__NR_SYSCALL_BASE+381)
-
- /*
-- * This may need to be greater than __NR_last_syscall+1 in order to
-- * account for the padding in the syscall table
-- */
--
--/*
- * The following SWIs are ARM private.
- */
- #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
-@@ -425,12 +420,6 @@
- #define __ARM_NR_set_tls (__ARM_NR_BASE+5)
-
- /*
-- * *NOTE*: This is a ghost syscall private to the kernel. Only the
-- * __kuser_cmpxchg code in entry-armv.S should be aware of its
-- * existence. Don't ever use this from user code.
-- */
--
--/*
- * The following syscalls are obsolete and no longer available for EABI.
- */
- #if !defined(__KERNEL__)
-diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
-index 44bb4d544dcf..89cde0786d25 100644
---- a/arch/arm/mach-omap2/control.c
-+++ b/arch/arm/mach-omap2/control.c
-@@ -314,7 +314,8 @@ void omap3_save_scratchpad_contents(void)
- scratchpad_contents.public_restore_ptr =
- virt_to_phys(omap3_restore_3630);
- else if (omap_rev() != OMAP3430_REV_ES3_0 &&
-- omap_rev() != OMAP3430_REV_ES3_1)
-+ omap_rev() != OMAP3430_REV_ES3_1 &&
-+ omap_rev() != OMAP3430_REV_ES3_1_2)
- scratchpad_contents.public_restore_ptr =
- virt_to_phys(omap3_restore);
- else
-diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
-index 66c60fe1104c..c914b0052fb9 100644
---- a/arch/arm/mach-omap2/omap_hwmod.c
-+++ b/arch/arm/mach-omap2/omap_hwmod.c
-@@ -2185,6 +2185,8 @@ static int _enable(struct omap_hwmod *oh)
- oh->mux->pads_dynamic))) {
- omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
- _reconfigure_io_chain();
-+ } else if (oh->flags & HWMOD_FORCE_MSTANDBY) {
-+ _reconfigure_io_chain();
- }
-
- _add_initiator_dep(oh, mpu_oh);
-@@ -2291,6 +2293,8 @@ static int _idle(struct omap_hwmod *oh)
- if (oh->mux && oh->mux->pads_dynamic) {
- omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);
- _reconfigure_io_chain();
-+ } else if (oh->flags & HWMOD_FORCE_MSTANDBY) {
-+ _reconfigure_io_chain();
- }
-
- oh->_state = _HWMOD_STATE_IDLE;
-diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
-index 3b2b4fb3585b..beedaf0c5e75 100644
---- a/arch/powerpc/platforms/powernv/pci-ioda.c
-+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
-@@ -491,6 +491,7 @@ static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb,
- set_dma_ops(&pdev->dev, &dma_iommu_ops);
- set_iommu_table_base(&pdev->dev, &pe->tce32_table);
- }
-+ *pdev->dev.dma_mask = dma_mask;
- return 0;
- }
-
-diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
-index efe61374f6ea..e68922b0d4f5 100644
---- a/arch/powerpc/platforms/pseries/pci_dlpar.c
-+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
-@@ -118,10 +118,10 @@ int remove_phb_dynamic(struct pci_controller *phb)
- }
- }
-
-- /* Unregister the bridge device from sysfs and remove the PCI bus */
-- device_unregister(b->bridge);
-+ /* Remove the PCI bus and unregister the bridge device from sysfs */
- phb->bus = NULL;
- pci_remove_bus(b);
-+ device_unregister(b->bridge);
-
- /* Now release the IO resource */
- if (res->flags & IORESOURCE_IO)
-diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
-index c718d9f25900..e4098912fef2 100644
---- a/arch/x86/Kconfig
-+++ b/arch/x86/Kconfig
-@@ -1597,6 +1597,7 @@ config EFI
- config EFI_STUB
- bool "EFI stub support"
- depends on EFI
-+ select RELOCATABLE
- ---help---
- This kernel feature allows a bzImage to be loaded directly
- by EFI firmware without the use of a bootloader.
-diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
-index 3092300a07cd..d71d5ac78e42 100644
---- a/arch/x86/include/asm/kvm_host.h
-+++ b/arch/x86/include/asm/kvm_host.h
-@@ -99,7 +99,7 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
- #define KVM_REFILL_PAGES 25
- #define KVM_MAX_CPUID_ENTRIES 80
- #define KVM_NR_FIXED_MTRR_REGION 88
--#define KVM_NR_VAR_MTRR 10
-+#define KVM_NR_VAR_MTRR 8
-
- #define ASYNC_PF_PER_VCPU 64
-
-diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
-index 2a26819bb6a8..80eab01c1a68 100644
---- a/arch/x86/kernel/resource.c
-+++ b/arch/x86/kernel/resource.c
-@@ -37,10 +37,12 @@ static void remove_e820_regions(struct resource *avail)
-
- void arch_remove_reservations(struct resource *avail)
- {
-- /* Trim out BIOS areas (low 1MB and high 2MB) and E820 regions */
-+ /*
-+ * Trim out BIOS area (high 2MB) and E820 regions. We do not remove
-+ * the low 1MB unconditionally, as this area is needed for some ISA
-+ * cards requiring a memory range, e.g. the i82365 PCMCIA controller.
-+ */
- if (avail->flags & IORESOURCE_MEM) {
-- if (avail->start < BIOS_END)
-- avail->start = BIOS_END;
- resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
-
- remove_e820_regions(avail);
-diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
-index 1f96f9347ed9..09ce23ae370c 100644
---- a/arch/x86/kernel/vsyscall_64.c
-+++ b/arch/x86/kernel/vsyscall_64.c
-@@ -125,10 +125,10 @@ static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
- if (!show_unhandled_signals)
- return;
-
-- pr_notice_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n",
-- level, current->comm, task_pid_nr(current),
-- message, regs->ip, regs->cs,
-- regs->sp, regs->ax, regs->si, regs->di);
-+ printk_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n",
-+ level, current->comm, task_pid_nr(current),
-+ message, regs->ip, regs->cs,
-+ regs->sp, regs->ax, regs->si, regs->di);
- }
-
- static int addr_to_vsyscall_nr(unsigned long addr)
-diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
-index 07ffca0a89e9..7bff3e2a7a11 100644
---- a/arch/x86/kvm/emulate.c
-+++ b/arch/x86/kvm/emulate.c
-@@ -2006,6 +2006,7 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
- {
- int rc;
- unsigned long cs;
-+ int cpl = ctxt->ops->cpl(ctxt);
-
- rc = emulate_pop(ctxt, &ctxt->_eip, ctxt->op_bytes);
- if (rc != X86EMUL_CONTINUE)
-@@ -2015,6 +2016,9 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
- rc = emulate_pop(ctxt, &cs, ctxt->op_bytes);
- if (rc != X86EMUL_CONTINUE)
- return rc;
-+ /* Outer-privilege level return is not implemented */
-+ if (ctxt->mode >= X86EMUL_MODE_PROT16 && (cs & 3) > cpl)
-+ return X86EMUL_UNHANDLEABLE;
- rc = load_segment_descriptor(ctxt, (u16)cs, VCPU_SREG_CS);
- return rc;
- }
-diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
-index 484bc874688b..3ec38cb56bd5 100644
---- a/arch/x86/kvm/irq.c
-+++ b/arch/x86/kvm/irq.c
-@@ -108,7 +108,7 @@ int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
-
- vector = kvm_cpu_get_extint(v);
-
-- if (kvm_apic_vid_enabled(v->kvm) || vector != -1)
-+ if (vector != -1)
- return vector; /* PIC */
-
- return kvm_get_apic_interrupt(v); /* APIC */
-diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
-index 006911858174..453e5fbbb7ae 100644
---- a/arch/x86/kvm/lapic.c
-+++ b/arch/x86/kvm/lapic.c
-@@ -352,25 +352,46 @@ static inline int apic_find_highest_irr(struct kvm_lapic *apic)
-
- static inline void apic_clear_irr(int vec, struct kvm_lapic *apic)
- {
-- apic->irr_pending = false;
-+ struct kvm_vcpu *vcpu;
-+
-+ vcpu = apic->vcpu;
-+
- apic_clear_vector(vec, apic->regs + APIC_IRR);
-- if (apic_search_irr(apic) != -1)
-- apic->irr_pending = true;
-+ if (unlikely(kvm_apic_vid_enabled(vcpu->kvm)))
-+ /* try to update RVI */
-+ kvm_make_request(KVM_REQ_EVENT, vcpu);
-+ else {
-+ vec = apic_search_irr(apic);
-+ apic->irr_pending = (vec != -1);
-+ }
- }
-
- static inline void apic_set_isr(int vec, struct kvm_lapic *apic)
- {
-- /* Note that we never get here with APIC virtualization enabled. */
-+ struct kvm_vcpu *vcpu;
-+
-+ if (__apic_test_and_set_vector(vec, apic->regs + APIC_ISR))
-+ return;
-+
-+ vcpu = apic->vcpu;
-
-- if (!__apic_test_and_set_vector(vec, apic->regs + APIC_ISR))
-- ++apic->isr_count;
-- BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
- /*
-- * ISR (in service register) bit is set when injecting an interrupt.
-- * The highest vector is injected. Thus the latest bit set matches
-- * the highest bit in ISR.
-+ * With APIC virtualization enabled, all caching is disabled
-+ * because the processor can modify ISR under the hood. Instead
-+ * just set SVI.
- */
-- apic->highest_isr_cache = vec;
-+ if (unlikely(kvm_apic_vid_enabled(vcpu->kvm)))
-+ kvm_x86_ops->hwapic_isr_update(vcpu->kvm, vec);
-+ else {
-+ ++apic->isr_count;
-+ BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
-+ /*
-+ * ISR (in service register) bit is set when injecting an interrupt.
-+ * The highest vector is injected. Thus the latest bit set matches
-+ * the highest bit in ISR.
-+ */
-+ apic->highest_isr_cache = vec;
-+ }
- }
-
- static inline int apic_find_highest_isr(struct kvm_lapic *apic)
-@@ -1627,11 +1648,16 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)
- int vector = kvm_apic_has_interrupt(vcpu);
- struct kvm_lapic *apic = vcpu->arch.apic;
-
-- /* Note that we never get here with APIC virtualization enabled. */
--
- if (vector == -1)
- return -1;
-
-+ /*
-+ * We get here even with APIC virtualization enabled, if doing
-+ * nested virtualization and L1 runs with the "acknowledge interrupt
-+ * on exit" mode. Then we cannot inject the interrupt via RVI,
-+ * because the process would deliver it through the IDT.
-+ */
-+
- apic_set_isr(vector, apic);
- apic_update_ppr(apic);
- apic_clear_irr(vector, apic);
-diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
-index db6b1ab43255..96a159afe3c6 100644
---- a/arch/x86/pci/i386.c
-+++ b/arch/x86/pci/i386.c
-@@ -162,6 +162,10 @@ pcibios_align_resource(void *data, const struct resource *res,
- return start;
- if (start & 0x300)
- start = (start + 0x3ff) & ~0x3ff;
-+ } else if (res->flags & IORESOURCE_MEM) {
-+ /* The low 1MB range is reserved for ISA cards */
-+ if (start < BIOS_END)
-+ start = BIOS_END;
- }
- return start;
- }
-diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c
-index c98583588580..5b406fc45674 100644
---- a/arch/x86/xen/grant-table.c
-+++ b/arch/x86/xen/grant-table.c
-@@ -134,6 +134,7 @@ static int __init xlated_setup_gnttab_pages(void)
- {
- struct page **pages;
- xen_pfn_t *pfns;
-+ void *vaddr;
- int rc;
- unsigned int i;
- unsigned long nr_grant_frames = gnttab_max_grant_frames();
-@@ -159,21 +160,20 @@ static int __init xlated_setup_gnttab_pages(void)
- for (i = 0; i < nr_grant_frames; i++)
- pfns[i] = page_to_pfn(pages[i]);
-
-- rc = arch_gnttab_map_shared(pfns, nr_grant_frames, nr_grant_frames,
-- &xen_auto_xlat_grant_frames.vaddr);
--
-- if (rc) {
-+ vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
-+ if (!vaddr) {
- pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
- nr_grant_frames, rc);
- free_xenballooned_pages(nr_grant_frames, pages);
- kfree(pages);
- kfree(pfns);
-- return rc;
-+ return -ENOMEM;
- }
- kfree(pages);
-
- xen_auto_xlat_grant_frames.pfn = pfns;
- xen_auto_xlat_grant_frames.count = nr_grant_frames;
-+ xen_auto_xlat_grant_frames.vaddr = vaddr;
-
- return 0;
- }
-diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
-index 7b78f88c1707..5718b0b58b60 100644
---- a/arch/x86/xen/time.c
-+++ b/arch/x86/xen/time.c
-@@ -444,7 +444,7 @@ void xen_setup_timer(int cpu)
-
- irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt,
- IRQF_PERCPU|IRQF_NOBALANCING|IRQF_TIMER|
-- IRQF_FORCE_RESUME,
-+ IRQF_FORCE_RESUME|IRQF_EARLY_RESUME,
- name, NULL);
- (void)xen_set_irq_priority(irq, XEN_IRQ_PRIORITY_MAX);
-
-diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
-index 5b0dd8ef74c0..be9af2e6ca5a 100644
---- a/drivers/char/tpm/tpm_i2c_stm_st33.c
-+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
-@@ -715,6 +715,7 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
- }
-
- tpm_get_timeouts(chip);
-+ tpm_do_selftest(chip);
-
- dev_info(chip->dev, "TPM I2C Initialized\n");
- return 0;
-diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
-index a999f537228f..92105f3dc8e0 100644
---- a/drivers/crypto/ux500/cryp/cryp_core.c
-+++ b/drivers/crypto/ux500/cryp/cryp_core.c
-@@ -190,7 +190,7 @@ static void add_session_id(struct cryp_ctx *ctx)
- static irqreturn_t cryp_interrupt_handler(int irq, void *param)
- {
- struct cryp_ctx *ctx;
-- int i;
-+ int count;
- struct cryp_device_data *device_data;
-
- if (param == NULL) {
-@@ -215,12 +215,11 @@ static irqreturn_t cryp_interrupt_handler(int irq, void *param)
- if (cryp_pending_irq_src(device_data,
- CRYP_IRQ_SRC_OUTPUT_FIFO)) {
- if (ctx->outlen / ctx->blocksize > 0) {
-- for (i = 0; i < ctx->blocksize / 4; i++) {
-- *(ctx->outdata) = readl_relaxed(
-- &device_data->base->dout);
-- ctx->outdata += 4;
-- ctx->outlen -= 4;
-- }
-+ count = ctx->blocksize / 4;
-+
-+ readsl(&device_data->base->dout, ctx->outdata, count);
-+ ctx->outdata += count;
-+ ctx->outlen -= count;
-
- if (ctx->outlen == 0) {
- cryp_disable_irq_src(device_data,
-@@ -230,12 +229,12 @@ static irqreturn_t cryp_interrupt_handler(int irq, void *param)
- } else if (cryp_pending_irq_src(device_data,
- CRYP_IRQ_SRC_INPUT_FIFO)) {
- if (ctx->datalen / ctx->blocksize > 0) {
-- for (i = 0 ; i < ctx->blocksize / 4; i++) {
-- writel_relaxed(ctx->indata,
-- &device_data->base->din);
-- ctx->indata += 4;
-- ctx->datalen -= 4;
-- }
-+ count = ctx->blocksize / 4;
-+
-+ writesl(&device_data->base->din, ctx->indata, count);
-+
-+ ctx->indata += count;
-+ ctx->datalen -= count;
-
- if (ctx->datalen == 0)
- cryp_disable_irq_src(device_data,
-diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
-index f926b4caf449..56c60552abba 100644
---- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
-+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
-@@ -199,7 +199,7 @@ static struct dmm_txn *dmm_txn_init(struct dmm *dmm, struct tcm *tcm)
- static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
- struct page **pages, uint32_t npages, uint32_t roll)
- {
-- dma_addr_t pat_pa = 0;
-+ dma_addr_t pat_pa = 0, data_pa = 0;
- uint32_t *data;
- struct pat *pat;
- struct refill_engine *engine = txn->engine_handle;
-@@ -223,7 +223,9 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
- .lut_id = engine->tcm->lut_id,
- };
-
-- data = alloc_dma(txn, 4*i, &pat->data_pa);
-+ data = alloc_dma(txn, 4*i, &data_pa);
-+ /* FIXME: what if data_pa is more than 32-bit ? */
-+ pat->data_pa = data_pa;
-
- while (i--) {
- int n = i + roll;
-diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
-index 5aec3e81fe24..5fd3bab8b803 100644
---- a/drivers/gpu/drm/omapdrm/omap_gem.c
-+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
-@@ -791,7 +791,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
- omap_obj->paddr = tiler_ssptr(block);
- omap_obj->block = block;
-
-- DBG("got paddr: %08x", omap_obj->paddr);
-+ DBG("got paddr: %pad", &omap_obj->paddr);
- }
-
- omap_obj->paddr_cnt++;
-@@ -988,9 +988,9 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
-
- off = drm_vma_node_start(&obj->vma_node);
-
-- seq_printf(m, "%08x: %2d (%2d) %08llx %08Zx (%2d) %p %4d",
-+ seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d",
- omap_obj->flags, obj->name, obj->refcount.refcount.counter,
-- off, omap_obj->paddr, omap_obj->paddr_cnt,
-+ off, &omap_obj->paddr, omap_obj->paddr_cnt,
- omap_obj->vaddr, omap_obj->roll);
-
- if (omap_obj->flags & OMAP_BO_TILED) {
-@@ -1468,8 +1468,8 @@ void omap_gem_init(struct drm_device *dev)
- entry->paddr = tiler_ssptr(block);
- entry->block = block;
-
-- DBG("%d:%d: %dx%d: paddr=%08x stride=%d", i, j, w, h,
-- entry->paddr,
-+ DBG("%d:%d: %dx%d: paddr=%pad stride=%d", i, j, w, h,
-+ &entry->paddr,
- usergart[i].stride_pfn << PAGE_SHIFT);
- }
- }
-diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
-index 046d5e660c04..5b62e212cbe5 100644
---- a/drivers/gpu/drm/omapdrm/omap_plane.c
-+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
-@@ -142,8 +142,8 @@ static void omap_plane_pre_apply(struct omap_drm_apply *apply)
- DBG("%dx%d -> %dx%d (%d)", info->width, info->height,
- info->out_width, info->out_height,
- info->screen_width);
-- DBG("%d,%d %08x %08x", info->pos_x, info->pos_y,
-- info->paddr, info->p_uv_addr);
-+ DBG("%d,%d %pad %pad", info->pos_x, info->pos_y,
-+ &info->paddr, &info->p_uv_addr);
-
- /* TODO: */
- ilace = false;
-diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
-index 7164045c06e4..bc9e56eb4e9c 100644
---- a/drivers/gpu/drm/radeon/cik.c
-+++ b/drivers/gpu/drm/radeon/cik.c
-@@ -3231,6 +3231,7 @@ static void cik_gpu_init(struct radeon_device *rdev)
- (rdev->pdev->device == 0x130B) ||
- (rdev->pdev->device == 0x130E) ||
- (rdev->pdev->device == 0x1315) ||
-+ (rdev->pdev->device == 0x1318) ||
- (rdev->pdev->device == 0x131B)) {
- rdev->config.cik.max_cu_per_sh = 4;
- rdev->config.cik.max_backends_per_se = 1;
-diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c
-index 1bdcccc54a1d..f745d2c1325e 100644
---- a/drivers/hid/hid-cherry.c
-+++ b/drivers/hid/hid-cherry.c
-@@ -28,7 +28,7 @@
- static __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- unsigned int *rsize)
- {
-- if (*rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
-+ if (*rsize >= 18 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
- hid_info(hdev, "fixing up Cherry Cymotion report descriptor\n");
- rdesc[11] = rdesc[16] = 0xff;
- rdesc[12] = rdesc[17] = 0x03;
-diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
-index e77696367591..b92bf01a1ae8 100644
---- a/drivers/hid/hid-kye.c
-+++ b/drivers/hid/hid-kye.c
-@@ -300,7 +300,7 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- * - change the button usage range to 4-7 for the extra
- * buttons
- */
-- if (*rsize >= 74 &&
-+ if (*rsize >= 75 &&
- rdesc[61] == 0x05 && rdesc[62] == 0x08 &&
- rdesc[63] == 0x19 && rdesc[64] == 0x08 &&
- rdesc[65] == 0x29 && rdesc[66] == 0x0f &&
-diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
-index 9fe9d4ac3114..b8207e0bfdc0 100644
---- a/drivers/hid/hid-lg.c
-+++ b/drivers/hid/hid-lg.c
-@@ -345,14 +345,14 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- struct usb_device_descriptor *udesc;
- __u16 bcdDevice, rev_maj, rev_min;
-
-- if ((drv_data->quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 &&
-+ if ((drv_data->quirks & LG_RDESC) && *rsize >= 91 && rdesc[83] == 0x26 &&
- rdesc[84] == 0x8c && rdesc[85] == 0x02) {
- hid_info(hdev,
- "fixing up Logitech keyboard report descriptor\n");
- rdesc[84] = rdesc[89] = 0x4d;
- rdesc[85] = rdesc[90] = 0x10;
- }
-- if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 50 &&
-+ if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 51 &&
- rdesc[32] == 0x81 && rdesc[33] == 0x06 &&
- rdesc[49] == 0x81 && rdesc[50] == 0x06) {
- hid_info(hdev,
-diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
-index f45279c3b11a..0b14d3261531 100644
---- a/drivers/hid/hid-logitech-dj.c
-+++ b/drivers/hid/hid-logitech-dj.c
-@@ -237,13 +237,6 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
- return;
- }
-
-- if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
-- (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
-- dev_err(&djrcv_hdev->dev, "%s: invalid device index:%d\n",
-- __func__, dj_report->device_index);
-- return;
-- }
--
- if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {
- /* The device is already known. No need to reallocate it. */
- dbg_hid("%s: device is already known\n", __func__);
-@@ -721,6 +714,12 @@ static int logi_dj_raw_event(struct hid_device *hdev,
- * device (via hid_input_report() ) and return 1 so hid-core does not do
- * anything else with it.
- */
-+ if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
-+ (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
-+ dev_err(&hdev->dev, "%s: invalid device index:%d\n",
-+ __func__, dj_report->device_index);
-+ return false;
-+ }
-
- spin_lock_irqsave(&djrcv_dev->lock, flags);
- if (dj_report->report_id == REPORT_ID_DJ_SHORT) {
-diff --git a/drivers/hid/hid-monterey.c b/drivers/hid/hid-monterey.c
-index 9e14c00eb1b6..25daf28b26bd 100644
---- a/drivers/hid/hid-monterey.c
-+++ b/drivers/hid/hid-monterey.c
-@@ -24,7 +24,7 @@
- static __u8 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- unsigned int *rsize)
- {
-- if (*rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
-+ if (*rsize >= 31 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
- hid_info(hdev, "fixing up button/consumer in HID report descriptor\n");
- rdesc[30] = 0x0c;
- }
-diff --git a/drivers/hid/hid-petalynx.c b/drivers/hid/hid-petalynx.c
-index 736b2502df4f..6aca4f2554bf 100644
---- a/drivers/hid/hid-petalynx.c
-+++ b/drivers/hid/hid-petalynx.c
-@@ -25,7 +25,7 @@
- static __u8 *pl_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- unsigned int *rsize)
- {
-- if (*rsize >= 60 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 &&
-+ if (*rsize >= 62 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 &&
- rdesc[41] == 0x00 && rdesc[59] == 0x26 &&
- rdesc[60] == 0xf9 && rdesc[61] == 0x00) {
- hid_info(hdev, "fixing up Petalynx Maxter Remote report descriptor\n");
-diff --git a/drivers/hid/hid-sunplus.c b/drivers/hid/hid-sunplus.c
-index 87fc91e1c8de..91072fa54663 100644
---- a/drivers/hid/hid-sunplus.c
-+++ b/drivers/hid/hid-sunplus.c
-@@ -24,7 +24,7 @@
- static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
- unsigned int *rsize)
- {
-- if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
-+ if (*rsize >= 112 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
- rdesc[106] == 0x03) {
- hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n");
- rdesc[105] = rdesc[110] = 0x03;
-diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
-index 7f9dc2f86b63..126516414c11 100644
---- a/drivers/hwmon/ads1015.c
-+++ b/drivers/hwmon/ads1015.c
-@@ -198,7 +198,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
- }
-
- channel = be32_to_cpup(property);
-- if (channel > ADS1015_CHANNELS) {
-+ if (channel >= ADS1015_CHANNELS) {
- dev_err(&client->dev,
- "invalid channel index %d on %s\n",
- channel, node->full_name);
-@@ -212,6 +212,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
- dev_err(&client->dev,
- "invalid gain on %s\n",
- node->full_name);
-+ return -EINVAL;
- }
- }
-
-@@ -222,6 +223,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
- dev_err(&client->dev,
- "invalid data_rate on %s\n",
- node->full_name);
-+ return -EINVAL;
- }
- }
-
-diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
-index 9f2be3dd28f3..8a67ec6279a4 100644
---- a/drivers/hwmon/amc6821.c
-+++ b/drivers/hwmon/amc6821.c
-@@ -360,11 +360,13 @@ static ssize_t set_pwm1_enable(
- if (config)
- return config;
-
-+ mutex_lock(&data->update_lock);
- config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF1);
- if (config < 0) {
- dev_err(&client->dev,
- "Error reading configuration register, aborting.\n");
-- return config;
-+ count = config;
-+ goto unlock;
- }
-
- switch (val) {
-@@ -381,14 +383,15 @@ static ssize_t set_pwm1_enable(
- config |= AMC6821_CONF1_FDRC1;
- break;
- default:
-- return -EINVAL;
-+ count = -EINVAL;
-+ goto unlock;
- }
-- mutex_lock(&data->update_lock);
- if (i2c_smbus_write_byte_data(client, AMC6821_REG_CONF1, config)) {
- dev_err(&client->dev,
- "Configuration register write error, aborting.\n");
- count = -EIO;
- }
-+unlock:
- mutex_unlock(&data->update_lock);
- return count;
- }
-@@ -493,8 +496,9 @@ static ssize_t set_temp_auto_point_temp(
- return -EINVAL;
- }
-
-- data->valid = 0;
- mutex_lock(&data->update_lock);
-+ data->valid = 0;
-+
- switch (ix) {
- case 0:
- ptemp[0] = clamp_val(val / 1000, 0,
-@@ -658,13 +662,14 @@ static ssize_t set_fan1_div(
- if (config)
- return config;
-
-+ mutex_lock(&data->update_lock);
- config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF4);
- if (config < 0) {
- dev_err(&client->dev,
- "Error reading configuration register, aborting.\n");
-- return config;
-+ count = config;
-+ goto EXIT;
- }
-- mutex_lock(&data->update_lock);
- switch (val) {
- case 2:
- config &= ~AMC6821_CONF4_PSPR;
-diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
-index 4ae3fff13f44..bea0a344fab5 100644
---- a/drivers/hwmon/dme1737.c
-+++ b/drivers/hwmon/dme1737.c
-@@ -247,8 +247,8 @@ struct dme1737_data {
- u8 pwm_acz[3];
- u8 pwm_freq[6];
- u8 pwm_rr[2];
-- u8 zone_low[3];
-- u8 zone_abs[3];
-+ s8 zone_low[3];
-+ s8 zone_abs[3];
- u8 zone_hyst[2];
- u32 alarms;
- };
-@@ -277,7 +277,7 @@ static inline int IN_FROM_REG(int reg, int nominal, int res)
- return (reg * nominal + (3 << (res - 3))) / (3 << (res - 2));
- }
-
--static inline int IN_TO_REG(int val, int nominal)
-+static inline int IN_TO_REG(long val, int nominal)
- {
- return clamp_val((val * 192 + nominal / 2) / nominal, 0, 255);
- }
-@@ -293,7 +293,7 @@ static inline int TEMP_FROM_REG(int reg, int res)
- return (reg * 1000) >> (res - 8);
- }
-
--static inline int TEMP_TO_REG(int val)
-+static inline int TEMP_TO_REG(long val)
- {
- return clamp_val((val < 0 ? val - 500 : val + 500) / 1000, -128, 127);
- }
-@@ -308,7 +308,7 @@ static inline int TEMP_RANGE_FROM_REG(int reg)
- return TEMP_RANGE[(reg >> 4) & 0x0f];
- }
-
--static int TEMP_RANGE_TO_REG(int val, int reg)
-+static int TEMP_RANGE_TO_REG(long val, int reg)
- {
- int i;
-
-@@ -331,7 +331,7 @@ static inline int TEMP_HYST_FROM_REG(int reg, int ix)
- return (((ix == 1) ? reg : reg >> 4) & 0x0f) * 1000;
- }
-
--static inline int TEMP_HYST_TO_REG(int val, int ix, int reg)
-+static inline int TEMP_HYST_TO_REG(long val, int ix, int reg)
- {
- int hyst = clamp_val((val + 500) / 1000, 0, 15);
-
-@@ -347,7 +347,7 @@ static inline int FAN_FROM_REG(int reg, int tpc)
- return (reg == 0 || reg == 0xffff) ? 0 : 90000 * 60 / reg;
- }
-
--static inline int FAN_TO_REG(int val, int tpc)
-+static inline int FAN_TO_REG(long val, int tpc)
- {
- if (tpc) {
- return clamp_val(val / tpc, 0, 0xffff);
-@@ -379,7 +379,7 @@ static inline int FAN_TYPE_FROM_REG(int reg)
- return (edge > 0) ? 1 << (edge - 1) : 0;
- }
-
--static inline int FAN_TYPE_TO_REG(int val, int reg)
-+static inline int FAN_TYPE_TO_REG(long val, int reg)
- {
- int edge = (val == 4) ? 3 : val;
-
-@@ -402,7 +402,7 @@ static int FAN_MAX_FROM_REG(int reg)
- return 1000 + i * 500;
- }
-
--static int FAN_MAX_TO_REG(int val)
-+static int FAN_MAX_TO_REG(long val)
- {
- int i;
-
-@@ -460,7 +460,7 @@ static inline int PWM_ACZ_FROM_REG(int reg)
- return acz[(reg >> 5) & 0x07];
- }
-
--static inline int PWM_ACZ_TO_REG(int val, int reg)
-+static inline int PWM_ACZ_TO_REG(long val, int reg)
- {
- int acz = (val == 4) ? 2 : val - 1;
-
-@@ -476,7 +476,7 @@ static inline int PWM_FREQ_FROM_REG(int reg)
- return PWM_FREQ[reg & 0x0f];
- }
-
--static int PWM_FREQ_TO_REG(int val, int reg)
-+static int PWM_FREQ_TO_REG(long val, int reg)
- {
- int i;
-
-@@ -510,7 +510,7 @@ static inline int PWM_RR_FROM_REG(int reg, int ix)
- return (rr & 0x08) ? PWM_RR[rr & 0x07] : 0;
- }
-
--static int PWM_RR_TO_REG(int val, int ix, int reg)
-+static int PWM_RR_TO_REG(long val, int ix, int reg)
- {
- int i;
-
-@@ -528,7 +528,7 @@ static inline int PWM_RR_EN_FROM_REG(int reg, int ix)
- return PWM_RR_FROM_REG(reg, ix) ? 1 : 0;
- }
-
--static inline int PWM_RR_EN_TO_REG(int val, int ix, int reg)
-+static inline int PWM_RR_EN_TO_REG(long val, int ix, int reg)
- {
- int en = (ix == 1) ? 0x80 : 0x08;
-
-@@ -1481,13 +1481,16 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
- {
- struct dme1737_data *data = dev_get_drvdata(dev);
-- long val;
-+ unsigned long val;
- int err;
-
-- err = kstrtol(buf, 10, &val);
-+ err = kstrtoul(buf, 10, &val);
- if (err)
- return err;
-
-+ if (val > 255)
-+ return -EINVAL;
-+
- data->vrm = val;
- return count;
- }
-diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
-index 73181be5b30b..814f7ee9026b 100644
---- a/drivers/hwmon/gpio-fan.c
-+++ b/drivers/hwmon/gpio-fan.c
-@@ -173,7 +173,7 @@ static int get_fan_speed_index(struct gpio_fan_data *fan_data)
- return -ENODEV;
- }
-
--static int rpm_to_speed_index(struct gpio_fan_data *fan_data, int rpm)
-+static int rpm_to_speed_index(struct gpio_fan_data *fan_data, unsigned long rpm)
- {
- struct gpio_fan_speed *speed = fan_data->speed;
- int i;
-diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
-index 9efadfc851bc..c1eb464f0fd0 100644
---- a/drivers/hwmon/lm78.c
-+++ b/drivers/hwmon/lm78.c
-@@ -108,7 +108,7 @@ static inline int FAN_FROM_REG(u8 val, int div)
- * TEMP: mC (-128C to +127C)
- * REG: 1C/bit, two's complement
- */
--static inline s8 TEMP_TO_REG(int val)
-+static inline s8 TEMP_TO_REG(long val)
- {
- int nval = clamp_val(val, -128000, 127000) ;
- return nval < 0 ? (nval - 500) / 1000 : (nval + 500) / 1000;
-diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
-index bed4af358308..21d6cc813a6d 100644
---- a/drivers/hwmon/lm85.c
-+++ b/drivers/hwmon/lm85.c
-@@ -158,7 +158,7 @@ static inline u16 FAN_TO_REG(unsigned long val)
-
- /* Temperature is reported in .001 degC increments */
- #define TEMP_TO_REG(val) \
-- clamp_val(SCALE(val, 1000, 1), -127, 127)
-+ DIV_ROUND_CLOSEST(clamp_val((val), -127000, 127000), 1000)
- #define TEMPEXT_FROM_REG(val, ext) \
- SCALE(((val) << 4) + (ext), 16, 1000)
- #define TEMP_FROM_REG(val) ((val) * 1000)
-@@ -192,7 +192,7 @@ static const int lm85_range_map[] = {
- 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
- };
-
--static int RANGE_TO_REG(int range)
-+static int RANGE_TO_REG(long range)
- {
- int i;
-
-@@ -214,7 +214,7 @@ static const int adm1027_freq_map[8] = { /* 1 Hz */
- 11, 15, 22, 29, 35, 44, 59, 88
- };
-
--static int FREQ_TO_REG(const int *map, int freq)
-+static int FREQ_TO_REG(const int *map, unsigned long freq)
- {
- int i;
-
-@@ -463,6 +463,9 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
- if (err)
- return err;
-
-+ if (val > 255)
-+ return -EINVAL;
-+
- data->vrm = val;
- return count;
- }
-diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
-index 3532026e25da..bf1d7893d51c 100644
---- a/drivers/hwmon/sis5595.c
-+++ b/drivers/hwmon/sis5595.c
-@@ -159,7 +159,7 @@ static inline int TEMP_FROM_REG(s8 val)
- {
- return val * 830 + 52120;
- }
--static inline s8 TEMP_TO_REG(int val)
-+static inline s8 TEMP_TO_REG(long val)
- {
- int nval = clamp_val(val, -54120, 157530) ;
- return nval < 0 ? (nval - 5212 - 415) / 830 : (nval - 5212 + 415) / 830;
-diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
-index 843d01268ae9..c56be739006b 100644
---- a/drivers/i2c/busses/i2c-at91.c
-+++ b/drivers/i2c/busses/i2c-at91.c
-@@ -210,7 +210,7 @@ static void at91_twi_write_data_dma_callback(void *data)
- struct at91_twi_dev *dev = (struct at91_twi_dev *)data;
-
- dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg),
-- dev->buf_len, DMA_MEM_TO_DEV);
-+ dev->buf_len, DMA_TO_DEVICE);
-
- at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP);
- }
-@@ -289,7 +289,7 @@ static void at91_twi_read_data_dma_callback(void *data)
- struct at91_twi_dev *dev = (struct at91_twi_dev *)data;
-
- dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg),
-- dev->buf_len, DMA_DEV_TO_MEM);
-+ dev->buf_len, DMA_FROM_DEVICE);
-
- /* The last two bytes have to be read without using dma */
- dev->buf += dev->buf_len - 2;
-diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
-index 5a9bfa71df86..540fe114ec60 100644
---- a/drivers/misc/mei/client.c
-+++ b/drivers/misc/mei/client.c
-@@ -459,6 +459,7 @@ int mei_cl_disconnect(struct mei_cl *cl)
- cl_err(dev, cl, "failed to disconnect.\n");
- goto free;
- }
-+ cl->timer_count = MEI_CONNECT_TIMEOUT;
- mdelay(10); /* Wait for hardware disconnection ready */
- list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
- } else {
-@@ -563,6 +564,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
- cl->timer_count = MEI_CONNECT_TIMEOUT;
- list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
- } else {
-+ cl->state = MEI_FILE_INITIALIZING;
- list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
- }
-
-diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
-index a58320c0c049..31149010224b 100644
---- a/drivers/misc/mei/nfc.c
-+++ b/drivers/misc/mei/nfc.c
-@@ -342,9 +342,10 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
- ndev = (struct mei_nfc_dev *) cldev->priv_data;
- dev = ndev->cl->dev;
-
-+ err = -ENOMEM;
- mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL);
- if (!mei_buf)
-- return -ENOMEM;
-+ goto out;
-
- hdr = (struct mei_nfc_hci_hdr *) mei_buf;
- hdr->cmd = MEI_NFC_CMD_HCI_SEND;
-@@ -354,12 +355,9 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
- hdr->data_size = length;
-
- memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length);
--
- err = __mei_cl_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE);
- if (err < 0)
-- return err;
--
-- kfree(mei_buf);
-+ goto out;
-
- if (!wait_event_interruptible_timeout(ndev->send_wq,
- ndev->recv_req_id == ndev->req_id, HZ)) {
-@@ -368,7 +366,8 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
- } else {
- ndev->req_id++;
- }
--
-+out:
-+ kfree(mei_buf);
- return err;
- }
-
-diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
-index 45113daaa778..e27a3dc9f4e8 100644
---- a/drivers/pci/pci-label.c
-+++ b/drivers/pci/pci-label.c
-@@ -168,8 +168,8 @@ enum acpi_attr_enum {
- static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
- {
- int len;
-- len = utf16s_to_utf8s((const wchar_t *)obj->string.pointer,
-- obj->string.length,
-+ len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
-+ obj->buffer.length,
- UTF16_LITTLE_ENDIAN,
- buf, PAGE_SIZE);
- buf[len] = '\n';
-@@ -194,16 +194,22 @@ dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr)
- tmp = obj->package.elements;
- if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
- tmp[0].type == ACPI_TYPE_INTEGER &&
-- tmp[1].type == ACPI_TYPE_STRING) {
-+ (tmp[1].type == ACPI_TYPE_STRING ||
-+ tmp[1].type == ACPI_TYPE_BUFFER)) {
- /*
- * The second string element is optional even when
- * this _DSM is implemented; when not implemented,
- * this entry must return a null string.
- */
-- if (attr == ACPI_ATTR_INDEX_SHOW)
-+ if (attr == ACPI_ATTR_INDEX_SHOW) {
- scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
-- else if (attr == ACPI_ATTR_LABEL_SHOW)
-- dsm_label_utf16s_to_utf8s(tmp + 1, buf);
-+ } else if (attr == ACPI_ATTR_LABEL_SHOW) {
-+ if (tmp[1].type == ACPI_TYPE_STRING)
-+ scnprintf(buf, PAGE_SIZE, "%s\n",
-+ tmp[1].string.pointer);
-+ else if (tmp[1].type == ACPI_TYPE_BUFFER)
-+ dsm_label_utf16s_to_utf8s(tmp + 1, buf);
-+ }
- len = strlen(buf) > 0 ? strlen(buf) : -1;
- }
-
-diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
-index be36adf33ab0..dae70d216762 100644
---- a/drivers/pci/pci.c
-+++ b/drivers/pci/pci.c
-@@ -830,12 +830,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
-
- if (!__pci_complete_power_transition(dev, state))
- error = 0;
-- /*
-- * When aspm_policy is "powersave" this call ensures
-- * that ASPM is configured.
-- */
-- if (!error && dev->bus->self)
-- pcie_aspm_powersave_config_link(dev->bus->self);
-
- return error;
- }
-@@ -1181,12 +1175,18 @@ EXPORT_SYMBOL_GPL(pci_load_and_free_saved_state);
- static int do_pci_enable_device(struct pci_dev *dev, int bars)
- {
- int err;
-+ struct pci_dev *bridge;
- u16 cmd;
- u8 pin;
-
- err = pci_set_power_state(dev, PCI_D0);
- if (err < 0 && err != -EIO)
- return err;
-+
-+ bridge = pci_upstream_bridge(dev);
-+ if (bridge)
-+ pcie_aspm_powersave_config_link(bridge);
-+
- err = pcibios_enable_device(dev, bars);
- if (err < 0)
- return err;
-diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
-index 868318a7067c..528bff5ec91f 100644
---- a/drivers/scsi/hpsa.c
-+++ b/drivers/scsi/hpsa.c
-@@ -3131,7 +3131,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
- }
- if (ioc->Request.Type.Direction == XFER_WRITE) {
- if (copy_from_user(buff[sg_used], data_ptr, sz)) {
-- status = -ENOMEM;
-+ status = -EFAULT;
- goto cleanup1;
- }
- } else
-@@ -4367,9 +4367,9 @@ static inline void hpsa_set_driver_support_bits(struct ctlr_info *h)
- {
- u32 driver_support;
-
--#ifdef CONFIG_X86
-- /* Need to enable prefetch in the SCSI core for 6400 in x86 */
- driver_support = readl(&(h->cfgtable->driver_support));
-+ /* Need to enable prefetch in the SCSI core for 6400 in x86 */
-+#ifdef CONFIG_X86
- driver_support |= ENABLE_SCSI_PREFETCH;
- #endif
- driver_support |= ENABLE_UNIT_ATTN;
-diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
-index e516bb69f3b4..907aa3078946 100644
---- a/drivers/staging/et131x/et131x.c
-+++ b/drivers/staging/et131x/et131x.c
-@@ -1422,22 +1422,16 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
- * @reg: the register to read
- * @value: 16-bit value to write
- */
--static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
-+static int et131x_mii_write(struct et131x_adapter *adapter, u8 addr, u8 reg,
-+ u16 value)
- {
- struct mac_regs __iomem *mac = &adapter->regs->mac;
-- struct phy_device *phydev = adapter->phydev;
- int status = 0;
-- u8 addr;
- u32 delay = 0;
- u32 mii_addr;
- u32 mii_cmd;
- u32 mii_indicator;
-
-- if (!phydev)
-- return -EIO;
--
-- addr = phydev->addr;
--
- /* Save a local copy of the registers we are dealing with so we can
- * set them back
- */
-@@ -1632,17 +1626,7 @@ static int et131x_mdio_write(struct mii_bus *bus, int phy_addr,
- struct net_device *netdev = bus->priv;
- struct et131x_adapter *adapter = netdev_priv(netdev);
-
-- return et131x_mii_write(adapter, reg, value);
--}
--
--static int et131x_mdio_reset(struct mii_bus *bus)
--{
-- struct net_device *netdev = bus->priv;
-- struct et131x_adapter *adapter = netdev_priv(netdev);
--
-- et131x_mii_write(adapter, MII_BMCR, BMCR_RESET);
--
-- return 0;
-+ return et131x_mii_write(adapter, phy_addr, reg, value);
- }
-
- /* et1310_phy_power_switch - PHY power control
-@@ -1657,18 +1641,20 @@ static int et131x_mdio_reset(struct mii_bus *bus)
- static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down)
- {
- u16 data;
-+ struct phy_device *phydev = adapter->phydev;
-
- et131x_mii_read(adapter, MII_BMCR, &data);
- data &= ~BMCR_PDOWN;
- if (down)
- data |= BMCR_PDOWN;
-- et131x_mii_write(adapter, MII_BMCR, data);
-+ et131x_mii_write(adapter, phydev->addr, MII_BMCR, data);
- }
-
- /* et131x_xcvr_init - Init the phy if we are setting it into force mode */
- static void et131x_xcvr_init(struct et131x_adapter *adapter)
- {
- u16 lcr2;
-+ struct phy_device *phydev = adapter->phydev;
-
- /* Set the LED behavior such that LED 1 indicates speed (off =
- * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates
-@@ -1689,7 +1675,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
- else
- lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT);
-
-- et131x_mii_write(adapter, PHY_LED_2, lcr2);
-+ et131x_mii_write(adapter, phydev->addr, PHY_LED_2, lcr2);
- }
- }
-
-@@ -3638,14 +3624,14 @@ static void et131x_adjust_link(struct net_device *netdev)
-
- et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
- ®ister18);
-- et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
-- register18 | 0x4);
-- et131x_mii_write(adapter, PHY_INDEX_REG,
-+ et131x_mii_write(adapter, phydev->addr,
-+ PHY_MPHY_CONTROL_REG, register18 | 0x4);
-+ et131x_mii_write(adapter, phydev->addr, PHY_INDEX_REG,
- register18 | 0x8402);
-- et131x_mii_write(adapter, PHY_DATA_REG,
-+ et131x_mii_write(adapter, phydev->addr, PHY_DATA_REG,
- register18 | 511);
-- et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
-- register18);
-+ et131x_mii_write(adapter, phydev->addr,
-+ PHY_MPHY_CONTROL_REG, register18);
- }
-
- et1310_config_flow_control(adapter);
-@@ -3657,7 +3643,8 @@ static void et131x_adjust_link(struct net_device *netdev)
- et131x_mii_read(adapter, PHY_CONFIG, ®);
- reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
- reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
-- et131x_mii_write(adapter, PHY_CONFIG, reg);
-+ et131x_mii_write(adapter, phydev->addr, PHY_CONFIG,
-+ reg);
- }
-
- et131x_set_rx_dma_timer(adapter);
-@@ -3670,14 +3657,14 @@ static void et131x_adjust_link(struct net_device *netdev)
-
- et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
- ®ister18);
-- et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
-- register18 | 0x4);
-- et131x_mii_write(adapter, PHY_INDEX_REG,
-- register18 | 0x8402);
-- et131x_mii_write(adapter, PHY_DATA_REG,
-- register18 | 511);
-- et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
-- register18);
-+ et131x_mii_write(adapter, phydev->addr,
-+ PHY_MPHY_CONTROL_REG, register18 | 0x4);
-+ et131x_mii_write(adapter, phydev->addr,
-+ PHY_INDEX_REG, register18 | 0x8402);
-+ et131x_mii_write(adapter, phydev->addr,
-+ PHY_DATA_REG, register18 | 511);
-+ et131x_mii_write(adapter, phydev->addr,
-+ PHY_MPHY_CONTROL_REG, register18);
- }
-
- /* Free the packets being actively sent & stopped */
-@@ -4646,10 +4633,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
- /* Copy address into the net_device struct */
- memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
-
-- /* Init variable for counting how long we do not have link status */
-- adapter->boot_coma = 0;
-- et1310_disable_phy_coma(adapter);
--
- rc = -ENOMEM;
-
- /* Setup the mii_bus struct */
-@@ -4665,7 +4648,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
- adapter->mii_bus->priv = netdev;
- adapter->mii_bus->read = et131x_mdio_read;
- adapter->mii_bus->write = et131x_mdio_write;
-- adapter->mii_bus->reset = et131x_mdio_reset;
- adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int),
- GFP_KERNEL);
- if (!adapter->mii_bus->irq)
-@@ -4689,6 +4671,10 @@ static int et131x_pci_setup(struct pci_dev *pdev,
- /* Setup et1310 as per the documentation */
- et131x_adapter_setup(adapter);
-
-+ /* Init variable for counting how long we do not have link status */
-+ adapter->boot_coma = 0;
-+ et1310_disable_phy_coma(adapter);
-+
- /* We can enable interrupts now
- *
- * NOTE - Because registration of interrupt handler is done in the
-diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
-index 2f40ff5901d6..fed699fc5918 100644
---- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
-+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
-@@ -53,9 +53,11 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
- {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
- /*=== Customer ID ===*/
- /****** 8188EUS ********/
-+ {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */
- {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
- {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
- {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
-+ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
- {} /* Terminating entry */
- };
-
-diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
-index ece2049bd270..25b8f6868788 100644
---- a/drivers/tty/serial/serial_core.c
-+++ b/drivers/tty/serial/serial_core.c
-@@ -235,6 +235,9 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
- /*
- * Turn off DTR and RTS early.
- */
-+ if (uart_console(uport) && tty)
-+ uport->cons->cflag = tty->termios.c_cflag;
-+
- if (!tty || (tty->termios.c_cflag & HUPCL))
- uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
-
-diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
-index 90e18f6fa2bb..9ca77166d37e 100644
---- a/drivers/usb/core/devio.c
-+++ b/drivers/usb/core/devio.c
-@@ -1411,7 +1411,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
- u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
- if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
- u |= URB_ISO_ASAP;
-- if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
-+ if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK && is_in)
- u |= URB_SHORT_NOT_OK;
- if (uurb->flags & USBDEVFS_URB_NO_FSBR)
- u |= URB_NO_FSBR;
-diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
-index 36b1e856bd00..6650df70bb35 100644
---- a/drivers/usb/core/hub.c
-+++ b/drivers/usb/core/hub.c
-@@ -1695,8 +1695,14 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
- * - Change autosuspend delay of hub can avoid unnecessary auto
- * suspend timer for hub, also may decrease power consumption
- * of USB bus.
-+ *
-+ * - If user has indicated to prevent autosuspend by passing
-+ * usbcore.autosuspend = -1 then keep autosuspend disabled.
- */
-- pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
-+#ifdef CONFIG_PM_RUNTIME
-+ if (hdev->dev.power.autosuspend_delay >= 0)
-+ pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
-+#endif
-
- /*
- * Hubs have proper suspend/resume support, except for root hubs
-@@ -3174,6 +3180,43 @@ static int finish_port_resume(struct usb_device *udev)
- }
-
- /*
-+ * There are some SS USB devices which take longer time for link training.
-+ * XHCI specs 4.19.4 says that when Link training is successful, port
-+ * sets CSC bit to 1. So if SW reads port status before successful link
-+ * training, then it will not find device to be present.
-+ * USB Analyzer log with such buggy devices show that in some cases
-+ * device switch on the RX termination after long delay of host enabling
-+ * the VBUS. In few other cases it has been seen that device fails to
-+ * negotiate link training in first attempt. It has been
-+ * reported till now that few devices take as long as 2000 ms to train
-+ * the link after host enabling its VBUS and termination. Following
-+ * routine implements a 2000 ms timeout for link training. If in a case
-+ * link trains before timeout, loop will exit earlier.
-+ *
-+ * FIXME: If a device was connected before suspend, but was removed
-+ * while system was asleep, then the loop in the following routine will
-+ * only exit at timeout.
-+ *
-+ * This routine should only be called when persist is enabled for a SS
-+ * device.
-+ */
-+static int wait_for_ss_port_enable(struct usb_device *udev,
-+ struct usb_hub *hub, int *port1,
-+ u16 *portchange, u16 *portstatus)
-+{
-+ int status = 0, delay_ms = 0;
-+
-+ while (delay_ms < 2000) {
-+ if (status || *portstatus & USB_PORT_STAT_CONNECTION)
-+ break;
-+ msleep(20);
-+ delay_ms += 20;
-+ status = hub_port_status(hub, *port1, portstatus, portchange);
-+ }
-+ return status;
-+}
-+
-+/*
- * usb_port_resume - re-activate a suspended usb device's upstream port
- * @udev: device to re-activate, not a root hub
- * Context: must be able to sleep; device not locked; pm locks held
-@@ -3275,6 +3318,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
-
- clear_bit(port1, hub->busy_bits);
-
-+ if (udev->persist_enabled && hub_is_superspeed(hub->hdev))
-+ status = wait_for_ss_port_enable(udev, hub, &port1, &portchange,
-+ &portstatus);
-+
- status = check_port_resume_type(udev,
- hub, port1, status, portchange, portstatus);
- if (status == 0)
-diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
-index 7ae0c4d51741..7d6f64c447bf 100644
---- a/drivers/usb/host/ehci-hub.c
-+++ b/drivers/usb/host/ehci-hub.c
-@@ -1239,7 +1239,7 @@ static int ehci_hub_control (
- if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) {
- spin_unlock_irqrestore(&ehci->lock, flags);
- retval = ehset_single_step_set_feature(hcd,
-- wIndex);
-+ wIndex + 1);
- spin_lock_irqsave(&ehci->lock, flags);
- break;
- }
-diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
-index 3e86bf4371b3..ca7b964124af 100644
---- a/drivers/usb/host/ehci-pci.c
-+++ b/drivers/usb/host/ehci-pci.c
-@@ -35,6 +35,21 @@ static const char hcd_name[] = "ehci-pci";
- #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70
-
- /*-------------------------------------------------------------------------*/
-+#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939
-+static inline bool is_intel_quark_x1000(struct pci_dev *pdev)
-+{
-+ return pdev->vendor == PCI_VENDOR_ID_INTEL &&
-+ pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC;
-+}
-+
-+/*
-+ * 0x84 is the offset of in/out threshold register,
-+ * and it is the same offset as the register of 'hostpc'.
-+ */
-+#define intel_quark_x1000_insnreg01 hostpc
-+
-+/* Maximum usable threshold value is 0x7f dwords for both IN and OUT */
-+#define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD 0x007f007f
-
- /* called after powerup, by probe or system-pm "wakeup" */
- static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
-@@ -50,6 +65,16 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
- if (!retval)
- ehci_dbg(ehci, "MWI active\n");
-
-+ /* Reset the threshold limit */
-+ if (is_intel_quark_x1000(pdev)) {
-+ /*
-+ * For the Intel QUARK X1000, raise the I/O threshold to the
-+ * maximum usable value in order to improve performance.
-+ */
-+ ehci_writel(ehci, INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD,
-+ ehci->regs->intel_quark_x1000_insnreg01);
-+ }
-+
- return 0;
- }
-
-diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
-index 45032e933e18..04f2186939d2 100644
---- a/drivers/usb/host/ohci-dbg.c
-+++ b/drivers/usb/host/ohci-dbg.c
-@@ -236,7 +236,7 @@ ohci_dump_roothub (
- }
- }
-
--static void ohci_dump (struct ohci_hcd *controller, int verbose)
-+static void ohci_dump(struct ohci_hcd *controller)
- {
- ohci_dbg (controller, "OHCI controller state\n");
-
-@@ -464,15 +464,16 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
- static ssize_t fill_async_buffer(struct debug_buffer *buf)
- {
- struct ohci_hcd *ohci;
-- size_t temp;
-+ size_t temp, size;
- unsigned long flags;
-
- ohci = buf->ohci;
-+ size = PAGE_SIZE;
-
- /* display control and bulk lists together, for simplicity */
- spin_lock_irqsave (&ohci->lock, flags);
-- temp = show_list(ohci, buf->page, buf->count, ohci->ed_controltail);
-- temp += show_list(ohci, buf->page + temp, buf->count - temp,
-+ temp = show_list(ohci, buf->page, size, ohci->ed_controltail);
-+ temp += show_list(ohci, buf->page + temp, size - temp,
- ohci->ed_bulktail);
- spin_unlock_irqrestore (&ohci->lock, flags);
-
-diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
-index 3586460fb2a1..34fc86ccb591 100644
---- a/drivers/usb/host/ohci-hcd.c
-+++ b/drivers/usb/host/ohci-hcd.c
-@@ -76,8 +76,8 @@ static const char hcd_name [] = "ohci_hcd";
- #include "ohci.h"
- #include "pci-quirks.h"
-
--static void ohci_dump (struct ohci_hcd *ohci, int verbose);
--static void ohci_stop (struct usb_hcd *hcd);
-+static void ohci_dump(struct ohci_hcd *ohci);
-+static void ohci_stop(struct usb_hcd *hcd);
-
- #include "ohci-hub.c"
- #include "ohci-dbg.c"
-@@ -744,7 +744,7 @@ retry:
- ohci->ed_to_check = NULL;
- }
-
-- ohci_dump (ohci, 1);
-+ ohci_dump(ohci);
-
- return 0;
- }
-@@ -825,7 +825,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
- usb_hc_died(hcd);
- }
-
-- ohci_dump (ohci, 1);
-+ ohci_dump(ohci);
- ohci_usb_reset (ohci);
- }
-
-@@ -925,7 +925,7 @@ static void ohci_stop (struct usb_hcd *hcd)
- {
- struct ohci_hcd *ohci = hcd_to_ohci (hcd);
-
-- ohci_dump (ohci, 1);
-+ ohci_dump(ohci);
-
- if (quirk_nec(ohci))
- flush_work(&ohci->nec_work);
-diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
-index d4253e319428..a8bde5b8cbdd 100644
---- a/drivers/usb/host/ohci-q.c
-+++ b/drivers/usb/host/ohci-q.c
-@@ -311,8 +311,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
- * - ED_OPER: when there's any request queued, the ED gets rescheduled
- * immediately. HC should be working on them.
- *
-- * - ED_IDLE: when there's no TD queue. there's no reason for the HC
-- * to care about this ED; safe to disable the endpoint.
-+ * - ED_IDLE: when there's no TD queue or the HC isn't running.
- *
- * When finish_unlinks() runs later, after SOF interrupt, it will often
- * complete one or more URB unlinks before making that state change.
-@@ -926,6 +925,10 @@ rescan_all:
- int completed, modified;
- __hc32 *prev;
-
-+ /* Is this ED already invisible to the hardware? */
-+ if (ed->state == ED_IDLE)
-+ goto ed_idle;
-+
- /* only take off EDs that the HC isn't using, accounting for
- * frame counter wraps and EDs with partially retired TDs
- */
-@@ -955,12 +958,20 @@ skip_ed:
- }
- }
-
-+ /* ED's now officially unlinked, hc doesn't see */
-+ ed->state = ED_IDLE;
-+ if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
-+ ohci->eds_scheduled--;
-+ ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
-+ ed->hwNextED = 0;
-+ wmb();
-+ ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE);
-+ed_idle:
-+
- /* reentrancy: if we drop the schedule lock, someone might
- * have modified this list. normally it's just prepending
- * entries (which we'd ignore), but paranoia won't hurt.
- */
-- *last = ed->ed_next;
-- ed->ed_next = NULL;
- modified = 0;
-
- /* unlink urbs as requested, but rescan the list after
-@@ -1018,19 +1029,20 @@ rescan_this:
- if (completed && !list_empty (&ed->td_list))
- goto rescan_this;
-
-- /* ED's now officially unlinked, hc doesn't see */
-- ed->state = ED_IDLE;
-- if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
-- ohci->eds_scheduled--;
-- ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
-- ed->hwNextED = 0;
-- wmb ();
-- ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE);
--
-- /* but if there's work queued, reschedule */
-- if (!list_empty (&ed->td_list)) {
-- if (ohci->rh_state == OHCI_RH_RUNNING)
-- ed_schedule (ohci, ed);
-+ /*
-+ * If no TDs are queued, take ED off the ed_rm_list.
-+ * Otherwise, if the HC is running, reschedule.
-+ * If not, leave it on the list for further dequeues.
-+ */
-+ if (list_empty(&ed->td_list)) {
-+ *last = ed->ed_next;
-+ ed->ed_next = NULL;
-+ } else if (ohci->rh_state == OHCI_RH_RUNNING) {
-+ *last = ed->ed_next;
-+ ed->ed_next = NULL;
-+ ed_schedule(ohci, ed);
-+ } else {
-+ last = &ed->ed_next;
- }
-
- if (modified)
-diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
-index 08a5f92d6c54..75cb1ff9d26b 100644
---- a/drivers/usb/host/xhci-pci.c
-+++ b/drivers/usb/host/xhci-pci.c
-@@ -101,6 +101,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
- /* AMD PLL quirk */
- if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
- xhci->quirks |= XHCI_AMD_PLL_FIX;
-+
-+ if (pdev->vendor == PCI_VENDOR_ID_AMD)
-+ xhci->quirks |= XHCI_TRUST_TX_LENGTH;
-+
- if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
- xhci->quirks |= XHCI_LPM_SUPPORT;
- xhci->quirks |= XHCI_INTEL_HOST;
-diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
-index 65091d9aa997..0e6665a82e88 100644
---- a/drivers/usb/host/xhci-ring.c
-+++ b/drivers/usb/host/xhci-ring.c
-@@ -2612,7 +2612,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
- * last TRB of the previous TD. The command completion handle
- * will take care the rest.
- */
-- if (!event_seg && trb_comp_code == COMP_STOP_INVAL) {
-+ if (!event_seg && (trb_comp_code == COMP_STOP ||
-+ trb_comp_code == COMP_STOP_INVAL)) {
- ret = 0;
- goto cleanup;
- }
-diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
-index 8a3813be1b28..8b0f517abb6b 100644
---- a/drivers/usb/serial/ftdi_sio.c
-+++ b/drivers/usb/serial/ftdi_sio.c
-@@ -151,6 +151,7 @@ static const struct usb_device_id id_table_combined[] = {
- { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
-+ { USB_DEVICE(FTDI_VID, FTDI_BM_ATOM_NANO_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
-@@ -673,6 +674,8 @@ static const struct usb_device_id id_table_combined[] = {
- { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
- { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
- { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
-+ { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
-+ { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
- { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
-@@ -945,6 +948,8 @@ static const struct usb_device_id id_table_combined[] = {
- { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) },
- { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) },
- { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) },
-+ /* ekey Devices */
-+ { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },
- /* Infineon Devices */
- { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) },
- { } /* Terminating entry */
-diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
-index c4777bc6aee0..70b0b1d88ae9 100644
---- a/drivers/usb/serial/ftdi_sio_ids.h
-+++ b/drivers/usb/serial/ftdi_sio_ids.h
-@@ -42,6 +42,8 @@
- /* www.candapter.com Ewert Energy Systems CANdapter device */
- #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
-
-+#define FTDI_BM_ATOM_NANO_PID 0xa559 /* Basic Micro ATOM Nano USB2Serial */
-+
- /*
- * Texas Instruments XDS100v2 JTAG / BeagleBone A3
- * http://processors.wiki.ti.com/index.php/XDS100
-@@ -140,12 +142,15 @@
- /*
- * Xsens Technologies BV products (http://www.xsens.com).
- */
--#define XSENS_CONVERTER_0_PID 0xD388
--#define XSENS_CONVERTER_1_PID 0xD389
-+#define XSENS_VID 0x2639
-+#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
-+#define XSENS_MTW_PID 0x0200 /* Xsens MTw */
-+#define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */
-+#define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */
- #define XSENS_CONVERTER_2_PID 0xD38A
--#define XSENS_CONVERTER_3_PID 0xD38B
--#define XSENS_CONVERTER_4_PID 0xD38C
--#define XSENS_CONVERTER_5_PID 0xD38D
-+#define XSENS_CONVERTER_3_PID 0xD38B /* Xsens USB-serial converter */
-+#define XSENS_CONVERTER_4_PID 0xD38C /* Xsens Wireless Receiver */
-+#define XSENS_CONVERTER_5_PID 0xD38D /* Xsens Awinda Station */
- #define XSENS_CONVERTER_6_PID 0xD38E
- #define XSENS_CONVERTER_7_PID 0xD38F
-
-@@ -1375,3 +1380,8 @@
- #define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */
- #define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */
- #define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */
-+
-+/*
-+ * ekey biometric systems GmbH (http://ekey.net/)
-+ */
-+#define FTDI_EKEY_CONV_USB_PID 0xCB08 /* Converter USB */
-diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
-index e62f2dff8b7d..6c3734d2b45a 100644
---- a/drivers/usb/serial/whiteheat.c
-+++ b/drivers/usb/serial/whiteheat.c
-@@ -514,6 +514,10 @@ static void command_port_read_callback(struct urb *urb)
- dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);
- return;
- }
-+ if (!urb->actual_length) {
-+ dev_dbg(&urb->dev->dev, "%s - empty response, exiting.\n", __func__);
-+ return;
-+ }
- if (status) {
- dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);
- if (status != -ENOENT)
-@@ -534,7 +538,8 @@ static void command_port_read_callback(struct urb *urb)
- /* These are unsolicited reports from the firmware, hence no
- waiting command to wakeup */
- dev_dbg(&urb->dev->dev, "%s - event received\n", __func__);
-- } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
-+ } else if ((data[0] == WHITEHEAT_GET_DTR_RTS) &&
-+ (urb->actual_length - 1 <= sizeof(command_info->result_buffer))) {
- memcpy(command_info->result_buffer, &data[1],
- urb->actual_length - 1);
- command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
-diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
-index 640b3cf1a338..172a8bc27abd 100644
---- a/drivers/xen/events/events_fifo.c
-+++ b/drivers/xen/events/events_fifo.c
-@@ -67,10 +67,9 @@ static event_word_t *event_array[MAX_EVENT_ARRAY_PAGES] __read_mostly;
- static unsigned event_array_pages __read_mostly;
-
- /*
-- * sync_set_bit() and friends must be unsigned long aligned on non-x86
-- * platforms.
-+ * sync_set_bit() and friends must be unsigned long aligned.
- */
--#if !defined(CONFIG_X86) && BITS_PER_LONG > 32
-+#if BITS_PER_LONG > 32
-
- #define BM(w) (unsigned long *)((unsigned long)w & ~0x7UL)
- #define EVTCHN_FIFO_BIT(b, w) \
-diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
-index 14d29d02097d..6244f9cf8ae3 100644
---- a/fs/btrfs/backref.c
-+++ b/fs/btrfs/backref.c
-@@ -275,9 +275,8 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
- }
- if (ret > 0)
- goto next;
-- ret = ulist_add_merge(parents, eb->start,
-- (uintptr_t)eie,
-- (u64 *)&old, GFP_NOFS);
-+ ret = ulist_add_merge_ptr(parents, eb->start,
-+ eie, (void **)&old, GFP_NOFS);
- if (ret < 0)
- break;
- if (!ret && extent_item_pos) {
-@@ -985,16 +984,19 @@ again:
- ret = -EIO;
- goto out;
- }
-+ btrfs_tree_read_lock(eb);
-+ btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
- ret = find_extent_in_eb(eb, bytenr,
- *extent_item_pos, &eie);
-+ btrfs_tree_read_unlock_blocking(eb);
- free_extent_buffer(eb);
- if (ret < 0)
- goto out;
- ref->inode_list = eie;
- }
-- ret = ulist_add_merge(refs, ref->parent,
-- (uintptr_t)ref->inode_list,
-- (u64 *)&eie, GFP_NOFS);
-+ ret = ulist_add_merge_ptr(refs, ref->parent,
-+ ref->inode_list,
-+ (void **)&eie, GFP_NOFS);
- if (ret < 0)
- goto out;
- if (!ret && extent_item_pos) {
-diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
-index 2eea43f5067c..1a858947006e 100644
---- a/fs/btrfs/extent_io.c
-+++ b/fs/btrfs/extent_io.c
-@@ -2525,6 +2525,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
- test_bit(BIO_UPTODATE, &bio->bi_flags);
- if (err)
- uptodate = 0;
-+ offset += len;
- continue;
- }
- }
-diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
-index 127555b29f58..ca248b0687f4 100644
---- a/fs/btrfs/file-item.c
-+++ b/fs/btrfs/file-item.c
-@@ -756,7 +756,7 @@ again:
- found_next = 1;
- if (ret != 0)
- goto insert;
-- slot = 0;
-+ slot = path->slots[0];
- }
- btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot);
- if (found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
-diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
-index d3d44486290b..c69c76351f12 100644
---- a/fs/btrfs/inode.c
-+++ b/fs/btrfs/inode.c
-@@ -701,6 +701,18 @@ retry:
- unlock_extent(io_tree, async_extent->start,
- async_extent->start +
- async_extent->ram_size - 1);
-+
-+ /*
-+ * we need to redirty the pages if we decide to
-+ * fallback to uncompressed IO, otherwise we
-+ * will not submit these pages down to lower
-+ * layers.
-+ */
-+ extent_range_redirty_for_io(inode,
-+ async_extent->start,
-+ async_extent->start +
-+ async_extent->ram_size - 1);
-+
- goto retry;
- }
- goto out_free;
-diff --git a/fs/btrfs/ulist.h b/fs/btrfs/ulist.h
-index 7f78cbf5cf41..4c29db604bbe 100644
---- a/fs/btrfs/ulist.h
-+++ b/fs/btrfs/ulist.h
-@@ -57,6 +57,21 @@ void ulist_free(struct ulist *ulist);
- int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask);
- int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
- u64 *old_aux, gfp_t gfp_mask);
-+
-+/* just like ulist_add_merge() but take a pointer for the aux data */
-+static inline int ulist_add_merge_ptr(struct ulist *ulist, u64 val, void *aux,
-+ void **old_aux, gfp_t gfp_mask)
-+{
-+#if BITS_PER_LONG == 32
-+ u64 old64 = (uintptr_t)*old_aux;
-+ int ret = ulist_add_merge(ulist, val, (uintptr_t)aux, &old64, gfp_mask);
-+ *old_aux = (void *)((uintptr_t)old64);
-+ return ret;
-+#else
-+ return ulist_add_merge(ulist, val, (u64)aux, (u64 *)old_aux, gfp_mask);
-+#endif
-+}
-+
- struct ulist_node *ulist_next(struct ulist *ulist,
- struct ulist_iterator *uiter);
-
-diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
-index 9c0444cccbe1..15761957cc3f 100644
---- a/fs/debugfs/inode.c
-+++ b/fs/debugfs/inode.c
-@@ -533,7 +533,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);
- */
- void debugfs_remove_recursive(struct dentry *dentry)
- {
-- struct dentry *child, *next, *parent;
-+ struct dentry *child, *parent;
-
- if (IS_ERR_OR_NULL(dentry))
- return;
-@@ -545,30 +545,49 @@ void debugfs_remove_recursive(struct dentry *dentry)
- parent = dentry;
- down:
- mutex_lock(&parent->d_inode->i_mutex);
-- list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {
-+ loop:
-+ /*
-+ * The parent->d_subdirs is protected by the d_lock. Outside that
-+ * lock, the child can be unlinked and set to be freed which can
-+ * use the d_u.d_child as the rcu head and corrupt this list.
-+ */
-+ spin_lock(&parent->d_lock);
-+ list_for_each_entry(child, &parent->d_subdirs, d_u.d_child) {
- if (!debugfs_positive(child))
- continue;
-
- /* perhaps simple_empty(child) makes more sense */
- if (!list_empty(&child->d_subdirs)) {
-+ spin_unlock(&parent->d_lock);
- mutex_unlock(&parent->d_inode->i_mutex);
- parent = child;
- goto down;
- }
-- up:
-+
-+ spin_unlock(&parent->d_lock);
-+
- if (!__debugfs_remove(child, parent))
- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
-+
-+ /*
-+ * The parent->d_lock protects agaist child from unlinking
-+ * from d_subdirs. When releasing the parent->d_lock we can
-+ * no longer trust that the next pointer is valid.
-+ * Restart the loop. We'll skip this one with the
-+ * debugfs_positive() check.
-+ */
-+ goto loop;
- }
-+ spin_unlock(&parent->d_lock);
-
- mutex_unlock(&parent->d_inode->i_mutex);
- child = parent;
- parent = parent->d_parent;
- mutex_lock(&parent->d_inode->i_mutex);
-
-- if (child != dentry) {
-- next = list_next_entry(child, d_u.d_child);
-- goto up;
-- }
-+ if (child != dentry)
-+ /* go up */
-+ goto loop;
-
- if (!__debugfs_remove(child, parent))
- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
-diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
-index a7029f481b7b..b56062dc8b62 100644
---- a/fs/ext4/inode.c
-+++ b/fs/ext4/inode.c
-@@ -2195,6 +2195,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
- struct ext4_map_blocks *map = &mpd->map;
- int err;
- loff_t disksize;
-+ int progress = 0;
-
- mpd->io_submit.io_end->offset =
- ((loff_t)map->m_lblk) << inode->i_blkbits;
-@@ -2211,8 +2212,11 @@ static int mpage_map_and_submit_extent(handle_t *handle,
- * is non-zero, a commit should free up blocks.
- */
- if ((err == -ENOMEM) ||
-- (err == -ENOSPC && ext4_count_free_clusters(sb)))
-+ (err == -ENOSPC && ext4_count_free_clusters(sb))) {
-+ if (progress)
-+ goto update_disksize;
- return err;
-+ }
- ext4_msg(sb, KERN_CRIT,
- "Delayed block allocation failed for "
- "inode %lu at logical offset %llu with"
-@@ -2229,15 +2233,17 @@ static int mpage_map_and_submit_extent(handle_t *handle,
- *give_up_on_write = true;
- return err;
- }
-+ progress = 1;
- /*
- * Update buffer state, submit mapped pages, and get us new
- * extent to map
- */
- err = mpage_map_and_submit_buffers(mpd);
- if (err < 0)
-- return err;
-+ goto update_disksize;
- } while (map->m_len);
-
-+update_disksize:
- /*
- * Update on-disk size after IO is submitted. Races with
- * truncate are avoided by checking i_size under i_data_sem.
-diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
-index 502f0fd71470..242226a87be7 100644
---- a/fs/ext4/mballoc.c
-+++ b/fs/ext4/mballoc.c
-@@ -1398,6 +1398,8 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
- int last = first + count - 1;
- struct super_block *sb = e4b->bd_sb;
-
-+ if (WARN_ON(count == 0))
-+ return;
- BUG_ON(last >= (sb->s_blocksize << 3));
- assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
- /* Don't bother if the block group is corrupt. */
-@@ -3196,8 +3198,30 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
- static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
- {
- struct ext4_prealloc_space *pa = ac->ac_pa;
-+ struct ext4_buddy e4b;
-+ int err;
-
-- if (pa && pa->pa_type == MB_INODE_PA)
-+ if (pa == NULL) {
-+ if (ac->ac_f_ex.fe_len == 0)
-+ return;
-+ err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b);
-+ if (err) {
-+ /*
-+ * This should never happen since we pin the
-+ * pages in the ext4_allocation_context so
-+ * ext4_mb_load_buddy() should never fail.
-+ */
-+ WARN(1, "mb_load_buddy failed (%d)", err);
-+ return;
-+ }
-+ ext4_lock_group(ac->ac_sb, ac->ac_f_ex.fe_group);
-+ mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start,
-+ ac->ac_f_ex.fe_len);
-+ ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group);
-+ ext4_mb_unload_buddy(&e4b);
-+ return;
-+ }
-+ if (pa->pa_type == MB_INODE_PA)
- pa->pa_free += ac->ac_b_ex.fe_len;
- }
-
-diff --git a/fs/ext4/super.c b/fs/ext4/super.c
-index 25b327e87318..a46030d6b4af 100644
---- a/fs/ext4/super.c
-+++ b/fs/ext4/super.c
-@@ -3169,9 +3169,9 @@ static int set_journal_csum_feature_set(struct super_block *sb)
-
- if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
-- /* journal checksum v2 */
-+ /* journal checksum v3 */
- compat = 0;
-- incompat = JBD2_FEATURE_INCOMPAT_CSUM_V2;
-+ incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
- } else {
- /* journal checksum v1 */
- compat = JBD2_FEATURE_COMPAT_CHECKSUM;
-@@ -3193,6 +3193,7 @@ static int set_journal_csum_feature_set(struct super_block *sb)
- jbd2_journal_clear_features(sbi->s_journal,
- JBD2_FEATURE_COMPAT_CHECKSUM, 0,
- JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
-+ JBD2_FEATURE_INCOMPAT_CSUM_V3 |
- JBD2_FEATURE_INCOMPAT_CSUM_V2);
- }
-
-diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
-index 4a9e10ea13f2..a9daccbd8fe7 100644
---- a/fs/isofs/inode.c
-+++ b/fs/isofs/inode.c
-@@ -61,7 +61,7 @@ static void isofs_put_super(struct super_block *sb)
- return;
- }
-
--static int isofs_read_inode(struct inode *);
-+static int isofs_read_inode(struct inode *, int relocated);
- static int isofs_statfs (struct dentry *, struct kstatfs *);
-
- static struct kmem_cache *isofs_inode_cachep;
-@@ -1258,7 +1258,7 @@ out_toomany:
- goto out;
- }
-
--static int isofs_read_inode(struct inode *inode)
-+static int isofs_read_inode(struct inode *inode, int relocated)
- {
- struct super_block *sb = inode->i_sb;
- struct isofs_sb_info *sbi = ISOFS_SB(sb);
-@@ -1403,7 +1403,7 @@ static int isofs_read_inode(struct inode *inode)
- */
-
- if (!high_sierra) {
-- parse_rock_ridge_inode(de, inode);
-+ parse_rock_ridge_inode(de, inode, relocated);
- /* if we want uid/gid set, override the rock ridge setting */
- if (sbi->s_uid_set)
- inode->i_uid = sbi->s_uid;
-@@ -1482,9 +1482,10 @@ static int isofs_iget5_set(struct inode *ino, void *data)
- * offset that point to the underlying meta-data for the inode. The
- * code below is otherwise similar to the iget() code in
- * include/linux/fs.h */
--struct inode *isofs_iget(struct super_block *sb,
-- unsigned long block,
-- unsigned long offset)
-+struct inode *__isofs_iget(struct super_block *sb,
-+ unsigned long block,
-+ unsigned long offset,
-+ int relocated)
- {
- unsigned long hashval;
- struct inode *inode;
-@@ -1506,7 +1507,7 @@ struct inode *isofs_iget(struct super_block *sb,
- return ERR_PTR(-ENOMEM);
-
- if (inode->i_state & I_NEW) {
-- ret = isofs_read_inode(inode);
-+ ret = isofs_read_inode(inode, relocated);
- if (ret < 0) {
- iget_failed(inode);
- inode = ERR_PTR(ret);
-diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
-index 99167238518d..0ac4c1f73fbd 100644
---- a/fs/isofs/isofs.h
-+++ b/fs/isofs/isofs.h
-@@ -107,7 +107,7 @@ extern int iso_date(char *, int);
-
- struct inode; /* To make gcc happy */
-
--extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *);
-+extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *, int relocated);
- extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
- extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
-
-@@ -118,9 +118,24 @@ extern struct dentry *isofs_lookup(struct inode *, struct dentry *, unsigned int
- extern struct buffer_head *isofs_bread(struct inode *, sector_t);
- extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long);
-
--extern struct inode *isofs_iget(struct super_block *sb,
-- unsigned long block,
-- unsigned long offset);
-+struct inode *__isofs_iget(struct super_block *sb,
-+ unsigned long block,
-+ unsigned long offset,
-+ int relocated);
-+
-+static inline struct inode *isofs_iget(struct super_block *sb,
-+ unsigned long block,
-+ unsigned long offset)
-+{
-+ return __isofs_iget(sb, block, offset, 0);
-+}
-+
-+static inline struct inode *isofs_iget_reloc(struct super_block *sb,
-+ unsigned long block,
-+ unsigned long offset)
-+{
-+ return __isofs_iget(sb, block, offset, 1);
-+}
-
- /* Because the inode number is no longer relevant to finding the
- * underlying meta-data for an inode, we are free to choose a more
-diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
-index c0bf42472e40..f488bbae541a 100644
---- a/fs/isofs/rock.c
-+++ b/fs/isofs/rock.c
-@@ -288,12 +288,16 @@ eio:
- goto out;
- }
-
-+#define RR_REGARD_XA 1
-+#define RR_RELOC_DE 2
-+
- static int
- parse_rock_ridge_inode_internal(struct iso_directory_record *de,
-- struct inode *inode, int regard_xa)
-+ struct inode *inode, int flags)
- {
- int symlink_len = 0;
- int cnt, sig;
-+ unsigned int reloc_block;
- struct inode *reloc;
- struct rock_ridge *rr;
- int rootflag;
-@@ -305,7 +309,7 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
-
- init_rock_state(&rs, inode);
- setup_rock_ridge(de, inode, &rs);
-- if (regard_xa) {
-+ if (flags & RR_REGARD_XA) {
- rs.chr += 14;
- rs.len -= 14;
- if (rs.len < 0)
-@@ -485,12 +489,22 @@ repeat:
- "relocated directory\n");
- goto out;
- case SIG('C', 'L'):
-- ISOFS_I(inode)->i_first_extent =
-- isonum_733(rr->u.CL.location);
-- reloc =
-- isofs_iget(inode->i_sb,
-- ISOFS_I(inode)->i_first_extent,
-- 0);
-+ if (flags & RR_RELOC_DE) {
-+ printk(KERN_ERR
-+ "ISOFS: Recursive directory relocation "
-+ "is not supported\n");
-+ goto eio;
-+ }
-+ reloc_block = isonum_733(rr->u.CL.location);
-+ if (reloc_block == ISOFS_I(inode)->i_iget5_block &&
-+ ISOFS_I(inode)->i_iget5_offset == 0) {
-+ printk(KERN_ERR
-+ "ISOFS: Directory relocation points to "
-+ "itself\n");
-+ goto eio;
-+ }
-+ ISOFS_I(inode)->i_first_extent = reloc_block;
-+ reloc = isofs_iget_reloc(inode->i_sb, reloc_block, 0);
- if (IS_ERR(reloc)) {
- ret = PTR_ERR(reloc);
- goto out;
-@@ -637,9 +651,11 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
- return rpnt;
- }
-
--int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode)
-+int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode,
-+ int relocated)
- {
-- int result = parse_rock_ridge_inode_internal(de, inode, 0);
-+ int flags = relocated ? RR_RELOC_DE : 0;
-+ int result = parse_rock_ridge_inode_internal(de, inode, flags);
-
- /*
- * if rockridge flag was reset and we didn't look for attributes
-@@ -647,7 +663,8 @@ int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode)
- */
- if ((ISOFS_SB(inode->i_sb)->s_rock_offset == -1)
- && (ISOFS_SB(inode->i_sb)->s_rock == 2)) {
-- result = parse_rock_ridge_inode_internal(de, inode, 14);
-+ result = parse_rock_ridge_inode_internal(de, inode,
-+ flags | RR_REGARD_XA);
- }
- return result;
- }
-diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
-index cf2fc0594063..9181c2b22b3c 100644
---- a/fs/jbd2/commit.c
-+++ b/fs/jbd2/commit.c
-@@ -97,7 +97,7 @@ static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
- struct commit_header *h;
- __u32 csum;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return;
-
- h = (struct commit_header *)(bh->b_data);
-@@ -313,11 +313,11 @@ static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
- return checksum;
- }
-
--static void write_tag_block(int tag_bytes, journal_block_tag_t *tag,
-+static void write_tag_block(journal_t *j, journal_block_tag_t *tag,
- unsigned long long block)
- {
- tag->t_blocknr = cpu_to_be32(block & (u32)~0);
-- if (tag_bytes > JBD2_TAG_SIZE32)
-+ if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_64BIT))
- tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
- }
-
-@@ -327,7 +327,7 @@ static void jbd2_descr_block_csum_set(journal_t *j,
- struct jbd2_journal_block_tail *tail;
- __u32 csum;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return;
-
- tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
-@@ -340,12 +340,13 @@ static void jbd2_descr_block_csum_set(journal_t *j,
- static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
- struct buffer_head *bh, __u32 sequence)
- {
-+ journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
- struct page *page = bh->b_page;
- __u8 *addr;
- __u32 csum32;
- __be32 seq;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return;
-
- seq = cpu_to_be32(sequence);
-@@ -355,8 +356,10 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
- bh->b_size);
- kunmap_atomic(addr);
-
-- /* We only have space to store the lower 16 bits of the crc32c. */
-- tag->t_checksum = cpu_to_be16(csum32);
-+ if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
-+ tag3->t_checksum = cpu_to_be32(csum32);
-+ else
-+ tag->t_checksum = cpu_to_be16(csum32);
- }
- /*
- * jbd2_journal_commit_transaction
-@@ -396,7 +399,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
- LIST_HEAD(io_bufs);
- LIST_HEAD(log_bufs);
-
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (jbd2_journal_has_csum_v2or3(journal))
- csum_size = sizeof(struct jbd2_journal_block_tail);
-
- /*
-@@ -692,7 +695,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
- tag_flag |= JBD2_FLAG_SAME_UUID;
-
- tag = (journal_block_tag_t *) tagp;
-- write_tag_block(tag_bytes, tag, jh2bh(jh)->b_blocknr);
-+ write_tag_block(journal, tag, jh2bh(jh)->b_blocknr);
- tag->t_flags = cpu_to_be16(tag_flag);
- jbd2_block_tag_csum_set(journal, tag, wbuf[bufs],
- commit_transaction->t_tid);
-diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
-index 5fa344afb49a..f2d78a3dae43 100644
---- a/fs/jbd2/journal.c
-+++ b/fs/jbd2/journal.c
-@@ -124,7 +124,7 @@ EXPORT_SYMBOL(__jbd2_debug);
- /* Checksumming functions */
- int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
- {
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return 1;
-
- return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
-@@ -145,7 +145,7 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
-
- int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
- {
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return 1;
-
- return sb->s_checksum == jbd2_superblock_csum(j, sb);
-@@ -153,7 +153,7 @@ int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
-
- void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
- {
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return;
-
- sb->s_checksum = jbd2_superblock_csum(j, sb);
-@@ -1522,21 +1522,29 @@ static int journal_get_superblock(journal_t *journal)
- goto out;
- }
-
-- if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) &&
-- JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
-+ if (jbd2_journal_has_csum_v2or3(journal) &&
-+ JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
- /* Can't have checksum v1 and v2 on at the same time! */
- printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
- "at the same time!\n");
- goto out;
- }
-
-+ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
-+ JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
-+ /* Can't have checksum v2 and v3 at the same time! */
-+ printk(KERN_ERR "JBD2: Can't enable checksumming v2 and v3 "
-+ "at the same time!\n");
-+ goto out;
-+ }
-+
- if (!jbd2_verify_csum_type(journal, sb)) {
- printk(KERN_ERR "JBD2: Unknown checksum type\n");
- goto out;
- }
-
- /* Load the checksum driver */
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
-+ if (jbd2_journal_has_csum_v2or3(journal)) {
- journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
- if (IS_ERR(journal->j_chksum_driver)) {
- printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");
-@@ -1553,7 +1561,7 @@ static int journal_get_superblock(journal_t *journal)
- }
-
- /* Precompute checksum seed for all metadata */
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (jbd2_journal_has_csum_v2or3(journal))
- journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
- sizeof(sb->s_uuid));
-
-@@ -1813,8 +1821,14 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
- if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
- return 0;
-
-- /* Asking for checksumming v2 and v1? Only give them v2. */
-- if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2 &&
-+ /* If enabling v2 checksums, turn on v3 instead */
-+ if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2) {
-+ incompat &= ~JBD2_FEATURE_INCOMPAT_CSUM_V2;
-+ incompat |= JBD2_FEATURE_INCOMPAT_CSUM_V3;
-+ }
-+
-+ /* Asking for checksumming v3 and v1? Only give them v3. */
-+ if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V3 &&
- compat & JBD2_FEATURE_COMPAT_CHECKSUM)
- compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
-
-@@ -1823,8 +1837,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
-
- sb = journal->j_superblock;
-
-- /* If enabling v2 checksums, update superblock */
-- if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
-+ /* If enabling v3 checksums, update superblock */
-+ if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
- sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
- sb->s_feature_compat &=
- ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
-@@ -1842,8 +1856,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
- }
-
- /* Precompute checksum seed for all metadata */
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal,
-- JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (jbd2_journal_has_csum_v2or3(journal))
- journal->j_csum_seed = jbd2_chksum(journal, ~0,
- sb->s_uuid,
- sizeof(sb->s_uuid));
-@@ -1852,7 +1865,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
- /* If enabling v1 checksums, downgrade superblock */
- if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
- sb->s_feature_incompat &=
-- ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2);
-+ ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2 |
-+ JBD2_FEATURE_INCOMPAT_CSUM_V3);
-
- sb->s_feature_compat |= cpu_to_be32(compat);
- sb->s_feature_ro_compat |= cpu_to_be32(ro);
-@@ -2165,16 +2179,20 @@ int jbd2_journal_blocks_per_page(struct inode *inode)
- */
- size_t journal_tag_bytes(journal_t *journal)
- {
-- journal_block_tag_t tag;
-- size_t x = 0;
-+ size_t sz;
-+
-+ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
-+ return sizeof(journal_block_tag3_t);
-+
-+ sz = sizeof(journal_block_tag_t);
-
- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-- x += sizeof(tag.t_checksum);
-+ sz += sizeof(__u16);
-
- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
-- return x + JBD2_TAG_SIZE64;
-+ return sz;
- else
-- return x + JBD2_TAG_SIZE32;
-+ return sz - sizeof(__u32);
- }
-
- /*
-diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
-index 3b6bb19d60b1..9b329b55ffe3 100644
---- a/fs/jbd2/recovery.c
-+++ b/fs/jbd2/recovery.c
-@@ -181,7 +181,7 @@ static int jbd2_descr_block_csum_verify(journal_t *j,
- __be32 provided;
- __u32 calculated;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return 1;
-
- tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize -
-@@ -205,7 +205,7 @@ static int count_tags(journal_t *journal, struct buffer_head *bh)
- int nr = 0, size = journal->j_blocksize;
- int tag_bytes = journal_tag_bytes(journal);
-
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (jbd2_journal_has_csum_v2or3(journal))
- size -= sizeof(struct jbd2_journal_block_tail);
-
- tagp = &bh->b_data[sizeof(journal_header_t)];
-@@ -338,10 +338,11 @@ int jbd2_journal_skip_recovery(journal_t *journal)
- return err;
- }
-
--static inline unsigned long long read_tag_block(int tag_bytes, journal_block_tag_t *tag)
-+static inline unsigned long long read_tag_block(journal_t *journal,
-+ journal_block_tag_t *tag)
- {
- unsigned long long block = be32_to_cpu(tag->t_blocknr);
-- if (tag_bytes > JBD2_TAG_SIZE32)
-+ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
- block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32;
- return block;
- }
-@@ -384,7 +385,7 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
- __be32 provided;
- __u32 calculated;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return 1;
-
- h = buf;
-@@ -399,17 +400,21 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
- static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag,
- void *buf, __u32 sequence)
- {
-+ journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
- __u32 csum32;
- __be32 seq;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return 1;
-
- seq = cpu_to_be32(sequence);
- csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
- csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
-
-- return tag->t_checksum == cpu_to_be16(csum32);
-+ if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
-+ return tag3->t_checksum == cpu_to_be32(csum32);
-+ else
-+ return tag->t_checksum == cpu_to_be16(csum32);
- }
-
- static int do_one_pass(journal_t *journal,
-@@ -426,6 +431,7 @@ static int do_one_pass(journal_t *journal,
- int tag_bytes = journal_tag_bytes(journal);
- __u32 crc32_sum = ~0; /* Transactional Checksums */
- int descr_csum_size = 0;
-+ int block_error = 0;
-
- /*
- * First thing is to establish what we expect to find in the log
-@@ -512,8 +518,7 @@ static int do_one_pass(journal_t *journal,
- switch(blocktype) {
- case JBD2_DESCRIPTOR_BLOCK:
- /* Verify checksum first */
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal,
-- JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (jbd2_journal_has_csum_v2or3(journal))
- descr_csum_size =
- sizeof(struct jbd2_journal_block_tail);
- if (descr_csum_size > 0 &&
-@@ -574,7 +579,7 @@ static int do_one_pass(journal_t *journal,
- unsigned long long blocknr;
-
- J_ASSERT(obh != NULL);
-- blocknr = read_tag_block(tag_bytes,
-+ blocknr = read_tag_block(journal,
- tag);
-
- /* If the block has been
-@@ -598,7 +603,8 @@ static int do_one_pass(journal_t *journal,
- "checksum recovering "
- "block %llu in log\n",
- blocknr);
-- continue;
-+ block_error = 1;
-+ goto skip_write;
- }
-
- /* Find a buffer for the new
-@@ -797,7 +803,8 @@ static int do_one_pass(journal_t *journal,
- success = -EIO;
- }
- }
--
-+ if (block_error && success == 0)
-+ success = -EIO;
- return success;
-
- failed:
-@@ -811,7 +818,7 @@ static int jbd2_revoke_block_csum_verify(journal_t *j,
- __be32 provided;
- __u32 calculated;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return 1;
-
- tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize -
-diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
-index 198c9c10276d..d5e95a175c92 100644
---- a/fs/jbd2/revoke.c
-+++ b/fs/jbd2/revoke.c
-@@ -91,8 +91,8 @@
- #include
- #include
- #include
--#endif
- #include
-+#endif
-
- static struct kmem_cache *jbd2_revoke_record_cache;
- static struct kmem_cache *jbd2_revoke_table_cache;
-@@ -597,7 +597,7 @@ static void write_one_revoke_record(journal_t *journal,
- offset = *offsetp;
-
- /* Do we need to leave space at the end for a checksum? */
-- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (jbd2_journal_has_csum_v2or3(journal))
- csum_size = sizeof(struct jbd2_journal_revoke_tail);
-
- /* Make sure we have a descriptor with space left for the record */
-@@ -644,7 +644,7 @@ static void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh)
- struct jbd2_journal_revoke_tail *tail;
- __u32 csum;
-
-- if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
-+ if (!jbd2_journal_has_csum_v2or3(j))
- return;
-
- tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize -
-diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
-index 8f854dde4150..24c6898159cc 100644
---- a/fs/nfs/nfs3acl.c
-+++ b/fs/nfs/nfs3acl.c
-@@ -129,7 +129,10 @@ static int __nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
- .rpc_argp = &args,
- .rpc_resp = &fattr,
- };
-- int status;
-+ int status = 0;
-+
-+ if (acl == NULL && (!S_ISDIR(inode->i_mode) || dfacl == NULL))
-+ goto out;
-
- status = -EOPNOTSUPP;
- if (!nfs_server_capable(inode, NFS_CAP_ACLS))
-@@ -256,7 +259,7 @@ nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data,
- char *p = data + *result;
-
- acl = get_acl(inode, type);
-- if (!acl)
-+ if (IS_ERR_OR_NULL(acl))
- return 0;
-
- posix_acl_release(acl);
-diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
-index d5d06e868841..17f91a72840b 100644
---- a/fs/nfs/nfs4proc.c
-+++ b/fs/nfs/nfs4proc.c
-@@ -2546,6 +2546,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
- struct nfs4_closedata *calldata = data;
- struct nfs4_state *state = calldata->state;
- struct inode *inode = calldata->inode;
-+ bool is_rdonly, is_wronly, is_rdwr;
- int call_close = 0;
-
- dprintk("%s: begin!\n", __func__);
-@@ -2553,18 +2554,24 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
- goto out_wait;
-
- task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
-- calldata->arg.fmode = FMODE_READ|FMODE_WRITE;
- spin_lock(&state->owner->so_lock);
-+ is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
-+ is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
-+ is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
-+ /* Calculate the current open share mode */
-+ calldata->arg.fmode = 0;
-+ if (is_rdonly || is_rdwr)
-+ calldata->arg.fmode |= FMODE_READ;
-+ if (is_wronly || is_rdwr)
-+ calldata->arg.fmode |= FMODE_WRITE;
- /* Calculate the change in open mode */
- if (state->n_rdwr == 0) {
- if (state->n_rdonly == 0) {
-- call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags);
-- call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
-+ call_close |= is_rdonly || is_rdwr;
- calldata->arg.fmode &= ~FMODE_READ;
- }
- if (state->n_wronly == 0) {
-- call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags);
-- call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
-+ call_close |= is_wronly || is_rdwr;
- calldata->arg.fmode &= ~FMODE_WRITE;
- }
- }
-diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
-index 3eaa6e30a2dc..cc8c5b32043c 100644
---- a/fs/nfsd/nfs4callback.c
-+++ b/fs/nfsd/nfs4callback.c
-@@ -672,7 +672,8 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
- clp->cl_cb_session = ses;
- args.bc_xprt = conn->cb_xprt;
- args.prognumber = clp->cl_cb_session->se_cb_prog;
-- args.protocol = XPRT_TRANSPORT_BC_TCP;
-+ args.protocol = conn->cb_xprt->xpt_class->xcl_ident |
-+ XPRT_TRANSPORT_BC;
- args.authflavor = ses->se_cb_sec.flavor;
- }
- /* Create RPC client */
-diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
-index 9a4a5f9e7468..c34e45d1539b 100644
---- a/fs/nfsd/nfssvc.c
-+++ b/fs/nfsd/nfssvc.c
-@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
- */
- ret = nfsd_racache_init(2*nrservs);
- if (ret)
-- return ret;
-+ goto dec_users;
-+
- ret = nfs4_state_start();
- if (ret)
- goto out_racache;
-@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
-
- out_racache:
- nfsd_racache_shutdown();
-+dec_users:
-+ nfsd_users--;
- return ret;
- }
-
-diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
-index 49376aec2fbb..bcec4c46cc2e 100644
---- a/include/drm/drm_pciids.h
-+++ b/include/drm/drm_pciids.h
-@@ -17,6 +17,7 @@
- {0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
- {0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
- {0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
-+ {0x1002, 0x1318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
- {0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
- {0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
- {0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
-@@ -164,8 +165,11 @@
- {0x1002, 0x6601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6602, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6603, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-+ {0x1002, 0x6604, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-+ {0x1002, 0x6605, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6606, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6607, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-+ {0x1002, 0x6608, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
-@@ -175,6 +179,8 @@
- {0x1002, 0x6631, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-+ {0x1002, 0x6646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-+ {0x1002, 0x6647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
-@@ -297,6 +303,7 @@
- {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-+ {0x1002, 0x682C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
- {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
-diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
-index d5b50a19463c..0dae71e9971c 100644
---- a/include/linux/jbd2.h
-+++ b/include/linux/jbd2.h
-@@ -159,7 +159,11 @@ typedef struct journal_header_s
- * journal_block_tag (in the descriptor). The other h_chksum* fields are
- * not used.
- *
-- * Checksum v1 and v2 are mutually exclusive features.
-+ * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
-+ * journal_block_tag3_t to store a full 32-bit checksum. Everything else
-+ * is the same as v2.
-+ *
-+ * Checksum v1, v2, and v3 are mutually exclusive features.
- */
- struct commit_header {
- __be32 h_magic;
-@@ -179,6 +183,14 @@ struct commit_header {
- * raw struct shouldn't be used for pointer math or sizeof() - use
- * journal_tag_bytes(journal) instead to compute this.
- */
-+typedef struct journal_block_tag3_s
-+{
-+ __be32 t_blocknr; /* The on-disk block number */
-+ __be32 t_flags; /* See below */
-+ __be32 t_blocknr_high; /* most-significant high 32bits. */
-+ __be32 t_checksum; /* crc32c(uuid+seq+block) */
-+} journal_block_tag3_t;
-+
- typedef struct journal_block_tag_s
- {
- __be32 t_blocknr; /* The on-disk block number */
-@@ -187,9 +199,6 @@ typedef struct journal_block_tag_s
- __be32 t_blocknr_high; /* most-significant high 32bits. */
- } journal_block_tag_t;
-
--#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
--#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
--
- /* Tail of descriptor block, for checksumming */
- struct jbd2_journal_block_tail {
- __be32 t_checksum; /* crc32c(uuid+descr_block) */
-@@ -284,6 +293,7 @@ typedef struct journal_superblock_s
- #define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
- #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
- #define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
-+#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
-
- /* Features known to this kernel version: */
- #define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
-@@ -291,7 +301,8 @@ typedef struct journal_superblock_s
- #define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
- JBD2_FEATURE_INCOMPAT_64BIT | \
- JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
-- JBD2_FEATURE_INCOMPAT_CSUM_V2)
-+ JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
-+ JBD2_FEATURE_INCOMPAT_CSUM_V3)
-
- #ifdef __KERNEL__
-
-@@ -1296,6 +1307,15 @@ static inline int tid_geq(tid_t x, tid_t y)
- extern int jbd2_journal_blocks_per_page(struct inode *inode);
- extern size_t journal_tag_bytes(journal_t *journal);
-
-+static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
-+{
-+ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
-+ JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
-+ return 1;
-+
-+ return 0;
-+}
-+
- /*
- * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for
- * transaction control blocks.
-diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
-index b05963f09ebf..f5bfb1a80abe 100644
---- a/include/linux/sunrpc/svc_xprt.h
-+++ b/include/linux/sunrpc/svc_xprt.h
-@@ -32,6 +32,7 @@ struct svc_xprt_class {
- struct svc_xprt_ops *xcl_ops;
- struct list_head xcl_list;
- u32 xcl_max_payload;
-+ int xcl_ident;
- };
-
- /*
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 515e212421c0..677ebad70ce1 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -3511,9 +3511,10 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
- };
-
- /*
-- * Fixup the legacy SCHED_RESET_ON_FORK hack
-+ * Fixup the legacy SCHED_RESET_ON_FORK hack, except if
-+ * the policy=-1 was passed by sched_setparam().
- */
-- if (policy & SCHED_RESET_ON_FORK) {
-+ if ((policy != -1) && (policy & SCHED_RESET_ON_FORK)) {
- attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
- policy &= ~SCHED_RESET_ON_FORK;
- attr.sched_policy = policy;
-diff --git a/mm/util.c b/mm/util.c
-index a24aa22f2473..c1010cb7ca0c 100644
---- a/mm/util.c
-+++ b/mm/util.c
-@@ -275,17 +275,14 @@ pid_t vm_is_stack(struct task_struct *task,
-
- if (in_group) {
- struct task_struct *t;
-- rcu_read_lock();
-- if (!pid_alive(task))
-- goto done;
-
-- t = task;
-- do {
-+ rcu_read_lock();
-+ for_each_thread(task, t) {
- if (vm_is_stack_for_task(t, vma)) {
- ret = t->pid;
- goto done;
- }
-- } while_each_thread(task, t);
-+ }
- done:
- rcu_read_unlock();
- }
-diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
-index d06cb8752dcd..5e8fe777772b 100644
---- a/net/sunrpc/svcsock.c
-+++ b/net/sunrpc/svcsock.c
-@@ -685,6 +685,7 @@ static struct svc_xprt_class svc_udp_class = {
- .xcl_owner = THIS_MODULE,
- .xcl_ops = &svc_udp_ops,
- .xcl_max_payload = RPCSVC_MAXPAYLOAD_UDP,
-+ .xcl_ident = XPRT_TRANSPORT_UDP,
- };
-
- static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
-@@ -1279,6 +1280,7 @@ static struct svc_xprt_class svc_tcp_class = {
- .xcl_owner = THIS_MODULE,
- .xcl_ops = &svc_tcp_ops,
- .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP,
-+ .xcl_ident = XPRT_TRANSPORT_TCP,
- };
-
- void svc_init_xprt_sock(void)
-diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
-index 7d4df99f761f..03ac88431984 100644
---- a/net/sunrpc/xprt.c
-+++ b/net/sunrpc/xprt.c
-@@ -1316,7 +1316,7 @@ struct rpc_xprt *xprt_create_transport(struct xprt_create *args)
- }
- }
- spin_unlock(&xprt_list_lock);
-- printk(KERN_ERR "RPC: transport (%d) not supported\n", args->ident);
-+ dprintk("RPC: transport (%d) not supported\n", args->ident);
- return ERR_PTR(-EIO);
-
- found:
-diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
-index 62e4f9bcc387..ed36cb52cd86 100644
---- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
-+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
-@@ -89,6 +89,7 @@ struct svc_xprt_class svc_rdma_class = {
- .xcl_owner = THIS_MODULE,
- .xcl_ops = &svc_rdma_ops,
- .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP,
-+ .xcl_ident = XPRT_TRANSPORT_RDMA,
- };
-
- struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
-diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
-index 8756c8e32922..46e563046bfb 100644
---- a/sound/pci/Kconfig
-+++ b/sound/pci/Kconfig
-@@ -859,8 +859,8 @@ config SND_VIRTUOSO
- select SND_JACK if INPUT=y || INPUT=SND
- help
- Say Y here to include support for sound cards based on the
-- Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS,
-- Essence ST (Deluxe), and Essence STX.
-+ Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS, DSX,
-+ Essence ST (Deluxe), and Essence STX (II).
- Support for the HDAV1.3 (Deluxe) and HDAV1.3 Slim is experimental;
- for the Xense, missing.
-
-diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
-index 46ecdbb9053f..d5843da4ae19 100644
---- a/sound/pci/hda/patch_ca0132.c
-+++ b/sound/pci/hda/patch_ca0132.c
-@@ -4379,6 +4379,9 @@ static void ca0132_download_dsp(struct hda_codec *codec)
- return; /* NOP */
- #endif
-
-+ if (spec->dsp_state == DSP_DOWNLOAD_FAILED)
-+ return; /* don't retry failures */
-+
- chipio_enable_clocks(codec);
- spec->dsp_state = DSP_DOWNLOADING;
- if (!ca0132_download_dsp_images(codec))
-@@ -4555,7 +4558,8 @@ static int ca0132_init(struct hda_codec *codec)
- struct auto_pin_cfg *cfg = &spec->autocfg;
- int i;
-
-- spec->dsp_state = DSP_DOWNLOAD_INIT;
-+ if (spec->dsp_state != DSP_DOWNLOAD_FAILED)
-+ spec->dsp_state = DSP_DOWNLOAD_INIT;
- spec->curr_chip_addx = INVALID_CHIP_ADDRESS;
-
- snd_hda_power_up(codec);
-@@ -4666,6 +4670,7 @@ static int patch_ca0132(struct hda_codec *codec)
- codec->spec = spec;
- spec->codec = codec;
-
-+ spec->dsp_state = DSP_DOWNLOAD_INIT;
- spec->num_mixers = 1;
- spec->mixers[0] = ca0132_mixer;
-
-diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
-index 2a16a90fd952..b35dbe25a6e3 100644
---- a/sound/pci/hda/patch_realtek.c
-+++ b/sound/pci/hda/patch_realtek.c
-@@ -180,6 +180,8 @@ static void alc_fix_pll(struct hda_codec *codec)
- spec->pll_coef_idx);
- val = snd_hda_codec_read(codec, spec->pll_nid, 0,
- AC_VERB_GET_PROC_COEF, 0);
-+ if (val == -1)
-+ return;
- snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
- spec->pll_coef_idx);
- snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
-@@ -2765,6 +2767,8 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
- static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
- {
- int val = alc_read_coef_idx(codec, 0x04);
-+ if (val == -1)
-+ return;
- if (power_up)
- val |= 1 << 11;
- else
-@@ -3064,6 +3068,15 @@ static int alc269_resume(struct hda_codec *codec)
- snd_hda_codec_resume_cache(codec);
- alc_inv_dmic_sync(codec, true);
- hda_call_check_power_status(codec, 0x01);
-+
-+ /* on some machine, the BIOS will clear the codec gpio data when enter
-+ * suspend, and won't restore the data after resume, so we restore it
-+ * in the driver.
-+ */
-+ if (spec->gpio_led)
-+ snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA,
-+ spec->gpio_led);
-+
- if (spec->has_alc5505_dsp)
- alc5505_dsp_resume(codec);
-
-@@ -4435,6 +4448,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
- SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
- SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
- /* ALC282 */
-+ SND_PCI_QUIRK(0x103c, 0x2191, "HP Touchsmart 14", ALC269_FIXUP_HP_MUTE_LED_MIC1),
-+ SND_PCI_QUIRK(0x103c, 0x2192, "HP Touchsmart 15", ALC269_FIXUP_HP_MUTE_LED_MIC1),
- SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
- SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
- SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
-@@ -4633,27 +4648,30 @@ static void alc269_fill_coef(struct hda_codec *codec)
- if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
- val = alc_read_coef_idx(codec, 0x04);
- /* Power up output pin */
-- alc_write_coef_idx(codec, 0x04, val | (1<<11));
-+ if (val != -1)
-+ alc_write_coef_idx(codec, 0x04, val | (1<<11));
- }
-
- if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
- val = alc_read_coef_idx(codec, 0xd);
-- if ((val & 0x0c00) >> 10 != 0x1) {
-+ if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
- /* Capless ramp up clock control */
- alc_write_coef_idx(codec, 0xd, val | (1<<10));
- }
- val = alc_read_coef_idx(codec, 0x17);
-- if ((val & 0x01c0) >> 6 != 0x4) {
-+ if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
- /* Class D power on reset */
- alc_write_coef_idx(codec, 0x17, val | (1<<7));
- }
- }
-
- val = alc_read_coef_idx(codec, 0xd); /* Class D */
-- alc_write_coef_idx(codec, 0xd, val | (1<<14));
-+ if (val != -1)
-+ alc_write_coef_idx(codec, 0xd, val | (1<<14));
-
- val = alc_read_coef_idx(codec, 0x4); /* HP */
-- alc_write_coef_idx(codec, 0x4, val | (1<<11));
-+ if (val != -1)
-+ alc_write_coef_idx(codec, 0x4, val | (1<<11));
- }
-
- /*
-diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 3bc29c9b2529..978df990f27c 100644
---- a/sound/pci/hda/patch_sigmatel.c
-+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -84,6 +84,7 @@ enum {
- STAC_DELL_EQ,
- STAC_ALIENWARE_M17X,
- STAC_92HD89XX_HP_FRONT_JACK,
-+ STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK,
- STAC_92HD73XX_MODELS
- };
-
-@@ -1803,6 +1804,11 @@ static const struct hda_pintbl stac92hd89xx_hp_front_jack_pin_configs[] = {
- {}
- };
-
-+static const struct hda_pintbl stac92hd89xx_hp_z1_g2_right_mic_jack_pin_configs[] = {
-+ { 0x0e, 0x400000f0 },
-+ {}
-+};
-+
- static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
- const struct hda_fixup *fix, int action)
- {
-@@ -1925,6 +1931,10 @@ static const struct hda_fixup stac92hd73xx_fixups[] = {
- [STAC_92HD89XX_HP_FRONT_JACK] = {
- .type = HDA_FIXUP_PINS,
- .v.pins = stac92hd89xx_hp_front_jack_pin_configs,
-+ },
-+ [STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK] = {
-+ .type = HDA_FIXUP_PINS,
-+ .v.pins = stac92hd89xx_hp_z1_g2_right_mic_jack_pin_configs,
- }
- };
-
-@@ -1985,6 +1995,8 @@ static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
- "Alienware M17x", STAC_ALIENWARE_M17X),
- SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
- "Alienware M17x R3", STAC_DELL_EQ),
-+ SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1927,
-+ "HP Z1 G2", STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK),
- SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2b17,
- "unknown HP", STAC_92HD89XX_HP_FRONT_JACK),
- {} /* terminator */
-diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
-index 64b9fda5f04a..dbbbacfd535e 100644
---- a/sound/pci/oxygen/virtuoso.c
-+++ b/sound/pci/oxygen/virtuoso.c
-@@ -53,6 +53,7 @@ static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = {
- { OXYGEN_PCI_SUBID(0x1043, 0x835e) },
- { OXYGEN_PCI_SUBID(0x1043, 0x838e) },
- { OXYGEN_PCI_SUBID(0x1043, 0x8522) },
-+ { OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
- { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
- { }
- };
-diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c
-index c8c7f2c9b355..e02605931669 100644
---- a/sound/pci/oxygen/xonar_pcm179x.c
-+++ b/sound/pci/oxygen/xonar_pcm179x.c
-@@ -100,8 +100,8 @@
- */
-
- /*
-- * Xonar Essence ST (Deluxe)/STX
-- * -----------------------------
-+ * Xonar Essence ST (Deluxe)/STX (II)
-+ * ----------------------------------
- *
- * CMI8788:
- *
-@@ -1138,6 +1138,14 @@ int get_xonar_pcm179x_model(struct oxygen *chip,
- chip->model.resume = xonar_stx_resume;
- chip->model.set_dac_params = set_pcm1796_params;
- break;
-+ case 0x85f4:
-+ chip->model = model_xonar_st;
-+ /* TODO: daughterboard support */
-+ chip->model.shortname = "Xonar STX II";
-+ chip->model.init = xonar_stx_init;
-+ chip->model.resume = xonar_stx_resume;
-+ chip->model.set_dac_params = set_pcm1796_params;
-+ break;
- default:
- return -EINVAL;
- }
-diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
-index f652b10ce905..223c47b33ba3 100644
---- a/sound/usb/quirks-table.h
-+++ b/sound/usb/quirks-table.h
-@@ -1581,6 +1581,35 @@ YAMAHA_DEVICE(0x7010, "UB99"),
- }
- },
- {
-+ /* BOSS ME-25 */
-+ USB_DEVICE(0x0582, 0x0113),
-+ .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
-+ .ifnum = QUIRK_ANY_INTERFACE,
-+ .type = QUIRK_COMPOSITE,
-+ .data = (const struct snd_usb_audio_quirk[]) {
-+ {
-+ .ifnum = 0,
-+ .type = QUIRK_AUDIO_STANDARD_INTERFACE
-+ },
-+ {
-+ .ifnum = 1,
-+ .type = QUIRK_AUDIO_STANDARD_INTERFACE
-+ },
-+ {
-+ .ifnum = 2,
-+ .type = QUIRK_MIDI_FIXED_ENDPOINT,
-+ .data = & (const struct snd_usb_midi_endpoint_info) {
-+ .out_cables = 0x0001,
-+ .in_cables = 0x0001
-+ }
-+ },
-+ {
-+ .ifnum = -1
-+ }
-+ }
-+ }
-+},
-+{
- /* only 44.1 kHz works at the moment */
- USB_DEVICE(0x0582, 0x0120),
- .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
-diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
-index 89730707614c..c64a3d96db22 100644
---- a/sound/usb/quirks.c
-+++ b/sound/usb/quirks.c
-@@ -666,7 +666,7 @@ static int snd_usb_gamecon780_boot_quirk(struct usb_device *dev)
- /* set the initial volume and don't change; other values are either
- * too loud or silent due to firmware bug (bko#65251)
- */
-- u8 buf[2] = { 0x74, 0xdc };
-+ u8 buf[2] = { 0x74, 0xe3 };
- return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
- USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
- UAC_FU_VOLUME << 8, 9 << 8, buf, 2);
-diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
-index 8c805a071507..b47541dd798f 100644
---- a/virt/kvm/ioapic.c
-+++ b/virt/kvm/ioapic.c
-@@ -203,10 +203,9 @@ void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap,
- spin_lock(&ioapic->lock);
- for (index = 0; index < IOAPIC_NUM_PINS; index++) {
- e = &ioapic->redirtbl[index];
-- if (!e->fields.mask &&
-- (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
-- kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC,
-- index) || index == RTC_GSI)) {
-+ if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
-+ kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index) ||
-+ index == RTC_GSI) {
- if (kvm_apic_match_dest(vcpu, NULL, 0,
- e->fields.dest_id, e->fields.dest_mode)) {
- __set_bit(e->fields.vector,
-diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
-index 0df7d4b34dfe..714b94932312 100644
---- a/virt/kvm/iommu.c
-+++ b/virt/kvm/iommu.c
-@@ -61,6 +61,14 @@ static pfn_t kvm_pin_pages(struct kvm_memory_slot *slot, gfn_t gfn,
- return pfn;
- }
-
-+static void kvm_unpin_pages(struct kvm *kvm, pfn_t pfn, unsigned long npages)
-+{
-+ unsigned long i;
-+
-+ for (i = 0; i < npages; ++i)
-+ kvm_release_pfn_clean(pfn + i);
-+}
-+
- int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
- {
- gfn_t gfn, end_gfn;
-@@ -123,6 +131,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
- if (r) {
- printk(KERN_ERR "kvm_iommu_map_address:"
- "iommu failed to map pfn=%llx\n", pfn);
-+ kvm_unpin_pages(kvm, pfn, page_size);
- goto unmap_pages;
- }
-
-@@ -134,7 +143,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
- return 0;
-
- unmap_pages:
-- kvm_iommu_put_pages(kvm, slot->base_gfn, gfn);
-+ kvm_iommu_put_pages(kvm, slot->base_gfn, gfn - slot->base_gfn);
- return r;
- }
-
-@@ -266,14 +275,6 @@ out_unlock:
- return r;
- }
-
--static void kvm_unpin_pages(struct kvm *kvm, pfn_t pfn, unsigned long npages)
--{
-- unsigned long i;
--
-- for (i = 0; i < npages; ++i)
-- kvm_release_pfn_clean(pfn + i);
--}
--
- static void kvm_iommu_put_pages(struct kvm *kvm,
- gfn_t base_gfn, unsigned long npages)
- {
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.18-19.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.18-19.patch
deleted file mode 100644
index 3b52b4ab6e..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.18-19.patch
+++ /dev/null
@@ -1,4843 +0,0 @@
-diff --git a/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt b/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt
-index 46f344965313..4eb7997674a0 100644
---- a/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt
-+++ b/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt
-@@ -1,7 +1,7 @@
- ADI AXI-SPDIF controller
-
- Required properties:
-- - compatible : Must be "adi,axi-spdif-1.00.a"
-+ - compatible : Must be "adi,axi-spdif-tx-1.00.a"
- - reg : Must contain SPDIF core's registers location and length
- - clocks : Pairs of phandle and specifier referencing the controller's clocks.
- The controller expects two clocks, the clock used for the AXI interface and
-diff --git a/Makefile b/Makefile
-index 05279d4f44c9..b1746b486646 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 18
-+SUBLEVEL = 19
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
-index 331b837cec57..270cb3c6c498 100644
---- a/arch/mips/cavium-octeon/setup.c
-+++ b/arch/mips/cavium-octeon/setup.c
-@@ -458,6 +458,18 @@ static void octeon_halt(void)
- octeon_kill_core(NULL);
- }
-
-+static char __read_mostly octeon_system_type[80];
-+
-+static int __init init_octeon_system_type(void)
-+{
-+ snprintf(octeon_system_type, sizeof(octeon_system_type), "%s (%s)",
-+ cvmx_board_type_to_string(octeon_bootinfo->board_type),
-+ octeon_model_get_string(read_c0_prid()));
-+
-+ return 0;
-+}
-+early_initcall(init_octeon_system_type);
-+
- /**
- * Return a string representing the system type
- *
-@@ -465,11 +477,7 @@ static void octeon_halt(void)
- */
- const char *octeon_board_type_string(void)
- {
-- static char name[80];
-- sprintf(name, "%s (%s)",
-- cvmx_board_type_to_string(octeon_bootinfo->board_type),
-- octeon_model_get_string(read_c0_prid()));
-- return name;
-+ return octeon_system_type;
- }
-
- const char *get_system_type(void)
-diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h
-index 7bba9da110af..6d019ca1bead 100644
---- a/arch/mips/include/asm/ptrace.h
-+++ b/arch/mips/include/asm/ptrace.h
-@@ -23,7 +23,7 @@
- struct pt_regs {
- #ifdef CONFIG_32BIT
- /* Pad bytes for argument save space on the stack. */
-- unsigned long pad0[6];
-+ unsigned long pad0[8];
- #endif
-
- /* Saved main processor registers. */
-diff --git a/arch/mips/include/asm/reg.h b/arch/mips/include/asm/reg.h
-index 910e71a12466..b8343ccbc989 100644
---- a/arch/mips/include/asm/reg.h
-+++ b/arch/mips/include/asm/reg.h
-@@ -12,116 +12,194 @@
- #ifndef __ASM_MIPS_REG_H
- #define __ASM_MIPS_REG_H
-
--
--#if defined(CONFIG_32BIT) || defined(WANT_COMPAT_REG_H)
--
--#define EF_R0 6
--#define EF_R1 7
--#define EF_R2 8
--#define EF_R3 9
--#define EF_R4 10
--#define EF_R5 11
--#define EF_R6 12
--#define EF_R7 13
--#define EF_R8 14
--#define EF_R9 15
--#define EF_R10 16
--#define EF_R11 17
--#define EF_R12 18
--#define EF_R13 19
--#define EF_R14 20
--#define EF_R15 21
--#define EF_R16 22
--#define EF_R17 23
--#define EF_R18 24
--#define EF_R19 25
--#define EF_R20 26
--#define EF_R21 27
--#define EF_R22 28
--#define EF_R23 29
--#define EF_R24 30
--#define EF_R25 31
-+#define MIPS32_EF_R0 6
-+#define MIPS32_EF_R1 7
-+#define MIPS32_EF_R2 8
-+#define MIPS32_EF_R3 9
-+#define MIPS32_EF_R4 10
-+#define MIPS32_EF_R5 11
-+#define MIPS32_EF_R6 12
-+#define MIPS32_EF_R7 13
-+#define MIPS32_EF_R8 14
-+#define MIPS32_EF_R9 15
-+#define MIPS32_EF_R10 16
-+#define MIPS32_EF_R11 17
-+#define MIPS32_EF_R12 18
-+#define MIPS32_EF_R13 19
-+#define MIPS32_EF_R14 20
-+#define MIPS32_EF_R15 21
-+#define MIPS32_EF_R16 22
-+#define MIPS32_EF_R17 23
-+#define MIPS32_EF_R18 24
-+#define MIPS32_EF_R19 25
-+#define MIPS32_EF_R20 26
-+#define MIPS32_EF_R21 27
-+#define MIPS32_EF_R22 28
-+#define MIPS32_EF_R23 29
-+#define MIPS32_EF_R24 30
-+#define MIPS32_EF_R25 31
-
- /*
- * k0/k1 unsaved
- */
--#define EF_R26 32
--#define EF_R27 33
-+#define MIPS32_EF_R26 32
-+#define MIPS32_EF_R27 33
-
--#define EF_R28 34
--#define EF_R29 35
--#define EF_R30 36
--#define EF_R31 37
-+#define MIPS32_EF_R28 34
-+#define MIPS32_EF_R29 35
-+#define MIPS32_EF_R30 36
-+#define MIPS32_EF_R31 37
-
- /*
- * Saved special registers
- */
--#define EF_LO 38
--#define EF_HI 39
--
--#define EF_CP0_EPC 40
--#define EF_CP0_BADVADDR 41
--#define EF_CP0_STATUS 42
--#define EF_CP0_CAUSE 43
--#define EF_UNUSED0 44
--
--#define EF_SIZE 180
--
--#endif
--
--#if defined(CONFIG_64BIT) && !defined(WANT_COMPAT_REG_H)
--
--#define EF_R0 0
--#define EF_R1 1
--#define EF_R2 2
--#define EF_R3 3
--#define EF_R4 4
--#define EF_R5 5
--#define EF_R6 6
--#define EF_R7 7
--#define EF_R8 8
--#define EF_R9 9
--#define EF_R10 10
--#define EF_R11 11
--#define EF_R12 12
--#define EF_R13 13
--#define EF_R14 14
--#define EF_R15 15
--#define EF_R16 16
--#define EF_R17 17
--#define EF_R18 18
--#define EF_R19 19
--#define EF_R20 20
--#define EF_R21 21
--#define EF_R22 22
--#define EF_R23 23
--#define EF_R24 24
--#define EF_R25 25
-+#define MIPS32_EF_LO 38
-+#define MIPS32_EF_HI 39
-+
-+#define MIPS32_EF_CP0_EPC 40
-+#define MIPS32_EF_CP0_BADVADDR 41
-+#define MIPS32_EF_CP0_STATUS 42
-+#define MIPS32_EF_CP0_CAUSE 43
-+#define MIPS32_EF_UNUSED0 44
-+
-+#define MIPS32_EF_SIZE 180
-+
-+#define MIPS64_EF_R0 0
-+#define MIPS64_EF_R1 1
-+#define MIPS64_EF_R2 2
-+#define MIPS64_EF_R3 3
-+#define MIPS64_EF_R4 4
-+#define MIPS64_EF_R5 5
-+#define MIPS64_EF_R6 6
-+#define MIPS64_EF_R7 7
-+#define MIPS64_EF_R8 8
-+#define MIPS64_EF_R9 9
-+#define MIPS64_EF_R10 10
-+#define MIPS64_EF_R11 11
-+#define MIPS64_EF_R12 12
-+#define MIPS64_EF_R13 13
-+#define MIPS64_EF_R14 14
-+#define MIPS64_EF_R15 15
-+#define MIPS64_EF_R16 16
-+#define MIPS64_EF_R17 17
-+#define MIPS64_EF_R18 18
-+#define MIPS64_EF_R19 19
-+#define MIPS64_EF_R20 20
-+#define MIPS64_EF_R21 21
-+#define MIPS64_EF_R22 22
-+#define MIPS64_EF_R23 23
-+#define MIPS64_EF_R24 24
-+#define MIPS64_EF_R25 25
-
- /*
- * k0/k1 unsaved
- */
--#define EF_R26 26
--#define EF_R27 27
-+#define MIPS64_EF_R26 26
-+#define MIPS64_EF_R27 27
-
-
--#define EF_R28 28
--#define EF_R29 29
--#define EF_R30 30
--#define EF_R31 31
-+#define MIPS64_EF_R28 28
-+#define MIPS64_EF_R29 29
-+#define MIPS64_EF_R30 30
-+#define MIPS64_EF_R31 31
-
- /*
- * Saved special registers
- */
--#define EF_LO 32
--#define EF_HI 33
--
--#define EF_CP0_EPC 34
--#define EF_CP0_BADVADDR 35
--#define EF_CP0_STATUS 36
--#define EF_CP0_CAUSE 37
--
--#define EF_SIZE 304 /* size in bytes */
-+#define MIPS64_EF_LO 32
-+#define MIPS64_EF_HI 33
-+
-+#define MIPS64_EF_CP0_EPC 34
-+#define MIPS64_EF_CP0_BADVADDR 35
-+#define MIPS64_EF_CP0_STATUS 36
-+#define MIPS64_EF_CP0_CAUSE 37
-+
-+#define MIPS64_EF_SIZE 304 /* size in bytes */
-+
-+#if defined(CONFIG_32BIT)
-+
-+#define EF_R0 MIPS32_EF_R0
-+#define EF_R1 MIPS32_EF_R1
-+#define EF_R2 MIPS32_EF_R2
-+#define EF_R3 MIPS32_EF_R3
-+#define EF_R4 MIPS32_EF_R4
-+#define EF_R5 MIPS32_EF_R5
-+#define EF_R6 MIPS32_EF_R6
-+#define EF_R7 MIPS32_EF_R7
-+#define EF_R8 MIPS32_EF_R8
-+#define EF_R9 MIPS32_EF_R9
-+#define EF_R10 MIPS32_EF_R10
-+#define EF_R11 MIPS32_EF_R11
-+#define EF_R12 MIPS32_EF_R12
-+#define EF_R13 MIPS32_EF_R13
-+#define EF_R14 MIPS32_EF_R14
-+#define EF_R15 MIPS32_EF_R15
-+#define EF_R16 MIPS32_EF_R16
-+#define EF_R17 MIPS32_EF_R17
-+#define EF_R18 MIPS32_EF_R18
-+#define EF_R19 MIPS32_EF_R19
-+#define EF_R20 MIPS32_EF_R20
-+#define EF_R21 MIPS32_EF_R21
-+#define EF_R22 MIPS32_EF_R22
-+#define EF_R23 MIPS32_EF_R23
-+#define EF_R24 MIPS32_EF_R24
-+#define EF_R25 MIPS32_EF_R25
-+#define EF_R26 MIPS32_EF_R26
-+#define EF_R27 MIPS32_EF_R27
-+#define EF_R28 MIPS32_EF_R28
-+#define EF_R29 MIPS32_EF_R29
-+#define EF_R30 MIPS32_EF_R30
-+#define EF_R31 MIPS32_EF_R31
-+#define EF_LO MIPS32_EF_LO
-+#define EF_HI MIPS32_EF_HI
-+#define EF_CP0_EPC MIPS32_EF_CP0_EPC
-+#define EF_CP0_BADVADDR MIPS32_EF_CP0_BADVADDR
-+#define EF_CP0_STATUS MIPS32_EF_CP0_STATUS
-+#define EF_CP0_CAUSE MIPS32_EF_CP0_CAUSE
-+#define EF_UNUSED0 MIPS32_EF_UNUSED0
-+#define EF_SIZE MIPS32_EF_SIZE
-+
-+#elif defined(CONFIG_64BIT)
-+
-+#define EF_R0 MIPS64_EF_R0
-+#define EF_R1 MIPS64_EF_R1
-+#define EF_R2 MIPS64_EF_R2
-+#define EF_R3 MIPS64_EF_R3
-+#define EF_R4 MIPS64_EF_R4
-+#define EF_R5 MIPS64_EF_R5
-+#define EF_R6 MIPS64_EF_R6
-+#define EF_R7 MIPS64_EF_R7
-+#define EF_R8 MIPS64_EF_R8
-+#define EF_R9 MIPS64_EF_R9
-+#define EF_R10 MIPS64_EF_R10
-+#define EF_R11 MIPS64_EF_R11
-+#define EF_R12 MIPS64_EF_R12
-+#define EF_R13 MIPS64_EF_R13
-+#define EF_R14 MIPS64_EF_R14
-+#define EF_R15 MIPS64_EF_R15
-+#define EF_R16 MIPS64_EF_R16
-+#define EF_R17 MIPS64_EF_R17
-+#define EF_R18 MIPS64_EF_R18
-+#define EF_R19 MIPS64_EF_R19
-+#define EF_R20 MIPS64_EF_R20
-+#define EF_R21 MIPS64_EF_R21
-+#define EF_R22 MIPS64_EF_R22
-+#define EF_R23 MIPS64_EF_R23
-+#define EF_R24 MIPS64_EF_R24
-+#define EF_R25 MIPS64_EF_R25
-+#define EF_R26 MIPS64_EF_R26
-+#define EF_R27 MIPS64_EF_R27
-+#define EF_R28 MIPS64_EF_R28
-+#define EF_R29 MIPS64_EF_R29
-+#define EF_R30 MIPS64_EF_R30
-+#define EF_R31 MIPS64_EF_R31
-+#define EF_LO MIPS64_EF_LO
-+#define EF_HI MIPS64_EF_HI
-+#define EF_CP0_EPC MIPS64_EF_CP0_EPC
-+#define EF_CP0_BADVADDR MIPS64_EF_CP0_BADVADDR
-+#define EF_CP0_STATUS MIPS64_EF_CP0_STATUS
-+#define EF_CP0_CAUSE MIPS64_EF_CP0_CAUSE
-+#define EF_SIZE MIPS64_EF_SIZE
-
- #endif /* CONFIG_64BIT */
-
-diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
-index 7faf5f2bee25..71df942fb77c 100644
---- a/arch/mips/kernel/binfmt_elfo32.c
-+++ b/arch/mips/kernel/binfmt_elfo32.c
-@@ -72,12 +72,6 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
-
- #include
-
--/*
-- * When this file is selected, we are definitely running a 64bit kernel.
-- * So using the right regs define in asm/reg.h
-- */
--#define WANT_COMPAT_REG_H
--
- /* These MUST be defined before elf.h gets included */
- extern void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs);
- #define ELF_CORE_COPY_REGS(_dest, _regs) elf32_core_copy_regs(_dest, _regs);
-@@ -149,21 +143,21 @@ void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs)
- {
- int i;
-
-- for (i = 0; i < EF_R0; i++)
-+ for (i = 0; i < MIPS32_EF_R0; i++)
- grp[i] = 0;
-- grp[EF_R0] = 0;
-+ grp[MIPS32_EF_R0] = 0;
- for (i = 1; i <= 31; i++)
-- grp[EF_R0 + i] = (elf_greg_t) regs->regs[i];
-- grp[EF_R26] = 0;
-- grp[EF_R27] = 0;
-- grp[EF_LO] = (elf_greg_t) regs->lo;
-- grp[EF_HI] = (elf_greg_t) regs->hi;
-- grp[EF_CP0_EPC] = (elf_greg_t) regs->cp0_epc;
-- grp[EF_CP0_BADVADDR] = (elf_greg_t) regs->cp0_badvaddr;
-- grp[EF_CP0_STATUS] = (elf_greg_t) regs->cp0_status;
-- grp[EF_CP0_CAUSE] = (elf_greg_t) regs->cp0_cause;
--#ifdef EF_UNUSED0
-- grp[EF_UNUSED0] = 0;
-+ grp[MIPS32_EF_R0 + i] = (elf_greg_t) regs->regs[i];
-+ grp[MIPS32_EF_R26] = 0;
-+ grp[MIPS32_EF_R27] = 0;
-+ grp[MIPS32_EF_LO] = (elf_greg_t) regs->lo;
-+ grp[MIPS32_EF_HI] = (elf_greg_t) regs->hi;
-+ grp[MIPS32_EF_CP0_EPC] = (elf_greg_t) regs->cp0_epc;
-+ grp[MIPS32_EF_CP0_BADVADDR] = (elf_greg_t) regs->cp0_badvaddr;
-+ grp[MIPS32_EF_CP0_STATUS] = (elf_greg_t) regs->cp0_status;
-+ grp[MIPS32_EF_CP0_CAUSE] = (elf_greg_t) regs->cp0_cause;
-+#ifdef MIPS32_EF_UNUSED0
-+ grp[MIPS32_EF_UNUSED0] = 0;
- #endif
- }
-
-diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c
-index 5b5ddb231f26..78f18436cdf2 100644
---- a/arch/mips/kernel/irq-gic.c
-+++ b/arch/mips/kernel/irq-gic.c
-@@ -255,11 +255,13 @@ static void __init gic_setup_intr(unsigned int intr, unsigned int cpu,
-
- /* Setup Intr to Pin mapping */
- if (pin & GIC_MAP_TO_NMI_MSK) {
-+ int i;
-+
- GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(intr)), pin);
- /* FIXME: hack to route NMI to all cpu's */
-- for (cpu = 0; cpu < NR_CPUS; cpu += 32) {
-+ for (i = 0; i < NR_CPUS; i += 32) {
- GICWRITE(GIC_REG_ADDR(SHARED,
-- GIC_SH_MAP_TO_VPE_REG_OFF(intr, cpu)),
-+ GIC_SH_MAP_TO_VPE_REG_OFF(intr, i)),
- 0xffffffff);
- }
- } else {
-diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
-index 7da9b76db4d9..60f48febe762 100644
---- a/arch/mips/kernel/ptrace.c
-+++ b/arch/mips/kernel/ptrace.c
-@@ -170,6 +170,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
- __get_user(fregs[i], i + (__u64 __user *) data);
-
- __get_user(child->thread.fpu.fcr31, data + 64);
-+ child->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X;
-
- /* FIR may not be written. */
-
-@@ -265,36 +266,160 @@ int ptrace_set_watch_regs(struct task_struct *child,
-
- /* regset get/set implementations */
-
--static int gpr_get(struct task_struct *target,
-- const struct user_regset *regset,
-- unsigned int pos, unsigned int count,
-- void *kbuf, void __user *ubuf)
-+#if defined(CONFIG_32BIT) || defined(CONFIG_MIPS32_O32)
-+
-+static int gpr32_get(struct task_struct *target,
-+ const struct user_regset *regset,
-+ unsigned int pos, unsigned int count,
-+ void *kbuf, void __user *ubuf)
- {
- struct pt_regs *regs = task_pt_regs(target);
-+ u32 uregs[ELF_NGREG] = {};
-+ unsigned i;
-
-- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-- regs, 0, sizeof(*regs));
-+ for (i = MIPS32_EF_R1; i <= MIPS32_EF_R31; i++) {
-+ /* k0/k1 are copied as zero. */
-+ if (i == MIPS32_EF_R26 || i == MIPS32_EF_R27)
-+ continue;
-+
-+ uregs[i] = regs->regs[i - MIPS32_EF_R0];
-+ }
-+
-+ uregs[MIPS32_EF_LO] = regs->lo;
-+ uregs[MIPS32_EF_HI] = regs->hi;
-+ uregs[MIPS32_EF_CP0_EPC] = regs->cp0_epc;
-+ uregs[MIPS32_EF_CP0_BADVADDR] = regs->cp0_badvaddr;
-+ uregs[MIPS32_EF_CP0_STATUS] = regs->cp0_status;
-+ uregs[MIPS32_EF_CP0_CAUSE] = regs->cp0_cause;
-+
-+ return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0,
-+ sizeof(uregs));
- }
-
--static int gpr_set(struct task_struct *target,
-- const struct user_regset *regset,
-- unsigned int pos, unsigned int count,
-- const void *kbuf, const void __user *ubuf)
-+static int gpr32_set(struct task_struct *target,
-+ const struct user_regset *regset,
-+ unsigned int pos, unsigned int count,
-+ const void *kbuf, const void __user *ubuf)
- {
-- struct pt_regs newregs;
-- int ret;
-+ struct pt_regs *regs = task_pt_regs(target);
-+ u32 uregs[ELF_NGREG];
-+ unsigned start, num_regs, i;
-+ int err;
-
-- ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-- &newregs,
-- 0, sizeof(newregs));
-- if (ret)
-- return ret;
-+ start = pos / sizeof(u32);
-+ num_regs = count / sizeof(u32);
-
-- *task_pt_regs(target) = newregs;
-+ if (start + num_regs > ELF_NGREG)
-+ return -EIO;
-+
-+ err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0,
-+ sizeof(uregs));
-+ if (err)
-+ return err;
-+
-+ for (i = start; i < num_regs; i++) {
-+ /*
-+ * Cast all values to signed here so that if this is a 64-bit
-+ * kernel, the supplied 32-bit values will be sign extended.
-+ */
-+ switch (i) {
-+ case MIPS32_EF_R1 ... MIPS32_EF_R25:
-+ /* k0/k1 are ignored. */
-+ case MIPS32_EF_R28 ... MIPS32_EF_R31:
-+ regs->regs[i - MIPS32_EF_R0] = (s32)uregs[i];
-+ break;
-+ case MIPS32_EF_LO:
-+ regs->lo = (s32)uregs[i];
-+ break;
-+ case MIPS32_EF_HI:
-+ regs->hi = (s32)uregs[i];
-+ break;
-+ case MIPS32_EF_CP0_EPC:
-+ regs->cp0_epc = (s32)uregs[i];
-+ break;
-+ }
-+ }
-
- return 0;
- }
-
-+#endif /* CONFIG_32BIT || CONFIG_MIPS32_O32 */
-+
-+#ifdef CONFIG_64BIT
-+
-+static int gpr64_get(struct task_struct *target,
-+ const struct user_regset *regset,
-+ unsigned int pos, unsigned int count,
-+ void *kbuf, void __user *ubuf)
-+{
-+ struct pt_regs *regs = task_pt_regs(target);
-+ u64 uregs[ELF_NGREG] = {};
-+ unsigned i;
-+
-+ for (i = MIPS64_EF_R1; i <= MIPS64_EF_R31; i++) {
-+ /* k0/k1 are copied as zero. */
-+ if (i == MIPS64_EF_R26 || i == MIPS64_EF_R27)
-+ continue;
-+
-+ uregs[i] = regs->regs[i - MIPS64_EF_R0];
-+ }
-+
-+ uregs[MIPS64_EF_LO] = regs->lo;
-+ uregs[MIPS64_EF_HI] = regs->hi;
-+ uregs[MIPS64_EF_CP0_EPC] = regs->cp0_epc;
-+ uregs[MIPS64_EF_CP0_BADVADDR] = regs->cp0_badvaddr;
-+ uregs[MIPS64_EF_CP0_STATUS] = regs->cp0_status;
-+ uregs[MIPS64_EF_CP0_CAUSE] = regs->cp0_cause;
-+
-+ return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0,
-+ sizeof(uregs));
-+}
-+
-+static int gpr64_set(struct task_struct *target,
-+ const struct user_regset *regset,
-+ unsigned int pos, unsigned int count,
-+ const void *kbuf, const void __user *ubuf)
-+{
-+ struct pt_regs *regs = task_pt_regs(target);
-+ u64 uregs[ELF_NGREG];
-+ unsigned start, num_regs, i;
-+ int err;
-+
-+ start = pos / sizeof(u64);
-+ num_regs = count / sizeof(u64);
-+
-+ if (start + num_regs > ELF_NGREG)
-+ return -EIO;
-+
-+ err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0,
-+ sizeof(uregs));
-+ if (err)
-+ return err;
-+
-+ for (i = start; i < num_regs; i++) {
-+ switch (i) {
-+ case MIPS64_EF_R1 ... MIPS64_EF_R25:
-+ /* k0/k1 are ignored. */
-+ case MIPS64_EF_R28 ... MIPS64_EF_R31:
-+ regs->regs[i - MIPS64_EF_R0] = uregs[i];
-+ break;
-+ case MIPS64_EF_LO:
-+ regs->lo = uregs[i];
-+ break;
-+ case MIPS64_EF_HI:
-+ regs->hi = uregs[i];
-+ break;
-+ case MIPS64_EF_CP0_EPC:
-+ regs->cp0_epc = uregs[i];
-+ break;
-+ }
-+ }
-+
-+ return 0;
-+}
-+
-+#endif /* CONFIG_64BIT */
-+
- static int fpr_get(struct task_struct *target,
- const struct user_regset *regset,
- unsigned int pos, unsigned int count,
-@@ -322,14 +447,16 @@ enum mips_regset {
- REGSET_FPR,
- };
-
-+#if defined(CONFIG_32BIT) || defined(CONFIG_MIPS32_O32)
-+
- static const struct user_regset mips_regsets[] = {
- [REGSET_GPR] = {
- .core_note_type = NT_PRSTATUS,
- .n = ELF_NGREG,
- .size = sizeof(unsigned int),
- .align = sizeof(unsigned int),
-- .get = gpr_get,
-- .set = gpr_set,
-+ .get = gpr32_get,
-+ .set = gpr32_set,
- },
- [REGSET_FPR] = {
- .core_note_type = NT_PRFPREG,
-@@ -349,14 +476,18 @@ static const struct user_regset_view user_mips_view = {
- .n = ARRAY_SIZE(mips_regsets),
- };
-
-+#endif /* CONFIG_32BIT || CONFIG_MIPS32_O32 */
-+
-+#ifdef CONFIG_64BIT
-+
- static const struct user_regset mips64_regsets[] = {
- [REGSET_GPR] = {
- .core_note_type = NT_PRSTATUS,
- .n = ELF_NGREG,
- .size = sizeof(unsigned long),
- .align = sizeof(unsigned long),
-- .get = gpr_get,
-- .set = gpr_set,
-+ .get = gpr64_get,
-+ .set = gpr64_set,
- },
- [REGSET_FPR] = {
- .core_note_type = NT_PRFPREG,
-@@ -369,25 +500,26 @@ static const struct user_regset mips64_regsets[] = {
- };
-
- static const struct user_regset_view user_mips64_view = {
-- .name = "mips",
-+ .name = "mips64",
- .e_machine = ELF_ARCH,
- .ei_osabi = ELF_OSABI,
- .regsets = mips64_regsets,
-- .n = ARRAY_SIZE(mips_regsets),
-+ .n = ARRAY_SIZE(mips64_regsets),
- };
-
-+#endif /* CONFIG_64BIT */
-+
- const struct user_regset_view *task_user_regset_view(struct task_struct *task)
- {
- #ifdef CONFIG_32BIT
- return &user_mips_view;
--#endif
--
-+#else
- #ifdef CONFIG_MIPS32_O32
-- if (test_thread_flag(TIF_32BIT_REGS))
-- return &user_mips_view;
-+ if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
-+ return &user_mips_view;
- #endif
--
- return &user_mips64_view;
-+#endif
- }
-
- long arch_ptrace(struct task_struct *child, long request,
-@@ -593,7 +725,7 @@ long arch_ptrace(struct task_struct *child, long request,
- break;
- #endif
- case FPC_CSR:
-- child->thread.fpu.fcr31 = data;
-+ child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X;
- break;
- case DSP_BASE ... DSP_BASE + 5: {
- dspreg_t *dregs;
-diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
-index c369a5d35527..b897dde93e7a 100644
---- a/arch/mips/kernel/unaligned.c
-+++ b/arch/mips/kernel/unaligned.c
-@@ -605,7 +605,6 @@ static void emulate_load_store_insn(struct pt_regs *regs,
- case sdc1_op:
- die_if_kernel("Unaligned FP access in kernel code", regs);
- BUG_ON(!used_math());
-- BUG_ON(!is_fpu_owner());
-
- lose_fpu(1); /* Save FPU state for the emulator. */
- res = fpu_emulator_cop1Handler(regs, ¤t->thread.fpu, 1,
-diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
-index b234b1b5ccad..65d452aa1fda 100644
---- a/arch/mips/mm/tlbex.c
-+++ b/arch/mips/mm/tlbex.c
-@@ -1295,6 +1295,7 @@ static void build_r4000_tlb_refill_handler(void)
- }
- #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
- uasm_l_tlb_huge_update(&l, p);
-+ UASM_i_LW(&p, K0, 0, K1);
- build_huge_update_entries(&p, htlb_info.huge_pte, K1);
- build_huge_tlb_write_entry(&p, &l, &r, K0, tlb_random,
- htlb_info.restore_scratch);
-diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
-index ad3025d0880b..f20786825b8f 100644
---- a/arch/powerpc/include/asm/machdep.h
-+++ b/arch/powerpc/include/asm/machdep.h
-@@ -57,10 +57,10 @@ struct machdep_calls {
- void (*hpte_removebolted)(unsigned long ea,
- int psize, int ssize);
- void (*flush_hash_range)(unsigned long number, int local);
-- void (*hugepage_invalidate)(struct mm_struct *mm,
-+ void (*hugepage_invalidate)(unsigned long vsid,
-+ unsigned long addr,
- unsigned char *hpte_slot_array,
-- unsigned long addr, int psize);
--
-+ int psize, int ssize);
- /* special for kexec, to be called in real mode, linear mapping is
- * destroyed as well */
- void (*hpte_clear_all)(void);
-diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
-index eb9261024f51..7b3d54fae46f 100644
---- a/arch/powerpc/include/asm/pgtable-ppc64.h
-+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
-@@ -413,7 +413,7 @@ static inline char *get_hpte_slot_array(pmd_t *pmdp)
- }
-
- extern void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
-- pmd_t *pmdp);
-+ pmd_t *pmdp, unsigned long old_pmd);
- #ifdef CONFIG_TRANSPARENT_HUGEPAGE
- extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);
- extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot);
-diff --git a/arch/powerpc/include/asm/pte-hash64-64k.h b/arch/powerpc/include/asm/pte-hash64-64k.h
-index d836d945068d..9ecede1e124c 100644
---- a/arch/powerpc/include/asm/pte-hash64-64k.h
-+++ b/arch/powerpc/include/asm/pte-hash64-64k.h
-@@ -46,11 +46,31 @@
- * in order to deal with 64K made of 4K HW pages. Thus we override the
- * generic accessors and iterators here
- */
--#define __real_pte(e,p) ((real_pte_t) { \
-- (e), (pte_val(e) & _PAGE_COMBO) ? \
-- (pte_val(*((p) + PTRS_PER_PTE))) : 0 })
--#define __rpte_to_hidx(r,index) ((pte_val((r).pte) & _PAGE_COMBO) ? \
-- (((r).hidx >> ((index)<<2)) & 0xf) : ((pte_val((r).pte) >> 12) & 0xf))
-+#define __real_pte __real_pte
-+static inline real_pte_t __real_pte(pte_t pte, pte_t *ptep)
-+{
-+ real_pte_t rpte;
-+
-+ rpte.pte = pte;
-+ rpte.hidx = 0;
-+ if (pte_val(pte) & _PAGE_COMBO) {
-+ /*
-+ * Make sure we order the hidx load against the _PAGE_COMBO
-+ * check. The store side ordering is done in __hash_page_4K
-+ */
-+ smp_rmb();
-+ rpte.hidx = pte_val(*((ptep) + PTRS_PER_PTE));
-+ }
-+ return rpte;
-+}
-+
-+static inline unsigned long __rpte_to_hidx(real_pte_t rpte, unsigned long index)
-+{
-+ if ((pte_val(rpte.pte) & _PAGE_COMBO))
-+ return (rpte.hidx >> (index<<2)) & 0xf;
-+ return (pte_val(rpte.pte) >> 12) & 0xf;
-+}
-+
- #define __rpte_to_pte(r) ((r).pte)
- #define __rpte_sub_valid(rpte, index) \
- (pte_val(rpte.pte) & (_PAGE_HPTE_SUB0 >> (index)))
-diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
-index 3ea26c25590b..838de8e17dc5 100644
---- a/arch/powerpc/mm/hash_native_64.c
-+++ b/arch/powerpc/mm/hash_native_64.c
-@@ -418,18 +418,18 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,
- local_irq_restore(flags);
- }
-
--static void native_hugepage_invalidate(struct mm_struct *mm,
-+static void native_hugepage_invalidate(unsigned long vsid,
-+ unsigned long addr,
- unsigned char *hpte_slot_array,
-- unsigned long addr, int psize)
-+ int psize, int ssize)
- {
-- int ssize = 0, i;
-- int lock_tlbie;
-+ int i;
- struct hash_pte *hptep;
- int actual_psize = MMU_PAGE_16M;
- unsigned int max_hpte_count, valid;
- unsigned long flags, s_addr = addr;
- unsigned long hpte_v, want_v, shift;
-- unsigned long hidx, vpn = 0, vsid, hash, slot;
-+ unsigned long hidx, vpn = 0, hash, slot;
-
- shift = mmu_psize_defs[psize].shift;
- max_hpte_count = 1U << (PMD_SHIFT - shift);
-@@ -443,15 +443,6 @@ static void native_hugepage_invalidate(struct mm_struct *mm,
-
- /* get the vpn */
- addr = s_addr + (i * (1ul << shift));
-- if (!is_kernel_addr(addr)) {
-- ssize = user_segment_size(addr);
-- vsid = get_vsid(mm->context.id, addr, ssize);
-- WARN_ON(vsid == 0);
-- } else {
-- vsid = get_kernel_vsid(addr, mmu_kernel_ssize);
-- ssize = mmu_kernel_ssize;
-- }
--
- vpn = hpt_vpn(addr, vsid, ssize);
- hash = hpt_hash(vpn, shift, ssize);
- if (hidx & _PTEIDX_SECONDARY)
-@@ -471,22 +462,13 @@ static void native_hugepage_invalidate(struct mm_struct *mm,
- else
- /* Invalidate the hpte. NOTE: this also unlocks it */
- hptep->v = 0;
-+ /*
-+ * We need to do tlb invalidate for all the address, tlbie
-+ * instruction compares entry_VA in tlb with the VA specified
-+ * here
-+ */
-+ tlbie(vpn, psize, actual_psize, ssize, 0);
- }
-- /*
-- * Since this is a hugepage, we just need a single tlbie.
-- * use the last vpn.
-- */
-- lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
-- if (lock_tlbie)
-- raw_spin_lock(&native_tlbie_lock);
--
-- asm volatile("ptesync":::"memory");
-- __tlbie(vpn, psize, actual_psize, ssize);
-- asm volatile("eieio; tlbsync; ptesync":::"memory");
--
-- if (lock_tlbie)
-- raw_spin_unlock(&native_tlbie_lock);
--
- local_irq_restore(flags);
- }
-
-diff --git a/arch/powerpc/mm/hugepage-hash64.c b/arch/powerpc/mm/hugepage-hash64.c
-index 826893fcb3a7..5f5e6328c21c 100644
---- a/arch/powerpc/mm/hugepage-hash64.c
-+++ b/arch/powerpc/mm/hugepage-hash64.c
-@@ -18,6 +18,57 @@
- #include
- #include
-
-+static void invalidate_old_hpte(unsigned long vsid, unsigned long addr,
-+ pmd_t *pmdp, unsigned int psize, int ssize)
-+{
-+ int i, max_hpte_count, valid;
-+ unsigned long s_addr;
-+ unsigned char *hpte_slot_array;
-+ unsigned long hidx, shift, vpn, hash, slot;
-+
-+ s_addr = addr & HPAGE_PMD_MASK;
-+ hpte_slot_array = get_hpte_slot_array(pmdp);
-+ /*
-+ * IF we try to do a HUGE PTE update after a withdraw is done.
-+ * we will find the below NULL. This happens when we do
-+ * split_huge_page_pmd
-+ */
-+ if (!hpte_slot_array)
-+ return;
-+
-+ if (ppc_md.hugepage_invalidate)
-+ return ppc_md.hugepage_invalidate(vsid, s_addr, hpte_slot_array,
-+ psize, ssize);
-+ /*
-+ * No bluk hpte removal support, invalidate each entry
-+ */
-+ shift = mmu_psize_defs[psize].shift;
-+ max_hpte_count = HPAGE_PMD_SIZE >> shift;
-+ for (i = 0; i < max_hpte_count; i++) {
-+ /*
-+ * 8 bits per each hpte entries
-+ * 000| [ secondary group (one bit) | hidx (3 bits) | valid bit]
-+ */
-+ valid = hpte_valid(hpte_slot_array, i);
-+ if (!valid)
-+ continue;
-+ hidx = hpte_hash_index(hpte_slot_array, i);
-+
-+ /* get the vpn */
-+ addr = s_addr + (i * (1ul << shift));
-+ vpn = hpt_vpn(addr, vsid, ssize);
-+ hash = hpt_hash(vpn, shift, ssize);
-+ if (hidx & _PTEIDX_SECONDARY)
-+ hash = ~hash;
-+
-+ slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
-+ slot += hidx & _PTEIDX_GROUP_IX;
-+ ppc_md.hpte_invalidate(slot, vpn, psize,
-+ MMU_PAGE_16M, ssize, 0);
-+ }
-+}
-+
-+
- int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
- pmd_t *pmdp, unsigned long trap, int local, int ssize,
- unsigned int psize)
-@@ -33,7 +84,9 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
- * atomically mark the linux large page PMD busy and dirty
- */
- do {
-- old_pmd = pmd_val(*pmdp);
-+ pmd_t pmd = ACCESS_ONCE(*pmdp);
-+
-+ old_pmd = pmd_val(pmd);
- /* If PMD busy, retry the access */
- if (unlikely(old_pmd & _PAGE_BUSY))
- return 0;
-@@ -85,6 +138,15 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
- vpn = hpt_vpn(ea, vsid, ssize);
- hash = hpt_hash(vpn, shift, ssize);
- hpte_slot_array = get_hpte_slot_array(pmdp);
-+ if (psize == MMU_PAGE_4K) {
-+ /*
-+ * invalidate the old hpte entry if we have that mapped via 64K
-+ * base page size. This is because demote_segment won't flush
-+ * hash page table entries.
-+ */
-+ if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO))
-+ invalidate_old_hpte(vsid, ea, pmdp, MMU_PAGE_64K, ssize);
-+ }
-
- valid = hpte_valid(hpte_slot_array, index);
- if (valid) {
-@@ -107,11 +169,8 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
- * safely update this here.
- */
- valid = 0;
-- new_pmd &= ~_PAGE_HPTEFLAGS;
- hpte_slot_array[index] = 0;
-- } else
-- /* clear the busy bits and set the hash pte bits */
-- new_pmd = (new_pmd & ~_PAGE_HPTEFLAGS) | _PAGE_HASHPTE;
-+ }
- }
-
- if (!valid) {
-@@ -119,11 +178,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
-
- /* insert new entry */
- pa = pmd_pfn(__pmd(old_pmd)) << PAGE_SHIFT;
--repeat:
-- hpte_group = ((hash & htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL;
--
-- /* clear the busy bits and set the hash pte bits */
-- new_pmd = (new_pmd & ~_PAGE_HPTEFLAGS) | _PAGE_HASHPTE;
-+ new_pmd |= _PAGE_HASHPTE;
-
- /* Add in WIMG bits */
- rflags |= (new_pmd & (_PAGE_WRITETHRU | _PAGE_NO_CACHE |
-@@ -132,6 +187,8 @@ repeat:
- * enable the memory coherence always
- */
- rflags |= HPTE_R_M;
-+repeat:
-+ hpte_group = ((hash & htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL;
-
- /* Insert into the hash table, primary slot */
- slot = ppc_md.hpte_insert(hpte_group, vpn, pa, rflags, 0,
-@@ -172,8 +229,17 @@ repeat:
- mark_hpte_slot_valid(hpte_slot_array, index, slot);
- }
- /*
-- * No need to use ldarx/stdcx here
-+ * Mark the pte with _PAGE_COMBO, if we are trying to hash it with
-+ * base page size 4k.
-+ */
-+ if (psize == MMU_PAGE_4K)
-+ new_pmd |= _PAGE_COMBO;
-+ /*
-+ * The hpte valid is stored in the pgtable whose address is in the
-+ * second half of the PMD. Order this against clearing of the busy bit in
-+ * huge pmd.
- */
-+ smp_wmb();
- *pmdp = __pmd(new_pmd & ~_PAGE_BUSY);
- return 0;
- }
-diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
-index 30a42e24bf14..a5fff173be4f 100644
---- a/arch/powerpc/mm/numa.c
-+++ b/arch/powerpc/mm/numa.c
-@@ -610,8 +610,8 @@ static int cpu_numa_callback(struct notifier_block *nfb, unsigned long action,
- case CPU_UP_CANCELED:
- case CPU_UP_CANCELED_FROZEN:
- unmap_cpu_from_node(lcpu);
-- break;
- ret = NOTIFY_OK;
-+ break;
- #endif
- }
- return ret;
-diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
-index 62bf5e8e78da..c64da56d7582 100644
---- a/arch/powerpc/mm/pgtable_64.c
-+++ b/arch/powerpc/mm/pgtable_64.c
-@@ -538,7 +538,7 @@ unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr,
- *pmdp = __pmd((old & ~clr) | set);
- #endif
- if (old & _PAGE_HASHPTE)
-- hpte_do_hugepage_flush(mm, addr, pmdp);
-+ hpte_do_hugepage_flush(mm, addr, pmdp, old);
- return old;
- }
-
-@@ -645,7 +645,7 @@ void pmdp_splitting_flush(struct vm_area_struct *vma,
- if (!(old & _PAGE_SPLITTING)) {
- /* We need to flush the hpte */
- if (old & _PAGE_HASHPTE)
-- hpte_do_hugepage_flush(vma->vm_mm, address, pmdp);
-+ hpte_do_hugepage_flush(vma->vm_mm, address, pmdp, old);
- }
- }
-
-@@ -718,7 +718,7 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
- * neesd to be flushed.
- */
- void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
-- pmd_t *pmdp)
-+ pmd_t *pmdp, unsigned long old_pmd)
- {
- int ssize, i;
- unsigned long s_addr;
-@@ -740,12 +740,29 @@ void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
- if (!hpte_slot_array)
- return;
-
-- /* get the base page size */
-+ /* get the base page size,vsid and segment size */
-+#ifdef CONFIG_DEBUG_VM
- psize = get_slice_psize(mm, s_addr);
-+ BUG_ON(psize == MMU_PAGE_16M);
-+#endif
-+ if (old_pmd & _PAGE_COMBO)
-+ psize = MMU_PAGE_4K;
-+ else
-+ psize = MMU_PAGE_64K;
-+
-+ if (!is_kernel_addr(s_addr)) {
-+ ssize = user_segment_size(s_addr);
-+ vsid = get_vsid(mm->context.id, s_addr, ssize);
-+ WARN_ON(vsid == 0);
-+ } else {
-+ vsid = get_kernel_vsid(s_addr, mmu_kernel_ssize);
-+ ssize = mmu_kernel_ssize;
-+ }
-
- if (ppc_md.hugepage_invalidate)
-- return ppc_md.hugepage_invalidate(mm, hpte_slot_array,
-- s_addr, psize);
-+ return ppc_md.hugepage_invalidate(vsid, s_addr,
-+ hpte_slot_array,
-+ psize, ssize);
- /*
- * No bluk hpte removal support, invalidate each entry
- */
-@@ -763,15 +780,6 @@ void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
-
- /* get the vpn */
- addr = s_addr + (i * (1ul << shift));
-- if (!is_kernel_addr(addr)) {
-- ssize = user_segment_size(addr);
-- vsid = get_vsid(mm->context.id, addr, ssize);
-- WARN_ON(vsid == 0);
-- } else {
-- vsid = get_kernel_vsid(addr, mmu_kernel_ssize);
-- ssize = mmu_kernel_ssize;
-- }
--
- vpn = hpt_vpn(addr, vsid, ssize);
- hash = hpt_hash(vpn, shift, ssize);
- if (hidx & _PTEIDX_SECONDARY)
-diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c
-index c99f6510a0b2..9adda5790463 100644
---- a/arch/powerpc/mm/tlb_hash64.c
-+++ b/arch/powerpc/mm/tlb_hash64.c
-@@ -216,7 +216,7 @@ void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
- if (!(pte & _PAGE_HASHPTE))
- continue;
- if (unlikely(hugepage_shift && pmd_trans_huge(*(pmd_t *)pte)))
-- hpte_do_hugepage_flush(mm, start, (pmd_t *)pte);
-+ hpte_do_hugepage_flush(mm, start, (pmd_t *)ptep, pte);
- else
- hpte_need_flush(mm, start, ptep, pte, 0);
- }
-diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
-index 9590dbb756f2..b9a82042760f 100644
---- a/arch/powerpc/platforms/pseries/hotplug-memory.c
-+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
-@@ -160,7 +160,7 @@ static int pseries_remove_memory(struct device_node *np)
- static inline int pseries_remove_memblock(unsigned long base,
- unsigned int memblock_size)
- {
-- return -EOPNOTSUPP;
-+ return 0;
- }
- static inline int pseries_remove_memory(struct device_node *np)
- {
-diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
-index 33b552ffbe57..4642d6a4d356 100644
---- a/arch/powerpc/platforms/pseries/iommu.c
-+++ b/arch/powerpc/platforms/pseries/iommu.c
-@@ -721,13 +721,13 @@ static int __init disable_ddw_setup(char *str)
-
- early_param("disable_ddw", disable_ddw_setup);
-
--static void remove_ddw(struct device_node *np)
-+static void remove_ddw(struct device_node *np, bool remove_prop)
- {
- struct dynamic_dma_window_prop *dwp;
- struct property *win64;
- const u32 *ddw_avail;
- u64 liobn;
-- int len, ret;
-+ int len, ret = 0;
-
- ddw_avail = of_get_property(np, "ibm,ddw-applicable", &len);
- win64 = of_find_property(np, DIRECT64_PROPNAME, NULL);
-@@ -761,7 +761,8 @@ static void remove_ddw(struct device_node *np)
- np->full_name, ret, ddw_avail[2], liobn);
-
- delprop:
-- ret = of_remove_property(np, win64);
-+ if (remove_prop)
-+ ret = of_remove_property(np, win64);
- if (ret)
- pr_warning("%s: failed to remove direct window property: %d\n",
- np->full_name, ret);
-@@ -805,7 +806,7 @@ static int find_existing_ddw_windows(void)
- window = kzalloc(sizeof(*window), GFP_KERNEL);
- if (!window || len < sizeof(struct dynamic_dma_window_prop)) {
- kfree(window);
-- remove_ddw(pdn);
-+ remove_ddw(pdn, true);
- continue;
- }
-
-@@ -1045,7 +1046,7 @@ out_free_window:
- kfree(window);
-
- out_clear_window:
-- remove_ddw(pdn);
-+ remove_ddw(pdn, true);
-
- out_free_prop:
- kfree(win64->name);
-@@ -1255,7 +1256,14 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti
-
- switch (action) {
- case OF_RECONFIG_DETACH_NODE:
-- remove_ddw(np);
-+ /*
-+ * Removing the property will invoke the reconfig
-+ * notifier again, which causes dead-lock on the
-+ * read-write semaphore of the notifier chain. So
-+ * we have to remove the property when releasing
-+ * the device node.
-+ */
-+ remove_ddw(np, false);
- if (pci && pci->iommu_table)
- iommu_free_table(pci->iommu_table, np->full_name);
-
-diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
-index b02af9ef3ff6..ccf6f162f69c 100644
---- a/arch/powerpc/platforms/pseries/lpar.c
-+++ b/arch/powerpc/platforms/pseries/lpar.c
-@@ -430,16 +430,17 @@ static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
- spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags);
- }
-
--static void pSeries_lpar_hugepage_invalidate(struct mm_struct *mm,
-- unsigned char *hpte_slot_array,
-- unsigned long addr, int psize)
-+static void pSeries_lpar_hugepage_invalidate(unsigned long vsid,
-+ unsigned long addr,
-+ unsigned char *hpte_slot_array,
-+ int psize, int ssize)
- {
-- int ssize = 0, i, index = 0;
-+ int i, index = 0;
- unsigned long s_addr = addr;
- unsigned int max_hpte_count, valid;
- unsigned long vpn_array[PPC64_HUGE_HPTE_BATCH];
- unsigned long slot_array[PPC64_HUGE_HPTE_BATCH];
-- unsigned long shift, hidx, vpn = 0, vsid, hash, slot;
-+ unsigned long shift, hidx, vpn = 0, hash, slot;
-
- shift = mmu_psize_defs[psize].shift;
- max_hpte_count = 1U << (PMD_SHIFT - shift);
-@@ -452,15 +453,6 @@ static void pSeries_lpar_hugepage_invalidate(struct mm_struct *mm,
-
- /* get the vpn */
- addr = s_addr + (i * (1ul << shift));
-- if (!is_kernel_addr(addr)) {
-- ssize = user_segment_size(addr);
-- vsid = get_vsid(mm->context.id, addr, ssize);
-- WARN_ON(vsid == 0);
-- } else {
-- vsid = get_kernel_vsid(addr, mmu_kernel_ssize);
-- ssize = mmu_kernel_ssize;
-- }
--
- vpn = hpt_vpn(addr, vsid, ssize);
- hash = hpt_hash(vpn, shift, ssize);
- if (hidx & _PTEIDX_SECONDARY)
-diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
-index bb74b21f007a..a0a3bed6e4dc 100644
---- a/arch/s390/Kconfig
-+++ b/arch/s390/Kconfig
-@@ -93,6 +93,7 @@ config S390
- select ARCH_INLINE_WRITE_UNLOCK_IRQ
- select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
- select ARCH_SAVE_PAGE_KEYS if HIBERNATION
-+ select ARCH_SUPPORTS_ATOMIC_RMW
- select ARCH_USE_CMPXCHG_LOCKREF
- select ARCH_WANT_IPC_PARSE_VERSION
- select BUILDTIME_EXTABLE_SORT
-diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
-index edff4e653d9a..c66bca17e736 100644
---- a/drivers/acpi/acpica/utcopy.c
-+++ b/drivers/acpi/acpica/utcopy.c
-@@ -1001,5 +1001,11 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
- status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
- }
-
-+ /* Delete the allocated object if copy failed */
-+
-+ if (ACPI_FAILURE(status)) {
-+ acpi_ut_remove_reference(*dest_desc);
-+ }
-+
- return_ACPI_STATUS(status);
- }
-diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
-index 3dca36d4ad26..17f9ec501972 100644
---- a/drivers/acpi/processor_idle.c
-+++ b/drivers/acpi/processor_idle.c
-@@ -1071,9 +1071,9 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
-
- if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
-
-- cpuidle_pause_and_lock();
- /* Protect against cpu-hotplug */
- get_online_cpus();
-+ cpuidle_pause_and_lock();
-
- /* Disable all cpuidle devices */
- for_each_online_cpu(cpu) {
-@@ -1100,8 +1100,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
- cpuidle_enable_device(dev);
- }
- }
-- put_online_cpus();
- cpuidle_resume_and_unlock();
-+ put_online_cpus();
- }
-
- return 0;
-diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
-index 57b053f424d1..92d5184e3654 100644
---- a/drivers/acpi/scan.c
-+++ b/drivers/acpi/scan.c
-@@ -329,7 +329,8 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
- unsigned long long sta;
- acpi_status status;
-
-- if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) {
-+ if (device->handler && device->handler->hotplug.demand_offline
-+ && !acpi_force_hot_remove) {
- if (!acpi_scan_is_offline(device, true))
- return -EBUSY;
- } else {
-@@ -660,8 +661,14 @@ static ssize_t
- acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
- char *buf) {
- struct acpi_device *acpi_dev = to_acpi_device(dev);
-+ acpi_status status;
-+ unsigned long long sun;
-+
-+ status = acpi_evaluate_integer(acpi_dev->handle, "_SUN", NULL, &sun);
-+ if (ACPI_FAILURE(status))
-+ return -ENODEV;
-
-- return sprintf(buf, "%lu\n", acpi_dev->pnp.sun);
-+ return sprintf(buf, "%llu\n", sun);
- }
- static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
-
-@@ -683,7 +690,6 @@ static int acpi_device_setup_files(struct acpi_device *dev)
- {
- struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
- acpi_status status;
-- unsigned long long sun;
- int result = 0;
-
- /*
-@@ -724,14 +730,10 @@ static int acpi_device_setup_files(struct acpi_device *dev)
- if (dev->pnp.unique_id)
- result = device_create_file(&dev->dev, &dev_attr_uid);
-
-- status = acpi_evaluate_integer(dev->handle, "_SUN", NULL, &sun);
-- if (ACPI_SUCCESS(status)) {
-- dev->pnp.sun = (unsigned long)sun;
-+ if (acpi_has_method(dev->handle, "_SUN")) {
- result = device_create_file(&dev->dev, &dev_attr_sun);
- if (result)
- goto end;
-- } else {
-- dev->pnp.sun = (unsigned long)-1;
- }
-
- if (acpi_has_method(dev->handle, "_STA")) {
-@@ -915,12 +917,17 @@ static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
- device->driver->ops.notify(device, event);
- }
-
--static acpi_status acpi_device_notify_fixed(void *data)
-+static void acpi_device_notify_fixed(void *data)
- {
- struct acpi_device *device = data;
-
- /* Fixed hardware devices have no handles */
- acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
-+}
-+
-+static acpi_status acpi_device_fixed_event(void *data)
-+{
-+ acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
- return AE_OK;
- }
-
-@@ -931,12 +938,12 @@ static int acpi_device_install_notify_handler(struct acpi_device *device)
- if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
- status =
- acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
-- acpi_device_notify_fixed,
-+ acpi_device_fixed_event,
- device);
- else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
- status =
- acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
-- acpi_device_notify_fixed,
-+ acpi_device_fixed_event,
- device);
- else
- status = acpi_install_notify_handler(device->handle,
-@@ -953,10 +960,10 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
- {
- if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
- acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
-- acpi_device_notify_fixed);
-+ acpi_device_fixed_event);
- else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
- acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
-- acpi_device_notify_fixed);
-+ acpi_device_fixed_event);
- else
- acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
- acpi_device_notify);
-diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
-index 7399303d7d99..9e81a3d01d2b 100644
---- a/drivers/bluetooth/btmrvl_drv.h
-+++ b/drivers/bluetooth/btmrvl_drv.h
-@@ -66,6 +66,7 @@ struct btmrvl_adapter {
- u8 hs_state;
- u8 wakeup_tries;
- wait_queue_head_t cmd_wait_q;
-+ wait_queue_head_t event_hs_wait_q;
- u8 cmd_complete;
- bool is_suspended;
- };
-diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
-index 1e0320af00c6..49d20989b45a 100644
---- a/drivers/bluetooth/btmrvl_main.c
-+++ b/drivers/bluetooth/btmrvl_main.c
-@@ -112,6 +112,7 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
- adapter->hs_state = HS_ACTIVATED;
- if (adapter->psmode)
- adapter->ps_state = PS_SLEEP;
-+ wake_up_interruptible(&adapter->event_hs_wait_q);
- BT_DBG("HS ACTIVATED!");
- } else {
- BT_DBG("HS Enable failed");
-@@ -251,11 +252,31 @@ EXPORT_SYMBOL_GPL(btmrvl_enable_ps);
-
- int btmrvl_enable_hs(struct btmrvl_private *priv)
- {
-+ struct btmrvl_adapter *adapter = priv->adapter;
- int ret;
-
- ret = btmrvl_send_sync_cmd(priv, BT_CMD_HOST_SLEEP_ENABLE, NULL, 0);
-- if (ret)
-+ if (ret) {
- BT_ERR("Host sleep enable command failed\n");
-+ return ret;
-+ }
-+
-+ ret = wait_event_interruptible_timeout(adapter->event_hs_wait_q,
-+ adapter->hs_state,
-+ msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED));
-+ if (ret < 0) {
-+ BT_ERR("event_hs_wait_q terminated (%d): %d,%d,%d",
-+ ret, adapter->hs_state, adapter->ps_state,
-+ adapter->wakeup_tries);
-+ } else if (!ret) {
-+ BT_ERR("hs_enable timeout: %d,%d,%d", adapter->hs_state,
-+ adapter->ps_state, adapter->wakeup_tries);
-+ ret = -ETIMEDOUT;
-+ } else {
-+ BT_DBG("host sleep enabled: %d,%d,%d", adapter->hs_state,
-+ adapter->ps_state, adapter->wakeup_tries);
-+ ret = 0;
-+ }
-
- return ret;
- }
-@@ -341,6 +362,7 @@ static void btmrvl_init_adapter(struct btmrvl_private *priv)
- priv->adapter->ps_state = PS_AWAKE;
-
- init_waitqueue_head(&priv->adapter->cmd_wait_q);
-+ init_waitqueue_head(&priv->adapter->event_hs_wait_q);
- }
-
- static void btmrvl_free_adapter(struct btmrvl_private *priv)
-@@ -648,6 +670,7 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
- hdev = priv->btmrvl_dev.hcidev;
-
- wake_up_interruptible(&priv->adapter->cmd_wait_q);
-+ wake_up_interruptible(&priv->adapter->event_hs_wait_q);
-
- kthread_stop(priv->main_thread.task);
-
-diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
-index 62e10fd1e1cb..6af17002a115 100644
---- a/drivers/char/tpm/tpm-interface.c
-+++ b/drivers/char/tpm/tpm-interface.c
-@@ -491,11 +491,10 @@ static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
- int tpm_get_timeouts(struct tpm_chip *chip)
- {
- struct tpm_cmd_t tpm_cmd;
-- struct timeout_t *timeout_cap;
-+ unsigned long new_timeout[4];
-+ unsigned long old_timeout[4];
- struct duration_t *duration_cap;
- ssize_t rc;
-- u32 timeout;
-- unsigned int scale = 1;
-
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
-@@ -529,25 +528,46 @@ int tpm_get_timeouts(struct tpm_chip *chip)
- != sizeof(tpm_cmd.header.out) + sizeof(u32) + 4 * sizeof(u32))
- return -EINVAL;
-
-- timeout_cap = &tpm_cmd.params.getcap_out.cap.timeout;
-- /* Don't overwrite default if value is 0 */
-- timeout = be32_to_cpu(timeout_cap->a);
-- if (timeout && timeout < 1000) {
-- /* timeouts in msec rather usec */
-- scale = 1000;
-- chip->vendor.timeout_adjusted = true;
-+ old_timeout[0] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.a);
-+ old_timeout[1] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.b);
-+ old_timeout[2] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.c);
-+ old_timeout[3] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.d);
-+ memcpy(new_timeout, old_timeout, sizeof(new_timeout));
-+
-+ /*
-+ * Provide ability for vendor overrides of timeout values in case
-+ * of misreporting.
-+ */
-+ if (chip->ops->update_timeouts != NULL)
-+ chip->vendor.timeout_adjusted =
-+ chip->ops->update_timeouts(chip, new_timeout);
-+
-+ if (!chip->vendor.timeout_adjusted) {
-+ /* Don't overwrite default if value is 0 */
-+ if (new_timeout[0] != 0 && new_timeout[0] < 1000) {
-+ int i;
-+
-+ /* timeouts in msec rather usec */
-+ for (i = 0; i != ARRAY_SIZE(new_timeout); i++)
-+ new_timeout[i] *= 1000;
-+ chip->vendor.timeout_adjusted = true;
-+ }
-+ }
-+
-+ /* Report adjusted timeouts */
-+ if (chip->vendor.timeout_adjusted) {
-+ dev_info(chip->dev,
-+ HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D %lu->%luus\n",
-+ old_timeout[0], new_timeout[0],
-+ old_timeout[1], new_timeout[1],
-+ old_timeout[2], new_timeout[2],
-+ old_timeout[3], new_timeout[3]);
- }
-- if (timeout)
-- chip->vendor.timeout_a = usecs_to_jiffies(timeout * scale);
-- timeout = be32_to_cpu(timeout_cap->b);
-- if (timeout)
-- chip->vendor.timeout_b = usecs_to_jiffies(timeout * scale);
-- timeout = be32_to_cpu(timeout_cap->c);
-- if (timeout)
-- chip->vendor.timeout_c = usecs_to_jiffies(timeout * scale);
-- timeout = be32_to_cpu(timeout_cap->d);
-- if (timeout)
-- chip->vendor.timeout_d = usecs_to_jiffies(timeout * scale);
-+
-+ chip->vendor.timeout_a = usecs_to_jiffies(new_timeout[0]);
-+ chip->vendor.timeout_b = usecs_to_jiffies(new_timeout[1]);
-+ chip->vendor.timeout_c = usecs_to_jiffies(new_timeout[2]);
-+ chip->vendor.timeout_d = usecs_to_jiffies(new_timeout[3]);
-
- duration:
- tpm_cmd.header.in = tpm_getcap_header;
-@@ -991,13 +1011,13 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
- int err, total = 0, retries = 5;
- u8 *dest = out;
-
-+ if (!out || !num_bytes || max > TPM_MAX_RNG_DATA)
-+ return -EINVAL;
-+
- chip = tpm_chip_find_get(chip_num);
- if (chip == NULL)
- return -ENODEV;
-
-- if (!out || !num_bytes || max > TPM_MAX_RNG_DATA)
-- return -EINVAL;
--
- do {
- tpm_cmd.header.in = tpm_getrandom_header;
- tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes);
-@@ -1016,6 +1036,7 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
- num_bytes -= recd;
- } while (retries-- && total < max);
-
-+ tpm_chip_put(chip);
- return total ? total : -EIO;
- }
- EXPORT_SYMBOL_GPL(tpm_get_random);
-@@ -1095,7 +1116,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
- goto del_misc;
-
- if (tpm_add_ppi(&dev->kobj))
-- goto del_misc;
-+ goto del_sysfs;
-
- chip->bios_dir = tpm_bios_log_setup(chip->devname);
-
-@@ -1106,6 +1127,8 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
-
- return chip;
-
-+del_sysfs:
-+ tpm_sysfs_del_device(chip);
- del_misc:
- tpm_dev_del_device(chip);
- put_device:
-diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
-index a9ed2270c25d..2c46734b266d 100644
---- a/drivers/char/tpm/tpm_tis.c
-+++ b/drivers/char/tpm/tpm_tis.c
-@@ -373,6 +373,36 @@ out_err:
- return rc;
- }
-
-+struct tis_vendor_timeout_override {
-+ u32 did_vid;
-+ unsigned long timeout_us[4];
-+};
-+
-+static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
-+ /* Atmel 3204 */
-+ { 0x32041114, { (TIS_SHORT_TIMEOUT*1000), (TIS_LONG_TIMEOUT*1000),
-+ (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
-+};
-+
-+static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
-+ unsigned long *timeout_cap)
-+{
-+ int i;
-+ u32 did_vid;
-+
-+ did_vid = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
-+
-+ for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
-+ if (vendor_timeout_overrides[i].did_vid != did_vid)
-+ continue;
-+ memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us,
-+ sizeof(vendor_timeout_overrides[i].timeout_us));
-+ return true;
-+ }
-+
-+ return false;
-+}
-+
- /*
- * Early probing for iTPM with STS_DATA_EXPECT flaw.
- * Try sending command without itpm flag set and if that
-@@ -437,6 +467,7 @@ static const struct tpm_class_ops tpm_tis = {
- .recv = tpm_tis_recv,
- .send = tpm_tis_send,
- .cancel = tpm_tis_ready,
-+ .update_timeouts = tpm_tis_update_timeouts,
- .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
- .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
- .req_canceled = tpm_tis_req_canceled,
-diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
-index b22659cccca4..e6125522860a 100644
---- a/drivers/firmware/efi/vars.c
-+++ b/drivers/firmware/efi/vars.c
-@@ -481,7 +481,7 @@ EXPORT_SYMBOL_GPL(efivar_entry_remove);
- */
- static void efivar_entry_list_del_unlock(struct efivar_entry *entry)
- {
-- WARN_ON(!spin_is_locked(&__efivars->lock));
-+ lockdep_assert_held(&__efivars->lock);
-
- list_del(&entry->list);
- spin_unlock_irq(&__efivars->lock);
-@@ -507,7 +507,7 @@ int __efivar_entry_delete(struct efivar_entry *entry)
- const struct efivar_operations *ops = __efivars->ops;
- efi_status_t status;
-
-- WARN_ON(!spin_is_locked(&__efivars->lock));
-+ lockdep_assert_held(&__efivars->lock);
-
- status = ops->set_variable(entry->var.VariableName,
- &entry->var.VendorGuid,
-@@ -667,7 +667,7 @@ struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
- int strsize1, strsize2;
- bool found = false;
-
-- WARN_ON(!spin_is_locked(&__efivars->lock));
-+ lockdep_assert_held(&__efivars->lock);
-
- list_for_each_entry_safe(entry, n, head, list) {
- strsize1 = ucs2_strsize(name, 1024);
-@@ -739,7 +739,7 @@ int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
- const struct efivar_operations *ops = __efivars->ops;
- efi_status_t status;
-
-- WARN_ON(!spin_is_locked(&__efivars->lock));
-+ lockdep_assert_held(&__efivars->lock);
-
- status = ops->get_variable(entry->var.VariableName,
- &entry->var.VendorGuid,
-diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
-index 23ca7a517246..74ed08a750f4 100644
---- a/drivers/gpu/drm/nouveau/nouveau_drm.h
-+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
-@@ -10,7 +10,7 @@
-
- #define DRIVER_MAJOR 1
- #define DRIVER_MINOR 1
--#define DRIVER_PATCHLEVEL 1
-+#define DRIVER_PATCHLEVEL 2
-
- /*
- * 1.1.1:
-@@ -21,6 +21,8 @@
- * to control registers on the MPs to enable performance counters,
- * and to control the warp error enable mask (OpenGL requires out of
- * bounds access to local memory to be silently ignored / return 0).
-+ * 1.1.2:
-+ * - fixes multiple bugs in flip completion events and timestamping
- */
-
- #include
-diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
-index bc9e56eb4e9c..7b3537c55c77 100644
---- a/drivers/gpu/drm/radeon/cik.c
-+++ b/drivers/gpu/drm/radeon/cik.c
-@@ -7779,6 +7779,7 @@ restart_ih:
- static int cik_startup(struct radeon_device *rdev)
- {
- struct radeon_ring *ring;
-+ u32 nop;
- int r;
-
- /* enable pcie gen2/3 link */
-@@ -7896,9 +7897,15 @@ static int cik_startup(struct radeon_device *rdev)
- }
- cik_irq_set(rdev);
-
-+ if (rdev->family == CHIP_HAWAII) {
-+ nop = RADEON_CP_PACKET2;
-+ } else {
-+ nop = PACKET3(PACKET3_NOP, 0x3FFF);
-+ }
-+
- ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
- r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP_RPTR_OFFSET,
-- PACKET3(PACKET3_NOP, 0x3FFF));
-+ nop);
- if (r)
- return r;
-
-@@ -7906,7 +7913,7 @@ static int cik_startup(struct radeon_device *rdev)
- /* type-2 packets are deprecated on MEC, use type-3 instead */
- ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
- r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP1_RPTR_OFFSET,
-- PACKET3(PACKET3_NOP, 0x3FFF));
-+ nop);
- if (r)
- return r;
- ring->me = 1; /* first MEC */
-@@ -7917,7 +7924,7 @@ static int cik_startup(struct radeon_device *rdev)
- /* type-2 packets are deprecated on MEC, use type-3 instead */
- ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
- r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP2_RPTR_OFFSET,
-- PACKET3(PACKET3_NOP, 0x3FFF));
-+ nop);
- if (r)
- return r;
- /* dGPU only have 1 MEC */
-diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
-index 3d2e489ab732..ff9163dc1596 100644
---- a/drivers/infiniband/core/iwcm.c
-+++ b/drivers/infiniband/core/iwcm.c
-@@ -46,6 +46,7 @@
- #include
- #include
- #include
-+#include
-
- #include
- #include
-@@ -65,6 +66,20 @@ struct iwcm_work {
- struct list_head free_list;
- };
-
-+static unsigned int default_backlog = 256;
-+
-+static struct ctl_table_header *iwcm_ctl_table_hdr;
-+static struct ctl_table iwcm_ctl_table[] = {
-+ {
-+ .procname = "default_backlog",
-+ .data = &default_backlog,
-+ .maxlen = sizeof(default_backlog),
-+ .mode = 0644,
-+ .proc_handler = proc_dointvec,
-+ },
-+ { }
-+};
-+
- /*
- * The following services provide a mechanism for pre-allocating iwcm_work
- * elements. The design pre-allocates them based on the cm_id type:
-@@ -425,6 +440,9 @@ int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
-
-+ if (!backlog)
-+ backlog = default_backlog;
-+
- ret = alloc_work_entries(cm_id_priv, backlog);
- if (ret)
- return ret;
-@@ -1030,11 +1048,20 @@ static int __init iw_cm_init(void)
- if (!iwcm_wq)
- return -ENOMEM;
-
-+ iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm",
-+ iwcm_ctl_table);
-+ if (!iwcm_ctl_table_hdr) {
-+ pr_err("iw_cm: couldn't register sysctl paths\n");
-+ destroy_workqueue(iwcm_wq);
-+ return -ENOMEM;
-+ }
-+
- return 0;
- }
-
- static void __exit iw_cm_cleanup(void)
- {
-+ unregister_net_sysctl_table(iwcm_ctl_table_hdr);
- destroy_workqueue(iwcm_wq);
- }
-
-diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
-index e96c07ee6756..ca0bc6c67abe 100644
---- a/drivers/infiniband/ulp/srp/ib_srp.c
-+++ b/drivers/infiniband/ulp/srp/ib_srp.c
-@@ -120,6 +120,7 @@ static void srp_send_completion(struct ib_cq *cq, void *target_ptr);
- static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event);
-
- static struct scsi_transport_template *ib_srp_transport_template;
-+static struct workqueue_struct *srp_remove_wq;
-
- static struct ib_client srp_client = {
- .name = "srp",
-@@ -539,7 +540,7 @@ static bool srp_queue_remove_work(struct srp_target_port *target)
- spin_unlock_irq(&target->lock);
-
- if (changed)
-- queue_work(system_long_wq, &target->remove_work);
-+ queue_work(srp_remove_wq, &target->remove_work);
-
- return changed;
- }
-@@ -2886,9 +2887,10 @@ static void srp_remove_one(struct ib_device *device)
- spin_unlock(&host->target_lock);
-
- /*
-- * Wait for target port removal tasks.
-+ * Wait for tl_err and target port removal tasks.
- */
- flush_workqueue(system_long_wq);
-+ flush_workqueue(srp_remove_wq);
-
- kfree(host);
- }
-@@ -2940,16 +2942,22 @@ static int __init srp_init_module(void)
- indirect_sg_entries = cmd_sg_entries;
- }
-
-+ srp_remove_wq = create_workqueue("srp_remove");
-+ if (IS_ERR(srp_remove_wq)) {
-+ ret = PTR_ERR(srp_remove_wq);
-+ goto out;
-+ }
-+
-+ ret = -ENOMEM;
- ib_srp_transport_template =
- srp_attach_transport(&ib_srp_transport_functions);
- if (!ib_srp_transport_template)
-- return -ENOMEM;
-+ goto destroy_wq;
-
- ret = class_register(&srp_class);
- if (ret) {
- pr_err("couldn't register class infiniband_srp\n");
-- srp_release_transport(ib_srp_transport_template);
-- return ret;
-+ goto release_tr;
- }
-
- ib_sa_register_client(&srp_sa_client);
-@@ -2957,13 +2965,22 @@ static int __init srp_init_module(void)
- ret = ib_register_client(&srp_client);
- if (ret) {
- pr_err("couldn't register IB client\n");
-- srp_release_transport(ib_srp_transport_template);
-- ib_sa_unregister_client(&srp_sa_client);
-- class_unregister(&srp_class);
-- return ret;
-+ goto unreg_sa;
- }
-
-- return 0;
-+out:
-+ return ret;
-+
-+unreg_sa:
-+ ib_sa_unregister_client(&srp_sa_client);
-+ class_unregister(&srp_class);
-+
-+release_tr:
-+ srp_release_transport(ib_srp_transport_template);
-+
-+destroy_wq:
-+ destroy_workqueue(srp_remove_wq);
-+ goto out;
- }
-
- static void __exit srp_cleanup_module(void)
-@@ -2972,6 +2989,7 @@ static void __exit srp_cleanup_module(void)
- ib_sa_unregister_client(&srp_sa_client);
- class_unregister(&srp_class);
- srp_release_transport(ib_srp_transport_template);
-+ destroy_workqueue(srp_remove_wq);
- }
-
- module_init(srp_init_module);
-diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
-index 71776ff5aedc..9cbef59d404a 100644
---- a/drivers/iommu/amd_iommu.c
-+++ b/drivers/iommu/amd_iommu.c
-@@ -3227,14 +3227,16 @@ free_domains:
-
- static void cleanup_domain(struct protection_domain *domain)
- {
-- struct iommu_dev_data *dev_data, *next;
-+ struct iommu_dev_data *entry;
- unsigned long flags;
-
- write_lock_irqsave(&amd_iommu_devtable_lock, flags);
-
-- list_for_each_entry_safe(dev_data, next, &domain->dev_list, list) {
-- __detach_device(dev_data);
-- atomic_set(&dev_data->bind, 0);
-+ while (!list_empty(&domain->dev_list)) {
-+ entry = list_first_entry(&domain->dev_list,
-+ struct iommu_dev_data, list);
-+ __detach_device(entry);
-+ atomic_set(&entry->bind, 0);
- }
-
- write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
-diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
-index 56e24c072b62..d7690f86fdb9 100644
---- a/drivers/md/raid1.c
-+++ b/drivers/md/raid1.c
-@@ -1501,12 +1501,12 @@ static void error(struct mddev *mddev, struct md_rdev *rdev)
- mddev->degraded++;
- set_bit(Faulty, &rdev->flags);
- spin_unlock_irqrestore(&conf->device_lock, flags);
-- /*
-- * if recovery is running, make sure it aborts.
-- */
-- set_bit(MD_RECOVERY_INTR, &mddev->recovery);
- } else
- set_bit(Faulty, &rdev->flags);
-+ /*
-+ * if recovery is running, make sure it aborts.
-+ */
-+ set_bit(MD_RECOVERY_INTR, &mddev->recovery);
- set_bit(MD_CHANGE_DEVS, &mddev->flags);
- printk(KERN_ALERT
- "md/raid1:%s: Disk failure on %s, disabling device.\n"
-diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
-index cb882aae9e20..a46124ecafc7 100644
---- a/drivers/md/raid10.c
-+++ b/drivers/md/raid10.c
-@@ -1684,13 +1684,12 @@ static void error(struct mddev *mddev, struct md_rdev *rdev)
- spin_unlock_irqrestore(&conf->device_lock, flags);
- return;
- }
-- if (test_and_clear_bit(In_sync, &rdev->flags)) {
-+ if (test_and_clear_bit(In_sync, &rdev->flags))
- mddev->degraded++;
-- /*
-- * if recovery is running, make sure it aborts.
-- */
-- set_bit(MD_RECOVERY_INTR, &mddev->recovery);
-- }
-+ /*
-+ * If recovery is running, make sure it aborts.
-+ */
-+ set_bit(MD_RECOVERY_INTR, &mddev->recovery);
- set_bit(Blocked, &rdev->flags);
- set_bit(Faulty, &rdev->flags);
- set_bit(MD_CHANGE_DEVS, &mddev->flags);
-@@ -2954,6 +2953,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
- */
- if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) {
- end_reshape(conf);
-+ close_sync(conf);
- return 0;
- }
-
-@@ -4411,7 +4411,7 @@ read_more:
- read_bio->bi_private = r10_bio;
- read_bio->bi_end_io = end_sync_read;
- read_bio->bi_rw = READ;
-- read_bio->bi_flags &= ~(BIO_POOL_MASK - 1);
-+ read_bio->bi_flags &= (~0UL << BIO_RESET_BITS);
- read_bio->bi_flags |= 1 << BIO_UPTODATE;
- read_bio->bi_vcnt = 0;
- read_bio->bi_iter.bi_size = 0;
-diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
-index 16f5c21963db..18cda77b4f79 100644
---- a/drivers/md/raid5.c
-+++ b/drivers/md/raid5.c
-@@ -3779,6 +3779,8 @@ static void handle_stripe(struct stripe_head *sh)
- set_bit(R5_Wantwrite, &dev->flags);
- if (prexor)
- continue;
-+ if (s.failed > 1)
-+ continue;
- if (!test_bit(R5_Insync, &dev->flags) ||
- ((i == sh->pd_idx || i == sh->qd_idx) &&
- s.failed == 0))
-diff --git a/drivers/media/common/siano/Kconfig b/drivers/media/common/siano/Kconfig
-index f953d33ee151..4bfbd5f463d1 100644
---- a/drivers/media/common/siano/Kconfig
-+++ b/drivers/media/common/siano/Kconfig
-@@ -22,8 +22,7 @@ config SMS_SIANO_DEBUGFS
- bool "Enable debugfs for smsdvb"
- depends on SMS_SIANO_MDTV
- depends on DEBUG_FS
-- depends on SMS_USB_DRV
-- depends on CONFIG_SMS_USB_DRV = CONFIG_SMS_SDIO_DRV
-+ depends on SMS_USB_DRV = SMS_SDIO_DRV
-
- ---help---
- Choose Y to enable visualizing a dump of the frontend
-diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
-index 36c504b78f2c..008ac87a9031 100644
---- a/drivers/media/i2c/mt9v032.c
-+++ b/drivers/media/i2c/mt9v032.c
-@@ -305,8 +305,8 @@ mt9v032_update_hblank(struct mt9v032 *mt9v032)
-
- if (mt9v032->version->version == MT9V034_CHIP_ID_REV1)
- min_hblank += (mt9v032->hratio - 1) * 10;
-- min_hblank = max_t(unsigned int, (int)mt9v032->model->data->min_row_time - crop->width,
-- (int)min_hblank);
-+ min_hblank = max_t(int, mt9v032->model->data->min_row_time - crop->width,
-+ min_hblank);
- hblank = max_t(unsigned int, mt9v032->hblank, min_hblank);
-
- return mt9v032_write(client, MT9V032_HORIZONTAL_BLANKING, hblank);
-diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
-index 703560fa5e73..88c1606fd555 100644
---- a/drivers/media/media-device.c
-+++ b/drivers/media/media-device.c
-@@ -106,8 +106,6 @@ static long media_device_enum_entities(struct media_device *mdev,
- if (ent->name) {
- strncpy(u_ent.name, ent->name, sizeof(u_ent.name));
- u_ent.name[sizeof(u_ent.name) - 1] = '\0';
-- } else {
-- memset(u_ent.name, 0, sizeof(u_ent.name));
- }
- u_ent.type = ent->type;
- u_ent.revision = ent->revision;
-diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
-index b4687a834f85..7245cca89257 100644
---- a/drivers/media/platform/vsp1/vsp1_video.c
-+++ b/drivers/media/platform/vsp1/vsp1_video.c
-@@ -635,8 +635,6 @@ static int vsp1_video_buffer_prepare(struct vb2_buffer *vb)
- if (vb->num_planes < format->num_planes)
- return -EINVAL;
-
-- buf->video = video;
--
- for (i = 0; i < vb->num_planes; ++i) {
- buf->addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
- buf->length[i] = vb2_plane_size(vb, i);
-diff --git a/drivers/media/platform/vsp1/vsp1_video.h b/drivers/media/platform/vsp1/vsp1_video.h
-index d8612a378345..47b7a8ab5e2f 100644
---- a/drivers/media/platform/vsp1/vsp1_video.h
-+++ b/drivers/media/platform/vsp1/vsp1_video.h
-@@ -89,7 +89,6 @@ static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
- }
-
- struct vsp1_video_buffer {
-- struct vsp1_video *video;
- struct vb2_buffer buf;
- struct list_head queue;
-
-diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c
-index 2018befabb5a..e71decbfd0af 100644
---- a/drivers/media/tuners/xc4000.c
-+++ b/drivers/media/tuners/xc4000.c
-@@ -93,7 +93,7 @@ struct xc4000_priv {
- struct firmware_description *firm;
- int firm_size;
- u32 if_khz;
-- u32 freq_hz;
-+ u32 freq_hz, freq_offset;
- u32 bandwidth;
- u8 video_standard;
- u8 rf_mode;
-@@ -1157,14 +1157,14 @@ static int xc4000_set_params(struct dvb_frontend *fe)
- case SYS_ATSC:
- dprintk(1, "%s() VSB modulation\n", __func__);
- priv->rf_mode = XC_RF_MODE_AIR;
-- priv->freq_hz = c->frequency - 1750000;
-+ priv->freq_offset = 1750000;
- priv->video_standard = XC4000_DTV6;
- type = DTV6;
- break;
- case SYS_DVBC_ANNEX_B:
- dprintk(1, "%s() QAM modulation\n", __func__);
- priv->rf_mode = XC_RF_MODE_CABLE;
-- priv->freq_hz = c->frequency - 1750000;
-+ priv->freq_offset = 1750000;
- priv->video_standard = XC4000_DTV6;
- type = DTV6;
- break;
-@@ -1173,23 +1173,23 @@ static int xc4000_set_params(struct dvb_frontend *fe)
- dprintk(1, "%s() OFDM\n", __func__);
- if (bw == 0) {
- if (c->frequency < 400000000) {
-- priv->freq_hz = c->frequency - 2250000;
-+ priv->freq_offset = 2250000;
- } else {
-- priv->freq_hz = c->frequency - 2750000;
-+ priv->freq_offset = 2750000;
- }
- priv->video_standard = XC4000_DTV7_8;
- type = DTV78;
- } else if (bw <= 6000000) {
- priv->video_standard = XC4000_DTV6;
-- priv->freq_hz = c->frequency - 1750000;
-+ priv->freq_offset = 1750000;
- type = DTV6;
- } else if (bw <= 7000000) {
- priv->video_standard = XC4000_DTV7;
-- priv->freq_hz = c->frequency - 2250000;
-+ priv->freq_offset = 2250000;
- type = DTV7;
- } else {
- priv->video_standard = XC4000_DTV8;
-- priv->freq_hz = c->frequency - 2750000;
-+ priv->freq_offset = 2750000;
- type = DTV8;
- }
- priv->rf_mode = XC_RF_MODE_AIR;
-@@ -1200,6 +1200,8 @@ static int xc4000_set_params(struct dvb_frontend *fe)
- goto fail;
- }
-
-+ priv->freq_hz = c->frequency - priv->freq_offset;
-+
- dprintk(1, "%s() frequency=%d (compensated)\n",
- __func__, priv->freq_hz);
-
-@@ -1520,7 +1522,7 @@ static int xc4000_get_frequency(struct dvb_frontend *fe, u32 *freq)
- {
- struct xc4000_priv *priv = fe->tuner_priv;
-
-- *freq = priv->freq_hz;
-+ *freq = priv->freq_hz + priv->freq_offset;
-
- if (debug) {
- mutex_lock(&priv->lock);
-diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
-index 5cd09a681b6a..b2d9e9cb97f7 100644
---- a/drivers/media/tuners/xc5000.c
-+++ b/drivers/media/tuners/xc5000.c
-@@ -55,7 +55,7 @@ struct xc5000_priv {
-
- u32 if_khz;
- u16 xtal_khz;
-- u32 freq_hz;
-+ u32 freq_hz, freq_offset;
- u32 bandwidth;
- u8 video_standard;
- u8 rf_mode;
-@@ -755,13 +755,13 @@ static int xc5000_set_params(struct dvb_frontend *fe)
- case SYS_ATSC:
- dprintk(1, "%s() VSB modulation\n", __func__);
- priv->rf_mode = XC_RF_MODE_AIR;
-- priv->freq_hz = freq - 1750000;
-+ priv->freq_offset = 1750000;
- priv->video_standard = DTV6;
- break;
- case SYS_DVBC_ANNEX_B:
- dprintk(1, "%s() QAM modulation\n", __func__);
- priv->rf_mode = XC_RF_MODE_CABLE;
-- priv->freq_hz = freq - 1750000;
-+ priv->freq_offset = 1750000;
- priv->video_standard = DTV6;
- break;
- case SYS_ISDBT:
-@@ -776,15 +776,15 @@ static int xc5000_set_params(struct dvb_frontend *fe)
- switch (bw) {
- case 6000000:
- priv->video_standard = DTV6;
-- priv->freq_hz = freq - 1750000;
-+ priv->freq_offset = 1750000;
- break;
- case 7000000:
- priv->video_standard = DTV7;
-- priv->freq_hz = freq - 2250000;
-+ priv->freq_offset = 2250000;
- break;
- case 8000000:
- priv->video_standard = DTV8;
-- priv->freq_hz = freq - 2750000;
-+ priv->freq_offset = 2750000;
- break;
- default:
- printk(KERN_ERR "xc5000 bandwidth not set!\n");
-@@ -798,15 +798,15 @@ static int xc5000_set_params(struct dvb_frontend *fe)
- priv->rf_mode = XC_RF_MODE_CABLE;
- if (bw <= 6000000) {
- priv->video_standard = DTV6;
-- priv->freq_hz = freq - 1750000;
-+ priv->freq_offset = 1750000;
- b = 6;
- } else if (bw <= 7000000) {
- priv->video_standard = DTV7;
-- priv->freq_hz = freq - 2250000;
-+ priv->freq_offset = 2250000;
- b = 7;
- } else {
- priv->video_standard = DTV7_8;
-- priv->freq_hz = freq - 2750000;
-+ priv->freq_offset = 2750000;
- b = 8;
- }
- dprintk(1, "%s() Bandwidth %dMHz (%d)\n", __func__,
-@@ -817,6 +817,8 @@ static int xc5000_set_params(struct dvb_frontend *fe)
- return -EINVAL;
- }
-
-+ priv->freq_hz = freq - priv->freq_offset;
-+
- dprintk(1, "%s() frequency=%d (compensated to %d)\n",
- __func__, freq, priv->freq_hz);
-
-@@ -1067,7 +1069,7 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq)
- {
- struct xc5000_priv *priv = fe->tuner_priv;
- dprintk(1, "%s()\n", __func__);
-- *freq = priv->freq_hz;
-+ *freq = priv->freq_hz + priv->freq_offset;
- return 0;
- }
-
-diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
-index f6154546b5c0..7ed75efa1c36 100644
---- a/drivers/media/usb/au0828/au0828-video.c
-+++ b/drivers/media/usb/au0828/au0828-video.c
-@@ -787,11 +787,27 @@ static int au0828_i2s_init(struct au0828_dev *dev)
-
- /*
- * Auvitek au0828 analog stream enable
-- * Please set interface0 to AS5 before enable the stream
- */
- static int au0828_analog_stream_enable(struct au0828_dev *d)
- {
-+ struct usb_interface *iface;
-+ int ret;
-+
- dprintk(1, "au0828_analog_stream_enable called\n");
-+
-+ iface = usb_ifnum_to_if(d->usbdev, 0);
-+ if (iface && iface->cur_altsetting->desc.bAlternateSetting != 5) {
-+ dprintk(1, "Changing intf#0 to alt 5\n");
-+ /* set au0828 interface0 to AS5 here again */
-+ ret = usb_set_interface(d->usbdev, 0, 5);
-+ if (ret < 0) {
-+ printk(KERN_INFO "Au0828 can't set alt setting to 5!\n");
-+ return -EBUSY;
-+ }
-+ }
-+
-+ /* FIXME: size should be calculated using d->width, d->height */
-+
- au0828_writereg(d, AU0828_SENSORCTRL_VBI_103, 0x00);
- au0828_writereg(d, 0x106, 0x00);
- /* set x position */
-@@ -1002,15 +1018,6 @@ static int au0828_v4l2_open(struct file *filp)
- return -ERESTARTSYS;
- }
- if (dev->users == 0) {
-- /* set au0828 interface0 to AS5 here again */
-- ret = usb_set_interface(dev->usbdev, 0, 5);
-- if (ret < 0) {
-- mutex_unlock(&dev->lock);
-- printk(KERN_INFO "Au0828 can't set alternate to 5!\n");
-- kfree(fh);
-- return -EBUSY;
-- }
--
- au0828_analog_stream_enable(dev);
- au0828_analog_stream_reset(dev);
-
-@@ -1252,13 +1259,6 @@ static int au0828_set_format(struct au0828_dev *dev, unsigned int cmd,
- }
- }
-
-- /* set au0828 interface0 to AS5 here again */
-- ret = usb_set_interface(dev->usbdev, 0, 5);
-- if (ret < 0) {
-- printk(KERN_INFO "Au0828 can't set alt setting to 5!\n");
-- return -EBUSY;
-- }
--
- au0828_analog_stream_enable(dev);
-
- return 0;
-diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
-index 90b630ccc8bc..0aefe501fd3c 100644
---- a/drivers/mfd/omap-usb-host.c
-+++ b/drivers/mfd/omap-usb-host.c
-@@ -445,7 +445,7 @@ static unsigned omap_usbhs_rev1_hostconfig(struct usbhs_hcd_omap *omap,
-
- for (i = 0; i < omap->nports; i++) {
- if (is_ehci_phy_mode(pdata->port_mode[i])) {
-- reg &= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
-+ reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
- break;
- }
- }
-diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
-index 19d637266fcd..71e4f6ccae2f 100644
---- a/drivers/mtd/ftl.c
-+++ b/drivers/mtd/ftl.c
-@@ -1075,7 +1075,6 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
- return;
- }
-
-- ftl_freepart(partition);
- kfree(partition);
- }
-
-diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
-index 6f55d92dc233..64d8e32b6ca0 100644
---- a/drivers/mtd/nand/omap2.c
-+++ b/drivers/mtd/nand/omap2.c
-@@ -933,7 +933,7 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
- u32 val;
-
- val = readl(info->reg.gpmc_ecc_config);
-- if (((val >> ECC_CONFIG_CS_SHIFT) & ~CS_MASK) != info->gpmc_cs)
-+ if (((val >> ECC_CONFIG_CS_SHIFT) & CS_MASK) != info->gpmc_cs)
- return -EINVAL;
-
- /* read ecc result */
-diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
-index 79a37f6d3307..e384844a1ae1 100644
---- a/drivers/power/bq2415x_charger.c
-+++ b/drivers/power/bq2415x_charger.c
-@@ -840,8 +840,7 @@ static int bq2415x_notifier_call(struct notifier_block *nb,
- if (bq->automode < 1)
- return NOTIFY_OK;
-
-- sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode");
-- bq2415x_set_mode(bq, bq->reported_mode);
-+ schedule_delayed_work(&bq->work, 0);
-
- return NOTIFY_OK;
- }
-@@ -892,6 +891,11 @@ static void bq2415x_timer_work(struct work_struct *work)
- int error;
- int boost;
-
-+ if (bq->automode > 0 && (bq->reported_mode != bq->mode)) {
-+ sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode");
-+ bq2415x_set_mode(bq, bq->reported_mode);
-+ }
-+
- if (!bq->autotimer)
- return;
-
-diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
-index f0ea4fdfde87..8b963a757883 100644
---- a/drivers/regulator/arizona-ldo1.c
-+++ b/drivers/regulator/arizona-ldo1.c
-@@ -141,8 +141,6 @@ static struct regulator_ops arizona_ldo1_ops = {
- .map_voltage = regulator_map_voltage_linear,
- .get_voltage_sel = regulator_get_voltage_sel_regmap,
- .set_voltage_sel = regulator_set_voltage_sel_regmap,
-- .get_bypass = regulator_get_bypass_regmap,
-- .set_bypass = regulator_set_bypass_regmap,
- };
-
- static const struct regulator_desc arizona_ldo1 = {
-diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
-index 2e28392c2fb6..a38aafa030b3 100644
---- a/drivers/scsi/bfa/bfa_ioc.h
-+++ b/drivers/scsi/bfa/bfa_ioc.h
-@@ -72,7 +72,7 @@ struct bfa_sge_s {
- } while (0)
-
- #define bfa_swap_words(_x) ( \
-- ((_x) << 32) | ((_x) >> 32))
-+ ((u64)(_x) << 32) | ((u64)(_x) >> 32))
-
- #ifdef __BIG_ENDIAN
- #define bfa_sge_to_be(_x)
-diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
-index f969aca0b54e..49014a143c6a 100644
---- a/drivers/scsi/scsi_devinfo.c
-+++ b/drivers/scsi/scsi_devinfo.c
-@@ -222,6 +222,7 @@ static struct {
- {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
- {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
- {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
-+ {"Promise", "VTrak E610f", NULL, BLIST_SPARSELUN | BLIST_NO_RSOC},
- {"Promise", "", NULL, BLIST_SPARSELUN},
- {"QUANTUM", "XP34301", "1071", BLIST_NOTQ},
- {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
-diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
-index 4109530e92a0..054ec2c412a4 100644
---- a/drivers/scsi/scsi_scan.c
-+++ b/drivers/scsi/scsi_scan.c
-@@ -922,6 +922,12 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
- if (*bflags & BLIST_USE_10_BYTE_MS)
- sdev->use_10_for_ms = 1;
-
-+ /* some devices don't like REPORT SUPPORTED OPERATION CODES
-+ * and will simply timeout causing sd_mod init to take a very
-+ * very long time */
-+ if (*bflags & BLIST_NO_RSOC)
-+ sdev->no_report_opcodes = 1;
-+
- /* set the device running here so that slave configure
- * may do I/O */
- ret = scsi_device_set_state(sdev, SDEV_RUNNING);
-@@ -950,7 +956,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
-
- sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
-
-- if (*bflags & BLIST_SKIP_VPD_PAGES)
-+ if (*bflags & BLIST_TRY_VPD_PAGES)
-+ sdev->try_vpd_pages = 1;
-+ else if (*bflags & BLIST_SKIP_VPD_PAGES)
- sdev->skip_vpd_pages = 1;
-
- transport_configure_device(&sdev->sdev_gendev);
-@@ -1236,6 +1244,12 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
- max_dev_lun = min(8U, max_dev_lun);
-
- /*
-+ * Stop scanning at 255 unless BLIST_SCSI3LUN
-+ */
-+ if (!(bflags & BLIST_SCSI3LUN))
-+ max_dev_lun = min(256U, max_dev_lun);
-+
-+ /*
- * We have already scanned LUN 0, so start at LUN 1. Keep scanning
- * until we reach the max, or no LUN is found and we are not
- * sparse_lun.
-diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
-index d47ffc8d3e43..e3e794ee7ddd 100644
---- a/drivers/scsi/scsi_transport_srp.c
-+++ b/drivers/scsi/scsi_transport_srp.c
-@@ -473,7 +473,8 @@ static void __srp_start_tl_fail_timers(struct srp_rport *rport)
- if (delay > 0)
- queue_delayed_work(system_long_wq, &rport->reconnect_work,
- 1UL * delay * HZ);
-- if (srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) {
-+ if ((fast_io_fail_tmo >= 0 || dev_loss_tmo >= 0) &&
-+ srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) {
- pr_debug("%s new state: %d\n", dev_name(&shost->shost_gendev),
- rport->state);
- scsi_target_block(&shost->shost_gendev);
-diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
-index 36d1a23f14be..e8abb731c7ec 100644
---- a/drivers/scsi/sd.c
-+++ b/drivers/scsi/sd.c
-@@ -2686,6 +2686,11 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
-
- static int sd_try_extended_inquiry(struct scsi_device *sdp)
- {
-+ /* Attempt VPD inquiry if the device blacklist explicitly calls
-+ * for it.
-+ */
-+ if (sdp->try_vpd_pages)
-+ return 1;
- /*
- * Although VPD inquiries can go to SCSI-2 type devices,
- * some USB ones crash on receiving them, and the pages
-diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
-index 9969fa1ef7c4..ed0f899e8aa5 100644
---- a/drivers/scsi/storvsc_drv.c
-+++ b/drivers/scsi/storvsc_drv.c
-@@ -33,6 +33,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -330,17 +331,17 @@ static int storvsc_timeout = 180;
-
- static void storvsc_on_channel_callback(void *context);
-
--/*
-- * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In
-- * reality, the path/target is not used (ie always set to 0) so our
-- * scsi host adapter essentially has 1 bus with 1 target that contains
-- * up to 256 luns.
-- */
--#define STORVSC_MAX_LUNS_PER_TARGET 64
--#define STORVSC_MAX_TARGETS 1
--#define STORVSC_MAX_CHANNELS 1
-+#define STORVSC_MAX_LUNS_PER_TARGET 255
-+#define STORVSC_MAX_TARGETS 2
-+#define STORVSC_MAX_CHANNELS 8
-
-+#define STORVSC_FC_MAX_LUNS_PER_TARGET 255
-+#define STORVSC_FC_MAX_TARGETS 128
-+#define STORVSC_FC_MAX_CHANNELS 8
-
-+#define STORVSC_IDE_MAX_LUNS_PER_TARGET 64
-+#define STORVSC_IDE_MAX_TARGETS 1
-+#define STORVSC_IDE_MAX_CHANNELS 1
-
- struct storvsc_cmd_request {
- struct list_head entry;
-@@ -1017,6 +1018,13 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,
- case ATA_12:
- set_host_byte(scmnd, DID_PASSTHROUGH);
- break;
-+ /*
-+ * On Some Windows hosts TEST_UNIT_READY command can return
-+ * SRB_STATUS_ERROR, let the upper level code deal with it
-+ * based on the sense information.
-+ */
-+ case TEST_UNIT_READY:
-+ break;
- default:
- set_host_byte(scmnd, DID_TARGET_FAILURE);
- }
-@@ -1518,6 +1526,16 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
- return SUCCESS;
- }
-
-+/*
-+ * The host guarantees to respond to each command, although I/O latencies might
-+ * be unbounded on Azure. Reset the timer unconditionally to give the host a
-+ * chance to perform EH.
-+ */
-+static enum blk_eh_timer_return storvsc_eh_timed_out(struct scsi_cmnd *scmnd)
-+{
-+ return BLK_EH_RESET_TIMER;
-+}
-+
- static bool storvsc_scsi_cmd_ok(struct scsi_cmnd *scmnd)
- {
- bool allowed = true;
-@@ -1553,9 +1571,19 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
- struct vmscsi_request *vm_srb;
- struct stor_mem_pools *memp = scmnd->device->hostdata;
-
-- if (!storvsc_scsi_cmd_ok(scmnd)) {
-- scmnd->scsi_done(scmnd);
-- return 0;
-+ if (vmstor_current_major <= VMSTOR_WIN8_MAJOR) {
-+ /*
-+ * On legacy hosts filter unimplemented commands.
-+ * Future hosts are expected to correctly handle
-+ * unsupported commands. Furthermore, it is
-+ * possible that some of the currently
-+ * unsupported commands maybe supported in
-+ * future versions of the host.
-+ */
-+ if (!storvsc_scsi_cmd_ok(scmnd)) {
-+ scmnd->scsi_done(scmnd);
-+ return 0;
-+ }
- }
-
- request_size = sizeof(struct storvsc_cmd_request);
-@@ -1580,26 +1608,24 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
- vm_srb = &cmd_request->vstor_packet.vm_srb;
- vm_srb->win8_extension.time_out_value = 60;
-
-+ vm_srb->win8_extension.srb_flags |=
-+ (SRB_FLAGS_QUEUE_ACTION_ENABLE |
-+ SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
-
- /* Build the SRB */
- switch (scmnd->sc_data_direction) {
- case DMA_TO_DEVICE:
- vm_srb->data_in = WRITE_TYPE;
- vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_OUT;
-- vm_srb->win8_extension.srb_flags |=
-- (SRB_FLAGS_QUEUE_ACTION_ENABLE |
-- SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
- break;
- case DMA_FROM_DEVICE:
- vm_srb->data_in = READ_TYPE;
- vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_IN;
-- vm_srb->win8_extension.srb_flags |=
-- (SRB_FLAGS_QUEUE_ACTION_ENABLE |
-- SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
- break;
- default:
- vm_srb->data_in = UNKNOWN_TYPE;
-- vm_srb->win8_extension.srb_flags = 0;
-+ vm_srb->win8_extension.srb_flags |= (SRB_FLAGS_DATA_IN |
-+ SRB_FLAGS_DATA_OUT);
- break;
- }
-
-@@ -1687,11 +1713,11 @@ static struct scsi_host_template scsi_driver = {
- .bios_param = storvsc_get_chs,
- .queuecommand = storvsc_queuecommand,
- .eh_host_reset_handler = storvsc_host_reset_handler,
-+ .eh_timed_out = storvsc_eh_timed_out,
- .slave_alloc = storvsc_device_alloc,
- .slave_destroy = storvsc_device_destroy,
- .slave_configure = storvsc_device_configure,
-- .cmd_per_lun = 1,
-- /* 64 max_queue * 1 target */
-+ .cmd_per_lun = 255,
- .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
- .this_id = -1,
- /* no use setting to 0 since ll_blk_rw reset it to 1 */
-@@ -1743,19 +1769,25 @@ static int storvsc_probe(struct hv_device *device,
- * set state to properly communicate with the host.
- */
-
-- if (vmbus_proto_version == VERSION_WIN8) {
-- sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
-- vmscsi_size_delta = 0;
-- vmstor_current_major = VMSTOR_WIN8_MAJOR;
-- vmstor_current_minor = VMSTOR_WIN8_MINOR;
-- } else {
-+ switch (vmbus_proto_version) {
-+ case VERSION_WS2008:
-+ case VERSION_WIN7:
- sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
- vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
- vmstor_current_major = VMSTOR_WIN7_MAJOR;
- vmstor_current_minor = VMSTOR_WIN7_MINOR;
-+ break;
-+ default:
-+ sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
-+ vmscsi_size_delta = 0;
-+ vmstor_current_major = VMSTOR_WIN8_MAJOR;
-+ vmstor_current_minor = VMSTOR_WIN8_MINOR;
-+ break;
- }
-
--
-+ if (dev_id->driver_data == SFC_GUID)
-+ scsi_driver.can_queue = (STORVSC_MAX_IO_REQUESTS *
-+ STORVSC_FC_MAX_TARGETS);
- host = scsi_host_alloc(&scsi_driver,
- sizeof(struct hv_host_device));
- if (!host)
-@@ -1789,12 +1821,25 @@ static int storvsc_probe(struct hv_device *device,
- host_dev->path = stor_device->path_id;
- host_dev->target = stor_device->target_id;
-
-- /* max # of devices per target */
-- host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
-- /* max # of targets per channel */
-- host->max_id = STORVSC_MAX_TARGETS;
-- /* max # of channels */
-- host->max_channel = STORVSC_MAX_CHANNELS - 1;
-+ switch (dev_id->driver_data) {
-+ case SFC_GUID:
-+ host->max_lun = STORVSC_FC_MAX_LUNS_PER_TARGET;
-+ host->max_id = STORVSC_FC_MAX_TARGETS;
-+ host->max_channel = STORVSC_FC_MAX_CHANNELS - 1;
-+ break;
-+
-+ case SCSI_GUID:
-+ host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
-+ host->max_id = STORVSC_MAX_TARGETS;
-+ host->max_channel = STORVSC_MAX_CHANNELS - 1;
-+ break;
-+
-+ default:
-+ host->max_lun = STORVSC_IDE_MAX_LUNS_PER_TARGET;
-+ host->max_id = STORVSC_IDE_MAX_TARGETS;
-+ host->max_channel = STORVSC_IDE_MAX_CHANNELS - 1;
-+ break;
-+ }
- /* max cmd length */
- host->max_cmd_len = STORVSC_MAX_CMD_LEN;
-
-diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
-index a72127f08e39..a64f1557c156 100644
---- a/drivers/spi/spi-omap2-mcspi.c
-+++ b/drivers/spi/spi-omap2-mcspi.c
-@@ -147,6 +147,7 @@ struct omap2_mcspi_cs {
- void __iomem *base;
- unsigned long phys;
- int word_len;
-+ u16 mode;
- struct list_head node;
- /* Context save and restore shadow register */
- u32 chconf0;
-@@ -899,6 +900,8 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
-
- mcspi_write_chconf0(spi, l);
-
-+ cs->mode = spi->mode;
-+
- dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s\n",
- OMAP2_MCSPI_MAX_FREQ >> div,
- (spi->mode & SPI_CPHA) ? "trailing" : "leading",
-@@ -971,6 +974,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
- return -ENOMEM;
- cs->base = mcspi->base + spi->chip_select * 0x14;
- cs->phys = mcspi->phys + spi->chip_select * 0x14;
-+ cs->mode = 0;
- cs->chconf0 = 0;
- spi->controller_state = cs;
- /* Link this to context save list */
-@@ -1051,6 +1055,16 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
- cs = spi->controller_state;
- cd = spi->controller_data;
-
-+ /*
-+ * The slave driver could have changed spi->mode in which case
-+ * it will be different from cs->mode (the current hardware setup).
-+ * If so, set par_override (even though its not a parity issue) so
-+ * omap2_mcspi_setup_transfer will be called to configure the hardware
-+ * with the correct mode on the first iteration of the loop below.
-+ */
-+ if (spi->mode != cs->mode)
-+ par_override = 1;
-+
- omap2_mcspi_set_enable(spi, 0);
- list_for_each_entry(t, &m->transfers, transfer_list) {
- if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
-diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
-index 7f2121fe2622..977b0619bb78 100644
---- a/drivers/spi/spi-orion.c
-+++ b/drivers/spi/spi-orion.c
-@@ -404,8 +404,6 @@ static int orion_spi_probe(struct platform_device *pdev)
- struct resource *r;
- unsigned long tclk_hz;
- int status = 0;
-- const u32 *iprop;
-- int size;
-
- master = spi_alloc_master(&pdev->dev, sizeof(*spi));
- if (master == NULL) {
-@@ -416,10 +414,10 @@ static int orion_spi_probe(struct platform_device *pdev)
- if (pdev->id != -1)
- master->bus_num = pdev->id;
- if (pdev->dev.of_node) {
-- iprop = of_get_property(pdev->dev.of_node, "cell-index",
-- &size);
-- if (iprop && size == sizeof(*iprop))
-- master->bus_num = *iprop;
-+ u32 cell_index;
-+ if (!of_property_read_u32(pdev->dev.of_node, "cell-index",
-+ &cell_index))
-+ master->bus_num = cell_index;
- }
-
- /* we support only mode 0, and no options */
-diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
-index c702fc536a77..ced9ecffa163 100644
---- a/drivers/spi/spi-pxa2xx.c
-+++ b/drivers/spi/spi-pxa2xx.c
-@@ -1078,6 +1078,7 @@ static struct acpi_device_id pxa2xx_spi_acpi_match[] = {
- { "INT3430", 0 },
- { "INT3431", 0 },
- { "80860F0E", 0 },
-+ { "8086228E", 0 },
- { },
- };
- MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
-diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
-index 172a8bc27abd..ef7d446e07ee 100644
---- a/drivers/xen/events/events_fifo.c
-+++ b/drivers/xen/events/events_fifo.c
-@@ -99,6 +99,25 @@ static unsigned evtchn_fifo_nr_channels(void)
- return event_array_pages * EVENT_WORDS_PER_PAGE;
- }
-
-+static int init_control_block(int cpu,
-+ struct evtchn_fifo_control_block *control_block)
-+{
-+ struct evtchn_fifo_queue *q = &per_cpu(cpu_queue, cpu);
-+ struct evtchn_init_control init_control;
-+ unsigned int i;
-+
-+ /* Reset the control block and the local HEADs. */
-+ clear_page(control_block);
-+ for (i = 0; i < EVTCHN_FIFO_MAX_QUEUES; i++)
-+ q->head[i] = 0;
-+
-+ init_control.control_gfn = virt_to_mfn(control_block);
-+ init_control.offset = 0;
-+ init_control.vcpu = cpu;
-+
-+ return HYPERVISOR_event_channel_op(EVTCHNOP_init_control, &init_control);
-+}
-+
- static void free_unused_array_pages(void)
- {
- unsigned i;
-@@ -327,7 +346,6 @@ static void evtchn_fifo_resume(void)
-
- for_each_possible_cpu(cpu) {
- void *control_block = per_cpu(cpu_control_block, cpu);
-- struct evtchn_init_control init_control;
- int ret;
-
- if (!control_block)
-@@ -344,12 +362,7 @@ static void evtchn_fifo_resume(void)
- continue;
- }
-
-- init_control.control_gfn = virt_to_mfn(control_block);
-- init_control.offset = 0;
-- init_control.vcpu = cpu;
--
-- ret = HYPERVISOR_event_channel_op(EVTCHNOP_init_control,
-- &init_control);
-+ ret = init_control_block(cpu, control_block);
- if (ret < 0)
- BUG();
- }
-@@ -377,30 +390,25 @@ static const struct evtchn_ops evtchn_ops_fifo = {
- .resume = evtchn_fifo_resume,
- };
-
--static int evtchn_fifo_init_control_block(unsigned cpu)
-+static int evtchn_fifo_alloc_control_block(unsigned cpu)
- {
-- struct page *control_block = NULL;
-- struct evtchn_init_control init_control;
-+ void *control_block = NULL;
- int ret = -ENOMEM;
-
-- control_block = alloc_page(GFP_KERNEL|__GFP_ZERO);
-+ control_block = (void *)__get_free_page(GFP_KERNEL);
- if (control_block == NULL)
- goto error;
-
-- init_control.control_gfn = virt_to_mfn(page_address(control_block));
-- init_control.offset = 0;
-- init_control.vcpu = cpu;
--
-- ret = HYPERVISOR_event_channel_op(EVTCHNOP_init_control, &init_control);
-+ ret = init_control_block(cpu, control_block);
- if (ret < 0)
- goto error;
-
-- per_cpu(cpu_control_block, cpu) = page_address(control_block);
-+ per_cpu(cpu_control_block, cpu) = control_block;
-
- return 0;
-
- error:
-- __free_page(control_block);
-+ free_page((unsigned long)control_block);
- return ret;
- }
-
-@@ -414,7 +422,7 @@ static int evtchn_fifo_cpu_notification(struct notifier_block *self,
- switch (action) {
- case CPU_UP_PREPARE:
- if (!per_cpu(cpu_control_block, cpu))
-- ret = evtchn_fifo_init_control_block(cpu);
-+ ret = evtchn_fifo_alloc_control_block(cpu);
- break;
- default:
- break;
-@@ -431,7 +439,7 @@ int __init xen_evtchn_fifo_init(void)
- int cpu = get_cpu();
- int ret;
-
-- ret = evtchn_fifo_init_control_block(cpu);
-+ ret = evtchn_fifo_alloc_control_block(cpu);
- if (ret < 0)
- goto out;
-
-diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
-index 30f6e9251a4a..f15d4353f30f 100644
---- a/fs/cifs/cifsglob.h
-+++ b/fs/cifs/cifsglob.h
-@@ -70,11 +70,6 @@
- #define SERVER_NAME_LENGTH 40
- #define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1)
-
--/* used to define string lengths for reversing unicode strings */
--/* (256+1)*2 = 514 */
--/* (max path length + 1 for null) * 2 for unicode */
--#define MAX_NAME 514
--
- /* SMB echo "timeout" -- FIXME: tunable? */
- #define SMB_ECHO_INTERVAL (60 * HZ)
-
-diff --git a/fs/cifs/file.c b/fs/cifs/file.c
-index 87c4dd072cde..8175b18df819 100644
---- a/fs/cifs/file.c
-+++ b/fs/cifs/file.c
-@@ -2844,7 +2844,7 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server,
- total_read += result;
- }
-
-- return total_read > 0 ? total_read : result;
-+ return total_read > 0 && result != -EAGAIN ? total_read : result;
- }
-
- static ssize_t
-@@ -3267,7 +3267,7 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server,
- total_read += result;
- }
-
-- return total_read > 0 ? total_read : result;
-+ return total_read > 0 && result != -EAGAIN ? total_read : result;
- }
-
- static int cifs_readpages(struct file *file, struct address_space *mapping,
-diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
-index aadc2b68678b..f2ddcf7ac9c3 100644
---- a/fs/cifs/inode.c
-+++ b/fs/cifs/inode.c
-@@ -1706,13 +1706,22 @@ cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
- unlink_target:
- /* Try unlinking the target dentry if it's not negative */
- if (target_dentry->d_inode && (rc == -EACCES || rc == -EEXIST)) {
-- tmprc = cifs_unlink(target_dir, target_dentry);
-+ if (d_is_dir(target_dentry))
-+ tmprc = cifs_rmdir(target_dir, target_dentry);
-+ else
-+ tmprc = cifs_unlink(target_dir, target_dentry);
- if (tmprc)
- goto cifs_rename_exit;
- rc = cifs_do_rename(xid, source_dentry, from_name,
- target_dentry, to_name);
- }
-
-+ /* force revalidate to go get info when needed */
-+ CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0;
-+
-+ source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime =
-+ target_dir->i_mtime = current_fs_time(source_dir->i_sb);
-+
- cifs_rename_exit:
- kfree(info_buf_source);
- kfree(from_name);
-diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
-index b15862e0f68c..2bbf11b09214 100644
---- a/fs/cifs/readdir.c
-+++ b/fs/cifs/readdir.c
-@@ -596,8 +596,8 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
- if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) {
- cfile->invalidHandle = true;
- spin_unlock(&cifs_file_list_lock);
-- if (server->ops->close)
-- server->ops->close(xid, tcon, &cfile->fid);
-+ if (server->ops->close_dir)
-+ server->ops->close_dir(xid, tcon, &cfile->fid);
- } else
- spin_unlock(&cifs_file_list_lock);
- if (cfile->srch_inf.ntwrk_buf_start) {
-diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
-index 3f17b4550831..45992944e238 100644
---- a/fs/cifs/smb2file.c
-+++ b/fs/cifs/smb2file.c
-@@ -50,7 +50,7 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
- goto out;
- }
-
-- smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
-+ smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
- GFP_KERNEL);
- if (smb2_data == NULL) {
- rc = -ENOMEM;
-diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
-index 84c012a6aba0..215f8d3e3e53 100644
---- a/fs/cifs/smb2inode.c
-+++ b/fs/cifs/smb2inode.c
-@@ -131,7 +131,7 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
- *adjust_tz = false;
- *symlink = false;
-
-- smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
-+ smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
- GFP_KERNEL);
- if (smb2_data == NULL)
- return -ENOMEM;
-diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c
-index 94bd4fbb13d3..e31a9dfdcd39 100644
---- a/fs/cifs/smb2maperror.c
-+++ b/fs/cifs/smb2maperror.c
-@@ -605,7 +605,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
- {STATUS_MAPPED_FILE_SIZE_ZERO, -EIO, "STATUS_MAPPED_FILE_SIZE_ZERO"},
- {STATUS_TOO_MANY_OPENED_FILES, -EMFILE, "STATUS_TOO_MANY_OPENED_FILES"},
- {STATUS_CANCELLED, -EIO, "STATUS_CANCELLED"},
-- {STATUS_CANNOT_DELETE, -EIO, "STATUS_CANNOT_DELETE"},
-+ {STATUS_CANNOT_DELETE, -EACCES, "STATUS_CANNOT_DELETE"},
- {STATUS_INVALID_COMPUTER_NAME, -EIO, "STATUS_INVALID_COMPUTER_NAME"},
- {STATUS_FILE_DELETED, -EIO, "STATUS_FILE_DELETED"},
- {STATUS_SPECIAL_ACCOUNT, -EIO, "STATUS_SPECIAL_ACCOUNT"},
-diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
-index 35ddc3ed119d..f8977b2d9187 100644
---- a/fs/cifs/smb2ops.c
-+++ b/fs/cifs/smb2ops.c
-@@ -339,7 +339,7 @@ smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
- int rc;
- struct smb2_file_all_info *smb2_data;
-
-- smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
-+ smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
- GFP_KERNEL);
- if (smb2_data == NULL)
- return -ENOMEM;
-diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
-index 049a3f2693ba..9aab8fe0e508 100644
---- a/fs/cifs/smb2pdu.c
-+++ b/fs/cifs/smb2pdu.c
-@@ -916,7 +916,8 @@ tcon_exit:
- tcon_error_exit:
- if (rsp->hdr.Status == STATUS_BAD_NETWORK_NAME) {
- cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
-- tcon->bad_network_name = true;
-+ if (tcon)
-+ tcon->bad_network_name = true;
- }
- goto tcon_exit;
- }
-@@ -1539,7 +1540,7 @@ SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
- {
- return query_info(xid, tcon, persistent_fid, volatile_fid,
- FILE_ALL_INFORMATION,
-- sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
-+ sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
- sizeof(struct smb2_file_all_info), data);
- }
-
-diff --git a/fs/dcache.c b/fs/dcache.c
-index 7f3b4004c6c3..58d57da91d2a 100644
---- a/fs/dcache.c
-+++ b/fs/dcache.c
-@@ -106,8 +106,7 @@ static inline struct hlist_bl_head *d_hash(const struct dentry *parent,
- unsigned int hash)
- {
- hash += (unsigned long) parent / L1_CACHE_BYTES;
-- hash = hash + (hash >> d_hash_shift);
-- return dentry_hashtable + (hash & d_hash_mask);
-+ return dentry_hashtable + hash_32(hash, d_hash_shift);
- }
-
- /* Statistics gathering. */
-diff --git a/fs/namei.c b/fs/namei.c
-index bdea10963aa5..d5a4faeb39a5 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -34,6 +34,7 @@
- #include
- #include
- #include
-+#include
- #include
-
- #include "internal.h"
-@@ -1624,8 +1625,7 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
-
- static inline unsigned int fold_hash(unsigned long hash)
- {
-- hash += hash >> (8*sizeof(int));
-- return hash;
-+ return hash_64(hash, 32);
- }
-
- #else /* 32-bit case */
-@@ -1797,7 +1797,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
- if (err)
- return err;
- }
-- if (!d_is_directory(nd->path.dentry)) {
-+ if (!d_can_lookup(nd->path.dentry)) {
- err = -ENOTDIR;
- break;
- }
-@@ -1818,7 +1818,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
- struct dentry *root = nd->root.dentry;
- struct inode *inode = root->d_inode;
- if (*name) {
-- if (!d_is_directory(root))
-+ if (!d_can_lookup(root))
- return -ENOTDIR;
- retval = inode_permission(inode, MAY_EXEC);
- if (retval)
-@@ -1874,7 +1874,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
- dentry = f.file->f_path.dentry;
-
- if (*name) {
-- if (!d_is_directory(dentry)) {
-+ if (!d_can_lookup(dentry)) {
- fdput(f);
- return -ENOTDIR;
- }
-@@ -1956,7 +1956,7 @@ static int path_lookupat(int dfd, const char *name,
- err = complete_walk(nd);
-
- if (!err && nd->flags & LOOKUP_DIRECTORY) {
-- if (!d_is_directory(nd->path.dentry)) {
-+ if (!d_can_lookup(nd->path.dentry)) {
- path_put(&nd->path);
- err = -ENOTDIR;
- }
-@@ -2416,11 +2416,11 @@ static int may_delete(struct inode *dir, struct dentry *victim, bool isdir)
- IS_IMMUTABLE(inode) || IS_SWAPFILE(inode))
- return -EPERM;
- if (isdir) {
-- if (!d_is_directory(victim) && !d_is_autodir(victim))
-+ if (!d_is_dir(victim))
- return -ENOTDIR;
- if (IS_ROOT(victim))
- return -EBUSY;
-- } else if (d_is_directory(victim) || d_is_autodir(victim))
-+ } else if (d_is_dir(victim))
- return -EISDIR;
- if (IS_DEADDIR(dir))
- return -ENOENT;
-@@ -3018,11 +3018,10 @@ finish_open:
- }
- audit_inode(name, nd->path.dentry, 0);
- error = -EISDIR;
-- if ((open_flag & O_CREAT) &&
-- (d_is_directory(nd->path.dentry) || d_is_autodir(nd->path.dentry)))
-+ if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
- goto out;
- error = -ENOTDIR;
-- if ((nd->flags & LOOKUP_DIRECTORY) && !d_is_directory(nd->path.dentry))
-+ if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
- goto out;
- if (!S_ISREG(nd->inode->i_mode))
- will_truncate = false;
-@@ -3746,7 +3745,7 @@ exit1:
- slashes:
- if (d_is_negative(dentry))
- error = -ENOENT;
-- else if (d_is_directory(dentry) || d_is_autodir(dentry))
-+ else if (d_is_dir(dentry))
- error = -EISDIR;
- else
- error = -ENOTDIR;
-@@ -4125,7 +4124,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
- struct inode **delegated_inode)
- {
- int error;
-- int is_dir = d_is_directory(old_dentry) || d_is_autodir(old_dentry);
-+ int is_dir = d_is_dir(old_dentry);
- const unsigned char *old_name;
-
- if (old_dentry->d_inode == new_dentry->d_inode)
-@@ -4218,7 +4217,7 @@ retry_deleg:
- if (d_is_negative(old_dentry))
- goto exit4;
- /* unless the source is a directory trailing slashes give -ENOTDIR */
-- if (!d_is_directory(old_dentry) && !d_is_autodir(old_dentry)) {
-+ if (!d_is_dir(old_dentry)) {
- error = -ENOTDIR;
- if (oldnd.last.name[oldnd.last.len])
- goto exit4;
-diff --git a/fs/namespace.c b/fs/namespace.c
-index 65233a5f390a..75536db4b69b 100644
---- a/fs/namespace.c
-+++ b/fs/namespace.c
-@@ -777,6 +777,20 @@ static void attach_mnt(struct mount *mnt,
- list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
- }
-
-+static void attach_shadowed(struct mount *mnt,
-+ struct mount *parent,
-+ struct mount *shadows)
-+{
-+ if (shadows) {
-+ hlist_add_after_rcu(&shadows->mnt_hash, &mnt->mnt_hash);
-+ list_add(&mnt->mnt_child, &shadows->mnt_child);
-+ } else {
-+ hlist_add_head_rcu(&mnt->mnt_hash,
-+ m_hash(&parent->mnt, mnt->mnt_mountpoint));
-+ list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
-+ }
-+}
-+
- /*
- * vfsmount lock must be held for write
- */
-@@ -795,12 +809,7 @@ static void commit_tree(struct mount *mnt, struct mount *shadows)
-
- list_splice(&head, n->list.prev);
-
-- if (shadows)
-- hlist_add_after_rcu(&shadows->mnt_hash, &mnt->mnt_hash);
-- else
-- hlist_add_head_rcu(&mnt->mnt_hash,
-- m_hash(&parent->mnt, mnt->mnt_mountpoint));
-- list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
-+ attach_shadowed(mnt, parent, shadows);
- touch_mnt_namespace(n);
- }
-
-@@ -887,8 +896,21 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
-
- mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~(MNT_WRITE_HOLD|MNT_MARKED);
- /* Don't allow unprivileged users to change mount flags */
-- if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY))
-- mnt->mnt.mnt_flags |= MNT_LOCK_READONLY;
-+ if (flag & CL_UNPRIVILEGED) {
-+ mnt->mnt.mnt_flags |= MNT_LOCK_ATIME;
-+
-+ if (mnt->mnt.mnt_flags & MNT_READONLY)
-+ mnt->mnt.mnt_flags |= MNT_LOCK_READONLY;
-+
-+ if (mnt->mnt.mnt_flags & MNT_NODEV)
-+ mnt->mnt.mnt_flags |= MNT_LOCK_NODEV;
-+
-+ if (mnt->mnt.mnt_flags & MNT_NOSUID)
-+ mnt->mnt.mnt_flags |= MNT_LOCK_NOSUID;
-+
-+ if (mnt->mnt.mnt_flags & MNT_NOEXEC)
-+ mnt->mnt.mnt_flags |= MNT_LOCK_NOEXEC;
-+ }
-
- /* Don't allow unprivileged users to reveal what is under a mount */
- if ((flag & CL_UNPRIVILEGED) && list_empty(&old->mnt_expire))
-@@ -1204,6 +1226,11 @@ static void namespace_unlock(void)
- head.first->pprev = &head.first;
- INIT_HLIST_HEAD(&unmounted);
-
-+ /* undo decrements we'd done in umount_tree() */
-+ hlist_for_each_entry(mnt, &head, mnt_hash)
-+ if (mnt->mnt_ex_mountpoint.mnt)
-+ mntget(mnt->mnt_ex_mountpoint.mnt);
-+
- up_write(&namespace_sem);
-
- synchronize_rcu();
-@@ -1240,6 +1267,9 @@ void umount_tree(struct mount *mnt, int how)
- hlist_add_head(&p->mnt_hash, &tmp_list);
- }
-
-+ hlist_for_each_entry(p, &tmp_list, mnt_hash)
-+ list_del_init(&p->mnt_child);
-+
- if (how)
- propagate_umount(&tmp_list);
-
-@@ -1250,9 +1280,9 @@ void umount_tree(struct mount *mnt, int how)
- p->mnt_ns = NULL;
- if (how < 2)
- p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
-- list_del_init(&p->mnt_child);
- if (mnt_has_parent(p)) {
- put_mountpoint(p->mnt_mp);
-+ mnt_add_count(p->mnt_parent, -1);
- /* move the reference to mountpoint into ->mnt_ex_mountpoint */
- p->mnt_ex_mountpoint.dentry = p->mnt_mountpoint;
- p->mnt_ex_mountpoint.mnt = &p->mnt_parent->mnt;
-@@ -1483,6 +1513,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
- continue;
-
- for (s = r; s; s = next_mnt(s, r)) {
-+ struct mount *t = NULL;
- if (!(flag & CL_COPY_UNBINDABLE) &&
- IS_MNT_UNBINDABLE(s)) {
- s = skip_mnt_tree(s);
-@@ -1504,7 +1535,14 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
- goto out;
- lock_mount_hash();
- list_add_tail(&q->mnt_list, &res->mnt_list);
-- attach_mnt(q, parent, p->mnt_mp);
-+ mnt_set_mountpoint(parent, p->mnt_mp, q);
-+ if (!list_empty(&parent->mnt_mounts)) {
-+ t = list_last_entry(&parent->mnt_mounts,
-+ struct mount, mnt_child);
-+ if (t->mnt_mp != p->mnt_mp)
-+ t = NULL;
-+ }
-+ attach_shadowed(q, parent, t);
- unlock_mount_hash();
- }
- }
-@@ -1887,9 +1925,6 @@ static int change_mount_flags(struct vfsmount *mnt, int ms_flags)
- if (readonly_request == __mnt_is_readonly(mnt))
- return 0;
-
-- if (mnt->mnt_flags & MNT_LOCK_READONLY)
-- return -EPERM;
--
- if (readonly_request)
- error = mnt_make_readonly(real_mount(mnt));
- else
-@@ -1915,6 +1950,33 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
- if (path->dentry != path->mnt->mnt_root)
- return -EINVAL;
-
-+ /* Don't allow changing of locked mnt flags.
-+ *
-+ * No locks need to be held here while testing the various
-+ * MNT_LOCK flags because those flags can never be cleared
-+ * once they are set.
-+ */
-+ if ((mnt->mnt.mnt_flags & MNT_LOCK_READONLY) &&
-+ !(mnt_flags & MNT_READONLY)) {
-+ return -EPERM;
-+ }
-+ if ((mnt->mnt.mnt_flags & MNT_LOCK_NODEV) &&
-+ !(mnt_flags & MNT_NODEV)) {
-+ return -EPERM;
-+ }
-+ if ((mnt->mnt.mnt_flags & MNT_LOCK_NOSUID) &&
-+ !(mnt_flags & MNT_NOSUID)) {
-+ return -EPERM;
-+ }
-+ if ((mnt->mnt.mnt_flags & MNT_LOCK_NOEXEC) &&
-+ !(mnt_flags & MNT_NOEXEC)) {
-+ return -EPERM;
-+ }
-+ if ((mnt->mnt.mnt_flags & MNT_LOCK_ATIME) &&
-+ ((mnt->mnt.mnt_flags & MNT_ATIME_MASK) != (mnt_flags & MNT_ATIME_MASK))) {
-+ return -EPERM;
-+ }
-+
- err = security_sb_remount(sb, data);
- if (err)
- return err;
-@@ -1928,7 +1990,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
- err = do_remount_sb(sb, flags, data, 0);
- if (!err) {
- lock_mount_hash();
-- mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK;
-+ mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK;
- mnt->mnt.mnt_flags = mnt_flags;
- touch_mnt_namespace(mnt->mnt_ns);
- unlock_mount_hash();
-@@ -2113,7 +2175,7 @@ static int do_new_mount(struct path *path, const char *fstype, int flags,
- */
- if (!(type->fs_flags & FS_USERNS_DEV_MOUNT)) {
- flags |= MS_NODEV;
-- mnt_flags |= MNT_NODEV;
-+ mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV;
- }
- }
-
-@@ -2427,6 +2489,14 @@ long do_mount(const char *dev_name, const char *dir_name,
- if (flags & MS_RDONLY)
- mnt_flags |= MNT_READONLY;
-
-+ /* The default atime for remount is preservation */
-+ if ((flags & MS_REMOUNT) &&
-+ ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME |
-+ MS_STRICTATIME)) == 0)) {
-+ mnt_flags &= ~MNT_ATIME_MASK;
-+ mnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK;
-+ }
-+
- flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
- MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
- MS_STRICTATIME);
-diff --git a/fs/pnode.c b/fs/pnode.c
-index a364a704333b..b7f831089500 100644
---- a/fs/pnode.c
-+++ b/fs/pnode.c
-@@ -381,6 +381,7 @@ static void __propagate_umount(struct mount *mnt)
- * other children
- */
- if (child && list_empty(&child->mnt_mounts)) {
-+ list_del_init(&child->mnt_child);
- hlist_del_init_rcu(&child->mnt_hash);
- hlist_add_before_rcu(&child->mnt_hash, &mnt->mnt_hash);
- }
-diff --git a/fs/proc/array.c b/fs/proc/array.c
-index 656e401794de..baf3464bbce0 100644
---- a/fs/proc/array.c
-+++ b/fs/proc/array.c
-@@ -297,15 +297,11 @@ static void render_cap_t(struct seq_file *m, const char *header,
- seq_puts(m, header);
- CAP_FOR_EACH_U32(__capi) {
- seq_printf(m, "%08x",
-- a->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
-+ a->cap[CAP_LAST_U32 - __capi]);
- }
- seq_putc(m, '\n');
- }
-
--/* Remove non-existent capabilities */
--#define NORM_CAPS(v) (v.cap[CAP_TO_INDEX(CAP_LAST_CAP)] &= \
-- CAP_TO_MASK(CAP_LAST_CAP + 1) - 1)
--
- static inline void task_cap(struct seq_file *m, struct task_struct *p)
- {
- const struct cred *cred;
-@@ -319,11 +315,6 @@ static inline void task_cap(struct seq_file *m, struct task_struct *p)
- cap_bset = cred->cap_bset;
- rcu_read_unlock();
-
-- NORM_CAPS(cap_inheritable);
-- NORM_CAPS(cap_permitted);
-- NORM_CAPS(cap_effective);
-- NORM_CAPS(cap_bset);
--
- render_cap_t(m, "CapInh:\t", &cap_inheritable);
- render_cap_t(m, "CapPrm:\t", &cap_permitted);
- render_cap_t(m, "CapEff:\t", &cap_effective);
-diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
-index db2cfb067d0b..5d2518b24cea 100644
---- a/fs/xfs/xfs_aops.c
-+++ b/fs/xfs/xfs_aops.c
-@@ -1660,11 +1660,72 @@ xfs_vm_readpages(
- return mpage_readpages(mapping, pages, nr_pages, xfs_get_blocks);
- }
-
-+/*
-+ * This is basically a copy of __set_page_dirty_buffers() with one
-+ * small tweak: buffers beyond EOF do not get marked dirty. If we mark them
-+ * dirty, we'll never be able to clean them because we don't write buffers
-+ * beyond EOF, and that means we can't invalidate pages that span EOF
-+ * that have been marked dirty. Further, the dirty state can leak into
-+ * the file interior if the file is extended, resulting in all sorts of
-+ * bad things happening as the state does not match the underlying data.
-+ *
-+ * XXX: this really indicates that bufferheads in XFS need to die. Warts like
-+ * this only exist because of bufferheads and how the generic code manages them.
-+ */
-+STATIC int
-+xfs_vm_set_page_dirty(
-+ struct page *page)
-+{
-+ struct address_space *mapping = page->mapping;
-+ struct inode *inode = mapping->host;
-+ loff_t end_offset;
-+ loff_t offset;
-+ int newly_dirty;
-+
-+ if (unlikely(!mapping))
-+ return !TestSetPageDirty(page);
-+
-+ end_offset = i_size_read(inode);
-+ offset = page_offset(page);
-+
-+ spin_lock(&mapping->private_lock);
-+ if (page_has_buffers(page)) {
-+ struct buffer_head *head = page_buffers(page);
-+ struct buffer_head *bh = head;
-+
-+ do {
-+ if (offset < end_offset)
-+ set_buffer_dirty(bh);
-+ bh = bh->b_this_page;
-+ offset += 1 << inode->i_blkbits;
-+ } while (bh != head);
-+ }
-+ newly_dirty = !TestSetPageDirty(page);
-+ spin_unlock(&mapping->private_lock);
-+
-+ if (newly_dirty) {
-+ /* sigh - __set_page_dirty() is static, so copy it here, too */
-+ unsigned long flags;
-+
-+ spin_lock_irqsave(&mapping->tree_lock, flags);
-+ if (page->mapping) { /* Race with truncate? */
-+ WARN_ON_ONCE(!PageUptodate(page));
-+ account_page_dirtied(page, mapping);
-+ radix_tree_tag_set(&mapping->page_tree,
-+ page_index(page), PAGECACHE_TAG_DIRTY);
-+ }
-+ spin_unlock_irqrestore(&mapping->tree_lock, flags);
-+ __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
-+ }
-+ return newly_dirty;
-+}
-+
- const struct address_space_operations xfs_address_space_operations = {
- .readpage = xfs_vm_readpage,
- .readpages = xfs_vm_readpages,
- .writepage = xfs_vm_writepage,
- .writepages = xfs_vm_writepages,
-+ .set_page_dirty = xfs_vm_set_page_dirty,
- .releasepage = xfs_vm_releasepage,
- .invalidatepage = xfs_vm_invalidatepage,
- .write_begin = xfs_vm_write_begin,
-diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
-index 7aeb4c895b32..95f94483c3d7 100644
---- a/fs/xfs/xfs_dquot.c
-+++ b/fs/xfs/xfs_dquot.c
-@@ -1011,7 +1011,8 @@ xfs_qm_dqflush(
- * Get the buffer containing the on-disk dquot
- */
- error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
-- mp->m_quotainfo->qi_dqchunklen, 0, &bp, NULL);
-+ mp->m_quotainfo->qi_dqchunklen, 0, &bp,
-+ &xfs_dquot_buf_ops);
- if (error)
- goto out_unlock;
-
-diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
-index 64b48eade91d..f50def6018a9 100644
---- a/fs/xfs/xfs_file.c
-+++ b/fs/xfs/xfs_file.c
-@@ -302,7 +302,16 @@ xfs_file_aio_read(
- xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL);
- return ret;
- }
-- truncate_pagecache_range(VFS_I(ip), pos, -1);
-+
-+ /*
-+ * Invalidate whole pages. This can return an error if
-+ * we fail to invalidate a page, but this should never
-+ * happen on XFS. Warn if it does fail.
-+ */
-+ ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
-+ pos >> PAGE_CACHE_SHIFT, -1);
-+ WARN_ON_ONCE(ret);
-+ ret = 0;
- }
- xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
- }
-@@ -683,7 +692,15 @@ xfs_file_dio_aio_write(
- pos, -1);
- if (ret)
- goto out;
-- truncate_pagecache_range(VFS_I(ip), pos, -1);
-+ /*
-+ * Invalidate whole pages. This can return an error if
-+ * we fail to invalidate a page, but this should never
-+ * happen on XFS. Warn if it does fail.
-+ */
-+ ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
-+ pos >> PAGE_CACHE_SHIFT, -1);
-+ WARN_ON_ONCE(ret);
-+ ret = 0;
- }
-
- /*
-diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
-index bce53ac81096..eb26418814fe 100644
---- a/fs/xfs/xfs_log_recover.c
-+++ b/fs/xfs/xfs_log_recover.c
-@@ -2125,6 +2125,17 @@ xlog_recover_validate_buf_type(
- __uint16_t magic16;
- __uint16_t magicda;
-
-+ /*
-+ * We can only do post recovery validation on items on CRC enabled
-+ * fielsystems as we need to know when the buffer was written to be able
-+ * to determine if we should have replayed the item. If we replay old
-+ * metadata over a newer buffer, then it will enter a temporarily
-+ * inconsistent state resulting in verification failures. Hence for now
-+ * just avoid the verification stage for non-crc filesystems
-+ */
-+ if (!xfs_sb_version_hascrc(&mp->m_sb))
-+ return;
-+
- magic32 = be32_to_cpu(*(__be32 *)bp->b_addr);
- magic16 = be16_to_cpu(*(__be16*)bp->b_addr);
- magicda = be16_to_cpu(info->magic);
-@@ -2160,8 +2171,6 @@ xlog_recover_validate_buf_type(
- bp->b_ops = &xfs_agf_buf_ops;
- break;
- case XFS_BLFT_AGFL_BUF:
-- if (!xfs_sb_version_hascrc(&mp->m_sb))
-- break;
- if (magic32 != XFS_AGFL_MAGIC) {
- xfs_warn(mp, "Bad AGFL block magic!");
- ASSERT(0);
-@@ -2194,10 +2203,6 @@ xlog_recover_validate_buf_type(
- #endif
- break;
- case XFS_BLFT_DINO_BUF:
-- /*
-- * we get here with inode allocation buffers, not buffers that
-- * track unlinked list changes.
-- */
- if (magic16 != XFS_DINODE_MAGIC) {
- xfs_warn(mp, "Bad INODE block magic!");
- ASSERT(0);
-@@ -2277,8 +2282,6 @@ xlog_recover_validate_buf_type(
- bp->b_ops = &xfs_attr3_leaf_buf_ops;
- break;
- case XFS_BLFT_ATTR_RMT_BUF:
-- if (!xfs_sb_version_hascrc(&mp->m_sb))
-- break;
- if (magic32 != XFS_ATTR3_RMT_MAGIC) {
- xfs_warn(mp, "Bad attr remote magic!");
- ASSERT(0);
-@@ -2385,16 +2388,7 @@ xlog_recover_do_reg_buffer(
- /* Shouldn't be any more regions */
- ASSERT(i == item->ri_total);
-
-- /*
-- * We can only do post recovery validation on items on CRC enabled
-- * fielsystems as we need to know when the buffer was written to be able
-- * to determine if we should have replayed the item. If we replay old
-- * metadata over a newer buffer, then it will enter a temporarily
-- * inconsistent state resulting in verification failures. Hence for now
-- * just avoid the verification stage for non-crc filesystems
-- */
-- if (xfs_sb_version_hascrc(&mp->m_sb))
-- xlog_recover_validate_buf_type(mp, bp, buf_f);
-+ xlog_recover_validate_buf_type(mp, bp, buf_f);
- }
-
- /*
-@@ -2502,12 +2496,29 @@ xlog_recover_buffer_pass2(
- }
-
- /*
-- * recover the buffer only if we get an LSN from it and it's less than
-+ * Recover the buffer only if we get an LSN from it and it's less than
- * the lsn of the transaction we are replaying.
-+ *
-+ * Note that we have to be extremely careful of readahead here.
-+ * Readahead does not attach verfiers to the buffers so if we don't
-+ * actually do any replay after readahead because of the LSN we found
-+ * in the buffer if more recent than that current transaction then we
-+ * need to attach the verifier directly. Failure to do so can lead to
-+ * future recovery actions (e.g. EFI and unlinked list recovery) can
-+ * operate on the buffers and they won't get the verifier attached. This
-+ * can lead to blocks on disk having the correct content but a stale
-+ * CRC.
-+ *
-+ * It is safe to assume these clean buffers are currently up to date.
-+ * If the buffer is dirtied by a later transaction being replayed, then
-+ * the verifier will be reset to match whatever recover turns that
-+ * buffer into.
- */
- lsn = xlog_recover_get_buf_lsn(mp, bp);
-- if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0)
-+ if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) {
-+ xlog_recover_validate_buf_type(mp, bp, buf_f);
- goto out_release;
-+ }
-
- if (buf_f->blf_flags & XFS_BLF_INODE_BUF) {
- error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f);
-diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
-index 348e4d2ed6e6..6d7d1de13403 100644
---- a/fs/xfs/xfs_qm.c
-+++ b/fs/xfs/xfs_qm.c
-@@ -1176,6 +1176,12 @@ xfs_qm_dqiter_bufs(
- if (error)
- break;
-
-+ /*
-+ * A corrupt buffer might not have a verifier attached, so
-+ * make sure we have the correct one attached before writeback
-+ * occurs.
-+ */
-+ bp->b_ops = &xfs_dquot_buf_ops;
- xfs_qm_reset_dqcounts(mp, bp, firstid, type);
- xfs_buf_delwri_queue(bp, buffer_list);
- xfs_buf_relse(bp);
-@@ -1261,7 +1267,7 @@ xfs_qm_dqiterate(
- xfs_buf_readahead(mp->m_ddev_targp,
- XFS_FSB_TO_DADDR(mp, rablkno),
- mp->m_quotainfo->qi_dqchunklen,
-- NULL);
-+ &xfs_dquot_buf_ops);
- rablkno++;
- }
- }
-diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
-index 8256eb4ad057..e9c4f190ffae 100644
---- a/include/acpi/acpi_bus.h
-+++ b/include/acpi/acpi_bus.h
-@@ -228,7 +228,6 @@ struct acpi_device_pnp {
- acpi_device_name device_name; /* Driver-determined */
- acpi_device_class device_class; /* " */
- union acpi_object *str_obj; /* unicode string for _STR method */
-- unsigned long sun; /* _SUN */
- };
-
- #define acpi_device_bid(d) ((d)->pnp.bus_id)
-diff --git a/include/linux/capability.h b/include/linux/capability.h
-index 84b13ad67c1c..aa93e5ef594c 100644
---- a/include/linux/capability.h
-+++ b/include/linux/capability.h
-@@ -78,8 +78,11 @@ extern const kernel_cap_t __cap_init_eff_set;
- # error Fix up hand-coded capability macro initializers
- #else /* HAND-CODED capability initializers */
-
-+#define CAP_LAST_U32 ((_KERNEL_CAPABILITY_U32S) - 1)
-+#define CAP_LAST_U32_VALID_MASK (CAP_TO_MASK(CAP_LAST_CAP + 1) -1)
-+
- # define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }})
--# define CAP_FULL_SET ((kernel_cap_t){{ ~0, ~0 }})
-+# define CAP_FULL_SET ((kernel_cap_t){{ ~0, CAP_LAST_U32_VALID_MASK }})
- # define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \
- | CAP_TO_MASK(CAP_LINUX_IMMUTABLE), \
- CAP_FS_MASK_B1 } })
-diff --git a/include/linux/dcache.h b/include/linux/dcache.h
-index bf72e9ac6de0..3b50cac7ccb3 100644
---- a/include/linux/dcache.h
-+++ b/include/linux/dcache.h
-@@ -429,7 +429,7 @@ static inline unsigned __d_entry_type(const struct dentry *dentry)
- return dentry->d_flags & DCACHE_ENTRY_TYPE;
- }
-
--static inline bool d_is_directory(const struct dentry *dentry)
-+static inline bool d_can_lookup(const struct dentry *dentry)
- {
- return __d_entry_type(dentry) == DCACHE_DIRECTORY_TYPE;
- }
-@@ -439,6 +439,11 @@ static inline bool d_is_autodir(const struct dentry *dentry)
- return __d_entry_type(dentry) == DCACHE_AUTODIR_TYPE;
- }
-
-+static inline bool d_is_dir(const struct dentry *dentry)
-+{
-+ return d_can_lookup(dentry) || d_is_autodir(dentry);
-+}
-+
- static inline bool d_is_symlink(const struct dentry *dentry)
- {
- return __d_entry_type(dentry) == DCACHE_SYMLINK_TYPE;
-diff --git a/include/linux/mount.h b/include/linux/mount.h
-index 839bac270904..b0c1e6574e7f 100644
---- a/include/linux/mount.h
-+++ b/include/linux/mount.h
-@@ -42,13 +42,20 @@ struct mnt_namespace;
- * flag, consider how it interacts with shared mounts.
- */
- #define MNT_SHARED_MASK (MNT_UNBINDABLE)
--#define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE)
-+#define MNT_USER_SETTABLE_MASK (MNT_NOSUID | MNT_NODEV | MNT_NOEXEC \
-+ | MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME \
-+ | MNT_READONLY)
-+#define MNT_ATIME_MASK (MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME )
-
- #define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
- MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED)
-
- #define MNT_INTERNAL 0x4000
-
-+#define MNT_LOCK_ATIME 0x040000
-+#define MNT_LOCK_NOEXEC 0x080000
-+#define MNT_LOCK_NOSUID 0x100000
-+#define MNT_LOCK_NODEV 0x200000
- #define MNT_LOCK_READONLY 0x400000
- #define MNT_LOCKED 0x800000
- #define MNT_DOOMED 0x1000000
-diff --git a/include/linux/tpm.h b/include/linux/tpm.h
-index fff1d0976f80..8350c538b486 100644
---- a/include/linux/tpm.h
-+++ b/include/linux/tpm.h
-@@ -39,6 +39,9 @@ struct tpm_class_ops {
- int (*send) (struct tpm_chip *chip, u8 *buf, size_t len);
- void (*cancel) (struct tpm_chip *chip);
- u8 (*status) (struct tpm_chip *chip);
-+ bool (*update_timeouts)(struct tpm_chip *chip,
-+ unsigned long *timeout_cap);
-+
- };
-
- #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
-diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
-index b4f1effc9216..409fafb63f63 100644
---- a/include/scsi/scsi_device.h
-+++ b/include/scsi/scsi_device.h
-@@ -149,6 +149,7 @@ struct scsi_device {
- unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
- unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
- unsigned skip_vpd_pages:1; /* do not read VPD pages */
-+ unsigned try_vpd_pages:1; /* attempt to read VPD pages */
- unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
- unsigned no_start_on_add:1; /* do not issue start on add */
- unsigned allow_restart:1; /* issue START_UNIT in error handler */
-diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
-index 447d2d7466fc..183eaab7c380 100644
---- a/include/scsi/scsi_devinfo.h
-+++ b/include/scsi/scsi_devinfo.h
-@@ -32,4 +32,9 @@
- #define BLIST_ATTACH_PQ3 0x1000000 /* Scan: Attach to PQ3 devices */
- #define BLIST_NO_DIF 0x2000000 /* Disable T10 PI (DIF) */
- #define BLIST_SKIP_VPD_PAGES 0x4000000 /* Ignore SBC-3 VPD pages */
-+#define BLIST_SCSI3LUN 0x8000000 /* Scan more than 256 LUNs
-+ for sequential scan */
-+#define BLIST_TRY_VPD_PAGES 0x10000000 /* Attempt to read VPD pages */
-+#define BLIST_NO_RSOC 0x20000000 /* don't try to issue RSOC */
-+
- #endif
-diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h
-index 99b80abf360a..3066718eb120 100644
---- a/include/uapi/rdma/rdma_user_cm.h
-+++ b/include/uapi/rdma/rdma_user_cm.h
-@@ -34,6 +34,7 @@
- #define RDMA_USER_CM_H
-
- #include
-+#include
- #include
- #include
- #include
-diff --git a/kernel/audit.c b/kernel/audit.c
-index 0c9dc860cc15..2c0ecd1753de 100644
---- a/kernel/audit.c
-+++ b/kernel/audit.c
-@@ -1628,7 +1628,7 @@ void audit_log_cap(struct audit_buffer *ab, char *prefix, kernel_cap_t *cap)
- audit_log_format(ab, " %s=", prefix);
- CAP_FOR_EACH_U32(i) {
- audit_log_format(ab, "%08x",
-- cap->cap[(_KERNEL_CAPABILITY_U32S-1) - i]);
-+ cap->cap[CAP_LAST_U32 - i]);
- }
- }
-
-diff --git a/kernel/capability.c b/kernel/capability.c
-index 1191a44786df..00adb2193d01 100644
---- a/kernel/capability.c
-+++ b/kernel/capability.c
-@@ -268,6 +268,10 @@ SYSCALL_DEFINE2(capset, cap_user_header_t, header, const cap_user_data_t, data)
- i++;
- }
-
-+ effective.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
-+ permitted.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
-+ inheritable.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
-+
- new = prepare_creds();
- if (!new)
- return -ENOMEM;
-diff --git a/kernel/smp.c b/kernel/smp.c
-index ffee35bef179..ff87d4479558 100644
---- a/kernel/smp.c
-+++ b/kernel/smp.c
-@@ -617,7 +617,7 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
- if (cond_func(cpu, info)) {
- ret = smp_call_function_single(cpu, func,
- info, wait);
-- WARN_ON_ONCE(!ret);
-+ WARN_ON_ONCE(ret);
- }
- preempt_enable();
- }
-diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
-index 0954450df7dc..a53f1bbc546b 100644
---- a/kernel/trace/ring_buffer.c
-+++ b/kernel/trace/ring_buffer.c
-@@ -1981,7 +1981,7 @@ rb_add_time_stamp(struct ring_buffer_event *event, u64 delta)
-
- /**
- * rb_update_event - update event type and data
-- * @event: the even to update
-+ * @event: the event to update
- * @type: the type of event
- * @length: the size of the event field in the ring buffer
- *
-@@ -3354,21 +3354,16 @@ static void rb_iter_reset(struct ring_buffer_iter *iter)
- struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
-
- /* Iterator usage is expected to have record disabled */
-- if (list_empty(&cpu_buffer->reader_page->list)) {
-- iter->head_page = rb_set_head_page(cpu_buffer);
-- if (unlikely(!iter->head_page))
-- return;
-- iter->head = iter->head_page->read;
-- } else {
-- iter->head_page = cpu_buffer->reader_page;
-- iter->head = cpu_buffer->reader_page->read;
-- }
-+ iter->head_page = cpu_buffer->reader_page;
-+ iter->head = cpu_buffer->reader_page->read;
-+
-+ iter->cache_reader_page = iter->head_page;
-+ iter->cache_read = iter->head;
-+
- if (iter->head)
- iter->read_stamp = cpu_buffer->read_stamp;
- else
- iter->read_stamp = iter->head_page->page->time_stamp;
-- iter->cache_reader_page = cpu_buffer->reader_page;
-- iter->cache_read = cpu_buffer->read;
- }
-
- /**
-@@ -3761,12 +3756,14 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
- return NULL;
-
- /*
-- * We repeat when a time extend is encountered.
-- * Since the time extend is always attached to a data event,
-- * we should never loop more than once.
-- * (We never hit the following condition more than twice).
-+ * We repeat when a time extend is encountered or we hit
-+ * the end of the page. Since the time extend is always attached
-+ * to a data event, we should never loop more than three times.
-+ * Once for going to next page, once on time extend, and
-+ * finally once to get the event.
-+ * (We never hit the following condition more than thrice).
- */
-- if (RB_WARN_ON(cpu_buffer, ++nr_loops > 2))
-+ if (RB_WARN_ON(cpu_buffer, ++nr_loops > 3))
- return NULL;
-
- if (rb_per_cpu_empty(cpu_buffer))
-diff --git a/lib/assoc_array.c b/lib/assoc_array.c
-index c0b1007011e1..2404d03e251a 100644
---- a/lib/assoc_array.c
-+++ b/lib/assoc_array.c
-@@ -1723,11 +1723,13 @@ ascend_old_tree:
- shortcut = assoc_array_ptr_to_shortcut(ptr);
- slot = shortcut->parent_slot;
- cursor = shortcut->back_pointer;
-+ if (!cursor)
-+ goto gc_complete;
- } else {
- slot = node->parent_slot;
- cursor = ptr;
- }
-- BUG_ON(!ptr);
-+ BUG_ON(!cursor);
- node = assoc_array_ptr_to_node(cursor);
- slot++;
- goto continue_node;
-@@ -1735,7 +1737,7 @@ ascend_old_tree:
- gc_complete:
- edit->set[0].to = new_root;
- assoc_array_apply_edit(edit);
-- edit->array->nr_leaves_on_tree = nr_leaves_on_tree;
-+ array->nr_leaves_on_tree = nr_leaves_on_tree;
- return 0;
-
- enomem:
-diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
-index 27ae84154586..06a7a769737f 100644
---- a/net/bluetooth/l2cap_sock.c
-+++ b/net/bluetooth/l2cap_sock.c
-@@ -1112,7 +1112,8 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
- l2cap_chan_close(chan, 0);
- lock_sock(sk);
-
-- if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
-+ if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
-+ !(current->flags & PF_EXITING))
- err = bt_sock_wait_state(sk, BT_CLOSED,
- sk->sk_lingertime);
- }
-diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
-index facd8a79c038..b08865111024 100644
---- a/net/bluetooth/rfcomm/core.c
-+++ b/net/bluetooth/rfcomm/core.c
-@@ -1859,10 +1859,13 @@ static struct rfcomm_session *rfcomm_process_rx(struct rfcomm_session *s)
- /* Get data directly from socket receive queue without copying it. */
- while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
- skb_orphan(skb);
-- if (!skb_linearize(skb))
-+ if (!skb_linearize(skb)) {
- s = rfcomm_recv_frame(s, skb);
-- else
-+ if (!s)
-+ break;
-+ } else {
- kfree_skb(skb);
-+ }
- }
-
- if (s && (sk->sk_state == BT_CLOSED))
-diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
-index 3c2d3e4aa2f5..a0050de6f1f1 100644
---- a/net/bluetooth/rfcomm/sock.c
-+++ b/net/bluetooth/rfcomm/sock.c
-@@ -898,7 +898,8 @@ static int rfcomm_sock_shutdown(struct socket *sock, int how)
- sk->sk_shutdown = SHUTDOWN_MASK;
- __rfcomm_sock_close(sk);
-
-- if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
-+ if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
-+ !(current->flags & PF_EXITING))
- err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime);
- }
- release_sock(sk);
-diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
-index 24fa3964b3c8..316dd4e0af39 100644
---- a/net/bluetooth/sco.c
-+++ b/net/bluetooth/sco.c
-@@ -909,7 +909,8 @@ static int sco_sock_shutdown(struct socket *sock, int how)
- sco_sock_clear_timer(sk);
- __sco_sock_close(sk);
-
-- if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
-+ if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
-+ !(current->flags & PF_EXITING))
- err = bt_sock_wait_state(sk, BT_CLOSED,
- sk->sk_lingertime);
- }
-@@ -929,7 +930,8 @@ static int sco_sock_release(struct socket *sock)
-
- sco_sock_close(sk);
-
-- if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) {
-+ if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
-+ !(current->flags & PF_EXITING)) {
- lock_sock(sk);
- err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime);
- release_sock(sk);
-diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
-index 96238ba95f2b..de6662b14e1f 100644
---- a/net/ceph/auth_x.c
-+++ b/net/ceph/auth_x.c
-@@ -13,8 +13,6 @@
- #include "auth_x.h"
- #include "auth_x_protocol.h"
-
--#define TEMP_TICKET_BUF_LEN 256
--
- static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed);
-
- static int ceph_x_is_authenticated(struct ceph_auth_client *ac)
-@@ -64,7 +62,7 @@ static int ceph_x_encrypt(struct ceph_crypto_key *secret,
- }
-
- static int ceph_x_decrypt(struct ceph_crypto_key *secret,
-- void **p, void *end, void *obuf, size_t olen)
-+ void **p, void *end, void **obuf, size_t olen)
- {
- struct ceph_x_encrypt_header head;
- size_t head_len = sizeof(head);
-@@ -75,8 +73,14 @@ static int ceph_x_decrypt(struct ceph_crypto_key *secret,
- return -EINVAL;
-
- dout("ceph_x_decrypt len %d\n", len);
-- ret = ceph_decrypt2(secret, &head, &head_len, obuf, &olen,
-- *p, len);
-+ if (*obuf == NULL) {
-+ *obuf = kmalloc(len, GFP_NOFS);
-+ if (!*obuf)
-+ return -ENOMEM;
-+ olen = len;
-+ }
-+
-+ ret = ceph_decrypt2(secret, &head, &head_len, *obuf, &olen, *p, len);
- if (ret)
- return ret;
- if (head.struct_v != 1 || le64_to_cpu(head.magic) != CEPHX_ENC_MAGIC)
-@@ -129,139 +133,120 @@ static void remove_ticket_handler(struct ceph_auth_client *ac,
- kfree(th);
- }
-
--static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
-- struct ceph_crypto_key *secret,
-- void *buf, void *end)
-+static int process_one_ticket(struct ceph_auth_client *ac,
-+ struct ceph_crypto_key *secret,
-+ void **p, void *end)
- {
- struct ceph_x_info *xi = ac->private;
-- int num;
-- void *p = buf;
-+ int type;
-+ u8 tkt_struct_v, blob_struct_v;
-+ struct ceph_x_ticket_handler *th;
-+ void *dbuf = NULL;
-+ void *dp, *dend;
-+ int dlen;
-+ char is_enc;
-+ struct timespec validity;
-+ struct ceph_crypto_key old_key;
-+ void *ticket_buf = NULL;
-+ void *tp, *tpend;
-+ struct ceph_timespec new_validity;
-+ struct ceph_crypto_key new_session_key;
-+ struct ceph_buffer *new_ticket_blob;
-+ unsigned long new_expires, new_renew_after;
-+ u64 new_secret_id;
- int ret;
-- char *dbuf;
-- char *ticket_buf;
-- u8 reply_struct_v;
-
-- dbuf = kmalloc(TEMP_TICKET_BUF_LEN, GFP_NOFS);
-- if (!dbuf)
-- return -ENOMEM;
-+ ceph_decode_need(p, end, sizeof(u32) + 1, bad);
-
-- ret = -ENOMEM;
-- ticket_buf = kmalloc(TEMP_TICKET_BUF_LEN, GFP_NOFS);
-- if (!ticket_buf)
-- goto out_dbuf;
-+ type = ceph_decode_32(p);
-+ dout(" ticket type %d %s\n", type, ceph_entity_type_name(type));
-
-- ceph_decode_need(&p, end, 1 + sizeof(u32), bad);
-- reply_struct_v = ceph_decode_8(&p);
-- if (reply_struct_v != 1)
-+ tkt_struct_v = ceph_decode_8(p);
-+ if (tkt_struct_v != 1)
- goto bad;
-- num = ceph_decode_32(&p);
-- dout("%d tickets\n", num);
-- while (num--) {
-- int type;
-- u8 tkt_struct_v, blob_struct_v;
-- struct ceph_x_ticket_handler *th;
-- void *dp, *dend;
-- int dlen;
-- char is_enc;
-- struct timespec validity;
-- struct ceph_crypto_key old_key;
-- void *tp, *tpend;
-- struct ceph_timespec new_validity;
-- struct ceph_crypto_key new_session_key;
-- struct ceph_buffer *new_ticket_blob;
-- unsigned long new_expires, new_renew_after;
-- u64 new_secret_id;
--
-- ceph_decode_need(&p, end, sizeof(u32) + 1, bad);
--
-- type = ceph_decode_32(&p);
-- dout(" ticket type %d %s\n", type, ceph_entity_type_name(type));
--
-- tkt_struct_v = ceph_decode_8(&p);
-- if (tkt_struct_v != 1)
-- goto bad;
--
-- th = get_ticket_handler(ac, type);
-- if (IS_ERR(th)) {
-- ret = PTR_ERR(th);
-- goto out;
-- }
-
-- /* blob for me */
-- dlen = ceph_x_decrypt(secret, &p, end, dbuf,
-- TEMP_TICKET_BUF_LEN);
-- if (dlen <= 0) {
-- ret = dlen;
-- goto out;
-- }
-- dout(" decrypted %d bytes\n", dlen);
-- dend = dbuf + dlen;
-- dp = dbuf;
-+ th = get_ticket_handler(ac, type);
-+ if (IS_ERR(th)) {
-+ ret = PTR_ERR(th);
-+ goto out;
-+ }
-
-- tkt_struct_v = ceph_decode_8(&dp);
-- if (tkt_struct_v != 1)
-- goto bad;
-+ /* blob for me */
-+ dlen = ceph_x_decrypt(secret, p, end, &dbuf, 0);
-+ if (dlen <= 0) {
-+ ret = dlen;
-+ goto out;
-+ }
-+ dout(" decrypted %d bytes\n", dlen);
-+ dp = dbuf;
-+ dend = dp + dlen;
-
-- memcpy(&old_key, &th->session_key, sizeof(old_key));
-- ret = ceph_crypto_key_decode(&new_session_key, &dp, dend);
-- if (ret)
-- goto out;
-+ tkt_struct_v = ceph_decode_8(&dp);
-+ if (tkt_struct_v != 1)
-+ goto bad;
-
-- ceph_decode_copy(&dp, &new_validity, sizeof(new_validity));
-- ceph_decode_timespec(&validity, &new_validity);
-- new_expires = get_seconds() + validity.tv_sec;
-- new_renew_after = new_expires - (validity.tv_sec / 4);
-- dout(" expires=%lu renew_after=%lu\n", new_expires,
-- new_renew_after);
-+ memcpy(&old_key, &th->session_key, sizeof(old_key));
-+ ret = ceph_crypto_key_decode(&new_session_key, &dp, dend);
-+ if (ret)
-+ goto out;
-
-- /* ticket blob for service */
-- ceph_decode_8_safe(&p, end, is_enc, bad);
-- tp = ticket_buf;
-- if (is_enc) {
-- /* encrypted */
-- dout(" encrypted ticket\n");
-- dlen = ceph_x_decrypt(&old_key, &p, end, ticket_buf,
-- TEMP_TICKET_BUF_LEN);
-- if (dlen < 0) {
-- ret = dlen;
-- goto out;
-- }
-- dlen = ceph_decode_32(&tp);
-- } else {
-- /* unencrypted */
-- ceph_decode_32_safe(&p, end, dlen, bad);
-- ceph_decode_need(&p, end, dlen, bad);
-- ceph_decode_copy(&p, ticket_buf, dlen);
-+ ceph_decode_copy(&dp, &new_validity, sizeof(new_validity));
-+ ceph_decode_timespec(&validity, &new_validity);
-+ new_expires = get_seconds() + validity.tv_sec;
-+ new_renew_after = new_expires - (validity.tv_sec / 4);
-+ dout(" expires=%lu renew_after=%lu\n", new_expires,
-+ new_renew_after);
-+
-+ /* ticket blob for service */
-+ ceph_decode_8_safe(p, end, is_enc, bad);
-+ if (is_enc) {
-+ /* encrypted */
-+ dout(" encrypted ticket\n");
-+ dlen = ceph_x_decrypt(&old_key, p, end, &ticket_buf, 0);
-+ if (dlen < 0) {
-+ ret = dlen;
-+ goto out;
- }
-- tpend = tp + dlen;
-- dout(" ticket blob is %d bytes\n", dlen);
-- ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad);
-- blob_struct_v = ceph_decode_8(&tp);
-- new_secret_id = ceph_decode_64(&tp);
-- ret = ceph_decode_buffer(&new_ticket_blob, &tp, tpend);
-- if (ret)
-+ tp = ticket_buf;
-+ dlen = ceph_decode_32(&tp);
-+ } else {
-+ /* unencrypted */
-+ ceph_decode_32_safe(p, end, dlen, bad);
-+ ticket_buf = kmalloc(dlen, GFP_NOFS);
-+ if (!ticket_buf) {
-+ ret = -ENOMEM;
- goto out;
--
-- /* all is well, update our ticket */
-- ceph_crypto_key_destroy(&th->session_key);
-- if (th->ticket_blob)
-- ceph_buffer_put(th->ticket_blob);
-- th->session_key = new_session_key;
-- th->ticket_blob = new_ticket_blob;
-- th->validity = new_validity;
-- th->secret_id = new_secret_id;
-- th->expires = new_expires;
-- th->renew_after = new_renew_after;
-- dout(" got ticket service %d (%s) secret_id %lld len %d\n",
-- type, ceph_entity_type_name(type), th->secret_id,
-- (int)th->ticket_blob->vec.iov_len);
-- xi->have_keys |= th->service;
-+ }
-+ tp = ticket_buf;
-+ ceph_decode_need(p, end, dlen, bad);
-+ ceph_decode_copy(p, ticket_buf, dlen);
- }
-+ tpend = tp + dlen;
-+ dout(" ticket blob is %d bytes\n", dlen);
-+ ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad);
-+ blob_struct_v = ceph_decode_8(&tp);
-+ new_secret_id = ceph_decode_64(&tp);
-+ ret = ceph_decode_buffer(&new_ticket_blob, &tp, tpend);
-+ if (ret)
-+ goto out;
-+
-+ /* all is well, update our ticket */
-+ ceph_crypto_key_destroy(&th->session_key);
-+ if (th->ticket_blob)
-+ ceph_buffer_put(th->ticket_blob);
-+ th->session_key = new_session_key;
-+ th->ticket_blob = new_ticket_blob;
-+ th->validity = new_validity;
-+ th->secret_id = new_secret_id;
-+ th->expires = new_expires;
-+ th->renew_after = new_renew_after;
-+ dout(" got ticket service %d (%s) secret_id %lld len %d\n",
-+ type, ceph_entity_type_name(type), th->secret_id,
-+ (int)th->ticket_blob->vec.iov_len);
-+ xi->have_keys |= th->service;
-
-- ret = 0;
- out:
- kfree(ticket_buf);
--out_dbuf:
- kfree(dbuf);
- return ret;
-
-@@ -270,6 +255,34 @@ bad:
- goto out;
- }
-
-+static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
-+ struct ceph_crypto_key *secret,
-+ void *buf, void *end)
-+{
-+ void *p = buf;
-+ u8 reply_struct_v;
-+ u32 num;
-+ int ret;
-+
-+ ceph_decode_8_safe(&p, end, reply_struct_v, bad);
-+ if (reply_struct_v != 1)
-+ return -EINVAL;
-+
-+ ceph_decode_32_safe(&p, end, num, bad);
-+ dout("%d tickets\n", num);
-+
-+ while (num--) {
-+ ret = process_one_ticket(ac, secret, &p, end);
-+ if (ret)
-+ return ret;
-+ }
-+
-+ return 0;
-+
-+bad:
-+ return -EINVAL;
-+}
-+
- static int ceph_x_build_authorizer(struct ceph_auth_client *ac,
- struct ceph_x_ticket_handler *th,
- struct ceph_x_authorizer *au)
-@@ -583,13 +596,14 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
- struct ceph_x_ticket_handler *th;
- int ret = 0;
- struct ceph_x_authorize_reply reply;
-+ void *preply = &reply;
- void *p = au->reply_buf;
- void *end = p + sizeof(au->reply_buf);
-
- th = get_ticket_handler(ac, au->service);
- if (IS_ERR(th))
- return PTR_ERR(th);
-- ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply));
-+ ret = ceph_x_decrypt(&th->session_key, &p, end, &preply, sizeof(reply));
- if (ret < 0)
- return ret;
- if (ret != sizeof(reply))
-diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
-index 988721a629eb..0a31298737ac 100644
---- a/net/ceph/messenger.c
-+++ b/net/ceph/messenger.c
-@@ -900,7 +900,7 @@ static void ceph_msg_data_pages_cursor_init(struct ceph_msg_data_cursor *cursor,
- BUG_ON(page_count > (int)USHRT_MAX);
- cursor->page_count = (unsigned short)page_count;
- BUG_ON(length > SIZE_MAX - cursor->page_offset);
-- cursor->last_piece = (size_t)cursor->page_offset + length <= PAGE_SIZE;
-+ cursor->last_piece = cursor->page_offset + cursor->resid <= PAGE_SIZE;
- }
-
- static struct page *
-diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
-index 2ac9ef35110b..dbcbf5a4707f 100644
---- a/net/ceph/mon_client.c
-+++ b/net/ceph/mon_client.c
-@@ -1041,7 +1041,15 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
- if (!m) {
- pr_info("alloc_msg unknown type %d\n", type);
- *skip = 1;
-+ } else if (front_len > m->front_alloc_len) {
-+ pr_warning("mon_alloc_msg front %d > prealloc %d (%u#%llu)\n",
-+ front_len, m->front_alloc_len,
-+ (unsigned int)con->peer_name.type,
-+ le64_to_cpu(con->peer_name.num));
-+ ceph_msg_put(m);
-+ m = ceph_msg_new(type, front_len, GFP_NOFS, false);
- }
-+
- return m;
- }
-
-diff --git a/security/commoncap.c b/security/commoncap.c
-index b9d613e0ef14..963dc5981661 100644
---- a/security/commoncap.c
-+++ b/security/commoncap.c
-@@ -421,6 +421,9 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
- cpu_caps->inheritable.cap[i] = le32_to_cpu(caps.data[i].inheritable);
- }
-
-+ cpu_caps->permitted.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
-+ cpu_caps->inheritable.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
-+
- return 0;
- }
-
-diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c
-index a3881c4381c9..bcf591373a7a 100644
---- a/sound/soc/blackfin/bf5xx-i2s-pcm.c
-+++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c
-@@ -290,19 +290,19 @@ static int bf5xx_pcm_silence(struct snd_pcm_substream *substream,
- unsigned int sample_size = runtime->sample_bits / 8;
- void *buf = runtime->dma_area;
- struct bf5xx_i2s_pcm_data *dma_data;
-- unsigned int offset, size;
-+ unsigned int offset, samples;
-
- dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
-
- if (dma_data->tdm_mode) {
- offset = pos * 8 * sample_size;
-- size = count * 8 * sample_size;
-+ samples = count * 8;
- } else {
- offset = frames_to_bytes(runtime, pos);
-- size = frames_to_bytes(runtime, count);
-+ samples = count * runtime->channels;
- }
-
-- snd_pcm_format_set_silence(runtime->format, buf + offset, size);
-+ snd_pcm_format_set_silence(runtime->format, buf + offset, samples);
-
- return 0;
- }
-diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
-index d71c59cf7bdd..370b742117ef 100644
---- a/sound/soc/codecs/adau1701.c
-+++ b/sound/soc/codecs/adau1701.c
-@@ -230,8 +230,10 @@ static int adau1701_reg_read(void *context, unsigned int reg,
-
- *value = 0;
-
-- for (i = 0; i < size; i++)
-- *value |= recv_buf[i] << (i * 8);
-+ for (i = 0; i < size; i++) {
-+ *value <<= 8;
-+ *value |= recv_buf[i];
-+ }
-
- return 0;
- }
-diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
-index b3f7c9026a29..ddfb0fddd030 100644
---- a/sound/soc/codecs/max98090.c
-+++ b/sound/soc/codecs/max98090.c
-@@ -2250,7 +2250,7 @@ static int max98090_probe(struct snd_soc_codec *codec)
- /* Register for interrupts */
- dev_dbg(codec->dev, "irq = %d\n", max98090->irq);
-
-- ret = request_threaded_irq(max98090->irq, NULL,
-+ ret = devm_request_threaded_irq(codec->dev, max98090->irq, NULL,
- max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- "max98090_interrupt", codec);
- if (ret < 0) {
-diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
-index 886924934aa5..5cb515b08a32 100644
---- a/sound/soc/codecs/rt5640.c
-+++ b/sound/soc/codecs/rt5640.c
-@@ -2071,6 +2071,7 @@ static struct snd_soc_codec_driver soc_codec_dev_rt5640 = {
- static const struct regmap_config rt5640_regmap = {
- .reg_bits = 8,
- .val_bits = 16,
-+ .use_single_rw = true,
-
- .max_register = RT5640_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5640_ranges) *
- RT5640_PR_SPACING),
-diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
-index adb72063d44e..d98e52f647d2 100644
---- a/sound/soc/codecs/wm8994.c
-+++ b/sound/soc/codecs/wm8994.c
-@@ -3497,6 +3497,7 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data)
- return IRQ_HANDLED;
- }
-
-+/* Should be called with accdet_lock held */
- static void wm1811_micd_stop(struct snd_soc_codec *codec)
- {
- struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
-@@ -3504,14 +3505,10 @@ static void wm1811_micd_stop(struct snd_soc_codec *codec)
- if (!wm8994->jackdet)
- return;
-
-- mutex_lock(&wm8994->accdet_lock);
--
- snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0);
-
- wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK);
-
-- mutex_unlock(&wm8994->accdet_lock);
--
- if (wm8994->wm8994->pdata.jd_ext_cap)
- snd_soc_dapm_disable_pin(&codec->dapm,
- "MICBIAS2");
-@@ -3552,10 +3549,10 @@ static void wm8958_open_circuit_work(struct work_struct *work)
- open_circuit_work.work);
- struct device *dev = wm8994->wm8994->dev;
-
-- wm1811_micd_stop(wm8994->hubs.codec);
--
- mutex_lock(&wm8994->accdet_lock);
-
-+ wm1811_micd_stop(wm8994->hubs.codec);
-+
- dev_dbg(dev, "Reporting open circuit\n");
-
- wm8994->jack_mic = false;
-diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
-index 444626fcab40..53c03aff762e 100644
---- a/sound/soc/codecs/wm_adsp.c
-+++ b/sound/soc/codecs/wm_adsp.c
-@@ -1745,3 +1745,5 @@ int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs)
- return 0;
- }
- EXPORT_SYMBOL_GPL(wm_adsp2_init);
-+
-+MODULE_LICENSE("GPL v2");
-diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
-index a3119a00d8fa..6c6b35e471c8 100644
---- a/sound/soc/pxa/pxa-ssp.c
-+++ b/sound/soc/pxa/pxa-ssp.c
-@@ -725,7 +725,8 @@ static int pxa_ssp_probe(struct snd_soc_dai *dai)
- ssp_handle = of_parse_phandle(dev->of_node, "port", 0);
- if (!ssp_handle) {
- dev_err(dev, "unable to get 'port' phandle\n");
-- return -ENODEV;
-+ ret = -ENODEV;
-+ goto err_priv;
- }
-
- priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio");
-@@ -766,9 +767,7 @@ static int pxa_ssp_remove(struct snd_soc_dai *dai)
- SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \
- SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
-
--#define PXA_SSP_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
-- SNDRV_PCM_FMTBIT_S24_LE | \
-- SNDRV_PCM_FMTBIT_S32_LE)
-+#define PXA_SSP_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
-
- static const struct snd_soc_dai_ops pxa_ssp_dai_ops = {
- .startup = pxa_ssp_startup,
-diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
-index 0a9b44c940ce..5dae66002a11 100644
---- a/sound/soc/samsung/i2s.c
-+++ b/sound/soc/samsung/i2s.c
-@@ -915,11 +915,9 @@ static int i2s_suspend(struct snd_soc_dai *dai)
- {
- struct i2s_dai *i2s = to_info(dai);
-
-- if (dai->active) {
-- i2s->suspend_i2smod = readl(i2s->addr + I2SMOD);
-- i2s->suspend_i2scon = readl(i2s->addr + I2SCON);
-- i2s->suspend_i2spsr = readl(i2s->addr + I2SPSR);
-- }
-+ i2s->suspend_i2smod = readl(i2s->addr + I2SMOD);
-+ i2s->suspend_i2scon = readl(i2s->addr + I2SCON);
-+ i2s->suspend_i2spsr = readl(i2s->addr + I2SPSR);
-
- return 0;
- }
-@@ -928,11 +926,9 @@ static int i2s_resume(struct snd_soc_dai *dai)
- {
- struct i2s_dai *i2s = to_info(dai);
-
-- if (dai->active) {
-- writel(i2s->suspend_i2scon, i2s->addr + I2SCON);
-- writel(i2s->suspend_i2smod, i2s->addr + I2SMOD);
-- writel(i2s->suspend_i2spsr, i2s->addr + I2SPSR);
-- }
-+ writel(i2s->suspend_i2scon, i2s->addr + I2SCON);
-+ writel(i2s->suspend_i2smod, i2s->addr + I2SMOD);
-+ writel(i2s->suspend_i2spsr, i2s->addr + I2SPSR);
-
- return 0;
- }
-diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
-index 47e1ce771e65..02733ded2cb1 100644
---- a/sound/soc/soc-pcm.c
-+++ b/sound/soc/soc-pcm.c
-@@ -2011,6 +2011,7 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)
- dpcm_be_disconnect(fe, SNDRV_PCM_STREAM_PLAYBACK);
- }
-
-+ dpcm_path_put(&list);
- capture:
- /* skip if FE doesn't have capture capability */
- if (!fe->cpu_dai->driver->capture.channels_min)
-diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
-index 32487ed18354..3d5979b23e50 100644
---- a/tools/testing/selftests/Makefile
-+++ b/tools/testing/selftests/Makefile
-@@ -4,6 +4,7 @@ TARGETS += efivarfs
- TARGETS += kcmp
- TARGETS += memory-hotplug
- TARGETS += mqueue
-+TARGETS += mount
- TARGETS += net
- TARGETS += ptrace
- TARGETS += timers
-diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
-new file mode 100644
-index 000000000000..337d853c2b72
---- /dev/null
-+++ b/tools/testing/selftests/mount/Makefile
-@@ -0,0 +1,17 @@
-+# Makefile for mount selftests.
-+
-+all: unprivileged-remount-test
-+
-+unprivileged-remount-test: unprivileged-remount-test.c
-+ gcc -Wall -O2 unprivileged-remount-test.c -o unprivileged-remount-test
-+
-+# Allow specific tests to be selected.
-+test_unprivileged_remount: unprivileged-remount-test
-+ @if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
-+
-+run_tests: all test_unprivileged_remount
-+
-+clean:
-+ rm -f unprivileged-remount-test
-+
-+.PHONY: all test_unprivileged_remount
-diff --git a/tools/testing/selftests/mount/unprivileged-remount-test.c b/tools/testing/selftests/mount/unprivileged-remount-test.c
-new file mode 100644
-index 000000000000..1b3ff2fda4d0
---- /dev/null
-+++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
-@@ -0,0 +1,242 @@
-+#define _GNU_SOURCE
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+#include
-+
-+#ifndef CLONE_NEWNS
-+# define CLONE_NEWNS 0x00020000
-+#endif
-+#ifndef CLONE_NEWUTS
-+# define CLONE_NEWUTS 0x04000000
-+#endif
-+#ifndef CLONE_NEWIPC
-+# define CLONE_NEWIPC 0x08000000
-+#endif
-+#ifndef CLONE_NEWNET
-+# define CLONE_NEWNET 0x40000000
-+#endif
-+#ifndef CLONE_NEWUSER
-+# define CLONE_NEWUSER 0x10000000
-+#endif
-+#ifndef CLONE_NEWPID
-+# define CLONE_NEWPID 0x20000000
-+#endif
-+
-+#ifndef MS_RELATIME
-+#define MS_RELATIME (1 << 21)
-+#endif
-+#ifndef MS_STRICTATIME
-+#define MS_STRICTATIME (1 << 24)
-+#endif
-+
-+static void die(char *fmt, ...)
-+{
-+ va_list ap;
-+ va_start(ap, fmt);
-+ vfprintf(stderr, fmt, ap);
-+ va_end(ap);
-+ exit(EXIT_FAILURE);
-+}
-+
-+static void write_file(char *filename, char *fmt, ...)
-+{
-+ char buf[4096];
-+ int fd;
-+ ssize_t written;
-+ int buf_len;
-+ va_list ap;
-+
-+ va_start(ap, fmt);
-+ buf_len = vsnprintf(buf, sizeof(buf), fmt, ap);
-+ va_end(ap);
-+ if (buf_len < 0) {
-+ die("vsnprintf failed: %s\n",
-+ strerror(errno));
-+ }
-+ if (buf_len >= sizeof(buf)) {
-+ die("vsnprintf output truncated\n");
-+ }
-+
-+ fd = open(filename, O_WRONLY);
-+ if (fd < 0) {
-+ die("open of %s failed: %s\n",
-+ filename, strerror(errno));
-+ }
-+ written = write(fd, buf, buf_len);
-+ if (written != buf_len) {
-+ if (written >= 0) {
-+ die("short write to %s\n", filename);
-+ } else {
-+ die("write to %s failed: %s\n",
-+ filename, strerror(errno));
-+ }
-+ }
-+ if (close(fd) != 0) {
-+ die("close of %s failed: %s\n",
-+ filename, strerror(errno));
-+ }
-+}
-+
-+static void create_and_enter_userns(void)
-+{
-+ uid_t uid;
-+ gid_t gid;
-+
-+ uid = getuid();
-+ gid = getgid();
-+
-+ if (unshare(CLONE_NEWUSER) !=0) {
-+ die("unshare(CLONE_NEWUSER) failed: %s\n",
-+ strerror(errno));
-+ }
-+
-+ write_file("/proc/self/uid_map", "0 %d 1", uid);
-+ write_file("/proc/self/gid_map", "0 %d 1", gid);
-+
-+ if (setgroups(0, NULL) != 0) {
-+ die("setgroups failed: %s\n",
-+ strerror(errno));
-+ }
-+ if (setgid(0) != 0) {
-+ die ("setgid(0) failed %s\n",
-+ strerror(errno));
-+ }
-+ if (setuid(0) != 0) {
-+ die("setuid(0) failed %s\n",
-+ strerror(errno));
-+ }
-+}
-+
-+static
-+bool test_unpriv_remount(int mount_flags, int remount_flags, int invalid_flags)
-+{
-+ pid_t child;
-+
-+ child = fork();
-+ if (child == -1) {
-+ die("fork failed: %s\n",
-+ strerror(errno));
-+ }
-+ if (child != 0) { /* parent */
-+ pid_t pid;
-+ int status;
-+ pid = waitpid(child, &status, 0);
-+ if (pid == -1) {
-+ die("waitpid failed: %s\n",
-+ strerror(errno));
-+ }
-+ if (pid != child) {
-+ die("waited for %d got %d\n",
-+ child, pid);
-+ }
-+ if (!WIFEXITED(status)) {
-+ die("child did not terminate cleanly\n");
-+ }
-+ return WEXITSTATUS(status) == EXIT_SUCCESS ? true : false;
-+ }
-+
-+ create_and_enter_userns();
-+ if (unshare(CLONE_NEWNS) != 0) {
-+ die("unshare(CLONE_NEWNS) failed: %s\n",
-+ strerror(errno));
-+ }
-+
-+ if (mount("testing", "/tmp", "ramfs", mount_flags, NULL) != 0) {
-+ die("mount of /tmp failed: %s\n",
-+ strerror(errno));
-+ }
-+
-+ create_and_enter_userns();
-+
-+ if (unshare(CLONE_NEWNS) != 0) {
-+ die("unshare(CLONE_NEWNS) failed: %s\n",
-+ strerror(errno));
-+ }
-+
-+ if (mount("/tmp", "/tmp", "none",
-+ MS_REMOUNT | MS_BIND | remount_flags, NULL) != 0) {
-+ /* system("cat /proc/self/mounts"); */
-+ die("remount of /tmp failed: %s\n",
-+ strerror(errno));
-+ }
-+
-+ if (mount("/tmp", "/tmp", "none",
-+ MS_REMOUNT | MS_BIND | invalid_flags, NULL) == 0) {
-+ /* system("cat /proc/self/mounts"); */
-+ die("remount of /tmp with invalid flags "
-+ "succeeded unexpectedly\n");
-+ }
-+ exit(EXIT_SUCCESS);
-+}
-+
-+static bool test_unpriv_remount_simple(int mount_flags)
-+{
-+ return test_unpriv_remount(mount_flags, mount_flags, 0);
-+}
-+
-+static bool test_unpriv_remount_atime(int mount_flags, int invalid_flags)
-+{
-+ return test_unpriv_remount(mount_flags, mount_flags, invalid_flags);
-+}
-+
-+int main(int argc, char **argv)
-+{
-+ if (!test_unpriv_remount_simple(MS_RDONLY|MS_NODEV)) {
-+ die("MS_RDONLY malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_simple(MS_NODEV)) {
-+ die("MS_NODEV malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_simple(MS_NOSUID|MS_NODEV)) {
-+ die("MS_NOSUID malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_simple(MS_NOEXEC|MS_NODEV)) {
-+ die("MS_NOEXEC malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_atime(MS_RELATIME|MS_NODEV,
-+ MS_NOATIME|MS_NODEV))
-+ {
-+ die("MS_RELATIME malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_atime(MS_STRICTATIME|MS_NODEV,
-+ MS_NOATIME|MS_NODEV))
-+ {
-+ die("MS_STRICTATIME malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_atime(MS_NOATIME|MS_NODEV,
-+ MS_STRICTATIME|MS_NODEV))
-+ {
-+ die("MS_RELATIME malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_atime(MS_RELATIME|MS_NODIRATIME|MS_NODEV,
-+ MS_NOATIME|MS_NODEV))
-+ {
-+ die("MS_RELATIME malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_atime(MS_STRICTATIME|MS_NODIRATIME|MS_NODEV,
-+ MS_NOATIME|MS_NODEV))
-+ {
-+ die("MS_RELATIME malfunctions\n");
-+ }
-+ if (!test_unpriv_remount_atime(MS_NOATIME|MS_NODIRATIME|MS_NODEV,
-+ MS_STRICTATIME|MS_NODEV))
-+ {
-+ die("MS_RELATIME malfunctions\n");
-+ }
-+ if (!test_unpriv_remount(MS_STRICTATIME|MS_NODEV, MS_NODEV,
-+ MS_NOATIME|MS_NODEV))
-+ {
-+ die("Default atime malfunctions\n");
-+ }
-+ return EXIT_SUCCESS;
-+}
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.19-20.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.19-20.patch
deleted file mode 100644
index e3560ed49f..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.19-20.patch
+++ /dev/null
@@ -1,7387 +0,0 @@
-diff --git a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
-index 1486497a24c1..ce6a1a072028 100644
---- a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
-+++ b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
-@@ -4,11 +4,13 @@ Specifying interrupt information for devices
- 1) Interrupt client nodes
- -------------------------
-
--Nodes that describe devices which generate interrupts must contain an either an
--"interrupts" property or an "interrupts-extended" property. These properties
--contain a list of interrupt specifiers, one per output interrupt. The format of
--the interrupt specifier is determined by the interrupt controller to which the
--interrupts are routed; see section 2 below for details.
-+Nodes that describe devices which generate interrupts must contain an
-+"interrupts" property, an "interrupts-extended" property, or both. If both are
-+present, the latter should take precedence; the former may be provided simply
-+for compatibility with software that does not recognize the latter. These
-+properties contain a list of interrupt specifiers, one per output interrupt. The
-+format of the interrupt specifier is determined by the interrupt controller to
-+which the interrupts are routed; see section 2 below for details.
-
- Example:
- interrupt-parent = <&intc1>;
-diff --git a/Makefile b/Makefile
-index b1746b486646..beb7e6f0803b 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 19
-+SUBLEVEL = 20
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
-index 904dcf5973f3..9381754b35cc 100644
---- a/arch/arm/boot/dts/dra7-evm.dts
-+++ b/arch/arm/boot/dts/dra7-evm.dts
-@@ -50,13 +50,13 @@
-
- mcspi1_pins: pinmux_mcspi1_pins {
- pinctrl-single,pins = <
-- 0x3a4 (PIN_INPUT | MUX_MODE0) /* spi2_clk */
-- 0x3a8 (PIN_INPUT | MUX_MODE0) /* spi2_d1 */
-- 0x3ac (PIN_INPUT | MUX_MODE0) /* spi2_d0 */
-- 0x3b0 (PIN_INPUT_SLEW | MUX_MODE0) /* spi2_cs0 */
-- 0x3b4 (PIN_INPUT_SLEW | MUX_MODE0) /* spi2_cs1 */
-- 0x3b8 (PIN_INPUT_SLEW | MUX_MODE6) /* spi2_cs2 */
-- 0x3bc (PIN_INPUT_SLEW | MUX_MODE6) /* spi2_cs3 */
-+ 0x3a4 (PIN_INPUT | MUX_MODE0) /* spi1_sclk */
-+ 0x3a8 (PIN_INPUT | MUX_MODE0) /* spi1_d1 */
-+ 0x3ac (PIN_INPUT | MUX_MODE0) /* spi1_d0 */
-+ 0x3b0 (PIN_INPUT_SLEW | MUX_MODE0) /* spi1_cs0 */
-+ 0x3b4 (PIN_INPUT_SLEW | MUX_MODE0) /* spi1_cs1 */
-+ 0x3b8 (PIN_INPUT_SLEW | MUX_MODE6) /* spi1_cs2.hdmi1_hpd */
-+ 0x3bc (PIN_INPUT_SLEW | MUX_MODE6) /* spi1_cs3.hdmi1_cec */
- >;
- };
-
-diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
-index 1fd75aa4639d..767f0e376f4d 100644
---- a/arch/arm/boot/dts/dra7.dtsi
-+++ b/arch/arm/boot/dts/dra7.dtsi
-@@ -178,7 +178,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio2: gpio@48055000 {
-@@ -189,7 +189,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio3: gpio@48057000 {
-@@ -200,7 +200,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio4: gpio@48059000 {
-@@ -211,7 +211,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio5: gpio@4805b000 {
-@@ -222,7 +222,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio6: gpio@4805d000 {
-@@ -233,7 +233,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio7: gpio@48051000 {
-@@ -244,7 +244,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- gpio8: gpio@48053000 {
-@@ -255,7 +255,7 @@
- gpio-controller;
- #gpio-cells = <2>;
- interrupt-controller;
-- #interrupt-cells = <1>;
-+ #interrupt-cells = <2>;
- };
-
- uart1: serial@4806a000 {
-diff --git a/arch/arm/include/asm/tls.h b/arch/arm/include/asm/tls.h
-index 83259b873333..5f833f7adba1 100644
---- a/arch/arm/include/asm/tls.h
-+++ b/arch/arm/include/asm/tls.h
-@@ -1,6 +1,9 @@
- #ifndef __ASMARM_TLS_H
- #define __ASMARM_TLS_H
-
-+#include
-+#include
-+
- #ifdef __ASSEMBLY__
- #include
- .macro switch_tls_none, base, tp, tpuser, tmp1, tmp2
-@@ -50,6 +53,49 @@
- #endif
-
- #ifndef __ASSEMBLY__
-+
-+static inline void set_tls(unsigned long val)
-+{
-+ struct thread_info *thread;
-+
-+ thread = current_thread_info();
-+
-+ thread->tp_value[0] = val;
-+
-+ /*
-+ * This code runs with preemption enabled and therefore must
-+ * be reentrant with respect to switch_tls.
-+ *
-+ * We need to ensure ordering between the shadow state and the
-+ * hardware state, so that we don't corrupt the hardware state
-+ * with a stale shadow state during context switch.
-+ *
-+ * If we're preempted here, switch_tls will load TPIDRURO from
-+ * thread_info upon resuming execution and the following mcr
-+ * is merely redundant.
-+ */
-+ barrier();
-+
-+ if (!tls_emu) {
-+ if (has_tls_reg) {
-+ asm("mcr p15, 0, %0, c13, c0, 3"
-+ : : "r" (val));
-+ } else {
-+#ifdef CONFIG_KUSER_HELPERS
-+ /*
-+ * User space must never try to access this
-+ * directly. Expect your app to break
-+ * eventually if you do so. The user helper
-+ * at 0xffff0fe0 must be used instead. (see
-+ * entry-armv.S for details)
-+ */
-+ *((unsigned int *)0xffff0ff0) = val;
-+#endif
-+ }
-+
-+ }
-+}
-+
- static inline unsigned long get_tpuser(void)
- {
- unsigned long reg = 0;
-@@ -59,5 +105,23 @@ static inline unsigned long get_tpuser(void)
-
- return reg;
- }
-+
-+static inline void set_tpuser(unsigned long val)
-+{
-+ /* Since TPIDRURW is fully context-switched (unlike TPIDRURO),
-+ * we need not update thread_info.
-+ */
-+ if (has_tls_reg && !tls_emu) {
-+ asm("mcr p15, 0, %0, c13, c0, 2"
-+ : : "r" (val));
-+ }
-+}
-+
-+static inline void flush_tls(void)
-+{
-+ set_tls(0);
-+ set_tpuser(0);
-+}
-+
- #endif
- #endif /* __ASMARM_TLS_H */
-diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
-index 9723d17b8f38..1e782bdeee49 100644
---- a/arch/arm/kernel/irq.c
-+++ b/arch/arm/kernel/irq.c
-@@ -163,7 +163,7 @@ static bool migrate_one_irq(struct irq_desc *desc)
- c = irq_data_get_irq_chip(d);
- if (!c->irq_set_affinity)
- pr_debug("IRQ%u: unable to set affinity\n", d->irq);
-- else if (c->irq_set_affinity(d, affinity, true) == IRQ_SET_MASK_OK && ret)
-+ else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
- cpumask_copy(d->affinity, affinity);
-
- return ret;
-diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
-index 92f7b15dd221..5f6e650ec9ab 100644
---- a/arch/arm/kernel/process.c
-+++ b/arch/arm/kernel/process.c
-@@ -334,6 +334,8 @@ void flush_thread(void)
- memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
- memset(&thread->fpstate, 0, sizeof(union fp_state));
-
-+ flush_tls();
-+
- thread_notify(THREAD_NOTIFY_FLUSH, thread);
- }
-
-diff --git a/arch/arm/kernel/thumbee.c b/arch/arm/kernel/thumbee.c
-index 7b8403b76666..80f0d69205e7 100644
---- a/arch/arm/kernel/thumbee.c
-+++ b/arch/arm/kernel/thumbee.c
-@@ -45,7 +45,7 @@ static int thumbee_notifier(struct notifier_block *self, unsigned long cmd, void
-
- switch (cmd) {
- case THREAD_NOTIFY_FLUSH:
-- thread->thumbee_state = 0;
-+ teehbr_write(0);
- break;
- case THREAD_NOTIFY_SWITCH:
- current_thread_info()->thumbee_state = teehbr_read();
-diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
-index 172ee18ff124..9265b8bb529a 100644
---- a/arch/arm/kernel/traps.c
-+++ b/arch/arm/kernel/traps.c
-@@ -578,7 +578,6 @@ do_cache_op(unsigned long start, unsigned long end, int flags)
- #define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
- asmlinkage int arm_syscall(int no, struct pt_regs *regs)
- {
-- struct thread_info *thread = current_thread_info();
- siginfo_t info;
-
- if ((no >> 16) != (__ARM_NR_BASE>> 16))
-@@ -629,21 +628,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
- return regs->ARM_r0;
-
- case NR(set_tls):
-- thread->tp_value[0] = regs->ARM_r0;
-- if (tls_emu)
-- return 0;
-- if (has_tls_reg) {
-- asm ("mcr p15, 0, %0, c13, c0, 3"
-- : : "r" (regs->ARM_r0));
-- } else {
-- /*
-- * User space must never try to access this directly.
-- * Expect your app to break eventually if you do so.
-- * The user helper at 0xffff0fe0 must be used instead.
-- * (see entry-armv.S for details)
-- */
-- *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
-- }
-+ set_tls(regs->ARM_r0);
- return 0;
-
- #ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG
-diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c
-index 0de91fc6de0f..ec4fa868a7ba 100644
---- a/arch/arm/kvm/handle_exit.c
-+++ b/arch/arm/kvm/handle_exit.c
-@@ -89,6 +89,8 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
- else
- kvm_vcpu_block(vcpu);
-
-+ kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
-+
- return 1;
- }
-
-diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S
-index 1b9844d369cc..ee4f7447a1d3 100644
---- a/arch/arm/kvm/init.S
-+++ b/arch/arm/kvm/init.S
-@@ -98,6 +98,10 @@ __do_hyp_init:
- mrc p15, 0, r0, c10, c2, 1
- mcr p15, 4, r0, c10, c2, 1
-
-+ @ Invalidate the stale TLBs from Bootloader
-+ mcr p15, 4, r0, c8, c7, 0 @ TLBIALLH
-+ dsb ish
-+
- @ Set the HSCTLR to:
- @ - ARM/THUMB exceptions: Kernel config (Thumb-2 kernel)
- @ - Endianness: Kernel config
-diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
-index c914b0052fb9..4551efd28f8d 100644
---- a/arch/arm/mach-omap2/omap_hwmod.c
-+++ b/arch/arm/mach-omap2/omap_hwmod.c
-@@ -3349,6 +3349,9 @@ int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois)
- if (!ois)
- return 0;
-
-+ if (ois[0] == NULL) /* Empty list */
-+ return 0;
-+
- if (!linkspace) {
- if (_alloc_linkspace(ois)) {
- pr_err("omap_hwmod: could not allocate link space\n");
-diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
-index 810c205d668b..2e35ff99f60e 100644
---- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
-+++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
-@@ -35,6 +35,7 @@
- #include "i2c.h"
- #include "mmc.h"
- #include "wd_timer.h"
-+#include "soc.h"
-
- /* Base offset for all DRA7XX interrupts external to MPUSS */
- #define DRA7XX_IRQ_GIC_START 32
-@@ -2707,7 +2708,6 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] __initdata = {
- &dra7xx_l4_per3__usb_otg_ss1,
- &dra7xx_l4_per3__usb_otg_ss2,
- &dra7xx_l4_per3__usb_otg_ss3,
-- &dra7xx_l4_per3__usb_otg_ss4,
- &dra7xx_l3_main_1__vcp1,
- &dra7xx_l4_per2__vcp1,
- &dra7xx_l3_main_1__vcp2,
-@@ -2716,8 +2716,26 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] __initdata = {
- NULL,
- };
-
-+static struct omap_hwmod_ocp_if *dra74x_hwmod_ocp_ifs[] __initdata = {
-+ &dra7xx_l4_per3__usb_otg_ss4,
-+ NULL,
-+};
-+
-+static struct omap_hwmod_ocp_if *dra72x_hwmod_ocp_ifs[] __initdata = {
-+ NULL,
-+};
-+
- int __init dra7xx_hwmod_init(void)
- {
-+ int ret;
-+
- omap_hwmod_init();
-- return omap_hwmod_register_links(dra7xx_hwmod_ocp_ifs);
-+ ret = omap_hwmod_register_links(dra7xx_hwmod_ocp_ifs);
-+
-+ if (!ret && soc_is_dra74x())
-+ return omap_hwmod_register_links(dra74x_hwmod_ocp_ifs);
-+ else if (!ret && soc_is_dra72x())
-+ return omap_hwmod_register_links(dra72x_hwmod_ocp_ifs);
-+
-+ return ret;
- }
-diff --git a/arch/arm/mach-omap2/soc.h b/arch/arm/mach-omap2/soc.h
-index 076bd90a6ce0..8a9be09d9f38 100644
---- a/arch/arm/mach-omap2/soc.h
-+++ b/arch/arm/mach-omap2/soc.h
-@@ -245,6 +245,8 @@ IS_AM_SUBCLASS(437x, 0x437)
- #define soc_is_omap54xx() 0
- #define soc_is_omap543x() 0
- #define soc_is_dra7xx() 0
-+#define soc_is_dra74x() 0
-+#define soc_is_dra72x() 0
-
- #if defined(MULTI_OMAP2)
- # if defined(CONFIG_ARCH_OMAP2)
-@@ -393,7 +395,11 @@ IS_OMAP_TYPE(3430, 0x3430)
-
- #if defined(CONFIG_SOC_DRA7XX)
- #undef soc_is_dra7xx
-+#undef soc_is_dra74x
-+#undef soc_is_dra72x
- #define soc_is_dra7xx() (of_machine_is_compatible("ti,dra7"))
-+#define soc_is_dra74x() (of_machine_is_compatible("ti,dra74"))
-+#define soc_is_dra72x() (of_machine_is_compatible("ti,dra72"))
- #endif
-
- /* Various silicon revisions for omap2 */
-diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
-index 3815a8262af0..8c48c5c22a33 100644
---- a/arch/arm/mm/abort-ev6.S
-+++ b/arch/arm/mm/abort-ev6.S
-@@ -17,12 +17,6 @@
- */
- .align 5
- ENTRY(v6_early_abort)
--#ifdef CONFIG_CPU_V6
-- sub r1, sp, #4 @ Get unused stack location
-- strex r0, r1, [r1] @ Clear the exclusive monitor
--#elif defined(CONFIG_CPU_32v6K)
-- clrex
--#endif
- mrc p15, 0, r1, c5, c0, 0 @ get FSR
- mrc p15, 0, r0, c6, c0, 0 @ get FAR
- /*
-diff --git a/arch/arm/mm/abort-ev7.S b/arch/arm/mm/abort-ev7.S
-index 703375277ba6..4812ad054214 100644
---- a/arch/arm/mm/abort-ev7.S
-+++ b/arch/arm/mm/abort-ev7.S
-@@ -13,12 +13,6 @@
- */
- .align 5
- ENTRY(v7_early_abort)
-- /*
-- * The effect of data aborts on on the exclusive access monitor are
-- * UNPREDICTABLE. Do a CLREX to clear the state
-- */
-- clrex
--
- mrc p15, 0, r1, c5, c0, 0 @ get FSR
- mrc p15, 0, r0, c6, c0, 0 @ get FAR
-
-diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
-index 924036473b16..d301662b7b32 100644
---- a/arch/arm/mm/alignment.c
-+++ b/arch/arm/mm/alignment.c
-@@ -40,6 +40,7 @@
- * This code is not portable to processors with late data abort handling.
- */
- #define CODING_BITS(i) (i & 0x0e000000)
-+#define COND_BITS(i) (i & 0xf0000000)
-
- #define LDST_I_BIT(i) (i & (1 << 26)) /* Immediate constant */
- #define LDST_P_BIT(i) (i & (1 << 24)) /* Preindex */
-@@ -817,6 +818,8 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
- break;
-
- case 0x04000000: /* ldr or str immediate */
-+ if (COND_BITS(instr) == 0xf0000000) /* NEON VLDn, VSTn */
-+ goto bad;
- offset.un = OFFSET_BITS(instr);
- handler = do_alignment_ldrstr;
- break;
-diff --git a/arch/arm64/include/asm/hw_breakpoint.h b/arch/arm64/include/asm/hw_breakpoint.h
-index d064047612b1..52b484b6aa1a 100644
---- a/arch/arm64/include/asm/hw_breakpoint.h
-+++ b/arch/arm64/include/asm/hw_breakpoint.h
-@@ -79,7 +79,6 @@ static inline void decode_ctrl_reg(u32 reg,
- */
- #define ARM_MAX_BRP 16
- #define ARM_MAX_WRP 16
--#define ARM_MAX_HBP_SLOTS (ARM_MAX_BRP + ARM_MAX_WRP)
-
- /* Virtual debug register bases. */
- #define AARCH64_DBG_REG_BVR 0
-diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
-index 0f08dfd69ebc..dfa6e3e74fdd 100644
---- a/arch/arm64/kernel/irq.c
-+++ b/arch/arm64/kernel/irq.c
-@@ -97,19 +97,15 @@ static bool migrate_one_irq(struct irq_desc *desc)
- if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
- return false;
-
-- if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids)
-+ if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
-+ affinity = cpu_online_mask;
- ret = true;
-+ }
-
-- /*
-- * when using forced irq_set_affinity we must ensure that the cpu
-- * being offlined is not present in the affinity mask, it may be
-- * selected as the target CPU otherwise
-- */
-- affinity = cpu_online_mask;
- c = irq_data_get_irq_chip(d);
- if (!c->irq_set_affinity)
- pr_debug("IRQ%u: unable to set affinity\n", d->irq);
-- else if (c->irq_set_affinity(d, affinity, true) == IRQ_SET_MASK_OK && ret)
-+ else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
- cpumask_copy(d->affinity, affinity);
-
- return ret;
-diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
-index 1c0a9be2ffa8..6e7e579c629d 100644
---- a/arch/arm64/kernel/process.c
-+++ b/arch/arm64/kernel/process.c
-@@ -187,9 +187,27 @@ void exit_thread(void)
- {
- }
-
-+static void tls_thread_flush(void)
-+{
-+ asm ("msr tpidr_el0, xzr");
-+
-+ if (is_compat_task()) {
-+ current->thread.tp_value = 0;
-+
-+ /*
-+ * We need to ensure ordering between the shadow state and the
-+ * hardware state, so that we don't corrupt the hardware state
-+ * with a stale shadow state during context switch.
-+ */
-+ barrier();
-+ asm ("msr tpidrro_el0, xzr");
-+ }
-+}
-+
- void flush_thread(void)
- {
- fpsimd_flush_thread();
-+ tls_thread_flush();
- flush_ptrace_hw_breakpoint(current);
- }
-
-diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
-index 7a50b86464cc..b1269dac1289 100644
---- a/arch/arm64/kernel/ptrace.c
-+++ b/arch/arm64/kernel/ptrace.c
-@@ -81,7 +81,8 @@ static void ptrace_hbptriggered(struct perf_event *bp,
- break;
- }
- }
-- for (i = ARM_MAX_BRP; i < ARM_MAX_HBP_SLOTS && !bp; ++i) {
-+
-+ for (i = 0; i < ARM_MAX_WRP; ++i) {
- if (current->thread.debug.hbp_watch[i] == bp) {
- info.si_errno = -((i << 1) + 1);
- break;
-diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c
-index 26e9c4eeaba8..78039927c807 100644
---- a/arch/arm64/kernel/sys_compat.c
-+++ b/arch/arm64/kernel/sys_compat.c
-@@ -79,6 +79,12 @@ long compat_arm_syscall(struct pt_regs *regs)
-
- case __ARM_NR_compat_set_tls:
- current->thread.tp_value = regs->regs[0];
-+
-+ /*
-+ * Protect against register corruption from context switch.
-+ * See comment in tls_thread_flush.
-+ */
-+ barrier();
- asm ("msr tpidrro_el0, %0" : : "r" (regs->regs[0]));
- return 0;
-
-diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
-index 7bc41eab4c64..fd9aeba99683 100644
---- a/arch/arm64/kvm/handle_exit.c
-+++ b/arch/arm64/kvm/handle_exit.c
-@@ -62,6 +62,8 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
- else
- kvm_vcpu_block(vcpu);
-
-+ kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
-+
- return 1;
- }
-
-diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S
-index 2b0244d65c16..12e26f358c31 100644
---- a/arch/arm64/kvm/hyp-init.S
-+++ b/arch/arm64/kvm/hyp-init.S
-@@ -74,6 +74,10 @@ __do_hyp_init:
- msr mair_el2, x4
- isb
-
-+ /* Invalidate the stale TLBs from Bootloader */
-+ tlbi alle2
-+ dsb sy
-+
- mrs x4, sctlr_el2
- and x4, x4, #SCTLR_EL2_EE // preserve endianness of EL2
- ldr x5, =SCTLR_EL2_FLAGS
-diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c
-index c00c4ddf4514..5244cecf1e45 100644
---- a/arch/mips/boot/compressed/decompress.c
-+++ b/arch/mips/boot/compressed/decompress.c
-@@ -13,6 +13,7 @@
-
- #include
- #include
-+#include
-
- #include
-
-diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
-index 539b6294b613..8f89ff4ed524 100644
---- a/arch/mips/kernel/mcount.S
-+++ b/arch/mips/kernel/mcount.S
-@@ -123,7 +123,11 @@ NESTED(_mcount, PT_SIZE, ra)
- nop
- #endif
- b ftrace_stub
-+#ifdef CONFIG_32BIT
-+ addiu sp, sp, 8
-+#else
- nop
-+#endif
-
- static_trace:
- MCOUNT_SAVE_REGS
-@@ -133,6 +137,9 @@ static_trace:
- move a1, AT /* arg2: parent's return address */
-
- MCOUNT_RESTORE_REGS
-+#ifdef CONFIG_32BIT
-+ addiu sp, sp, 8
-+#endif
- .globl ftrace_stub
- ftrace_stub:
- RETURN_BACK
-@@ -177,6 +184,11 @@ NESTED(ftrace_graph_caller, PT_SIZE, ra)
- jal prepare_ftrace_return
- nop
- MCOUNT_RESTORE_REGS
-+#ifndef CONFIG_DYNAMIC_FTRACE
-+#ifdef CONFIG_32BIT
-+ addiu sp, sp, 8
-+#endif
-+#endif
- RETURN_BACK
- END(ftrace_graph_caller)
-
-diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
-index 7187664034c3..5db8882f732c 100644
---- a/arch/parisc/Makefile
-+++ b/arch/parisc/Makefile
-@@ -48,7 +48,12 @@ cflags-y := -pipe
-
- # These flags should be implied by an hppa-linux configuration, but they
- # are not in gcc 3.2.
--cflags-y += -mno-space-regs -mfast-indirect-calls
-+cflags-y += -mno-space-regs
-+
-+# -mfast-indirect-calls is only relevant for 32-bit kernels.
-+ifndef CONFIG_64BIT
-+cflags-y += -mfast-indirect-calls
-+endif
-
- # Currently we save and restore fpregs on all kernel entry/interruption paths.
- # If that gets optimized, we might need to disable the use of fpregs in the
-diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
-index 838786011037..7ef22e3387e0 100644
---- a/arch/parisc/kernel/syscall.S
-+++ b/arch/parisc/kernel/syscall.S
-@@ -74,7 +74,7 @@ ENTRY(linux_gateway_page)
- /* ADDRESS 0xb0 to 0xb8, lws uses two insns for entry */
- /* Light-weight-syscall entry must always be located at 0xb0 */
- /* WARNING: Keep this number updated with table size changes */
--#define __NR_lws_entries (2)
-+#define __NR_lws_entries (3)
-
- lws_entry:
- gate lws_start, %r0 /* increase privilege */
-@@ -502,7 +502,7 @@ lws_exit:
-
-
- /***************************************************
-- Implementing CAS as an atomic operation:
-+ Implementing 32bit CAS as an atomic operation:
-
- %r26 - Address to examine
- %r25 - Old value to check (old)
-@@ -659,6 +659,230 @@ cas_action:
- ASM_EXCEPTIONTABLE_ENTRY(2b-linux_gateway_page, 3b-linux_gateway_page)
-
-
-+ /***************************************************
-+ New CAS implementation which uses pointers and variable size
-+ information. The value pointed by old and new MUST NOT change
-+ while performing CAS. The lock only protect the value at %r26.
-+
-+ %r26 - Address to examine
-+ %r25 - Pointer to the value to check (old)
-+ %r24 - Pointer to the value to set (new)
-+ %r23 - Size of the variable (0/1/2/3 for 8/16/32/64 bit)
-+ %r28 - Return non-zero on failure
-+ %r21 - Kernel error code
-+
-+ %r21 has the following meanings:
-+
-+ EAGAIN - CAS is busy, ldcw failed, try again.
-+ EFAULT - Read or write failed.
-+
-+ Scratch: r20, r22, r28, r29, r1, fr4 (32bit for 64bit CAS only)
-+
-+ ****************************************************/
-+
-+ /* ELF32 Process entry path */
-+lws_compare_and_swap_2:
-+#ifdef CONFIG_64BIT
-+ /* Clip the input registers */
-+ depdi 0, 31, 32, %r26
-+ depdi 0, 31, 32, %r25
-+ depdi 0, 31, 32, %r24
-+ depdi 0, 31, 32, %r23
-+#endif
-+
-+ /* Check the validity of the size pointer */
-+ subi,>>= 4, %r23, %r0
-+ b,n lws_exit_nosys
-+
-+ /* Jump to the functions which will load the old and new values into
-+ registers depending on the their size */
-+ shlw %r23, 2, %r29
-+ blr %r29, %r0
-+ nop
-+
-+ /* 8bit load */
-+4: ldb 0(%sr3,%r25), %r25
-+ b cas2_lock_start
-+5: ldb 0(%sr3,%r24), %r24
-+ nop
-+ nop
-+ nop
-+ nop
-+ nop
-+
-+ /* 16bit load */
-+6: ldh 0(%sr3,%r25), %r25
-+ b cas2_lock_start
-+7: ldh 0(%sr3,%r24), %r24
-+ nop
-+ nop
-+ nop
-+ nop
-+ nop
-+
-+ /* 32bit load */
-+8: ldw 0(%sr3,%r25), %r25
-+ b cas2_lock_start
-+9: ldw 0(%sr3,%r24), %r24
-+ nop
-+ nop
-+ nop
-+ nop
-+ nop
-+
-+ /* 64bit load */
-+#ifdef CONFIG_64BIT
-+10: ldd 0(%sr3,%r25), %r25
-+11: ldd 0(%sr3,%r24), %r24
-+#else
-+ /* Load new value into r22/r23 - high/low */
-+10: ldw 0(%sr3,%r25), %r22
-+11: ldw 4(%sr3,%r25), %r23
-+ /* Load new value into fr4 for atomic store later */
-+12: flddx 0(%sr3,%r24), %fr4
-+#endif
-+
-+cas2_lock_start:
-+ /* Load start of lock table */
-+ ldil L%lws_lock_start, %r20
-+ ldo R%lws_lock_start(%r20), %r28
-+
-+ /* Extract four bits from r26 and hash lock (Bits 4-7) */
-+ extru %r26, 27, 4, %r20
-+
-+ /* Find lock to use, the hash is either one of 0 to
-+ 15, multiplied by 16 (keep it 16-byte aligned)
-+ and add to the lock table offset. */
-+ shlw %r20, 4, %r20
-+ add %r20, %r28, %r20
-+
-+ rsm PSW_SM_I, %r0 /* Disable interrupts */
-+ /* COW breaks can cause contention on UP systems */
-+ LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
-+ cmpb,<>,n %r0, %r28, cas2_action /* Did we get it? */
-+cas2_wouldblock:
-+ ldo 2(%r0), %r28 /* 2nd case */
-+ ssm PSW_SM_I, %r0
-+ b lws_exit /* Contended... */
-+ ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
-+
-+ /*
-+ prev = *addr;
-+ if ( prev == old )
-+ *addr = new;
-+ return prev;
-+ */
-+
-+ /* NOTES:
-+ This all works becuse intr_do_signal
-+ and schedule both check the return iasq
-+ and see that we are on the kernel page
-+ so this process is never scheduled off
-+ or is ever sent any signal of any sort,
-+ thus it is wholly atomic from usrspaces
-+ perspective
-+ */
-+cas2_action:
-+ /* Jump to the correct function */
-+ blr %r29, %r0
-+ /* Set %r28 as non-zero for now */
-+ ldo 1(%r0),%r28
-+
-+ /* 8bit CAS */
-+13: ldb,ma 0(%sr3,%r26), %r29
-+ sub,= %r29, %r25, %r0
-+ b,n cas2_end
-+14: stb,ma %r24, 0(%sr3,%r26)
-+ b cas2_end
-+ copy %r0, %r28
-+ nop
-+ nop
-+
-+ /* 16bit CAS */
-+15: ldh,ma 0(%sr3,%r26), %r29
-+ sub,= %r29, %r25, %r0
-+ b,n cas2_end
-+16: sth,ma %r24, 0(%sr3,%r26)
-+ b cas2_end
-+ copy %r0, %r28
-+ nop
-+ nop
-+
-+ /* 32bit CAS */
-+17: ldw,ma 0(%sr3,%r26), %r29
-+ sub,= %r29, %r25, %r0
-+ b,n cas2_end
-+18: stw,ma %r24, 0(%sr3,%r26)
-+ b cas2_end
-+ copy %r0, %r28
-+ nop
-+ nop
-+
-+ /* 64bit CAS */
-+#ifdef CONFIG_64BIT
-+19: ldd,ma 0(%sr3,%r26), %r29
-+ sub,= %r29, %r25, %r0
-+ b,n cas2_end
-+20: std,ma %r24, 0(%sr3,%r26)
-+ copy %r0, %r28
-+#else
-+ /* Compare first word */
-+19: ldw,ma 0(%sr3,%r26), %r29
-+ sub,= %r29, %r22, %r0
-+ b,n cas2_end
-+ /* Compare second word */
-+20: ldw,ma 4(%sr3,%r26), %r29
-+ sub,= %r29, %r23, %r0
-+ b,n cas2_end
-+ /* Perform the store */
-+21: fstdx %fr4, 0(%sr3,%r26)
-+ copy %r0, %r28
-+#endif
-+
-+cas2_end:
-+ /* Free lock */
-+ stw,ma %r20, 0(%sr2,%r20)
-+ /* Enable interrupts */
-+ ssm PSW_SM_I, %r0
-+ /* Return to userspace, set no error */
-+ b lws_exit
-+ copy %r0, %r21
-+
-+22:
-+ /* Error occurred on load or store */
-+ /* Free lock */
-+ stw %r20, 0(%sr2,%r20)
-+ ssm PSW_SM_I, %r0
-+ ldo 1(%r0),%r28
-+ b lws_exit
-+ ldo -EFAULT(%r0),%r21 /* set errno */
-+ nop
-+ nop
-+ nop
-+
-+ /* Exception table entries, for the load and store, return EFAULT.
-+ Each of the entries must be relocated. */
-+ ASM_EXCEPTIONTABLE_ENTRY(4b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(5b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(6b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(7b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(8b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(9b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(10b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(11b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(13b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(14b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(15b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(16b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(17b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(18b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(19b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(20b-linux_gateway_page, 22b-linux_gateway_page)
-+#ifndef CONFIG_64BIT
-+ ASM_EXCEPTIONTABLE_ENTRY(12b-linux_gateway_page, 22b-linux_gateway_page)
-+ ASM_EXCEPTIONTABLE_ENTRY(21b-linux_gateway_page, 22b-linux_gateway_page)
-+#endif
-+
- /* Make sure nothing else is placed on this page */
- .align PAGE_SIZE
- END(linux_gateway_page)
-@@ -675,8 +899,9 @@ ENTRY(end_linux_gateway_page)
- /* Light-weight-syscall table */
- /* Start of lws table. */
- ENTRY(lws_table)
-- LWS_ENTRY(compare_and_swap32) /* 0 - ELF32 Atomic compare and swap */
-- LWS_ENTRY(compare_and_swap64) /* 1 - ELF64 Atomic compare and swap */
-+ LWS_ENTRY(compare_and_swap32) /* 0 - ELF32 Atomic 32bit CAS */
-+ LWS_ENTRY(compare_and_swap64) /* 1 - ELF64 Atomic 32bit CAS */
-+ LWS_ENTRY(compare_and_swap_2) /* 2 - ELF32 Atomic 64bit CAS */
- END(lws_table)
- /* End of lws table */
-
-diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
-index 279b80f3bb29..c0c61fa9cd9e 100644
---- a/arch/powerpc/include/asm/ptrace.h
-+++ b/arch/powerpc/include/asm/ptrace.h
-@@ -47,6 +47,12 @@
- STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE)
- #define STACK_FRAME_MARKER 12
-
-+#if defined(_CALL_ELF) && _CALL_ELF == 2
-+#define STACK_FRAME_MIN_SIZE 32
-+#else
-+#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
-+#endif
-+
- /* Size of dummy stack frame allocated when calling signal handler. */
- #define __SIGNAL_FRAMESIZE 128
- #define __SIGNAL_FRAMESIZE32 64
-@@ -60,6 +66,7 @@
- #define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
- #define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
- #define STACK_FRAME_MARKER 2
-+#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
-
- /* Size of stack frame allocated when calling signal handler. */
- #define __SIGNAL_FRAMESIZE 64
-diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
-index 35aa339410bd..4dbe072eecbe 100644
---- a/arch/powerpc/include/asm/spinlock.h
-+++ b/arch/powerpc/include/asm/spinlock.h
-@@ -61,6 +61,7 @@ static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
-
- static inline int arch_spin_is_locked(arch_spinlock_t *lock)
- {
-+ smp_mb();
- return !arch_spin_value_unlocked(*lock);
- }
-
-diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
-index 0c9c8d7d0734..170a0346f756 100644
---- a/arch/powerpc/lib/locks.c
-+++ b/arch/powerpc/lib/locks.c
-@@ -70,12 +70,16 @@ void __rw_yield(arch_rwlock_t *rw)
-
- void arch_spin_unlock_wait(arch_spinlock_t *lock)
- {
-+ smp_mb();
-+
- while (lock->slock) {
- HMT_low();
- if (SHARED_PROCESSOR)
- __spin_yield(lock);
- }
- HMT_medium();
-+
-+ smp_mb();
- }
-
- EXPORT_SYMBOL(arch_spin_unlock_wait);
-diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
-index 74d1e780748b..2396dda282cd 100644
---- a/arch/powerpc/perf/callchain.c
-+++ b/arch/powerpc/perf/callchain.c
-@@ -35,7 +35,7 @@ static int valid_next_sp(unsigned long sp, unsigned long prev_sp)
- return 0; /* must be 16-byte aligned */
- if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
- return 0;
-- if (sp >= prev_sp + STACK_FRAME_OVERHEAD)
-+ if (sp >= prev_sp + STACK_FRAME_MIN_SIZE)
- return 1;
- /*
- * sp could decrease when we jump off an interrupt stack
-diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
-index 3584ed9b20a1..e309c5c41158 100644
---- a/arch/s390/mm/pgtable.c
-+++ b/arch/s390/mm/pgtable.c
-@@ -810,11 +810,21 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
- pte_t *ptep;
-
- down_read(&mm->mmap_sem);
-+retry:
- ptep = get_locked_pte(current->mm, addr, &ptl);
- if (unlikely(!ptep)) {
- up_read(&mm->mmap_sem);
- return -EFAULT;
- }
-+ if (!(pte_val(*ptep) & _PAGE_INVALID) &&
-+ (pte_val(*ptep) & _PAGE_PROTECT)) {
-+ pte_unmap_unlock(*ptep, ptl);
-+ if (fixup_user_fault(current, mm, addr, FAULT_FLAG_WRITE)) {
-+ up_read(&mm->mmap_sem);
-+ return -EFAULT;
-+ }
-+ goto retry;
-+ }
-
- new = old = pgste_get_lock(ptep);
- pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT |
-diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
-index 4dbf967da50d..6cfcf2a2eb93 100644
---- a/arch/x86/boot/compressed/aslr.c
-+++ b/arch/x86/boot/compressed/aslr.c
-@@ -183,12 +183,27 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
- static bool mem_avoid_overlap(struct mem_vector *img)
- {
- int i;
-+ struct setup_data *ptr;
-
- for (i = 0; i < MEM_AVOID_MAX; i++) {
- if (mem_overlaps(img, &mem_avoid[i]))
- return true;
- }
-
-+ /* Avoid all entries in the setup_data linked list. */
-+ ptr = (struct setup_data *)(unsigned long)real_mode->hdr.setup_data;
-+ while (ptr) {
-+ struct mem_vector avoid;
-+
-+ avoid.start = (u64)ptr;
-+ avoid.size = sizeof(*ptr) + ptr->len;
-+
-+ if (mem_overlaps(img, &avoid))
-+ return true;
-+
-+ ptr = (struct setup_data *)(unsigned long)ptr->next;
-+ }
-+
- return false;
- }
-
-diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
-index 7252cd339175..6762a55b798a 100644
---- a/arch/x86/include/asm/fixmap.h
-+++ b/arch/x86/include/asm/fixmap.h
-@@ -123,14 +123,14 @@ enum fixed_addresses {
- __end_of_permanent_fixed_addresses,
-
- /*
-- * 256 temporary boot-time mappings, used by early_ioremap(),
-+ * 512 temporary boot-time mappings, used by early_ioremap(),
- * before ioremap() is functional.
- *
-- * If necessary we round it up to the next 256 pages boundary so
-+ * If necessary we round it up to the next 512 pages boundary so
- * that we can have a single pgd entry and a single pte table:
- */
- #define NR_FIX_BTMAPS 64
--#define FIX_BTMAPS_SLOTS 4
-+#define FIX_BTMAPS_SLOTS 8
- #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
- FIX_BTMAP_END =
- (__end_of_permanent_fixed_addresses ^
-diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
-index e22c1dbf7feb..d869931bde62 100644
---- a/arch/x86/include/asm/pgtable_64.h
-+++ b/arch/x86/include/asm/pgtable_64.h
-@@ -19,6 +19,7 @@ extern pud_t level3_ident_pgt[512];
- extern pmd_t level2_kernel_pgt[512];
- extern pmd_t level2_fixmap_pgt[512];
- extern pmd_t level2_ident_pgt[512];
-+extern pte_t level1_fixmap_pgt[512];
- extern pgd_t init_level4_pgt[];
-
- #define swapper_pg_dir init_level4_pgt
-diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
-index 5ad35ad94d0f..95700e52061d 100644
---- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
-+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
-@@ -511,6 +511,7 @@ static int rapl_cpu_prepare(int cpu)
- struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu);
- int phys_id = topology_physical_package_id(cpu);
- u64 ms;
-+ u64 msr_rapl_power_unit_bits;
-
- if (pmu)
- return 0;
-@@ -518,6 +519,9 @@ static int rapl_cpu_prepare(int cpu)
- if (phys_id < 0)
- return -1;
-
-+ if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
-+ return -1;
-+
- pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
- if (!pmu)
- return -1;
-@@ -531,8 +535,7 @@ static int rapl_cpu_prepare(int cpu)
- *
- * we cache in local PMU instance
- */
-- rdmsrl(MSR_RAPL_POWER_UNIT, pmu->hw_unit);
-- pmu->hw_unit = (pmu->hw_unit >> 8) & 0x1FULL;
-+ pmu->hw_unit = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
- pmu->pmu = &rapl_pmu_class;
-
- /*
-@@ -649,7 +652,9 @@ static int __init rapl_pmu_init(void)
- get_online_cpus();
-
- for_each_online_cpu(cpu) {
-- rapl_cpu_prepare(cpu);
-+ ret = rapl_cpu_prepare(cpu);
-+ if (ret)
-+ goto out;
- rapl_cpu_init(cpu);
- }
-
-@@ -672,6 +677,7 @@ static int __init rapl_pmu_init(void)
- hweight32(rapl_cntr_mask),
- ktime_to_ms(pmu->timer_interval));
-
-+out:
- put_online_cpus();
-
- return 0;
-diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
-index 395be6d8bbde..682876533ed9 100644
---- a/arch/x86/kernel/smpboot.c
-+++ b/arch/x86/kernel/smpboot.c
-@@ -1287,6 +1287,9 @@ static void remove_siblinginfo(int cpu)
-
- for_each_cpu(sibling, cpu_sibling_mask(cpu))
- cpumask_clear_cpu(cpu, cpu_sibling_mask(sibling));
-+ for_each_cpu(sibling, cpu_llc_shared_mask(cpu))
-+ cpumask_clear_cpu(cpu, cpu_llc_shared_mask(sibling));
-+ cpumask_clear(cpu_llc_shared_mask(cpu));
- cpumask_clear(cpu_sibling_mask(cpu));
- cpumask_clear(cpu_core_mask(cpu));
- c->phys_proc_id = 0;
-diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
-index 2423ef04ffea..c83da6fb2dee 100644
---- a/arch/x86/xen/mmu.c
-+++ b/arch/x86/xen/mmu.c
-@@ -1866,12 +1866,11 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
- *
- * We can construct this by grafting the Xen provided pagetable into
- * head_64.S's preconstructed pagetables. We copy the Xen L2's into
-- * level2_ident_pgt, level2_kernel_pgt and level2_fixmap_pgt. This
-- * means that only the kernel has a physical mapping to start with -
-- * but that's enough to get __va working. We need to fill in the rest
-- * of the physical mapping once some sort of allocator has been set
-- * up.
-- * NOTE: for PVH, the page tables are native.
-+ * level2_ident_pgt, and level2_kernel_pgt. This means that only the
-+ * kernel has a physical mapping to start with - but that's enough to
-+ * get __va working. We need to fill in the rest of the physical
-+ * mapping once some sort of allocator has been set up. NOTE: for
-+ * PVH, the page tables are native.
- */
- void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
- {
-@@ -1902,8 +1901,11 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
- /* L3_i[0] -> level2_ident_pgt */
- convert_pfn_mfn(level3_ident_pgt);
- /* L3_k[510] -> level2_kernel_pgt
-- * L3_i[511] -> level2_fixmap_pgt */
-+ * L3_k[511] -> level2_fixmap_pgt */
- convert_pfn_mfn(level3_kernel_pgt);
-+
-+ /* L3_k[511][506] -> level1_fixmap_pgt */
-+ convert_pfn_mfn(level2_fixmap_pgt);
- }
- /* We get [511][511] and have Xen's version of level2_kernel_pgt */
- l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
-@@ -1913,21 +1915,15 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
- addr[1] = (unsigned long)l3;
- addr[2] = (unsigned long)l2;
- /* Graft it onto L4[272][0]. Note that we creating an aliasing problem:
-- * Both L4[272][0] and L4[511][511] have entries that point to the same
-+ * Both L4[272][0] and L4[511][510] have entries that point to the same
- * L2 (PMD) tables. Meaning that if you modify it in __va space
- * it will be also modified in the __ka space! (But if you just
- * modify the PMD table to point to other PTE's or none, then you
- * are OK - which is what cleanup_highmap does) */
- copy_page(level2_ident_pgt, l2);
-- /* Graft it onto L4[511][511] */
-+ /* Graft it onto L4[511][510] */
- copy_page(level2_kernel_pgt, l2);
-
-- /* Get [511][510] and graft that in level2_fixmap_pgt */
-- l3 = m2v(pgd[pgd_index(__START_KERNEL_map + PMD_SIZE)].pgd);
-- l2 = m2v(l3[pud_index(__START_KERNEL_map + PMD_SIZE)].pud);
-- copy_page(level2_fixmap_pgt, l2);
-- /* Note that we don't do anything with level1_fixmap_pgt which
-- * we don't need. */
- if (!xen_feature(XENFEAT_auto_translated_physmap)) {
- /* Make pagetable pieces RO */
- set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
-@@ -1937,6 +1933,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
- set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
- set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
- set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
-+ set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
-
- /* Pin down new L4 */
- pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
-diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h
-index 216446295ada..51230ba97bef 100644
---- a/arch/xtensa/include/asm/pgtable.h
-+++ b/arch/xtensa/include/asm/pgtable.h
-@@ -67,7 +67,12 @@
- #define VMALLOC_START 0xC0000000
- #define VMALLOC_END 0xC7FEFFFF
- #define TLBTEMP_BASE_1 0xC7FF0000
--#define TLBTEMP_BASE_2 0xC7FF8000
-+#define TLBTEMP_BASE_2 (TLBTEMP_BASE_1 + DCACHE_WAY_SIZE)
-+#if 2 * DCACHE_WAY_SIZE > ICACHE_WAY_SIZE
-+#define TLBTEMP_SIZE (2 * DCACHE_WAY_SIZE)
-+#else
-+#define TLBTEMP_SIZE ICACHE_WAY_SIZE
-+#endif
-
- /*
- * For the Xtensa architecture, the PTE layout is as follows:
-diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
-index fd686dc45d1a..c7211e7e182d 100644
---- a/arch/xtensa/include/asm/uaccess.h
-+++ b/arch/xtensa/include/asm/uaccess.h
-@@ -52,7 +52,12 @@
- */
- .macro get_fs ad, sp
- GET_CURRENT(\ad,\sp)
-+#if THREAD_CURRENT_DS > 1020
-+ addi \ad, \ad, TASK_THREAD
-+ l32i \ad, \ad, THREAD_CURRENT_DS - TASK_THREAD
-+#else
- l32i \ad, \ad, THREAD_CURRENT_DS
-+#endif
- .endm
-
- /*
-diff --git a/arch/xtensa/include/uapi/asm/ioctls.h b/arch/xtensa/include/uapi/asm/ioctls.h
-index b4cb1100c0fb..a47909f0c34b 100644
---- a/arch/xtensa/include/uapi/asm/ioctls.h
-+++ b/arch/xtensa/include/uapi/asm/ioctls.h
-@@ -28,17 +28,17 @@
- #define TCSETSW 0x5403
- #define TCSETSF 0x5404
-
--#define TCGETA _IOR('t', 23, struct termio)
--#define TCSETA _IOW('t', 24, struct termio)
--#define TCSETAW _IOW('t', 25, struct termio)
--#define TCSETAF _IOW('t', 28, struct termio)
-+#define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */
-+#define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */
-+#define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */
-+#define TCSETAF 0x4012741C /* _IOW('t', 28, struct termio) */
-
- #define TCSBRK _IO('t', 29)
- #define TCXONC _IO('t', 30)
- #define TCFLSH _IO('t', 31)
-
--#define TIOCSWINSZ _IOW('t', 103, struct winsize)
--#define TIOCGWINSZ _IOR('t', 104, struct winsize)
-+#define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */
-+#define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */
- #define TIOCSTART _IO('t', 110) /* start output, like ^Q */
- #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
- #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
-@@ -88,7 +88,6 @@
- #define TIOCSETD _IOW('T', 35, int)
- #define TIOCGETD _IOR('T', 36, int)
- #define TCSBRKP _IOW('T', 37, int) /* Needed for POSIX tcsendbreak()*/
--#define TIOCTTYGSTRUCT _IOR('T', 38, struct tty_struct) /* For debugging only*/
- #define TIOCSBRK _IO('T', 39) /* BSD compatibility */
- #define TIOCCBRK _IO('T', 40) /* BSD compatibility */
- #define TIOCGSID _IOR('T', 41, pid_t) /* Return the session ID of FD*/
-@@ -114,8 +113,10 @@
- #define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* Get line status reg. */
- /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
- # define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
--#define TIOCSERGETMULTI _IOR('T', 90, struct serial_multiport_struct) /* Get multiport config */
--#define TIOCSERSETMULTI _IOW('T', 91, struct serial_multiport_struct) /* Set multiport config */
-+#define TIOCSERGETMULTI 0x80a8545a /* Get multiport config */
-+ /* _IOR('T', 90, struct serial_multiport_struct) */
-+#define TIOCSERSETMULTI 0x40a8545b /* Set multiport config */
-+ /* _IOW('T', 91, struct serial_multiport_struct) */
-
- #define TIOCMIWAIT _IO('T', 92) /* wait for a change on serial input line(s) */
- #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
-diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
-index ef7f4990722b..a06b7efaae82 100644
---- a/arch/xtensa/kernel/entry.S
-+++ b/arch/xtensa/kernel/entry.S
-@@ -1001,9 +1001,8 @@ ENTRY(fast_syscall_xtensa)
- movi a7, 4 # sizeof(unsigned int)
- access_ok a3, a7, a0, a2, .Leac # a0: scratch reg, a2: sp
-
-- addi a6, a6, -1 # assuming SYS_XTENSA_ATOMIC_SET = 1
-- _bgeui a6, SYS_XTENSA_COUNT - 1, .Lill
-- _bnei a6, SYS_XTENSA_ATOMIC_CMP_SWP - 1, .Lnswp
-+ _bgeui a6, SYS_XTENSA_COUNT, .Lill
-+ _bnei a6, SYS_XTENSA_ATOMIC_CMP_SWP, .Lnswp
-
- /* Fall through for ATOMIC_CMP_SWP. */
-
-@@ -1015,27 +1014,26 @@ TRY s32i a5, a3, 0 # different, modify value
- l32i a7, a2, PT_AREG7 # restore a7
- l32i a0, a2, PT_AREG0 # restore a0
- movi a2, 1 # and return 1
-- addi a6, a6, 1 # restore a6 (really necessary?)
- rfe
-
- 1: l32i a7, a2, PT_AREG7 # restore a7
- l32i a0, a2, PT_AREG0 # restore a0
- movi a2, 0 # return 0 (note that we cannot set
-- addi a6, a6, 1 # restore a6 (really necessary?)
- rfe
-
- .Lnswp: /* Atomic set, add, and exg_add. */
-
- TRY l32i a7, a3, 0 # orig
-+ addi a6, a6, -SYS_XTENSA_ATOMIC_SET
- add a0, a4, a7 # + arg
- moveqz a0, a4, a6 # set
-+ addi a6, a6, SYS_XTENSA_ATOMIC_SET
- TRY s32i a0, a3, 0 # write new value
-
- mov a0, a2
- mov a2, a7
- l32i a7, a0, PT_AREG7 # restore a7
- l32i a0, a0, PT_AREG0 # restore a0
-- addi a6, a6, 1 # restore a6 (really necessary?)
- rfe
-
- CATCH
-@@ -1044,7 +1042,7 @@ CATCH
- movi a2, -EFAULT
- rfe
-
--.Lill: l32i a7, a2, PT_AREG0 # restore a7
-+.Lill: l32i a7, a2, PT_AREG7 # restore a7
- l32i a0, a2, PT_AREG0 # restore a0
- movi a2, -EINVAL
- rfe
-@@ -1565,7 +1563,7 @@ ENTRY(fast_second_level_miss)
- rsr a0, excvaddr
- bltu a0, a3, 2f
-
-- addi a1, a0, -(2 << (DCACHE_ALIAS_ORDER + PAGE_SHIFT))
-+ addi a1, a0, -TLBTEMP_SIZE
- bgeu a1, a3, 2f
-
- /* Check if we have to restore an ITLB mapping. */
-@@ -1820,7 +1818,6 @@ ENTRY(_switch_to)
-
- entry a1, 16
-
-- mov a10, a2 # preserve 'prev' (a2)
- mov a11, a3 # and 'next' (a3)
-
- l32i a4, a2, TASK_THREAD_INFO
-@@ -1828,8 +1825,14 @@ ENTRY(_switch_to)
-
- save_xtregs_user a4 a6 a8 a9 a12 a13 THREAD_XTREGS_USER
-
-- s32i a0, a10, THREAD_RA # save return address
-- s32i a1, a10, THREAD_SP # save stack pointer
-+#if THREAD_RA > 1020 || THREAD_SP > 1020
-+ addi a10, a2, TASK_THREAD
-+ s32i a0, a10, THREAD_RA - TASK_THREAD # save return address
-+ s32i a1, a10, THREAD_SP - TASK_THREAD # save stack pointer
-+#else
-+ s32i a0, a2, THREAD_RA # save return address
-+ s32i a1, a2, THREAD_SP # save stack pointer
-+#endif
-
- /* Disable ints while we manipulate the stack pointer. */
-
-@@ -1870,7 +1873,6 @@ ENTRY(_switch_to)
- load_xtregs_user a5 a6 a8 a9 a12 a13 THREAD_XTREGS_USER
-
- wsr a14, ps
-- mov a2, a10 # return 'prev'
- rsync
-
- retw
-diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c
-index 2d9cc6dbfd78..e8b76b8e4b29 100644
---- a/arch/xtensa/kernel/pci-dma.c
-+++ b/arch/xtensa/kernel/pci-dma.c
-@@ -49,9 +49,8 @@ dma_alloc_coherent(struct device *dev,size_t size,dma_addr_t *handle,gfp_t flag)
-
- /* We currently don't support coherent memory outside KSEG */
-
-- if (ret < XCHAL_KSEG_CACHED_VADDR
-- || ret >= XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_SIZE)
-- BUG();
-+ BUG_ON(ret < XCHAL_KSEG_CACHED_VADDR ||
-+ ret > XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_SIZE - 1);
-
-
- if (ret != 0) {
-@@ -68,10 +67,11 @@ EXPORT_SYMBOL(dma_alloc_coherent);
- void dma_free_coherent(struct device *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle)
- {
-- long addr=(long)vaddr+XCHAL_KSEG_CACHED_VADDR-XCHAL_KSEG_BYPASS_VADDR;
-+ unsigned long addr = (unsigned long)vaddr +
-+ XCHAL_KSEG_CACHED_VADDR - XCHAL_KSEG_BYPASS_VADDR;
-
-- if (addr < 0 || addr >= XCHAL_KSEG_SIZE)
-- BUG();
-+ BUG_ON(addr < XCHAL_KSEG_CACHED_VADDR ||
-+ addr > XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_SIZE - 1);
-
- free_pages(addr, get_order(size));
- }
-diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
-index 744833b630c6..91c25f261c91 100644
---- a/block/cfq-iosched.c
-+++ b/block/cfq-iosched.c
-@@ -1275,12 +1275,16 @@ __cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
- static void
- cfq_update_group_weight(struct cfq_group *cfqg)
- {
-- BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
--
- if (cfqg->new_weight) {
- cfqg->weight = cfqg->new_weight;
- cfqg->new_weight = 0;
- }
-+}
-+
-+static void
-+cfq_update_group_leaf_weight(struct cfq_group *cfqg)
-+{
-+ BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
-
- if (cfqg->new_leaf_weight) {
- cfqg->leaf_weight = cfqg->new_leaf_weight;
-@@ -1299,7 +1303,7 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
- /* add to the service tree */
- BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
-
-- cfq_update_group_weight(cfqg);
-+ cfq_update_group_leaf_weight(cfqg);
- __cfq_group_service_tree_add(st, cfqg);
-
- /*
-@@ -1323,6 +1327,7 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
- */
- while ((parent = cfqg_parent(pos))) {
- if (propagate) {
-+ cfq_update_group_weight(pos);
- propagate = !parent->nr_active++;
- parent->children_weight += pos->weight;
- }
-diff --git a/block/genhd.c b/block/genhd.c
-index 791f41943132..e6723bd4d7a1 100644
---- a/block/genhd.c
-+++ b/block/genhd.c
-@@ -28,10 +28,10 @@ struct kobject *block_depr;
- /* for extended dynamic devt allocation, currently only one major is used */
- #define NR_EXT_DEVT (1 << MINORBITS)
-
--/* For extended devt allocation. ext_devt_mutex prevents look up
-+/* For extended devt allocation. ext_devt_lock prevents look up
- * results from going away underneath its user.
- */
--static DEFINE_MUTEX(ext_devt_mutex);
-+static DEFINE_SPINLOCK(ext_devt_lock);
- static DEFINE_IDR(ext_devt_idr);
-
- static struct device_type disk_type;
-@@ -420,9 +420,13 @@ int blk_alloc_devt(struct hd_struct *part, dev_t *devt)
- }
-
- /* allocate ext devt */
-- mutex_lock(&ext_devt_mutex);
-- idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_KERNEL);
-- mutex_unlock(&ext_devt_mutex);
-+ idr_preload(GFP_KERNEL);
-+
-+ spin_lock(&ext_devt_lock);
-+ idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_NOWAIT);
-+ spin_unlock(&ext_devt_lock);
-+
-+ idr_preload_end();
- if (idx < 0)
- return idx == -ENOSPC ? -EBUSY : idx;
-
-@@ -441,15 +445,13 @@ int blk_alloc_devt(struct hd_struct *part, dev_t *devt)
- */
- void blk_free_devt(dev_t devt)
- {
-- might_sleep();
--
- if (devt == MKDEV(0, 0))
- return;
-
- if (MAJOR(devt) == BLOCK_EXT_MAJOR) {
-- mutex_lock(&ext_devt_mutex);
-+ spin_lock(&ext_devt_lock);
- idr_remove(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
-- mutex_unlock(&ext_devt_mutex);
-+ spin_unlock(&ext_devt_lock);
- }
- }
-
-@@ -665,7 +667,6 @@ void del_gendisk(struct gendisk *disk)
- sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
- pm_runtime_set_memalloc_noio(disk_to_dev(disk), false);
- device_del(disk_to_dev(disk));
-- blk_free_devt(disk_to_dev(disk)->devt);
- }
- EXPORT_SYMBOL(del_gendisk);
-
-@@ -690,13 +691,13 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
- } else {
- struct hd_struct *part;
-
-- mutex_lock(&ext_devt_mutex);
-+ spin_lock(&ext_devt_lock);
- part = idr_find(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
- if (part && get_disk(part_to_disk(part))) {
- *partno = part->partno;
- disk = part_to_disk(part);
- }
-- mutex_unlock(&ext_devt_mutex);
-+ spin_unlock(&ext_devt_lock);
- }
-
- return disk;
-@@ -1098,6 +1099,7 @@ static void disk_release(struct device *dev)
- {
- struct gendisk *disk = dev_to_disk(dev);
-
-+ blk_free_devt(dev->devt);
- disk_release_events(disk);
- kfree(disk->random);
- disk_replace_part_tbl(disk, NULL);
-diff --git a/block/partition-generic.c b/block/partition-generic.c
-index 789cdea05893..0d9e5f97f0a8 100644
---- a/block/partition-generic.c
-+++ b/block/partition-generic.c
-@@ -211,6 +211,7 @@ static const struct attribute_group *part_attr_groups[] = {
- static void part_release(struct device *dev)
- {
- struct hd_struct *p = dev_to_part(dev);
-+ blk_free_devt(dev->devt);
- free_part_stats(p);
- free_part_info(p);
- kfree(p);
-@@ -253,7 +254,6 @@ void delete_partition(struct gendisk *disk, int partno)
- rcu_assign_pointer(ptbl->last_lookup, NULL);
- kobject_put(part->holder_dir);
- device_del(part_to_dev(part));
-- blk_free_devt(part_devt(part));
-
- hd_struct_put(part);
- }
-diff --git a/block/partitions/aix.c b/block/partitions/aix.c
-index 43be471d9b1d..0931f5136ab2 100644
---- a/block/partitions/aix.c
-+++ b/block/partitions/aix.c
-@@ -253,7 +253,7 @@ int aix_partition(struct parsed_partitions *state)
- continue;
- }
- lv_ix = be16_to_cpu(p->lv_ix) - 1;
-- if (lv_ix > state->limit) {
-+ if (lv_ix >= state->limit) {
- cur_lv_ix = -1;
- continue;
- }
-diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c
-index 84190ed89c04..aff69d9bfcbf 100644
---- a/drivers/acpi/acpi_cmos_rtc.c
-+++ b/drivers/acpi/acpi_cmos_rtc.c
-@@ -35,7 +35,7 @@ acpi_cmos_rtc_space_handler(u32 function, acpi_physical_address address,
- void *handler_context, void *region_context)
- {
- int i;
-- u8 *value = (u8 *)&value64;
-+ u8 *value = (u8 *)value64;
-
- if (address > 0xff || !value64)
- return AE_BAD_PARAMETER;
-diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
-index d95ca5449ace..e6ab104afe42 100644
---- a/drivers/acpi/acpica/aclocal.h
-+++ b/drivers/acpi/acpica/aclocal.h
-@@ -254,6 +254,7 @@ struct acpi_create_field_info {
- u32 field_bit_position;
- u32 field_bit_length;
- u16 resource_length;
-+ u16 pin_number_index;
- u8 field_flags;
- u8 attribute;
- u8 field_type;
-diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
-index cc7ab6dd724e..a47cc78ffd4f 100644
---- a/drivers/acpi/acpica/acobject.h
-+++ b/drivers/acpi/acpica/acobject.h
-@@ -263,6 +263,7 @@ struct acpi_object_region_field {
- ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO u16 resource_length;
- union acpi_operand_object *region_obj; /* Containing op_region object */
- u8 *resource_buffer; /* resource_template for serial regions/fields */
-+ u16 pin_number_index; /* Index relative to previous Connection/Template */
- };
-
- struct acpi_object_bank_field {
-diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
-index e7a57c554e84..9af55bd6c4d7 100644
---- a/drivers/acpi/acpica/dsfield.c
-+++ b/drivers/acpi/acpica/dsfield.c
-@@ -360,6 +360,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
- */
- info->resource_buffer = NULL;
- info->connection_node = NULL;
-+ info->pin_number_index = 0;
-
- /*
- * A Connection() is either an actual resource descriptor (buffer)
-@@ -437,6 +438,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
- }
-
- info->field_bit_position += info->field_bit_length;
-+ info->pin_number_index++; /* Index relative to previous Connection() */
- break;
-
- default:
-diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
-index 144cbb9b73bc..cd4b231ae760 100644
---- a/drivers/acpi/acpica/evregion.c
-+++ b/drivers/acpi/acpica/evregion.c
-@@ -142,6 +142,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
- union acpi_operand_object *region_obj2;
- void *region_context = NULL;
- struct acpi_connection_info *context;
-+ acpi_physical_address address;
-
- ACPI_FUNCTION_TRACE(ev_address_space_dispatch);
-
-@@ -231,25 +232,23 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
- /* We have everything we need, we can invoke the address space handler */
-
- handler = handler_desc->address_space.handler;
--
-- ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
-- "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
-- ®ion_obj->region.handler->address_space, handler,
-- ACPI_FORMAT_NATIVE_UINT(region_obj->region.address +
-- region_offset),
-- acpi_ut_get_region_name(region_obj->region.
-- space_id)));
-+ address = (region_obj->region.address + region_offset);
-
- /*
- * Special handling for generic_serial_bus and general_purpose_io:
- * There are three extra parameters that must be passed to the
- * handler via the context:
-- * 1) Connection buffer, a resource template from Connection() op.
-- * 2) Length of the above buffer.
-- * 3) Actual access length from the access_as() op.
-+ * 1) Connection buffer, a resource template from Connection() op
-+ * 2) Length of the above buffer
-+ * 3) Actual access length from the access_as() op
-+ *
-+ * In addition, for general_purpose_io, the Address and bit_width fields
-+ * are defined as follows:
-+ * 1) Address is the pin number index of the field (bit offset from
-+ * the previous Connection)
-+ * 2) bit_width is the actual bit length of the field (number of pins)
- */
-- if (((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) ||
-- (region_obj->region.space_id == ACPI_ADR_SPACE_GPIO)) &&
-+ if ((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) &&
- context && field_obj) {
-
- /* Get the Connection (resource_template) buffer */
-@@ -258,6 +257,24 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
- context->length = field_obj->field.resource_length;
- context->access_length = field_obj->field.access_length;
- }
-+ if ((region_obj->region.space_id == ACPI_ADR_SPACE_GPIO) &&
-+ context && field_obj) {
-+
-+ /* Get the Connection (resource_template) buffer */
-+
-+ context->connection = field_obj->field.resource_buffer;
-+ context->length = field_obj->field.resource_length;
-+ context->access_length = field_obj->field.access_length;
-+ address = field_obj->field.pin_number_index;
-+ bit_width = field_obj->field.bit_length;
-+ }
-+
-+ ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
-+ "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
-+ ®ion_obj->region.handler->address_space, handler,
-+ ACPI_FORMAT_NATIVE_UINT(address),
-+ acpi_ut_get_region_name(region_obj->region.
-+ space_id)));
-
- if (!(handler_desc->address_space.handler_flags &
- ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
-@@ -271,9 +288,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
-
- /* Call the handler */
-
-- status = handler(function,
-- (region_obj->region.address + region_offset),
-- bit_width, value, context,
-+ status = handler(function, address, bit_width, value, context,
- region_obj2->extra.region_context);
-
- if (ACPI_FAILURE(status)) {
-diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
-index cfd875243421..d36894a228b1 100644
---- a/drivers/acpi/acpica/exfield.c
-+++ b/drivers/acpi/acpica/exfield.c
-@@ -178,6 +178,37 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
- buffer = &buffer_desc->integer.value;
- }
-
-+ if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
-+ (obj_desc->field.region_obj->region.space_id ==
-+ ACPI_ADR_SPACE_GPIO)) {
-+ /*
-+ * For GPIO (general_purpose_io), the Address will be the bit offset
-+ * from the previous Connection() operator, making it effectively a
-+ * pin number index. The bit_length is the length of the field, which
-+ * is thus the number of pins.
-+ */
-+ ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
-+ "GPIO FieldRead [FROM]: Pin %u Bits %u\n",
-+ obj_desc->field.pin_number_index,
-+ obj_desc->field.bit_length));
-+
-+ /* Lock entire transaction if requested */
-+
-+ acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
-+
-+ /* Perform the write */
-+
-+ status = acpi_ex_access_region(obj_desc, 0,
-+ (u64 *)buffer, ACPI_READ);
-+ acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
-+ if (ACPI_FAILURE(status)) {
-+ acpi_ut_remove_reference(buffer_desc);
-+ } else {
-+ *ret_buffer_desc = buffer_desc;
-+ }
-+ return_ACPI_STATUS(status);
-+ }
-+
- ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
- "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
- obj_desc, obj_desc->common.type, buffer,
-@@ -325,6 +356,42 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
-
- *result_desc = buffer_desc;
- return_ACPI_STATUS(status);
-+ } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
-+ (obj_desc->field.region_obj->region.space_id ==
-+ ACPI_ADR_SPACE_GPIO)) {
-+ /*
-+ * For GPIO (general_purpose_io), we will bypass the entire field
-+ * mechanism and handoff the bit address and bit width directly to
-+ * the handler. The Address will be the bit offset
-+ * from the previous Connection() operator, making it effectively a
-+ * pin number index. The bit_length is the length of the field, which
-+ * is thus the number of pins.
-+ */
-+ if (source_desc->common.type != ACPI_TYPE_INTEGER) {
-+ return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
-+ }
-+
-+ ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
-+ "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n",
-+ acpi_ut_get_type_name(source_desc->common.
-+ type),
-+ source_desc->common.type,
-+ (u32)source_desc->integer.value,
-+ obj_desc->field.pin_number_index,
-+ obj_desc->field.bit_length));
-+
-+ buffer = &source_desc->integer.value;
-+
-+ /* Lock entire transaction if requested */
-+
-+ acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
-+
-+ /* Perform the write */
-+
-+ status = acpi_ex_access_region(obj_desc, 0,
-+ (u64 *)buffer, ACPI_WRITE);
-+ acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
-+ return_ACPI_STATUS(status);
- }
-
- /* Get a pointer to the data to be written */
-diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
-index 5a588611ab48..8c88cfdec441 100644
---- a/drivers/acpi/acpica/exprep.c
-+++ b/drivers/acpi/acpica/exprep.c
-@@ -484,6 +484,8 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
- obj_desc->field.resource_length = info->resource_length;
- }
-
-+ obj_desc->field.pin_number_index = info->pin_number_index;
-+
- /* Allow full data read from EC address space */
-
- if ((obj_desc->field.region_obj->region.space_id ==
-diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
-index 368f9ddb8480..e4a6f78f3bbc 100644
---- a/drivers/acpi/container.c
-+++ b/drivers/acpi/container.c
-@@ -96,6 +96,13 @@ static void container_device_detach(struct acpi_device *adev)
- device_unregister(dev);
- }
-
-+static void container_device_online(struct acpi_device *adev)
-+{
-+ struct device *dev = acpi_driver_data(adev);
-+
-+ kobject_uevent(&dev->kobj, KOBJ_ONLINE);
-+}
-+
- static struct acpi_scan_handler container_handler = {
- .ids = container_device_ids,
- .attach = container_device_attach,
-@@ -103,6 +110,7 @@ static struct acpi_scan_handler container_handler = {
- .hotplug = {
- .enabled = true,
- .demand_offline = true,
-+ .notify_online = container_device_online,
- },
- };
-
-diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
-index 92d5184e3654..493a342efa44 100644
---- a/drivers/acpi/scan.c
-+++ b/drivers/acpi/scan.c
-@@ -106,7 +106,7 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
- list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
- count = snprintf(&modalias[len], size, "%s:", id->id);
- if (count < 0)
-- return EINVAL;
-+ return -EINVAL;
- if (count >= size)
- return -ENOMEM;
- len += count;
-@@ -2068,6 +2068,9 @@ static void acpi_bus_attach(struct acpi_device *device)
- ok:
- list_for_each_entry(child, &device->children, node)
- acpi_bus_attach(child);
-+
-+ if (device->handler && device->handler->hotplug.notify_online)
-+ device->handler->hotplug.notify_online(device);
- }
-
- /**
-diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
-index b54f8b3c7924..00663d60f6d4 100644
---- a/drivers/ata/ahci.c
-+++ b/drivers/ata/ahci.c
-@@ -306,6 +306,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
- { PCI_VDEVICE(INTEL, 0x9c85), board_ahci }, /* Wildcat Point-LP RAID */
- { PCI_VDEVICE(INTEL, 0x9c87), board_ahci }, /* Wildcat Point-LP RAID */
- { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci }, /* Wildcat Point-LP RAID */
-+ { PCI_VDEVICE(INTEL, 0x8c82), board_ahci }, /* 9 Series AHCI */
-+ { PCI_VDEVICE(INTEL, 0x8c83), board_ahci }, /* 9 Series AHCI */
-+ { PCI_VDEVICE(INTEL, 0x8c84), board_ahci }, /* 9 Series RAID */
-+ { PCI_VDEVICE(INTEL, 0x8c85), board_ahci }, /* 9 Series RAID */
-+ { PCI_VDEVICE(INTEL, 0x8c86), board_ahci }, /* 9 Series RAID */
-+ { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series RAID */
-+ { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */
-+ { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series RAID */
-
- /* JMicron 360/1/3/5/6, match class to avoid IDE function */
- { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-@@ -443,6 +451,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
- { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x917a),
- .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
- { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9172),
-+ .driver_data = board_ahci_yes_fbs }, /* 88se9182 */
-+ { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9182),
- .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
- { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9192),
- .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */
-diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
-index 6334c8d7c3f1..39f76b987c75 100644
---- a/drivers/ata/ata_piix.c
-+++ b/drivers/ata/ata_piix.c
-@@ -340,6 +340,14 @@ static const struct pci_device_id piix_pci_tbl[] = {
- { 0x8086, 0x0F21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_byt },
- /* SATA Controller IDE (Coleto Creek) */
- { 0x8086, 0x23a6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
-+ /* SATA Controller IDE (9 Series) */
-+ { 0x8086, 0x8c88, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_snb },
-+ /* SATA Controller IDE (9 Series) */
-+ { 0x8086, 0x8c89, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_snb },
-+ /* SATA Controller IDE (9 Series) */
-+ { 0x8086, 0x8c80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
-+ /* SATA Controller IDE (9 Series) */
-+ { 0x8086, 0x8c81, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
-
- { } /* terminate list */
- };
-diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
-index f7616036663b..538574f98e22 100644
---- a/drivers/ata/libata-core.c
-+++ b/drivers/ata/libata-core.c
-@@ -4227,7 +4227,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
- { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
- { "Crucial_CT???M500SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
- { "Micron_M550*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
-- { "Crucial_CT???M550SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
-+ { "Crucial_CT*M550SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
-
- /*
- * Some WD SATA-I drives spin up and down erratically when the link
-diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
-index f35f15f4d83e..f7badaa39eb6 100644
---- a/drivers/ata/pata_scc.c
-+++ b/drivers/ata/pata_scc.c
-@@ -586,7 +586,7 @@ static int scc_wait_after_reset(struct ata_link *link, unsigned int devmask,
- * Note: Original code is ata_bus_softreset().
- */
-
--static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask,
-+static int scc_bus_softreset(struct ata_port *ap, unsigned int devmask,
- unsigned long deadline)
- {
- struct ata_ioports *ioaddr = &ap->ioaddr;
-@@ -600,9 +600,7 @@ static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask,
- udelay(20);
- out_be32(ioaddr->ctl_addr, ap->ctl);
-
-- scc_wait_after_reset(&ap->link, devmask, deadline);
--
-- return 0;
-+ return scc_wait_after_reset(&ap->link, devmask, deadline);
- }
-
- /**
-@@ -619,7 +617,8 @@ static int scc_softreset(struct ata_link *link, unsigned int *classes,
- {
- struct ata_port *ap = link->ap;
- unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
-- unsigned int devmask = 0, err_mask;
-+ unsigned int devmask = 0;
-+ int rc;
- u8 err;
-
- DPRINTK("ENTER\n");
-@@ -635,9 +634,9 @@ static int scc_softreset(struct ata_link *link, unsigned int *classes,
-
- /* issue bus reset */
- DPRINTK("about to softreset, devmask=%x\n", devmask);
-- err_mask = scc_bus_softreset(ap, devmask, deadline);
-- if (err_mask) {
-- ata_port_err(ap, "SRST failed (err_mask=0x%x)\n", err_mask);
-+ rc = scc_bus_softreset(ap, devmask, deadline);
-+ if (rc) {
-+ ata_port_err(ap, "SRST failed (err_mask=0x%x)\n", rc);
- return -EIO;
- }
-
-diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
-index d4dd77134814..154e7a8c0a04 100644
---- a/drivers/base/regmap/regcache.c
-+++ b/drivers/base/regmap/regcache.c
-@@ -701,7 +701,7 @@ int regcache_sync_block(struct regmap *map, void *block,
- unsigned int block_base, unsigned int start,
- unsigned int end)
- {
-- if (regmap_can_raw_write(map))
-+ if (regmap_can_raw_write(map) && !map->use_single_rw)
- return regcache_sync_block_raw(map, block, cache_present,
- block_base, start, end);
- else
-diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
-index 6a19515f8a45..2ea056c09aeb 100644
---- a/drivers/base/regmap/regmap.c
-+++ b/drivers/base/regmap/regmap.c
-@@ -105,7 +105,7 @@ bool regmap_readable(struct regmap *map, unsigned int reg)
-
- bool regmap_volatile(struct regmap *map, unsigned int reg)
- {
-- if (!regmap_readable(map, reg))
-+ if (!map->format.format_write && !regmap_readable(map, reg))
- return false;
-
- if (map->volatile_reg)
-diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
-index b94a311e5ab6..f9c4632d4dd3 100644
---- a/drivers/clk/clk.c
-+++ b/drivers/clk/clk.c
-@@ -1487,6 +1487,7 @@ static struct clk *clk_propagate_rate_change(struct clk *clk, unsigned long even
- static void clk_change_rate(struct clk *clk)
- {
- struct clk *child;
-+ struct hlist_node *tmp;
- unsigned long old_rate;
- unsigned long best_parent_rate = 0;
- bool skip_set_rate = false;
-@@ -1525,7 +1526,11 @@ static void clk_change_rate(struct clk *clk)
- if (clk->notifier_count && old_rate != clk->rate)
- __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate);
-
-- hlist_for_each_entry(child, &clk->children, child_node) {
-+ /*
-+ * Use safe iteration, as change_rate can actually swap parents
-+ * for certain clock types.
-+ */
-+ hlist_for_each_entry_safe(child, tmp, &clk->children, child_node) {
- /* Skip children who will be reparented to another clock */
- if (child->new_parent && child->new_parent != clk)
- continue;
-diff --git a/drivers/clk/qcom/mmcc-msm8960.c b/drivers/clk/qcom/mmcc-msm8960.c
-index 9be47a829144..f3c95d648a53 100644
---- a/drivers/clk/qcom/mmcc-msm8960.c
-+++ b/drivers/clk/qcom/mmcc-msm8960.c
-@@ -37,6 +37,8 @@
- #define P_PLL2 2
- #define P_PLL3 3
-
-+#define F_MN(f, s, _m, _n) { .freq = f, .src = s, .m = _m, .n = _n }
-+
- static u8 mmcc_pxo_pll8_pll2_map[] = {
- [P_PXO] = 0,
- [P_PLL8] = 2,
-@@ -58,8 +60,8 @@ static u8 mmcc_pxo_pll8_pll2_pll3_map[] = {
-
- static const char *mmcc_pxo_pll8_pll2_pll3[] = {
- "pxo",
-- "pll2",
- "pll8_vote",
-+ "pll2",
- "pll3",
- };
-
-@@ -709,18 +711,18 @@ static struct clk_branch csiphy2_timer_clk = {
- };
-
- static struct freq_tbl clk_tbl_gfx2d[] = {
-- { 27000000, P_PXO, 1, 0 },
-- { 48000000, P_PLL8, 1, 8 },
-- { 54857000, P_PLL8, 1, 7 },
-- { 64000000, P_PLL8, 1, 6 },
-- { 76800000, P_PLL8, 1, 5 },
-- { 96000000, P_PLL8, 1, 4 },
-- { 128000000, P_PLL8, 1, 3 },
-- { 145455000, P_PLL2, 2, 11 },
-- { 160000000, P_PLL2, 1, 5 },
-- { 177778000, P_PLL2, 2, 9 },
-- { 200000000, P_PLL2, 1, 4 },
-- { 228571000, P_PLL2, 2, 7 },
-+ F_MN( 27000000, P_PXO, 1, 0),
-+ F_MN( 48000000, P_PLL8, 1, 8),
-+ F_MN( 54857000, P_PLL8, 1, 7),
-+ F_MN( 64000000, P_PLL8, 1, 6),
-+ F_MN( 76800000, P_PLL8, 1, 5),
-+ F_MN( 96000000, P_PLL8, 1, 4),
-+ F_MN(128000000, P_PLL8, 1, 3),
-+ F_MN(145455000, P_PLL2, 2, 11),
-+ F_MN(160000000, P_PLL2, 1, 5),
-+ F_MN(177778000, P_PLL2, 2, 9),
-+ F_MN(200000000, P_PLL2, 1, 4),
-+ F_MN(228571000, P_PLL2, 2, 7),
- { }
- };
-
-@@ -841,22 +843,22 @@ static struct clk_branch gfx2d1_clk = {
- };
-
- static struct freq_tbl clk_tbl_gfx3d[] = {
-- { 27000000, P_PXO, 1, 0 },
-- { 48000000, P_PLL8, 1, 8 },
-- { 54857000, P_PLL8, 1, 7 },
-- { 64000000, P_PLL8, 1, 6 },
-- { 76800000, P_PLL8, 1, 5 },
-- { 96000000, P_PLL8, 1, 4 },
-- { 128000000, P_PLL8, 1, 3 },
-- { 145455000, P_PLL2, 2, 11 },
-- { 160000000, P_PLL2, 1, 5 },
-- { 177778000, P_PLL2, 2, 9 },
-- { 200000000, P_PLL2, 1, 4 },
-- { 228571000, P_PLL2, 2, 7 },
-- { 266667000, P_PLL2, 1, 3 },
-- { 300000000, P_PLL3, 1, 4 },
-- { 320000000, P_PLL2, 2, 5 },
-- { 400000000, P_PLL2, 1, 2 },
-+ F_MN( 27000000, P_PXO, 1, 0),
-+ F_MN( 48000000, P_PLL8, 1, 8),
-+ F_MN( 54857000, P_PLL8, 1, 7),
-+ F_MN( 64000000, P_PLL8, 1, 6),
-+ F_MN( 76800000, P_PLL8, 1, 5),
-+ F_MN( 96000000, P_PLL8, 1, 4),
-+ F_MN(128000000, P_PLL8, 1, 3),
-+ F_MN(145455000, P_PLL2, 2, 11),
-+ F_MN(160000000, P_PLL2, 1, 5),
-+ F_MN(177778000, P_PLL2, 2, 9),
-+ F_MN(200000000, P_PLL2, 1, 4),
-+ F_MN(228571000, P_PLL2, 2, 7),
-+ F_MN(266667000, P_PLL2, 1, 3),
-+ F_MN(300000000, P_PLL3, 1, 4),
-+ F_MN(320000000, P_PLL2, 2, 5),
-+ F_MN(400000000, P_PLL2, 1, 2),
- { }
- };
-
-@@ -896,7 +898,7 @@ static struct clk_dyn_rcg gfx3d_src = {
- .hw.init = &(struct clk_init_data){
- .name = "gfx3d_src",
- .parent_names = mmcc_pxo_pll8_pll2_pll3,
-- .num_parents = 3,
-+ .num_parents = 4,
- .ops = &clk_dyn_rcg_ops,
- },
- },
-@@ -994,7 +996,7 @@ static struct clk_rcg jpegd_src = {
- .ns_reg = 0x00ac,
- .p = {
- .pre_div_shift = 12,
-- .pre_div_width = 2,
-+ .pre_div_width = 4,
- },
- .s = {
- .src_sel_shift = 0,
-@@ -1114,7 +1116,7 @@ static struct clk_branch mdp_lut_clk = {
- .enable_reg = 0x016c,
- .enable_mask = BIT(0),
- .hw.init = &(struct clk_init_data){
-- .parent_names = (const char *[]){ "mdp_clk" },
-+ .parent_names = (const char *[]){ "mdp_src" },
- .num_parents = 1,
- .name = "mdp_lut_clk",
- .ops = &clk_branch_ops,
-@@ -1341,15 +1343,15 @@ static struct clk_branch hdmi_app_clk = {
- };
-
- static struct freq_tbl clk_tbl_vcodec[] = {
-- { 27000000, P_PXO, 1, 0 },
-- { 32000000, P_PLL8, 1, 12 },
-- { 48000000, P_PLL8, 1, 8 },
-- { 54860000, P_PLL8, 1, 7 },
-- { 96000000, P_PLL8, 1, 4 },
-- { 133330000, P_PLL2, 1, 6 },
-- { 200000000, P_PLL2, 1, 4 },
-- { 228570000, P_PLL2, 2, 7 },
-- { 266670000, P_PLL2, 1, 3 },
-+ F_MN( 27000000, P_PXO, 1, 0),
-+ F_MN( 32000000, P_PLL8, 1, 12),
-+ F_MN( 48000000, P_PLL8, 1, 8),
-+ F_MN( 54860000, P_PLL8, 1, 7),
-+ F_MN( 96000000, P_PLL8, 1, 4),
-+ F_MN(133330000, P_PLL2, 1, 6),
-+ F_MN(200000000, P_PLL2, 1, 4),
-+ F_MN(228570000, P_PLL2, 2, 7),
-+ F_MN(266670000, P_PLL2, 1, 3),
- { }
- };
-
-diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
-index 153f4b92cc05..415923606164 100644
---- a/drivers/cpufreq/cpufreq.c
-+++ b/drivers/cpufreq/cpufreq.c
-@@ -1225,6 +1225,8 @@ err_get_freq:
- per_cpu(cpufreq_cpu_data, j) = NULL;
- write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
-+ up_write(&policy->rwsem);
-+
- if (cpufreq_driver->exit)
- cpufreq_driver->exit(policy);
- err_set_policy_cpu:
-diff --git a/drivers/dma/TODO b/drivers/dma/TODO
-index 734ed0206cd5..b8045cd42ee1 100644
---- a/drivers/dma/TODO
-+++ b/drivers/dma/TODO
-@@ -7,7 +7,6 @@ TODO for slave dma
- - imx-dma
- - imx-sdma
- - mxs-dma.c
-- - dw_dmac
- - intel_mid_dma
- 4. Check other subsystems for dma drivers and merge/move to dmaengine
- 5. Remove dma_slave_config's dma direction.
-diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
-index 01a200cd0189..b0972b3869c7 100644
---- a/drivers/dma/dw/core.c
-+++ b/drivers/dma/dw/core.c
-@@ -279,6 +279,15 @@ static void dwc_dostart(struct dw_dma_chan *dwc, struct dw_desc *first)
- channel_set_bit(dw, CH_EN, dwc->mask);
- }
-
-+static void dwc_dostart_first_queued(struct dw_dma_chan *dwc)
-+{
-+ if (list_empty(&dwc->queue))
-+ return;
-+
-+ list_move(dwc->queue.next, &dwc->active_list);
-+ dwc_dostart(dwc, dwc_first_active(dwc));
-+}
-+
- /*----------------------------------------------------------------------*/
-
- static void
-@@ -335,10 +344,7 @@ static void dwc_complete_all(struct dw_dma *dw, struct dw_dma_chan *dwc)
- * the completed ones.
- */
- list_splice_init(&dwc->active_list, &list);
-- if (!list_empty(&dwc->queue)) {
-- list_move(dwc->queue.next, &dwc->active_list);
-- dwc_dostart(dwc, dwc_first_active(dwc));
-- }
-+ dwc_dostart_first_queued(dwc);
-
- spin_unlock_irqrestore(&dwc->lock, flags);
-
-@@ -467,10 +473,7 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct dw_dma_chan *dwc)
- /* Try to continue after resetting the channel... */
- dwc_chan_disable(dw, dwc);
-
-- if (!list_empty(&dwc->queue)) {
-- list_move(dwc->queue.next, &dwc->active_list);
-- dwc_dostart(dwc, dwc_first_active(dwc));
-- }
-+ dwc_dostart_first_queued(dwc);
- spin_unlock_irqrestore(&dwc->lock, flags);
- }
-
-@@ -677,17 +680,9 @@ static dma_cookie_t dwc_tx_submit(struct dma_async_tx_descriptor *tx)
- * possible, perhaps even appending to those already submitted
- * for DMA. But this is hard to do in a race-free manner.
- */
-- if (list_empty(&dwc->active_list)) {
-- dev_vdbg(chan2dev(tx->chan), "%s: started %u\n", __func__,
-- desc->txd.cookie);
-- list_add_tail(&desc->desc_node, &dwc->active_list);
-- dwc_dostart(dwc, dwc_first_active(dwc));
-- } else {
-- dev_vdbg(chan2dev(tx->chan), "%s: queued %u\n", __func__,
-- desc->txd.cookie);
-
-- list_add_tail(&desc->desc_node, &dwc->queue);
-- }
-+ dev_vdbg(chan2dev(tx->chan), "%s: queued %u\n", __func__, desc->txd.cookie);
-+ list_add_tail(&desc->desc_node, &dwc->queue);
-
- spin_unlock_irqrestore(&dwc->lock, flags);
-
-@@ -1092,9 +1087,12 @@ dwc_tx_status(struct dma_chan *chan,
- static void dwc_issue_pending(struct dma_chan *chan)
- {
- struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
-+ unsigned long flags;
-
-- if (!list_empty(&dwc->queue))
-- dwc_scan_descriptors(to_dw_dma(chan->device), dwc);
-+ spin_lock_irqsave(&dwc->lock, flags);
-+ if (list_empty(&dwc->active_list))
-+ dwc_dostart_first_queued(dwc);
-+ spin_unlock_irqrestore(&dwc->lock, flags);
- }
-
- static int dwc_alloc_chan_resources(struct dma_chan *chan)
-diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
-index 50535fd5a88d..d830b38e54f6 100644
---- a/drivers/gpu/drm/ast/ast_main.c
-+++ b/drivers/gpu/drm/ast/ast_main.c
-@@ -100,7 +100,7 @@ static int ast_detect_chip(struct drm_device *dev)
- }
- ast->vga2_clone = false;
- } else {
-- ast->chip = 2000;
-+ ast->chip = AST2000;
- DRM_INFO("AST 2000 detected\n");
- }
- }
-diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
-index 3ecb332e7cfa..7410a507eacc 100644
---- a/drivers/gpu/drm/i915/i915_gem.c
-+++ b/drivers/gpu/drm/i915/i915_gem.c
-@@ -1426,10 +1426,13 @@ unlock:
- out:
- switch (ret) {
- case -EIO:
-- /* If this -EIO is due to a gpu hang, give the reset code a
-- * chance to clean up the mess. Otherwise return the proper
-- * SIGBUS. */
-- if (i915_terminally_wedged(&dev_priv->gpu_error)) {
-+ /*
-+ * We eat errors when the gpu is terminally wedged to avoid
-+ * userspace unduly crashing (gl has no provisions for mmaps to
-+ * fail). But any other -EIO isn't ours (e.g. swap in failure)
-+ * and so needs to be reported.
-+ */
-+ if (!i915_terminally_wedged(&dev_priv->gpu_error)) {
- ret = VM_FAULT_SIGBUS;
- break;
- }
-diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
-index f22041973f3a..08105fddfd2a 100644
---- a/drivers/gpu/drm/i915/intel_bios.c
-+++ b/drivers/gpu/drm/i915/intel_bios.c
-@@ -839,7 +839,7 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
- }
- }
-
--static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id)
-+static int intel_no_opregion_vbt_callback(const struct dmi_system_id *id)
- {
- DRM_DEBUG_KMS("Falling back to manually reading VBT from "
- "VBIOS ROM for %s\n",
-diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
-index b19ddacbe19d..834847527982 100644
---- a/drivers/gpu/drm/i915/intel_crt.c
-+++ b/drivers/gpu/drm/i915/intel_crt.c
-@@ -750,7 +750,7 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = {
- .destroy = intel_encoder_destroy,
- };
-
--static int __init intel_no_crt_dmi_callback(const struct dmi_system_id *id)
-+static int intel_no_crt_dmi_callback(const struct dmi_system_id *id)
- {
- DRM_INFO("Skipping CRT initialization for %s\n", id->ident);
- return 1;
-diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
-index eb8f64b5fb85..67c9ff389989 100644
---- a/drivers/gpu/drm/i915/intel_lvds.c
-+++ b/drivers/gpu/drm/i915/intel_lvds.c
-@@ -544,7 +544,7 @@ static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
- .destroy = intel_encoder_destroy,
- };
-
--static int __init intel_no_lvds_dmi_callback(const struct dmi_system_id *id)
-+static int intel_no_lvds_dmi_callback(const struct dmi_system_id *id)
- {
- DRM_INFO("Skipping LVDS initialization for %s\n", id->ident);
- return 1;
-diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
-index 31b36c5ac894..d488fc71ef49 100644
---- a/drivers/gpu/drm/i915/intel_ringbuffer.c
-+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
-@@ -475,6 +475,9 @@ static int init_ring_common(struct intel_ring_buffer *ring)
- }
- }
-
-+ /* Enforce ordering by reading HEAD register back */
-+ I915_READ_HEAD(ring);
-+
- /* Initialize the ring. This must happen _after_ we've cleared the ring
- * registers with the above sequence (the readback of the HEAD registers
- * also enforces ordering), otherwise the hw might lose the new ring
-diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
-index 365c7c47c46c..9c9606c8bb1a 100644
---- a/drivers/gpu/drm/i915/intel_tv.c
-+++ b/drivers/gpu/drm/i915/intel_tv.c
-@@ -854,6 +854,10 @@ intel_enable_tv(struct intel_encoder *encoder)
- struct drm_device *dev = encoder->base.dev;
- struct drm_i915_private *dev_priv = dev->dev_private;
-
-+ /* Prevents vblank waits from timing out in intel_tv_detect_type() */
-+ intel_wait_for_vblank(encoder->base.dev,
-+ to_intel_crtc(encoder->base.crtc)->pipe);
-+
- I915_WRITE(TV_CTL, I915_READ(TV_CTL) | TV_ENC_ENABLE);
- }
-
-diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
-index 471347edc27e..a92fb01459c9 100644
---- a/drivers/gpu/drm/nouveau/nouveau_vga.c
-+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
-@@ -100,7 +100,16 @@ void
- nouveau_vga_fini(struct nouveau_drm *drm)
- {
- struct drm_device *dev = drm->dev;
-+ bool runtime = false;
-+
-+ if (nouveau_runtime_pm == 1)
-+ runtime = true;
-+ if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_is_v1_dsm()))
-+ runtime = true;
-+
- vga_switcheroo_unregister_client(dev->pdev);
-+ if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus())
-+ vga_switcheroo_fini_domain_pm_ops(drm->dev->dev);
- vga_client_register(dev->pdev, NULL, NULL, NULL);
- }
-
-diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
-index 5fa854c84d62..543ba2d4a659 100644
---- a/drivers/gpu/drm/radeon/ci_dpm.c
-+++ b/drivers/gpu/drm/radeon/ci_dpm.c
-@@ -851,6 +851,9 @@ static int ci_set_thermal_temperature_range(struct radeon_device *rdev,
- WREG32_SMC(CG_THERMAL_CTRL, tmp);
- #endif
-
-+ rdev->pm.dpm.thermal.min_temp = low_temp;
-+ rdev->pm.dpm.thermal.max_temp = high_temp;
-+
- return 0;
- }
-
-@@ -922,7 +925,18 @@ static void ci_get_leakage_voltages(struct radeon_device *rdev)
- pi->vddc_leakage.count = 0;
- pi->vddci_leakage.count = 0;
-
-- if (radeon_atom_get_leakage_id_from_vbios(rdev, &leakage_id) == 0) {
-+ if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_EVV) {
-+ for (i = 0; i < CISLANDS_MAX_LEAKAGE_COUNT; i++) {
-+ virtual_voltage_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
-+ if (radeon_atom_get_voltage_evv(rdev, virtual_voltage_id, &vddc) != 0)
-+ continue;
-+ if (vddc != 0 && vddc != virtual_voltage_id) {
-+ pi->vddc_leakage.actual_voltage[pi->vddc_leakage.count] = vddc;
-+ pi->vddc_leakage.leakage_id[pi->vddc_leakage.count] = virtual_voltage_id;
-+ pi->vddc_leakage.count++;
-+ }
-+ }
-+ } else if (radeon_atom_get_leakage_id_from_vbios(rdev, &leakage_id) == 0) {
- for (i = 0; i < CISLANDS_MAX_LEAKAGE_COUNT; i++) {
- virtual_voltage_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
- if (radeon_atom_get_leakage_vddc_based_on_leakage_params(rdev, &vddc, &vddci,
-diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
-index 7b3537c55c77..ab5c26575622 100644
---- a/drivers/gpu/drm/radeon/cik.c
-+++ b/drivers/gpu/drm/radeon/cik.c
-@@ -4392,7 +4392,7 @@ struct bonaire_mqd
- */
- static int cik_cp_compute_resume(struct radeon_device *rdev)
- {
-- int r, i, idx;
-+ int r, i, j, idx;
- u32 tmp;
- bool use_doorbell = true;
- u64 hqd_gpu_addr;
-@@ -4511,7 +4511,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
- mqd->queue_state.cp_hqd_pq_wptr= 0;
- if (RREG32(CP_HQD_ACTIVE) & 1) {
- WREG32(CP_HQD_DEQUEUE_REQUEST, 1);
-- for (i = 0; i < rdev->usec_timeout; i++) {
-+ for (j = 0; j < rdev->usec_timeout; j++) {
- if (!(RREG32(CP_HQD_ACTIVE) & 1))
- break;
- udelay(1);
-@@ -5545,12 +5545,13 @@ static void cik_vm_decode_fault(struct radeon_device *rdev,
- void cik_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
- {
- struct radeon_ring *ring = &rdev->ring[ridx];
-+ int usepfp = (ridx == RADEON_RING_TYPE_GFX_INDEX);
-
- if (vm == NULL)
- return;
-
- radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
-- radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
-+ radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) |
- WRITE_DATA_DST_SEL(0)));
- if (vm->id < 8) {
- radeon_ring_write(ring,
-@@ -5600,7 +5601,7 @@ void cik_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
- radeon_ring_write(ring, 1 << vm->id);
-
- /* compute doesn't have PFP */
-- if (ridx == RADEON_RING_TYPE_GFX_INDEX) {
-+ if (usepfp) {
- /* sync PFP to ME, otherwise we might get invalid PFP reads */
- radeon_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
- radeon_ring_write(ring, 0x0);
-diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c
-index aac8f487e6df..66ba713ba7d7 100644
---- a/drivers/gpu/drm/radeon/cik_sdma.c
-+++ b/drivers/gpu/drm/radeon/cik_sdma.c
-@@ -461,13 +461,6 @@ int cik_sdma_resume(struct radeon_device *rdev)
- {
- int r;
-
-- /* Reset dma */
-- WREG32(SRBM_SOFT_RESET, SOFT_RESET_SDMA | SOFT_RESET_SDMA1);
-- RREG32(SRBM_SOFT_RESET);
-- udelay(50);
-- WREG32(SRBM_SOFT_RESET, 0);
-- RREG32(SRBM_SOFT_RESET);
--
- r = cik_sdma_load_microcode(rdev);
- if (r)
- return r;
-diff --git a/drivers/gpu/drm/radeon/ni_dma.c b/drivers/gpu/drm/radeon/ni_dma.c
-index 7cf96b15377f..94fa49e974eb 100644
---- a/drivers/gpu/drm/radeon/ni_dma.c
-+++ b/drivers/gpu/drm/radeon/ni_dma.c
-@@ -191,12 +191,6 @@ int cayman_dma_resume(struct radeon_device *rdev)
- u32 reg_offset, wb_offset;
- int i, r;
-
-- /* Reset dma */
-- WREG32(SRBM_SOFT_RESET, SOFT_RESET_DMA | SOFT_RESET_DMA1);
-- RREG32(SRBM_SOFT_RESET);
-- udelay(50);
-- WREG32(SRBM_SOFT_RESET, 0);
--
- for (i = 0; i < 2; i++) {
- if (i == 0) {
- ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX];
-diff --git a/drivers/gpu/drm/radeon/r600_dma.c b/drivers/gpu/drm/radeon/r600_dma.c
-index b2d4c91e6272..99495513f6b1 100644
---- a/drivers/gpu/drm/radeon/r600_dma.c
-+++ b/drivers/gpu/drm/radeon/r600_dma.c
-@@ -124,15 +124,6 @@ int r600_dma_resume(struct radeon_device *rdev)
- u32 rb_bufsz;
- int r;
-
-- /* Reset dma */
-- if (rdev->family >= CHIP_RV770)
-- WREG32(SRBM_SOFT_RESET, RV770_SOFT_RESET_DMA);
-- else
-- WREG32(SRBM_SOFT_RESET, SOFT_RESET_DMA);
-- RREG32(SRBM_SOFT_RESET);
-- udelay(50);
-- WREG32(SRBM_SOFT_RESET, 0);
--
- WREG32(DMA_SEM_INCOMPLETE_TIMER_CNTL, 0);
- WREG32(DMA_SEM_WAIT_FAIL_TIMER_CNTL, 0);
-
-diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
-index 08e86f90c9a4..b837e9f9f8ce 100644
---- a/drivers/gpu/drm/radeon/radeon.h
-+++ b/drivers/gpu/drm/radeon/radeon.h
-@@ -294,6 +294,9 @@ int radeon_atom_get_leakage_vddc_based_on_leakage_params(struct radeon_device *r
- u16 *vddc, u16 *vddci,
- u16 virtual_voltage_id,
- u16 vbios_voltage_id);
-+int radeon_atom_get_voltage_evv(struct radeon_device *rdev,
-+ u16 virtual_voltage_id,
-+ u16 *voltage);
- int radeon_atom_round_to_true_voltage(struct radeon_device *rdev,
- u8 voltage_type,
- u16 nominal_voltage,
-diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
-index 30844814c25a..e2de749327ad 100644
---- a/drivers/gpu/drm/radeon/radeon_atombios.c
-+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
-@@ -447,6 +447,13 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
- }
- }
-
-+ /* Fujitsu D3003-S2 board lists DVI-I as DVI-I and VGA */
-+ if ((dev->pdev->device == 0x9805) &&
-+ (dev->pdev->subsystem_vendor == 0x1734) &&
-+ (dev->pdev->subsystem_device == 0x11bd)) {
-+ if (*connector_type == DRM_MODE_CONNECTOR_VGA)
-+ return false;
-+ }
-
- return true;
- }
-@@ -1955,7 +1962,7 @@ static const char *thermal_controller_names[] = {
- "adm1032",
- "adm1030",
- "max6649",
-- "lm64",
-+ "lm63", /* lm64 */
- "f75375",
- "asc7xxx",
- };
-@@ -1966,7 +1973,7 @@ static const char *pp_lib_thermal_controller_names[] = {
- "adm1032",
- "adm1030",
- "max6649",
-- "lm64",
-+ "lm63", /* lm64 */
- "f75375",
- "RV6xx",
- "RV770",
-@@ -2273,19 +2280,31 @@ static void radeon_atombios_add_pplib_thermal_controller(struct radeon_device *r
- (controller->ucFanParameters &
- ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
- rdev->pm.int_thermal_type = THERMAL_TYPE_KV;
-- } else if ((controller->ucType ==
-- ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) ||
-- (controller->ucType ==
-- ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL) ||
-- (controller->ucType ==
-- ATOM_PP_THERMALCONTROLLER_EMC2103_WITH_INTERNAL)) {
-- DRM_INFO("Special thermal controller config\n");
-+ } else if (controller->ucType ==
-+ ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) {
-+ DRM_INFO("External GPIO thermal controller %s fan control\n",
-+ (controller->ucFanParameters &
-+ ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
-+ rdev->pm.int_thermal_type = THERMAL_TYPE_EXTERNAL_GPIO;
-+ } else if (controller->ucType ==
-+ ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL) {
-+ DRM_INFO("ADT7473 with internal thermal controller %s fan control\n",
-+ (controller->ucFanParameters &
-+ ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
-+ rdev->pm.int_thermal_type = THERMAL_TYPE_ADT7473_WITH_INTERNAL;
-+ } else if (controller->ucType ==
-+ ATOM_PP_THERMALCONTROLLER_EMC2103_WITH_INTERNAL) {
-+ DRM_INFO("EMC2103 with internal thermal controller %s fan control\n",
-+ (controller->ucFanParameters &
-+ ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
-+ rdev->pm.int_thermal_type = THERMAL_TYPE_EMC2103_WITH_INTERNAL;
- } else if (controller->ucType < ARRAY_SIZE(pp_lib_thermal_controller_names)) {
- DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n",
- pp_lib_thermal_controller_names[controller->ucType],
- controller->ucI2cAddress >> 1,
- (controller->ucFanParameters &
- ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
-+ rdev->pm.int_thermal_type = THERMAL_TYPE_EXTERNAL;
- i2c_bus = radeon_lookup_i2c_gpio(rdev, controller->ucI2cLine);
- rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
- if (rdev->pm.i2c_bus) {
-@@ -3228,6 +3247,41 @@ int radeon_atom_get_leakage_vddc_based_on_leakage_params(struct radeon_device *r
- return 0;
- }
-
-+union get_voltage_info {
-+ struct _GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 in;
-+ struct _GET_EVV_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_2 evv_out;
-+};
-+
-+int radeon_atom_get_voltage_evv(struct radeon_device *rdev,
-+ u16 virtual_voltage_id,
-+ u16 *voltage)
-+{
-+ int index = GetIndexIntoMasterTable(COMMAND, GetVoltageInfo);
-+ u32 entry_id;
-+ u32 count = rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count;
-+ union get_voltage_info args;
-+
-+ for (entry_id = 0; entry_id < count; entry_id++) {
-+ if (rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[entry_id].v ==
-+ virtual_voltage_id)
-+ break;
-+ }
-+
-+ if (entry_id >= count)
-+ return -EINVAL;
-+
-+ args.in.ucVoltageType = VOLTAGE_TYPE_VDDC;
-+ args.in.ucVoltageMode = ATOM_GET_VOLTAGE_EVV_VOLTAGE;
-+ args.in.ulSCLKFreq =
-+ cpu_to_le32(rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[entry_id].clk);
-+
-+ atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
-+
-+ *voltage = le16_to_cpu(args.evv_out.usVoltageLevel);
-+
-+ return 0;
-+}
-+
- int radeon_atom_get_voltage_gpio_settings(struct radeon_device *rdev,
- u16 voltage_level, u8 voltage_type,
- u32 *gpio_value, u32 *gpio_mask)
-diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
-index 0bf6f4a2bb97..e39026cc7d07 100644
---- a/drivers/gpu/drm/radeon/radeon_device.c
-+++ b/drivers/gpu/drm/radeon/radeon_device.c
-@@ -1314,7 +1314,7 @@ int radeon_device_init(struct radeon_device *rdev,
-
- r = radeon_init(rdev);
- if (r)
-- return r;
-+ goto failed;
-
- r = radeon_ib_ring_tests(rdev);
- if (r)
-@@ -1334,7 +1334,7 @@ int radeon_device_init(struct radeon_device *rdev,
- radeon_agp_disable(rdev);
- r = radeon_init(rdev);
- if (r)
-- return r;
-+ goto failed;
- }
-
- if ((radeon_testing & 1)) {
-@@ -1356,6 +1356,11 @@ int radeon_device_init(struct radeon_device *rdev,
- DRM_INFO("radeon: acceleration disabled, skipping benchmarks\n");
- }
- return 0;
-+
-+failed:
-+ if (runtime)
-+ vga_switcheroo_fini_domain_pm_ops(rdev->dev);
-+ return r;
- }
-
- static void radeon_debugfs_remove_files(struct radeon_device *rdev);
-@@ -1376,6 +1381,8 @@ void radeon_device_fini(struct radeon_device *rdev)
- radeon_bo_evict_vram(rdev);
- radeon_fini(rdev);
- vga_switcheroo_unregister_client(rdev->pdev);
-+ if (rdev->flags & RADEON_IS_PX)
-+ vga_switcheroo_fini_domain_pm_ops(rdev->dev);
- vga_client_register(rdev->pdev, NULL, NULL, NULL);
- if (rdev->rio_mem)
- pci_iounmap(rdev->pdev, rdev->rio_mem);
-@@ -1600,7 +1607,6 @@ int radeon_gpu_reset(struct radeon_device *rdev)
- radeon_save_bios_scratch_regs(rdev);
- /* block TTM */
- resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
-- radeon_pm_suspend(rdev);
- radeon_suspend(rdev);
-
- for (i = 0; i < RADEON_NUM_RINGS; ++i) {
-@@ -1646,9 +1652,24 @@ retry:
- }
- }
-
-- radeon_pm_resume(rdev);
-+ if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) {
-+ /* do dpm late init */
-+ r = radeon_pm_late_init(rdev);
-+ if (r) {
-+ rdev->pm.dpm_enabled = false;
-+ DRM_ERROR("radeon_pm_late_init failed, disabling dpm\n");
-+ }
-+ } else {
-+ /* resume old pm late */
-+ radeon_pm_resume(rdev);
-+ }
-+
- drm_helper_resume_force_mode(rdev->ddev);
-
-+ /* set the power state here in case we are a PX system or headless */
-+ if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled)
-+ radeon_pm_compute_clocks(rdev);
-+
- ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched);
- if (r) {
- /* bad news, how to tell it to userspace ? */
-diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
-index ea34a31d3bc8..0bc9106ef435 100644
---- a/drivers/gpu/drm/radeon/radeon_kms.c
-+++ b/drivers/gpu/drm/radeon/radeon_kms.c
-@@ -254,7 +254,14 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
- }
- break;
- case RADEON_INFO_ACCEL_WORKING2:
-- *value = rdev->accel_working;
-+ if (rdev->family == CHIP_HAWAII) {
-+ if (rdev->accel_working)
-+ *value = 2;
-+ else
-+ *value = 0;
-+ } else {
-+ *value = rdev->accel_working;
-+ }
- break;
- case RADEON_INFO_TILING_CONFIG:
- if (rdev->family >= CHIP_BONAIRE)
-diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
-index f77d9d0d54b5..cfb513f933d5 100644
---- a/drivers/gpu/drm/radeon/radeon_pm.c
-+++ b/drivers/gpu/drm/radeon/radeon_pm.c
-@@ -458,10 +458,6 @@ static ssize_t radeon_get_dpm_state(struct device *dev,
- struct radeon_device *rdev = ddev->dev_private;
- enum radeon_pm_state_type pm = rdev->pm.dpm.user_state;
-
-- if ((rdev->flags & RADEON_IS_PX) &&
-- (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
-- return snprintf(buf, PAGE_SIZE, "off\n");
--
- return snprintf(buf, PAGE_SIZE, "%s\n",
- (pm == POWER_STATE_TYPE_BATTERY) ? "battery" :
- (pm == POWER_STATE_TYPE_BALANCED) ? "balanced" : "performance");
-@@ -475,11 +471,6 @@ static ssize_t radeon_set_dpm_state(struct device *dev,
- struct drm_device *ddev = dev_get_drvdata(dev);
- struct radeon_device *rdev = ddev->dev_private;
-
-- /* Can't set dpm state when the card is off */
-- if ((rdev->flags & RADEON_IS_PX) &&
-- (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
-- return -EINVAL;
--
- mutex_lock(&rdev->pm.mutex);
- if (strncmp("battery", buf, strlen("battery")) == 0)
- rdev->pm.dpm.user_state = POWER_STATE_TYPE_BATTERY;
-@@ -493,7 +484,12 @@ static ssize_t radeon_set_dpm_state(struct device *dev,
- goto fail;
- }
- mutex_unlock(&rdev->pm.mutex);
-- radeon_pm_compute_clocks(rdev);
-+
-+ /* Can't set dpm state when the card is off */
-+ if (!(rdev->flags & RADEON_IS_PX) ||
-+ (ddev->switch_power_state == DRM_SWITCH_POWER_ON))
-+ radeon_pm_compute_clocks(rdev);
-+
- fail:
- return count;
- }
-@@ -1276,10 +1272,6 @@ int radeon_pm_init(struct radeon_device *rdev)
- case CHIP_RS780:
- case CHIP_RS880:
- case CHIP_RV770:
-- case CHIP_BARTS:
-- case CHIP_TURKS:
-- case CHIP_CAICOS:
-- case CHIP_CAYMAN:
- /* DPM requires the RLC, RV770+ dGPU requires SMC */
- if (!rdev->rlc_fw)
- rdev->pm.pm_method = PM_METHOD_PROFILE;
-@@ -1303,6 +1295,10 @@ int radeon_pm_init(struct radeon_device *rdev)
- case CHIP_PALM:
- case CHIP_SUMO:
- case CHIP_SUMO2:
-+ case CHIP_BARTS:
-+ case CHIP_TURKS:
-+ case CHIP_CAICOS:
-+ case CHIP_CAYMAN:
- case CHIP_ARUBA:
- case CHIP_TAHITI:
- case CHIP_PITCAIRN:
-diff --git a/drivers/gpu/drm/radeon/radeon_semaphore.c b/drivers/gpu/drm/radeon/radeon_semaphore.c
-index 9006b32d5eed..eb7b60047e86 100644
---- a/drivers/gpu/drm/radeon/radeon_semaphore.c
-+++ b/drivers/gpu/drm/radeon/radeon_semaphore.c
-@@ -34,7 +34,7 @@
- int radeon_semaphore_create(struct radeon_device *rdev,
- struct radeon_semaphore **semaphore)
- {
-- uint32_t *cpu_addr;
-+ uint64_t *cpu_addr;
- int i, r;
-
- *semaphore = kmalloc(sizeof(struct radeon_semaphore), GFP_KERNEL);
-diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
-index ea93393374df..559564c1dc97 100644
---- a/drivers/gpu/drm/radeon/si.c
-+++ b/drivers/gpu/drm/radeon/si.c
-@@ -4810,7 +4810,7 @@ void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
-
- /* write new base address */
- radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
-- radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
-+ radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
- WRITE_DATA_DST_SEL(0)));
-
- if (vm->id < 8) {
-diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c
-index 2da0e17eb960..d9cfa09b2e3f 100644
---- a/drivers/gpu/drm/radeon/trinity_dpm.c
-+++ b/drivers/gpu/drm/radeon/trinity_dpm.c
-@@ -1877,7 +1877,16 @@ int trinity_dpm_init(struct radeon_device *rdev)
- for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++)
- pi->at[i] = TRINITY_AT_DFLT;
-
-- pi->enable_bapm = false;
-+ /* There are stability issues reported on with
-+ * bapm enabled when switching between AC and battery
-+ * power. At the same time, some MSI boards hang
-+ * if it's not enabled and dpm is enabled. Just enable
-+ * it for MSI boards right now.
-+ */
-+ if (rdev->pdev->subsystem_vendor == 0x1462)
-+ pi->enable_bapm = true;
-+ else
-+ pi->enable_bapm = false;
- pi->enable_nbps_policy = true;
- pi->enable_sclk_ds = true;
- pi->enable_gfx_power_gating = true;
-diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
-index 171a8203892c..0644429f8559 100644
---- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
-+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
-@@ -122,6 +122,7 @@ static int tilcdc_unload(struct drm_device *dev)
- struct tilcdc_drm_private *priv = dev->dev_private;
- struct tilcdc_module *mod, *cur;
-
-+ drm_fbdev_cma_fini(priv->fbdev);
- drm_kms_helper_poll_fini(dev);
- drm_mode_config_cleanup(dev);
- drm_vblank_cleanup(dev);
-@@ -628,10 +629,10 @@ static int __init tilcdc_drm_init(void)
- static void __exit tilcdc_drm_fini(void)
- {
- DBG("fini");
-- tilcdc_tfp410_fini();
-- tilcdc_slave_fini();
-- tilcdc_panel_fini();
- platform_driver_unregister(&tilcdc_platform_driver);
-+ tilcdc_panel_fini();
-+ tilcdc_slave_fini();
-+ tilcdc_tfp410_fini();
- }
-
- late_initcall(tilcdc_drm_init);
-diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
-index 86c67329b605..b085dcc54fb5 100644
---- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
-+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
-@@ -151,6 +151,7 @@ struct panel_connector {
- static void panel_connector_destroy(struct drm_connector *connector)
- {
- struct panel_connector *panel_connector = to_panel_connector(connector);
-+ drm_sysfs_connector_remove(connector);
- drm_connector_cleanup(connector);
- kfree(panel_connector);
- }
-@@ -285,10 +286,8 @@ static void panel_destroy(struct tilcdc_module *mod)
- {
- struct panel_module *panel_mod = to_panel_module(mod);
-
-- if (panel_mod->timings) {
-+ if (panel_mod->timings)
- display_timings_release(panel_mod->timings);
-- kfree(panel_mod->timings);
-- }
-
- tilcdc_module_cleanup(mod);
- kfree(panel_mod->info);
-diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave.c b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
-index 595068ba2d5e..2f83ffb7f37e 100644
---- a/drivers/gpu/drm/tilcdc/tilcdc_slave.c
-+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
-@@ -166,6 +166,7 @@ struct slave_connector {
- static void slave_connector_destroy(struct drm_connector *connector)
- {
- struct slave_connector *slave_connector = to_slave_connector(connector);
-+ drm_sysfs_connector_remove(connector);
- drm_connector_cleanup(connector);
- kfree(slave_connector);
- }
-diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
-index c38b56b268ac..ce75ac8de4f8 100644
---- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
-+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
-@@ -167,6 +167,7 @@ struct tfp410_connector {
- static void tfp410_connector_destroy(struct drm_connector *connector)
- {
- struct tfp410_connector *tfp410_connector = to_tfp410_connector(connector);
-+ drm_sysfs_connector_remove(connector);
- drm_connector_cleanup(connector);
- kfree(tfp410_connector);
- }
-diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
-index 863bef9f9234..cf4bad2c1d59 100644
---- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
-+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
-@@ -297,8 +297,10 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
- *
- * @pool: to free the pages from
- * @free_all: If set to true will free all pages in pool
-+ * @gfp: GFP flags.
- **/
--static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free)
-+static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
-+ gfp_t gfp)
- {
- unsigned long irq_flags;
- struct page *p;
-@@ -309,8 +311,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free)
- if (NUM_PAGES_TO_ALLOC < nr_free)
- npages_to_free = NUM_PAGES_TO_ALLOC;
-
-- pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
-- GFP_KERNEL);
-+ pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), gfp);
- if (!pages_to_free) {
- pr_err("Failed to allocate memory for pool free operation\n");
- return 0;
-@@ -382,32 +383,35 @@ out:
- *
- * XXX: (dchinner) Deadlock warning!
- *
-- * ttm_page_pool_free() does memory allocation using GFP_KERNEL. that means
-- * this can deadlock when called a sc->gfp_mask that is not equal to
-- * GFP_KERNEL.
-+ * We need to pass sc->gfp_mask to ttm_page_pool_free().
- *
- * This code is crying out for a shrinker per pool....
- */
- static unsigned long
- ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
- {
-- static atomic_t start_pool = ATOMIC_INIT(0);
-+ static DEFINE_MUTEX(lock);
-+ static unsigned start_pool;
- unsigned i;
-- unsigned pool_offset = atomic_add_return(1, &start_pool);
-+ unsigned pool_offset;
- struct ttm_page_pool *pool;
- int shrink_pages = sc->nr_to_scan;
- unsigned long freed = 0;
-
-- pool_offset = pool_offset % NUM_POOLS;
-+ if (!mutex_trylock(&lock))
-+ return SHRINK_STOP;
-+ pool_offset = ++start_pool % NUM_POOLS;
- /* select start pool in round robin fashion */
- for (i = 0; i < NUM_POOLS; ++i) {
- unsigned nr_free = shrink_pages;
- if (shrink_pages == 0)
- break;
- pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
-- shrink_pages = ttm_page_pool_free(pool, nr_free);
-+ shrink_pages = ttm_page_pool_free(pool, nr_free,
-+ sc->gfp_mask);
- freed += nr_free - shrink_pages;
- }
-+ mutex_unlock(&lock);
- return freed;
- }
-
-@@ -706,7 +710,7 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
- }
- spin_unlock_irqrestore(&pool->lock, irq_flags);
- if (npages)
-- ttm_page_pool_free(pool, npages);
-+ ttm_page_pool_free(pool, npages, GFP_KERNEL);
- }
-
- /*
-@@ -846,7 +850,8 @@ void ttm_page_alloc_fini(void)
- ttm_pool_mm_shrink_fini(_manager);
-
- for (i = 0; i < NUM_POOLS; ++i)
-- ttm_page_pool_free(&_manager->pools[i], FREE_ALL_PAGES);
-+ ttm_page_pool_free(&_manager->pools[i], FREE_ALL_PAGES,
-+ GFP_KERNEL);
-
- kobject_put(&_manager->kobj);
- _manager = NULL;
-diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
-index fb8259f69839..ca65df144765 100644
---- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
-+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
-@@ -411,8 +411,10 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
- *
- * @pool: to free the pages from
- * @nr_free: If set to true will free all pages in pool
-+ * @gfp: GFP flags.
- **/
--static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free)
-+static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
-+ gfp_t gfp)
- {
- unsigned long irq_flags;
- struct dma_page *dma_p, *tmp;
-@@ -430,8 +432,7 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free)
- npages_to_free, nr_free);
- }
- #endif
-- pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
-- GFP_KERNEL);
-+ pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), gfp);
-
- if (!pages_to_free) {
- pr_err("%s: Failed to allocate memory for pool free operation\n",
-@@ -530,7 +531,7 @@ static void ttm_dma_free_pool(struct device *dev, enum pool_type type)
- if (pool->type != type)
- continue;
- /* Takes a spinlock.. */
-- ttm_dma_page_pool_free(pool, FREE_ALL_PAGES);
-+ ttm_dma_page_pool_free(pool, FREE_ALL_PAGES, GFP_KERNEL);
- WARN_ON(((pool->npages_in_use + pool->npages_free) != 0));
- /* This code path is called after _all_ references to the
- * struct device has been dropped - so nobody should be
-@@ -983,7 +984,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
-
- /* shrink pool if necessary (only on !is_cached pools)*/
- if (npages)
-- ttm_dma_page_pool_free(pool, npages);
-+ ttm_dma_page_pool_free(pool, npages, GFP_KERNEL);
- ttm->state = tt_unpopulated;
- }
- EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
-@@ -993,10 +994,7 @@ EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
- *
- * XXX: (dchinner) Deadlock warning!
- *
-- * ttm_dma_page_pool_free() does GFP_KERNEL memory allocation, and so attention
-- * needs to be paid to sc->gfp_mask to determine if this can be done or not.
-- * GFP_KERNEL memory allocation in a GFP_ATOMIC reclaim context woul dbe really
-- * bad.
-+ * We need to pass sc->gfp_mask to ttm_dma_page_pool_free().
- *
- * I'm getting sadder as I hear more pathetical whimpers about needing per-pool
- * shrinkers
-@@ -1004,9 +1002,9 @@ EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
- static unsigned long
- ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
- {
-- static atomic_t start_pool = ATOMIC_INIT(0);
-+ static unsigned start_pool;
- unsigned idx = 0;
-- unsigned pool_offset = atomic_add_return(1, &start_pool);
-+ unsigned pool_offset;
- unsigned shrink_pages = sc->nr_to_scan;
- struct device_pools *p;
- unsigned long freed = 0;
-@@ -1014,8 +1012,11 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
- if (list_empty(&_manager->pools))
- return SHRINK_STOP;
-
-- mutex_lock(&_manager->lock);
-- pool_offset = pool_offset % _manager->npools;
-+ if (!mutex_trylock(&_manager->lock))
-+ return SHRINK_STOP;
-+ if (!_manager->npools)
-+ goto out;
-+ pool_offset = ++start_pool % _manager->npools;
- list_for_each_entry(p, &_manager->pools, pools) {
- unsigned nr_free;
-
-@@ -1027,13 +1028,15 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
- if (++idx < pool_offset)
- continue;
- nr_free = shrink_pages;
-- shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free);
-+ shrink_pages = ttm_dma_page_pool_free(p->pool, nr_free,
-+ sc->gfp_mask);
- freed += nr_free - shrink_pages;
-
- pr_debug("%s: (%s:%d) Asked to shrink %d, have %d more to go\n",
- p->pool->dev_name, p->pool->name, current->pid,
- nr_free, shrink_pages);
- }
-+out:
- mutex_unlock(&_manager->lock);
- return freed;
- }
-@@ -1044,7 +1047,8 @@ ttm_dma_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
- struct device_pools *p;
- unsigned long count = 0;
-
-- mutex_lock(&_manager->lock);
-+ if (!mutex_trylock(&_manager->lock))
-+ return 0;
- list_for_each_entry(p, &_manager->pools, pools)
- count += p->pool->npages_free;
- mutex_unlock(&_manager->lock);
-diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
-index 6ccd993e26bf..6eae14d2a3f7 100644
---- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
-+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
-@@ -180,8 +180,9 @@ void vmw_fifo_release(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
-
- mutex_lock(&dev_priv->hw_mutex);
-
-+ vmw_write(dev_priv, SVGA_REG_SYNC, SVGA_SYNC_GENERIC);
- while (vmw_read(dev_priv, SVGA_REG_BUSY) != 0)
-- vmw_write(dev_priv, SVGA_REG_SYNC, SVGA_SYNC_GENERIC);
-+ ;
-
- dev_priv->last_read_seqno = ioread32(fifo_mem + SVGA_FIFO_FENCE);
-
-diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
-index 6866448083b2..37ac7b5dbd06 100644
---- a/drivers/gpu/vga/vga_switcheroo.c
-+++ b/drivers/gpu/vga/vga_switcheroo.c
-@@ -660,6 +660,12 @@ int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *
- }
- EXPORT_SYMBOL(vga_switcheroo_init_domain_pm_ops);
-
-+void vga_switcheroo_fini_domain_pm_ops(struct device *dev)
-+{
-+ dev->pm_domain = NULL;
-+}
-+EXPORT_SYMBOL(vga_switcheroo_fini_domain_pm_ops);
-+
- static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
- {
- struct pci_dev *pdev = to_pci_dev(dev);
-diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
-index 0b14d3261531..5da115a6fd22 100644
---- a/drivers/hid/hid-logitech-dj.c
-+++ b/drivers/hid/hid-logitech-dj.c
-@@ -687,7 +687,6 @@ static int logi_dj_raw_event(struct hid_device *hdev,
- struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
- struct dj_report *dj_report = (struct dj_report *) data;
- unsigned long flags;
-- bool report_processed = false;
-
- dbg_hid("%s, size:%d\n", __func__, size);
-
-@@ -714,34 +713,42 @@ static int logi_dj_raw_event(struct hid_device *hdev,
- * device (via hid_input_report() ) and return 1 so hid-core does not do
- * anything else with it.
- */
-+
-+ /* case 1) */
-+ if (data[0] != REPORT_ID_DJ_SHORT)
-+ return false;
-+
- if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
- (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
-- dev_err(&hdev->dev, "%s: invalid device index:%d\n",
-+ /*
-+ * Device index is wrong, bail out.
-+ * This driver can ignore safely the receiver notifications,
-+ * so ignore those reports too.
-+ */
-+ if (dj_report->device_index != DJ_RECEIVER_INDEX)
-+ dev_err(&hdev->dev, "%s: invalid device index:%d\n",
- __func__, dj_report->device_index);
- return false;
- }
-
- spin_lock_irqsave(&djrcv_dev->lock, flags);
-- if (dj_report->report_id == REPORT_ID_DJ_SHORT) {
-- switch (dj_report->report_type) {
-- case REPORT_TYPE_NOTIF_DEVICE_PAIRED:
-- case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED:
-- logi_dj_recv_queue_notification(djrcv_dev, dj_report);
-- break;
-- case REPORT_TYPE_NOTIF_CONNECTION_STATUS:
-- if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] ==
-- STATUS_LINKLOSS) {
-- logi_dj_recv_forward_null_report(djrcv_dev, dj_report);
-- }
-- break;
-- default:
-- logi_dj_recv_forward_report(djrcv_dev, dj_report);
-+ switch (dj_report->report_type) {
-+ case REPORT_TYPE_NOTIF_DEVICE_PAIRED:
-+ case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED:
-+ logi_dj_recv_queue_notification(djrcv_dev, dj_report);
-+ break;
-+ case REPORT_TYPE_NOTIF_CONNECTION_STATUS:
-+ if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] ==
-+ STATUS_LINKLOSS) {
-+ logi_dj_recv_forward_null_report(djrcv_dev, dj_report);
- }
-- report_processed = true;
-+ break;
-+ default:
-+ logi_dj_recv_forward_report(djrcv_dev, dj_report);
- }
- spin_unlock_irqrestore(&djrcv_dev->lock, flags);
-
-- return report_processed;
-+ return true;
- }
-
- static int logi_dj_probe(struct hid_device *hdev,
-diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h
-index 4a4000340ce1..daeb0aa4bee9 100644
---- a/drivers/hid/hid-logitech-dj.h
-+++ b/drivers/hid/hid-logitech-dj.h
-@@ -27,6 +27,7 @@
-
- #define DJ_MAX_PAIRED_DEVICES 6
- #define DJ_MAX_NUMBER_NOTIFICATIONS 8
-+#define DJ_RECEIVER_INDEX 0
- #define DJ_DEVICE_INDEX_MIN 1
- #define DJ_DEVICE_INDEX_MAX 6
-
-diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
-index 3b43d1cfa936..991ba79cfc72 100644
---- a/drivers/hid/hid-magicmouse.c
-+++ b/drivers/hid/hid-magicmouse.c
-@@ -290,6 +290,11 @@ static int magicmouse_raw_event(struct hid_device *hdev,
- if (size < 4 || ((size - 4) % 9) != 0)
- return 0;
- npoints = (size - 4) / 9;
-+ if (npoints > 15) {
-+ hid_warn(hdev, "invalid size value (%d) for TRACKPAD_REPORT_ID\n",
-+ size);
-+ return 0;
-+ }
- msc->ntouches = 0;
- for (ii = 0; ii < npoints; ii++)
- magicmouse_emit_touch(msc, ii, data + ii * 9 + 4);
-@@ -307,6 +312,11 @@ static int magicmouse_raw_event(struct hid_device *hdev,
- if (size < 6 || ((size - 6) % 8) != 0)
- return 0;
- npoints = (size - 6) / 8;
-+ if (npoints > 15) {
-+ hid_warn(hdev, "invalid size value (%d) for MOUSE_REPORT_ID\n",
-+ size);
-+ return 0;
-+ }
- msc->ntouches = 0;
- for (ii = 0; ii < npoints; ii++)
- magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);
-diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
-index acbb021065ec..020df3c2e8b4 100644
---- a/drivers/hid/hid-picolcd_core.c
-+++ b/drivers/hid/hid-picolcd_core.c
-@@ -350,6 +350,12 @@ static int picolcd_raw_event(struct hid_device *hdev,
- if (!data)
- return 1;
-
-+ if (size > 64) {
-+ hid_warn(hdev, "invalid size value (%d) for picolcd raw event\n",
-+ size);
-+ return 0;
-+ }
-+
- if (report->id == REPORT_KEY_STATE) {
- if (data->input_keys)
- ret = picolcd_raw_keypad(data, report, raw_data+1, size-1);
-diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
-index fc6f5d54e7f7..8890870309e4 100644
---- a/drivers/hwmon/ds1621.c
-+++ b/drivers/hwmon/ds1621.c
-@@ -309,6 +309,7 @@ static ssize_t set_convrate(struct device *dev, struct device_attribute *da,
- data->conf |= (resol << DS1621_REG_CONFIG_RESOL_SHIFT);
- i2c_smbus_write_byte_data(client, DS1621_REG_CONF, data->conf);
- data->update_interval = ds1721_convrates[resol];
-+ data->zbits = 7 - resol;
- mutex_unlock(&data->update_lock);
-
- return count;
-diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
-index c56be739006b..11e9c7f9bf9b 100644
---- a/drivers/i2c/busses/i2c-at91.c
-+++ b/drivers/i2c/busses/i2c-at91.c
-@@ -101,6 +101,7 @@ struct at91_twi_dev {
- unsigned twi_cwgr_reg;
- struct at91_twi_pdata *pdata;
- bool use_dma;
-+ bool recv_len_abort;
- struct at91_twi_dma dma;
- };
-
-@@ -267,12 +268,24 @@ static void at91_twi_read_next_byte(struct at91_twi_dev *dev)
- *dev->buf = at91_twi_read(dev, AT91_TWI_RHR) & 0xff;
- --dev->buf_len;
-
-+ /* return if aborting, we only needed to read RHR to clear RXRDY*/
-+ if (dev->recv_len_abort)
-+ return;
-+
- /* handle I2C_SMBUS_BLOCK_DATA */
- if (unlikely(dev->msg->flags & I2C_M_RECV_LEN)) {
-- dev->msg->flags &= ~I2C_M_RECV_LEN;
-- dev->buf_len += *dev->buf;
-- dev->msg->len = dev->buf_len + 1;
-- dev_dbg(dev->dev, "received block length %d\n", dev->buf_len);
-+ /* ensure length byte is a valid value */
-+ if (*dev->buf <= I2C_SMBUS_BLOCK_MAX && *dev->buf > 0) {
-+ dev->msg->flags &= ~I2C_M_RECV_LEN;
-+ dev->buf_len += *dev->buf;
-+ dev->msg->len = dev->buf_len + 1;
-+ dev_dbg(dev->dev, "received block length %d\n",
-+ dev->buf_len);
-+ } else {
-+ /* abort and send the stop by reading one more byte */
-+ dev->recv_len_abort = true;
-+ dev->buf_len = 1;
-+ }
- }
-
- /* send stop if second but last byte has been read */
-@@ -421,8 +434,8 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
- }
- }
-
-- ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
-- dev->adapter.timeout);
-+ ret = wait_for_completion_io_timeout(&dev->cmd_complete,
-+ dev->adapter.timeout);
- if (ret == 0) {
- dev_err(dev->dev, "controller timed out\n");
- at91_init_twi_bus(dev);
-@@ -444,6 +457,12 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
- ret = -EIO;
- goto error;
- }
-+ if (dev->recv_len_abort) {
-+ dev_err(dev->dev, "invalid smbus block length recvd\n");
-+ ret = -EPROTO;
-+ goto error;
-+ }
-+
- dev_dbg(dev->dev, "transfer complete\n");
-
- return 0;
-@@ -500,6 +519,7 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
- dev->buf_len = m_start->len;
- dev->buf = m_start->buf;
- dev->msg = m_start;
-+ dev->recv_len_abort = false;
-
- ret = at91_do_twi_transfer(dev);
-
-diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
-index 8ce4f517fc56..6e932d140573 100644
---- a/drivers/i2c/busses/i2c-ismt.c
-+++ b/drivers/i2c/busses/i2c-ismt.c
-@@ -497,7 +497,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
- desc->wr_len_cmd = dma_size;
- desc->control |= ISMT_DESC_BLK;
- priv->dma_buffer[0] = command;
-- memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
-+ memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
- } else {
- /* Block Read */
- dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA: READ\n");
-@@ -525,7 +525,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
- desc->wr_len_cmd = dma_size;
- desc->control |= ISMT_DESC_I2C;
- priv->dma_buffer[0] = command;
-- memcpy(&priv->dma_buffer[1], &data->block[1], dma_size);
-+ memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1);
- } else {
- /* i2c Block Read */
- dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: READ\n");
-diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
-index d52d84937ad3..cf891752cc73 100644
---- a/drivers/i2c/busses/i2c-mv64xxx.c
-+++ b/drivers/i2c/busses/i2c-mv64xxx.c
-@@ -748,8 +748,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
- }
- tclk = clk_get_rate(drv_data->clk);
-
-- rc = of_property_read_u32(np, "clock-frequency", &bus_freq);
-- if (rc)
-+ if (of_property_read_u32(np, "clock-frequency", &bus_freq))
- bus_freq = 100000; /* 100kHz by default */
-
- if (!mv64xxx_find_baud_factors(bus_freq, tclk,
-diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
-index fe83d04784c8..6f039c300141 100644
---- a/drivers/iio/accel/bma180.c
-+++ b/drivers/iio/accel/bma180.c
-@@ -571,7 +571,7 @@ static int bma180_probe(struct i2c_client *client,
- trig->ops = &bma180_trigger_ops;
- iio_trigger_set_drvdata(trig, indio_dev);
- data->trig = trig;
-- indio_dev->trig = trig;
-+ indio_dev->trig = iio_trigger_get(trig);
-
- ret = iio_trigger_register(trig);
- if (ret)
-diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
-index 9a4e0e32a771..eb799a43aef0 100644
---- a/drivers/iio/adc/ad_sigma_delta.c
-+++ b/drivers/iio/adc/ad_sigma_delta.c
-@@ -472,7 +472,7 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
- goto error_free_irq;
-
- /* select default trigger */
-- indio_dev->trig = sigma_delta->trig;
-+ indio_dev->trig = iio_trigger_get(sigma_delta->trig);
-
- return 0;
-
-diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
-index 7dcf83998e6f..1be235b01934 100644
---- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
-+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
-@@ -99,7 +99,8 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
- dev_err(&indio_dev->dev, "Trigger Register Failed\n");
- goto error_free_trig;
- }
-- indio_dev->trig = attrb->trigger = trig;
-+ attrb->trigger = trig;
-+ indio_dev->trig = iio_trigger_get(trig);
-
- return ret;
-
-diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
-index 8fc3a97eb266..8d8ca6f1e16a 100644
---- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
-+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
-@@ -49,7 +49,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
- dev_err(&indio_dev->dev, "failed to register iio trigger.\n");
- goto iio_trigger_register_error;
- }
-- indio_dev->trig = sdata->trig;
-+ indio_dev->trig = iio_trigger_get(sdata->trig);
-
- return 0;
-
-diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
-index e3b3c5084070..eef50e91f17c 100644
---- a/drivers/iio/gyro/itg3200_buffer.c
-+++ b/drivers/iio/gyro/itg3200_buffer.c
-@@ -132,7 +132,7 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)
- goto error_free_irq;
-
- /* select default trigger */
-- indio_dev->trig = st->trig;
-+ indio_dev->trig = iio_trigger_get(st->trig);
-
- return 0;
-
-diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
-index 03b9372c1212..926fccea8de0 100644
---- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
-+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
-@@ -135,7 +135,7 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
- ret = iio_trigger_register(st->trig);
- if (ret)
- goto error_free_irq;
-- indio_dev->trig = st->trig;
-+ indio_dev->trig = iio_trigger_get(st->trig);
-
- return 0;
-
-diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
-index 1e8e94d4db7d..4fc88e617acf 100644
---- a/drivers/iio/inkern.c
-+++ b/drivers/iio/inkern.c
-@@ -178,7 +178,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
- index = of_property_match_string(np, "io-channel-names",
- name);
- chan = of_iio_channel_get(np, index);
-- if (!IS_ERR(chan))
-+ if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
- break;
- else if (name && index >= 0) {
- pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
-diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
-index 52bbcfa1e077..476aa132a192 100644
---- a/drivers/iio/magnetometer/st_magn_core.c
-+++ b/drivers/iio/magnetometer/st_magn_core.c
-@@ -42,7 +42,8 @@
- #define ST_MAGN_FS_AVL_5600MG 5600
- #define ST_MAGN_FS_AVL_8000MG 8000
- #define ST_MAGN_FS_AVL_8100MG 8100
--#define ST_MAGN_FS_AVL_10000MG 10000
-+#define ST_MAGN_FS_AVL_12000MG 12000
-+#define ST_MAGN_FS_AVL_16000MG 16000
-
- /* CUSTOM VALUES FOR SENSOR 1 */
- #define ST_MAGN_1_WAI_EXP 0x3c
-@@ -69,20 +70,20 @@
- #define ST_MAGN_1_FS_AVL_4700_VAL 0x05
- #define ST_MAGN_1_FS_AVL_5600_VAL 0x06
- #define ST_MAGN_1_FS_AVL_8100_VAL 0x07
--#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 1100
--#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 855
--#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 670
--#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 450
--#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 400
--#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 330
--#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 230
--#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 980
--#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 760
--#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 600
--#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 400
--#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 355
--#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 295
--#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 205
-+#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 909
-+#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 1169
-+#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 1492
-+#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 2222
-+#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 2500
-+#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 3030
-+#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 4347
-+#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 1020
-+#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 1315
-+#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 1666
-+#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 2500
-+#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 2816
-+#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 3389
-+#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 4878
- #define ST_MAGN_1_MULTIREAD_BIT false
-
- /* CUSTOM VALUES FOR SENSOR 2 */
-@@ -105,10 +106,12 @@
- #define ST_MAGN_2_FS_MASK 0x60
- #define ST_MAGN_2_FS_AVL_4000_VAL 0x00
- #define ST_MAGN_2_FS_AVL_8000_VAL 0x01
--#define ST_MAGN_2_FS_AVL_10000_VAL 0x02
--#define ST_MAGN_2_FS_AVL_4000_GAIN 430
--#define ST_MAGN_2_FS_AVL_8000_GAIN 230
--#define ST_MAGN_2_FS_AVL_10000_GAIN 230
-+#define ST_MAGN_2_FS_AVL_12000_VAL 0x02
-+#define ST_MAGN_2_FS_AVL_16000_VAL 0x03
-+#define ST_MAGN_2_FS_AVL_4000_GAIN 146
-+#define ST_MAGN_2_FS_AVL_8000_GAIN 292
-+#define ST_MAGN_2_FS_AVL_12000_GAIN 438
-+#define ST_MAGN_2_FS_AVL_16000_GAIN 584
- #define ST_MAGN_2_MULTIREAD_BIT false
- #define ST_MAGN_2_OUT_X_L_ADDR 0x28
- #define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
-@@ -266,9 +269,14 @@ static const struct st_sensors st_magn_sensors[] = {
- .gain = ST_MAGN_2_FS_AVL_8000_GAIN,
- },
- [2] = {
-- .num = ST_MAGN_FS_AVL_10000MG,
-- .value = ST_MAGN_2_FS_AVL_10000_VAL,
-- .gain = ST_MAGN_2_FS_AVL_10000_GAIN,
-+ .num = ST_MAGN_FS_AVL_12000MG,
-+ .value = ST_MAGN_2_FS_AVL_12000_VAL,
-+ .gain = ST_MAGN_2_FS_AVL_12000_GAIN,
-+ },
-+ [3] = {
-+ .num = ST_MAGN_FS_AVL_16000MG,
-+ .value = ST_MAGN_2_FS_AVL_16000_VAL,
-+ .gain = ST_MAGN_2_FS_AVL_16000_GAIN,
- },
- },
- },
-diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
-index e7bee46868d1..abd97247443e 100644
---- a/drivers/infiniband/core/uverbs_marshall.c
-+++ b/drivers/infiniband/core/uverbs_marshall.c
-@@ -140,5 +140,9 @@ void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
- dst->packet_life_time = src->packet_life_time;
- dst->preference = src->preference;
- dst->packet_life_time_selector = src->packet_life_time_selector;
-+
-+ memset(dst->smac, 0, sizeof(dst->smac));
-+ memset(dst->dmac, 0, sizeof(dst->dmac));
-+ dst->vlan_id = 0xffff;
- }
- EXPORT_SYMBOL(ib_copy_path_rec_from_user);
-diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
-index f9c12e92fdd6..11f0606792bb 100644
---- a/drivers/infiniband/hw/mlx4/main.c
-+++ b/drivers/infiniband/hw/mlx4/main.c
-@@ -1622,6 +1622,7 @@ static void mlx4_ib_get_dev_addr(struct net_device *dev,
- struct inet6_dev *in6_dev;
- union ib_gid *pgid;
- struct inet6_ifaddr *ifp;
-+ union ib_gid default_gid;
- #endif
- union ib_gid gid;
-
-@@ -1642,12 +1643,15 @@ static void mlx4_ib_get_dev_addr(struct net_device *dev,
- in_dev_put(in_dev);
- }
- #if IS_ENABLED(CONFIG_IPV6)
-+ mlx4_make_default_gid(dev, &default_gid);
- /* IPv6 gids */
- in6_dev = in6_dev_get(dev);
- if (in6_dev) {
- read_lock_bh(&in6_dev->lock);
- list_for_each_entry(ifp, &in6_dev->addr_list, if_list) {
- pgid = (union ib_gid *)&ifp->addr;
-+ if (!memcmp(pgid, &default_gid, sizeof(*pgid)))
-+ continue;
- update_gid_table(ibdev, port, pgid, 0, 0);
- }
- read_unlock_bh(&in6_dev->lock);
-@@ -1723,31 +1727,34 @@ static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev)
- port_state = (netif_running(curr_netdev) && netif_carrier_ok(curr_netdev)) ?
- IB_PORT_ACTIVE : IB_PORT_DOWN;
- mlx4_ib_set_default_gid(ibdev, curr_netdev, port);
-- } else {
-- reset_gid_table(ibdev, port);
-- }
-- /* if using bonding/team and a slave port is down, we don't the bond IP
-- * based gids in the table since flows that select port by gid may get
-- * the down port.
-- */
-- if (curr_master && (port_state == IB_PORT_DOWN)) {
-- reset_gid_table(ibdev, port);
-- mlx4_ib_set_default_gid(ibdev, curr_netdev, port);
-- }
-- /* if bonding is used it is possible that we add it to masters
-- * only after IP address is assigned to the net bonding
-- * interface.
-- */
-- if (curr_master && (old_master != curr_master)) {
-- reset_gid_table(ibdev, port);
-- mlx4_ib_set_default_gid(ibdev, curr_netdev, port);
-- mlx4_ib_get_dev_addr(curr_master, ibdev, port);
-- }
-+ /* if using bonding/team and a slave port is down, we
-+ * don't the bond IP based gids in the table since
-+ * flows that select port by gid may get the down port.
-+ */
-+ if (curr_master && (port_state == IB_PORT_DOWN)) {
-+ reset_gid_table(ibdev, port);
-+ mlx4_ib_set_default_gid(ibdev,
-+ curr_netdev, port);
-+ }
-+ /* if bonding is used it is possible that we add it to
-+ * masters only after IP address is assigned to the
-+ * net bonding interface.
-+ */
-+ if (curr_master && (old_master != curr_master)) {
-+ reset_gid_table(ibdev, port);
-+ mlx4_ib_set_default_gid(ibdev,
-+ curr_netdev, port);
-+ mlx4_ib_get_dev_addr(curr_master, ibdev, port);
-+ }
-
-- if (!curr_master && (old_master != curr_master)) {
-+ if (!curr_master && (old_master != curr_master)) {
-+ reset_gid_table(ibdev, port);
-+ mlx4_ib_set_default_gid(ibdev,
-+ curr_netdev, port);
-+ mlx4_ib_get_dev_addr(curr_netdev, ibdev, port);
-+ }
-+ } else {
- reset_gid_table(ibdev, port);
-- mlx4_ib_set_default_gid(ibdev, curr_netdev, port);
-- mlx4_ib_get_dev_addr(curr_netdev, ibdev, port);
- }
- }
-
-diff --git a/drivers/infiniband/hw/qib/qib_debugfs.c b/drivers/infiniband/hw/qib/qib_debugfs.c
-index 799a0c3bffc4..6abd3ed3cd51 100644
---- a/drivers/infiniband/hw/qib/qib_debugfs.c
-+++ b/drivers/infiniband/hw/qib/qib_debugfs.c
-@@ -193,6 +193,7 @@ static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos)
- struct qib_qp_iter *iter;
- loff_t n = *pos;
-
-+ rcu_read_lock();
- iter = qib_qp_iter_init(s->private);
- if (!iter)
- return NULL;
-@@ -224,7 +225,7 @@ static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr,
-
- static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr)
- {
-- /* nothing for now */
-+ rcu_read_unlock();
- }
-
- static int _qp_stats_seq_show(struct seq_file *s, void *iter_ptr)
-diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c
-index 0cad0c40d742..6a71b2b41b27 100644
---- a/drivers/infiniband/hw/qib/qib_qp.c
-+++ b/drivers/infiniband/hw/qib/qib_qp.c
-@@ -1324,7 +1324,6 @@ int qib_qp_iter_next(struct qib_qp_iter *iter)
- struct qib_qp *pqp = iter->qp;
- struct qib_qp *qp;
-
-- rcu_read_lock();
- for (; n < dev->qp_table_size; n++) {
- if (pqp)
- qp = rcu_dereference(pqp->next);
-@@ -1332,18 +1331,11 @@ int qib_qp_iter_next(struct qib_qp_iter *iter)
- qp = rcu_dereference(dev->qp_table[n]);
- pqp = qp;
- if (qp) {
-- if (iter->qp)
-- atomic_dec(&iter->qp->refcount);
-- atomic_inc(&qp->refcount);
-- rcu_read_unlock();
- iter->qp = qp;
- iter->n = n;
- return 0;
- }
- }
-- rcu_read_unlock();
-- if (iter->qp)
-- atomic_dec(&iter->qp->refcount);
- return ret;
- }
-
-diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
-index 156205a81523..c5c194c2e0b6 100644
---- a/drivers/infiniband/ulp/isert/ib_isert.c
-+++ b/drivers/infiniband/ulp/isert/ib_isert.c
-@@ -511,7 +511,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
- init_completion(&isert_conn->conn_wait);
- init_completion(&isert_conn->conn_wait_comp_err);
- kref_init(&isert_conn->conn_kref);
-- kref_get(&isert_conn->conn_kref);
- mutex_init(&isert_conn->conn_mutex);
- spin_lock_init(&isert_conn->conn_lock);
- INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
-@@ -663,7 +662,9 @@ isert_connect_release(struct isert_conn *isert_conn)
- static void
- isert_connected_handler(struct rdma_cm_id *cma_id)
- {
-- return;
-+ struct isert_conn *isert_conn = cma_id->context;
-+
-+ kref_get(&isert_conn->conn_kref);
- }
-
- static void
-@@ -715,7 +716,6 @@ isert_disconnect_work(struct work_struct *work)
-
- wake_up:
- complete(&isert_conn->conn_wait);
-- isert_put_conn(isert_conn);
- }
-
- static void
-@@ -2800,6 +2800,7 @@ static void isert_wait_conn(struct iscsi_conn *conn)
- wait_for_completion(&isert_conn->conn_wait_comp_err);
-
- wait_for_completion(&isert_conn->conn_wait);
-+ isert_put_conn(isert_conn);
- }
-
- static void isert_free_conn(struct iscsi_conn *conn)
-diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
-index 2dd1d0dd4f7d..6f5d79569136 100644
---- a/drivers/input/keyboard/atkbd.c
-+++ b/drivers/input/keyboard/atkbd.c
-@@ -1791,14 +1791,6 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
- {
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
-- DMI_MATCH(DMI_PRODUCT_NAME, "LW25-B7HV"),
-- },
-- .callback = atkbd_deactivate_fixup,
-- },
-- {
-- .matches = {
-- DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
-- DMI_MATCH(DMI_PRODUCT_NAME, "P1-J273B"),
- },
- .callback = atkbd_deactivate_fixup,
- },
-diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
-index 233516aff595..0b75b5764f31 100644
---- a/drivers/input/mouse/elantech.c
-+++ b/drivers/input/mouse/elantech.c
-@@ -1253,6 +1253,13 @@ static bool elantech_is_signature_valid(const unsigned char *param)
- if (param[1] == 0)
- return true;
-
-+ /*
-+ * Some models have a revision higher then 20. Meaning param[2] may
-+ * be 10 or 20, skip the rates check for these.
-+ */
-+ if (param[0] == 0x46 && (param[1] & 0xef) == 0x0f && param[2] < 40)
-+ return true;
-+
- for (i = 0; i < ARRAY_SIZE(rates); i++)
- if (param[2] == rates[i])
- return false;
-diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
-index ef9e0b8a9aa7..a50a2a7a43f7 100644
---- a/drivers/input/mouse/synaptics.c
-+++ b/drivers/input/mouse/synaptics.c
-@@ -626,10 +626,61 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
- ((buf[0] & 0x04) >> 1) |
- ((buf[3] & 0x04) >> 2));
-
-+ if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) ||
-+ SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) &&
-+ hw->w == 2) {
-+ synaptics_parse_agm(buf, priv, hw);
-+ return 1;
-+ }
-+
-+ hw->x = (((buf[3] & 0x10) << 8) |
-+ ((buf[1] & 0x0f) << 8) |
-+ buf[4]);
-+ hw->y = (((buf[3] & 0x20) << 7) |
-+ ((buf[1] & 0xf0) << 4) |
-+ buf[5]);
-+ hw->z = buf[2];
-+
- hw->left = (buf[0] & 0x01) ? 1 : 0;
- hw->right = (buf[0] & 0x02) ? 1 : 0;
-
-- if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
-+ if (SYN_CAP_FORCEPAD(priv->ext_cap_0c)) {
-+ /*
-+ * ForcePads, like Clickpads, use middle button
-+ * bits to report primary button clicks.
-+ * Unfortunately they report primary button not
-+ * only when user presses on the pad above certain
-+ * threshold, but also when there are more than one
-+ * finger on the touchpad, which interferes with
-+ * out multi-finger gestures.
-+ */
-+ if (hw->z == 0) {
-+ /* No contacts */
-+ priv->press = priv->report_press = false;
-+ } else if (hw->w >= 4 && ((buf[0] ^ buf[3]) & 0x01)) {
-+ /*
-+ * Single-finger touch with pressure above
-+ * the threshold. If pressure stays long
-+ * enough, we'll start reporting primary
-+ * button. We rely on the device continuing
-+ * sending data even if finger does not
-+ * move.
-+ */
-+ if (!priv->press) {
-+ priv->press_start = jiffies;
-+ priv->press = true;
-+ } else if (time_after(jiffies,
-+ priv->press_start +
-+ msecs_to_jiffies(50))) {
-+ priv->report_press = true;
-+ }
-+ } else {
-+ priv->press = false;
-+ }
-+
-+ hw->left = priv->report_press;
-+
-+ } else if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
- /*
- * Clickpad's button is transmitted as middle button,
- * however, since it is primary button, we will report
-@@ -648,21 +699,6 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
- hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
- }
-
-- if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) ||
-- SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) &&
-- hw->w == 2) {
-- synaptics_parse_agm(buf, priv, hw);
-- return 1;
-- }
--
-- hw->x = (((buf[3] & 0x10) << 8) |
-- ((buf[1] & 0x0f) << 8) |
-- buf[4]);
-- hw->y = (((buf[3] & 0x20) << 7) |
-- ((buf[1] & 0xf0) << 4) |
-- buf[5]);
-- hw->z = buf[2];
--
- if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) &&
- ((buf[0] ^ buf[3]) & 0x02)) {
- switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
-diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
-index e594af0b264b..fb2e076738ae 100644
---- a/drivers/input/mouse/synaptics.h
-+++ b/drivers/input/mouse/synaptics.h
-@@ -78,6 +78,11 @@
- * 2 0x08 image sensor image sensor tracks 5 fingers, but only
- * reports 2.
- * 2 0x20 report min query 0x0f gives min coord reported
-+ * 2 0x80 forcepad forcepad is a variant of clickpad that
-+ * does not have physical buttons but rather
-+ * uses pressure above certain threshold to
-+ * report primary clicks. Forcepads also have
-+ * clickpad bit set.
- */
- #define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000) /* 1-button ClickPad */
- #define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100) /* 2-button ClickPad */
-@@ -86,6 +91,7 @@
- #define SYN_CAP_ADV_GESTURE(ex0c) ((ex0c) & 0x080000)
- #define SYN_CAP_REDUCED_FILTERING(ex0c) ((ex0c) & 0x000400)
- #define SYN_CAP_IMAGE_SENSOR(ex0c) ((ex0c) & 0x000800)
-+#define SYN_CAP_FORCEPAD(ex0c) ((ex0c) & 0x008000)
-
- /* synaptics modes query bits */
- #define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7))
-@@ -177,6 +183,11 @@ struct synaptics_data {
- */
- struct synaptics_hw_state agm;
- bool agm_pending; /* new AGM packet received */
-+
-+ /* ForcePad handling */
-+ unsigned long press_start;
-+ bool press;
-+ bool report_press;
- };
-
- void synaptics_module_init(void);
-diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
-index 381b20d4c561..f1da362c3e65 100644
---- a/drivers/input/serio/i8042-x86ia64io.h
-+++ b/drivers/input/serio/i8042-x86ia64io.h
-@@ -458,6 +458,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
- DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
- },
- },
-+ {
-+ /* Avatar AVIU-145A6 */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
-+ },
-+ },
- { }
- };
-
-@@ -601,6 +608,14 @@ static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
- DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
- },
- },
-+ {
-+ /* Fujitsu U574 laptop */
-+ /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U574"),
-+ },
-+ },
- { }
- };
-
-diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
-index 0cb7ef59071b..69175b825346 100644
---- a/drivers/input/serio/serport.c
-+++ b/drivers/input/serio/serport.c
-@@ -21,6 +21,7 @@
- #include
- #include
- #include
-+#include
-
- MODULE_AUTHOR("Vojtech Pavlik ");
- MODULE_DESCRIPTION("Input device TTY line discipline");
-@@ -198,28 +199,55 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
- return 0;
- }
-
-+static void serport_set_type(struct tty_struct *tty, unsigned long type)
-+{
-+ struct serport *serport = tty->disc_data;
-+
-+ serport->id.proto = type & 0x000000ff;
-+ serport->id.id = (type & 0x0000ff00) >> 8;
-+ serport->id.extra = (type & 0x00ff0000) >> 16;
-+}
-+
- /*
- * serport_ldisc_ioctl() allows to set the port protocol, and device ID
- */
-
--static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsigned int cmd, unsigned long arg)
-+static int serport_ldisc_ioctl(struct tty_struct *tty, struct file *file,
-+ unsigned int cmd, unsigned long arg)
- {
-- struct serport *serport = (struct serport*) tty->disc_data;
-- unsigned long type;
--
- if (cmd == SPIOCSTYPE) {
-+ unsigned long type;
-+
- if (get_user(type, (unsigned long __user *) arg))
- return -EFAULT;
-
-- serport->id.proto = type & 0x000000ff;
-- serport->id.id = (type & 0x0000ff00) >> 8;
-- serport->id.extra = (type & 0x00ff0000) >> 16;
-+ serport_set_type(tty, type);
-+ return 0;
-+ }
-+
-+ return -EINVAL;
-+}
-+
-+#ifdef CONFIG_COMPAT
-+#define COMPAT_SPIOCSTYPE _IOW('q', 0x01, compat_ulong_t)
-+static long serport_ldisc_compat_ioctl(struct tty_struct *tty,
-+ struct file *file,
-+ unsigned int cmd, unsigned long arg)
-+{
-+ if (cmd == COMPAT_SPIOCSTYPE) {
-+ void __user *uarg = compat_ptr(arg);
-+ compat_ulong_t compat_type;
-+
-+ if (get_user(compat_type, (compat_ulong_t __user *)uarg))
-+ return -EFAULT;
-
-+ serport_set_type(tty, compat_type);
- return 0;
- }
-
- return -EINVAL;
- }
-+#endif
-
- static void serport_ldisc_write_wakeup(struct tty_struct * tty)
- {
-@@ -243,6 +271,9 @@ static struct tty_ldisc_ops serport_ldisc = {
- .close = serport_ldisc_close,
- .read = serport_ldisc_read,
- .ioctl = serport_ldisc_ioctl,
-+#ifdef CONFIG_COMPAT
-+ .compat_ioctl = serport_ldisc_compat_ioctl,
-+#endif
- .receive_buf = serport_ldisc_receive,
- .write_wakeup = serport_ldisc_write_wakeup
- };
-diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
-index 1d9ab39af29f..2ecac467f78f 100644
---- a/drivers/iommu/arm-smmu.c
-+++ b/drivers/iommu/arm-smmu.c
-@@ -794,8 +794,11 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain)
- reg |= TTBCR_EAE |
- (TTBCR_SH_IS << TTBCR_SH0_SHIFT) |
- (TTBCR_RGN_WBWA << TTBCR_ORGN0_SHIFT) |
-- (TTBCR_RGN_WBWA << TTBCR_IRGN0_SHIFT) |
-- (TTBCR_SL0_LVL_1 << TTBCR_SL0_SHIFT);
-+ (TTBCR_RGN_WBWA << TTBCR_IRGN0_SHIFT);
-+
-+ if (!stage1)
-+ reg |= (TTBCR_SL0_LVL_1 << TTBCR_SL0_SHIFT);
-+
- writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBCR);
-
- /* MAIR0 (stage-1 only) */
-diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
-index 735e939a846d..2331543005b2 100644
---- a/drivers/md/dm-cache-target.c
-+++ b/drivers/md/dm-cache-target.c
-@@ -890,8 +890,8 @@ static void migration_success_pre_commit(struct dm_cache_migration *mg)
- struct cache *cache = mg->cache;
-
- if (mg->writeback) {
-- cell_defer(cache, mg->old_ocell, false);
- clear_dirty(cache, mg->old_oblock, mg->cblock);
-+ cell_defer(cache, mg->old_ocell, false);
- cleanup_migration(mg);
- return;
-
-@@ -946,13 +946,13 @@ static void migration_success_post_commit(struct dm_cache_migration *mg)
- }
-
- } else {
-+ clear_dirty(cache, mg->new_oblock, mg->cblock);
- if (mg->requeue_holder)
- cell_defer(cache, mg->new_ocell, true);
- else {
- bio_endio(mg->new_ocell->holder, 0);
- cell_defer(cache, mg->new_ocell, false);
- }
-- clear_dirty(cache, mg->new_oblock, mg->cblock);
- cleanup_migration(mg);
- }
- }
-diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
-index 53b213226c01..9533f835ce07 100644
---- a/drivers/md/dm-crypt.c
-+++ b/drivers/md/dm-crypt.c
-@@ -1681,6 +1681,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
- unsigned int key_size, opt_params;
- unsigned long long tmpll;
- int ret;
-+ size_t iv_size_padding;
- struct dm_arg_set as;
- const char *opt_string;
- char dummy;
-@@ -1717,12 +1718,23 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
-
- cc->dmreq_start = sizeof(struct ablkcipher_request);
- cc->dmreq_start += crypto_ablkcipher_reqsize(any_tfm(cc));
-- cc->dmreq_start = ALIGN(cc->dmreq_start, crypto_tfm_ctx_alignment());
-- cc->dmreq_start += crypto_ablkcipher_alignmask(any_tfm(cc)) &
-- ~(crypto_tfm_ctx_alignment() - 1);
-+ cc->dmreq_start = ALIGN(cc->dmreq_start, __alignof__(struct dm_crypt_request));
-+
-+ if (crypto_ablkcipher_alignmask(any_tfm(cc)) < CRYPTO_MINALIGN) {
-+ /* Allocate the padding exactly */
-+ iv_size_padding = -(cc->dmreq_start + sizeof(struct dm_crypt_request))
-+ & crypto_ablkcipher_alignmask(any_tfm(cc));
-+ } else {
-+ /*
-+ * If the cipher requires greater alignment than kmalloc
-+ * alignment, we don't know the exact position of the
-+ * initialization vector. We must assume worst case.
-+ */
-+ iv_size_padding = crypto_ablkcipher_alignmask(any_tfm(cc));
-+ }
-
- cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start +
-- sizeof(struct dm_crypt_request) + cc->iv_size);
-+ sizeof(struct dm_crypt_request) + iv_size_padding + cc->iv_size);
- if (!cc->req_pool) {
- ti->error = "Cannot allocate crypt request mempool";
- goto bad;
-diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
-index d7690f86fdb9..55de4f6f7eaf 100644
---- a/drivers/md/raid1.c
-+++ b/drivers/md/raid1.c
-@@ -540,11 +540,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
- has_nonrot_disk = 0;
- choose_next_idle = 0;
-
-- if (conf->mddev->recovery_cp < MaxSector &&
-- (this_sector + sectors >= conf->next_resync))
-- choose_first = 1;
-- else
-- choose_first = 0;
-+ choose_first = (conf->mddev->recovery_cp < this_sector + sectors);
-
- for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) {
- sector_t dist;
-@@ -831,7 +827,7 @@ static void flush_pending_writes(struct r1conf *conf)
- * there is no normal IO happeing. It must arrange to call
- * lower_barrier when the particular background IO completes.
- */
--static void raise_barrier(struct r1conf *conf)
-+static void raise_barrier(struct r1conf *conf, sector_t sector_nr)
- {
- spin_lock_irq(&conf->resync_lock);
-
-@@ -841,6 +837,7 @@ static void raise_barrier(struct r1conf *conf)
-
- /* block any new IO from starting */
- conf->barrier++;
-+ conf->next_resync = sector_nr;
-
- /* For these conditions we must wait:
- * A: while the array is in frozen state
-@@ -849,14 +846,17 @@ static void raise_barrier(struct r1conf *conf)
- * C: next_resync + RESYNC_SECTORS > start_next_window, meaning
- * next resync will reach to the window which normal bios are
- * handling.
-+ * D: while there are any active requests in the current window.
- */
- wait_event_lock_irq(conf->wait_barrier,
- !conf->array_frozen &&
- conf->barrier < RESYNC_DEPTH &&
-+ conf->current_window_requests == 0 &&
- (conf->start_next_window >=
- conf->next_resync + RESYNC_SECTORS),
- conf->resync_lock);
-
-+ conf->nr_pending++;
- spin_unlock_irq(&conf->resync_lock);
- }
-
-@@ -866,6 +866,7 @@ static void lower_barrier(struct r1conf *conf)
- BUG_ON(conf->barrier <= 0);
- spin_lock_irqsave(&conf->resync_lock, flags);
- conf->barrier--;
-+ conf->nr_pending--;
- spin_unlock_irqrestore(&conf->resync_lock, flags);
- wake_up(&conf->wait_barrier);
- }
-@@ -877,12 +878,10 @@ static bool need_to_wait_for_sync(struct r1conf *conf, struct bio *bio)
- if (conf->array_frozen || !bio)
- wait = true;
- else if (conf->barrier && bio_data_dir(bio) == WRITE) {
-- if (conf->next_resync < RESYNC_WINDOW_SECTORS)
-- wait = true;
-- else if ((conf->next_resync - RESYNC_WINDOW_SECTORS
-- >= bio_end_sector(bio)) ||
-- (conf->next_resync + NEXT_NORMALIO_DISTANCE
-- <= bio->bi_iter.bi_sector))
-+ if ((conf->mddev->curr_resync_completed
-+ >= bio_end_sector(bio)) ||
-+ (conf->next_resync + NEXT_NORMALIO_DISTANCE
-+ <= bio->bi_iter.bi_sector))
- wait = false;
- else
- wait = true;
-@@ -919,8 +918,8 @@ static sector_t wait_barrier(struct r1conf *conf, struct bio *bio)
- }
-
- if (bio && bio_data_dir(bio) == WRITE) {
-- if (conf->next_resync + NEXT_NORMALIO_DISTANCE
-- <= bio->bi_iter.bi_sector) {
-+ if (bio->bi_iter.bi_sector >=
-+ conf->mddev->curr_resync_completed) {
- if (conf->start_next_window == MaxSector)
- conf->start_next_window =
- conf->next_resync +
-@@ -1186,6 +1185,7 @@ read_again:
- atomic_read(&bitmap->behind_writes) == 0);
- }
- r1_bio->read_disk = rdisk;
-+ r1_bio->start_next_window = 0;
-
- read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
- bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector,
-@@ -1548,8 +1548,13 @@ static void close_sync(struct r1conf *conf)
- mempool_destroy(conf->r1buf_pool);
- conf->r1buf_pool = NULL;
-
-+ spin_lock_irq(&conf->resync_lock);
- conf->next_resync = 0;
- conf->start_next_window = MaxSector;
-+ conf->current_window_requests +=
-+ conf->next_window_requests;
-+ conf->next_window_requests = 0;
-+ spin_unlock_irq(&conf->resync_lock);
- }
-
- static int raid1_spare_active(struct mddev *mddev)
-@@ -2150,7 +2155,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
- d--;
- rdev = conf->mirrors[d].rdev;
- if (rdev &&
-- test_bit(In_sync, &rdev->flags))
-+ !test_bit(Faulty, &rdev->flags))
- r1_sync_page_io(rdev, sect, s,
- conf->tmppage, WRITE);
- }
-@@ -2162,7 +2167,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
- d--;
- rdev = conf->mirrors[d].rdev;
- if (rdev &&
-- test_bit(In_sync, &rdev->flags)) {
-+ !test_bit(Faulty, &rdev->flags)) {
- if (r1_sync_page_io(rdev, sect, s,
- conf->tmppage, READ)) {
- atomic_add(s, &rdev->corrected_errors);
-@@ -2541,9 +2546,8 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp
-
- bitmap_cond_end_sync(mddev->bitmap, sector_nr);
- r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO);
-- raise_barrier(conf);
-
-- conf->next_resync = sector_nr;
-+ raise_barrier(conf, sector_nr);
-
- rcu_read_lock();
- /*
-diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
-index 80643ef9183f..fabe2fce9bc5 100644
---- a/drivers/media/dvb-core/dvb-usb-ids.h
-+++ b/drivers/media/dvb-core/dvb-usb-ids.h
-@@ -279,6 +279,8 @@
- #define USB_PID_PCTV_400E 0x020f
- #define USB_PID_PCTV_450E 0x0222
- #define USB_PID_PCTV_452E 0x021f
-+#define USB_PID_PCTV_78E 0x025a
-+#define USB_PID_PCTV_79E 0x0262
- #define USB_PID_REALTEK_RTL2831U 0x2831
- #define USB_PID_REALTEK_RTL2832U 0x2832
- #define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007
-diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
-index 71c8570bd9ea..112394d138c9 100644
---- a/drivers/media/i2c/adv7604.c
-+++ b/drivers/media/i2c/adv7604.c
-@@ -1984,7 +1984,7 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
- v4l2_info(sd, "HDCP keys read: %s%s\n",
- (hdmi_read(sd, 0x04) & 0x20) ? "yes" : "no",
- (hdmi_read(sd, 0x04) & 0x10) ? "ERROR" : "");
-- if (!is_hdmi(sd)) {
-+ if (is_hdmi(sd)) {
- bool audio_pll_locked = hdmi_read(sd, 0x04) & 0x01;
- bool audio_sample_packet_detect = hdmi_read(sd, 0x18) & 0x01;
- bool audio_mute = io_read(sd, 0x65) & 0x40;
-diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
-index 716bdc57fac6..83f5074706f9 100644
---- a/drivers/media/pci/cx18/cx18-driver.c
-+++ b/drivers/media/pci/cx18/cx18-driver.c
-@@ -1091,6 +1091,7 @@ static int cx18_probe(struct pci_dev *pci_dev,
- setup.addr = ADDR_UNSET;
- setup.type = cx->options.tuner;
- setup.mode_mask = T_ANALOG_TV; /* matches TV tuners */
-+ setup.config = NULL;
- if (cx->options.radio > 0)
- setup.mode_mask |= T_RADIO;
- setup.tuner_callback = (setup.type == TUNER_XC2028) ?
-diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
-index 8ede8ea762e6..88228f735342 100644
---- a/drivers/media/usb/dvb-usb-v2/af9035.c
-+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
-@@ -1541,6 +1541,10 @@ static const struct usb_device_id af9035_id_table[] = {
- &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) },
- { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xf900,
- &af9035_props, "Hauppauge WinTV-MiniStick 2", NULL) },
-+ { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_78E,
-+ &af9035_props, "PCTV 78e", RC_MAP_IT913X_V1) },
-+ { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_79E,
-+ &af9035_props, "PCTV 79e", RC_MAP_IT913X_V2) },
- { }
- };
- MODULE_DEVICE_TABLE(usb, af9035_id_table);
-diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
-index 1fc8334fc181..55e3075492da 100644
---- a/drivers/net/ethernet/ibm/ibmveth.c
-+++ b/drivers/net/ethernet/ibm/ibmveth.c
-@@ -292,6 +292,18 @@ failure:
- atomic_add(buffers_added, &(pool->available));
- }
-
-+/*
-+ * The final 8 bytes of the buffer list is a counter of frames dropped
-+ * because there was not a buffer in the buffer list capable of holding
-+ * the frame.
-+ */
-+static void ibmveth_update_rx_no_buffer(struct ibmveth_adapter *adapter)
-+{
-+ __be64 *p = adapter->buffer_list_addr + 4096 - 8;
-+
-+ adapter->rx_no_buffer = be64_to_cpup(p);
-+}
-+
- /* replenish routine */
- static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
- {
-@@ -307,8 +319,7 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
- ibmveth_replenish_buffer_pool(adapter, pool);
- }
-
-- adapter->rx_no_buffer = *(u64 *)(((char*)adapter->buffer_list_addr) +
-- 4096 - 8);
-+ ibmveth_update_rx_no_buffer(adapter);
- }
-
- /* empty and free ana buffer pool - also used to do cleanup in error paths */
-@@ -698,8 +709,7 @@ static int ibmveth_close(struct net_device *netdev)
-
- free_irq(netdev->irq, netdev);
-
-- adapter->rx_no_buffer = *(u64 *)(((char *)adapter->buffer_list_addr) +
-- 4096 - 8);
-+ ibmveth_update_rx_no_buffer(adapter);
-
- ibmveth_cleanup(adapter);
-
-diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
-index 8596aba34f96..237d0cda1bcb 100644
---- a/drivers/net/wireless/ath/carl9170/carl9170.h
-+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
-@@ -256,6 +256,7 @@ struct ar9170 {
- atomic_t rx_work_urbs;
- atomic_t rx_pool_urbs;
- kernel_ulong_t features;
-+ bool usb_ep_cmd_is_bulk;
-
- /* firmware settings */
- struct completion fw_load_wait;
-diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
-index ca115f33746f..bc931f6f1f0f 100644
---- a/drivers/net/wireless/ath/carl9170/usb.c
-+++ b/drivers/net/wireless/ath/carl9170/usb.c
-@@ -621,9 +621,16 @@ int __carl9170_exec_cmd(struct ar9170 *ar, struct carl9170_cmd *cmd,
- goto err_free;
- }
-
-- usb_fill_int_urb(urb, ar->udev, usb_sndintpipe(ar->udev,
-- AR9170_USB_EP_CMD), cmd, cmd->hdr.len + 4,
-- carl9170_usb_cmd_complete, ar, 1);
-+ if (ar->usb_ep_cmd_is_bulk)
-+ usb_fill_bulk_urb(urb, ar->udev,
-+ usb_sndbulkpipe(ar->udev, AR9170_USB_EP_CMD),
-+ cmd, cmd->hdr.len + 4,
-+ carl9170_usb_cmd_complete, ar);
-+ else
-+ usb_fill_int_urb(urb, ar->udev,
-+ usb_sndintpipe(ar->udev, AR9170_USB_EP_CMD),
-+ cmd, cmd->hdr.len + 4,
-+ carl9170_usb_cmd_complete, ar, 1);
-
- if (free_buf)
- urb->transfer_flags |= URB_FREE_BUFFER;
-@@ -1032,9 +1039,10 @@ static void carl9170_usb_firmware_step2(const struct firmware *fw,
- static int carl9170_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
- {
-+ struct usb_endpoint_descriptor *ep;
- struct ar9170 *ar;
- struct usb_device *udev;
-- int err;
-+ int i, err;
-
- err = usb_reset_device(interface_to_usbdev(intf));
- if (err)
-@@ -1050,6 +1058,21 @@ static int carl9170_usb_probe(struct usb_interface *intf,
- ar->intf = intf;
- ar->features = id->driver_info;
-
-+ /* We need to remember the type of endpoint 4 because it differs
-+ * between high- and full-speed configuration. The high-speed
-+ * configuration specifies it as interrupt and the full-speed
-+ * configuration as bulk endpoint. This information is required
-+ * later when sending urbs to that endpoint.
-+ */
-+ for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; ++i) {
-+ ep = &intf->cur_altsetting->endpoint[i].desc;
-+
-+ if (usb_endpoint_num(ep) == AR9170_USB_EP_CMD &&
-+ usb_endpoint_dir_out(ep) &&
-+ usb_endpoint_type(ep) == USB_ENDPOINT_XFER_BULK)
-+ ar->usb_ep_cmd_is_bulk = true;
-+ }
-+
- usb_set_intfdata(intf, ar);
- SET_IEEE80211_DEV(ar->hw, &intf->dev);
-
-diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
-index fad77dd2a3a5..3f9cb894d001 100644
---- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
-+++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.c
-@@ -185,7 +185,13 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
- ifevent->action, ifevent->ifidx, ifevent->bssidx,
- ifevent->flags, ifevent->role);
-
-- if (ifevent->flags & BRCMF_E_IF_FLAG_NOIF) {
-+ /* The P2P Device interface event must not be ignored
-+ * contrary to what firmware tells us. The only way to
-+ * distinguish the P2P Device is by looking at the ifidx
-+ * and bssidx received.
-+ */
-+ if (!(ifevent->ifidx == 0 && ifevent->bssidx == 1) &&
-+ (ifevent->flags & BRCMF_E_IF_FLAG_NOIF)) {
- brcmf_dbg(EVENT, "event can be ignored\n");
- return;
- }
-@@ -210,12 +216,12 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
- return;
- }
-
-- if (ifevent->action == BRCMF_E_IF_CHANGE)
-+ if (ifp && ifevent->action == BRCMF_E_IF_CHANGE)
- brcmf_fws_reset_interface(ifp);
-
- err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
-
-- if (ifevent->action == BRCMF_E_IF_DEL) {
-+ if (ifp && ifevent->action == BRCMF_E_IF_DEL) {
- brcmf_fws_del_interface(ifp);
- brcmf_del_if(drvr, ifevent->bssidx);
- }
-diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fweh.h b/drivers/net/wireless/brcm80211/brcmfmac/fweh.h
-index 51b53a73d074..d26b47698f68 100644
---- a/drivers/net/wireless/brcm80211/brcmfmac/fweh.h
-+++ b/drivers/net/wireless/brcm80211/brcmfmac/fweh.h
-@@ -167,6 +167,8 @@ enum brcmf_fweh_event_code {
- #define BRCMF_E_IF_ROLE_STA 0
- #define BRCMF_E_IF_ROLE_AP 1
- #define BRCMF_E_IF_ROLE_WDS 2
-+#define BRCMF_E_IF_ROLE_P2P_GO 3
-+#define BRCMF_E_IF_ROLE_P2P_CLIENT 4
-
- /**
- * definitions for event packet validation.
-diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c
-index c1e311341b74..503a81e58185 100644
---- a/drivers/net/wireless/iwlwifi/dvm/rxon.c
-+++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c
-@@ -1068,6 +1068,13 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
- /* recalculate basic rates */
- iwl_calc_basic_rates(priv, ctx);
-
-+ /*
-+ * force CTS-to-self frames protection if RTS-CTS is not preferred
-+ * one aggregation protection method
-+ */
-+ if (!priv->hw_params.use_rts_for_aggregation)
-+ ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
-+
- if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) ||
- !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK))
- ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
-@@ -1473,6 +1480,11 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
- else
- ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
-
-+ if (bss_conf->use_cts_prot)
-+ ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
-+ else
-+ ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
-+
- memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN);
-
- if (vif->type == NL80211_IFTYPE_AP ||
-diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h
-index 1ced525157dc..b45d78f53f08 100644
---- a/drivers/net/wireless/iwlwifi/iwl-config.h
-+++ b/drivers/net/wireless/iwlwifi/iwl-config.h
-@@ -119,6 +119,8 @@ enum iwl_led_mode {
- #define IWL_LONG_WD_TIMEOUT 10000
- #define IWL_MAX_WD_TIMEOUT 120000
-
-+#define IWL_DEFAULT_MAX_TX_POWER 22
-+
- /* Antenna presence definitions */
- #define ANT_NONE 0x0
- #define ANT_A BIT(0)
-diff --git a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
-index 725e954d8475..3c3eb7842c62 100644
---- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
-+++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
-@@ -118,8 +118,6 @@ static const u8 iwl_nvm_channels[] = {
- #define LAST_2GHZ_HT_PLUS 9
- #define LAST_5GHZ_HT 161
-
--#define DEFAULT_MAX_TX_POWER 16
--
- /* rate data (static) */
- static struct ieee80211_rate iwl_cfg80211_rates[] = {
- { .bitrate = 1 * 10, .hw_value = 0, .hw_value_short = 0, },
-@@ -242,7 +240,7 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
- * Default value - highest tx power value. max_power
- * is not used in mvm, and is used for backwards compatibility
- */
-- channel->max_power = DEFAULT_MAX_TX_POWER;
-+ channel->max_power = IWL_DEFAULT_MAX_TX_POWER;
- is_5ghz = channel->band == IEEE80211_BAND_5GHZ;
- IWL_DEBUG_EEPROM(dev,
- "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n",
-diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
-index 989d7dbdca6c..d0a04779d734 100644
---- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
-+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
-@@ -1415,14 +1415,14 @@ enum iwl_sf_scenario {
-
- /**
- * Smart Fifo configuration command.
-- * @state: smart fifo state, types listed in iwl_sf_sate.
-+ * @state: smart fifo state, types listed in enum %iwl_sf_sate.
- * @watermark: Minimum allowed availabe free space in RXF for transient state.
- * @long_delay_timeouts: aging and idle timer values for each scenario
- * in long delay state.
- * @full_on_timeouts: timer values for each scenario in full on state.
- */
- struct iwl_sf_cfg_cmd {
-- enum iwl_sf_state state;
-+ __le32 state;
- __le32 watermark[SF_TRANSIENT_STATES_NUMBER];
- __le32 long_delay_timeouts[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES];
- __le32 full_on_timeouts[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES];
-diff --git a/drivers/net/wireless/iwlwifi/mvm/sf.c b/drivers/net/wireless/iwlwifi/mvm/sf.c
-index 88809b2d1654..dab8fd13857a 100644
---- a/drivers/net/wireless/iwlwifi/mvm/sf.c
-+++ b/drivers/net/wireless/iwlwifi/mvm/sf.c
-@@ -172,7 +172,7 @@ static int iwl_mvm_sf_config(struct iwl_mvm *mvm, u8 sta_id,
- enum iwl_sf_state new_state)
- {
- struct iwl_sf_cfg_cmd sf_cmd = {
-- .state = new_state,
-+ .state = cpu_to_le32(new_state),
- };
- struct ieee80211_sta *sta;
- int ret = 0;
-diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
-index 76ee486039d7..2ca62af3f81b 100644
---- a/drivers/net/wireless/iwlwifi/mvm/tx.c
-+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
-@@ -173,10 +173,14 @@ static void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
-
- /*
- * for data packets, rate info comes from the table inside the fw. This
-- * table is controlled by LINK_QUALITY commands
-+ * table is controlled by LINK_QUALITY commands. Exclude ctrl port
-+ * frames like EAPOLs which should be treated as mgmt frames. This
-+ * avoids them being sent initially in high rates which increases the
-+ * chances for completion of the 4-Way handshake.
- */
-
-- if (ieee80211_is_data(fc) && sta) {
-+ if (ieee80211_is_data(fc) && sta &&
-+ !(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) {
- tx_cmd->initial_rate_index = 0;
- tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE);
- return;
-diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
-index c61311084d7e..f58316769159 100644
---- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
-+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
-@@ -317,6 +317,7 @@ static struct usb_device_id rtl8192c_usb_ids[] = {
- {RTL_USB_DEVICE(0x0bda, 0x5088, rtl92cu_hal_cfg)}, /*Thinkware-CC&C*/
- {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/
- {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/
-+ {RTL_USB_DEVICE(0x0df6, 0x0070, rtl92cu_hal_cfg)}, /*Sitecom - 150N */
- {RTL_USB_DEVICE(0x0df6, 0x0077, rtl92cu_hal_cfg)}, /*Sitecom-WLA2100V2*/
- {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/
- {RTL_USB_DEVICE(0x4856, 0x0091, rtl92cu_hal_cfg)}, /*NetweeN - Feixun*/
-diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c
-index f868333271aa..963a4a5dc88e 100644
---- a/drivers/nfc/microread/microread.c
-+++ b/drivers/nfc/microread/microread.c
-@@ -501,9 +501,13 @@ static void microread_target_discovered(struct nfc_hci_dev *hdev, u8 gate,
- targets->sens_res =
- be16_to_cpu(*(u16 *)&skb->data[MICROREAD_EMCF_A_ATQA]);
- targets->sel_res = skb->data[MICROREAD_EMCF_A_SAK];
-- memcpy(targets->nfcid1, &skb->data[MICROREAD_EMCF_A_UID],
-- skb->data[MICROREAD_EMCF_A_LEN]);
- targets->nfcid1_len = skb->data[MICROREAD_EMCF_A_LEN];
-+ if (targets->nfcid1_len > sizeof(targets->nfcid1)) {
-+ r = -EINVAL;
-+ goto exit_free;
-+ }
-+ memcpy(targets->nfcid1, &skb->data[MICROREAD_EMCF_A_UID],
-+ targets->nfcid1_len);
- break;
- case MICROREAD_GATE_ID_MREAD_ISO_A_3:
- targets->supported_protocols =
-@@ -511,9 +515,13 @@ static void microread_target_discovered(struct nfc_hci_dev *hdev, u8 gate,
- targets->sens_res =
- be16_to_cpu(*(u16 *)&skb->data[MICROREAD_EMCF_A3_ATQA]);
- targets->sel_res = skb->data[MICROREAD_EMCF_A3_SAK];
-- memcpy(targets->nfcid1, &skb->data[MICROREAD_EMCF_A3_UID],
-- skb->data[MICROREAD_EMCF_A3_LEN]);
- targets->nfcid1_len = skb->data[MICROREAD_EMCF_A3_LEN];
-+ if (targets->nfcid1_len > sizeof(targets->nfcid1)) {
-+ r = -EINVAL;
-+ goto exit_free;
-+ }
-+ memcpy(targets->nfcid1, &skb->data[MICROREAD_EMCF_A3_UID],
-+ targets->nfcid1_len);
- break;
- case MICROREAD_GATE_ID_MREAD_ISO_B:
- targets->supported_protocols = NFC_PROTO_ISO14443_B_MASK;
-diff --git a/drivers/of/irq.c b/drivers/of/irq.c
-index ca0189308d72..48f20ff1add9 100644
---- a/drivers/of/irq.c
-+++ b/drivers/of/irq.c
-@@ -301,16 +301,17 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
- /* Get the reg property (if any) */
- addr = of_get_property(device, "reg", NULL);
-
-+ /* Try the new-style interrupts-extended first */
-+ res = of_parse_phandle_with_args(device, "interrupts-extended",
-+ "#interrupt-cells", index, out_irq);
-+ if (!res)
-+ return of_irq_parse_raw(addr, out_irq);
-+
- /* Get the interrupts property */
- intspec = of_get_property(device, "interrupts", &intlen);
-- if (intspec == NULL) {
-- /* Try the new-style interrupts-extended */
-- res = of_parse_phandle_with_args(device, "interrupts-extended",
-- "#interrupt-cells", index, out_irq);
-- if (res)
-- return -EINVAL;
-- return of_irq_parse_raw(addr, out_irq);
-- }
-+ if (intspec == NULL)
-+ return -EINVAL;
-+
- intlen /= sizeof(*intspec);
-
- pr_debug(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
-diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
-index c3ace1db8136..aaac3594f83b 100644
---- a/drivers/phy/phy-twl4030-usb.c
-+++ b/drivers/phy/phy-twl4030-usb.c
-@@ -34,6 +34,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -422,37 +423,55 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on)
- }
- }
-
--static int twl4030_phy_power_off(struct phy *phy)
-+static int twl4030_usb_runtime_suspend(struct device *dev)
- {
-- struct twl4030_usb *twl = phy_get_drvdata(phy);
-+ struct twl4030_usb *twl = dev_get_drvdata(dev);
-
-+ dev_dbg(twl->dev, "%s\n", __func__);
- if (twl->asleep)
- return 0;
-
- twl4030_phy_power(twl, 0);
- twl->asleep = 1;
-- dev_dbg(twl->dev, "%s\n", __func__);
-+
- return 0;
- }
-
--static void __twl4030_phy_power_on(struct twl4030_usb *twl)
-+static int twl4030_usb_runtime_resume(struct device *dev)
- {
-+ struct twl4030_usb *twl = dev_get_drvdata(dev);
-+
-+ dev_dbg(twl->dev, "%s\n", __func__);
-+ if (!twl->asleep)
-+ return 0;
-+
- twl4030_phy_power(twl, 1);
-- twl4030_i2c_access(twl, 1);
-- twl4030_usb_set_mode(twl, twl->usb_mode);
-- if (twl->usb_mode == T2_USB_MODE_ULPI)
-- twl4030_i2c_access(twl, 0);
-+ twl->asleep = 0;
-+
-+ return 0;
-+}
-+
-+static int twl4030_phy_power_off(struct phy *phy)
-+{
-+ struct twl4030_usb *twl = phy_get_drvdata(phy);
-+
-+ dev_dbg(twl->dev, "%s\n", __func__);
-+ pm_runtime_mark_last_busy(twl->dev);
-+ pm_runtime_put_autosuspend(twl->dev);
-+
-+ return 0;
- }
-
- static int twl4030_phy_power_on(struct phy *phy)
- {
- struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-- if (!twl->asleep)
-- return 0;
-- __twl4030_phy_power_on(twl);
-- twl->asleep = 0;
- dev_dbg(twl->dev, "%s\n", __func__);
-+ pm_runtime_get_sync(twl->dev);
-+ twl4030_i2c_access(twl, 1);
-+ twl4030_usb_set_mode(twl, twl->usb_mode);
-+ if (twl->usb_mode == T2_USB_MODE_ULPI)
-+ twl4030_i2c_access(twl, 0);
-
- /*
- * XXX When VBUS gets driven after musb goes to A mode,
-@@ -558,9 +577,27 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
- * USB_LINK_VBUS state. musb_hdrc won't care until it
- * starts to handle softconnect right.
- */
-+ if ((status == OMAP_MUSB_VBUS_VALID) ||
-+ (status == OMAP_MUSB_ID_GROUND)) {
-+ if (twl->asleep)
-+ pm_runtime_get_sync(twl->dev);
-+ } else {
-+ if (!twl->asleep) {
-+ pm_runtime_mark_last_busy(twl->dev);
-+ pm_runtime_put_autosuspend(twl->dev);
-+ }
-+ }
- omap_musb_mailbox(status);
- }
-- sysfs_notify(&twl->dev->kobj, NULL, "vbus");
-+
-+ /* don't schedule during sleep - irq works right then */
-+ if (status == OMAP_MUSB_ID_GROUND && !twl->asleep) {
-+ cancel_delayed_work(&twl->id_workaround_work);
-+ schedule_delayed_work(&twl->id_workaround_work, HZ);
-+ }
-+
-+ if (irq)
-+ sysfs_notify(&twl->dev->kobj, NULL, "vbus");
-
- return IRQ_HANDLED;
- }
-@@ -569,29 +606,8 @@ static void twl4030_id_workaround_work(struct work_struct *work)
- {
- struct twl4030_usb *twl = container_of(work, struct twl4030_usb,
- id_workaround_work.work);
-- enum omap_musb_vbus_id_status status;
-- bool status_changed = false;
--
-- status = twl4030_usb_linkstat(twl);
--
-- spin_lock_irq(&twl->lock);
-- if (status >= 0 && status != twl->linkstat) {
-- twl->linkstat = status;
-- status_changed = true;
-- }
-- spin_unlock_irq(&twl->lock);
--
-- if (status_changed) {
-- dev_dbg(twl->dev, "handle missing status change to %d\n",
-- status);
-- omap_musb_mailbox(status);
-- }
-
-- /* don't schedule during sleep - irq works right then */
-- if (status == OMAP_MUSB_ID_GROUND && !twl->asleep) {
-- cancel_delayed_work(&twl->id_workaround_work);
-- schedule_delayed_work(&twl->id_workaround_work, HZ);
-- }
-+ twl4030_usb_irq(0, twl);
- }
-
- static int twl4030_phy_init(struct phy *phy)
-@@ -599,22 +615,17 @@ static int twl4030_phy_init(struct phy *phy)
- struct twl4030_usb *twl = phy_get_drvdata(phy);
- enum omap_musb_vbus_id_status status;
-
-- /*
-- * Start in sleep state, we'll get called through set_suspend()
-- * callback when musb is runtime resumed and it's time to start.
-- */
-- __twl4030_phy_power(twl, 0);
-- twl->asleep = 1;
--
-+ pm_runtime_get_sync(twl->dev);
- status = twl4030_usb_linkstat(twl);
- twl->linkstat = status;
-
-- if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
-+ if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
- omap_musb_mailbox(twl->linkstat);
-- twl4030_phy_power_on(phy);
-- }
-
- sysfs_notify(&twl->dev->kobj, NULL, "vbus");
-+ pm_runtime_mark_last_busy(twl->dev);
-+ pm_runtime_put_autosuspend(twl->dev);
-+
- return 0;
- }
-
-@@ -650,6 +661,11 @@ static const struct phy_ops ops = {
- .owner = THIS_MODULE,
- };
-
-+static const struct dev_pm_ops twl4030_usb_pm_ops = {
-+ SET_RUNTIME_PM_OPS(twl4030_usb_runtime_suspend,
-+ twl4030_usb_runtime_resume, NULL)
-+};
-+
- static int twl4030_usb_probe(struct platform_device *pdev)
- {
- struct twl4030_usb_data *pdata = dev_get_platdata(&pdev->dev);
-@@ -726,6 +742,11 @@ static int twl4030_usb_probe(struct platform_device *pdev)
-
- ATOMIC_INIT_NOTIFIER_HEAD(&twl->phy.notifier);
-
-+ pm_runtime_use_autosuspend(&pdev->dev);
-+ pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
-+ pm_runtime_enable(&pdev->dev);
-+ pm_runtime_get_sync(&pdev->dev);
-+
- /* Our job is to use irqs and status from the power module
- * to keep the transceiver disabled when nothing's connected.
- *
-@@ -744,6 +765,9 @@ static int twl4030_usb_probe(struct platform_device *pdev)
- return status;
- }
-
-+ pm_runtime_mark_last_busy(&pdev->dev);
-+ pm_runtime_put_autosuspend(twl->dev);
-+
- dev_info(&pdev->dev, "Initialized TWL4030 USB module\n");
- return 0;
- }
-@@ -753,6 +777,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
- struct twl4030_usb *twl = platform_get_drvdata(pdev);
- int val;
-
-+ pm_runtime_get_sync(twl->dev);
- cancel_delayed_work(&twl->id_workaround_work);
- device_remove_file(twl->dev, &dev_attr_vbus);
-
-@@ -772,9 +797,8 @@ static int twl4030_usb_remove(struct platform_device *pdev)
-
- /* disable complete OTG block */
- twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
--
-- if (!twl->asleep)
-- twl4030_phy_power(twl, 0);
-+ pm_runtime_mark_last_busy(twl->dev);
-+ pm_runtime_put(twl->dev);
-
- return 0;
- }
-@@ -792,6 +816,7 @@ static struct platform_driver twl4030_usb_driver = {
- .remove = twl4030_usb_remove,
- .driver = {
- .name = "twl4030_usb",
-+ .pm = &twl4030_usb_pm_ops,
- .owner = THIS_MODULE,
- .of_match_table = of_match_ptr(twl4030_usb_id_table),
- },
-diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
-index 40462415291e..454998669c2a 100644
---- a/drivers/scsi/libiscsi.c
-+++ b/drivers/scsi/libiscsi.c
-@@ -717,11 +717,21 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
- return NULL;
- }
-
-+ if (data_size > ISCSI_DEF_MAX_RECV_SEG_LEN) {
-+ iscsi_conn_printk(KERN_ERR, conn, "Invalid buffer len of %u for login task. Max len is %u\n", data_size, ISCSI_DEF_MAX_RECV_SEG_LEN);
-+ return NULL;
-+ }
-+
- task = conn->login_task;
- } else {
- if (session->state != ISCSI_STATE_LOGGED_IN)
- return NULL;
-
-+ if (data_size != 0) {
-+ iscsi_conn_printk(KERN_ERR, conn, "Can not send data buffer of len %u for op 0x%x\n", data_size, opcode);
-+ return NULL;
-+ }
-+
- BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
- BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
-
-diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
-index 3f3dc1226edf..e14960470d8d 100644
---- a/drivers/spi/spi-dw-pci.c
-+++ b/drivers/spi/spi-dw-pci.c
-@@ -62,6 +62,8 @@ static int spi_pci_probe(struct pci_dev *pdev,
- if (ret)
- return ret;
-
-+ dws->regs = pcim_iomap_table(pdev)[pci_bar];
-+
- dws->bus_num = 0;
- dws->num_cs = 4;
- dws->irq = pdev->irq;
-diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
-index a64f1557c156..b0059e7552b0 100644
---- a/drivers/spi/spi-omap2-mcspi.c
-+++ b/drivers/spi/spi-omap2-mcspi.c
-@@ -321,7 +321,8 @@ static void omap2_mcspi_set_fifo(const struct spi_device *spi,
- disable_fifo:
- if (t->rx_buf != NULL)
- chconf &= ~OMAP2_MCSPI_CHCONF_FFER;
-- else
-+
-+ if (t->tx_buf != NULL)
- chconf &= ~OMAP2_MCSPI_CHCONF_FFET;
-
- mcspi_write_chconf0(spi, chconf);
-diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
-index 7a94ddd42f59..8c4f2896cd0d 100644
---- a/drivers/staging/iio/meter/ade7758_trigger.c
-+++ b/drivers/staging/iio/meter/ade7758_trigger.c
-@@ -85,7 +85,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
- ret = iio_trigger_register(st->trig);
-
- /* select default trigger */
-- indio_dev->trig = st->trig;
-+ indio_dev->trig = iio_trigger_get(st->trig);
- if (ret)
- goto error_free_irq;
-
-diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c
-index 34b642a12f8b..c70f1734b274 100644
---- a/drivers/staging/imx-drm/ipuv3-plane.c
-+++ b/drivers/staging/imx-drm/ipuv3-plane.c
-@@ -277,7 +277,8 @@ static void ipu_plane_dpms(struct ipu_plane *ipu_plane, int mode)
-
- ipu_idmac_put(ipu_plane->ipu_ch);
- ipu_dmfc_put(ipu_plane->dmfc);
-- ipu_dp_put(ipu_plane->dp);
-+ if (ipu_plane->dp)
-+ ipu_dp_put(ipu_plane->dp);
- }
- }
-
-diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig
-index 209e4c7e6f8a..4f65ba1158bf 100644
---- a/drivers/staging/lustre/lustre/Kconfig
-+++ b/drivers/staging/lustre/lustre/Kconfig
-@@ -57,4 +57,5 @@ config LUSTRE_TRANSLATE_ERRNOS
- config LUSTRE_LLITE_LLOOP
- tristate "Lustre virtual block device"
- depends on LUSTRE_FS && BLOCK
-+ depends on !PPC_64K_PAGES && !ARM64_64K_PAGES
- default m
-diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
-index f329ad294fc0..104f29e6b290 100644
---- a/drivers/target/iscsi/iscsi_target.c
-+++ b/drivers/target/iscsi/iscsi_target.c
-@@ -4513,6 +4513,7 @@ static void iscsit_logout_post_handler_diffcid(
- {
- struct iscsi_conn *l_conn;
- struct iscsi_session *sess = conn->sess;
-+ bool conn_found = false;
-
- if (!sess)
- return;
-@@ -4521,12 +4522,13 @@ static void iscsit_logout_post_handler_diffcid(
- list_for_each_entry(l_conn, &sess->sess_conn_list, conn_list) {
- if (l_conn->cid == cid) {
- iscsit_inc_conn_usage_count(l_conn);
-+ conn_found = true;
- break;
- }
- }
- spin_unlock_bh(&sess->conn_lock);
-
-- if (!l_conn)
-+ if (!conn_found)
- return;
-
- if (l_conn->sock)
-diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
-index 4d2e23fc76fd..43b7e6a616b8 100644
---- a/drivers/target/iscsi/iscsi_target_parameters.c
-+++ b/drivers/target/iscsi/iscsi_target_parameters.c
-@@ -601,7 +601,7 @@ int iscsi_copy_param_list(
- param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
- if (!param_list) {
- pr_err("Unable to allocate memory for struct iscsi_param_list.\n");
-- goto err_out;
-+ return -1;
- }
- INIT_LIST_HEAD(¶m_list->param_list);
- INIT_LIST_HEAD(¶m_list->extra_response_list);
-diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
-index 483d324020a6..f30385385544 100644
---- a/drivers/target/target_core_configfs.c
-+++ b/drivers/target/target_core_configfs.c
-@@ -2359,7 +2359,7 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_support_##_name(\
- pr_err("Invalid value '%ld', must be '0' or '1'\n", tmp); \
- return -EINVAL; \
- } \
-- if (!tmp) \
-+ if (tmp) \
- t->_var |= _bit; \
- else \
- t->_var &= ~_bit; \
-diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
-index ab9096dc3849..148ffe4c232f 100644
---- a/drivers/tty/serial/8250/8250_dma.c
-+++ b/drivers/tty/serial/8250/8250_dma.c
-@@ -192,21 +192,28 @@ int serial8250_request_dma(struct uart_8250_port *p)
-
- dma->rx_buf = dma_alloc_coherent(dma->rxchan->device->dev, dma->rx_size,
- &dma->rx_addr, GFP_KERNEL);
-- if (!dma->rx_buf) {
-- dma_release_channel(dma->rxchan);
-- dma_release_channel(dma->txchan);
-- return -ENOMEM;
-- }
-+ if (!dma->rx_buf)
-+ goto err;
-
- /* TX buffer */
- dma->tx_addr = dma_map_single(dma->txchan->device->dev,
- p->port.state->xmit.buf,
- UART_XMIT_SIZE,
- DMA_TO_DEVICE);
-+ if (dma_mapping_error(dma->txchan->device->dev, dma->tx_addr)) {
-+ dma_free_coherent(dma->rxchan->device->dev, dma->rx_size,
-+ dma->rx_buf, dma->rx_addr);
-+ goto err;
-+ }
-
- dev_dbg_ratelimited(p->port.dev, "got both dma channels\n");
-
- return 0;
-+err:
-+ dma_release_channel(dma->rxchan);
-+ dma_release_channel(dma->txchan);
-+
-+ return -ENOMEM;
- }
- EXPORT_SYMBOL_GPL(serial8250_request_dma);
-
-diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c
-index 2d51d852b474..ca1123d415c5 100644
---- a/drivers/usb/chipidea/ci_hdrc_msm.c
-+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
-@@ -20,13 +20,13 @@
- static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
- {
- struct device *dev = ci->gadget.dev.parent;
-- int val;
-
- switch (event) {
- case CI_HDRC_CONTROLLER_RESET_EVENT:
- dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n");
- writel(0, USB_AHBBURST);
- writel(0, USB_AHBMODE);
-+ usb_phy_init(ci->transceiver);
- break;
- case CI_HDRC_CONTROLLER_STOPPED_EVENT:
- dev_dbg(dev, "CI_HDRC_CONTROLLER_STOPPED_EVENT received\n");
-@@ -34,10 +34,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event)
- * Put the transceiver in non-driving mode. Otherwise host
- * may not detect soft-disconnection.
- */
-- val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL);
-- val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
-- val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
-- usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL);
-+ usb_phy_notify_disconnect(ci->transceiver, USB_SPEED_UNKNOWN);
- break;
- default:
- dev_dbg(dev, "unknown ci_hdrc event\n");
-diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
-index 6650df70bb35..263612ce1f62 100644
---- a/drivers/usb/core/hub.c
-+++ b/drivers/usb/core/hub.c
-@@ -4764,9 +4764,10 @@ static void hub_events(void)
-
- hub = list_entry(tmp, struct usb_hub, event_list);
- kref_get(&hub->kref);
-+ hdev = hub->hdev;
-+ usb_get_dev(hdev);
- spin_unlock_irq(&hub_event_lock);
-
-- hdev = hub->hdev;
- hub_dev = hub->intfdev;
- intf = to_usb_interface(hub_dev);
- dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
-@@ -4979,6 +4980,7 @@ static void hub_events(void)
- usb_autopm_put_interface(intf);
- loop_disconnected:
- usb_unlock_device(hdev);
-+ usb_put_dev(hdev);
- kref_put(&hub->kref, hub_release);
-
- } /* end while (1) */
-diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
-index a49217ae3533..f074755372a0 100644
---- a/drivers/usb/dwc3/core.c
-+++ b/drivers/usb/dwc3/core.c
-@@ -583,12 +583,6 @@ static int dwc3_remove(struct platform_device *pdev)
- {
- struct dwc3 *dwc = platform_get_drvdata(pdev);
-
-- usb_phy_set_suspend(dwc->usb2_phy, 1);
-- usb_phy_set_suspend(dwc->usb3_phy, 1);
--
-- pm_runtime_put_sync(&pdev->dev);
-- pm_runtime_disable(&pdev->dev);
--
- dwc3_debugfs_exit(dwc);
-
- switch (dwc->dr_mode) {
-@@ -609,8 +603,15 @@ static int dwc3_remove(struct platform_device *pdev)
-
- dwc3_event_buffers_cleanup(dwc);
- dwc3_free_event_buffers(dwc);
-+
-+ usb_phy_set_suspend(dwc->usb2_phy, 1);
-+ usb_phy_set_suspend(dwc->usb3_phy, 1);
-+
- dwc3_core_exit(dwc);
-
-+ pm_runtime_put_sync(&pdev->dev);
-+ pm_runtime_disable(&pdev->dev);
-+
- return 0;
- }
-
-diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
-index b269dbd47fc4..2a6841c95b64 100644
---- a/drivers/usb/dwc3/dwc3-omap.c
-+++ b/drivers/usb/dwc3/dwc3-omap.c
-@@ -582,9 +582,9 @@ static int dwc3_omap_remove(struct platform_device *pdev)
- if (omap->extcon_id_dev.edev)
- extcon_unregister_interest(&omap->extcon_id_dev);
- dwc3_omap_disable_irqs(omap);
-+ device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);
- pm_runtime_put_sync(&pdev->dev);
- pm_runtime_disable(&pdev->dev);
-- device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);
-
- return 0;
- }
-diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
-index 81cda09b47e3..488a30836c36 100644
---- a/drivers/usb/host/ehci-hcd.c
-+++ b/drivers/usb/host/ehci-hcd.c
-@@ -965,8 +965,6 @@ rescan:
- }
-
- qh->exception = 1;
-- if (ehci->rh_state < EHCI_RH_RUNNING)
-- qh->qh_state = QH_STATE_IDLE;
- switch (qh->qh_state) {
- case QH_STATE_LINKED:
- WARN_ON(!list_empty(&qh->qtd_list));
-diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
-index 9992fbfec85f..93fe089cd51a 100644
---- a/drivers/usb/host/xhci-hub.c
-+++ b/drivers/usb/host/xhci-hub.c
-@@ -470,7 +470,8 @@ static void xhci_hub_report_usb2_link_state(u32 *status, u32 status_reg)
- }
-
- /* Updates Link Status for super Speed port */
--static void xhci_hub_report_usb3_link_state(u32 *status, u32 status_reg)
-+static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
-+ u32 *status, u32 status_reg)
- {
- u32 pls = status_reg & PORT_PLS_MASK;
-
-@@ -509,7 +510,8 @@ static void xhci_hub_report_usb3_link_state(u32 *status, u32 status_reg)
- * in which sometimes the port enters compliance mode
- * caused by a delay on the host-device negotiation.
- */
-- if (pls == USB_SS_PORT_LS_COMP_MOD)
-+ if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
-+ (pls == USB_SS_PORT_LS_COMP_MOD))
- pls |= USB_PORT_STAT_CONNECTION;
- }
-
-@@ -668,7 +670,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
- }
- /* Update Port Link State */
- if (hcd->speed == HCD_USB3) {
-- xhci_hub_report_usb3_link_state(&status, raw_port_status);
-+ xhci_hub_report_usb3_link_state(xhci, &status, raw_port_status);
- /*
- * Verify if all USB3 Ports Have entered U0 already.
- * Delete Compliance Mode Timer if so.
-diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
-index 4133a00461b1..9bce4f0e99be 100644
---- a/drivers/usb/host/xhci-mem.c
-+++ b/drivers/usb/host/xhci-mem.c
-@@ -1723,7 +1723,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
- }
-
- num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
-- for (i = 0; i < num_ports; i++) {
-+ for (i = 0; i < num_ports && xhci->rh_bw; i++) {
- struct xhci_interval_bw_table *bwt = &xhci->rh_bw[i].bw_table;
- for (j = 0; j < XHCI_MAX_INTERVAL; j++) {
- struct list_head *ep = &bwt->interval_bw[j].endpoints;
-diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
-index ab831048e8a4..82b563fc4fd6 100644
---- a/drivers/usb/host/xhci.c
-+++ b/drivers/usb/host/xhci.c
-@@ -3928,13 +3928,21 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
- int ret;
-
- spin_lock_irqsave(&xhci->lock, flags);
-- if (max_exit_latency == xhci->devs[udev->slot_id]->current_mel) {
-+
-+ virt_dev = xhci->devs[udev->slot_id];
-+
-+ /*
-+ * virt_dev might not exists yet if xHC resumed from hibernate (S4) and
-+ * xHC was re-initialized. Exit latency will be set later after
-+ * hub_port_finish_reset() is done and xhci->devs[] are re-allocated
-+ */
-+
-+ if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
- spin_unlock_irqrestore(&xhci->lock, flags);
- return 0;
- }
-
- /* Attempt to issue an Evaluate Context command to change the MEL. */
-- virt_dev = xhci->devs[udev->slot_id];
- command = xhci->lpm_command;
- ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx);
- if (!ctrl_ctx) {
-diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
-index de98906f786d..0aef801edbc1 100644
---- a/drivers/usb/misc/sisusbvga/sisusb.c
-+++ b/drivers/usb/misc/sisusbvga/sisusb.c
-@@ -3248,6 +3248,7 @@ static const struct usb_device_id sisusb_table[] = {
- { USB_DEVICE(0x0711, 0x0918) },
- { USB_DEVICE(0x0711, 0x0920) },
- { USB_DEVICE(0x0711, 0x0950) },
-+ { USB_DEVICE(0x0711, 0x5200) },
- { USB_DEVICE(0x182d, 0x021c) },
- { USB_DEVICE(0x182d, 0x0269) },
- { }
-diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
-index bbe4f8e6e8d7..8834b70c868c 100644
---- a/drivers/usb/phy/phy-tegra-usb.c
-+++ b/drivers/usb/phy/phy-tegra-usb.c
-@@ -881,8 +881,8 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
- return -ENOMEM;
- }
-
-- tegra_phy->config = devm_kzalloc(&pdev->dev,
-- sizeof(*tegra_phy->config), GFP_KERNEL);
-+ tegra_phy->config = devm_kzalloc(&pdev->dev, sizeof(*config),
-+ GFP_KERNEL);
- if (!tegra_phy->config) {
- dev_err(&pdev->dev,
- "unable to allocate memory for USB UTMIP config\n");
-diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
-index 8b0f517abb6b..3614620e09e1 100644
---- a/drivers/usb/serial/ftdi_sio.c
-+++ b/drivers/usb/serial/ftdi_sio.c
-@@ -741,6 +741,7 @@ static const struct usb_device_id id_table_combined[] = {
- { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
- .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
- { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
-+ { USB_DEVICE(NOVITUS_VID, NOVITUS_BONO_E_PID) },
- { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S03_PID) },
- { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_59_PID) },
- { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57A_PID) },
-@@ -952,6 +953,8 @@ static const struct usb_device_id id_table_combined[] = {
- { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },
- /* Infineon Devices */
- { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) },
-+ /* GE Healthcare devices */
-+ { USB_DEVICE(GE_HEALTHCARE_VID, GE_HEALTHCARE_NEMO_TRACKER_PID) },
- { } /* Terminating entry */
- };
-
-diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
-index 70b0b1d88ae9..5937b2d242f2 100644
---- a/drivers/usb/serial/ftdi_sio_ids.h
-+++ b/drivers/usb/serial/ftdi_sio_ids.h
-@@ -837,6 +837,12 @@
- #define TELLDUS_TELLSTICK_PID 0x0C30 /* RF control dongle 433 MHz using FT232RL */
-
- /*
-+ * NOVITUS printers
-+ */
-+#define NOVITUS_VID 0x1a28
-+#define NOVITUS_BONO_E_PID 0x6010
-+
-+/*
- * RT Systems programming cables for various ham radios
- */
- #define RTSYSTEMS_VID 0x2100 /* Vendor ID */
-@@ -1385,3 +1391,9 @@
- * ekey biometric systems GmbH (http://ekey.net/)
- */
- #define FTDI_EKEY_CONV_USB_PID 0xCB08 /* Converter USB */
-+
-+/*
-+ * GE Healthcare devices
-+ */
-+#define GE_HEALTHCARE_VID 0x1901
-+#define GE_HEALTHCARE_NEMO_TRACKER_PID 0x0015
-diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
-index 9da566a3f5c8..e47aabe0c760 100644
---- a/drivers/usb/serial/option.c
-+++ b/drivers/usb/serial/option.c
-@@ -275,8 +275,12 @@ static void option_instat_callback(struct urb *urb);
- #define ZTE_PRODUCT_MF622 0x0001
- #define ZTE_PRODUCT_MF628 0x0015
- #define ZTE_PRODUCT_MF626 0x0031
--#define ZTE_PRODUCT_MC2718 0xffe8
- #define ZTE_PRODUCT_AC2726 0xfff1
-+#define ZTE_PRODUCT_CDMA_TECH 0xfffe
-+#define ZTE_PRODUCT_AC8710T 0xffff
-+#define ZTE_PRODUCT_MC2718 0xffe8
-+#define ZTE_PRODUCT_AD3812 0xffeb
-+#define ZTE_PRODUCT_MC2716 0xffed
-
- #define BENQ_VENDOR_ID 0x04a5
- #define BENQ_PRODUCT_H10 0x4068
-@@ -494,6 +498,10 @@ static void option_instat_callback(struct urb *urb);
- #define INOVIA_VENDOR_ID 0x20a6
- #define INOVIA_SEW858 0x1105
-
-+/* VIA Telecom */
-+#define VIATELECOM_VENDOR_ID 0x15eb
-+#define VIATELECOM_PRODUCT_CDS7 0x0001
-+
- /* some devices interfaces need special handling due to a number of reasons */
- enum option_blacklist_reason {
- OPTION_BLACKLIST_NONE = 0,
-@@ -527,10 +535,18 @@ static const struct option_blacklist_info zte_k3765_z_blacklist = {
- .reserved = BIT(4),
- };
-
-+static const struct option_blacklist_info zte_ad3812_z_blacklist = {
-+ .sendsetup = BIT(0) | BIT(1) | BIT(2),
-+};
-+
- static const struct option_blacklist_info zte_mc2718_z_blacklist = {
- .sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4),
- };
-
-+static const struct option_blacklist_info zte_mc2716_z_blacklist = {
-+ .sendsetup = BIT(1) | BIT(2) | BIT(3),
-+};
-+
- static const struct option_blacklist_info huawei_cdc12_blacklist = {
- .reserved = BIT(1) | BIT(2),
- };
-@@ -1070,6 +1086,7 @@ static const struct usb_device_id option_ids[] = {
- { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) },
- { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
- { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
-+ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
- { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
- { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
- { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
-@@ -1544,13 +1561,18 @@ static const struct usb_device_id option_ids[] = {
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff93, 0xff, 0xff, 0xff) },
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff94, 0xff, 0xff, 0xff) },
-
-- /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */
-+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
-+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
-+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) },
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 0xff, 0xff, 0xff),
- .driver_info = (kernel_ulong_t)&zte_mc2718_z_blacklist },
-+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AD3812, 0xff, 0xff, 0xff),
-+ .driver_info = (kernel_ulong_t)&zte_ad3812_z_blacklist },
-+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 0xff, 0xff, 0xff),
-+ .driver_info = (kernel_ulong_t)&zte_mc2716_z_blacklist },
- { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
- { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
- { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
-- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
-
- { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
- { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
-@@ -1724,6 +1746,7 @@ static const struct usb_device_id option_ids[] = {
- { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
- { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
- { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
-+ { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
- { } /* Terminating entry */
- };
- MODULE_DEVICE_TABLE(usb, option_ids);
-diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
-index b3d5a35c0d4b..e9bad928039f 100644
---- a/drivers/usb/serial/pl2303.c
-+++ b/drivers/usb/serial/pl2303.c
-@@ -45,6 +45,7 @@ static const struct usb_device_id id_table[] = {
- { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
- { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
- { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) },
-+ { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) },
- { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
- { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
- { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
-diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
-index 42bc082896ac..71fd9da1d6e7 100644
---- a/drivers/usb/serial/pl2303.h
-+++ b/drivers/usb/serial/pl2303.h
-@@ -22,6 +22,7 @@
- #define PL2303_PRODUCT_ID_GPRS 0x0609
- #define PL2303_PRODUCT_ID_HCR331 0x331a
- #define PL2303_PRODUCT_ID_MOTOROLA 0x0307
-+#define PL2303_PRODUCT_ID_ZTEK 0xe1f1
-
- #define ATEN_VENDOR_ID 0x0557
- #define ATEN_VENDOR_ID2 0x0547
-diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
-index 37480348e39b..74a9375a9bb5 100644
---- a/drivers/usb/serial/sierra.c
-+++ b/drivers/usb/serial/sierra.c
-@@ -282,14 +282,19 @@ static const struct usb_device_id id_table[] = {
- /* Sierra Wireless HSPA Non-Composite Device */
- { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
- { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
-- { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */
-+ /* Sierra Wireless Direct IP modems */
-+ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68A3, 0xFF, 0xFF, 0xFF),
-+ .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
-+ },
-+ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF),
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
- },
- /* AT&T Direct IP LTE modems */
- { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF),
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
- },
-- { USB_DEVICE(0x0f3d, 0x68A3), /* Airprime/Sierra Wireless Direct IP modems */
-+ /* Airprime/Sierra Wireless Direct IP modems */
-+ { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68A3, 0xFF, 0xFF, 0xFF),
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
- },
-
-diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
-index b169b0f9b3a2..9a08e18e09b9 100644
---- a/drivers/usb/serial/usb-serial.c
-+++ b/drivers/usb/serial/usb-serial.c
-@@ -764,29 +764,39 @@ static int usb_serial_probe(struct usb_interface *interface,
- if (usb_endpoint_is_bulk_in(endpoint)) {
- /* we found a bulk in endpoint */
- dev_dbg(ddev, "found bulk in on endpoint %d\n", i);
-- bulk_in_endpoint[num_bulk_in] = endpoint;
-- ++num_bulk_in;
-+ if (num_bulk_in < MAX_NUM_PORTS) {
-+ bulk_in_endpoint[num_bulk_in] = endpoint;
-+ ++num_bulk_in;
-+ }
- }
-
- if (usb_endpoint_is_bulk_out(endpoint)) {
- /* we found a bulk out endpoint */
- dev_dbg(ddev, "found bulk out on endpoint %d\n", i);
-- bulk_out_endpoint[num_bulk_out] = endpoint;
-- ++num_bulk_out;
-+ if (num_bulk_out < MAX_NUM_PORTS) {
-+ bulk_out_endpoint[num_bulk_out] = endpoint;
-+ ++num_bulk_out;
-+ }
- }
-
- if (usb_endpoint_is_int_in(endpoint)) {
- /* we found a interrupt in endpoint */
- dev_dbg(ddev, "found interrupt in on endpoint %d\n", i);
-- interrupt_in_endpoint[num_interrupt_in] = endpoint;
-- ++num_interrupt_in;
-+ if (num_interrupt_in < MAX_NUM_PORTS) {
-+ interrupt_in_endpoint[num_interrupt_in] =
-+ endpoint;
-+ ++num_interrupt_in;
-+ }
- }
-
- if (usb_endpoint_is_int_out(endpoint)) {
- /* we found an interrupt out endpoint */
- dev_dbg(ddev, "found interrupt out on endpoint %d\n", i);
-- interrupt_out_endpoint[num_interrupt_out] = endpoint;
-- ++num_interrupt_out;
-+ if (num_interrupt_out < MAX_NUM_PORTS) {
-+ interrupt_out_endpoint[num_interrupt_out] =
-+ endpoint;
-+ ++num_interrupt_out;
-+ }
- }
- }
-
-@@ -809,8 +819,10 @@ static int usb_serial_probe(struct usb_interface *interface,
- if (usb_endpoint_is_int_in(endpoint)) {
- /* we found a interrupt in endpoint */
- dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n");
-- interrupt_in_endpoint[num_interrupt_in] = endpoint;
-- ++num_interrupt_in;
-+ if (num_interrupt_in < MAX_NUM_PORTS) {
-+ interrupt_in_endpoint[num_interrupt_in] = endpoint;
-+ ++num_interrupt_in;
-+ }
- }
- }
- }
-@@ -850,6 +862,11 @@ static int usb_serial_probe(struct usb_interface *interface,
- num_ports = type->num_ports;
- }
-
-+ if (num_ports > MAX_NUM_PORTS) {
-+ dev_warn(ddev, "too many ports requested: %d\n", num_ports);
-+ num_ports = MAX_NUM_PORTS;
-+ }
-+
- serial->num_ports = num_ports;
- serial->num_bulk_in = num_bulk_in;
- serial->num_bulk_out = num_bulk_out;
-diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c
-index e40ab739c4a6..c9bb107d5e5c 100644
---- a/drivers/usb/serial/zte_ev.c
-+++ b/drivers/usb/serial/zte_ev.c
-@@ -272,28 +272,16 @@ static void zte_ev_usb_serial_close(struct usb_serial_port *port)
- }
-
- static const struct usb_device_id id_table[] = {
-- /* AC8710, AC8710T */
-- { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffff, 0xff, 0xff, 0xff) },
-- /* AC8700 */
-- { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
-- /* MG880 */
-- { USB_DEVICE(0x19d2, 0xfffd) },
-- { USB_DEVICE(0x19d2, 0xfffc) },
-- { USB_DEVICE(0x19d2, 0xfffb) },
-- /* AC8710_V3 */
-+ { USB_DEVICE(0x19d2, 0xffec) },
-+ { USB_DEVICE(0x19d2, 0xffee) },
- { USB_DEVICE(0x19d2, 0xfff6) },
- { USB_DEVICE(0x19d2, 0xfff7) },
- { USB_DEVICE(0x19d2, 0xfff8) },
- { USB_DEVICE(0x19d2, 0xfff9) },
-- { USB_DEVICE(0x19d2, 0xffee) },
-- /* AC2716, MC2716 */
-- { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffed, 0xff, 0xff, 0xff) },
-- /* AD3812 */
-- { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xffeb, 0xff, 0xff, 0xff) },
-- { USB_DEVICE(0x19d2, 0xffec) },
-- { USB_DEVICE(0x05C6, 0x3197) },
-- { USB_DEVICE(0x05C6, 0x6000) },
-- { USB_DEVICE(0x05C6, 0x9008) },
-+ { USB_DEVICE(0x19d2, 0xfffb) },
-+ { USB_DEVICE(0x19d2, 0xfffc) },
-+ /* MG880 */
-+ { USB_DEVICE(0x19d2, 0xfffd) },
- { },
- };
- MODULE_DEVICE_TABLE(usb, id_table);
-diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
-index 042c83b01046..7f625306ea80 100644
---- a/drivers/usb/storage/unusual_devs.h
-+++ b/drivers/usb/storage/unusual_devs.h
-@@ -101,6 +101,12 @@ UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001,
- "PhotoSmart R707",
- USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_CAPACITY),
-
-+UNUSUAL_DEV( 0x03f3, 0x0001, 0x0000, 0x9999,
-+ "Adaptec",
-+ "USBConnect 2000",
-+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
-+ US_FL_SCM_MULT_TARG ),
-+
- /* Reported by Sebastian Kapfer
- * and Olaf Hering (different bcd's, same vendor/product)
- * for USB floppies that need the SINGLE_LUN enforcement.
-@@ -741,6 +747,12 @@ UNUSUAL_DEV( 0x059b, 0x0001, 0x0100, 0x0100,
- USB_SC_DEVICE, USB_PR_DEVICE, NULL,
- US_FL_SINGLE_LUN ),
-
-+UNUSUAL_DEV( 0x059b, 0x0040, 0x0100, 0x0100,
-+ "Iomega",
-+ "Jaz USB Adapter",
-+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-+ US_FL_SINGLE_LUN ),
-+
- /* Reported by */
- UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
- "LaCie",
-@@ -1113,6 +1125,18 @@ UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200,
- USB_SC_DEVICE, USB_PR_DEVICE, NULL,
- US_FL_NOT_LOCKABLE),
-
-+UNUSUAL_DEV( 0x085a, 0x0026, 0x0100, 0x0133,
-+ "Xircom",
-+ "PortGear USB-SCSI (Mac USB Dock)",
-+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
-+ US_FL_SCM_MULT_TARG ),
-+
-+UNUSUAL_DEV( 0x085a, 0x0028, 0x0100, 0x0133,
-+ "Xircom",
-+ "PortGear USB to SCSI Converter",
-+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
-+ US_FL_SCM_MULT_TARG ),
-+
- /* Submitted by Jan De Luyck */
- UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000,
- "CITIZEN",
-@@ -1945,6 +1969,14 @@ UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
- USB_SC_DEVICE, USB_PR_DEVICE, NULL,
- US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
-
-+/* Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI)
-+ * and Mac USB Dock USB-SCSI */
-+UNUSUAL_DEV( 0x1645, 0x0007, 0x0100, 0x0133,
-+ "Entrega Technologies",
-+ "USB to SCSI Converter",
-+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
-+ US_FL_SCM_MULT_TARG ),
-+
- /* Reported by Robert Schedel
- * Note: this is a 'super top' device like the above 14cd/6600 device */
- UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
-@@ -1967,6 +1999,12 @@ UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000,
- USB_SC_DEVICE, USB_PR_DEVICE, NULL,
- US_FL_BULK_IGNORE_TAG | US_FL_MAX_SECTORS_64 ),
-
-+UNUSUAL_DEV( 0x1822, 0x0001, 0x0000, 0x9999,
-+ "Ariston Technologies",
-+ "iConnect USB to SCSI adapter",
-+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
-+ US_FL_SCM_MULT_TARG ),
-+
- /* Reported by Hans de Goede
- * These Appotech controllers are found in Picture Frames, they provide a
- * (buggy) emulation of a cdrom drive which contains the windows software
-diff --git a/drivers/uwb/lc-dev.c b/drivers/uwb/lc-dev.c
-index 80079b8fed15..d0303f0dbe15 100644
---- a/drivers/uwb/lc-dev.c
-+++ b/drivers/uwb/lc-dev.c
-@@ -431,16 +431,19 @@ void uwbd_dev_onair(struct uwb_rc *rc, struct uwb_beca_e *bce)
- uwb_dev->mac_addr = *bce->mac_addr;
- uwb_dev->dev_addr = bce->dev_addr;
- dev_set_name(&uwb_dev->dev, "%s", macbuf);
-+
-+ /* plug the beacon cache */
-+ bce->uwb_dev = uwb_dev;
-+ uwb_dev->bce = bce;
-+ uwb_bce_get(bce); /* released in uwb_dev_sys_release() */
-+
- result = uwb_dev_add(uwb_dev, &rc->uwb_dev.dev, rc);
- if (result < 0) {
- dev_err(dev, "new device %s: cannot instantiate device\n",
- macbuf);
- goto error_dev_add;
- }
-- /* plug the beacon cache */
-- bce->uwb_dev = uwb_dev;
-- uwb_dev->bce = bce;
-- uwb_bce_get(bce); /* released in uwb_dev_sys_release() */
-+
- dev_info(dev, "uwb device (mac %s dev %s) connected to %s %s\n",
- macbuf, devbuf, rc->uwb_dev.dev.parent->bus->name,
- dev_name(rc->uwb_dev.dev.parent));
-@@ -448,6 +451,8 @@ void uwbd_dev_onair(struct uwb_rc *rc, struct uwb_beca_e *bce)
- return;
-
- error_dev_add:
-+ bce->uwb_dev = NULL;
-+ uwb_bce_put(bce);
- kfree(uwb_dev);
- return;
- }
-diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
-index 624e8dc24532..602913d7ae03 100644
---- a/drivers/xen/manage.c
-+++ b/drivers/xen/manage.c
-@@ -111,16 +111,11 @@ static void do_suspend(void)
-
- shutting_down = SHUTDOWN_SUSPEND;
-
--#ifdef CONFIG_PREEMPT
-- /* If the kernel is preemptible, we need to freeze all the processes
-- to prevent them from being in the middle of a pagetable update
-- during suspend. */
- err = freeze_processes();
- if (err) {
- pr_err("%s: freeze failed %d\n", __func__, err);
- goto out;
- }
--#endif
-
- err = dpm_suspend_start(PMSG_FREEZE);
- if (err) {
-@@ -169,10 +164,8 @@ out_resume:
- dpm_resume_end(si.cancelled ? PMSG_THAW : PMSG_RESTORE);
-
- out_thaw:
--#ifdef CONFIG_PREEMPT
- thaw_processes();
- out:
--#endif
- shutting_down = SHUTDOWN_INVALID;
- }
- #endif /* CONFIG_HIBERNATE_CALLBACKS */
-diff --git a/fs/aio.c b/fs/aio.c
-index 6d68e01dc7ca..f45ddaa4fffa 100644
---- a/fs/aio.c
-+++ b/fs/aio.c
-@@ -141,6 +141,7 @@ struct kioctx {
-
- struct {
- unsigned tail;
-+ unsigned completed_events;
- spinlock_t completion_lock;
- } ____cacheline_aligned_in_smp;
-
-@@ -796,6 +797,9 @@ void exit_aio(struct mm_struct *mm)
- unsigned i = 0;
-
- while (1) {
-+ struct completion requests_done =
-+ COMPLETION_INITIALIZER_ONSTACK(requests_done);
-+
- rcu_read_lock();
- table = rcu_dereference(mm->ioctx_table);
-
-@@ -823,7 +827,10 @@ void exit_aio(struct mm_struct *mm)
- */
- ctx->mmap_size = 0;
-
-- kill_ioctx(mm, ctx, NULL);
-+ kill_ioctx(mm, ctx, &requests_done);
-+
-+ /* Wait until all IO for the context are done. */
-+ wait_for_completion(&requests_done);
- }
- }
-
-@@ -880,6 +887,68 @@ out:
- return ret;
- }
-
-+/* refill_reqs_available
-+ * Updates the reqs_available reference counts used for tracking the
-+ * number of free slots in the completion ring. This can be called
-+ * from aio_complete() (to optimistically update reqs_available) or
-+ * from aio_get_req() (the we're out of events case). It must be
-+ * called holding ctx->completion_lock.
-+ */
-+static void refill_reqs_available(struct kioctx *ctx, unsigned head,
-+ unsigned tail)
-+{
-+ unsigned events_in_ring, completed;
-+
-+ /* Clamp head since userland can write to it. */
-+ head %= ctx->nr_events;
-+ if (head <= tail)
-+ events_in_ring = tail - head;
-+ else
-+ events_in_ring = ctx->nr_events - (head - tail);
-+
-+ completed = ctx->completed_events;
-+ if (events_in_ring < completed)
-+ completed -= events_in_ring;
-+ else
-+ completed = 0;
-+
-+ if (!completed)
-+ return;
-+
-+ ctx->completed_events -= completed;
-+ put_reqs_available(ctx, completed);
-+}
-+
-+/* user_refill_reqs_available
-+ * Called to refill reqs_available when aio_get_req() encounters an
-+ * out of space in the completion ring.
-+ */
-+static void user_refill_reqs_available(struct kioctx *ctx)
-+{
-+ spin_lock_irq(&ctx->completion_lock);
-+ if (ctx->completed_events) {
-+ struct aio_ring *ring;
-+ unsigned head;
-+
-+ /* Access of ring->head may race with aio_read_events_ring()
-+ * here, but that's okay since whether we read the old version
-+ * or the new version, and either will be valid. The important
-+ * part is that head cannot pass tail since we prevent
-+ * aio_complete() from updating tail by holding
-+ * ctx->completion_lock. Even if head is invalid, the check
-+ * against ctx->completed_events below will make sure we do the
-+ * safe/right thing.
-+ */
-+ ring = kmap_atomic(ctx->ring_pages[0]);
-+ head = ring->head;
-+ kunmap_atomic(ring);
-+
-+ refill_reqs_available(ctx, head, ctx->tail);
-+ }
-+
-+ spin_unlock_irq(&ctx->completion_lock);
-+}
-+
- /* aio_get_req
- * Allocate a slot for an aio request.
- * Returns NULL if no requests are free.
-@@ -888,8 +957,11 @@ static inline struct kiocb *aio_get_req(struct kioctx *ctx)
- {
- struct kiocb *req;
-
-- if (!get_reqs_available(ctx))
-- return NULL;
-+ if (!get_reqs_available(ctx)) {
-+ user_refill_reqs_available(ctx);
-+ if (!get_reqs_available(ctx))
-+ return NULL;
-+ }
-
- req = kmem_cache_alloc(kiocb_cachep, GFP_KERNEL|__GFP_ZERO);
- if (unlikely(!req))
-@@ -948,8 +1020,8 @@ void aio_complete(struct kiocb *iocb, long res, long res2)
- struct kioctx *ctx = iocb->ki_ctx;
- struct aio_ring *ring;
- struct io_event *ev_page, *event;
-+ unsigned tail, pos, head;
- unsigned long flags;
-- unsigned tail, pos;
-
- /*
- * Special case handling for sync iocbs:
-@@ -1010,10 +1082,14 @@ void aio_complete(struct kiocb *iocb, long res, long res2)
- ctx->tail = tail;
-
- ring = kmap_atomic(ctx->ring_pages[0]);
-+ head = ring->head;
- ring->tail = tail;
- kunmap_atomic(ring);
- flush_dcache_page(ctx->ring_pages[0]);
-
-+ ctx->completed_events++;
-+ if (ctx->completed_events > 1)
-+ refill_reqs_available(ctx, head, tail);
- spin_unlock_irqrestore(&ctx->completion_lock, flags);
-
- pr_debug("added to ring %p at [%u]\n", iocb, tail);
-@@ -1028,7 +1104,6 @@ void aio_complete(struct kiocb *iocb, long res, long res2)
-
- /* everything turned out well, dispose of the aiocb. */
- kiocb_free(iocb);
-- put_reqs_available(ctx, 1);
-
- /*
- * We have to order our ring_info tail store above and test
-@@ -1065,6 +1140,12 @@ static long aio_read_events_ring(struct kioctx *ctx,
- tail = ring->tail;
- kunmap_atomic(ring);
-
-+ /*
-+ * Ensure that once we've read the current tail pointer, that
-+ * we also see the events that were stored up to the tail.
-+ */
-+ smp_rmb();
-+
- pr_debug("h%u t%u m%u\n", head, tail, ctx->nr_events);
-
- if (head == tail)
-diff --git a/fs/buffer.c b/fs/buffer.c
-index 27265a8b43c1..71e2d0ed8530 100644
---- a/fs/buffer.c
-+++ b/fs/buffer.c
-@@ -1029,7 +1029,8 @@ grow_dev_page(struct block_device *bdev, sector_t block,
- bh = page_buffers(page);
- if (bh->b_size == size) {
- end_block = init_page_buffers(page, bdev,
-- index << sizebits, size);
-+ (sector_t)index << sizebits,
-+ size);
- goto done;
- }
- if (!try_to_free_buffers(page))
-@@ -1050,7 +1051,8 @@ grow_dev_page(struct block_device *bdev, sector_t block,
- */
- spin_lock(&inode->i_mapping->private_lock);
- link_dev_buffers(page, bh);
-- end_block = init_page_buffers(page, bdev, index << sizebits, size);
-+ end_block = init_page_buffers(page, bdev, (sector_t)index << sizebits,
-+ size);
- spin_unlock(&inode->i_mapping->private_lock);
- done:
- ret = (block < end_block) ? 1 : -ENXIO;
-diff --git a/fs/cifs/link.c b/fs/cifs/link.c
-index 68559fd557fb..a5c2812ead68 100644
---- a/fs/cifs/link.c
-+++ b/fs/cifs/link.c
-@@ -213,8 +213,12 @@ create_mf_symlink(const unsigned int xid, struct cifs_tcon *tcon,
- if (rc)
- goto out;
-
-- rc = tcon->ses->server->ops->create_mf_symlink(xid, tcon, cifs_sb,
-- fromName, buf, &bytes_written);
-+ if (tcon->ses->server->ops->create_mf_symlink)
-+ rc = tcon->ses->server->ops->create_mf_symlink(xid, tcon,
-+ cifs_sb, fromName, buf, &bytes_written);
-+ else
-+ rc = -EOPNOTSUPP;
-+
- if (rc)
- goto out;
-
-diff --git a/fs/eventpoll.c b/fs/eventpoll.c
-index ead00467282d..f50d79eb52db 100644
---- a/fs/eventpoll.c
-+++ b/fs/eventpoll.c
-@@ -1852,7 +1852,8 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
- goto error_tgt_fput;
-
- /* Check if EPOLLWAKEUP is allowed */
-- ep_take_care_of_epollwakeup(&epds);
-+ if (ep_op_has_event(op))
-+ ep_take_care_of_epollwakeup(&epds);
-
- /*
- * We have to check that the file structure underneath the file descriptor
-diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
-index 5c524180c98e..bc643b97423c 100644
---- a/fs/gfs2/inode.c
-+++ b/fs/gfs2/inode.c
-@@ -606,8 +606,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
- if (!IS_ERR(inode)) {
- d = d_splice_alias(inode, dentry);
- error = PTR_ERR(d);
-- if (IS_ERR(d))
-+ if (IS_ERR(d)) {
-+ inode = ERR_CAST(d);
- goto fail_gunlock;
-+ }
- error = 0;
- if (file) {
- if (S_ISREG(inode->i_mode)) {
-@@ -823,7 +825,6 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
-
- d = d_splice_alias(inode, dentry);
- if (IS_ERR(d)) {
-- iput(inode);
- gfs2_glock_dq_uninit(&gh);
- return d;
- }
-diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
-index 6bf06a07f3e0..223e1cb14345 100644
---- a/fs/lockd/svc.c
-+++ b/fs/lockd/svc.c
-@@ -253,13 +253,11 @@ static int lockd_up_net(struct svc_serv *serv, struct net *net)
-
- error = make_socks(serv, net);
- if (error < 0)
-- goto err_socks;
-+ goto err_bind;
- set_grace_period(net);
- dprintk("lockd_up_net: per-net data created; net=%p\n", net);
- return 0;
-
--err_socks:
-- svc_rpcb_cleanup(serv, net);
- err_bind:
- ln->nlmsvc_users--;
- return error;
-diff --git a/fs/namei.c b/fs/namei.c
-index d5a4faeb39a5..dd2f2c5bda55 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -642,24 +642,22 @@ static int complete_walk(struct nameidata *nd)
-
- static __always_inline void set_root(struct nameidata *nd)
- {
-- if (!nd->root.mnt)
-- get_fs_root(current->fs, &nd->root);
-+ get_fs_root(current->fs, &nd->root);
- }
-
- static int link_path_walk(const char *, struct nameidata *);
-
--static __always_inline void set_root_rcu(struct nameidata *nd)
-+static __always_inline unsigned set_root_rcu(struct nameidata *nd)
- {
-- if (!nd->root.mnt) {
-- struct fs_struct *fs = current->fs;
-- unsigned seq;
-+ struct fs_struct *fs = current->fs;
-+ unsigned seq, res;
-
-- do {
-- seq = read_seqcount_begin(&fs->seq);
-- nd->root = fs->root;
-- nd->seq = __read_seqcount_begin(&nd->root.dentry->d_seq);
-- } while (read_seqcount_retry(&fs->seq, seq));
-- }
-+ do {
-+ seq = read_seqcount_begin(&fs->seq);
-+ nd->root = fs->root;
-+ res = __read_seqcount_begin(&nd->root.dentry->d_seq);
-+ } while (read_seqcount_retry(&fs->seq, seq));
-+ return res;
- }
-
- static void path_put_conditional(struct path *path, struct nameidata *nd)
-@@ -859,7 +857,8 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
- return PTR_ERR(s);
- }
- if (*s == '/') {
-- set_root(nd);
-+ if (!nd->root.mnt)
-+ set_root(nd);
- path_put(&nd->path);
- nd->path = nd->root;
- path_get(&nd->root);
-@@ -1132,7 +1131,8 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
-
- static int follow_dotdot_rcu(struct nameidata *nd)
- {
-- set_root_rcu(nd);
-+ if (!nd->root.mnt)
-+ set_root_rcu(nd);
-
- while (1) {
- if (nd->path.dentry == nd->root.dentry &&
-@@ -1244,7 +1244,8 @@ static void follow_mount(struct path *path)
-
- static void follow_dotdot(struct nameidata *nd)
- {
-- set_root(nd);
-+ if (!nd->root.mnt)
-+ set_root(nd);
-
- while(1) {
- struct dentry *old = nd->path.dentry;
-@@ -1842,7 +1843,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
- if (*name=='/') {
- if (flags & LOOKUP_RCU) {
- rcu_read_lock();
-- set_root_rcu(nd);
-+ nd->seq = set_root_rcu(nd);
- } else {
- set_root(nd);
- path_get(&nd->root);
-diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
-index 0e46d3d1b6cc..1abe4f55dea2 100644
---- a/fs/nfs/nfs4client.c
-+++ b/fs/nfs/nfs4client.c
-@@ -482,6 +482,16 @@ int nfs40_walk_client_list(struct nfs_client *new,
-
- spin_lock(&nn->nfs_client_lock);
- list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
-+
-+ if (pos->rpc_ops != new->rpc_ops)
-+ continue;
-+
-+ if (pos->cl_proto != new->cl_proto)
-+ continue;
-+
-+ if (pos->cl_minorversion != new->cl_minorversion)
-+ continue;
-+
- /* If "pos" isn't marked ready, we can't trust the
- * remaining fields in "pos" */
- if (pos->cl_cons_state > NFS_CS_READY) {
-@@ -501,15 +511,6 @@ int nfs40_walk_client_list(struct nfs_client *new,
- if (pos->cl_cons_state != NFS_CS_READY)
- continue;
-
-- if (pos->rpc_ops != new->rpc_ops)
-- continue;
--
-- if (pos->cl_proto != new->cl_proto)
-- continue;
--
-- if (pos->cl_minorversion != new->cl_minorversion)
-- continue;
--
- if (pos->cl_clientid != new->cl_clientid)
- continue;
-
-@@ -615,6 +616,16 @@ int nfs41_walk_client_list(struct nfs_client *new,
-
- spin_lock(&nn->nfs_client_lock);
- list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
-+
-+ if (pos->rpc_ops != new->rpc_ops)
-+ continue;
-+
-+ if (pos->cl_proto != new->cl_proto)
-+ continue;
-+
-+ if (pos->cl_minorversion != new->cl_minorversion)
-+ continue;
-+
- /* If "pos" isn't marked ready, we can't trust the
- * remaining fields in "pos", especially the client
- * ID and serverowner fields. Wait for CREATE_SESSION
-@@ -640,15 +651,6 @@ int nfs41_walk_client_list(struct nfs_client *new,
- if (pos->cl_cons_state != NFS_CS_READY)
- continue;
-
-- if (pos->rpc_ops != new->rpc_ops)
-- continue;
--
-- if (pos->cl_proto != new->cl_proto)
-- continue;
--
-- if (pos->cl_minorversion != new->cl_minorversion)
-- continue;
--
- if (!nfs4_match_clientids(pos, new))
- continue;
-
-diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
-index 17f91a72840b..2e9662ea5451 100644
---- a/fs/nfs/nfs4proc.c
-+++ b/fs/nfs/nfs4proc.c
-@@ -2558,23 +2558,23 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
- is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
- is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
- is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
-- /* Calculate the current open share mode */
-- calldata->arg.fmode = 0;
-- if (is_rdonly || is_rdwr)
-- calldata->arg.fmode |= FMODE_READ;
-- if (is_wronly || is_rdwr)
-- calldata->arg.fmode |= FMODE_WRITE;
- /* Calculate the change in open mode */
-+ calldata->arg.fmode = 0;
- if (state->n_rdwr == 0) {
-- if (state->n_rdonly == 0) {
-- call_close |= is_rdonly || is_rdwr;
-- calldata->arg.fmode &= ~FMODE_READ;
-- }
-- if (state->n_wronly == 0) {
-- call_close |= is_wronly || is_rdwr;
-- calldata->arg.fmode &= ~FMODE_WRITE;
-- }
-- }
-+ if (state->n_rdonly == 0)
-+ call_close |= is_rdonly;
-+ else if (is_rdonly)
-+ calldata->arg.fmode |= FMODE_READ;
-+ if (state->n_wronly == 0)
-+ call_close |= is_wronly;
-+ else if (is_wronly)
-+ calldata->arg.fmode |= FMODE_WRITE;
-+ } else if (is_rdwr)
-+ calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;
-+
-+ if (calldata->arg.fmode == 0)
-+ call_close |= is_rdwr;
-+
- if (!nfs4_valid_open_stateid(state))
- call_close = 0;
- spin_unlock(&state->owner->so_lock);
-diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
-index 7e350c562e0e..1e0bbae06ee7 100644
---- a/fs/nilfs2/inode.c
-+++ b/fs/nilfs2/inode.c
-@@ -24,6 +24,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include "nilfs.h"
-@@ -219,10 +220,10 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
-
- static int nilfs_set_page_dirty(struct page *page)
- {
-+ struct inode *inode = page->mapping->host;
- int ret = __set_page_dirty_nobuffers(page);
-
- if (page_has_buffers(page)) {
-- struct inode *inode = page->mapping->host;
- unsigned nr_dirty = 0;
- struct buffer_head *bh, *head;
-
-@@ -245,6 +246,10 @@ static int nilfs_set_page_dirty(struct page *page)
-
- if (nr_dirty)
- nilfs_set_file_dirty(inode, nr_dirty);
-+ } else if (ret) {
-+ unsigned nr_dirty = 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits);
-+
-+ nilfs_set_file_dirty(inode, nr_dirty);
- }
- return ret;
- }
-diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
-index 238a5930cb3c..9d7e2b9659cb 100644
---- a/fs/notify/fdinfo.c
-+++ b/fs/notify/fdinfo.c
-@@ -42,7 +42,7 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
- {
- struct {
- struct file_handle handle;
-- u8 pad[64];
-+ u8 pad[MAX_HANDLE_SZ];
- } f;
- int size, ret, i;
-
-@@ -50,7 +50,7 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
- size = f.handle.handle_bytes >> 2;
-
- ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
-- if ((ret == 255) || (ret == -ENOSPC)) {
-+ if ((ret == FILEID_INVALID) || (ret < 0)) {
- WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
- return 0;
- }
-diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
-index af3f7aa73e13..1be3398c96f6 100644
---- a/fs/ocfs2/dlm/dlmmaster.c
-+++ b/fs/ocfs2/dlm/dlmmaster.c
-@@ -650,12 +650,9 @@ void dlm_lockres_clear_refmap_bit(struct dlm_ctxt *dlm,
- clear_bit(bit, res->refmap);
- }
-
--
--void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
-+static void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
- struct dlm_lock_resource *res)
- {
-- assert_spin_locked(&res->spinlock);
--
- res->inflight_locks++;
-
- mlog(0, "%s: res %.*s, inflight++: now %u, %ps()\n", dlm->name,
-@@ -663,6 +660,13 @@ void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
- __builtin_return_address(0));
- }
-
-+void dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
-+ struct dlm_lock_resource *res)
-+{
-+ assert_spin_locked(&res->spinlock);
-+ __dlm_lockres_grab_inflight_ref(dlm, res);
-+}
-+
- void dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm,
- struct dlm_lock_resource *res)
- {
-@@ -852,10 +856,8 @@ lookup:
- /* finally add the lockres to its hash bucket */
- __dlm_insert_lockres(dlm, res);
-
-- /* Grab inflight ref to pin the resource */
-- spin_lock(&res->spinlock);
-- dlm_lockres_grab_inflight_ref(dlm, res);
-- spin_unlock(&res->spinlock);
-+ /* since this lockres is new it doesn't not require the spinlock */
-+ __dlm_lockres_grab_inflight_ref(dlm, res);
-
- /* get an extra ref on the mle in case this is a BLOCK
- * if so, the creator of the BLOCK may try to put the last
-diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
-index e9c4f190ffae..ac46782c10d3 100644
---- a/include/acpi/acpi_bus.h
-+++ b/include/acpi/acpi_bus.h
-@@ -118,6 +118,7 @@ struct acpi_device;
- struct acpi_hotplug_profile {
- struct kobject kobj;
- int (*scan_dependent)(struct acpi_device *adev);
-+ void (*notify_online)(struct acpi_device *adev);
- bool enabled:1;
- bool demand_offline:1;
- };
-diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
-index 369cf2cd5144..68f46cd5d514 100644
---- a/include/linux/iio/trigger.h
-+++ b/include/linux/iio/trigger.h
-@@ -84,10 +84,12 @@ static inline void iio_trigger_put(struct iio_trigger *trig)
- put_device(&trig->dev);
- }
-
--static inline void iio_trigger_get(struct iio_trigger *trig)
-+static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig)
- {
- get_device(&trig->dev);
- __module_get(trig->ops->owner);
-+
-+ return trig;
- }
-
- /**
-diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
-index 535f158977b9..8cf350325dc6 100644
---- a/include/linux/seqlock.h
-+++ b/include/linux/seqlock.h
-@@ -164,8 +164,6 @@ static inline unsigned read_seqcount_begin(const seqcount_t *s)
- static inline unsigned raw_seqcount_begin(const seqcount_t *s)
- {
- unsigned ret = ACCESS_ONCE(s->sequence);
--
-- seqcount_lockdep_reader_access(s);
- smp_rmb();
- return ret & ~1;
- }
-diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
-index 502073a53dd3..b483abd34493 100644
---- a/include/linux/vga_switcheroo.h
-+++ b/include/linux/vga_switcheroo.h
-@@ -64,6 +64,7 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
- void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
-
- int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
-+void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
- int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
- #else
-
-@@ -82,6 +83,7 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
- static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
-
- static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
-+static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
- static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
-
- #endif
-diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
-index 704f4f652d0a..6c62cfa25f1a 100644
---- a/include/linux/workqueue.h
-+++ b/include/linux/workqueue.h
-@@ -452,7 +452,7 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
- alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
- 1, (name))
- #define create_singlethread_workqueue(name) \
-- alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
-+ alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)
-
- extern void destroy_workqueue(struct workqueue_struct *wq);
-
-diff --git a/include/net/regulatory.h b/include/net/regulatory.h
-index b07cdc9fa454..f103f30122a1 100644
---- a/include/net/regulatory.h
-+++ b/include/net/regulatory.h
-@@ -160,7 +160,7 @@ struct ieee80211_reg_rule {
- struct ieee80211_regdomain {
- struct rcu_head rcu_head;
- u32 n_reg_rules;
-- char alpha2[2];
-+ char alpha2[3];
- enum nl80211_dfs_regions dfs_region;
- struct ieee80211_reg_rule reg_rules[];
- };
-diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
-index 29e9c7aa9c66..f279394aafb0 100644
---- a/include/uapi/linux/usb/functionfs.h
-+++ b/include/uapi/linux/usb/functionfs.h
-@@ -27,24 +27,18 @@ struct usb_endpoint_descriptor_no_audio {
- __u8 bInterval;
- } __attribute__((packed));
-
--/* Legacy format, deprecated as of 3.14. */
--struct usb_functionfs_descs_head {
-- __le32 magic;
-- __le32 length;
-- __le32 fs_count;
-- __le32 hs_count;
--} __attribute__((packed, deprecated));
-
- /*
- * All numbers must be in little endian order.
- */
-
-+/* Legacy format, deprecated as of 3.14. */
- struct usb_functionfs_descs_head {
- __le32 magic;
- __le32 length;
- __le32 fs_count;
- __le32 hs_count;
--} __attribute__((packed));
-+} __attribute__((packed, deprecated));
-
- /*
- * Descriptors format:
-diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
-index c38355c1f3c9..1590c49cae57 100644
---- a/include/uapi/linux/xattr.h
-+++ b/include/uapi/linux/xattr.h
-@@ -13,7 +13,7 @@
- #ifndef _UAPI_LINUX_XATTR_H
- #define _UAPI_LINUX_XATTR_H
-
--#ifdef __UAPI_DEF_XATTR
-+#if __UAPI_DEF_XATTR
- #define __USE_KERNEL_XATTR_DEFS
-
- #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
-diff --git a/kernel/cgroup.c b/kernel/cgroup.c
-index 0c753ddd223b..550e2050d778 100644
---- a/kernel/cgroup.c
-+++ b/kernel/cgroup.c
-@@ -3663,7 +3663,6 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
-
- l = cgroup_pidlist_find_create(cgrp, type);
- if (!l) {
-- mutex_unlock(&cgrp->pidlist_mutex);
- pidlist_free(array);
- return -ENOMEM;
- }
-diff --git a/kernel/events/core.c b/kernel/events/core.c
-index f774e9365a03..3a140ca37777 100644
---- a/kernel/events/core.c
-+++ b/kernel/events/core.c
-@@ -1516,6 +1516,11 @@ retry:
- */
- if (ctx->is_active) {
- raw_spin_unlock_irq(&ctx->lock);
-+ /*
-+ * Reload the task pointer, it might have been changed by
-+ * a concurrent perf_event_context_sched_out().
-+ */
-+ task = ctx->task;
- goto retry;
- }
-
-@@ -1957,6 +1962,11 @@ retry:
- */
- if (ctx->is_active) {
- raw_spin_unlock_irq(&ctx->lock);
-+ /*
-+ * Reload the task pointer, it might have been changed by
-+ * a concurrent perf_event_context_sched_out().
-+ */
-+ task = ctx->task;
- goto retry;
- }
-
-diff --git a/kernel/futex.c b/kernel/futex.c
-index e3087afb7429..0b0dc02aabce 100644
---- a/kernel/futex.c
-+++ b/kernel/futex.c
-@@ -2614,6 +2614,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
- * shared futexes. We need to compare the keys:
- */
- if (match_futex(&q.key, &key2)) {
-+ queue_unlock(hb);
- ret = -EINVAL;
- goto out_put_keys;
- }
-diff --git a/kernel/kcmp.c b/kernel/kcmp.c
-index e30ac0fe61c3..0aa69ea1d8fd 100644
---- a/kernel/kcmp.c
-+++ b/kernel/kcmp.c
-@@ -44,11 +44,12 @@ static long kptr_obfuscate(long v, int type)
- */
- static int kcmp_ptr(void *v1, void *v2, enum kcmp_type type)
- {
-- long ret;
-+ long t1, t2;
-
-- ret = kptr_obfuscate((long)v1, type) - kptr_obfuscate((long)v2, type);
-+ t1 = kptr_obfuscate((long)v1, type);
-+ t2 = kptr_obfuscate((long)v2, type);
-
-- return (ret < 0) | ((ret > 0) << 1);
-+ return (t1 < t2) | ((t1 > t2) << 1);
- }
-
- /* The caller must have pinned the task */
-diff --git a/kernel/power/main.c b/kernel/power/main.c
-index 1d1bf630e6e9..3ae41cdd804a 100644
---- a/kernel/power/main.c
-+++ b/kernel/power/main.c
-@@ -293,12 +293,12 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
- {
- char *s = buf;
- #ifdef CONFIG_SUSPEND
-- int i;
-+ suspend_state_t i;
-+
-+ for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
-+ if (pm_states[i].state)
-+ s += sprintf(s,"%s ", pm_states[i].label);
-
-- for (i = 0; i < PM_SUSPEND_MAX; i++) {
-- if (pm_states[i] && valid_state(i))
-- s += sprintf(s,"%s ", pm_states[i]);
-- }
- #endif
- #ifdef CONFIG_HIBERNATION
- s += sprintf(s, "%s\n", "disk");
-@@ -314,7 +314,7 @@ static suspend_state_t decode_state(const char *buf, size_t n)
- {
- #ifdef CONFIG_SUSPEND
- suspend_state_t state = PM_SUSPEND_MIN;
-- const char * const *s;
-+ struct pm_sleep_state *s;
- #endif
- char *p;
- int len;
-@@ -328,8 +328,9 @@ static suspend_state_t decode_state(const char *buf, size_t n)
-
- #ifdef CONFIG_SUSPEND
- for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++)
-- if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
-- return state;
-+ if (s->state && len == strlen(s->label)
-+ && !strncmp(buf, s->label, len))
-+ return s->state;
- #endif
-
- return PM_SUSPEND_ON;
-@@ -447,8 +448,8 @@ static ssize_t autosleep_show(struct kobject *kobj,
-
- #ifdef CONFIG_SUSPEND
- if (state < PM_SUSPEND_MAX)
-- return sprintf(buf, "%s\n", valid_state(state) ?
-- pm_states[state] : "error");
-+ return sprintf(buf, "%s\n", pm_states[state].state ?
-+ pm_states[state].label : "error");
- #endif
- #ifdef CONFIG_HIBERNATION
- return sprintf(buf, "disk\n");
-diff --git a/kernel/power/power.h b/kernel/power/power.h
-index 7d4b7ffb3c1d..f770cad3666c 100644
---- a/kernel/power/power.h
-+++ b/kernel/power/power.h
-@@ -175,17 +175,20 @@ extern void swsusp_show_speed(struct timeval *, struct timeval *,
- unsigned int, char *);
-
- #ifdef CONFIG_SUSPEND
-+struct pm_sleep_state {
-+ const char *label;
-+ suspend_state_t state;
-+};
-+
- /* kernel/power/suspend.c */
--extern const char *const pm_states[];
-+extern struct pm_sleep_state pm_states[];
-
--extern bool valid_state(suspend_state_t state);
- extern int suspend_devices_and_enter(suspend_state_t state);
- #else /* !CONFIG_SUSPEND */
- static inline int suspend_devices_and_enter(suspend_state_t state)
- {
- return -ENOSYS;
- }
--static inline bool valid_state(suspend_state_t state) { return false; }
- #endif /* !CONFIG_SUSPEND */
-
- #ifdef CONFIG_PM_TEST_SUSPEND
-diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
-index 62ee437b5c7e..5455d5c3c149 100644
---- a/kernel/power/suspend.c
-+++ b/kernel/power/suspend.c
-@@ -29,10 +29,10 @@
-
- #include "power.h"
-
--const char *const pm_states[PM_SUSPEND_MAX] = {
-- [PM_SUSPEND_FREEZE] = "freeze",
-- [PM_SUSPEND_STANDBY] = "standby",
-- [PM_SUSPEND_MEM] = "mem",
-+struct pm_sleep_state pm_states[PM_SUSPEND_MAX] = {
-+ [PM_SUSPEND_FREEZE] = { .label = "freeze", .state = PM_SUSPEND_FREEZE },
-+ [PM_SUSPEND_STANDBY] = { .label = "standby", },
-+ [PM_SUSPEND_MEM] = { .label = "mem", },
- };
-
- static const struct platform_suspend_ops *suspend_ops;
-@@ -62,42 +62,34 @@ void freeze_wake(void)
- }
- EXPORT_SYMBOL_GPL(freeze_wake);
-
-+static bool valid_state(suspend_state_t state)
-+{
-+ /*
-+ * PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states need low level
-+ * support and need to be valid to the low level
-+ * implementation, no valid callback implies that none are valid.
-+ */
-+ return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
-+}
-+
- /**
- * suspend_set_ops - Set the global suspend method table.
- * @ops: Suspend operations to use.
- */
- void suspend_set_ops(const struct platform_suspend_ops *ops)
- {
-+ suspend_state_t i;
-+
- lock_system_sleep();
-+
- suspend_ops = ops;
-+ for (i = PM_SUSPEND_STANDBY; i <= PM_SUSPEND_MEM; i++)
-+ pm_states[i].state = valid_state(i) ? i : 0;
-+
- unlock_system_sleep();
- }
- EXPORT_SYMBOL_GPL(suspend_set_ops);
-
--bool valid_state(suspend_state_t state)
--{
-- if (state == PM_SUSPEND_FREEZE) {
--#ifdef CONFIG_PM_DEBUG
-- if (pm_test_level != TEST_NONE &&
-- pm_test_level != TEST_FREEZER &&
-- pm_test_level != TEST_DEVICES &&
-- pm_test_level != TEST_PLATFORM) {
-- printk(KERN_WARNING "Unsupported pm_test mode for "
-- "freeze state, please choose "
-- "none/freezer/devices/platform.\n");
-- return false;
-- }
--#endif
-- return true;
-- }
-- /*
-- * PM_SUSPEND_STANDBY and PM_SUSPEND_MEMORY states need lowlevel
-- * support and need to be valid to the lowlevel
-- * implementation, no valid callback implies that none are valid.
-- */
-- return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
--}
--
- /**
- * suspend_valid_only_mem - Generic memory-only valid callback.
- *
-@@ -324,9 +316,17 @@ static int enter_state(suspend_state_t state)
- {
- int error;
-
-- if (!valid_state(state))
-- return -ENODEV;
--
-+ if (state == PM_SUSPEND_FREEZE) {
-+#ifdef CONFIG_PM_DEBUG
-+ if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) {
-+ pr_warning("PM: Unsupported test mode for freeze state,"
-+ "please choose none/freezer/devices/platform.\n");
-+ return -EAGAIN;
-+ }
-+#endif
-+ } else if (!valid_state(state)) {
-+ return -EINVAL;
-+ }
- if (!mutex_trylock(&pm_mutex))
- return -EBUSY;
-
-@@ -337,7 +337,7 @@ static int enter_state(suspend_state_t state)
- sys_sync();
- printk("done.\n");
-
-- pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
-+ pr_debug("PM: Preparing system for %s sleep\n", pm_states[state].label);
- error = suspend_prepare(state);
- if (error)
- goto Unlock;
-@@ -345,7 +345,7 @@ static int enter_state(suspend_state_t state)
- if (suspend_test(TEST_FREEZER))
- goto Finish;
-
-- pr_debug("PM: Entering %s sleep\n", pm_states[state]);
-+ pr_debug("PM: Entering %s sleep\n", pm_states[state].label);
- pm_restrict_gfp_mask();
- error = suspend_devices_and_enter(state);
- pm_restore_gfp_mask();
-diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c
-index 9b2a1d58558d..269b097e78ea 100644
---- a/kernel/power/suspend_test.c
-+++ b/kernel/power/suspend_test.c
-@@ -92,13 +92,13 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
- }
-
- if (state == PM_SUSPEND_MEM) {
-- printk(info_test, pm_states[state]);
-+ printk(info_test, pm_states[state].label);
- status = pm_suspend(state);
- if (status == -ENODEV)
- state = PM_SUSPEND_STANDBY;
- }
- if (state == PM_SUSPEND_STANDBY) {
-- printk(info_test, pm_states[state]);
-+ printk(info_test, pm_states[state].label);
- status = pm_suspend(state);
- }
- if (status < 0)
-@@ -136,18 +136,16 @@ static char warn_bad_state[] __initdata =
-
- static int __init setup_test_suspend(char *value)
- {
-- unsigned i;
-+ suspend_state_t i;
-
- /* "=mem" ==> "mem" */
- value++;
-- for (i = 0; i < PM_SUSPEND_MAX; i++) {
-- if (!pm_states[i])
-- continue;
-- if (strcmp(pm_states[i], value) != 0)
-- continue;
-- test_state = (__force suspend_state_t) i;
-- return 0;
-- }
-+ for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
-+ if (!strcmp(pm_states[i].label, value)) {
-+ test_state = pm_states[i].state;
-+ return 0;
-+ }
-+
- printk(warn_bad_state, value);
- return 0;
- }
-@@ -164,8 +162,8 @@ static int __init test_suspend(void)
- /* PM is initialized by now; is that state testable? */
- if (test_state == PM_SUSPEND_ON)
- goto done;
-- if (!valid_state(test_state)) {
-- printk(warn_bad_state, pm_states[test_state]);
-+ if (!pm_states[test_state].state) {
-+ printk(warn_bad_state, pm_states[test_state].label);
- goto done;
- }
-
-diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
-index fe75444ae7ec..cd45a0727a16 100644
---- a/kernel/time/alarmtimer.c
-+++ b/kernel/time/alarmtimer.c
-@@ -464,18 +464,26 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)
- static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
- ktime_t now)
- {
-+ unsigned long flags;
- struct k_itimer *ptr = container_of(alarm, struct k_itimer,
- it.alarm.alarmtimer);
-- if (posix_timer_event(ptr, 0) != 0)
-- ptr->it_overrun++;
-+ enum alarmtimer_restart result = ALARMTIMER_NORESTART;
-+
-+ spin_lock_irqsave(&ptr->it_lock, flags);
-+ if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
-+ if (posix_timer_event(ptr, 0) != 0)
-+ ptr->it_overrun++;
-+ }
-
- /* Re-add periodic timers */
- if (ptr->it.alarm.interval.tv64) {
- ptr->it_overrun += alarm_forward(alarm, now,
- ptr->it.alarm.interval);
-- return ALARMTIMER_RESTART;
-+ result = ALARMTIMER_RESTART;
- }
-- return ALARMTIMER_NORESTART;
-+ spin_unlock_irqrestore(&ptr->it_lock, flags);
-+
-+ return result;
- }
-
- /**
-@@ -541,18 +549,22 @@ static int alarm_timer_create(struct k_itimer *new_timer)
- * @new_timer: k_itimer pointer
- * @cur_setting: itimerspec data to fill
- *
-- * Copies the itimerspec data out from the k_itimer
-+ * Copies out the current itimerspec data
- */
- static void alarm_timer_get(struct k_itimer *timr,
- struct itimerspec *cur_setting)
- {
-- memset(cur_setting, 0, sizeof(struct itimerspec));
-+ ktime_t relative_expiry_time =
-+ alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
-+
-+ if (ktime_to_ns(relative_expiry_time) > 0) {
-+ cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
-+ } else {
-+ cur_setting->it_value.tv_sec = 0;
-+ cur_setting->it_value.tv_nsec = 0;
-+ }
-
-- cur_setting->it_interval =
-- ktime_to_timespec(timr->it.alarm.interval);
-- cur_setting->it_value =
-- ktime_to_timespec(timr->it.alarm.alarmtimer.node.expires);
-- return;
-+ cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
- }
-
- /**
-diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
-index a53f1bbc546b..773aba836e81 100644
---- a/kernel/trace/ring_buffer.c
-+++ b/kernel/trace/ring_buffer.c
-@@ -626,8 +626,22 @@ int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu,
- work = &cpu_buffer->irq_work;
- }
-
-- work->waiters_pending = true;
- poll_wait(filp, &work->waiters, poll_table);
-+ work->waiters_pending = true;
-+ /*
-+ * There's a tight race between setting the waiters_pending and
-+ * checking if the ring buffer is empty. Once the waiters_pending bit
-+ * is set, the next event will wake the task up, but we can get stuck
-+ * if there's only a single event in.
-+ *
-+ * FIXME: Ideally, we need a memory barrier on the writer side as well,
-+ * but adding a memory barrier to all events will cause too much of a
-+ * performance hit in the fast path. We only need a memory barrier when
-+ * the buffer goes from empty to having content. But as this race is
-+ * extremely small, and it's not a problem if another event comes in, we
-+ * will fix it later.
-+ */
-+ smp_mb();
-
- if ((cpu == RING_BUFFER_ALL_CPUS && !ring_buffer_empty(buffer)) ||
- (cpu != RING_BUFFER_ALL_CPUS && !ring_buffer_empty_cpu(buffer, cpu)))
-diff --git a/mm/memblock.c b/mm/memblock.c
-index 39a31e7f0045..0739dc1b4095 100644
---- a/mm/memblock.c
-+++ b/mm/memblock.c
-@@ -183,8 +183,7 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,
- phys_addr_t align, phys_addr_t start,
- phys_addr_t end, int nid)
- {
-- int ret;
-- phys_addr_t kernel_end;
-+ phys_addr_t kernel_end, ret;
-
- /* pump up @end */
- if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
-diff --git a/mm/memory.c b/mm/memory.c
-index 2121d8b8db56..492e36f27f43 100644
---- a/mm/memory.c
-+++ b/mm/memory.c
-@@ -1120,7 +1120,7 @@ again:
- addr) != page->index) {
- pte_t ptfile = pgoff_to_pte(page->index);
- if (pte_soft_dirty(ptent))
-- pte_file_mksoft_dirty(ptfile);
-+ ptfile = pte_file_mksoft_dirty(ptfile);
- set_pte_at(mm, addr, pte, ptfile);
- }
- if (PageAnon(page))
-diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c
-index 3707c71ae4cd..51108165f829 100644
---- a/mm/percpu-vm.c
-+++ b/mm/percpu-vm.c
-@@ -108,7 +108,7 @@ static int pcpu_alloc_pages(struct pcpu_chunk *chunk,
- int page_start, int page_end)
- {
- const gfp_t gfp = GFP_KERNEL | __GFP_HIGHMEM | __GFP_COLD;
-- unsigned int cpu;
-+ unsigned int cpu, tcpu;
- int i;
-
- for_each_possible_cpu(cpu) {
-@@ -116,14 +116,23 @@ static int pcpu_alloc_pages(struct pcpu_chunk *chunk,
- struct page **pagep = &pages[pcpu_page_idx(cpu, i)];
-
- *pagep = alloc_pages_node(cpu_to_node(cpu), gfp, 0);
-- if (!*pagep) {
-- pcpu_free_pages(chunk, pages, populated,
-- page_start, page_end);
-- return -ENOMEM;
-- }
-+ if (!*pagep)
-+ goto err;
- }
- }
- return 0;
-+
-+err:
-+ while (--i >= page_start)
-+ __free_page(pages[pcpu_page_idx(cpu, i)]);
-+
-+ for_each_possible_cpu(tcpu) {
-+ if (tcpu == cpu)
-+ break;
-+ for (i = page_start; i < page_end; i++)
-+ __free_page(pages[pcpu_page_idx(tcpu, i)]);
-+ }
-+ return -ENOMEM;
- }
-
- /**
-@@ -263,6 +272,7 @@ err:
- __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start),
- page_end - page_start);
- }
-+ pcpu_post_unmap_tlb_flush(chunk, page_start, page_end);
- return err;
- }
-
-diff --git a/mm/percpu.c b/mm/percpu.c
-index a2a54a85f691..8cd4308471c3 100644
---- a/mm/percpu.c
-+++ b/mm/percpu.c
-@@ -1917,6 +1917,8 @@ void __init setup_per_cpu_areas(void)
-
- if (pcpu_setup_first_chunk(ai, fc) < 0)
- panic("Failed to initialize percpu areas.");
-+
-+ pcpu_free_alloc_info(ai);
- }
-
- #endif /* CONFIG_SMP */
-diff --git a/mm/shmem.c b/mm/shmem.c
-index ff85863587ee..f0d698ba7d0f 100644
---- a/mm/shmem.c
-+++ b/mm/shmem.c
-@@ -2143,8 +2143,10 @@ static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry, struct
-
- if (new_dentry->d_inode) {
- (void) shmem_unlink(new_dir, new_dentry);
-- if (they_are_dirs)
-+ if (they_are_dirs) {
-+ drop_nlink(new_dentry->d_inode);
- drop_nlink(old_dir);
-+ }
- } else if (they_are_dirs) {
- drop_nlink(old_dir);
- inc_nlink(new_dir);
-diff --git a/mm/slab.c b/mm/slab.c
-index 6dd8d5f3a3ac..ea854eb2388c 100644
---- a/mm/slab.c
-+++ b/mm/slab.c
-@@ -2189,7 +2189,8 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
- int
- __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
- {
-- size_t left_over, freelist_size, ralign;
-+ size_t left_over, freelist_size;
-+ size_t ralign = BYTES_PER_WORD;
- gfp_t gfp;
- int err;
- size_t size = cachep->size;
-@@ -2222,14 +2223,6 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
- size &= ~(BYTES_PER_WORD - 1);
- }
-
-- /*
-- * Redzoning and user store require word alignment or possibly larger.
-- * Note this will be overridden by architecture or caller mandated
-- * alignment if either is greater than BYTES_PER_WORD.
-- */
-- if (flags & SLAB_STORE_USER)
-- ralign = BYTES_PER_WORD;
--
- if (flags & SLAB_RED_ZONE) {
- ralign = REDZONE_ALIGN;
- /* If redzoning, ensure that the second redzone is suitably
-diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
-index e6a84cb1a5e4..189eef014c4f 100644
---- a/net/mac80211/mlme.c
-+++ b/net/mac80211/mlme.c
-@@ -4240,8 +4240,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
- rcu_read_unlock();
-
- if (bss->wmm_used && bss->uapsd_supported &&
-- (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) &&
-- sdata->wmm_acm != 0xff) {
-+ (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)) {
- assoc_data->uapsd = true;
- ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED;
- } else {
-diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
-index a8eb0a89326a..610e19c0e13f 100644
---- a/net/netfilter/ipvs/ip_vs_conn.c
-+++ b/net/netfilter/ipvs/ip_vs_conn.c
-@@ -797,7 +797,6 @@ static void ip_vs_conn_expire(unsigned long data)
- ip_vs_control_del(cp);
-
- if (cp->flags & IP_VS_CONN_F_NFCT) {
-- ip_vs_conn_drop_conntrack(cp);
- /* Do not access conntracks during subsys cleanup
- * because nf_conntrack_find_get can not be used after
- * conntrack cleanup for the net.
-diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
-index 3d2d2c8108ca..27d3f40de3cd 100644
---- a/net/netfilter/ipvs/ip_vs_core.c
-+++ b/net/netfilter/ipvs/ip_vs_core.c
-@@ -1906,7 +1906,7 @@ static struct nf_hook_ops ip_vs_ops[] __read_mostly = {
- {
- .hook = ip_vs_local_reply6,
- .owner = THIS_MODULE,
-- .pf = NFPROTO_IPV4,
-+ .pf = NFPROTO_IPV6,
- .hooknum = NF_INET_LOCAL_OUT,
- .priority = NF_IP6_PRI_NAT_DST + 1,
- },
-diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
-index 7f0e1cf2d7e8..1692e7534759 100644
---- a/net/netfilter/ipvs/ip_vs_xmit.c
-+++ b/net/netfilter/ipvs/ip_vs_xmit.c
-@@ -967,8 +967,8 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
- iph->nexthdr = IPPROTO_IPV6;
- iph->payload_len = old_iph->payload_len;
- be16_add_cpu(&iph->payload_len, sizeof(*old_iph));
-- iph->priority = old_iph->priority;
- memset(&iph->flow_lbl, 0, sizeof(iph->flow_lbl));
-+ ipv6_change_dsfield(iph, 0, ipv6_get_dsfield(old_iph));
- iph->daddr = cp->daddr.in6;
- iph->saddr = saddr;
- iph->hop_limit = old_iph->hop_limit;
-diff --git a/net/netfilter/xt_cgroup.c b/net/netfilter/xt_cgroup.c
-index 9a8e77e7f8d4..ef5c75a5b200 100644
---- a/net/netfilter/xt_cgroup.c
-+++ b/net/netfilter/xt_cgroup.c
-@@ -31,7 +31,7 @@ static int cgroup_mt_check(const struct xt_mtchk_param *par)
- if (info->invert & ~1)
- return -EINVAL;
-
-- return info->id ? 0 : -EINVAL;
-+ return 0;
- }
-
- static bool
-diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
-index a3910fc2122b..47dc6836830a 100644
---- a/net/netfilter/xt_hashlimit.c
-+++ b/net/netfilter/xt_hashlimit.c
-@@ -104,7 +104,7 @@ struct xt_hashlimit_htable {
- spinlock_t lock; /* lock for list_head */
- u_int32_t rnd; /* random seed for hash */
- unsigned int count; /* number entries in table */
-- struct timer_list timer; /* timer for gc */
-+ struct delayed_work gc_work;
-
- /* seq_file stuff */
- struct proc_dir_entry *pde;
-@@ -213,7 +213,7 @@ dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent)
- call_rcu_bh(&ent->rcu, dsthash_free_rcu);
- ht->count--;
- }
--static void htable_gc(unsigned long htlong);
-+static void htable_gc(struct work_struct *work);
-
- static int htable_create(struct net *net, struct xt_hashlimit_mtinfo1 *minfo,
- u_int8_t family)
-@@ -273,9 +273,9 @@ static int htable_create(struct net *net, struct xt_hashlimit_mtinfo1 *minfo,
- }
- hinfo->net = net;
-
-- setup_timer(&hinfo->timer, htable_gc, (unsigned long)hinfo);
-- hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
-- add_timer(&hinfo->timer);
-+ INIT_DEFERRABLE_WORK(&hinfo->gc_work, htable_gc);
-+ queue_delayed_work(system_power_efficient_wq, &hinfo->gc_work,
-+ msecs_to_jiffies(hinfo->cfg.gc_interval));
-
- hlist_add_head(&hinfo->node, &hashlimit_net->htables);
-
-@@ -300,29 +300,30 @@ static void htable_selective_cleanup(struct xt_hashlimit_htable *ht,
- {
- unsigned int i;
-
-- /* lock hash table and iterate over it */
-- spin_lock_bh(&ht->lock);
- for (i = 0; i < ht->cfg.size; i++) {
- struct dsthash_ent *dh;
- struct hlist_node *n;
-+
-+ spin_lock_bh(&ht->lock);
- hlist_for_each_entry_safe(dh, n, &ht->hash[i], node) {
- if ((*select)(ht, dh))
- dsthash_free(ht, dh);
- }
-+ spin_unlock_bh(&ht->lock);
-+ cond_resched();
- }
-- spin_unlock_bh(&ht->lock);
- }
-
--/* hash table garbage collector, run by timer */
--static void htable_gc(unsigned long htlong)
-+static void htable_gc(struct work_struct *work)
- {
-- struct xt_hashlimit_htable *ht = (struct xt_hashlimit_htable *)htlong;
-+ struct xt_hashlimit_htable *ht;
-+
-+ ht = container_of(work, struct xt_hashlimit_htable, gc_work.work);
-
- htable_selective_cleanup(ht, select_gc);
-
-- /* re-add the timer accordingly */
-- ht->timer.expires = jiffies + msecs_to_jiffies(ht->cfg.gc_interval);
-- add_timer(&ht->timer);
-+ queue_delayed_work(system_power_efficient_wq,
-+ &ht->gc_work, msecs_to_jiffies(ht->cfg.gc_interval));
- }
-
- static void htable_remove_proc_entry(struct xt_hashlimit_htable *hinfo)
-@@ -341,7 +342,7 @@ static void htable_remove_proc_entry(struct xt_hashlimit_htable *hinfo)
-
- static void htable_destroy(struct xt_hashlimit_htable *hinfo)
- {
-- del_timer_sync(&hinfo->timer);
-+ cancel_delayed_work_sync(&hinfo->gc_work);
- htable_remove_proc_entry(hinfo);
- htable_selective_cleanup(hinfo, select_all);
- kfree(hinfo->name);
-diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
-index e6283464a8e6..df33156ecd2d 100644
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -6796,6 +6796,9 @@ void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp)
- struct nlattr *data = ((void **)skb->cb)[2];
- enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE;
-
-+ /* clear CB data for netlink core to own from now on */
-+ memset(skb->cb, 0, sizeof(skb->cb));
-+
- nla_nest_end(skb, data);
- genlmsg_end(skb, hdr);
-
-@@ -9075,6 +9078,9 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb)
- void *hdr = ((void **)skb->cb)[1];
- struct nlattr *data = ((void **)skb->cb)[2];
-
-+ /* clear CB data for netlink core to own from now on */
-+ memset(skb->cb, 0, sizeof(skb->cb));
-+
- if (WARN_ON(!rdev->cur_cmd_info)) {
- kfree_skb(skb);
- return -EINVAL;
-diff --git a/sound/core/info.c b/sound/core/info.c
-index e79baa11b60e..08070e1eefeb 100644
---- a/sound/core/info.c
-+++ b/sound/core/info.c
-@@ -679,7 +679,7 @@ int snd_info_card_free(struct snd_card *card)
- * snd_info_get_line - read one line from the procfs buffer
- * @buffer: the procfs buffer
- * @line: the buffer to store
-- * @len: the max. buffer size - 1
-+ * @len: the max. buffer size
- *
- * Reads one line from the buffer and stores the string.
- *
-@@ -699,7 +699,7 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
- buffer->stop = 1;
- if (c == '\n')
- break;
-- if (len) {
-+ if (len > 1) {
- len--;
- *line++ = c;
- }
-diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
-index a2104671f51d..e1ef106c8a6f 100644
---- a/sound/core/pcm_lib.c
-+++ b/sound/core/pcm_lib.c
-@@ -1783,14 +1783,16 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
- {
- struct snd_pcm_hw_params *params = arg;
- snd_pcm_format_t format;
-- int channels, width;
-+ int channels;
-+ ssize_t frame_size;
-
- params->fifo_size = substream->runtime->hw.fifo_size;
- if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) {
- format = params_format(params);
- channels = params_channels(params);
-- width = snd_pcm_format_physical_width(format);
-- params->fifo_size /= width * channels;
-+ frame_size = snd_pcm_format_size(format, channels);
-+ if (frame_size > 0)
-+ params->fifo_size /= (unsigned)frame_size;
- }
- return 0;
- }
-diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
-index bcf91bea3317..ffc19464b978 100644
---- a/sound/pci/hda/patch_conexant.c
-+++ b/sound/pci/hda/patch_conexant.c
-@@ -3237,6 +3237,7 @@ enum {
- CXT_FIXUP_HEADPHONE_MIC_PIN,
- CXT_FIXUP_HEADPHONE_MIC,
- CXT_FIXUP_GPIO1,
-+ CXT_FIXUP_ASPIRE_DMIC,
- CXT_FIXUP_THINKPAD_ACPI,
- };
-
-@@ -3397,6 +3398,12 @@ static const struct hda_fixup cxt_fixups[] = {
- { }
- },
- },
-+ [CXT_FIXUP_ASPIRE_DMIC] = {
-+ .type = HDA_FIXUP_FUNC,
-+ .v.func = cxt_fixup_stereo_dmic,
-+ .chained = true,
-+ .chain_id = CXT_FIXUP_GPIO1,
-+ },
- [CXT_FIXUP_THINKPAD_ACPI] = {
- .type = HDA_FIXUP_FUNC,
- .v.func = hda_fixup_thinkpad_acpi,
-@@ -3410,7 +3417,7 @@ static const struct snd_pci_quirk cxt5051_fixups[] = {
-
- static const struct snd_pci_quirk cxt5066_fixups[] = {
- SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
-- SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1),
-+ SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC),
- SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
- SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
- SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
-diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
-index b35dbe25a6e3..5d0058bd6259 100644
---- a/sound/pci/hda/patch_realtek.c
-+++ b/sound/pci/hda/patch_realtek.c
-@@ -327,6 +327,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
- case 0x10ec0885:
- case 0x10ec0887:
- /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
-+ case 0x10ec0900:
- alc889_coef_init(codec);
- break;
- case 0x10ec0888:
-@@ -2330,6 +2331,7 @@ static int patch_alc882(struct hda_codec *codec)
- switch (codec->vendor_id) {
- case 0x10ec0882:
- case 0x10ec0885:
-+ case 0x10ec0900:
- break;
- default:
- /* ALC883 and variants */
-diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
-index 978df990f27c..15270a2e71cc 100644
---- a/sound/pci/hda/patch_sigmatel.c
-+++ b/sound/pci/hda/patch_sigmatel.c
-@@ -559,8 +559,8 @@ static void stac_init_power_map(struct hda_codec *codec)
- if (snd_hda_jack_tbl_get(codec, nid))
- continue;
- if (def_conf == AC_JACK_PORT_COMPLEX &&
-- !(spec->vref_mute_led_nid == nid ||
-- is_jack_detectable(codec, nid))) {
-+ spec->vref_mute_led_nid != nid &&
-+ is_jack_detectable(codec, nid)) {
- snd_hda_jack_detect_enable_callback(codec, nid,
- STAC_PWR_EVENT,
- jack_update_power);
-@@ -4212,11 +4212,18 @@ static int stac_parse_auto_config(struct hda_codec *codec)
- return err;
- }
-
-- stac_init_power_map(codec);
--
- return 0;
- }
-
-+static int stac_build_controls(struct hda_codec *codec)
-+{
-+ int err = snd_hda_gen_build_controls(codec);
-+
-+ if (err < 0)
-+ return err;
-+ stac_init_power_map(codec);
-+ return 0;
-+}
-
- static int stac_init(struct hda_codec *codec)
- {
-@@ -4328,7 +4335,7 @@ static int stac_suspend(struct hda_codec *codec)
- #endif /* CONFIG_PM */
-
- static const struct hda_codec_ops stac_patch_ops = {
-- .build_controls = snd_hda_gen_build_controls,
-+ .build_controls = stac_build_controls,
- .build_pcms = snd_hda_gen_build_pcms,
- .init = stac_init,
- .free = stac_free,
-diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
-index 670afa29e30d..7350ebbae642 100644
---- a/sound/soc/davinci/davinci-mcasp.c
-+++ b/sound/soc/davinci/davinci-mcasp.c
-@@ -418,8 +418,17 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp,
- {
- u32 fmt;
- u32 tx_rotate = (word_length / 4) & 0x7;
-- u32 rx_rotate = (32 - word_length) / 4;
- u32 mask = (1ULL << word_length) - 1;
-+ /*
-+ * For captured data we should not rotate, inversion and masking is
-+ * enoguh to get the data to the right position:
-+ * Format data from bus after reverse (XRBUF)
-+ * S16_LE: |LSB|MSB|xxx|xxx| |xxx|xxx|MSB|LSB|
-+ * S24_3LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB|
-+ * S24_LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB|
-+ * S32_LE: |LSB|DAT|DAT|MSB| |MSB|DAT|DAT|LSB|
-+ */
-+ u32 rx_rotate = 0;
-
- /*
- * if s BCLK-to-LRCLK ratio has been configured via the set_clkdiv()
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.20-21.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.20-21.patch
deleted file mode 100644
index a8ab18d36d..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.20-21.patch
+++ /dev/null
@@ -1,2520 +0,0 @@
-diff --git a/Makefile b/Makefile
-index beb7e6f0803b..41e6e19fe2e9 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 20
-+SUBLEVEL = 21
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h
-index fb5e4c658f7a..ef470a7a3d0f 100644
---- a/arch/unicore32/include/asm/mmu_context.h
-+++ b/arch/unicore32/include/asm/mmu_context.h
-@@ -14,6 +14,8 @@
-
- #include
- #include
-+#include
-+#include
- #include
-
- #include
-@@ -73,7 +75,7 @@ do { \
- else \
- mm->mmap = NULL; \
- rb_erase(&high_vma->vm_rb, &mm->mm_rb); \
-- mm->mmap_cache = NULL; \
-+ vmacache_invalidate(mm); \
- mm->map_count--; \
- remove_vma(high_vma); \
- } \
-diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
-index c706d50a8b06..8c16c2f97026 100644
---- a/drivers/block/drbd/drbd_nl.c
-+++ b/drivers/block/drbd/drbd_nl.c
-@@ -525,6 +525,12 @@ void conn_try_outdate_peer_async(struct drbd_tconn *tconn)
- struct task_struct *opa;
-
- kref_get(&tconn->kref);
-+ /* We may just have force_sig()'ed this thread
-+ * to get it out of some blocking network function.
-+ * Clear signals; otherwise kthread_run(), which internally uses
-+ * wait_on_completion_killable(), will mistake our pending signal
-+ * for a new fatal signal and fail. */
-+ flush_signals(current);
- opa = kthread_run(_try_outdate_peer_async, tconn, "drbd_async_h");
- if (IS_ERR(opa)) {
- conn_err(tconn, "out of mem, failed to invoke fence-peer helper\n");
-diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c
-index 0e27844e8c2d..8089dd2cd9d8 100644
---- a/drivers/cpufreq/integrator-cpufreq.c
-+++ b/drivers/cpufreq/integrator-cpufreq.c
-@@ -213,9 +213,9 @@ static int __init integrator_cpufreq_probe(struct platform_device *pdev)
- return cpufreq_register_driver(&integrator_driver);
- }
-
--static void __exit integrator_cpufreq_remove(struct platform_device *pdev)
-+static int __exit integrator_cpufreq_remove(struct platform_device *pdev)
- {
-- cpufreq_unregister_driver(&integrator_driver);
-+ return cpufreq_unregister_driver(&integrator_driver);
- }
-
- static const struct of_device_id integrator_cpufreq_match[] = {
-diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
-index d278be110805..1855cdca39cd 100644
---- a/drivers/gpu/drm/i915/i915_gem_gtt.c
-+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
-@@ -827,6 +827,16 @@ void i915_check_and_clear_faults(struct drm_device *dev)
- POSTING_READ(RING_FAULT_REG(&dev_priv->ring[RCS]));
- }
-
-+static void i915_ggtt_flush(struct drm_i915_private *dev_priv)
-+{
-+ if (INTEL_INFO(dev_priv->dev)->gen < 6) {
-+ intel_gtt_chipset_flush();
-+ } else {
-+ I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
-+ POSTING_READ(GFX_FLSH_CNTL_GEN6);
-+ }
-+}
-+
- void i915_gem_suspend_gtt_mappings(struct drm_device *dev)
- {
- struct drm_i915_private *dev_priv = dev->dev_private;
-@@ -843,6 +853,8 @@ void i915_gem_suspend_gtt_mappings(struct drm_device *dev)
- dev_priv->gtt.base.start / PAGE_SIZE,
- dev_priv->gtt.base.total / PAGE_SIZE,
- true);
-+
-+ i915_ggtt_flush(dev_priv);
- }
-
- void i915_gem_restore_gtt_mappings(struct drm_device *dev)
-@@ -863,7 +875,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
- i915_gem_gtt_bind_object(obj, obj->cache_level);
- }
-
-- i915_gem_chipset_flush(dev);
-+ i915_ggtt_flush(dev_priv);
- }
-
- int i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj)
-diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
-index 18cda77b4f79..4913c0690872 100644
---- a/drivers/md/raid5.c
-+++ b/drivers/md/raid5.c
-@@ -64,6 +64,10 @@
- #define cpu_to_group(cpu) cpu_to_node(cpu)
- #define ANY_GROUP NUMA_NO_NODE
-
-+static bool devices_handle_discard_safely = false;
-+module_param(devices_handle_discard_safely, bool, 0644);
-+MODULE_PARM_DESC(devices_handle_discard_safely,
-+ "Set to Y if all devices in each array reliably return zeroes on reads from discarded regions");
- static struct workqueue_struct *raid5_wq;
- /*
- * Stripe cache
-@@ -6117,7 +6121,7 @@ static int run(struct mddev *mddev)
- mddev->queue->limits.discard_granularity = stripe;
- /*
- * unaligned part of discard request will be ignored, so can't
-- * guarantee discard_zerors_data
-+ * guarantee discard_zeroes_data
- */
- mddev->queue->limits.discard_zeroes_data = 0;
-
-@@ -6142,6 +6146,18 @@ static int run(struct mddev *mddev)
- !bdev_get_queue(rdev->bdev)->
- limits.discard_zeroes_data)
- discard_supported = false;
-+ /* Unfortunately, discard_zeroes_data is not currently
-+ * a guarantee - just a hint. So we only allow DISCARD
-+ * if the sysadmin has confirmed that only safe devices
-+ * are in use by setting a module parameter.
-+ */
-+ if (!devices_handle_discard_safely) {
-+ if (discard_supported) {
-+ pr_info("md/raid456: discard support disabled due to uncertainty.\n");
-+ pr_info("Set raid456.devices_handle_discard_safely=Y to override.\n");
-+ }
-+ discard_supported = false;
-+ }
- }
-
- if (discard_supported &&
-diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
-index a127925c9d61..06faea4d60ee 100644
---- a/drivers/media/v4l2-core/videobuf2-core.c
-+++ b/drivers/media/v4l2-core/videobuf2-core.c
-@@ -745,6 +745,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
- * to the userspace.
- */
- req->count = allocated_buffers;
-+ q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
-
- return 0;
- }
-@@ -793,6 +794,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
- memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
- memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
- q->memory = create->memory;
-+ q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
- }
-
- num_buffers = min(create->count, VIDEO_MAX_FRAME - q->num_buffers);
-@@ -1447,6 +1449,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
- * dequeued in dqbuf.
- */
- list_add_tail(&vb->queued_entry, &q->queued_list);
-+ q->waiting_for_buffers = false;
- vb->state = VB2_BUF_STATE_QUEUED;
-
- /*
-@@ -1841,6 +1844,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
- * and videobuf, effectively returning control over them to userspace.
- */
- __vb2_queue_cancel(q);
-+ q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
-
- dprintk(3, "Streamoff successful\n");
- return 0;
-@@ -2150,9 +2154,16 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
- }
-
- /*
-- * There is nothing to wait for if no buffers have already been queued.
-+ * There is nothing to wait for if the queue isn't streaming.
- */
-- if (list_empty(&q->queued_list))
-+ if (!vb2_is_streaming(q))
-+ return res | POLLERR;
-+ /*
-+ * For compatibility with vb1: if QBUF hasn't been called yet, then
-+ * return POLLERR as well. This only affects capture queues, output
-+ * queues will always initialize waiting_for_buffers to false.
-+ */
-+ if (q->waiting_for_buffers)
- return res | POLLERR;
-
- if (list_empty(&q->done_list))
-diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
-index f15d4353f30f..5d12d69e2045 100644
---- a/fs/cifs/cifsglob.h
-+++ b/fs/cifs/cifsglob.h
-@@ -399,6 +399,8 @@ struct smb_version_operations {
- const struct cifs_fid *, u32 *);
- int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *,
- int);
-+ /* check if we need to issue closedir */
-+ bool (*dir_needs_close)(struct cifsFileInfo *);
- };
-
- struct smb_version_values {
-diff --git a/fs/cifs/file.c b/fs/cifs/file.c
-index 8175b18df819..d375322b6cec 100644
---- a/fs/cifs/file.c
-+++ b/fs/cifs/file.c
-@@ -762,7 +762,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
-
- cifs_dbg(FYI, "Freeing private data in close dir\n");
- spin_lock(&cifs_file_list_lock);
-- if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) {
-+ if (server->ops->dir_needs_close(cfile)) {
- cfile->invalidHandle = true;
- spin_unlock(&cifs_file_list_lock);
- if (server->ops->close_dir)
-diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
-index 2bbf11b09214..b334a89d6a66 100644
---- a/fs/cifs/readdir.c
-+++ b/fs/cifs/readdir.c
-@@ -593,7 +593,7 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
- /* close and restart search */
- cifs_dbg(FYI, "search backing up - close and restart search\n");
- spin_lock(&cifs_file_list_lock);
-- if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) {
-+ if (server->ops->dir_needs_close(cfile)) {
- cfile->invalidHandle = true;
- spin_unlock(&cifs_file_list_lock);
- if (server->ops->close_dir)
-diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
-index d1fdfa848703..e9ad8d37bb00 100644
---- a/fs/cifs/smb1ops.c
-+++ b/fs/cifs/smb1ops.c
-@@ -586,7 +586,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
- tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
- if (tmprc == -EOPNOTSUPP)
- *symlink = true;
-- else
-+ else if (tmprc == 0)
- CIFSSMBClose(xid, tcon, fid.netfid);
- }
-
-@@ -1009,6 +1009,12 @@ cifs_is_read_op(__u32 oplock)
- return oplock == OPLOCK_READ;
- }
-
-+static bool
-+cifs_dir_needs_close(struct cifsFileInfo *cfile)
-+{
-+ return !cfile->srch_inf.endOfSearch && !cfile->invalidHandle;
-+}
-+
- struct smb_version_operations smb1_operations = {
- .send_cancel = send_nt_cancel,
- .compare_fids = cifs_compare_fids,
-@@ -1078,6 +1084,7 @@ struct smb_version_operations smb1_operations = {
- .query_mf_symlink = cifs_query_mf_symlink,
- .create_mf_symlink = cifs_create_mf_symlink,
- .is_read_op = cifs_is_read_op,
-+ .dir_needs_close = cifs_dir_needs_close,
- #ifdef CONFIG_CIFS_XATTR
- .query_all_EAs = CIFSSMBQAllEAs,
- .set_EA = CIFSSMBSetEA,
-diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c
-index e31a9dfdcd39..a491814cb2c0 100644
---- a/fs/cifs/smb2maperror.c
-+++ b/fs/cifs/smb2maperror.c
-@@ -214,7 +214,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
- {STATUS_BREAKPOINT, -EIO, "STATUS_BREAKPOINT"},
- {STATUS_SINGLE_STEP, -EIO, "STATUS_SINGLE_STEP"},
- {STATUS_BUFFER_OVERFLOW, -EIO, "STATUS_BUFFER_OVERFLOW"},
-- {STATUS_NO_MORE_FILES, -EIO, "STATUS_NO_MORE_FILES"},
-+ {STATUS_NO_MORE_FILES, -ENODATA, "STATUS_NO_MORE_FILES"},
- {STATUS_WAKE_SYSTEM_DEBUGGER, -EIO, "STATUS_WAKE_SYSTEM_DEBUGGER"},
- {STATUS_HANDLES_CLOSED, -EIO, "STATUS_HANDLES_CLOSED"},
- {STATUS_NO_INHERITANCE, -EIO, "STATUS_NO_INHERITANCE"},
-@@ -256,6 +256,8 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
- {STATUS_DLL_MIGHT_BE_INCOMPATIBLE, -EIO,
- "STATUS_DLL_MIGHT_BE_INCOMPATIBLE"},
- {STATUS_STOPPED_ON_SYMLINK, -EOPNOTSUPP, "STATUS_STOPPED_ON_SYMLINK"},
-+ {STATUS_IO_REPARSE_TAG_NOT_HANDLED, -EOPNOTSUPP,
-+ "STATUS_REPARSE_NOT_HANDLED"},
- {STATUS_DEVICE_REQUIRES_CLEANING, -EIO,
- "STATUS_DEVICE_REQUIRES_CLEANING"},
- {STATUS_DEVICE_DOOR_OPEN, -EIO, "STATUS_DEVICE_DOOR_OPEN"},
-diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
-index f8977b2d9187..34a17d425be6 100644
---- a/fs/cifs/smb2ops.c
-+++ b/fs/cifs/smb2ops.c
-@@ -1102,6 +1102,12 @@ smb3_parse_lease_buf(void *buf, unsigned int *epoch)
- return le32_to_cpu(lc->lcontext.LeaseState);
- }
-
-+static bool
-+smb2_dir_needs_close(struct cifsFileInfo *cfile)
-+{
-+ return !cfile->invalidHandle;
-+}
-+
- struct smb_version_operations smb20_operations = {
- .compare_fids = smb2_compare_fids,
- .setup_request = smb2_setup_request,
-@@ -1175,6 +1181,7 @@ struct smb_version_operations smb20_operations = {
- .create_lease_buf = smb2_create_lease_buf,
- .parse_lease_buf = smb2_parse_lease_buf,
- .clone_range = smb2_clone_range,
-+ .dir_needs_close = smb2_dir_needs_close,
- };
-
- struct smb_version_operations smb21_operations = {
-@@ -1250,6 +1257,7 @@ struct smb_version_operations smb21_operations = {
- .create_lease_buf = smb2_create_lease_buf,
- .parse_lease_buf = smb2_parse_lease_buf,
- .clone_range = smb2_clone_range,
-+ .dir_needs_close = smb2_dir_needs_close,
- };
-
- struct smb_version_operations smb30_operations = {
-@@ -1328,6 +1336,7 @@ struct smb_version_operations smb30_operations = {
- .parse_lease_buf = smb3_parse_lease_buf,
- .clone_range = smb2_clone_range,
- .validate_negotiate = smb3_validate_negotiate,
-+ .dir_needs_close = smb2_dir_needs_close,
- };
-
- struct smb_version_values smb20_values = {
-diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
-index 9aab8fe0e508..348792911e1f 100644
---- a/fs/cifs/smb2pdu.c
-+++ b/fs/cifs/smb2pdu.c
-@@ -2136,6 +2136,10 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
- rsp = (struct smb2_query_directory_rsp *)iov[0].iov_base;
-
- if (rc) {
-+ if (rc == -ENODATA && rsp->hdr.Status == STATUS_NO_MORE_FILES) {
-+ srch_inf->endOfSearch = true;
-+ rc = 0;
-+ }
- cifs_stats_fail_inc(tcon, SMB2_QUERY_DIRECTORY_HE);
- goto qdir_exit;
- }
-@@ -2173,11 +2177,6 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
- else
- cifs_dbg(VFS, "illegal search buffer type\n");
-
-- if (rsp->hdr.Status == STATUS_NO_MORE_FILES)
-- srch_inf->endOfSearch = 1;
-- else
-- srch_inf->endOfSearch = 0;
--
- return rc;
-
- qdir_exit:
-diff --git a/fs/exec.c b/fs/exec.c
-index 31e46b1b358b..ea4449d0536a 100644
---- a/fs/exec.c
-+++ b/fs/exec.c
-@@ -26,6 +26,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -820,7 +821,7 @@ EXPORT_SYMBOL(read_code);
- static int exec_mmap(struct mm_struct *mm)
- {
- struct task_struct *tsk;
-- struct mm_struct * old_mm, *active_mm;
-+ struct mm_struct *old_mm, *active_mm;
-
- /* Notify parent that we're no longer interested in the old VM */
- tsk = current;
-@@ -846,6 +847,8 @@ static int exec_mmap(struct mm_struct *mm)
- tsk->mm = mm;
- tsk->active_mm = mm;
- activate_mm(active_mm, mm);
-+ tsk->mm->vmacache_seqnum = 0;
-+ vmacache_flush(tsk);
- task_unlock(tsk);
- if (old_mm) {
- up_read(&old_mm->mmap_sem);
-diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
-index d19b30ababf1..a4a8ed56e438 100644
---- a/fs/hugetlbfs/inode.c
-+++ b/fs/hugetlbfs/inode.c
-@@ -1017,6 +1017,11 @@ static int __init init_hugetlbfs_fs(void)
- int error;
- int i;
-
-+ if (!hugepages_supported()) {
-+ pr_info("hugetlbfs: disabling because there are no supported hugepage sizes\n");
-+ return -ENOTSUPP;
-+ }
-+
- error = bdi_init(&hugetlbfs_backing_dev_info);
- if (error)
- return error;
-diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
-index 8f788193e3d4..c4b2646b6d7c 100644
---- a/fs/proc/task_mmu.c
-+++ b/fs/proc/task_mmu.c
-@@ -1,4 +1,5 @@
- #include
-+#include
- #include
- #include
- #include
-@@ -152,7 +153,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
-
- /*
- * We remember last_addr rather than next_addr to hit with
-- * mmap_cache most of the time. We have zero last_addr at
-+ * vmacache most of the time. We have zero last_addr at
- * the beginning and also after lseek. We will have -1 last_addr
- * after the end of the vmas.
- */
-diff --git a/fs/udf/inode.c b/fs/udf/inode.c
-index 982ce05c87ed..287cd5f23421 100644
---- a/fs/udf/inode.c
-+++ b/fs/udf/inode.c
-@@ -1271,13 +1271,22 @@ update_time:
- return 0;
- }
-
-+/*
-+ * Maximum length of linked list formed by ICB hierarchy. The chosen number is
-+ * arbitrary - just that we hopefully don't limit any real use of rewritten
-+ * inode on write-once media but avoid looping for too long on corrupted media.
-+ */
-+#define UDF_MAX_ICB_NESTING 1024
-+
- static void __udf_read_inode(struct inode *inode)
- {
- struct buffer_head *bh = NULL;
- struct fileEntry *fe;
- uint16_t ident;
- struct udf_inode_info *iinfo = UDF_I(inode);
-+ unsigned int indirections = 0;
-
-+reread:
- /*
- * Set defaults, but the inode is still incomplete!
- * Note: get_new_inode() sets the following on a new inode:
-@@ -1314,28 +1323,26 @@ static void __udf_read_inode(struct inode *inode)
- ibh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 1,
- &ident);
- if (ident == TAG_IDENT_IE && ibh) {
-- struct buffer_head *nbh = NULL;
- struct kernel_lb_addr loc;
- struct indirectEntry *ie;
-
- ie = (struct indirectEntry *)ibh->b_data;
- loc = lelb_to_cpu(ie->indirectICB.extLocation);
-
-- if (ie->indirectICB.extLength &&
-- (nbh = udf_read_ptagged(inode->i_sb, &loc, 0,
-- &ident))) {
-- if (ident == TAG_IDENT_FE ||
-- ident == TAG_IDENT_EFE) {
-- memcpy(&iinfo->i_location,
-- &loc,
-- sizeof(struct kernel_lb_addr));
-- brelse(bh);
-- brelse(ibh);
-- brelse(nbh);
-- __udf_read_inode(inode);
-+ if (ie->indirectICB.extLength) {
-+ brelse(bh);
-+ brelse(ibh);
-+ memcpy(&iinfo->i_location, &loc,
-+ sizeof(struct kernel_lb_addr));
-+ if (++indirections > UDF_MAX_ICB_NESTING) {
-+ udf_err(inode->i_sb,
-+ "too many ICBs in ICB hierarchy"
-+ " (max %d supported)\n",
-+ UDF_MAX_ICB_NESTING);
-+ make_bad_inode(inode);
- return;
- }
-- brelse(nbh);
-+ goto reread;
- }
- }
- brelse(ibh);
-diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
-index 3fe661fe96d1..b19d3dc2e651 100644
---- a/include/linux/cpuset.h
-+++ b/include/linux/cpuset.h
-@@ -87,25 +87,26 @@ extern void rebuild_sched_domains(void);
- extern void cpuset_print_task_mems_allowed(struct task_struct *p);
-
- /*
-- * get_mems_allowed is required when making decisions involving mems_allowed
-- * such as during page allocation. mems_allowed can be updated in parallel
-- * and depending on the new value an operation can fail potentially causing
-- * process failure. A retry loop with get_mems_allowed and put_mems_allowed
-- * prevents these artificial failures.
-+ * read_mems_allowed_begin is required when making decisions involving
-+ * mems_allowed such as during page allocation. mems_allowed can be updated in
-+ * parallel and depending on the new value an operation can fail potentially
-+ * causing process failure. A retry loop with read_mems_allowed_begin and
-+ * read_mems_allowed_retry prevents these artificial failures.
- */
--static inline unsigned int get_mems_allowed(void)
-+static inline unsigned int read_mems_allowed_begin(void)
- {
- return read_seqcount_begin(¤t->mems_allowed_seq);
- }
-
- /*
-- * If this returns false, the operation that took place after get_mems_allowed
-- * may have failed. It is up to the caller to retry the operation if
-+ * If this returns true, the operation that took place after
-+ * read_mems_allowed_begin may have failed artificially due to a concurrent
-+ * update of mems_allowed. It is up to the caller to retry the operation if
- * appropriate.
- */
--static inline bool put_mems_allowed(unsigned int seq)
-+static inline bool read_mems_allowed_retry(unsigned int seq)
- {
-- return !read_seqcount_retry(¤t->mems_allowed_seq, seq);
-+ return read_seqcount_retry(¤t->mems_allowed_seq, seq);
- }
-
- static inline void set_mems_allowed(nodemask_t nodemask)
-@@ -225,14 +226,14 @@ static inline void set_mems_allowed(nodemask_t nodemask)
- {
- }
-
--static inline unsigned int get_mems_allowed(void)
-+static inline unsigned int read_mems_allowed_begin(void)
- {
- return 0;
- }
-
--static inline bool put_mems_allowed(unsigned int seq)
-+static inline bool read_mems_allowed_retry(unsigned int seq)
- {
-- return true;
-+ return false;
- }
-
- #endif /* !CONFIG_CPUSETS */
-diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
-index bd1e9bcec547..42b05c4c53e5 100644
---- a/include/linux/hugetlb.h
-+++ b/include/linux/hugetlb.h
-@@ -400,6 +400,16 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
- return &mm->page_table_lock;
- }
-
-+static inline bool hugepages_supported(void)
-+{
-+ /*
-+ * Some platform decide whether they support huge pages at boot
-+ * time. On these, such as powerpc, HPAGE_SHIFT is set to 0 when
-+ * there is no such support
-+ */
-+ return HPAGE_SHIFT != 0;
-+}
-+
- #else /* CONFIG_HUGETLB_PAGE */
- struct hstate {};
- #define alloc_huge_page_node(h, nid) NULL
-diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
-index 1f44466c1e9d..c367cbdf73ab 100644
---- a/include/linux/jiffies.h
-+++ b/include/linux/jiffies.h
-@@ -258,23 +258,11 @@ extern unsigned long preset_lpj;
- #define SEC_JIFFIE_SC (32 - SHIFT_HZ)
- #endif
- #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
--#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
- #define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\
- TICK_NSEC -1) / (u64)TICK_NSEC))
-
- #define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\
- TICK_NSEC -1) / (u64)TICK_NSEC))
--#define USEC_CONVERSION \
-- ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\
-- TICK_NSEC -1) / (u64)TICK_NSEC))
--/*
-- * USEC_ROUND is used in the timeval to jiffie conversion. See there
-- * for more details. It is the scaled resolution rounding value. Note
-- * that it is a 64-bit value. Since, when it is applied, we are already
-- * in jiffies (albit scaled), it is nothing but the bits we will shift
-- * off.
-- */
--#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)
- /*
- * The maximum jiffie value is (MAX_INT >> 1). Here we translate that
- * into seconds. The 64-bit case will overflow if we are not careful,
-diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
-index 290901a8c1de..2b58d192ea24 100644
---- a/include/linux/mm_types.h
-+++ b/include/linux/mm_types.h
-@@ -342,9 +342,9 @@ struct mm_rss_stat {
-
- struct kioctx_table;
- struct mm_struct {
-- struct vm_area_struct * mmap; /* list of VMAs */
-+ struct vm_area_struct *mmap; /* list of VMAs */
- struct rb_root mm_rb;
-- struct vm_area_struct * mmap_cache; /* last find_vma result */
-+ u32 vmacache_seqnum; /* per-thread vmacache */
- #ifdef CONFIG_MMU
- unsigned long (*get_unmapped_area) (struct file *filp,
- unsigned long addr, unsigned long len,
-diff --git a/include/linux/plist.h b/include/linux/plist.h
-index aa0fb390bd29..8b6c970cff6c 100644
---- a/include/linux/plist.h
-+++ b/include/linux/plist.h
-@@ -98,6 +98,13 @@ struct plist_node {
- }
-
- /**
-+ * PLIST_HEAD - declare and init plist_head
-+ * @head: name for struct plist_head variable
-+ */
-+#define PLIST_HEAD(head) \
-+ struct plist_head head = PLIST_HEAD_INIT(head)
-+
-+/**
- * PLIST_NODE_INIT - static struct plist_node initializer
- * @node: struct plist_node variable name
- * @__prio: initial node priority
-@@ -134,6 +141,8 @@ static inline void plist_node_init(struct plist_node *node, int prio)
- extern void plist_add(struct plist_node *node, struct plist_head *head);
- extern void plist_del(struct plist_node *node, struct plist_head *head);
-
-+extern void plist_requeue(struct plist_node *node, struct plist_head *head);
-+
- /**
- * plist_for_each - iterate over the plist
- * @pos: the type * to use as a loop counter
-@@ -143,6 +152,16 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
- list_for_each_entry(pos, &(head)->node_list, node_list)
-
- /**
-+ * plist_for_each_continue - continue iteration over the plist
-+ * @pos: the type * to use as a loop cursor
-+ * @head: the head for your list
-+ *
-+ * Continue to iterate over plist, continuing after the current position.
-+ */
-+#define plist_for_each_continue(pos, head) \
-+ list_for_each_entry_continue(pos, &(head)->node_list, node_list)
-+
-+/**
- * plist_for_each_safe - iterate safely over a plist of given type
- * @pos: the type * to use as a loop counter
- * @n: another type * to use as temporary storage
-@@ -163,6 +182,18 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
- list_for_each_entry(pos, &(head)->node_list, mem.node_list)
-
- /**
-+ * plist_for_each_entry_continue - continue iteration over list of given type
-+ * @pos: the type * to use as a loop cursor
-+ * @head: the head for your list
-+ * @m: the name of the list_struct within the struct
-+ *
-+ * Continue to iterate over list of given type, continuing after
-+ * the current position.
-+ */
-+#define plist_for_each_entry_continue(pos, head, m) \
-+ list_for_each_entry_continue(pos, &(head)->node_list, m.node_list)
-+
-+/**
- * plist_for_each_entry_safe - iterate safely over list of given type
- * @pos: the type * to use as a loop counter
- * @n: another type * to use as temporary storage
-@@ -229,6 +260,20 @@ static inline int plist_node_empty(const struct plist_node *node)
- #endif
-
- /**
-+ * plist_next - get the next entry in list
-+ * @pos: the type * to cursor
-+ */
-+#define plist_next(pos) \
-+ list_next_entry(pos, node_list)
-+
-+/**
-+ * plist_prev - get the prev entry in list
-+ * @pos: the type * to cursor
-+ */
-+#define plist_prev(pos) \
-+ list_prev_entry(pos, node_list)
-+
-+/**
- * plist_first - return the first node (and thus, highest priority)
- * @head: the &struct plist_head pointer
- *
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index ccd0c6f24f2c..d7ca410ace93 100644
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -59,6 +59,10 @@ struct sched_param {
-
- #define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
-
-+#define VMACACHE_BITS 2
-+#define VMACACHE_SIZE (1U << VMACACHE_BITS)
-+#define VMACACHE_MASK (VMACACHE_SIZE - 1)
-+
- /*
- * Extended scheduling parameters data structure.
- *
-@@ -1228,6 +1232,9 @@ struct task_struct {
- #ifdef CONFIG_COMPAT_BRK
- unsigned brk_randomized:1;
- #endif
-+ /* per-thread vma caching */
-+ u32 vmacache_seqnum;
-+ struct vm_area_struct *vmacache[VMACACHE_SIZE];
- #if defined(SPLIT_RSS_COUNTING)
- struct task_rss_stat rss_stat;
- #endif
-diff --git a/include/linux/swap.h b/include/linux/swap.h
-index 46ba0c6c219f..789324976801 100644
---- a/include/linux/swap.h
-+++ b/include/linux/swap.h
-@@ -214,8 +214,9 @@ struct percpu_cluster {
- struct swap_info_struct {
- unsigned long flags; /* SWP_USED etc: see above */
- signed short prio; /* swap priority of this type */
-+ struct plist_node list; /* entry in swap_active_head */
-+ struct plist_node avail_list; /* entry in swap_avail_head */
- signed char type; /* strange name for an index */
-- signed char next; /* next type on the swap list */
- unsigned int max; /* extent of the swap_map */
- unsigned char *swap_map; /* vmalloc'ed array of usage counts */
- struct swap_cluster_info *cluster_info; /* cluster info. Only for SSD */
-@@ -255,11 +256,6 @@ struct swap_info_struct {
- struct swap_cluster_info discard_cluster_tail; /* list tail of discard clusters */
- };
-
--struct swap_list_t {
-- int head; /* head of priority-ordered swapfile list */
-- int next; /* swapfile to be used next */
--};
--
- /* linux/mm/page_alloc.c */
- extern unsigned long totalram_pages;
- extern unsigned long totalreserve_pages;
-diff --git a/include/linux/swapfile.h b/include/linux/swapfile.h
-index e282624e8c10..388293a91e8c 100644
---- a/include/linux/swapfile.h
-+++ b/include/linux/swapfile.h
-@@ -6,7 +6,7 @@
- * want to expose them to the dozens of source files that include swap.h
- */
- extern spinlock_t swap_lock;
--extern struct swap_list_t swap_list;
-+extern struct plist_head swap_active_head;
- extern struct swap_info_struct *swap_info[];
- extern int try_to_unuse(unsigned int, bool, unsigned long);
-
-diff --git a/include/linux/vmacache.h b/include/linux/vmacache.h
-new file mode 100644
-index 000000000000..c3fa0fd43949
---- /dev/null
-+++ b/include/linux/vmacache.h
-@@ -0,0 +1,38 @@
-+#ifndef __LINUX_VMACACHE_H
-+#define __LINUX_VMACACHE_H
-+
-+#include
-+#include
-+
-+/*
-+ * Hash based on the page number. Provides a good hit rate for
-+ * workloads with good locality and those with random accesses as well.
-+ */
-+#define VMACACHE_HASH(addr) ((addr >> PAGE_SHIFT) & VMACACHE_MASK)
-+
-+static inline void vmacache_flush(struct task_struct *tsk)
-+{
-+ memset(tsk->vmacache, 0, sizeof(tsk->vmacache));
-+}
-+
-+extern void vmacache_flush_all(struct mm_struct *mm);
-+extern void vmacache_update(unsigned long addr, struct vm_area_struct *newvma);
-+extern struct vm_area_struct *vmacache_find(struct mm_struct *mm,
-+ unsigned long addr);
-+
-+#ifndef CONFIG_MMU
-+extern struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
-+ unsigned long start,
-+ unsigned long end);
-+#endif
-+
-+static inline void vmacache_invalidate(struct mm_struct *mm)
-+{
-+ mm->vmacache_seqnum++;
-+
-+ /* deal with overflows */
-+ if (unlikely(mm->vmacache_seqnum == 0))
-+ vmacache_flush_all(mm);
-+}
-+
-+#endif /* __LINUX_VMACACHE_H */
-diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
-index bef53ce555d2..b10682cb138c 100644
---- a/include/media/videobuf2-core.h
-+++ b/include/media/videobuf2-core.h
-@@ -329,6 +329,9 @@ struct v4l2_fh;
- * @retry_start_streaming: start_streaming() was called, but there were not enough
- * buffers queued. If set, then retry calling start_streaming when
- * queuing a new buffer.
-+ * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for
-+ * buffers. Only set for capture queues if qbuf has not yet been
-+ * called since poll() needs to return POLLERR in that situation.
- * @fileio: file io emulator internal data, used only if emulator is active
- */
- struct vb2_queue {
-@@ -362,6 +365,7 @@ struct vb2_queue {
-
- unsigned int streaming:1;
- unsigned int retry_start_streaming:1;
-+ unsigned int waiting_for_buffers:1;
-
- struct vb2_fileio_data *fileio;
- };
-diff --git a/init/Kconfig b/init/Kconfig
-index 93c5ef0c5210..8b9521a2d2c1 100644
---- a/init/Kconfig
-+++ b/init/Kconfig
-@@ -1389,6 +1389,7 @@ config FUTEX
-
- config HAVE_FUTEX_CMPXCHG
- bool
-+ depends on FUTEX
- help
- Architectures should select this if futex_atomic_cmpxchg_inatomic()
- is implemented and always working. This removes a couple of runtime
-diff --git a/kernel/cpuset.c b/kernel/cpuset.c
-index 6b27e5c0cd86..15b3ea693225 100644
---- a/kernel/cpuset.c
-+++ b/kernel/cpuset.c
-@@ -1022,7 +1022,7 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
- task_lock(tsk);
- /*
- * Determine if a loop is necessary if another thread is doing
-- * get_mems_allowed(). If at least one node remains unchanged and
-+ * read_mems_allowed_begin(). If at least one node remains unchanged and
- * tsk does not have a mempolicy, then an empty nodemask will not be
- * possible when mems_allowed is larger than a word.
- */
-diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
-index 334b3980ffc1..8865caec45fb 100644
---- a/kernel/debug/debug_core.c
-+++ b/kernel/debug/debug_core.c
-@@ -49,6 +49,7 @@
- #include
- #include
- #include
-+#include
- #include
-
- #include
-@@ -224,10 +225,17 @@ static void kgdb_flush_swbreak_addr(unsigned long addr)
- if (!CACHE_FLUSH_IS_SAFE)
- return;
-
-- if (current->mm && current->mm->mmap_cache) {
-- flush_cache_range(current->mm->mmap_cache,
-- addr, addr + BREAK_INSTR_SIZE);
-+ if (current->mm) {
-+ int i;
-+
-+ for (i = 0; i < VMACACHE_SIZE; i++) {
-+ if (!current->vmacache[i])
-+ continue;
-+ flush_cache_range(current->vmacache[i],
-+ addr, addr + BREAK_INSTR_SIZE);
-+ }
- }
-+
- /* Force flush instruction cache if it was outside the mm */
- flush_icache_range(addr, addr + BREAK_INSTR_SIZE);
- }
-diff --git a/kernel/events/core.c b/kernel/events/core.c
-index 3a140ca37777..4ced342f1ba9 100644
---- a/kernel/events/core.c
-+++ b/kernel/events/core.c
-@@ -7836,8 +7836,10 @@ int perf_event_init_task(struct task_struct *child)
-
- for_each_task_context_nr(ctxn) {
- ret = perf_event_init_context(child, ctxn);
-- if (ret)
-+ if (ret) {
-+ perf_event_free_task(child);
- return ret;
-+ }
- }
-
- return 0;
-diff --git a/kernel/fork.c b/kernel/fork.c
-index c44bff8097f5..e2c685396295 100644
---- a/kernel/fork.c
-+++ b/kernel/fork.c
-@@ -28,6 +28,8 @@
- #include
- #include
- #include
-+#include
-+#include
- #include
- #include
- #include
-@@ -363,7 +365,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
-
- mm->locked_vm = 0;
- mm->mmap = NULL;
-- mm->mmap_cache = NULL;
-+ mm->vmacache_seqnum = 0;
- mm->map_count = 0;
- cpumask_clear(mm_cpumask(mm));
- mm->mm_rb = RB_ROOT;
-@@ -876,6 +878,9 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
- if (!oldmm)
- return 0;
-
-+ /* initialize the new vmacache entries */
-+ vmacache_flush(tsk);
-+
- if (clone_flags & CLONE_VM) {
- atomic_inc(&oldmm->mm_users);
- mm = oldmm;
-@@ -1323,7 +1328,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
- goto bad_fork_cleanup_policy;
- retval = audit_alloc(p);
- if (retval)
-- goto bad_fork_cleanup_policy;
-+ goto bad_fork_cleanup_perf;
- /* copy all the process information */
- retval = copy_semundo(clone_flags, p);
- if (retval)
-@@ -1522,8 +1527,9 @@ bad_fork_cleanup_semundo:
- exit_sem(p);
- bad_fork_cleanup_audit:
- audit_free(p);
--bad_fork_cleanup_policy:
-+bad_fork_cleanup_perf:
- perf_event_free_task(p);
-+bad_fork_cleanup_policy:
- #ifdef CONFIG_NUMA
- mpol_put(p->mempolicy);
- bad_fork_cleanup_cgroup:
-diff --git a/kernel/time.c b/kernel/time.c
-index 7c7964c33ae7..3c49ab45f822 100644
---- a/kernel/time.c
-+++ b/kernel/time.c
-@@ -496,17 +496,20 @@ EXPORT_SYMBOL(usecs_to_jiffies);
- * that a remainder subtract here would not do the right thing as the
- * resolution values don't fall on second boundries. I.e. the line:
- * nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding.
-+ * Note that due to the small error in the multiplier here, this
-+ * rounding is incorrect for sufficiently large values of tv_nsec, but
-+ * well formed timespecs should have tv_nsec < NSEC_PER_SEC, so we're
-+ * OK.
- *
- * Rather, we just shift the bits off the right.
- *
- * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
- * value to a scaled second value.
- */
--unsigned long
--timespec_to_jiffies(const struct timespec *value)
-+static unsigned long
-+__timespec_to_jiffies(unsigned long sec, long nsec)
- {
-- unsigned long sec = value->tv_sec;
-- long nsec = value->tv_nsec + TICK_NSEC - 1;
-+ nsec = nsec + TICK_NSEC - 1;
-
- if (sec >= MAX_SEC_IN_JIFFIES){
- sec = MAX_SEC_IN_JIFFIES;
-@@ -517,6 +520,13 @@ timespec_to_jiffies(const struct timespec *value)
- (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
-
- }
-+
-+unsigned long
-+timespec_to_jiffies(const struct timespec *value)
-+{
-+ return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
-+}
-+
- EXPORT_SYMBOL(timespec_to_jiffies);
-
- void
-@@ -533,31 +543,27 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
- }
- EXPORT_SYMBOL(jiffies_to_timespec);
-
--/* Same for "timeval"
-+/*
-+ * We could use a similar algorithm to timespec_to_jiffies (with a
-+ * different multiplier for usec instead of nsec). But this has a
-+ * problem with rounding: we can't exactly add TICK_NSEC - 1 to the
-+ * usec value, since it's not necessarily integral.
- *
-- * Well, almost. The problem here is that the real system resolution is
-- * in nanoseconds and the value being converted is in micro seconds.
-- * Also for some machines (those that use HZ = 1024, in-particular),
-- * there is a LARGE error in the tick size in microseconds.
--
-- * The solution we use is to do the rounding AFTER we convert the
-- * microsecond part. Thus the USEC_ROUND, the bits to be shifted off.
-- * Instruction wise, this should cost only an additional add with carry
-- * instruction above the way it was done above.
-+ * We could instead round in the intermediate scaled representation
-+ * (i.e. in units of 1/2^(large scale) jiffies) but that's also
-+ * perilous: the scaling introduces a small positive error, which
-+ * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1
-+ * units to the intermediate before shifting) leads to accidental
-+ * overflow and overestimates.
-+ *
-+ * At the cost of one additional multiplication by a constant, just
-+ * use the timespec implementation.
- */
- unsigned long
- timeval_to_jiffies(const struct timeval *value)
- {
-- unsigned long sec = value->tv_sec;
-- long usec = value->tv_usec;
--
-- if (sec >= MAX_SEC_IN_JIFFIES){
-- sec = MAX_SEC_IN_JIFFIES;
-- usec = 0;
-- }
-- return (((u64)sec * SEC_CONVERSION) +
-- (((u64)usec * USEC_CONVERSION + USEC_ROUND) >>
-- (USEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
-+ return __timespec_to_jiffies(value->tv_sec,
-+ value->tv_usec * NSEC_PER_USEC);
- }
- EXPORT_SYMBOL(timeval_to_jiffies);
-
-diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
-index 773aba836e81..774a0807fe81 100644
---- a/kernel/trace/ring_buffer.c
-+++ b/kernel/trace/ring_buffer.c
-@@ -3372,7 +3372,7 @@ static void rb_iter_reset(struct ring_buffer_iter *iter)
- iter->head = cpu_buffer->reader_page->read;
-
- iter->cache_reader_page = iter->head_page;
-- iter->cache_read = iter->head;
-+ iter->cache_read = cpu_buffer->read;
-
- if (iter->head)
- iter->read_stamp = cpu_buffer->read_stamp;
-diff --git a/lib/plist.c b/lib/plist.c
-index 1ebc95f7a46f..0f2084d30798 100644
---- a/lib/plist.c
-+++ b/lib/plist.c
-@@ -134,6 +134,46 @@ void plist_del(struct plist_node *node, struct plist_head *head)
- plist_check_head(head);
- }
-
-+/**
-+ * plist_requeue - Requeue @node at end of same-prio entries.
-+ *
-+ * This is essentially an optimized plist_del() followed by
-+ * plist_add(). It moves an entry already in the plist to
-+ * after any other same-priority entries.
-+ *
-+ * @node: &struct plist_node pointer - entry to be moved
-+ * @head: &struct plist_head pointer - list head
-+ */
-+void plist_requeue(struct plist_node *node, struct plist_head *head)
-+{
-+ struct plist_node *iter;
-+ struct list_head *node_next = &head->node_list;
-+
-+ plist_check_head(head);
-+ BUG_ON(plist_head_empty(head));
-+ BUG_ON(plist_node_empty(node));
-+
-+ if (node == plist_last(head))
-+ return;
-+
-+ iter = plist_next(node);
-+
-+ if (node->prio != iter->prio)
-+ return;
-+
-+ plist_del(node, head);
-+
-+ plist_for_each_continue(iter, head) {
-+ if (node->prio != iter->prio) {
-+ node_next = &iter->node_list;
-+ break;
-+ }
-+ }
-+ list_add_tail(&node->node_list, node_next);
-+
-+ plist_check_head(head);
-+}
-+
- #ifdef CONFIG_DEBUG_PI_LIST
- #include
- #include
-@@ -170,6 +210,14 @@ static void __init plist_test_check(int nr_expect)
- BUG_ON(prio_pos->prio_list.next != &first->prio_list);
- }
-
-+static void __init plist_test_requeue(struct plist_node *node)
-+{
-+ plist_requeue(node, &test_head);
-+
-+ if (node != plist_last(&test_head))
-+ BUG_ON(node->prio == plist_next(node)->prio);
-+}
-+
- static int __init plist_test(void)
- {
- int nr_expect = 0, i, loop;
-@@ -193,6 +241,10 @@ static int __init plist_test(void)
- nr_expect--;
- }
- plist_test_check(nr_expect);
-+ if (!plist_node_empty(test_node + i)) {
-+ plist_test_requeue(test_node + i);
-+ plist_test_check(nr_expect);
-+ }
- }
-
- for (i = 0; i < ARRAY_SIZE(test_node); i++) {
-diff --git a/mm/Makefile b/mm/Makefile
-index 310c90a09264..c561f1f6bca0 100644
---- a/mm/Makefile
-+++ b/mm/Makefile
-@@ -16,7 +16,7 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
- readahead.o swap.o truncate.o vmscan.o shmem.o \
- util.o mmzone.o vmstat.o backing-dev.o \
- mm_init.o mmu_context.o percpu.o slab_common.o \
-- compaction.o balloon_compaction.o \
-+ compaction.o balloon_compaction.o vmacache.o \
- interval_tree.o list_lru.o $(mmu-y)
-
- obj-y += init-mm.o
-diff --git a/mm/compaction.c b/mm/compaction.c
-index 5f702ef0a65f..5e38e5706f62 100644
---- a/mm/compaction.c
-+++ b/mm/compaction.c
-@@ -217,21 +217,12 @@ static inline bool compact_trylock_irqsave(spinlock_t *lock,
- /* Returns true if the page is within a block suitable for migration to */
- static bool suitable_migration_target(struct page *page)
- {
-- int migratetype = get_pageblock_migratetype(page);
--
-- /* Don't interfere with memory hot-remove or the min_free_kbytes blocks */
-- if (migratetype == MIGRATE_RESERVE)
-- return false;
--
-- if (is_migrate_isolate(migratetype))
-- return false;
--
-- /* If the page is a large free page, then allow migration */
-+ /* If the page is a large free page, then disallow migration */
- if (PageBuddy(page) && page_order(page) >= pageblock_order)
-- return true;
-+ return false;
-
- /* If the block is MIGRATE_MOVABLE or MIGRATE_CMA, allow migration */
-- if (migrate_async_suitable(migratetype))
-+ if (migrate_async_suitable(get_pageblock_migratetype(page)))
- return true;
-
- /* Otherwise skip the block */
-@@ -253,6 +244,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
- struct page *cursor, *valid_page = NULL;
- unsigned long flags;
- bool locked = false;
-+ bool checked_pageblock = false;
-
- cursor = pfn_to_page(blockpfn);
-
-@@ -284,8 +276,16 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
- break;
-
- /* Recheck this is a suitable migration target under lock */
-- if (!strict && !suitable_migration_target(page))
-- break;
-+ if (!strict && !checked_pageblock) {
-+ /*
-+ * We need to check suitability of pageblock only once
-+ * and this isolate_freepages_block() is called with
-+ * pageblock range, so just check once is sufficient.
-+ */
-+ checked_pageblock = true;
-+ if (!suitable_migration_target(page))
-+ break;
-+ }
-
- /* Recheck this is a buddy page under lock */
- if (!PageBuddy(page))
-@@ -460,12 +460,13 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- unsigned long last_pageblock_nr = 0, pageblock_nr;
- unsigned long nr_scanned = 0, nr_isolated = 0;
- struct list_head *migratelist = &cc->migratepages;
-- isolate_mode_t mode = 0;
- struct lruvec *lruvec;
- unsigned long flags;
- bool locked = false;
- struct page *page = NULL, *valid_page = NULL;
- bool skipped_async_unsuitable = false;
-+ const isolate_mode_t mode = (!cc->sync ? ISOLATE_ASYNC_MIGRATE : 0) |
-+ (unevictable ? ISOLATE_UNEVICTABLE : 0);
-
- /*
- * Ensure that there are not too many pages isolated from the LRU
-@@ -487,7 +488,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- cond_resched();
- for (; low_pfn < end_pfn; low_pfn++) {
- /* give a chance to irqs before checking need_resched() */
-- if (locked && !((low_pfn+1) % SWAP_CLUSTER_MAX)) {
-+ if (locked && !(low_pfn % SWAP_CLUSTER_MAX)) {
- if (should_release_lock(&zone->lru_lock)) {
- spin_unlock_irqrestore(&zone->lru_lock, flags);
- locked = false;
-@@ -526,8 +527,25 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
-
- /* If isolation recently failed, do not retry */
- pageblock_nr = low_pfn >> pageblock_order;
-- if (!isolation_suitable(cc, page))
-- goto next_pageblock;
-+ if (last_pageblock_nr != pageblock_nr) {
-+ int mt;
-+
-+ last_pageblock_nr = pageblock_nr;
-+ if (!isolation_suitable(cc, page))
-+ goto next_pageblock;
-+
-+ /*
-+ * For async migration, also only scan in MOVABLE
-+ * blocks. Async migration is optimistic to see if
-+ * the minimum amount of work satisfies the allocation
-+ */
-+ mt = get_pageblock_migratetype(page);
-+ if (!cc->sync && !migrate_async_suitable(mt)) {
-+ cc->finished_update_migrate = true;
-+ skipped_async_unsuitable = true;
-+ goto next_pageblock;
-+ }
-+ }
-
- /*
- * Skip if free. page_order cannot be used without zone->lock
-@@ -537,18 +555,6 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- continue;
-
- /*
-- * For async migration, also only scan in MOVABLE blocks. Async
-- * migration is optimistic to see if the minimum amount of work
-- * satisfies the allocation
-- */
-- if (!cc->sync && last_pageblock_nr != pageblock_nr &&
-- !migrate_async_suitable(get_pageblock_migratetype(page))) {
-- cc->finished_update_migrate = true;
-- skipped_async_unsuitable = true;
-- goto next_pageblock;
-- }
--
-- /*
- * Check may be lockless but that's ok as we recheck later.
- * It's possible to migrate LRU pages and balloon pages
- * Skip any other type of page
-@@ -557,11 +563,7 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- if (unlikely(balloon_page_movable(page))) {
- if (locked && balloon_page_isolate(page)) {
- /* Successfully isolated */
-- cc->finished_update_migrate = true;
-- list_add(&page->lru, migratelist);
-- cc->nr_migratepages++;
-- nr_isolated++;
-- goto check_compact_cluster;
-+ goto isolate_success;
- }
- }
- continue;
-@@ -584,6 +586,15 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- continue;
- }
-
-+ /*
-+ * Migration will fail if an anonymous page is pinned in memory,
-+ * so avoid taking lru_lock and isolating it unnecessarily in an
-+ * admittedly racy check.
-+ */
-+ if (!page_mapping(page) &&
-+ page_count(page) > page_mapcount(page))
-+ continue;
-+
- /* Check if it is ok to still hold the lock */
- locked = compact_checklock_irqsave(&zone->lru_lock, &flags,
- locked, cc);
-@@ -598,12 +609,6 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- continue;
- }
-
-- if (!cc->sync)
-- mode |= ISOLATE_ASYNC_MIGRATE;
--
-- if (unevictable)
-- mode |= ISOLATE_UNEVICTABLE;
--
- lruvec = mem_cgroup_page_lruvec(page, zone);
-
- /* Try isolate the page */
-@@ -613,13 +618,14 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
- VM_BUG_ON_PAGE(PageTransCompound(page), page);
-
- /* Successfully isolated */
-- cc->finished_update_migrate = true;
- del_page_from_lru_list(page, lruvec, page_lru(page));
-+
-+isolate_success:
-+ cc->finished_update_migrate = true;
- list_add(&page->lru, migratelist);
- cc->nr_migratepages++;
- nr_isolated++;
-
--check_compact_cluster:
- /* Avoid isolating too much */
- if (cc->nr_migratepages == COMPACT_CLUSTER_MAX) {
- ++low_pfn;
-@@ -630,7 +636,6 @@ check_compact_cluster:
-
- next_pageblock:
- low_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages) - 1;
-- last_pageblock_nr = pageblock_nr;
- }
-
- acct_isolated(zone, locked, cc);
-@@ -1188,6 +1193,7 @@ static void compact_node(int nid)
- struct compact_control cc = {
- .order = -1,
- .sync = true,
-+ .ignore_skip_hint = true,
- };
-
- __compact_pgdat(NODE_DATA(nid), &cc);
-diff --git a/mm/filemap.c b/mm/filemap.c
-index 7a13f6ac5421..c2cc7c95eff1 100644
---- a/mm/filemap.c
-+++ b/mm/filemap.c
-@@ -192,9 +192,11 @@ static int filemap_check_errors(struct address_space *mapping)
- {
- int ret = 0;
- /* Check for outstanding write errors */
-- if (test_and_clear_bit(AS_ENOSPC, &mapping->flags))
-+ if (test_bit(AS_ENOSPC, &mapping->flags) &&
-+ test_and_clear_bit(AS_ENOSPC, &mapping->flags))
- ret = -ENOSPC;
-- if (test_and_clear_bit(AS_EIO, &mapping->flags))
-+ if (test_bit(AS_EIO, &mapping->flags) &&
-+ test_and_clear_bit(AS_EIO, &mapping->flags))
- ret = -EIO;
- return ret;
- }
-@@ -520,10 +522,10 @@ struct page *__page_cache_alloc(gfp_t gfp)
- if (cpuset_do_page_mem_spread()) {
- unsigned int cpuset_mems_cookie;
- do {
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
- n = cpuset_mem_spread_node();
- page = alloc_pages_exact_node(n, gfp, 0);
-- } while (!put_mems_allowed(cpuset_mems_cookie) && !page);
-+ } while (!page && read_mems_allowed_retry(cpuset_mems_cookie));
-
- return page;
- }
-diff --git a/mm/frontswap.c b/mm/frontswap.c
-index 1b24bdcb3197..c30eec536f03 100644
---- a/mm/frontswap.c
-+++ b/mm/frontswap.c
-@@ -327,15 +327,12 @@ EXPORT_SYMBOL(__frontswap_invalidate_area);
-
- static unsigned long __frontswap_curr_pages(void)
- {
-- int type;
- unsigned long totalpages = 0;
- struct swap_info_struct *si = NULL;
-
- assert_spin_locked(&swap_lock);
-- for (type = swap_list.head; type >= 0; type = si->next) {
-- si = swap_info[type];
-+ plist_for_each_entry(si, &swap_active_head, list)
- totalpages += atomic_read(&si->frontswap_pages);
-- }
- return totalpages;
- }
-
-@@ -347,11 +344,9 @@ static int __frontswap_unuse_pages(unsigned long total, unsigned long *unused,
- int si_frontswap_pages;
- unsigned long total_pages_to_unuse = total;
- unsigned long pages = 0, pages_to_unuse = 0;
-- int type;
-
- assert_spin_locked(&swap_lock);
-- for (type = swap_list.head; type >= 0; type = si->next) {
-- si = swap_info[type];
-+ plist_for_each_entry(si, &swap_active_head, list) {
- si_frontswap_pages = atomic_read(&si->frontswap_pages);
- if (total_pages_to_unuse < si_frontswap_pages) {
- pages = pages_to_unuse = total_pages_to_unuse;
-@@ -366,7 +361,7 @@ static int __frontswap_unuse_pages(unsigned long total, unsigned long *unused,
- }
- vm_unacct_memory(pages);
- *unused = pages_to_unuse;
-- *swapid = type;
-+ *swapid = si->type;
- ret = 0;
- break;
- }
-@@ -413,7 +408,7 @@ void frontswap_shrink(unsigned long target_pages)
- /*
- * we don't want to hold swap_lock while doing a very
- * lengthy try_to_unuse, but swap_list may change
-- * so restart scan from swap_list.head each time
-+ * so restart scan from swap_active_head each time
- */
- spin_lock(&swap_lock);
- ret = __frontswap_shrink(target_pages, &pages_to_unuse, &type);
-diff --git a/mm/huge_memory.c b/mm/huge_memory.c
-index 1c42d0c36d0b..718bfa16a36f 100644
---- a/mm/huge_memory.c
-+++ b/mm/huge_memory.c
-@@ -1819,21 +1819,24 @@ static int __split_huge_page_map(struct page *page,
- if (pmd) {
- pgtable = pgtable_trans_huge_withdraw(mm, pmd);
- pmd_populate(mm, &_pmd, pgtable);
-+ if (pmd_write(*pmd))
-+ BUG_ON(page_mapcount(page) != 1);
-
- haddr = address;
- for (i = 0; i < HPAGE_PMD_NR; i++, haddr += PAGE_SIZE) {
- pte_t *pte, entry;
- BUG_ON(PageCompound(page+i));
-+ /*
-+ * Note that pmd_numa is not transferred deliberately
-+ * to avoid any possibility that pte_numa leaks to
-+ * a PROT_NONE VMA by accident.
-+ */
- entry = mk_pte(page + i, vma->vm_page_prot);
- entry = maybe_mkwrite(pte_mkdirty(entry), vma);
- if (!pmd_write(*pmd))
- entry = pte_wrprotect(entry);
-- else
-- BUG_ON(page_mapcount(page) != 1);
- if (!pmd_young(*pmd))
- entry = pte_mkold(entry);
-- if (pmd_numa(*pmd))
-- entry = pte_mknuma(entry);
- pte = pte_offset_map(&_pmd, haddr);
- BUG_ON(!pte_none(*pte));
- set_pte_at(mm, haddr, pte, entry);
-diff --git a/mm/hugetlb.c b/mm/hugetlb.c
-index 923f38e62bcf..67d0c175efcf 100644
---- a/mm/hugetlb.c
-+++ b/mm/hugetlb.c
-@@ -540,7 +540,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
- goto err;
-
- retry_cpuset:
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
- zonelist = huge_zonelist(vma, address,
- htlb_alloc_mask(h), &mpol, &nodemask);
-
-@@ -562,7 +562,7 @@ retry_cpuset:
- }
-
- mpol_cond_put(mpol);
-- if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
-+ if (unlikely(!page && read_mems_allowed_retry(cpuset_mems_cookie)))
- goto retry_cpuset;
- return page;
-
-@@ -2071,6 +2071,9 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
- unsigned long tmp;
- int ret;
-
-+ if (!hugepages_supported())
-+ return -ENOTSUPP;
-+
- tmp = h->max_huge_pages;
-
- if (write && h->order >= MAX_ORDER)
-@@ -2124,6 +2127,9 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
- unsigned long tmp;
- int ret;
-
-+ if (!hugepages_supported())
-+ return -ENOTSUPP;
-+
- tmp = h->nr_overcommit_huge_pages;
-
- if (write && h->order >= MAX_ORDER)
-@@ -2149,6 +2155,8 @@ out:
- void hugetlb_report_meminfo(struct seq_file *m)
- {
- struct hstate *h = &default_hstate;
-+ if (!hugepages_supported())
-+ return;
- seq_printf(m,
- "HugePages_Total: %5lu\n"
- "HugePages_Free: %5lu\n"
-@@ -2165,6 +2173,8 @@ void hugetlb_report_meminfo(struct seq_file *m)
- int hugetlb_report_node_meminfo(int nid, char *buf)
- {
- struct hstate *h = &default_hstate;
-+ if (!hugepages_supported())
-+ return 0;
- return sprintf(buf,
- "Node %d HugePages_Total: %5u\n"
- "Node %d HugePages_Free: %5u\n"
-@@ -2179,6 +2189,9 @@ void hugetlb_show_meminfo(void)
- struct hstate *h;
- int nid;
-
-+ if (!hugepages_supported())
-+ return;
-+
- for_each_node_state(nid, N_MEMORY)
- for_each_hstate(h)
- pr_info("Node %d hugepages_total=%u hugepages_free=%u hugepages_surp=%u hugepages_size=%lukB\n",
-diff --git a/mm/mempolicy.c b/mm/mempolicy.c
-index 15a8ea031526..796c7e6cf93b 100644
---- a/mm/mempolicy.c
-+++ b/mm/mempolicy.c
-@@ -1897,7 +1897,7 @@ int node_random(const nodemask_t *maskp)
- * If the effective policy is 'BIND, returns a pointer to the mempolicy's
- * @nodemask for filtering the zonelist.
- *
-- * Must be protected by get_mems_allowed()
-+ * Must be protected by read_mems_allowed_begin()
- */
- struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr,
- gfp_t gfp_flags, struct mempolicy **mpol,
-@@ -2061,7 +2061,7 @@ alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma,
-
- retry_cpuset:
- pol = get_vma_policy(current, vma, addr);
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
-
- if (unlikely(pol->mode == MPOL_INTERLEAVE)) {
- unsigned nid;
-@@ -2069,7 +2069,7 @@ retry_cpuset:
- nid = interleave_nid(pol, vma, addr, PAGE_SHIFT + order);
- mpol_cond_put(pol);
- page = alloc_page_interleave(gfp, order, nid);
-- if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
-+ if (unlikely(!page && read_mems_allowed_retry(cpuset_mems_cookie)))
- goto retry_cpuset;
-
- return page;
-@@ -2079,7 +2079,7 @@ retry_cpuset:
- policy_nodemask(gfp, pol));
- if (unlikely(mpol_needs_cond_ref(pol)))
- __mpol_put(pol);
-- if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
-+ if (unlikely(!page && read_mems_allowed_retry(cpuset_mems_cookie)))
- goto retry_cpuset;
- return page;
- }
-@@ -2113,7 +2113,7 @@ struct page *alloc_pages_current(gfp_t gfp, unsigned order)
- pol = &default_policy;
-
- retry_cpuset:
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
-
- /*
- * No reference counting needed for current->mempolicy
-@@ -2126,7 +2126,7 @@ retry_cpuset:
- policy_zonelist(gfp, pol, numa_node_id()),
- policy_nodemask(gfp, pol));
-
-- if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
-+ if (unlikely(!page && read_mems_allowed_retry(cpuset_mems_cookie)))
- goto retry_cpuset;
-
- return page;
-diff --git a/mm/migrate.c b/mm/migrate.c
-index bed48809e5d0..13f47fbe3550 100644
---- a/mm/migrate.c
-+++ b/mm/migrate.c
-@@ -148,8 +148,11 @@ static int remove_migration_pte(struct page *new, struct vm_area_struct *vma,
- pte = pte_mkold(mk_pte(new, vma->vm_page_prot));
- if (pte_swp_soft_dirty(*ptep))
- pte = pte_mksoft_dirty(pte);
-+
-+ /* Recheck VMA as permissions can change since migration started */
- if (is_write_migration_entry(entry))
-- pte = pte_mkwrite(pte);
-+ pte = maybe_mkwrite(pte, vma);
-+
- #ifdef CONFIG_HUGETLB_PAGE
- if (PageHuge(new)) {
- pte = pte_mkhuge(pte);
-diff --git a/mm/mmap.c b/mm/mmap.c
-index 20ff0c33274c..dfe90657a6db 100644
---- a/mm/mmap.c
-+++ b/mm/mmap.c
-@@ -10,6 +10,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -681,8 +682,9 @@ __vma_unlink(struct mm_struct *mm, struct vm_area_struct *vma,
- prev->vm_next = next = vma->vm_next;
- if (next)
- next->vm_prev = prev;
-- if (mm->mmap_cache == vma)
-- mm->mmap_cache = prev;
-+
-+ /* Kill the cache */
-+ vmacache_invalidate(mm);
- }
-
- /*
-@@ -1989,34 +1991,33 @@ EXPORT_SYMBOL(get_unmapped_area);
- /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
- struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
- {
-- struct vm_area_struct *vma = NULL;
-+ struct rb_node *rb_node;
-+ struct vm_area_struct *vma;
-
- /* Check the cache first. */
-- /* (Cache hit rate is typically around 35%.) */
-- vma = ACCESS_ONCE(mm->mmap_cache);
-- if (!(vma && vma->vm_end > addr && vma->vm_start <= addr)) {
-- struct rb_node *rb_node;
-+ vma = vmacache_find(mm, addr);
-+ if (likely(vma))
-+ return vma;
-
-- rb_node = mm->mm_rb.rb_node;
-- vma = NULL;
-+ rb_node = mm->mm_rb.rb_node;
-+ vma = NULL;
-
-- while (rb_node) {
-- struct vm_area_struct *vma_tmp;
--
-- vma_tmp = rb_entry(rb_node,
-- struct vm_area_struct, vm_rb);
--
-- if (vma_tmp->vm_end > addr) {
-- vma = vma_tmp;
-- if (vma_tmp->vm_start <= addr)
-- break;
-- rb_node = rb_node->rb_left;
-- } else
-- rb_node = rb_node->rb_right;
-- }
-- if (vma)
-- mm->mmap_cache = vma;
-+ while (rb_node) {
-+ struct vm_area_struct *tmp;
-+
-+ tmp = rb_entry(rb_node, struct vm_area_struct, vm_rb);
-+
-+ if (tmp->vm_end > addr) {
-+ vma = tmp;
-+ if (tmp->vm_start <= addr)
-+ break;
-+ rb_node = rb_node->rb_left;
-+ } else
-+ rb_node = rb_node->rb_right;
- }
-+
-+ if (vma)
-+ vmacache_update(addr, vma);
- return vma;
- }
-
-@@ -2388,7 +2389,9 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
- } else
- mm->highest_vm_end = prev ? prev->vm_end : 0;
- tail_vma->vm_next = NULL;
-- mm->mmap_cache = NULL; /* Kill the cache. */
-+
-+ /* Kill the cache */
-+ vmacache_invalidate(mm);
- }
-
- /*
-diff --git a/mm/nommu.c b/mm/nommu.c
-index 8740213b1647..3ee4f74fbfbe 100644
---- a/mm/nommu.c
-+++ b/mm/nommu.c
-@@ -15,6 +15,7 @@
-
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -768,16 +769,23 @@ static void add_vma_to_mm(struct mm_struct *mm, struct vm_area_struct *vma)
- */
- static void delete_vma_from_mm(struct vm_area_struct *vma)
- {
-+ int i;
- struct address_space *mapping;
- struct mm_struct *mm = vma->vm_mm;
-+ struct task_struct *curr = current;
-
- kenter("%p", vma);
-
- protect_vma(vma, 0);
-
- mm->map_count--;
-- if (mm->mmap_cache == vma)
-- mm->mmap_cache = NULL;
-+ for (i = 0; i < VMACACHE_SIZE; i++) {
-+ /* if the vma is cached, invalidate the entire cache */
-+ if (curr->vmacache[i] == vma) {
-+ vmacache_invalidate(curr->mm);
-+ break;
-+ }
-+ }
-
- /* remove the VMA from the mapping */
- if (vma->vm_file) {
-@@ -825,8 +833,8 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
- struct vm_area_struct *vma;
-
- /* check the cache first */
-- vma = ACCESS_ONCE(mm->mmap_cache);
-- if (vma && vma->vm_start <= addr && vma->vm_end > addr)
-+ vma = vmacache_find(mm, addr);
-+ if (likely(vma))
- return vma;
-
- /* trawl the list (there may be multiple mappings in which addr
-@@ -835,7 +843,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
- if (vma->vm_start > addr)
- return NULL;
- if (vma->vm_end > addr) {
-- mm->mmap_cache = vma;
-+ vmacache_update(addr, vma);
- return vma;
- }
- }
-@@ -874,8 +882,8 @@ static struct vm_area_struct *find_vma_exact(struct mm_struct *mm,
- unsigned long end = addr + len;
-
- /* check the cache first */
-- vma = mm->mmap_cache;
-- if (vma && vma->vm_start == addr && vma->vm_end == end)
-+ vma = vmacache_find_exact(mm, addr, end);
-+ if (vma)
- return vma;
-
- /* trawl the list (there may be multiple mappings in which addr
-@@ -886,7 +894,7 @@ static struct vm_area_struct *find_vma_exact(struct mm_struct *mm,
- if (vma->vm_start > addr)
- return NULL;
- if (vma->vm_end == end) {
-- mm->mmap_cache = vma;
-+ vmacache_update(addr, vma);
- return vma;
- }
- }
-diff --git a/mm/page_alloc.c b/mm/page_alloc.c
-index 62e400d00e3f..ff0f6b13f32f 100644
---- a/mm/page_alloc.c
-+++ b/mm/page_alloc.c
-@@ -1869,7 +1869,7 @@ static void __paginginit init_zone_allows_reclaim(int nid)
- {
- int i;
-
-- for_each_online_node(i)
-+ for_each_node_state(i, N_MEMORY)
- if (node_distance(nid, i) <= RECLAIM_DISTANCE)
- node_set(i, NODE_DATA(nid)->reclaim_nodes);
- else
-@@ -2736,7 +2736,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
- return NULL;
-
- retry_cpuset:
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
-
- /* The preferred zone is used for statistics later */
- first_zones_zonelist(zonelist, high_zoneidx,
-@@ -2791,7 +2791,7 @@ out:
- * the mask is being updated. If a page allocation is about to fail,
- * check if the cpuset changed during allocation and if so, retry.
- */
-- if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
-+ if (unlikely(!page && read_mems_allowed_retry(cpuset_mems_cookie)))
- goto retry_cpuset;
-
- memcg_kmem_commit_charge(page, memcg, order);
-@@ -3059,9 +3059,9 @@ bool skip_free_areas_node(unsigned int flags, int nid)
- goto out;
-
- do {
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
- ret = !node_isset(nid, cpuset_current_mems_allowed);
-- } while (!put_mems_allowed(cpuset_mems_cookie));
-+ } while (read_mems_allowed_retry(cpuset_mems_cookie));
- out:
- return ret;
- }
-@@ -4933,7 +4933,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
-
- pgdat->node_id = nid;
- pgdat->node_start_pfn = node_start_pfn;
-- init_zone_allows_reclaim(nid);
-+ if (node_state(nid, N_MEMORY))
-+ init_zone_allows_reclaim(nid);
- #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
- get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
- #endif
-diff --git a/mm/readahead.c b/mm/readahead.c
-index 0de2360d65f3..1fa0d6fca556 100644
---- a/mm/readahead.c
-+++ b/mm/readahead.c
-@@ -233,14 +233,14 @@ int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
- return 0;
- }
-
-+#define MAX_READAHEAD ((512*4096)/PAGE_CACHE_SIZE)
- /*
- * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a
- * sensible upper limit.
- */
- unsigned long max_sane_readahead(unsigned long nr)
- {
-- return min(nr, (node_page_state(numa_node_id(), NR_INACTIVE_FILE)
-- + node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
-+ return min(nr, MAX_READAHEAD);
- }
-
- /*
-diff --git a/mm/slab.c b/mm/slab.c
-index ea854eb2388c..0b1c2a58559d 100644
---- a/mm/slab.c
-+++ b/mm/slab.c
-@@ -3122,7 +3122,7 @@ static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
- local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
-
- retry_cpuset:
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
- zonelist = node_zonelist(slab_node(), flags);
-
- retry:
-@@ -3180,7 +3180,7 @@ retry:
- }
- }
-
-- if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !obj))
-+ if (unlikely(!obj && read_mems_allowed_retry(cpuset_mems_cookie)))
- goto retry_cpuset;
- return obj;
- }
-diff --git a/mm/slub.c b/mm/slub.c
-index 25f14ad8f817..7611f148ee81 100644
---- a/mm/slub.c
-+++ b/mm/slub.c
-@@ -1684,7 +1684,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
- return NULL;
-
- do {
-- cpuset_mems_cookie = get_mems_allowed();
-+ cpuset_mems_cookie = read_mems_allowed_begin();
- zonelist = node_zonelist(slab_node(), flags);
- for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {
- struct kmem_cache_node *n;
-@@ -1696,19 +1696,17 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
- object = get_partial_node(s, n, c, flags);
- if (object) {
- /*
-- * Return the object even if
-- * put_mems_allowed indicated that
-- * the cpuset mems_allowed was
-- * updated in parallel. It's a
-- * harmless race between the alloc
-- * and the cpuset update.
-+ * Don't check read_mems_allowed_retry()
-+ * here - if mems_allowed was updated in
-+ * parallel, that was a harmless race
-+ * between allocation and the cpuset
-+ * update
- */
-- put_mems_allowed(cpuset_mems_cookie);
- return object;
- }
- }
- }
-- } while (!put_mems_allowed(cpuset_mems_cookie));
-+ } while (read_mems_allowed_retry(cpuset_mems_cookie));
- #endif
- return NULL;
- }
-diff --git a/mm/swapfile.c b/mm/swapfile.c
-index 4a7f7e6992b6..beeeef8a1b2d 100644
---- a/mm/swapfile.c
-+++ b/mm/swapfile.c
-@@ -51,14 +51,32 @@ atomic_long_t nr_swap_pages;
- /* protected with swap_lock. reading in vm_swap_full() doesn't need lock */
- long total_swap_pages;
- static int least_priority;
--static atomic_t highest_priority_index = ATOMIC_INIT(-1);
-
- static const char Bad_file[] = "Bad swap file entry ";
- static const char Unused_file[] = "Unused swap file entry ";
- static const char Bad_offset[] = "Bad swap offset entry ";
- static const char Unused_offset[] = "Unused swap offset entry ";
-
--struct swap_list_t swap_list = {-1, -1};
-+/*
-+ * all active swap_info_structs
-+ * protected with swap_lock, and ordered by priority.
-+ */
-+PLIST_HEAD(swap_active_head);
-+
-+/*
-+ * all available (active, not full) swap_info_structs
-+ * protected with swap_avail_lock, ordered by priority.
-+ * This is used by get_swap_page() instead of swap_active_head
-+ * because swap_active_head includes all swap_info_structs,
-+ * but get_swap_page() doesn't need to look at full ones.
-+ * This uses its own lock instead of swap_lock because when a
-+ * swap_info_struct changes between not-full/full, it needs to
-+ * add/remove itself to/from this list, but the swap_info_struct->lock
-+ * is held and the locking order requires swap_lock to be taken
-+ * before any swap_info_struct->lock.
-+ */
-+static PLIST_HEAD(swap_avail_head);
-+static DEFINE_SPINLOCK(swap_avail_lock);
-
- struct swap_info_struct *swap_info[MAX_SWAPFILES];
-
-@@ -591,6 +609,9 @@ checks:
- if (si->inuse_pages == si->pages) {
- si->lowest_bit = si->max;
- si->highest_bit = 0;
-+ spin_lock(&swap_avail_lock);
-+ plist_del(&si->avail_list, &swap_avail_head);
-+ spin_unlock(&swap_avail_lock);
- }
- si->swap_map[offset] = usage;
- inc_cluster_info_page(si, si->cluster_info, offset);
-@@ -640,71 +661,65 @@ no_page:
-
- swp_entry_t get_swap_page(void)
- {
-- struct swap_info_struct *si;
-+ struct swap_info_struct *si, *next;
- pgoff_t offset;
-- int type, next;
-- int wrapped = 0;
-- int hp_index;
-
-- spin_lock(&swap_lock);
- if (atomic_long_read(&nr_swap_pages) <= 0)
- goto noswap;
- atomic_long_dec(&nr_swap_pages);
-
-- for (type = swap_list.next; type >= 0 && wrapped < 2; type = next) {
-- hp_index = atomic_xchg(&highest_priority_index, -1);
-- /*
-- * highest_priority_index records current highest priority swap
-- * type which just frees swap entries. If its priority is
-- * higher than that of swap_list.next swap type, we use it. It
-- * isn't protected by swap_lock, so it can be an invalid value
-- * if the corresponding swap type is swapoff. We double check
-- * the flags here. It's even possible the swap type is swapoff
-- * and swapon again and its priority is changed. In such rare
-- * case, low prority swap type might be used, but eventually
-- * high priority swap will be used after several rounds of
-- * swap.
-- */
-- if (hp_index != -1 && hp_index != type &&
-- swap_info[type]->prio < swap_info[hp_index]->prio &&
-- (swap_info[hp_index]->flags & SWP_WRITEOK)) {
-- type = hp_index;
-- swap_list.next = type;
-- }
--
-- si = swap_info[type];
-- next = si->next;
-- if (next < 0 ||
-- (!wrapped && si->prio != swap_info[next]->prio)) {
-- next = swap_list.head;
-- wrapped++;
-- }
-+ spin_lock(&swap_avail_lock);
-
-+start_over:
-+ plist_for_each_entry_safe(si, next, &swap_avail_head, avail_list) {
-+ /* requeue si to after same-priority siblings */
-+ plist_requeue(&si->avail_list, &swap_avail_head);
-+ spin_unlock(&swap_avail_lock);
- spin_lock(&si->lock);
-- if (!si->highest_bit) {
-+ if (!si->highest_bit || !(si->flags & SWP_WRITEOK)) {
-+ spin_lock(&swap_avail_lock);
-+ if (plist_node_empty(&si->avail_list)) {
-+ spin_unlock(&si->lock);
-+ goto nextsi;
-+ }
-+ WARN(!si->highest_bit,
-+ "swap_info %d in list but !highest_bit\n",
-+ si->type);
-+ WARN(!(si->flags & SWP_WRITEOK),
-+ "swap_info %d in list but !SWP_WRITEOK\n",
-+ si->type);
-+ plist_del(&si->avail_list, &swap_avail_head);
- spin_unlock(&si->lock);
-- continue;
-+ goto nextsi;
- }
-- if (!(si->flags & SWP_WRITEOK)) {
-- spin_unlock(&si->lock);
-- continue;
-- }
--
-- swap_list.next = next;
-
-- spin_unlock(&swap_lock);
- /* This is called for allocating swap entry for cache */
- offset = scan_swap_map(si, SWAP_HAS_CACHE);
- spin_unlock(&si->lock);
- if (offset)
-- return swp_entry(type, offset);
-- spin_lock(&swap_lock);
-- next = swap_list.next;
-+ return swp_entry(si->type, offset);
-+ pr_debug("scan_swap_map of si %d failed to find offset\n",
-+ si->type);
-+ spin_lock(&swap_avail_lock);
-+nextsi:
-+ /*
-+ * if we got here, it's likely that si was almost full before,
-+ * and since scan_swap_map() can drop the si->lock, multiple
-+ * callers probably all tried to get a page from the same si
-+ * and it filled up before we could get one; or, the si filled
-+ * up between us dropping swap_avail_lock and taking si->lock.
-+ * Since we dropped the swap_avail_lock, the swap_avail_head
-+ * list may have been modified; so if next is still in the
-+ * swap_avail_head list then try it, otherwise start over.
-+ */
-+ if (plist_node_empty(&next->avail_list))
-+ goto start_over;
- }
-
-+ spin_unlock(&swap_avail_lock);
-+
- atomic_long_inc(&nr_swap_pages);
- noswap:
-- spin_unlock(&swap_lock);
- return (swp_entry_t) {0};
- }
-
-@@ -766,27 +781,6 @@ out:
- return NULL;
- }
-
--/*
-- * This swap type frees swap entry, check if it is the highest priority swap
-- * type which just frees swap entry. get_swap_page() uses
-- * highest_priority_index to search highest priority swap type. The
-- * swap_info_struct.lock can't protect us if there are multiple swap types
-- * active, so we use atomic_cmpxchg.
-- */
--static void set_highest_priority_index(int type)
--{
-- int old_hp_index, new_hp_index;
--
-- do {
-- old_hp_index = atomic_read(&highest_priority_index);
-- if (old_hp_index != -1 &&
-- swap_info[old_hp_index]->prio >= swap_info[type]->prio)
-- break;
-- new_hp_index = type;
-- } while (atomic_cmpxchg(&highest_priority_index,
-- old_hp_index, new_hp_index) != old_hp_index);
--}
--
- static unsigned char swap_entry_free(struct swap_info_struct *p,
- swp_entry_t entry, unsigned char usage)
- {
-@@ -828,9 +822,18 @@ static unsigned char swap_entry_free(struct swap_info_struct *p,
- dec_cluster_info_page(p, p->cluster_info, offset);
- if (offset < p->lowest_bit)
- p->lowest_bit = offset;
-- if (offset > p->highest_bit)
-+ if (offset > p->highest_bit) {
-+ bool was_full = !p->highest_bit;
- p->highest_bit = offset;
-- set_highest_priority_index(p->type);
-+ if (was_full && (p->flags & SWP_WRITEOK)) {
-+ spin_lock(&swap_avail_lock);
-+ WARN_ON(!plist_node_empty(&p->avail_list));
-+ if (plist_node_empty(&p->avail_list))
-+ plist_add(&p->avail_list,
-+ &swap_avail_head);
-+ spin_unlock(&swap_avail_lock);
-+ }
-+ }
- atomic_long_inc(&nr_swap_pages);
- p->inuse_pages--;
- frontswap_invalidate_page(p->type, offset);
-@@ -1765,30 +1768,37 @@ static void _enable_swap_info(struct swap_info_struct *p, int prio,
- unsigned char *swap_map,
- struct swap_cluster_info *cluster_info)
- {
-- int i, prev;
--
- if (prio >= 0)
- p->prio = prio;
- else
- p->prio = --least_priority;
-+ /*
-+ * the plist prio is negated because plist ordering is
-+ * low-to-high, while swap ordering is high-to-low
-+ */
-+ p->list.prio = -p->prio;
-+ p->avail_list.prio = -p->prio;
- p->swap_map = swap_map;
- p->cluster_info = cluster_info;
- p->flags |= SWP_WRITEOK;
- atomic_long_add(p->pages, &nr_swap_pages);
- total_swap_pages += p->pages;
-
-- /* insert swap space into swap_list: */
-- prev = -1;
-- for (i = swap_list.head; i >= 0; i = swap_info[i]->next) {
-- if (p->prio >= swap_info[i]->prio)
-- break;
-- prev = i;
-- }
-- p->next = i;
-- if (prev < 0)
-- swap_list.head = swap_list.next = p->type;
-- else
-- swap_info[prev]->next = p->type;
-+ assert_spin_locked(&swap_lock);
-+ /*
-+ * both lists are plists, and thus priority ordered.
-+ * swap_active_head needs to be priority ordered for swapoff(),
-+ * which on removal of any swap_info_struct with an auto-assigned
-+ * (i.e. negative) priority increments the auto-assigned priority
-+ * of any lower-priority swap_info_structs.
-+ * swap_avail_head needs to be priority ordered for get_swap_page(),
-+ * which allocates swap pages from the highest available priority
-+ * swap_info_struct.
-+ */
-+ plist_add(&p->list, &swap_active_head);
-+ spin_lock(&swap_avail_lock);
-+ plist_add(&p->avail_list, &swap_avail_head);
-+ spin_unlock(&swap_avail_lock);
- }
-
- static void enable_swap_info(struct swap_info_struct *p, int prio,
-@@ -1823,8 +1833,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
- struct address_space *mapping;
- struct inode *inode;
- struct filename *pathname;
-- int i, type, prev;
-- int err;
-+ int err, found = 0;
- unsigned int old_block_size;
-
- if (!capable(CAP_SYS_ADMIN))
-@@ -1842,17 +1851,16 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
- goto out;
-
- mapping = victim->f_mapping;
-- prev = -1;
- spin_lock(&swap_lock);
-- for (type = swap_list.head; type >= 0; type = swap_info[type]->next) {
-- p = swap_info[type];
-+ plist_for_each_entry(p, &swap_active_head, list) {
- if (p->flags & SWP_WRITEOK) {
-- if (p->swap_file->f_mapping == mapping)
-+ if (p->swap_file->f_mapping == mapping) {
-+ found = 1;
- break;
-+ }
- }
-- prev = type;
- }
-- if (type < 0) {
-+ if (!found) {
- err = -EINVAL;
- spin_unlock(&swap_lock);
- goto out_dput;
-@@ -1864,20 +1872,21 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
- spin_unlock(&swap_lock);
- goto out_dput;
- }
-- if (prev < 0)
-- swap_list.head = p->next;
-- else
-- swap_info[prev]->next = p->next;
-- if (type == swap_list.next) {
-- /* just pick something that's safe... */
-- swap_list.next = swap_list.head;
-- }
-+ spin_lock(&swap_avail_lock);
-+ plist_del(&p->avail_list, &swap_avail_head);
-+ spin_unlock(&swap_avail_lock);
- spin_lock(&p->lock);
- if (p->prio < 0) {
-- for (i = p->next; i >= 0; i = swap_info[i]->next)
-- swap_info[i]->prio = p->prio--;
-+ struct swap_info_struct *si = p;
-+
-+ plist_for_each_entry_continue(si, &swap_active_head, list) {
-+ si->prio++;
-+ si->list.prio--;
-+ si->avail_list.prio--;
-+ }
- least_priority++;
- }
-+ plist_del(&p->list, &swap_active_head);
- atomic_long_sub(p->pages, &nr_swap_pages);
- total_swap_pages -= p->pages;
- p->flags &= ~SWP_WRITEOK;
-@@ -1885,7 +1894,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
- spin_unlock(&swap_lock);
-
- set_current_oom_origin();
-- err = try_to_unuse(type, false, 0); /* force all pages to be unused */
-+ err = try_to_unuse(p->type, false, 0); /* force unuse all pages */
- clear_current_oom_origin();
-
- if (err) {
-@@ -1926,7 +1935,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
- frontswap_map = frontswap_map_get(p);
- spin_unlock(&p->lock);
- spin_unlock(&swap_lock);
-- frontswap_invalidate_area(type);
-+ frontswap_invalidate_area(p->type);
- frontswap_map_set(p, NULL);
- mutex_unlock(&swapon_mutex);
- free_percpu(p->percpu_cluster);
-@@ -1935,7 +1944,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
- vfree(cluster_info);
- vfree(frontswap_map);
- /* Destroy swap account information */
-- swap_cgroup_swapoff(type);
-+ swap_cgroup_swapoff(p->type);
-
- inode = mapping->host;
- if (S_ISBLK(inode->i_mode)) {
-@@ -2142,8 +2151,9 @@ static struct swap_info_struct *alloc_swap_info(void)
- */
- }
- INIT_LIST_HEAD(&p->first_swap_extent.list);
-+ plist_node_init(&p->list, 0);
-+ plist_node_init(&p->avail_list, 0);
- p->flags = SWP_USED;
-- p->next = -1;
- spin_unlock(&swap_lock);
- spin_lock_init(&p->lock);
-
-diff --git a/mm/vmacache.c b/mm/vmacache.c
-new file mode 100644
-index 000000000000..1037a3bab505
---- /dev/null
-+++ b/mm/vmacache.c
-@@ -0,0 +1,114 @@
-+/*
-+ * Copyright (C) 2014 Davidlohr Bueso.
-+ */
-+#include
-+#include
-+#include
-+
-+/*
-+ * Flush vma caches for threads that share a given mm.
-+ *
-+ * The operation is safe because the caller holds the mmap_sem
-+ * exclusively and other threads accessing the vma cache will
-+ * have mmap_sem held at least for read, so no extra locking
-+ * is required to maintain the vma cache.
-+ */
-+void vmacache_flush_all(struct mm_struct *mm)
-+{
-+ struct task_struct *g, *p;
-+
-+ rcu_read_lock();
-+ for_each_process_thread(g, p) {
-+ /*
-+ * Only flush the vmacache pointers as the
-+ * mm seqnum is already set and curr's will
-+ * be set upon invalidation when the next
-+ * lookup is done.
-+ */
-+ if (mm == p->mm)
-+ vmacache_flush(p);
-+ }
-+ rcu_read_unlock();
-+}
-+
-+/*
-+ * This task may be accessing a foreign mm via (for example)
-+ * get_user_pages()->find_vma(). The vmacache is task-local and this
-+ * task's vmacache pertains to a different mm (ie, its own). There is
-+ * nothing we can do here.
-+ *
-+ * Also handle the case where a kernel thread has adopted this mm via use_mm().
-+ * That kernel thread's vmacache is not applicable to this mm.
-+ */
-+static bool vmacache_valid_mm(struct mm_struct *mm)
-+{
-+ return current->mm == mm && !(current->flags & PF_KTHREAD);
-+}
-+
-+void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
-+{
-+ if (vmacache_valid_mm(newvma->vm_mm))
-+ current->vmacache[VMACACHE_HASH(addr)] = newvma;
-+}
-+
-+static bool vmacache_valid(struct mm_struct *mm)
-+{
-+ struct task_struct *curr;
-+
-+ if (!vmacache_valid_mm(mm))
-+ return false;
-+
-+ curr = current;
-+ if (mm->vmacache_seqnum != curr->vmacache_seqnum) {
-+ /*
-+ * First attempt will always be invalid, initialize
-+ * the new cache for this task here.
-+ */
-+ curr->vmacache_seqnum = mm->vmacache_seqnum;
-+ vmacache_flush(curr);
-+ return false;
-+ }
-+ return true;
-+}
-+
-+struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
-+{
-+ int i;
-+
-+ if (!vmacache_valid(mm))
-+ return NULL;
-+
-+ for (i = 0; i < VMACACHE_SIZE; i++) {
-+ struct vm_area_struct *vma = current->vmacache[i];
-+
-+ if (!vma)
-+ continue;
-+ if (WARN_ON_ONCE(vma->vm_mm != mm))
-+ break;
-+ if (vma->vm_start <= addr && vma->vm_end > addr)
-+ return vma;
-+ }
-+
-+ return NULL;
-+}
-+
-+#ifndef CONFIG_MMU
-+struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
-+ unsigned long start,
-+ unsigned long end)
-+{
-+ int i;
-+
-+ if (!vmacache_valid(mm))
-+ return NULL;
-+
-+ for (i = 0; i < VMACACHE_SIZE; i++) {
-+ struct vm_area_struct *vma = current->vmacache[i];
-+
-+ if (vma && vma->vm_start == start && vma->vm_end == end)
-+ return vma;
-+ }
-+
-+ return NULL;
-+}
-+#endif
-diff --git a/mm/vmscan.c b/mm/vmscan.c
-index 6ef484f0777f..0c0b36e5b4f8 100644
---- a/mm/vmscan.c
-+++ b/mm/vmscan.c
-@@ -224,15 +224,15 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
- unsigned long freed = 0;
- unsigned long long delta;
- long total_scan;
-- long max_pass;
-+ long freeable;
- long nr;
- long new_nr;
- int nid = shrinkctl->nid;
- long batch_size = shrinker->batch ? shrinker->batch
- : SHRINK_BATCH;
-
-- max_pass = shrinker->count_objects(shrinker, shrinkctl);
-- if (max_pass == 0)
-+ freeable = shrinker->count_objects(shrinker, shrinkctl);
-+ if (freeable == 0)
- return 0;
-
- /*
-@@ -244,14 +244,14 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
-
- total_scan = nr;
- delta = (4 * nr_pages_scanned) / shrinker->seeks;
-- delta *= max_pass;
-+ delta *= freeable;
- do_div(delta, lru_pages + 1);
- total_scan += delta;
- if (total_scan < 0) {
- printk(KERN_ERR
- "shrink_slab: %pF negative objects to delete nr=%ld\n",
- shrinker->scan_objects, total_scan);
-- total_scan = max_pass;
-+ total_scan = freeable;
- }
-
- /*
-@@ -260,26 +260,26 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
- * shrinkers to return -1 all the time. This results in a large
- * nr being built up so when a shrink that can do some work
- * comes along it empties the entire cache due to nr >>>
-- * max_pass. This is bad for sustaining a working set in
-+ * freeable. This is bad for sustaining a working set in
- * memory.
- *
- * Hence only allow the shrinker to scan the entire cache when
- * a large delta change is calculated directly.
- */
-- if (delta < max_pass / 4)
-- total_scan = min(total_scan, max_pass / 2);
-+ if (delta < freeable / 4)
-+ total_scan = min(total_scan, freeable / 2);
-
- /*
- * Avoid risking looping forever due to too large nr value:
- * never try to free more than twice the estimate number of
- * freeable entries.
- */
-- if (total_scan > max_pass * 2)
-- total_scan = max_pass * 2;
-+ if (total_scan > freeable * 2)
-+ total_scan = freeable * 2;
-
- trace_mm_shrink_slab_start(shrinker, shrinkctl, nr,
- nr_pages_scanned, lru_pages,
-- max_pass, delta, total_scan);
-+ freeable, delta, total_scan);
-
- /*
- * Normally, we should not scan less than batch_size objects in one
-@@ -292,12 +292,12 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker,
- *
- * We detect the "tight on memory" situations by looking at the total
- * number of objects we want to scan (total_scan). If it is greater
-- * than the total number of objects on slab (max_pass), we must be
-+ * than the total number of objects on slab (freeable), we must be
- * scanning at high prio and therefore should try to reclaim as much as
- * possible.
- */
- while (total_scan >= batch_size ||
-- total_scan >= max_pass) {
-+ total_scan >= freeable) {
- unsigned long ret;
- unsigned long nr_to_scan = min(batch_size, total_scan);
-
-@@ -1144,7 +1144,7 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,
- TTU_UNMAP|TTU_IGNORE_ACCESS,
- &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, true);
- list_splice(&clean_pages, page_list);
-- __mod_zone_page_state(zone, NR_ISOLATED_FILE, -ret);
-+ mod_zone_page_state(zone, NR_ISOLATED_FILE, -ret);
- return ret;
- }
-
-@@ -2424,8 +2424,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
- unsigned long lru_pages = 0;
-
- nodes_clear(shrink->nodes_to_scan);
-- for_each_zone_zonelist(zone, z, zonelist,
-- gfp_zone(sc->gfp_mask)) {
-+ for_each_zone_zonelist_nodemask(zone, z, zonelist,
-+ gfp_zone(sc->gfp_mask), sc->nodemask) {
- if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
- continue;
-
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.21-22.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.21-22.patch
deleted file mode 100644
index 23599bd341..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.21-22.patch
+++ /dev/null
@@ -1,1795 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 41e6e19fe2e9..a59980eb4557 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 21
-+SUBLEVEL = 22
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
-index 0378328f47a7..a4127453baae 100644
---- a/drivers/crypto/caam/caamhash.c
-+++ b/drivers/crypto/caam/caamhash.c
-@@ -1348,9 +1348,9 @@ static int ahash_update_first(struct ahash_request *req)
- struct device *jrdev = ctx->jrdev;
- gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
- CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
-- u8 *next_buf = state->buf_0 + state->current_buf *
-- CAAM_MAX_HASH_BLOCK_SIZE;
-- int *next_buflen = &state->buflen_0 + state->current_buf;
-+ u8 *next_buf = state->current_buf ? state->buf_1 : state->buf_0;
-+ int *next_buflen = state->current_buf ?
-+ &state->buflen_1 : &state->buflen_0;
- int to_hash;
- u32 *sh_desc = ctx->sh_desc_update_first, *desc;
- dma_addr_t ptr = ctx->sh_desc_update_first_dma;
-diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
-index a95b322f0924..cc38948cf65d 100644
---- a/drivers/net/bonding/bond_main.c
-+++ b/drivers/net/bonding/bond_main.c
-@@ -3624,8 +3624,14 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
- else
- bond_xmit_slave_id(bond, skb, 0);
- } else {
-- slave_id = bond_rr_gen_slave_id(bond);
-- bond_xmit_slave_id(bond, skb, slave_id % bond->slave_cnt);
-+ int slave_cnt = ACCESS_ONCE(bond->slave_cnt);
-+
-+ if (likely(slave_cnt)) {
-+ slave_id = bond_rr_gen_slave_id(bond);
-+ bond_xmit_slave_id(bond, skb, slave_id % slave_cnt);
-+ } else {
-+ dev_kfree_skb_any(skb);
-+ }
- }
-
- return NETDEV_TX_OK;
-@@ -3656,8 +3662,13 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
- static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
- {
- struct bonding *bond = netdev_priv(bond_dev);
-+ int slave_cnt = ACCESS_ONCE(bond->slave_cnt);
-
-- bond_xmit_slave_id(bond, skb, bond_xmit_hash(bond, skb, bond->slave_cnt));
-+ if (likely(slave_cnt))
-+ bond_xmit_slave_id(bond, skb,
-+ bond_xmit_hash(bond, skb, bond->slave_cnt));
-+ else
-+ dev_kfree_skb_any(skb);
-
- return NETDEV_TX_OK;
- }
-diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
-index a210766279d3..9373f1f59605 100644
---- a/drivers/net/ethernet/broadcom/tg3.c
-+++ b/drivers/net/ethernet/broadcom/tg3.c
-@@ -6923,7 +6923,8 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
- skb->protocol = eth_type_trans(skb, tp->dev);
-
- if (len > (tp->dev->mtu + ETH_HLEN) &&
-- skb->protocol != htons(ETH_P_8021Q)) {
-+ skb->protocol != htons(ETH_P_8021Q) &&
-+ skb->protocol != htons(ETH_P_8021AD)) {
- dev_kfree_skb(skb);
- goto drop_it_no_recycle;
- }
-@@ -7915,8 +7916,6 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
-
- entry = tnapi->tx_prod;
- base_flags = 0;
-- if (skb->ip_summed == CHECKSUM_PARTIAL)
-- base_flags |= TXD_FLAG_TCPUDP_CSUM;
-
- mss = skb_shinfo(skb)->gso_size;
- if (mss) {
-@@ -7932,6 +7931,13 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
-
- hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb) - ETH_HLEN;
-
-+ /* HW/FW can not correctly segment packets that have been
-+ * vlan encapsulated.
-+ */
-+ if (skb->protocol == htons(ETH_P_8021Q) ||
-+ skb->protocol == htons(ETH_P_8021AD))
-+ return tg3_tso_bug(tp, skb);
-+
- if (!skb_is_gso_v6(skb)) {
- iph->check = 0;
- iph->tot_len = htons(mss + hdr_len);
-@@ -7978,6 +7984,17 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
- base_flags |= tsflags << 12;
- }
- }
-+ } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
-+ /* HW/FW can not correctly checksum packets that have been
-+ * vlan encapsulated.
-+ */
-+ if (skb->protocol == htons(ETH_P_8021Q) ||
-+ skb->protocol == htons(ETH_P_8021AD)) {
-+ if (skb_checksum_help(skb))
-+ goto drop;
-+ } else {
-+ base_flags |= TXD_FLAG_TCPUDP_CSUM;
-+ }
- }
-
- if (tg3_flag(tp, USE_JUMBO_BDFLAG) &&
-diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
-index d0c38e01e99f..0085476a0258 100644
---- a/drivers/net/ethernet/cadence/macb.c
-+++ b/drivers/net/ethernet/cadence/macb.c
-@@ -30,7 +30,6 @@
- #include
- #include
- #include
--#include
-
- #include "macb.h"
-
-@@ -1810,7 +1809,6 @@ static int __init macb_probe(struct platform_device *pdev)
- struct phy_device *phydev;
- u32 config;
- int err = -ENXIO;
-- struct pinctrl *pinctrl;
- const char *mac;
-
- regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-@@ -1819,15 +1817,6 @@ static int __init macb_probe(struct platform_device *pdev)
- goto err_out;
- }
-
-- pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
-- if (IS_ERR(pinctrl)) {
-- err = PTR_ERR(pinctrl);
-- if (err == -EPROBE_DEFER)
-- goto err_out;
--
-- dev_warn(&pdev->dev, "No pinctrl provided\n");
-- }
--
- err = -ENOMEM;
- dev = alloc_etherdev(sizeof(*bp));
- if (!dev)
-diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
-index b901371ca361..5d3206d5cb07 100644
---- a/drivers/net/ethernet/intel/i40e/i40e_main.c
-+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
-@@ -4024,6 +4024,9 @@ static int i40e_init_pf_dcb(struct i40e_pf *pf)
- DCB_CAP_DCBX_VER_IEEE;
- pf->flags |= I40E_FLAG_DCB_ENABLED;
- }
-+ } else {
-+ dev_info(&pf->pdev->dev, "AQ Querying DCB configuration failed: %d\n",
-+ pf->hw.aq.asq_last_status);
- }
-
- out:
-@@ -8003,7 +8006,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
- if (err) {
- dev_info(&pdev->dev, "init_pf_dcb failed: %d\n", err);
- pf->flags &= ~I40E_FLAG_DCB_ENABLED;
-- goto err_init_dcb;
-+ /* Continue without DCB enabled */
- }
- #endif /* CONFIG_I40E_DCB */
-
-@@ -8119,9 +8122,6 @@ err_vsis:
- err_switch_setup:
- i40e_reset_interrupt_capability(pf);
- del_timer_sync(&pf->service_timer);
--#ifdef CONFIG_I40E_DCB
--err_init_dcb:
--#endif /* CONFIG_I40E_DCB */
- err_mac_addr:
- err_configure_lan_hmc:
- (void)i40e_shutdown_lan_hmc(hw);
-diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
-index 68026f7e8ba3..4a474dd9c910 100644
---- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
-+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
-@@ -872,6 +872,10 @@ static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type)
- return -ENOMEM;
- dmatest_bus = pci_map_page(mgp->pdev, dmatest_page, 0, PAGE_SIZE,
- DMA_BIDIRECTIONAL);
-+ if (unlikely(pci_dma_mapping_error(mgp->pdev, dmatest_bus))) {
-+ __free_page(dmatest_page);
-+ return -ENOMEM;
-+ }
-
- /* Run a small DMA test.
- * The magic multipliers to the length tell the firmware
-@@ -1293,6 +1297,7 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
- int bytes, int watchdog)
- {
- struct page *page;
-+ dma_addr_t bus;
- int idx;
- #if MYRI10GE_ALLOC_SIZE > 4096
- int end_offset;
-@@ -1317,11 +1322,21 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
- rx->watchdog_needed = 1;
- return;
- }
-+
-+ bus = pci_map_page(mgp->pdev, page, 0,
-+ MYRI10GE_ALLOC_SIZE,
-+ PCI_DMA_FROMDEVICE);
-+ if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) {
-+ __free_pages(page, MYRI10GE_ALLOC_ORDER);
-+ if (rx->fill_cnt - rx->cnt < 16)
-+ rx->watchdog_needed = 1;
-+ return;
-+ }
-+
- rx->page = page;
- rx->page_offset = 0;
-- rx->bus = pci_map_page(mgp->pdev, page, 0,
-- MYRI10GE_ALLOC_SIZE,
-- PCI_DMA_FROMDEVICE);
-+ rx->bus = bus;
-+
- }
- rx->info[idx].page = rx->page;
- rx->info[idx].page_offset = rx->page_offset;
-@@ -2765,6 +2780,35 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
- mb();
- }
-
-+static void myri10ge_unmap_tx_dma(struct myri10ge_priv *mgp,
-+ struct myri10ge_tx_buf *tx, int idx)
-+{
-+ unsigned int len;
-+ int last_idx;
-+
-+ /* Free any DMA resources we've alloced and clear out the skb slot */
-+ last_idx = (idx + 1) & tx->mask;
-+ idx = tx->req & tx->mask;
-+ do {
-+ len = dma_unmap_len(&tx->info[idx], len);
-+ if (len) {
-+ if (tx->info[idx].skb != NULL)
-+ pci_unmap_single(mgp->pdev,
-+ dma_unmap_addr(&tx->info[idx],
-+ bus), len,
-+ PCI_DMA_TODEVICE);
-+ else
-+ pci_unmap_page(mgp->pdev,
-+ dma_unmap_addr(&tx->info[idx],
-+ bus), len,
-+ PCI_DMA_TODEVICE);
-+ dma_unmap_len_set(&tx->info[idx], len, 0);
-+ tx->info[idx].skb = NULL;
-+ }
-+ idx = (idx + 1) & tx->mask;
-+ } while (idx != last_idx);
-+}
-+
- /*
- * Transmit a packet. We need to split the packet so that a single
- * segment does not cross myri10ge->tx_boundary, so this makes segment
-@@ -2788,7 +2832,7 @@ static netdev_tx_t myri10ge_xmit(struct sk_buff *skb,
- u32 low;
- __be32 high_swapped;
- unsigned int len;
-- int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
-+ int idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
- u16 pseudo_hdr_offset, cksum_offset, queue;
- int cum_len, seglen, boundary, rdma_count;
- u8 flags, odd_flag;
-@@ -2885,9 +2929,12 @@ again:
-
- /* map the skb for DMA */
- len = skb_headlen(skb);
-+ bus = pci_map_single(mgp->pdev, skb->data, len, PCI_DMA_TODEVICE);
-+ if (unlikely(pci_dma_mapping_error(mgp->pdev, bus)))
-+ goto drop;
-+
- idx = tx->req & tx->mask;
- tx->info[idx].skb = skb;
-- bus = pci_map_single(mgp->pdev, skb->data, len, PCI_DMA_TODEVICE);
- dma_unmap_addr_set(&tx->info[idx], bus, bus);
- dma_unmap_len_set(&tx->info[idx], len, len);
-
-@@ -2986,12 +3033,16 @@ again:
- break;
-
- /* map next fragment for DMA */
-- idx = (count + tx->req) & tx->mask;
- frag = &skb_shinfo(skb)->frags[frag_idx];
- frag_idx++;
- len = skb_frag_size(frag);
- bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len,
- DMA_TO_DEVICE);
-+ if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) {
-+ myri10ge_unmap_tx_dma(mgp, tx, idx);
-+ goto drop;
-+ }
-+ idx = (count + tx->req) & tx->mask;
- dma_unmap_addr_set(&tx->info[idx], bus, bus);
- dma_unmap_len_set(&tx->info[idx], len, len);
- }
-@@ -3022,31 +3073,8 @@ again:
- return NETDEV_TX_OK;
-
- abort_linearize:
-- /* Free any DMA resources we've alloced and clear out the skb
-- * slot so as to not trip up assertions, and to avoid a
-- * double-free if linearizing fails */
-+ myri10ge_unmap_tx_dma(mgp, tx, idx);
-
-- last_idx = (idx + 1) & tx->mask;
-- idx = tx->req & tx->mask;
-- tx->info[idx].skb = NULL;
-- do {
-- len = dma_unmap_len(&tx->info[idx], len);
-- if (len) {
-- if (tx->info[idx].skb != NULL)
-- pci_unmap_single(mgp->pdev,
-- dma_unmap_addr(&tx->info[idx],
-- bus), len,
-- PCI_DMA_TODEVICE);
-- else
-- pci_unmap_page(mgp->pdev,
-- dma_unmap_addr(&tx->info[idx],
-- bus), len,
-- PCI_DMA_TODEVICE);
-- dma_unmap_len_set(&tx->info[idx], len, 0);
-- tx->info[idx].skb = NULL;
-- }
-- idx = (idx + 1) & tx->mask;
-- } while (idx != last_idx);
- if (skb_is_gso(skb)) {
- netdev_err(mgp->dev, "TSO but wanted to linearize?!?!?\n");
- goto drop;
-diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
-index d6fce9750b95..3c1c33ceffba 100644
---- a/drivers/net/hyperv/netvsc_drv.c
-+++ b/drivers/net/hyperv/netvsc_drv.c
-@@ -146,6 +146,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
- struct hv_netvsc_packet *packet;
- int ret;
- unsigned int i, num_pages, npg_data;
-+ u32 skb_length = skb->len;
-
- /* Add multipages for skb->data and additional 2 for RNDIS */
- npg_data = (((unsigned long)skb->data + skb_headlen(skb) - 1)
-@@ -216,7 +217,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
- ret = rndis_filter_send(net_device_ctx->device_ctx,
- packet);
- if (ret == 0) {
-- net->stats.tx_bytes += skb->len;
-+ net->stats.tx_bytes += skb_length;
- net->stats.tx_packets++;
- } else {
- kfree(packet);
-diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
-index 7f1abb7c18f2..fbf7dcdc22b0 100644
---- a/drivers/net/macvlan.c
-+++ b/drivers/net/macvlan.c
-@@ -709,6 +709,7 @@ static netdev_features_t macvlan_fix_features(struct net_device *dev,
- features,
- mask);
- features |= ALWAYS_ON_FEATURES;
-+ features &= ~NETIF_F_NETNS_LOCAL;
-
- return features;
- }
-diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
-index 3381c4f91a8c..0c6adaaf898c 100644
---- a/drivers/net/macvtap.c
-+++ b/drivers/net/macvtap.c
-@@ -112,17 +112,15 @@ out:
- return err;
- }
-
-+/* Requires RTNL */
- static int macvtap_set_queue(struct net_device *dev, struct file *file,
- struct macvtap_queue *q)
- {
- struct macvlan_dev *vlan = netdev_priv(dev);
-- int err = -EBUSY;
-
-- rtnl_lock();
- if (vlan->numqueues == MAX_MACVTAP_QUEUES)
-- goto out;
-+ return -EBUSY;
-
-- err = 0;
- rcu_assign_pointer(q->vlan, vlan);
- rcu_assign_pointer(vlan->taps[vlan->numvtaps], q);
- sock_hold(&q->sk);
-@@ -136,9 +134,7 @@ static int macvtap_set_queue(struct net_device *dev, struct file *file,
- vlan->numvtaps++;
- vlan->numqueues++;
-
--out:
-- rtnl_unlock();
-- return err;
-+ return 0;
- }
-
- static int macvtap_disable_queue(struct macvtap_queue *q)
-@@ -454,11 +450,12 @@ static void macvtap_sock_destruct(struct sock *sk)
- static int macvtap_open(struct inode *inode, struct file *file)
- {
- struct net *net = current->nsproxy->net_ns;
-- struct net_device *dev = dev_get_by_macvtap_minor(iminor(inode));
-+ struct net_device *dev;
- struct macvtap_queue *q;
-- int err;
-+ int err = -ENODEV;
-
-- err = -ENODEV;
-+ rtnl_lock();
-+ dev = dev_get_by_macvtap_minor(iminor(inode));
- if (!dev)
- goto out;
-
-@@ -498,6 +495,7 @@ out:
- if (dev)
- dev_put(dev);
-
-+ rtnl_unlock();
- return err;
- }
-
-diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
-index 26d8c29b59de..979fe433278c 100644
---- a/drivers/net/team/team.c
-+++ b/drivers/net/team/team.c
-@@ -647,7 +647,7 @@ static void team_notify_peers(struct team *team)
- {
- if (!team->notify_peers.count || !netif_running(team->dev))
- return;
-- atomic_set(&team->notify_peers.count_pending, team->notify_peers.count);
-+ atomic_add(team->notify_peers.count, &team->notify_peers.count_pending);
- schedule_delayed_work(&team->notify_peers.dw, 0);
- }
-
-@@ -687,7 +687,7 @@ static void team_mcast_rejoin(struct team *team)
- {
- if (!team->mcast_rejoin.count || !netif_running(team->dev))
- return;
-- atomic_set(&team->mcast_rejoin.count_pending, team->mcast_rejoin.count);
-+ atomic_add(team->mcast_rejoin.count, &team->mcast_rejoin.count_pending);
- schedule_delayed_work(&team->mcast_rejoin.dw, 0);
- }
-
-diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
-index 40ad25d7f28b..9b40532041cb 100644
---- a/drivers/net/vxlan.c
-+++ b/drivers/net/vxlan.c
-@@ -1334,7 +1334,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb)
- } else if (vxlan->flags & VXLAN_F_L3MISS) {
- union vxlan_addr ipa = {
- .sin.sin_addr.s_addr = tip,
-- .sa.sa_family = AF_INET,
-+ .sin.sin_family = AF_INET,
- };
-
- vxlan_ip_miss(dev, &ipa);
-@@ -1495,7 +1495,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb)
- } else if (vxlan->flags & VXLAN_F_L3MISS) {
- union vxlan_addr ipa = {
- .sin6.sin6_addr = msg->target,
-- .sa.sa_family = AF_INET6,
-+ .sin6.sin6_family = AF_INET6,
- };
-
- vxlan_ip_miss(dev, &ipa);
-@@ -1528,7 +1528,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
- if (!n && (vxlan->flags & VXLAN_F_L3MISS)) {
- union vxlan_addr ipa = {
- .sin.sin_addr.s_addr = pip->daddr,
-- .sa.sa_family = AF_INET,
-+ .sin.sin_family = AF_INET,
- };
-
- vxlan_ip_miss(dev, &ipa);
-@@ -1549,7 +1549,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
- if (!n && (vxlan->flags & VXLAN_F_L3MISS)) {
- union vxlan_addr ipa = {
- .sin6.sin6_addr = pip6->daddr,
-- .sa.sa_family = AF_INET6,
-+ .sin6.sin6_family = AF_INET6,
- };
-
- vxlan_ip_miss(dev, &ipa);
-diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
-index 0ff3e3624d4c..feda34404ed0 100644
---- a/drivers/tty/serial/8250/8250_pci.c
-+++ b/drivers/tty/serial/8250/8250_pci.c
-@@ -1766,6 +1766,7 @@ pci_wch_ch353_setup(struct serial_private *priv,
- #define PCI_DEVICE_ID_COMMTECH_4222PCIE 0x0022
- #define PCI_DEVICE_ID_BROADCOM_TRUMANAGE 0x160a
- #define PCI_DEVICE_ID_AMCC_ADDIDATA_APCI7800 0x818e
-+#define PCI_DEVICE_ID_INTEL_QRK_UART 0x0936
-
- #define PCI_VENDOR_ID_SUNIX 0x1fd4
- #define PCI_DEVICE_ID_SUNIX_1999 0x1999
-@@ -1876,6 +1877,13 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
- .subdevice = PCI_ANY_ID,
- .setup = byt_serial_setup,
- },
-+ {
-+ .vendor = PCI_VENDOR_ID_INTEL,
-+ .device = PCI_DEVICE_ID_INTEL_QRK_UART,
-+ .subvendor = PCI_ANY_ID,
-+ .subdevice = PCI_ANY_ID,
-+ .setup = pci_default_setup,
-+ },
- /*
- * ITE
- */
-@@ -2710,6 +2718,7 @@ enum pci_board_num_t {
- pbn_ADDIDATA_PCIe_8_3906250,
- pbn_ce4100_1_115200,
- pbn_byt,
-+ pbn_qrk,
- pbn_omegapci,
- pbn_NETMOS9900_2s_115200,
- pbn_brcm_trumanage,
-@@ -3456,6 +3465,12 @@ static struct pciserial_board pci_boards[] = {
- .uart_offset = 0x80,
- .reg_shift = 2,
- },
-+ [pbn_qrk] = {
-+ .flags = FL_BASE0,
-+ .num_ports = 1,
-+ .base_baud = 2764800,
-+ .reg_shift = 2,
-+ },
- [pbn_omegapci] = {
- .flags = FL_BASE0,
- .num_ports = 8,
-@@ -5150,6 +5165,12 @@ static struct pci_device_id serial_pci_tbl[] = {
- pbn_byt },
-
- /*
-+ * Intel Quark x1000
-+ */
-+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_UART,
-+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-+ pbn_qrk },
-+ /*
- * Cronyx Omega PCI
- */
- { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_CRONYX_OMEGA,
-diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
-index 263612ce1f62..445d62a4316a 100644
---- a/drivers/usb/core/hub.c
-+++ b/drivers/usb/core/hub.c
-@@ -1948,8 +1948,10 @@ void usb_set_device_state(struct usb_device *udev,
- || new_state == USB_STATE_SUSPENDED)
- ; /* No change to wakeup settings */
- else if (new_state == USB_STATE_CONFIGURED)
-- wakeup = udev->actconfig->desc.bmAttributes
-- & USB_CONFIG_ATT_WAKEUP;
-+ wakeup = (udev->quirks &
-+ USB_QUIRK_IGNORE_REMOTE_WAKEUP) ? 0 :
-+ udev->actconfig->desc.bmAttributes &
-+ USB_CONFIG_ATT_WAKEUP;
- else
- wakeup = 0;
- }
-diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
-index 739ee8e8bdfd..5144d11d032c 100644
---- a/drivers/usb/core/quirks.c
-+++ b/drivers/usb/core/quirks.c
-@@ -160,6 +160,10 @@ static const struct usb_device_id usb_interface_quirk_list[] = {
- { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
- .driver_info = USB_QUIRK_RESET_RESUME },
-
-+ /* ASUS Base Station(T100) */
-+ { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
-+ USB_QUIRK_IGNORE_REMOTE_WAKEUP },
-+
- { } /* terminating entry must be last */
- };
-
-diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
-index 7a109eae9b9a..85f5215871de 100644
---- a/drivers/usb/musb/musb_dsps.c
-+++ b/drivers/usb/musb/musb_dsps.c
-@@ -707,6 +707,7 @@ static int dsps_suspend(struct device *dev)
- struct musb *musb = platform_get_drvdata(glue->musb);
- void __iomem *mbase = musb->ctrl_base;
-
-+ del_timer_sync(&glue->timer);
- glue->context.control = dsps_readl(mbase, wrp->control);
- glue->context.epintr = dsps_readl(mbase, wrp->epintr_set);
- glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set);
-@@ -732,6 +733,7 @@ static int dsps_resume(struct device *dev)
- dsps_writel(mbase, wrp->mode, glue->context.mode);
- dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
- dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
-+ setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
-
- return 0;
- }
-diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
-index 330df5ce435b..63b2af2a87c0 100644
---- a/drivers/usb/serial/cp210x.c
-+++ b/drivers/usb/serial/cp210x.c
-@@ -122,6 +122,7 @@ static const struct usb_device_id id_table[] = {
- { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
- { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
- { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
-+ { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
- { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
- { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
- { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
-@@ -155,6 +156,7 @@ static const struct usb_device_id id_table[] = {
- { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
- { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
- { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
-+ { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */
- { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
- { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */
- { USB_DEVICE(0x1FB9, 0x0100) }, /* Lake Shore Model 121 Current Source */
-diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
-index 72ba6f5cbc8d..2abe67bd4df8 100644
---- a/include/linux/if_vlan.h
-+++ b/include/linux/if_vlan.h
-@@ -186,7 +186,6 @@ vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio)
- }
-
- extern bool vlan_do_receive(struct sk_buff **skb);
--extern struct sk_buff *vlan_untag(struct sk_buff *skb);
-
- extern int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid);
- extern void vlan_vid_del(struct net_device *dev, __be16 proto, u16 vid);
-@@ -228,11 +227,6 @@ static inline bool vlan_do_receive(struct sk_buff **skb)
- return false;
- }
-
--static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
--{
-- return skb;
--}
--
- static inline int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid)
- {
- return 0;
-diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
-index 15ede6a823a6..ad8f85908a56 100644
---- a/include/linux/skbuff.h
-+++ b/include/linux/skbuff.h
-@@ -2458,6 +2458,7 @@ int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen);
- void skb_scrub_packet(struct sk_buff *skb, bool xnet);
- unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
- struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
-+struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
-
- struct skb_checksum_ops {
- __wsum (*update)(const void *mem, int len, __wsum wsum);
-diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
-index 52f944dfe2fd..49587dc22f5d 100644
---- a/include/linux/usb/quirks.h
-+++ b/include/linux/usb/quirks.h
-@@ -30,4 +30,7 @@
- descriptor */
- #define USB_QUIRK_DELAY_INIT 0x00000040
-
-+/* device generates spurious wakeup, ignore remote wakeup capability */
-+#define USB_QUIRK_IGNORE_REMOTE_WAKEUP 0x00000200
-+
- #endif /* __LINUX_USB_QUIRKS_H */
-diff --git a/include/net/dst.h b/include/net/dst.h
-index 77eb53fabfb0..909032821c37 100644
---- a/include/net/dst.h
-+++ b/include/net/dst.h
-@@ -466,6 +466,7 @@ void dst_init(void);
- /* Flags for xfrm_lookup flags argument. */
- enum {
- XFRM_LOOKUP_ICMP = 1 << 0,
-+ XFRM_LOOKUP_QUEUE = 1 << 1,
- };
-
- struct flowi;
-@@ -476,7 +477,16 @@ static inline struct dst_entry *xfrm_lookup(struct net *net,
- int flags)
- {
- return dst_orig;
--}
-+}
-+
-+static inline struct dst_entry *xfrm_lookup_route(struct net *net,
-+ struct dst_entry *dst_orig,
-+ const struct flowi *fl,
-+ struct sock *sk,
-+ int flags)
-+{
-+ return dst_orig;
-+}
-
- static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
- {
-@@ -488,6 +498,10 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
- const struct flowi *fl, struct sock *sk,
- int flags);
-
-+struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
-+ const struct flowi *fl, struct sock *sk,
-+ int flags);
-+
- /* skb attached with this dst needs transformation if dst->xfrm is valid */
- static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
- {
-diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
-index c55aeed41ace..cf9272807788 100644
---- a/include/net/inet_connection_sock.h
-+++ b/include/net/inet_connection_sock.h
-@@ -62,6 +62,7 @@ struct inet_connection_sock_af_ops {
- void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
- int (*bind_conflict)(const struct sock *sk,
- const struct inet_bind_bucket *tb, bool relax);
-+ void (*mtu_reduced)(struct sock *sk);
- };
-
- /** inet_connection_sock - INET connection oriented sock
-diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
-index 4b7cd695e431..cfcbc3f627bd 100644
---- a/include/net/sctp/command.h
-+++ b/include/net/sctp/command.h
-@@ -115,7 +115,7 @@ typedef enum {
- * analysis of the state functions, but in reality just taken from
- * thin air in the hopes othat we don't trigger a kernel panic.
- */
--#define SCTP_MAX_NUM_COMMANDS 14
-+#define SCTP_MAX_NUM_COMMANDS 20
-
- typedef union {
- __s32 i32;
-diff --git a/include/net/sock.h b/include/net/sock.h
-index 2f7bc435c93d..f66b2b19a6e4 100644
---- a/include/net/sock.h
-+++ b/include/net/sock.h
-@@ -969,7 +969,6 @@ struct proto {
- struct sk_buff *skb);
-
- void (*release_cb)(struct sock *sk);
-- void (*mtu_reduced)(struct sock *sk);
-
- /* Keeping track of sk's, looking them up, and port selection methods. */
- void (*hash)(struct sock *sk);
-diff --git a/include/net/tcp.h b/include/net/tcp.h
-index 743accec6c76..1f0d8479e15f 100644
---- a/include/net/tcp.h
-+++ b/include/net/tcp.h
-@@ -453,6 +453,7 @@ const u8 *tcp_parse_md5sig_option(const struct tcphdr *th);
- */
-
- void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
-+void tcp_v4_mtu_reduced(struct sock *sk);
- int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
- struct sock *tcp_create_openreq_child(struct sock *sk,
- struct request_sock *req,
-@@ -720,8 +721,10 @@ struct tcp_skb_cb {
- #define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */
- #define TCPCB_LOST 0x04 /* SKB is lost */
- #define TCPCB_TAGBITS 0x07 /* All tag bits */
-+#define TCPCB_REPAIRED 0x10 /* SKB repaired (no skb_mstamp) */
- #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */
--#define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS)
-+#define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS| \
-+ TCPCB_REPAIRED)
-
- __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
- /* 1 byte hole */
-diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
-index 7e57135c7cc4..5d56e05d83dd 100644
---- a/net/8021q/vlan_core.c
-+++ b/net/8021q/vlan_core.c
-@@ -106,59 +106,6 @@ u16 vlan_dev_vlan_id(const struct net_device *dev)
- }
- EXPORT_SYMBOL(vlan_dev_vlan_id);
-
--static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
--{
-- if (skb_cow(skb, skb_headroom(skb)) < 0) {
-- kfree_skb(skb);
-- return NULL;
-- }
--
-- memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
-- skb->mac_header += VLAN_HLEN;
-- return skb;
--}
--
--struct sk_buff *vlan_untag(struct sk_buff *skb)
--{
-- struct vlan_hdr *vhdr;
-- u16 vlan_tci;
--
-- if (unlikely(vlan_tx_tag_present(skb))) {
-- /* vlan_tci is already set-up so leave this for another time */
-- return skb;
-- }
--
-- skb = skb_share_check(skb, GFP_ATOMIC);
-- if (unlikely(!skb))
-- goto err_free;
--
-- if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
-- goto err_free;
--
-- vhdr = (struct vlan_hdr *) skb->data;
-- vlan_tci = ntohs(vhdr->h_vlan_TCI);
-- __vlan_hwaccel_put_tag(skb, skb->protocol, vlan_tci);
--
-- skb_pull_rcsum(skb, VLAN_HLEN);
-- vlan_set_encap_proto(skb, vhdr);
--
-- skb = vlan_reorder_header(skb);
-- if (unlikely(!skb))
-- goto err_free;
--
-- skb_reset_network_header(skb);
-- skb_reset_transport_header(skb);
-- skb_reset_mac_len(skb);
--
-- return skb;
--
--err_free:
-- kfree_skb(skb);
-- return NULL;
--}
--EXPORT_SYMBOL(vlan_untag);
--
--
- /*
- * vlan info and vid list
- */
-diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
-index f2d254b69353..4acfc3eef56a 100644
---- a/net/bridge/br_private.h
-+++ b/net/bridge/br_private.h
-@@ -302,6 +302,9 @@ struct br_input_skb_cb {
- int igmp;
- int mrouters_only;
- #endif
-+#ifdef CONFIG_BRIDGE_VLAN_FILTERING
-+ bool vlan_filtered;
-+#endif
- };
-
- #define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb)
-diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
-index b1c637208497..e1bd2539f9dc 100644
---- a/net/bridge/br_vlan.c
-+++ b/net/bridge/br_vlan.c
-@@ -125,7 +125,8 @@ struct sk_buff *br_handle_vlan(struct net_bridge *br,
- {
- u16 vid;
-
-- if (!br->vlan_enabled)
-+ /* If this packet was not filtered at input, let it pass */
-+ if (!BR_INPUT_SKB_CB(skb)->vlan_filtered)
- goto out;
-
- /* Vlan filter table must be configured at this point. The
-@@ -163,8 +164,10 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
- /* If VLAN filtering is disabled on the bridge, all packets are
- * permitted.
- */
-- if (!br->vlan_enabled)
-+ if (!br->vlan_enabled) {
-+ BR_INPUT_SKB_CB(skb)->vlan_filtered = false;
- return true;
-+ }
-
- /* If there are no vlan in the permitted list, all packets are
- * rejected.
-@@ -172,6 +175,8 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
- if (!v)
- goto drop;
-
-+ BR_INPUT_SKB_CB(skb)->vlan_filtered = true;
-+
- /* If vlan tx offload is disabled on bridge device and frame was
- * sent from vlan device on the bridge device, it does not have
- * HW accelerated vlan tag.
-@@ -179,7 +184,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
- if (unlikely(!vlan_tx_tag_present(skb) &&
- (skb->protocol == htons(ETH_P_8021Q) ||
- skb->protocol == htons(ETH_P_8021AD)))) {
-- skb = vlan_untag(skb);
-+ skb = skb_vlan_untag(skb);
- if (unlikely(!skb))
- return false;
- }
-@@ -228,7 +233,8 @@ bool br_allowed_egress(struct net_bridge *br,
- {
- u16 vid;
-
-- if (!br->vlan_enabled)
-+ /* If this packet was not filtered at input, let it pass */
-+ if (!BR_INPUT_SKB_CB(skb)->vlan_filtered)
- return true;
-
- if (!v)
-@@ -247,6 +253,7 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
- struct net_bridge *br = p->br;
- struct net_port_vlans *v;
-
-+ /* If filtering was disabled at input, let it pass. */
- if (!br->vlan_enabled)
- return true;
-
-diff --git a/net/core/dev.c b/net/core/dev.c
-index 37bddf729e77..3ed11a555834 100644
---- a/net/core/dev.c
-+++ b/net/core/dev.c
-@@ -3554,7 +3554,7 @@ another_round:
-
- if (skb->protocol == cpu_to_be16(ETH_P_8021Q) ||
- skb->protocol == cpu_to_be16(ETH_P_8021AD)) {
-- skb = vlan_untag(skb);
-+ skb = skb_vlan_untag(skb);
- if (unlikely(!skb))
- goto unlock;
- }
-diff --git a/net/core/netpoll.c b/net/core/netpoll.c
-index df9e6b1a9759..723fa7da8025 100644
---- a/net/core/netpoll.c
-+++ b/net/core/netpoll.c
-@@ -788,7 +788,7 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
- }
-
- if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) {
-- skb = vlan_untag(skb);
-+ skb = skb_vlan_untag(skb);
- if (unlikely(!skb))
- goto out;
- }
-diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
-index aef1500ebc05..b0db904f083d 100644
---- a/net/core/rtnetlink.c
-+++ b/net/core/rtnetlink.c
-@@ -799,7 +799,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,
- (nla_total_size(sizeof(struct ifla_vf_mac)) +
- nla_total_size(sizeof(struct ifla_vf_vlan)) +
- nla_total_size(sizeof(struct ifla_vf_tx_rate)) +
-- nla_total_size(sizeof(struct ifla_vf_spoofchk)));
-+ nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
-+ nla_total_size(sizeof(struct ifla_vf_link_state)));
- return size;
- } else
- return 0;
-diff --git a/net/core/skbuff.c b/net/core/skbuff.c
-index 8f6391bbf509..baf6fc457df9 100644
---- a/net/core/skbuff.c
-+++ b/net/core/skbuff.c
-@@ -62,6 +62,7 @@
- #include
- #include
- #include
-+#include
-
- #include
- #include
-@@ -3139,6 +3140,9 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
- NAPI_GRO_CB(skb)->free = NAPI_GRO_FREE_STOLEN_HEAD;
- goto done;
- }
-+ /* switch back to head shinfo */
-+ pinfo = skb_shinfo(p);
-+
- if (pinfo->frag_list)
- goto merge;
- if (skb_gro_len(p) != pinfo->gso_size)
-@@ -3963,3 +3967,55 @@ unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
- return shinfo->gso_size;
- }
- EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
-+
-+static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
-+{
-+ if (skb_cow(skb, skb_headroom(skb)) < 0) {
-+ kfree_skb(skb);
-+ return NULL;
-+ }
-+
-+ memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
-+ skb->mac_header += VLAN_HLEN;
-+ return skb;
-+}
-+
-+struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
-+{
-+ struct vlan_hdr *vhdr;
-+ u16 vlan_tci;
-+
-+ if (unlikely(vlan_tx_tag_present(skb))) {
-+ /* vlan_tci is already set-up so leave this for another time */
-+ return skb;
-+ }
-+
-+ skb = skb_share_check(skb, GFP_ATOMIC);
-+ if (unlikely(!skb))
-+ goto err_free;
-+
-+ if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
-+ goto err_free;
-+
-+ vhdr = (struct vlan_hdr *)skb->data;
-+ vlan_tci = ntohs(vhdr->h_vlan_TCI);
-+ __vlan_hwaccel_put_tag(skb, skb->protocol, vlan_tci);
-+
-+ skb_pull_rcsum(skb, VLAN_HLEN);
-+ vlan_set_encap_proto(skb, vhdr);
-+
-+ skb = skb_reorder_vlan_header(skb);
-+ if (unlikely(!skb))
-+ goto err_free;
-+
-+ skb_reset_network_header(skb);
-+ skb_reset_transport_header(skb);
-+ skb_reset_mac_len(skb);
-+
-+ return skb;
-+
-+err_free:
-+ kfree_skb(skb);
-+ return NULL;
-+}
-+EXPORT_SYMBOL(skb_vlan_untag);
-diff --git a/net/ipv4/route.c b/net/ipv4/route.c
-index ca5a01ed8ed6..487bb6252520 100644
---- a/net/ipv4/route.c
-+++ b/net/ipv4/route.c
-@@ -2268,9 +2268,9 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
- return rt;
-
- if (flp4->flowi4_proto)
-- rt = (struct rtable *) xfrm_lookup(net, &rt->dst,
-- flowi4_to_flowi(flp4),
-- sk, 0);
-+ rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst,
-+ flowi4_to_flowi(flp4),
-+ sk, 0);
-
- return rt;
- }
-diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
-index b48fba0aaa92..f7d71ec72a47 100644
---- a/net/ipv4/tcp.c
-+++ b/net/ipv4/tcp.c
-@@ -1175,13 +1175,6 @@ new_segment:
- goto wait_for_memory;
-
- /*
-- * All packets are restored as if they have
-- * already been sent.
-- */
-- if (tp->repair)
-- TCP_SKB_CB(skb)->when = tcp_time_stamp;
--
-- /*
- * Check whether we can use HW checksum.
- */
- if (sk->sk_route_caps & NETIF_F_ALL_CSUM)
-@@ -1190,6 +1183,13 @@ new_segment:
- skb_entail(sk, skb);
- copy = size_goal;
- max = size_goal;
-+
-+ /* All packets are restored as if they have
-+ * already been sent. skb_mstamp isn't set to
-+ * avoid wrong rtt estimation.
-+ */
-+ if (tp->repair)
-+ TCP_SKB_CB(skb)->sacked |= TCPCB_REPAIRED;
- }
-
- /* Try to append data to the end of skb. */
-diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
-index 3898694d0300..22917918fa80 100644
---- a/net/ipv4/tcp_input.c
-+++ b/net/ipv4/tcp_input.c
-@@ -2678,7 +2678,6 @@ static void tcp_enter_recovery(struct sock *sk, bool ece_ack)
- */
- static void tcp_process_loss(struct sock *sk, int flag, bool is_dupack)
- {
-- struct inet_connection_sock *icsk = inet_csk(sk);
- struct tcp_sock *tp = tcp_sk(sk);
- bool recovered = !before(tp->snd_una, tp->high_seq);
-
-@@ -2704,12 +2703,9 @@ static void tcp_process_loss(struct sock *sk, int flag, bool is_dupack)
-
- if (recovered) {
- /* F-RTO RFC5682 sec 3.1 step 2.a and 1st part of step 3.a */
-- icsk->icsk_retransmits = 0;
- tcp_try_undo_recovery(sk);
- return;
- }
-- if (flag & FLAG_DATA_ACKED)
-- icsk->icsk_retransmits = 0;
- if (tcp_is_reno(tp)) {
- /* A Reno DUPACK means new data in F-RTO step 2.b above are
- * delivered. Lower inflight to clock out (re)tranmissions.
-@@ -3398,8 +3394,10 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
- icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)
- tcp_rearm_rto(sk);
-
-- if (after(ack, prior_snd_una))
-+ if (after(ack, prior_snd_una)) {
- flag |= FLAG_SND_UNA_ADVANCED;
-+ icsk->icsk_retransmits = 0;
-+ }
-
- prior_fackets = tp->fackets_out;
- prior_in_flight = tcp_packets_in_flight(tp);
-diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
-index 1e4eac779f51..a782d5be132e 100644
---- a/net/ipv4/tcp_ipv4.c
-+++ b/net/ipv4/tcp_ipv4.c
-@@ -269,7 +269,7 @@ EXPORT_SYMBOL(tcp_v4_connect);
- * It can be called through tcp_release_cb() if socket was owned by user
- * at the time tcp_v4_err() was called to handle ICMP message.
- */
--static void tcp_v4_mtu_reduced(struct sock *sk)
-+void tcp_v4_mtu_reduced(struct sock *sk)
- {
- struct dst_entry *dst;
- struct inet_sock *inet = inet_sk(sk);
-@@ -300,6 +300,7 @@ static void tcp_v4_mtu_reduced(struct sock *sk)
- tcp_simple_retransmit(sk);
- } /* else let the usual retransmit timer handle it */
- }
-+EXPORT_SYMBOL(tcp_v4_mtu_reduced);
-
- static void do_redirect(struct sk_buff *skb, struct sock *sk)
- {
-@@ -2117,6 +2118,7 @@ const struct inet_connection_sock_af_ops ipv4_specific = {
- .compat_setsockopt = compat_ip_setsockopt,
- .compat_getsockopt = compat_ip_getsockopt,
- #endif
-+ .mtu_reduced = tcp_v4_mtu_reduced,
- };
- EXPORT_SYMBOL(ipv4_specific);
-
-@@ -2736,7 +2738,6 @@ struct proto tcp_prot = {
- .sendpage = tcp_sendpage,
- .backlog_rcv = tcp_v4_do_rcv,
- .release_cb = tcp_release_cb,
-- .mtu_reduced = tcp_v4_mtu_reduced,
- .hash = inet_hash,
- .unhash = inet_unhash,
- .get_port = inet_csk_get_port,
-diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
-index b3d1addd816b..91b98e5a17aa 100644
---- a/net/ipv4/tcp_output.c
-+++ b/net/ipv4/tcp_output.c
-@@ -787,7 +787,7 @@ void tcp_release_cb(struct sock *sk)
- __sock_put(sk);
- }
- if (flags & (1UL << TCP_MTU_REDUCED_DEFERRED)) {
-- sk->sk_prot->mtu_reduced(sk);
-+ inet_csk(sk)->icsk_af_ops->mtu_reduced(sk);
- __sock_put(sk);
- }
- }
-@@ -1876,8 +1876,11 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
- tso_segs = tcp_init_tso_segs(sk, skb, mss_now);
- BUG_ON(!tso_segs);
-
-- if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE)
-+ if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE) {
-+ /* "when" is used as a start point for the retransmit timer */
-+ TCP_SKB_CB(skb)->when = tcp_time_stamp;
- goto repair; /* Skip network transmission */
-+ }
-
- cwnd_quota = tcp_cwnd_test(tp, skb);
- if (!cwnd_quota) {
-@@ -2066,9 +2069,7 @@ void tcp_send_loss_probe(struct sock *sk)
- if (WARN_ON(!skb || !tcp_skb_pcount(skb)))
- goto rearm_timer;
-
-- /* Probe with zero data doesn't trigger fast recovery. */
-- if (skb->len > 0)
-- err = __tcp_retransmit_skb(sk, skb);
-+ err = __tcp_retransmit_skb(sk, skb);
-
- /* Record snd_nxt for loss detection. */
- if (likely(!err))
-diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
-index 6c7fa0853fc7..3f0ec063d7f8 100644
---- a/net/ipv6/addrconf.c
-+++ b/net/ipv6/addrconf.c
-@@ -1684,14 +1684,12 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
- addrconf_mod_dad_work(ifp, 0);
- }
-
--/* Join to solicited addr multicast group. */
--
-+/* Join to solicited addr multicast group.
-+ * caller must hold RTNL */
- void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr)
- {
- struct in6_addr maddr;
-
-- ASSERT_RTNL();
--
- if (dev->flags&(IFF_LOOPBACK|IFF_NOARP))
- return;
-
-@@ -1699,12 +1697,11 @@ void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr)
- ipv6_dev_mc_inc(dev, &maddr);
- }
-
-+/* caller must hold RTNL */
- void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
- {
- struct in6_addr maddr;
-
-- ASSERT_RTNL();
--
- if (idev->dev->flags&(IFF_LOOPBACK|IFF_NOARP))
- return;
-
-@@ -1712,12 +1709,11 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
- __ipv6_dev_mc_dec(idev, &maddr);
- }
-
-+/* caller must hold RTNL */
- static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
- {
- struct in6_addr addr;
-
-- ASSERT_RTNL();
--
- if (ifp->prefix_len >= 127) /* RFC 6164 */
- return;
- ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
-@@ -1726,12 +1722,11 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
- ipv6_dev_ac_inc(ifp->idev->dev, &addr);
- }
-
-+/* caller must hold RTNL */
- static void addrconf_leave_anycast(struct inet6_ifaddr *ifp)
- {
- struct in6_addr addr;
-
-- ASSERT_RTNL();
--
- if (ifp->prefix_len >= 127) /* RFC 6164 */
- return;
- ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
-diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
-index 210183244689..ff2de7d9d8e6 100644
---- a/net/ipv6/anycast.c
-+++ b/net/ipv6/anycast.c
-@@ -77,6 +77,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
- pac->acl_next = NULL;
- pac->acl_addr = *addr;
-
-+ rtnl_lock();
- rcu_read_lock();
- if (ifindex == 0) {
- struct rt6_info *rt;
-@@ -137,6 +138,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
-
- error:
- rcu_read_unlock();
-+ rtnl_unlock();
- if (pac)
- sock_kfree_s(sk, pac, sizeof(*pac));
- return err;
-@@ -171,11 +173,13 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
-
- spin_unlock_bh(&ipv6_sk_ac_lock);
-
-+ rtnl_lock();
- rcu_read_lock();
- dev = dev_get_by_index_rcu(net, pac->acl_ifindex);
- if (dev)
- ipv6_dev_ac_dec(dev, &pac->acl_addr);
- rcu_read_unlock();
-+ rtnl_unlock();
-
- sock_kfree_s(sk, pac, sizeof(*pac));
- return 0;
-@@ -198,6 +202,7 @@ void ipv6_sock_ac_close(struct sock *sk)
- spin_unlock_bh(&ipv6_sk_ac_lock);
-
- prev_index = 0;
-+ rtnl_lock();
- rcu_read_lock();
- while (pac) {
- struct ipv6_ac_socklist *next = pac->acl_next;
-@@ -212,6 +217,7 @@ void ipv6_sock_ac_close(struct sock *sk)
- pac = next;
- }
- rcu_read_unlock();
-+ rtnl_unlock();
- }
-
- static void aca_put(struct ifacaddr6 *ac)
-@@ -233,6 +239,8 @@ int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr)
- struct rt6_info *rt;
- int err;
-
-+ ASSERT_RTNL();
-+
- idev = in6_dev_get(dev);
-
- if (idev == NULL)
-@@ -302,6 +310,8 @@ int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr)
- {
- struct ifacaddr6 *aca, *prev_aca;
-
-+ ASSERT_RTNL();
-+
- write_lock_bh(&idev->lock);
- prev_aca = NULL;
- for (aca = idev->ac_list; aca; aca = aca->aca_next) {
-diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
-index 2465d18e8a26..cb57aa862177 100644
---- a/net/ipv6/ip6_gre.c
-+++ b/net/ipv6/ip6_gre.c
-@@ -787,7 +787,7 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
- encap_limit = t->parms.encap_limit;
-
- memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
-- fl6.flowi6_proto = IPPROTO_IPIP;
-+ fl6.flowi6_proto = IPPROTO_GRE;
-
- dsfield = ipv4_get_dsfield(iph);
-
-@@ -837,7 +837,7 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
- encap_limit = t->parms.encap_limit;
-
- memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
-- fl6.flowi6_proto = IPPROTO_IPV6;
-+ fl6.flowi6_proto = IPPROTO_GRE;
-
- dsfield = ipv6_get_dsfield(ipv6h);
- if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
-diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
-index 073e5a6fc631..12f7ef0f243a 100644
---- a/net/ipv6/ip6_output.c
-+++ b/net/ipv6/ip6_output.c
-@@ -1008,7 +1008,7 @@ struct dst_entry *ip6_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
- if (final_dst)
- fl6->daddr = *final_dst;
-
-- return xfrm_lookup(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
-+ return xfrm_lookup_route(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
- }
- EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow);
-
-@@ -1040,7 +1040,7 @@ struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi6 *fl6,
- if (final_dst)
- fl6->daddr = *final_dst;
-
-- return xfrm_lookup(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
-+ return xfrm_lookup_route(sock_net(sk), dst, flowi6_to_flowi(fl6), sk, 0);
- }
- EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow);
-
-diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
-index 08b367c6b9cf..761e4586ab5f 100644
---- a/net/ipv6/mcast.c
-+++ b/net/ipv6/mcast.c
-@@ -172,6 +172,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
- mc_lst->next = NULL;
- mc_lst->addr = *addr;
-
-+ rtnl_lock();
- rcu_read_lock();
- if (ifindex == 0) {
- struct rt6_info *rt;
-@@ -185,6 +186,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
-
- if (dev == NULL) {
- rcu_read_unlock();
-+ rtnl_unlock();
- sock_kfree_s(sk, mc_lst, sizeof(*mc_lst));
- return -ENODEV;
- }
-@@ -202,6 +204,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
-
- if (err) {
- rcu_read_unlock();
-+ rtnl_unlock();
- sock_kfree_s(sk, mc_lst, sizeof(*mc_lst));
- return err;
- }
-@@ -212,6 +215,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
- spin_unlock(&ipv6_sk_mc_lock);
-
- rcu_read_unlock();
-+ rtnl_unlock();
-
- return 0;
- }
-@@ -229,6 +233,7 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
- if (!ipv6_addr_is_multicast(addr))
- return -EINVAL;
-
-+ rtnl_lock();
- spin_lock(&ipv6_sk_mc_lock);
- for (lnk = &np->ipv6_mc_list;
- (mc_lst = rcu_dereference_protected(*lnk,
-@@ -252,12 +257,15 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
- } else
- (void) ip6_mc_leave_src(sk, mc_lst, NULL);
- rcu_read_unlock();
-+ rtnl_unlock();
-+
- atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc);
- kfree_rcu(mc_lst, rcu);
- return 0;
- }
- }
- spin_unlock(&ipv6_sk_mc_lock);
-+ rtnl_unlock();
-
- return -EADDRNOTAVAIL;
- }
-@@ -302,6 +310,7 @@ void ipv6_sock_mc_close(struct sock *sk)
- if (!rcu_access_pointer(np->ipv6_mc_list))
- return;
-
-+ rtnl_lock();
- spin_lock(&ipv6_sk_mc_lock);
- while ((mc_lst = rcu_dereference_protected(np->ipv6_mc_list,
- lockdep_is_held(&ipv6_sk_mc_lock))) != NULL) {
-@@ -328,6 +337,7 @@ void ipv6_sock_mc_close(struct sock *sk)
- spin_lock(&ipv6_sk_mc_lock);
- }
- spin_unlock(&ipv6_sk_mc_lock);
-+ rtnl_unlock();
- }
-
- int ip6_mc_source(int add, int omode, struct sock *sk,
-@@ -845,6 +855,8 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
- struct ifmcaddr6 *mc;
- struct inet6_dev *idev;
-
-+ ASSERT_RTNL();
-+
- /* we need to take a reference on idev */
- idev = in6_dev_get(dev);
-
-@@ -916,6 +928,8 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr)
- {
- struct ifmcaddr6 *ma, **map;
-
-+ ASSERT_RTNL();
-+
- write_lock_bh(&idev->lock);
- for (map = &idev->mc_list; (ma=*map) != NULL; map = &ma->next) {
- if (ipv6_addr_equal(&ma->mca_addr, addr)) {
-diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
-index fe548ba72687..b12b11b123ff 100644
---- a/net/ipv6/sit.c
-+++ b/net/ipv6/sit.c
-@@ -101,19 +101,19 @@ static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net,
- for_each_ip_tunnel_rcu(t, sitn->tunnels_r_l[h0 ^ h1]) {
- if (local == t->parms.iph.saddr &&
- remote == t->parms.iph.daddr &&
-- (!dev || !t->parms.link || dev->iflink == t->parms.link) &&
-+ (!dev || !t->parms.link || dev->ifindex == t->parms.link) &&
- (t->dev->flags & IFF_UP))
- return t;
- }
- for_each_ip_tunnel_rcu(t, sitn->tunnels_r[h0]) {
- if (remote == t->parms.iph.daddr &&
-- (!dev || !t->parms.link || dev->iflink == t->parms.link) &&
-+ (!dev || !t->parms.link || dev->ifindex == t->parms.link) &&
- (t->dev->flags & IFF_UP))
- return t;
- }
- for_each_ip_tunnel_rcu(t, sitn->tunnels_l[h1]) {
- if (local == t->parms.iph.saddr &&
-- (!dev || !t->parms.link || dev->iflink == t->parms.link) &&
-+ (!dev || !t->parms.link || dev->ifindex == t->parms.link) &&
- (t->dev->flags & IFF_UP))
- return t;
- }
-diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
-index 889079b2ea85..a4f890dd223a 100644
---- a/net/ipv6/tcp_ipv6.c
-+++ b/net/ipv6/tcp_ipv6.c
-@@ -1668,6 +1668,7 @@ static const struct inet_connection_sock_af_ops ipv6_specific = {
- .compat_setsockopt = compat_ipv6_setsockopt,
- .compat_getsockopt = compat_ipv6_getsockopt,
- #endif
-+ .mtu_reduced = tcp_v6_mtu_reduced,
- };
-
- #ifdef CONFIG_TCP_MD5SIG
-@@ -1699,6 +1700,7 @@ static const struct inet_connection_sock_af_ops ipv6_mapped = {
- .compat_setsockopt = compat_ipv6_setsockopt,
- .compat_getsockopt = compat_ipv6_getsockopt,
- #endif
-+ .mtu_reduced = tcp_v4_mtu_reduced,
- };
-
- #ifdef CONFIG_TCP_MD5SIG
-@@ -1935,7 +1937,6 @@ struct proto tcpv6_prot = {
- .sendpage = tcp_sendpage,
- .backlog_rcv = tcp_v6_do_rcv,
- .release_cb = tcp_release_cb,
-- .mtu_reduced = tcp_v6_mtu_reduced,
- .hash = tcp_v6_hash,
- .unhash = inet_unhash,
- .get_port = inet_csk_get_port,
-diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
-index 1e05bbde47ba..da8d067d6107 100644
---- a/net/l2tp/l2tp_ppp.c
-+++ b/net/l2tp/l2tp_ppp.c
-@@ -758,7 +758,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
- /* If PMTU discovery was enabled, use the MTU that was discovered */
- dst = sk_dst_get(tunnel->sock);
- if (dst != NULL) {
-- u32 pmtu = dst_mtu(__sk_dst_get(tunnel->sock));
-+ u32 pmtu = dst_mtu(dst);
-+
- if (pmtu != 0)
- session->mtu = session->mru = pmtu -
- PPPOL2TP_HEADER_OVERHEAD;
-diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
-index 0dfe894afd48..c375d731587f 100644
---- a/net/netlink/af_netlink.c
-+++ b/net/netlink/af_netlink.c
-@@ -205,7 +205,7 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb,
- nskb->protocol = htons((u16) sk->sk_protocol);
- nskb->pkt_type = netlink_is_kernel(sk) ?
- PACKET_KERNEL : PACKET_USER;
--
-+ skb_reset_network_header(nskb);
- ret = dev_queue_xmit(nskb);
- if (unlikely(ret > 0))
- ret = net_xmit_errno(ret);
-diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
-index 2c77e7b1a913..600c7646b3d3 100644
---- a/net/openvswitch/actions.c
-+++ b/net/openvswitch/actions.c
-@@ -42,6 +42,9 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
-
- static int make_writable(struct sk_buff *skb, int write_len)
- {
-+ if (!pskb_may_pull(skb, write_len))
-+ return -ENOMEM;
-+
- if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
- return 0;
-
-@@ -70,6 +73,8 @@ static int __pop_vlan_tci(struct sk_buff *skb, __be16 *current_tci)
-
- vlan_set_encap_proto(skb, vhdr);
- skb->mac_header += VLAN_HLEN;
-+ if (skb_network_offset(skb) < ETH_HLEN)
-+ skb_set_network_header(skb, ETH_HLEN);
- skb_reset_mac_len(skb);
-
- return 0;
-diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
-index 48a6a93db296..48b181797d7b 100644
---- a/net/packet/af_packet.c
-+++ b/net/packet/af_packet.c
-@@ -635,6 +635,7 @@ static void init_prb_bdqc(struct packet_sock *po,
- p1->tov_in_jiffies = msecs_to_jiffies(p1->retire_blk_tov);
- p1->blk_sizeof_priv = req_u->req3.tp_sizeof_priv;
-
-+ p1->max_frame_len = p1->kblk_size - BLK_PLUS_PRIV(p1->blk_sizeof_priv);
- prb_init_ft_ops(p1, req_u);
- prb_setup_retire_blk_timer(po, tx_ring);
- prb_open_block(p1, pbd);
-@@ -1946,6 +1947,18 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
- if ((int)snaplen < 0)
- snaplen = 0;
- }
-+ } else if (unlikely(macoff + snaplen >
-+ GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) {
-+ u32 nval;
-+
-+ nval = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len - macoff;
-+ pr_err_once("tpacket_rcv: packet too big, clamped from %u to %u. macoff=%u\n",
-+ snaplen, nval, macoff);
-+ snaplen = nval;
-+ if (unlikely((int)snaplen < 0)) {
-+ snaplen = 0;
-+ macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len;
-+ }
- }
- spin_lock(&sk->sk_receive_queue.lock);
- h.raw = packet_current_rx_frame(po, skb,
-@@ -3779,6 +3792,10 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
- goto out;
- if (unlikely(req->tp_block_size & (PAGE_SIZE - 1)))
- goto out;
-+ if (po->tp_version >= TPACKET_V3 &&
-+ (int)(req->tp_block_size -
-+ BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0)
-+ goto out;
- if (unlikely(req->tp_frame_size < po->tp_hdrlen +
- po->tp_reserve))
- goto out;
-diff --git a/net/packet/internal.h b/net/packet/internal.h
-index eb9580a6b25f..cdddf6a30399 100644
---- a/net/packet/internal.h
-+++ b/net/packet/internal.h
-@@ -29,6 +29,7 @@ struct tpacket_kbdq_core {
- char *pkblk_start;
- char *pkblk_end;
- int kblk_size;
-+ unsigned int max_frame_len;
- unsigned int knum_blocks;
- uint64_t knxt_seq_num;
- char *prev;
-diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
-index 5170a1ff95a1..7194fe8589b0 100644
---- a/net/sctp/sm_statefuns.c
-+++ b/net/sctp/sm_statefuns.c
-@@ -1775,9 +1775,22 @@ static sctp_disposition_t sctp_sf_do_dupcook_a(struct net *net,
- /* Update the content of current association. */
- sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
- sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
-- sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
-- SCTP_STATE(SCTP_STATE_ESTABLISHED));
-- sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
-+ if (sctp_state(asoc, SHUTDOWN_PENDING) &&
-+ (sctp_sstate(asoc->base.sk, CLOSING) ||
-+ sock_flag(asoc->base.sk, SOCK_DEAD))) {
-+ /* if were currently in SHUTDOWN_PENDING, but the socket
-+ * has been closed by user, don't transition to ESTABLISHED.
-+ * Instead trigger SHUTDOWN bundled with COOKIE_ACK.
-+ */
-+ sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
-+ return sctp_sf_do_9_2_start_shutdown(net, ep, asoc,
-+ SCTP_ST_CHUNK(0), NULL,
-+ commands);
-+ } else {
-+ sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
-+ SCTP_STATE(SCTP_STATE_ESTABLISHED));
-+ sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
-+ }
- return SCTP_DISPOSITION_CONSUME;
-
- nomem_ev:
-diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
-index 1d5c7bf29938..59cf325f2772 100644
---- a/net/xfrm/xfrm_policy.c
-+++ b/net/xfrm/xfrm_policy.c
-@@ -41,6 +41,11 @@
-
- static struct dst_entry *xfrm_policy_sk_bundles;
-
-+struct xfrm_flo {
-+ struct dst_entry *dst_orig;
-+ u8 flags;
-+};
-+
- static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock);
- static struct xfrm_policy_afinfo __rcu *xfrm_policy_afinfo[NPROTO]
- __read_mostly;
-@@ -1889,13 +1894,14 @@ static int xdst_queue_output(struct sk_buff *skb)
- }
-
- static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
-- struct dst_entry *dst,
-+ struct xfrm_flo *xflo,
- const struct flowi *fl,
- int num_xfrms,
- u16 family)
- {
- int err;
- struct net_device *dev;
-+ struct dst_entry *dst;
- struct dst_entry *dst1;
- struct xfrm_dst *xdst;
-
-@@ -1903,9 +1909,12 @@ static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
- if (IS_ERR(xdst))
- return xdst;
-
-- if (net->xfrm.sysctl_larval_drop || num_xfrms <= 0)
-+ if (!(xflo->flags & XFRM_LOOKUP_QUEUE) ||
-+ net->xfrm.sysctl_larval_drop ||
-+ num_xfrms <= 0)
- return xdst;
-
-+ dst = xflo->dst_orig;
- dst1 = &xdst->u.dst;
- dst_hold(dst);
- xdst->route = dst;
-@@ -1947,7 +1956,7 @@ static struct flow_cache_object *
- xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
- struct flow_cache_object *oldflo, void *ctx)
- {
-- struct dst_entry *dst_orig = (struct dst_entry *)ctx;
-+ struct xfrm_flo *xflo = (struct xfrm_flo *)ctx;
- struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
- struct xfrm_dst *xdst, *new_xdst;
- int num_pols = 0, num_xfrms = 0, i, err, pol_dead;
-@@ -1988,7 +1997,8 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
- goto make_dummy_bundle;
- }
-
-- new_xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family, dst_orig);
-+ new_xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,
-+ xflo->dst_orig);
- if (IS_ERR(new_xdst)) {
- err = PTR_ERR(new_xdst);
- if (err != -EAGAIN)
-@@ -2022,7 +2032,7 @@ make_dummy_bundle:
- /* We found policies, but there's no bundles to instantiate:
- * either because the policy blocks, has no transformations or
- * we could not build template (no xfrm_states).*/
-- xdst = xfrm_create_dummy_bundle(net, dst_orig, fl, num_xfrms, family);
-+ xdst = xfrm_create_dummy_bundle(net, xflo, fl, num_xfrms, family);
- if (IS_ERR(xdst)) {
- xfrm_pols_put(pols, num_pols);
- return ERR_CAST(xdst);
-@@ -2121,13 +2131,18 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
- }
-
- if (xdst == NULL) {
-+ struct xfrm_flo xflo;
-+
-+ xflo.dst_orig = dst_orig;
-+ xflo.flags = flags;
-+
- /* To accelerate a bit... */
- if ((dst_orig->flags & DST_NOXFRM) ||
- !net->xfrm.policy_count[XFRM_POLICY_OUT])
- goto nopol;
-
- flo = flow_cache_lookup(net, fl, family, dir,
-- xfrm_bundle_lookup, dst_orig);
-+ xfrm_bundle_lookup, &xflo);
- if (flo == NULL)
- goto nopol;
- if (IS_ERR(flo)) {
-@@ -2155,7 +2170,7 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
- xfrm_pols_put(pols, drop_pols);
- XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES);
-
-- return make_blackhole(net, family, dst_orig);
-+ return ERR_PTR(-EREMOTE);
- }
-
- err = -EAGAIN;
-@@ -2212,6 +2227,23 @@ dropdst:
- }
- EXPORT_SYMBOL(xfrm_lookup);
-
-+/* Callers of xfrm_lookup_route() must ensure a call to dst_output().
-+ * Otherwise we may send out blackholed packets.
-+ */
-+struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
-+ const struct flowi *fl,
-+ struct sock *sk, int flags)
-+{
-+ struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk,
-+ flags | XFRM_LOOKUP_QUEUE);
-+
-+ if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE)
-+ return make_blackhole(net, dst_orig->ops->family, dst_orig);
-+
-+ return dst;
-+}
-+EXPORT_SYMBOL(xfrm_lookup_route);
-+
- static inline int
- xfrm_secpath_reject(int idx, struct sk_buff *skb, const struct flowi *fl)
- {
-@@ -2477,7 +2509,7 @@ int __xfrm_route_forward(struct sk_buff *skb, unsigned short family)
-
- skb_dst_force(skb);
-
-- dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, 0);
-+ dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, XFRM_LOOKUP_QUEUE);
- if (IS_ERR(dst)) {
- res = 0;
- dst = NULL;
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.22-23.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.22-23.patch
deleted file mode 100644
index 62db8b47c1..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.22-23.patch
+++ /dev/null
@@ -1,5877 +0,0 @@
-diff --git a/Documentation/lzo.txt b/Documentation/lzo.txt
-new file mode 100644
-index 000000000000..ea45dd3901e3
---- /dev/null
-+++ b/Documentation/lzo.txt
-@@ -0,0 +1,164 @@
-+
-+LZO stream format as understood by Linux's LZO decompressor
-+===========================================================
-+
-+Introduction
-+
-+ This is not a specification. No specification seems to be publicly available
-+ for the LZO stream format. This document describes what input format the LZO
-+ decompressor as implemented in the Linux kernel understands. The file subject
-+ of this analysis is lib/lzo/lzo1x_decompress_safe.c. No analysis was made on
-+ the compressor nor on any other implementations though it seems likely that
-+ the format matches the standard one. The purpose of this document is to
-+ better understand what the code does in order to propose more efficient fixes
-+ for future bug reports.
-+
-+Description
-+
-+ The stream is composed of a series of instructions, operands, and data. The
-+ instructions consist in a few bits representing an opcode, and bits forming
-+ the operands for the instruction, whose size and position depend on the
-+ opcode and on the number of literals copied by previous instruction. The
-+ operands are used to indicate :
-+
-+ - a distance when copying data from the dictionary (past output buffer)
-+ - a length (number of bytes to copy from dictionary)
-+ - the number of literals to copy, which is retained in variable "state"
-+ as a piece of information for next instructions.
-+
-+ Optionally depending on the opcode and operands, extra data may follow. These
-+ extra data can be a complement for the operand (eg: a length or a distance
-+ encoded on larger values), or a literal to be copied to the output buffer.
-+
-+ The first byte of the block follows a different encoding from other bytes, it
-+ seems to be optimized for literal use only, since there is no dictionary yet
-+ prior to that byte.
-+
-+ Lengths are always encoded on a variable size starting with a small number
-+ of bits in the operand. If the number of bits isn't enough to represent the
-+ length, up to 255 may be added in increments by consuming more bytes with a
-+ rate of at most 255 per extra byte (thus the compression ratio cannot exceed
-+ around 255:1). The variable length encoding using #bits is always the same :
-+
-+ length = byte & ((1 << #bits) - 1)
-+ if (!length) {
-+ length = ((1 << #bits) - 1)
-+ length += 255*(number of zero bytes)
-+ length += first-non-zero-byte
-+ }
-+ length += constant (generally 2 or 3)
-+
-+ For references to the dictionary, distances are relative to the output
-+ pointer. Distances are encoded using very few bits belonging to certain
-+ ranges, resulting in multiple copy instructions using different encodings.
-+ Certain encodings involve one extra byte, others involve two extra bytes
-+ forming a little-endian 16-bit quantity (marked LE16 below).
-+
-+ After any instruction except the large literal copy, 0, 1, 2 or 3 literals
-+ are copied before starting the next instruction. The number of literals that
-+ were copied may change the meaning and behaviour of the next instruction. In
-+ practice, only one instruction needs to know whether 0, less than 4, or more
-+ literals were copied. This is the information stored in the variable
-+ in this implementation. This number of immediate literals to be copied is
-+ generally encoded in the last two bits of the instruction but may also be
-+ taken from the last two bits of an extra operand (eg: distance).
-+
-+ End of stream is declared when a block copy of distance 0 is seen. Only one
-+ instruction may encode this distance (0001HLLL), it takes one LE16 operand
-+ for the distance, thus requiring 3 bytes.
-+
-+ IMPORTANT NOTE : in the code some length checks are missing because certain
-+ instructions are called under the assumption that a certain number of bytes
-+ follow because it has already been garanteed before parsing the instructions.
-+ They just have to "refill" this credit if they consume extra bytes. This is
-+ an implementation design choice independant on the algorithm or encoding.
-+
-+Byte sequences
-+
-+ First byte encoding :
-+
-+ 0..17 : follow regular instruction encoding, see below. It is worth
-+ noting that codes 16 and 17 will represent a block copy from
-+ the dictionary which is empty, and that they will always be
-+ invalid at this place.
-+
-+ 18..21 : copy 0..3 literals
-+ state = (byte - 17) = 0..3 [ copy literals ]
-+ skip byte
-+
-+ 22..255 : copy literal string
-+ length = (byte - 17) = 4..238
-+ state = 4 [ don't copy extra literals ]
-+ skip byte
-+
-+ Instruction encoding :
-+
-+ 0 0 0 0 X X X X (0..15)
-+ Depends on the number of literals copied by the last instruction.
-+ If last instruction did not copy any literal (state == 0), this
-+ encoding will be a copy of 4 or more literal, and must be interpreted
-+ like this :
-+
-+ 0 0 0 0 L L L L (0..15) : copy long literal string
-+ length = 3 + (L ?: 15 + (zero_bytes * 255) + non_zero_byte)
-+ state = 4 (no extra literals are copied)
-+
-+ If last instruction used to copy between 1 to 3 literals (encoded in
-+ the instruction's opcode or distance), the instruction is a copy of a
-+ 2-byte block from the dictionary within a 1kB distance. It is worth
-+ noting that this instruction provides little savings since it uses 2
-+ bytes to encode a copy of 2 other bytes but it encodes the number of
-+ following literals for free. It must be interpreted like this :
-+
-+ 0 0 0 0 D D S S (0..15) : copy 2 bytes from <= 1kB distance
-+ length = 2
-+ state = S (copy S literals after this block)
-+ Always followed by exactly one byte : H H H H H H H H
-+ distance = (H << 2) + D + 1
-+
-+ If last instruction used to copy 4 or more literals (as detected by
-+ state == 4), the instruction becomes a copy of a 3-byte block from the
-+ dictionary from a 2..3kB distance, and must be interpreted like this :
-+
-+ 0 0 0 0 D D S S (0..15) : copy 3 bytes from 2..3 kB distance
-+ length = 3
-+ state = S (copy S literals after this block)
-+ Always followed by exactly one byte : H H H H H H H H
-+ distance = (H << 2) + D + 2049
-+
-+ 0 0 0 1 H L L L (16..31)
-+ Copy of a block within 16..48kB distance (preferably less than 10B)
-+ length = 2 + (L ?: 7 + (zero_bytes * 255) + non_zero_byte)
-+ Always followed by exactly one LE16 : D D D D D D D D : D D D D D D S S
-+ distance = 16384 + (H << 14) + D
-+ state = S (copy S literals after this block)
-+ End of stream is reached if distance == 16384
-+
-+ 0 0 1 L L L L L (32..63)
-+ Copy of small block within 16kB distance (preferably less than 34B)
-+ length = 2 + (L ?: 31 + (zero_bytes * 255) + non_zero_byte)
-+ Always followed by exactly one LE16 : D D D D D D D D : D D D D D D S S
-+ distance = D + 1
-+ state = S (copy S literals after this block)
-+
-+ 0 1 L D D D S S (64..127)
-+ Copy 3-4 bytes from block within 2kB distance
-+ state = S (copy S literals after this block)
-+ length = 3 + L
-+ Always followed by exactly one byte : H H H H H H H H
-+ distance = (H << 3) + D + 1
-+
-+ 1 L L D D D S S (128..255)
-+ Copy 5-8 bytes from block within 2kB distance
-+ state = S (copy S literals after this block)
-+ length = 5 + L
-+ Always followed by exactly one byte : H H H H H H H H
-+ distance = (H << 3) + D + 1
-+
-+Authors
-+
-+ This document was written by Willy Tarreau on 2014/07/19 during an
-+ analysis of the decompression code available in Linux 3.16-rc5. The code is
-+ tricky, it is possible that this document contains mistakes or that a few
-+ corner cases were overlooked. In any case, please report any doubt, fix, or
-+ proposed updates to the author(s) so that the document can be updated.
-diff --git a/Documentation/virtual/kvm/mmu.txt b/Documentation/virtual/kvm/mmu.txt
-index 290894176142..53838d9c6295 100644
---- a/Documentation/virtual/kvm/mmu.txt
-+++ b/Documentation/virtual/kvm/mmu.txt
-@@ -425,6 +425,20 @@ fault through the slow path.
- Since only 19 bits are used to store generation-number on mmio spte, all
- pages are zapped when there is an overflow.
-
-+Unfortunately, a single memory access might access kvm_memslots(kvm) multiple
-+times, the last one happening when the generation number is retrieved and
-+stored into the MMIO spte. Thus, the MMIO spte might be created based on
-+out-of-date information, but with an up-to-date generation number.
-+
-+To avoid this, the generation number is incremented again after synchronize_srcu
-+returns; thus, the low bit of kvm_memslots(kvm)->generation is only 1 during a
-+memslot update, while some SRCU readers might be using the old copy. We do not
-+want to use an MMIO sptes created with an odd generation number, and we can do
-+this without losing a bit in the MMIO spte. The low bit of the generation
-+is not stored in MMIO spte, and presumed zero when it is extracted out of the
-+spte. If KVM is unlucky and creates an MMIO spte while the low bit is 1,
-+the next access to the spte will always be a cache miss.
-+
-
- Further reading
- ===============
-diff --git a/Makefile b/Makefile
-index a59980eb4557..135a04a26076 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 22
-+SUBLEVEL = 23
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/arm/boot/dts/armada-370-netgear-rn102.dts b/arch/arm/boot/dts/armada-370-netgear-rn102.dts
-index 651aeb5ef439..f3188e953de4 100644
---- a/arch/arm/boot/dts/armada-370-netgear-rn102.dts
-+++ b/arch/arm/boot/dts/armada-370-netgear-rn102.dts
-@@ -144,6 +144,10 @@
- marvell,nand-enable-arbiter;
- nand-on-flash-bbt;
-
-+ /* Use Hardware BCH ECC */
-+ nand-ecc-strength = <4>;
-+ nand-ecc-step-size = <512>;
-+
- partition@0 {
- label = "u-boot";
- reg = <0x0000000 0x180000>; /* 1.5MB */
-diff --git a/arch/arm/boot/dts/armada-370-netgear-rn104.dts b/arch/arm/boot/dts/armada-370-netgear-rn104.dts
-index 4e27587667bf..da406c1c726a 100644
---- a/arch/arm/boot/dts/armada-370-netgear-rn104.dts
-+++ b/arch/arm/boot/dts/armada-370-netgear-rn104.dts
-@@ -146,6 +146,10 @@
- marvell,nand-enable-arbiter;
- nand-on-flash-bbt;
-
-+ /* Use Hardware BCH ECC */
-+ nand-ecc-strength = <4>;
-+ nand-ecc-step-size = <512>;
-+
- partition@0 {
- label = "u-boot";
- reg = <0x0000000 0x180000>; /* 1.5MB */
-diff --git a/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts b/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
-index ff049ee862eb..b4aba09de911 100644
---- a/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
-+++ b/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
-@@ -224,6 +224,10 @@
- marvell,nand-enable-arbiter;
- nand-on-flash-bbt;
-
-+ /* Use Hardware BCH ECC */
-+ nand-ecc-strength = <4>;
-+ nand-ecc-step-size = <512>;
-+
- partition@0 {
- label = "u-boot";
- reg = <0x0000000 0x180000>; /* 1.5MB */
-diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
-index fece8665fb63..b8f234bf7de8 100644
---- a/arch/arm/boot/dts/at91sam9263.dtsi
-+++ b/arch/arm/boot/dts/at91sam9263.dtsi
-@@ -535,6 +535,7 @@
- compatible = "atmel,hsmci";
- reg = <0xfff80000 0x600>;
- interrupts = <10 IRQ_TYPE_LEVEL_HIGH 0>;
-+ pinctrl-names = "default";
- #address-cells = <1>;
- #size-cells = <0>;
- status = "disabled";
-@@ -544,6 +545,7 @@
- compatible = "atmel,hsmci";
- reg = <0xfff84000 0x600>;
- interrupts = <11 IRQ_TYPE_LEVEL_HIGH 0>;
-+ pinctrl-names = "default";
- #address-cells = <1>;
- #size-cells = <0>;
- status = "disabled";
-diff --git a/arch/arm/boot/dts/sama5d3_can.dtsi b/arch/arm/boot/dts/sama5d3_can.dtsi
-index a0775851cce5..eaf41451ad0c 100644
---- a/arch/arm/boot/dts/sama5d3_can.dtsi
-+++ b/arch/arm/boot/dts/sama5d3_can.dtsi
-@@ -40,7 +40,7 @@
- atmel,clk-output-range = <0 66000000>;
- };
-
-- can1_clk: can0_clk {
-+ can1_clk: can1_clk {
- #clock-cells = <0>;
- reg = <41>;
- atmel,clk-output-range = <0 66000000>;
-diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
-index 034529d801b2..d66f102c352a 100644
---- a/arch/arm/mach-at91/clock.c
-+++ b/arch/arm/mach-at91/clock.c
-@@ -962,6 +962,7 @@ static int __init at91_clock_reset(void)
- }
-
- at91_pmc_write(AT91_PMC_SCDR, scdr);
-+ at91_pmc_write(AT91_PMC_PCDR, pcdr);
- if (cpu_is_sama5d3())
- at91_pmc_write(AT91_PMC_PCDR1, pcdr1);
-
-diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
-index fda2704b3f9f..e72289a97367 100644
---- a/arch/arm64/include/asm/compat.h
-+++ b/arch/arm64/include/asm/compat.h
-@@ -37,8 +37,8 @@ typedef s32 compat_ssize_t;
- typedef s32 compat_time_t;
- typedef s32 compat_clock_t;
- typedef s32 compat_pid_t;
--typedef u32 __compat_uid_t;
--typedef u32 __compat_gid_t;
-+typedef u16 __compat_uid_t;
-+typedef u16 __compat_gid_t;
- typedef u16 __compat_uid16_t;
- typedef u16 __compat_gid16_t;
- typedef u32 __compat_uid32_t;
-diff --git a/arch/m68k/mm/hwtest.c b/arch/m68k/mm/hwtest.c
-index 2c7dde3c6430..2a5259fd23eb 100644
---- a/arch/m68k/mm/hwtest.c
-+++ b/arch/m68k/mm/hwtest.c
-@@ -28,9 +28,11 @@
- int hwreg_present( volatile void *regp )
- {
- int ret = 0;
-+ unsigned long flags;
- long save_sp, save_vbr;
- long tmp_vectors[3];
-
-+ local_irq_save(flags);
- __asm__ __volatile__
- ( "movec %/vbr,%2\n\t"
- "movel #Lberr1,%4@(8)\n\t"
-@@ -46,6 +48,7 @@ int hwreg_present( volatile void *regp )
- : "=&d" (ret), "=&r" (save_sp), "=&r" (save_vbr)
- : "a" (regp), "a" (tmp_vectors)
- );
-+ local_irq_restore(flags);
-
- return( ret );
- }
-@@ -58,9 +61,11 @@ EXPORT_SYMBOL(hwreg_present);
- int hwreg_write( volatile void *regp, unsigned short val )
- {
- int ret;
-+ unsigned long flags;
- long save_sp, save_vbr;
- long tmp_vectors[3];
-
-+ local_irq_save(flags);
- __asm__ __volatile__
- ( "movec %/vbr,%2\n\t"
- "movel #Lberr2,%4@(8)\n\t"
-@@ -78,6 +83,7 @@ int hwreg_write( volatile void *regp, unsigned short val )
- : "=&d" (ret), "=&r" (save_sp), "=&r" (save_vbr)
- : "a" (regp), "a" (tmp_vectors), "g" (val)
- );
-+ local_irq_restore(flags);
-
- return( ret );
- }
-diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
-index 4642d6a4d356..de1ec54a2a57 100644
---- a/arch/powerpc/platforms/pseries/iommu.c
-+++ b/arch/powerpc/platforms/pseries/iommu.c
-@@ -329,16 +329,16 @@ struct direct_window {
-
- /* Dynamic DMA Window support */
- struct ddw_query_response {
-- __be32 windows_available;
-- __be32 largest_available_block;
-- __be32 page_size;
-- __be32 migration_capable;
-+ u32 windows_available;
-+ u32 largest_available_block;
-+ u32 page_size;
-+ u32 migration_capable;
- };
-
- struct ddw_create_response {
-- __be32 liobn;
-- __be32 addr_hi;
-- __be32 addr_lo;
-+ u32 liobn;
-+ u32 addr_hi;
-+ u32 addr_lo;
- };
-
- static LIST_HEAD(direct_window_list);
-@@ -725,16 +725,18 @@ static void remove_ddw(struct device_node *np, bool remove_prop)
- {
- struct dynamic_dma_window_prop *dwp;
- struct property *win64;
-- const u32 *ddw_avail;
-+ u32 ddw_avail[3];
- u64 liobn;
-- int len, ret = 0;
-+ int ret = 0;
-+
-+ ret = of_property_read_u32_array(np, "ibm,ddw-applicable",
-+ &ddw_avail[0], 3);
-
-- ddw_avail = of_get_property(np, "ibm,ddw-applicable", &len);
- win64 = of_find_property(np, DIRECT64_PROPNAME, NULL);
- if (!win64)
- return;
-
-- if (!ddw_avail || len < 3 * sizeof(u32) || win64->length < sizeof(*dwp))
-+ if (ret || win64->length < sizeof(*dwp))
- goto delprop;
-
- dwp = win64->value;
-@@ -872,8 +874,9 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
-
- do {
- /* extra outputs are LIOBN and dma-addr (hi, lo) */
-- ret = rtas_call(ddw_avail[1], 5, 4, (u32 *)create, cfg_addr,
-- BUID_HI(buid), BUID_LO(buid), page_shift, window_shift);
-+ ret = rtas_call(ddw_avail[1], 5, 4, (u32 *)create,
-+ cfg_addr, BUID_HI(buid), BUID_LO(buid),
-+ page_shift, window_shift);
- } while (rtas_busy_delay(ret));
- dev_info(&dev->dev,
- "ibm,create-pe-dma-window(%x) %x %x %x %x %x returned %d "
-@@ -910,7 +913,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
- int page_shift;
- u64 dma_addr, max_addr;
- struct device_node *dn;
-- const u32 *uninitialized_var(ddw_avail);
-+ u32 ddw_avail[3];
- struct direct_window *window;
- struct property *win64;
- struct dynamic_dma_window_prop *ddwprop;
-@@ -942,8 +945,9 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
- * for the given node in that order.
- * the property is actually in the parent, not the PE
- */
-- ddw_avail = of_get_property(pdn, "ibm,ddw-applicable", &len);
-- if (!ddw_avail || len < 3 * sizeof(u32))
-+ ret = of_property_read_u32_array(pdn, "ibm,ddw-applicable",
-+ &ddw_avail[0], 3);
-+ if (ret)
- goto out_failed;
-
- /*
-@@ -966,11 +970,11 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
- dev_dbg(&dev->dev, "no free dynamic windows");
- goto out_failed;
- }
-- if (be32_to_cpu(query.page_size) & 4) {
-+ if (query.page_size & 4) {
- page_shift = 24; /* 16MB */
-- } else if (be32_to_cpu(query.page_size) & 2) {
-+ } else if (query.page_size & 2) {
- page_shift = 16; /* 64kB */
-- } else if (be32_to_cpu(query.page_size) & 1) {
-+ } else if (query.page_size & 1) {
- page_shift = 12; /* 4kB */
- } else {
- dev_dbg(&dev->dev, "no supported direct page size in mask %x",
-@@ -980,7 +984,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
- /* verify the window * number of ptes will map the partition */
- /* check largest block * page size > max memory hotplug addr */
- max_addr = memory_hotplug_max();
-- if (be32_to_cpu(query.largest_available_block) < (max_addr >> page_shift)) {
-+ if (query.largest_available_block < (max_addr >> page_shift)) {
- dev_dbg(&dev->dev, "can't map partiton max 0x%llx with %u "
- "%llu-sized pages\n", max_addr, query.largest_available_block,
- 1ULL << page_shift);
-@@ -1006,8 +1010,9 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
- if (ret != 0)
- goto out_free_prop;
-
-- ddwprop->liobn = create.liobn;
-- ddwprop->dma_base = cpu_to_be64(of_read_number(&create.addr_hi, 2));
-+ ddwprop->liobn = cpu_to_be32(create.liobn);
-+ ddwprop->dma_base = cpu_to_be64(((u64)create.addr_hi << 32) |
-+ create.addr_lo);
- ddwprop->tce_shift = cpu_to_be32(page_shift);
- ddwprop->window_shift = cpu_to_be32(len);
-
-@@ -1039,7 +1044,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
- list_add(&window->list, &direct_window_list);
- spin_unlock(&direct_window_list_lock);
-
-- dma_addr = of_read_number(&create.addr_hi, 2);
-+ dma_addr = be64_to_cpu(ddwprop->dma_base);
- goto out_unlock;
-
- out_free_window:
-diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
-index 5f79d2d79ca7..f1ba119878ec 100644
---- a/arch/s390/kvm/interrupt.c
-+++ b/arch/s390/kvm/interrupt.c
-@@ -71,6 +71,7 @@ static int __interrupt_is_deliverable(struct kvm_vcpu *vcpu,
- return 0;
- if (vcpu->arch.sie_block->gcr[0] & 0x2000ul)
- return 1;
-+ return 0;
- case KVM_S390_INT_EMERGENCY:
- if (psw_extint_disabled(vcpu))
- return 0;
-diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
-index b398c68b2713..a38513c33a62 100644
---- a/arch/sparc/Kconfig
-+++ b/arch/sparc/Kconfig
-@@ -67,6 +67,7 @@ config SPARC64
- select HAVE_SYSCALL_TRACEPOINTS
- select HAVE_CONTEXT_TRACKING
- select HAVE_DEBUG_KMEMLEAK
-+ select SPARSE_IRQ
- select RTC_DRV_CMOS
- select RTC_DRV_BQ4802
- select RTC_DRV_SUN4V
-diff --git a/arch/sparc/include/asm/hypervisor.h b/arch/sparc/include/asm/hypervisor.h
-index ca121f0fa3ec..17be9d618335 100644
---- a/arch/sparc/include/asm/hypervisor.h
-+++ b/arch/sparc/include/asm/hypervisor.h
-@@ -2944,6 +2944,16 @@ extern unsigned long sun4v_vt_set_perfreg(unsigned long reg_num,
- unsigned long reg_val);
- #endif
-
-+#define HV_FAST_T5_GET_PERFREG 0x1a8
-+#define HV_FAST_T5_SET_PERFREG 0x1a9
-+
-+#ifndef __ASSEMBLY__
-+unsigned long sun4v_t5_get_perfreg(unsigned long reg_num,
-+ unsigned long *reg_val);
-+unsigned long sun4v_t5_set_perfreg(unsigned long reg_num,
-+ unsigned long reg_val);
-+#endif
-+
- /* Function numbers for HV_CORE_TRAP. */
- #define HV_CORE_SET_VER 0x00
- #define HV_CORE_PUTCHAR 0x01
-@@ -2975,6 +2985,7 @@ extern unsigned long sun4v_vt_set_perfreg(unsigned long reg_num,
- #define HV_GRP_VF_CPU 0x0205
- #define HV_GRP_KT_CPU 0x0209
- #define HV_GRP_VT_CPU 0x020c
-+#define HV_GRP_T5_CPU 0x0211
- #define HV_GRP_DIAG 0x0300
-
- #ifndef __ASSEMBLY__
-diff --git a/arch/sparc/include/asm/irq_64.h b/arch/sparc/include/asm/irq_64.h
-index abf6afe82ca8..3deb07ff1e00 100644
---- a/arch/sparc/include/asm/irq_64.h
-+++ b/arch/sparc/include/asm/irq_64.h
-@@ -37,7 +37,7 @@
- *
- * ino_bucket->irq allocation is made during {sun4v_,}build_irq().
- */
--#define NR_IRQS 255
-+#define NR_IRQS (2048)
-
- extern void irq_install_pre_handler(int irq,
- void (*func)(unsigned int, void *, void *),
-@@ -57,11 +57,8 @@ extern unsigned int sun4u_build_msi(u32 portid, unsigned int *irq_p,
- unsigned long iclr_base);
- extern void sun4u_destroy_msi(unsigned int irq);
-
--extern unsigned char irq_alloc(unsigned int dev_handle,
-- unsigned int dev_ino);
--#ifdef CONFIG_PCI_MSI
--extern void irq_free(unsigned int irq);
--#endif
-+unsigned int irq_alloc(unsigned int dev_handle, unsigned int dev_ino);
-+void irq_free(unsigned int irq);
-
- extern void __init init_IRQ(void);
- extern void fixup_irqs(void);
-diff --git a/arch/sparc/include/asm/ldc.h b/arch/sparc/include/asm/ldc.h
-index bdb524a7b814..8732ed391aff 100644
---- a/arch/sparc/include/asm/ldc.h
-+++ b/arch/sparc/include/asm/ldc.h
-@@ -53,13 +53,14 @@ struct ldc_channel;
- /* Allocate state for a channel. */
- extern struct ldc_channel *ldc_alloc(unsigned long id,
- const struct ldc_channel_config *cfgp,
-- void *event_arg);
-+ void *event_arg,
-+ const char *name);
-
- /* Shut down and free state for a channel. */
- extern void ldc_free(struct ldc_channel *lp);
-
- /* Register TX and RX queues of the link with the hypervisor. */
--extern int ldc_bind(struct ldc_channel *lp, const char *name);
-+extern int ldc_bind(struct ldc_channel *lp);
-
- /* For non-RAW protocols we need to complete a handshake before
- * communication can proceed. ldc_connect() does that, if the
-diff --git a/arch/sparc/include/asm/oplib_64.h b/arch/sparc/include/asm/oplib_64.h
-index a12dbe3b7762..e48fdf4e16ff 100644
---- a/arch/sparc/include/asm/oplib_64.h
-+++ b/arch/sparc/include/asm/oplib_64.h
-@@ -62,7 +62,8 @@ struct linux_mem_p1275 {
- /* You must call prom_init() before using any of the library services,
- * preferably as early as possible. Pass it the romvec pointer.
- */
--extern void prom_init(void *cif_handler, void *cif_stack);
-+extern void prom_init(void *cif_handler);
-+extern void prom_init_report(void);
-
- /* Boot argument acquisition, returns the boot command line string. */
- extern char *prom_getbootargs(void);
-diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h
-index aac53fcea807..b18e602fcac4 100644
---- a/arch/sparc/include/asm/page_64.h
-+++ b/arch/sparc/include/asm/page_64.h
-@@ -57,18 +57,21 @@ extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct pag
- typedef struct { unsigned long pte; } pte_t;
- typedef struct { unsigned long iopte; } iopte_t;
- typedef struct { unsigned long pmd; } pmd_t;
-+typedef struct { unsigned long pud; } pud_t;
- typedef struct { unsigned long pgd; } pgd_t;
- typedef struct { unsigned long pgprot; } pgprot_t;
-
- #define pte_val(x) ((x).pte)
- #define iopte_val(x) ((x).iopte)
- #define pmd_val(x) ((x).pmd)
-+#define pud_val(x) ((x).pud)
- #define pgd_val(x) ((x).pgd)
- #define pgprot_val(x) ((x).pgprot)
-
- #define __pte(x) ((pte_t) { (x) } )
- #define __iopte(x) ((iopte_t) { (x) } )
- #define __pmd(x) ((pmd_t) { (x) } )
-+#define __pud(x) ((pud_t) { (x) } )
- #define __pgd(x) ((pgd_t) { (x) } )
- #define __pgprot(x) ((pgprot_t) { (x) } )
-
-@@ -77,18 +80,21 @@ typedef struct { unsigned long pgprot; } pgprot_t;
- typedef unsigned long pte_t;
- typedef unsigned long iopte_t;
- typedef unsigned long pmd_t;
-+typedef unsigned long pud_t;
- typedef unsigned long pgd_t;
- typedef unsigned long pgprot_t;
-
- #define pte_val(x) (x)
- #define iopte_val(x) (x)
- #define pmd_val(x) (x)
-+#define pud_val(x) (x)
- #define pgd_val(x) (x)
- #define pgprot_val(x) (x)
-
- #define __pte(x) (x)
- #define __iopte(x) (x)
- #define __pmd(x) (x)
-+#define __pud(x) (x)
- #define __pgd(x) (x)
- #define __pgprot(x) (x)
-
-@@ -96,21 +102,14 @@ typedef unsigned long pgprot_t;
-
- typedef pte_t *pgtable_t;
-
--/* These two values define the virtual address space range in which we
-- * must forbid 64-bit user processes from making mappings. It used to
-- * represent precisely the virtual address space hole present in most
-- * early sparc64 chips including UltraSPARC-I. But now it also is
-- * further constrained by the limits of our page tables, which is
-- * 43-bits of virtual address.
-- */
--#define SPARC64_VA_HOLE_TOP _AC(0xfffffc0000000000,UL)
--#define SPARC64_VA_HOLE_BOTTOM _AC(0x0000040000000000,UL)
-+extern unsigned long sparc64_va_hole_top;
-+extern unsigned long sparc64_va_hole_bottom;
-
- /* The next two defines specify the actual exclusion region we
- * enforce, wherein we use a 4GB red zone on each side of the VA hole.
- */
--#define VA_EXCLUDE_START (SPARC64_VA_HOLE_BOTTOM - (1UL << 32UL))
--#define VA_EXCLUDE_END (SPARC64_VA_HOLE_TOP + (1UL << 32UL))
-+#define VA_EXCLUDE_START (sparc64_va_hole_bottom - (1UL << 32UL))
-+#define VA_EXCLUDE_END (sparc64_va_hole_top + (1UL << 32UL))
-
- #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
- _AC(0x0000000070000000,UL) : \
-@@ -118,20 +117,16 @@ typedef pte_t *pgtable_t;
-
- #include
-
--#define PAGE_OFFSET_BY_BITS(X) (-(_AC(1,UL) << (X)))
- extern unsigned long PAGE_OFFSET;
-
- #endif /* !(__ASSEMBLY__) */
-
--/* The maximum number of physical memory address bits we support, this
-- * is used to size various tables used to manage kernel TLB misses and
-- * also the sparsemem code.
-+/* The maximum number of physical memory address bits we support. The
-+ * largest value we can support is whatever "KPGD_SHIFT + KPTE_BITS"
-+ * evaluates to.
- */
--#define MAX_PHYS_ADDRESS_BITS 47
-+#define MAX_PHYS_ADDRESS_BITS 53
-
--/* These two shift counts are used when indexing sparc64_valid_addr_bitmap
-- * and kpte_linear_bitmap.
-- */
- #define ILOG2_4MB 22
- #define ILOG2_256MB 28
-
-diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
-index bcfe063bce23..2c8d41fb13a4 100644
---- a/arch/sparc/include/asm/pgalloc_64.h
-+++ b/arch/sparc/include/asm/pgalloc_64.h
-@@ -15,6 +15,13 @@
-
- extern struct kmem_cache *pgtable_cache;
-
-+static inline void __pgd_populate(pgd_t *pgd, pud_t *pud)
-+{
-+ pgd_set(pgd, pud);
-+}
-+
-+#define pgd_populate(MM, PGD, PUD) __pgd_populate(PGD, PUD)
-+
- static inline pgd_t *pgd_alloc(struct mm_struct *mm)
- {
- return kmem_cache_alloc(pgtable_cache, GFP_KERNEL);
-@@ -25,7 +32,23 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
- kmem_cache_free(pgtable_cache, pgd);
- }
-
--#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
-+static inline void __pud_populate(pud_t *pud, pmd_t *pmd)
-+{
-+ pud_set(pud, pmd);
-+}
-+
-+#define pud_populate(MM, PUD, PMD) __pud_populate(PUD, PMD)
-+
-+static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
-+{
-+ return kmem_cache_alloc(pgtable_cache,
-+ GFP_KERNEL|__GFP_REPEAT);
-+}
-+
-+static inline void pud_free(struct mm_struct *mm, pud_t *pud)
-+{
-+ kmem_cache_free(pgtable_cache, pud);
-+}
-
- static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
- {
-@@ -91,4 +114,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pte_t *pte,
- #define __pmd_free_tlb(tlb, pmd, addr) \
- pgtable_free_tlb(tlb, pmd, false)
-
-+#define __pud_free_tlb(tlb, pud, addr) \
-+ pgtable_free_tlb(tlb, pud, false)
-+
- #endif /* _SPARC64_PGALLOC_H */
-diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
-index 1a49ffdf9da9..e8dfabf156c7 100644
---- a/arch/sparc/include/asm/pgtable_64.h
-+++ b/arch/sparc/include/asm/pgtable_64.h
-@@ -20,8 +20,6 @@
- #include
- #include
-
--#include
--
- /* The kernel image occupies 0x4000000 to 0x6000000 (4MB --> 96MB).
- * The page copy blockops can use 0x6000000 to 0x8000000.
- * The 8K TSB is mapped in the 0x8000000 to 0x8400000 range.
-@@ -42,10 +40,7 @@
- #define LOW_OBP_ADDRESS _AC(0x00000000f0000000,UL)
- #define HI_OBP_ADDRESS _AC(0x0000000100000000,UL)
- #define VMALLOC_START _AC(0x0000000100000000,UL)
--#define VMALLOC_END _AC(0x0000010000000000,UL)
--#define VMEMMAP_BASE _AC(0x0000010000000000,UL)
--
--#define vmemmap ((struct page *)VMEMMAP_BASE)
-+#define VMEMMAP_BASE VMALLOC_END
-
- /* PMD_SHIFT determines the size of the area a second-level page
- * table can map
-@@ -55,13 +50,25 @@
- #define PMD_MASK (~(PMD_SIZE-1))
- #define PMD_BITS (PAGE_SHIFT - 3)
-
--/* PGDIR_SHIFT determines what a third-level page table entry can map */
--#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS)
-+/* PUD_SHIFT determines the size of the area a third-level page
-+ * table can map
-+ */
-+#define PUD_SHIFT (PMD_SHIFT + PMD_BITS)
-+#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
-+#define PUD_MASK (~(PUD_SIZE-1))
-+#define PUD_BITS (PAGE_SHIFT - 3)
-+
-+/* PGDIR_SHIFT determines what a fourth-level page table entry can map */
-+#define PGDIR_SHIFT (PUD_SHIFT + PUD_BITS)
- #define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT)
- #define PGDIR_MASK (~(PGDIR_SIZE-1))
- #define PGDIR_BITS (PAGE_SHIFT - 3)
-
--#if (PGDIR_SHIFT + PGDIR_BITS) != 43
-+#if (MAX_PHYS_ADDRESS_BITS > PGDIR_SHIFT + PGDIR_BITS)
-+#error MAX_PHYS_ADDRESS_BITS exceeds what kernel page tables can support
-+#endif
-+
-+#if (PGDIR_SHIFT + PGDIR_BITS) != 53
- #error Page table parameters do not cover virtual address space properly.
- #endif
-
-@@ -71,28 +78,18 @@
-
- #ifndef __ASSEMBLY__
-
--#include
--
--extern unsigned long sparc64_valid_addr_bitmap[];
-+extern unsigned long VMALLOC_END;
-
--/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
--static inline bool __kern_addr_valid(unsigned long paddr)
--{
-- if ((paddr >> MAX_PHYS_ADDRESS_BITS) != 0UL)
-- return false;
-- return test_bit(paddr >> ILOG2_4MB, sparc64_valid_addr_bitmap);
--}
-+#define vmemmap ((struct page *)VMEMMAP_BASE)
-
--static inline bool kern_addr_valid(unsigned long addr)
--{
-- unsigned long paddr = __pa(addr);
-+#include
-
-- return __kern_addr_valid(paddr);
--}
-+bool kern_addr_valid(unsigned long addr);
-
- /* Entries per page directory level. */
- #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-3))
- #define PTRS_PER_PMD (1UL << PMD_BITS)
-+#define PTRS_PER_PUD (1UL << PUD_BITS)
- #define PTRS_PER_PGD (1UL << PGDIR_BITS)
-
- /* Kernel has a separate 44bit address space. */
-@@ -101,6 +98,9 @@ static inline bool kern_addr_valid(unsigned long addr)
- #define pmd_ERROR(e) \
- pr_err("%s:%d: bad pmd %p(%016lx) seen at (%pS)\n", \
- __FILE__, __LINE__, &(e), pmd_val(e), __builtin_return_address(0))
-+#define pud_ERROR(e) \
-+ pr_err("%s:%d: bad pud %p(%016lx) seen at (%pS)\n", \
-+ __FILE__, __LINE__, &(e), pud_val(e), __builtin_return_address(0))
- #define pgd_ERROR(e) \
- pr_err("%s:%d: bad pgd %p(%016lx) seen at (%pS)\n", \
- __FILE__, __LINE__, &(e), pgd_val(e), __builtin_return_address(0))
-@@ -112,6 +112,7 @@ static inline bool kern_addr_valid(unsigned long addr)
- #define _PAGE_R _AC(0x8000000000000000,UL) /* Keep ref bit uptodate*/
- #define _PAGE_SPECIAL _AC(0x0200000000000000,UL) /* Special page */
- #define _PAGE_PMD_HUGE _AC(0x0100000000000000,UL) /* Huge page */
-+#define _PAGE_PUD_HUGE _PAGE_PMD_HUGE
-
- /* Advertise support for _PAGE_SPECIAL */
- #define __HAVE_ARCH_PTE_SPECIAL
-@@ -658,26 +659,26 @@ static inline unsigned long pmd_large(pmd_t pmd)
- return pte_val(pte) & _PAGE_PMD_HUGE;
- }
-
--#ifdef CONFIG_TRANSPARENT_HUGEPAGE
--static inline unsigned long pmd_young(pmd_t pmd)
-+static inline unsigned long pmd_pfn(pmd_t pmd)
- {
- pte_t pte = __pte(pmd_val(pmd));
-
-- return pte_young(pte);
-+ return pte_pfn(pte);
- }
-
--static inline unsigned long pmd_write(pmd_t pmd)
-+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-+static inline unsigned long pmd_young(pmd_t pmd)
- {
- pte_t pte = __pte(pmd_val(pmd));
-
-- return pte_write(pte);
-+ return pte_young(pte);
- }
-
--static inline unsigned long pmd_pfn(pmd_t pmd)
-+static inline unsigned long pmd_write(pmd_t pmd)
- {
- pte_t pte = __pte(pmd_val(pmd));
-
-- return pte_pfn(pte);
-+ return pte_write(pte);
- }
-
- static inline unsigned long pmd_trans_huge(pmd_t pmd)
-@@ -771,13 +772,15 @@ static inline int pmd_present(pmd_t pmd)
- * the top bits outside of the range of any physical address size we
- * support are clear as well. We also validate the physical itself.
- */
--#define pmd_bad(pmd) ((pmd_val(pmd) & ~PAGE_MASK) || \
-- !__kern_addr_valid(pmd_val(pmd)))
-+#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
-
- #define pud_none(pud) (!pud_val(pud))
-
--#define pud_bad(pud) ((pud_val(pud) & ~PAGE_MASK) || \
-- !__kern_addr_valid(pud_val(pud)))
-+#define pud_bad(pud) (pud_val(pud) & ~PAGE_MASK)
-+
-+#define pgd_none(pgd) (!pgd_val(pgd))
-+
-+#define pgd_bad(pgd) (pgd_val(pgd) & ~PAGE_MASK)
-
- #ifdef CONFIG_TRANSPARENT_HUGEPAGE
- extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
-@@ -815,10 +818,31 @@ static inline unsigned long __pmd_page(pmd_t pmd)
- #define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0UL)
- #define pud_present(pud) (pud_val(pud) != 0U)
- #define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
-+#define pgd_page_vaddr(pgd) \
-+ ((unsigned long) __va(pgd_val(pgd)))
-+#define pgd_present(pgd) (pgd_val(pgd) != 0U)
-+#define pgd_clear(pgdp) (pgd_val(*(pgd)) = 0UL)
-+
-+static inline unsigned long pud_large(pud_t pud)
-+{
-+ pte_t pte = __pte(pud_val(pud));
-+
-+ return pte_val(pte) & _PAGE_PMD_HUGE;
-+}
-+
-+static inline unsigned long pud_pfn(pud_t pud)
-+{
-+ pte_t pte = __pte(pud_val(pud));
-+
-+ return pte_pfn(pte);
-+}
-
- /* Same in both SUN4V and SUN4U. */
- #define pte_none(pte) (!pte_val(pte))
-
-+#define pgd_set(pgdp, pudp) \
-+ (pgd_val(*(pgdp)) = (__pa((unsigned long) (pudp))))
-+
- /* to find an entry in a page-table-directory. */
- #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
- #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
-@@ -826,6 +850,11 @@ static inline unsigned long __pmd_page(pmd_t pmd)
- /* to find an entry in a kernel page-table-directory */
- #define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-+/* Find an entry in the third-level page table.. */
-+#define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
-+#define pud_offset(pgdp, address) \
-+ ((pud_t *) pgd_page_vaddr(*(pgdp)) + pud_index(address))
-+
- /* Find an entry in the second-level page table.. */
- #define pmd_offset(pudp, address) \
- ((pmd_t *) pud_page_vaddr(*(pudp)) + \
-@@ -898,7 +927,6 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
- #endif
-
- extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
--extern pmd_t swapper_low_pmd_dir[PTRS_PER_PMD];
-
- extern void paging_init(void);
- extern unsigned long find_ecache_flush_span(unsigned long size);
-diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
-index 5e35e0517318..acd614668ec1 100644
---- a/arch/sparc/include/asm/setup.h
-+++ b/arch/sparc/include/asm/setup.h
-@@ -24,6 +24,10 @@ static inline int con_is_present(void)
- }
- #endif
-
-+#ifdef CONFIG_SPARC64
-+extern void __init start_early_boot(void);
-+#endif
-+
- extern void sun_do_break(void);
- extern int stop_a_enabled;
- extern int scons_pwroff;
-diff --git a/arch/sparc/include/asm/spitfire.h b/arch/sparc/include/asm/spitfire.h
-index 6b67e50fb9b4..69424d48cbb7 100644
---- a/arch/sparc/include/asm/spitfire.h
-+++ b/arch/sparc/include/asm/spitfire.h
-@@ -45,6 +45,8 @@
- #define SUN4V_CHIP_NIAGARA3 0x03
- #define SUN4V_CHIP_NIAGARA4 0x04
- #define SUN4V_CHIP_NIAGARA5 0x05
-+#define SUN4V_CHIP_SPARC_M6 0x06
-+#define SUN4V_CHIP_SPARC_M7 0x07
- #define SUN4V_CHIP_SPARC64X 0x8a
- #define SUN4V_CHIP_UNKNOWN 0xff
-
-diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
-index a5f01ac6d0f1..cc6275c931a5 100644
---- a/arch/sparc/include/asm/thread_info_64.h
-+++ b/arch/sparc/include/asm/thread_info_64.h
-@@ -63,7 +63,8 @@ struct thread_info {
- struct pt_regs *kern_una_regs;
- unsigned int kern_una_insn;
-
-- unsigned long fpregs[0] __attribute__ ((aligned(64)));
-+ unsigned long fpregs[(7 * 256) / sizeof(unsigned long)]
-+ __attribute__ ((aligned(64)));
- };
-
- #endif /* !(__ASSEMBLY__) */
-@@ -102,6 +103,7 @@ struct thread_info {
- #define FAULT_CODE_ITLB 0x04 /* Miss happened in I-TLB */
- #define FAULT_CODE_WINFIXUP 0x08 /* Miss happened during spill/fill */
- #define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in copy_page */
-+#define FAULT_CODE_BAD_RA 0x20 /* Bad RA for sun4v */
-
- #if PAGE_SHIFT == 13
- #define THREAD_SIZE (2*PAGE_SIZE)
-diff --git a/arch/sparc/include/asm/tsb.h b/arch/sparc/include/asm/tsb.h
-index 90916f955cac..ecb49cfa3be9 100644
---- a/arch/sparc/include/asm/tsb.h
-+++ b/arch/sparc/include/asm/tsb.h
-@@ -133,9 +133,24 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- sub TSB, 0x8, TSB; \
- TSB_STORE(TSB, TAG);
-
-- /* Do a kernel page table walk. Leaves physical PTE pointer in
-- * REG1. Jumps to FAIL_LABEL on early page table walk termination.
-- * VADDR will not be clobbered, but REG2 will.
-+ /* Do a kernel page table walk. Leaves valid PTE value in
-+ * REG1. Jumps to FAIL_LABEL on early page table walk
-+ * termination. VADDR will not be clobbered, but REG2 will.
-+ *
-+ * There are two masks we must apply to propagate bits from
-+ * the virtual address into the PTE physical address field
-+ * when dealing with huge pages. This is because the page
-+ * table boundaries do not match the huge page size(s) the
-+ * hardware supports.
-+ *
-+ * In these cases we propagate the bits that are below the
-+ * page table level where we saw the huge page mapping, but
-+ * are still within the relevant physical bits for the huge
-+ * page size in question. So for PMD mappings (which fall on
-+ * bit 23, for 8MB per PMD) we must propagate bit 22 for a
-+ * 4MB huge page. For huge PUDs (which fall on bit 33, for
-+ * 8GB per PUD), we have to accomodate 256MB and 2GB huge
-+ * pages. So for those we propagate bits 32 to 28.
- */
- #define KERN_PGTABLE_WALK(VADDR, REG1, REG2, FAIL_LABEL) \
- sethi %hi(swapper_pg_dir), REG1; \
-@@ -145,15 +160,40 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- andn REG2, 0x7, REG2; \
- ldx [REG1 + REG2], REG1; \
- brz,pn REG1, FAIL_LABEL; \
-- sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \
-+ sllx VADDR, 64 - (PUD_SHIFT + PUD_BITS), REG2; \
- srlx REG2, 64 - PAGE_SHIFT, REG2; \
- andn REG2, 0x7, REG2; \
- ldxa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \
- brz,pn REG1, FAIL_LABEL; \
-- sllx VADDR, 64 - PMD_SHIFT, REG2; \
-+ sethi %uhi(_PAGE_PUD_HUGE), REG2; \
-+ brz,pn REG1, FAIL_LABEL; \
-+ sllx REG2, 32, REG2; \
-+ andcc REG1, REG2, %g0; \
-+ sethi %hi(0xf8000000), REG2; \
-+ bne,pt %xcc, 697f; \
-+ sllx REG2, 1, REG2; \
-+ sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \
- srlx REG2, 64 - PAGE_SHIFT, REG2; \
- andn REG2, 0x7, REG2; \
-- add REG1, REG2, REG1;
-+ ldxa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \
-+ sethi %uhi(_PAGE_PMD_HUGE), REG2; \
-+ brz,pn REG1, FAIL_LABEL; \
-+ sllx REG2, 32, REG2; \
-+ andcc REG1, REG2, %g0; \
-+ be,pn %xcc, 698f; \
-+ sethi %hi(0x400000), REG2; \
-+697: brgez,pn REG1, FAIL_LABEL; \
-+ andn REG1, REG2, REG1; \
-+ and VADDR, REG2, REG2; \
-+ ba,pt %xcc, 699f; \
-+ or REG1, REG2, REG1; \
-+698: sllx VADDR, 64 - PMD_SHIFT, REG2; \
-+ srlx REG2, 64 - PAGE_SHIFT, REG2; \
-+ andn REG2, 0x7, REG2; \
-+ ldxa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \
-+ brgez,pn REG1, FAIL_LABEL; \
-+ nop; \
-+699:
-
- /* PMD has been loaded into REG1, interpret the value, seeing
- * if it is a HUGE PMD or a normal one. If it is not valid
-@@ -198,6 +238,11 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- andn REG2, 0x7, REG2; \
- ldxa [PHYS_PGD + REG2] ASI_PHYS_USE_EC, REG1; \
- brz,pn REG1, FAIL_LABEL; \
-+ sllx VADDR, 64 - (PUD_SHIFT + PUD_BITS), REG2; \
-+ srlx REG2, 64 - PAGE_SHIFT, REG2; \
-+ andn REG2, 0x7, REG2; \
-+ ldxa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \
-+ brz,pn REG1, FAIL_LABEL; \
- sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \
- srlx REG2, 64 - PAGE_SHIFT, REG2; \
- andn REG2, 0x7, REG2; \
-@@ -246,8 +291,6 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- (KERNEL_TSB_SIZE_BYTES / 16)
- #define KERNEL_TSB4M_NENTRIES 4096
-
--#define KTSB_PHYS_SHIFT 15
--
- /* Do a kernel TSB lookup at tl>0 on VADDR+TAG, branch to OK_LABEL
- * on TSB hit. REG1, REG2, REG3, and REG4 are used as temporaries
- * and the found TTE will be left in REG1. REG3 and REG4 must
-@@ -256,17 +299,15 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- * VADDR and TAG will be preserved and not clobbered by this macro.
- */
- #define KERN_TSB_LOOKUP_TL1(VADDR, TAG, REG1, REG2, REG3, REG4, OK_LABEL) \
--661: sethi %hi(swapper_tsb), REG1; \
-- or REG1, %lo(swapper_tsb), REG1; \
-+661: sethi %uhi(swapper_tsb), REG1; \
-+ sethi %hi(swapper_tsb), REG2; \
-+ or REG1, %ulo(swapper_tsb), REG1; \
-+ or REG2, %lo(swapper_tsb), REG2; \
- .section .swapper_tsb_phys_patch, "ax"; \
- .word 661b; \
- .previous; \
--661: nop; \
-- .section .tsb_ldquad_phys_patch, "ax"; \
-- .word 661b; \
-- sllx REG1, KTSB_PHYS_SHIFT, REG1; \
-- sllx REG1, KTSB_PHYS_SHIFT, REG1; \
-- .previous; \
-+ sllx REG1, 32, REG1; \
-+ or REG1, REG2, REG1; \
- srlx VADDR, PAGE_SHIFT, REG2; \
- and REG2, (KERNEL_TSB_NENTRIES - 1), REG2; \
- sllx REG2, 4, REG2; \
-@@ -281,17 +322,15 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end;
- * we can make use of that for the index computation.
- */
- #define KERN_TSB4M_LOOKUP_TL1(TAG, REG1, REG2, REG3, REG4, OK_LABEL) \
--661: sethi %hi(swapper_4m_tsb), REG1; \
-- or REG1, %lo(swapper_4m_tsb), REG1; \
-+661: sethi %uhi(swapper_4m_tsb), REG1; \
-+ sethi %hi(swapper_4m_tsb), REG2; \
-+ or REG1, %ulo(swapper_4m_tsb), REG1; \
-+ or REG2, %lo(swapper_4m_tsb), REG2; \
- .section .swapper_4m_tsb_phys_patch, "ax"; \
- .word 661b; \
- .previous; \
--661: nop; \
-- .section .tsb_ldquad_phys_patch, "ax"; \
-- .word 661b; \
-- sllx REG1, KTSB_PHYS_SHIFT, REG1; \
-- sllx REG1, KTSB_PHYS_SHIFT, REG1; \
-- .previous; \
-+ sllx REG1, 32, REG1; \
-+ or REG1, REG2, REG1; \
- and TAG, (KERNEL_TSB4M_NENTRIES - 1), REG2; \
- sllx REG2, 4, REG2; \
- add REG1, REG2, REG2; \
-diff --git a/arch/sparc/include/asm/visasm.h b/arch/sparc/include/asm/visasm.h
-index 39ca301920db..11fdf0ef50bb 100644
---- a/arch/sparc/include/asm/visasm.h
-+++ b/arch/sparc/include/asm/visasm.h
-@@ -39,6 +39,14 @@
- 297: wr %o5, FPRS_FEF, %fprs; \
- 298:
-
-+#define VISEntryHalfFast(fail_label) \
-+ rd %fprs, %o5; \
-+ andcc %o5, FPRS_FEF, %g0; \
-+ be,pt %icc, 297f; \
-+ nop; \
-+ ba,a,pt %xcc, fail_label; \
-+297: wr %o5, FPRS_FEF, %fprs;
-+
- #define VISExitHalf \
- wr %o5, 0, %fprs;
-
-diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
-index 5c5125895db8..52e10defedc4 100644
---- a/arch/sparc/kernel/cpu.c
-+++ b/arch/sparc/kernel/cpu.c
-@@ -493,6 +493,18 @@ static void __init sun4v_cpu_probe(void)
- sparc_pmu_type = "niagara5";
- break;
-
-+ case SUN4V_CHIP_SPARC_M6:
-+ sparc_cpu_type = "SPARC-M6";
-+ sparc_fpu_type = "SPARC-M6 integrated FPU";
-+ sparc_pmu_type = "sparc-m6";
-+ break;
-+
-+ case SUN4V_CHIP_SPARC_M7:
-+ sparc_cpu_type = "SPARC-M7";
-+ sparc_fpu_type = "SPARC-M7 integrated FPU";
-+ sparc_pmu_type = "sparc-m7";
-+ break;
-+
- case SUN4V_CHIP_SPARC64X:
- sparc_cpu_type = "SPARC64-X";
- sparc_fpu_type = "SPARC64-X integrated FPU";
-diff --git a/arch/sparc/kernel/cpumap.c b/arch/sparc/kernel/cpumap.c
-index de1c844dfabc..e69ec0e3f155 100644
---- a/arch/sparc/kernel/cpumap.c
-+++ b/arch/sparc/kernel/cpumap.c
-@@ -326,6 +326,8 @@ static int iterate_cpu(struct cpuinfo_tree *t, unsigned int root_index)
- case SUN4V_CHIP_NIAGARA3:
- case SUN4V_CHIP_NIAGARA4:
- case SUN4V_CHIP_NIAGARA5:
-+ case SUN4V_CHIP_SPARC_M6:
-+ case SUN4V_CHIP_SPARC_M7:
- case SUN4V_CHIP_SPARC64X:
- rover_inc_table = niagara_iterate_method;
- break;
-diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
-index dff60abbea01..f87a55d77094 100644
---- a/arch/sparc/kernel/ds.c
-+++ b/arch/sparc/kernel/ds.c
-@@ -1200,14 +1200,14 @@ static int ds_probe(struct vio_dev *vdev, const struct vio_device_id *id)
- ds_cfg.tx_irq = vdev->tx_irq;
- ds_cfg.rx_irq = vdev->rx_irq;
-
-- lp = ldc_alloc(vdev->channel_id, &ds_cfg, dp);
-+ lp = ldc_alloc(vdev->channel_id, &ds_cfg, dp, "DS");
- if (IS_ERR(lp)) {
- err = PTR_ERR(lp);
- goto out_free_ds_states;
- }
- dp->lp = lp;
-
-- err = ldc_bind(lp, "DS");
-+ err = ldc_bind(lp);
- if (err)
- goto out_free_ldc;
-
-diff --git a/arch/sparc/kernel/dtlb_prot.S b/arch/sparc/kernel/dtlb_prot.S
-index b2c2c5be281c..d668ca149e64 100644
---- a/arch/sparc/kernel/dtlb_prot.S
-+++ b/arch/sparc/kernel/dtlb_prot.S
-@@ -24,11 +24,11 @@
- mov TLB_TAG_ACCESS, %g4 ! For reload of vaddr
-
- /* PROT ** ICACHE line 2: More real fault processing */
-+ ldxa [%g4] ASI_DMMU, %g5 ! Put tagaccess in %g5
- bgu,pn %xcc, winfix_trampoline ! Yes, perform winfixup
-- ldxa [%g4] ASI_DMMU, %g5 ! Put tagaccess in %g5
-- ba,pt %xcc, sparc64_realfault_common ! Nope, normal fault
- mov FAULT_CODE_DTLB | FAULT_CODE_WRITE, %g4
-- nop
-+ ba,pt %xcc, sparc64_realfault_common ! Nope, normal fault
-+ nop
- nop
- nop
- nop
-diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
-index 140966fbd303..c88ffb9ee482 100644
---- a/arch/sparc/kernel/entry.h
-+++ b/arch/sparc/kernel/entry.h
-@@ -66,13 +66,10 @@ struct pause_patch_entry {
- extern struct pause_patch_entry __pause_3insn_patch,
- __pause_3insn_patch_end;
-
--extern void __init per_cpu_patch(void);
- extern void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *,
- struct sun4v_1insn_patch_entry *);
- extern void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *,
- struct sun4v_2insn_patch_entry *);
--extern void __init sun4v_patch(void);
--extern void __init boot_cpu_id_too_large(int cpu);
- extern unsigned int dcache_parity_tl1_occurred;
- extern unsigned int icache_parity_tl1_occurred;
-
-diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
-index 452f04fe8da6..3d61fcae7ee3 100644
---- a/arch/sparc/kernel/head_64.S
-+++ b/arch/sparc/kernel/head_64.S
-@@ -427,6 +427,12 @@ sun4v_chip_type:
- cmp %g2, '5'
- be,pt %xcc, 5f
- mov SUN4V_CHIP_NIAGARA5, %g4
-+ cmp %g2, '6'
-+ be,pt %xcc, 5f
-+ mov SUN4V_CHIP_SPARC_M6, %g4
-+ cmp %g2, '7'
-+ be,pt %xcc, 5f
-+ mov SUN4V_CHIP_SPARC_M7, %g4
- ba,pt %xcc, 49f
- nop
-
-@@ -585,6 +591,12 @@ niagara_tlb_fixup:
- cmp %g1, SUN4V_CHIP_NIAGARA5
- be,pt %xcc, niagara4_patch
- nop
-+ cmp %g1, SUN4V_CHIP_SPARC_M6
-+ be,pt %xcc, niagara4_patch
-+ nop
-+ cmp %g1, SUN4V_CHIP_SPARC_M7
-+ be,pt %xcc, niagara4_patch
-+ nop
-
- call generic_patch_copyops
- nop
-@@ -660,14 +672,12 @@ tlb_fixup_done:
- sethi %hi(init_thread_union), %g6
- or %g6, %lo(init_thread_union), %g6
- ldx [%g6 + TI_TASK], %g4
-- mov %sp, %l6
-
- wr %g0, ASI_P, %asi
- mov 1, %g1
- sllx %g1, THREAD_SHIFT, %g1
- sub %g1, (STACKFRAME_SZ + STACK_BIAS), %g1
- add %g6, %g1, %sp
-- mov 0, %fp
-
- /* Set per-cpu pointer initially to zero, this makes
- * the boot-cpu use the in-kernel-image per-cpu areas
-@@ -694,44 +704,14 @@ tlb_fixup_done:
- nop
- #endif
-
-- mov %l6, %o1 ! OpenPROM stack
- call prom_init
- mov %l7, %o0 ! OpenPROM cif handler
-
-- /* Initialize current_thread_info()->cpu as early as possible.
-- * In order to do that accurately we have to patch up the get_cpuid()
-- * assembler sequences. And that, in turn, requires that we know
-- * if we are on a Starfire box or not. While we're here, patch up
-- * the sun4v sequences as well.
-+ /* To create a one-register-window buffer between the kernel's
-+ * initial stack and the last stack frame we use from the firmware,
-+ * do the rest of the boot from a C helper function.
- */
-- call check_if_starfire
-- nop
-- call per_cpu_patch
-- nop
-- call sun4v_patch
-- nop
--
--#ifdef CONFIG_SMP
-- call hard_smp_processor_id
-- nop
-- cmp %o0, NR_CPUS
-- blu,pt %xcc, 1f
-- nop
-- call boot_cpu_id_too_large
-- nop
-- /* Not reached... */
--
--1:
--#else
-- mov 0, %o0
--#endif
-- sth %o0, [%g6 + TI_CPU]
--
-- call prom_init_report
-- nop
--
-- /* Off we go.... */
-- call start_kernel
-+ call start_early_boot
- nop
- /* Not reached... */
-
-diff --git a/arch/sparc/kernel/hvapi.c b/arch/sparc/kernel/hvapi.c
-index c0a2de0fd624..5c55145bfbf0 100644
---- a/arch/sparc/kernel/hvapi.c
-+++ b/arch/sparc/kernel/hvapi.c
-@@ -46,6 +46,7 @@ static struct api_info api_table[] = {
- { .group = HV_GRP_VF_CPU, },
- { .group = HV_GRP_KT_CPU, },
- { .group = HV_GRP_VT_CPU, },
-+ { .group = HV_GRP_T5_CPU, },
- { .group = HV_GRP_DIAG, .flags = FLAG_PRE_API },
- };
-
-diff --git a/arch/sparc/kernel/hvcalls.S b/arch/sparc/kernel/hvcalls.S
-index f3ab509b76a8..caedf8320416 100644
---- a/arch/sparc/kernel/hvcalls.S
-+++ b/arch/sparc/kernel/hvcalls.S
-@@ -821,3 +821,19 @@ ENTRY(sun4v_vt_set_perfreg)
- retl
- nop
- ENDPROC(sun4v_vt_set_perfreg)
-+
-+ENTRY(sun4v_t5_get_perfreg)
-+ mov %o1, %o4
-+ mov HV_FAST_T5_GET_PERFREG, %o5
-+ ta HV_FAST_TRAP
-+ stx %o1, [%o4]
-+ retl
-+ nop
-+ENDPROC(sun4v_t5_get_perfreg)
-+
-+ENTRY(sun4v_t5_set_perfreg)
-+ mov HV_FAST_T5_SET_PERFREG, %o5
-+ ta HV_FAST_TRAP
-+ retl
-+ nop
-+ENDPROC(sun4v_t5_set_perfreg)
-diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S
-index b7ddcdd1dea9..cdbfec299f2f 100644
---- a/arch/sparc/kernel/hvtramp.S
-+++ b/arch/sparc/kernel/hvtramp.S
-@@ -109,7 +109,6 @@ hv_cpu_startup:
- sllx %g5, THREAD_SHIFT, %g5
- sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
- add %g6, %g5, %sp
-- mov 0, %fp
-
- call init_irqwork_curcpu
- nop
-diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
-index e7e215dfa866..c2d81ad62e78 100644
---- a/arch/sparc/kernel/ioport.c
-+++ b/arch/sparc/kernel/ioport.c
-@@ -278,7 +278,8 @@ static void *sbus_alloc_coherent(struct device *dev, size_t len,
- }
-
- order = get_order(len_total);
-- if ((va = __get_free_pages(GFP_KERNEL|__GFP_COMP, order)) == 0)
-+ va = __get_free_pages(gfp, order);
-+ if (va == 0)
- goto err_nopages;
-
- if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == NULL)
-@@ -443,7 +444,7 @@ static void *pci32_alloc_coherent(struct device *dev, size_t len,
- }
-
- order = get_order(len_total);
-- va = (void *) __get_free_pages(GFP_KERNEL, order);
-+ va = (void *) __get_free_pages(gfp, order);
- if (va == NULL) {
- printk("pci_alloc_consistent: no %ld pages\n", len_total>>PAGE_SHIFT);
- goto err_nopages;
-diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
-index 666193f4e8bb..4033c23bdfa6 100644
---- a/arch/sparc/kernel/irq_64.c
-+++ b/arch/sparc/kernel/irq_64.c
-@@ -47,8 +47,6 @@
- #include "cpumap.h"
- #include "kstack.h"
-
--#define NUM_IVECS (IMAP_INR + 1)
--
- struct ino_bucket *ivector_table;
- unsigned long ivector_table_pa;
-
-@@ -107,55 +105,196 @@ static void bucket_set_irq(unsigned long bucket_pa, unsigned int irq)
-
- #define irq_work_pa(__cpu) &(trap_block[(__cpu)].irq_worklist_pa)
-
--static struct {
-- unsigned int dev_handle;
-- unsigned int dev_ino;
-- unsigned int in_use;
--} irq_table[NR_IRQS];
--static DEFINE_SPINLOCK(irq_alloc_lock);
-+static unsigned long hvirq_major __initdata;
-+static int __init early_hvirq_major(char *p)
-+{
-+ int rc = kstrtoul(p, 10, &hvirq_major);
-+
-+ return rc;
-+}
-+early_param("hvirq", early_hvirq_major);
-+
-+static int hv_irq_version;
-+
-+/* Major version 2.0 of HV_GRP_INTR added support for the VIRQ cookie
-+ * based interfaces, but:
-+ *
-+ * 1) Several OSs, Solaris and Linux included, use them even when only
-+ * negotiating version 1.0 (or failing to negotiate at all). So the
-+ * hypervisor has a workaround that provides the VIRQ interfaces even
-+ * when only verion 1.0 of the API is in use.
-+ *
-+ * 2) Second, and more importantly, with major version 2.0 these VIRQ
-+ * interfaces only were actually hooked up for LDC interrupts, even
-+ * though the Hypervisor specification clearly stated:
-+ *
-+ * The new interrupt API functions will be available to a guest
-+ * when it negotiates version 2.0 in the interrupt API group 0x2. When
-+ * a guest negotiates version 2.0, all interrupt sources will only
-+ * support using the cookie interface, and any attempt to use the
-+ * version 1.0 interrupt APIs numbered 0xa0 to 0xa6 will result in the
-+ * ENOTSUPPORTED error being returned.
-+ *
-+ * with an emphasis on "all interrupt sources".
-+ *
-+ * To correct this, major version 3.0 was created which does actually
-+ * support VIRQs for all interrupt sources (not just LDC devices). So
-+ * if we want to move completely over the cookie based VIRQs we must
-+ * negotiate major version 3.0 or later of HV_GRP_INTR.
-+ */
-+static bool sun4v_cookie_only_virqs(void)
-+{
-+ if (hv_irq_version >= 3)
-+ return true;
-+ return false;
-+}
-
--unsigned char irq_alloc(unsigned int dev_handle, unsigned int dev_ino)
-+static void __init irq_init_hv(void)
- {
-- unsigned long flags;
-- unsigned char ent;
-+ unsigned long hv_error, major, minor = 0;
-+
-+ if (tlb_type != hypervisor)
-+ return;
-
-- BUILD_BUG_ON(NR_IRQS >= 256);
-+ if (hvirq_major)
-+ major = hvirq_major;
-+ else
-+ major = 3;
-
-- spin_lock_irqsave(&irq_alloc_lock, flags);
-+ hv_error = sun4v_hvapi_register(HV_GRP_INTR, major, &minor);
-+ if (!hv_error)
-+ hv_irq_version = major;
-+ else
-+ hv_irq_version = 1;
-
-- for (ent = 1; ent < NR_IRQS; ent++) {
-- if (!irq_table[ent].in_use)
-+ pr_info("SUN4V: Using IRQ API major %d, cookie only virqs %s\n",
-+ hv_irq_version,
-+ sun4v_cookie_only_virqs() ? "enabled" : "disabled");
-+}
-+
-+/* This function is for the timer interrupt.*/
-+int __init arch_probe_nr_irqs(void)
-+{
-+ return 1;
-+}
-+
-+#define DEFAULT_NUM_IVECS (0xfffU)
-+static unsigned int nr_ivec = DEFAULT_NUM_IVECS;
-+#define NUM_IVECS (nr_ivec)
-+
-+static unsigned int __init size_nr_ivec(void)
-+{
-+ if (tlb_type == hypervisor) {
-+ switch (sun4v_chip_type) {
-+ /* Athena's devhandle|devino is large.*/
-+ case SUN4V_CHIP_SPARC64X:
-+ nr_ivec = 0xffff;
- break;
-+ }
- }
-- if (ent >= NR_IRQS) {
-- printk(KERN_ERR "IRQ: Out of virtual IRQs.\n");
-- ent = 0;
-- } else {
-- irq_table[ent].dev_handle = dev_handle;
-- irq_table[ent].dev_ino = dev_ino;
-- irq_table[ent].in_use = 1;
-- }
-+ return nr_ivec;
-+}
-+
-+struct irq_handler_data {
-+ union {
-+ struct {
-+ unsigned int dev_handle;
-+ unsigned int dev_ino;
-+ };
-+ unsigned long sysino;
-+ };
-+ struct ino_bucket bucket;
-+ unsigned long iclr;
-+ unsigned long imap;
-+};
-+
-+static inline unsigned int irq_data_to_handle(struct irq_data *data)
-+{
-+ struct irq_handler_data *ihd = data->handler_data;
-+
-+ return ihd->dev_handle;
-+}
-+
-+static inline unsigned int irq_data_to_ino(struct irq_data *data)
-+{
-+ struct irq_handler_data *ihd = data->handler_data;
-
-- spin_unlock_irqrestore(&irq_alloc_lock, flags);
-+ return ihd->dev_ino;
-+}
-+
-+static inline unsigned long irq_data_to_sysino(struct irq_data *data)
-+{
-+ struct irq_handler_data *ihd = data->handler_data;
-
-- return ent;
-+ return ihd->sysino;
- }
-
--#ifdef CONFIG_PCI_MSI
- void irq_free(unsigned int irq)
- {
-- unsigned long flags;
-+ void *data = irq_get_handler_data(irq);
-
-- if (irq >= NR_IRQS)
-- return;
-+ kfree(data);
-+ irq_set_handler_data(irq, NULL);
-+ irq_free_descs(irq, 1);
-+}
-
-- spin_lock_irqsave(&irq_alloc_lock, flags);
-+unsigned int irq_alloc(unsigned int dev_handle, unsigned int dev_ino)
-+{
-+ int irq;
-
-- irq_table[irq].in_use = 0;
-+ irq = __irq_alloc_descs(-1, 1, 1, numa_node_id(), NULL);
-+ if (irq <= 0)
-+ goto out;
-
-- spin_unlock_irqrestore(&irq_alloc_lock, flags);
-+ return irq;
-+out:
-+ return 0;
-+}
-+
-+static unsigned int cookie_exists(u32 devhandle, unsigned int devino)
-+{
-+ unsigned long hv_err, cookie;
-+ struct ino_bucket *bucket;
-+ unsigned int irq = 0U;
-+
-+ hv_err = sun4v_vintr_get_cookie(devhandle, devino, &cookie);
-+ if (hv_err) {
-+ pr_err("HV get cookie failed hv_err = %ld\n", hv_err);
-+ goto out;
-+ }
-+
-+ if (cookie & ((1UL << 63UL))) {
-+ cookie = ~cookie;
-+ bucket = (struct ino_bucket *) __va(cookie);
-+ irq = bucket->__irq;
-+ }
-+out:
-+ return irq;
-+}
-+
-+static unsigned int sysino_exists(u32 devhandle, unsigned int devino)
-+{
-+ unsigned long sysino = sun4v_devino_to_sysino(devhandle, devino);
-+ struct ino_bucket *bucket;
-+ unsigned int irq;
-+
-+ bucket = &ivector_table[sysino];
-+ irq = bucket_get_irq(__pa(bucket));
-+
-+ return irq;
-+}
-+
-+void ack_bad_irq(unsigned int irq)
-+{
-+ pr_crit("BAD IRQ ack %d\n", irq);
-+}
-+
-+void irq_install_pre_handler(int irq,
-+ void (*func)(unsigned int, void *, void *),
-+ void *arg1, void *arg2)
-+{
-+ pr_warn("IRQ pre handler NOT supported.\n");
- }
--#endif
-
- /*
- * /proc/interrupts printing:
-@@ -206,15 +345,6 @@ static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid)
- return tid;
- }
-
--struct irq_handler_data {
-- unsigned long iclr;
-- unsigned long imap;
--
-- void (*pre_handler)(unsigned int, void *, void *);
-- void *arg1;
-- void *arg2;
--};
--
- #ifdef CONFIG_SMP
- static int irq_choose_cpu(unsigned int irq, const struct cpumask *affinity)
- {
-@@ -316,8 +446,8 @@ static void sun4u_irq_eoi(struct irq_data *data)
-
- static void sun4v_irq_enable(struct irq_data *data)
- {
-- unsigned int ino = irq_table[data->irq].dev_ino;
- unsigned long cpuid = irq_choose_cpu(data->irq, data->affinity);
-+ unsigned int ino = irq_data_to_sysino(data);
- int err;
-
- err = sun4v_intr_settarget(ino, cpuid);
-@@ -337,8 +467,8 @@ static void sun4v_irq_enable(struct irq_data *data)
- static int sun4v_set_affinity(struct irq_data *data,
- const struct cpumask *mask, bool force)
- {
-- unsigned int ino = irq_table[data->irq].dev_ino;
- unsigned long cpuid = irq_choose_cpu(data->irq, mask);
-+ unsigned int ino = irq_data_to_sysino(data);
- int err;
-
- err = sun4v_intr_settarget(ino, cpuid);
-@@ -351,7 +481,7 @@ static int sun4v_set_affinity(struct irq_data *data,
-
- static void sun4v_irq_disable(struct irq_data *data)
- {
-- unsigned int ino = irq_table[data->irq].dev_ino;
-+ unsigned int ino = irq_data_to_sysino(data);
- int err;
-
- err = sun4v_intr_setenabled(ino, HV_INTR_DISABLED);
-@@ -362,7 +492,7 @@ static void sun4v_irq_disable(struct irq_data *data)
-
- static void sun4v_irq_eoi(struct irq_data *data)
- {
-- unsigned int ino = irq_table[data->irq].dev_ino;
-+ unsigned int ino = irq_data_to_sysino(data);
- int err;
-
- err = sun4v_intr_setstate(ino, HV_INTR_STATE_IDLE);
-@@ -373,14 +503,13 @@ static void sun4v_irq_eoi(struct irq_data *data)
-
- static void sun4v_virq_enable(struct irq_data *data)
- {
-- unsigned long cpuid, dev_handle, dev_ino;
-+ unsigned long dev_handle = irq_data_to_handle(data);
-+ unsigned long dev_ino = irq_data_to_ino(data);
-+ unsigned long cpuid;
- int err;
-
- cpuid = irq_choose_cpu(data->irq, data->affinity);
-
-- dev_handle = irq_table[data->irq].dev_handle;
-- dev_ino = irq_table[data->irq].dev_ino;
--
- err = sun4v_vintr_set_target(dev_handle, dev_ino, cpuid);
- if (err != HV_EOK)
- printk(KERN_ERR "sun4v_vintr_set_target(%lx,%lx,%lu): "
-@@ -403,14 +532,13 @@ static void sun4v_virq_enable(struct irq_data *data)
- static int sun4v_virt_set_affinity(struct irq_data *data,
- const struct cpumask *mask, bool force)
- {
-- unsigned long cpuid, dev_handle, dev_ino;
-+ unsigned long dev_handle = irq_data_to_handle(data);
-+ unsigned long dev_ino = irq_data_to_ino(data);
-+ unsigned long cpuid;
- int err;
-
- cpuid = irq_choose_cpu(data->irq, mask);
-
-- dev_handle = irq_table[data->irq].dev_handle;
-- dev_ino = irq_table[data->irq].dev_ino;
--
- err = sun4v_vintr_set_target(dev_handle, dev_ino, cpuid);
- if (err != HV_EOK)
- printk(KERN_ERR "sun4v_vintr_set_target(%lx,%lx,%lu): "
-@@ -422,11 +550,10 @@ static int sun4v_virt_set_affinity(struct irq_data *data,
-
- static void sun4v_virq_disable(struct irq_data *data)
- {
-- unsigned long dev_handle, dev_ino;
-+ unsigned long dev_handle = irq_data_to_handle(data);
-+ unsigned long dev_ino = irq_data_to_ino(data);
- int err;
-
-- dev_handle = irq_table[data->irq].dev_handle;
-- dev_ino = irq_table[data->irq].dev_ino;
-
- err = sun4v_vintr_set_valid(dev_handle, dev_ino,
- HV_INTR_DISABLED);
-@@ -438,12 +565,10 @@ static void sun4v_virq_disable(struct irq_data *data)
-
- static void sun4v_virq_eoi(struct irq_data *data)
- {
-- unsigned long dev_handle, dev_ino;
-+ unsigned long dev_handle = irq_data_to_handle(data);
-+ unsigned long dev_ino = irq_data_to_ino(data);
- int err;
-
-- dev_handle = irq_table[data->irq].dev_handle;
-- dev_ino = irq_table[data->irq].dev_ino;
--
- err = sun4v_vintr_set_state(dev_handle, dev_ino,
- HV_INTR_STATE_IDLE);
- if (err != HV_EOK)
-@@ -479,31 +604,10 @@ static struct irq_chip sun4v_virq = {
- .flags = IRQCHIP_EOI_IF_HANDLED,
- };
-
--static void pre_flow_handler(struct irq_data *d)
--{
-- struct irq_handler_data *handler_data = irq_data_get_irq_handler_data(d);
-- unsigned int ino = irq_table[d->irq].dev_ino;
--
-- handler_data->pre_handler(ino, handler_data->arg1, handler_data->arg2);
--}
--
--void irq_install_pre_handler(int irq,
-- void (*func)(unsigned int, void *, void *),
-- void *arg1, void *arg2)
--{
-- struct irq_handler_data *handler_data = irq_get_handler_data(irq);
--
-- handler_data->pre_handler = func;
-- handler_data->arg1 = arg1;
-- handler_data->arg2 = arg2;
--
-- __irq_set_preflow_handler(irq, pre_flow_handler);
--}
--
- unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap)
- {
-- struct ino_bucket *bucket;
- struct irq_handler_data *handler_data;
-+ struct ino_bucket *bucket;
- unsigned int irq;
- int ino;
-
-@@ -537,119 +641,166 @@ out:
- return irq;
- }
-
--static unsigned int sun4v_build_common(unsigned long sysino,
-- struct irq_chip *chip)
-+static unsigned int sun4v_build_common(u32 devhandle, unsigned int devino,
-+ void (*handler_data_init)(struct irq_handler_data *data,
-+ u32 devhandle, unsigned int devino),
-+ struct irq_chip *chip)
- {
-- struct ino_bucket *bucket;
-- struct irq_handler_data *handler_data;
-+ struct irq_handler_data *data;
- unsigned int irq;
-
-- BUG_ON(tlb_type != hypervisor);
-+ irq = irq_alloc(devhandle, devino);
-+ if (!irq)
-+ goto out;
-
-- bucket = &ivector_table[sysino];
-- irq = bucket_get_irq(__pa(bucket));
-- if (!irq) {
-- irq = irq_alloc(0, sysino);
-- bucket_set_irq(__pa(bucket), irq);
-- irq_set_chip_and_handler_name(irq, chip, handle_fasteoi_irq,
-- "IVEC");
-+ data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC);
-+ if (unlikely(!data)) {
-+ pr_err("IRQ handler data allocation failed.\n");
-+ irq_free(irq);
-+ irq = 0;
-+ goto out;
- }
-
-- handler_data = irq_get_handler_data(irq);
-- if (unlikely(handler_data))
-- goto out;
-+ irq_set_handler_data(irq, data);
-+ handler_data_init(data, devhandle, devino);
-+ irq_set_chip_and_handler_name(irq, chip, handle_fasteoi_irq, "IVEC");
-+ data->imap = ~0UL;
-+ data->iclr = ~0UL;
-+out:
-+ return irq;
-+}
-
-- handler_data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC);
-- if (unlikely(!handler_data)) {
-- prom_printf("IRQ: kzalloc(irq_handler_data) failed.\n");
-- prom_halt();
-- }
-- irq_set_handler_data(irq, handler_data);
-+static unsigned long cookie_assign(unsigned int irq, u32 devhandle,
-+ unsigned int devino)
-+{
-+ struct irq_handler_data *ihd = irq_get_handler_data(irq);
-+ unsigned long hv_error, cookie;
-
-- /* Catch accidental accesses to these things. IMAP/ICLR handling
-- * is done by hypervisor calls on sun4v platforms, not by direct
-- * register accesses.
-+ /* handler_irq needs to find the irq. cookie is seen signed in
-+ * sun4v_dev_mondo and treated as a non ivector_table delivery.
- */
-- handler_data->imap = ~0UL;
-- handler_data->iclr = ~0UL;
-+ ihd->bucket.__irq = irq;
-+ cookie = ~__pa(&ihd->bucket);
-
--out:
-- return irq;
-+ hv_error = sun4v_vintr_set_cookie(devhandle, devino, cookie);
-+ if (hv_error)
-+ pr_err("HV vintr set cookie failed = %ld\n", hv_error);
-+
-+ return hv_error;
- }
-
--unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino)
-+static void cookie_handler_data(struct irq_handler_data *data,
-+ u32 devhandle, unsigned int devino)
- {
-- unsigned long sysino = sun4v_devino_to_sysino(devhandle, devino);
-+ data->dev_handle = devhandle;
-+ data->dev_ino = devino;
-+}
-
-- return sun4v_build_common(sysino, &sun4v_irq);
-+static unsigned int cookie_build_irq(u32 devhandle, unsigned int devino,
-+ struct irq_chip *chip)
-+{
-+ unsigned long hv_error;
-+ unsigned int irq;
-+
-+ irq = sun4v_build_common(devhandle, devino, cookie_handler_data, chip);
-+
-+ hv_error = cookie_assign(irq, devhandle, devino);
-+ if (hv_error) {
-+ irq_free(irq);
-+ irq = 0;
-+ }
-+
-+ return irq;
- }
-
--unsigned int sun4v_build_virq(u32 devhandle, unsigned int devino)
-+static unsigned int sun4v_build_cookie(u32 devhandle, unsigned int devino)
- {
-- struct irq_handler_data *handler_data;
-- unsigned long hv_err, cookie;
-- struct ino_bucket *bucket;
- unsigned int irq;
-
-- bucket = kzalloc(sizeof(struct ino_bucket), GFP_ATOMIC);
-- if (unlikely(!bucket))
-- return 0;
-+ irq = cookie_exists(devhandle, devino);
-+ if (irq)
-+ goto out;
-
-- /* The only reference we store to the IRQ bucket is
-- * by physical address which kmemleak can't see, tell
-- * it that this object explicitly is not a leak and
-- * should be scanned.
-- */
-- kmemleak_not_leak(bucket);
-+ irq = cookie_build_irq(devhandle, devino, &sun4v_virq);
-
-- __flush_dcache_range((unsigned long) bucket,
-- ((unsigned long) bucket +
-- sizeof(struct ino_bucket)));
-+out:
-+ return irq;
-+}
-
-- irq = irq_alloc(devhandle, devino);
-+static void sysino_set_bucket(unsigned int irq)
-+{
-+ struct irq_handler_data *ihd = irq_get_handler_data(irq);
-+ struct ino_bucket *bucket;
-+ unsigned long sysino;
-+
-+ sysino = sun4v_devino_to_sysino(ihd->dev_handle, ihd->dev_ino);
-+ BUG_ON(sysino >= nr_ivec);
-+ bucket = &ivector_table[sysino];
- bucket_set_irq(__pa(bucket), irq);
-+}
-
-- irq_set_chip_and_handler_name(irq, &sun4v_virq, handle_fasteoi_irq,
-- "IVEC");
-+static void sysino_handler_data(struct irq_handler_data *data,
-+ u32 devhandle, unsigned int devino)
-+{
-+ unsigned long sysino;
-
-- handler_data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC);
-- if (unlikely(!handler_data))
-- return 0;
-+ sysino = sun4v_devino_to_sysino(devhandle, devino);
-+ data->sysino = sysino;
-+}
-
-- /* In order to make the LDC channel startup sequence easier,
-- * especially wrt. locking, we do not let request_irq() enable
-- * the interrupt.
-- */
-- irq_set_status_flags(irq, IRQ_NOAUTOEN);
-- irq_set_handler_data(irq, handler_data);
-+static unsigned int sysino_build_irq(u32 devhandle, unsigned int devino,
-+ struct irq_chip *chip)
-+{
-+ unsigned int irq;
-
-- /* Catch accidental accesses to these things. IMAP/ICLR handling
-- * is done by hypervisor calls on sun4v platforms, not by direct
-- * register accesses.
-- */
-- handler_data->imap = ~0UL;
-- handler_data->iclr = ~0UL;
-+ irq = sun4v_build_common(devhandle, devino, sysino_handler_data, chip);
-+ if (!irq)
-+ goto out;
-
-- cookie = ~__pa(bucket);
-- hv_err = sun4v_vintr_set_cookie(devhandle, devino, cookie);
-- if (hv_err) {
-- prom_printf("IRQ: Fatal, cannot set cookie for [%x:%x] "
-- "err=%lu\n", devhandle, devino, hv_err);
-- prom_halt();
-- }
-+ sysino_set_bucket(irq);
-+out:
-+ return irq;
-+}
-
-+static int sun4v_build_sysino(u32 devhandle, unsigned int devino)
-+{
-+ int irq;
-+
-+ irq = sysino_exists(devhandle, devino);
-+ if (irq)
-+ goto out;
-+
-+ irq = sysino_build_irq(devhandle, devino, &sun4v_irq);
-+out:
- return irq;
- }
-
--void ack_bad_irq(unsigned int irq)
-+unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino)
- {
-- unsigned int ino = irq_table[irq].dev_ino;
-+ unsigned int irq;
-
-- if (!ino)
-- ino = 0xdeadbeef;
-+ if (sun4v_cookie_only_virqs())
-+ irq = sun4v_build_cookie(devhandle, devino);
-+ else
-+ irq = sun4v_build_sysino(devhandle, devino);
-
-- printk(KERN_CRIT "Unexpected IRQ from ino[%x] irq[%u]\n",
-- ino, irq);
-+ return irq;
-+}
-+
-+unsigned int sun4v_build_virq(u32 devhandle, unsigned int devino)
-+{
-+ int irq;
-+
-+ irq = cookie_build_irq(devhandle, devino, &sun4v_virq);
-+ if (!irq)
-+ goto out;
-+
-+ /* This is borrowed from the original function.
-+ */
-+ irq_set_status_flags(irq, IRQ_NOAUTOEN);
-+
-+out:
-+ return irq;
- }
-
- void *hardirq_stack[NR_CPUS];
-@@ -720,9 +871,12 @@ void fixup_irqs(void)
-
- for (irq = 0; irq < NR_IRQS; irq++) {
- struct irq_desc *desc = irq_to_desc(irq);
-- struct irq_data *data = irq_desc_get_irq_data(desc);
-+ struct irq_data *data;
- unsigned long flags;
-
-+ if (!desc)
-+ continue;
-+ data = irq_desc_get_irq_data(desc);
- raw_spin_lock_irqsave(&desc->lock, flags);
- if (desc->action && !irqd_is_per_cpu(data)) {
- if (data->chip->irq_set_affinity)
-@@ -922,16 +1076,22 @@ static struct irqaction timer_irq_action = {
- .name = "timer",
- };
-
--/* Only invoked on boot processor. */
--void __init init_IRQ(void)
-+static void __init irq_ivector_init(void)
- {
-- unsigned long size;
-+ unsigned long size, order;
-+ unsigned int ivecs;
-
-- map_prom_timers();
-- kill_prom_timer();
-+ /* If we are doing cookie only VIRQs then we do not need the ivector
-+ * table to process interrupts.
-+ */
-+ if (sun4v_cookie_only_virqs())
-+ return;
-
-- size = sizeof(struct ino_bucket) * NUM_IVECS;
-- ivector_table = kzalloc(size, GFP_KERNEL);
-+ ivecs = size_nr_ivec();
-+ size = sizeof(struct ino_bucket) * ivecs;
-+ order = get_order(size);
-+ ivector_table = (struct ino_bucket *)
-+ __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
- if (!ivector_table) {
- prom_printf("Fatal error, cannot allocate ivector_table\n");
- prom_halt();
-@@ -940,6 +1100,15 @@ void __init init_IRQ(void)
- ((unsigned long) ivector_table) + size);
-
- ivector_table_pa = __pa(ivector_table);
-+}
-+
-+/* Only invoked on boot processor.*/
-+void __init init_IRQ(void)
-+{
-+ irq_init_hv();
-+ irq_ivector_init();
-+ map_prom_timers();
-+ kill_prom_timer();
-
- if (tlb_type == hypervisor)
- sun4v_init_mondo_queues();
-diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
-index 605d49204580..ef0d8e9e1210 100644
---- a/arch/sparc/kernel/ktlb.S
-+++ b/arch/sparc/kernel/ktlb.S
-@@ -47,14 +47,6 @@ kvmap_itlb_vmalloc_addr:
- KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath)
-
- TSB_LOCK_TAG(%g1, %g2, %g7)
--
-- /* Load and check PTE. */
-- ldxa [%g5] ASI_PHYS_USE_EC, %g5
-- mov 1, %g7
-- sllx %g7, TSB_TAG_INVALID_BIT, %g7
-- brgez,a,pn %g5, kvmap_itlb_longpath
-- TSB_STORE(%g1, %g7)
--
- TSB_WRITE(%g1, %g5, %g6)
-
- /* fallthrough to TLB load */
-@@ -118,6 +110,12 @@ kvmap_dtlb_obp:
- ba,pt %xcc, kvmap_dtlb_load
- nop
-
-+kvmap_linear_early:
-+ sethi %hi(kern_linear_pte_xor), %g7
-+ ldx [%g7 + %lo(kern_linear_pte_xor)], %g2
-+ ba,pt %xcc, kvmap_dtlb_tsb4m_load
-+ xor %g2, %g4, %g5
-+
- .align 32
- kvmap_dtlb_tsb4m_load:
- TSB_LOCK_TAG(%g1, %g2, %g7)
-@@ -146,105 +144,17 @@ kvmap_dtlb_4v:
- /* Correct TAG_TARGET is already in %g6, check 4mb TSB. */
- KERN_TSB4M_LOOKUP_TL1(%g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load)
- #endif
-- /* TSB entry address left in %g1, lookup linear PTE.
-- * Must preserve %g1 and %g6 (TAG).
-- */
--kvmap_dtlb_tsb4m_miss:
-- /* Clear the PAGE_OFFSET top virtual bits, shift
-- * down to get PFN, and make sure PFN is in range.
-- */
--661: sllx %g4, 0, %g5
-- .section .page_offset_shift_patch, "ax"
-- .word 661b
-- .previous
--
-- /* Check to see if we know about valid memory at the 4MB
-- * chunk this physical address will reside within.
-+ /* Linear mapping TSB lookup failed. Fallthrough to kernel
-+ * page table based lookup.
- */
--661: srlx %g5, MAX_PHYS_ADDRESS_BITS, %g2
-- .section .page_offset_shift_patch, "ax"
-- .word 661b
-- .previous
--
-- brnz,pn %g2, kvmap_dtlb_longpath
-- nop
--
-- /* This unconditional branch and delay-slot nop gets patched
-- * by the sethi sequence once the bitmap is properly setup.
-- */
-- .globl valid_addr_bitmap_insn
--valid_addr_bitmap_insn:
-- ba,pt %xcc, 2f
-- nop
-- .subsection 2
-- .globl valid_addr_bitmap_patch
--valid_addr_bitmap_patch:
-- sethi %hi(sparc64_valid_addr_bitmap), %g7
-- or %g7, %lo(sparc64_valid_addr_bitmap), %g7
-- .previous
--
--661: srlx %g5, ILOG2_4MB, %g2
-- .section .page_offset_shift_patch, "ax"
-- .word 661b
-- .previous
--
-- srlx %g2, 6, %g5
-- and %g2, 63, %g2
-- sllx %g5, 3, %g5
-- ldx [%g7 + %g5], %g5
-- mov 1, %g7
-- sllx %g7, %g2, %g7
-- andcc %g5, %g7, %g0
-- be,pn %xcc, kvmap_dtlb_longpath
--
--2: sethi %hi(kpte_linear_bitmap), %g2
--
-- /* Get the 256MB physical address index. */
--661: sllx %g4, 0, %g5
-- .section .page_offset_shift_patch, "ax"
-- .word 661b
-- .previous
--
-- or %g2, %lo(kpte_linear_bitmap), %g2
--
--661: srlx %g5, ILOG2_256MB, %g5
-- .section .page_offset_shift_patch, "ax"
-- .word 661b
-- .previous
--
-- and %g5, (32 - 1), %g7
--
-- /* Divide by 32 to get the offset into the bitmask. */
-- srlx %g5, 5, %g5
-- add %g7, %g7, %g7
-- sllx %g5, 3, %g5
--
-- /* kern_linear_pte_xor[(mask >> shift) & 3)] */
-- ldx [%g2 + %g5], %g2
-- srlx %g2, %g7, %g7
-- sethi %hi(kern_linear_pte_xor), %g5
-- and %g7, 3, %g7
-- or %g5, %lo(kern_linear_pte_xor), %g5
-- sllx %g7, 3, %g7
-- ldx [%g5 + %g7], %g2
--
- .globl kvmap_linear_patch
- kvmap_linear_patch:
-- ba,pt %xcc, kvmap_dtlb_tsb4m_load
-- xor %g2, %g4, %g5
-+ ba,a,pt %xcc, kvmap_linear_early
-
- kvmap_dtlb_vmalloc_addr:
- KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
-
- TSB_LOCK_TAG(%g1, %g2, %g7)
--
-- /* Load and check PTE. */
-- ldxa [%g5] ASI_PHYS_USE_EC, %g5
-- mov 1, %g7
-- sllx %g7, TSB_TAG_INVALID_BIT, %g7
-- brgez,a,pn %g5, kvmap_dtlb_longpath
-- TSB_STORE(%g1, %g7)
--
- TSB_WRITE(%g1, %g5, %g6)
-
- /* fallthrough to TLB load */
-@@ -276,13 +186,8 @@ kvmap_dtlb_load:
-
- #ifdef CONFIG_SPARSEMEM_VMEMMAP
- kvmap_vmemmap:
-- sub %g4, %g5, %g5
-- srlx %g5, ILOG2_4MB, %g5
-- sethi %hi(vmemmap_table), %g1
-- sllx %g5, 3, %g5
-- or %g1, %lo(vmemmap_table), %g1
-- ba,pt %xcc, kvmap_dtlb_load
-- ldx [%g1 + %g5], %g5
-+ KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
-+ ba,a,pt %xcc, kvmap_dtlb_load
- #endif
-
- kvmap_dtlb_nonlinear:
-@@ -294,8 +199,8 @@ kvmap_dtlb_nonlinear:
-
- #ifdef CONFIG_SPARSEMEM_VMEMMAP
- /* Do not use the TSB for vmemmap. */
-- mov (VMEMMAP_BASE >> 40), %g5
-- sllx %g5, 40, %g5
-+ sethi %hi(VMEMMAP_BASE), %g5
-+ ldx [%g5 + %lo(VMEMMAP_BASE)], %g5
- cmp %g4,%g5
- bgeu,pn %xcc, kvmap_vmemmap
- nop
-@@ -307,8 +212,8 @@ kvmap_dtlb_tsbmiss:
- sethi %hi(MODULES_VADDR), %g5
- cmp %g4, %g5
- blu,pn %xcc, kvmap_dtlb_longpath
-- mov (VMALLOC_END >> 40), %g5
-- sllx %g5, 40, %g5
-+ sethi %hi(VMALLOC_END), %g5
-+ ldx [%g5 + %lo(VMALLOC_END)], %g5
- cmp %g4, %g5
- bgeu,pn %xcc, kvmap_dtlb_longpath
- nop
-diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c
-index 66dacd56bb10..27bb55485472 100644
---- a/arch/sparc/kernel/ldc.c
-+++ b/arch/sparc/kernel/ldc.c
-@@ -1078,7 +1078,8 @@ static void ldc_iommu_release(struct ldc_channel *lp)
-
- struct ldc_channel *ldc_alloc(unsigned long id,
- const struct ldc_channel_config *cfgp,
-- void *event_arg)
-+ void *event_arg,
-+ const char *name)
- {
- struct ldc_channel *lp;
- const struct ldc_mode_ops *mops;
-@@ -1093,6 +1094,8 @@ struct ldc_channel *ldc_alloc(unsigned long id,
- err = -EINVAL;
- if (!cfgp)
- goto out_err;
-+ if (!name)
-+ goto out_err;
-
- switch (cfgp->mode) {
- case LDC_MODE_RAW:
-@@ -1185,6 +1188,21 @@ struct ldc_channel *ldc_alloc(unsigned long id,
-
- INIT_HLIST_HEAD(&lp->mh_list);
-
-+ snprintf(lp->rx_irq_name, LDC_IRQ_NAME_MAX, "%s RX", name);
-+ snprintf(lp->tx_irq_name, LDC_IRQ_NAME_MAX, "%s TX", name);
-+
-+ err = request_irq(lp->cfg.rx_irq, ldc_rx, 0,
-+ lp->rx_irq_name, lp);
-+ if (err)
-+ goto out_free_txq;
-+
-+ err = request_irq(lp->cfg.tx_irq, ldc_tx, 0,
-+ lp->tx_irq_name, lp);
-+ if (err) {
-+ free_irq(lp->cfg.rx_irq, lp);
-+ goto out_free_txq;
-+ }
-+
- return lp;
-
- out_free_txq:
-@@ -1237,31 +1255,14 @@ EXPORT_SYMBOL(ldc_free);
- * state. This does not initiate a handshake, ldc_connect() does
- * that.
- */
--int ldc_bind(struct ldc_channel *lp, const char *name)
-+int ldc_bind(struct ldc_channel *lp)
- {
- unsigned long hv_err, flags;
- int err = -EINVAL;
-
-- if (!name ||
-- (lp->state != LDC_STATE_INIT))
-+ if (lp->state != LDC_STATE_INIT)
- return -EINVAL;
-
-- snprintf(lp->rx_irq_name, LDC_IRQ_NAME_MAX, "%s RX", name);
-- snprintf(lp->tx_irq_name, LDC_IRQ_NAME_MAX, "%s TX", name);
--
-- err = request_irq(lp->cfg.rx_irq, ldc_rx, 0,
-- lp->rx_irq_name, lp);
-- if (err)
-- return err;
--
-- err = request_irq(lp->cfg.tx_irq, ldc_tx, 0,
-- lp->tx_irq_name, lp);
-- if (err) {
-- free_irq(lp->cfg.rx_irq, lp);
-- return err;
-- }
--
--
- spin_lock_irqsave(&lp->lock, flags);
-
- enable_irq(lp->cfg.rx_irq);
-diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c
-index 6479256fd5a4..fce8ab17bcbb 100644
---- a/arch/sparc/kernel/nmi.c
-+++ b/arch/sparc/kernel/nmi.c
-@@ -141,7 +141,6 @@ static inline unsigned int get_nmi_count(int cpu)
-
- static __init void nmi_cpu_busy(void *data)
- {
-- local_irq_enable_in_hardirq();
- while (endflag == 0)
- mb();
- }
-diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
-index 269af58497aa..7e967c8018c8 100644
---- a/arch/sparc/kernel/pcr.c
-+++ b/arch/sparc/kernel/pcr.c
-@@ -191,12 +191,41 @@ static const struct pcr_ops n4_pcr_ops = {
- .pcr_nmi_disable = PCR_N4_PICNPT,
- };
-
-+static u64 n5_pcr_read(unsigned long reg_num)
-+{
-+ unsigned long val;
-+
-+ (void) sun4v_t5_get_perfreg(reg_num, &val);
-+
-+ return val;
-+}
-+
-+static void n5_pcr_write(unsigned long reg_num, u64 val)
-+{
-+ (void) sun4v_t5_set_perfreg(reg_num, val);
-+}
-+
-+static const struct pcr_ops n5_pcr_ops = {
-+ .read_pcr = n5_pcr_read,
-+ .write_pcr = n5_pcr_write,
-+ .read_pic = n4_pic_read,
-+ .write_pic = n4_pic_write,
-+ .nmi_picl_value = n4_picl_value,
-+ .pcr_nmi_enable = (PCR_N4_PICNPT | PCR_N4_STRACE |
-+ PCR_N4_UTRACE | PCR_N4_TOE |
-+ (26 << PCR_N4_SL_SHIFT)),
-+ .pcr_nmi_disable = PCR_N4_PICNPT,
-+};
-+
-+
- static unsigned long perf_hsvc_group;
- static unsigned long perf_hsvc_major;
- static unsigned long perf_hsvc_minor;
-
- static int __init register_perf_hsvc(void)
- {
-+ unsigned long hverror;
-+
- if (tlb_type == hypervisor) {
- switch (sun4v_chip_type) {
- case SUN4V_CHIP_NIAGARA1:
-@@ -215,6 +244,10 @@ static int __init register_perf_hsvc(void)
- perf_hsvc_group = HV_GRP_VT_CPU;
- break;
-
-+ case SUN4V_CHIP_NIAGARA5:
-+ perf_hsvc_group = HV_GRP_T5_CPU;
-+ break;
-+
- default:
- return -ENODEV;
- }
-@@ -222,10 +255,12 @@ static int __init register_perf_hsvc(void)
-
- perf_hsvc_major = 1;
- perf_hsvc_minor = 0;
-- if (sun4v_hvapi_register(perf_hsvc_group,
-- perf_hsvc_major,
-- &perf_hsvc_minor)) {
-- printk("perfmon: Could not register hvapi.\n");
-+ hverror = sun4v_hvapi_register(perf_hsvc_group,
-+ perf_hsvc_major,
-+ &perf_hsvc_minor);
-+ if (hverror) {
-+ pr_err("perfmon: Could not register hvapi(0x%lx).\n",
-+ hverror);
- return -ENODEV;
- }
- }
-@@ -254,6 +289,10 @@ static int __init setup_sun4v_pcr_ops(void)
- pcr_ops = &n4_pcr_ops;
- break;
-
-+ case SUN4V_CHIP_NIAGARA5:
-+ pcr_ops = &n5_pcr_ops;
-+ break;
-+
- default:
- ret = -ENODEV;
- break;
-diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
-index b5c38faa4ead..617b9fe33771 100644
---- a/arch/sparc/kernel/perf_event.c
-+++ b/arch/sparc/kernel/perf_event.c
-@@ -1662,7 +1662,8 @@ static bool __init supported_pmu(void)
- sparc_pmu = &niagara2_pmu;
- return true;
- }
-- if (!strcmp(sparc_pmu_type, "niagara4")) {
-+ if (!strcmp(sparc_pmu_type, "niagara4") ||
-+ !strcmp(sparc_pmu_type, "niagara5")) {
- sparc_pmu = &niagara4_pmu;
- return true;
- }
-@@ -1671,9 +1672,12 @@ static bool __init supported_pmu(void)
-
- int __init init_hw_perf_events(void)
- {
-+ int err;
-+
- pr_info("Performance events: ");
-
-- if (!supported_pmu()) {
-+ err = pcr_arch_init();
-+ if (err || !supported_pmu()) {
- pr_cont("No support for PMU type '%s'\n", sparc_pmu_type);
- return 0;
- }
-@@ -1685,7 +1689,7 @@ int __init init_hw_perf_events(void)
-
- return 0;
- }
--early_initcall(init_hw_perf_events);
-+pure_initcall(init_hw_perf_events);
-
- void perf_callchain_kernel(struct perf_callchain_entry *entry,
- struct pt_regs *regs)
-diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
-index d7b4967f8fa6..c6f7113b6e2f 100644
---- a/arch/sparc/kernel/process_64.c
-+++ b/arch/sparc/kernel/process_64.c
-@@ -306,6 +306,9 @@ static void __global_pmu_self(int this_cpu)
- struct global_pmu_snapshot *pp;
- int i, num;
-
-+ if (!pcr_ops)
-+ return;
-+
- pp = &global_cpu_snapshot[this_cpu].pmu;
-
- num = 1;
-diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
-index 3fdb455e3318..61a519808cb7 100644
---- a/arch/sparc/kernel/setup_64.c
-+++ b/arch/sparc/kernel/setup_64.c
-@@ -30,6 +30,7 @@
- #include
- #include
- #include
-+#include
-
- #include
- #include
-@@ -174,7 +175,7 @@ char reboot_command[COMMAND_LINE_SIZE];
-
- static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
-
--void __init per_cpu_patch(void)
-+static void __init per_cpu_patch(void)
- {
- struct cpuid_patch_entry *p;
- unsigned long ver;
-@@ -266,7 +267,7 @@ void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *start,
- }
- }
-
--void __init sun4v_patch(void)
-+static void __init sun4v_patch(void)
- {
- extern void sun4v_hvapi_init(void);
-
-@@ -335,14 +336,25 @@ static void __init pause_patch(void)
- }
- }
-
--#ifdef CONFIG_SMP
--void __init boot_cpu_id_too_large(int cpu)
-+void __init start_early_boot(void)
- {
-- prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
-- cpu, NR_CPUS);
-- prom_halt();
-+ int cpu;
-+
-+ check_if_starfire();
-+ per_cpu_patch();
-+ sun4v_patch();
-+
-+ cpu = hard_smp_processor_id();
-+ if (cpu >= NR_CPUS) {
-+ prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
-+ cpu, NR_CPUS);
-+ prom_halt();
-+ }
-+ current_thread_info()->cpu = cpu;
-+
-+ prom_init_report();
-+ start_kernel();
- }
--#endif
-
- /* On Ultra, we support all of the v8 capabilities. */
- unsigned long sparc64_elf_hwcap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
-@@ -500,12 +512,16 @@ static void __init init_sparc64_elf_hwcap(void)
- sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
- sun4v_chip_type == SUN4V_CHIP_SPARC64X)
- cap |= HWCAP_SPARC_BLKINIT;
- if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
- sun4v_chip_type == SUN4V_CHIP_SPARC64X)
- cap |= HWCAP_SPARC_N2;
- }
-@@ -533,6 +549,8 @@ static void __init init_sparc64_elf_hwcap(void)
- sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
- sun4v_chip_type == SUN4V_CHIP_SPARC64X)
- cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 |
- AV_SPARC_ASI_BLK_INIT |
-@@ -540,6 +558,8 @@ static void __init init_sparc64_elf_hwcap(void)
- if (sun4v_chip_type == SUN4V_CHIP_NIAGARA3 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA4 ||
- sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
-+ sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
- sun4v_chip_type == SUN4V_CHIP_SPARC64X)
- cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC |
- AV_SPARC_FMAF);
-diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
-index 8416d7fadcce..50c3dd03be31 100644
---- a/arch/sparc/kernel/smp_64.c
-+++ b/arch/sparc/kernel/smp_64.c
-@@ -1395,7 +1395,6 @@ void __cpu_die(unsigned int cpu)
-
- void __init smp_cpus_done(unsigned int max_cpus)
- {
-- pcr_arch_init();
- }
-
- void smp_send_reschedule(int cpu)
-@@ -1480,6 +1479,13 @@ static void __init pcpu_populate_pte(unsigned long addr)
- pud_t *pud;
- pmd_t *pmd;
-
-+ if (pgd_none(*pgd)) {
-+ pud_t *new;
-+
-+ new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
-+ pgd_populate(&init_mm, pgd, new);
-+ }
-+
- pud = pud_offset(pgd, addr);
- if (pud_none(*pud)) {
- pmd_t *new;
-diff --git a/arch/sparc/kernel/sun4v_tlb_miss.S b/arch/sparc/kernel/sun4v_tlb_miss.S
-index e0c09bf85610..6179e19bc9b9 100644
---- a/arch/sparc/kernel/sun4v_tlb_miss.S
-+++ b/arch/sparc/kernel/sun4v_tlb_miss.S
-@@ -195,6 +195,11 @@ sun4v_tsb_miss_common:
- ldx [%g2 + TRAP_PER_CPU_PGD_PADDR], %g7
-
- sun4v_itlb_error:
-+ rdpr %tl, %g1
-+ cmp %g1, 1
-+ ble,pt %icc, sun4v_bad_ra
-+ or %g0, FAULT_CODE_BAD_RA | FAULT_CODE_ITLB, %g1
-+
- sethi %hi(sun4v_err_itlb_vaddr), %g1
- stx %g4, [%g1 + %lo(sun4v_err_itlb_vaddr)]
- sethi %hi(sun4v_err_itlb_ctx), %g1
-@@ -206,15 +211,10 @@ sun4v_itlb_error:
- sethi %hi(sun4v_err_itlb_error), %g1
- stx %o0, [%g1 + %lo(sun4v_err_itlb_error)]
-
-+ sethi %hi(1f), %g7
- rdpr %tl, %g4
-- cmp %g4, 1
-- ble,pt %icc, 1f
-- sethi %hi(2f), %g7
- ba,pt %xcc, etraptl1
-- or %g7, %lo(2f), %g7
--
--1: ba,pt %xcc, etrap
--2: or %g7, %lo(2b), %g7
-+1: or %g7, %lo(1f), %g7
- mov %l4, %o1
- call sun4v_itlb_error_report
- add %sp, PTREGS_OFF, %o0
-@@ -222,6 +222,11 @@ sun4v_itlb_error:
- /* NOTREACHED */
-
- sun4v_dtlb_error:
-+ rdpr %tl, %g1
-+ cmp %g1, 1
-+ ble,pt %icc, sun4v_bad_ra
-+ or %g0, FAULT_CODE_BAD_RA | FAULT_CODE_DTLB, %g1
-+
- sethi %hi(sun4v_err_dtlb_vaddr), %g1
- stx %g4, [%g1 + %lo(sun4v_err_dtlb_vaddr)]
- sethi %hi(sun4v_err_dtlb_ctx), %g1
-@@ -233,21 +238,23 @@ sun4v_dtlb_error:
- sethi %hi(sun4v_err_dtlb_error), %g1
- stx %o0, [%g1 + %lo(sun4v_err_dtlb_error)]
-
-+ sethi %hi(1f), %g7
- rdpr %tl, %g4
-- cmp %g4, 1
-- ble,pt %icc, 1f
-- sethi %hi(2f), %g7
- ba,pt %xcc, etraptl1
-- or %g7, %lo(2f), %g7
--
--1: ba,pt %xcc, etrap
--2: or %g7, %lo(2b), %g7
-+1: or %g7, %lo(1f), %g7
- mov %l4, %o1
- call sun4v_dtlb_error_report
- add %sp, PTREGS_OFF, %o0
-
- /* NOTREACHED */
-
-+sun4v_bad_ra:
-+ or %g0, %g4, %g5
-+ ba,pt %xcc, sparc64_realfault_common
-+ or %g1, %g0, %g4
-+
-+ /* NOTREACHED */
-+
- /* Instruction Access Exception, tl0. */
- sun4v_iacc:
- ldxa [%g0] ASI_SCRATCHPAD, %g2
-diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
-index 737f8cbc7d56..88ede1d53b4c 100644
---- a/arch/sparc/kernel/trampoline_64.S
-+++ b/arch/sparc/kernel/trampoline_64.S
-@@ -109,10 +109,13 @@ startup_continue:
- brnz,pn %g1, 1b
- nop
-
-- sethi %hi(p1275buf), %g2
-- or %g2, %lo(p1275buf), %g2
-- ldx [%g2 + 0x10], %l2
-- add %l2, -(192 + 128), %sp
-+ /* Get onto temporary stack which will be in the locked
-+ * kernel image.
-+ */
-+ sethi %hi(tramp_stack), %g1
-+ or %g1, %lo(tramp_stack), %g1
-+ add %g1, TRAMP_STACK_SIZE, %g1
-+ sub %g1, STACKFRAME_SZ + STACK_BIAS + 256, %sp
- flushw
-
- /* Setup the loop variables:
-@@ -394,7 +397,6 @@ after_lock_tlb:
- sllx %g5, THREAD_SHIFT, %g5
- sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
- add %g6, %g5, %sp
-- mov 0, %fp
-
- rdpr %pstate, %o1
- or %o1, PSTATE_IE, %o1
-diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
-index 4ced92f05358..25d0c7ece9cc 100644
---- a/arch/sparc/kernel/traps_64.c
-+++ b/arch/sparc/kernel/traps_64.c
-@@ -2102,6 +2102,11 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
- atomic_inc(&sun4v_nonresum_oflow_cnt);
- }
-
-+static void sun4v_tlb_error(struct pt_regs *regs)
-+{
-+ die_if_kernel("TLB/TSB error", regs);
-+}
-+
- unsigned long sun4v_err_itlb_vaddr;
- unsigned long sun4v_err_itlb_ctx;
- unsigned long sun4v_err_itlb_pte;
-@@ -2109,8 +2114,7 @@ unsigned long sun4v_err_itlb_error;
-
- void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
- {
-- if (tl > 1)
-- dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
-+ dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
-
- printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
- regs->tpc, tl);
-@@ -2123,7 +2127,7 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
- sun4v_err_itlb_vaddr, sun4v_err_itlb_ctx,
- sun4v_err_itlb_pte, sun4v_err_itlb_error);
-
-- prom_halt();
-+ sun4v_tlb_error(regs);
- }
-
- unsigned long sun4v_err_dtlb_vaddr;
-@@ -2133,8 +2137,7 @@ unsigned long sun4v_err_dtlb_error;
-
- void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
- {
-- if (tl > 1)
-- dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
-+ dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
-
- printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
- regs->tpc, tl);
-@@ -2147,7 +2150,7 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
- sun4v_err_dtlb_vaddr, sun4v_err_dtlb_ctx,
- sun4v_err_dtlb_pte, sun4v_err_dtlb_error);
-
-- prom_halt();
-+ sun4v_tlb_error(regs);
- }
-
- void hypervisor_tlbop_error(unsigned long err, unsigned long op)
-diff --git a/arch/sparc/kernel/tsb.S b/arch/sparc/kernel/tsb.S
-index 14158d40ba76..be98685c14c6 100644
---- a/arch/sparc/kernel/tsb.S
-+++ b/arch/sparc/kernel/tsb.S
-@@ -162,10 +162,10 @@ tsb_miss_page_table_walk_sun4v_fastpath:
- nop
- .previous
-
-- rdpr %tl, %g3
-- cmp %g3, 1
-+ rdpr %tl, %g7
-+ cmp %g7, 1
- bne,pn %xcc, winfix_trampoline
-- nop
-+ mov %g3, %g4
- ba,pt %xcc, etrap
- rd %pc, %g7
- call hugetlb_setup
-diff --git a/arch/sparc/kernel/viohs.c b/arch/sparc/kernel/viohs.c
-index f8e7dd53e1c7..9c5fbd0b8a04 100644
---- a/arch/sparc/kernel/viohs.c
-+++ b/arch/sparc/kernel/viohs.c
-@@ -714,7 +714,7 @@ int vio_ldc_alloc(struct vio_driver_state *vio,
- cfg.tx_irq = vio->vdev->tx_irq;
- cfg.rx_irq = vio->vdev->rx_irq;
-
-- lp = ldc_alloc(vio->vdev->channel_id, &cfg, event_arg);
-+ lp = ldc_alloc(vio->vdev->channel_id, &cfg, event_arg, vio->name);
- if (IS_ERR(lp))
- return PTR_ERR(lp);
-
-@@ -746,7 +746,7 @@ void vio_port_up(struct vio_driver_state *vio)
-
- err = 0;
- if (state == LDC_STATE_INIT) {
-- err = ldc_bind(vio->lp, vio->name);
-+ err = ldc_bind(vio->lp);
- if (err)
- printk(KERN_WARNING "%s: Port %lu bind failed, "
- "err=%d\n",
-diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
-index 932ff90fd760..09243057cb0b 100644
---- a/arch/sparc/kernel/vmlinux.lds.S
-+++ b/arch/sparc/kernel/vmlinux.lds.S
-@@ -35,8 +35,9 @@ jiffies = jiffies_64;
-
- SECTIONS
- {
-- /* swapper_low_pmd_dir is sparc64 only */
-- swapper_low_pmd_dir = 0x0000000000402000;
-+#ifdef CONFIG_SPARC64
-+ swapper_pg_dir = 0x0000000000402000;
-+#endif
- . = INITIAL_ADDRESS;
- .text TEXTSTART :
- {
-@@ -122,11 +123,6 @@ SECTIONS
- *(.swapper_4m_tsb_phys_patch)
- __swapper_4m_tsb_phys_patch_end = .;
- }
-- .page_offset_shift_patch : {
-- __page_offset_shift_patch = .;
-- *(.page_offset_shift_patch)
-- __page_offset_shift_patch_end = .;
-- }
- .popc_3insn_patch : {
- __popc_3insn_patch = .;
- *(.popc_3insn_patch)
-diff --git a/arch/sparc/lib/NG4memcpy.S b/arch/sparc/lib/NG4memcpy.S
-index 9cf2ee01cee3..140527a20e7d 100644
---- a/arch/sparc/lib/NG4memcpy.S
-+++ b/arch/sparc/lib/NG4memcpy.S
-@@ -41,6 +41,10 @@
- #endif
- #endif
-
-+#if !defined(EX_LD) && !defined(EX_ST)
-+#define NON_USER_COPY
-+#endif
-+
- #ifndef EX_LD
- #define EX_LD(x) x
- #endif
-@@ -197,9 +201,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
- mov EX_RETVAL(%o3), %o0
-
- .Llarge_src_unaligned:
-+#ifdef NON_USER_COPY
-+ VISEntryHalfFast(.Lmedium_vis_entry_fail)
-+#else
-+ VISEntryHalf
-+#endif
- andn %o2, 0x3f, %o4
- sub %o2, %o4, %o2
-- VISEntryHalf
- alignaddr %o1, %g0, %g1
- add %o1, %o4, %o1
- EX_LD(LOAD(ldd, %g1 + 0x00, %f0))
-@@ -240,6 +248,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
- nop
- ba,a,pt %icc, .Lmedium_unaligned
-
-+#ifdef NON_USER_COPY
-+.Lmedium_vis_entry_fail:
-+ or %o0, %o1, %g2
-+#endif
- .Lmedium:
- LOAD(prefetch, %o1 + 0x40, #n_reads_strong)
- andcc %g2, 0x7, %g0
-diff --git a/arch/sparc/lib/memset.S b/arch/sparc/lib/memset.S
-index 99c017be8719..f75e6906df14 100644
---- a/arch/sparc/lib/memset.S
-+++ b/arch/sparc/lib/memset.S
-@@ -3,8 +3,9 @@
- * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
- * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
- *
-- * Returns 0, if ok, and number of bytes not yet set if exception
-- * occurs and we were called as clear_user.
-+ * Calls to memset returns initial %o0. Calls to bzero returns 0, if ok, and
-+ * number of bytes not yet set if exception occurs and we were called as
-+ * clear_user.
- */
-
- #include
-@@ -65,6 +66,8 @@ __bzero_begin:
- .globl __memset_start, __memset_end
- __memset_start:
- memset:
-+ mov %o0, %g1
-+ mov 1, %g4
- and %o1, 0xff, %g3
- sll %g3, 8, %g2
- or %g3, %g2, %g3
-@@ -89,6 +92,7 @@ memset:
- sub %o0, %o2, %o0
-
- __bzero:
-+ clr %g4
- mov %g0, %g3
- 1:
- cmp %o1, 7
-@@ -151,8 +155,8 @@ __bzero:
- bne,a 8f
- EX(stb %g3, [%o0], and %o1, 1)
- 8:
-- retl
-- clr %o0
-+ b 0f
-+ nop
- 7:
- be 13b
- orcc %o1, 0, %g0
-@@ -164,6 +168,12 @@ __bzero:
- bne 8b
- EX(stb %g3, [%o0 - 1], add %o1, 1)
- 0:
-+ andcc %g4, 1, %g0
-+ be 5f
-+ nop
-+ retl
-+ mov %g1, %o0
-+5:
- retl
- clr %o0
- __memset_end:
-diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
-index 4ced3fc66130..45a413e4380a 100644
---- a/arch/sparc/mm/fault_64.c
-+++ b/arch/sparc/mm/fault_64.c
-@@ -348,6 +348,9 @@ retry:
- down_read(&mm->mmap_sem);
- }
-
-+ if (fault_code & FAULT_CODE_BAD_RA)
-+ goto do_sigbus;
-+
- vma = find_vma(mm, address);
- if (!vma)
- goto bad_area;
-diff --git a/arch/sparc/mm/gup.c b/arch/sparc/mm/gup.c
-index 1aed0432c64b..ae6ce383d4df 100644
---- a/arch/sparc/mm/gup.c
-+++ b/arch/sparc/mm/gup.c
-@@ -160,6 +160,36 @@ static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
- return 1;
- }
-
-+int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
-+ struct page **pages)
-+{
-+ struct mm_struct *mm = current->mm;
-+ unsigned long addr, len, end;
-+ unsigned long next, flags;
-+ pgd_t *pgdp;
-+ int nr = 0;
-+
-+ start &= PAGE_MASK;
-+ addr = start;
-+ len = (unsigned long) nr_pages << PAGE_SHIFT;
-+ end = start + len;
-+
-+ local_irq_save(flags);
-+ pgdp = pgd_offset(mm, addr);
-+ do {
-+ pgd_t pgd = *pgdp;
-+
-+ next = pgd_addr_end(addr, end);
-+ if (pgd_none(pgd))
-+ break;
-+ if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
-+ break;
-+ } while (pgdp++, addr = next, addr != end);
-+ local_irq_restore(flags);
-+
-+ return nr;
-+}
-+
- int get_user_pages_fast(unsigned long start, int nr_pages, int write,
- struct page **pages)
- {
-diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
-index 96862241b342..34506f292533 100644
---- a/arch/sparc/mm/init_64.c
-+++ b/arch/sparc/mm/init_64.c
-@@ -73,7 +73,6 @@ unsigned long kern_linear_pte_xor[4] __read_mostly;
- * 'cpu' properties, but we need to have this table setup before the
- * MDESC is initialized.
- */
--unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
-
- #ifndef CONFIG_DEBUG_PAGEALLOC
- /* A special kernel TSB for 4MB, 256MB, 2GB and 16GB linear mappings.
-@@ -82,10 +81,11 @@ unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
- */
- extern struct tsb swapper_4m_tsb[KERNEL_TSB4M_NENTRIES];
- #endif
-+extern struct tsb swapper_tsb[KERNEL_TSB_NENTRIES];
-
- static unsigned long cpu_pgsz_mask;
-
--#define MAX_BANKS 32
-+#define MAX_BANKS 1024
-
- static struct linux_prom64_registers pavail[MAX_BANKS];
- static int pavail_ents;
-@@ -163,10 +163,6 @@ static void __init read_obp_memory(const char *property,
- cmp_p64, NULL);
- }
-
--unsigned long sparc64_valid_addr_bitmap[VALID_ADDR_BITMAP_BYTES /
-- sizeof(unsigned long)];
--EXPORT_SYMBOL(sparc64_valid_addr_bitmap);
--
- /* Kernel physical address base and size in bytes. */
- unsigned long kern_base __read_mostly;
- unsigned long kern_size __read_mostly;
-@@ -838,7 +834,10 @@ static int find_node(unsigned long addr)
- if ((addr & p->mask) == p->val)
- return i;
- }
-- return -1;
-+ /* The following condition has been observed on LDOM guests.*/
-+ WARN_ONCE(1, "find_node: A physical address doesn't match a NUMA node"
-+ " rule. Some physical memory will be owned by node 0.");
-+ return 0;
- }
-
- static u64 memblock_nid_range(u64 start, u64 end, int *nid)
-@@ -1360,9 +1359,144 @@ static unsigned long __init bootmem_init(unsigned long phys_base)
- static struct linux_prom64_registers pall[MAX_BANKS] __initdata;
- static int pall_ents __initdata;
-
--#ifdef CONFIG_DEBUG_PAGEALLOC
-+static unsigned long max_phys_bits = 40;
-+
-+bool kern_addr_valid(unsigned long addr)
-+{
-+ pgd_t *pgd;
-+ pud_t *pud;
-+ pmd_t *pmd;
-+ pte_t *pte;
-+
-+ if ((long)addr < 0L) {
-+ unsigned long pa = __pa(addr);
-+
-+ if ((addr >> max_phys_bits) != 0UL)
-+ return false;
-+
-+ return pfn_valid(pa >> PAGE_SHIFT);
-+ }
-+
-+ if (addr >= (unsigned long) KERNBASE &&
-+ addr < (unsigned long)&_end)
-+ return true;
-+
-+ pgd = pgd_offset_k(addr);
-+ if (pgd_none(*pgd))
-+ return 0;
-+
-+ pud = pud_offset(pgd, addr);
-+ if (pud_none(*pud))
-+ return 0;
-+
-+ if (pud_large(*pud))
-+ return pfn_valid(pud_pfn(*pud));
-+
-+ pmd = pmd_offset(pud, addr);
-+ if (pmd_none(*pmd))
-+ return 0;
-+
-+ if (pmd_large(*pmd))
-+ return pfn_valid(pmd_pfn(*pmd));
-+
-+ pte = pte_offset_kernel(pmd, addr);
-+ if (pte_none(*pte))
-+ return 0;
-+
-+ return pfn_valid(pte_pfn(*pte));
-+}
-+EXPORT_SYMBOL(kern_addr_valid);
-+
-+static unsigned long __ref kernel_map_hugepud(unsigned long vstart,
-+ unsigned long vend,
-+ pud_t *pud)
-+{
-+ const unsigned long mask16gb = (1UL << 34) - 1UL;
-+ u64 pte_val = vstart;
-+
-+ /* Each PUD is 8GB */
-+ if ((vstart & mask16gb) ||
-+ (vend - vstart <= mask16gb)) {
-+ pte_val ^= kern_linear_pte_xor[2];
-+ pud_val(*pud) = pte_val | _PAGE_PUD_HUGE;
-+
-+ return vstart + PUD_SIZE;
-+ }
-+
-+ pte_val ^= kern_linear_pte_xor[3];
-+ pte_val |= _PAGE_PUD_HUGE;
-+
-+ vend = vstart + mask16gb + 1UL;
-+ while (vstart < vend) {
-+ pud_val(*pud) = pte_val;
-+
-+ pte_val += PUD_SIZE;
-+ vstart += PUD_SIZE;
-+ pud++;
-+ }
-+ return vstart;
-+}
-+
-+static bool kernel_can_map_hugepud(unsigned long vstart, unsigned long vend,
-+ bool guard)
-+{
-+ if (guard && !(vstart & ~PUD_MASK) && (vend - vstart) >= PUD_SIZE)
-+ return true;
-+
-+ return false;
-+}
-+
-+static unsigned long __ref kernel_map_hugepmd(unsigned long vstart,
-+ unsigned long vend,
-+ pmd_t *pmd)
-+{
-+ const unsigned long mask256mb = (1UL << 28) - 1UL;
-+ const unsigned long mask2gb = (1UL << 31) - 1UL;
-+ u64 pte_val = vstart;
-+
-+ /* Each PMD is 8MB */
-+ if ((vstart & mask256mb) ||
-+ (vend - vstart <= mask256mb)) {
-+ pte_val ^= kern_linear_pte_xor[0];
-+ pmd_val(*pmd) = pte_val | _PAGE_PMD_HUGE;
-+
-+ return vstart + PMD_SIZE;
-+ }
-+
-+ if ((vstart & mask2gb) ||
-+ (vend - vstart <= mask2gb)) {
-+ pte_val ^= kern_linear_pte_xor[1];
-+ pte_val |= _PAGE_PMD_HUGE;
-+ vend = vstart + mask256mb + 1UL;
-+ } else {
-+ pte_val ^= kern_linear_pte_xor[2];
-+ pte_val |= _PAGE_PMD_HUGE;
-+ vend = vstart + mask2gb + 1UL;
-+ }
-+
-+ while (vstart < vend) {
-+ pmd_val(*pmd) = pte_val;
-+
-+ pte_val += PMD_SIZE;
-+ vstart += PMD_SIZE;
-+ pmd++;
-+ }
-+
-+ return vstart;
-+}
-+
-+static bool kernel_can_map_hugepmd(unsigned long vstart, unsigned long vend,
-+ bool guard)
-+{
-+ if (guard && !(vstart & ~PMD_MASK) && (vend - vstart) >= PMD_SIZE)
-+ return true;
-+
-+ return false;
-+}
-+
- static unsigned long __ref kernel_map_range(unsigned long pstart,
-- unsigned long pend, pgprot_t prot)
-+ unsigned long pend, pgprot_t prot,
-+ bool use_huge)
- {
- unsigned long vstart = PAGE_OFFSET + pstart;
- unsigned long vend = PAGE_OFFSET + pend;
-@@ -1381,19 +1515,34 @@ static unsigned long __ref kernel_map_range(unsigned long pstart,
- pmd_t *pmd;
- pte_t *pte;
-
-+ if (pgd_none(*pgd)) {
-+ pud_t *new;
-+
-+ new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
-+ alloc_bytes += PAGE_SIZE;
-+ pgd_populate(&init_mm, pgd, new);
-+ }
- pud = pud_offset(pgd, vstart);
- if (pud_none(*pud)) {
- pmd_t *new;
-
-+ if (kernel_can_map_hugepud(vstart, vend, use_huge)) {
-+ vstart = kernel_map_hugepud(vstart, vend, pud);
-+ continue;
-+ }
- new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
- alloc_bytes += PAGE_SIZE;
- pud_populate(&init_mm, pud, new);
- }
-
- pmd = pmd_offset(pud, vstart);
-- if (!pmd_present(*pmd)) {
-+ if (pmd_none(*pmd)) {
- pte_t *new;
-
-+ if (kernel_can_map_hugepmd(vstart, vend, use_huge)) {
-+ vstart = kernel_map_hugepmd(vstart, vend, pmd);
-+ continue;
-+ }
- new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
- alloc_bytes += PAGE_SIZE;
- pmd_populate_kernel(&init_mm, pmd, new);
-@@ -1416,100 +1565,34 @@ static unsigned long __ref kernel_map_range(unsigned long pstart,
- return alloc_bytes;
- }
-
--extern unsigned int kvmap_linear_patch[1];
--#endif /* CONFIG_DEBUG_PAGEALLOC */
--
--static void __init kpte_set_val(unsigned long index, unsigned long val)
-+static void __init flush_all_kernel_tsbs(void)
- {
-- unsigned long *ptr = kpte_linear_bitmap;
--
-- val <<= ((index % (BITS_PER_LONG / 2)) * 2);
-- ptr += (index / (BITS_PER_LONG / 2));
--
-- *ptr |= val;
--}
--
--static const unsigned long kpte_shift_min = 28; /* 256MB */
--static const unsigned long kpte_shift_max = 34; /* 16GB */
--static const unsigned long kpte_shift_incr = 3;
--
--static unsigned long kpte_mark_using_shift(unsigned long start, unsigned long end,
-- unsigned long shift)
--{
-- unsigned long size = (1UL << shift);
-- unsigned long mask = (size - 1UL);
-- unsigned long remains = end - start;
-- unsigned long val;
--
-- if (remains < size || (start & mask))
-- return start;
--
-- /* VAL maps:
-- *
-- * shift 28 --> kern_linear_pte_xor index 1
-- * shift 31 --> kern_linear_pte_xor index 2
-- * shift 34 --> kern_linear_pte_xor index 3
-- */
-- val = ((shift - kpte_shift_min) / kpte_shift_incr) + 1;
--
-- remains &= ~mask;
-- if (shift != kpte_shift_max)
-- remains = size;
--
-- while (remains) {
-- unsigned long index = start >> kpte_shift_min;
-+ int i;
-
-- kpte_set_val(index, val);
-+ for (i = 0; i < KERNEL_TSB_NENTRIES; i++) {
-+ struct tsb *ent = &swapper_tsb[i];
-
-- start += 1UL << kpte_shift_min;
-- remains -= 1UL << kpte_shift_min;
-+ ent->tag = (1UL << TSB_TAG_INVALID_BIT);
- }
-+#ifndef CONFIG_DEBUG_PAGEALLOC
-+ for (i = 0; i < KERNEL_TSB4M_NENTRIES; i++) {
-+ struct tsb *ent = &swapper_4m_tsb[i];
-
-- return start;
--}
--
--static void __init mark_kpte_bitmap(unsigned long start, unsigned long end)
--{
-- unsigned long smallest_size, smallest_mask;
-- unsigned long s;
--
-- smallest_size = (1UL << kpte_shift_min);
-- smallest_mask = (smallest_size - 1UL);
--
-- while (start < end) {
-- unsigned long orig_start = start;
--
-- for (s = kpte_shift_max; s >= kpte_shift_min; s -= kpte_shift_incr) {
-- start = kpte_mark_using_shift(start, end, s);
--
-- if (start != orig_start)
-- break;
-- }
--
-- if (start == orig_start)
-- start = (start + smallest_size) & ~smallest_mask;
-+ ent->tag = (1UL << TSB_TAG_INVALID_BIT);
- }
-+#endif
- }
-
--static void __init init_kpte_bitmap(void)
--{
-- unsigned long i;
--
-- for (i = 0; i < pall_ents; i++) {
-- unsigned long phys_start, phys_end;
--
-- phys_start = pall[i].phys_addr;
-- phys_end = phys_start + pall[i].reg_size;
--
-- mark_kpte_bitmap(phys_start, phys_end);
-- }
--}
-+extern unsigned int kvmap_linear_patch[1];
-
- static void __init kernel_physical_mapping_init(void)
- {
--#ifdef CONFIG_DEBUG_PAGEALLOC
- unsigned long i, mem_alloced = 0UL;
-+ bool use_huge = true;
-
-+#ifdef CONFIG_DEBUG_PAGEALLOC
-+ use_huge = false;
-+#endif
- for (i = 0; i < pall_ents; i++) {
- unsigned long phys_start, phys_end;
-
-@@ -1517,7 +1600,7 @@ static void __init kernel_physical_mapping_init(void)
- phys_end = phys_start + pall[i].reg_size;
-
- mem_alloced += kernel_map_range(phys_start, phys_end,
-- PAGE_KERNEL);
-+ PAGE_KERNEL, use_huge);
- }
-
- printk("Allocated %ld bytes for kernel page tables.\n",
-@@ -1526,8 +1609,9 @@ static void __init kernel_physical_mapping_init(void)
- kvmap_linear_patch[0] = 0x01000000; /* nop */
- flushi(&kvmap_linear_patch[0]);
-
-+ flush_all_kernel_tsbs();
-+
- __flush_tlb_all();
--#endif
- }
-
- #ifdef CONFIG_DEBUG_PAGEALLOC
-@@ -1537,7 +1621,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
- unsigned long phys_end = phys_start + (numpages * PAGE_SIZE);
-
- kernel_map_range(phys_start, phys_end,
-- (enable ? PAGE_KERNEL : __pgprot(0)));
-+ (enable ? PAGE_KERNEL : __pgprot(0)), false);
-
- flush_tsb_kernel_range(PAGE_OFFSET + phys_start,
- PAGE_OFFSET + phys_end);
-@@ -1565,76 +1649,56 @@ unsigned long __init find_ecache_flush_span(unsigned long size)
- unsigned long PAGE_OFFSET;
- EXPORT_SYMBOL(PAGE_OFFSET);
-
--static void __init page_offset_shift_patch_one(unsigned int *insn, unsigned long phys_bits)
--{
-- unsigned long final_shift;
-- unsigned int val = *insn;
-- unsigned int cnt;
--
-- /* We are patching in ilog2(max_supported_phys_address), and
-- * we are doing so in a manner similar to a relocation addend.
-- * That is, we are adding the shift value to whatever value
-- * is in the shift instruction count field already.
-- */
-- cnt = (val & 0x3f);
-- val &= ~0x3f;
--
-- /* If we are trying to shift >= 64 bits, clear the destination
-- * register. This can happen when phys_bits ends up being equal
-- * to MAX_PHYS_ADDRESS_BITS.
-- */
-- final_shift = (cnt + (64 - phys_bits));
-- if (final_shift >= 64) {
-- unsigned int rd = (val >> 25) & 0x1f;
--
-- val = 0x80100000 | (rd << 25);
-- } else {
-- val |= final_shift;
-- }
-- *insn = val;
--
-- __asm__ __volatile__("flush %0"
-- : /* no outputs */
-- : "r" (insn));
--}
--
--static void __init page_offset_shift_patch(unsigned long phys_bits)
--{
-- extern unsigned int __page_offset_shift_patch;
-- extern unsigned int __page_offset_shift_patch_end;
-- unsigned int *p;
--
-- p = &__page_offset_shift_patch;
-- while (p < &__page_offset_shift_patch_end) {
-- unsigned int *insn = (unsigned int *)(unsigned long)*p;
-+unsigned long VMALLOC_END = 0x0000010000000000UL;
-+EXPORT_SYMBOL(VMALLOC_END);
-
-- page_offset_shift_patch_one(insn, phys_bits);
--
-- p++;
-- }
--}
-+unsigned long sparc64_va_hole_top = 0xfffff80000000000UL;
-+unsigned long sparc64_va_hole_bottom = 0x0000080000000000UL;
-
- static void __init setup_page_offset(void)
- {
-- unsigned long max_phys_bits = 40;
--
- if (tlb_type == cheetah || tlb_type == cheetah_plus) {
-+ /* Cheetah/Panther support a full 64-bit virtual
-+ * address, so we can use all that our page tables
-+ * support.
-+ */
-+ sparc64_va_hole_top = 0xfff0000000000000UL;
-+ sparc64_va_hole_bottom = 0x0010000000000000UL;
-+
- max_phys_bits = 42;
- } else if (tlb_type == hypervisor) {
- switch (sun4v_chip_type) {
- case SUN4V_CHIP_NIAGARA1:
- case SUN4V_CHIP_NIAGARA2:
-+ /* T1 and T2 support 48-bit virtual addresses. */
-+ sparc64_va_hole_top = 0xffff800000000000UL;
-+ sparc64_va_hole_bottom = 0x0000800000000000UL;
-+
- max_phys_bits = 39;
- break;
- case SUN4V_CHIP_NIAGARA3:
-+ /* T3 supports 48-bit virtual addresses. */
-+ sparc64_va_hole_top = 0xffff800000000000UL;
-+ sparc64_va_hole_bottom = 0x0000800000000000UL;
-+
- max_phys_bits = 43;
- break;
- case SUN4V_CHIP_NIAGARA4:
- case SUN4V_CHIP_NIAGARA5:
- case SUN4V_CHIP_SPARC64X:
-- default:
-+ case SUN4V_CHIP_SPARC_M6:
-+ /* T4 and later support 52-bit virtual addresses. */
-+ sparc64_va_hole_top = 0xfff8000000000000UL;
-+ sparc64_va_hole_bottom = 0x0008000000000000UL;
- max_phys_bits = 47;
- break;
-+ case SUN4V_CHIP_SPARC_M7:
-+ default:
-+ /* M7 and later support 52-bit virtual addresses. */
-+ sparc64_va_hole_top = 0xfff8000000000000UL;
-+ sparc64_va_hole_bottom = 0x0008000000000000UL;
-+ max_phys_bits = 49;
-+ break;
- }
- }
-
-@@ -1644,12 +1708,16 @@ static void __init setup_page_offset(void)
- prom_halt();
- }
-
-- PAGE_OFFSET = PAGE_OFFSET_BY_BITS(max_phys_bits);
-+ PAGE_OFFSET = sparc64_va_hole_top;
-+ VMALLOC_END = ((sparc64_va_hole_bottom >> 1) +
-+ (sparc64_va_hole_bottom >> 2));
-
-- pr_info("PAGE_OFFSET is 0x%016lx (max_phys_bits == %lu)\n",
-+ pr_info("MM: PAGE_OFFSET is 0x%016lx (max_phys_bits == %lu)\n",
- PAGE_OFFSET, max_phys_bits);
--
-- page_offset_shift_patch(max_phys_bits);
-+ pr_info("MM: VMALLOC [0x%016lx --> 0x%016lx]\n",
-+ VMALLOC_START, VMALLOC_END);
-+ pr_info("MM: VMEMMAP [0x%016lx --> 0x%016lx]\n",
-+ VMEMMAP_BASE, VMEMMAP_BASE << 1);
- }
-
- static void __init tsb_phys_patch(void)
-@@ -1694,21 +1762,42 @@ static void __init tsb_phys_patch(void)
- #define NUM_KTSB_DESCR 1
- #endif
- static struct hv_tsb_descr ktsb_descr[NUM_KTSB_DESCR];
--extern struct tsb swapper_tsb[KERNEL_TSB_NENTRIES];
-+
-+/* The swapper TSBs are loaded with a base sequence of:
-+ *
-+ * sethi %uhi(SYMBOL), REG1
-+ * sethi %hi(SYMBOL), REG2
-+ * or REG1, %ulo(SYMBOL), REG1
-+ * or REG2, %lo(SYMBOL), REG2
-+ * sllx REG1, 32, REG1
-+ * or REG1, REG2, REG1
-+ *
-+ * When we use physical addressing for the TSB accesses, we patch the
-+ * first four instructions in the above sequence.
-+ */
-
- static void patch_one_ktsb_phys(unsigned int *start, unsigned int *end, unsigned long pa)
- {
-- pa >>= KTSB_PHYS_SHIFT;
-+ unsigned long high_bits, low_bits;
-+
-+ high_bits = (pa >> 32) & 0xffffffff;
-+ low_bits = (pa >> 0) & 0xffffffff;
-
- while (start < end) {
- unsigned int *ia = (unsigned int *)(unsigned long)*start;
-
-- ia[0] = (ia[0] & ~0x3fffff) | (pa >> 10);
-+ ia[0] = (ia[0] & ~0x3fffff) | (high_bits >> 10);
- __asm__ __volatile__("flush %0" : : "r" (ia));
-
-- ia[1] = (ia[1] & ~0x3ff) | (pa & 0x3ff);
-+ ia[1] = (ia[1] & ~0x3fffff) | (low_bits >> 10);
- __asm__ __volatile__("flush %0" : : "r" (ia + 1));
-
-+ ia[2] = (ia[2] & ~0x1fff) | (high_bits & 0x3ff);
-+ __asm__ __volatile__("flush %0" : : "r" (ia + 2));
-+
-+ ia[3] = (ia[3] & ~0x1fff) | (low_bits & 0x3ff);
-+ __asm__ __volatile__("flush %0" : : "r" (ia + 3));
-+
- start++;
- }
- }
-@@ -1847,7 +1936,6 @@ static void __init sun4v_linear_pte_xor_finalize(void)
- /* paging_init() sets up the page tables */
-
- static unsigned long last_valid_pfn;
--pgd_t swapper_pg_dir[PTRS_PER_PGD];
-
- static void sun4u_pgprot_init(void);
- static void sun4v_pgprot_init(void);
-@@ -1950,16 +2038,10 @@ void __init paging_init(void)
- */
- init_mm.pgd += ((shift) / (sizeof(pgd_t)));
-
-- memset(swapper_low_pmd_dir, 0, sizeof(swapper_low_pmd_dir));
-+ memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir));
-
-- /* Now can init the kernel/bad page tables. */
-- pud_set(pud_offset(&swapper_pg_dir[0], 0),
-- swapper_low_pmd_dir + (shift / sizeof(pgd_t)));
--
- inherit_prom_mappings();
-
-- init_kpte_bitmap();
--
- /* Ok, we can use our TLB miss and window trap handlers safely. */
- setup_tba();
-
-@@ -2066,70 +2148,6 @@ int page_in_phys_avail(unsigned long paddr)
- return 0;
- }
-
--static struct linux_prom64_registers pavail_rescan[MAX_BANKS] __initdata;
--static int pavail_rescan_ents __initdata;
--
--/* Certain OBP calls, such as fetching "available" properties, can
-- * claim physical memory. So, along with initializing the valid
-- * address bitmap, what we do here is refetch the physical available
-- * memory list again, and make sure it provides at least as much
-- * memory as 'pavail' does.
-- */
--static void __init setup_valid_addr_bitmap_from_pavail(unsigned long *bitmap)
--{
-- int i;
--
-- read_obp_memory("available", &pavail_rescan[0], &pavail_rescan_ents);
--
-- for (i = 0; i < pavail_ents; i++) {
-- unsigned long old_start, old_end;
--
-- old_start = pavail[i].phys_addr;
-- old_end = old_start + pavail[i].reg_size;
-- while (old_start < old_end) {
-- int n;
--
-- for (n = 0; n < pavail_rescan_ents; n++) {
-- unsigned long new_start, new_end;
--
-- new_start = pavail_rescan[n].phys_addr;
-- new_end = new_start +
-- pavail_rescan[n].reg_size;
--
-- if (new_start <= old_start &&
-- new_end >= (old_start + PAGE_SIZE)) {
-- set_bit(old_start >> ILOG2_4MB, bitmap);
-- goto do_next_page;
-- }
-- }
--
-- prom_printf("mem_init: Lost memory in pavail\n");
-- prom_printf("mem_init: OLD start[%lx] size[%lx]\n",
-- pavail[i].phys_addr,
-- pavail[i].reg_size);
-- prom_printf("mem_init: NEW start[%lx] size[%lx]\n",
-- pavail_rescan[i].phys_addr,
-- pavail_rescan[i].reg_size);
-- prom_printf("mem_init: Cannot continue, aborting.\n");
-- prom_halt();
--
-- do_next_page:
-- old_start += PAGE_SIZE;
-- }
-- }
--}
--
--static void __init patch_tlb_miss_handler_bitmap(void)
--{
-- extern unsigned int valid_addr_bitmap_insn[];
-- extern unsigned int valid_addr_bitmap_patch[];
--
-- valid_addr_bitmap_insn[1] = valid_addr_bitmap_patch[1];
-- mb();
-- valid_addr_bitmap_insn[0] = valid_addr_bitmap_patch[0];
-- flushi(&valid_addr_bitmap_insn[0]);
--}
--
- static void __init register_page_bootmem_info(void)
- {
- #ifdef CONFIG_NEED_MULTIPLE_NODES
-@@ -2142,18 +2160,6 @@ static void __init register_page_bootmem_info(void)
- }
- void __init mem_init(void)
- {
-- unsigned long addr, last;
--
-- addr = PAGE_OFFSET + kern_base;
-- last = PAGE_ALIGN(kern_size) + addr;
-- while (addr < last) {
-- set_bit(__pa(addr) >> ILOG2_4MB, sparc64_valid_addr_bitmap);
-- addr += PAGE_SIZE;
-- }
--
-- setup_valid_addr_bitmap_from_pavail(sparc64_valid_addr_bitmap);
-- patch_tlb_miss_handler_bitmap();
--
- high_memory = __va(last_valid_pfn << PAGE_SHIFT);
-
- register_page_bootmem_info();
-@@ -2243,18 +2249,9 @@ unsigned long _PAGE_CACHE __read_mostly;
- EXPORT_SYMBOL(_PAGE_CACHE);
-
- #ifdef CONFIG_SPARSEMEM_VMEMMAP
--unsigned long vmemmap_table[VMEMMAP_SIZE];
--
--static long __meminitdata addr_start, addr_end;
--static int __meminitdata node_start;
--
- int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend,
- int node)
- {
-- unsigned long phys_start = (vstart - VMEMMAP_BASE);
-- unsigned long phys_end = (vend - VMEMMAP_BASE);
-- unsigned long addr = phys_start & VMEMMAP_CHUNK_MASK;
-- unsigned long end = VMEMMAP_ALIGN(phys_end);
- unsigned long pte_base;
-
- pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4U |
-@@ -2265,47 +2262,52 @@ int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend,
- _PAGE_CP_4V | _PAGE_CV_4V |
- _PAGE_P_4V | _PAGE_W_4V);
-
-- for (; addr < end; addr += VMEMMAP_CHUNK) {
-- unsigned long *vmem_pp =
-- vmemmap_table + (addr >> VMEMMAP_CHUNK_SHIFT);
-- void *block;
-+ pte_base |= _PAGE_PMD_HUGE;
-
-- if (!(*vmem_pp & _PAGE_VALID)) {
-- block = vmemmap_alloc_block(1UL << ILOG2_4MB, node);
-- if (!block)
-+ vstart = vstart & PMD_MASK;
-+ vend = ALIGN(vend, PMD_SIZE);
-+ for (; vstart < vend; vstart += PMD_SIZE) {
-+ pgd_t *pgd = pgd_offset_k(vstart);
-+ unsigned long pte;
-+ pud_t *pud;
-+ pmd_t *pmd;
-+
-+ if (pgd_none(*pgd)) {
-+ pud_t *new = vmemmap_alloc_block(PAGE_SIZE, node);
-+
-+ if (!new)
- return -ENOMEM;
-+ pgd_populate(&init_mm, pgd, new);
-+ }
-
-- *vmem_pp = pte_base | __pa(block);
-+ pud = pud_offset(pgd, vstart);
-+ if (pud_none(*pud)) {
-+ pmd_t *new = vmemmap_alloc_block(PAGE_SIZE, node);
-
-- /* check to see if we have contiguous blocks */
-- if (addr_end != addr || node_start != node) {
-- if (addr_start)
-- printk(KERN_DEBUG " [%lx-%lx] on node %d\n",
-- addr_start, addr_end-1, node_start);
-- addr_start = addr;
-- node_start = node;
-- }
-- addr_end = addr + VMEMMAP_CHUNK;
-+ if (!new)
-+ return -ENOMEM;
-+ pud_populate(&init_mm, pud, new);
- }
-- }
-- return 0;
--}
-
--void __meminit vmemmap_populate_print_last(void)
--{
-- if (addr_start) {
-- printk(KERN_DEBUG " [%lx-%lx] on node %d\n",
-- addr_start, addr_end-1, node_start);
-- addr_start = 0;
-- addr_end = 0;
-- node_start = 0;
-+ pmd = pmd_offset(pud, vstart);
-+
-+ pte = pmd_val(*pmd);
-+ if (!(pte & _PAGE_VALID)) {
-+ void *block = vmemmap_alloc_block(PMD_SIZE, node);
-+
-+ if (!block)
-+ return -ENOMEM;
-+
-+ pmd_val(*pmd) = pte_base | __pa(block);
-+ }
- }
-+
-+ return 0;
- }
-
- void vmemmap_free(unsigned long start, unsigned long end)
- {
- }
--
- #endif /* CONFIG_SPARSEMEM_VMEMMAP */
-
- static void prot_init_common(unsigned long page_none,
-@@ -2717,8 +2719,8 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
- do_flush_tlb_kernel_range(start, LOW_OBP_ADDRESS);
- }
- if (end > HI_OBP_ADDRESS) {
-- flush_tsb_kernel_range(end, HI_OBP_ADDRESS);
-- do_flush_tlb_kernel_range(end, HI_OBP_ADDRESS);
-+ flush_tsb_kernel_range(HI_OBP_ADDRESS, end);
-+ do_flush_tlb_kernel_range(HI_OBP_ADDRESS, end);
- }
- } else {
- flush_tsb_kernel_range(start, end);
-diff --git a/arch/sparc/mm/init_64.h b/arch/sparc/mm/init_64.h
-index 5d3782deb403..ac491193cb54 100644
---- a/arch/sparc/mm/init_64.h
-+++ b/arch/sparc/mm/init_64.h
-@@ -8,15 +8,8 @@
- */
-
- #define MAX_PHYS_ADDRESS (1UL << MAX_PHYS_ADDRESS_BITS)
--#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL)
--#define KPTE_BITMAP_BYTES \
-- ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 4)
--#define VALID_ADDR_BITMAP_CHUNK_SZ (4UL * 1024UL * 1024UL)
--#define VALID_ADDR_BITMAP_BYTES \
-- ((MAX_PHYS_ADDRESS / VALID_ADDR_BITMAP_CHUNK_SZ) / 8)
-
- extern unsigned long kern_linear_pte_xor[4];
--extern unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
- extern unsigned int sparc64_highest_unlocked_tlb_ent;
- extern unsigned long sparc64_kern_pri_context;
- extern unsigned long sparc64_kern_pri_nuc_bits;
-@@ -38,15 +31,4 @@ extern unsigned long kern_locked_tte_data;
-
- extern void prom_world(int enter);
-
--#ifdef CONFIG_SPARSEMEM_VMEMMAP
--#define VMEMMAP_CHUNK_SHIFT 22
--#define VMEMMAP_CHUNK (1UL << VMEMMAP_CHUNK_SHIFT)
--#define VMEMMAP_CHUNK_MASK ~(VMEMMAP_CHUNK - 1UL)
--#define VMEMMAP_ALIGN(x) (((x)+VMEMMAP_CHUNK-1UL)&VMEMMAP_CHUNK_MASK)
--
--#define VMEMMAP_SIZE ((((1UL << MAX_PHYSADDR_BITS) >> PAGE_SHIFT) * \
-- sizeof(struct page)) >> VMEMMAP_CHUNK_SHIFT)
--extern unsigned long vmemmap_table[VMEMMAP_SIZE];
--#endif
--
- #endif /* _SPARC64_MM_INIT_H */
-diff --git a/arch/sparc/power/hibernate_asm.S b/arch/sparc/power/hibernate_asm.S
-index 79942166df84..d7d9017dcb15 100644
---- a/arch/sparc/power/hibernate_asm.S
-+++ b/arch/sparc/power/hibernate_asm.S
-@@ -54,8 +54,8 @@ ENTRY(swsusp_arch_resume)
- nop
-
- /* Write PAGE_OFFSET to %g7 */
-- sethi %uhi(PAGE_OFFSET), %g7
-- sllx %g7, 32, %g7
-+ sethi %hi(PAGE_OFFSET), %g7
-+ ldx [%g7 + %lo(PAGE_OFFSET)], %g7
-
- setuw (PAGE_SIZE-8), %g3
-
-diff --git a/arch/sparc/prom/bootstr_64.c b/arch/sparc/prom/bootstr_64.c
-index ab9ccc63b388..7149e77714a4 100644
---- a/arch/sparc/prom/bootstr_64.c
-+++ b/arch/sparc/prom/bootstr_64.c
-@@ -14,7 +14,10 @@
- * the .bss section or it will break things.
- */
-
--#define BARG_LEN 256
-+/* We limit BARG_LEN to 1024 because this is the size of the
-+ * 'barg_out' command line buffer in the SILO bootloader.
-+ */
-+#define BARG_LEN 1024
- struct {
- int bootstr_len;
- int bootstr_valid;
-diff --git a/arch/sparc/prom/cif.S b/arch/sparc/prom/cif.S
-index 9c86b4b7d429..8050f381f518 100644
---- a/arch/sparc/prom/cif.S
-+++ b/arch/sparc/prom/cif.S
-@@ -11,11 +11,10 @@
- .text
- .globl prom_cif_direct
- prom_cif_direct:
-+ save %sp, -192, %sp
- sethi %hi(p1275buf), %o1
- or %o1, %lo(p1275buf), %o1
-- ldx [%o1 + 0x0010], %o2 ! prom_cif_stack
-- save %o2, -192, %sp
-- ldx [%i1 + 0x0008], %l2 ! prom_cif_handler
-+ ldx [%o1 + 0x0008], %l2 ! prom_cif_handler
- mov %g4, %l0
- mov %g5, %l1
- mov %g6, %l3
-diff --git a/arch/sparc/prom/init_64.c b/arch/sparc/prom/init_64.c
-index d95db755828f..110b0d78b864 100644
---- a/arch/sparc/prom/init_64.c
-+++ b/arch/sparc/prom/init_64.c
-@@ -26,13 +26,13 @@ phandle prom_chosen_node;
- * It gets passed the pointer to the PROM vector.
- */
-
--extern void prom_cif_init(void *, void *);
-+extern void prom_cif_init(void *);
-
--void __init prom_init(void *cif_handler, void *cif_stack)
-+void __init prom_init(void *cif_handler)
- {
- phandle node;
-
-- prom_cif_init(cif_handler, cif_stack);
-+ prom_cif_init(cif_handler);
-
- prom_chosen_node = prom_finddevice(prom_chosen_path);
- if (!prom_chosen_node || (s32)prom_chosen_node == -1)
-diff --git a/arch/sparc/prom/p1275.c b/arch/sparc/prom/p1275.c
-index e58b81726319..545d8bb79b65 100644
---- a/arch/sparc/prom/p1275.c
-+++ b/arch/sparc/prom/p1275.c
-@@ -9,6 +9,7 @@
- #include
- #include
- #include
-+#include
-
- #include
- #include
-@@ -19,7 +20,6 @@
- struct {
- long prom_callback; /* 0x00 */
- void (*prom_cif_handler)(long *); /* 0x08 */
-- unsigned long prom_cif_stack; /* 0x10 */
- } p1275buf;
-
- extern void prom_world(int);
-@@ -36,8 +36,8 @@ void p1275_cmd_direct(unsigned long *args)
- {
- unsigned long flags;
-
-- raw_local_save_flags(flags);
-- raw_local_irq_restore((unsigned long)PIL_NMI);
-+ local_save_flags(flags);
-+ local_irq_restore((unsigned long)PIL_NMI);
- raw_spin_lock(&prom_entry_lock);
-
- prom_world(1);
-@@ -45,11 +45,10 @@ void p1275_cmd_direct(unsigned long *args)
- prom_world(0);
-
- raw_spin_unlock(&prom_entry_lock);
-- raw_local_irq_restore(flags);
-+ local_irq_restore(flags);
- }
-
- void prom_cif_init(void *cif_handler, void *cif_stack)
- {
- p1275buf.prom_cif_handler = (void (*)(long *))cif_handler;
-- p1275buf.prom_cif_stack = (unsigned long)cif_stack;
- }
-diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
-index d71d5ac78e42..ac63ea4af5b0 100644
---- a/arch/x86/include/asm/kvm_host.h
-+++ b/arch/x86/include/asm/kvm_host.h
-@@ -480,6 +480,7 @@ struct kvm_vcpu_arch {
- u64 mmio_gva;
- unsigned access;
- gfn_t mmio_gfn;
-+ u64 mmio_gen;
-
- struct kvm_pmu pmu;
-
-diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
-index 5cd9bfabd645..c1a07d33e67e 100644
---- a/arch/x86/kernel/cpu/intel.c
-+++ b/arch/x86/kernel/cpu/intel.c
-@@ -153,6 +153,21 @@ static void early_init_intel(struct cpuinfo_x86 *c)
- setup_clear_cpu_cap(X86_FEATURE_ERMS);
- }
- }
-+
-+ /*
-+ * Intel Quark Core DevMan_001.pdf section 6.4.11
-+ * "The operating system also is required to invalidate (i.e., flush)
-+ * the TLB when any changes are made to any of the page table entries.
-+ * The operating system must reload CR3 to cause the TLB to be flushed"
-+ *
-+ * As a result cpu_has_pge() in arch/x86/include/asm/tlbflush.h should
-+ * be false so that __flush_tlb_all() causes CR3 insted of CR4.PGE
-+ * to be modified
-+ */
-+ if (c->x86 == 5 && c->x86_model == 9) {
-+ pr_info("Disabling PGE capability bit\n");
-+ setup_clear_cpu_cap(X86_FEATURE_PGE);
-+ }
- }
-
- #ifdef CONFIG_X86_32
-diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
-index 9b531351a587..49088b8a3ee3 100644
---- a/arch/x86/kvm/mmu.c
-+++ b/arch/x86/kvm/mmu.c
-@@ -198,16 +198,20 @@ void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask)
- EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask);
-
- /*
-- * spte bits of bit 3 ~ bit 11 are used as low 9 bits of generation number,
-- * the bits of bits 52 ~ bit 61 are used as high 10 bits of generation
-- * number.
-+ * the low bit of the generation number is always presumed to be zero.
-+ * This disables mmio caching during memslot updates. The concept is
-+ * similar to a seqcount but instead of retrying the access we just punt
-+ * and ignore the cache.
-+ *
-+ * spte bits 3-11 are used as bits 1-9 of the generation number,
-+ * the bits 52-61 are used as bits 10-19 of the generation number.
- */
--#define MMIO_SPTE_GEN_LOW_SHIFT 3
-+#define MMIO_SPTE_GEN_LOW_SHIFT 2
- #define MMIO_SPTE_GEN_HIGH_SHIFT 52
-
--#define MMIO_GEN_SHIFT 19
--#define MMIO_GEN_LOW_SHIFT 9
--#define MMIO_GEN_LOW_MASK ((1 << MMIO_GEN_LOW_SHIFT) - 1)
-+#define MMIO_GEN_SHIFT 20
-+#define MMIO_GEN_LOW_SHIFT 10
-+#define MMIO_GEN_LOW_MASK ((1 << MMIO_GEN_LOW_SHIFT) - 2)
- #define MMIO_GEN_MASK ((1 << MMIO_GEN_SHIFT) - 1)
- #define MMIO_MAX_GEN ((1 << MMIO_GEN_SHIFT) - 1)
-
-@@ -3157,7 +3161,7 @@ static void mmu_sync_roots(struct kvm_vcpu *vcpu)
- if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
- return;
-
-- vcpu_clear_mmio_info(vcpu, ~0ul);
-+ vcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY);
- kvm_mmu_audit(vcpu, AUDIT_PRE_SYNC);
- if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
- hpa_t root = vcpu->arch.mmu.root_hpa;
-@@ -4379,7 +4383,7 @@ void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm)
- * The very rare case: if the generation-number is round,
- * zap all shadow pages.
- */
-- if (unlikely(kvm_current_mmio_generation(kvm) >= MMIO_MAX_GEN)) {
-+ if (unlikely(kvm_current_mmio_generation(kvm) == 0)) {
- printk_ratelimited(KERN_INFO "kvm: zapping shadow pages for mmio generation wraparound\n");
- kvm_mmu_invalidate_zap_all_pages(kvm);
- }
-diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
-index 8da5823bcde6..21ea4fc91b5b 100644
---- a/arch/x86/kvm/x86.h
-+++ b/arch/x86/kvm/x86.h
-@@ -78,15 +78,23 @@ static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
- vcpu->arch.mmio_gva = gva & PAGE_MASK;
- vcpu->arch.access = access;
- vcpu->arch.mmio_gfn = gfn;
-+ vcpu->arch.mmio_gen = kvm_memslots(vcpu->kvm)->generation;
-+}
-+
-+static inline bool vcpu_match_mmio_gen(struct kvm_vcpu *vcpu)
-+{
-+ return vcpu->arch.mmio_gen == kvm_memslots(vcpu->kvm)->generation;
- }
-
- /*
-- * Clear the mmio cache info for the given gva,
-- * specially, if gva is ~0ul, we clear all mmio cache info.
-+ * Clear the mmio cache info for the given gva. If gva is MMIO_GVA_ANY, we
-+ * clear all mmio cache info.
- */
-+#define MMIO_GVA_ANY (~(gva_t)0)
-+
- static inline void vcpu_clear_mmio_info(struct kvm_vcpu *vcpu, gva_t gva)
- {
-- if (gva != (~0ul) && vcpu->arch.mmio_gva != (gva & PAGE_MASK))
-+ if (gva != MMIO_GVA_ANY && vcpu->arch.mmio_gva != (gva & PAGE_MASK))
- return;
-
- vcpu->arch.mmio_gva = 0;
-@@ -94,7 +102,8 @@ static inline void vcpu_clear_mmio_info(struct kvm_vcpu *vcpu, gva_t gva)
-
- static inline bool vcpu_match_mmio_gva(struct kvm_vcpu *vcpu, unsigned long gva)
- {
-- if (vcpu->arch.mmio_gva && vcpu->arch.mmio_gva == (gva & PAGE_MASK))
-+ if (vcpu_match_mmio_gen(vcpu) && vcpu->arch.mmio_gva &&
-+ vcpu->arch.mmio_gva == (gva & PAGE_MASK))
- return true;
-
- return false;
-@@ -102,7 +111,8 @@ static inline bool vcpu_match_mmio_gva(struct kvm_vcpu *vcpu, unsigned long gva)
-
- static inline bool vcpu_match_mmio_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
- {
-- if (vcpu->arch.mmio_gfn && vcpu->arch.mmio_gfn == gpa >> PAGE_SHIFT)
-+ if (vcpu_match_mmio_gen(vcpu) && vcpu->arch.mmio_gfn &&
-+ vcpu->arch.mmio_gfn == gpa >> PAGE_SHIFT)
- return true;
-
- return false;
-diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c
-index 3c562f5a60bb..e1bce26cd4f9 100644
---- a/crypto/async_tx/async_xor.c
-+++ b/crypto/async_tx/async_xor.c
-@@ -78,8 +78,6 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,
- tx = dma->device_prep_dma_xor(chan, dma_dest, src_list,
- xor_src_cnt, unmap->len,
- dma_flags);
-- src_list[0] = tmp;
--
-
- if (unlikely(!tx))
- async_tx_quiesce(&submit->depend_tx);
-@@ -92,6 +90,7 @@ do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap,
- xor_src_cnt, unmap->len,
- dma_flags);
- }
-+ src_list[0] = tmp;
-
- dma_set_unmap(tx, unmap);
- async_tx_submit(chan, tx, submit);
-diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
-index c30df50e4440..2495ee577a64 100644
---- a/drivers/base/firmware_class.c
-+++ b/drivers/base/firmware_class.c
-@@ -1081,6 +1081,9 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
- if (!firmware_p)
- return -EINVAL;
-
-+ if (!name || name[0] == '\0')
-+ return -EINVAL;
-+
- ret = _request_firmware_prepare(&fw, name, device);
- if (ret <= 0) /* error or already assigned */
- goto out;
-diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
-index c5471cd6ebb7..d39fd610aa3b 100644
---- a/drivers/base/regmap/regmap-debugfs.c
-+++ b/drivers/base/regmap/regmap-debugfs.c
-@@ -473,6 +473,7 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
- {
- struct rb_node *next;
- struct regmap_range_node *range_node;
-+ const char *devname = "dummy";
-
- /* If we don't have the debugfs root yet, postpone init */
- if (!regmap_debugfs_root) {
-@@ -491,12 +492,15 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
- INIT_LIST_HEAD(&map->debugfs_off_cache);
- mutex_init(&map->cache_lock);
-
-+ if (map->dev)
-+ devname = dev_name(map->dev);
-+
- if (name) {
- map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
-- dev_name(map->dev), name);
-+ devname, name);
- name = map->debugfs_name;
- } else {
-- name = dev_name(map->dev);
-+ name = devname;
- }
-
- map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
-diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
-index 2ea056c09aeb..f6cff3be0ed7 100644
---- a/drivers/base/regmap/regmap.c
-+++ b/drivers/base/regmap/regmap.c
-@@ -1308,7 +1308,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
- }
-
- #ifdef LOG_DEVICE
-- if (strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
-+ if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
- dev_info(map->dev, "%x <= %x\n", reg, val);
- #endif
-
-@@ -1557,6 +1557,9 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
- } else {
- void *wval;
-
-+ if (!val_count)
-+ return -EINVAL;
-+
- wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL);
- if (!wval) {
- ret = -ENOMEM;
-@@ -1739,7 +1742,7 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
- ret = map->reg_read(context, reg, val);
- if (ret == 0) {
- #ifdef LOG_DEVICE
-- if (strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
-+ if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
- dev_info(map->dev, "%x => %x\n", reg, *val);
- #endif
-
-diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
-index 1c7b5040d921..e00c3f84a4cf 100644
---- a/drivers/bluetooth/btusb.c
-+++ b/drivers/bluetooth/btusb.c
-@@ -309,6 +309,9 @@ static void btusb_intr_complete(struct urb *urb)
- BT_ERR("%s corrupted event packet", hdev->name);
- hdev->stat.err_rx++;
- }
-+ } else if (urb->status == -ENOENT) {
-+ /* Avoid suspend failed when usb_kill_urb */
-+ return;
- }
-
- if (!test_bit(BTUSB_INTR_RUNNING, &data->flags))
-@@ -397,6 +400,9 @@ static void btusb_bulk_complete(struct urb *urb)
- BT_ERR("%s corrupted ACL packet", hdev->name);
- hdev->stat.err_rx++;
- }
-+ } else if (urb->status == -ENOENT) {
-+ /* Avoid suspend failed when usb_kill_urb */
-+ return;
- }
-
- if (!test_bit(BTUSB_BULK_RUNNING, &data->flags))
-@@ -491,6 +497,9 @@ static void btusb_isoc_complete(struct urb *urb)
- hdev->stat.err_rx++;
- }
- }
-+ } else if (urb->status == -ENOENT) {
-+ /* Avoid suspend failed when usb_kill_urb */
-+ return;
- }
-
- if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags))
-diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
-index e36a0245f2c1..56519927479f 100644
---- a/drivers/bluetooth/hci_h5.c
-+++ b/drivers/bluetooth/hci_h5.c
-@@ -237,7 +237,7 @@ static void h5_pkt_cull(struct h5 *h5)
- break;
-
- to_remove--;
-- seq = (seq - 1) % 8;
-+ seq = (seq - 1) & 0x07;
- }
-
- if (seq != h5->rx_ack)
-diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
-index 69ea36f07b4d..e99e71a6ea59 100644
---- a/drivers/hv/channel.c
-+++ b/drivers/hv/channel.c
-@@ -164,8 +164,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
- ret = vmbus_post_msg(open_msg,
- sizeof(struct vmbus_channel_open_channel));
-
-- if (ret != 0)
-+ if (ret != 0) {
-+ err = ret;
- goto error1;
-+ }
-
- t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ);
- if (t == 0) {
-@@ -362,7 +364,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
- u32 next_gpadl_handle;
- unsigned long flags;
- int ret = 0;
-- int t;
-
- next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
- atomic_inc(&vmbus_connection.next_gpadl_handle);
-@@ -409,9 +410,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
-
- }
- }
-- t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ);
-- BUG_ON(t == 0);
--
-+ wait_for_completion(&msginfo->waitevent);
-
- /* At this point, we received the gpadl created msg */
- *gpadl_handle = gpadlmsg->gpadl;
-@@ -434,7 +433,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
- struct vmbus_channel_gpadl_teardown *msg;
- struct vmbus_channel_msginfo *info;
- unsigned long flags;
-- int ret, t;
-+ int ret;
-
- info = kmalloc(sizeof(*info) +
- sizeof(struct vmbus_channel_gpadl_teardown), GFP_KERNEL);
-@@ -456,11 +455,12 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
- ret = vmbus_post_msg(msg,
- sizeof(struct vmbus_channel_gpadl_teardown));
-
-- BUG_ON(ret != 0);
-- t = wait_for_completion_timeout(&info->waitevent, 5*HZ);
-- BUG_ON(t == 0);
-+ if (ret)
-+ goto post_msg_err;
-+
-+ wait_for_completion(&info->waitevent);
-
-- /* Received a torndown response */
-+post_msg_err:
- spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
- list_del(&info->msglistentry);
- spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
-@@ -470,7 +470,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
- }
- EXPORT_SYMBOL_GPL(vmbus_teardown_gpadl);
-
--static void vmbus_close_internal(struct vmbus_channel *channel)
-+static int vmbus_close_internal(struct vmbus_channel *channel)
- {
- struct vmbus_channel_close_channel *msg;
- int ret;
-@@ -492,11 +492,28 @@ static void vmbus_close_internal(struct vmbus_channel *channel)
-
- ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel));
-
-- BUG_ON(ret != 0);
-+ if (ret) {
-+ pr_err("Close failed: close post msg return is %d\n", ret);
-+ /*
-+ * If we failed to post the close msg,
-+ * it is perhaps better to leak memory.
-+ */
-+ return ret;
-+ }
-+
- /* Tear down the gpadl for the channel's ring buffer */
-- if (channel->ringbuffer_gpadlhandle)
-- vmbus_teardown_gpadl(channel,
-- channel->ringbuffer_gpadlhandle);
-+ if (channel->ringbuffer_gpadlhandle) {
-+ ret = vmbus_teardown_gpadl(channel,
-+ channel->ringbuffer_gpadlhandle);
-+ if (ret) {
-+ pr_err("Close failed: teardown gpadl return %d\n", ret);
-+ /*
-+ * If we failed to teardown gpadl,
-+ * it is perhaps better to leak memory.
-+ */
-+ return ret;
-+ }
-+ }
-
- /* Cleanup the ring buffers for this channel */
- hv_ringbuffer_cleanup(&channel->outbound);
-@@ -505,7 +522,7 @@ static void vmbus_close_internal(struct vmbus_channel *channel)
- free_pages((unsigned long)channel->ringbuffer_pages,
- get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
-
--
-+ return ret;
- }
-
- /*
-diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
-index ce5a9f2584f3..d8fd95cb0456 100644
---- a/drivers/hv/connection.c
-+++ b/drivers/hv/connection.c
-@@ -408,10 +408,21 @@ int vmbus_post_msg(void *buffer, size_t buflen)
- * insufficient resources. Retry the operation a couple of
- * times before giving up.
- */
-- while (retries < 3) {
-- ret = hv_post_message(conn_id, 1, buffer, buflen);
-- if (ret != HV_STATUS_INSUFFICIENT_BUFFERS)
-+ while (retries < 10) {
-+ ret = hv_post_message(conn_id, 1, buffer, buflen);
-+
-+ switch (ret) {
-+ case HV_STATUS_INSUFFICIENT_BUFFERS:
-+ ret = -ENOMEM;
-+ case -ENOMEM:
-+ break;
-+ case HV_STATUS_SUCCESS:
- return ret;
-+ default:
-+ pr_err("hv_post_msg() failed; error code:%d\n", ret);
-+ return -EINVAL;
-+ }
-+
- retries++;
- msleep(100);
- }
-diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
-index 5653e505f91f..424f51d1e2ce 100644
---- a/drivers/message/fusion/mptspi.c
-+++ b/drivers/message/fusion/mptspi.c
-@@ -1422,6 +1422,11 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
- goto out_mptspi_probe;
- }
-
-+ /* VMWare emulation doesn't properly implement WRITE_SAME
-+ */
-+ if (pdev->subsystem_vendor == 0x15AD)
-+ sh->no_write_same = 1;
-+
- spin_lock_irqsave(&ioc->FreeQlock, flags);
-
- /* Attach the SCSI Host to the IOC structure
-diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
-index 4bc7d620d695..9a07bba3ade4 100644
---- a/drivers/misc/mei/bus.c
-+++ b/drivers/misc/mei/bus.c
-@@ -71,7 +71,7 @@ static int mei_cl_device_probe(struct device *dev)
-
- dev_dbg(dev, "Device probe\n");
-
-- strncpy(id.name, dev_name(dev), sizeof(id.name));
-+ strlcpy(id.name, dev_name(dev), sizeof(id.name));
-
- return driver->probe(device, &id);
- }
-diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
-index df1f5e732ab5..1ac33d9cd396 100644
---- a/drivers/net/wireless/iwlwifi/pcie/drv.c
-+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
-@@ -272,6 +272,8 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
- {IWL_PCI_DEVICE(0x08B1, 0x4070, iwl7260_2ac_cfg)},
- {IWL_PCI_DEVICE(0x08B1, 0x4072, iwl7260_2ac_cfg)},
- {IWL_PCI_DEVICE(0x08B1, 0x4170, iwl7260_2ac_cfg)},
-+ {IWL_PCI_DEVICE(0x08B1, 0x4C60, iwl7260_2ac_cfg)},
-+ {IWL_PCI_DEVICE(0x08B1, 0x4C70, iwl7260_2ac_cfg)},
- {IWL_PCI_DEVICE(0x08B1, 0x4060, iwl7260_2n_cfg)},
- {IWL_PCI_DEVICE(0x08B1, 0x406A, iwl7260_2n_cfg)},
- {IWL_PCI_DEVICE(0x08B1, 0x4160, iwl7260_2n_cfg)},
-@@ -315,6 +317,8 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
- {IWL_PCI_DEVICE(0x08B1, 0xC770, iwl7260_2ac_cfg)},
- {IWL_PCI_DEVICE(0x08B1, 0xC760, iwl7260_2n_cfg)},
- {IWL_PCI_DEVICE(0x08B2, 0xC270, iwl7260_2ac_cfg)},
-+ {IWL_PCI_DEVICE(0x08B1, 0xCC70, iwl7260_2ac_cfg)},
-+ {IWL_PCI_DEVICE(0x08B1, 0xCC60, iwl7260_2ac_cfg)},
- {IWL_PCI_DEVICE(0x08B2, 0xC272, iwl7260_2ac_cfg)},
- {IWL_PCI_DEVICE(0x08B2, 0xC260, iwl7260_2n_cfg)},
- {IWL_PCI_DEVICE(0x08B2, 0xC26A, iwl7260_n_cfg)},
-diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
-index a394a9a95919..7cf6081a05a1 100644
---- a/drivers/net/wireless/rt2x00/rt2800.h
-+++ b/drivers/net/wireless/rt2x00/rt2800.h
-@@ -2039,7 +2039,7 @@ struct mac_iveiv_entry {
- * 2 - drop tx power by 12dBm,
- * 3 - increase tx power by 6dBm
- */
--#define BBP1_TX_POWER_CTRL FIELD8(0x07)
-+#define BBP1_TX_POWER_CTRL FIELD8(0x03)
- #define BBP1_TX_ANTENNA FIELD8(0x18)
-
- /*
-diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
-index 483d9ad89705..97736674ddcd 100644
---- a/drivers/pci/host/pci-mvebu.c
-+++ b/drivers/pci/host/pci-mvebu.c
-@@ -855,7 +855,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
- rangesz = pna + na + ns;
- nranges = rlen / sizeof(__be32) / rangesz;
-
-- for (i = 0; i < nranges; i++) {
-+ for (i = 0; i < nranges; i++, range += rangesz) {
- u32 flags = of_read_number(range, 1);
- u32 slot = of_read_number(range + 1, 1);
- u64 cpuaddr = of_read_number(range + na, pna);
-@@ -865,14 +865,14 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
- rtype = IORESOURCE_IO;
- else if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_MEM32)
- rtype = IORESOURCE_MEM;
-+ else
-+ continue;
-
- if (slot == PCI_SLOT(devfn) && type == rtype) {
- *tgt = DT_CPUADDR_TO_TARGET(cpuaddr);
- *attr = DT_CPUADDR_TO_ATTR(cpuaddr);
- return 0;
- }
--
-- range += rangesz;
- }
-
- return -ENOENT;
-diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
-index 276ef9c18802..39a207abaa10 100644
---- a/drivers/pci/pci-sysfs.c
-+++ b/drivers/pci/pci-sysfs.c
-@@ -178,7 +178,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
- {
- struct pci_dev *pci_dev = to_pci_dev(dev);
-
-- return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
-+ return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02X\n",
- pci_dev->vendor, pci_dev->device,
- pci_dev->subsystem_vendor, pci_dev->subsystem_device,
- (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
-diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
-index 813f437f3ee8..6e8776b59a2c 100644
---- a/drivers/pci/quirks.c
-+++ b/drivers/pci/quirks.c
-@@ -24,6 +24,7 @@
- #include
- #include
- #include
-+#include
- #include /* isa_dma_bridge_buggy */
- #include "pci.h"
-
-@@ -287,6 +288,25 @@ static void quirk_citrine(struct pci_dev *dev)
- }
- DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine);
-
-+/* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */
-+static void quirk_extend_bar_to_page(struct pci_dev *dev)
-+{
-+ int i;
-+
-+ for (i = 0; i < PCI_STD_RESOURCE_END; i++) {
-+ struct resource *r = &dev->resource[i];
-+
-+ if (r->flags & IORESOURCE_MEM && resource_size(r) < PAGE_SIZE) {
-+ r->end = PAGE_SIZE - 1;
-+ r->start = 0;
-+ r->flags |= IORESOURCE_UNSET;
-+ dev_info(&dev->dev, "expanded BAR %d to page size: %pR\n",
-+ i, r);
-+ }
-+ }
-+}
-+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, 0x034a, quirk_extend_bar_to_page);
-+
- /*
- * S3 868 and 968 chips report region size equal to 32M, but they decode 64M.
- * If it's needed, re-allocate the region.
-diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
-index b2fcac78feaa..5bb9406688c9 100644
---- a/drivers/scsi/be2iscsi/be_mgmt.c
-+++ b/drivers/scsi/be2iscsi/be_mgmt.c
-@@ -897,17 +897,20 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba,
-
- if (ip_action == IP_ACTION_ADD) {
- memcpy(req->ip_params.ip_record.ip_addr.addr, ip_param->value,
-- ip_param->len);
-+ sizeof(req->ip_params.ip_record.ip_addr.addr));
-
- if (subnet_param)
- memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
-- subnet_param->value, subnet_param->len);
-+ subnet_param->value,
-+ sizeof(req->ip_params.ip_record.ip_addr.subnet_mask));
- } else {
- memcpy(req->ip_params.ip_record.ip_addr.addr,
-- if_info->ip_addr.addr, ip_param->len);
-+ if_info->ip_addr.addr,
-+ sizeof(req->ip_params.ip_record.ip_addr.addr));
-
- memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
-- if_info->ip_addr.subnet_mask, ip_param->len);
-+ if_info->ip_addr.subnet_mask,
-+ sizeof(req->ip_params.ip_record.ip_addr.subnet_mask));
- }
-
- rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
-@@ -935,7 +938,7 @@ static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr,
- req->action = gtway_action;
- req->ip_addr.ip_type = BE2_IPV4;
-
-- memcpy(req->ip_addr.addr, gt_addr, param_len);
-+ memcpy(req->ip_addr.addr, gt_addr, sizeof(req->ip_addr.addr));
-
- return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
- }
-diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
-index 83cb61266979..23c1b0cd3074 100644
---- a/drivers/scsi/qla2xxx/qla_os.c
-+++ b/drivers/scsi/qla2xxx/qla_os.c
-@@ -3039,10 +3039,8 @@ qla2x00_unmap_iobases(struct qla_hw_data *ha)
- }
-
- static void
--qla2x00_clear_drv_active(scsi_qla_host_t *vha)
-+qla2x00_clear_drv_active(struct qla_hw_data *ha)
- {
-- struct qla_hw_data *ha = vha->hw;
--
- if (IS_QLA8044(ha)) {
- qla8044_idc_lock(ha);
- qla8044_clear_drv_active(ha);
-@@ -3111,7 +3109,7 @@ qla2x00_remove_one(struct pci_dev *pdev)
-
- scsi_host_put(base_vha->host);
-
-- qla2x00_clear_drv_active(base_vha);
-+ qla2x00_clear_drv_active(ha);
-
- qla2x00_unmap_iobases(ha);
-
-diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
-index 0cb73074c199..2f264ac79546 100644
---- a/drivers/scsi/qla2xxx/qla_target.c
-+++ b/drivers/scsi/qla2xxx/qla_target.c
-@@ -1382,12 +1382,10 @@ static inline void qlt_unmap_sg(struct scsi_qla_host *vha,
- static int qlt_check_reserve_free_req(struct scsi_qla_host *vha,
- uint32_t req_cnt)
- {
-- struct qla_hw_data *ha = vha->hw;
-- device_reg_t __iomem *reg = ha->iobase;
- uint32_t cnt;
-
- if (vha->req->cnt < (req_cnt + 2)) {
-- cnt = (uint16_t)RD_REG_DWORD(®->isp24.req_q_out);
-+ cnt = (uint16_t)RD_REG_DWORD(vha->req->req_q_out);
-
- ql_dbg(ql_dbg_tgt, vha, 0xe00a,
- "Request ring circled: cnt=%d, vha->->ring_index=%d, "
-diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
-index 6d207afec8cb..a4c45ea8f688 100644
---- a/drivers/spi/spi-dw-mid.c
-+++ b/drivers/spi/spi-dw-mid.c
-@@ -89,7 +89,13 @@ err_exit:
-
- static void mid_spi_dma_exit(struct dw_spi *dws)
- {
-+ if (!dws->dma_inited)
-+ return;
-+
-+ dmaengine_terminate_all(dws->txchan);
- dma_release_channel(dws->txchan);
-+
-+ dmaengine_terminate_all(dws->rxchan);
- dma_release_channel(dws->rxchan);
- }
-
-@@ -136,7 +142,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
- txconf.dst_addr = dws->dma_addr;
- txconf.dst_maxburst = LNW_DMA_MSIZE_16;
- txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-- txconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
-+ txconf.dst_addr_width = dws->dma_width;
- txconf.device_fc = false;
-
- txchan->device->device_control(txchan, DMA_SLAVE_CONFIG,
-@@ -159,7 +165,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
- rxconf.src_addr = dws->dma_addr;
- rxconf.src_maxburst = LNW_DMA_MSIZE_16;
- rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-- rxconf.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
-+ rxconf.src_addr_width = dws->dma_width;
- rxconf.device_fc = false;
-
- rxchan->device->device_control(rxchan, DMA_SLAVE_CONFIG,
-diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
-index db8434d3def9..f4e68b3fc39d 100644
---- a/drivers/tty/serial/omap-serial.c
-+++ b/drivers/tty/serial/omap-serial.c
-@@ -260,8 +260,16 @@ serial_omap_baud_is_mode16(struct uart_port *port, unsigned int baud)
- {
- unsigned int n13 = port->uartclk / (13 * baud);
- unsigned int n16 = port->uartclk / (16 * baud);
-- int baudAbsDiff13 = baud - (port->uartclk / (13 * n13));
-- int baudAbsDiff16 = baud - (port->uartclk / (16 * n16));
-+ int baudAbsDiff13;
-+ int baudAbsDiff16;
-+
-+ if (n13 == 0)
-+ n13 = 1;
-+ if (n16 == 0)
-+ n16 = 1;
-+
-+ baudAbsDiff13 = baud - (port->uartclk / (13 * n13));
-+ baudAbsDiff16 = baud - (port->uartclk / (16 * n16));
- if (baudAbsDiff13 < 0)
- baudAbsDiff13 = -baudAbsDiff13;
- if (baudAbsDiff16 < 0)
-diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
-index 8154165aa601..fd13ef0a96c9 100644
---- a/drivers/usb/gadget/Kconfig
-+++ b/drivers/usb/gadget/Kconfig
-@@ -445,7 +445,7 @@ config USB_GOKU
- gadget drivers to also be dynamically linked.
-
- config USB_EG20T
-- tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC"
-+ tristate "Intel QUARK X1000/EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7831) UDC"
- depends on PCI
- help
- This is a USB device driver for EG20T PCH.
-@@ -466,6 +466,7 @@ config USB_EG20T
- ML7213/ML7831 is companion chip for Intel Atom E6xx series.
- ML7213/ML7831 is completely compatible for Intel EG20T PCH.
-
-+ This driver can be used with Intel's Quark X1000 SOC platform
- #
- # LAST -- dummy/emulated controller
- #
-diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
-index eb8c3bedb57a..460d953c91b6 100644
---- a/drivers/usb/gadget/pch_udc.c
-+++ b/drivers/usb/gadget/pch_udc.c
-@@ -343,6 +343,7 @@ struct pch_vbus_gpio_data {
- * @setup_data: Received setup data
- * @phys_addr: of device memory
- * @base_addr: for mapped device memory
-+ * @bar: Indicates which PCI BAR for USB regs
- * @irq: IRQ line for the device
- * @cfg_data: current cfg, intf, and alt in use
- * @vbus_gpio: GPIO informaton for detecting VBUS
-@@ -370,14 +371,17 @@ struct pch_udc_dev {
- struct usb_ctrlrequest setup_data;
- unsigned long phys_addr;
- void __iomem *base_addr;
-+ unsigned bar;
- unsigned irq;
- struct pch_udc_cfg_data cfg_data;
- struct pch_vbus_gpio_data vbus_gpio;
- };
- #define to_pch_udc(g) (container_of((g), struct pch_udc_dev, gadget))
-
-+#define PCH_UDC_PCI_BAR_QUARK_X1000 0
- #define PCH_UDC_PCI_BAR 1
- #define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808
-+#define PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC 0x0939
- #define PCI_VENDOR_ID_ROHM 0x10DB
- #define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D
- #define PCI_DEVICE_ID_ML7831_IOH_UDC 0x8808
-@@ -3076,7 +3080,7 @@ static void pch_udc_remove(struct pci_dev *pdev)
- iounmap(dev->base_addr);
- if (dev->mem_region)
- release_mem_region(dev->phys_addr,
-- pci_resource_len(pdev, PCH_UDC_PCI_BAR));
-+ pci_resource_len(pdev, dev->bar));
- if (dev->active)
- pci_disable_device(pdev);
- kfree(dev);
-@@ -3144,9 +3148,15 @@ static int pch_udc_probe(struct pci_dev *pdev,
- dev->active = 1;
- pci_set_drvdata(pdev, dev);
-
-+ /* Determine BAR based on PCI ID */
-+ if (id->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC)
-+ dev->bar = PCH_UDC_PCI_BAR_QUARK_X1000;
-+ else
-+ dev->bar = PCH_UDC_PCI_BAR;
-+
- /* PCI resource allocation */
-- resource = pci_resource_start(pdev, 1);
-- len = pci_resource_len(pdev, 1);
-+ resource = pci_resource_start(pdev, dev->bar);
-+ len = pci_resource_len(pdev, dev->bar);
-
- if (!request_mem_region(resource, len, KBUILD_MODNAME)) {
- dev_err(&pdev->dev, "%s: pci device used already\n", __func__);
-@@ -3212,6 +3222,12 @@ finished:
-
- static const struct pci_device_id pch_udc_pcidev_id[] = {
- {
-+ PCI_DEVICE(PCI_VENDOR_ID_INTEL,
-+ PCI_DEVICE_ID_INTEL_QUARK_X1000_UDC),
-+ .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
-+ .class_mask = 0xffffffff,
-+ },
-+ {
- PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC),
- .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
- .class_mask = 0xffffffff,
-diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
-index 0165b8672f09..a9a881ed8cbe 100644
---- a/fs/btrfs/file.c
-+++ b/fs/btrfs/file.c
-@@ -2510,23 +2510,28 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int whence)
- struct btrfs_root *root = BTRFS_I(inode)->root;
- struct extent_map *em = NULL;
- struct extent_state *cached_state = NULL;
-- u64 lockstart = *offset;
-- u64 lockend = i_size_read(inode);
-- u64 start = *offset;
-- u64 len = i_size_read(inode);
-+ u64 lockstart;
-+ u64 lockend;
-+ u64 start;
-+ u64 len;
- int ret = 0;
-
-- lockend = max_t(u64, root->sectorsize, lockend);
-+ if (inode->i_size == 0)
-+ return -ENXIO;
-+
-+ /*
-+ * *offset can be negative, in this case we start finding DATA/HOLE from
-+ * the very start of the file.
-+ */
-+ start = max_t(loff_t, 0, *offset);
-+
-+ lockstart = round_down(start, root->sectorsize);
-+ lockend = round_up(i_size_read(inode), root->sectorsize);
- if (lockend <= lockstart)
- lockend = lockstart + root->sectorsize;
--
- lockend--;
- len = lockend - lockstart + 1;
-
-- len = max_t(u64, len, root->sectorsize);
-- if (inode->i_size == 0)
-- return -ENXIO;
--
- lock_extent_bits(&BTRFS_I(inode)->io_tree, lockstart, lockend, 0,
- &cached_state);
-
-diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
-index c69c76351f12..d68a7250f00b 100644
---- a/fs/btrfs/inode.c
-+++ b/fs/btrfs/inode.c
-@@ -3596,7 +3596,8 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
- * without delay
- */
- if (!btrfs_is_free_space_inode(inode)
-- && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) {
-+ && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID
-+ && !root->fs_info->log_root_recovering) {
- btrfs_update_root_times(trans, root);
-
- ret = btrfs_delayed_update_inode(trans, root, inode);
-diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
-index a6d8efa46bfe..0b72006aecbe 100644
---- a/fs/btrfs/ioctl.c
-+++ b/fs/btrfs/ioctl.c
-@@ -302,6 +302,9 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
- goto out_drop;
-
- } else {
-+ ret = btrfs_set_prop(inode, "btrfs.compression", NULL, 0, 0);
-+ if (ret && ret != -ENODATA)
-+ goto out_drop;
- ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
- }
-
-@@ -4750,6 +4753,12 @@ long btrfs_ioctl(struct file *file, unsigned int
- if (ret)
- return ret;
- ret = btrfs_sync_fs(file->f_dentry->d_sb, 1);
-+ /*
-+ * The transaction thread may want to do more work,
-+ * namely it pokes the cleaner ktread that will start
-+ * processing uncleaned subvols.
-+ */
-+ wake_up_process(root->fs_info->transaction_kthread);
- return ret;
- }
- case BTRFS_IOC_START_SYNC:
-diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
-index 07b3b36f40ee..01f977e3ce09 100644
---- a/fs/btrfs/relocation.c
-+++ b/fs/btrfs/relocation.c
-@@ -736,7 +736,8 @@ again:
- err = ret;
- goto out;
- }
-- BUG_ON(!ret || !path1->slots[0]);
-+ ASSERT(ret);
-+ ASSERT(path1->slots[0]);
-
- path1->slots[0]--;
-
-@@ -746,10 +747,10 @@ again:
- * the backref was added previously when processing
- * backref of type BTRFS_TREE_BLOCK_REF_KEY
- */
-- BUG_ON(!list_is_singular(&cur->upper));
-+ ASSERT(list_is_singular(&cur->upper));
- edge = list_entry(cur->upper.next, struct backref_edge,
- list[LOWER]);
-- BUG_ON(!list_empty(&edge->list[UPPER]));
-+ ASSERT(list_empty(&edge->list[UPPER]));
- exist = edge->node[UPPER];
- /*
- * add the upper level block to pending list if we need
-@@ -831,7 +832,7 @@ again:
- cur->cowonly = 1;
- }
- #else
-- BUG_ON(key.type == BTRFS_EXTENT_REF_V0_KEY);
-+ ASSERT(key.type != BTRFS_EXTENT_REF_V0_KEY);
- if (key.type == BTRFS_SHARED_BLOCK_REF_KEY) {
- #endif
- if (key.objectid == key.offset) {
-@@ -840,7 +841,7 @@ again:
- * backref of this type.
- */
- root = find_reloc_root(rc, cur->bytenr);
-- BUG_ON(!root);
-+ ASSERT(root);
- cur->root = root;
- break;
- }
-@@ -868,7 +869,7 @@ again:
- } else {
- upper = rb_entry(rb_node, struct backref_node,
- rb_node);
-- BUG_ON(!upper->checked);
-+ ASSERT(upper->checked);
- INIT_LIST_HEAD(&edge->list[UPPER]);
- }
- list_add_tail(&edge->list[LOWER], &cur->upper);
-@@ -892,7 +893,7 @@ again:
-
- if (btrfs_root_level(&root->root_item) == cur->level) {
- /* tree root */
-- BUG_ON(btrfs_root_bytenr(&root->root_item) !=
-+ ASSERT(btrfs_root_bytenr(&root->root_item) ==
- cur->bytenr);
- if (should_ignore_root(root))
- list_add(&cur->list, &useless);
-@@ -927,7 +928,7 @@ again:
- need_check = true;
- for (; level < BTRFS_MAX_LEVEL; level++) {
- if (!path2->nodes[level]) {
-- BUG_ON(btrfs_root_bytenr(&root->root_item) !=
-+ ASSERT(btrfs_root_bytenr(&root->root_item) ==
- lower->bytenr);
- if (should_ignore_root(root))
- list_add(&lower->list, &useless);
-@@ -976,12 +977,15 @@ again:
- need_check = false;
- list_add_tail(&edge->list[UPPER],
- &list);
-- } else
-+ } else {
-+ if (upper->checked)
-+ need_check = true;
- INIT_LIST_HEAD(&edge->list[UPPER]);
-+ }
- } else {
- upper = rb_entry(rb_node, struct backref_node,
- rb_node);
-- BUG_ON(!upper->checked);
-+ ASSERT(upper->checked);
- INIT_LIST_HEAD(&edge->list[UPPER]);
- if (!upper->owner)
- upper->owner = btrfs_header_owner(eb);
-@@ -1025,7 +1029,7 @@ next:
- * everything goes well, connect backref nodes and insert backref nodes
- * into the cache.
- */
-- BUG_ON(!node->checked);
-+ ASSERT(node->checked);
- cowonly = node->cowonly;
- if (!cowonly) {
- rb_node = tree_insert(&cache->rb_root, node->bytenr,
-@@ -1061,8 +1065,21 @@ next:
- continue;
- }
-
-- BUG_ON(!upper->checked);
-- BUG_ON(cowonly != upper->cowonly);
-+ if (!upper->checked) {
-+ /*
-+ * Still want to blow up for developers since this is a
-+ * logic bug.
-+ */
-+ ASSERT(0);
-+ err = -EINVAL;
-+ goto out;
-+ }
-+ if (cowonly != upper->cowonly) {
-+ ASSERT(0);
-+ err = -EINVAL;
-+ goto out;
-+ }
-+
- if (!cowonly) {
- rb_node = tree_insert(&cache->rb_root, upper->bytenr,
- &upper->rb_node);
-@@ -1085,7 +1102,7 @@ next:
- while (!list_empty(&useless)) {
- upper = list_entry(useless.next, struct backref_node, list);
- list_del_init(&upper->list);
-- BUG_ON(!list_empty(&upper->upper));
-+ ASSERT(list_empty(&upper->upper));
- if (upper == node)
- node = NULL;
- if (upper->lowest) {
-@@ -1118,29 +1135,45 @@ out:
- if (err) {
- while (!list_empty(&useless)) {
- lower = list_entry(useless.next,
-- struct backref_node, upper);
-- list_del_init(&lower->upper);
-+ struct backref_node, list);
-+ list_del_init(&lower->list);
- }
-- upper = node;
-- INIT_LIST_HEAD(&list);
-- while (upper) {
-- if (RB_EMPTY_NODE(&upper->rb_node)) {
-- list_splice_tail(&upper->upper, &list);
-- free_backref_node(cache, upper);
-- }
--
-- if (list_empty(&list))
-- break;
--
-- edge = list_entry(list.next, struct backref_edge,
-- list[LOWER]);
-+ while (!list_empty(&list)) {
-+ edge = list_first_entry(&list, struct backref_edge,
-+ list[UPPER]);
-+ list_del(&edge->list[UPPER]);
- list_del(&edge->list[LOWER]);
-+ lower = edge->node[LOWER];
- upper = edge->node[UPPER];
- free_backref_edge(cache, edge);
-+
-+ /*
-+ * Lower is no longer linked to any upper backref nodes
-+ * and isn't in the cache, we can free it ourselves.
-+ */
-+ if (list_empty(&lower->upper) &&
-+ RB_EMPTY_NODE(&lower->rb_node))
-+ list_add(&lower->list, &useless);
-+
-+ if (!RB_EMPTY_NODE(&upper->rb_node))
-+ continue;
-+
-+ /* Add this guy's upper edges to the list to proces */
-+ list_for_each_entry(edge, &upper->upper, list[LOWER])
-+ list_add_tail(&edge->list[UPPER], &list);
-+ if (list_empty(&upper->upper))
-+ list_add(&upper->list, &useless);
-+ }
-+
-+ while (!list_empty(&useless)) {
-+ lower = list_entry(useless.next,
-+ struct backref_node, list);
-+ list_del_init(&lower->list);
-+ free_backref_node(cache, lower);
- }
- return ERR_PTR(err);
- }
-- BUG_ON(node && node->detached);
-+ ASSERT(!node || !node->detached);
- return node;
- }
-
-diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
-index a65ed4cb436b..20d793542096 100644
---- a/fs/btrfs/send.c
-+++ b/fs/btrfs/send.c
-@@ -4728,7 +4728,9 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end)
-
- if (S_ISREG(sctx->cur_inode_mode)) {
- if (need_send_hole(sctx)) {
-- if (sctx->cur_inode_last_extent == (u64)-1) {
-+ if (sctx->cur_inode_last_extent == (u64)-1 ||
-+ sctx->cur_inode_last_extent <
-+ sctx->cur_inode_size) {
- ret = get_last_extent(sctx, (u64)-1);
- if (ret)
- goto out;
-diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
-index b05bf58b9395..a0b65a01fed7 100644
---- a/fs/btrfs/transaction.c
-+++ b/fs/btrfs/transaction.c
-@@ -592,7 +592,6 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
- if (transid <= root->fs_info->last_trans_committed)
- goto out;
-
-- ret = -EINVAL;
- /* find specified transaction */
- spin_lock(&root->fs_info->trans_lock);
- list_for_each_entry(t, &root->fs_info->trans_list, list) {
-@@ -608,9 +607,16 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
- }
- }
- spin_unlock(&root->fs_info->trans_lock);
-- /* The specified transaction doesn't exist */
-- if (!cur_trans)
-+
-+ /*
-+ * The specified transaction doesn't exist, or we
-+ * raced with btrfs_commit_transaction
-+ */
-+ if (!cur_trans) {
-+ if (transid > root->fs_info->last_trans_committed)
-+ ret = -EINVAL;
- goto out;
-+ }
- } else {
- /* find newest transaction that is committing | committed */
- spin_lock(&root->fs_info->trans_lock);
-diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
-index b167ca48b8ee..a85ceb7c91bc 100644
---- a/fs/ecryptfs/inode.c
-+++ b/fs/ecryptfs/inode.c
-@@ -1039,7 +1039,7 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
- }
-
- rc = vfs_setxattr(lower_dentry, name, value, size, flags);
-- if (!rc)
-+ if (!rc && dentry->d_inode)
- fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode);
- out:
- return rc;
-diff --git a/fs/namespace.c b/fs/namespace.c
-index 75536db4b69b..c7d4a0ae2c65 100644
---- a/fs/namespace.c
-+++ b/fs/namespace.c
-@@ -1365,6 +1365,8 @@ static int do_umount(struct mount *mnt, int flags)
- * Special case for "unmounting" root ...
- * we just try to remount it readonly.
- */
-+ if (!capable(CAP_SYS_ADMIN))
-+ return -EPERM;
- down_write(&sb->s_umount);
- if (!(sb->s_flags & MS_RDONLY))
- retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
-diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
-index 2e9662ea5451..da657b7804a5 100644
---- a/fs/nfs/nfs4proc.c
-+++ b/fs/nfs/nfs4proc.c
-@@ -7242,7 +7242,7 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cr
- int ret = 0;
-
- if ((renew_flags & NFS4_RENEW_TIMEOUT) == 0)
-- return 0;
-+ return -EAGAIN;
- task = _nfs41_proc_sequence(clp, cred, false);
- if (IS_ERR(task))
- ret = PTR_ERR(task);
-diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
-index 1720d32ffa54..e1ba58c3d1ad 100644
---- a/fs/nfs/nfs4renewd.c
-+++ b/fs/nfs/nfs4renewd.c
-@@ -88,10 +88,18 @@ nfs4_renew_state(struct work_struct *work)
- }
- nfs_expire_all_delegations(clp);
- } else {
-+ int ret;
-+
- /* Queue an asynchronous RENEW. */
-- ops->sched_state_renewal(clp, cred, renew_flags);
-+ ret = ops->sched_state_renewal(clp, cred, renew_flags);
- put_rpccred(cred);
-- goto out_exp;
-+ switch (ret) {
-+ default:
-+ goto out_exp;
-+ case -EAGAIN:
-+ case -ENOMEM:
-+ break;
-+ }
- }
- } else {
- dprintk("%s: failed to call renewd. Reason: lease not expired \n",
-diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
-index 27f5f858502b..b4f177f1d405 100644
---- a/fs/nfs/nfs4state.c
-+++ b/fs/nfs/nfs4state.c
-@@ -1732,7 +1732,8 @@ restart:
- if (status < 0) {
- set_bit(ops->owner_flag_bit, &sp->so_flags);
- nfs4_put_state_owner(sp);
-- return nfs4_recovery_handle_error(clp, status);
-+ status = nfs4_recovery_handle_error(clp, status);
-+ return (status != 0) ? status : -EAGAIN;
- }
-
- nfs4_put_state_owner(sp);
-@@ -1741,7 +1742,7 @@ restart:
- spin_unlock(&clp->cl_lock);
- }
- rcu_read_unlock();
-- return status;
-+ return 0;
- }
-
- static int nfs4_check_lease(struct nfs_client *clp)
-@@ -1788,7 +1789,6 @@ static int nfs4_handle_reclaim_lease_error(struct nfs_client *clp, int status)
- break;
- case -NFS4ERR_STALE_CLIENTID:
- clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
-- nfs4_state_clear_reclaim_reboot(clp);
- nfs4_state_start_reclaim_reboot(clp);
- break;
- case -NFS4ERR_CLID_INUSE:
-@@ -2370,6 +2370,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
- status = nfs4_check_lease(clp);
- if (status < 0)
- goto out_error;
-+ continue;
- }
-
- if (test_and_clear_bit(NFS4CLNT_MOVED, &clp->cl_state)) {
-@@ -2391,14 +2392,11 @@ static void nfs4_state_manager(struct nfs_client *clp)
- section = "reclaim reboot";
- status = nfs4_do_reclaim(clp,
- clp->cl_mvops->reboot_recovery_ops);
-- if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) ||
-- test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
-- continue;
-- nfs4_state_end_reclaim_reboot(clp);
-- if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state))
-+ if (status == -EAGAIN)
- continue;
- if (status < 0)
- goto out_error;
-+ nfs4_state_end_reclaim_reboot(clp);
- }
-
- /* Now recover expired state... */
-@@ -2406,9 +2404,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
- section = "reclaim nograce";
- status = nfs4_do_reclaim(clp,
- clp->cl_mvops->nograce_recovery_ops);
-- if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) ||
-- test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) ||
-- test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state))
-+ if (status == -EAGAIN)
- continue;
- if (status < 0)
- goto out_error;
-diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
-index 287a22c04149..de6323eb0113 100644
---- a/fs/notify/fanotify/fanotify_user.c
-+++ b/fs/notify/fanotify/fanotify_user.c
-@@ -71,7 +71,7 @@ static int create_fd(struct fsnotify_group *group,
-
- pr_debug("%s: group=%p event=%p\n", __func__, group, event);
-
-- client_fd = get_unused_fd();
-+ client_fd = get_unused_fd_flags(group->fanotify_data.f_flags);
- if (client_fd < 0)
- return client_fd;
-
-diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
-index 5d2518b24cea..0461fbe405b7 100644
---- a/fs/xfs/xfs_aops.c
-+++ b/fs/xfs/xfs_aops.c
-@@ -434,10 +434,22 @@ xfs_start_page_writeback(
- {
- ASSERT(PageLocked(page));
- ASSERT(!PageWriteback(page));
-- if (clear_dirty)
-+
-+ /*
-+ * if the page was not fully cleaned, we need to ensure that the higher
-+ * layers come back to it correctly. That means we need to keep the page
-+ * dirty, and for WB_SYNC_ALL writeback we need to ensure the
-+ * PAGECACHE_TAG_TOWRITE index mark is not removed so another attempt to
-+ * write this page in this writeback sweep will be made.
-+ */
-+ if (clear_dirty) {
- clear_page_dirty_for_io(page);
-- set_page_writeback(page);
-+ set_page_writeback(page);
-+ } else
-+ set_page_writeback_keepwrite(page);
-+
- unlock_page(page);
-+
- /* If no buffers on the page are to be written, finish it here */
- if (!buffers)
- end_page_writeback(page);
-diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
-new file mode 100644
-index 000000000000..cdd1cc202d51
---- /dev/null
-+++ b/include/linux/compiler-gcc5.h
-@@ -0,0 +1,66 @@
-+#ifndef __LINUX_COMPILER_H
-+#error "Please don't include directly, include instead."
-+#endif
-+
-+#define __used __attribute__((__used__))
-+#define __must_check __attribute__((warn_unused_result))
-+#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
-+
-+/* Mark functions as cold. gcc will assume any path leading to a call
-+ to them will be unlikely. This means a lot of manual unlikely()s
-+ are unnecessary now for any paths leading to the usual suspects
-+ like BUG(), printk(), panic() etc. [but let's keep them for now for
-+ older compilers]
-+
-+ Early snapshots of gcc 4.3 don't support this and we can't detect this
-+ in the preprocessor, but we can live with this because they're unreleased.
-+ Maketime probing would be overkill here.
-+
-+ gcc also has a __attribute__((__hot__)) to move hot functions into
-+ a special section, but I don't see any sense in this right now in
-+ the kernel context */
-+#define __cold __attribute__((__cold__))
-+
-+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
-+
-+#ifndef __CHECKER__
-+# define __compiletime_warning(message) __attribute__((warning(message)))
-+# define __compiletime_error(message) __attribute__((error(message)))
-+#endif /* __CHECKER__ */
-+
-+/*
-+ * Mark a position in code as unreachable. This can be used to
-+ * suppress control flow warnings after asm blocks that transfer
-+ * control elsewhere.
-+ *
-+ * Early snapshots of gcc 4.5 don't support this and we can't detect
-+ * this in the preprocessor, but we can live with this because they're
-+ * unreleased. Really, we need to have autoconf for the kernel.
-+ */
-+#define unreachable() __builtin_unreachable()
-+
-+/* Mark a function definition as prohibited from being cloned. */
-+#define __noclone __attribute__((__noclone__))
-+
-+/*
-+ * Tell the optimizer that something else uses this function or variable.
-+ */
-+#define __visible __attribute__((externally_visible))
-+
-+/*
-+ * GCC 'asm goto' miscompiles certain code sequences:
-+ *
-+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
-+ *
-+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
-+ * Fixed in GCC 4.8.2 and later versions.
-+ *
-+ * (asm goto is automatically volatile - the naming reflects this.)
-+ */
-+#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
-+
-+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
-+#define __HAVE_BUILTIN_BSWAP32__
-+#define __HAVE_BUILTIN_BSWAP64__
-+#define __HAVE_BUILTIN_BSWAP16__
-+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
-diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
-index 97fbecdd7a40..057c1d8c77e5 100644
---- a/include/linux/pci_ids.h
-+++ b/include/linux/pci_ids.h
-@@ -2551,6 +2551,7 @@
- #define PCI_DEVICE_ID_INTEL_MFD_EMMC0 0x0823
- #define PCI_DEVICE_ID_INTEL_MFD_EMMC1 0x0824
- #define PCI_DEVICE_ID_INTEL_MRST_SD2 0x084F
-+#define PCI_DEVICE_ID_INTEL_QUARK_X1000_ILB 0x095E
- #define PCI_DEVICE_ID_INTEL_I960 0x0960
- #define PCI_DEVICE_ID_INTEL_I960RM 0x0962
- #define PCI_DEVICE_ID_INTEL_CENTERTON_ILB 0x0c60
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index d7ca410ace93..218b058060f1 100644
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -1876,11 +1876,13 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
- #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
- #define used_math() tsk_used_math(current)
-
--/* __GFP_IO isn't allowed if PF_MEMALLOC_NOIO is set in current->flags */
-+/* __GFP_IO isn't allowed if PF_MEMALLOC_NOIO is set in current->flags
-+ * __GFP_FS is also cleared as it implies __GFP_IO.
-+ */
- static inline gfp_t memalloc_noio_flags(gfp_t flags)
- {
- if (unlikely(current->flags & PF_MEMALLOC_NOIO))
-- flags &= ~__GFP_IO;
-+ flags &= ~(__GFP_IO | __GFP_FS);
- return flags;
- }
-
-diff --git a/kernel/futex.c b/kernel/futex.c
-index 0b0dc02aabce..fda2950f2ce4 100644
---- a/kernel/futex.c
-+++ b/kernel/futex.c
-@@ -329,6 +329,8 @@ static void get_futex_key_refs(union futex_key *key)
- case FUT_OFF_MMSHARED:
- futex_get_mm(key); /* implies MB (B) */
- break;
-+ default:
-+ smp_mb(); /* explicit MB (B) */
- }
- }
-
-diff --git a/lib/lzo/lzo1x_decompress_safe.c b/lib/lzo/lzo1x_decompress_safe.c
-index 8563081e8da3..a1c387f6afba 100644
---- a/lib/lzo/lzo1x_decompress_safe.c
-+++ b/lib/lzo/lzo1x_decompress_safe.c
-@@ -19,31 +19,21 @@
- #include
- #include "lzodefs.h"
-
--#define HAVE_IP(t, x) \
-- (((size_t)(ip_end - ip) >= (size_t)(t + x)) && \
-- (((t + x) >= t) && ((t + x) >= x)))
-+#define HAVE_IP(x) ((size_t)(ip_end - ip) >= (size_t)(x))
-+#define HAVE_OP(x) ((size_t)(op_end - op) >= (size_t)(x))
-+#define NEED_IP(x) if (!HAVE_IP(x)) goto input_overrun
-+#define NEED_OP(x) if (!HAVE_OP(x)) goto output_overrun
-+#define TEST_LB(m_pos) if ((m_pos) < out) goto lookbehind_overrun
-
--#define HAVE_OP(t, x) \
-- (((size_t)(op_end - op) >= (size_t)(t + x)) && \
-- (((t + x) >= t) && ((t + x) >= x)))
--
--#define NEED_IP(t, x) \
-- do { \
-- if (!HAVE_IP(t, x)) \
-- goto input_overrun; \
-- } while (0)
--
--#define NEED_OP(t, x) \
-- do { \
-- if (!HAVE_OP(t, x)) \
-- goto output_overrun; \
-- } while (0)
--
--#define TEST_LB(m_pos) \
-- do { \
-- if ((m_pos) < out) \
-- goto lookbehind_overrun; \
-- } while (0)
-+/* This MAX_255_COUNT is the maximum number of times we can add 255 to a base
-+ * count without overflowing an integer. The multiply will overflow when
-+ * multiplying 255 by more than MAXINT/255. The sum will overflow earlier
-+ * depending on the base count. Since the base count is taken from a u8
-+ * and a few bits, it is safe to assume that it will always be lower than
-+ * or equal to 2*255, thus we can always prevent any overflow by accepting
-+ * two less 255 steps. See Documentation/lzo.txt for more information.
-+ */
-+#define MAX_255_COUNT ((((size_t)~0) / 255) - 2)
-
- int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
- unsigned char *out, size_t *out_len)
-@@ -75,17 +65,24 @@ int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
- if (t < 16) {
- if (likely(state == 0)) {
- if (unlikely(t == 0)) {
-+ size_t offset;
-+ const unsigned char *ip_last = ip;
-+
- while (unlikely(*ip == 0)) {
-- t += 255;
- ip++;
-- NEED_IP(1, 0);
-+ NEED_IP(1);
- }
-- t += 15 + *ip++;
-+ offset = ip - ip_last;
-+ if (unlikely(offset > MAX_255_COUNT))
-+ return LZO_E_ERROR;
-+
-+ offset = (offset << 8) - offset;
-+ t += offset + 15 + *ip++;
- }
- t += 3;
- copy_literal_run:
- #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
-- if (likely(HAVE_IP(t, 15) && HAVE_OP(t, 15))) {
-+ if (likely(HAVE_IP(t + 15) && HAVE_OP(t + 15))) {
- const unsigned char *ie = ip + t;
- unsigned char *oe = op + t;
- do {
-@@ -101,8 +98,8 @@ copy_literal_run:
- } else
- #endif
- {
-- NEED_OP(t, 0);
-- NEED_IP(t, 3);
-+ NEED_OP(t);
-+ NEED_IP(t + 3);
- do {
- *op++ = *ip++;
- } while (--t > 0);
-@@ -115,7 +112,7 @@ copy_literal_run:
- m_pos -= t >> 2;
- m_pos -= *ip++ << 2;
- TEST_LB(m_pos);
-- NEED_OP(2, 0);
-+ NEED_OP(2);
- op[0] = m_pos[0];
- op[1] = m_pos[1];
- op += 2;
-@@ -136,13 +133,20 @@ copy_literal_run:
- } else if (t >= 32) {
- t = (t & 31) + (3 - 1);
- if (unlikely(t == 2)) {
-+ size_t offset;
-+ const unsigned char *ip_last = ip;
-+
- while (unlikely(*ip == 0)) {
-- t += 255;
- ip++;
-- NEED_IP(1, 0);
-+ NEED_IP(1);
- }
-- t += 31 + *ip++;
-- NEED_IP(2, 0);
-+ offset = ip - ip_last;
-+ if (unlikely(offset > MAX_255_COUNT))
-+ return LZO_E_ERROR;
-+
-+ offset = (offset << 8) - offset;
-+ t += offset + 31 + *ip++;
-+ NEED_IP(2);
- }
- m_pos = op - 1;
- next = get_unaligned_le16(ip);
-@@ -154,13 +158,20 @@ copy_literal_run:
- m_pos -= (t & 8) << 11;
- t = (t & 7) + (3 - 1);
- if (unlikely(t == 2)) {
-+ size_t offset;
-+ const unsigned char *ip_last = ip;
-+
- while (unlikely(*ip == 0)) {
-- t += 255;
- ip++;
-- NEED_IP(1, 0);
-+ NEED_IP(1);
- }
-- t += 7 + *ip++;
-- NEED_IP(2, 0);
-+ offset = ip - ip_last;
-+ if (unlikely(offset > MAX_255_COUNT))
-+ return LZO_E_ERROR;
-+
-+ offset = (offset << 8) - offset;
-+ t += offset + 7 + *ip++;
-+ NEED_IP(2);
- }
- next = get_unaligned_le16(ip);
- ip += 2;
-@@ -174,7 +185,7 @@ copy_literal_run:
- #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
- if (op - m_pos >= 8) {
- unsigned char *oe = op + t;
-- if (likely(HAVE_OP(t, 15))) {
-+ if (likely(HAVE_OP(t + 15))) {
- do {
- COPY8(op, m_pos);
- op += 8;
-@@ -184,7 +195,7 @@ copy_literal_run:
- m_pos += 8;
- } while (op < oe);
- op = oe;
-- if (HAVE_IP(6, 0)) {
-+ if (HAVE_IP(6)) {
- state = next;
- COPY4(op, ip);
- op += next;
-@@ -192,7 +203,7 @@ copy_literal_run:
- continue;
- }
- } else {
-- NEED_OP(t, 0);
-+ NEED_OP(t);
- do {
- *op++ = *m_pos++;
- } while (op < oe);
-@@ -201,7 +212,7 @@ copy_literal_run:
- #endif
- {
- unsigned char *oe = op + t;
-- NEED_OP(t, 0);
-+ NEED_OP(t);
- op[0] = m_pos[0];
- op[1] = m_pos[1];
- op += 2;
-@@ -214,15 +225,15 @@ match_next:
- state = next;
- t = next;
- #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
-- if (likely(HAVE_IP(6, 0) && HAVE_OP(4, 0))) {
-+ if (likely(HAVE_IP(6) && HAVE_OP(4))) {
- COPY4(op, ip);
- op += t;
- ip += t;
- } else
- #endif
- {
-- NEED_IP(t, 3);
-- NEED_OP(t, 0);
-+ NEED_IP(t + 3);
-+ NEED_OP(t);
- while (t > 0) {
- *op++ = *ip++;
- t--;
-diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
-index 6afa3b45f25a..0007c9e9853a 100644
---- a/net/bluetooth/l2cap_core.c
-+++ b/net/bluetooth/l2cap_core.c
-@@ -2608,12 +2608,8 @@ static int l2cap_segment_le_sdu(struct l2cap_chan *chan,
-
- BT_DBG("chan %p, msg %p, len %zu", chan, msg, len);
-
-- pdu_len = chan->conn->mtu - L2CAP_HDR_SIZE;
--
-- pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
--
- sdu_len = len;
-- pdu_len -= L2CAP_SDULEN_SIZE;
-+ pdu_len = chan->remote_mps - L2CAP_SDULEN_SIZE;
-
- while (len > 0) {
- if (len <= pdu_len)
-diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
-index 734e9468aca0..6df1b2527d02 100644
---- a/security/integrity/ima/ima_appraise.c
-+++ b/security/integrity/ima/ima_appraise.c
-@@ -194,8 +194,11 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint,
- goto out;
-
- cause = "missing-hash";
-- status =
-- (inode->i_size == 0) ? INTEGRITY_PASS : INTEGRITY_NOLABEL;
-+ status = INTEGRITY_NOLABEL;
-+ if (inode->i_size == 0) {
-+ iint->flags |= IMA_NEW_FILE;
-+ status = INTEGRITY_PASS;
-+ }
- goto out;
- }
-
-diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
-index 76d8aad146a8..9f70efd08058 100644
---- a/security/integrity/ima/ima_main.c
-+++ b/security/integrity/ima/ima_main.c
-@@ -131,11 +131,13 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint,
- return;
-
- mutex_lock(&inode->i_mutex);
-- if (atomic_read(&inode->i_writecount) == 1 &&
-- iint->version != inode->i_version) {
-- iint->flags &= ~IMA_DONE_MASK;
-- if (iint->flags & IMA_APPRAISE)
-- ima_update_xattr(iint, file);
-+ if (atomic_read(&inode->i_writecount) == 1) {
-+ if ((iint->version != inode->i_version) ||
-+ (iint->flags & IMA_NEW_FILE)) {
-+ iint->flags &= ~(IMA_DONE_MASK | IMA_NEW_FILE);
-+ if (iint->flags & IMA_APPRAISE)
-+ ima_update_xattr(iint, file);
-+ }
- }
- mutex_unlock(&inode->i_mutex);
- }
-diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
-index 33c0a70f6b15..2f8715d77a5a 100644
---- a/security/integrity/integrity.h
-+++ b/security/integrity/integrity.h
-@@ -31,6 +31,7 @@
- #define IMA_DIGSIG 0x01000000
- #define IMA_DIGSIG_REQUIRED 0x02000000
- #define IMA_PERMIT_DIRECTIO 0x04000000
-+#define IMA_NEW_FILE 0x08000000
-
- #define IMA_DO_MASK (IMA_MEASURE | IMA_APPRAISE | IMA_AUDIT | \
- IMA_APPRAISE_SUBMASK)
-diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
-index 01a5e05ede95..566b0f69d628 100644
---- a/sound/core/pcm_native.c
-+++ b/sound/core/pcm_native.c
-@@ -3189,7 +3189,7 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = {
-
- #ifndef ARCH_HAS_DMA_MMAP_COHERENT
- /* This should be defined / handled globally! */
--#ifdef CONFIG_ARM
-+#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
- #define ARCH_HAS_DMA_MMAP_COHERENT
- #endif
- #endif
-diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c
-index cae36597aa71..0a34b5f1c475 100644
---- a/sound/pci/emu10k1/emu10k1_callback.c
-+++ b/sound/pci/emu10k1/emu10k1_callback.c
-@@ -85,6 +85,8 @@ snd_emu10k1_ops_setup(struct snd_emux *emux)
- * get more voice for pcm
- *
- * terminate most inactive voice and give it as a pcm voice.
-+ *
-+ * voice_lock is already held.
- */
- int
- snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
-@@ -92,12 +94,10 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
- struct snd_emux *emu;
- struct snd_emux_voice *vp;
- struct best_voice best[V_END];
-- unsigned long flags;
- int i;
-
- emu = hw->synth;
-
-- spin_lock_irqsave(&emu->voice_lock, flags);
- lookup_voices(emu, hw, best, 1); /* no OFF voices */
- for (i = 0; i < V_END; i++) {
- if (best[i].voice >= 0) {
-@@ -113,11 +113,9 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
- vp->emu->num_voices--;
- vp->ch = -1;
- vp->state = SNDRV_EMUX_ST_OFF;
-- spin_unlock_irqrestore(&emu->voice_lock, flags);
- return ch;
- }
- }
-- spin_unlock_irqrestore(&emu->voice_lock, flags);
-
- /* not found */
- return -ENOMEM;
-diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
-index d135c906caff..8253b48a435b 100644
---- a/sound/pci/hda/patch_hdmi.c
-+++ b/sound/pci/hda/patch_hdmi.c
-@@ -1557,19 +1557,22 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
- }
- }
-
-- if (pin_eld->eld_valid && !eld->eld_valid) {
-- update_eld = true;
-+ if (pin_eld->eld_valid != eld->eld_valid)
- eld_changed = true;
-- }
-+
-+ if (pin_eld->eld_valid && !eld->eld_valid)
-+ update_eld = true;
-+
- if (update_eld) {
- bool old_eld_valid = pin_eld->eld_valid;
- pin_eld->eld_valid = eld->eld_valid;
-- eld_changed = pin_eld->eld_size != eld->eld_size ||
-+ if (pin_eld->eld_size != eld->eld_size ||
- memcmp(pin_eld->eld_buffer, eld->eld_buffer,
-- eld->eld_size) != 0;
-- if (eld_changed)
-+ eld->eld_size) != 0) {
- memcpy(pin_eld->eld_buffer, eld->eld_buffer,
- eld->eld_size);
-+ eld_changed = true;
-+ }
- pin_eld->eld_size = eld->eld_size;
- pin_eld->info = eld->info;
-
-diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
-index 5d0058bd6259..4c826a40705c 100644
---- a/sound/pci/hda/patch_realtek.c
-+++ b/sound/pci/hda/patch_realtek.c
-@@ -2926,6 +2926,9 @@ static void alc283_shutup(struct hda_codec *codec)
-
- alc_write_coef_idx(codec, 0x43, 0x9004);
-
-+ /*depop hp during suspend*/
-+ alc_write_coef_idx(codec, 0x06, 0x2100);
-+
- snd_hda_codec_write(codec, hp_pin, 0,
- AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
-
-diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
-index 223c47b33ba3..c657752a420c 100644
---- a/sound/usb/quirks-table.h
-+++ b/sound/usb/quirks-table.h
-@@ -385,6 +385,36 @@ YAMAHA_DEVICE(0x105d, NULL),
- }
- },
- {
-+ USB_DEVICE(0x0499, 0x1509),
-+ .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
-+ /* .vendor_name = "Yamaha", */
-+ /* .product_name = "Steinberg UR22", */
-+ .ifnum = QUIRK_ANY_INTERFACE,
-+ .type = QUIRK_COMPOSITE,
-+ .data = (const struct snd_usb_audio_quirk[]) {
-+ {
-+ .ifnum = 1,
-+ .type = QUIRK_AUDIO_STANDARD_INTERFACE
-+ },
-+ {
-+ .ifnum = 2,
-+ .type = QUIRK_AUDIO_STANDARD_INTERFACE
-+ },
-+ {
-+ .ifnum = 3,
-+ .type = QUIRK_MIDI_YAMAHA
-+ },
-+ {
-+ .ifnum = 4,
-+ .type = QUIRK_IGNORE_INTERFACE
-+ },
-+ {
-+ .ifnum = -1
-+ }
-+ }
-+ }
-+},
-+{
- USB_DEVICE(0x0499, 0x150a),
- .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
- /* .vendor_name = "Yamaha", */
-diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
-index 03a0381b1cb7..66112533b1e9 100644
---- a/virt/kvm/kvm_main.c
-+++ b/virt/kvm/kvm_main.c
-@@ -52,6 +52,7 @@
-
- #include
- #include
-+#include
- #include
- #include
-
-@@ -95,8 +96,6 @@ static int hardware_enable_all(void);
- static void hardware_disable_all(void);
-
- static void kvm_io_bus_destroy(struct kvm_io_bus *bus);
--static void update_memslots(struct kvm_memslots *slots,
-- struct kvm_memory_slot *new, u64 last_generation);
-
- static void kvm_release_pfn_dirty(pfn_t pfn);
- static void mark_page_dirty_in_slot(struct kvm *kvm,
-@@ -682,8 +681,7 @@ static void sort_memslots(struct kvm_memslots *slots)
- }
-
- static void update_memslots(struct kvm_memslots *slots,
-- struct kvm_memory_slot *new,
-- u64 last_generation)
-+ struct kvm_memory_slot *new)
- {
- if (new) {
- int id = new->id;
-@@ -694,8 +692,6 @@ static void update_memslots(struct kvm_memslots *slots,
- if (new->npages != npages)
- sort_memslots(slots);
- }
--
-- slots->generation = last_generation + 1;
- }
-
- static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
-@@ -717,10 +713,24 @@ static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
- {
- struct kvm_memslots *old_memslots = kvm->memslots;
-
-- update_memslots(slots, new, kvm->memslots->generation);
-+ /*
-+ * Set the low bit in the generation, which disables SPTE caching
-+ * until the end of synchronize_srcu_expedited.
-+ */
-+ WARN_ON(old_memslots->generation & 1);
-+ slots->generation = old_memslots->generation + 1;
-+
-+ update_memslots(slots, new);
- rcu_assign_pointer(kvm->memslots, slots);
- synchronize_srcu_expedited(&kvm->srcu);
-
-+ /*
-+ * Increment the new memslot generation a second time. This prevents
-+ * vm exits that race with memslot updates from caching a memslot
-+ * generation that will (potentially) be valid forever.
-+ */
-+ slots->generation++;
-+
- kvm_arch_memslots_updated(kvm);
-
- return old_memslots;
-@@ -1970,6 +1980,9 @@ static long kvm_vcpu_ioctl(struct file *filp,
- if (vcpu->kvm->mm != current->mm)
- return -EIO;
-
-+ if (unlikely(_IOC_TYPE(ioctl) != KVMIO))
-+ return -EINVAL;
-+
- #if defined(CONFIG_S390) || defined(CONFIG_PPC) || defined(CONFIG_MIPS)
- /*
- * Special cases: vcpu ioctls that are asynchronous to vcpu execution,
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.23-24.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.23-24.patch
deleted file mode 100644
index 0e862921c3..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.23-24.patch
+++ /dev/null
@@ -1,7091 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 135a04a26076..8fd06101c482 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 23
-+SUBLEVEL = 24
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/arc/boot/dts/nsimosci.dts b/arch/arc/boot/dts/nsimosci.dts
-index 4f31b2eb5cdf..398064cef746 100644
---- a/arch/arc/boot/dts/nsimosci.dts
-+++ b/arch/arc/boot/dts/nsimosci.dts
-@@ -20,7 +20,7 @@
- /* this is for console on PGU */
- /* bootargs = "console=tty0 consoleblank=0"; */
- /* this is for console on serial */
-- bootargs = "earlycon=uart8250,mmio32,0xc0000000,115200n8 console=ttyS0,115200n8 consoleblank=0 debug";
-+ bootargs = "earlycon=uart8250,mmio32,0xc0000000,115200n8 console=tty0 console=ttyS0,115200n8 consoleblank=0 debug";
- };
-
- aliases {
-diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
-index 2fd3162ec4df..c1d3d2da1191 100644
---- a/arch/arc/include/asm/cache.h
-+++ b/arch/arc/include/asm/cache.h
-@@ -55,4 +55,31 @@ extern void read_decode_cache_bcr(void);
-
- #endif /* !__ASSEMBLY__ */
-
-+/* Instruction cache related Auxiliary registers */
-+#define ARC_REG_IC_BCR 0x77 /* Build Config reg */
-+#define ARC_REG_IC_IVIC 0x10
-+#define ARC_REG_IC_CTRL 0x11
-+#define ARC_REG_IC_IVIL 0x19
-+#if defined(CONFIG_ARC_MMU_V3) || defined (CONFIG_ARC_MMU_V4)
-+#define ARC_REG_IC_PTAG 0x1E
-+#endif
-+
-+/* Bit val in IC_CTRL */
-+#define IC_CTRL_CACHE_DISABLE 0x1
-+
-+/* Data cache related Auxiliary registers */
-+#define ARC_REG_DC_BCR 0x72 /* Build Config reg */
-+#define ARC_REG_DC_IVDC 0x47
-+#define ARC_REG_DC_CTRL 0x48
-+#define ARC_REG_DC_IVDL 0x4A
-+#define ARC_REG_DC_FLSH 0x4B
-+#define ARC_REG_DC_FLDL 0x4C
-+#if defined(CONFIG_ARC_MMU_V3) || defined (CONFIG_ARC_MMU_V4)
-+#define ARC_REG_DC_PTAG 0x5C
-+#endif
-+
-+/* Bit val in DC_CTRL */
-+#define DC_CTRL_INV_MODE_FLUSH 0x40
-+#define DC_CTRL_FLUSH_STATUS 0x100
-+
- #endif /* _ASM_CACHE_H */
-diff --git a/arch/arc/include/asm/kgdb.h b/arch/arc/include/asm/kgdb.h
-index b65fca7ffeb5..fea931634136 100644
---- a/arch/arc/include/asm/kgdb.h
-+++ b/arch/arc/include/asm/kgdb.h
-@@ -19,7 +19,7 @@
- * register API yet */
- #undef DBG_MAX_REG_NUM
-
--#define GDB_MAX_REGS 39
-+#define GDB_MAX_REGS 87
-
- #define BREAK_INSTR_SIZE 2
- #define CACHE_FLUSH_IS_SAFE 1
-@@ -33,23 +33,27 @@ static inline void arch_kgdb_breakpoint(void)
-
- extern void kgdb_trap(struct pt_regs *regs);
-
--enum arc700_linux_regnums {
-+/* This is the numbering of registers according to the GDB. See GDB's
-+ * arc-tdep.h for details.
-+ *
-+ * Registers are ordered for GDB 7.5. It is incompatible with GDB 6.8. */
-+enum arc_linux_regnums {
- _R0 = 0,
- _R1, _R2, _R3, _R4, _R5, _R6, _R7, _R8, _R9, _R10, _R11, _R12, _R13,
- _R14, _R15, _R16, _R17, _R18, _R19, _R20, _R21, _R22, _R23, _R24,
- _R25, _R26,
-- _BTA = 27,
-- _LP_START = 28,
-- _LP_END = 29,
-- _LP_COUNT = 30,
-- _STATUS32 = 31,
-- _BLINK = 32,
-- _FP = 33,
-- __SP = 34,
-- _EFA = 35,
-- _RET = 36,
-- _ORIG_R8 = 37,
-- _STOP_PC = 38
-+ _FP = 27,
-+ __SP = 28,
-+ _R30 = 30,
-+ _BLINK = 31,
-+ _LP_COUNT = 60,
-+ _STOP_PC = 64,
-+ _RET = 64,
-+ _LP_START = 65,
-+ _LP_END = 66,
-+ _STATUS32 = 67,
-+ _ECR = 76,
-+ _BTA = 82,
- };
-
- #else
-diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
-index 991997269d02..07a58f2d3077 100644
---- a/arch/arc/kernel/head.S
-+++ b/arch/arc/kernel/head.S
-@@ -12,10 +12,42 @@
- * to skip certain things during boot on simulator
- */
-
-+#include
- #include
- #include
--#include
- #include
-+#include
-+
-+.macro CPU_EARLY_SETUP
-+
-+ ; Setting up Vectror Table (in case exception happens in early boot
-+ sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
-+
-+ ; Disable I-cache/D-cache if kernel so configured
-+ lr r5, [ARC_REG_IC_BCR]
-+ breq r5, 0, 1f ; I$ doesn't exist
-+ lr r5, [ARC_REG_IC_CTRL]
-+#ifdef CONFIG_ARC_HAS_ICACHE
-+ bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
-+#else
-+ bset r5, r5, 0 ; I$ exists, but is not used
-+#endif
-+ sr r5, [ARC_REG_IC_CTRL]
-+
-+1:
-+ lr r5, [ARC_REG_DC_BCR]
-+ breq r5, 0, 1f ; D$ doesn't exist
-+ lr r5, [ARC_REG_DC_CTRL]
-+ bclr r5, r5, 6 ; Invalidate (discard w/o wback)
-+#ifdef CONFIG_ARC_HAS_DCACHE
-+ bclr r5, r5, 0 ; Enable (+Inv)
-+#else
-+ bset r5, r5, 0 ; Disable (+Inv)
-+#endif
-+ sr r5, [ARC_REG_DC_CTRL]
-+
-+1:
-+.endm
-
- .cpu A7
-
-@@ -24,13 +56,13 @@
- .globl stext
- stext:
- ;-------------------------------------------------------------------
-- ; Don't clobber r0-r4 yet. It might have bootloader provided info
-+ ; Don't clobber r0-r2 yet. It might have bootloader provided info
- ;-------------------------------------------------------------------
-
-- sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
-+ CPU_EARLY_SETUP
-
- #ifdef CONFIG_SMP
-- ; Only Boot (Master) proceeds. Others wait in platform dependent way
-+ ; Ensure Boot (Master) proceeds. Others wait in platform dependent way
- ; IDENTITY Reg [ 3 2 1 0 ]
- ; (cpu-id) ^^^ => Zero for UP ARC700
- ; => #Core-ID if SMP (Master 0)
-@@ -39,7 +71,8 @@ stext:
- ; need to make sure only boot cpu takes this path.
- GET_CPU_ID r5
- cmp r5, 0
-- jnz arc_platform_smp_wait_to_boot
-+ mov.ne r0, r5
-+ jne arc_platform_smp_wait_to_boot
- #endif
- ; Clear BSS before updating any globals
- ; XXX: use ZOL here
-@@ -89,7 +122,7 @@ stext:
-
- first_lines_of_secondary:
-
-- sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
-+ CPU_EARLY_SETUP
-
- ; setup per-cpu idle task as "current" on this CPU
- ld r0, [@secondary_idle_tsk]
-diff --git a/arch/arc/mm/cache_arc700.c b/arch/arc/mm/cache_arc700.c
-index 400c663b21c2..1f676c4794e0 100644
---- a/arch/arc/mm/cache_arc700.c
-+++ b/arch/arc/mm/cache_arc700.c
-@@ -73,37 +73,9 @@
- #include
- #include
-
--/* Instruction cache related Auxiliary registers */
--#define ARC_REG_IC_BCR 0x77 /* Build Config reg */
--#define ARC_REG_IC_IVIC 0x10
--#define ARC_REG_IC_CTRL 0x11
--#define ARC_REG_IC_IVIL 0x19
--#if (CONFIG_ARC_MMU_VER > 2)
--#define ARC_REG_IC_PTAG 0x1E
--#endif
--
--/* Bit val in IC_CTRL */
--#define IC_CTRL_CACHE_DISABLE 0x1
--
--/* Data cache related Auxiliary registers */
--#define ARC_REG_DC_BCR 0x72 /* Build Config reg */
--#define ARC_REG_DC_IVDC 0x47
--#define ARC_REG_DC_CTRL 0x48
--#define ARC_REG_DC_IVDL 0x4A
--#define ARC_REG_DC_FLSH 0x4B
--#define ARC_REG_DC_FLDL 0x4C
--#if (CONFIG_ARC_MMU_VER > 2)
--#define ARC_REG_DC_PTAG 0x5C
--#endif
--
--/* Bit val in DC_CTRL */
--#define DC_CTRL_INV_MODE_FLUSH 0x40
--#define DC_CTRL_FLUSH_STATUS 0x100
--
--char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len)
-+char *arc_cache_mumbojumbo(int c, char *buf, int len)
- {
- int n = 0;
-- unsigned int c = smp_processor_id();
-
- #define PR_CACHE(p, enb, str) \
- { \
-@@ -169,72 +141,43 @@ void read_decode_cache_bcr(void)
- */
- void arc_cache_init(void)
- {
-- unsigned int cpu = smp_processor_id();
-- struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache;
-- struct cpuinfo_arc_cache *dc = &cpuinfo_arc700[cpu].dcache;
-- unsigned int dcache_does_alias, temp;
-+ unsigned int __maybe_unused cpu = smp_processor_id();
-+ struct cpuinfo_arc_cache __maybe_unused *ic, __maybe_unused *dc;
- char str[256];
-
- printk(arc_cache_mumbojumbo(0, str, sizeof(str)));
-
-- if (!ic->ver)
-- goto chk_dc;
--
--#ifdef CONFIG_ARC_HAS_ICACHE
-- /* 1. Confirm some of I-cache params which Linux assumes */
-- if (ic->line_len != L1_CACHE_BYTES)
-- panic("Cache H/W doesn't match kernel Config");
--
-- if (ic->ver != CONFIG_ARC_MMU_VER)
-- panic("Cache ver doesn't match MMU ver\n");
--#endif
--
-- /* Enable/disable I-Cache */
-- temp = read_aux_reg(ARC_REG_IC_CTRL);
--
- #ifdef CONFIG_ARC_HAS_ICACHE
-- temp &= ~IC_CTRL_CACHE_DISABLE;
--#else
-- temp |= IC_CTRL_CACHE_DISABLE;
-+ ic = &cpuinfo_arc700[cpu].icache;
-+ if (ic->ver) {
-+ if (ic->line_len != L1_CACHE_BYTES)
-+ panic("ICache line [%d] != kernel Config [%d]",
-+ ic->line_len, L1_CACHE_BYTES);
-+
-+ if (ic->ver != CONFIG_ARC_MMU_VER)
-+ panic("Cache ver [%d] doesn't match MMU ver [%d]\n",
-+ ic->ver, CONFIG_ARC_MMU_VER);
-+ }
- #endif
-
-- write_aux_reg(ARC_REG_IC_CTRL, temp);
--
--chk_dc:
-- if (!dc->ver)
-- return;
--
- #ifdef CONFIG_ARC_HAS_DCACHE
-- if (dc->line_len != L1_CACHE_BYTES)
-- panic("Cache H/W doesn't match kernel Config");
-+ dc = &cpuinfo_arc700[cpu].dcache;
-+ if (dc->ver) {
-+ unsigned int dcache_does_alias;
-
-- /* check for D-Cache aliasing */
-- dcache_does_alias = (dc->sz / dc->assoc) > PAGE_SIZE;
-+ if (dc->line_len != L1_CACHE_BYTES)
-+ panic("DCache line [%d] != kernel Config [%d]",
-+ dc->line_len, L1_CACHE_BYTES);
-
-- if (dcache_does_alias && !cache_is_vipt_aliasing())
-- panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
-- else if (!dcache_does_alias && cache_is_vipt_aliasing())
-- panic("Don't need CONFIG_ARC_CACHE_VIPT_ALIASING\n");
--#endif
--
-- /* Set the default Invalidate Mode to "simpy discard dirty lines"
-- * as this is more frequent then flush before invalidate
-- * Ofcourse we toggle this default behviour when desired
-- */
-- temp = read_aux_reg(ARC_REG_DC_CTRL);
-- temp &= ~DC_CTRL_INV_MODE_FLUSH;
-+ /* check for D-Cache aliasing */
-+ dcache_does_alias = (dc->sz / dc->assoc) > PAGE_SIZE;
-
--#ifdef CONFIG_ARC_HAS_DCACHE
-- /* Enable D-Cache: Clear Bit 0 */
-- write_aux_reg(ARC_REG_DC_CTRL, temp & ~IC_CTRL_CACHE_DISABLE);
--#else
-- /* Flush D cache */
-- write_aux_reg(ARC_REG_DC_FLSH, 0x1);
-- /* Disable D cache */
-- write_aux_reg(ARC_REG_DC_CTRL, temp | IC_CTRL_CACHE_DISABLE);
-+ if (dcache_does_alias && !cache_is_vipt_aliasing())
-+ panic("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n");
-+ else if (!dcache_does_alias && cache_is_vipt_aliasing())
-+ panic("Don't need CONFIG_ARC_CACHE_VIPT_ALIASING\n");
-+ }
- #endif
--
-- return;
- }
-
- #define OP_INV 0x1
-@@ -254,12 +197,16 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr,
-
- if (cacheop == OP_INV_IC) {
- aux_cmd = ARC_REG_IC_IVIL;
-+#if (CONFIG_ARC_MMU_VER > 2)
- aux_tag = ARC_REG_IC_PTAG;
-+#endif
- }
- else {
- /* d$ cmd: INV (discard or wback-n-discard) OR FLUSH (wback) */
- aux_cmd = cacheop & OP_INV ? ARC_REG_DC_IVDL : ARC_REG_DC_FLDL;
-+#if (CONFIG_ARC_MMU_VER > 2)
- aux_tag = ARC_REG_DC_PTAG;
-+#endif
- }
-
- /* Ensure we properly floor/ceil the non-line aligned/sized requests
-diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
-index 992aaba603b5..b463f2aa5a61 100644
---- a/arch/mips/include/asm/ftrace.h
-+++ b/arch/mips/include/asm/ftrace.h
-@@ -24,7 +24,7 @@ do { \
- asm volatile ( \
- "1: " load " %[tmp_dst], 0(%[tmp_src])\n" \
- " li %[tmp_err], 0\n" \
-- "2:\n" \
-+ "2: .insn\n" \
- \
- ".section .fixup, \"ax\"\n" \
- "3: li %[tmp_err], 1\n" \
-@@ -46,7 +46,7 @@ do { \
- asm volatile ( \
- "1: " store " %[tmp_src], 0(%[tmp_dst])\n"\
- " li %[tmp_err], 0\n" \
-- "2:\n" \
-+ "2: .insn\n" \
- \
- ".section .fixup, \"ax\"\n" \
- "3: li %[tmp_err], 1\n" \
-diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
-index 65d452aa1fda..dd012c599ad1 100644
---- a/arch/mips/mm/tlbex.c
-+++ b/arch/mips/mm/tlbex.c
-@@ -1057,6 +1057,7 @@ static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
- struct mips_huge_tlb_info {
- int huge_pte;
- int restore_scratch;
-+ bool need_reload_pte;
- };
-
- static struct mips_huge_tlb_info
-@@ -1071,6 +1072,7 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
-
- rv.huge_pte = scratch;
- rv.restore_scratch = 0;
-+ rv.need_reload_pte = false;
-
- if (check_for_high_segbits) {
- UASM_i_MFC0(p, tmp, C0_BADVADDR);
-@@ -1259,6 +1261,7 @@ static void build_r4000_tlb_refill_handler(void)
- } else {
- htlb_info.huge_pte = K0;
- htlb_info.restore_scratch = 0;
-+ htlb_info.need_reload_pte = true;
- vmalloc_mode = refill_noscratch;
- /*
- * create the plain linear handler
-@@ -1295,7 +1298,8 @@ static void build_r4000_tlb_refill_handler(void)
- }
- #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
- uasm_l_tlb_huge_update(&l, p);
-- UASM_i_LW(&p, K0, 0, K1);
-+ if (htlb_info.need_reload_pte)
-+ UASM_i_LW(&p, htlb_info.huge_pte, 0, K1);
- build_huge_update_entries(&p, htlb_info.huge_pte, K1);
- build_huge_tlb_write_entry(&p, &l, &r, K0, tlb_random,
- htlb_info.restore_scratch);
-diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
-index a8fe5aa3d34f..3b46eed1dcf6 100644
---- a/arch/powerpc/platforms/pseries/dlpar.c
-+++ b/arch/powerpc/platforms/pseries/dlpar.c
-@@ -380,7 +380,7 @@ static int dlpar_online_cpu(struct device_node *dn)
- BUG_ON(get_cpu_current_state(cpu)
- != CPU_STATE_OFFLINE);
- cpu_maps_update_done();
-- rc = cpu_up(cpu);
-+ rc = device_online(get_cpu_device(cpu));
- if (rc)
- goto out;
- cpu_maps_update_begin();
-@@ -463,7 +463,7 @@ static int dlpar_offline_cpu(struct device_node *dn)
- if (get_cpu_current_state(cpu) == CPU_STATE_ONLINE) {
- set_preferred_offline_state(cpu, CPU_STATE_OFFLINE);
- cpu_maps_update_done();
-- rc = cpu_down(cpu);
-+ rc = device_offline(get_cpu_device(cpu));
- if (rc)
- goto out;
- cpu_maps_update_begin();
-diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
-index ff1465c0519c..5acf89c1afc5 100644
---- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c
-+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
-@@ -118,7 +118,7 @@ static struct plat_sci_port scif0_platform_data = {
- };
-
- static struct resource scif0_resources[] = {
-- DEFINE_RES_MEM(0xfffffe80, 0x100),
-+ DEFINE_RES_MEM(0xfffffe80, 0x10),
- DEFINE_RES_IRQ(evt2irq(0x4e0)),
- };
-
-@@ -143,7 +143,7 @@ static struct plat_sci_port scif1_platform_data = {
- };
-
- static struct resource scif1_resources[] = {
-- DEFINE_RES_MEM(0xa4000150, 0x100),
-+ DEFINE_RES_MEM(0xa4000150, 0x10),
- DEFINE_RES_IRQ(evt2irq(0x900)),
- };
-
-@@ -169,7 +169,7 @@ static struct plat_sci_port scif2_platform_data = {
- };
-
- static struct resource scif2_resources[] = {
-- DEFINE_RES_MEM(0xa4000140, 0x100),
-+ DEFINE_RES_MEM(0xa4000140, 0x10),
- DEFINE_RES_IRQ(evt2irq(0x880)),
- };
-
-diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
-index 3716e6952554..e8ab93c3e638 100644
---- a/arch/um/drivers/ubd_kern.c
-+++ b/arch/um/drivers/ubd_kern.c
-@@ -1277,7 +1277,7 @@ static void do_ubd_request(struct request_queue *q)
-
- while(1){
- struct ubd *dev = q->queuedata;
-- if(dev->end_sg == 0){
-+ if(dev->request == NULL){
- struct request *req = blk_fetch_request(q);
- if(req == NULL)
- return;
-@@ -1299,7 +1299,8 @@ static void do_ubd_request(struct request_queue *q)
- return;
- }
- prepare_flush_request(req, io_req);
-- submit_request(io_req, dev);
-+ if (submit_request(io_req, dev) == false)
-+ return;
- }
-
- while(dev->start_sg < dev->end_sg){
-diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
-index e4098912fef2..98aa930230ec 100644
---- a/arch/x86/Kconfig
-+++ b/arch/x86/Kconfig
-@@ -2436,12 +2436,9 @@ config X86_DMA_REMAP
- depends on STA2X11
-
- config IOSF_MBI
-- bool
-+ tristate
-+ default m
- depends on PCI
-- ---help---
-- To be selected by modules requiring access to the Intel OnChip System
-- Fabric (IOSF) Sideband MailBox Interface (MBI). For MBI platforms
-- enumerable by PCI.
-
- source "net/Kconfig"
-
-diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
-index 4299eb05023c..92a2e9333620 100644
---- a/arch/x86/ia32/ia32entry.S
-+++ b/arch/x86/ia32/ia32entry.S
-@@ -151,6 +151,16 @@ ENTRY(ia32_sysenter_target)
- 1: movl (%rbp),%ebp
- _ASM_EXTABLE(1b,ia32_badarg)
- ASM_CLAC
-+
-+ /*
-+ * Sysenter doesn't filter flags, so we need to clear NT
-+ * ourselves. To save a few cycles, we can check whether
-+ * NT was set instead of doing an unconditional popfq.
-+ */
-+ testl $X86_EFLAGS_NT,EFLAGS-ARGOFFSET(%rsp)
-+ jnz sysenter_fix_flags
-+sysenter_flags_fixed:
-+
- orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
- testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
- CFI_REMEMBER_STATE
-@@ -184,6 +194,8 @@ sysexit_from_sys_call:
- TRACE_IRQS_ON
- ENABLE_INTERRUPTS_SYSEXIT32
-
-+ CFI_RESTORE_STATE
-+
- #ifdef CONFIG_AUDITSYSCALL
- .macro auditsys_entry_common
- movl %esi,%r9d /* 6th arg: 4th syscall arg */
-@@ -226,7 +238,6 @@ sysexit_from_sys_call:
- .endm
-
- sysenter_auditsys:
-- CFI_RESTORE_STATE
- auditsys_entry_common
- movl %ebp,%r9d /* reload 6th syscall arg */
- jmp sysenter_dispatch
-@@ -235,6 +246,11 @@ sysexit_audit:
- auditsys_exit sysexit_from_sys_call
- #endif
-
-+sysenter_fix_flags:
-+ pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED)
-+ popfq_cfi
-+ jmp sysenter_flags_fixed
-+
- sysenter_tracesys:
- #ifdef CONFIG_AUDITSYSCALL
- testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
-diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
-index 9c999c1674fa..01f15b227d7e 100644
---- a/arch/x86/include/asm/elf.h
-+++ b/arch/x86/include/asm/elf.h
-@@ -155,8 +155,9 @@ do { \
- #define elf_check_arch(x) \
- ((x)->e_machine == EM_X86_64)
-
--#define compat_elf_check_arch(x) \
-- (elf_check_arch_ia32(x) || (x)->e_machine == EM_X86_64)
-+#define compat_elf_check_arch(x) \
-+ (elf_check_arch_ia32(x) || \
-+ (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64))
-
- #if __USER32_DS != __USER_DS
- # error "The following code assumes __USER32_DS == __USER_DS"
-diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
-index 8e71c7941767..57995f0596a6 100644
---- a/arch/x86/include/asm/iosf_mbi.h
-+++ b/arch/x86/include/asm/iosf_mbi.h
-@@ -50,6 +50,32 @@
- #define BT_MBI_PCIE_READ 0x00
- #define BT_MBI_PCIE_WRITE 0x01
-
-+/* Quark available units */
-+#define QRK_MBI_UNIT_HBA 0x00
-+#define QRK_MBI_UNIT_HB 0x03
-+#define QRK_MBI_UNIT_RMU 0x04
-+#define QRK_MBI_UNIT_MM 0x05
-+#define QRK_MBI_UNIT_MMESRAM 0x05
-+#define QRK_MBI_UNIT_SOC 0x31
-+
-+/* Quark read/write opcodes */
-+#define QRK_MBI_HBA_READ 0x10
-+#define QRK_MBI_HBA_WRITE 0x11
-+#define QRK_MBI_HB_READ 0x10
-+#define QRK_MBI_HB_WRITE 0x11
-+#define QRK_MBI_RMU_READ 0x10
-+#define QRK_MBI_RMU_WRITE 0x11
-+#define QRK_MBI_MM_READ 0x10
-+#define QRK_MBI_MM_WRITE 0x11
-+#define QRK_MBI_MMESRAM_READ 0x12
-+#define QRK_MBI_MMESRAM_WRITE 0x13
-+#define QRK_MBI_SOC_READ 0x06
-+#define QRK_MBI_SOC_WRITE 0x07
-+
-+#if IS_ENABLED(CONFIG_IOSF_MBI)
-+
-+bool iosf_mbi_available(void);
-+
- /**
- * iosf_mbi_read() - MailBox Interface read command
- * @port: port indicating subunit being accessed
-@@ -87,4 +113,33 @@ int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
- */
- int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
-
-+#else /* CONFIG_IOSF_MBI is not enabled */
-+static inline
-+bool iosf_mbi_available(void)
-+{
-+ return false;
-+}
-+
-+static inline
-+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
-+{
-+ WARN(1, "IOSF_MBI driver not available");
-+ return -EPERM;
-+}
-+
-+static inline
-+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
-+{
-+ WARN(1, "IOSF_MBI driver not available");
-+ return -EPERM;
-+}
-+
-+static inline
-+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
-+{
-+ WARN(1, "IOSF_MBI driver not available");
-+ return -EPERM;
-+}
-+#endif /* CONFIG_IOSF_MBI */
-+
- #endif /* IOSF_MBI_SYMS_H */
-diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
-index ac63ea4af5b0..e9dc02968cf8 100644
---- a/arch/x86/include/asm/kvm_host.h
-+++ b/arch/x86/include/asm/kvm_host.h
-@@ -984,6 +984,20 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code)
- kvm_queue_exception_e(vcpu, GP_VECTOR, error_code);
- }
-
-+static inline u64 get_canonical(u64 la)
-+{
-+ return ((int64_t)la << 16) >> 16;
-+}
-+
-+static inline bool is_noncanonical_address(u64 la)
-+{
-+#ifdef CONFIG_X86_64
-+ return get_canonical(la) != la;
-+#else
-+ return false;
-+#endif
-+}
-+
- #define TSS_IOPB_BASE_OFFSET 0x66
- #define TSS_BASE_SIZE 0x68
- #define TSS_IOPB_SIZE (65536 / 8)
-@@ -1042,7 +1056,7 @@ int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
- void kvm_vcpu_reset(struct kvm_vcpu *vcpu);
-
- void kvm_define_shared_msr(unsigned index, u32 msr);
--void kvm_set_shared_msr(unsigned index, u64 val, u64 mask);
-+int kvm_set_shared_msr(unsigned index, u64 val, u64 mask);
-
- bool kvm_is_linear_rip(struct kvm_vcpu *vcpu, unsigned long linear_rip);
-
-diff --git a/arch/x86/include/uapi/asm/vmx.h b/arch/x86/include/uapi/asm/vmx.h
-index 0e79420376eb..990a2fe1588d 100644
---- a/arch/x86/include/uapi/asm/vmx.h
-+++ b/arch/x86/include/uapi/asm/vmx.h
-@@ -67,6 +67,7 @@
- #define EXIT_REASON_EPT_MISCONFIG 49
- #define EXIT_REASON_INVEPT 50
- #define EXIT_REASON_PREEMPTION_TIMER 52
-+#define EXIT_REASON_INVVPID 53
- #define EXIT_REASON_WBINVD 54
- #define EXIT_REASON_XSETBV 55
- #define EXIT_REASON_APIC_WRITE 56
-@@ -114,6 +115,7 @@
- { EXIT_REASON_EOI_INDUCED, "EOI_INDUCED" }, \
- { EXIT_REASON_INVALID_STATE, "INVALID_STATE" }, \
- { EXIT_REASON_INVD, "INVD" }, \
-+ { EXIT_REASON_INVVPID, "INVVPID" }, \
- { EXIT_REASON_INVPCID, "INVPCID" }
-
- #endif /* _UAPIVMX_H */
-diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
-index 7f26c9a70a9e..523f147b2470 100644
---- a/arch/x86/kernel/apic/apic.c
-+++ b/arch/x86/kernel/apic/apic.c
-@@ -1290,7 +1290,7 @@ void setup_local_APIC(void)
- unsigned int value, queued;
- int i, j, acked = 0;
- unsigned long long tsc = 0, ntsc;
-- long long max_loops = cpu_khz;
-+ long long max_loops = cpu_khz ? cpu_khz : 1000000;
-
- if (cpu_has_tsc)
- rdtscll(tsc);
-@@ -1387,7 +1387,7 @@ void setup_local_APIC(void)
- break;
- }
- if (queued) {
-- if (cpu_has_tsc) {
-+ if (cpu_has_tsc && cpu_khz) {
- rdtscll(ntsc);
- max_loops = (cpu_khz << 10) - (ntsc - tsc);
- } else
-diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
-index 8e28bf2fc3ef..3f27f5fd0847 100644
---- a/arch/x86/kernel/cpu/common.c
-+++ b/arch/x86/kernel/cpu/common.c
-@@ -1141,7 +1141,7 @@ void syscall_init(void)
- /* Flags to clear on syscall */
- wrmsrl(MSR_SYSCALL_MASK,
- X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|
-- X86_EFLAGS_IOPL|X86_EFLAGS_AC);
-+ X86_EFLAGS_IOPL|X86_EFLAGS_AC|X86_EFLAGS_NT);
- }
-
- /*
-diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
-index c1a07d33e67e..66746a880dec 100644
---- a/arch/x86/kernel/cpu/intel.c
-+++ b/arch/x86/kernel/cpu/intel.c
-@@ -383,6 +383,13 @@ static void init_intel(struct cpuinfo_x86 *c)
- detect_extended_topology(c);
-
- l2 = init_intel_cacheinfo(c);
-+
-+ /* Detect legacy cache sizes if init_intel_cacheinfo did not */
-+ if (l2 == 0) {
-+ cpu_detect_cache_sizes(c);
-+ l2 = c->x86_cache_size;
-+ }
-+
- if (c->cpuid_level > 9) {
- unsigned eax = cpuid_eax(10);
- /* Check for version and the number of counters */
-@@ -497,6 +504,13 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
- */
- if ((c->x86 == 6) && (c->x86_model == 11) && (size == 0))
- size = 256;
-+
-+ /*
-+ * Intel Quark SoC X1000 contains a 4-way set associative
-+ * 16K cache with a 16 byte cache line and 256 lines per tag
-+ */
-+ if ((c->x86 == 5) && (c->x86_model == 9))
-+ size = 16;
- return size;
- }
- #endif
-@@ -724,7 +738,8 @@ static const struct cpu_dev intel_cpu_dev = {
- [3] = "OverDrive PODP5V83",
- [4] = "Pentium MMX",
- [7] = "Mobile Pentium 75 - 200",
-- [8] = "Mobile Pentium MMX"
-+ [8] = "Mobile Pentium MMX",
-+ [9] = "Quark SoC X1000",
- }
- },
- { .family = 6, .model_names =
-diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
-index c3aae6672843..2e97b3cfa6c7 100644
---- a/arch/x86/kernel/iosf_mbi.c
-+++ b/arch/x86/kernel/iosf_mbi.c
-@@ -25,6 +25,10 @@
-
- #include
-
-+#define PCI_DEVICE_ID_BAYTRAIL 0x0F00
-+#define PCI_DEVICE_ID_BRASWELL 0x2280
-+#define PCI_DEVICE_ID_QUARK_X1000 0x0958
-+
- static DEFINE_SPINLOCK(iosf_mbi_lock);
-
- static inline u32 iosf_mbi_form_mcr(u8 op, u8 port, u8 offset)
-@@ -177,6 +181,13 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
- }
- EXPORT_SYMBOL(iosf_mbi_modify);
-
-+bool iosf_mbi_available(void)
-+{
-+ /* Mbi isn't hot-pluggable. No remove routine is provided */
-+ return mbi_pdev;
-+}
-+EXPORT_SYMBOL(iosf_mbi_available);
-+
- static int iosf_mbi_probe(struct pci_dev *pdev,
- const struct pci_device_id *unused)
- {
-@@ -193,7 +204,9 @@ static int iosf_mbi_probe(struct pci_dev *pdev,
- }
-
- static DEFINE_PCI_DEVICE_TABLE(iosf_mbi_pci_ids) = {
-- { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0F00) },
-+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_BAYTRAIL) },
-+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_BRASWELL) },
-+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_QUARK_X1000) },
- { 0, },
- };
- MODULE_DEVICE_TABLE(pci, iosf_mbi_pci_ids);
-diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
-index 9e5de6813e1f..b88fc86309bc 100644
---- a/arch/x86/kernel/signal.c
-+++ b/arch/x86/kernel/signal.c
-@@ -673,6 +673,11 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
- * handler too.
- */
- regs->flags &= ~(X86_EFLAGS_DF|X86_EFLAGS_RF|X86_EFLAGS_TF);
-+ /*
-+ * Ensure the signal handler starts with the new fpu state.
-+ */
-+ if (used_math())
-+ drop_init_fpu(current);
- }
- signal_setup_done(failed, ksig, test_thread_flag(TIF_SINGLESTEP));
- }
-diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
-index e0d1d7a8354e..de0290605903 100644
---- a/arch/x86/kernel/tsc.c
-+++ b/arch/x86/kernel/tsc.c
-@@ -1173,14 +1173,17 @@ void __init tsc_init(void)
-
- x86_init.timers.tsc_pre_init();
-
-- if (!cpu_has_tsc)
-+ if (!cpu_has_tsc) {
-+ setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
- return;
-+ }
-
- tsc_khz = x86_platform.calibrate_tsc();
- cpu_khz = tsc_khz;
-
- if (!tsc_khz) {
- mark_tsc_unstable("could not calculate TSC khz");
-+ setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
- return;
- }
-
-diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
-index a4b451c6addf..dd50e26c58f6 100644
---- a/arch/x86/kernel/xsave.c
-+++ b/arch/x86/kernel/xsave.c
-@@ -268,8 +268,6 @@ int save_xstate_sig(void __user *buf, void __user *buf_fx, int size)
- if (use_fxsr() && save_xstate_epilog(buf_fx, ia32_fxstate))
- return -1;
-
-- drop_init_fpu(tsk); /* trigger finit */
--
- return 0;
- }
-
-@@ -399,8 +397,11 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
- set_used_math();
- }
-
-- if (use_eager_fpu())
-+ if (use_eager_fpu()) {
-+ preempt_disable();
- math_state_restore();
-+ preempt_enable();
-+ }
-
- return err;
- } else {
-diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
-index 7bff3e2a7a11..38d3751472e4 100644
---- a/arch/x86/kvm/emulate.c
-+++ b/arch/x86/kvm/emulate.c
-@@ -498,11 +498,6 @@ static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc)
- masked_increment(reg_rmw(ctxt, VCPU_REGS_RSP), stack_mask(ctxt), inc);
- }
-
--static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
--{
-- register_address_increment(ctxt, &ctxt->_eip, rel);
--}
--
- static u32 desc_limit_scaled(struct desc_struct *desc)
- {
- u32 limit = get_desc_limit(desc);
-@@ -576,6 +571,38 @@ static int emulate_nm(struct x86_emulate_ctxt *ctxt)
- return emulate_exception(ctxt, NM_VECTOR, 0, false);
- }
-
-+static inline int assign_eip_far(struct x86_emulate_ctxt *ctxt, ulong dst,
-+ int cs_l)
-+{
-+ switch (ctxt->op_bytes) {
-+ case 2:
-+ ctxt->_eip = (u16)dst;
-+ break;
-+ case 4:
-+ ctxt->_eip = (u32)dst;
-+ break;
-+ case 8:
-+ if ((cs_l && is_noncanonical_address(dst)) ||
-+ (!cs_l && (dst & ~(u32)-1)))
-+ return emulate_gp(ctxt, 0);
-+ ctxt->_eip = dst;
-+ break;
-+ default:
-+ WARN(1, "unsupported eip assignment size\n");
-+ }
-+ return X86EMUL_CONTINUE;
-+}
-+
-+static inline int assign_eip_near(struct x86_emulate_ctxt *ctxt, ulong dst)
-+{
-+ return assign_eip_far(ctxt, dst, ctxt->mode == X86EMUL_MODE_PROT64);
-+}
-+
-+static inline int jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
-+{
-+ return assign_eip_near(ctxt, ctxt->_eip + rel);
-+}
-+
- static u16 get_segment_selector(struct x86_emulate_ctxt *ctxt, unsigned seg)
- {
- u16 selector;
-@@ -1958,13 +1985,15 @@ static int em_grp45(struct x86_emulate_ctxt *ctxt)
- case 2: /* call near abs */ {
- long int old_eip;
- old_eip = ctxt->_eip;
-- ctxt->_eip = ctxt->src.val;
-+ rc = assign_eip_near(ctxt, ctxt->src.val);
-+ if (rc != X86EMUL_CONTINUE)
-+ break;
- ctxt->src.val = old_eip;
- rc = em_push(ctxt);
- break;
- }
- case 4: /* jmp abs */
-- ctxt->_eip = ctxt->src.val;
-+ rc = assign_eip_near(ctxt, ctxt->src.val);
- break;
- case 5: /* jmp far */
- rc = em_jmp_far(ctxt);
-@@ -1996,10 +2025,14 @@ static int em_cmpxchg8b(struct x86_emulate_ctxt *ctxt)
-
- static int em_ret(struct x86_emulate_ctxt *ctxt)
- {
-- ctxt->dst.type = OP_REG;
-- ctxt->dst.addr.reg = &ctxt->_eip;
-- ctxt->dst.bytes = ctxt->op_bytes;
-- return em_pop(ctxt);
-+ int rc;
-+ unsigned long eip;
-+
-+ rc = emulate_pop(ctxt, &eip, ctxt->op_bytes);
-+ if (rc != X86EMUL_CONTINUE)
-+ return rc;
-+
-+ return assign_eip_near(ctxt, eip);
- }
-
- static int em_ret_far(struct x86_emulate_ctxt *ctxt)
-@@ -2277,7 +2310,7 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt)
- {
- const struct x86_emulate_ops *ops = ctxt->ops;
- struct desc_struct cs, ss;
-- u64 msr_data;
-+ u64 msr_data, rcx, rdx;
- int usermode;
- u16 cs_sel = 0, ss_sel = 0;
-
-@@ -2293,6 +2326,9 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt)
- else
- usermode = X86EMUL_MODE_PROT32;
-
-+ rcx = reg_read(ctxt, VCPU_REGS_RCX);
-+ rdx = reg_read(ctxt, VCPU_REGS_RDX);
-+
- cs.dpl = 3;
- ss.dpl = 3;
- ops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data);
-@@ -2310,6 +2346,9 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt)
- ss_sel = cs_sel + 8;
- cs.d = 0;
- cs.l = 1;
-+ if (is_noncanonical_address(rcx) ||
-+ is_noncanonical_address(rdx))
-+ return emulate_gp(ctxt, 0);
- break;
- }
- cs_sel |= SELECTOR_RPL_MASK;
-@@ -2318,8 +2357,8 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt)
- ops->set_segment(ctxt, cs_sel, &cs, 0, VCPU_SREG_CS);
- ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS);
-
-- ctxt->_eip = reg_read(ctxt, VCPU_REGS_RDX);
-- *reg_write(ctxt, VCPU_REGS_RSP) = reg_read(ctxt, VCPU_REGS_RCX);
-+ ctxt->_eip = rdx;
-+ *reg_write(ctxt, VCPU_REGS_RSP) = rcx;
-
- return X86EMUL_CONTINUE;
- }
-@@ -2858,10 +2897,13 @@ static int em_aad(struct x86_emulate_ctxt *ctxt)
-
- static int em_call(struct x86_emulate_ctxt *ctxt)
- {
-+ int rc;
- long rel = ctxt->src.val;
-
- ctxt->src.val = (unsigned long)ctxt->_eip;
-- jmp_rel(ctxt, rel);
-+ rc = jmp_rel(ctxt, rel);
-+ if (rc != X86EMUL_CONTINUE)
-+ return rc;
- return em_push(ctxt);
- }
-
-@@ -2893,11 +2935,12 @@ static int em_call_far(struct x86_emulate_ctxt *ctxt)
- static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt)
- {
- int rc;
-+ unsigned long eip;
-
-- ctxt->dst.type = OP_REG;
-- ctxt->dst.addr.reg = &ctxt->_eip;
-- ctxt->dst.bytes = ctxt->op_bytes;
-- rc = emulate_pop(ctxt, &ctxt->dst.val, ctxt->op_bytes);
-+ rc = emulate_pop(ctxt, &eip, ctxt->op_bytes);
-+ if (rc != X86EMUL_CONTINUE)
-+ return rc;
-+ rc = assign_eip_near(ctxt, eip);
- if (rc != X86EMUL_CONTINUE)
- return rc;
- rsp_increment(ctxt, ctxt->src.val);
-@@ -3227,20 +3270,24 @@ static int em_lmsw(struct x86_emulate_ctxt *ctxt)
-
- static int em_loop(struct x86_emulate_ctxt *ctxt)
- {
-+ int rc = X86EMUL_CONTINUE;
-+
- register_address_increment(ctxt, reg_rmw(ctxt, VCPU_REGS_RCX), -1);
- if ((address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) != 0) &&
- (ctxt->b == 0xe2 || test_cc(ctxt->b ^ 0x5, ctxt->eflags)))
-- jmp_rel(ctxt, ctxt->src.val);
-+ rc = jmp_rel(ctxt, ctxt->src.val);
-
-- return X86EMUL_CONTINUE;
-+ return rc;
- }
-
- static int em_jcxz(struct x86_emulate_ctxt *ctxt)
- {
-+ int rc = X86EMUL_CONTINUE;
-+
- if (address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) == 0)
-- jmp_rel(ctxt, ctxt->src.val);
-+ rc = jmp_rel(ctxt, ctxt->src.val);
-
-- return X86EMUL_CONTINUE;
-+ return rc;
- }
-
- static int em_in(struct x86_emulate_ctxt *ctxt)
-@@ -4637,7 +4684,7 @@ special_insn:
- break;
- case 0x70 ... 0x7f: /* jcc (short) */
- if (test_cc(ctxt->b, ctxt->eflags))
-- jmp_rel(ctxt, ctxt->src.val);
-+ rc = jmp_rel(ctxt, ctxt->src.val);
- break;
- case 0x8d: /* lea r16/r32, m */
- ctxt->dst.val = ctxt->src.addr.mem.ea;
-@@ -4666,7 +4713,7 @@ special_insn:
- break;
- case 0xe9: /* jmp rel */
- case 0xeb: /* jmp rel short */
-- jmp_rel(ctxt, ctxt->src.val);
-+ rc = jmp_rel(ctxt, ctxt->src.val);
- ctxt->dst.type = OP_NONE; /* Disable writeback. */
- break;
- case 0xf4: /* hlt */
-@@ -4786,7 +4833,7 @@ twobyte_insn:
- break;
- case 0x80 ... 0x8f: /* jnz rel, etc*/
- if (test_cc(ctxt->b, ctxt->eflags))
-- jmp_rel(ctxt, ctxt->src.val);
-+ rc = jmp_rel(ctxt, ctxt->src.val);
- break;
- case 0x90 ... 0x9f: /* setcc r/m8 */
- ctxt->dst.val = test_cc(ctxt->b, ctxt->eflags);
-diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
-index 518d86471b76..298781d4cfb4 100644
---- a/arch/x86/kvm/i8254.c
-+++ b/arch/x86/kvm/i8254.c
-@@ -262,8 +262,10 @@ void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu)
- return;
-
- timer = &pit->pit_state.timer;
-+ mutex_lock(&pit->pit_state.lock);
- if (hrtimer_cancel(timer))
- hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
-+ mutex_unlock(&pit->pit_state.lock);
- }
-
- static void destroy_pit_timer(struct kvm_pit *pit)
-diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
-index 2de1bc09a8d4..9643eda60a52 100644
---- a/arch/x86/kvm/svm.c
-+++ b/arch/x86/kvm/svm.c
-@@ -3213,7 +3213,7 @@ static int wrmsr_interception(struct vcpu_svm *svm)
- msr.host_initiated = false;
-
- svm->next_rip = kvm_rip_read(&svm->vcpu) + 2;
-- if (svm_set_msr(&svm->vcpu, &msr)) {
-+ if (kvm_set_msr(&svm->vcpu, &msr)) {
- trace_kvm_msr_write_ex(ecx, data);
- kvm_inject_gp(&svm->vcpu, 0);
- } else {
-@@ -3495,9 +3495,9 @@ static int handle_exit(struct kvm_vcpu *vcpu)
-
- if (exit_code >= ARRAY_SIZE(svm_exit_handlers)
- || !svm_exit_handlers[exit_code]) {
-- kvm_run->exit_reason = KVM_EXIT_UNKNOWN;
-- kvm_run->hw.hardware_exit_reason = exit_code;
-- return 0;
-+ WARN_ONCE(1, "vmx: unexpected exit reason 0x%x\n", exit_code);
-+ kvm_queue_exception(vcpu, UD_VECTOR);
-+ return 1;
- }
-
- return svm_exit_handlers[exit_code](svm);
-diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
-index 392752834751..0c90f4b3f835 100644
---- a/arch/x86/kvm/vmx.c
-+++ b/arch/x86/kvm/vmx.c
-@@ -2582,12 +2582,15 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
- default:
- msr = find_msr_entry(vmx, msr_index);
- if (msr) {
-+ u64 old_msr_data = msr->data;
- msr->data = data;
- if (msr - vmx->guest_msrs < vmx->save_nmsrs) {
- preempt_disable();
-- kvm_set_shared_msr(msr->index, msr->data,
-- msr->mask);
-+ ret = kvm_set_shared_msr(msr->index, msr->data,
-+ msr->mask);
- preempt_enable();
-+ if (ret)
-+ msr->data = old_msr_data;
- }
- break;
- }
-@@ -5169,7 +5172,7 @@ static int handle_wrmsr(struct kvm_vcpu *vcpu)
- msr.data = data;
- msr.index = ecx;
- msr.host_initiated = false;
-- if (vmx_set_msr(vcpu, &msr) != 0) {
-+ if (kvm_set_msr(vcpu, &msr) != 0) {
- trace_kvm_msr_write_ex(ecx, data);
- kvm_inject_gp(vcpu, 0);
- return 1;
-@@ -6441,6 +6444,12 @@ static int handle_invept(struct kvm_vcpu *vcpu)
- return 1;
- }
-
-+static int handle_invvpid(struct kvm_vcpu *vcpu)
-+{
-+ kvm_queue_exception(vcpu, UD_VECTOR);
-+ return 1;
-+}
-+
- /*
- * The exit handlers return 1 if the exit was handled fully and guest execution
- * may resume. Otherwise they set the kvm_run parameter to indicate what needs
-@@ -6486,6 +6495,7 @@ static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
- [EXIT_REASON_MWAIT_INSTRUCTION] = handle_invalid_op,
- [EXIT_REASON_MONITOR_INSTRUCTION] = handle_invalid_op,
- [EXIT_REASON_INVEPT] = handle_invept,
-+ [EXIT_REASON_INVVPID] = handle_invvpid,
- };
-
- static const int kvm_vmx_max_exit_handlers =
-@@ -6719,7 +6729,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
- case EXIT_REASON_VMPTRST: case EXIT_REASON_VMREAD:
- case EXIT_REASON_VMRESUME: case EXIT_REASON_VMWRITE:
- case EXIT_REASON_VMOFF: case EXIT_REASON_VMON:
-- case EXIT_REASON_INVEPT:
-+ case EXIT_REASON_INVEPT: case EXIT_REASON_INVVPID:
- /*
- * VMX instructions trap unconditionally. This allows L1 to
- * emulate them for its L2 guest, i.e., allows 3-level nesting!
-@@ -6884,10 +6894,10 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu)
- && kvm_vmx_exit_handlers[exit_reason])
- return kvm_vmx_exit_handlers[exit_reason](vcpu);
- else {
-- vcpu->run->exit_reason = KVM_EXIT_UNKNOWN;
-- vcpu->run->hw.hardware_exit_reason = exit_reason;
-+ WARN_ONCE(1, "vmx: unexpected exit reason 0x%x\n", exit_reason);
-+ kvm_queue_exception(vcpu, UD_VECTOR);
-+ return 1;
- }
-- return 0;
- }
-
- static void update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr)
-diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
-index 8fbd1a772272..51c2851ca243 100644
---- a/arch/x86/kvm/x86.c
-+++ b/arch/x86/kvm/x86.c
-@@ -225,20 +225,25 @@ static void kvm_shared_msr_cpu_online(void)
- shared_msr_update(i, shared_msrs_global.msrs[i]);
- }
-
--void kvm_set_shared_msr(unsigned slot, u64 value, u64 mask)
-+int kvm_set_shared_msr(unsigned slot, u64 value, u64 mask)
- {
- unsigned int cpu = smp_processor_id();
- struct kvm_shared_msrs *smsr = per_cpu_ptr(shared_msrs, cpu);
-+ int err;
-
- if (((value ^ smsr->values[slot].curr) & mask) == 0)
-- return;
-+ return 0;
- smsr->values[slot].curr = value;
-- wrmsrl(shared_msrs_global.msrs[slot], value);
-+ err = wrmsrl_safe(shared_msrs_global.msrs[slot], value);
-+ if (err)
-+ return 1;
-+
- if (!smsr->registered) {
- smsr->urn.on_user_return = kvm_on_user_return;
- user_return_notifier_register(&smsr->urn);
- smsr->registered = true;
- }
-+ return 0;
- }
- EXPORT_SYMBOL_GPL(kvm_set_shared_msr);
-
-@@ -946,7 +951,6 @@ void kvm_enable_efer_bits(u64 mask)
- }
- EXPORT_SYMBOL_GPL(kvm_enable_efer_bits);
-
--
- /*
- * Writes msr value into into the appropriate "register".
- * Returns 0 on success, non-0 otherwise.
-@@ -954,8 +958,34 @@ EXPORT_SYMBOL_GPL(kvm_enable_efer_bits);
- */
- int kvm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
- {
-+ switch (msr->index) {
-+ case MSR_FS_BASE:
-+ case MSR_GS_BASE:
-+ case MSR_KERNEL_GS_BASE:
-+ case MSR_CSTAR:
-+ case MSR_LSTAR:
-+ if (is_noncanonical_address(msr->data))
-+ return 1;
-+ break;
-+ case MSR_IA32_SYSENTER_EIP:
-+ case MSR_IA32_SYSENTER_ESP:
-+ /*
-+ * IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if
-+ * non-canonical address is written on Intel but not on
-+ * AMD (which ignores the top 32-bits, because it does
-+ * not implement 64-bit SYSENTER).
-+ *
-+ * 64-bit code should hence be able to write a non-canonical
-+ * value on AMD. Making the address canonical ensures that
-+ * vmentry does not fail on Intel after writing a non-canonical
-+ * value, and that something deterministic happens if the guest
-+ * invokes 64-bit SYSENTER.
-+ */
-+ msr->data = get_canonical(msr->data);
-+ }
- return kvm_x86_ops->set_msr(vcpu, msr);
- }
-+EXPORT_SYMBOL_GPL(kvm_set_msr);
-
- /*
- * Adapt set_msr() to msr_io()'s calling convention
-diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
-index a3488689e301..fed892de9baf 100644
---- a/arch/x86/mm/pageattr.c
-+++ b/arch/x86/mm/pageattr.c
-@@ -405,7 +405,7 @@ phys_addr_t slow_virt_to_phys(void *__virt_addr)
- psize = page_level_size(level);
- pmask = page_level_mask(level);
- offset = virt_addr & ~pmask;
-- phys_addr = pte_pfn(*pte) << PAGE_SHIFT;
-+ phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT;
- return (phys_addr | offset);
- }
- EXPORT_SYMBOL_GPL(slow_virt_to_phys);
-diff --git a/block/blk-settings.c b/block/blk-settings.c
-index 5d21239bc859..95138e9d0ad5 100644
---- a/block/blk-settings.c
-+++ b/block/blk-settings.c
-@@ -553,7 +553,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
- bottom = max(b->physical_block_size, b->io_min) + alignment;
-
- /* Verify that top and bottom intervals line up */
-- if (max(top, bottom) & (min(top, bottom) - 1)) {
-+ if (max(top, bottom) % min(top, bottom)) {
- t->misaligned = 1;
- ret = -1;
- }
-@@ -598,7 +598,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
-
- /* Find lowest common alignment_offset */
- t->alignment_offset = lcm(t->alignment_offset, alignment)
-- & (max(t->physical_block_size, t->io_min) - 1);
-+ % max(t->physical_block_size, t->io_min);
-
- /* Verify that new alignment_offset is on a logical block boundary */
- if (t->alignment_offset & (t->logical_block_size - 1)) {
-diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
-index 26487972ac54..4044cf789c7a 100644
---- a/block/scsi_ioctl.c
-+++ b/block/scsi_ioctl.c
-@@ -489,7 +489,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
-
- if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_WAIT)) {
- err = DRIVER_ERROR << 24;
-- goto out;
-+ goto error;
- }
-
- memset(sense, 0, sizeof(sense));
-@@ -499,7 +499,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
-
- blk_execute_rq(q, disk, rq, 0);
-
--out:
- err = rq->errors & 0xff; /* only 8 bit SCSI status */
- if (err) {
- if (rq->sense_len && rq->sense) {
-diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
-index a19c027b29bd..83187f497c7c 100644
---- a/crypto/algif_skcipher.c
-+++ b/crypto/algif_skcipher.c
-@@ -49,7 +49,7 @@ struct skcipher_ctx {
- struct ablkcipher_request req;
- };
-
--#define MAX_SGL_ENTS ((PAGE_SIZE - sizeof(struct skcipher_sg_list)) / \
-+#define MAX_SGL_ENTS ((4096 - sizeof(struct skcipher_sg_list)) / \
- sizeof(struct scatterlist) - 1)
-
- static inline int skcipher_sndbuf(struct sock *sk)
-diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
-index b603720b877d..37acda6fa7e4 100644
---- a/drivers/ata/libata-sff.c
-+++ b/drivers/ata/libata-sff.c
-@@ -2008,13 +2008,15 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask,
-
- DPRINTK("ata%u: bus reset via SRST\n", ap->print_id);
-
-- /* software reset. causes dev0 to be selected */
-- iowrite8(ap->ctl, ioaddr->ctl_addr);
-- udelay(20); /* FIXME: flush */
-- iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
-- udelay(20); /* FIXME: flush */
-- iowrite8(ap->ctl, ioaddr->ctl_addr);
-- ap->last_ctl = ap->ctl;
-+ if (ap->ioaddr.ctl_addr) {
-+ /* software reset. causes dev0 to be selected */
-+ iowrite8(ap->ctl, ioaddr->ctl_addr);
-+ udelay(20); /* FIXME: flush */
-+ iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
-+ udelay(20); /* FIXME: flush */
-+ iowrite8(ap->ctl, ioaddr->ctl_addr);
-+ ap->last_ctl = ap->ctl;
-+ }
-
- /* wait the port to become ready */
- return ata_sff_wait_after_reset(&ap->link, devmask, deadline);
-@@ -2215,10 +2217,6 @@ void ata_sff_error_handler(struct ata_port *ap)
-
- spin_unlock_irqrestore(ap->lock, flags);
-
-- /* ignore ata_sff_softreset if ctl isn't accessible */
-- if (softreset == ata_sff_softreset && !ap->ioaddr.ctl_addr)
-- softreset = NULL;
--
- /* ignore built-in hardresets if SCR access is not available */
- if ((hardreset == sata_std_hardreset ||
- hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link))
-diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
-index 96c6a79ef606..79dedbae282c 100644
---- a/drivers/ata/pata_serverworks.c
-+++ b/drivers/ata/pata_serverworks.c
-@@ -252,12 +252,18 @@ static void serverworks_set_dmamode(struct ata_port *ap, struct ata_device *adev
- pci_write_config_byte(pdev, 0x54, ultra_cfg);
- }
-
--static struct scsi_host_template serverworks_sht = {
-+static struct scsi_host_template serverworks_osb4_sht = {
-+ ATA_BMDMA_SHT(DRV_NAME),
-+ .sg_tablesize = LIBATA_DUMB_MAX_PRD,
-+};
-+
-+static struct scsi_host_template serverworks_csb_sht = {
- ATA_BMDMA_SHT(DRV_NAME),
- };
-
- static struct ata_port_operations serverworks_osb4_port_ops = {
- .inherits = &ata_bmdma_port_ops,
-+ .qc_prep = ata_bmdma_dumb_qc_prep,
- .cable_detect = serverworks_cable_detect,
- .mode_filter = serverworks_osb4_filter,
- .set_piomode = serverworks_set_piomode,
-@@ -266,6 +272,7 @@ static struct ata_port_operations serverworks_osb4_port_ops = {
-
- static struct ata_port_operations serverworks_csb_port_ops = {
- .inherits = &serverworks_osb4_port_ops,
-+ .qc_prep = ata_bmdma_qc_prep,
- .mode_filter = serverworks_csb_filter,
- };
-
-@@ -405,6 +412,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
- }
- };
- const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
-+ struct scsi_host_template *sht = &serverworks_csb_sht;
- int rc;
-
- rc = pcim_enable_device(pdev);
-@@ -418,6 +426,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
- /* Select non UDMA capable OSB4 if we can't do fixups */
- if (rc < 0)
- ppi[0] = &info[1];
-+ sht = &serverworks_osb4_sht;
- }
- /* setup CSB5/CSB6 : South Bridge and IDE option RAID */
- else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
-@@ -434,7 +443,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
- ppi[1] = &ata_dummy_port_info;
- }
-
-- return ata_pci_bmdma_init_one(pdev, ppi, &serverworks_sht, NULL, 0);
-+ return ata_pci_bmdma_init_one(pdev, ppi, sht, NULL, 0);
- }
-
- #ifdef CONFIG_PM
-diff --git a/drivers/base/core.c b/drivers/base/core.c
-index 2b567177ef78..6a8955e78610 100644
---- a/drivers/base/core.c
-+++ b/drivers/base/core.c
-@@ -741,12 +741,12 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj)
- return &dir->kobj;
- }
-
-+static DEFINE_MUTEX(gdp_mutex);
-
- static struct kobject *get_device_parent(struct device *dev,
- struct device *parent)
- {
- if (dev->class) {
-- static DEFINE_MUTEX(gdp_mutex);
- struct kobject *kobj = NULL;
- struct kobject *parent_kobj;
- struct kobject *k;
-@@ -810,7 +810,9 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
- glue_dir->kset != &dev->class->p->glue_dirs)
- return;
-
-+ mutex_lock(&gdp_mutex);
- kobject_put(glue_dir);
-+ mutex_unlock(&gdp_mutex);
- }
-
- static void cleanup_device_parent(struct device *dev)
-diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c
-index 89c497c630b4..04a14e0f8878 100644
---- a/drivers/block/drbd/drbd_interval.c
-+++ b/drivers/block/drbd/drbd_interval.c
-@@ -79,6 +79,7 @@ bool
- drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
- {
- struct rb_node **new = &root->rb_node, *parent = NULL;
-+ sector_t this_end = this->sector + (this->size >> 9);
-
- BUG_ON(!IS_ALIGNED(this->size, 512));
-
-@@ -87,6 +88,8 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
- rb_entry(*new, struct drbd_interval, rb);
-
- parent = *new;
-+ if (here->end < this_end)
-+ here->end = this_end;
- if (this->sector < here->sector)
- new = &(*new)->rb_left;
- else if (this->sector > here->sector)
-@@ -99,6 +102,7 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
- return false;
- }
-
-+ this->end = this_end;
- rb_link_node(&this->rb, parent, new);
- rb_insert_augmented(&this->rb, root, &augment_callbacks);
- return true;
-diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
-index 7296c7f074bd..255ca232ecc7 100644
---- a/drivers/block/rbd.c
-+++ b/drivers/block/rbd.c
-@@ -3217,7 +3217,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
- page_count = (u32) calc_pages_for(offset, length);
- pages = ceph_alloc_page_vector(page_count, GFP_KERNEL);
- if (IS_ERR(pages))
-- ret = PTR_ERR(pages);
-+ return PTR_ERR(pages);
-
- ret = -ENOMEM;
- obj_request = rbd_obj_request_create(object_name, offset, length,
-diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
-index 64c60edcdfbc..63fc7f06a014 100644
---- a/drivers/block/xen-blkback/blkback.c
-+++ b/drivers/block/xen-blkback/blkback.c
-@@ -763,6 +763,7 @@ again:
- BUG_ON(new_map_idx >= segs_to_map);
- if (unlikely(map[new_map_idx].status != 0)) {
- pr_debug(DRV_PFX "invalid buffer -- could not remap it\n");
-+ put_free_pages(blkif, &pages[seg_idx]->page, 1);
- pages[seg_idx]->handle = BLKBACK_INVALID_HANDLE;
- ret |= 1;
- goto next;
-diff --git a/drivers/char/random.c b/drivers/char/random.c
-index 429b75bb60e8..8a64dbeae7b1 100644
---- a/drivers/char/random.c
-+++ b/drivers/char/random.c
-@@ -1063,8 +1063,8 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
- * pool while mixing, and hash one final time.
- */
- sha_transform(hash.w, extract, workspace);
-- memset(extract, 0, sizeof(extract));
-- memset(workspace, 0, sizeof(workspace));
-+ memzero_explicit(extract, sizeof(extract));
-+ memzero_explicit(workspace, sizeof(workspace));
-
- /*
- * In case the hash function has some recognizable output
-@@ -1076,7 +1076,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
- hash.w[2] ^= rol32(hash.w[2], 16);
-
- memcpy(out, &hash, EXTRACT_SIZE);
-- memset(&hash, 0, sizeof(hash));
-+ memzero_explicit(&hash, sizeof(hash));
- }
-
- static ssize_t extract_entropy(struct entropy_store *r, void *buf,
-@@ -1124,7 +1124,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
- }
-
- /* Wipe data just returned from memory */
-- memset(tmp, 0, sizeof(tmp));
-+ memzero_explicit(tmp, sizeof(tmp));
-
- return ret;
- }
-@@ -1162,7 +1162,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
- }
-
- /* Wipe data just returned from memory */
-- memset(tmp, 0, sizeof(tmp));
-+ memzero_explicit(tmp, sizeof(tmp));
-
- return ret;
- }
-diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
-index 415923606164..4854f81d038b 100644
---- a/drivers/cpufreq/cpufreq.c
-+++ b/drivers/cpufreq/cpufreq.c
-@@ -460,7 +460,18 @@ show_one(cpuinfo_max_freq, cpuinfo.max_freq);
- show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
- show_one(scaling_min_freq, min);
- show_one(scaling_max_freq, max);
--show_one(scaling_cur_freq, cur);
-+
-+static ssize_t show_scaling_cur_freq(
-+ struct cpufreq_policy *policy, char *buf)
-+{
-+ ssize_t ret;
-+
-+ if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get)
-+ ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu));
-+ else
-+ ret = sprintf(buf, "%u\n", policy->cur);
-+ return ret;
-+}
-
- static int cpufreq_set_policy(struct cpufreq_policy *policy,
- struct cpufreq_policy *new_policy);
-@@ -854,11 +865,11 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy,
- if (ret)
- goto err_out_kobj_put;
- }
-- if (has_target()) {
-- ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
-- if (ret)
-- goto err_out_kobj_put;
-- }
-+
-+ ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
-+ if (ret)
-+ goto err_out_kobj_put;
-+
- if (cpufreq_driver->bios_limit) {
- ret = sysfs_create_file(&policy->kobj, &bios_limit.attr);
- if (ret)
-diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
-index ae52c777339d..533a509439ca 100644
---- a/drivers/cpufreq/intel_pstate.c
-+++ b/drivers/cpufreq/intel_pstate.c
-@@ -55,6 +55,17 @@ static inline int32_t div_fp(int32_t x, int32_t y)
- return div_s64((int64_t)x << FRAC_BITS, (int64_t)y);
- }
-
-+static inline int ceiling_fp(int32_t x)
-+{
-+ int mask, ret;
-+
-+ ret = fp_toint(x);
-+ mask = (1 << FRAC_BITS) - 1;
-+ if (x & mask)
-+ ret += 1;
-+ return ret;
-+}
-+
- struct sample {
- int32_t core_pct_busy;
- u64 aperf;
-@@ -67,6 +78,7 @@ struct pstate_data {
- int current_pstate;
- int min_pstate;
- int max_pstate;
-+ int scaling;
- int turbo_pstate;
- };
-
-@@ -118,6 +130,7 @@ struct pstate_funcs {
- int (*get_max)(void);
- int (*get_min)(void);
- int (*get_turbo)(void);
-+ int (*get_scaling)(void);
- void (*set)(struct cpudata*, int pstate);
- void (*get_vid)(struct cpudata *);
- };
-@@ -397,7 +410,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate)
- cpudata->vid.ratio);
-
- vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max);
-- vid = fp_toint(vid_fp);
-+ vid = ceiling_fp(vid_fp);
-
- if (pstate > cpudata->pstate.max_pstate)
- vid = cpudata->vid.turbo;
-@@ -407,6 +420,22 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate)
- wrmsrl(MSR_IA32_PERF_CTL, val);
- }
-
-+#define BYT_BCLK_FREQS 5
-+static int byt_freq_table[BYT_BCLK_FREQS] = { 833, 1000, 1333, 1167, 800};
-+
-+static int byt_get_scaling(void)
-+{
-+ u64 value;
-+ int i;
-+
-+ rdmsrl(MSR_FSB_FREQ, value);
-+ i = value & 0x3;
-+
-+ BUG_ON(i > BYT_BCLK_FREQS);
-+
-+ return byt_freq_table[i] * 100;
-+}
-+
- static void byt_get_vid(struct cpudata *cpudata)
- {
- u64 value;
-@@ -451,6 +480,11 @@ static int core_get_turbo_pstate(void)
- return ret;
- }
-
-+static inline int core_get_scaling(void)
-+{
-+ return 100000;
-+}
-+
- static void core_set_pstate(struct cpudata *cpudata, int pstate)
- {
- u64 val;
-@@ -475,6 +509,7 @@ static struct cpu_defaults core_params = {
- .get_max = core_get_max_pstate,
- .get_min = core_get_min_pstate,
- .get_turbo = core_get_turbo_pstate,
-+ .get_scaling = core_get_scaling,
- .set = core_set_pstate,
- },
- };
-@@ -493,6 +528,7 @@ static struct cpu_defaults byt_params = {
- .get_min = byt_get_min_pstate,
- .get_turbo = byt_get_turbo_pstate,
- .set = byt_set_pstate,
-+ .get_scaling = byt_get_scaling,
- .get_vid = byt_get_vid,
- },
- };
-@@ -526,7 +562,7 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
- if (pstate == cpu->pstate.current_pstate)
- return;
-
-- trace_cpu_frequency(pstate * 100000, cpu->cpu);
-+ trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu);
-
- cpu->pstate.current_pstate = pstate;
-
-@@ -555,6 +591,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
- cpu->pstate.min_pstate = pstate_funcs.get_min();
- cpu->pstate.max_pstate = pstate_funcs.get_max();
- cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
-+ cpu->pstate.scaling = pstate_funcs.get_scaling();
-
- if (pstate_funcs.get_vid)
- pstate_funcs.get_vid(cpu);
-@@ -574,7 +611,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu,
- core_pct += 1;
-
- sample->freq = fp_toint(
-- mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
-+ mul_fp(int_tofp(
-+ cpu->pstate.max_pstate * cpu->pstate.scaling / 100),
-+ core_pct));
-
- sample->core_pct_busy = (int32_t)core_pct;
- }
-@@ -685,10 +724,14 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
- ICPU(0x37, byt_params),
- ICPU(0x3a, core_params),
- ICPU(0x3c, core_params),
-+ ICPU(0x3d, core_params),
- ICPU(0x3e, core_params),
- ICPU(0x3f, core_params),
- ICPU(0x45, core_params),
- ICPU(0x46, core_params),
-+ ICPU(0x4c, byt_params),
-+ ICPU(0x4f, core_params),
-+ ICPU(0x56, core_params),
- {}
- };
- MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids);
-@@ -751,6 +794,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
- if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
- limits.min_perf_pct = 100;
- limits.min_perf = int_tofp(1);
-+ limits.max_policy_pct = 100;
- limits.max_perf_pct = 100;
- limits.max_perf = int_tofp(1);
- limits.no_turbo = limits.turbo_disabled;
-@@ -812,12 +856,13 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
- else
- policy->policy = CPUFREQ_POLICY_POWERSAVE;
-
-- policy->min = cpu->pstate.min_pstate * 100000;
-- policy->max = cpu->pstate.turbo_pstate * 100000;
-+ policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling;
-+ policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
-
- /* cpuinfo and default policy values */
-- policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000;
-- policy->cpuinfo.max_freq = cpu->pstate.turbo_pstate * 100000;
-+ policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling;
-+ policy->cpuinfo.max_freq =
-+ cpu->pstate.turbo_pstate * cpu->pstate.scaling;
- policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
- cpumask_set_cpu(policy->cpu, policy->cpus);
-
-@@ -875,6 +920,7 @@ static void copy_cpu_funcs(struct pstate_funcs *funcs)
- pstate_funcs.get_max = funcs->get_max;
- pstate_funcs.get_min = funcs->get_min;
- pstate_funcs.get_turbo = funcs->get_turbo;
-+ pstate_funcs.get_scaling = funcs->get_scaling;
- pstate_funcs.set = funcs->set;
- pstate_funcs.get_vid = funcs->get_vid;
- }
-diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
-index df6575f1430d..682288ced4ac 100644
---- a/drivers/edac/cpc925_edac.c
-+++ b/drivers/edac/cpc925_edac.c
-@@ -562,7 +562,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
-
- if (apiexcp & UECC_EXCP_DETECTED) {
- cpc925_mc_printk(mci, KERN_INFO, "DRAM UECC Fault\n");
-- edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
-+ edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
- pfn, offset, 0,
- csrow, -1, -1,
- mci->ctl_name, "");
-diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
-index 3cda79bc8b00..ece3aef16bb1 100644
---- a/drivers/edac/e7xxx_edac.c
-+++ b/drivers/edac/e7xxx_edac.c
-@@ -226,7 +226,7 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
- static void process_ce_no_info(struct mem_ctl_info *mci)
- {
- edac_dbg(3, "\n");
-- edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0, -1, -1, -1,
-+ edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 0, -1, -1, -1,
- "e7xxx CE log register overflow", "");
- }
-
-diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
-index fa1326e5a4b0..ad76f10865c6 100644
---- a/drivers/edac/i3200_edac.c
-+++ b/drivers/edac/i3200_edac.c
-@@ -242,11 +242,11 @@ static void i3200_process_error_info(struct mem_ctl_info *mci,
- -1, -1,
- "i3000 UE", "");
- } else if (log & I3200_ECCERRLOG_CE) {
-- edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
-+ edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
- 0, 0, eccerrlog_syndrome(log),
- eccerrlog_row(channel, log),
- -1, -1,
-- "i3000 UE", "");
-+ "i3000 CE", "");
- }
- }
- }
-diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
-index 3382f6344e42..4382343a7c60 100644
---- a/drivers/edac/i82860_edac.c
-+++ b/drivers/edac/i82860_edac.c
-@@ -124,7 +124,7 @@ static int i82860_process_error_info(struct mem_ctl_info *mci,
- dimm->location[0], dimm->location[1], -1,
- "i82860 UE", "");
- else
-- edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
-+ edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
- info->eap, 0, info->derrsyn,
- dimm->location[0], dimm->location[1], -1,
- "i82860 CE", "");
-diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
-index cca063b11083..d2e56e95d886 100644
---- a/drivers/gpu/drm/ast/ast_mode.c
-+++ b/drivers/gpu/drm/ast/ast_mode.c
-@@ -1012,8 +1012,8 @@ static u32 copy_cursor_image(u8 *src, u8 *dst, int width, int height)
- srcdata32[1].ul = *((u32 *)(srcxor + 4)) & 0xf0f0f0f0;
- data32.b[0] = srcdata32[0].b[1] | (srcdata32[0].b[0] >> 4);
- data32.b[1] = srcdata32[0].b[3] | (srcdata32[0].b[2] >> 4);
-- data32.b[2] = srcdata32[0].b[1] | (srcdata32[1].b[0] >> 4);
-- data32.b[3] = srcdata32[0].b[3] | (srcdata32[1].b[2] >> 4);
-+ data32.b[2] = srcdata32[1].b[1] | (srcdata32[1].b[0] >> 4);
-+ data32.b[3] = srcdata32[1].b[3] | (srcdata32[1].b[2] >> 4);
-
- writel(data32.ul, dstxor);
- csum += data32.ul;
-diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
-index 08ce520f61a5..faa1f421f1b8 100644
---- a/drivers/gpu/drm/cirrus/cirrus_drv.c
-+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
-@@ -32,6 +32,8 @@ static struct drm_driver driver;
- static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
- { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, 0x1af4, 0x1100, 0,
- 0, 0 },
-+ { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, PCI_VENDOR_ID_XEN,
-+ 0x0001, 0, 0, 0 },
- {0,}
- };
-
-diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
-index fd98bec78816..c6d9777bdb45 100644
---- a/drivers/gpu/drm/i915/intel_panel.c
-+++ b/drivers/gpu/drm/i915/intel_panel.c
-@@ -645,7 +645,7 @@ static void pch_enable_backlight(struct intel_connector *connector)
-
- cpu_ctl2 = I915_READ(BLC_PWM_CPU_CTL2);
- if (cpu_ctl2 & BLM_PWM_ENABLE) {
-- WARN(1, "cpu backlight already enabled\n");
-+ DRM_DEBUG_KMS("cpu backlight already enabled\n");
- cpu_ctl2 &= ~BLM_PWM_ENABLE;
- I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2);
- }
-@@ -693,7 +693,7 @@ static void i9xx_enable_backlight(struct intel_connector *connector)
-
- ctl = I915_READ(BLC_PWM_CTL);
- if (ctl & BACKLIGHT_DUTY_CYCLE_MASK_PNV) {
-- WARN(1, "backlight already enabled\n");
-+ DRM_DEBUG_KMS("backlight already enabled\n");
- I915_WRITE(BLC_PWM_CTL, 0);
- }
-
-@@ -724,7 +724,7 @@ static void i965_enable_backlight(struct intel_connector *connector)
-
- ctl2 = I915_READ(BLC_PWM_CTL2);
- if (ctl2 & BLM_PWM_ENABLE) {
-- WARN(1, "backlight already enabled\n");
-+ DRM_DEBUG_KMS("backlight already enabled\n");
- ctl2 &= ~BLM_PWM_ENABLE;
- I915_WRITE(BLC_PWM_CTL2, ctl2);
- }
-@@ -758,7 +758,7 @@ static void vlv_enable_backlight(struct intel_connector *connector)
-
- ctl2 = I915_READ(VLV_BLC_PWM_CTL2(pipe));
- if (ctl2 & BLM_PWM_ENABLE) {
-- WARN(1, "backlight already enabled\n");
-+ DRM_DEBUG_KMS("backlight already enabled\n");
- ctl2 &= ~BLM_PWM_ENABLE;
- I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2);
- }
-diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
-index 2d9b9d7a7992..f3edd2841f2d 100644
---- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
-+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
-@@ -124,6 +124,7 @@ dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len,
- struct dcb_output *outp)
- {
- u16 dcb = dcb_outp(bios, idx, ver, len);
-+ memset(outp, 0x00, sizeof(*outp));
- if (dcb) {
- if (*ver >= 0x20) {
- u32 conn = nv_ro32(bios, dcb + 0x00);
-diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
-index 798bde2e5881..c39c414c7751 100644
---- a/drivers/gpu/drm/qxl/qxl_display.c
-+++ b/drivers/gpu/drm/qxl/qxl_display.c
-@@ -523,7 +523,6 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
- struct qxl_framebuffer *qfb;
- struct qxl_bo *bo, *old_bo = NULL;
- struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
-- uint32_t width, height, base_offset;
- bool recreate_primary = false;
- int ret;
- int surf_id;
-@@ -553,9 +552,10 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
- if (qcrtc->index == 0)
- recreate_primary = true;
-
-- width = mode->hdisplay;
-- height = mode->vdisplay;
-- base_offset = 0;
-+ if (bo->surf.stride * bo->surf.height > qdev->vram_size) {
-+ DRM_ERROR("Mode doesn't fit in vram size (vgamem)");
-+ return -EINVAL;
-+ }
-
- ret = qxl_bo_reserve(bo, false);
- if (ret != 0)
-@@ -569,10 +569,10 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc,
- if (recreate_primary) {
- qxl_io_destroy_primary(qdev);
- qxl_io_log(qdev,
-- "recreate primary: %dx%d (was %dx%d,%d,%d)\n",
-- width, height, bo->surf.width,
-- bo->surf.height, bo->surf.stride, bo->surf.format);
-- qxl_io_create_primary(qdev, base_offset, bo);
-+ "recreate primary: %dx%d,%d,%d\n",
-+ bo->surf.width, bo->surf.height,
-+ bo->surf.stride, bo->surf.format);
-+ qxl_io_create_primary(qdev, 0, bo);
- bo->is_primary = true;
- surf_id = 0;
- } else {
-diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
-index 0a2f5b4bca43..879e62844b2b 100644
---- a/drivers/gpu/drm/radeon/si_dpm.c
-+++ b/drivers/gpu/drm/radeon/si_dpm.c
-@@ -6200,7 +6200,7 @@ static void si_parse_pplib_clock_info(struct radeon_device *rdev,
- if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
- index == 0) {
- /* XXX disable for A0 tahiti */
-- si_pi->ulv.supported = true;
-+ si_pi->ulv.supported = false;
- si_pi->ulv.pl = *pl;
- si_pi->ulv.one_pcie_lane_in_ulv = false;
- si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
-diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
-index 0644429f8559..52b47115b5cb 100644
---- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
-+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
-@@ -84,6 +84,7 @@ static int modeset_init(struct drm_device *dev)
- if ((priv->num_encoders == 0) || (priv->num_connectors == 0)) {
- /* oh nos! */
- dev_err(dev->dev, "no encoders/connectors found\n");
-+ drm_mode_config_cleanup(dev);
- return -ENXIO;
- }
-
-@@ -178,33 +179,37 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
- dev->dev_private = priv;
-
- priv->wq = alloc_ordered_workqueue("tilcdc", 0);
-+ if (!priv->wq) {
-+ ret = -ENOMEM;
-+ goto fail_free_priv;
-+ }
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(dev->dev, "failed to get memory resource\n");
- ret = -EINVAL;
-- goto fail;
-+ goto fail_free_wq;
- }
-
- priv->mmio = ioremap_nocache(res->start, resource_size(res));
- if (!priv->mmio) {
- dev_err(dev->dev, "failed to ioremap\n");
- ret = -ENOMEM;
-- goto fail;
-+ goto fail_free_wq;
- }
-
- priv->clk = clk_get(dev->dev, "fck");
- if (IS_ERR(priv->clk)) {
- dev_err(dev->dev, "failed to get functional clock\n");
- ret = -ENODEV;
-- goto fail;
-+ goto fail_iounmap;
- }
-
- priv->disp_clk = clk_get(dev->dev, "dpll_disp_ck");
- if (IS_ERR(priv->clk)) {
- dev_err(dev->dev, "failed to get display clock\n");
- ret = -ENODEV;
-- goto fail;
-+ goto fail_put_clk;
- }
-
- #ifdef CONFIG_CPU_FREQ
-@@ -214,7 +219,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
- CPUFREQ_TRANSITION_NOTIFIER);
- if (ret) {
- dev_err(dev->dev, "failed to register cpufreq notifier\n");
-- goto fail;
-+ goto fail_put_disp_clk;
- }
- #endif
-
-@@ -259,13 +264,13 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
- ret = modeset_init(dev);
- if (ret < 0) {
- dev_err(dev->dev, "failed to initialize mode setting\n");
-- goto fail;
-+ goto fail_cpufreq_unregister;
- }
-
- ret = drm_vblank_init(dev, 1);
- if (ret < 0) {
- dev_err(dev->dev, "failed to initialize vblank\n");
-- goto fail;
-+ goto fail_mode_config_cleanup;
- }
-
- pm_runtime_get_sync(dev->dev);
-@@ -273,7 +278,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
- pm_runtime_put_sync(dev->dev);
- if (ret < 0) {
- dev_err(dev->dev, "failed to install IRQ handler\n");
-- goto fail;
-+ goto fail_vblank_cleanup;
- }
-
- platform_set_drvdata(pdev, dev);
-@@ -289,13 +294,48 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
- priv->fbdev = drm_fbdev_cma_init(dev, bpp,
- dev->mode_config.num_crtc,
- dev->mode_config.num_connector);
-+ if (IS_ERR(priv->fbdev)) {
-+ ret = PTR_ERR(priv->fbdev);
-+ goto fail_irq_uninstall;
-+ }
-
- drm_kms_helper_poll_init(dev);
-
- return 0;
-
--fail:
-- tilcdc_unload(dev);
-+fail_irq_uninstall:
-+ pm_runtime_get_sync(dev->dev);
-+ drm_irq_uninstall(dev);
-+ pm_runtime_put_sync(dev->dev);
-+
-+fail_vblank_cleanup:
-+ drm_vblank_cleanup(dev);
-+
-+fail_mode_config_cleanup:
-+ drm_mode_config_cleanup(dev);
-+
-+fail_cpufreq_unregister:
-+ pm_runtime_disable(dev->dev);
-+#ifdef CONFIG_CPU_FREQ
-+ cpufreq_unregister_notifier(&priv->freq_transition,
-+ CPUFREQ_TRANSITION_NOTIFIER);
-+fail_put_disp_clk:
-+ clk_put(priv->disp_clk);
-+#endif
-+
-+fail_put_clk:
-+ clk_put(priv->clk);
-+
-+fail_iounmap:
-+ iounmap(priv->mmio);
-+
-+fail_free_wq:
-+ flush_workqueue(priv->wq);
-+ destroy_workqueue(priv->wq);
-+
-+fail_free_priv:
-+ dev->dev_private = NULL;
-+ kfree(priv);
- return ret;
- }
-
-diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
-index 0083cbf99edf..fb7c36e93fd4 100644
---- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
-+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
-@@ -688,7 +688,11 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
- goto out_err0;
- }
-
-- if (unlikely(dev_priv->prim_bb_mem < dev_priv->vram_size))
-+ /*
-+ * Limit back buffer size to VRAM size. Remove this once
-+ * screen targets are implemented.
-+ */
-+ if (dev_priv->prim_bb_mem > dev_priv->vram_size)
- dev_priv->prim_bb_mem = dev_priv->vram_size;
-
- mutex_unlock(&dev_priv->hw_mutex);
-diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
-index 8a650413dea5..c8f8ecf7b282 100644
---- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
-+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
-@@ -1954,6 +1954,14 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
- DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
- };
- int i;
-+ u32 assumed_bpp = 2;
-+
-+ /*
-+ * If using screen objects, then assume 32-bpp because that's what the
-+ * SVGA device is assuming
-+ */
-+ if (dev_priv->sou_priv)
-+ assumed_bpp = 4;
-
- /* Add preferred mode */
- {
-@@ -1964,8 +1972,9 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
- mode->vdisplay = du->pref_height;
- vmw_guess_mode_timing(mode);
-
-- if (vmw_kms_validate_mode_vram(dev_priv, mode->hdisplay * 2,
-- mode->vdisplay)) {
-+ if (vmw_kms_validate_mode_vram(dev_priv,
-+ mode->hdisplay * assumed_bpp,
-+ mode->vdisplay)) {
- drm_mode_probed_add(connector, mode);
- } else {
- drm_mode_destroy(dev, mode);
-@@ -1987,7 +1996,8 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
- bmode->vdisplay > max_height)
- continue;
-
-- if (!vmw_kms_validate_mode_vram(dev_priv, bmode->hdisplay * 2,
-+ if (!vmw_kms_validate_mode_vram(dev_priv,
-+ bmode->hdisplay * assumed_bpp,
- bmode->vdisplay))
- continue;
-
-diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
-index 6e12cd0317f6..91bc66b4b151 100644
---- a/drivers/hid/hid-ids.h
-+++ b/drivers/hid/hid-ids.h
-@@ -292,6 +292,11 @@
- #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7 0x73f7
- #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001
-
-+#define USB_VENDOR_ID_ELAN 0x04f3
-+#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089
-+#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b
-+#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f
-+
- #define USB_VENDOR_ID_ELECOM 0x056e
- #define USB_DEVICE_ID_ELECOM_BM084 0x0061
-
-diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
-index 44df131d390a..617c47f9ebe6 100644
---- a/drivers/hid/usbhid/hid-core.c
-+++ b/drivers/hid/usbhid/hid-core.c
-@@ -82,7 +82,7 @@ static int hid_start_in(struct hid_device *hid)
- struct usbhid_device *usbhid = hid->driver_data;
-
- spin_lock_irqsave(&usbhid->lock, flags);
-- if (hid->open > 0 &&
-+ if ((hid->open > 0 || hid->quirks & HID_QUIRK_ALWAYS_POLL) &&
- !test_bit(HID_DISCONNECTED, &usbhid->iofl) &&
- !test_bit(HID_SUSPENDED, &usbhid->iofl) &&
- !test_and_set_bit(HID_IN_RUNNING, &usbhid->iofl)) {
-@@ -292,6 +292,8 @@ static void hid_irq_in(struct urb *urb)
- case 0: /* success */
- usbhid_mark_busy(usbhid);
- usbhid->retry_delay = 0;
-+ if ((hid->quirks & HID_QUIRK_ALWAYS_POLL) && !hid->open)
-+ break;
- hid_input_report(urb->context, HID_INPUT_REPORT,
- urb->transfer_buffer,
- urb->actual_length, 1);
-@@ -734,8 +736,10 @@ void usbhid_close(struct hid_device *hid)
- if (!--hid->open) {
- spin_unlock_irq(&usbhid->lock);
- hid_cancel_delayed_stuff(usbhid);
-- usb_kill_urb(usbhid->urbin);
-- usbhid->intf->needs_remote_wakeup = 0;
-+ if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL)) {
-+ usb_kill_urb(usbhid->urbin);
-+ usbhid->intf->needs_remote_wakeup = 0;
-+ }
- } else {
- spin_unlock_irq(&usbhid->lock);
- }
-@@ -1119,6 +1123,19 @@ static int usbhid_start(struct hid_device *hid)
-
- set_bit(HID_STARTED, &usbhid->iofl);
-
-+ if (hid->quirks & HID_QUIRK_ALWAYS_POLL) {
-+ ret = usb_autopm_get_interface(usbhid->intf);
-+ if (ret)
-+ goto fail;
-+ usbhid->intf->needs_remote_wakeup = 1;
-+ ret = hid_start_in(hid);
-+ if (ret) {
-+ dev_err(&hid->dev,
-+ "failed to start in urb: %d\n", ret);
-+ }
-+ usb_autopm_put_interface(usbhid->intf);
-+ }
-+
- /* Some keyboards don't work until their LEDs have been set.
- * Since BIOSes do set the LEDs, it must be safe for any device
- * that supports the keyboard boot protocol.
-@@ -1151,6 +1168,9 @@ static void usbhid_stop(struct hid_device *hid)
- if (WARN_ON(!usbhid))
- return;
-
-+ if (hid->quirks & HID_QUIRK_ALWAYS_POLL)
-+ usbhid->intf->needs_remote_wakeup = 0;
-+
- clear_bit(HID_STARTED, &usbhid->iofl);
- spin_lock_irq(&usbhid->lock); /* Sync with error and led handlers */
- set_bit(HID_DISCONNECTED, &usbhid->iofl);
-diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
-index 8e4ddb369883..deb364306636 100644
---- a/drivers/hid/usbhid/hid-quirks.c
-+++ b/drivers/hid/usbhid/hid-quirks.c
-@@ -69,6 +69,9 @@ static const struct hid_blacklist {
- { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET },
- { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
- { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
-+ { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL },
-+ { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL },
-+ { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL },
- { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
- { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
- { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
-diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
-index 11e9c7f9bf9b..8873d84e1d4f 100644
---- a/drivers/i2c/busses/i2c-at91.c
-+++ b/drivers/i2c/busses/i2c-at91.c
-@@ -434,7 +434,7 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
- }
- }
-
-- ret = wait_for_completion_io_timeout(&dev->cmd_complete,
-+ ret = wait_for_completion_timeout(&dev->cmd_complete,
- dev->adapter.timeout);
- if (ret == 0) {
- dev_err(dev->dev, "controller timed out\n");
-diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
-index 1665c8e4b62b..e18bc6782256 100644
---- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
-+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
-@@ -71,7 +71,7 @@ int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf)
- goto st_sensors_free_memory;
- }
-
-- for (i = 0; i < n * num_data_channels; i++) {
-+ for (i = 0; i < n * byte_for_channel; i++) {
- if (i < n)
- buf[i] = rx_array[i];
- else
-diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
-index f1da362c3e65..8fca488fdc15 100644
---- a/drivers/input/serio/i8042-x86ia64io.h
-+++ b/drivers/input/serio/i8042-x86ia64io.h
-@@ -101,6 +101,12 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
- },
- {
- .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "X750LN"),
-+ },
-+ },
-+ {
-+ .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
- DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
- DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
-@@ -609,6 +615,22 @@ static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
- },
- },
- {
-+ /* Fujitsu A544 laptop */
-+ /* https://bugzilla.redhat.com/show_bug.cgi?id=1111138 */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK A544"),
-+ },
-+ },
-+ {
-+ /* Fujitsu AH544 laptop */
-+ /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
-+ },
-+ },
-+ {
- /* Fujitsu U574 laptop */
- /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
- .matches = {
-diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
-index 0e722c103562..ca1621b49453 100644
---- a/drivers/md/dm-bufio.c
-+++ b/drivers/md/dm-bufio.c
-@@ -465,6 +465,7 @@ static void __relink_lru(struct dm_buffer *b, int dirty)
- c->n_buffers[dirty]++;
- b->list_mode = dirty;
- list_move(&b->lru_list, &c->lru[dirty]);
-+ b->last_accessed = jiffies;
- }
-
- /*----------------------------------------------------------------
-@@ -1485,9 +1486,9 @@ static long __scan(struct dm_bufio_client *c, unsigned long nr_to_scan,
- list_for_each_entry_safe_reverse(b, tmp, &c->lru[l], lru_list) {
- freed += __cleanup_old_buffer(b, gfp_mask, 0);
- if (!--nr_to_scan)
-- break;
-+ return freed;
-+ dm_bufio_cond_resched();
- }
-- dm_bufio_cond_resched();
- }
- return freed;
- }
-diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
-index 08d9a207259a..c69d0b787746 100644
---- a/drivers/md/dm-log-userspace-transfer.c
-+++ b/drivers/md/dm-log-userspace-transfer.c
-@@ -272,7 +272,7 @@ int dm_ulog_tfr_init(void)
-
- r = cn_add_callback(&ulog_cn_id, "dmlogusr", cn_ulog_callback);
- if (r) {
-- cn_del_callback(&ulog_cn_id);
-+ kfree(prealloced_cn_msg);
- return r;
- }
-
-diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
-index 1e344b033277..22e8c2032f6d 100644
---- a/drivers/media/dvb-frontends/ds3000.c
-+++ b/drivers/media/dvb-frontends/ds3000.c
-@@ -864,6 +864,13 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
- memcpy(&state->frontend.ops, &ds3000_ops,
- sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-+
-+ /*
-+ * Some devices like T480 starts with voltage on. Be sure
-+ * to turn voltage off during init, as this can otherwise
-+ * interfere with Unicable SCR systems.
-+ */
-+ ds3000_set_voltage(&state->frontend, SEC_VOLTAGE_OFF);
- return &state->frontend;
-
- error3:
-diff --git a/drivers/media/i2c/tda7432.c b/drivers/media/i2c/tda7432.c
-index 72af644fa051..cf93021a6500 100644
---- a/drivers/media/i2c/tda7432.c
-+++ b/drivers/media/i2c/tda7432.c
-@@ -293,7 +293,7 @@ static int tda7432_s_ctrl(struct v4l2_ctrl *ctrl)
- if (t->mute->val) {
- lf |= TDA7432_MUTE;
- lr |= TDA7432_MUTE;
-- lf |= TDA7432_MUTE;
-+ rf |= TDA7432_MUTE;
- rr |= TDA7432_MUTE;
- }
- /* Mute & update balance*/
-diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
-index 40c42dec721b..7a62097aa9ea 100644
---- a/drivers/media/tuners/m88ts2022.c
-+++ b/drivers/media/tuners/m88ts2022.c
-@@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
- div_min = gdiv28 * 78 / 100;
- div_max = clamp_val(div_max, 0U, 63U);
-
-- f_3db_hz = c->symbol_rate * 135UL / 200UL;
-+ f_3db_hz = mult_frac(c->symbol_rate, 135, 200);
- f_3db_hz += 2000000U + (frequency_offset_khz * 1000U);
- f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
-
-diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
-index 4d97a76cc3b0..c1a3f8f95750 100644
---- a/drivers/media/usb/em28xx/em28xx-cards.c
-+++ b/drivers/media/usb/em28xx/em28xx-cards.c
-@@ -2993,16 +2993,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
- }
- }
-
-- if (dev->chip_id == CHIP_ID_EM2870 ||
-- dev->chip_id == CHIP_ID_EM2874 ||
-- dev->chip_id == CHIP_ID_EM28174 ||
-- dev->chip_id == CHIP_ID_EM28178) {
-- /* Digital only device - don't load any alsa module */
-- dev->audio_mode.has_audio = false;
-- dev->has_audio_class = false;
-- dev->has_alsa_audio = false;
-- }
--
- if (chip_name != default_chip_name)
- printk(KERN_INFO DRIVER_NAME
- ": chip ID is %s\n", chip_name);
-@@ -3272,7 +3262,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
- dev->alt = -1;
- dev->is_audio_only = has_audio && !(has_video || has_dvb);
- dev->has_alsa_audio = has_audio;
-- dev->audio_mode.has_audio = has_audio;
- dev->has_video = has_video;
- dev->ifnum = ifnum;
-
-diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
-index 898fb9bd88a2..97fd881a4e7b 100644
---- a/drivers/media/usb/em28xx/em28xx-core.c
-+++ b/drivers/media/usb/em28xx/em28xx-core.c
-@@ -506,8 +506,18 @@ int em28xx_audio_setup(struct em28xx *dev)
- int vid1, vid2, feat, cfg;
- u32 vid;
-
-- if (!dev->audio_mode.has_audio)
-+ if (dev->chip_id == CHIP_ID_EM2870 ||
-+ dev->chip_id == CHIP_ID_EM2874 ||
-+ dev->chip_id == CHIP_ID_EM28174 ||
-+ dev->chip_id == CHIP_ID_EM28178) {
-+ /* Digital only device - don't load any alsa module */
-+ dev->audio_mode.has_audio = false;
-+ dev->has_audio_class = false;
-+ dev->has_alsa_audio = false;
- return 0;
-+ }
-+
-+ dev->audio_mode.has_audio = true;
-
- /* See how this device is configured */
- cfg = em28xx_read_reg(dev, EM28XX_R00_CHIPCFG);
-diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
-index c3c928937dcd..e24ee08e634e 100644
---- a/drivers/media/usb/em28xx/em28xx-video.c
-+++ b/drivers/media/usb/em28xx/em28xx-video.c
-@@ -953,13 +953,16 @@ static int em28xx_stop_streaming(struct vb2_queue *vq)
- }
-
- spin_lock_irqsave(&dev->slock, flags);
-+ if (dev->usb_ctl.vid_buf != NULL) {
-+ vb2_buffer_done(&dev->usb_ctl.vid_buf->vb, VB2_BUF_STATE_ERROR);
-+ dev->usb_ctl.vid_buf = NULL;
-+ }
- while (!list_empty(&vidq->active)) {
- struct em28xx_buffer *buf;
- buf = list_entry(vidq->active.next, struct em28xx_buffer, list);
- list_del(&buf->list);
- vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
- }
-- dev->usb_ctl.vid_buf = NULL;
- spin_unlock_irqrestore(&dev->slock, flags);
-
- return 0;
-@@ -981,13 +984,16 @@ int em28xx_stop_vbi_streaming(struct vb2_queue *vq)
- }
-
- spin_lock_irqsave(&dev->slock, flags);
-+ if (dev->usb_ctl.vbi_buf != NULL) {
-+ vb2_buffer_done(&dev->usb_ctl.vbi_buf->vb, VB2_BUF_STATE_ERROR);
-+ dev->usb_ctl.vbi_buf = NULL;
-+ }
- while (!list_empty(&vbiq->active)) {
- struct em28xx_buffer *buf;
- buf = list_entry(vbiq->active.next, struct em28xx_buffer, list);
- list_del(&buf->list);
- vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
- }
-- dev->usb_ctl.vbi_buf = NULL;
- spin_unlock_irqrestore(&dev->slock, flags);
-
- return 0;
-diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
-index c3bb2502225b..753ad4cfc118 100644
---- a/drivers/media/usb/uvc/uvc_driver.c
-+++ b/drivers/media/usb/uvc/uvc_driver.c
-@@ -2210,6 +2210,15 @@ static struct usb_device_id uvc_ids[] = {
- .bInterfaceSubClass = 1,
- .bInterfaceProtocol = 0,
- .driver_info = UVC_QUIRK_PROBE_DEF },
-+ /* Dell XPS M1330 (OmniVision OV7670 webcam) */
-+ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
-+ | USB_DEVICE_ID_MATCH_INT_INFO,
-+ .idVendor = 0x05a9,
-+ .idProduct = 0x7670,
-+ .bInterfaceClass = USB_CLASS_VIDEO,
-+ .bInterfaceSubClass = 1,
-+ .bInterfaceProtocol = 0,
-+ .driver_info = UVC_QUIRK_PROBE_DEF },
- /* Apple Built-In iSight */
- { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
- | USB_DEVICE_ID_MATCH_INT_INFO,
-diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
-index 433d6d77942e..c5521cec933b 100644
---- a/drivers/media/v4l2-core/v4l2-common.c
-+++ b/drivers/media/v4l2-core/v4l2-common.c
-@@ -431,16 +431,13 @@ static unsigned int clamp_align(unsigned int x, unsigned int min,
- /* Bits that must be zero to be aligned */
- unsigned int mask = ~((1 << align) - 1);
-
-+ /* Clamp to aligned min and max */
-+ x = clamp(x, (min + ~mask) & mask, max & mask);
-+
- /* Round to nearest aligned value */
- if (align)
- x = (x + (1 << (align - 1))) & mask;
-
-- /* Clamp to aligned value of min and max */
-- if (x < min)
-- x = (min + ~mask) & mask;
-- else if (x > max)
-- x = max & mask;
--
- return x;
- }
-
-diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
-index 1d15735f9ef9..89b4c4216d0c 100644
---- a/drivers/mfd/rtsx_pcr.c
-+++ b/drivers/mfd/rtsx_pcr.c
-@@ -1177,7 +1177,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
- pcr->msi_en = msi_en;
- if (pcr->msi_en) {
- ret = pci_enable_msi(pcidev);
-- if (ret < 0)
-+ if (ret)
- pcr->msi_en = false;
- }
-
-diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
-index d4e860413bb5..e87a2485468f 100644
---- a/drivers/mfd/ti_am335x_tscadc.c
-+++ b/drivers/mfd/ti_am335x_tscadc.c
-@@ -54,11 +54,11 @@ void am335x_tsc_se_set_cache(struct ti_tscadc_dev *tsadc, u32 val)
- unsigned long flags;
-
- spin_lock_irqsave(&tsadc->reg_lock, flags);
-- tsadc->reg_se_cache = val;
-+ tsadc->reg_se_cache |= val;
- if (tsadc->adc_waiting)
- wake_up(&tsadc->reg_se_wait);
- else if (!tsadc->adc_in_use)
-- tscadc_writel(tsadc, REG_SE, val);
-+ tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache);
-
- spin_unlock_irqrestore(&tsadc->reg_lock, flags);
- }
-@@ -97,6 +97,7 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc)
- void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val)
- {
- spin_lock_irq(&tsadc->reg_lock);
-+ tsadc->reg_se_cache |= val;
- am335x_tscadc_need_adc(tsadc);
-
- tscadc_writel(tsadc, REG_SE, val);
-diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
-index 7e1866175e7b..ca297d741207 100644
---- a/drivers/mmc/host/rtsx_pci_sdmmc.c
-+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
-@@ -342,6 +342,13 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
- }
-
- if (rsp_type == SD_RSP_TYPE_R2) {
-+ /*
-+ * The controller offloads the last byte {CRC-7, end bit 1'b1}
-+ * of response type R2. Assign dummy CRC, 0, and end bit to the
-+ * byte(ptr[16], goes into the LSB of resp[3] later).
-+ */
-+ ptr[16] = 1;
-+
- for (i = 0; i < 4; i++) {
- cmd->resp[i] = get_unaligned_be32(ptr + 1 + i * 4);
- dev_dbg(sdmmc_dev(host), "cmd->resp[%d] = 0x%08x\n",
-diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
-index 0955777b6c7e..19bfa0ad70c4 100644
---- a/drivers/mmc/host/sdhci-pci.c
-+++ b/drivers/mmc/host/sdhci-pci.c
-@@ -103,6 +103,10 @@ static const struct sdhci_pci_fixes sdhci_cafe = {
- SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
- };
-
-+static const struct sdhci_pci_fixes sdhci_intel_qrk = {
-+ .quirks = SDHCI_QUIRK_NO_HISPD_BIT,
-+};
-+
- static int mrst_hc_probe_slot(struct sdhci_pci_slot *slot)
- {
- slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA;
-@@ -733,6 +737,14 @@ static const struct pci_device_id pci_ids[] = {
-
- {
- .vendor = PCI_VENDOR_ID_INTEL,
-+ .device = PCI_DEVICE_ID_INTEL_QRK_SD,
-+ .subvendor = PCI_ANY_ID,
-+ .subdevice = PCI_ANY_ID,
-+ .driver_data = (kernel_ulong_t)&sdhci_intel_qrk,
-+ },
-+
-+ {
-+ .vendor = PCI_VENDOR_ID_INTEL,
- .device = PCI_DEVICE_ID_INTEL_MRST_SD0,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
-diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
-index 6d718719659e..c101477ef3be 100644
---- a/drivers/mmc/host/sdhci-pci.h
-+++ b/drivers/mmc/host/sdhci-pci.h
-@@ -17,6 +17,7 @@
- #define PCI_DEVICE_ID_INTEL_CLV_SDIO2 0x08fb
- #define PCI_DEVICE_ID_INTEL_CLV_EMMC0 0x08e5
- #define PCI_DEVICE_ID_INTEL_CLV_EMMC1 0x08e6
-+#define PCI_DEVICE_ID_INTEL_QRK_SD 0x08A7
-
- /*
- * PCI registers
-diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
-index c5dad652614d..904b4517fc1e 100644
---- a/drivers/mtd/ubi/fastmap.c
-+++ b/drivers/mtd/ubi/fastmap.c
-@@ -330,6 +330,7 @@ static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai,
- av = tmp_av;
- else {
- ubi_err("orphaned volume in fastmap pool!");
-+ kmem_cache_free(ai->aeb_slab_cache, new_aeb);
- return UBI_BAD_FASTMAP;
- }
-
-diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
-index 494b888a6568..7e5c6a8b89e7 100644
---- a/drivers/net/Kconfig
-+++ b/drivers/net/Kconfig
-@@ -135,6 +135,7 @@ config MACVLAN
- config MACVTAP
- tristate "MAC-VLAN based tap driver"
- depends on MACVLAN
-+ depends on INET
- help
- This adds a specialized tap character device driver that is based
- on the MAC-VLAN network interface, called macvtap. A macvtap device
-@@ -205,6 +206,7 @@ config RIONET_RX_SIZE
-
- config TUN
- tristate "Universal TUN/TAP device driver support"
-+ depends on INET
- select CRC32
- ---help---
- TUN/TAP provides packet reception and transmission for user space
-diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
-index 0c6adaaf898c..f30ceb17d5fc 100644
---- a/drivers/net/macvtap.c
-+++ b/drivers/net/macvtap.c
-@@ -16,6 +16,7 @@
- #include
- #include
-
-+#include
- #include
- #include
- #include
-@@ -65,7 +66,7 @@ static struct cdev macvtap_cdev;
- static const struct proto_ops macvtap_socket_ops;
-
- #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-- NETIF_F_TSO6 | NETIF_F_UFO)
-+ NETIF_F_TSO6)
- #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
- #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
-
-@@ -569,7 +570,11 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
- gso_type = SKB_GSO_TCPV6;
- break;
- case VIRTIO_NET_HDR_GSO_UDP:
-+ pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-+ current->comm);
- gso_type = SKB_GSO_UDP;
-+ if (skb->protocol == htons(ETH_P_IPV6))
-+ ipv6_proxy_select_ident(skb);
- break;
- default:
- return -EINVAL;
-@@ -614,8 +619,6 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
- vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
- else if (sinfo->gso_type & SKB_GSO_TCPV6)
- vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-- else if (sinfo->gso_type & SKB_GSO_UDP)
-- vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
- else
- BUG();
- if (sinfo->gso_type & SKB_GSO_TCP_ECN)
-@@ -950,9 +953,6 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
- if (arg & TUN_F_TSO6)
- feature_mask |= NETIF_F_TSO6;
- }
--
-- if (arg & TUN_F_UFO)
-- feature_mask |= NETIF_F_UFO;
- }
-
- /* tun/tap driver inverts the usage for TSO offloads, where
-@@ -963,7 +963,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
- * When user space turns off TSO, we turn off GSO/LRO so that
- * user-space will not receive TSO frames.
- */
-- if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
-+ if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
- features |= RX_OFFLOADS;
- else
- features &= ~RX_OFFLOADS;
-@@ -1064,7 +1064,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
- case TUNSETOFFLOAD:
- /* let the user check for future flags */
- if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-- TUN_F_TSO_ECN | TUN_F_UFO))
-+ TUN_F_TSO_ECN))
- return -EINVAL;
-
- rtnl_lock();
-diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
-index 72ff14b811c6..5a1897d86e94 100644
---- a/drivers/net/ppp/ppp_generic.c
-+++ b/drivers/net/ppp/ppp_generic.c
-@@ -601,7 +601,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
- if (file == ppp->owner)
- ppp_shutdown_interface(ppp);
- }
-- if (atomic_long_read(&file->f_count) <= 2) {
-+ if (atomic_long_read(&file->f_count) < 2) {
- ppp_release(NULL, file);
- err = 0;
- } else
-diff --git a/drivers/net/tun.c b/drivers/net/tun.c
-index 26f8635b027d..2c8b1c21c452 100644
---- a/drivers/net/tun.c
-+++ b/drivers/net/tun.c
-@@ -65,6 +65,7 @@
- #include
- #include
- #include
-+#include
- #include
- #include
- #include
-@@ -174,7 +175,7 @@ struct tun_struct {
- struct net_device *dev;
- netdev_features_t set_features;
- #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-- NETIF_F_TSO6|NETIF_F_UFO)
-+ NETIF_F_TSO6)
-
- int vnet_hdr_sz;
- int sndbuf;
-@@ -1140,6 +1141,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
- break;
- }
-
-+ skb_reset_network_header(skb);
-+
- if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
- pr_debug("GSO!\n");
- switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
-@@ -1150,8 +1153,20 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
- skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
- break;
- case VIRTIO_NET_HDR_GSO_UDP:
-+ {
-+ static bool warned;
-+
-+ if (!warned) {
-+ warned = true;
-+ netdev_warn(tun->dev,
-+ "%s: using disabled UFO feature; please fix this program\n",
-+ current->comm);
-+ }
- skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-+ if (skb->protocol == htons(ETH_P_IPV6))
-+ ipv6_proxy_select_ident(skb);
- break;
-+ }
- default:
- tun->dev->stats.rx_frame_errors++;
- kfree_skb(skb);
-@@ -1180,7 +1195,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
- skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
- }
-
-- skb_reset_network_header(skb);
- skb_probe_transport_header(skb, 0);
-
- rxhash = skb_get_hash(skb);
-@@ -1252,8 +1266,6 @@ static ssize_t tun_put_user(struct tun_struct *tun,
- gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
- else if (sinfo->gso_type & SKB_GSO_TCPV6)
- gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-- else if (sinfo->gso_type & SKB_GSO_UDP)
-- gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
- else {
- pr_err("unexpected GSO type: "
- "0x%x, gso_size %d, hdr_len %d\n",
-@@ -1783,11 +1795,6 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
- features |= NETIF_F_TSO6;
- arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
- }
--
-- if (arg & TUN_F_UFO) {
-- features |= NETIF_F_UFO;
-- arg &= ~TUN_F_UFO;
-- }
- }
-
- /* This gives the user a way to test for new features in future by
-diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
-index 054e59ca6946..8cee173eefb2 100644
---- a/drivers/net/usb/ax88179_178a.c
-+++ b/drivers/net/usb/ax88179_178a.c
-@@ -696,6 +696,7 @@ static int ax88179_set_mac_addr(struct net_device *net, void *p)
- {
- struct usbnet *dev = netdev_priv(net);
- struct sockaddr *addr = p;
-+ int ret;
-
- if (netif_running(net))
- return -EBUSY;
-@@ -705,8 +706,12 @@ static int ax88179_set_mac_addr(struct net_device *net, void *p)
- memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
-
- /* Set the MAC address */
-- return ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-+ ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
- ETH_ALEN, net->dev_addr);
-+ if (ret < 0)
-+ return ret;
-+
-+ return 0;
- }
-
- static const struct net_device_ops ax88179_netdev_ops = {
-diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
-index 841b60831df1..07a3255fd3cc 100644
---- a/drivers/net/virtio_net.c
-+++ b/drivers/net/virtio_net.c
-@@ -496,8 +496,17 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
- skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
- break;
- case VIRTIO_NET_HDR_GSO_UDP:
-+ {
-+ static bool warned;
-+
-+ if (!warned) {
-+ warned = true;
-+ netdev_warn(dev,
-+ "host using disabled UFO feature; please fix it\n");
-+ }
- skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
- break;
-+ }
- case VIRTIO_NET_HDR_GSO_TCPV6:
- skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
- break;
-@@ -836,8 +845,6 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
- hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
- else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
- hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-- else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
-- hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
- else
- BUG();
- if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
-@@ -1657,7 +1664,7 @@ static int virtnet_probe(struct virtio_device *vdev)
- dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
-
- if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
-- dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
-+ dev->hw_features |= NETIF_F_TSO
- | NETIF_F_TSO_ECN | NETIF_F_TSO6;
- }
- /* Individual feature bits: what can host handle? */
-@@ -1667,11 +1674,9 @@ static int virtnet_probe(struct virtio_device *vdev)
- dev->hw_features |= NETIF_F_TSO6;
- if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
- dev->hw_features |= NETIF_F_TSO_ECN;
-- if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
-- dev->hw_features |= NETIF_F_UFO;
-
- if (gso)
-- dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
-+ dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
- /* (!csum && gso) case will be fixed by register_netdev() */
- }
- if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
-@@ -1711,8 +1716,7 @@ static int virtnet_probe(struct virtio_device *vdev)
- /* If we can receive ANY GSO packets, we must allocate large ones. */
- if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
- virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
-- virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
-- virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
-+ virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
- vi->big_packets = true;
-
- if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
-@@ -1903,9 +1907,9 @@ static struct virtio_device_id id_table[] = {
- static unsigned int features[] = {
- VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
- VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
-- VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
-+ VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
- VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
-- VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
-+ VIRTIO_NET_F_GUEST_ECN,
- VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
- VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
- VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
-diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
-index 9b40532041cb..0704a0402897 100644
---- a/drivers/net/vxlan.c
-+++ b/drivers/net/vxlan.c
-@@ -1447,9 +1447,6 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb)
- if (!in6_dev)
- goto out;
-
-- if (!pskb_may_pull(skb, skb->len))
-- goto out;
--
- iphdr = ipv6_hdr(skb);
- saddr = &iphdr->saddr;
- daddr = &iphdr->daddr;
-@@ -1770,6 +1767,8 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
- struct pcpu_sw_netstats *tx_stats, *rx_stats;
- union vxlan_addr loopback;
- union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;
-+ struct net_device *dev = skb->dev;
-+ int len = skb->len;
-
- tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
- rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats);
-@@ -1793,16 +1792,16 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
-
- u64_stats_update_begin(&tx_stats->syncp);
- tx_stats->tx_packets++;
-- tx_stats->tx_bytes += skb->len;
-+ tx_stats->tx_bytes += len;
- u64_stats_update_end(&tx_stats->syncp);
-
- if (netif_rx(skb) == NET_RX_SUCCESS) {
- u64_stats_update_begin(&rx_stats->syncp);
- rx_stats->rx_packets++;
-- rx_stats->rx_bytes += skb->len;
-+ rx_stats->rx_bytes += len;
- u64_stats_update_end(&rx_stats->syncp);
- } else {
-- skb->dev->stats.rx_dropped++;
-+ dev->stats.rx_dropped++;
- }
- }
-
-@@ -1977,7 +1976,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
- return arp_reduce(dev, skb);
- #if IS_ENABLED(CONFIG_IPV6)
- else if (ntohs(eth->h_proto) == ETH_P_IPV6 &&
-- skb->len >= sizeof(struct ipv6hdr) + sizeof(struct nd_msg) &&
-+ pskb_may_pull(skb, sizeof(struct ipv6hdr)
-+ + sizeof(struct nd_msg)) &&
- ipv6_hdr(skb)->nexthdr == IPPROTO_ICMPV6) {
- struct nd_msg *msg;
-
-@@ -1986,6 +1986,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
- msg->icmph.icmp6_type == NDISC_NEIGHBOUR_SOLICITATION)
- return neigh_reduce(dev, skb);
- }
-+ eth = eth_hdr(skb);
- #endif
- }
-
-diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
-index 2ca62af3f81b..76ee486039d7 100644
---- a/drivers/net/wireless/iwlwifi/mvm/tx.c
-+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
-@@ -173,14 +173,10 @@ static void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
-
- /*
- * for data packets, rate info comes from the table inside the fw. This
-- * table is controlled by LINK_QUALITY commands. Exclude ctrl port
-- * frames like EAPOLs which should be treated as mgmt frames. This
-- * avoids them being sent initially in high rates which increases the
-- * chances for completion of the 4-Way handshake.
-+ * table is controlled by LINK_QUALITY commands
- */
-
-- if (ieee80211_is_data(fc) && sta &&
-- !(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) {
-+ if (ieee80211_is_data(fc) && sta) {
- tx_cmd->initial_rate_index = 0;
- tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE);
- return;
-diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
-index 7cf6081a05a1..ebd5625d13f1 100644
---- a/drivers/net/wireless/rt2x00/rt2800.h
-+++ b/drivers/net/wireless/rt2x00/rt2800.h
-@@ -52,6 +52,7 @@
- * RF5592 2.4G/5G 2T2R
- * RF3070 2.4G 1T1R
- * RF5360 2.4G 1T1R
-+ * RF5362 2.4G 1T1R
- * RF5370 2.4G 1T1R
- * RF5390 2.4G 1T1R
- */
-@@ -72,6 +73,7 @@
- #define RF3070 0x3070
- #define RF3290 0x3290
- #define RF5360 0x5360
-+#define RF5362 0x5362
- #define RF5370 0x5370
- #define RF5372 0x5372
- #define RF5390 0x5390
-@@ -2145,7 +2147,7 @@ struct mac_iveiv_entry {
- /* Bits [7-4] for RF3320 (RT3370/RT3390), on other chipsets reserved */
- #define RFCSR3_PA1_BIAS_CCK FIELD8(0x70)
- #define RFCSR3_PA2_CASCODE_BIAS_CCKK FIELD8(0x80)
--/* Bits for RF3290/RF5360/RF5370/RF5372/RF5390/RF5392 */
-+/* Bits for RF3290/RF5360/RF5362/RF5370/RF5372/RF5390/RF5392 */
- #define RFCSR3_VCOCAL_EN FIELD8(0x80)
- /* Bits for RF3050 */
- #define RFCSR3_BIT1 FIELD8(0x02)
-diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
-index 41d4a8167dc3..4e16d4da9d82 100644
---- a/drivers/net/wireless/rt2x00/rt2800lib.c
-+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
-@@ -3142,6 +3142,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
- break;
- case RF3070:
- case RF5360:
-+ case RF5362:
- case RF5370:
- case RF5372:
- case RF5390:
-@@ -3159,6 +3160,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
- rt2x00_rf(rt2x00dev, RF3290) ||
- rt2x00_rf(rt2x00dev, RF3322) ||
- rt2x00_rf(rt2x00dev, RF5360) ||
-+ rt2x00_rf(rt2x00dev, RF5362) ||
- rt2x00_rf(rt2x00dev, RF5370) ||
- rt2x00_rf(rt2x00dev, RF5372) ||
- rt2x00_rf(rt2x00dev, RF5390) ||
-@@ -4273,6 +4275,7 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev)
- case RF3070:
- case RF3290:
- case RF5360:
-+ case RF5362:
- case RF5370:
- case RF5372:
- case RF5390:
-@@ -7073,6 +7076,7 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
- case RF3320:
- case RF3322:
- case RF5360:
-+ case RF5362:
- case RF5370:
- case RF5372:
- case RF5390:
-@@ -7529,6 +7533,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
- case RF3320:
- case RF3322:
- case RF5360:
-+ case RF5362:
- case RF5370:
- case RF5372:
- case RF5390:
-@@ -7658,6 +7663,7 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
- case RF3070:
- case RF3290:
- case RF5360:
-+ case RF5362:
- case RF5370:
- case RF5372:
- case RF5390:
-diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
-index caddc1b427a9..57d3967de32f 100644
---- a/drivers/net/wireless/rt2x00/rt2800usb.c
-+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
-@@ -1062,6 +1062,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
- /* Ovislink */
- { USB_DEVICE(0x1b75, 0x3071) },
- { USB_DEVICE(0x1b75, 0x3072) },
-+ { USB_DEVICE(0x1b75, 0xa200) },
- /* Para */
- { USB_DEVICE(0x20b8, 0x8888) },
- /* Pegatron */
-@@ -1235,6 +1236,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
- /* Arcadyan */
- { USB_DEVICE(0x043e, 0x7a12) },
- { USB_DEVICE(0x043e, 0x7a32) },
-+ /* ASUS */
-+ { USB_DEVICE(0x0b05, 0x17e8) },
- /* Azurewave */
- { USB_DEVICE(0x13d3, 0x3329) },
- { USB_DEVICE(0x13d3, 0x3365) },
-@@ -1271,6 +1274,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
- { USB_DEVICE(0x057c, 0x8501) },
- /* Buffalo */
- { USB_DEVICE(0x0411, 0x0241) },
-+ { USB_DEVICE(0x0411, 0x0253) },
- /* D-Link */
- { USB_DEVICE(0x2001, 0x3c1a) },
- { USB_DEVICE(0x2001, 0x3c21) },
-@@ -1361,6 +1365,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
- { USB_DEVICE(0x0df6, 0x0053) },
- { USB_DEVICE(0x0df6, 0x0069) },
- { USB_DEVICE(0x0df6, 0x006f) },
-+ { USB_DEVICE(0x0df6, 0x0078) },
- /* SMC */
- { USB_DEVICE(0x083a, 0xa512) },
- { USB_DEVICE(0x083a, 0xc522) },
-diff --git a/drivers/of/base.c b/drivers/of/base.c
-index 89e888a78899..3935614274eb 100644
---- a/drivers/of/base.c
-+++ b/drivers/of/base.c
-@@ -1117,52 +1117,6 @@ int of_property_read_string(struct device_node *np, const char *propname,
- EXPORT_SYMBOL_GPL(of_property_read_string);
-
- /**
-- * of_property_read_string_index - Find and read a string from a multiple
-- * strings property.
-- * @np: device node from which the property value is to be read.
-- * @propname: name of the property to be searched.
-- * @index: index of the string in the list of strings
-- * @out_string: pointer to null terminated return string, modified only if
-- * return value is 0.
-- *
-- * Search for a property in a device tree node and retrieve a null
-- * terminated string value (pointer to data, not a copy) in the list of strings
-- * contained in that property.
-- * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if
-- * property does not have a value, and -EILSEQ if the string is not
-- * null-terminated within the length of the property data.
-- *
-- * The out_string pointer is modified only if a valid string can be decoded.
-- */
--int of_property_read_string_index(struct device_node *np, const char *propname,
-- int index, const char **output)
--{
-- struct property *prop = of_find_property(np, propname, NULL);
-- int i = 0;
-- size_t l = 0, total = 0;
-- const char *p;
--
-- if (!prop)
-- return -EINVAL;
-- if (!prop->value)
-- return -ENODATA;
-- if (strnlen(prop->value, prop->length) >= prop->length)
-- return -EILSEQ;
--
-- p = prop->value;
--
-- for (i = 0; total < prop->length; total += l, p += l) {
-- l = strlen(p) + 1;
-- if (i++ == index) {
-- *output = p;
-- return 0;
-- }
-- }
-- return -ENODATA;
--}
--EXPORT_SYMBOL_GPL(of_property_read_string_index);
--
--/**
- * of_property_match_string() - Find string in a list and return index
- * @np: pointer to node containing string list property
- * @propname: string list property name
-@@ -1188,7 +1142,7 @@ int of_property_match_string(struct device_node *np, const char *propname,
- end = p + prop->length;
-
- for (i = 0; p < end; i++, p += l) {
-- l = strlen(p) + 1;
-+ l = strnlen(p, end - p) + 1;
- if (p + l > end)
- return -EILSEQ;
- pr_debug("comparing %s with %s\n", string, p);
-@@ -1200,39 +1154,41 @@ int of_property_match_string(struct device_node *np, const char *propname,
- EXPORT_SYMBOL_GPL(of_property_match_string);
-
- /**
-- * of_property_count_strings - Find and return the number of strings from a
-- * multiple strings property.
-+ * of_property_read_string_util() - Utility helper for parsing string properties
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
-+ * @out_strs: output array of string pointers.
-+ * @sz: number of array elements to read.
-+ * @skip: Number of strings to skip over at beginning of list.
- *
-- * Search for a property in a device tree node and retrieve the number of null
-- * terminated string contain in it. Returns the number of strings on
-- * success, -EINVAL if the property does not exist, -ENODATA if property
-- * does not have a value, and -EILSEQ if the string is not null-terminated
-- * within the length of the property data.
-+ * Don't call this function directly. It is a utility helper for the
-+ * of_property_read_string*() family of functions.
- */
--int of_property_count_strings(struct device_node *np, const char *propname)
-+int of_property_read_string_helper(struct device_node *np, const char *propname,
-+ const char **out_strs, size_t sz, int skip)
- {
- struct property *prop = of_find_property(np, propname, NULL);
-- int i = 0;
-- size_t l = 0, total = 0;
-- const char *p;
-+ int l = 0, i = 0;
-+ const char *p, *end;
-
- if (!prop)
- return -EINVAL;
- if (!prop->value)
- return -ENODATA;
-- if (strnlen(prop->value, prop->length) >= prop->length)
-- return -EILSEQ;
--
- p = prop->value;
-+ end = p + prop->length;
-
-- for (i = 0; total < prop->length; total += l, p += l, i++)
-- l = strlen(p) + 1;
--
-- return i;
-+ for (i = 0; p < end && (!out_strs || i < skip + sz); i++, p += l) {
-+ l = strnlen(p, end - p) + 1;
-+ if (p + l > end)
-+ return -EILSEQ;
-+ if (out_strs && i >= skip)
-+ *out_strs++ = p;
-+ }
-+ i -= skip;
-+ return i <= 0 ? -ENODATA : i;
- }
--EXPORT_SYMBOL_GPL(of_property_count_strings);
-+EXPORT_SYMBOL_GPL(of_property_read_string_helper);
-
- void of_print_phandle_args(const char *msg, const struct of_phandle_args *args)
- {
-diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
-index 6643d1920985..70c61d75b75e 100644
---- a/drivers/of/selftest.c
-+++ b/drivers/of/selftest.c
-@@ -132,8 +132,9 @@ static void __init of_selftest_parse_phandle_with_args(void)
- selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
- }
-
--static void __init of_selftest_property_match_string(void)
-+static void __init of_selftest_property_string(void)
- {
-+ const char *strings[4];
- struct device_node *np;
- int rc;
-
-@@ -150,13 +151,66 @@ static void __init of_selftest_property_match_string(void)
- rc = of_property_match_string(np, "phandle-list-names", "third");
- selftest(rc == 2, "third expected:0 got:%i\n", rc);
- rc = of_property_match_string(np, "phandle-list-names", "fourth");
-- selftest(rc == -ENODATA, "unmatched string; rc=%i", rc);
-+ selftest(rc == -ENODATA, "unmatched string; rc=%i\n", rc);
- rc = of_property_match_string(np, "missing-property", "blah");
-- selftest(rc == -EINVAL, "missing property; rc=%i", rc);
-+ selftest(rc == -EINVAL, "missing property; rc=%i\n", rc);
- rc = of_property_match_string(np, "empty-property", "blah");
-- selftest(rc == -ENODATA, "empty property; rc=%i", rc);
-+ selftest(rc == -ENODATA, "empty property; rc=%i\n", rc);
- rc = of_property_match_string(np, "unterminated-string", "blah");
-- selftest(rc == -EILSEQ, "unterminated string; rc=%i", rc);
-+ selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
-+
-+ /* of_property_count_strings() tests */
-+ rc = of_property_count_strings(np, "string-property");
-+ selftest(rc == 1, "Incorrect string count; rc=%i\n", rc);
-+ rc = of_property_count_strings(np, "phandle-list-names");
-+ selftest(rc == 3, "Incorrect string count; rc=%i\n", rc);
-+ rc = of_property_count_strings(np, "unterminated-string");
-+ selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
-+ rc = of_property_count_strings(np, "unterminated-string-list");
-+ selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
-+
-+ /* of_property_read_string_index() tests */
-+ rc = of_property_read_string_index(np, "string-property", 0, strings);
-+ selftest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i\n", rc);
-+ strings[0] = NULL;
-+ rc = of_property_read_string_index(np, "string-property", 1, strings);
-+ selftest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
-+ rc = of_property_read_string_index(np, "phandle-list-names", 0, strings);
-+ selftest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
-+ rc = of_property_read_string_index(np, "phandle-list-names", 1, strings);
-+ selftest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i\n", rc);
-+ rc = of_property_read_string_index(np, "phandle-list-names", 2, strings);
-+ selftest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc);
-+ strings[0] = NULL;
-+ rc = of_property_read_string_index(np, "phandle-list-names", 3, strings);
-+ selftest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
-+ strings[0] = NULL;
-+ rc = of_property_read_string_index(np, "unterminated-string", 0, strings);
-+ selftest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
-+ rc = of_property_read_string_index(np, "unterminated-string-list", 0, strings);
-+ selftest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
-+ strings[0] = NULL;
-+ rc = of_property_read_string_index(np, "unterminated-string-list", 2, strings); /* should fail */
-+ selftest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
-+ strings[1] = NULL;
-+
-+ /* of_property_read_string_array() tests */
-+ rc = of_property_read_string_array(np, "string-property", strings, 4);
-+ selftest(rc == 1, "Incorrect string count; rc=%i\n", rc);
-+ rc = of_property_read_string_array(np, "phandle-list-names", strings, 4);
-+ selftest(rc == 3, "Incorrect string count; rc=%i\n", rc);
-+ rc = of_property_read_string_array(np, "unterminated-string", strings, 4);
-+ selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
-+ /* -- An incorrectly formed string should cause a failure */
-+ rc = of_property_read_string_array(np, "unterminated-string-list", strings, 4);
-+ selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
-+ /* -- parsing the correctly formed strings should still work: */
-+ strings[2] = NULL;
-+ rc = of_property_read_string_array(np, "unterminated-string-list", strings, 2);
-+ selftest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc);
-+ strings[1] = NULL;
-+ rc = of_property_read_string_array(np, "phandle-list-names", strings, 1);
-+ selftest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]);
- }
-
- static void __init of_selftest_parse_interrupts(void)
-@@ -379,7 +433,7 @@ static int __init of_selftest(void)
-
- pr_info("start of selftest - you will see error messages\n");
- of_selftest_parse_phandle_with_args();
-- of_selftest_property_match_string();
-+ of_selftest_property_string();
- of_selftest_parse_interrupts();
- of_selftest_parse_interrupts_extended();
- of_selftest_match_node();
-diff --git a/drivers/of/testcase-data/tests-phandle.dtsi b/drivers/of/testcase-data/tests-phandle.dtsi
-index 0007d3cd7dc2..eedee37d70d7 100644
---- a/drivers/of/testcase-data/tests-phandle.dtsi
-+++ b/drivers/of/testcase-data/tests-phandle.dtsi
-@@ -32,7 +32,9 @@
- phandle-list-bad-args = <&provider2 1 0>,
- <&provider3 0>;
- empty-property;
-+ string-property = "foobar";
- unterminated-string = [40 41 42 43];
-+ unterminated-string-list = "first", "second", [40 41 42 43];
- };
- };
- };
-diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
-index 39a207abaa10..a943c6c0f206 100644
---- a/drivers/pci/pci-sysfs.c
-+++ b/drivers/pci/pci-sysfs.c
-@@ -186,9 +186,9 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
- }
- static DEVICE_ATTR_RO(modalias);
-
--static ssize_t enabled_store(struct device *dev,
-- struct device_attribute *attr, const char *buf,
-- size_t count)
-+static ssize_t enable_store(struct device *dev,
-+ struct device_attribute *attr, const char *buf,
-+ size_t count)
- {
- struct pci_dev *pdev = to_pci_dev(dev);
- unsigned long val;
-@@ -212,15 +212,15 @@ static ssize_t enabled_store(struct device *dev,
- return result < 0 ? result : count;
- }
-
--static ssize_t enabled_show(struct device *dev,
-- struct device_attribute *attr, char *buf)
-+static ssize_t enable_show(struct device *dev,
-+ struct device_attribute *attr, char *buf)
- {
- struct pci_dev *pdev;
-
- pdev = to_pci_dev (dev);
- return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
- }
--static DEVICE_ATTR_RW(enabled);
-+static DEVICE_ATTR_RW(enable);
-
- #ifdef CONFIG_NUMA
- static ssize_t
-@@ -526,7 +526,7 @@ static struct attribute *pci_dev_attrs[] = {
- #endif
- &dev_attr_dma_mask_bits.attr,
- &dev_attr_consistent_dma_mask_bits.attr,
-- &dev_attr_enabled.attr,
-+ &dev_attr_enable.attr,
- &dev_attr_broken_parity_status.attr,
- &dev_attr_msi_bus.attr,
- #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
-diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
-index 665b96bc0c3a..eb9f1906952a 100644
---- a/drivers/pinctrl/pinctrl-baytrail.c
-+++ b/drivers/pinctrl/pinctrl-baytrail.c
-@@ -263,7 +263,7 @@ static int byt_gpio_direction_output(struct gpio_chip *chip,
- spin_lock_irqsave(&vg->lock, flags);
-
- reg_val = readl(reg) | BYT_DIR_MASK;
-- reg_val &= ~BYT_OUTPUT_EN;
-+ reg_val &= ~(BYT_OUTPUT_EN | BYT_INPUT_EN);
-
- if (value)
- writel(reg_val | BYT_LEVEL, reg);
-diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
-index c91f69b39db4..dcfcaea76048 100644
---- a/drivers/platform/x86/acer-wmi.c
-+++ b/drivers/platform/x86/acer-wmi.c
-@@ -570,6 +570,17 @@ static const struct dmi_system_id video_vendor_dmi_table[] = {
- DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"),
- },
- },
-+ {
-+ /*
-+ * Note no video_set_backlight_video_vendor, we must use the
-+ * acer interface, as there is no native backlight interface.
-+ */
-+ .ident = "Acer KAV80",
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "KAV80"),
-+ },
-+ },
- {}
- };
-
-diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
-index 9e4dab46eefd..ef1f4c928431 100644
---- a/drivers/power/charger-manager.c
-+++ b/drivers/power/charger-manager.c
-@@ -1720,6 +1720,11 @@ static int charger_manager_probe(struct platform_device *pdev)
- return -EINVAL;
- }
-
-+ if (!desc->psy_fuel_gauge) {
-+ dev_err(&pdev->dev, "No fuel gauge power supply defined\n");
-+ return -EINVAL;
-+ }
-+
- /* Counting index only */
- while (desc->psy_charger_stat[i])
- i++;
-diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c
-index 5fb899f461d0..24c926bfe6d4 100644
---- a/drivers/regulator/max77693.c
-+++ b/drivers/regulator/max77693.c
-@@ -232,7 +232,7 @@ static int max77693_pmic_probe(struct platform_device *pdev)
- struct max77693_pmic_dev *max77693_pmic;
- struct max77693_regulator_data *rdata = NULL;
- int num_rdata, i;
-- struct regulator_config config;
-+ struct regulator_config config = { };
-
- num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata);
- if (!rdata || num_rdata <= 0) {
-diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
-index 788c4fe2b0c9..9d81f7693f99 100644
---- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
-+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
-@@ -707,7 +707,16 @@ static void tcm_qla2xxx_clear_nacl_from_fcport_map(struct qla_tgt_sess *sess)
- pr_debug("fc_rport domain: port_id 0x%06x\n", nacl->nport_id);
-
- node = btree_remove32(&lport->lport_fcport_map, nacl->nport_id);
-- WARN_ON(node && (node != se_nacl));
-+ if (WARN_ON(node && (node != se_nacl))) {
-+ /*
-+ * The nacl no longer matches what we think it should be.
-+ * Most likely a new dynamic acl has been added while
-+ * someone dropped the hardware lock. It clearly is a
-+ * bug elsewhere, but this bit can't make things worse.
-+ */
-+ btree_insert32(&lport->lport_fcport_map, nacl->nport_id,
-+ node, GFP_ATOMIC);
-+ }
-
- pr_debug("Removed from fcport_map: %p for WWNN: 0x%016LX, port_id: 0x%06x\n",
- se_nacl, nacl->nport_wwnn, nacl->nport_id);
-diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
-index a25392065d9b..a5db6f930fa3 100644
---- a/drivers/spi/spi-fsl-dspi.c
-+++ b/drivers/spi/spi-fsl-dspi.c
-@@ -45,7 +45,7 @@
-
- #define SPI_TCR 0x08
-
--#define SPI_CTAR(x) (0x0c + (x * 4))
-+#define SPI_CTAR(x) (0x0c + (((x) & 0x3) * 4))
- #define SPI_CTAR_FMSZ(x) (((x) & 0x0000000f) << 27)
- #define SPI_CTAR_CPOL(x) ((x) << 26)
- #define SPI_CTAR_CPHA(x) ((x) << 25)
-@@ -69,7 +69,7 @@
-
- #define SPI_PUSHR 0x34
- #define SPI_PUSHR_CONT (1 << 31)
--#define SPI_PUSHR_CTAS(x) (((x) & 0x00000007) << 28)
-+#define SPI_PUSHR_CTAS(x) (((x) & 0x00000003) << 28)
- #define SPI_PUSHR_EOQ (1 << 27)
- #define SPI_PUSHR_CTCNT (1 << 26)
- #define SPI_PUSHR_PCS(x) (((1 << x) & 0x0000003f) << 16)
-diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
-index 2789b452e711..971855e859c7 100644
---- a/drivers/spi/spi-pl022.c
-+++ b/drivers/spi/spi-pl022.c
-@@ -1075,7 +1075,7 @@ err_rxdesc:
- pl022->sgt_tx.nents, DMA_TO_DEVICE);
- err_tx_sgmap:
- dma_unmap_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
-- pl022->sgt_tx.nents, DMA_FROM_DEVICE);
-+ pl022->sgt_rx.nents, DMA_FROM_DEVICE);
- err_rx_sgmap:
- sg_free_table(&pl022->sgt_tx);
- err_alloc_tx_sg:
-diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
-index ced9ecffa163..7ab3ccb592eb 100644
---- a/drivers/spi/spi-pxa2xx.c
-+++ b/drivers/spi/spi-pxa2xx.c
-@@ -1280,7 +1280,9 @@ static int pxa2xx_spi_suspend(struct device *dev)
- if (status != 0)
- return status;
- write_SSCR0(0, drv_data->ioaddr);
-- clk_disable_unprepare(ssp->clk);
-+
-+ if (!pm_runtime_suspended(dev))
-+ clk_disable_unprepare(ssp->clk);
-
- return 0;
- }
-@@ -1294,7 +1296,8 @@ static int pxa2xx_spi_resume(struct device *dev)
- pxa2xx_spi_dma_resume(drv_data);
-
- /* Enable the SSP clock */
-- clk_prepare_enable(ssp->clk);
-+ if (!pm_runtime_suspended(dev))
-+ clk_prepare_enable(ssp->clk);
-
- /* Restore LPSS private register bits */
- lpss_ssp_setup(drv_data);
-diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
-index 2b96665da8a2..97d4b3fb7e95 100644
---- a/drivers/staging/iio/impedance-analyzer/ad5933.c
-+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
-@@ -115,6 +115,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
- .address = AD5933_REG_TEMP_DATA,
-+ .scan_index = -1,
- .scan_type = {
- .sign = 's',
- .realbits = 14,
-@@ -124,9 +125,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "real_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-- BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "real",
- .address = AD5933_REG_REAL_DATA,
- .scan_index = 0,
- .scan_type = {
-@@ -138,9 +137,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "imag_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-- BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "imag",
- .address = AD5933_REG_IMAG_DATA,
- .scan_index = 1,
- .scan_type = {
-@@ -748,14 +745,14 @@ static int ad5933_probe(struct i2c_client *client,
- indio_dev->name = id->name;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = ad5933_channels;
-- indio_dev->num_channels = 1; /* only register temp0_input */
-+ indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
-
- ret = ad5933_register_ring_funcs_and_init(indio_dev);
- if (ret)
- goto error_disable_reg;
-
-- /* skip temp0_input, register in0_(real|imag)_raw */
-- ret = iio_buffer_register(indio_dev, &ad5933_channels[1], 2);
-+ ret = iio_buffer_register(indio_dev, ad5933_channels,
-+ ARRAY_SIZE(ad5933_channels));
- if (ret)
- goto error_unreg_ring;
-
-diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
-index 07318203a836..e8c98cf57070 100644
---- a/drivers/staging/iio/meter/ade7758.h
-+++ b/drivers/staging/iio/meter/ade7758.h
-@@ -119,7 +119,6 @@ struct ade7758_state {
- u8 *tx;
- u8 *rx;
- struct mutex buf_lock;
-- const struct iio_chan_spec *ade7758_ring_channels;
- struct spi_transfer ring_xfer[4];
- struct spi_message ring_msg;
- /*
-diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
-index cba183e24838..94d9914a602c 100644
---- a/drivers/staging/iio/meter/ade7758_core.c
-+++ b/drivers/staging/iio/meter/ade7758_core.c
-@@ -630,9 +630,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
- .scan_index = 0,
- .scan_type = {
-@@ -644,9 +641,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_CURRENT,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
- .scan_index = 1,
- .scan_type = {
-@@ -658,9 +652,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "apparent_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "apparent",
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
- .scan_index = 2,
- .scan_type = {
-@@ -672,9 +664,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "active_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "active",
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
- .scan_index = 3,
- .scan_type = {
-@@ -686,9 +676,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 0,
-- .extend_name = "reactive_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "reactive",
- .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
- .scan_index = 4,
- .scan_type = {
-@@ -700,9 +688,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 1,
-- .extend_name = "raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
- .scan_index = 5,
- .scan_type = {
-@@ -714,9 +699,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_CURRENT,
- .indexed = 1,
- .channel = 1,
-- .extend_name = "raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
- .scan_index = 6,
- .scan_type = {
-@@ -728,9 +710,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 1,
-- .extend_name = "apparent_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "apparent",
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
- .scan_index = 7,
- .scan_type = {
-@@ -742,9 +722,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 1,
-- .extend_name = "active_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "active",
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
- .scan_index = 8,
- .scan_type = {
-@@ -756,9 +734,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 1,
-- .extend_name = "reactive_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "reactive",
- .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
- .scan_index = 9,
- .scan_type = {
-@@ -770,9 +746,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 2,
-- .extend_name = "raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
- .scan_index = 10,
- .scan_type = {
-@@ -784,9 +757,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_CURRENT,
- .indexed = 1,
- .channel = 2,
-- .extend_name = "raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
- .scan_index = 11,
- .scan_type = {
-@@ -798,9 +768,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 2,
-- .extend_name = "apparent_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "apparent",
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
- .scan_index = 12,
- .scan_type = {
-@@ -812,9 +780,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 2,
-- .extend_name = "active_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "active",
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
- .scan_index = 13,
- .scan_type = {
-@@ -826,9 +792,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
- .type = IIO_POWER,
- .indexed = 1,
- .channel = 2,
-- .extend_name = "reactive_raw",
-- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
-- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
-+ .extend_name = "reactive",
- .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
- .scan_index = 14,
- .scan_type = {
-@@ -869,13 +833,14 @@ static int ade7758_probe(struct spi_device *spi)
- goto error_free_rx;
- }
- st->us = spi;
-- st->ade7758_ring_channels = &ade7758_channels[0];
- mutex_init(&st->buf_lock);
-
- indio_dev->name = spi->dev.driver->name;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &ade7758_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
-+ indio_dev->channels = ade7758_channels;
-+ indio_dev->num_channels = ARRAY_SIZE(ade7758_channels);
-
- ret = ade7758_configure_ring(indio_dev);
- if (ret)
-diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
-index c0accf8cce93..6e9006490742 100644
---- a/drivers/staging/iio/meter/ade7758_ring.c
-+++ b/drivers/staging/iio/meter/ade7758_ring.c
-@@ -85,17 +85,16 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
- **/
- static int ade7758_ring_preenable(struct iio_dev *indio_dev)
- {
-- struct ade7758_state *st = iio_priv(indio_dev);
- unsigned channel;
-
-- if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
-+ if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
- return -EINVAL;
-
- channel = find_first_bit(indio_dev->active_scan_mask,
- indio_dev->masklength);
-
- ade7758_write_waveform_type(&indio_dev->dev,
-- st->ade7758_ring_channels[channel].address);
-+ indio_dev->channels[channel].address);
-
- return 0;
- }
-diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
-index 6ea95d216eb8..38b4be24d13f 100644
---- a/drivers/target/target_core_device.c
-+++ b/drivers/target/target_core_device.c
-@@ -1409,7 +1409,8 @@ int core_dev_add_initiator_node_lun_acl(
- * Check to see if there are any existing persistent reservation APTPL
- * pre-registrations that need to be enabled for this LUN ACL..
- */
-- core_scsi3_check_aptpl_registration(lun->lun_se_dev, tpg, lun, lacl);
-+ core_scsi3_check_aptpl_registration(lun->lun_se_dev, tpg, lun, nacl,
-+ lacl->mapped_lun);
- return 0;
- }
-
-diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
-index 3013287a2aaa..1205dbd4f83d 100644
---- a/drivers/target/target_core_pr.c
-+++ b/drivers/target/target_core_pr.c
-@@ -944,10 +944,10 @@ int core_scsi3_check_aptpl_registration(
- struct se_device *dev,
- struct se_portal_group *tpg,
- struct se_lun *lun,
-- struct se_lun_acl *lun_acl)
-+ struct se_node_acl *nacl,
-+ u32 mapped_lun)
- {
-- struct se_node_acl *nacl = lun_acl->se_lun_nacl;
-- struct se_dev_entry *deve = nacl->device_list[lun_acl->mapped_lun];
-+ struct se_dev_entry *deve = nacl->device_list[mapped_lun];
-
- if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
- return 0;
-diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h
-index 2ee2936fa0bd..749fd7bb7510 100644
---- a/drivers/target/target_core_pr.h
-+++ b/drivers/target/target_core_pr.h
-@@ -60,7 +60,7 @@ extern int core_scsi3_alloc_aptpl_registration(
- unsigned char *, u16, u32, int, int, u8);
- extern int core_scsi3_check_aptpl_registration(struct se_device *,
- struct se_portal_group *, struct se_lun *,
-- struct se_lun_acl *);
-+ struct se_node_acl *, u32);
- extern void core_scsi3_free_pr_reg_from_nacl(struct se_device *,
- struct se_node_acl *);
- extern void core_scsi3_free_all_registrations(struct se_device *);
-diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
-index c036595b17cf..fb8a1a12dda9 100644
---- a/drivers/target/target_core_tpg.c
-+++ b/drivers/target/target_core_tpg.c
-@@ -40,6 +40,7 @@
- #include
-
- #include "target_core_internal.h"
-+#include "target_core_pr.h"
-
- extern struct se_device *g_lun0_dev;
-
-@@ -166,6 +167,13 @@ void core_tpg_add_node_to_devs(
-
- core_enable_device_list_for_node(lun, NULL, lun->unpacked_lun,
- lun_access, acl, tpg);
-+ /*
-+ * Check to see if there are any existing persistent reservation
-+ * APTPL pre-registrations that need to be enabled for this dynamic
-+ * LUN ACL now..
-+ */
-+ core_scsi3_check_aptpl_registration(dev, tpg, lun, acl,
-+ lun->unpacked_lun);
- spin_lock(&tpg->tpg_lun_lock);
- }
- spin_unlock(&tpg->tpg_lun_lock);
-diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
-index 24f527977ddb..9232c7738ed1 100644
---- a/drivers/target/target_core_transport.c
-+++ b/drivers/target/target_core_transport.c
-@@ -1855,8 +1855,7 @@ static void transport_complete_qf(struct se_cmd *cmd)
- if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) {
- trace_target_cmd_complete(cmd);
- ret = cmd->se_tfo->queue_status(cmd);
-- if (ret)
-- goto out;
-+ goto out;
- }
-
- switch (cmd->data_direction) {
-diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
-index 25b8f6868788..27b5554e20d9 100644
---- a/drivers/tty/serial/serial_core.c
-+++ b/drivers/tty/serial/serial_core.c
-@@ -353,7 +353,7 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
- * The spd_hi, spd_vhi, spd_shi, spd_warp kludge...
- * Die! Die! Die!
- */
-- if (baud == 38400)
-+ if (try == 0 && baud == 38400)
- baud = altbaud;
-
- /*
-diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
-index d3448a90f0f9..25d07412e08e 100644
---- a/drivers/tty/tty_io.c
-+++ b/drivers/tty/tty_io.c
-@@ -1701,6 +1701,7 @@ int tty_release(struct inode *inode, struct file *filp)
- int pty_master, tty_closing, o_tty_closing, do_sleep;
- int idx;
- char buf[64];
-+ long timeout = 0;
-
- if (tty_paranoia_check(tty, inode, __func__))
- return 0;
-@@ -1785,7 +1786,11 @@ int tty_release(struct inode *inode, struct file *filp)
- __func__, tty_name(tty, buf));
- tty_unlock_pair(tty, o_tty);
- mutex_unlock(&tty_mutex);
-- schedule();
-+ schedule_timeout_killable(timeout);
-+ if (timeout < 120 * HZ)
-+ timeout = 2 * timeout + 1;
-+ else
-+ timeout = MAX_SCHEDULE_TIMEOUT;
- }
-
- /*
-diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
-index eabccd45f4e8..331f06a91cc3 100644
---- a/drivers/usb/class/cdc-acm.c
-+++ b/drivers/usb/class/cdc-acm.c
-@@ -965,11 +965,12 @@ static void acm_tty_set_termios(struct tty_struct *tty,
- /* FIXME: Needs to clear unsupported bits in the termios */
- acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
-
-- if (!newline.dwDTERate) {
-+ if (C_BAUD(tty) == B0) {
- newline.dwDTERate = acm->line.dwDTERate;
- newctrl &= ~ACM_CTRL_DTR;
-- } else
-+ } else if (termios_old && (termios_old->c_cflag & CBAUD) == B0) {
- newctrl |= ACM_CTRL_DTR;
-+ }
-
- if (newctrl != acm->ctrlout)
- acm_set_control(acm, acm->ctrlout = newctrl);
-@@ -1672,6 +1673,7 @@ static const struct usb_device_id acm_ids[] = {
- { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
- .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
- },
-+ { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */
- { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */
- },
- /* Motorola H24 HSPA module: */
-diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
-index 2518c3250750..ef6ec13b6ae5 100644
---- a/drivers/usb/core/hcd.c
-+++ b/drivers/usb/core/hcd.c
-@@ -2057,6 +2057,8 @@ int usb_alloc_streams(struct usb_interface *interface,
- return -EINVAL;
- if (dev->speed != USB_SPEED_SUPER)
- return -EINVAL;
-+ if (dev->state < USB_STATE_CONFIGURED)
-+ return -ENODEV;
-
- /* Streams only apply to bulk endpoints. */
- for (i = 0; i < num_eps; i++)
-diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
-index 445d62a4316a..d2bd9d7c8f4b 100644
---- a/drivers/usb/core/hub.c
-+++ b/drivers/usb/core/hub.c
-@@ -4378,6 +4378,9 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
- struct usb_qualifier_descriptor *qual;
- int status;
-
-+ if (udev->quirks & USB_QUIRK_DEVICE_QUALIFIER)
-+ return;
-+
- qual = kmalloc (sizeof *qual, GFP_KERNEL);
- if (qual == NULL)
- return;
-diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
-index 5144d11d032c..c85459338991 100644
---- a/drivers/usb/core/quirks.c
-+++ b/drivers/usb/core/quirks.c
-@@ -93,6 +93,16 @@ static const struct usb_device_id usb_quirk_list[] = {
- { USB_DEVICE(0x04e8, 0x6601), .driver_info =
- USB_QUIRK_CONFIG_INTF_STRINGS },
-
-+ /* Elan Touchscreen */
-+ { USB_DEVICE(0x04f3, 0x0089), .driver_info =
-+ USB_QUIRK_DEVICE_QUALIFIER },
-+
-+ { USB_DEVICE(0x04f3, 0x009b), .driver_info =
-+ USB_QUIRK_DEVICE_QUALIFIER },
-+
-+ { USB_DEVICE(0x04f3, 0x016f), .driver_info =
-+ USB_QUIRK_DEVICE_QUALIFIER },
-+
- /* Roland SC-8820 */
- { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
-
-diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
-index 21a352079bc2..0985ff715c0c 100644
---- a/drivers/usb/dwc3/ep0.c
-+++ b/drivers/usb/dwc3/ep0.c
-@@ -251,7 +251,7 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
-
- /* stall is always issued on EP0 */
- dep = dwc->eps[0];
-- __dwc3_gadget_ep_set_halt(dep, 1);
-+ __dwc3_gadget_ep_set_halt(dep, 1, false);
- dep->flags = DWC3_EP_ENABLED;
- dwc->delayed_status = false;
-
-@@ -461,7 +461,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
- return -EINVAL;
- if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
- break;
-- ret = __dwc3_gadget_ep_set_halt(dep, set);
-+ ret = __dwc3_gadget_ep_set_halt(dep, set, true);
- if (ret)
- return -EINVAL;
- break;
-diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
-index 09e9619ae381..d90c70c23adb 100644
---- a/drivers/usb/dwc3/gadget.c
-+++ b/drivers/usb/dwc3/gadget.c
-@@ -532,12 +532,11 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
- if (!usb_endpoint_xfer_isoc(desc))
- return 0;
-
-- memset(&trb_link, 0, sizeof(trb_link));
--
- /* Link TRB for ISOC. The HWO bit is never reset */
- trb_st_hw = &dep->trb_pool[0];
-
- trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1];
-+ memset(trb_link, 0, sizeof(*trb_link));
-
- trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
- trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
-@@ -588,7 +587,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
-
- /* make sure HW endpoint isn't stalled */
- if (dep->flags & DWC3_EP_STALL)
-- __dwc3_gadget_ep_set_halt(dep, 0);
-+ __dwc3_gadget_ep_set_halt(dep, 0, false);
-
- reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
- reg &= ~DWC3_DALEPENA_EP(dep->number);
-@@ -1186,7 +1185,7 @@ out0:
- return ret;
- }
-
--int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
-+int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
- {
- struct dwc3_gadget_ep_cmd_params params;
- struct dwc3 *dwc = dep->dwc;
-@@ -1195,6 +1194,14 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
- memset(¶ms, 0x00, sizeof(params));
-
- if (value) {
-+ if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) ||
-+ (!list_empty(&dep->req_queued) ||
-+ !list_empty(&dep->request_list)))) {
-+ dev_dbg(dwc->dev, "%s: pending request, cannot halt\n",
-+ dep->name);
-+ return -EAGAIN;
-+ }
-+
- ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
- DWC3_DEPCMD_SETSTALL, ¶ms);
- if (ret)
-@@ -1234,7 +1241,7 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value)
- goto out;
- }
-
-- ret = __dwc3_gadget_ep_set_halt(dep, value);
-+ ret = __dwc3_gadget_ep_set_halt(dep, value, false);
- out:
- spin_unlock_irqrestore(&dwc->lock, flags);
-
-@@ -1254,7 +1261,7 @@ static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep)
- if (dep->number == 0 || dep->number == 1)
- return dwc3_gadget_ep0_set_halt(ep, 1);
- else
-- return dwc3_gadget_ep_set_halt(ep, 1);
-+ return __dwc3_gadget_ep_set_halt(dep, 1, false);
- }
-
- /* -------------------------------------------------------------------------- */
-diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
-index a0ee75b68a80..ac62558231be 100644
---- a/drivers/usb/dwc3/gadget.h
-+++ b/drivers/usb/dwc3/gadget.h
-@@ -85,7 +85,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc);
- int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);
- int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
- gfp_t gfp_flags);
--int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value);
-+int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol);
-
- /**
- * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
-diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
-index ab1065afbbd0..3384486c2884 100644
---- a/drivers/usb/gadget/f_acm.c
-+++ b/drivers/usb/gadget/f_acm.c
-@@ -430,11 +430,12 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
- if (acm->notify->driver_data) {
- VDBG(cdev, "reset acm control interface %d\n", intf);
- usb_ep_disable(acm->notify);
-- } else {
-- VDBG(cdev, "init acm ctrl interface %d\n", intf);
-+ }
-+
-+ if (!acm->notify->desc)
- if (config_ep_by_speed(cdev->gadget, f, acm->notify))
- return -EINVAL;
-- }
-+
- usb_ep_enable(acm->notify);
- acm->notify->driver_data = acm;
-
-diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
-index 5bcf7d001259..afd0a159fe61 100644
---- a/drivers/usb/gadget/f_fs.c
-+++ b/drivers/usb/gadget/f_fs.c
-@@ -1995,8 +1995,6 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
- func->conf = c;
- func->gadget = c->cdev->gadget;
-
-- ffs_data_get(func->ffs);
--
- /*
- * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
- * configurations are bound in sequence with list_for_each_entry,
-diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
-index 27768a7d986a..9ce0b135c8c8 100644
---- a/drivers/usb/gadget/udc-core.c
-+++ b/drivers/usb/gadget/udc-core.c
-@@ -456,6 +456,11 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
- {
- struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
-
-+ if (!udc->driver) {
-+ dev_err(dev, "soft-connect without a gadget driver\n");
-+ return -EOPNOTSUPP;
-+ }
-+
- if (sysfs_streq(buf, "connect")) {
- usb_gadget_udc_start(udc->gadget, udc->driver);
- usb_gadget_connect(udc->gadget);
-diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
-index c2d5afc57e22..1d29bbfeb9d5 100644
---- a/drivers/usb/musb/musb_cppi41.c
-+++ b/drivers/usb/musb/musb_cppi41.c
-@@ -190,7 +190,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
- }
- }
-
-- if (!list_empty(&controller->early_tx_list)) {
-+ if (!list_empty(&controller->early_tx_list) &&
-+ !hrtimer_is_queued(&controller->early_tx)) {
- ret = HRTIMER_RESTART;
- hrtimer_forward_now(&controller->early_tx,
- ktime_set(0, 150 * NSEC_PER_USEC));
-diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
-index 85f5215871de..865243e818b7 100644
---- a/drivers/usb/musb/musb_dsps.c
-+++ b/drivers/usb/musb/musb_dsps.c
-@@ -733,7 +733,9 @@ static int dsps_resume(struct device *dev)
- dsps_writel(mbase, wrp->mode, glue->context.mode);
- dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
- dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
-- setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
-+ if (musb->xceiv->state == OTG_STATE_B_IDLE &&
-+ musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
-+ mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
-
- return 0;
- }
-diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
-index 8afa813d690b..0180eef05656 100644
---- a/drivers/usb/phy/phy.c
-+++ b/drivers/usb/phy/phy.c
-@@ -229,6 +229,9 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
- phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
- if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
- dev_dbg(dev, "unable to find transceiver\n");
-+ if (!IS_ERR(phy))
-+ phy = ERR_PTR(-ENODEV);
-+
- goto err0;
- }
-
-diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
-index 63b2af2a87c0..3beae723ad3a 100644
---- a/drivers/usb/serial/cp210x.c
-+++ b/drivers/usb/serial/cp210x.c
-@@ -155,6 +155,7 @@ static const struct usb_device_id id_table[] = {
- { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
- { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
- { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
-+ { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */
- { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
- { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */
- { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
-diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
-index 3614620e09e1..a523adad6380 100644
---- a/drivers/usb/serial/ftdi_sio.c
-+++ b/drivers/usb/serial/ftdi_sio.c
-@@ -145,6 +145,7 @@ static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
- * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report.
- */
- static const struct usb_device_id id_table_combined[] = {
-+ { USB_DEVICE(FTDI_VID, FTDI_BRICK_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) },
-@@ -674,6 +675,8 @@ static const struct usb_device_id id_table_combined[] = {
- { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
- { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
- { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
-+ { USB_DEVICE(XSENS_VID, XSENS_AWINDA_DONGLE_PID) },
-+ { USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) },
- { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
- { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
-diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
-index 5937b2d242f2..6786b705ccf6 100644
---- a/drivers/usb/serial/ftdi_sio_ids.h
-+++ b/drivers/usb/serial/ftdi_sio_ids.h
-@@ -30,6 +30,12 @@
-
- /*** third-party PIDs (using FTDI_VID) ***/
-
-+/*
-+ * Certain versions of the official Windows FTDI driver reprogrammed
-+ * counterfeit FTDI devices to PID 0. Support these devices anyway.
-+ */
-+#define FTDI_BRICK_PID 0x0000
-+
- #define FTDI_LUMEL_PD12_PID 0x6002
-
- /*
-@@ -143,8 +149,12 @@
- * Xsens Technologies BV products (http://www.xsens.com).
- */
- #define XSENS_VID 0x2639
--#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
-+#define XSENS_AWINDA_STATION_PID 0x0101
-+#define XSENS_AWINDA_DONGLE_PID 0x0102
- #define XSENS_MTW_PID 0x0200 /* Xsens MTw */
-+#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
-+
-+/* Xsens devices using FTDI VID */
- #define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */
- #define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */
- #define XSENS_CONVERTER_2_PID 0xD38A
-diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
-index 618c1c1f227e..5cdb32b37e85 100644
---- a/drivers/usb/serial/kobil_sct.c
-+++ b/drivers/usb/serial/kobil_sct.c
-@@ -335,7 +335,8 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
- port->interrupt_out_urb->transfer_buffer_length = length;
-
- priv->cur_pos = priv->cur_pos + length;
-- result = usb_submit_urb(port->interrupt_out_urb, GFP_NOIO);
-+ result = usb_submit_urb(port->interrupt_out_urb,
-+ GFP_ATOMIC);
- dev_dbg(&port->dev, "%s - Send write URB returns: %i\n", __func__, result);
- todo = priv->filled - priv->cur_pos;
-
-@@ -350,7 +351,7 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
- if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
- priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
- result = usb_submit_urb(port->interrupt_in_urb,
-- GFP_NOIO);
-+ GFP_ATOMIC);
- dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result);
- }
- }
-diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
-index 4856fb7e637e..4b7bfb394a32 100644
---- a/drivers/usb/serial/opticon.c
-+++ b/drivers/usb/serial/opticon.c
-@@ -215,7 +215,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
-
- /* The connected devices do not have a bulk write endpoint,
- * to transmit data to de barcode device the control endpoint is used */
-- dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
-+ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
- if (!dr) {
- count = -ENOMEM;
- goto error_no_dr;
-diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
-index e47aabe0c760..8b3484134ab0 100644
---- a/drivers/usb/serial/option.c
-+++ b/drivers/usb/serial/option.c
-@@ -269,6 +269,7 @@ static void option_instat_callback(struct urb *urb);
- #define TELIT_PRODUCT_DE910_DUAL 0x1010
- #define TELIT_PRODUCT_UE910_V2 0x1012
- #define TELIT_PRODUCT_LE920 0x1200
-+#define TELIT_PRODUCT_LE910 0x1201
-
- /* ZTE PRODUCTS */
- #define ZTE_VENDOR_ID 0x19d2
-@@ -361,6 +362,7 @@ static void option_instat_callback(struct urb *urb);
-
- /* Haier products */
- #define HAIER_VENDOR_ID 0x201e
-+#define HAIER_PRODUCT_CE81B 0x10f8
- #define HAIER_PRODUCT_CE100 0x2009
-
- /* Cinterion (formerly Siemens) products */
-@@ -588,6 +590,11 @@ static const struct option_blacklist_info zte_1255_blacklist = {
- .reserved = BIT(3) | BIT(4),
- };
-
-+static const struct option_blacklist_info telit_le910_blacklist = {
-+ .sendsetup = BIT(0),
-+ .reserved = BIT(1) | BIT(2),
-+};
-+
- static const struct option_blacklist_info telit_le920_blacklist = {
- .sendsetup = BIT(0),
- .reserved = BIT(1) | BIT(5),
-@@ -1137,6 +1144,8 @@ static const struct usb_device_id option_ids[] = {
- { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) },
- { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) },
- { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) },
-+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
-+ .driver_info = (kernel_ulong_t)&telit_le910_blacklist },
- { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
- .driver_info = (kernel_ulong_t)&telit_le920_blacklist },
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
-@@ -1612,6 +1621,7 @@ static const struct usb_device_id option_ids[] = {
- { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
- { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
- { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
-+ { USB_DEVICE_AND_INTERFACE_INFO(HAIER_VENDOR_ID, HAIER_PRODUCT_CE81B, 0xff, 0xff, 0xff) },
- /* Pirelli */
- { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
- { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) },
-diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
-index 22c7d4360fa2..b1d815eb6d0b 100644
---- a/drivers/usb/storage/transport.c
-+++ b/drivers/usb/storage/transport.c
-@@ -1118,6 +1118,31 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
- */
- if (result == USB_STOR_XFER_LONG)
- fake_sense = 1;
-+
-+ /*
-+ * Sometimes a device will mistakenly skip the data phase
-+ * and go directly to the status phase without sending a
-+ * zero-length packet. If we get a 13-byte response here,
-+ * check whether it really is a CSW.
-+ */
-+ if (result == USB_STOR_XFER_SHORT &&
-+ srb->sc_data_direction == DMA_FROM_DEVICE &&
-+ transfer_length - scsi_get_resid(srb) ==
-+ US_BULK_CS_WRAP_LEN) {
-+ struct scatterlist *sg = NULL;
-+ unsigned int offset = 0;
-+
-+ if (usb_stor_access_xfer_buf((unsigned char *) bcs,
-+ US_BULK_CS_WRAP_LEN, srb, &sg,
-+ &offset, FROM_XFER_BUF) ==
-+ US_BULK_CS_WRAP_LEN &&
-+ bcs->Signature ==
-+ cpu_to_le32(US_BULK_CS_SIGN)) {
-+ usb_stor_dbg(us, "Device skipped data phase\n");
-+ scsi_set_resid(srb, transfer_length);
-+ goto skipped_data_phase;
-+ }
-+ }
- }
-
- /* See flow chart on pg 15 of the Bulk Only Transport spec for
-@@ -1153,6 +1178,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
- if (result != USB_STOR_XFER_GOOD)
- return USB_STOR_TRANSPORT_ERROR;
-
-+ skipped_data_phase:
- /* check bulk status */
- residue = le32_to_cpu(bcs->Residue);
- usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
-diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
-index 61b182bf32a2..dbfe4eecf12e 100644
---- a/drivers/video/console/bitblit.c
-+++ b/drivers/video/console/bitblit.c
-@@ -205,7 +205,6 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
- static void bit_clear_margins(struct vc_data *vc, struct fb_info *info,
- int bottom_only)
- {
-- int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
- unsigned int cw = vc->vc_font.width;
- unsigned int ch = vc->vc_font.height;
- unsigned int rw = info->var.xres - (vc->vc_cols*cw);
-@@ -214,7 +213,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info,
- unsigned int bs = info->var.yres - bh;
- struct fb_fillrect region;
-
-- region.color = attr_bgcol_ec(bgshift, vc, info);
-+ region.color = 0;
- region.rop = ROP_COPY;
-
- if (rw && !bottom_only) {
-diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c
-index 41b32ae23dac..5a3cbf6dff4d 100644
---- a/drivers/video/console/fbcon_ccw.c
-+++ b/drivers/video/console/fbcon_ccw.c
-@@ -197,9 +197,8 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info,
- unsigned int bh = info->var.xres - (vc->vc_rows*ch);
- unsigned int bs = vc->vc_rows*ch;
- struct fb_fillrect region;
-- int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-
-- region.color = attr_bgcol_ec(bgshift,vc,info);
-+ region.color = 0;
- region.rop = ROP_COPY;
-
- if (rw && !bottom_only) {
-diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c
-index a93670ef7f89..e7ee44db4e98 100644
---- a/drivers/video/console/fbcon_cw.c
-+++ b/drivers/video/console/fbcon_cw.c
-@@ -180,9 +180,8 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info,
- unsigned int bh = info->var.xres - (vc->vc_rows*ch);
- unsigned int rs = info->var.yres - rw;
- struct fb_fillrect region;
-- int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-
-- region.color = attr_bgcol_ec(bgshift,vc,info);
-+ region.color = 0;
- region.rop = ROP_COPY;
-
- if (rw && !bottom_only) {
-diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c
-index ff0872c0498b..19e3714abfe8 100644
---- a/drivers/video/console/fbcon_ud.c
-+++ b/drivers/video/console/fbcon_ud.c
-@@ -227,9 +227,8 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info,
- unsigned int rw = info->var.xres - (vc->vc_cols*cw);
- unsigned int bh = info->var.yres - (vc->vc_rows*ch);
- struct fb_fillrect region;
-- int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
-
-- region.color = attr_bgcol_ec(bgshift,vc,info);
-+ region.color = 0;
- region.rop = ROP_COPY;
-
- if (rw && !bottom_only) {
-diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
-index a416f9b2a7f6..827b5f8e6297 100644
---- a/drivers/virtio/virtio_pci.c
-+++ b/drivers/virtio/virtio_pci.c
-@@ -791,6 +791,7 @@ static int virtio_pci_restore(struct device *dev)
- struct pci_dev *pci_dev = to_pci_dev(dev);
- struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
- struct virtio_driver *drv;
-+ unsigned status = 0;
- int ret;
-
- drv = container_of(vp_dev->vdev.dev.driver,
-@@ -801,14 +802,40 @@ static int virtio_pci_restore(struct device *dev)
- return ret;
-
- pci_set_master(pci_dev);
-+ /* We always start by resetting the device, in case a previous
-+ * driver messed it up. */
-+ vp_reset(&vp_dev->vdev);
-+
-+ /* Acknowledge that we've seen the device. */
-+ status |= VIRTIO_CONFIG_S_ACKNOWLEDGE;
-+ vp_set_status(&vp_dev->vdev, status);
-+
-+ /* Maybe driver failed before freeze.
-+ * Restore the failed status, for debugging. */
-+ status |= vp_dev->saved_status & VIRTIO_CONFIG_S_FAILED;
-+ vp_set_status(&vp_dev->vdev, status);
-+
-+ if (!drv)
-+ return 0;
-+
-+ /* We have a driver! */
-+ status |= VIRTIO_CONFIG_S_DRIVER;
-+ vp_set_status(&vp_dev->vdev, status);
-+
- vp_finalize_features(&vp_dev->vdev);
-
-- if (drv && drv->restore)
-+ if (drv->restore) {
- ret = drv->restore(&vp_dev->vdev);
-+ if (ret) {
-+ status |= VIRTIO_CONFIG_S_FAILED;
-+ vp_set_status(&vp_dev->vdev, status);
-+ return ret;
-+ }
-+ }
-
- /* Finally, tell the device we're all set */
-- if (!ret)
-- vp_set_status(&vp_dev->vdev, vp_dev->saved_status);
-+ status |= VIRTIO_CONFIG_S_DRIVER_OK;
-+ vp_set_status(&vp_dev->vdev, status);
-
- return ret;
- }
-diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
-index ca248b0687f4..196b089b0052 100644
---- a/fs/btrfs/file-item.c
-+++ b/fs/btrfs/file-item.c
-@@ -423,7 +423,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
- ret = 0;
- fail:
- while (ret < 0 && !list_empty(&tmplist)) {
-- sums = list_entry(&tmplist, struct btrfs_ordered_sum, list);
-+ sums = list_entry(tmplist.next, struct btrfs_ordered_sum, list);
- list_del(&sums->list);
- kfree(sums);
- }
-diff --git a/fs/buffer.c b/fs/buffer.c
-index 71e2d0ed8530..4d06a573d199 100644
---- a/fs/buffer.c
-+++ b/fs/buffer.c
-@@ -2077,6 +2077,7 @@ int generic_write_end(struct file *file, struct address_space *mapping,
- struct page *page, void *fsdata)
- {
- struct inode *inode = mapping->host;
-+ loff_t old_size = inode->i_size;
- int i_size_changed = 0;
-
- copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
-@@ -2096,6 +2097,8 @@ int generic_write_end(struct file *file, struct address_space *mapping,
- unlock_page(page);
- page_cache_release(page);
-
-+ if (old_size < pos)
-+ pagecache_isize_extended(inode, old_size, pos);
- /*
- * Don't mark the inode dirty under page lock. First, it unnecessarily
- * makes the holding time of page lock longer. Second, it forces lock
-@@ -2313,6 +2316,11 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
- err = 0;
-
- balance_dirty_pages_ratelimited(mapping);
-+
-+ if (unlikely(fatal_signal_pending(current))) {
-+ err = -EINTR;
-+ goto out;
-+ }
- }
-
- /* page covers the boundary, find the boundary offset */
-diff --git a/fs/dcache.c b/fs/dcache.c
-index 58d57da91d2a..436612777203 100644
---- a/fs/dcache.c
-+++ b/fs/dcache.c
-@@ -2824,6 +2824,9 @@ static int prepend(char **buffer, int *buflen, const char *str, int namelen)
- * the beginning of the name. The sequence number check at the caller will
- * retry it again when a d_move() does happen. So any garbage in the buffer
- * due to mismatched pointer and length will be discarded.
-+ *
-+ * Data dependency barrier is needed to make sure that we see that terminating
-+ * NUL. Alpha strikes again, film at 11...
- */
- static int prepend_name(char **buffer, int *buflen, struct qstr *name)
- {
-@@ -2831,6 +2834,8 @@ static int prepend_name(char **buffer, int *buflen, struct qstr *name)
- u32 dlen = ACCESS_ONCE(name->len);
- char *p;
-
-+ smp_read_barrier_depends();
-+
- *buflen -= dlen + 1;
- if (*buflen < 0)
- return -ENAMETOOLONG;
-diff --git a/fs/ext3/super.c b/fs/ext3/super.c
-index 37fd31ed16e7..0498390f309e 100644
---- a/fs/ext3/super.c
-+++ b/fs/ext3/super.c
-@@ -1354,13 +1354,6 @@ set_qf_format:
- "not specified.");
- return 0;
- }
-- } else {
-- if (sbi->s_jquota_fmt) {
-- ext3_msg(sb, KERN_ERR, "error: journaled quota format "
-- "specified with no journaling "
-- "enabled.");
-- return 0;
-- }
- }
- #endif
- return 1;
-diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
-index 3285aa5a706a..b610779a958c 100644
---- a/fs/ext4/bitmap.c
-+++ b/fs/ext4/bitmap.c
-@@ -24,8 +24,7 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
- __u32 provided, calculated;
- struct ext4_sb_info *sbi = EXT4_SB(sb);
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return 1;
-
- provided = le16_to_cpu(gdp->bg_inode_bitmap_csum_lo);
-@@ -46,8 +45,7 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
- __u32 csum;
- struct ext4_sb_info *sbi = EXT4_SB(sb);
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return;
-
- csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
-@@ -65,8 +63,7 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
- struct ext4_sb_info *sbi = EXT4_SB(sb);
- int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return 1;
-
- provided = le16_to_cpu(gdp->bg_block_bitmap_csum_lo);
-@@ -91,8 +88,7 @@ void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
- __u32 csum;
- struct ext4_sb_info *sbi = EXT4_SB(sb);
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return;
-
- csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
-diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
-index 62f024c051ce..2a6830a7af33 100644
---- a/fs/ext4/ext4.h
-+++ b/fs/ext4/ext4.h
-@@ -2110,6 +2110,7 @@ int do_journal_get_write_access(handle_t *handle,
- #define CONVERT_INLINE_DATA 2
-
- extern struct inode *ext4_iget(struct super_block *, unsigned long);
-+extern struct inode *ext4_iget_normal(struct super_block *, unsigned long);
- extern int ext4_write_inode(struct inode *, struct writeback_control *);
- extern int ext4_setattr(struct dentry *, struct iattr *);
- extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
-@@ -2340,10 +2341,18 @@ extern int ext4_register_li_request(struct super_block *sb,
- static inline int ext4_has_group_desc_csum(struct super_block *sb)
- {
- return EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_GDT_CSUM |
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM);
-+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM) ||
-+ (EXT4_SB(sb)->s_chksum_driver != NULL);
- }
-
-+static inline int ext4_has_metadata_csum(struct super_block *sb)
-+{
-+ WARN_ON_ONCE(EXT4_HAS_RO_COMPAT_FEATURE(sb,
-+ EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
-+ !EXT4_SB(sb)->s_chksum_driver);
-+
-+ return (EXT4_SB(sb)->s_chksum_driver != NULL);
-+}
- static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
- {
- return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
-diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
-index 47188916dd8d..96a1ce159f51 100644
---- a/fs/ext4/extents.c
-+++ b/fs/ext4/extents.c
-@@ -74,8 +74,7 @@ static int ext4_extent_block_csum_verify(struct inode *inode,
- {
- struct ext4_extent_tail *et;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return 1;
-
- et = find_ext4_extent_tail(eh);
-@@ -89,8 +88,7 @@ static void ext4_extent_block_csum_set(struct inode *inode,
- {
- struct ext4_extent_tail *et;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return;
-
- et = find_ext4_extent_tail(eh);
-diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
-index 64bb32f17903..a8d1a64d8cb0 100644
---- a/fs/ext4/ialloc.c
-+++ b/fs/ext4/ialloc.c
-@@ -864,6 +864,10 @@ got:
- struct buffer_head *block_bitmap_bh;
-
- block_bitmap_bh = ext4_read_block_bitmap(sb, group);
-+ if (!block_bitmap_bh) {
-+ err = -EIO;
-+ goto out;
-+ }
- BUFFER_TRACE(block_bitmap_bh, "get block bitmap access");
- err = ext4_journal_get_write_access(handle, block_bitmap_bh);
- if (err) {
-@@ -988,8 +992,7 @@ got:
- spin_unlock(&sbi->s_next_gen_lock);
-
- /* Precompute checksum seed for inode metadata */
-- if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
-+ if (ext4_has_metadata_csum(sb)) {
- __u32 csum;
- __le32 inum = cpu_to_le32(inode->i_ino);
- __le32 gen = cpu_to_le32(inode->i_generation);
-diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
-index 82edf5b93352..8c03b747021b 100644
---- a/fs/ext4/inline.c
-+++ b/fs/ext4/inline.c
-@@ -1128,8 +1128,7 @@ static int ext4_finish_convert_inline_dir(handle_t *handle,
- memcpy((void *)de, buf + EXT4_INLINE_DOTDOT_SIZE,
- inline_size - EXT4_INLINE_DOTDOT_SIZE);
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(inode->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- inode->i_size = inode->i_sb->s_blocksize;
-diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
-index b56062dc8b62..3a7e0341447f 100644
---- a/fs/ext4/inode.c
-+++ b/fs/ext4/inode.c
-@@ -83,8 +83,7 @@ static int ext4_inode_csum_verify(struct inode *inode, struct ext4_inode *raw,
-
- if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
- cpu_to_le32(EXT4_OS_LINUX) ||
-- !EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ !ext4_has_metadata_csum(inode->i_sb))
- return 1;
-
- provided = le16_to_cpu(raw->i_checksum_lo);
-@@ -105,8 +104,7 @@ static void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw,
-
- if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
- cpu_to_le32(EXT4_OS_LINUX) ||
-- !EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ !ext4_has_metadata_csum(inode->i_sb))
- return;
-
- csum = ext4_inode_csum(inode, raw, ei);
-@@ -2633,6 +2631,20 @@ static int ext4_nonda_switch(struct super_block *sb)
- return 0;
- }
-
-+/* We always reserve for an inode update; the superblock could be there too */
-+static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len)
-+{
-+ if (likely(EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-+ EXT4_FEATURE_RO_COMPAT_LARGE_FILE)))
-+ return 1;
-+
-+ if (pos + len <= 0x7fffffffULL)
-+ return 1;
-+
-+ /* We might need to update the superblock to set LARGE_FILE */
-+ return 2;
-+}
-+
- static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata)
-@@ -2683,7 +2695,8 @@ retry_grab:
- * of file which has an already mapped buffer.
- */
- retry_journal:
-- handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, 1);
-+ handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
-+ ext4_da_write_credits(inode, pos, len));
- if (IS_ERR(handle)) {
- page_cache_release(page);
- return PTR_ERR(handle);
-@@ -4061,8 +4074,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
- ei->i_extra_isize = 0;
-
- /* Precompute checksum seed for inode metadata */
-- if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
-+ if (ext4_has_metadata_csum(sb)) {
- struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
- __u32 csum;
- __le32 inum = cpu_to_le32(inode->i_ino);
-@@ -4250,6 +4262,13 @@ bad_inode:
- return ERR_PTR(ret);
- }
-
-+struct inode *ext4_iget_normal(struct super_block *sb, unsigned long ino)
-+{
-+ if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
-+ return ERR_PTR(-EIO);
-+ return ext4_iget(sb, ino);
-+}
-+
- static int ext4_inode_blocks_set(handle_t *handle,
- struct ext4_inode *raw_inode,
- struct ext4_inode_info *ei)
-@@ -4645,8 +4664,12 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
- ext4_orphan_del(NULL, inode);
- goto err_out;
- }
-- } else
-+ } else {
-+ loff_t oldsize = inode->i_size;
-+
- i_size_write(inode, attr->ia_size);
-+ pagecache_isize_extended(inode, oldsize, inode->i_size);
-+ }
-
- /*
- * Blocks are going to be removed from the inode. Wait
-diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
-index a2a837f00407..dfe982dee0b3 100644
---- a/fs/ext4/ioctl.c
-+++ b/fs/ext4/ioctl.c
-@@ -343,8 +343,7 @@ flags_out:
- if (!inode_owner_or_capable(inode))
- return -EPERM;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
-+ if (ext4_has_metadata_csum(inode->i_sb)) {
- ext4_warning(sb, "Setting inode version is not "
- "supported with metadata_csum enabled.");
- return -ENOTTY;
-@@ -544,9 +543,17 @@ group_add_out:
- }
-
- case EXT4_IOC_SWAP_BOOT:
-+ {
-+ int err;
- if (!(filp->f_mode & FMODE_WRITE))
- return -EBADF;
-- return swap_inode_boot_loader(sb, inode);
-+ err = mnt_want_write_file(filp);
-+ if (err)
-+ return err;
-+ err = swap_inode_boot_loader(sb, inode);
-+ mnt_drop_write_file(filp);
-+ return err;
-+ }
-
- case EXT4_IOC_RESIZE_FS: {
- ext4_fsblk_t n_blocks_count;
-diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
-index 04434ad3e8e0..1268a1b5afa9 100644
---- a/fs/ext4/mmp.c
-+++ b/fs/ext4/mmp.c
-@@ -20,8 +20,7 @@ static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
-
- int ext4_mmp_csum_verify(struct super_block *sb, struct mmp_struct *mmp)
- {
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return 1;
-
- return mmp->mmp_checksum == ext4_mmp_csum(sb, mmp);
-@@ -29,8 +28,7 @@ int ext4_mmp_csum_verify(struct super_block *sb, struct mmp_struct *mmp)
-
- void ext4_mmp_csum_set(struct super_block *sb, struct mmp_struct *mmp)
- {
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return;
-
- mmp->mmp_checksum = ext4_mmp_csum(sb, mmp);
-diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
-index d050e043e884..2dcbfb6245d8 100644
---- a/fs/ext4/namei.c
-+++ b/fs/ext4/namei.c
-@@ -123,8 +123,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
- "directory leaf block found instead of index block");
- return ERR_PTR(-EIO);
- }
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) ||
-+ if (!ext4_has_metadata_csum(inode->i_sb) ||
- buffer_verified(bh))
- return bh;
-
-@@ -339,8 +338,7 @@ int ext4_dirent_csum_verify(struct inode *inode, struct ext4_dir_entry *dirent)
- {
- struct ext4_dir_entry_tail *t;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return 1;
-
- t = get_dirent_tail(inode, dirent);
-@@ -361,8 +359,7 @@ static void ext4_dirent_csum_set(struct inode *inode,
- {
- struct ext4_dir_entry_tail *t;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return;
-
- t = get_dirent_tail(inode, dirent);
-@@ -437,8 +434,7 @@ static int ext4_dx_csum_verify(struct inode *inode,
- struct dx_tail *t;
- int count_offset, limit, count;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return 1;
-
- c = get_dx_countlimit(inode, dirent, &count_offset);
-@@ -467,8 +463,7 @@ static void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry *dirent)
- struct dx_tail *t;
- int count_offset, limit, count;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return;
-
- c = get_dx_countlimit(inode, dirent, &count_offset);
-@@ -556,8 +551,7 @@ static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize)
- unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) -
- EXT4_DIR_REC_LEN(2) - infosize;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(dir->i_sb))
- entry_space -= sizeof(struct dx_tail);
- return entry_space / sizeof(struct dx_entry);
- }
-@@ -566,8 +560,7 @@ static inline unsigned dx_node_limit(struct inode *dir)
- {
- unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0);
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(dir->i_sb))
- entry_space -= sizeof(struct dx_tail);
- return entry_space / sizeof(struct dx_entry);
- }
-@@ -1429,7 +1422,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
- dentry);
- return ERR_PTR(-EIO);
- }
-- inode = ext4_iget(dir->i_sb, ino);
-+ inode = ext4_iget_normal(dir->i_sb, ino);
- if (inode == ERR_PTR(-ESTALE)) {
- EXT4_ERROR_INODE(dir,
- "deleted inode referenced: %u",
-@@ -1460,7 +1453,7 @@ struct dentry *ext4_get_parent(struct dentry *child)
- return ERR_PTR(-EIO);
- }
-
-- return d_obtain_alias(ext4_iget(child->d_inode->i_sb, ino));
-+ return d_obtain_alias(ext4_iget_normal(child->d_inode->i_sb, ino));
- }
-
- /*
-@@ -1534,8 +1527,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
- int csum_size = 0;
- int err = 0, i;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(dir->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- bh2 = ext4_append(handle, dir, &newblock);
-@@ -1704,8 +1696,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
- int csum_size = 0;
- int err;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(inode->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- if (!de) {
-@@ -1772,8 +1763,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
- struct fake_dirent *fde;
- int csum_size = 0;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(inode->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- blocksize = dir->i_sb->s_blocksize;
-@@ -1889,8 +1879,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
- ext4_lblk_t block, blocks;
- int csum_size = 0;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(inode->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- sb = dir->i_sb;
-@@ -2152,8 +2141,7 @@ static int ext4_delete_entry(handle_t *handle,
- return err;
- }
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(dir->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- BUFFER_TRACE(bh, "get_write_access");
-@@ -2372,8 +2360,7 @@ static int ext4_init_new_dir(handle_t *handle, struct inode *dir,
- int csum_size = 0;
- int err;
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(dir->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-
- if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
-diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
-index f3b84cd9de56..2400ad1c3d12 100644
---- a/fs/ext4/resize.c
-+++ b/fs/ext4/resize.c
-@@ -1071,7 +1071,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
- break;
-
- if (meta_bg == 0)
-- backup_block = group * bpg + blk_off;
-+ backup_block = ((ext4_fsblk_t)group) * bpg + blk_off;
- else
- backup_block = (ext4_group_first_block_no(sb, group) +
- ext4_bg_has_super(sb, group));
-@@ -1200,8 +1200,7 @@ static int ext4_set_bitmap_checksums(struct super_block *sb,
- {
- struct buffer_head *bh;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return 0;
-
- bh = ext4_get_bitmap(sb, group_data->inode_bitmap);
-diff --git a/fs/ext4/super.c b/fs/ext4/super.c
-index a46030d6b4af..9fb3e6c0c578 100644
---- a/fs/ext4/super.c
-+++ b/fs/ext4/super.c
-@@ -140,8 +140,7 @@ static __le32 ext4_superblock_csum(struct super_block *sb,
- int ext4_superblock_csum_verify(struct super_block *sb,
- struct ext4_super_block *es)
- {
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return 1;
-
- return es->s_checksum == ext4_superblock_csum(sb, es);
-@@ -151,8 +150,7 @@ void ext4_superblock_csum_set(struct super_block *sb)
- {
- struct ext4_super_block *es = EXT4_SB(sb)->s_es;
-
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(sb))
- return;
-
- es->s_checksum = ext4_superblock_csum(sb, es);
-@@ -996,7 +994,7 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb,
- * Currently we don't know the generation for parent directory, so
- * a generation of 0 means "accept any"
- */
-- inode = ext4_iget(sb, ino);
-+ inode = ext4_iget_normal(sb, ino);
- if (IS_ERR(inode))
- return ERR_CAST(inode);
- if (generation && inode->i_generation != generation) {
-@@ -1706,13 +1704,6 @@ static int parse_options(char *options, struct super_block *sb,
- "not specified");
- return 0;
- }
-- } else {
-- if (sbi->s_jquota_fmt) {
-- ext4_msg(sb, KERN_ERR, "journaled quota format "
-- "specified with no journaling "
-- "enabled");
-- return 0;
-- }
- }
- #endif
- if (test_opt(sb, DIOREAD_NOLOCK)) {
-@@ -2010,8 +2001,7 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
- __u16 crc = 0;
- __le32 le_group = cpu_to_le32(block_group);
-
-- if ((sbi->s_es->s_feature_ro_compat &
-- cpu_to_le32(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))) {
-+ if (ext4_has_metadata_csum(sbi->s_sb)) {
- /* Use new metadata_csum algorithm */
- __le16 save_csum;
- __u32 csum32;
-@@ -2029,6 +2019,10 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
- }
-
- /* old crc16 code */
-+ if (!(sbi->s_es->s_feature_ro_compat &
-+ cpu_to_le32(EXT4_FEATURE_RO_COMPAT_GDT_CSUM)))
-+ return 0;
-+
- offset = offsetof(struct ext4_group_desc, bg_checksum);
-
- crc = crc16(~0, sbi->s_es->s_uuid, sizeof(sbi->s_es->s_uuid));
-@@ -3167,8 +3161,7 @@ static int set_journal_csum_feature_set(struct super_block *sb)
- int compat, incompat;
- struct ext4_sb_info *sbi = EXT4_SB(sb);
-
-- if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
-+ if (ext4_has_metadata_csum(sb)) {
- /* journal checksum v3 */
- compat = 0;
- incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
-@@ -3475,8 +3468,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
- }
-
- /* Precompute checksum seed for all metadata */
-- if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (ext4_has_metadata_csum(sb))
- sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid,
- sizeof(es->s_uuid));
-
-@@ -3494,6 +3486,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
- #ifdef CONFIG_EXT4_FS_POSIX_ACL
- set_opt(sb, POSIX_ACL);
- #endif
-+ /* don't forget to enable journal_csum when metadata_csum is enabled. */
-+ if (ext4_has_metadata_csum(sb))
-+ set_opt(sb, JOURNAL_CHECKSUM);
-+
- if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
- set_opt(sb, JOURNAL_DATA);
- else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
-diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
-index 55e611c1513c..8825154b20b6 100644
---- a/fs/ext4/xattr.c
-+++ b/fs/ext4/xattr.c
-@@ -141,8 +141,7 @@ static int ext4_xattr_block_csum_verify(struct inode *inode,
- sector_t block_nr,
- struct ext4_xattr_header *hdr)
- {
-- if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
-+ if (ext4_has_metadata_csum(inode->i_sb) &&
- (hdr->h_checksum != ext4_xattr_block_csum(inode, block_nr, hdr)))
- return 0;
- return 1;
-@@ -152,8 +151,7 @@ static void ext4_xattr_block_csum_set(struct inode *inode,
- sector_t block_nr,
- struct ext4_xattr_header *hdr)
- {
-- if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
-+ if (!ext4_has_metadata_csum(inode->i_sb))
- return;
-
- hdr->h_checksum = ext4_xattr_block_csum(inode, block_nr, hdr);
-@@ -189,14 +187,28 @@ ext4_listxattr(struct dentry *dentry, char *buffer, size_t size)
- }
-
- static int
--ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end)
-+ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end,
-+ void *value_start)
- {
-- while (!IS_LAST_ENTRY(entry)) {
-- struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(entry);
-+ struct ext4_xattr_entry *e = entry;
-+
-+ while (!IS_LAST_ENTRY(e)) {
-+ struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(e);
- if ((void *)next >= end)
- return -EIO;
-- entry = next;
-+ e = next;
- }
-+
-+ while (!IS_LAST_ENTRY(entry)) {
-+ if (entry->e_value_size != 0 &&
-+ (value_start + le16_to_cpu(entry->e_value_offs) <
-+ (void *)e + sizeof(__u32) ||
-+ value_start + le16_to_cpu(entry->e_value_offs) +
-+ le32_to_cpu(entry->e_value_size) > end))
-+ return -EIO;
-+ entry = EXT4_XATTR_NEXT(entry);
-+ }
-+
- return 0;
- }
-
-@@ -213,7 +225,8 @@ ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh)
- return -EIO;
- if (!ext4_xattr_block_csum_verify(inode, bh->b_blocknr, BHDR(bh)))
- return -EIO;
-- error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size);
-+ error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,
-+ bh->b_data);
- if (!error)
- set_buffer_verified(bh);
- return error;
-@@ -329,7 +342,7 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
- header = IHDR(inode, raw_inode);
- entry = IFIRST(header);
- end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
-- error = ext4_xattr_check_names(entry, end);
-+ error = ext4_xattr_check_names(entry, end, entry);
- if (error)
- goto cleanup;
- error = ext4_xattr_find_entry(&entry, name_index, name,
-@@ -457,7 +470,7 @@ ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
- raw_inode = ext4_raw_inode(&iloc);
- header = IHDR(inode, raw_inode);
- end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
-- error = ext4_xattr_check_names(IFIRST(header), end);
-+ error = ext4_xattr_check_names(IFIRST(header), end, IFIRST(header));
- if (error)
- goto cleanup;
- error = ext4_xattr_list_entries(dentry, IFIRST(header),
-@@ -972,7 +985,8 @@ int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
- is->s.here = is->s.first;
- is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
- if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
-- error = ext4_xattr_check_names(IFIRST(header), is->s.end);
-+ error = ext4_xattr_check_names(IFIRST(header), is->s.end,
-+ IFIRST(header));
- if (error)
- return error;
- /* Find the named attribute. */
-diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
-index 9b329b55ffe3..bcbef08a4d8f 100644
---- a/fs/jbd2/recovery.c
-+++ b/fs/jbd2/recovery.c
-@@ -525,6 +525,7 @@ static int do_one_pass(journal_t *journal,
- !jbd2_descr_block_csum_verify(journal,
- bh->b_data)) {
- err = -EIO;
-+ brelse(bh);
- goto failed;
- }
-
-diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h
-index 413ef89c2d1b..046fee8b6e9b 100644
---- a/fs/jffs2/jffs2_fs_sb.h
-+++ b/fs/jffs2/jffs2_fs_sb.h
-@@ -134,8 +134,6 @@ struct jffs2_sb_info {
- struct rw_semaphore wbuf_sem; /* Protects the write buffer */
-
- struct delayed_work wbuf_dwork; /* write-buffer write-out work */
-- int wbuf_queued; /* non-zero delayed work is queued */
-- spinlock_t wbuf_dwork_lock; /* protects wbuf_dwork and and wbuf_queued */
-
- unsigned char *oobbuf;
- int oobavail; /* How many bytes are available for JFFS2 in OOB */
-diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
-index a6597d60d76d..09ed55190ee2 100644
---- a/fs/jffs2/wbuf.c
-+++ b/fs/jffs2/wbuf.c
-@@ -1162,10 +1162,6 @@ static void delayed_wbuf_sync(struct work_struct *work)
- struct jffs2_sb_info *c = work_to_sb(work);
- struct super_block *sb = OFNI_BS_2SFFJ(c);
-
-- spin_lock(&c->wbuf_dwork_lock);
-- c->wbuf_queued = 0;
-- spin_unlock(&c->wbuf_dwork_lock);
--
- if (!(sb->s_flags & MS_RDONLY)) {
- jffs2_dbg(1, "%s()\n", __func__);
- jffs2_flush_wbuf_gc(c, 0);
-@@ -1180,14 +1176,9 @@ void jffs2_dirty_trigger(struct jffs2_sb_info *c)
- if (sb->s_flags & MS_RDONLY)
- return;
-
-- spin_lock(&c->wbuf_dwork_lock);
-- if (!c->wbuf_queued) {
-+ delay = msecs_to_jiffies(dirty_writeback_interval * 10);
-+ if (queue_delayed_work(system_long_wq, &c->wbuf_dwork, delay))
- jffs2_dbg(1, "%s()\n", __func__);
-- delay = msecs_to_jiffies(dirty_writeback_interval * 10);
-- queue_delayed_work(system_long_wq, &c->wbuf_dwork, delay);
-- c->wbuf_queued = 1;
-- }
-- spin_unlock(&c->wbuf_dwork_lock);
- }
-
- int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
-@@ -1211,7 +1202,6 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
-
- /* Initialise write buffer */
- init_rwsem(&c->wbuf_sem);
-- spin_lock_init(&c->wbuf_dwork_lock);
- INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync);
- c->wbuf_pagesize = c->mtd->writesize;
- c->wbuf_ofs = 0xFFFFFFFF;
-@@ -1251,7 +1241,6 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) {
-
- /* Initialize write buffer */
- init_rwsem(&c->wbuf_sem);
-- spin_lock_init(&c->wbuf_dwork_lock);
- INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync);
- c->wbuf_pagesize = c->mtd->erasesize;
-
-@@ -1311,7 +1300,6 @@ int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
-
- /* Initialize write buffer */
- init_rwsem(&c->wbuf_sem);
-- spin_lock_init(&c->wbuf_dwork_lock);
- INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync);
-
- c->wbuf_pagesize = c->mtd->writesize;
-@@ -1346,7 +1334,6 @@ int jffs2_ubivol_setup(struct jffs2_sb_info *c) {
- return 0;
-
- init_rwsem(&c->wbuf_sem);
-- spin_lock_init(&c->wbuf_dwork_lock);
- INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync);
-
- c->wbuf_pagesize = c->mtd->writesize;
-diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
-index 1812f026960c..6ae664b489af 100644
---- a/fs/lockd/mon.c
-+++ b/fs/lockd/mon.c
-@@ -159,6 +159,12 @@ static int nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res,
-
- msg.rpc_proc = &clnt->cl_procinfo[proc];
- status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFTCONN);
-+ if (status == -ECONNREFUSED) {
-+ dprintk("lockd: NSM upcall RPC failed, status=%d, forcing rebind\n",
-+ status);
-+ rpc_force_rebind(clnt);
-+ status = rpc_call_sync(clnt, &msg, RPC_TASK_SOFTCONN);
-+ }
- if (status < 0)
- dprintk("lockd: NSM upcall RPC failed, status=%d\n",
- status);
-diff --git a/fs/namei.c b/fs/namei.c
-index dd2f2c5bda55..0dd72c8e65fd 100644
---- a/fs/namei.c
-+++ b/fs/namei.c
-@@ -3128,7 +3128,8 @@ static int do_tmpfile(int dfd, struct filename *pathname,
- if (error)
- goto out2;
- audit_inode(pathname, nd->path.dentry, 0);
-- error = may_open(&nd->path, op->acc_mode, op->open_flag);
-+ /* Don't check for other permissions, the inode was just created */
-+ error = may_open(&nd->path, MAY_OPEN, op->open_flag);
- if (error)
- goto out2;
- file->f_path.mnt = nd->path.mnt;
-diff --git a/fs/namespace.c b/fs/namespace.c
-index c7d4a0ae2c65..d9bf3efbf040 100644
---- a/fs/namespace.c
-+++ b/fs/namespace.c
-@@ -2831,6 +2831,9 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
- /* make sure we can reach put_old from new_root */
- if (!is_path_reachable(old_mnt, old.dentry, &new))
- goto out4;
-+ /* make certain new is below the root */
-+ if (!is_path_reachable(new_mnt, new.dentry, &root))
-+ goto out4;
- root_mp->m_count++; /* pin it so it won't go away */
- lock_mount_hash();
- detach_mnt(new_mnt, &parent_path);
-diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
-index f23a6ca37504..86f5d3e474bf 100644
---- a/fs/nfsd/nfs4proc.c
-+++ b/fs/nfsd/nfs4proc.c
-@@ -1243,7 +1243,8 @@ static bool need_wrongsec_check(struct svc_rqst *rqstp)
- */
- if (argp->opcnt == resp->opcnt)
- return false;
--
-+ if (next->opnum == OP_ILLEGAL)
-+ return false;
- nextd = OPDESC(next);
- /*
- * Rest of 2.6.3.1.1: certain operations will return WRONGSEC
-diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
-index 12823845d324..14120a3c6195 100644
---- a/fs/pstore/inode.c
-+++ b/fs/pstore/inode.c
-@@ -319,10 +319,10 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
- compressed ? ".enc.z" : "");
- break;
- case PSTORE_TYPE_CONSOLE:
-- sprintf(name, "console-%s", psname);
-+ sprintf(name, "console-%s-%lld", psname, id);
- break;
- case PSTORE_TYPE_FTRACE:
-- sprintf(name, "ftrace-%s", psname);
-+ sprintf(name, "ftrace-%s-%lld", psname, id);
- break;
- case PSTORE_TYPE_MCE:
- sprintf(name, "mce-%s-%lld", psname, id);
-diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
-index ce87c9007b0f..89da95700c69 100644
---- a/fs/quota/dquot.c
-+++ b/fs/quota/dquot.c
-@@ -637,7 +637,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
- dqstats_inc(DQST_LOOKUPS);
- err = sb->dq_op->write_dquot(dquot);
- if (!ret && err)
-- err = ret;
-+ ret = err;
- dqput(dquot);
- spin_lock(&dq_list_lock);
- }
-diff --git a/fs/super.c b/fs/super.c
-index 7624267b2043..88a6bc6e3cc9 100644
---- a/fs/super.c
-+++ b/fs/super.c
-@@ -81,6 +81,8 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
- inodes = list_lru_count_node(&sb->s_inode_lru, sc->nid);
- dentries = list_lru_count_node(&sb->s_dentry_lru, sc->nid);
- total_objects = dentries + inodes + fs_objects + 1;
-+ if (!total_objects)
-+ total_objects = 1;
-
- /* proportion the scan between the caches */
- dentries = mult_frac(sc->nr_to_scan, dentries, total_objects);
-diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
-index ff8229340cd5..26b69b2d4a45 100644
---- a/fs/ubifs/commit.c
-+++ b/fs/ubifs/commit.c
-@@ -166,15 +166,10 @@ static int do_commit(struct ubifs_info *c)
- err = ubifs_orphan_end_commit(c);
- if (err)
- goto out;
-- old_ltail_lnum = c->ltail_lnum;
-- err = ubifs_log_end_commit(c, new_ltail_lnum);
-- if (err)
-- goto out;
- err = dbg_check_old_index(c, &zroot);
- if (err)
- goto out;
-
-- mutex_lock(&c->mst_mutex);
- c->mst_node->cmt_no = cpu_to_le64(c->cmt_no);
- c->mst_node->log_lnum = cpu_to_le32(new_ltail_lnum);
- c->mst_node->root_lnum = cpu_to_le32(zroot.lnum);
-@@ -203,8 +198,9 @@ static int do_commit(struct ubifs_info *c)
- c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS);
- else
- c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_NO_ORPHS);
-- err = ubifs_write_master(c);
-- mutex_unlock(&c->mst_mutex);
-+
-+ old_ltail_lnum = c->ltail_lnum;
-+ err = ubifs_log_end_commit(c, new_ltail_lnum);
- if (err)
- goto out;
-
-diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
-index a902c5919e42..8d59de86dc9a 100644
---- a/fs/ubifs/log.c
-+++ b/fs/ubifs/log.c
-@@ -106,10 +106,14 @@ static inline long long empty_log_bytes(const struct ubifs_info *c)
- h = (long long)c->lhead_lnum * c->leb_size + c->lhead_offs;
- t = (long long)c->ltail_lnum * c->leb_size;
-
-- if (h >= t)
-+ if (h > t)
- return c->log_bytes - h + t;
-- else
-+ else if (h != t)
- return t - h;
-+ else if (c->lhead_lnum != c->ltail_lnum)
-+ return 0;
-+ else
-+ return c->log_bytes;
- }
-
- /**
-@@ -447,9 +451,9 @@ out:
- * @ltail_lnum: new log tail LEB number
- *
- * This function is called on when the commit operation was finished. It
-- * moves log tail to new position and unmaps LEBs which contain obsolete data.
-- * Returns zero in case of success and a negative error code in case of
-- * failure.
-+ * moves log tail to new position and updates the master node so that it stores
-+ * the new log tail LEB number. Returns zero in case of success and a negative
-+ * error code in case of failure.
- */
- int ubifs_log_end_commit(struct ubifs_info *c, int ltail_lnum)
- {
-@@ -477,7 +481,12 @@ int ubifs_log_end_commit(struct ubifs_info *c, int ltail_lnum)
- spin_unlock(&c->buds_lock);
-
- err = dbg_check_bud_bytes(c);
-+ if (err)
-+ goto out;
-
-+ err = ubifs_write_master(c);
-+
-+out:
- mutex_unlock(&c->log_mutex);
- return err;
- }
-diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c
-index ab83ace9910a..1a4bb9e8b3b8 100644
---- a/fs/ubifs/master.c
-+++ b/fs/ubifs/master.c
-@@ -352,10 +352,9 @@ int ubifs_read_master(struct ubifs_info *c)
- * ubifs_write_master - write master node.
- * @c: UBIFS file-system description object
- *
-- * This function writes the master node. The caller has to take the
-- * @c->mst_mutex lock before calling this function. Returns zero in case of
-- * success and a negative error code in case of failure. The master node is
-- * written twice to enable recovery.
-+ * This function writes the master node. Returns zero in case of success and a
-+ * negative error code in case of failure. The master node is written twice to
-+ * enable recovery.
- */
- int ubifs_write_master(struct ubifs_info *c)
- {
-diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
-index 5ded8490c0c6..94d9a64287b7 100644
---- a/fs/ubifs/super.c
-+++ b/fs/ubifs/super.c
-@@ -1957,7 +1957,6 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
- mutex_init(&c->lp_mutex);
- mutex_init(&c->tnc_mutex);
- mutex_init(&c->log_mutex);
-- mutex_init(&c->mst_mutex);
- mutex_init(&c->umount_mutex);
- mutex_init(&c->bu_mutex);
- mutex_init(&c->write_reserve_mutex);
-diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
-index e8c8cfe1435c..7ab9c710c749 100644
---- a/fs/ubifs/ubifs.h
-+++ b/fs/ubifs/ubifs.h
-@@ -1042,7 +1042,6 @@ struct ubifs_debug_info;
- *
- * @mst_node: master node
- * @mst_offs: offset of valid master node
-- * @mst_mutex: protects the master node area, @mst_node, and @mst_offs
- *
- * @max_bu_buf_len: maximum bulk-read buffer length
- * @bu_mutex: protects the pre-allocated bulk-read buffer and @c->bu
-@@ -1282,7 +1281,6 @@ struct ubifs_info {
-
- struct ubifs_mst_node *mst_node;
- int mst_offs;
-- struct mutex mst_mutex;
-
- int max_bu_buf_len;
- struct mutex bu_mutex;
-diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
-index c6ff3cf5a5bb..0eaaa2d296f0 100644
---- a/fs/xfs/xfs_mount.c
-+++ b/fs/xfs/xfs_mount.c
-@@ -321,7 +321,6 @@ reread:
- * Initialize the mount structure from the superblock.
- */
- xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
-- xfs_sb_quota_from_disk(sbp);
-
- /*
- * If we haven't validated the superblock, do so now before we try
-diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
-index 1e116794bb66..4afd393846d3 100644
---- a/fs/xfs/xfs_sb.c
-+++ b/fs/xfs/xfs_sb.c
-@@ -397,10 +397,11 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)
- }
- }
-
--void
--xfs_sb_from_disk(
-+static void
-+__xfs_sb_from_disk(
- struct xfs_sb *to,
-- xfs_dsb_t *from)
-+ xfs_dsb_t *from,
-+ bool convert_xquota)
- {
- to->sb_magicnum = be32_to_cpu(from->sb_magicnum);
- to->sb_blocksize = be32_to_cpu(from->sb_blocksize);
-@@ -456,6 +457,17 @@ xfs_sb_from_disk(
- to->sb_pad = 0;
- to->sb_pquotino = be64_to_cpu(from->sb_pquotino);
- to->sb_lsn = be64_to_cpu(from->sb_lsn);
-+ /* Convert on-disk flags to in-memory flags? */
-+ if (convert_xquota)
-+ xfs_sb_quota_from_disk(to);
-+}
-+
-+void
-+xfs_sb_from_disk(
-+ struct xfs_sb *to,
-+ xfs_dsb_t *from)
-+{
-+ __xfs_sb_from_disk(to, from, true);
- }
-
- static inline void
-@@ -571,7 +583,11 @@ xfs_sb_verify(
- struct xfs_mount *mp = bp->b_target->bt_mount;
- struct xfs_sb sb;
-
-- xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp));
-+ /*
-+ * Use call variant which doesn't convert quota flags from disk
-+ * format, because xfs_mount_validate_sb checks the on-disk flags.
-+ */
-+ __xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp), false);
-
- /*
- * Only check the in progress field for the primary superblock as
-diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
-index bcec4c46cc2e..ca52de5a5c97 100644
---- a/include/drm/drm_pciids.h
-+++ b/include/drm/drm_pciids.h
-@@ -74,7 +74,6 @@
- {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
- {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
- {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
-- {0x1002, 0x4C6E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \
- {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
- {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
- {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
-diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
-index 4afa4f8f6090..a693c6d29328 100644
---- a/include/linux/blkdev.h
-+++ b/include/linux/blkdev.h
-@@ -1232,10 +1232,9 @@ static inline int queue_alignment_offset(struct request_queue *q)
- static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
- {
- unsigned int granularity = max(lim->physical_block_size, lim->io_min);
-- unsigned int alignment = (sector << 9) & (granularity - 1);
-+ unsigned int alignment = sector_div(sector, granularity >> 9) << 9;
-
-- return (granularity + lim->alignment_offset - alignment)
-- & (granularity - 1);
-+ return (granularity + lim->alignment_offset - alignment) % granularity;
- }
-
- static inline int bdev_alignment_offset(struct block_device *bdev)
-diff --git a/include/linux/hid.h b/include/linux/hid.h
-index 31b9d299ef6c..00c88fccd162 100644
---- a/include/linux/hid.h
-+++ b/include/linux/hid.h
-@@ -286,6 +286,7 @@ struct hid_item {
- #define HID_QUIRK_HIDINPUT_FORCE 0x00000080
- #define HID_QUIRK_NO_EMPTY_INPUT 0x00000100
- #define HID_QUIRK_NO_INIT_INPUT_REPORTS 0x00000200
-+#define HID_QUIRK_ALWAYS_POLL 0x00000400
- #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000
- #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000
- #define HID_QUIRK_NO_INIT_REPORTS 0x20000000
-diff --git a/include/linux/mm.h b/include/linux/mm.h
-index c1b7414c7bef..0a0b024ec7e8 100644
---- a/include/linux/mm.h
-+++ b/include/linux/mm.h
-@@ -1123,6 +1123,7 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping,
-
- extern void truncate_pagecache(struct inode *inode, loff_t new);
- extern void truncate_setsize(struct inode *inode, loff_t newsize);
-+void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to);
- void truncate_pagecache_range(struct inode *inode, loff_t offset, loff_t end);
- int truncate_inode_page(struct address_space *mapping, struct page *page);
- int generic_error_remove_page(struct address_space *mapping, struct page *page);
-diff --git a/include/linux/of.h b/include/linux/of.h
-index 435cb995904d..3f8144dadaef 100644
---- a/include/linux/of.h
-+++ b/include/linux/of.h
-@@ -215,14 +215,12 @@ extern int of_property_read_u64(const struct device_node *np,
- extern int of_property_read_string(struct device_node *np,
- const char *propname,
- const char **out_string);
--extern int of_property_read_string_index(struct device_node *np,
-- const char *propname,
-- int index, const char **output);
- extern int of_property_match_string(struct device_node *np,
- const char *propname,
- const char *string);
--extern int of_property_count_strings(struct device_node *np,
-- const char *propname);
-+extern int of_property_read_string_helper(struct device_node *np,
-+ const char *propname,
-+ const char **out_strs, size_t sz, int index);
- extern int of_device_is_compatible(const struct device_node *device,
- const char *);
- extern int of_device_is_available(const struct device_node *device);
-@@ -422,15 +420,9 @@ static inline int of_property_read_string(struct device_node *np,
- return -ENOSYS;
- }
-
--static inline int of_property_read_string_index(struct device_node *np,
-- const char *propname, int index,
-- const char **out_string)
--{
-- return -ENOSYS;
--}
--
--static inline int of_property_count_strings(struct device_node *np,
-- const char *propname)
-+static inline int of_property_read_string_helper(struct device_node *np,
-+ const char *propname,
-+ const char **out_strs, size_t sz, int index)
- {
- return -ENOSYS;
- }
-@@ -536,6 +528,70 @@ static inline struct device_node *of_find_matching_node(
- }
-
- /**
-+ * of_property_read_string_array() - Read an array of strings from a multiple
-+ * strings property.
-+ * @np: device node from which the property value is to be read.
-+ * @propname: name of the property to be searched.
-+ * @out_strs: output array of string pointers.
-+ * @sz: number of array elements to read.
-+ *
-+ * Search for a property in a device tree node and retrieve a list of
-+ * terminated string values (pointer to data, not a copy) in that property.
-+ *
-+ * If @out_strs is NULL, the number of strings in the property is returned.
-+ */
-+static inline int of_property_read_string_array(struct device_node *np,
-+ const char *propname, const char **out_strs,
-+ size_t sz)
-+{
-+ return of_property_read_string_helper(np, propname, out_strs, sz, 0);
-+}
-+
-+/**
-+ * of_property_count_strings() - Find and return the number of strings from a
-+ * multiple strings property.
-+ * @np: device node from which the property value is to be read.
-+ * @propname: name of the property to be searched.
-+ *
-+ * Search for a property in a device tree node and retrieve the number of null
-+ * terminated string contain in it. Returns the number of strings on
-+ * success, -EINVAL if the property does not exist, -ENODATA if property
-+ * does not have a value, and -EILSEQ if the string is not null-terminated
-+ * within the length of the property data.
-+ */
-+static inline int of_property_count_strings(struct device_node *np,
-+ const char *propname)
-+{
-+ return of_property_read_string_helper(np, propname, NULL, 0, 0);
-+}
-+
-+/**
-+ * of_property_read_string_index() - Find and read a string from a multiple
-+ * strings property.
-+ * @np: device node from which the property value is to be read.
-+ * @propname: name of the property to be searched.
-+ * @index: index of the string in the list of strings
-+ * @out_string: pointer to null terminated return string, modified only if
-+ * return value is 0.
-+ *
-+ * Search for a property in a device tree node and retrieve a null
-+ * terminated string value (pointer to data, not a copy) in the list of strings
-+ * contained in that property.
-+ * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if
-+ * property does not have a value, and -EILSEQ if the string is not
-+ * null-terminated within the length of the property data.
-+ *
-+ * The out_string pointer is modified only if a valid string can be decoded.
-+ */
-+static inline int of_property_read_string_index(struct device_node *np,
-+ const char *propname,
-+ int index, const char **output)
-+{
-+ int rc = of_property_read_string_helper(np, propname, output, 1, index);
-+ return rc < 0 ? rc : 0;
-+}
-+
-+/**
- * of_property_read_bool - Findfrom a property
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
-diff --git a/include/linux/oom.h b/include/linux/oom.h
-index 4cd62677feb9..17f0949bd822 100644
---- a/include/linux/oom.h
-+++ b/include/linux/oom.h
-@@ -50,6 +50,9 @@ static inline bool oom_task_origin(const struct task_struct *p)
- extern unsigned long oom_badness(struct task_struct *p,
- struct mem_cgroup *memcg, const nodemask_t *nodemask,
- unsigned long totalpages);
-+
-+extern int oom_kills_count(void);
-+extern void note_oom_kill(void);
- extern void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
- unsigned int points, unsigned long totalpages,
- struct mem_cgroup *memcg, nodemask_t *nodemask,
-diff --git a/include/linux/string.h b/include/linux/string.h
-index ac889c5ea11b..0ed878d0465c 100644
---- a/include/linux/string.h
-+++ b/include/linux/string.h
-@@ -129,7 +129,7 @@ int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4);
- #endif
-
- extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
-- const void *from, size_t available);
-+ const void *from, size_t available);
-
- /**
- * strstarts - does @str start with @prefix?
-@@ -141,7 +141,8 @@ static inline bool strstarts(const char *str, const char *prefix)
- return strncmp(str, prefix, strlen(prefix)) == 0;
- }
-
--extern size_t memweight(const void *ptr, size_t bytes);
-+size_t memweight(const void *ptr, size_t bytes);
-+void memzero_explicit(void *s, size_t count);
-
- /**
- * kbasename - return the last part of a pathname.
-diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
-index 8097b9df6773..51009d280ac7 100644
---- a/include/linux/sunrpc/xprt.h
-+++ b/include/linux/sunrpc/xprt.h
-@@ -340,6 +340,7 @@ int xs_swapper(struct rpc_xprt *xprt, int enable);
- #define XPRT_CONNECTION_ABORT (7)
- #define XPRT_CONNECTION_CLOSE (8)
- #define XPRT_CONGESTED (9)
-+#define XPRT_CONNECTION_REUSE (10)
-
- static inline void xprt_set_connected(struct rpc_xprt *xprt)
- {
-diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
-index 49587dc22f5d..8b96ae2a38fe 100644
---- a/include/linux/usb/quirks.h
-+++ b/include/linux/usb/quirks.h
-@@ -33,4 +33,7 @@
- /* device generates spurious wakeup, ignore remote wakeup capability */
- #define USB_QUIRK_IGNORE_REMOTE_WAKEUP 0x00000200
-
-+/* device can't handle device_qualifier descriptor requests */
-+#define USB_QUIRK_DEVICE_QUALIFIER 0x00000100
-+
- #endif /* __LINUX_USB_QUIRKS_H */
-diff --git a/include/net/ipv6.h b/include/net/ipv6.h
-index 9ac65781d44b..a60948d7bcea 100644
---- a/include/net/ipv6.h
-+++ b/include/net/ipv6.h
-@@ -660,6 +660,8 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
- return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
- }
-
-+void ipv6_proxy_select_ident(struct sk_buff *skb);
-+
- int ip6_dst_hoplimit(struct dst_entry *dst);
-
- /*
-diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
-index 87792a5fee3b..33b739522840 100644
---- a/include/uapi/drm/vmwgfx_drm.h
-+++ b/include/uapi/drm/vmwgfx_drm.h
-@@ -29,7 +29,7 @@
- #define __VMWGFX_DRM_H__
-
- #ifndef __KERNEL__
--#include
-+#include
- #endif
-
- #define DRM_VMW_MAX_SURFACE_FACES 6
-diff --git a/kernel/freezer.c b/kernel/freezer.c
-index aa6a8aadb911..8f9279b9c6d7 100644
---- a/kernel/freezer.c
-+++ b/kernel/freezer.c
-@@ -42,6 +42,9 @@ bool freezing_slow_path(struct task_struct *p)
- if (p->flags & (PF_NOFREEZE | PF_SUSPEND_TASK))
- return false;
-
-+ if (test_thread_flag(TIF_MEMDIE))
-+ return false;
-+
- if (pm_nosig_freezing || cgroup_freezing(p))
- return true;
-
-diff --git a/kernel/module.c b/kernel/module.c
-index 6716a1fa618b..1d679a6c942f 100644
---- a/kernel/module.c
-+++ b/kernel/module.c
-@@ -1841,7 +1841,9 @@ static void free_module(struct module *mod)
-
- /* We leave it in list to prevent duplicate loads, but make sure
- * that noone uses it while it's being deconstructed. */
-+ mutex_lock(&module_mutex);
- mod->state = MODULE_STATE_UNFORMED;
-+ mutex_unlock(&module_mutex);
-
- /* Remove dynamic debug info */
- ddebug_remove_module(mod->name);
-diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
-index 424c2d4265c9..77e6b83c0431 100644
---- a/kernel/posix-timers.c
-+++ b/kernel/posix-timers.c
-@@ -634,6 +634,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
- goto out;
- }
- } else {
-+ memset(&event.sigev_value, 0, sizeof(event.sigev_value));
- event.sigev_notify = SIGEV_SIGNAL;
- event.sigev_signo = SIGALRM;
- event.sigev_value.sival_int = new_timer->it_id;
-diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
-index 37170d4dd9a6..126586a31408 100644
---- a/kernel/power/hibernate.c
-+++ b/kernel/power/hibernate.c
-@@ -492,8 +492,14 @@ int hibernation_restore(int platform_mode)
- error = dpm_suspend_start(PMSG_QUIESCE);
- if (!error) {
- error = resume_target_kernel(platform_mode);
-- dpm_resume_end(PMSG_RECOVER);
-+ /*
-+ * The above should either succeed and jump to the new kernel,
-+ * or return with an error. Otherwise things are just
-+ * undefined, so let's be paranoid.
-+ */
-+ BUG_ON(!error);
- }
-+ dpm_resume_end(PMSG_RECOVER);
- pm_restore_gfp_mask();
- ftrace_start();
- resume_console();
-diff --git a/kernel/power/process.c b/kernel/power/process.c
-index 14f9a8d4725d..f1fe7ec110bb 100644
---- a/kernel/power/process.c
-+++ b/kernel/power/process.c
-@@ -107,6 +107,28 @@ static int try_to_freeze_tasks(bool user_only)
- return todo ? -EBUSY : 0;
- }
-
-+/*
-+ * Returns true if all freezable tasks (except for current) are frozen already
-+ */
-+static bool check_frozen_processes(void)
-+{
-+ struct task_struct *g, *p;
-+ bool ret = true;
-+
-+ read_lock(&tasklist_lock);
-+ for_each_process_thread(g, p) {
-+ if (p != current && !freezer_should_skip(p) &&
-+ !frozen(p)) {
-+ ret = false;
-+ goto done;
-+ }
-+ }
-+done:
-+ read_unlock(&tasklist_lock);
-+
-+ return ret;
-+}
-+
- /**
- * freeze_processes - Signal user space processes to enter the refrigerator.
- * The current thread will not be frozen. The same process that calls
-@@ -117,6 +139,7 @@ static int try_to_freeze_tasks(bool user_only)
- int freeze_processes(void)
- {
- int error;
-+ int oom_kills_saved;
-
- error = __usermodehelper_disable(UMH_FREEZING);
- if (error)
-@@ -130,12 +153,27 @@ int freeze_processes(void)
-
- printk("Freezing user space processes ... ");
- pm_freezing = true;
-+ oom_kills_saved = oom_kills_count();
- error = try_to_freeze_tasks(true);
- if (!error) {
-- printk("done.");
- __usermodehelper_set_disable_depth(UMH_DISABLED);
- oom_killer_disable();
-+
-+ /*
-+ * There might have been an OOM kill while we were
-+ * freezing tasks and the killed task might be still
-+ * on the way out so we have to double check for race.
-+ */
-+ if (oom_kills_count() != oom_kills_saved &&
-+ !check_frozen_processes()) {
-+ __usermodehelper_set_disable_depth(UMH_ENABLED);
-+ printk("OOM in progress.");
-+ error = -EBUSY;
-+ goto done;
-+ }
-+ printk("done.");
- }
-+done:
- printk("\n");
- BUG_ON(in_atomic());
-
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 677ebad70ce1..9a3f3c4e1f5a 100644
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -1895,6 +1895,8 @@ unsigned long to_ratio(u64 period, u64 runtime)
- #ifdef CONFIG_SMP
- inline struct dl_bw *dl_bw_of(int i)
- {
-+ rcu_lockdep_assert(rcu_read_lock_sched_held(),
-+ "sched RCU must be held");
- return &cpu_rq(i)->rd->dl_bw;
- }
-
-@@ -1903,6 +1905,8 @@ static inline int dl_bw_cpus(int i)
- struct root_domain *rd = cpu_rq(i)->rd;
- int cpus = 0;
-
-+ rcu_lockdep_assert(rcu_read_lock_sched_held(),
-+ "sched RCU must be held");
- for_each_cpu_and(i, rd->span, cpu_active_mask)
- cpus++;
-
-@@ -3937,13 +3941,14 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
- * root_domain.
- */
- #ifdef CONFIG_SMP
-- if (task_has_dl_policy(p)) {
-- const struct cpumask *span = task_rq(p)->rd->span;
--
-- if (dl_bandwidth_enabled() && !cpumask_subset(span, new_mask)) {
-+ if (task_has_dl_policy(p) && dl_bandwidth_enabled()) {
-+ rcu_read_lock();
-+ if (!cpumask_subset(task_rq(p)->rd->span, new_mask)) {
- retval = -EBUSY;
-+ rcu_read_unlock();
- goto out_unlock;
- }
-+ rcu_read_unlock();
- }
- #endif
- again:
-@@ -7458,6 +7463,8 @@ static int sched_dl_global_constraints(void)
- int cpu, ret = 0;
- unsigned long flags;
-
-+ rcu_read_lock();
-+
- /*
- * Here we want to check the bandwidth not being set to some
- * value smaller than the currently allocated bandwidth in
-@@ -7479,6 +7486,8 @@ static int sched_dl_global_constraints(void)
- break;
- }
-
-+ rcu_read_unlock();
-+
- return ret;
- }
-
-@@ -7494,6 +7503,7 @@ static void sched_dl_do_global(void)
- if (global_rt_runtime() != RUNTIME_INF)
- new_bw = to_ratio(global_rt_period(), global_rt_runtime());
-
-+ rcu_read_lock();
- /*
- * FIXME: As above...
- */
-@@ -7504,6 +7514,7 @@ static void sched_dl_do_global(void)
- dl_b->bw = new_bw;
- raw_spin_unlock_irqrestore(&dl_b->lock, flags);
- }
-+ rcu_read_unlock();
- }
-
- static int sched_rt_global_validate(void)
-diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
-index 759d5e004517..7e3cd7aaec83 100644
---- a/kernel/trace/trace_syscalls.c
-+++ b/kernel/trace/trace_syscalls.c
-@@ -313,7 +313,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
- int size;
-
- syscall_nr = trace_get_syscall_nr(current, regs);
-- if (syscall_nr < 0)
-+ if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
- return;
-
- /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */
-@@ -360,7 +360,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
- int syscall_nr;
-
- syscall_nr = trace_get_syscall_nr(current, regs);
-- if (syscall_nr < 0)
-+ if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
- return;
-
- /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */
-@@ -567,7 +567,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
- int size;
-
- syscall_nr = trace_get_syscall_nr(current, regs);
-- if (syscall_nr < 0)
-+ if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
- return;
- if (!test_bit(syscall_nr, enabled_perf_enter_syscalls))
- return;
-@@ -641,7 +641,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
- int size;
-
- syscall_nr = trace_get_syscall_nr(current, regs);
-- if (syscall_nr < 0)
-+ if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
- return;
- if (!test_bit(syscall_nr, enabled_perf_exit_syscalls))
- return;
-diff --git a/lib/bitmap.c b/lib/bitmap.c
-index 06f7e4fe8d2d..e5c4ebe586ba 100644
---- a/lib/bitmap.c
-+++ b/lib/bitmap.c
-@@ -131,7 +131,9 @@ void __bitmap_shift_right(unsigned long *dst,
- lower = src[off + k];
- if (left && off + k == lim - 1)
- lower &= mask;
-- dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem;
-+ dst[k] = lower >> rem;
-+ if (rem)
-+ dst[k] |= upper << (BITS_PER_LONG - rem);
- if (left && k == lim - 1)
- dst[k] &= mask;
- }
-@@ -172,7 +174,9 @@ void __bitmap_shift_left(unsigned long *dst,
- upper = src[k];
- if (left && k == lim - 1)
- upper &= (1UL << left) - 1;
-- dst[k + off] = lower >> (BITS_PER_LONG - rem) | upper << rem;
-+ dst[k + off] = upper << rem;
-+ if (rem)
-+ dst[k + off] |= lower >> (BITS_PER_LONG - rem);
- if (left && k + off == lim - 1)
- dst[k + off] &= (1UL << left) - 1;
- }
-diff --git a/lib/string.c b/lib/string.c
-index e5878de4f101..43d0781daf47 100644
---- a/lib/string.c
-+++ b/lib/string.c
-@@ -586,6 +586,22 @@ void *memset(void *s, int c, size_t count)
- EXPORT_SYMBOL(memset);
- #endif
-
-+/**
-+ * memzero_explicit - Fill a region of memory (e.g. sensitive
-+ * keying data) with 0s.
-+ * @s: Pointer to the start of the area.
-+ * @count: The size of the area.
-+ *
-+ * memzero_explicit() doesn't need an arch-specific version as
-+ * it just invokes the one of memset() implicitly.
-+ */
-+void memzero_explicit(void *s, size_t count)
-+{
-+ memset(s, 0, count);
-+ OPTIMIZER_HIDE_VAR(s);
-+}
-+EXPORT_SYMBOL(memzero_explicit);
-+
- #ifndef __HAVE_ARCH_MEMCPY
- /**
- * memcpy - Copy one area of memory to another
-diff --git a/mm/huge_memory.c b/mm/huge_memory.c
-index 718bfa16a36f..331faa5c0d5e 100644
---- a/mm/huge_memory.c
-+++ b/mm/huge_memory.c
-@@ -199,7 +199,7 @@ retry:
- preempt_disable();
- if (cmpxchg(&huge_zero_page, NULL, zero_page)) {
- preempt_enable();
-- __free_page(zero_page);
-+ __free_pages(zero_page, compound_order(zero_page));
- goto retry;
- }
-
-@@ -231,7 +231,7 @@ static unsigned long shrink_huge_zero_page_scan(struct shrinker *shrink,
- if (atomic_cmpxchg(&huge_zero_refcount, 1, 0) == 1) {
- struct page *zero_page = xchg(&huge_zero_page, NULL);
- BUG_ON(zero_page == NULL);
-- __free_page(zero_page);
-+ __free_pages(zero_page, compound_order(zero_page));
- return HPAGE_PMD_NR;
- }
-
-diff --git a/mm/memcontrol.c b/mm/memcontrol.c
-index 9b35da28b587..b58d4fbe6c48 100644
---- a/mm/memcontrol.c
-+++ b/mm/memcontrol.c
-@@ -292,6 +292,9 @@ struct mem_cgroup {
- /* vmpressure notifications */
- struct vmpressure vmpressure;
-
-+ /* css_online() has been completed */
-+ int initialized;
-+
- /*
- * the counter to account for mem+swap usage.
- */
-@@ -1127,9 +1130,21 @@ skip_node:
- * skipping css reference should be safe.
- */
- if (next_css) {
-- if ((next_css == &root->css) ||
-- ((next_css->flags & CSS_ONLINE) && css_tryget(next_css)))
-- return mem_cgroup_from_css(next_css);
-+ struct mem_cgroup *memcg = mem_cgroup_from_css(next_css);
-+
-+ if (next_css == &root->css)
-+ return memcg;
-+
-+ if (css_tryget(next_css)) {
-+ /*
-+ * Make sure the memcg is initialized:
-+ * mem_cgroup_css_online() orders the the
-+ * initialization against setting the flag.
-+ */
-+ if (smp_load_acquire(&memcg->initialized))
-+ return memcg;
-+ css_put(next_css);
-+ }
-
- prev_css = next_css;
- goto skip_node;
-@@ -6538,6 +6553,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
- {
- struct mem_cgroup *memcg = mem_cgroup_from_css(css);
- struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css));
-+ int ret;
-
- if (css->cgroup->id > MEM_CGROUP_ID_MAX)
- return -ENOSPC;
-@@ -6574,7 +6590,18 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
- }
- mutex_unlock(&memcg_create_mutex);
-
-- return memcg_init_kmem(memcg, &mem_cgroup_subsys);
-+ ret = memcg_init_kmem(memcg, &mem_cgroup_subsys);
-+ if (ret)
-+ return ret;
-+
-+ /*
-+ * Make sure the memcg is initialized: mem_cgroup_iter()
-+ * orders reading memcg->initialized against its callers
-+ * reading the memcg members.
-+ */
-+ smp_store_release(&memcg->initialized, 1);
-+
-+ return 0;
- }
-
- /*
-diff --git a/mm/oom_kill.c b/mm/oom_kill.c
-index 3291e82d4352..171c00f2e495 100644
---- a/mm/oom_kill.c
-+++ b/mm/oom_kill.c
-@@ -406,6 +406,23 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order,
- dump_tasks(memcg, nodemask);
- }
-
-+/*
-+ * Number of OOM killer invocations (including memcg OOM killer).
-+ * Primarily used by PM freezer to check for potential races with
-+ * OOM killed frozen task.
-+ */
-+static atomic_t oom_kills = ATOMIC_INIT(0);
-+
-+int oom_kills_count(void)
-+{
-+ return atomic_read(&oom_kills);
-+}
-+
-+void note_oom_kill(void)
-+{
-+ atomic_inc(&oom_kills);
-+}
-+
- #define K(x) ((x) << (PAGE_SHIFT-10))
- /*
- * Must be called while holding a reference to p, which will be released upon
-diff --git a/mm/page_alloc.c b/mm/page_alloc.c
-index ff0f6b13f32f..7b2611a055a7 100644
---- a/mm/page_alloc.c
-+++ b/mm/page_alloc.c
-@@ -1957,7 +1957,7 @@ zonelist_scan:
- if (alloc_flags & ALLOC_FAIR) {
- if (!zone_local(preferred_zone, zone))
- continue;
-- if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0)
-+ if (atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0)
- continue;
- }
- /*
-@@ -2196,6 +2196,14 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
- }
-
- /*
-+ * PM-freezer should be notified that there might be an OOM killer on
-+ * its way to kill and wake somebody up. This is too early and we might
-+ * end up not killing anything but false positives are acceptable.
-+ * See freeze_processes.
-+ */
-+ note_oom_kill();
-+
-+ /*
- * Go through the zonelist yet one more time, keep very high watermark
- * here, this is only to catch a parallel oom killing, we must fail if
- * we're still under heavy pressure.
-@@ -5662,9 +5670,8 @@ static void __setup_per_zone_wmarks(void)
- zone->watermark[WMARK_HIGH] = min_wmark_pages(zone) + (tmp >> 1);
-
- __mod_zone_page_state(zone, NR_ALLOC_BATCH,
-- high_wmark_pages(zone) -
-- low_wmark_pages(zone) -
-- zone_page_state(zone, NR_ALLOC_BATCH));
-+ high_wmark_pages(zone) - low_wmark_pages(zone) -
-+ atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]));
-
- setup_zone_migrate_reserve(zone);
- spin_unlock_irqrestore(&zone->lock, flags);
-diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
-index cfd162882c00..0e9a319d5f8d 100644
---- a/mm/page_cgroup.c
-+++ b/mm/page_cgroup.c
-@@ -171,6 +171,7 @@ static void free_page_cgroup(void *addr)
- sizeof(struct page_cgroup) * PAGES_PER_SECTION;
-
- BUG_ON(PageReserved(page));
-+ kmemleak_free(addr);
- free_pages_exact(addr, table_size);
- }
- }
-diff --git a/mm/percpu.c b/mm/percpu.c
-index 8cd4308471c3..a2a54a85f691 100644
---- a/mm/percpu.c
-+++ b/mm/percpu.c
-@@ -1917,8 +1917,6 @@ void __init setup_per_cpu_areas(void)
-
- if (pcpu_setup_first_chunk(ai, fc) < 0)
- panic("Failed to initialize percpu areas.");
--
-- pcpu_free_alloc_info(ai);
- }
-
- #endif /* CONFIG_SMP */
-diff --git a/mm/truncate.c b/mm/truncate.c
-index 353b683afd6e..ac18edc30649 100644
---- a/mm/truncate.c
-+++ b/mm/truncate.c
-@@ -20,6 +20,7 @@
- #include /* grr. try_to_release_page,
- do_invalidatepage */
- #include
-+#include
- #include "internal.h"
-
-
-@@ -613,12 +614,67 @@ EXPORT_SYMBOL(truncate_pagecache);
- */
- void truncate_setsize(struct inode *inode, loff_t newsize)
- {
-+ loff_t oldsize = inode->i_size;
-+
- i_size_write(inode, newsize);
-+ if (newsize > oldsize)
-+ pagecache_isize_extended(inode, oldsize, newsize);
- truncate_pagecache(inode, newsize);
- }
- EXPORT_SYMBOL(truncate_setsize);
-
- /**
-+ * pagecache_isize_extended - update pagecache after extension of i_size
-+ * @inode: inode for which i_size was extended
-+ * @from: original inode size
-+ * @to: new inode size
-+ *
-+ * Handle extension of inode size either caused by extending truncate or by
-+ * write starting after current i_size. We mark the page straddling current
-+ * i_size RO so that page_mkwrite() is called on the nearest write access to
-+ * the page. This way filesystem can be sure that page_mkwrite() is called on
-+ * the page before user writes to the page via mmap after the i_size has been
-+ * changed.
-+ *
-+ * The function must be called after i_size is updated so that page fault
-+ * coming after we unlock the page will already see the new i_size.
-+ * The function must be called while we still hold i_mutex - this not only
-+ * makes sure i_size is stable but also that userspace cannot observe new
-+ * i_size value before we are prepared to store mmap writes at new inode size.
-+ */
-+void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to)
-+{
-+ int bsize = 1 << inode->i_blkbits;
-+ loff_t rounded_from;
-+ struct page *page;
-+ pgoff_t index;
-+
-+ WARN_ON(to > inode->i_size);
-+
-+ if (from >= to || bsize == PAGE_CACHE_SIZE)
-+ return;
-+ /* Page straddling @from will not have any hole block created? */
-+ rounded_from = round_up(from, bsize);
-+ if (to <= rounded_from || !(rounded_from & (PAGE_CACHE_SIZE - 1)))
-+ return;
-+
-+ index = from >> PAGE_CACHE_SHIFT;
-+ page = find_lock_page(inode->i_mapping, index);
-+ /* Page not cached? Nothing to do */
-+ if (!page)
-+ return;
-+ /*
-+ * See clear_page_dirty_for_io() for details why set_page_dirty()
-+ * is needed.
-+ */
-+ if (page_mkclean(page))
-+ set_page_dirty(page);
-+ unlock_page(page);
-+ page_cache_release(page);
-+}
-+EXPORT_SYMBOL(pagecache_isize_extended);
-+
-+/**
- * truncate_pagecache_range - unmap and remove pagecache that is hole-punched
- * @inode: inode
- * @lstart: offset of beginning of hole
-diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
-index 0a31298737ac..2e87eecec8f6 100644
---- a/net/ceph/messenger.c
-+++ b/net/ceph/messenger.c
-@@ -291,7 +291,11 @@ int ceph_msgr_init(void)
- if (ceph_msgr_slab_init())
- return -ENOMEM;
-
-- ceph_msgr_wq = alloc_workqueue("ceph-msgr", 0, 0);
-+ /*
-+ * The number of active work items is limited by the number of
-+ * connections, so leave @max_active at default.
-+ */
-+ ceph_msgr_wq = alloc_workqueue("ceph-msgr", WQ_MEM_RECLAIM, 0);
- if (ceph_msgr_wq)
- return 0;
-
-diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
-index 9d43468722ed..017fa5e17594 100644
---- a/net/ipv4/fib_semantics.c
-+++ b/net/ipv4/fib_semantics.c
-@@ -535,7 +535,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
- return 1;
-
- attrlen = rtnh_attrlen(rtnh);
-- if (attrlen < 0) {
-+ if (attrlen > 0) {
- struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
-
- nla = nla_find(attrs, attrlen, RTA_GATEWAY);
-diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
-index 2d24f293f977..8c8493ea6b1c 100644
---- a/net/ipv4/gre_offload.c
-+++ b/net/ipv4/gre_offload.c
-@@ -50,7 +50,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
-
- greh = (struct gre_base_hdr *)skb_transport_header(skb);
-
-- ghl = skb_inner_network_header(skb) - skb_transport_header(skb);
-+ ghl = skb_inner_mac_header(skb) - skb_transport_header(skb);
- if (unlikely(ghl < sizeof(*greh)))
- goto out;
-
-diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
-index ed88d781248f..844323b6cfb9 100644
---- a/net/ipv4/ip_output.c
-+++ b/net/ipv4/ip_output.c
-@@ -1487,6 +1487,7 @@ void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr,
- struct sk_buff *nskb;
- struct sock *sk;
- struct inet_sock *inet;
-+ int err;
-
- if (ip_options_echo(&replyopts.opt.opt, skb))
- return;
-@@ -1525,8 +1526,13 @@ void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr,
- sock_net_set(sk, net);
- __skb_queue_head_init(&sk->sk_write_queue);
- sk->sk_sndbuf = sysctl_wmem_default;
-- ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, len, 0,
-- &ipc, &rt, MSG_DONTWAIT);
-+ err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base,
-+ len, 0, &ipc, &rt, MSG_DONTWAIT);
-+ if (unlikely(err)) {
-+ ip_flush_pending_frames(sk);
-+ goto out;
-+ }
-+
- nskb = skb_peek(&sk->sk_write_queue);
- if (nskb) {
- if (arg->csumoffset >= 0)
-@@ -1538,7 +1544,7 @@ void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr,
- skb_set_queue_mapping(nskb, skb_get_queue_mapping(skb));
- ip_push_pending_frames(sk, &fl4);
- }
--
-+out:
- put_cpu_var(unicast_sock);
-
- ip_rt_put(rt);
-diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
-index 65b664d30fa1..791a419f0699 100644
---- a/net/ipv4/ip_tunnel_core.c
-+++ b/net/ipv4/ip_tunnel_core.c
-@@ -91,11 +91,12 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
- skb_pull_rcsum(skb, hdr_len);
-
- if (inner_proto == htons(ETH_P_TEB)) {
-- struct ethhdr *eh = (struct ethhdr *)skb->data;
-+ struct ethhdr *eh;
-
- if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
- return -ENOMEM;
-
-+ eh = (struct ethhdr *)skb->data;
- if (likely(ntohs(eh->h_proto) >= ETH_P_802_3_MIN))
- skb->protocol = eh->h_proto;
- else
-diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
-index f7d71ec72a47..29d240b87af1 100644
---- a/net/ipv4/tcp.c
-+++ b/net/ipv4/tcp.c
-@@ -2954,61 +2954,42 @@ EXPORT_SYMBOL(compat_tcp_getsockopt);
- #endif
-
- #ifdef CONFIG_TCP_MD5SIG
--static struct tcp_md5sig_pool __percpu *tcp_md5sig_pool __read_mostly;
-+static DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool);
- static DEFINE_MUTEX(tcp_md5sig_mutex);
--
--static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool __percpu *pool)
--{
-- int cpu;
--
-- for_each_possible_cpu(cpu) {
-- struct tcp_md5sig_pool *p = per_cpu_ptr(pool, cpu);
--
-- if (p->md5_desc.tfm)
-- crypto_free_hash(p->md5_desc.tfm);
-- }
-- free_percpu(pool);
--}
-+static bool tcp_md5sig_pool_populated = false;
-
- static void __tcp_alloc_md5sig_pool(void)
- {
- int cpu;
-- struct tcp_md5sig_pool __percpu *pool;
--
-- pool = alloc_percpu(struct tcp_md5sig_pool);
-- if (!pool)
-- return;
-
- for_each_possible_cpu(cpu) {
-- struct crypto_hash *hash;
--
-- hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
-- if (IS_ERR_OR_NULL(hash))
-- goto out_free;
-+ if (!per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm) {
-+ struct crypto_hash *hash;
-
-- per_cpu_ptr(pool, cpu)->md5_desc.tfm = hash;
-+ hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
-+ if (IS_ERR_OR_NULL(hash))
-+ return;
-+ per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm = hash;
-+ }
- }
-- /* before setting tcp_md5sig_pool, we must commit all writes
-- * to memory. See ACCESS_ONCE() in tcp_get_md5sig_pool()
-+ /* before setting tcp_md5sig_pool_populated, we must commit all writes
-+ * to memory. See smp_rmb() in tcp_get_md5sig_pool()
- */
- smp_wmb();
-- tcp_md5sig_pool = pool;
-- return;
--out_free:
-- __tcp_free_md5sig_pool(pool);
-+ tcp_md5sig_pool_populated = true;
- }
-
- bool tcp_alloc_md5sig_pool(void)
- {
-- if (unlikely(!tcp_md5sig_pool)) {
-+ if (unlikely(!tcp_md5sig_pool_populated)) {
- mutex_lock(&tcp_md5sig_mutex);
-
-- if (!tcp_md5sig_pool)
-+ if (!tcp_md5sig_pool_populated)
- __tcp_alloc_md5sig_pool();
-
- mutex_unlock(&tcp_md5sig_mutex);
- }
-- return tcp_md5sig_pool != NULL;
-+ return tcp_md5sig_pool_populated;
- }
- EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
-
-@@ -3022,13 +3003,13 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
- */
- struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
- {
-- struct tcp_md5sig_pool __percpu *p;
--
- local_bh_disable();
-- p = ACCESS_ONCE(tcp_md5sig_pool);
-- if (p)
-- return __this_cpu_ptr(p);
-
-+ if (tcp_md5sig_pool_populated) {
-+ /* coupled with smp_wmb() in __tcp_alloc_md5sig_pool() */
-+ smp_rmb();
-+ return this_cpu_ptr(&tcp_md5sig_pool);
-+ }
- local_bh_enable();
- return NULL;
- }
-diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
-index 798eb0f79078..ae4a06be14df 100644
---- a/net/ipv6/output_core.c
-+++ b/net/ipv6/output_core.c
-@@ -3,10 +3,43 @@
- * not configured or static. These functions are needed by GSO/GRO implementation.
- */
- #include
-+#include
- #include
- #include
- #include
-
-+/* This function exists only for tap drivers that must support broken
-+ * clients requesting UFO without specifying an IPv6 fragment ID.
-+ *
-+ * This is similar to ipv6_select_ident() but we use an independent hash
-+ * seed to limit information leakage.
-+ *
-+ * The network header must be set before calling this.
-+ */
-+void ipv6_proxy_select_ident(struct sk_buff *skb)
-+{
-+ static u32 ip6_proxy_idents_hashrnd __read_mostly;
-+ struct in6_addr buf[2];
-+ struct in6_addr *addrs;
-+ u32 hash, id;
-+
-+ addrs = skb_header_pointer(skb,
-+ skb_network_offset(skb) +
-+ offsetof(struct ipv6hdr, saddr),
-+ sizeof(buf), buf);
-+ if (!addrs)
-+ return;
-+
-+ net_get_random_once(&ip6_proxy_idents_hashrnd,
-+ sizeof(ip6_proxy_idents_hashrnd));
-+
-+ hash = __ipv6_addr_jhash(&addrs[1], ip6_proxy_idents_hashrnd);
-+ hash = __ipv6_addr_jhash(&addrs[0], hash);
-+
-+ id = ip_idents_reserve(hash, 1);
-+ skb_shinfo(skb)->ip6_frag_id = htonl(id);
-+}
-+EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);
-
- int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
- {
-diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
-index 22b223f13c9f..74350c3863b8 100644
---- a/net/mac80211/rate.c
-+++ b/net/mac80211/rate.c
-@@ -462,7 +462,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
- */
- if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
- u32 basic_rates = vif->bss_conf.basic_rates;
-- s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
-+ s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
-
- rate = &sband->bitrates[rates[0].idx];
-
-diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
-index c375d731587f..7c177bc43806 100644
---- a/net/netlink/af_netlink.c
-+++ b/net/netlink/af_netlink.c
-@@ -707,7 +707,7 @@ static int netlink_mmap_sendmsg(struct sock *sk, struct msghdr *msg,
- * after validation, the socket and the ring may only be used by a
- * single process, otherwise we fall back to copying.
- */
-- if (atomic_long_read(&sk->sk_socket->file->f_count) > 2 ||
-+ if (atomic_long_read(&sk->sk_socket->file->f_count) > 1 ||
- atomic_read(&nlk->mapped) > 1)
- excl = false;
-
-diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
-index 3ea5cda787c7..5ff8b87c3d04 100644
---- a/net/sunrpc/clnt.c
-+++ b/net/sunrpc/clnt.c
-@@ -533,6 +533,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
-
- if (args->flags & RPC_CLNT_CREATE_AUTOBIND)
- clnt->cl_autobind = 1;
-+ if (args->flags & RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT)
-+ clnt->cl_noretranstimeo = 1;
- if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
- clnt->cl_discrtry = 1;
- if (!(args->flags & RPC_CLNT_CREATE_QUIET))
-@@ -571,6 +573,7 @@ static struct rpc_clnt *__rpc_clone_client(struct rpc_create_args *args,
- /* Turn off autobind on clones */
- new->cl_autobind = 0;
- new->cl_softrtry = clnt->cl_softrtry;
-+ new->cl_noretranstimeo = clnt->cl_noretranstimeo;
- new->cl_discrtry = clnt->cl_discrtry;
- new->cl_chatty = clnt->cl_chatty;
- return new;
-diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
-index 0addefca8e77..41c2f9d7a148 100644
---- a/net/sunrpc/xprtsock.c
-+++ b/net/sunrpc/xprtsock.c
-@@ -842,6 +842,8 @@ static void xs_error_report(struct sock *sk)
- dprintk("RPC: xs_error_report client %p, error=%d...\n",
- xprt, -err);
- trace_rpc_socket_error(xprt, sk->sk_socket, err);
-+ if (test_bit(XPRT_CONNECTION_REUSE, &xprt->state))
-+ goto out;
- xprt_wake_pending_tasks(xprt, err);
- out:
- read_unlock_bh(&sk->sk_callback_lock);
-@@ -2251,7 +2253,9 @@ static void xs_tcp_setup_socket(struct work_struct *work)
- abort_and_exit = test_and_clear_bit(XPRT_CONNECTION_ABORT,
- &xprt->state);
- /* "close" the socket, preserving the local port */
-+ set_bit(XPRT_CONNECTION_REUSE, &xprt->state);
- xs_tcp_reuse_connection(transport);
-+ clear_bit(XPRT_CONNECTION_REUSE, &xprt->state);
-
- if (abort_and_exit)
- goto out_eagain;
-diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
-index 3c5cbb977254..7e71e066198f 100644
---- a/security/integrity/evm/evm_main.c
-+++ b/security/integrity/evm/evm_main.c
-@@ -269,6 +269,13 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name,
- goto out;
- }
- evm_status = evm_verify_current_integrity(dentry);
-+ if (evm_status == INTEGRITY_NOXATTRS) {
-+ struct integrity_iint_cache *iint;
-+
-+ iint = integrity_iint_find(dentry->d_inode);
-+ if (iint && (iint->flags & IMA_NEW_FILE))
-+ return 0;
-+ }
- out:
- if (evm_status != INTEGRITY_PASS)
- integrity_audit_msg(AUDIT_INTEGRITY_METADATA, dentry->d_inode,
-@@ -296,9 +303,12 @@ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
- {
- const struct evm_ima_xattr_data *xattr_data = xattr_value;
-
-- if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0)
-- && (xattr_data->type == EVM_XATTR_HMAC))
-- return -EPERM;
-+ if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) {
-+ if (!xattr_value_len)
-+ return -EINVAL;
-+ if (xattr_data->type != EVM_IMA_XATTR_DIGSIG)
-+ return -EPERM;
-+ }
- return evm_protect_xattr(dentry, xattr_name, xattr_value,
- xattr_value_len);
- }
-diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
-index e294b86c8d88..47b5c69e4605 100644
---- a/security/selinux/hooks.c
-+++ b/security/selinux/hooks.c
-@@ -470,6 +470,7 @@ next_inode:
- list_entry(sbsec->isec_head.next,
- struct inode_security_struct, list);
- struct inode *inode = isec->inode;
-+ list_del_init(&isec->list);
- spin_unlock(&sbsec->isec_lock);
- inode = igrab(inode);
- if (inode) {
-@@ -478,7 +479,6 @@ next_inode:
- iput(inode);
- }
- spin_lock(&sbsec->isec_lock);
-- list_del_init(&isec->list);
- goto next_inode;
- }
- spin_unlock(&sbsec->isec_lock);
-diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
-index af49721ba0e3..c4ac3c1e19af 100644
---- a/sound/core/pcm_compat.c
-+++ b/sound/core/pcm_compat.c
-@@ -206,6 +206,8 @@ static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
- if (err < 0)
- return err;
-
-+ if (clear_user(src, sizeof(*src)))
-+ return -EFAULT;
- if (put_user(status.state, &src->state) ||
- compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
- compat_put_timespec(&status.tstamp, &src->tstamp) ||
-diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
-index 7ec91424ba22..103e85a13f35 100644
---- a/sound/pci/hda/hda_intel.c
-+++ b/sound/pci/hda/hda_intel.c
-@@ -4027,6 +4027,9 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
- /* BayTrail */
- { PCI_DEVICE(0x8086, 0x0f04),
- .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH_NOPM },
-+ /* Braswell */
-+ { PCI_DEVICE(0x8086, 0x2284),
-+ .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
- /* ICH */
- { PCI_DEVICE(0x8086, 0x2668),
- .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
-diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
-index 8253b48a435b..611110a3f1a4 100644
---- a/sound/pci/hda/patch_hdmi.c
-+++ b/sound/pci/hda/patch_hdmi.c
-@@ -3317,6 +3317,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
- { .id = 0x80862808, .name = "Broadwell HDMI", .patch = patch_generic_hdmi },
- { .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi },
- { .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi },
-+{ .id = 0x80862883, .name = "Braswell HDMI", .patch = patch_generic_hdmi },
- { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi },
- {} /* terminator */
- };
-@@ -3373,6 +3374,7 @@ MODULE_ALIAS("snd-hda-codec-id:80862807");
- MODULE_ALIAS("snd-hda-codec-id:80862808");
- MODULE_ALIAS("snd-hda-codec-id:80862880");
- MODULE_ALIAS("snd-hda-codec-id:80862882");
-+MODULE_ALIAS("snd-hda-codec-id:80862883");
- MODULE_ALIAS("snd-hda-codec-id:808629fb");
-
- MODULE_LICENSE("GPL");
-diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
-index eb241c6571a9..fd53d37e1181 100644
---- a/sound/soc/codecs/tlv320aic3x.c
-+++ b/sound/soc/codecs/tlv320aic3x.c
-@@ -1121,6 +1121,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
- static int aic3x_set_power(struct snd_soc_codec *codec, int power)
- {
- struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
-+ unsigned int pll_c, pll_d;
- int ret;
-
- if (power) {
-@@ -1138,6 +1139,18 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
- /* Sync reg_cache with the hardware */
- regcache_cache_only(aic3x->regmap, false);
- regcache_sync(aic3x->regmap);
-+
-+ /* Rewrite paired PLL D registers in case cached sync skipped
-+ * writing one of them and thus caused other one also not
-+ * being written
-+ */
-+ pll_c = snd_soc_read(codec, AIC3X_PLL_PROGC_REG);
-+ pll_d = snd_soc_read(codec, AIC3X_PLL_PROGD_REG);
-+ if (pll_c == aic3x_reg[AIC3X_PLL_PROGC_REG].def ||
-+ pll_d == aic3x_reg[AIC3X_PLL_PROGD_REG].def) {
-+ snd_soc_write(codec, AIC3X_PLL_PROGC_REG, pll_c);
-+ snd_soc_write(codec, AIC3X_PLL_PROGD_REG, pll_d);
-+ }
- } else {
- /*
- * Do soft reset to this codec instance in order to clear
-diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
-index 731d47b64daa..e4da224d7253 100644
---- a/sound/soc/soc-dapm.c
-+++ b/sound/soc/soc-dapm.c
-@@ -689,9 +689,9 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
- int shared;
- struct snd_kcontrol *kcontrol;
- bool wname_in_long_name, kcname_in_long_name;
-- char *long_name;
-+ char *long_name = NULL;
- const char *name;
-- int ret;
-+ int ret = 0;
-
- if (dapm->codec)
- prefix = dapm->codec->name_prefix;
-@@ -756,15 +756,17 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
-
- kcontrol = snd_soc_cnew(&w->kcontrol_news[kci], NULL, name,
- prefix);
-- kfree(long_name);
-- if (!kcontrol)
-- return -ENOMEM;
-+ if (!kcontrol) {
-+ ret = -ENOMEM;
-+ goto exit_free;
-+ }
-+
- kcontrol->private_free = dapm_kcontrol_free;
-
- ret = dapm_kcontrol_data_alloc(w, kcontrol);
- if (ret) {
- snd_ctl_free_one(kcontrol);
-- return ret;
-+ goto exit_free;
- }
-
- ret = snd_ctl_add(card, kcontrol);
-@@ -772,17 +774,18 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
- dev_err(dapm->dev,
- "ASoC: failed to add widget %s dapm kcontrol %s: %d\n",
- w->name, name, ret);
-- return ret;
-+ goto exit_free;
- }
- }
-
- ret = dapm_kcontrol_add_widget(kcontrol, w);
-- if (ret)
-- return ret;
-+ if (ret == 0)
-+ w->kcontrols[kci] = kcontrol;
-
-- w->kcontrols[kci] = kcontrol;
-+exit_free:
-+ kfree(long_name);
-
-- return 0;
-+ return ret;
- }
-
- /* create new dapm mixer control */
-diff --git a/sound/usb/card.c b/sound/usb/card.c
-index af1956042c9e..ab433a02dbf1 100644
---- a/sound/usb/card.c
-+++ b/sound/usb/card.c
-@@ -586,18 +586,19 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
- {
- struct snd_card *card;
- struct list_head *p;
-+ bool was_shutdown;
-
- if (chip == (void *)-1L)
- return;
-
- card = chip->card;
- down_write(&chip->shutdown_rwsem);
-+ was_shutdown = chip->shutdown;
- chip->shutdown = 1;
- up_write(&chip->shutdown_rwsem);
-
- mutex_lock(®ister_mutex);
-- chip->num_interfaces--;
-- if (chip->num_interfaces <= 0) {
-+ if (!was_shutdown) {
- struct snd_usb_endpoint *ep;
-
- snd_card_disconnect(card);
-@@ -617,6 +618,10 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
- list_for_each(p, &chip->mixer_list) {
- snd_usb_mixer_disconnect(p);
- }
-+ }
-+
-+ chip->num_interfaces--;
-+ if (chip->num_interfaces <= 0) {
- usb_chip[chip->index] = NULL;
- mutex_unlock(®ister_mutex);
- snd_card_free_when_closed(card);
-diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
-index 714b94932312..1f0dc1e5f1f0 100644
---- a/virt/kvm/iommu.c
-+++ b/virt/kvm/iommu.c
-@@ -43,13 +43,13 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
- gfn_t base_gfn, unsigned long npages);
-
- static pfn_t kvm_pin_pages(struct kvm_memory_slot *slot, gfn_t gfn,
-- unsigned long size)
-+ unsigned long npages)
- {
- gfn_t end_gfn;
- pfn_t pfn;
-
- pfn = gfn_to_pfn_memslot(slot, gfn);
-- end_gfn = gfn + (size >> PAGE_SHIFT);
-+ end_gfn = gfn + npages;
- gfn += 1;
-
- if (is_error_noslot_pfn(pfn))
-@@ -119,7 +119,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
- * Pin all pages we are about to map in memory. This is
- * important because we unmap and unpin in 4kb steps later.
- */
-- pfn = kvm_pin_pages(slot, gfn, page_size);
-+ pfn = kvm_pin_pages(slot, gfn, page_size >> PAGE_SHIFT);
- if (is_error_noslot_pfn(pfn)) {
- gfn += 1;
- continue;
-@@ -131,7 +131,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
- if (r) {
- printk(KERN_ERR "kvm_iommu_map_address:"
- "iommu failed to map pfn=%llx\n", pfn);
-- kvm_unpin_pages(kvm, pfn, page_size);
-+ kvm_unpin_pages(kvm, pfn, page_size >> PAGE_SHIFT);
- goto unmap_pages;
- }
-
diff --git a/projects/imx6/patches/linux/linux-000-patch-3.14.24-25.patch b/projects/imx6/patches/linux/linux-000-patch-3.14.24-25.patch
deleted file mode 100644
index 03df3d2b23..0000000000
--- a/projects/imx6/patches/linux/linux-000-patch-3.14.24-25.patch
+++ /dev/null
@@ -1,7549 +0,0 @@
-diff --git a/Documentation/devicetree/bindings/ata/sata_rcar.txt b/Documentation/devicetree/bindings/ata/sata_rcar.txt
-index 1e6111333fa8..7dd32d321a34 100644
---- a/Documentation/devicetree/bindings/ata/sata_rcar.txt
-+++ b/Documentation/devicetree/bindings/ata/sata_rcar.txt
-@@ -3,7 +3,8 @@
- Required properties:
- - compatible : should contain one of the following:
- - "renesas,sata-r8a7779" for R-Car H1
-- - "renesas,sata-r8a7790" for R-Car H2
-+ - "renesas,sata-r8a7790-es1" for R-Car H2 ES1
-+ - "renesas,sata-r8a7790" for R-Car H2 other than ES1
- - "renesas,sata-r8a7791" for R-Car M2
- - reg : address and length of the SATA registers;
- - interrupts : must consist of one interrupt specifier.
-diff --git a/Makefile b/Makefile
-index 8fd06101c482..eb96e40238f7 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,6 +1,6 @@
- VERSION = 3
- PATCHLEVEL = 14
--SUBLEVEL = 24
-+SUBLEVEL = 25
- EXTRAVERSION =
- NAME = Remembering Coco
-
-diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
-index 066b03480b63..8017cde13648 100644
---- a/arch/arm/boot/compressed/head.S
-+++ b/arch/arm/boot/compressed/head.S
-@@ -400,8 +400,7 @@ dtb_check_done:
- add sp, sp, r6
- #endif
-
-- tst r4, #1
-- bleq cache_clean_flush
-+ bl cache_clean_flush
-
- adr r0, BSYM(restart)
- add r0, r0, r6
-@@ -1050,6 +1049,8 @@ cache_clean_flush:
- b call_cache_fn
-
- __armv4_mpu_cache_flush:
-+ tst r4, #1
-+ movne pc, lr
- mov r2, #1
- mov r3, #0
- mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
-@@ -1067,6 +1068,8 @@ __armv4_mpu_cache_flush:
- mov pc, lr
-
- __fa526_cache_flush:
-+ tst r4, #1
-+ movne pc, lr
- mov r1, #0
- mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache
- mcr p15, 0, r1, c7, c5, 0 @ flush I cache
-@@ -1075,13 +1078,16 @@ __fa526_cache_flush:
-
- __armv6_mmu_cache_flush:
- mov r1, #0
-- mcr p15, 0, r1, c7, c14, 0 @ clean+invalidate D
-+ tst r4, #1
-+ mcreq p15, 0, r1, c7, c14, 0 @ clean+invalidate D
- mcr p15, 0, r1, c7, c5, 0 @ invalidate I+BTB
-- mcr p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
-+ mcreq p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
- mcr p15, 0, r1, c7, c10, 4 @ drain WB
- mov pc, lr
-
- __armv7_mmu_cache_flush:
-+ tst r4, #1
-+ bne iflush
- mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
- tst r10, #0xf << 16 @ hierarchical cache (ARMv7)
- mov r10, #0
-@@ -1142,6 +1148,8 @@ iflush:
- mov pc, lr
-
- __armv5tej_mmu_cache_flush:
-+ tst r4, #1
-+ movne pc, lr
- 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate D cache
- bne 1b
- mcr p15, 0, r0, c7, c5, 0 @ flush I cache
-@@ -1149,6 +1157,8 @@ __armv5tej_mmu_cache_flush:
- mov pc, lr
-
- __armv4_mmu_cache_flush:
-+ tst r4, #1
-+ movne pc, lr
- mov r2, #64*1024 @ default: 32K dcache size (*2)
- mov r11, #32 @ default: 32 byte line size
- mrc p15, 0, r3, c0, c0, 1 @ read cache type
-@@ -1182,6 +1192,8 @@ no_cache_id:
-
- __armv3_mmu_cache_flush:
- __armv3_mpu_cache_flush:
-+ tst r4, #1
-+ movne pc, lr
- mov r1, #0
- mcr p15, 0, r1, c7, c0, 0 @ invalidate whole cache v3
- mov pc, lr
-diff --git a/arch/arm/kernel/kprobes-common.c b/arch/arm/kernel/kprobes-common.c
-index 18a76282970e..380c20fb9c85 100644
---- a/arch/arm/kernel/kprobes-common.c
-+++ b/arch/arm/kernel/kprobes-common.c
-@@ -14,6 +14,7 @@
- #include
- #include
- #include
-+#include
-
- #include "kprobes.h"
-
-@@ -305,7 +306,8 @@ kprobe_decode_ldmstm(kprobe_opcode_t insn, struct arch_specific_insn *asi)
-
- if (handler) {
- /* We can emulate the instruction in (possibly) modified form */
-- asi->insn[0] = (insn & 0xfff00000) | (rn << 16) | reglist;
-+ asi->insn[0] = __opcode_to_mem_arm((insn & 0xfff00000) |
-+ (rn << 16) | reglist);
- asi->insn_handler = handler;
- return INSN_GOOD;
- }
-@@ -334,13 +336,14 @@ prepare_emulated_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
- #ifdef CONFIG_THUMB2_KERNEL
- if (thumb) {
- u16 *thumb_insn = (u16 *)asi->insn;
-- thumb_insn[1] = 0x4770; /* Thumb bx lr */
-- thumb_insn[2] = 0x4770; /* Thumb bx lr */
-+ /* Thumb bx lr */
-+ thumb_insn[1] = __opcode_to_mem_thumb16(0x4770);
-+ thumb_insn[2] = __opcode_to_mem_thumb16(0x4770);
- return insn;
- }
-- asi->insn[1] = 0xe12fff1e; /* ARM bx lr */
-+ asi->insn[1] = __opcode_to_mem_arm(0xe12fff1e); /* ARM bx lr */
- #else
-- asi->insn[1] = 0xe1a0f00e; /* mov pc, lr */
-+ asi->insn[1] = __opcode_to_mem_arm(0xe1a0f00e); /* mov pc, lr */
- #endif
- /* Make an ARM instruction unconditional */
- if (insn < 0xe0000000)
-@@ -360,12 +363,12 @@ set_emulated_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi,
- if (thumb) {
- u16 *ip = (u16 *)asi->insn;
- if (is_wide_instruction(insn))
-- *ip++ = insn >> 16;
-- *ip++ = insn;
-+ *ip++ = __opcode_to_mem_thumb16(insn >> 16);
-+ *ip++ = __opcode_to_mem_thumb16(insn);
- return;
- }
- #endif
-- asi->insn[0] = insn;
-+ asi->insn[0] = __opcode_to_mem_arm(insn);
- }
-
- /*
-diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c
-index 6123daf397a7..241222c66a13 100644
---- a/arch/arm/kernel/kprobes-thumb.c
-+++ b/arch/arm/kernel/kprobes-thumb.c
-@@ -11,6 +11,7 @@
- #include