diff --git a/README.md b/README.md index d17f23a81..08688ea0c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ build tools ## What do you need to get started? - x64 machine with at least 2GB of memory and ~35GB of disk space for the VM, container or native OS, -- Ubuntu Bionic 18.04 / Focal 20.04 x64 for native building or any [Docker](https://docs.armbian.com/Developer-Guide_Building-with-Docker/) capable x64 Linux for containerised, +- Ubuntu Focal 20.04 x64 for native building or any [Docker](https://docs.armbian.com/Developer-Guide_Building-with-Docker/) capable x64 Linux for containerised, - superuser rights (configured sudo or root access).

diff --git a/config/kernel/linux-imx6-current.config b/config/kernel/linux-imx6-current.config index e7703a05b..8182d7a91 100644 --- a/config/kernel/linux-imx6-current.config +++ b/config/kernel/linux-imx6-current.config @@ -2858,14 +2858,8 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m -CONFIG_TCM_IBLOCK=m -CONFIG_TCM_FILEIO=m -CONFIG_TCM_PSCSI=m -CONFIG_TCM_USER2=m CONFIG_LOOPBACK_TARGET=m CONFIG_TCM_FC=m -CONFIG_ISCSI_TARGET=m CONFIG_ISCSI_TARGET_CXGB4=m # CONFIG_FUSION is not set @@ -10615,3 +10609,12 @@ CONFIG_TEST_FREE_PAGES=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-imx7d-legacy.config b/config/kernel/linux-imx7d-legacy.config index 6ff092730..8bec47979 100644 --- a/config/kernel/linux-imx7d-legacy.config +++ b/config/kernel/linux-imx7d-legacy.config @@ -1641,7 +1641,6 @@ CONFIG_PATA_IMX=y # Generic fallback / legacy drivers # # CONFIG_MD is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -5475,3 +5474,12 @@ CONFIG_ARCH_HAS_SG_CHAIN=y CONFIG_SBITMAP=y # CONFIG_STRING_SELFTEST is not set # CONFIG_VIRTUALIZATION is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-meson-current.config b/config/kernel/linux-meson-current.config index ba0cce337..a1edf060b 100644 --- a/config/kernel/linux-meson-current.config +++ b/config/kernel/linux-meson-current.config @@ -2556,7 +2556,6 @@ CONFIG_DM_VERITY=m CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -9018,3 +9017,12 @@ CONFIG_TEST_FREE_PAGES=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-meson-dev.config b/config/kernel/linux-meson-dev.config index 7005b35a7..3000e6894 100644 --- a/config/kernel/linux-meson-dev.config +++ b/config/kernel/linux-meson-dev.config @@ -2519,7 +2519,6 @@ CONFIG_DM_VERITY=m CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -8874,3 +8873,12 @@ CONFIG_TEST_MEMCAT_P=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-meson-legacy.config b/config/kernel/linux-meson-legacy.config index d3e7e0589..aec845b62 100644 --- a/config/kernel/linux-meson-legacy.config +++ b/config/kernel/linux-meson-legacy.config @@ -2533,7 +2533,6 @@ CONFIG_DM_VERITY=m CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -8584,3 +8583,12 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" # CONFIG_PID_IN_CONTEXTIDR is not set # CONFIG_CORESIGHT is not set # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-meson64-current.config b/config/kernel/linux-meson64-current.config index c6196b90f..961d8e97f 100644 --- a/config/kernel/linux-meson64-current.config +++ b/config/kernel/linux-meson64-current.config @@ -2508,7 +2508,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -9385,3 +9384,12 @@ CONFIG_TEST_FREE_PAGES=m CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-meson64-dev.config b/config/kernel/linux-meson64-dev.config index 090c596d2..a0b55173d 100644 --- a/config/kernel/linux-meson64-dev.config +++ b/config/kernel/linux-meson64-dev.config @@ -2508,7 +2508,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -9383,3 +9382,12 @@ CONFIG_TEST_FREE_PAGES=m CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-meson64-legacy.config b/config/kernel/linux-meson64-legacy.config index 99f705033..db04d64a8 100644 --- a/config/kernel/linux-meson64-legacy.config +++ b/config/kernel/linux-meson64-legacy.config @@ -1380,7 +1380,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 CONFIG_RFKILL=y CONFIG_RFKILL_PM=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_REGULATOR is not set # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set @@ -2325,7 +2325,6 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_LOG_WRITES=m CONFIG_DM_VERITY_AVB=m # CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED is not set -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -6756,3 +6755,12 @@ CONFIG_FONT_10x18=y CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y CONFIG_SBITMAP=y + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mt7623-dev.config b/config/kernel/linux-mt7623-dev.config index 854a02b6f..f515316dd 100644 --- a/config/kernel/linux-mt7623-dev.config +++ b/config/kernel/linux-mt7623-dev.config @@ -2522,7 +2522,6 @@ CONFIG_DM_DUST=m # CONFIG_DM_SWITCH is not set # CONFIG_DM_LOG_WRITES is not set # CONFIG_DM_INTEGRITY is not set -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -7630,3 +7629,12 @@ CONFIG_TEST_MEMINIT=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mt7623-legacy.config b/config/kernel/linux-mt7623-legacy.config index f9e5b4def..dadfbd00e 100644 --- a/config/kernel/linux-mt7623-legacy.config +++ b/config/kernel/linux-mt7623-legacy.config @@ -2359,7 +2359,6 @@ CONFIG_DM_VERITY=m # CONFIG_DM_SWITCH is not set CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -6787,3 +6786,12 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_EARLY_PRINTK=y # CONFIG_PID_IN_CONTEXTIDR is not set # CONFIG_CORESIGHT is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mvebu-current.config b/config/kernel/linux-mvebu-current.config index 2732eb66b..d94905460 100644 --- a/config/kernel/linux-mvebu-current.config +++ b/config/kernel/linux-mvebu-current.config @@ -2437,12 +2437,10 @@ CONFIG_DM_VERITY=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m # CONFIG_TCM_IBLOCK is not set # CONFIG_TCM_FILEIO is not set # CONFIG_TCM_PSCSI is not set # CONFIG_LOOPBACK_TARGET is not set -CONFIG_ISCSI_TARGET=m # CONFIG_FUSION is not set # @@ -7093,3 +7091,12 @@ CONFIG_TEST_STACKINIT=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mvebu-dev.config b/config/kernel/linux-mvebu-dev.config index a0f1bfe7e..088b50067 100644 --- a/config/kernel/linux-mvebu-dev.config +++ b/config/kernel/linux-mvebu-dev.config @@ -2251,12 +2251,10 @@ CONFIG_DM_VERITY=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m # CONFIG_TCM_IBLOCK is not set # CONFIG_TCM_FILEIO is not set # CONFIG_TCM_PSCSI is not set # CONFIG_LOOPBACK_TARGET is not set -CONFIG_ISCSI_TARGET=m # CONFIG_FUSION is not set # @@ -6235,3 +6233,12 @@ CONFIG_EARLY_PRINTK=y # CONFIG_PID_IN_CONTEXTIDR is not set # CONFIG_CORESIGHT is not set # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mvebu-legacy.config b/config/kernel/linux-mvebu-legacy.config index d88b74e8c..e0b44b393 100644 --- a/config/kernel/linux-mvebu-legacy.config +++ b/config/kernel/linux-mvebu-legacy.config @@ -2107,12 +2107,7 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m -CONFIG_TCM_IBLOCK=m -CONFIG_TCM_FILEIO=m -CONFIG_TCM_PSCSI=m CONFIG_LOOPBACK_TARGET=m -CONFIG_ISCSI_TARGET=m # CONFIG_FUSION is not set # @@ -5728,3 +5723,12 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_EARLY_PRINTK=y # CONFIG_PID_IN_CONTEXTIDR is not set # CONFIG_CORESIGHT is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mvebu64-current.config b/config/kernel/linux-mvebu64-current.config index 840cf460a..b3a32adfc 100644 --- a/config/kernel/linux-mvebu64-current.config +++ b/config/kernel/linux-mvebu64-current.config @@ -2471,7 +2471,6 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -7516,3 +7515,12 @@ CONFIG_TEST_BITOPS=m CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mvebu64-dev.config b/config/kernel/linux-mvebu64-dev.config index f0be28228..2894a60f5 100644 --- a/config/kernel/linux-mvebu64-dev.config +++ b/config/kernel/linux-mvebu64-dev.config @@ -2455,7 +2455,6 @@ CONFIG_DM_VERITY=m CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -6580,3 +6579,12 @@ CONFIG_LIST_KUNIT_TEST=m CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-mvebu64-legacy.config b/config/kernel/linux-mvebu64-legacy.config index fb1fc5191..e27fdede6 100644 --- a/config/kernel/linux-mvebu64-legacy.config +++ b/config/kernel/linux-mvebu64-legacy.config @@ -2071,7 +2071,6 @@ CONFIG_PATA_OF_PLATFORM=y # CONFIG_ATA_GENERIC is not set # CONFIG_PATA_LEGACY is not set # CONFIG_MD is not set -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -6074,3 +6073,12 @@ CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y CONFIG_SBITMAP=y # CONFIG_STRING_SELFTEST is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-odroidxu4-current.config b/config/kernel/linux-odroidxu4-current.config index bf5a5e1bf..74f33afd3 100644 --- a/config/kernel/linux-odroidxu4-current.config +++ b/config/kernel/linux-odroidxu4-current.config @@ -1987,7 +1987,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m # CONFIG_TCM_IBLOCK is not set # CONFIG_TCM_FILEIO is not set # CONFIG_TCM_PSCSI is not set @@ -6988,3 +6987,12 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" # CONFIG_PID_IN_CONTEXTIDR is not set # CONFIG_CORESIGHT is not set # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-odroidxu4-dev.config b/config/kernel/linux-odroidxu4-dev.config index cb46a785f..363b192d3 100644 --- a/config/kernel/linux-odroidxu4-dev.config +++ b/config/kernel/linux-odroidxu4-dev.config @@ -1971,7 +1971,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m # CONFIG_TCM_IBLOCK is not set # CONFIG_TCM_FILEIO is not set # CONFIG_TCM_PSCSI is not set @@ -7116,3 +7115,12 @@ CONFIG_TEST_FREE_PAGES=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-odroidxu4-legacy.config b/config/kernel/linux-odroidxu4-legacy.config index 333024fc5..1eb5fab36 100644 --- a/config/kernel/linux-odroidxu4-legacy.config +++ b/config/kernel/linux-odroidxu4-legacy.config @@ -1829,7 +1829,6 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m # CONFIG_DM_INTEGRITY is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -6164,3 +6163,12 @@ CONFIG_VIRTUALIZATION=y CONFIG_VHOST_VSOCK=m CONFIG_VHOST=m # CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rk322x-current.config b/config/kernel/linux-rk322x-current.config index c67404d47..ef587fe97 100644 --- a/config/kernel/linux-rk322x-current.config +++ b/config/kernel/linux-rk322x-current.config @@ -1709,7 +1709,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 # CONFIG_WIMAX is not set CONFIG_RFKILL=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set # CONFIG_CAIF is not set @@ -1979,7 +1979,6 @@ CONFIG_DM_VERITY=y # CONFIG_DM_SWITCH is not set # CONFIG_DM_LOG_WRITES is not set # CONFIG_DM_INTEGRITY is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7095,3 +7094,12 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rk322x-dev.config b/config/kernel/linux-rk322x-dev.config index 8af918d8f..5f98141cc 100644 --- a/config/kernel/linux-rk322x-dev.config +++ b/config/kernel/linux-rk322x-dev.config @@ -1713,7 +1713,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 # CONFIG_WIMAX is not set CONFIG_RFKILL=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set # CONFIG_CAIF is not set @@ -1984,7 +1984,6 @@ CONFIG_DM_VERITY=y # CONFIG_DM_SWITCH is not set # CONFIG_DM_LOG_WRITES is not set # CONFIG_DM_INTEGRITY is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7123,3 +7122,12 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rk322x-legacy.config b/config/kernel/linux-rk322x-legacy.config index 36e7afaf6..6062bce05 100644 --- a/config/kernel/linux-rk322x-legacy.config +++ b/config/kernel/linux-rk322x-legacy.config @@ -1365,7 +1365,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 CONFIG_RFKILL=y CONFIG_RFKILL_PM=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_REGULATOR is not set # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set @@ -1620,7 +1620,6 @@ CONFIG_DM_VERITY=y # CONFIG_DM_LOG_WRITES is not set # CONFIG_DM_VERITY_AVB is not set # CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -5679,3 +5678,12 @@ CONFIG_FONT_8x16=y # CONFIG_SG_SPLIT is not set CONFIG_ARCH_HAS_SG_CHAIN=y # CONFIG_VIRTUALIZATION is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rk3399-legacy.config b/config/kernel/linux-rk3399-legacy.config index 164b99689..7b9111c16 100644 --- a/config/kernel/linux-rk3399-legacy.config +++ b/config/kernel/linux-rk3399-legacy.config @@ -1380,7 +1380,7 @@ CONFIG_WIMAX_DEBUG_LEVEL=8 CONFIG_RFKILL=y CONFIG_RFKILL_PM=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_REGULATOR is not set # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set @@ -1916,7 +1916,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m # CONFIG_DM_VERITY_AVB is not set # CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED is not set -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -6675,3 +6674,12 @@ CONFIG_FONT_8x8=y CONFIG_FONT_8x16=y # CONFIG_SG_SPLIT is not set CONFIG_ARCH_HAS_SG_CHAIN=y + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockchip-current.config b/config/kernel/linux-rockchip-current.config index 65ecb34a6..4ff01f015 100644 --- a/config/kernel/linux-rockchip-current.config +++ b/config/kernel/linux-rockchip-current.config @@ -1700,7 +1700,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 # CONFIG_WIMAX is not set CONFIG_RFKILL=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set # CONFIG_CAIF is not set @@ -1976,7 +1976,6 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7167,3 +7166,12 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockchip-dev.config b/config/kernel/linux-rockchip-dev.config index 63598298e..c349ccab9 100644 --- a/config/kernel/linux-rockchip-dev.config +++ b/config/kernel/linux-rockchip-dev.config @@ -1970,7 +1970,6 @@ CONFIG_DM_VERITY=y # CONFIG_DM_SWITCH is not set # CONFIG_DM_LOG_WRITES is not set # CONFIG_DM_INTEGRITY is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7161,3 +7160,12 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockchip-legacy.config b/config/kernel/linux-rockchip-legacy.config index 8f75fc75d..edfd314ce 100644 --- a/config/kernel/linux-rockchip-legacy.config +++ b/config/kernel/linux-rockchip-legacy.config @@ -1630,7 +1630,6 @@ CONFIG_DM_VERITY_HASH_PREFETCH_MIN_SIZE=1 # CONFIG_DM_LOG_WRITES is not set # CONFIG_DM_VERITY_AVB is not set # CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -5548,3 +5547,12 @@ CONFIG_FONT_8x16=y # CONFIG_SG_SPLIT is not set CONFIG_ARCH_HAS_SG_CHAIN=y # CONFIG_VIRTUALIZATION is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockchip64-current.config b/config/kernel/linux-rockchip64-current.config index 3dc1d415d..60c7b58bd 100644 --- a/config/kernel/linux-rockchip64-current.config +++ b/config/kernel/linux-rockchip64-current.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 5.8.5 Kernel Configuration +# Linux/arm64 5.9.6 Kernel Configuration # CONFIG_CC_VERSION_TEXT="aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025" CONFIG_CC_IS_GCC=y @@ -162,6 +162,7 @@ CONFIG_CGROUP_BPF=y CONFIG_SOCK_CGROUP_DATA=y CONFIG_NAMESPACES=y CONFIG_UTS_NS=y +CONFIG_TIME_NS=y CONFIG_IPC_NS=y CONFIG_USER_NS=y CONFIG_PID_NS=y @@ -178,6 +179,7 @@ CONFIG_RD_LZMA=y CONFIG_RD_XZ=y CONFIG_RD_LZO=y CONFIG_RD_LZ4=y +CONFIG_RD_ZSTD=y CONFIG_BOOT_CONFIG=y CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set @@ -291,10 +293,12 @@ CONFIG_ARCH_SUNXI=y # CONFIG_ARCH_BITMAIN is not set # CONFIG_ARCH_BRCMSTB is not set # CONFIG_ARCH_EXYNOS is not set +# CONFIG_ARCH_SPARX5 is not set # CONFIG_ARCH_K3 is not set # CONFIG_ARCH_LAYERSCAPE is not set # CONFIG_ARCH_LG1K is not set # CONFIG_ARCH_HISI is not set +# CONFIG_ARCH_KEEMBAY is not set # CONFIG_ARCH_MEDIATEK is not set CONFIG_ARCH_MESON=y # CONFIG_ARCH_MVEBU is not set @@ -406,7 +410,6 @@ CONFIG_XEN=y CONFIG_FORCE_MAX_ZONEORDER=11 CONFIG_UNMAP_KERNEL_AT_EL0=y CONFIG_HARDEN_BRANCH_PREDICTOR=y -CONFIG_HARDEN_EL2_VECTORS=y CONFIG_ARM64_SSBD=y CONFIG_RODATA_FULL_DEFAULT_ENABLED=y # CONFIG_ARM64_SW_TTBR0_PAN is not set @@ -451,6 +454,8 @@ CONFIG_AS_HAS_CFI_NEGATE_RA_STATE=y # ARMv8.4 architectural features # CONFIG_ARM64_AMU_EXTN=y +CONFIG_AS_HAS_ARMV8_4=y +CONFIG_ARM64_TLB_RANGE=y # end of ARMv8.4 architectural features # @@ -599,6 +604,7 @@ CONFIG_ARM_PSCI_FW=y # CONFIG_ARM_PSCI_CHECKER is not set CONFIG_HAVE_ARM_SMCCC=y CONFIG_HAVE_ARM_SMCCC_DISCOVERY=y +CONFIG_ARM_SMCCC_SOC_ID=y # # Tegra firmware driver @@ -689,7 +695,6 @@ CONFIG_HAVE_ARCH_SECCOMP_FILTER=y CONFIG_SECCOMP_FILTER=y CONFIG_HAVE_ARCH_STACKLEAK=y CONFIG_HAVE_STACKPROTECTOR=y -CONFIG_CC_HAS_STACKPROTECTOR_NONE=y CONFIG_STACKPROTECTOR=y CONFIG_STACKPROTECTOR_STRONG=y CONFIG_HAVE_CONTEXT_TRACKING=y @@ -705,7 +710,6 @@ CONFIG_ARCH_MMAP_RND_BITS=18 CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y CONFIG_ARCH_MMAP_RND_COMPAT_BITS=11 CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT=y -CONFIG_HAVE_COPY_THREAD_TLS=y CONFIG_CLONE_BACKWARDS=y CONFIG_OLD_SIGSUSPEND3=y CONFIG_COMPAT_OLD_SIGACTION=y @@ -836,7 +840,6 @@ CONFIG_SELECT_MEMORY_MODEL=y CONFIG_SPARSEMEM_MANUAL=y CONFIG_SPARSEMEM=y CONFIG_NEED_MULTIPLE_NODES=y -CONFIG_HAVE_MEMORY_PRESENT=y CONFIG_SPARSEMEM_EXTREME=y CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y CONFIG_SPARSEMEM_VMEMMAP=y @@ -1433,6 +1436,7 @@ CONFIG_NET_DSA_TAG_DSA=m CONFIG_NET_DSA_TAG_EDSA=m CONFIG_NET_DSA_TAG_MTK=m CONFIG_NET_DSA_TAG_KSZ=m +CONFIG_NET_DSA_TAG_RTL4_A=m CONFIG_NET_DSA_TAG_OCELOT=m CONFIG_NET_DSA_TAG_QCA=m CONFIG_NET_DSA_TAG_LAN9303=m @@ -1514,6 +1518,7 @@ CONFIG_NET_SCH_DEFAULT=y # CONFIG_DEFAULT_FQ is not set # CONFIG_DEFAULT_CODEL is not set # CONFIG_DEFAULT_FQ_CODEL is not set +# CONFIG_DEFAULT_FQ_PIE is not set # CONFIG_DEFAULT_SFQ is not set CONFIG_DEFAULT_PFIFO_FAST=y CONFIG_DEFAULT_NET_SCH="pfifo_fast" @@ -1947,6 +1952,8 @@ CONFIG_PCIE_ROCKCHIP_EP=y # # CONFIG_PCIE_CADENCE_PLAT_HOST is not set # CONFIG_PCIE_CADENCE_PLAT_EP is not set +# CONFIG_PCI_J721E_HOST is not set +# CONFIG_PCI_J721E_EP is not set # end of Cadence PCIe controllers support # end of PCI controller drivers @@ -2106,9 +2113,13 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y # CONFIG_MTD_DOCG3 is not set # end of Self-contained MTD device drivers +# +# NAND +# # CONFIG_MTD_ONENAND is not set # CONFIG_MTD_RAW_NAND is not set # CONFIG_MTD_SPI_NAND is not set +# end of NAND # # LPDDR & LPDDR2 PCM memory drivers @@ -2118,7 +2129,6 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y -# CONFIG_SPI_CADENCE_QUADSPI is not set # CONFIG_MTD_UBI is not set CONFIG_MTD_HYPERBUS=m CONFIG_HBMC_AM654=m @@ -2177,6 +2187,7 @@ CONFIG_NVME_FABRICS=m CONFIG_NVME_FC=m # CONFIG_NVME_TCP is not set CONFIG_NVME_TARGET=m +# CONFIG_NVME_TARGET_PASSTHRU is not set CONFIG_NVME_TARGET_LOOP=m CONFIG_NVME_TARGET_FC=m # CONFIG_NVME_TARGET_FCLOOP is not set @@ -2455,7 +2466,7 @@ CONFIG_MD_CLUSTER=m CONFIG_BCACHE=y # CONFIG_BCACHE_DEBUG is not set # CONFIG_BCACHE_CLOSURES_DEBUG is not set -# CONFIG_BCACHE_ASYNC_REGISTRAION is not set +# CONFIG_BCACHE_ASYNC_REGISTRATION is not set CONFIG_BLK_DEV_DM_BUILTIN=y CONFIG_BLK_DEV_DM=m # CONFIG_DM_DEBUG is not set @@ -2492,7 +2503,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -2741,8 +2751,8 @@ CONFIG_ENC28J60_WRITEVERIFY=y # CONFIG_ENCX24J600 is not set # CONFIG_LAN743X is not set CONFIG_NET_VENDOR_MICROSEMI=y +CONFIG_MSCC_OCELOT_SWITCH_LIB=m CONFIG_MSCC_OCELOT_SWITCH=m -CONFIG_MSCC_OCELOT_SWITCH_OCELOT=m CONFIG_NET_VENDOR_MYRI=y # CONFIG_MYRI10GE is not set # CONFIG_FEALNX is not set @@ -2840,6 +2850,7 @@ CONFIG_XILINX_LL_TEMAC=m # CONFIG_HIPPI is not set CONFIG_MDIO_DEVICE=y CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVRES=y CONFIG_MDIO_BCM_UNIMAC=m CONFIG_MDIO_BITBANG=y CONFIG_MDIO_BUS_MUX=y @@ -3105,7 +3116,11 @@ CONFIG_MT7603E=m CONFIG_MT7615_COMMON=m CONFIG_MT7615E=m # CONFIG_MT7663U is not set +# CONFIG_MT7663S is not set # CONFIG_MT7915E is not set +CONFIG_WLAN_VENDOR_MICROCHIP=y +# CONFIG_WILC1000_SDIO is not set +# CONFIG_WILC1000_SPI is not set CONFIG_WLAN_VENDOR_RALINK=y CONFIG_RT2X00=m CONFIG_RT2400PCI=m @@ -3162,6 +3177,7 @@ CONFIG_RTW88=m # CONFIG_RTW88_8822BE is not set # CONFIG_RTW88_8822CE is not set # CONFIG_RTW88_8723DE is not set +# CONFIG_RTW88_8821CE is not set CONFIG_WLAN_VENDOR_RSI=y CONFIG_RSI_91X=m # CONFIG_RSI_DEBUGFS is not set @@ -3587,6 +3603,7 @@ CONFIG_VIRTIO_CONSOLE=y # CONFIG_IPMB_DEVICE_INTERFACE is not set CONFIG_HW_RANDOM=m # CONFIG_HW_RANDOM_TIMERIOMEM is not set +# CONFIG_HW_RANDOM_BA431 is not set # CONFIG_HW_RANDOM_VIRTIO is not set CONFIG_HW_RANDOM_MESON=m CONFIG_HW_RANDOM_CAVIUM=m @@ -3711,6 +3728,7 @@ CONFIG_SPI_ALTERA=m CONFIG_SPI_AXI_SPI_ENGINE=m CONFIG_SPI_BITBANG=m CONFIG_SPI_CADENCE=m +# CONFIG_SPI_CADENCE_QUADSPI is not set CONFIG_SPI_DESIGNWARE=m # CONFIG_SPI_DW_DMA is not set CONFIG_SPI_DW_PCI=m @@ -3864,6 +3882,7 @@ CONFIG_GPIO_MAX7300=m CONFIG_GPIO_MAX732X=m CONFIG_GPIO_PCA953X=y CONFIG_GPIO_PCA953X_IRQ=y +# CONFIG_GPIO_PCA9570 is not set CONFIG_GPIO_PCF857X=m CONFIG_GPIO_TPIC2810=m # end of I2C GPIO expanders @@ -4001,6 +4020,7 @@ CONFIG_CHARGER_MAX77650=m # CONFIG_CHARGER_BQ24190 is not set # CONFIG_CHARGER_BQ24257 is not set # CONFIG_CHARGER_BQ24735 is not set +# CONFIG_CHARGER_BQ2515X is not set # CONFIG_CHARGER_BQ25890 is not set # CONFIG_CHARGER_SMB347 is not set # CONFIG_BATTERY_GAUGE_LTC2941 is not set @@ -4040,6 +4060,7 @@ CONFIG_SENSORS_AXI_FAN_CONTROL=m CONFIG_SENSORS_ARM_SCPI=m CONFIG_SENSORS_ASPEED=m CONFIG_SENSORS_ATXP1=m +# CONFIG_SENSORS_CORSAIR_CPRO is not set CONFIG_SENSORS_DRIVETEMP=m CONFIG_SENSORS_DS620=m CONFIG_SENSORS_DS1621=m @@ -4190,6 +4211,7 @@ CONFIG_SENSORS_W83L786NG=m CONFIG_SENSORS_W83627HF=m CONFIG_SENSORS_W83627EHF=m CONFIG_THERMAL=y +# CONFIG_THERMAL_NETLINK is not set CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 CONFIG_THERMAL_HWMON=y @@ -4204,7 +4226,6 @@ CONFIG_THERMAL_GOV_BANG_BANG=y CONFIG_THERMAL_GOV_USER_SPACE=y CONFIG_CPU_THERMAL=y CONFIG_CPU_FREQ_THERMAL=y -CONFIG_CLOCK_THERMAL=y CONFIG_DEVFREQ_THERMAL=y CONFIG_THERMAL_EMULATION=y CONFIG_THERMAL_MMIO=m @@ -4354,7 +4375,6 @@ CONFIG_MFD_SEC_CORE=y # CONFIG_MFD_SI476X_CORE is not set # CONFIG_MFD_SM501 is not set # CONFIG_MFD_SKY81452 is not set -# CONFIG_MFD_SMSC is not set # CONFIG_ABX500_CORE is not set # CONFIG_MFD_STMPE is not set CONFIG_MFD_SUN6I_PRCM=y @@ -4398,6 +4418,7 @@ CONFIG_MFD_ROHM_BD70528=m CONFIG_MFD_ROHM_BD71828=m # CONFIG_MFD_STPMIC1 is not set CONFIG_MFD_STMFX=m +# CONFIG_MFD_KHADAS_MCU is not set CONFIG_MFD_VEXPRESS_SYSREG=y CONFIG_RAVE_SP_CORE=m # end of Multifunction device drivers @@ -4416,9 +4437,11 @@ CONFIG_REGULATOR_AS3722=m CONFIG_REGULATOR_AXP20X=m CONFIG_REGULATOR_BD70528=m CONFIG_REGULATOR_BD71828=m +# CONFIG_REGULATOR_CROS_EC is not set # CONFIG_REGULATOR_DA9210 is not set # CONFIG_REGULATOR_DA9211 is not set CONFIG_REGULATOR_FAN53555=y +# CONFIG_REGULATOR_FAN53880 is not set CONFIG_REGULATOR_GPIO=y # CONFIG_REGULATOR_ISL9305 is not set # CONFIG_REGULATOR_ISL6271A is not set @@ -4442,12 +4465,14 @@ CONFIG_REGULATOR_MP8859=m CONFIG_REGULATOR_MP886X=m CONFIG_REGULATOR_MPQ7920=m # CONFIG_REGULATOR_MT6311 is not set +# CONFIG_REGULATOR_PCA9450 is not set # CONFIG_REGULATOR_PFUZE100 is not set # CONFIG_REGULATOR_PV88060 is not set # CONFIG_REGULATOR_PV88080 is not set # CONFIG_REGULATOR_PV88090 is not set CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_QCOM_SPMI=y +# CONFIG_REGULATOR_QCOM_USB_VBUS is not set CONFIG_REGULATOR_RC5T583=m CONFIG_REGULATOR_RK808=y CONFIG_REGULATOR_RN5T618=m @@ -4459,6 +4484,7 @@ CONFIG_REGULATOR_S2MPS11=y CONFIG_REGULATOR_SLG51000=m # CONFIG_REGULATOR_SY8106A is not set CONFIG_REGULATOR_SY8824X=m +# CONFIG_REGULATOR_SY8827N is not set # CONFIG_REGULATOR_TPS51632 is not set # CONFIG_REGULATOR_TPS62360 is not set # CONFIG_REGULATOR_TPS65023 is not set @@ -4467,6 +4493,7 @@ CONFIG_REGULATOR_SY8824X=m # CONFIG_REGULATOR_TPS6524X is not set # CONFIG_REGULATOR_VCTRL is not set # CONFIG_REGULATOR_VEXPRESS is not set +# CONFIG_REGULATOR_QCOM_LABIBB is not set CONFIG_RC_CORE=m CONFIG_RC_MAP=m CONFIG_LIRC=y @@ -4504,12 +4531,14 @@ CONFIG_IR_SERIAL=m CONFIG_IR_SERIAL_TRANSMITTER=y CONFIG_IR_SIR=m CONFIG_RC_XBOX_DVD=m +# CONFIG_IR_TOY is not set CONFIG_CEC_CORE=m CONFIG_CEC_NOTIFIER=y CONFIG_CEC_PIN=y CONFIG_MEDIA_CEC_RC=y CONFIG_CEC_PIN_ERROR_INJ=y CONFIG_MEDIA_CEC_SUPPORT=y +# CONFIG_CEC_CH7322 is not set # CONFIG_CEC_CROS_EC is not set # CONFIG_CEC_MESON_AO is not set # CONFIG_CEC_MESON_G12A_AO is not set @@ -4864,6 +4893,7 @@ CONFIG_VIDEO_TW9903=m CONFIG_VIDEO_TW9906=m CONFIG_VIDEO_TW9910=m CONFIG_VIDEO_VPX3220=m +# CONFIG_VIDEO_MAX9286 is not set # # Video and audio decoders @@ -4931,7 +4961,6 @@ CONFIG_VIDEO_OV2640=m CONFIG_VIDEO_OV2659=m CONFIG_VIDEO_OV2680=m CONFIG_VIDEO_OV2685=m -# CONFIG_VIDEO_OV2740 is not set CONFIG_VIDEO_OV5640=m CONFIG_VIDEO_OV5645=m CONFIG_VIDEO_OV5647=m @@ -4961,6 +4990,7 @@ CONFIG_VIDEO_MT9V111=m CONFIG_VIDEO_SR030PC30=m CONFIG_VIDEO_NOON010PC30=m CONFIG_VIDEO_M5MOLS=m +# CONFIG_VIDEO_RDACM20 is not set CONFIG_VIDEO_RJ54N1=m CONFIG_VIDEO_S5K6AA=m CONFIG_VIDEO_S5K6A3=m @@ -4977,6 +5007,7 @@ CONFIG_VIDEO_S5C73M3=m CONFIG_VIDEO_AD5820=m CONFIG_VIDEO_AK7375=m CONFIG_VIDEO_DW9714=m +# CONFIG_VIDEO_DW9768 is not set CONFIG_VIDEO_DW9807_VCM=m # end of Lens drivers @@ -5325,7 +5356,6 @@ CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00=m CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN=m CONFIG_DRM_PANEL_RAYDIUM_RM67191=m CONFIG_DRM_PANEL_RAYDIUM_RM68200=m -CONFIG_DRM_PANEL_ROCKTECH_JH057N00900=m CONFIG_DRM_PANEL_RONBO_RB070D30=m CONFIG_DRM_PANEL_SAMSUNG_S6D16D0=m CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2=m @@ -5338,6 +5368,7 @@ CONFIG_DRM_PANEL_SHARP_LQ101R1SX01=m CONFIG_DRM_PANEL_SHARP_LS037V7DW01=m CONFIG_DRM_PANEL_SHARP_LS043T1LE01=m CONFIG_DRM_PANEL_SITRONIX_ST7701=m +# CONFIG_DRM_PANEL_SITRONIX_ST7703 is not set # CONFIG_DRM_PANEL_SITRONIX_ST7789V is not set CONFIG_DRM_PANEL_SONY_ACX424AKP=m CONFIG_DRM_PANEL_SONY_ACX565AKM=m @@ -5500,7 +5531,6 @@ CONFIG_LCD_CLASS_DEVICE=m # CONFIG_LCD_HX8357 is not set CONFIG_LCD_OTM3225A=m CONFIG_BACKLIGHT_CLASS_DEVICE=y -CONFIG_BACKLIGHT_GENERIC=m CONFIG_BACKLIGHT_LM3533=m CONFIG_BACKLIGHT_PWM=m CONFIG_BACKLIGHT_QCOM_WLED=m @@ -5700,6 +5730,7 @@ CONFIG_SND_SOC_FSL_MICFIL=m # CONFIG_SND_I2S_HI6210_I2S is not set # CONFIG_SND_SOC_IMG is not set +# CONFIG_SND_SOC_INTEL_KEEMBAY is not set # CONFIG_SND_SOC_MTK_BTCVSD is not set # @@ -5822,7 +5853,7 @@ CONFIG_SND_SOC_MAX98357A=m # CONFIG_SND_SOC_MAX98504 is not set CONFIG_SND_SOC_MAX9867=m # CONFIG_SND_SOC_MAX98927 is not set -CONFIG_SND_SOC_MAX98373=m +# CONFIG_SND_SOC_MAX98373_I2C is not set # CONFIG_SND_SOC_MAX98390 is not set # CONFIG_SND_SOC_MAX9860 is not set # CONFIG_SND_SOC_MSM8916_WCD_ANALOG is not set @@ -6088,8 +6119,8 @@ CONFIG_USB_ANNOUNCE_NEW_DEVICES=y CONFIG_USB_DEFAULT_PERSIST=y # CONFIG_USB_DYNAMIC_MINORS is not set CONFIG_USB_OTG=y -# CONFIG_USB_OTG_WHITELIST is not set -# CONFIG_USB_OTG_BLACKLIST_HUB is not set +# CONFIG_USB_OTG_PRODUCTLIST is not set +# CONFIG_USB_OTG_DISABLE_EXTERNAL_HUB is not set CONFIG_USB_OTG_FSM=m CONFIG_USB_LEDS_TRIGGER_USBPORT=y CONFIG_USB_AUTOSUSPEND_DELAY=2 @@ -6504,6 +6535,7 @@ CONFIG_MMC_SDHCI_AM654=m CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y # CONFIG_LEDS_CLASS_FLASH is not set +# CONFIG_LEDS_CLASS_MULTICOLOR is not set # CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set # @@ -6524,10 +6556,7 @@ CONFIG_LEDS_LM3692X=m CONFIG_LEDS_GPIO=y # CONFIG_LEDS_LP3944 is not set # CONFIG_LEDS_LP3952 is not set -# CONFIG_LEDS_LP5521 is not set -# CONFIG_LEDS_LP5523 is not set -# CONFIG_LEDS_LP5562 is not set -# CONFIG_LEDS_LP8501 is not set +# CONFIG_LEDS_LP55XX_COMMON is not set # CONFIG_LEDS_LP8860 is not set # CONFIG_LEDS_PCA955X is not set # CONFIG_LEDS_PCA963X is not set @@ -6737,6 +6766,7 @@ CONFIG_PL330_DMA=y CONFIG_PLX_DMA=m # CONFIG_XILINX_DMA is not set # CONFIG_XILINX_ZYNQMP_DMA is not set +# CONFIG_XILINX_ZYNQMP_DPDMA is not set CONFIG_QCOM_HIDMA_MGMT=y CONFIG_QCOM_HIDMA=y # CONFIG_DW_DMAC is not set @@ -6908,13 +6938,6 @@ CONFIG_AD9834=m # end of IIO staging drivers CONFIG_FB_SM750=m - -# -# Speakup console speech -# -# CONFIG_SPEAKUP is not set -# end of Speakup console speech - CONFIG_STAGING_MEDIA=y CONFIG_VIDEO_HANTRO=m CONFIG_VIDEO_HANTRO_ROCKCHIP=y @@ -6922,10 +6945,6 @@ CONFIG_VIDEO_MESON_VDEC=m CONFIG_VIDEO_ROCKCHIP_VDEC=m CONFIG_VIDEO_SUNXI=y CONFIG_VIDEO_SUNXI_CEDRUS=m - -# -# soc_camera sensor drivers -# CONFIG_PHY_ROCKCHIP_DPHY_RX0=m CONFIG_VIDEO_ROCKCHIP_ISP1=m CONFIG_VIDEO_USBVISION=m @@ -6939,7 +6958,6 @@ CONFIG_VIDEO_USBVISION=m # CONFIG_LTE_GDM724X is not set # CONFIG_GS_FPGABOOT is not set # CONFIG_UNISYSSPAR is not set -# CONFIG_COMMON_CLK_XLNX_CLKWZRD is not set CONFIG_FB_TFT=m CONFIG_FB_TFT_AGM1264K_FL=m CONFIG_FB_TFT_BD663474=m @@ -6974,8 +6992,6 @@ CONFIG_FB_TFT_UC1701=m CONFIG_FB_TFT_UPD161704=m CONFIG_FB_TFT_WATTEROTT=m CONFIG_FUSB_30X=m -# CONFIG_WILC1000_SDIO is not set -# CONFIG_WILC1000_SPI is not set # CONFIG_MOST_COMPONENTS is not set # CONFIG_KS7010 is not set # CONFIG_PI433 is not set @@ -7247,6 +7263,7 @@ CONFIG_BMA180=m CONFIG_BMA220=m CONFIG_BMA400=m CONFIG_BMA400_I2C=m +CONFIG_BMA400_SPI=m CONFIG_BMC150_ACCEL=m CONFIG_BMC150_ACCEL_I2C=m CONFIG_BMC150_ACCEL_SPI=m @@ -7375,6 +7392,7 @@ CONFIG_BME680_SPI=m # CONFIG_CCS811 is not set # CONFIG_IAQCORE is not set CONFIG_PMS7003=m +# CONFIG_SCD30_CORE is not set CONFIG_SENSIRION_SGP30=m CONFIG_SPS30=m # CONFIG_VZ89X is not set @@ -7532,6 +7550,8 @@ CONFIG_FXOS8700=m CONFIG_FXOS8700_I2C=m CONFIG_FXOS8700_SPI=m # CONFIG_KMX61 is not set +# CONFIG_INV_ICM42600_I2C is not set +# CONFIG_INV_ICM42600_SPI is not set # CONFIG_INV_MPU6050_I2C is not set # CONFIG_INV_MPU6050_SPI is not set # CONFIG_IIO_ST_LSM6DSX is not set @@ -7881,7 +7901,9 @@ CONFIG_PM_OPP=y # CONFIG_INTERCONNECT is not set CONFIG_COUNTER=m CONFIG_FTM_QUADDEC=m +# CONFIG_MICROCHIP_TCB_CAPTURE is not set CONFIG_MOST=m +# CONFIG_MOST_USB_HDM is not set # end of Device Drivers # @@ -8037,6 +8059,7 @@ CONFIG_SYSFS=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y CONFIG_TMPFS_XATTR=y +# CONFIG_TMPFS_INODE64 is not set CONFIG_HUGETLBFS=y CONFIG_HUGETLB_PAGE=y CONFIG_MEMFD_CREATE=y @@ -8130,25 +8153,6 @@ CONFIG_EROFS_FS_XATTR=y CONFIG_EROFS_FS_POSIX_ACL=y CONFIG_EROFS_FS_SECURITY=y # CONFIG_EROFS_FS_ZIP is not set -CONFIG_AUFS_FS=m -CONFIG_AUFS_BRANCH_MAX_127=y -# CONFIG_AUFS_BRANCH_MAX_511 is not set -# CONFIG_AUFS_BRANCH_MAX_1023 is not set -# CONFIG_AUFS_BRANCH_MAX_32767 is not set -CONFIG_AUFS_SBILIST=y -# CONFIG_AUFS_HNOTIFY is not set -CONFIG_AUFS_EXPORT=y -CONFIG_AUFS_INO_T_64=y -CONFIG_AUFS_XATTR=y -# CONFIG_AUFS_FHSM is not set -# CONFIG_AUFS_RDU is not set -CONFIG_AUFS_DIRREN=y -# CONFIG_AUFS_SHWH is not set -# CONFIG_AUFS_BR_RAMFS is not set -# CONFIG_AUFS_BR_FUSE is not set -CONFIG_AUFS_BR_HFSPLUS=y -CONFIG_AUFS_BDEV_LOOP=y -# CONFIG_AUFS_DEBUG is not set CONFIG_NETWORK_FILESYSTEMS=y CONFIG_NFS_FS=m CONFIG_NFS_V2=m @@ -8178,6 +8182,7 @@ CONFIG_NFSD_PNFS=y CONFIG_NFSD_BLOCKLAYOUT=y CONFIG_NFSD_SCSILAYOUT=y CONFIG_NFSD_FLEXFILELAYOUT=y +# CONFIG_NFSD_V4_2_INTER_SSC is not set CONFIG_NFSD_V4_SECURITY_LABEL=y CONFIG_GRACE_PERIOD=m CONFIG_LOCKD=m @@ -8656,6 +8661,7 @@ CONFIG_DECOMPRESS_LZMA=y CONFIG_DECOMPRESS_XZ=y CONFIG_DECOMPRESS_LZO=y CONFIG_DECOMPRESS_LZ4=y +CONFIG_DECOMPRESS_ZSTD=y CONFIG_GENERIC_ALLOCATOR=y CONFIG_REED_SOLOMON=m CONFIG_REED_SOLOMON_ENC8=y @@ -8672,6 +8678,7 @@ CONFIG_ASSOCIATIVE_ARRAY=y CONFIG_HAS_IOMEM=y CONFIG_HAS_IOPORT_MAP=y CONFIG_HAS_DMA=y +CONFIG_DMA_OPS=y CONFIG_NEED_SG_DMA_LENGTH=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_ARCH_DMA_ADDR_T_64BIT=y @@ -8715,6 +8722,7 @@ CONFIG_OID_REGISTRY=y CONFIG_UCS2_STRING=y CONFIG_HAVE_GENERIC_VDSO=y CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_VDSO_TIME_NS=y CONFIG_FONT_SUPPORT=y CONFIG_FONTS=y CONFIG_FONT_8x8=y @@ -8765,6 +8773,7 @@ CONFIG_FRAME_WARN=2048 # CONFIG_HEADERS_INSTALL is not set # CONFIG_DEBUG_SECTION_MISMATCH is not set CONFIG_SECTION_MISMATCH_WARN_ONLY=y +# CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B is not set CONFIG_ARCH_WANT_FRAME_POINTERS=y CONFIG_FRAME_POINTER=y # CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set @@ -8778,6 +8787,9 @@ CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1 CONFIG_MAGIC_SYSRQ_SERIAL=y CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE="" CONFIG_DEBUG_FS=y +CONFIG_DEBUG_FS_ALLOW_ALL=y +# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set +# CONFIG_DEBUG_FS_ALLOW_NONE is not set CONFIG_HAVE_ARCH_KGDB=y # CONFIG_KGDB is not set CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y @@ -8819,7 +8831,6 @@ CONFIG_HAVE_ARCH_KASAN_SW_TAGS=y CONFIG_CC_HAS_KASAN_GENERIC=y CONFIG_CC_HAS_WORKING_NOSANITIZE_ADDRESS=y # CONFIG_KASAN is not set -CONFIG_KASAN_STACK=1 # end of Memory Debugging # CONFIG_DEBUG_SHIRQ is not set @@ -8888,6 +8899,7 @@ CONFIG_HAVE_DEBUG_BUGVERBOSE=y CONFIG_TORTURE_TEST=m CONFIG_RCU_PERF_TEST=m CONFIG_RCU_TORTURE_TEST=m +# CONFIG_RCU_REF_SCALE_TEST is not set CONFIG_RCU_CPU_STALL_TIMEOUT=60 CONFIG_RCU_TRACE=y # CONFIG_RCU_EQS_DEBUG is not set @@ -9000,12 +9012,23 @@ CONFIG_TEST_BLACKHOLE_DEV=m # CONFIG_SYSCTL_KUNIT_TEST is not set # CONFIG_LIST_KUNIT_TEST is not set # CONFIG_LINEAR_RANGES_TEST is not set +# CONFIG_BITS_TEST is not set # CONFIG_TEST_UDELAY is not set # CONFIG_TEST_STATIC_KEYS is not set # CONFIG_TEST_KMOD is not set CONFIG_TEST_MEMCAT_P=m CONFIG_TEST_STACKINIT=m # CONFIG_TEST_MEMINIT is not set +# CONFIG_TEST_FREE_PAGES is not set CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockchip64-dev.config b/config/kernel/linux-rockchip64-dev.config index d4f0a5103..f723c3129 100644 --- a/config/kernel/linux-rockchip64-dev.config +++ b/config/kernel/linux-rockchip64-dev.config @@ -2504,7 +2504,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -9023,3 +9022,12 @@ CONFIG_TEST_STACKINIT=m CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockchip64-legacy.config b/config/kernel/linux-rockchip64-legacy.config index 83a069257..8a52a32e6 100644 --- a/config/kernel/linux-rockchip64-legacy.config +++ b/config/kernel/linux-rockchip64-legacy.config @@ -1225,7 +1225,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 CONFIG_RFKILL=y CONFIG_RFKILL_PM=y CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y # CONFIG_RFKILL_REGULATOR is not set # CONFIG_RFKILL_GPIO is not set # CONFIG_NET_9P is not set @@ -1731,7 +1731,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m # CONFIG_DM_VERITY_AVB is not set # CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED is not set -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -6405,3 +6404,12 @@ CONFIG_FONT_8x8=y CONFIG_FONT_8x16=y # CONFIG_SG_SPLIT is not set CONFIG_ARCH_HAS_SG_CHAIN=y + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockpis-dev.config b/config/kernel/linux-rockpis-dev.config index 5aaeee769..37aca0714 100644 --- a/config/kernel/linux-rockpis-dev.config +++ b/config/kernel/linux-rockpis-dev.config @@ -2137,7 +2137,6 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -# CONFIG_TARGET_CORE is not set # CONFIG_FUSION is not set # @@ -7543,3 +7542,12 @@ CONFIG_TEST_STACKINIT=m CONFIG_MEMTEST=y # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-rockpis-legacy.config b/config/kernel/linux-rockpis-legacy.config index 16450e624..a5a9b39d6 100644 --- a/config/kernel/linux-rockpis-legacy.config +++ b/config/kernel/linux-rockpis-legacy.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 4.4.228 Kernel Configuration +# Linux/arm64 4.4.243 Kernel Configuration # CONFIG_ARM64=y CONFIG_64BIT=y @@ -272,9 +272,9 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_MODULE_COMPRESS is not set CONFIG_MODULES_TREE_LOOKUP=y CONFIG_BLOCK=y -# CONFIG_BLK_DEV_BSG is not set -# CONFIG_BLK_DEV_BSGLIB is not set -# CONFIG_BLK_DEV_INTEGRITY is not set +CONFIG_BLK_DEV_BSG=y +CONFIG_BLK_DEV_BSGLIB=y +CONFIG_BLK_DEV_INTEGRITY=y CONFIG_BLK_DEV_THROTTLING=y # CONFIG_BLK_CMDLINE_PARSER is not set @@ -1464,7 +1464,12 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_VERITY_AVB=m CONFIG_DM_ANDROID_VERITY_AT_MOST_ONCE_DEFAULT_ENABLED=y -# CONFIG_TARGET_CORE is not set +CONFIG_TARGET_CORE=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_LOOPBACK_TARGET=m +CONFIG_ISCSI_TARGET=m CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -3493,6 +3498,7 @@ CONFIG_USB_FUNCTIONFS_ETH=y CONFIG_USB_FUNCTIONFS_RNDIS=y CONFIG_USB_FUNCTIONFS_GENERIC=y CONFIG_USB_MASS_STORAGE=m +CONFIG_USB_GADGET_TARGET=m CONFIG_USB_G_SERIAL=m CONFIG_USB_MIDI_GADGET=m # CONFIG_USB_G_PRINTER is not set diff --git a/config/kernel/linux-s5p6818-legacy.config b/config/kernel/linux-s5p6818-legacy.config index c3384bf42..4b1e3193a 100644 --- a/config/kernel/linux-s5p6818-legacy.config +++ b/config/kernel/linux-s5p6818-legacy.config @@ -1727,7 +1727,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -5758,3 +5757,12 @@ CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y CONFIG_SBITMAP=y # CONFIG_STRING_SELFTEST is not set + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-sunxi-current.config b/config/kernel/linux-sunxi-current.config index 6d8a01363..7b6b1aead 100644 --- a/config/kernel/linux-sunxi-current.config +++ b/config/kernel/linux-sunxi-current.config @@ -1714,7 +1714,7 @@ CONFIG_WIMAX=m CONFIG_WIMAX_DEBUG_LEVEL=8 CONFIG_RFKILL=m CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y CONFIG_RFKILL_GPIO=m # CONFIG_NET_9P is not set # CONFIG_CAIF is not set @@ -2199,13 +2199,7 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -CONFIG_TARGET_CORE=m -CONFIG_TCM_IBLOCK=m -CONFIG_TCM_FILEIO=m -CONFIG_TCM_PSCSI=m -CONFIG_TCM_USER2=m CONFIG_LOOPBACK_TARGET=m -CONFIG_ISCSI_TARGET=m CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7819,3 +7813,12 @@ CONFIG_TEST_MEMCAT_P=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-sunxi-dev.config b/config/kernel/linux-sunxi-dev.config index f92365ff4..fd4c75b48 100644 --- a/config/kernel/linux-sunxi-dev.config +++ b/config/kernel/linux-sunxi-dev.config @@ -1721,7 +1721,7 @@ CONFIG_WIMAX=m CONFIG_WIMAX_DEBUG_LEVEL=8 CONFIG_RFKILL=m CONFIG_RFKILL_LEDS=y -# CONFIG_RFKILL_INPUT is not set +CONFIG_RFKILL_INPUT=y CONFIG_RFKILL_GPIO=m # CONFIG_NET_9P is not set # CONFIG_CAIF is not set @@ -2206,13 +2206,7 @@ CONFIG_DM_VERITY_FEC=y CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m -CONFIG_TARGET_CORE=m -CONFIG_TCM_IBLOCK=m -CONFIG_TCM_FILEIO=m -CONFIG_TCM_PSCSI=m -CONFIG_TCM_USER2=m CONFIG_LOOPBACK_TARGET=m -CONFIG_ISCSI_TARGET=m CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7889,3 +7883,12 @@ CONFIG_TEST_MEMCAT_P=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-sunxi-legacy.config b/config/kernel/linux-sunxi-legacy.config index 416220e5e..aa91ce743 100644 --- a/config/kernel/linux-sunxi-legacy.config +++ b/config/kernel/linux-sunxi-legacy.config @@ -2221,13 +2221,7 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m # CONFIG_DM_INTEGRITY is not set CONFIG_DM_ZONED=m -CONFIG_TARGET_CORE=m -CONFIG_TCM_IBLOCK=m -CONFIG_TCM_FILEIO=m -CONFIG_TCM_PSCSI=m -CONFIG_TCM_USER2=m CONFIG_LOOPBACK_TARGET=m -CONFIG_ISCSI_TARGET=m CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7945,3 +7939,12 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" # CONFIG_PID_IN_CONTEXTIDR is not set # CONFIG_CORESIGHT is not set # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-sunxi64-current.config b/config/kernel/linux-sunxi64-current.config index ac20b9d90..2fc89c824 100644 --- a/config/kernel/linux-sunxi64-current.config +++ b/config/kernel/linux-sunxi64-current.config @@ -2149,7 +2149,6 @@ CONFIG_DM_DUST=m # CONFIG_DM_LOG_WRITES is not set CONFIG_DM_INTEGRITY=m # CONFIG_DM_ZONED is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7517,3 +7516,12 @@ CONFIG_TEST_STACKINIT=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-sunxi64-dev.config b/config/kernel/linux-sunxi64-dev.config index 33b08d34f..aaccb7201 100644 --- a/config/kernel/linux-sunxi64-dev.config +++ b/config/kernel/linux-sunxi64-dev.config @@ -2162,7 +2162,6 @@ CONFIG_DM_DUST=m # CONFIG_DM_LOG_WRITES is not set CONFIG_DM_INTEGRITY=m # CONFIG_DM_ZONED is not set -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -7598,3 +7597,12 @@ CONFIG_TEST_STACKINIT=m # CONFIG_MEMTEST is not set # end of Kernel Testing and Coverage # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/kernel/linux-sunxi64-legacy.config b/config/kernel/linux-sunxi64-legacy.config index d3ba5d2a0..2d253091b 100644 --- a/config/kernel/linux-sunxi64-legacy.config +++ b/config/kernel/linux-sunxi64-legacy.config @@ -2253,7 +2253,6 @@ CONFIG_DM_SWITCH=m CONFIG_DM_LOG_WRITES=m CONFIG_DM_INTEGRITY=m CONFIG_DM_ZONED=m -# CONFIG_TARGET_CORE is not set CONFIG_NETDEVICES=y CONFIG_MII=y CONFIG_NET_CORE=y @@ -8012,3 +8011,12 @@ CONFIG_STRICT_DEVMEM=y # CONFIG_ARM64_RELOC_TEST is not set # CONFIG_CORESIGHT is not set # end of Kernel hacking + +## LinuxIO - iSCSI Target modules +CONFIG_TARGET_CORE=m +CONFIG_ISCSI_TARGET=m +CONFIG_TCM_IBLOCK=m +CONFIG_TCM_FILEIO=m +CONFIG_TCM_PSCSI=m +CONFIG_TCM_USER2=m + diff --git a/config/sources/families/include/rockchip64_common.inc b/config/sources/families/include/rockchip64_common.inc index a012cb185..5a56c9a31 100644 --- a/config/sources/families/include/rockchip64_common.inc +++ b/config/sources/families/include/rockchip64_common.inc @@ -74,7 +74,7 @@ case $BRANCH in current) KERNELPATCHDIR='rockchip64-'$BRANCH - KERNELBRANCH="branch:linux-5.8.y" + KERNELBRANCH="branch:linux-5.9.y" LINUXFAMILY=rockchip64 LINUXCONFIG='linux-rockchip64-'$BRANCH diff --git a/lib/build-all-ng.sh b/lib/build-all-ng.sh index c134480e3..8e1b7afde 100644 --- a/lib/build-all-ng.sh +++ b/lib/build-all-ng.sh @@ -63,7 +63,7 @@ unset LINUXFAMILY LINUXCONFIG KERNELDIR KERNELSOURCE KERNELBRANCH BOOTDIR BOOTSO PACKAGE_LIST_BOARD_REMOVE PACKAGE_LIST_FAMILY_REMOVE PACKAGE_LIST_DESKTOP_BOARD_REMOVE PACKAGE_LIST_DESKTOP_FAMILY_REMOVE BOOTCONFIG_DEV \ DESKTOP_ENVIRONMENT DESKTOP_ENVIRONMENT_CONFIG_NAME DESKTOP_APPGROUPS_SELECTED DESKTOP_APT_FLAGS_SELECTED \ DESKTOP_ENVIRONMENT_DIRPATH DESKTOP_ENVIRONMENT_PACKAGE_LIST_DIRPATH DESKTOP_ENVIRONMENT_DIRPATH DESKTOP_ENVIRONMENT_PACKAGE_LIST_DIRPATH \ - DESKTOP_CONFIG_PREFIX DESKTOP_CONFIGS_DIR DESKTOP_APPGROUPS_DIR DEBIAN_RECOMMENDS + DESKTOP_CONFIG_PREFIX DESKTOP_CONFIGS_DIR DESKTOP_APPGROUPS_DIR DEBIAN_RECOMMENDS USE_OVERLAYFS } pack_upload () @@ -343,7 +343,7 @@ function build_all() done display_alert "Building ${n}." - if [[ "$KERNEL_ONLY" == "no" ]]; then + if [[ "$KERNEL_ONLY" == "no" && "${MULTITHREAD}" -gt 0 ]]; then build_main & else build_main diff --git a/lib/compilation.sh b/lib/compilation.sh index ff85bfd6f..ffefbdbe6 100644 --- a/lib/compilation.sh +++ b/lib/compilation.sh @@ -169,7 +169,7 @@ compile_uboot() # create patch for manual source changes [[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot" - if [[ -n $ATFSOURCE ]]; then + if [[ -n $ATFSOURCE ]]; then cp -Rv "${atftempdir}"/*.bin . rm -rf "${atftempdir}" fi @@ -275,7 +275,7 @@ compile_uboot() [[ ! -f $uboottempdir/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed" - mv "$uboottempdir/${uboot_name}.deb" "${DEB_STORAGE}/" + rsync -rq "$uboottempdir/${uboot_name}.deb" "${DEB_STORAGE}/" } compile_kernel() @@ -447,14 +447,14 @@ compile_kernel() if [[ $BUILD_KSRC != no ]]; then fakeroot dpkg-deb -z0 -b "${sources_pkg_dir}" "${sources_pkg_dir}.deb" - mv "${sources_pkg_dir}.deb" "${DEB_STORAGE}/" + rsync -rq "${sources_pkg_dir}.deb" "${DEB_STORAGE}/" fi rm -rf "${sources_pkg_dir}" cd .. || exit # remove firmare image packages here - easier than patching ~40 packaging scripts at once rm -f linux-firmware-image-*.deb - mv ./*.deb "${DEB_STORAGE}/" || exit_with_error "Failed moving kernel DEBs" + rsync -rq ./*.deb "${DEB_STORAGE}/" || exit_with_error "Failed moving kernel DEBs" # store git hash to the file echo "${hash}" > "${SRC}/cache/hash"$([[ ${BETA} == yes ]] && echo "-beta")"/linux-image-${BRANCH}-${LINUXFAMILY}.githash" @@ -516,7 +516,7 @@ compile_firmware() mv "armbian-firmware${FULL}" "armbian-firmware${FULL}_${REVISION}_all" fakeroot dpkg -b "armbian-firmware${FULL}_${REVISION}_all" >> "${DEST}"/debug/install.log 2>&1 mv "armbian-firmware${FULL}_${REVISION}_all" "armbian-firmware${FULL}" - mv "armbian-firmware${FULL}_${REVISION}_all.deb" "${DEB_STORAGE}/" + rsync -rq "armbian-firmware${FULL}_${REVISION}_all.deb" "${DEB_STORAGE}/" # remove temp directory rm -rf "${firmwaretempdir}" @@ -564,7 +564,7 @@ compile_armbian-config() ln -sf /usr/sbin/softy "${tmpdir}"/usr/bin/softy fakeroot dpkg -b "${tmpdir}" >/dev/null - mv "${tmpdir}.deb" "${DEB_STORAGE}/" + rsync -rq "${tmpdir}.deb" "${DEB_STORAGE}/" rm -rf "${tmpdir}" } diff --git a/lib/debootstrap.sh b/lib/debootstrap.sh index 99147908f..3d018cde4 100644 --- a/lib/debootstrap.sh +++ b/lib/debootstrap.sh @@ -53,10 +53,10 @@ debootstrap_ng() install_common # install locally built packages - [[ $EXTERNAL_NEW == compile ]] && chroot_installpackages_local + [[ $EXTERNAL_NEW == compile ]] && chroot_installpackages_local >> "${DEST}"/debug/install.log 2>&1 # install from apt.armbian.com - [[ $EXTERNAL_NEW == prebuilt ]] && chroot_installpackages "yes" + [[ $EXTERNAL_NEW == prebuilt ]] && chroot_installpackages "yes" >> "${DEST}"/debug/install.log 2>&1 # stage: user customization script # NOTE: installing too many packages may fill tmpfs mount @@ -273,8 +273,10 @@ create_rootfs_cache() chroot $SDCARD /bin/bash -c "apt-get clean" # DEBUG: print free space - echo -e "\nFree space:" - eval 'df -h' ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/debootstrap.log'} + local freespace=$(LC_ALL=C df -h) + echo $freespace >> $DEST/debug/debootstrap.log + display_alert "SD" "$(echo -e "$freespace" | grep $SDCARD | awk '{print $5}')" "info" + display_alert "Mount point" "$(echo -e "$freespace" | grep $MOUNT | awk '{print $5}')" "info" # create list of installed packages for debug purposes chroot $SDCARD /bin/bash -c "dpkg --get-selections" | grep -v deinstall | awk '{print $1}' | cut -f1 -d':' > ${cache_fname}.list 2>&1 @@ -619,9 +621,9 @@ create_image() [[ $ROOTFS_TYPE == nfs ]] && version=${version}_nfsboot if [[ $ROOTFS_TYPE != nfs ]]; then - display_alert "Copying files to root directory" + display_alert "Copying files to" "/" rsync -aHWXh --exclude="/boot/*" --exclude="/dev/*" --exclude="/proc/*" --exclude="/run/*" --exclude="/tmp/*" \ - --exclude="/sys/*" --info=progress2,stats1 $SDCARD/ $MOUNT/ + --exclude="/sys/*" --info=progress2,stats1 $SDCARD/ $MOUNT/ >> "${DEST}"/debug/install.log 2>&1 else display_alert "Creating rootfs archive" "rootfs.tgz" "info" tar cp --xattrs --directory=$SDCARD/ --exclude='./boot/*' --exclude='./dev/*' --exclude='./proc/*' --exclude='./run/*' --exclude='./tmp/*' \ @@ -629,21 +631,23 @@ create_image() fi # stage: rsync /boot - display_alert "Copying files to /boot directory" + display_alert "Copying files to" "/boot" if [[ $(findmnt --target $MOUNT/boot -o FSTYPE -n) == vfat ]]; then # fat32 - rsync -rLtWh --info=progress2,stats1 $SDCARD/boot $MOUNT + rsync -rLtWh --info=progress2,stats1 $SDCARD/boot $MOUNT >> "${DEST}"/debug/install.log 2>&1 else # ext4 - rsync -aHWXh --info=progress2,stats1 $SDCARD/boot $MOUNT + rsync -aHWXh --info=progress2,stats1 $SDCARD/boot $MOUNT >> "${DEST}"/debug/install.log 2>&1 fi # stage: create final initramfs update_initramfs $MOUNT # DEBUG: print free space - display_alert "Free space:" "SD card" "info" - eval 'df -h' ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/debootstrap.log'} + local freespace=$(LC_ALL=C df -h) + echo $freespace >> $DEST/debug/debootstrap.log + display_alert "SD" "$(echo -e "$freespace" | grep $SDCARD | awk '{print $5}')" "info" + display_alert "Mount point" "$(echo -e "$freespace" | grep $MOUNT | awk '{print $5}')" "info" # stage: write u-boot write_uboot $LOOP diff --git a/lib/distributions.sh b/lib/distributions.sh index cb5c0d551..de5db386d 100644 --- a/lib/distributions.sh +++ b/lib/distributions.sh @@ -8,7 +8,6 @@ # This file is a part of the Armbian build script # https://github.com/armbian/build/ - # Functions: # install_common # install_rclocal @@ -247,7 +246,8 @@ install_common() chroot "${SDCARD}" /bin/bash -c "apt-get -qq -y install linux-u-boot-${BOARD}-${BRANCH}" >> "${DEST}"/debug/install.log 2>&1 # we need package later, move to output, apt-get must be here, apt deletes file UPSTREM_VER=$(dpkg-deb -I "${SDCARD}"/var/cache/apt/archives/linux-u-boot-${BOARD}-${BRANCH}*_${ARCH}.deb | grep Version | awk '{print $(NF)}') - mv "${SDCARD}"/var/cache/apt/archives/linux-u-boot-${BOARD}-${BRANCH}*_${ARCH}.deb ${DEB_STORAGE}/${CHOSEN_UBOOT}_${UPSTREM_VER}_${ARCH}.deb + rsync -rq "${SDCARD}"/var/cache/apt/archives/linux-u-boot-${BOARD}-${BRANCH}*_${ARCH}.deb ${DEB_STORAGE}/${CHOSEN_UBOOT}_${UPSTREM_VER}_${ARCH}.deb + [[ $? -ne 0 ]] && exit_with_error "U-boot linux-u-boot-${BOARD}-${BRANCH}*_${ARCH}.deb download failed" fi # install kernel diff --git a/lib/general.sh b/lib/general.sh index 9db3d4e57..f30ce51a0 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -990,12 +990,12 @@ prepare_host() display_alert "Build host OS release" "${codename:-(unknown)}" "info" # Ubuntu Focal x86_64 is the only fully supported host OS release - # Ubuntu Bionic x86_64 support is legacy until it breaks + # Ubuntu Bionic x86_64 support is no longer supported # Using Docker/VirtualBox/Vagrant is the only supported way to run the build script on other Linux distributions # # NO_HOST_RELEASE_CHECK overrides the check for a supported host system # Disable host OS check at your own risk, any issues reported with unsupported releases will be closed without a discussion - if [[ -z $codename || "bionic buster groovy focal debbie tricia ulyana" != *"$codename"* ]]; then + if [[ -z $codename || "buster groovy focal debbie tricia ulyana" != *"$codename"* ]]; then if [[ $NO_HOST_RELEASE_CHECK == yes ]]; then display_alert "You are running on an unsupported system" "${codename:-(unknown)}" "wrn" display_alert "Do not report any errors, warnings or other issues encountered beyond this point" "" "wrn" diff --git a/lib/makeboarddeb.sh b/lib/makeboarddeb.sh index 88f61b5c4..ac1c13a74 100644 --- a/lib/makeboarddeb.sh +++ b/lib/makeboarddeb.sh @@ -307,7 +307,7 @@ fi display_alert "Building package" "$CHOSEN_ROOTFS" "info" fakeroot dpkg-deb -b "${destination}" "${destination}.deb" >> "${DEST}"/debug/install.log 2>&1 mkdir -p "${DEB_STORAGE}/${RELEASE}/" - mv "${destination}.deb" "${DEB_STORAGE}/${RELEASE}/" + rsync -rq --delete-after "${destination}.deb" "${DEB_STORAGE}/${RELEASE}/" # cleanup rm -rf "${destination}" } diff --git a/patch/kernel/rockchip64-current/0010-arm64-dts-rockchip-add-cw2015-node-to-PBP.patch b/patch/kernel/rockchip64-current/0010-arm64-dts-rockchip-add-cw2015-node-to-PBP.patch deleted file mode 100644 index a0e3f0c1c..000000000 --- a/patch/kernel/rockchip64-current/0010-arm64-dts-rockchip-add-cw2015-node-to-PBP.patch +++ /dev/null @@ -1,56 +0,0 @@ -From bf967280def5ef5fe6e4cf1ce27196a9eb988cf5 Mon Sep 17 00:00:00 2001 -From: Dan Johansen -Date: Sat, 30 May 2020 17:19:41 +0200 -Subject: [PATCH] arm64-dts-rockchip-add-cw2015-node-to-PBP - ---- - .../boot/dts/rockchip/rk3399-pinebook-pro.dts | 26 +++++++++++++++++++ - 1 file changed, 26 insertions(+) - -diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts -index c49982dfd8fc..e814917c013b 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts -+++ b/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts -@@ -28,6 +28,13 @@ backlight: edp-backlight { - pwms = <&pwm0 0 740740 0>; - }; - -+ bat: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <9800000>; -+ voltage-max-design-microvolt = <4350000>; -+ voltage-min-design-microvolt = <3000000>; -+ }; -+ - edp_panel: edp-panel { - compatible = "boe,nv140fhmn49"; - backlight = <&backlight>; -@@ -741,6 +748,25 @@ usbc_dp: endpoint { - }; - }; - }; -+ -+ cw2015@62 { -+ compatible = "cellwise,cw2015"; -+ reg = <0x62>; -+ cellwise,battery-profile = /bits/ 8 < -+ 0x17 0x67 0x80 0x73 0x6E 0x6C 0x6B 0x63 -+ 0x77 0x51 0x5C 0x58 0x50 0x4C 0x48 0x36 -+ 0x15 0x0C 0x0C 0x19 0x5B 0x7D 0x6F 0x69 -+ 0x69 0x5B 0x0C 0x29 0x20 0x40 0x52 0x59 -+ 0x57 0x56 0x54 0x4F 0x3B 0x1F 0x7F 0x17 -+ 0x06 0x1A 0x30 0x5A 0x85 0x93 0x96 0x2D -+ 0x48 0x77 0x9C 0xB3 0x80 0x52 0x94 0xCB -+ 0x2F 0x00 0x64 0xA5 0xB5 0x11 0xF0 0x11 -+ >; -+ cellwise,monitor-interval-ms = <5000>; -+ monitored-battery = <&bat>; -+ power-supplies = <&mains_charger>, <&fusb0>; -+ }; -+ - }; - - &i2s1 { --- -2.26.2 - diff --git a/patch/kernel/rockchip64-current/0015-add-dp-alt-mode-to-PBP.patch b/patch/kernel/rockchip64-current/0015-add-dp-alt-mode-to-PBP.patch index 096f9c596..5cfd048dd 100644 --- a/patch/kernel/rockchip64-current/0015-add-dp-alt-mode-to-PBP.patch +++ b/patch/kernel/rockchip64-current/0015-add-dp-alt-mode-to-PBP.patch @@ -281,13 +281,14 @@ index 82b19ebd7838..6f00b17afc15 100644 pmdata->altmodes, paltmode->svid, paltmode->mode, paltmode->vdo); -@@ -1064,6 +1101,9 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) - if (!altmode) +@@ -1064,7 +1101,9 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port) tcpm_log(port, "Failed to register partner SVID 0x%04x", modep->altmode_desc[i].svid); -+ else + altmode = NULL; +- } ++ } else { + tcpm_log(port, "Registered altmode 0x%04x", modep->altmode_desc[i].svid); -+ ++ } port->partner_altmode[i] = altmode; } } diff --git a/patch/kernel/rockchip64-current/add-board-nanopi-r2s.patch b/patch/kernel/rockchip64-current/add-board-nanopi-r2s.patch index 9902ee5b4..2b7d5f9ae 100644 --- a/patch/kernel/rockchip64-current/add-board-nanopi-r2s.patch +++ b/patch/kernel/rockchip64-current/add-board-nanopi-r2s.patch @@ -422,7 +422,7 @@ index 000000000..36890bb7f + compatible = "regulator-fixed"; + gpio = <&gpio0 30 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; -+ pinctrl-0 = <&sdmmc0m1_gpio>; ++ pinctrl-0 = <&sdmmc0m1_pin>; + regulator-boot-on; + regulator-name = "vcc_sd"; + regulator-min-microvolt = <3300000>; diff --git a/patch/kernel/rockchip64-current/add-board-rockpi-e.patch b/patch/kernel/rockchip64-current/add-board-rockpi-e.patch index a7ad816fd..ac13a8b56 100644 --- a/patch/kernel/rockchip64-current/add-board-rockpi-e.patch +++ b/patch/kernel/rockchip64-current/add-board-rockpi-e.patch @@ -98,7 +98,7 @@ index 000000000..52732643f + compatible = "regulator-fixed"; + gpio = <&gpio0 30 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; -+ pinctrl-0 = <&sdmmc0m1_gpio>; ++ pinctrl-0 = <&sdmmc0m1_pin>; + regulator-name = "vcc_sd"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; diff --git a/patch/kernel/rockchip64-current/add-fusb30x-driver.patch b/patch/kernel/rockchip64-current/add-fusb30x-driver.patch index fa6ca6db3..5dbfaa04b 100644 --- a/patch/kernel/rockchip64-current/add-fusb30x-driver.patch +++ b/patch/kernel/rockchip64-current/add-fusb30x-driver.patch @@ -8,9 +8,9 @@ index 1abf76be2..7ad8b090c 100644 +source "drivers/staging/fusb30x/Kconfig" + - source "drivers/staging/wilc1000/Kconfig" - source "drivers/staging/most/Kconfig" + + source "drivers/staging/ks7010/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe881..2e308d901 100644 --- a/drivers/staging/Makefile @@ -20,9 +20,9 @@ index ab0cbe881..2e308d901 100644 obj-$(CONFIG_FB_TFT) += fbtft/ obj-$(CONFIG_FSL_DPAA2) += fsl-dpaa2/ +obj-$(CONFIG_FUSB_30X) += fusb30x/ - obj-$(CONFIG_WILC1000) += wilc1000/ obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_KS7010) += ks7010/ + obj-$(CONFIG_GREYBUS) += greybus/ diff --git a/drivers/staging/fusb30x/Kconfig b/drivers/staging/fusb30x/Kconfig new file mode 100644 index 000000000..5bb75270f diff --git a/patch/kernel/rockchip64-current/general-disable-mtu-validation.patch b/patch/kernel/rockchip64-current/general-disable-mtu-validation.patch new file mode 100644 index 000000000..c5d9c4e75 --- /dev/null +++ b/patch/kernel/rockchip64-current/general-disable-mtu-validation.patch @@ -0,0 +1,37 @@ +This patch reverts: https://github.com/torvalds/linux/commit/eaf4fac478077d4ed57cbca2c044c4b58a96bd98 + +It works around following issues: + - no way to change MTU (tx_fifo_size is reported as 0 for Rockchip's dwmac) + - no way to set MTU of 1500 (it is aligned to 1536) + +Signed-off-by: Piotr Szczepanik + +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +index 122a06972..951d2281f 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +@@ -3961,24 +3961,12 @@ static void stmmac_set_rx_mode(struct net_device *dev) + static int stmmac_change_mtu(struct net_device *dev, int new_mtu) + { + struct stmmac_priv *priv = netdev_priv(dev); +- int txfifosz = priv->plat->tx_fifo_size; +- +- if (txfifosz == 0) +- txfifosz = priv->dma_cap.tx_fifo_size; +- +- txfifosz /= priv->plat->tx_queues_to_use; + + if (netif_running(dev)) { + netdev_err(priv->dev, "must be stopped to change its MTU\n"); + return -EBUSY; + } + +- new_mtu = STMMAC_ALIGN(new_mtu); +- +- /* If condition true, FIFO is too small or MTU too large */ +- if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB)) +- return -EINVAL; +- + dev->mtu = new_mtu; + + netdev_update_features(dev); diff --git a/patch/kernel/rockchip64-current/general-resolve-regulator-before-create.patch b/patch/kernel/rockchip64-current/general-resolve-regulator-before-create.patch index bc0bb01e1..0f4d3dc4c 100644 --- a/patch/kernel/rockchip64-current/general-resolve-regulator-before-create.patch +++ b/patch/kernel/rockchip64-current/general-resolve-regulator-before-create.patch @@ -4,10 +4,10 @@ that got backported into both 5.8.17 and 5.9.2 Without it rk808 used by all rk3399 boards fails to be probed. diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c -index dababe5b7..18f6d04cd 100644 +index 4859cf84c..b6dcbb779 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c -@@ -5187,20 +5187,15 @@ regulator_register(const struct regulator_desc *regulator_desc, +@@ -5256,20 +5256,15 @@ regulator_register(const struct regulator_desc *regulator_desc, else if (regulator_desc->supply_name) rdev->supply_name = regulator_desc->supply_name; diff --git a/patch/kernel/rockchip64-current/general-rockchip-overlays.patch b/patch/kernel/rockchip64-current/general-rockchip-overlays.patch index c4752abc1..119b188d5 100644 --- a/patch/kernel/rockchip64-current/general-rockchip-overlays.patch +++ b/patch/kernel/rockchip64-current/general-rockchip-overlays.patch @@ -21,6 +21,7 @@ index e69de29..576e190 100644 + rockchip-spi-jedec-nor.dtbo \ + rockchip-spi-spidev.dtbo \ + rockchip-uart4.dtbo \ ++ rockchip-dwc3-0-host.dtbo \ + rockchip-w1-gpio.dtbo + +scr-$(CONFIG_ARCH_ROCKCHIP) += \ @@ -133,6 +134,13 @@ index e69de29..9512445 100644 +Notice: UART4 cannot be activated together with SPI1 - they share the sam pins. +Enabling this overlay disables SPI1. + ++### dwc3-0-host ++ ++Forces port 0 of the DesignWare xHCI controller to host mode. ++ ++This can be used on plaforms such as NanoPC-T4, where devices plugged into the ++USB-C port may not be detected otherwise. ++ +### w1-gpio + +Activates 1-Wire GPIO master @@ -448,6 +456,25 @@ index 0000000..fe8fb14 + }; + }; +}; +diff --git a/arch/arm64/boot/dts/rockchip/overlay/rockchip-dwc3-0-host.dts b/arch/arm64/boot/dts/rockchip/overlay/rockchip-dwc3-0-host.dts +new file mode 100644 +index 0000000..abcd123 +--- /dev/null ++++ b/arch/arm64/boot/dts/rockchip/overlay/rockchip-dwc3-0-host.dts +@@ -0,0 +1,13 @@ ++/dts-v1/; ++/plugin/; ++ ++/ { ++ compatible = "rockchip,rk3399"; ++ ++ fragment@0 { ++ target = <&usbdrd_dwc3_0>; ++ __overlay__ { ++ dr_mode = "host"; ++ }; ++ }; ++}; diff --git a/arch/arm64/boot/dts/rockchip/overlay/rockchip-w1-gpio.dts b/arch/arm64/boot/dts/rockchip/overlay/rockchip-w1-gpio.dts new file mode 100644 index 0000000..bfbc16a diff --git a/patch/kernel/rockchip64-current/rk3328-audio-and-renegade-supplies.patch b/patch/kernel/rockchip64-current/rk3328-audio-and-renegade-supplies.patch index ac254994d..06f9d0410 100644 --- a/patch/kernel/rockchip64-current/rk3328-audio-and-renegade-supplies.patch +++ b/patch/kernel/rockchip64-current/rk3328-audio-and-renegade-supplies.patch @@ -20,7 +20,7 @@ index f4b6799a8..a1041ec3e 100644 - gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_LOW>; + gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; - pinctrl-0 = <&sdmmc0m1_gpio>; + pinctrl-0 = <&sdmmc0m1_pin>; regulator-boot-on; regulator-name = "vcc_sd"; regulator-min-microvolt = <3300000>; diff --git a/patch/kernel/rockchip64-current/rk3328-fix-wrong-mmc-shift.patch b/patch/kernel/rockchip64-current/rk3328-fix-wrong-mmc-shift.patch deleted file mode 100644 index 132e20cd4..000000000 --- a/patch/kernel/rockchip64-current/rk3328-fix-wrong-mmc-shift.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 6376a1b0e30a1d30c4269083fb5b9a146a944ada Mon Sep 17 00:00:00 2001 -From: Ziyuan Xu -Date: Wed, 28 Nov 2018 17:39:50 +0800 -Subject: [PATCH] Revert "clk: rockchip: fix wrong mmc phase shift for rk3328" - -This reverts commit 4ef244988993afc8a6447e990a4ccb4a223d3f20. - -The description for CRU_EMMC/SDMMC/SDIO_CON[0/1] is jumble on -chapters, make it clear that the correct shift is 1 that from -IC engineer. - -Change-Id: I48dce293ec6ef82a5c78db38efc083227776ea99 -Signed-off-by: Ziyuan Xu ---- - drivers/clk/rockchip/clk-rk3328.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/clk/rockchip/clk-rk3328.c b/drivers/clk/rockchip/clk-rk3328.c -index ac6e6163a232..d77925271198 100644 ---- a/drivers/clk/rockchip/clk-rk3328.c -+++ b/drivers/clk/rockchip/clk-rk3328.c -@@ -809,22 +809,22 @@ static struct rockchip_clk_branch rk3328_clk_branches[] __initdata = { - MMC(SCLK_SDMMC_DRV, "sdmmc_drv", "clk_sdmmc", - RK3328_SDMMC_CON0, 1), - MMC(SCLK_SDMMC_SAMPLE, "sdmmc_sample", "clk_sdmmc", -- RK3328_SDMMC_CON1, 0), -+ RK3328_SDMMC_CON1, 1), - - MMC(SCLK_SDIO_DRV, "sdio_drv", "clk_sdio", - RK3328_SDIO_CON0, 1), - MMC(SCLK_SDIO_SAMPLE, "sdio_sample", "clk_sdio", -- RK3328_SDIO_CON1, 0), -+ RK3328_SDIO_CON1, 1), - - MMC(SCLK_EMMC_DRV, "emmc_drv", "clk_emmc", - RK3328_EMMC_CON0, 1), - MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "clk_emmc", -- RK3328_EMMC_CON1, 0), -+ RK3328_EMMC_CON1, 1), - - MMC(SCLK_SDMMC_EXT_DRV, "sdmmc_ext_drv", "clk_sdmmc_ext", - RK3328_SDMMC_EXT_CON0, 1), - MMC(SCLK_SDMMC_EXT_SAMPLE, "sdmmc_ext_sample", "clk_sdmmc_ext", -- RK3328_SDMMC_EXT_CON1, 0), -+ RK3328_SDMMC_EXT_CON1, 1), - }; - - static const char *const rk3328_critical_clocks[] __initconst = { diff --git a/patch/kernel/rockchip64-current/rkvdec_nv15.patch b/patch/kernel/rockchip64-current/rkvdec_nv15.patch index ac531c4fd..26debb3f5 100644 --- a/patch/kernel/rockchip64-current/rkvdec_nv15.patch +++ b/patch/kernel/rockchip64-current/rkvdec_nv15.patch @@ -1,182 +1,3 @@ -From bbfdef43b6f4a65b960ebe6e540233a4c26e9374 Mon Sep 17 00:00:00 2001 -From: Ezequiel Garcia -Date: Fri, 26 Jun 2020 14:11:29 -0300 -Subject: [PATCH 01/18] rkvdec: h264: Refuse to decode unsupported bitstream - -The hardware only supports 4:2:2, 4:2:0 or 4:0:0 (monochrome), -8-bit or 10-bit depth content. - -Verify that the PPS refers to a supported bitstream, and refuse -unsupported bitstreams by failing at TRY_EXT_CTRLS time. - -The driver is currently broken on 10-bit and 4:2:2 -so disallow those as well. - -Signed-off-by: Ezequiel Garcia ---- - drivers/staging/media/rkvdec/rkvdec.c | 27 +++++++++++++++++++++++++++ - 1 file changed, 27 insertions(+) - -diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c -index 225eeca73356..0f81b47792f6 100644 ---- a/drivers/staging/media/rkvdec/rkvdec.c -+++ b/drivers/staging/media/rkvdec/rkvdec.c -@@ -27,6 +27,32 @@ - #include "rkvdec.h" - #include "rkvdec-regs.h" - -+static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) -+{ -+ if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_SPS) { -+ const struct v4l2_ctrl_h264_sps *sps = ctrl->p_cur.p; -+ /* -+ * TODO: The hardware supports 10-bit and 4:2:2 profiles, -+ * but it's currently broken in the driver. -+ * Reject them for now, until it's fixed. -+ */ -+ if (sps->chroma_format_idc > 1) -+ /* Only 4:0:0 and 4:2:0 are supported */ -+ return -EINVAL; -+ if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) -+ /* Luma and chroma bit depth mismatch */ -+ return -EINVAL; -+ if (sps->bit_depth_luma_minus8 != 0) -+ /* Only 8-bit is supported */ -+ return -EINVAL; -+ } -+ return 0; -+} -+ -+static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = { -+ .try_ctrl = rkvdec_try_ctrl, -+}; -+ - static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { - { - .per_request = true, -@@ -42,6 +68,7 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { - .per_request = true, - .mandatory = true, - .cfg.id = V4L2_CID_MPEG_VIDEO_H264_SPS, -+ .cfg.ops = &rkvdec_ctrl_ops, - }, - { - .per_request = true, --- -2.25.1 - - -From 843e3576055776df5cafb3f8e28ea08f9fa71e9a Mon Sep 17 00:00:00 2001 -From: Ezequiel Garcia -Date: Fri, 26 Jun 2020 14:11:30 -0300 -Subject: [PATCH 02/18] hantro: h264: Refuse to decode unsupported bitstream - -The hardware only supports 4:2:0 or 4:0:0 (monochrome), -8-bit depth content. - -Verify that the PPS refers to a supported bitstream, and refuse -unsupported bitstreams by failing at TRY_EXT_CTRLS time. - -Given the JPEG compression level control is the only one -that needs setting, a specific ops is provided. - -Signed-off-by: Ezequiel Garcia ---- - drivers/staging/media/hantro/hantro_drv.c | 29 ++++++++++++++++++++--- - 1 file changed, 26 insertions(+), 3 deletions(-) - -diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c -index 0db8ad455160..361ffaa821ef 100644 ---- a/drivers/staging/media/hantro/hantro_drv.c -+++ b/drivers/staging/media/hantro/hantro_drv.c -@@ -261,7 +261,25 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) - return vb2_queue_init(dst_vq); - } - --static int hantro_s_ctrl(struct v4l2_ctrl *ctrl) -+static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) -+{ -+ if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_SPS) { -+ const struct v4l2_ctrl_h264_sps *sps = ctrl->p_cur.p; -+ -+ if (sps->chroma_format_idc > 1) -+ /* Only 4:0:0 and 4:2:0 are supported */ -+ return -EINVAL; -+ if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) -+ /* Luma and chroma bit depth mismatch */ -+ return -EINVAL; -+ if (sps->bit_depth_luma_minus8 != 0) -+ /* Only 8-bit is supported */ -+ return -EINVAL; -+ } -+ return 0; -+} -+ -+static int hantro_jpeg_s_ctrl(struct v4l2_ctrl *ctrl) - { - struct hantro_ctx *ctx; - -@@ -282,7 +300,11 @@ static int hantro_s_ctrl(struct v4l2_ctrl *ctrl) - } - - static const struct v4l2_ctrl_ops hantro_ctrl_ops = { -- .s_ctrl = hantro_s_ctrl, -+ .try_ctrl = hantro_try_ctrl, -+}; -+ -+static const struct v4l2_ctrl_ops hantro_jpeg_ctrl_ops = { -+ .s_ctrl = hantro_jpeg_s_ctrl, - }; - - static const struct hantro_ctrl controls[] = { -@@ -294,7 +316,7 @@ static const struct hantro_ctrl controls[] = { - .max = 100, - .step = 1, - .def = 50, -- .ops = &hantro_ctrl_ops, -+ .ops = &hantro_jpeg_ctrl_ops, - }, - }, { - .codec = HANTRO_MPEG2_DECODER, -@@ -325,6 +347,7 @@ static const struct hantro_ctrl controls[] = { - .codec = HANTRO_H264_DECODER, - .cfg = { - .id = V4L2_CID_MPEG_VIDEO_H264_SPS, -+ .ops = &hantro_ctrl_ops, - }, - }, { - .codec = HANTRO_H264_DECODER, --- -2.25.1 - - -From 22400b16c3d7af8cf3b044277264cc5fc3a07c54 Mon Sep 17 00:00:00 2001 -From: Jonas Karlman -Date: Sun, 5 Jul 2020 21:48:56 +0000 -Subject: [PATCH 03/18] fixup! rkvdec: h264: Refuse to decode unsupported - bitstream - ---- - drivers/staging/media/rkvdec/rkvdec.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c -index 0f81b47792f6..55dc27171ce4 100644 ---- a/drivers/staging/media/rkvdec/rkvdec.c -+++ b/drivers/staging/media/rkvdec/rkvdec.c -@@ -30,7 +30,7 @@ - static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) - { - if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_SPS) { -- const struct v4l2_ctrl_h264_sps *sps = ctrl->p_cur.p; -+ const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p; - /* - * TODO: The hardware supports 10-bit and 4:2:2 profiles, - * but it's currently broken in the driver. --- -2.25.1 - - From 974229575250290e49d004933cb0aade87fa4566 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 6 Jul 2020 21:54:33 +0000 @@ -294,7 +115,7 @@ index 4ab8f7e0566b..7a9f78bc0a55 100644 + struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl); + if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_SPS) { - const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p; + const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; + unsigned int width, height; /* * TODO: The hardware supports 10-bit and 4:2:2 profiles, @@ -1256,110 +1077,6 @@ index 4faee9262392..b21031535330 100644 2.25.1 -From 4bf8f995e8b6f06db483cee2952de5662bb5cf37 Mon Sep 17 00:00:00 2001 -From: Ben Davis -Date: Mon, 1 Jun 2020 17:28:17 +0100 -Subject: [PATCH 16/18] drm: drm_fourcc: add NV15, Q410, Q401 YUV formats - -DRM_FORMAT_NV15 is a 2 plane format suitable for linear and 16x16 -block-linear memory layouts (DRM_FORMAT_MOD_SAMSUNG_16_16_TILE). The -format is similar to P010 with 4:2:0 sub-sampling but has no padding -between components. Instead, luminance and chrominance samples are -grouped into 4s so that each group is packed into an integer number -of bytes: - -YYYY = UVUV = 4 * 10 bits = 40 bits = 5 bytes - -The '15' suffix refers to the optimum effective bits per pixel which is -achieved when the total number of luminance samples is a multiple of 8. - -Q410 and Q401 are both 3 plane non-subsampled formats with 16 bits per -component, but only 10 bits are used and 6 are padded. 'Q' is chosen -as the first letter to denote 3 plane YUV444, (and is the next letter -along from P which is usually 2 plane). - -V2: Updated block_w of NV15 to {4, 2, 0} -V3: Updated commit message to include specific modifier name - -NV15: -Tested-by: Jonas Karlman - -Reviewed-by: Brian Starkey -Signed-off-by: Ben Davis -Signed-off-by: Liviu Dudau -Link: https://patchwork.freedesktop.org/patch/msgid/20200601162817.18230-1-ben.davis@arm.com ---- - drivers/gpu/drm/drm_fourcc.c | 12 ++++++++++++ - include/uapi/drm/drm_fourcc.h | 22 ++++++++++++++++++++++ - 2 files changed, 34 insertions(+) - -diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c -index b234bfaeda06..722c7ebe4e88 100644 ---- a/drivers/gpu/drm/drm_fourcc.c -+++ b/drivers/gpu/drm/drm_fourcc.c -@@ -274,6 +274,18 @@ const struct drm_format_info *__drm_format_info(u32 format) - { .format = DRM_FORMAT_YUV420_10BIT, .depth = 0, - .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 2, .vsub = 2, - .is_yuv = true }, -+ { .format = DRM_FORMAT_NV15, .depth = 0, -+ .num_planes = 2, .char_per_block = { 5, 5, 0 }, -+ .block_w = { 4, 2, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2, -+ .vsub = 2, .is_yuv = true }, -+ { .format = DRM_FORMAT_Q410, .depth = 0, -+ .num_planes = 3, .char_per_block = { 2, 2, 2 }, -+ .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0, -+ .vsub = 0, .is_yuv = true }, -+ { .format = DRM_FORMAT_Q401, .depth = 0, -+ .num_planes = 3, .char_per_block = { 2, 2, 2 }, -+ .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0, -+ .vsub = 0, .is_yuv = true }, - }; - - unsigned int i; -diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h -index 490143500a50..8ba2d9153a94 100644 ---- a/include/uapi/drm/drm_fourcc.h -+++ b/include/uapi/drm/drm_fourcc.h -@@ -236,6 +236,12 @@ extern "C" { - #define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ - #define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ - #define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ -+/* -+ * 2 plane YCbCr -+ * index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian -+ * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian -+ */ -+#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */ - - /* - * 2 plane YCbCr MSB aligned -@@ -265,6 +271,22 @@ extern "C" { - */ - #define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */ - -+/* 3 plane non-subsampled (444) YCbCr -+ * 16 bits per component, but only 10 bits are used and 6 bits are padded -+ * index 0: Y plane, [15:0] Y:x [10:6] little endian -+ * index 1: Cb plane, [15:0] Cb:x [10:6] little endian -+ * index 2: Cr plane, [15:0] Cr:x [10:6] little endian -+ */ -+#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') -+ -+/* 3 plane non-subsampled (444) YCrCb -+ * 16 bits per component, but only 10 bits are used and 6 bits are padded -+ * index 0: Y plane, [15:0] Y:x [10:6] little endian -+ * index 1: Cr plane, [15:0] Cr:x [10:6] little endian -+ * index 2: Cb plane, [15:0] Cb:x [10:6] little endian -+ */ -+#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') -+ - /* - * 3 plane YCbCr - * index 0: Y plane, [7:0] Y --- -2.25.1 - - From 588b8545dda3cd0ef8f066dcafff3fa7a93e4056 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 6 Jul 2020 22:30:13 +0000 diff --git a/patch/kernel/rockchip64-current/rockpis-0007-arm64-dts-rockchip-add-cpu-s-thermal-config-for-rk33.patch b/patch/kernel/rockchip64-current/rockpis-0007-arm64-dts-rockchip-add-cpu-s-thermal-config-for-rk33.patch index 28da6b243..36ace0791 100644 --- a/patch/kernel/rockchip64-current/rockpis-0007-arm64-dts-rockchip-add-cpu-s-thermal-config-for-rk33.patch +++ b/patch/kernel/rockchip64-current/rockpis-0007-arm64-dts-rockchip-add-cpu-s-thermal-config-for-rk33.patch @@ -73,7 +73,7 @@ index 26af951be980..d2613ec774c1 100644 + resets = <&cru SRST_TSADC>; + reset-names = "tsadc-apb"; + pinctrl-names = "gpio", "otpout"; -+ pinctrl-0 = <&tsadc_otp_gpio>; ++ pinctrl-0 = <&tsadc_otp_pin>; + pinctrl-1 = <&tsadc_otp_out>; + #thermal-sensor-cells = <1>; + rockchip,hw-tshut-temp = <120000>; diff --git a/patch/kernel/rockchip64-current/rockpis-0017-WIP-Sync-rockchip_i2s_tdm-to-BSP-tree.patch b/patch/kernel/rockchip64-current/rockpis-0017-WIP-Sync-rockchip_i2s_tdm-to-BSP-tree.patch index 323447a19..8e70501d2 100644 --- a/patch/kernel/rockchip64-current/rockpis-0017-WIP-Sync-rockchip_i2s_tdm-to-BSP-tree.patch +++ b/patch/kernel/rockchip64-current/rockpis-0017-WIP-Sync-rockchip_i2s_tdm-to-BSP-tree.patch @@ -86,6 +86,7 @@ index e26e72e3315f..db130be87d47 100644 pinctrl-0 = <&i2s_8ch_0_sclktx &i2s_8ch_0_sclkrx diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c +index 61c984f10d8e..e6125ebfe5a9 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -1,4 +1,3 @@ @@ -283,7 +284,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s struct snd_soc_dai *dai) { struct rk_i2s_dev *i2s = to_info(dai); -- struct snd_soc_pcm_runtime *rtd = substream->private_data; +- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); unsigned int val = 0; unsigned int mclk_rate, bclk_rate, div_bclk, div_lrck; @@ -314,7 +315,17 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s return 0; } -@@ -471,7 +500,6 @@ static struct snd_soc_dai_driver rockchip_i2s_dai = { +@@ -419,9 +448,6 @@ static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, + struct rk_i2s_dev *i2s = to_info(cpu_dai); + int ret; + +- if (freq == 0) +- return 0; +- + ret = clk_set_rate(i2s->mclk, freq); + if (ret) + dev_err(i2s->dev, "Fail to set mclk %d\n", ret); +@@ -471,7 +497,6 @@ static struct snd_soc_dai_driver rockchip_i2s_dai = { SNDRV_PCM_FMTBIT_S32_LE), }, .ops = &rockchip_i2s_dai_ops, @@ -322,7 +333,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s }; static const struct snd_soc_component_driver rockchip_i2s_component = { -@@ -567,9 +595,16 @@ static const struct rk_i2s_pins rk3399_i2s_pins = { +@@ -567,9 +592,16 @@ static const struct rk_i2s_pins rk3399_i2s_pins = { }; static const struct of_device_id rockchip_i2s_match[] = { @@ -339,7 +350,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s { .compatible = "rockchip,rk3399-i2s", .data = &rk3399_i2s_pins }, {}, }; -@@ -586,8 +621,10 @@ static int rockchip_i2s_probe(struct platform_device *pdev) +@@ -586,8 +618,10 @@ static int rockchip_i2s_probe(struct platform_device *pdev) int val; i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); @@ -351,7 +362,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s i2s->dev = &pdev->dev; -@@ -600,6 +637,9 @@ static int rockchip_i2s_probe(struct platform_device *pdev) +@@ -600,6 +634,9 @@ static int rockchip_i2s_probe(struct platform_device *pdev) i2s->pins = of_id->data; } @@ -361,7 +372,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s /* try to prepare related clocks */ i2s->hclk = devm_clk_get(&pdev->dev, "i2s_hclk"); if (IS_ERR(i2s->hclk)) { -@@ -633,11 +673,11 @@ static int rockchip_i2s_probe(struct platform_device *pdev) +@@ -633,11 +670,11 @@ static int rockchip_i2s_probe(struct platform_device *pdev) i2s->playback_dma_data.addr = res->start + I2S_TXDR; i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; @@ -375,7 +386,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s dev_set_drvdata(&pdev->dev, i2s); -@@ -648,13 +688,12 @@ static int rockchip_i2s_probe(struct platform_device *pdev) +@@ -648,13 +685,12 @@ static int rockchip_i2s_probe(struct platform_device *pdev) goto err_pm_disable; } @@ -393,7 +404,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s if (!of_property_read_u32(node, "rockchip,playback-channels", &val)) { if (val >= 2 && val <= 8) soc_dai->playback.channels_max = val; -@@ -665,6 +704,24 @@ static int rockchip_i2s_probe(struct platform_device *pdev) +@@ -665,6 +701,24 @@ static int rockchip_i2s_probe(struct platform_device *pdev) soc_dai->capture.channels_max = val; } @@ -418,7 +429,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s ret = devm_snd_soc_register_component(&pdev->dev, &rockchip_i2s_component, soc_dai, 1); -@@ -674,10 +731,12 @@ static int rockchip_i2s_probe(struct platform_device *pdev) +@@ -674,10 +728,12 @@ static int rockchip_i2s_probe(struct platform_device *pdev) goto err_suspend; } @@ -433,7 +444,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s } return 0; -@@ -699,14 +758,41 @@ static int rockchip_i2s_remove(struct platform_device *pdev) +@@ -699,14 +755,41 @@ static int rockchip_i2s_remove(struct platform_device *pdev) if (!pm_runtime_status_suspended(&pdev->dev)) i2s_runtime_suspend(&pdev->dev); @@ -476,6 +487,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s static struct platform_driver rockchip_i2s_driver = { diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c +index 39c1b98f9593..499b991c3c1a 100644 --- a/sound/soc/rockchip/rockchip_i2s_tdm.c +++ b/sound/soc/rockchip/rockchip_i2s_tdm.c @@ -15,9 +15,13 @@ @@ -1850,6 +1862,7 @@ diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip if (ret) { dev_err(&pdev->dev, "Could not register PCM\n"); diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.h b/sound/soc/rockchip/rockchip_i2s_tdm.h +index 1a28523cfd82..3a69fa276f8f 100644 --- a/sound/soc/rockchip/rockchip_i2s_tdm.h +++ b/sound/soc/rockchip/rockchip_i2s_tdm.h @@ -18,6 +18,9 @@ diff --git a/patch/kernel/rockpis-legacy/patch-4.4.228-229.patch b/patch/kernel/rockpis-legacy/patch-4.4.228-229.patch new file mode 100644 index 000000000..376f96f4c --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.228-229.patch @@ -0,0 +1,3339 @@ +diff --git a/Makefile b/Makefile +index 009a36b276f7..99b211904ac5 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 228 ++SUBLEVEL = 229 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c +index 532d4b08276d..fd996187fc5f 100644 +--- a/arch/arm/mach-imx/pm-imx5.c ++++ b/arch/arm/mach-imx/pm-imx5.c +@@ -301,14 +301,14 @@ static int __init imx_suspend_alloc_ocram( + if (!ocram_pool) { + pr_warn("%s: ocram pool unavailable!\n", __func__); + ret = -ENODEV; +- goto put_node; ++ goto put_device; + } + + ocram_base = gen_pool_alloc(ocram_pool, size); + if (!ocram_base) { + pr_warn("%s: unable to alloc ocram!\n", __func__); + ret = -ENOMEM; +- goto put_node; ++ goto put_device; + } + + phys = gen_pool_virt_to_phys(ocram_pool, ocram_base); +@@ -318,6 +318,8 @@ static int __init imx_suspend_alloc_ocram( + if (virt_out) + *virt_out = virt; + ++put_device: ++ put_device(&pdev->dev); + put_node: + of_node_put(node); + +diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c +index 3f62b35fb6f1..815c395a1076 100644 +--- a/arch/arm64/kernel/perf_regs.c ++++ b/arch/arm64/kernel/perf_regs.c +@@ -13,15 +13,34 @@ u64 perf_reg_value(struct pt_regs *regs, int idx) + return 0; + + /* +- * Compat (i.e. 32 bit) mode: +- * - PC has been set in the pt_regs struct in kernel_entry, +- * - Handle SP and LR here. ++ * Our handling of compat tasks (PERF_SAMPLE_REGS_ABI_32) is weird, but ++ * we're stuck with it for ABI compatability reasons. ++ * ++ * For a 32-bit consumer inspecting a 32-bit task, then it will look at ++ * the first 16 registers (see arch/arm/include/uapi/asm/perf_regs.h). ++ * These correspond directly to a prefix of the registers saved in our ++ * 'struct pt_regs', with the exception of the PC, so we copy that down ++ * (x15 corresponds to SP_hyp in the architecture). ++ * ++ * So far, so good. ++ * ++ * The oddity arises when a 64-bit consumer looks at a 32-bit task and ++ * asks for registers beyond PERF_REG_ARM_MAX. In this case, we return ++ * SP_usr, LR_usr and PC in the positions where the AArch64 SP, LR and ++ * PC registers would normally live. The initial idea was to allow a ++ * 64-bit unwinder to unwind a 32-bit task and, although it's not clear ++ * how well that works in practice, somebody might be relying on it. ++ * ++ * At the time we make a sample, we don't know whether the consumer is ++ * 32-bit or 64-bit, so we have to cater for both possibilities. + */ + if (compat_user_mode(regs)) { + if ((u32)idx == PERF_REG_ARM64_SP) + return regs->compat_sp; + if ((u32)idx == PERF_REG_ARM64_LR) + return regs->compat_lr; ++ if (idx == 15) ++ return regs->pc; + } + + if ((u32)idx == PERF_REG_ARM64_SP) +diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S +index c17e8451d997..3fbe420f49c4 100644 +--- a/arch/openrisc/kernel/entry.S ++++ b/arch/openrisc/kernel/entry.S +@@ -1092,13 +1092,13 @@ ENTRY(__sys_clone) + l.movhi r29,hi(sys_clone) + l.ori r29,r29,lo(sys_clone) + l.j _fork_save_extra_regs_and_call +- l.addi r7,r1,0 ++ l.nop + + ENTRY(__sys_fork) + l.movhi r29,hi(sys_fork) + l.ori r29,r29,lo(sys_fork) + l.j _fork_save_extra_regs_and_call +- l.addi r3,r1,0 ++ l.nop + + ENTRY(sys_rt_sigreturn) + l.j _sys_rt_sigreturn +diff --git a/arch/powerpc/include/asm/kprobes.h b/arch/powerpc/include/asm/kprobes.h +index 039b583db029..f0717eedf781 100644 +--- a/arch/powerpc/include/asm/kprobes.h ++++ b/arch/powerpc/include/asm/kprobes.h +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -61,7 +62,7 @@ typedef ppc_opcode_t kprobe_opcode_t; + #define kprobe_lookup_name(name, addr) \ + { \ + char dot_name[MODULE_NAME_LEN + 1 + KSYM_NAME_LEN]; \ +- char *modsym; \ ++ const char *modsym; \ + bool dot_appended = false; \ + if ((modsym = strchr(name, ':')) != NULL) { \ + modsym++; \ +diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c +index 8dff2b371219..a14d9b008f74 100644 +--- a/arch/powerpc/kernel/machine_kexec.c ++++ b/arch/powerpc/kernel/machine_kexec.c +@@ -113,11 +113,12 @@ void machine_kexec(struct kimage *image) + + void __init reserve_crashkernel(void) + { +- unsigned long long crash_size, crash_base; ++ unsigned long long crash_size, crash_base, total_mem_sz; + int ret; + ++ total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size(); + /* use common parsing */ +- ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), ++ ret = parse_crashkernel(boot_command_line, total_mem_sz, + &crash_size, &crash_base); + if (ret == 0 && crash_size > 0) { + crashk_res.start = crash_base; +@@ -176,6 +177,7 @@ void __init reserve_crashkernel(void) + /* Crash kernel trumps memory limit */ + if (memory_limit && memory_limit <= crashk_res.end) { + memory_limit = crashk_res.end + 1; ++ total_mem_sz = memory_limit; + printk("Adjusted memory limit for crashkernel, now 0x%llx\n", + memory_limit); + } +@@ -184,7 +186,7 @@ void __init reserve_crashkernel(void) + "for crashkernel (System RAM: %ldMB)\n", + (unsigned long)(crash_size >> 20), + (unsigned long)(crashk_res.start >> 20), +- (unsigned long)(memblock_phys_mem_size() >> 20)); ++ (unsigned long)(total_mem_sz >> 20)); + + if (!memblock_is_region_memory(crashk_res.start, crash_size) || + memblock_reserve(crashk_res.start, crash_size)) { +diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h +index 6bc941be6921..166fbd74e316 100644 +--- a/arch/s390/include/asm/syscall.h ++++ b/arch/s390/include/asm/syscall.h +@@ -41,7 +41,17 @@ static inline void syscall_rollback(struct task_struct *task, + static inline long syscall_get_error(struct task_struct *task, + struct pt_regs *regs) + { +- return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0; ++ unsigned long error = regs->gprs[2]; ++#ifdef CONFIG_COMPAT ++ if (test_tsk_thread_flag(task, TIF_31BIT)) { ++ /* ++ * Sign-extend the value so (int)-EFOO becomes (long)-EFOO ++ * and will match correctly in comparisons. ++ */ ++ error = (long)(int)error; ++ } ++#endif ++ return IS_ERR_VALUE(error) ? error : 0; + } + + static inline long syscall_get_return_value(struct task_struct *task, +diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c +index 396dbdea0cfa..2f4316c14266 100644 +--- a/arch/sparc/kernel/ptrace_32.c ++++ b/arch/sparc/kernel/ptrace_32.c +@@ -167,12 +167,17 @@ static int genregs32_set(struct task_struct *target, + if (ret || !count) + return ret; + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, +- ®s->y, ++ ®s->npc, + 34 * sizeof(u32), 35 * sizeof(u32)); + if (ret || !count) + return ret; ++ ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ++ ®s->y, ++ 35 * sizeof(u32), 36 * sizeof(u32)); ++ if (ret || !count) ++ return ret; + return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, +- 35 * sizeof(u32), 38 * sizeof(u32)); ++ 36 * sizeof(u32), 38 * sizeof(u32)); + } + + static int fpregs32_get(struct task_struct *target, +diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c +index c1566170964f..829592d5efe0 100644 +--- a/arch/sparc/kernel/ptrace_64.c ++++ b/arch/sparc/kernel/ptrace_64.c +@@ -534,13 +534,8 @@ static int genregs32_get(struct task_struct *target, + ®, sizeof(reg), 0) + != sizeof(reg)) + return -EFAULT; +- if (access_process_vm(target, +- (unsigned long) u, +- ®, sizeof(reg), 1) +- != sizeof(reg)) ++ if (put_user(reg, u++)) + return -EFAULT; +- pos++; +- u++; + } + } + } +@@ -639,11 +634,7 @@ static int genregs32_set(struct task_struct *target, + } + } else { + for (; count > 0 && pos < 32; count--) { +- if (access_process_vm(target, +- (unsigned long) +- u, +- ®, sizeof(reg), 0) +- != sizeof(reg)) ++ if (get_user(reg, u++)) + return -EFAULT; + if (access_process_vm(target, + (unsigned long) +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c +index 7c48aa03fe77..5a6cb30b1c62 100644 +--- a/arch/x86/kernel/kprobes/core.c ++++ b/arch/x86/kernel/kprobes/core.c +@@ -750,6 +750,13 @@ __visible __used void *trampoline_handler(struct pt_regs *regs) + void *frame_pointer; + bool skipped = false; + ++ /* ++ * Set a dummy kprobe for avoiding kretprobe recursion. ++ * Since kretprobe never run in kprobe handler, kprobe must not ++ * be running at this point. ++ */ ++ kprobe_busy_begin(); ++ + INIT_HLIST_HEAD(&empty_rp); + kretprobe_hash_lock(current, &head, &flags); + /* fixup registers */ +@@ -825,10 +832,9 @@ __visible __used void *trampoline_handler(struct pt_regs *regs) + orig_ret_address = (unsigned long)ri->ret_addr; + if (ri->rp && ri->rp->handler) { + __this_cpu_write(current_kprobe, &ri->rp->kp); +- get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE; + ri->ret_addr = correct_ret_addr; + ri->rp->handler(ri, regs); +- __this_cpu_write(current_kprobe, NULL); ++ __this_cpu_write(current_kprobe, &kprobe_busy); + } + + recycle_rp_inst(ri, &empty_rp); +@@ -844,6 +850,8 @@ __visible __used void *trampoline_handler(struct pt_regs *regs) + + kretprobe_hash_unlock(current, &flags); + ++ kprobe_busy_end(); ++ + hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { + hlist_del(&ri->hlist); + kfree(ri); +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index aac60d1605ff..61fc92f92e0a 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -2162,7 +2162,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) + return kvm_mtrr_set_msr(vcpu, msr, data); + case MSR_IA32_APICBASE: + return kvm_set_apic_base(vcpu, msr_info); +- case APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff: ++ case APIC_BASE_MSR ... APIC_BASE_MSR + 0xff: + return kvm_x2apic_msr_write(vcpu, msr, data); + case MSR_IA32_TSCDEADLINE: + kvm_set_lapic_tscdeadline_msr(vcpu, data); +@@ -2432,7 +2432,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) + case MSR_IA32_APICBASE: + msr_info->data = kvm_get_apic_base(vcpu); + break; +- case APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff: ++ case APIC_BASE_MSR ... APIC_BASE_MSR + 0xff: + return kvm_x2apic_msr_read(vcpu, msr_info->index, &msr_info->data); + break; + case MSR_IA32_TSCDEADLINE: +diff --git a/crypto/algboss.c b/crypto/algboss.c +index 6e39d9c05b98..5cbc588555ca 100644 +--- a/crypto/algboss.c ++++ b/crypto/algboss.c +@@ -194,8 +194,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval) + if (IS_ERR(thread)) + goto err_put_larval; + +- wait_for_completion_interruptible(&larval->completion); +- + return NOTIFY_STOP; + + err_put_larval: +diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c +index ef3dfc90e817..13c308323e94 100644 +--- a/drivers/acpi/sysfs.c ++++ b/drivers/acpi/sysfs.c +@@ -776,13 +776,13 @@ static void __exit interrupt_stats_exit(void) + } + + static ssize_t +-acpi_show_profile(struct device *dev, struct device_attribute *attr, ++acpi_show_profile(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) + { + return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile); + } + +-static const struct device_attribute pm_profile_attr = ++static const struct kobj_attribute pm_profile_attr = + __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL); + + static ssize_t hotplug_enabled_show(struct kobject *kobj, +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c +index fc4bf8ff40ea..17cebfe5acc8 100644 +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -56,7 +56,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -6222,7 +6221,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) + /* perform each probe asynchronously */ + for (i = 0; i < host->n_ports; i++) { + struct ata_port *ap = host->ports[i]; +- async_schedule(async_port_probe, ap); ++ ap->cookie = async_schedule(async_port_probe, ap); + } + + return 0; +@@ -6355,11 +6354,11 @@ void ata_host_detach(struct ata_host *host) + { + int i; + +- /* Ensure ata_port probe has completed */ +- async_synchronize_full(); +- +- for (i = 0; i < host->n_ports; i++) ++ for (i = 0; i < host->n_ports; i++) { ++ /* Ensure ata_port probe has completed */ ++ async_synchronize_cookie(host->ports[i]->cookie + 1); + ata_port_detach(host->ports[i]); ++ } + + /* the host is dead now, dissociate ACPI */ + ata_acpi_dissociate(host); +diff --git a/drivers/base/platform.c b/drivers/base/platform.c +index 065fcc4be263..f89cb143f1cd 100644 +--- a/drivers/base/platform.c ++++ b/drivers/base/platform.c +@@ -638,6 +638,8 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv, + /* temporary section violation during probe() */ + drv->probe = probe; + retval = code = __platform_driver_register(drv, module); ++ if (retval) ++ return retval; + + /* + * Fixup that section violation, being paranoid about code scanning +diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c +index c120d70d3fb3..fc7a20286090 100644 +--- a/drivers/block/ps3disk.c ++++ b/drivers/block/ps3disk.c +@@ -464,7 +464,6 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev) + blk_queue_bounce_limit(queue, BLK_BOUNCE_HIGH); + + blk_queue_max_hw_sectors(queue, dev->bounce_size >> 9); +- blk_queue_segment_boundary(queue, -1UL); + blk_queue_dma_alignment(queue, dev->blk_size-1); + blk_queue_logical_block_size(queue, dev->blk_size); + +diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c +index 95a4dd290f35..d7dd0417ef5e 100644 +--- a/drivers/clk/qcom/gcc-msm8916.c ++++ b/drivers/clk/qcom/gcc-msm8916.c +@@ -270,7 +270,7 @@ static struct clk_pll gpll0 = { + .l_reg = 0x21004, + .m_reg = 0x21008, + .n_reg = 0x2100c, +- .config_reg = 0x21014, ++ .config_reg = 0x21010, + .mode_reg = 0x21000, + .status_reg = 0x2101c, + .status_bit = 17, +@@ -297,7 +297,7 @@ static struct clk_pll gpll1 = { + .l_reg = 0x20004, + .m_reg = 0x20008, + .n_reg = 0x2000c, +- .config_reg = 0x20014, ++ .config_reg = 0x20010, + .mode_reg = 0x20000, + .status_reg = 0x2001c, + .status_bit = 17, +@@ -324,7 +324,7 @@ static struct clk_pll gpll2 = { + .l_reg = 0x4a004, + .m_reg = 0x4a008, + .n_reg = 0x4a00c, +- .config_reg = 0x4a014, ++ .config_reg = 0x4a010, + .mode_reg = 0x4a000, + .status_reg = 0x4a01c, + .status_bit = 17, +@@ -351,7 +351,7 @@ static struct clk_pll bimc_pll = { + .l_reg = 0x23004, + .m_reg = 0x23008, + .n_reg = 0x2300c, +- .config_reg = 0x23014, ++ .config_reg = 0x23010, + .mode_reg = 0x23000, + .status_reg = 0x2301c, + .status_bit = 17, +diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c +index 91c89ac193b9..77ae2d21c488 100644 +--- a/drivers/clk/samsung/clk-exynos5433.c ++++ b/drivers/clk/samsung/clk-exynos5433.c +@@ -1708,7 +1708,8 @@ static struct samsung_gate_clock peric_gate_clks[] __initdata = { + GATE(CLK_SCLK_PCM1, "sclk_pcm1", "sclk_pcm1_peric", + ENABLE_SCLK_PERIC, 7, CLK_SET_RATE_PARENT, 0), + GATE(CLK_SCLK_I2S1, "sclk_i2s1", "sclk_i2s1_peric", +- ENABLE_SCLK_PERIC, 6, CLK_SET_RATE_PARENT, 0), ++ ENABLE_SCLK_PERIC, 6, ++ CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0), + GATE(CLK_SCLK_SPI2, "sclk_spi2", "sclk_spi2_peric", ENABLE_SCLK_PERIC, + 5, CLK_SET_RATE_PARENT, 0), + GATE(CLK_SCLK_SPI1, "sclk_spi1", "sclk_spi1_peric", ENABLE_SCLK_PERIC, +diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c +index 9c79af0c03b2..2cec9e83831f 100644 +--- a/drivers/clk/sunxi/clk-sunxi.c ++++ b/drivers/clk/sunxi/clk-sunxi.c +@@ -311,7 +311,7 @@ static void sun6i_a31_get_pll1_factors(u32 *freq, u32 parent_rate, + * Round down the frequency to the closest multiple of either + * 6 or 16 + */ +- u32 round_freq_6 = round_down(freq_mhz, 6); ++ u32 round_freq_6 = rounddown(freq_mhz, 6); + u32 round_freq_16 = round_down(freq_mhz, 16); + + if (round_freq_6 > round_freq_16) +diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c +index dbef218fe5ec..14201c52b44b 100644 +--- a/drivers/clk/ti/composite.c ++++ b/drivers/clk/ti/composite.c +@@ -228,6 +228,7 @@ cleanup: + if (!cclk->comp_clks[i]) + continue; + list_del(&cclk->comp_clks[i]->link); ++ kfree(cclk->comp_clks[i]->parent_names); + kfree(cclk->comp_clks[i]); + } + +diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c +index 341b8c686ec7..4aaaccf95b36 100644 +--- a/drivers/firmware/efi/esrt.c ++++ b/drivers/firmware/efi/esrt.c +@@ -182,7 +182,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num) + rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL, + "%s", name); + if (rc) { +- kfree(entry); ++ kobject_put(&entry->kobj); + return rc; + } + } +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c +index bb25abba7ad0..51cdff2af8b2 100644 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + + #include + +@@ -2647,6 +2648,17 @@ fail: + return ret; + } + ++static int do_get_act_status(struct drm_dp_aux *aux) ++{ ++ int ret; ++ u8 status; ++ ++ ret = drm_dp_dpcd_readb(aux, DP_PAYLOAD_TABLE_UPDATE_STATUS, &status); ++ if (ret < 0) ++ return ret; ++ ++ return status; ++} + + /** + * drm_dp_check_act_status() - Check ACT handled status. +@@ -2656,33 +2668,29 @@ fail: + */ + int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr) + { +- u8 status; +- int ret; +- int count = 0; +- +- do { +- ret = drm_dp_dpcd_readb(mgr->aux, DP_PAYLOAD_TABLE_UPDATE_STATUS, &status); +- +- if (ret < 0) { +- DRM_DEBUG_KMS("failed to read payload table status %d\n", ret); +- goto fail; +- } +- +- if (status & DP_PAYLOAD_ACT_HANDLED) +- break; +- count++; +- udelay(100); +- +- } while (count < 30); +- +- if (!(status & DP_PAYLOAD_ACT_HANDLED)) { +- DRM_DEBUG_KMS("failed to get ACT bit %d after %d retries\n", status, count); +- ret = -EINVAL; +- goto fail; ++ /* ++ * There doesn't seem to be any recommended retry count or timeout in ++ * the MST specification. Since some hubs have been observed to take ++ * over 1 second to update their payload allocations under certain ++ * conditions, we use a rather large timeout value. ++ */ ++ const int timeout_ms = 3000; ++ int ret, status; ++ ++ ret = readx_poll_timeout(do_get_act_status, mgr->aux, status, ++ status & DP_PAYLOAD_ACT_HANDLED || status < 0, ++ 200, timeout_ms * USEC_PER_MSEC); ++ if (ret < 0 && status >= 0) { ++ DRM_DEBUG_KMS("Failed to get ACT after %dms, last status: %02x\n", ++ timeout_ms, status); ++ return -EINVAL; ++ } else if (status < 0) { ++ DRM_DEBUG_KMS("Failed to read payload table status: %d\n", ++ status); ++ return status; + } ++ + return 0; +-fail: +- return ret; + } + EXPORT_SYMBOL(drm_dp_check_act_status); + +diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c +index d18b88b755c3..5c595d9f7e8f 100644 +--- a/drivers/gpu/drm/drm_encoder_slave.c ++++ b/drivers/gpu/drm/drm_encoder_slave.c +@@ -84,7 +84,7 @@ int drm_i2c_encoder_init(struct drm_device *dev, + + err = encoder_drv->encoder_init(client, dev, encoder); + if (err) +- goto fail_unregister; ++ goto fail_module_put; + + if (info->platform_data) + encoder->slave_funcs->set_config(&encoder->base, +@@ -92,9 +92,10 @@ int drm_i2c_encoder_init(struct drm_device *dev, + + return 0; + ++fail_module_put: ++ module_put(module); + fail_unregister: + i2c_unregister_device(client); +- module_put(module); + fail: + return err; + } +diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c +index b2977a181935..e8664a9f1e77 100644 +--- a/drivers/gpu/drm/qxl/qxl_kms.c ++++ b/drivers/gpu/drm/qxl/qxl_kms.c +@@ -199,7 +199,7 @@ static int qxl_device_init(struct qxl_device *qdev, + &(qdev->ram_header->cursor_ring_hdr), + sizeof(struct qxl_command), + QXL_CURSOR_RING_SIZE, +- qdev->io_base + QXL_IO_NOTIFY_CMD, ++ qdev->io_base + QXL_IO_NOTIFY_CURSOR, + false, + &qdev->cursor_event); + +diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c +index c3d531a1114b..14ee1d9a56a7 100644 +--- a/drivers/gpu/drm/radeon/ni_dpm.c ++++ b/drivers/gpu/drm/radeon/ni_dpm.c +@@ -2128,7 +2128,7 @@ static int ni_init_smc_spll_table(struct radeon_device *rdev) + if (clk_s & ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT)) + ret = -EINVAL; + +- if (clk_s & ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT)) ++ if (fb_div & ~(SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT)) + ret = -EINVAL; + + if (clk_v & ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT)) +diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c +index b61db9db3ca5..c85ac178c483 100644 +--- a/drivers/i2c/busses/i2c-piix4.c ++++ b/drivers/i2c/busses/i2c-piix4.c +@@ -647,7 +647,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) + } + + if (dev->vendor == PCI_VENDOR_ID_AMD && +- dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS) { ++ (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS || ++ dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS)) { + retval = piix4_setup_sb800(dev, id, 1); + } + +diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c +index 0d351954db02..8fca6e3dd750 100644 +--- a/drivers/i2c/busses/i2c-pxa.c ++++ b/drivers/i2c/busses/i2c-pxa.c +@@ -297,11 +297,10 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) + dev_err(dev, "IBMR: %08x IDBR: %08x ICR: %08x ISR: %08x\n", + readl(_IBMR(i2c)), readl(_IDBR(i2c)), readl(_ICR(i2c)), + readl(_ISR(i2c))); +- dev_dbg(dev, "log: "); ++ dev_err(dev, "log:"); + for (i = 0; i < i2c->irqlogidx; i++) +- pr_debug("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]); +- +- pr_debug("\n"); ++ pr_cont(" [%03x:%05x]", i2c->isrlog[i], i2c->icrlog[i]); ++ pr_cont("\n"); + } + + #else /* ifdef DEBUG */ +@@ -691,11 +690,9 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c) + { + u32 icr; + +- /* +- * Clear the STOP and ACK flags +- */ ++ /* Clear the START, STOP, ACK, TB and MA flags */ + icr = readl(_ICR(i2c)); +- icr &= ~(ICR_STOP | ICR_ACKNAK); ++ icr &= ~(ICR_START | ICR_STOP | ICR_ACKNAK | ICR_TB | ICR_MA); + writel(icr, _ICR(i2c)); + } + +diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c +index 616173b7a5e8..c26fdcb7dddf 100644 +--- a/drivers/infiniband/core/mad.c ++++ b/drivers/infiniband/core/mad.c +@@ -2912,6 +2912,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info, + DMA_FROM_DEVICE); + if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device, + sg_list.addr))) { ++ kfree(mad_priv); + ret = -ENOMEM; + break; + } +diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c +index 5c93582c71cc..634e9284b7be 100644 +--- a/drivers/md/bcache/btree.c ++++ b/drivers/md/bcache/btree.c +@@ -1375,7 +1375,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, + if (__set_blocks(n1, n1->keys + n2->keys, + block_bytes(b->c)) > + btree_blocks(new_nodes[i])) +- goto out_nocoalesce; ++ goto out_unlock_nocoalesce; + + keys = n2->keys; + /* Take the key of the node we're getting rid of */ +@@ -1404,7 +1404,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, + + if (__bch_keylist_realloc(&keylist, + bkey_u64s(&new_nodes[i]->key))) +- goto out_nocoalesce; ++ goto out_unlock_nocoalesce; + + bch_btree_node_write(new_nodes[i], &cl); + bch_keylist_add(&keylist, &new_nodes[i]->key); +@@ -1450,6 +1450,10 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, + /* Invalidated our iterator */ + return -EINTR; + ++out_unlock_nocoalesce: ++ for (i = 0; i < nodes; i++) ++ mutex_unlock(&new_nodes[i]->write_lock); ++ + out_nocoalesce: + closure_sync(&cl); + bch_keylist_free(&keylist); +diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c +index 7eec619a6023..3d1457189fa2 100644 +--- a/drivers/mfd/wm8994-core.c ++++ b/drivers/mfd/wm8994-core.c +@@ -690,3 +690,4 @@ module_i2c_driver(wm8994_i2c_driver); + MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC"); + MODULE_LICENSE("GPL"); + MODULE_AUTHOR("Mark Brown "); ++MODULE_SOFTDEP("pre: wm8994_regulator"); +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c +index df54475d163b..43bcc19c9068 100644 +--- a/drivers/net/ethernet/atheros/alx/main.c ++++ b/drivers/net/ethernet/atheros/alx/main.c +@@ -872,8 +872,12 @@ out_free_rings: + + static void __alx_stop(struct alx_priv *alx) + { +- alx_halt(alx); + alx_free_irq(alx); ++ ++ cancel_work_sync(&alx->link_check_wk); ++ cancel_work_sync(&alx->reset_wk); ++ ++ alx_halt(alx); + alx_free_rings(alx); + } + +@@ -1406,9 +1410,6 @@ static void alx_remove(struct pci_dev *pdev) + struct alx_priv *alx = pci_get_drvdata(pdev); + struct alx_hw *hw = &alx->hw; + +- cancel_work_sync(&alx->link_check_wk); +- cancel_work_sync(&alx->reset_wk); +- + /* restore permanent mac address */ + alx_set_macaddr(hw, hw->perm_addr); + +diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c +index 58102e96ac5c..e198427d0f29 100644 +--- a/drivers/net/ethernet/broadcom/tg3.c ++++ b/drivers/net/ethernet/broadcom/tg3.c +@@ -18182,8 +18182,8 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev, + + rtnl_lock(); + +- /* We probably don't have netdev yet */ +- if (!netdev || !netif_running(netdev)) ++ /* Could be second call or maybe we don't have netdev yet */ ++ if (!netdev || tp->pcierr_recovery || !netif_running(netdev)) + goto done; + + /* We needn't recover from permanent error */ +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c +index 203f96faf6fb..3bd0bdbdfa0e 100644 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c +@@ -6270,11 +6270,17 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) + struct net_device *netdev = pci_get_drvdata(pdev); + struct e1000_adapter *adapter = netdev_priv(netdev); + struct e1000_hw *hw = &adapter->hw; +- u32 ctrl, ctrl_ext, rctl, status; +- /* Runtime suspend should only enable wakeup for link changes */ +- u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol; ++ u32 ctrl, ctrl_ext, rctl, status, wufc; + int retval = 0; + ++ /* Runtime suspend should only enable wakeup for link changes */ ++ if (runtime) ++ wufc = E1000_WUFC_LNKC; ++ else if (device_may_wakeup(&pdev->dev)) ++ wufc = adapter->wol; ++ else ++ wufc = 0; ++ + status = er32(STATUS); + if (status & E1000_STATUS_LU) + wufc &= ~E1000_WUFC_LNKC; +@@ -6332,7 +6338,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) + e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); + } else if ((hw->mac.type == e1000_pch_lpt) || + (hw->mac.type == e1000_pch_spt)) { +- if (!(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC))) ++ if (wufc && !(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC))) + /* ULP does not support wake from unicast, multicast + * or broadcast. + */ +diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c +index 1a4729c36aa4..623e4225e7c8 100644 +--- a/drivers/net/hamradio/yam.c ++++ b/drivers/net/hamradio/yam.c +@@ -1160,6 +1160,7 @@ static int __init yam_init_driver(void) + err = register_netdev(dev); + if (err) { + printk(KERN_WARNING "yam: cannot register net device %s\n", dev->name); ++ free_netdev(dev); + goto error; + } + yam_devs[i] = dev; +diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c +index e3f2e6098db4..2dcc8a039d42 100644 +--- a/drivers/net/usb/ax88179_178a.c ++++ b/drivers/net/usb/ax88179_178a.c +@@ -1396,10 +1396,10 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) + } + + if (pkt_cnt == 0) { +- /* Skip IP alignment psudo header */ +- skb_pull(skb, 2); + skb->len = pkt_len; +- skb_set_tail_pointer(skb, pkt_len); ++ /* Skip IP alignment pseudo header */ ++ skb_pull(skb, 2); ++ skb_set_tail_pointer(skb, skb->len); + skb->truesize = pkt_len + sizeof(struct sk_buff); + ax88179_rx_checksum(skb, pkt_hdr); + return 1; +@@ -1408,8 +1408,9 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) + ax_skb = skb_clone(skb, GFP_ATOMIC); + if (ax_skb) { + ax_skb->len = pkt_len; +- ax_skb->data = skb->data + 2; +- skb_set_tail_pointer(ax_skb, pkt_len); ++ /* Skip IP alignment pseudo header */ ++ skb_pull(ax_skb, 2); ++ skb_set_tail_pointer(ax_skb, ax_skb->len); + ax_skb->truesize = pkt_len + sizeof(struct sk_buff); + ax88179_rx_checksum(ax_skb, pkt_hdr); + usbnet_skb_return(dev, ax_skb); +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c +index c6a012b5ba39..966b6947e565 100644 +--- a/drivers/pci/pcie/aspm.c ++++ b/drivers/pci/pcie/aspm.c +@@ -388,16 +388,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) + + /* Setup initial capable state. Will be updated later */ + link->aspm_capable = link->aspm_support; +- /* +- * If the downstream component has pci bridge function, don't +- * do ASPM for now. +- */ +- list_for_each_entry(child, &linkbus->devices, bus_list) { +- if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) { +- link->aspm_disable = ASPM_STATE_ALL; +- break; +- } +- } + + /* Get and check endpoint acceptable latencies */ + list_for_each_entry(child, &linkbus->devices, bus_list) { +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index 83ad32b07cc3..ab161bbeb4d4 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -1624,6 +1624,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quir + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch); + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_pcie_mch); + ++DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI, 8, quirk_pcie_mch); + + /* + * It's possible for the MSI to get corrupted if shpc and acpi +diff --git a/drivers/power/smb347-charger.c b/drivers/power/smb347-charger.c +index 072c5189bd6d..0655dbdc7000 100644 +--- a/drivers/power/smb347-charger.c ++++ b/drivers/power/smb347-charger.c +@@ -1141,6 +1141,7 @@ static bool smb347_volatile_reg(struct device *dev, unsigned int reg) + switch (reg) { + case IRQSTAT_A: + case IRQSTAT_C: ++ case IRQSTAT_D: + case IRQSTAT_E: + case IRQSTAT_F: + case STAT_A: +diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h +index 7e70f9298cc1..11f6ebd04545 100644 +--- a/drivers/s390/cio/qdio.h ++++ b/drivers/s390/cio/qdio.h +@@ -376,7 +376,6 @@ static inline int multicast_outbound(struct qdio_q *q) + extern u64 last_ai_time; + + /* prototypes for thin interrupt */ +-void qdio_setup_thinint(struct qdio_irq *irq_ptr); + int qdio_establish_thinint(struct qdio_irq *irq_ptr); + void qdio_shutdown_thinint(struct qdio_irq *irq_ptr); + void tiqdio_add_input_queues(struct qdio_irq *irq_ptr); +diff --git a/drivers/s390/cio/qdio_setup.c b/drivers/s390/cio/qdio_setup.c +index d0090c5c88e7..a64615a10352 100644 +--- a/drivers/s390/cio/qdio_setup.c ++++ b/drivers/s390/cio/qdio_setup.c +@@ -479,7 +479,6 @@ int qdio_setup_irq(struct qdio_initialize *init_data) + setup_queues(irq_ptr, init_data); + + setup_qib(irq_ptr, init_data); +- qdio_setup_thinint(irq_ptr); + set_impl_params(irq_ptr, init_data->qib_param_field_format, + init_data->qib_param_field, + init_data->input_slib_elements, +diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c +index debe69adfc70..aecb6445a567 100644 +--- a/drivers/s390/cio/qdio_thinint.c ++++ b/drivers/s390/cio/qdio_thinint.c +@@ -268,17 +268,19 @@ int __init tiqdio_register_thinints(void) + + int qdio_establish_thinint(struct qdio_irq *irq_ptr) + { ++ int rc; ++ + if (!is_thinint_irq(irq_ptr)) + return 0; +- return set_subchannel_ind(irq_ptr, 0); +-} + +-void qdio_setup_thinint(struct qdio_irq *irq_ptr) +-{ +- if (!is_thinint_irq(irq_ptr)) +- return; + irq_ptr->dsci = get_indicator(); + DBF_HEX(&irq_ptr->dsci, sizeof(void *)); ++ ++ rc = set_subchannel_ind(irq_ptr, 0); ++ if (rc) ++ put_indicator(irq_ptr->dsci); ++ ++ return rc; + } + + void qdio_shutdown_thinint(struct qdio_irq *irq_ptr) +diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c +index deaaf84989cd..be595add8026 100644 +--- a/drivers/scsi/arm/acornscsi.c ++++ b/drivers/scsi/arm/acornscsi.c +@@ -2912,8 +2912,10 @@ static int acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id) + + ashost->base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); + ashost->fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); +- if (!ashost->base || !ashost->fast) ++ if (!ashost->base || !ashost->fast) { ++ ret = -ENOMEM; + goto out_put; ++ } + + host->irq = ec->irq; + ashost->host = host; +diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c +index e26747a1b35a..e7075aae15da 100644 +--- a/drivers/scsi/ibmvscsi/ibmvscsi.c ++++ b/drivers/scsi/ibmvscsi/ibmvscsi.c +@@ -427,6 +427,8 @@ static int ibmvscsi_reenable_crq_queue(struct crq_queue *queue, + int rc = 0; + struct vio_dev *vdev = to_vio_dev(hostdata->dev); + ++ set_adapter_info(hostdata); ++ + /* Re-enable the CRQ */ + do { + if (rc) +diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c +index 680bf6f0ce76..476f46aad54c 100644 +--- a/drivers/scsi/iscsi_boot_sysfs.c ++++ b/drivers/scsi/iscsi_boot_sysfs.c +@@ -319,7 +319,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset, + boot_kobj->kobj.kset = boot_kset->kset; + if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype, + NULL, name, index)) { +- kfree(boot_kobj); ++ kobject_put(&boot_kobj->kobj); + return NULL; + } + boot_kobj->data = data; +diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c +index 530b7df21322..315dd25a0c44 100644 +--- a/drivers/scsi/lpfc/lpfc_els.c ++++ b/drivers/scsi/lpfc/lpfc_els.c +@@ -7315,6 +7315,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, + spin_lock_irq(shost->host_lock); + if (ndlp->nlp_flag & NLP_IN_DEV_LOSS) { + spin_unlock_irq(shost->host_lock); ++ if (newnode) ++ lpfc_nlp_put(ndlp); + goto dropit; + } + spin_unlock_irq(shost->host_lock); +diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c +index 7af7a0859478..8d52afd1f71d 100644 +--- a/drivers/scsi/mpt3sas/mpt3sas_base.c ++++ b/drivers/scsi/mpt3sas/mpt3sas_base.c +@@ -3136,7 +3136,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) + ioc->scsi_lookup = NULL; + } + kfree(ioc->hpr_lookup); ++ ioc->hpr_lookup = NULL; + kfree(ioc->internal_lookup); ++ ioc->internal_lookup = NULL; + if (ioc->chain_lookup) { + for (i = 0; i < ioc->chain_depth; i++) { + if (ioc->chain_lookup[i].chain_buffer) +diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c +index b1233ce6cb47..1cef25ea0da1 100644 +--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c ++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c +@@ -827,6 +827,7 @@ static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item, + + atomic_set(&tpg->lport_tpg_enabled, 0); + qlt_stop_phase1(vha->vha_tgt.qla_tgt); ++ qlt_stop_phase2(vha->vha_tgt.qla_tgt); + } + + return count; +@@ -990,6 +991,7 @@ static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item, + + atomic_set(&tpg->lport_tpg_enabled, 0); + qlt_stop_phase1(vha->vha_tgt.qla_tgt); ++ qlt_stop_phase2(vha->vha_tgt.qla_tgt); + } + + return count; +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c +index 4055cb7c212b..3a9b6b61607e 100644 +--- a/drivers/scsi/scsi_devinfo.c ++++ b/drivers/scsi/scsi_devinfo.c +@@ -443,7 +443,8 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, + /* + * vendor strings must be an exact match + */ +- if (vmax != strlen(devinfo->vendor) || ++ if (vmax != strnlen(devinfo->vendor, ++ sizeof(devinfo->vendor)) || + memcmp(devinfo->vendor, vskip, vmax)) + continue; + +@@ -451,7 +452,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, + * @model specifies the full string, and + * must be larger or equal to devinfo->model + */ +- mlen = strlen(devinfo->model); ++ mlen = strnlen(devinfo->model, sizeof(devinfo->model)); + if (mmax < mlen || memcmp(devinfo->model, mskip, mlen)) + continue; + return devinfo; +diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c +index 5dc288fecace..7dd4d9ded249 100644 +--- a/drivers/scsi/sr.c ++++ b/drivers/scsi/sr.c +@@ -746,7 +746,7 @@ static int sr_probe(struct device *dev) + cd->cdi.disk = disk; + + if (register_cdrom(&cd->cdi)) +- goto fail_put; ++ goto fail_minor; + + /* + * Initialize block layer runtime PM stuffs before the +@@ -764,6 +764,10 @@ static int sr_probe(struct device *dev) + + return 0; + ++fail_minor: ++ spin_lock(&sr_index_lock); ++ clear_bit(minor, sr_index_bits); ++ spin_unlock(&sr_index_lock); + fail_put: + put_disk(disk); + fail_free: +diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c +index 860e1c288ad5..75b47d61318a 100644 +--- a/drivers/staging/sm750fb/sm750.c ++++ b/drivers/staging/sm750fb/sm750.c +@@ -894,6 +894,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) + fix->visual = FB_VISUAL_PSEUDOCOLOR; + break; + case 16: ++ case 24: + case 32: + fix->visual = FB_VISUAL_TRUECOLOR; + break; +diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c +index acf6d143c753..81f23af8beca 100644 +--- a/drivers/tty/hvc/hvc_console.c ++++ b/drivers/tty/hvc/hvc_console.c +@@ -89,6 +89,8 @@ static LIST_HEAD(hvc_structs); + */ + static DEFINE_SPINLOCK(hvc_structs_lock); + ++/* Mutex to serialize hvc_open */ ++static DEFINE_MUTEX(hvc_open_mutex); + /* + * This value is used to assign a tty->index value to a hvc_struct based + * upon order of exposure via hvc_probe(), when we can not match it to +@@ -333,16 +335,24 @@ static int hvc_install(struct tty_driver *driver, struct tty_struct *tty) + */ + static int hvc_open(struct tty_struct *tty, struct file * filp) + { +- struct hvc_struct *hp = tty->driver_data; ++ struct hvc_struct *hp; + unsigned long flags; + int rc = 0; + ++ mutex_lock(&hvc_open_mutex); ++ ++ hp = tty->driver_data; ++ if (!hp) { ++ rc = -EIO; ++ goto out; ++ } ++ + spin_lock_irqsave(&hp->port.lock, flags); + /* Check and then increment for fast path open. */ + if (hp->port.count++ > 0) { + spin_unlock_irqrestore(&hp->port.lock, flags); + hvc_kick(); +- return 0; ++ goto out; + } /* else count == 0 */ + spin_unlock_irqrestore(&hp->port.lock, flags); + +@@ -371,6 +381,8 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) + /* Force wakeup of the polling thread */ + hvc_kick(); + ++out: ++ mutex_unlock(&hvc_open_mutex); + return rc; + } + +diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c +index 6060c3e8925e..9b2beada2ff3 100644 +--- a/drivers/tty/n_gsm.c ++++ b/drivers/tty/n_gsm.c +@@ -681,11 +681,10 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len, + * FIXME: lock against link layer control transmissions + */ + +-static void gsm_data_kick(struct gsm_mux *gsm) ++static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci) + { + struct gsm_msg *msg, *nmsg; + int len; +- int skip_sof = 0; + + list_for_each_entry_safe(msg, nmsg, &gsm->tx_list, list) { + if (gsm->constipated && msg->addr) +@@ -707,18 +706,23 @@ static void gsm_data_kick(struct gsm_mux *gsm) + print_hex_dump_bytes("gsm_data_kick: ", + DUMP_PREFIX_OFFSET, + gsm->txframe, len); +- +- if (gsm->output(gsm, gsm->txframe + skip_sof, +- len - skip_sof) < 0) ++ if (gsm->output(gsm, gsm->txframe, len) < 0) + break; + /* FIXME: Can eliminate one SOF in many more cases */ + gsm->tx_bytes -= msg->len; +- /* For a burst of frames skip the extra SOF within the +- burst */ +- skip_sof = 1; + + list_del(&msg->list); + kfree(msg); ++ ++ if (dlci) { ++ tty_port_tty_wakeup(&dlci->port); ++ } else { ++ int i = 0; ++ ++ for (i = 0; i < NUM_DLCI; i++) ++ if (gsm->dlci[i]) ++ tty_port_tty_wakeup(&gsm->dlci[i]->port); ++ } + } + } + +@@ -770,7 +774,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg) + /* Add to the actual output queue */ + list_add_tail(&msg->list, &gsm->tx_list); + gsm->tx_bytes += msg->len; +- gsm_data_kick(gsm); ++ gsm_data_kick(gsm, dlci); + } + + /** +@@ -1231,7 +1235,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, + gsm_control_reply(gsm, CMD_FCON, NULL, 0); + /* Kick the link in case it is idling */ + spin_lock_irqsave(&gsm->tx_lock, flags); +- gsm_data_kick(gsm); ++ gsm_data_kick(gsm, NULL); + spin_unlock_irqrestore(&gsm->tx_lock, flags); + break; + case CMD_FCOFF: +@@ -2429,7 +2433,7 @@ static void gsmld_write_wakeup(struct tty_struct *tty) + /* Queue poll */ + clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); + spin_lock_irqsave(&gsm->tx_lock, flags); +- gsm_data_kick(gsm); ++ gsm_data_kick(gsm, NULL); + if (gsm->tx_bytes < TX_THRESH_LO) { + gsm_dlci_data_sweep(gsm); + } +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c +index 899a77187bde..c5da46f7b909 100644 +--- a/drivers/tty/serial/amba-pl011.c ++++ b/drivers/tty/serial/amba-pl011.c +@@ -2323,6 +2323,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap, + uap->port.fifosize = uap->fifosize; + uap->port.flags = UPF_BOOT_AUTOCONF; + uap->port.line = index; ++ spin_lock_init(&uap->port.lock); + + amba_ports[index] = uap; + +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c +index 04fd6c8e3090..515839034dfb 100644 +--- a/drivers/usb/class/cdc-acm.c ++++ b/drivers/usb/class/cdc-acm.c +@@ -1684,6 +1684,8 @@ static int acm_reset_resume(struct usb_interface *intf) + + static const struct usb_device_id acm_ids[] = { + /* quirky and broken devices */ ++ { USB_DEVICE(0x0424, 0x274e), /* Microchip Technology, Inc. (formerly SMSC) */ ++ .driver_info = DISABLE_ECHO, }, /* DISABLE ECHO in termios flag */ + { USB_DEVICE(0x076d, 0x0006), /* Denso Cradle CU-321 */ + .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */ + { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */ +diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c +index 07c3c3449147..c578d64edc15 100644 +--- a/drivers/usb/class/usblp.c ++++ b/drivers/usb/class/usblp.c +@@ -481,7 +481,8 @@ static int usblp_release(struct inode *inode, struct file *file) + usb_autopm_put_interface(usblp->intf); + + if (!usblp->present) /* finish cleanup from disconnect */ +- usblp_cleanup(usblp); ++ usblp_cleanup(usblp); /* any URBs must be dead */ ++ + mutex_unlock(&usblp_mutex); + return 0; + } +@@ -1397,9 +1398,11 @@ static void usblp_disconnect(struct usb_interface *intf) + + usblp_unlink_urbs(usblp); + mutex_unlock(&usblp->mut); ++ usb_poison_anchored_urbs(&usblp->urbs); + + if (!usblp->used) + usblp_cleanup(usblp); ++ + mutex_unlock(&usblp_mutex); + } + +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c +index 27d05f0134de..e6e0f786547b 100644 +--- a/drivers/usb/core/quirks.c ++++ b/drivers/usb/core/quirks.c +@@ -73,11 +73,12 @@ static const struct usb_device_id usb_quirk_list[] = { + /* Logitech HD Webcam C270 */ + { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME }, + +- /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */ ++ /* Logitech HD Pro Webcams C920, C920-C, C922, C925e and C930e */ + { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT }, ++ { USB_DEVICE(0x046d, 0x085c), .driver_info = USB_QUIRK_DELAY_INIT }, + + /* Logitech ConferenceCam CC3000e */ + { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT }, +diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c +index ea43cb74a6f2..c9590949e4f0 100644 +--- a/drivers/usb/gadget/udc/lpc32xx_udc.c ++++ b/drivers/usb/gadget/udc/lpc32xx_udc.c +@@ -1662,17 +1662,17 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep, + const struct usb_endpoint_descriptor *desc) + { + struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep); +- struct lpc32xx_udc *udc = ep->udc; ++ struct lpc32xx_udc *udc; + u16 maxpacket; + u32 tmp; + unsigned long flags; + + /* Verify EP data */ + if ((!_ep) || (!ep) || (!desc) || +- (desc->bDescriptorType != USB_DT_ENDPOINT)) { +- dev_dbg(udc->dev, "bad ep or descriptor\n"); ++ (desc->bDescriptorType != USB_DT_ENDPOINT)) + return -EINVAL; +- } ++ ++ udc = ep->udc; + maxpacket = usb_endpoint_maxp(desc); + if ((maxpacket == 0) || (maxpacket > ep->maxpacket)) { + dev_dbg(udc->dev, "bad ep descriptor's packet size\n"); +@@ -1920,7 +1920,7 @@ static int lpc32xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) + static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value) + { + struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep); +- struct lpc32xx_udc *udc = ep->udc; ++ struct lpc32xx_udc *udc; + unsigned long flags; + + if ((!ep) || (ep->hwep_num <= 1)) +@@ -1930,6 +1930,7 @@ static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value) + if (ep->is_in) + return -EAGAIN; + ++ udc = ep->udc; + spin_lock_irqsave(&udc->lock, flags); + + if (value == 1) { +diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c +index b1cfa96cc88f..db95eab8b432 100644 +--- a/drivers/usb/gadget/udc/m66592-udc.c ++++ b/drivers/usb/gadget/udc/m66592-udc.c +@@ -1684,7 +1684,7 @@ static int m66592_probe(struct platform_device *pdev) + + err_add_udc: + m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); +- ++ m66592->ep0_req = NULL; + clean_up3: + if (m66592->pdata->on_chip) { + clk_disable(m66592->clk); +diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c +index 81b6229c7805..4f480059f851 100644 +--- a/drivers/usb/gadget/udc/mv_udc_core.c ++++ b/drivers/usb/gadget/udc/mv_udc_core.c +@@ -2322,7 +2322,8 @@ static int mv_udc_probe(struct platform_device *pdev) + return 0; + + err_create_workqueue: +- destroy_workqueue(udc->qwork); ++ if (udc->qwork) ++ destroy_workqueue(udc->qwork); + err_destroy_dma: + dma_pool_destroy(udc->dtd_pool); + err_free_dma: +diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c +index eb3571ee59e3..08153a48704b 100644 +--- a/drivers/usb/gadget/udc/s3c2410_udc.c ++++ b/drivers/usb/gadget/udc/s3c2410_udc.c +@@ -269,10 +269,6 @@ static void s3c2410_udc_done(struct s3c2410_ep *ep, + static void s3c2410_udc_nuke(struct s3c2410_udc *udc, + struct s3c2410_ep *ep, int status) + { +- /* Sanity check */ +- if (&ep->queue == NULL) +- return; +- + while (!list_empty(&ep->queue)) { + struct s3c2410_request *req; + req = list_entry(ep->queue.next, struct s3c2410_request, +diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c +index 46f5354c534d..3b5a28f43ef9 100644 +--- a/drivers/usb/host/ehci-exynos.c ++++ b/drivers/usb/host/ehci-exynos.c +@@ -199,9 +199,8 @@ skip_phy: + hcd->rsrc_len = resource_size(res); + + irq = platform_get_irq(pdev, 0); +- if (!irq) { +- dev_err(&pdev->dev, "Failed to get IRQ\n"); +- err = -ENODEV; ++ if (irq < 0) { ++ err = irq; + goto fail_io; + } + +diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c +index c7a9b31eeaef..637079a35003 100644 +--- a/drivers/usb/host/ehci-mxc.c ++++ b/drivers/usb/host/ehci-mxc.c +@@ -63,6 +63,8 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) + } + + irq = platform_get_irq(pdev, 0); ++ if (irq < 0) ++ return irq; + + hcd = usb_create_hcd(&ehci_mxc_hc_driver, dev, dev_name(dev)); + if (!hcd) +diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c +index 2a5d2fd76040..33e9ed7fe026 100644 +--- a/drivers/usb/host/ehci-pci.c ++++ b/drivers/usb/host/ehci-pci.c +@@ -229,6 +229,13 @@ static int ehci_pci_setup(struct usb_hcd *hcd) + ehci_info(ehci, "applying MosChip frame-index workaround\n"); + ehci->frame_index_bug = 1; + break; ++ case PCI_VENDOR_ID_HUAWEI: ++ /* Synopsys HC bug */ ++ if (pdev->device == 0xa239) { ++ ehci_info(ehci, "applying Synopsys HC workaround\n"); ++ ehci->has_synopsys_hc_bug = 1; ++ } ++ break; + } + + /* optional debug port, normally in the first BAR */ +diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c +index bd7082f297bb..56200650b46b 100644 +--- a/drivers/usb/host/ehci-platform.c ++++ b/drivers/usb/host/ehci-platform.c +@@ -375,6 +375,11 @@ static int ehci_platform_resume(struct device *dev) + } + + ehci_resume(hcd, priv->reset_on_resume); ++ ++ pm_runtime_disable(dev); ++ pm_runtime_set_active(dev); ++ pm_runtime_enable(dev); ++ + return 0; + } + #endif /* CONFIG_PM_SLEEP */ +diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c +index c2669f185f65..0e5580e6f35c 100644 +--- a/drivers/usb/host/ohci-platform.c ++++ b/drivers/usb/host/ohci-platform.c +@@ -339,6 +339,11 @@ static int ohci_platform_resume(struct device *dev) + } + + ohci_resume(hcd, false); ++ ++ pm_runtime_disable(dev); ++ pm_runtime_set_active(dev); ++ pm_runtime_enable(dev); ++ + return 0; + } + #endif /* CONFIG_PM_SLEEP */ +diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c +index a8b8d8b8d9f3..a960d2bb8dd1 100644 +--- a/drivers/usb/host/ohci-sm501.c ++++ b/drivers/usb/host/ohci-sm501.c +@@ -196,6 +196,7 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev) + struct resource *mem; + + usb_remove_hcd(hcd); ++ iounmap(hcd->regs); + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); + usb_put_hcd(hcd); + dma_release_declared_memory(&pdev->dev); +diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c +index c4c40e9d4247..510fb7853f92 100644 +--- a/drivers/usb/host/xhci-plat.c ++++ b/drivers/usb/host/xhci-plat.c +@@ -249,8 +249,17 @@ static int xhci_plat_resume(struct device *dev) + { + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct xhci_hcd *xhci = hcd_to_xhci(hcd); ++ int ret; ++ ++ ret = xhci_resume(xhci, 0); ++ if (ret) ++ return ret; + +- return xhci_resume(xhci, 0); ++ pm_runtime_disable(dev); ++ pm_runtime_set_active(dev); ++ pm_runtime_enable(dev); ++ ++ return 0; + } + + static const struct dev_pm_ops xhci_plat_pm_ops = { +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c +index af4e68152776..51d84332eb78 100644 +--- a/drivers/usb/host/xhci.c ++++ b/drivers/usb/host/xhci.c +@@ -1340,6 +1340,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, + xhci->devs[slot_id]->out_ctx, ep_index); + + ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index); ++ ep_ctx->ep_info &= cpu_to_le32(~EP_STATE_MASK);/* must clear */ + ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK); + ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size)); + +@@ -4263,6 +4264,9 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, + mutex_lock(hcd->bandwidth_mutex); + xhci_change_max_exit_latency(xhci, udev, 0); + mutex_unlock(hcd->bandwidth_mutex); ++ readl_poll_timeout(port_array[port_num], pm_val, ++ (pm_val & PORT_PLS_MASK) == XDEV_U0, ++ 100, 10000); + return 0; + } + } +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h +index 0a3aa38b3c96..a7f346529f91 100644 +--- a/drivers/usb/host/xhci.h ++++ b/drivers/usb/host/xhci.h +@@ -706,7 +706,7 @@ struct xhci_ep_ctx { + * 4 - TRB error + * 5-7 - reserved + */ +-#define EP_STATE_MASK (0xf) ++#define EP_STATE_MASK (0x7) + #define EP_STATE_DISABLED 0 + #define EP_STATE_RUNNING 1 + #define EP_STATE_HALTED 2 +diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c +index 98a12be76c9c..666b234acca0 100644 +--- a/drivers/vfio/pci/vfio_pci_config.c ++++ b/drivers/vfio/pci/vfio_pci_config.c +@@ -1405,7 +1405,12 @@ static int vfio_cap_init(struct vfio_pci_device *vdev) + if (ret) + return ret; + +- if (cap <= PCI_CAP_ID_MAX) { ++ /* ++ * ID 0 is a NULL capability, conflicting with our fake ++ * PCI_CAP_ID_BASIC. As it has no content, consider it ++ * hidden for now. ++ */ ++ if (cap && cap <= PCI_CAP_ID_MAX) { + len = pci_cap_length[cap]; + if (len == 0xFF) { /* Variable length */ + len = vfio_cap_len(vdev, cap, pos); +@@ -1644,8 +1649,11 @@ void vfio_config_free(struct vfio_pci_device *vdev) + vdev->vconfig = NULL; + kfree(vdev->pci_config_map); + vdev->pci_config_map = NULL; +- kfree(vdev->msi_perm); +- vdev->msi_perm = NULL; ++ if (vdev->msi_perm) { ++ free_perm_bits(vdev->msi_perm); ++ kfree(vdev->msi_perm); ++ vdev->msi_perm = NULL; ++ } + } + + /* +diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c +index daeb645fcea8..519419136ce8 100644 +--- a/drivers/watchdog/da9062_wdt.c ++++ b/drivers/watchdog/da9062_wdt.c +@@ -94,11 +94,6 @@ static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt, + unsigned int regval) + { + struct da9062 *chip = wdt->hw; +- int ret; +- +- ret = da9062_reset_watchdog_timer(wdt); +- if (ret) +- return ret; + + return regmap_update_bits(chip->regmap, + DA9062AA_CONTROL_D, +diff --git a/fs/block_dev.c b/fs/block_dev.c +index 26bbaaefdff4..b2ebfd96785b 100644 +--- a/fs/block_dev.c ++++ b/fs/block_dev.c +@@ -1181,10 +1181,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) + */ + if (!for_part) { + ret = devcgroup_inode_permission(bdev->bd_inode, perm); +- if (ret != 0) { +- bdput(bdev); ++ if (ret != 0) + return ret; +- } + } + + restart: +@@ -1253,8 +1251,10 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) + goto out_clear; + BUG_ON(for_part); + ret = __blkdev_get(whole, mode, 1); +- if (ret) ++ if (ret) { ++ bdput(whole); + goto out_clear; ++ } + bdev->bd_contains = whole; + bdev->bd_part = disk_get_part(disk, partno); + if (!(disk->flags & GENHD_FL_UP) || +@@ -1311,7 +1311,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) + put_disk(disk); + module_put(owner); + out: +- bdput(bdev); + + return ret; + } +@@ -1397,6 +1396,9 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) + bdput(whole); + } + ++ if (res) ++ bdput(bdev); ++ + return res; + } + EXPORT_SYMBOL(blkdev_get); +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c +index 0fcf42401a5d..087261ca6d46 100644 +--- a/fs/cifs/smb2ops.c ++++ b/fs/cifs/smb2ops.c +@@ -1145,6 +1145,12 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, + inode = d_inode(cfile->dentry); + cifsi = CIFS_I(inode); + ++ /* ++ * We zero the range through ioctl, so we need remove the page caches ++ * first, otherwise the data may be inconsistent with the server. ++ */ ++ truncate_pagecache_range(inode, offset, offset + len - 1); ++ + /* if file not oplocked can't be sure whether asking to extend size */ + if (!CIFS_CACHE_READ(cifsi)) + if (keep_size == false) +@@ -1201,6 +1207,12 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, + if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse)) + return -EOPNOTSUPP; + ++ /* ++ * We implement the punch hole through ioctl, so we need remove the page ++ * caches first, otherwise the data may be inconsistent with the server. ++ */ ++ truncate_pagecache_range(inode, offset, offset + len - 1); ++ + cifs_dbg(FYI, "offset %lld len %lld", offset, len); + + fsctl_buf.FileOffset = cpu_to_le64(offset); +diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h +index 5eff6ea3e27f..63e856d90ed0 100644 +--- a/fs/dlm/dlm_internal.h ++++ b/fs/dlm/dlm_internal.h +@@ -92,7 +92,6 @@ do { \ + __LINE__, __FILE__, #x, jiffies); \ + {do} \ + printk("\n"); \ +- BUG(); \ + panic("DLM: Record message above and reboot.\n"); \ + } \ + } +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c +index 96336830f035..fc2746e14c42 100644 +--- a/fs/ext4/extents.c ++++ b/fs/ext4/extents.c +@@ -2902,7 +2902,7 @@ again: + * in use to avoid freeing it when removing blocks. + */ + if (sbi->s_cluster_ratio > 1) { +- pblk = ext4_ext_pblock(ex) + end - ee_block + 2; ++ pblk = ext4_ext_pblock(ex) + end - ee_block + 1; + partial_cluster = + -(long long) EXT4_B2C(sbi, pblk); + } +diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c +index de7143e2b361..b7b43d00cc6d 100644 +--- a/fs/gfs2/ops_fstype.c ++++ b/fs/gfs2/ops_fstype.c +@@ -916,7 +916,7 @@ fail: + } + + static const match_table_t nolock_tokens = { +- { Opt_jid, "jid=%d\n", }, ++ { Opt_jid, "jid=%d", }, + { Opt_err, NULL }, + }; + +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c +index 7789f0b9b999..4d76e9a97538 100644 +--- a/fs/nfs/direct.c ++++ b/fs/nfs/direct.c +@@ -385,8 +385,6 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write) + if (write) + nfs_zap_mapping(inode, inode->i_mapping); + +- inode_dio_end(inode); +- + if (dreq->iocb) { + long res = (long) dreq->error; + if (!res) +@@ -396,7 +394,10 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write) + + complete_all(&dreq->completion); + ++ igrab(inode); + nfs_direct_req_release(dreq); ++ inode_dio_end(inode); ++ iput(inode); + } + + static void nfs_direct_readpage_release(struct nfs_page *req) +@@ -537,8 +538,10 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq, + * generic layer handle the completion. + */ + if (requested_bytes == 0) { +- inode_dio_end(inode); ++ igrab(inode); + nfs_direct_req_release(dreq); ++ inode_dio_end(inode); ++ iput(inode); + return result < 0 ? result : -EIO; + } + +@@ -939,8 +942,10 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, + * generic layer handle the completion. + */ + if (requested_bytes == 0) { +- inode_dio_end(inode); ++ igrab(inode); + nfs_direct_req_release(dreq); ++ inode_dio_end(inode); ++ iput(inode); + return result < 0 ? result : -EIO; + } + +diff --git a/fs/nfs/file.c b/fs/nfs/file.c +index dc875cd0e11d..eaa6697d256e 100644 +--- a/fs/nfs/file.c ++++ b/fs/nfs/file.c +@@ -82,6 +82,7 @@ nfs_file_release(struct inode *inode, struct file *filp) + dprintk("NFS: release(%pD2)\n", filp); + + nfs_inc_stats(inode, NFSIOS_VFSRELEASE); ++ inode_dio_wait(inode); + nfs_file_clear_open_context(filp); + return 0; + } +diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c +index 6506775575aa..17771e157e92 100644 +--- a/fs/nfs/flexfilelayout/flexfilelayout.c ++++ b/fs/nfs/flexfilelayout/flexfilelayout.c +@@ -855,9 +855,8 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, + goto out_mds; + + /* Use a direct mapping of ds_idx to pgio mirror_idx */ +- if (WARN_ON_ONCE(pgio->pg_mirror_count != +- FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))) +- goto out_mds; ++ if (pgio->pg_mirror_count != FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg)) ++ goto out_eagain; + + for (i = 0; i < pgio->pg_mirror_count; i++) { + ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true); +@@ -869,11 +868,15 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, + } + + return; +- ++out_eagain: ++ pnfs_generic_pg_cleanup(pgio); ++ pgio->pg_error = -EAGAIN; ++ return; + out_mds: + pnfs_put_lseg(pgio->pg_lseg); + pgio->pg_lseg = NULL; + nfs_pageio_reset_write_mds(pgio); ++ pgio->pg_error = -EAGAIN; + } + + static unsigned int +diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c +index 4fa3f0ba9ab3..0a0b41071ed7 100644 +--- a/fs/nfsd/nfs4callback.c ++++ b/fs/nfsd/nfs4callback.c +@@ -1096,6 +1096,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) + err = setup_callback_client(clp, &conn, ses); + if (err) { + nfsd4_mark_cb_down(clp, err); ++ if (c) ++ svc_xprt_put(c->cn_xprt); + return; + } + } +diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h +index 540ab5b75dbb..5617ec167a9d 100644 +--- a/fs/ocfs2/ocfs2_fs.h ++++ b/fs/ocfs2/ocfs2_fs.h +@@ -304,7 +304,7 @@ + #define OCFS2_MAX_SLOTS 255 + + /* Slot map indicator for an empty slot */ +-#define OCFS2_INVALID_SLOT -1 ++#define OCFS2_INVALID_SLOT ((u16)-1) + + #define OCFS2_VOL_UUID_LEN 16 + #define OCFS2_MAX_VOL_LABEL_LEN 64 +@@ -340,8 +340,8 @@ struct ocfs2_system_inode_info { + enum { + BAD_BLOCK_SYSTEM_INODE = 0, + GLOBAL_INODE_ALLOC_SYSTEM_INODE, ++#define OCFS2_FIRST_ONLINE_SYSTEM_INODE GLOBAL_INODE_ALLOC_SYSTEM_INODE + SLOT_MAP_SYSTEM_INODE, +-#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE + HEARTBEAT_SYSTEM_INODE, + GLOBAL_BITMAP_SYSTEM_INODE, + USER_QUOTA_SYSTEM_INODE, +diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c +index fc6d25f6d444..28cc343bf6e3 100644 +--- a/fs/ocfs2/suballoc.c ++++ b/fs/ocfs2/suballoc.c +@@ -2863,9 +2863,12 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) + goto bail; + } + +- inode_alloc_inode = +- ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE, +- suballoc_slot); ++ if (suballoc_slot == (u16)OCFS2_INVALID_SLOT) ++ inode_alloc_inode = ocfs2_get_system_file_inode(osb, ++ GLOBAL_INODE_ALLOC_SYSTEM_INODE, suballoc_slot); ++ else ++ inode_alloc_inode = ocfs2_get_system_file_inode(osb, ++ INODE_ALLOC_SYSTEM_INODE, suballoc_slot); + if (!inode_alloc_inode) { + /* the error code could be inaccurate, but we are not able to + * get the correct one. */ +diff --git a/include/linux/bitops.h b/include/linux/bitops.h +index ce2bb045b3fd..9b9711ea267a 100644 +--- a/include/linux/bitops.h ++++ b/include/linux/bitops.h +@@ -59,7 +59,7 @@ static inline int get_count_order(unsigned int count) + + static __always_inline unsigned long hweight_long(unsigned long w) + { +- return sizeof(w) == 4 ? hweight32(w) : hweight64(w); ++ return sizeof(w) == 4 ? hweight32(w) : hweight64((__u64)w); + } + + /** +diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h +index 278e3ef05336..56c6d9031663 100644 +--- a/include/linux/elfnote.h ++++ b/include/linux/elfnote.h +@@ -53,7 +53,7 @@ + .popsection ; + + #define ELFNOTE(name, type, desc) \ +- ELFNOTE_START(name, type, "") \ ++ ELFNOTE_START(name, type, "a") \ + desc ; \ + ELFNOTE_END + +diff --git a/include/linux/genhd.h b/include/linux/genhd.h +index 5012fcdb4c9e..a27d0aef07f6 100644 +--- a/include/linux/genhd.h ++++ b/include/linux/genhd.h +@@ -727,9 +727,11 @@ static inline sector_t part_nr_sects_read(struct hd_struct *part) + static inline void part_nr_sects_write(struct hd_struct *part, sector_t size) + { + #if BITS_PER_LONG==32 && defined(CONFIG_LBDAF) && defined(CONFIG_SMP) ++ preempt_disable(); + write_seqcount_begin(&part->nr_sects_seq); + part->nr_sects = size; + write_seqcount_end(&part->nr_sects_seq); ++ preempt_enable(); + #elif BITS_PER_LONG==32 && defined(CONFIG_LBDAF) && defined(CONFIG_PREEMPT) + preempt_disable(); + part->nr_sects = size; +diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h +index cb527c78de9f..4db62045f01a 100644 +--- a/include/linux/kprobes.h ++++ b/include/linux/kprobes.h +@@ -366,6 +366,10 @@ static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void) + return this_cpu_ptr(&kprobe_ctlblk); + } + ++extern struct kprobe kprobe_busy; ++void kprobe_busy_begin(void); ++void kprobe_busy_end(void); ++ + int register_kprobe(struct kprobe *p); + void unregister_kprobe(struct kprobe *p); + int register_kprobes(struct kprobe **kps, int num); +diff --git a/include/linux/libata.h b/include/linux/libata.h +index 6428ac4746de..af561d33221d 100644 +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + + /* + * Define if arch has non-standard setup. This is a _PCI_ standard +@@ -872,6 +873,8 @@ struct ata_port { + struct timer_list fastdrain_timer; + unsigned long fastdrain_cnt; + ++ async_cookie_t cookie; ++ + int em_message_type; + void *private_data; + +diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h +index 1af616138d1d..5547f1a0f83b 100644 +--- a/include/linux/pci_ids.h ++++ b/include/linux/pci_ids.h +@@ -2496,6 +2496,8 @@ + #define PCI_DEVICE_ID_KORENIX_JETCARDF2 0x1700 + #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff + ++#define PCI_VENDOR_ID_HUAWEI 0x19e5 ++ + #define PCI_VENDOR_ID_NETRONOME 0x19ee + #define PCI_DEVICE_ID_NETRONOME_NFP3200 0x3200 + #define PCI_DEVICE_ID_NETRONOME_NFP3240 0x3240 +diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h +index 8c337cd0e1e4..bf03bab93d9e 100644 +--- a/include/net/sctp/constants.h ++++ b/include/net/sctp/constants.h +@@ -357,11 +357,13 @@ typedef enum { + ipv4_is_anycast_6to4(a)) + + /* Flags used for the bind address copy functions. */ +-#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by ++#define SCTP_ADDR4_ALLOWED 0x00000001 /* IPv4 address is allowed by + local sock family */ +-#define SCTP_ADDR4_PEERSUPP 0x00000002 /* IPv4 address is supported by ++#define SCTP_ADDR6_ALLOWED 0x00000002 /* IPv6 address is allowed by ++ local sock family */ ++#define SCTP_ADDR4_PEERSUPP 0x00000004 /* IPv4 address is supported by + peer */ +-#define SCTP_ADDR6_PEERSUPP 0x00000004 /* IPv6 address is supported by ++#define SCTP_ADDR6_PEERSUPP 0x00000008 /* IPv6 address is supported by + peer */ + + /* Reasons to retransmit. */ +diff --git a/include/net/sock.h b/include/net/sock.h +index be5ec94020f1..426a57874964 100644 +--- a/include/net/sock.h ++++ b/include/net/sock.h +@@ -1678,7 +1678,6 @@ static inline int sk_tx_queue_get(const struct sock *sk) + + static inline void sk_set_socket(struct sock *sk, struct socket *sock) + { +- sk_tx_queue_clear(sk); + sk->sk_socket = sock; + } + +diff --git a/kernel/kprobes.c b/kernel/kprobes.c +index f59f49bc2a5d..5bda113a3116 100644 +--- a/kernel/kprobes.c ++++ b/kernel/kprobes.c +@@ -561,11 +561,12 @@ static void kprobe_optimizer(struct work_struct *work) + do_free_cleaned_kprobes(); + + mutex_unlock(&module_mutex); +- mutex_unlock(&kprobe_mutex); + + /* Step 5: Kick optimizer again if needed */ + if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) + kick_kprobe_optimizer(); ++ ++ mutex_unlock(&kprobe_mutex); + } + + /* Wait for completing optimization and unoptimization */ +@@ -1149,6 +1150,26 @@ __releases(hlist_lock) + } + NOKPROBE_SYMBOL(kretprobe_table_unlock); + ++struct kprobe kprobe_busy = { ++ .addr = (void *) get_kprobe, ++}; ++ ++void kprobe_busy_begin(void) ++{ ++ struct kprobe_ctlblk *kcb; ++ ++ preempt_disable(); ++ __this_cpu_write(current_kprobe, &kprobe_busy); ++ kcb = get_kprobe_ctlblk(); ++ kcb->kprobe_status = KPROBE_HIT_ACTIVE; ++} ++ ++void kprobe_busy_end(void) ++{ ++ __this_cpu_write(current_kprobe, NULL); ++ preempt_enable(); ++} ++ + /* + * This function is called from finish_task_switch when task tk becomes dead, + * so that we can recycle any function-return probe instances associated +@@ -1166,6 +1187,8 @@ void kprobe_flush_task(struct task_struct *tk) + /* Early boot. kretprobe_table_locks not yet initialized. */ + return; + ++ kprobe_busy_begin(); ++ + INIT_HLIST_HEAD(&empty_rp); + hash = hash_ptr(tk, KPROBE_HASH_BITS); + head = &kretprobe_inst_table[hash]; +@@ -1179,6 +1202,8 @@ void kprobe_flush_task(struct task_struct *tk) + hlist_del(&ri->hlist); + kfree(ri); + } ++ ++ kprobe_busy_end(); + } + NOKPROBE_SYMBOL(kprobe_flush_task); + +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index d81bcc6362ff..14a87c1f3a3a 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -3439,7 +3439,8 @@ void rt_mutex_setprio(struct task_struct *p, int prio) + if (dl_prio(prio)) { + struct task_struct *pi_task = rt_mutex_get_top_task(p); + if (!dl_prio(p->normal_prio) || +- (pi_task && dl_entity_preempt(&pi_task->dl, &p->dl))) { ++ (pi_task && dl_prio(pi_task->prio) && ++ dl_entity_preempt(&pi_task->dl, &p->dl))) { + p->dl.dl_boosted = 1; + enqueue_flag |= ENQUEUE_REPLENISH; + } else +diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c +index 673756468019..8ac3663e0012 100644 +--- a/kernel/trace/blktrace.c ++++ b/kernel/trace/blktrace.c +@@ -15,6 +15,9 @@ + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ ++ ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ++ + #include + #include + #include +@@ -481,6 +484,16 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, + */ + strreplace(buts->name, '/', '_'); + ++ /* ++ * bdev can be NULL, as with scsi-generic, this is a helpful as ++ * we can be. ++ */ ++ if (q->blk_trace) { ++ pr_warn("Concurrent blktraces are not allowed on %s\n", ++ buts->name); ++ return -EBUSY; ++ } ++ + bt = kzalloc(sizeof(*bt), GFP_KERNEL); + if (!bt) + return -ENOMEM; +diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c +index 78346aba6980..94fca4d687ad 100644 +--- a/kernel/trace/trace_events_trigger.c ++++ b/kernel/trace/trace_events_trigger.c +@@ -204,11 +204,17 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file) + + static int trigger_process_regex(struct trace_event_file *file, char *buff) + { +- char *command, *next = buff; ++ char *command, *next; + struct event_command *p; + int ret = -EINVAL; + ++ next = buff = skip_spaces(buff); + command = strsep(&next, ": \t"); ++ if (next) { ++ next = skip_spaces(next); ++ if (!*next) ++ next = NULL; ++ } + command = (command[0] != '!') ? command : command + 1; + + mutex_lock(&trigger_cmd_mutex); +@@ -615,8 +621,14 @@ event_trigger_callback(struct event_command *cmd_ops, + int ret; + + /* separate the trigger from the filter (t:n [if filter]) */ +- if (param && isdigit(param[0])) ++ if (param && isdigit(param[0])) { + trigger = strsep(¶m, " \t"); ++ if (param) { ++ param = skip_spaces(param); ++ if (!*param) ++ param = NULL; ++ } ++ } + + trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger); + +@@ -1185,6 +1197,11 @@ event_enable_trigger_func(struct event_command *cmd_ops, + trigger = strsep(¶m, " \t"); + if (!trigger) + return -EINVAL; ++ if (param) { ++ param = skip_spaces(param); ++ if (!*param) ++ param = NULL; ++ } + + system = strsep(&trigger, ":"); + if (!trigger) +diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c +index 2c13ecc5bb2c..ed1f3df27260 100644 +--- a/lib/zlib_inflate/inffast.c ++++ b/lib/zlib_inflate/inffast.c +@@ -10,17 +10,6 @@ + + #ifndef ASMINF + +-/* Allow machine dependent optimization for post-increment or pre-increment. +- Based on testing to date, +- Pre-increment preferred for: +- - PowerPC G3 (Adler) +- - MIPS R5000 (Randers-Pehrson) +- Post-increment preferred for: +- - none +- No measurable difference: +- - Pentium III (Anderson) +- - M68060 (Nikl) +- */ + union uu { + unsigned short us; + unsigned char b[2]; +@@ -38,16 +27,6 @@ get_unaligned16(const unsigned short *p) + return mm.us; + } + +-#ifdef POSTINC +-# define OFF 0 +-# define PUP(a) *(a)++ +-# define UP_UNALIGNED(a) get_unaligned16((a)++) +-#else +-# define OFF 1 +-# define PUP(a) *++(a) +-# define UP_UNALIGNED(a) get_unaligned16(++(a)) +-#endif +- + /* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is +@@ -115,9 +94,9 @@ void inflate_fast(z_streamp strm, unsigned start) + + /* copy state to local variables */ + state = (struct inflate_state *)strm->state; +- in = strm->next_in - OFF; ++ in = strm->next_in; + last = in + (strm->avail_in - 5); +- out = strm->next_out - OFF; ++ out = strm->next_out; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); + #ifdef INFLATE_STRICT +@@ -138,9 +117,9 @@ void inflate_fast(z_streamp strm, unsigned start) + input data or output space */ + do { + if (bits < 15) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + this = lcode[hold & lmask]; +@@ -150,14 +129,14 @@ void inflate_fast(z_streamp strm, unsigned start) + bits -= op; + op = (unsigned)(this.op); + if (op == 0) { /* literal */ +- PUP(out) = (unsigned char)(this.val); ++ *out++ = (unsigned char)(this.val); + } + else if (op & 16) { /* length base */ + len = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); +@@ -165,9 +144,9 @@ void inflate_fast(z_streamp strm, unsigned start) + bits -= op; + } + if (bits < 15) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + this = dcode[hold & dmask]; +@@ -180,10 +159,10 @@ void inflate_fast(z_streamp strm, unsigned start) + dist = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (bits < op) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + if (bits < op) { +- hold += (unsigned long)(PUP(in)) << bits; ++ hold += (unsigned long)(*in++) << bits; + bits += 8; + } + } +@@ -205,13 +184,13 @@ void inflate_fast(z_streamp strm, unsigned start) + state->mode = BAD; + break; + } +- from = window - OFF; ++ from = window; + if (write == 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } +@@ -222,14 +201,14 @@ void inflate_fast(z_streamp strm, unsigned start) + if (op < len) { /* some from end of window */ + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); +- from = window - OFF; ++ from = window; + if (write < len) { /* some from start of window */ + op = write; + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } +@@ -240,21 +219,21 @@ void inflate_fast(z_streamp strm, unsigned start) + if (op < len) { /* some from window */ + len -= op; + do { +- PUP(out) = PUP(from); ++ *out++ = *from++; + } while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) { +- PUP(out) = PUP(from); +- PUP(out) = PUP(from); +- PUP(out) = PUP(from); ++ *out++ = *from++; ++ *out++ = *from++; ++ *out++ = *from++; + len -= 3; + } + if (len) { +- PUP(out) = PUP(from); ++ *out++ = *from++; + if (len > 1) +- PUP(out) = PUP(from); ++ *out++ = *from++; + } + } + else { +@@ -264,29 +243,29 @@ void inflate_fast(z_streamp strm, unsigned start) + from = out - dist; /* copy direct from output */ + /* minimum length is three */ + /* Align out addr */ +- if (!((long)(out - 1 + OFF) & 1)) { +- PUP(out) = PUP(from); ++ if (!((long)(out - 1) & 1)) { ++ *out++ = *from++; + len--; + } +- sout = (unsigned short *)(out - OFF); ++ sout = (unsigned short *)(out); + if (dist > 2) { + unsigned short *sfrom; + +- sfrom = (unsigned short *)(from - OFF); ++ sfrom = (unsigned short *)(from); + loops = len >> 1; + do + #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +- PUP(sout) = PUP(sfrom); ++ *sout++ = *sfrom++; + #else +- PUP(sout) = UP_UNALIGNED(sfrom); ++ *sout++ = get_unaligned16(sfrom++); + #endif + while (--loops); +- out = (unsigned char *)sout + OFF; +- from = (unsigned char *)sfrom + OFF; ++ out = (unsigned char *)sout; ++ from = (unsigned char *)sfrom; + } else { /* dist == 1 or dist == 2 */ + unsigned short pat16; + +- pat16 = *(sout-1+OFF); ++ pat16 = *(sout-1); + if (dist == 1) { + union uu mm; + /* copy one char pattern to both bytes */ +@@ -296,12 +275,12 @@ void inflate_fast(z_streamp strm, unsigned start) + } + loops = len >> 1; + do +- PUP(sout) = pat16; ++ *sout++ = pat16; + while (--loops); +- out = (unsigned char *)sout + OFF; ++ out = (unsigned char *)sout; + } + if (len & 1) +- PUP(out) = PUP(from); ++ *out++ = *from++; + } + } + else if ((op & 64) == 0) { /* 2nd level distance code */ +@@ -336,8 +315,8 @@ void inflate_fast(z_streamp strm, unsigned start) + hold &= (1U << bits) - 1; + + /* update state and return */ +- strm->next_in = in + OFF; +- strm->next_out = out + OFF; ++ strm->next_in = in; ++ strm->next_out = out; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? + 257 + (end - out) : 257 - (out - end)); +diff --git a/mm/slab_common.c b/mm/slab_common.c +index 01e7246de8df..5d8c809a3ff7 100644 +--- a/mm/slab_common.c ++++ b/mm/slab_common.c +@@ -1269,7 +1269,7 @@ void kzfree(const void *p) + if (unlikely(ZERO_OR_NULL_PTR(mem))) + return; + ks = ksize(mem); +- memset(mem, 0, ks); ++ memzero_explicit(mem, ks); + kfree(mem); + } + EXPORT_SYMBOL(kzfree); +diff --git a/net/core/dev.c b/net/core/dev.c +index 38e4977eb09d..09115c68f29d 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -82,6 +82,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -185,7 +186,7 @@ static DEFINE_SPINLOCK(napi_hash_lock); + static unsigned int napi_gen_id = NR_CPUS; + static DEFINE_HASHTABLE(napi_hash, 8); + +-static seqcount_t devnet_rename_seq; ++static DECLARE_RWSEM(devnet_rename_sem); + + static inline void dev_base_seq_inc(struct net *net) + { +@@ -862,33 +863,28 @@ EXPORT_SYMBOL(dev_get_by_index); + * @net: network namespace + * @name: a pointer to the buffer where the name will be stored. + * @ifindex: the ifindex of the interface to get the name from. +- * +- * The use of raw_seqcount_begin() and cond_resched() before +- * retrying is required as we want to give the writers a chance +- * to complete when CONFIG_PREEMPT is not set. + */ + int netdev_get_name(struct net *net, char *name, int ifindex) + { + struct net_device *dev; +- unsigned int seq; ++ int ret; + +-retry: +- seq = raw_seqcount_begin(&devnet_rename_seq); ++ down_read(&devnet_rename_sem); + rcu_read_lock(); ++ + dev = dev_get_by_index_rcu(net, ifindex); + if (!dev) { +- rcu_read_unlock(); +- return -ENODEV; ++ ret = -ENODEV; ++ goto out; + } + + strcpy(name, dev->name); +- rcu_read_unlock(); +- if (read_seqcount_retry(&devnet_rename_seq, seq)) { +- cond_resched(); +- goto retry; +- } + +- return 0; ++ ret = 0; ++out: ++ rcu_read_unlock(); ++ up_read(&devnet_rename_sem); ++ return ret; + } + + /** +@@ -1153,10 +1149,10 @@ int dev_change_name(struct net_device *dev, const char *newname) + if (dev->flags & IFF_UP) + return -EBUSY; + +- write_seqcount_begin(&devnet_rename_seq); ++ down_write(&devnet_rename_sem); + + if (strncmp(newname, dev->name, IFNAMSIZ) == 0) { +- write_seqcount_end(&devnet_rename_seq); ++ up_write(&devnet_rename_sem); + return 0; + } + +@@ -1164,7 +1160,7 @@ int dev_change_name(struct net_device *dev, const char *newname) + + err = dev_get_valid_name(net, dev, newname); + if (err < 0) { +- write_seqcount_end(&devnet_rename_seq); ++ up_write(&devnet_rename_sem); + return err; + } + +@@ -1179,11 +1175,11 @@ rollback: + if (ret) { + memcpy(dev->name, oldname, IFNAMSIZ); + dev->name_assign_type = old_assign_type; +- write_seqcount_end(&devnet_rename_seq); ++ up_write(&devnet_rename_sem); + return ret; + } + +- write_seqcount_end(&devnet_rename_seq); ++ up_write(&devnet_rename_sem); + + netdev_adjacent_rename_links(dev, oldname); + +@@ -1204,7 +1200,7 @@ rollback: + /* err >= 0 after dev_alloc_name() or stores the first errno */ + if (err >= 0) { + err = ret; +- write_seqcount_begin(&devnet_rename_seq); ++ down_write(&devnet_rename_sem); + memcpy(dev->name, oldname, IFNAMSIZ); + memcpy(oldname, newname, IFNAMSIZ); + dev->name_assign_type = old_assign_type; +@@ -3021,7 +3017,7 @@ static void skb_update_prio(struct sk_buff *skb) + DEFINE_PER_CPU(int, xmit_recursion); + EXPORT_SYMBOL(xmit_recursion); + +-#define RECURSION_LIMIT 10 ++#define RECURSION_LIMIT 8 + + /** + * dev_loopback_xmit - loop back @skb +@@ -6844,6 +6840,13 @@ int register_netdevice(struct net_device *dev) + rcu_barrier(); + + dev->reg_state = NETREG_UNREGISTERED; ++ /* We should put the kobject that hold in ++ * netdev_unregister_kobject(), otherwise ++ * the net device cannot be freed when ++ * driver calls free_netdev(), because the ++ * kobject is being hold. ++ */ ++ kobject_put(&dev->dev.kobj); + } + /* + * Prevent userspace races by waiting until the network +diff --git a/net/core/sock.c b/net/core/sock.c +index 60b19c3bb0f7..120d5058d81a 100644 +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -1435,6 +1435,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, + + sock_update_classid(sk); + sock_update_netprioidx(sk); ++ sk_tx_queue_clear(sk); + } + + return sk; +@@ -1601,6 +1602,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) + */ + sk_refcnt_debug_inc(newsk); + sk_set_socket(newsk, NULL); ++ sk_tx_queue_clear(newsk); + newsk->sk_wq = NULL; + + sk_update_clone(sk, newsk); +diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c +index 498d5a929d6f..3c1e42d49520 100644 +--- a/net/ipv4/fib_semantics.c ++++ b/net/ipv4/fib_semantics.c +@@ -776,7 +776,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, + if (fl4.flowi4_scope < RT_SCOPE_LINK) + fl4.flowi4_scope = RT_SCOPE_LINK; + +- if (cfg->fc_table) ++ if (cfg->fc_table && cfg->fc_table != RT_TABLE_MAIN) + tbl = fib_get_table(net, cfg->fc_table); + + if (tbl) +diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c +index 20b21f8578e1..3d9761516683 100644 +--- a/net/ipv4/ip_tunnel.c ++++ b/net/ipv4/ip_tunnel.c +@@ -98,9 +98,10 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, + __be32 remote, __be32 local, + __be32 key) + { +- unsigned int hash; + struct ip_tunnel *t, *cand = NULL; + struct hlist_head *head; ++ struct net_device *ndev; ++ unsigned int hash; + + hash = ip_tunnel_hash(key, remote); + head = &itn->tunnels[hash]; +@@ -175,8 +176,9 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, + if (t) + return t; + +- if (itn->fb_tunnel_dev && itn->fb_tunnel_dev->flags & IFF_UP) +- return netdev_priv(itn->fb_tunnel_dev); ++ ndev = READ_ONCE(itn->fb_tunnel_dev); ++ if (ndev && ndev->flags & IFF_UP) ++ return netdev_priv(ndev); + + return NULL; + } +@@ -1160,9 +1162,9 @@ void ip_tunnel_uninit(struct net_device *dev) + struct ip_tunnel_net *itn; + + itn = net_generic(net, tunnel->ip_tnl_net_id); +- /* fb_tunnel_dev will be unregisted in net-exit call. */ +- if (itn->fb_tunnel_dev != dev) +- ip_tunnel_del(itn, netdev_priv(dev)); ++ ip_tunnel_del(itn, netdev_priv(dev)); ++ if (itn->fb_tunnel_dev == dev) ++ WRITE_ONCE(itn->fb_tunnel_dev, NULL); + + dst_cache_reset(&tunnel->dst_cache); + } +diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c +index 448c2615fece..9fb3a5e83a7c 100644 +--- a/net/ipv4/tcp_cubic.c ++++ b/net/ipv4/tcp_cubic.c +@@ -414,6 +414,8 @@ static void hystart_update(struct sock *sk, u32 delay) + + if (hystart_detect & HYSTART_DELAY) { + /* obtain the minimum delay of more than sampling packets */ ++ if (ca->curr_rtt > delay) ++ ca->curr_rtt = delay; + if (ca->sample_cnt < HYSTART_MIN_SAMPLES) { + if (ca->curr_rtt == 0 || ca->curr_rtt > delay) + ca->curr_rtt = delay; +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c +index 64c7265793a5..e2066f2f19b4 100644 +--- a/net/ipv4/tcp_input.c ++++ b/net/ipv4/tcp_input.c +@@ -4465,7 +4465,11 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) + if (tcp_ooo_try_coalesce(sk, tp->ooo_last_skb, + skb, &fragstolen)) { + coalesce_done: +- tcp_grow_window(sk, skb); ++ /* For non sack flows, do not grow window to force DUPACK ++ * and trigger fast retransmit. ++ */ ++ if (tcp_is_sack(tp)) ++ tcp_grow_window(sk, skb); + kfree_skb_partial(skb, fragstolen); + skb = NULL; + goto add_sack; +@@ -4545,7 +4549,11 @@ add_sack: + tcp_sack_new_ofo_skb(sk, seq, end_seq); + end: + if (skb) { +- tcp_grow_window(sk, skb); ++ /* For non sack flows, do not grow window to force DUPACK ++ * and trigger fast retransmit. ++ */ ++ if (tcp_is_sack(tp)) ++ tcp_grow_window(sk, skb); + skb_set_owner_r(skb, sk); + } + } +diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c +index b25f4ad28b03..546172bfaba1 100644 +--- a/net/ipv6/ip6_gre.c ++++ b/net/ipv6/ip6_gre.c +@@ -125,6 +125,7 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, + int dev_type = (gre_proto == htons(ETH_P_TEB)) ? + ARPHRD_ETHER : ARPHRD_IP6GRE; + int score, cand_score = 4; ++ struct net_device *ndev; + + for_each_ip_tunnel_rcu(t, ign->tunnels_r_l[h0 ^ h1]) { + if (!ipv6_addr_equal(local, &t->parms.laddr) || +@@ -227,9 +228,9 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, + if (cand) + return cand; + +- dev = ign->fb_tunnel_dev; +- if (dev->flags & IFF_UP) +- return netdev_priv(dev); ++ ndev = READ_ONCE(ign->fb_tunnel_dev); ++ if (ndev && ndev->flags & IFF_UP) ++ return netdev_priv(ndev); + + return NULL; + } +@@ -364,6 +365,8 @@ static void ip6gre_tunnel_uninit(struct net_device *dev) + struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id); + + ip6gre_tunnel_unlink(ign, t); ++ if (ign->fb_tunnel_dev == dev) ++ WRITE_ONCE(ign->fb_tunnel_dev, NULL); + dst_cache_reset(&t->dst_cache); + dev_put(dev); + } +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c +index 976c8133a281..2d28f0b54494 100644 +--- a/net/ipv6/mcast.c ++++ b/net/ipv6/mcast.c +@@ -2580,6 +2580,7 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev) + write_unlock_bh(&idev->lock); + + igmp6_group_dropped(i); ++ ip6_mc_clear_src(i); + ma_put(i); + + write_lock_bh(&idev->lock); +diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c +index 239464045697..53c53b1c881c 100644 +--- a/net/l2tp/l2tp_core.c ++++ b/net/l2tp/l2tp_core.c +@@ -351,8 +351,13 @@ int l2tp_session_register(struct l2tp_session *session, + + spin_lock_bh(&pn->l2tp_session_hlist_lock); + ++ /* IP encap expects session IDs to be globally unique, while ++ * UDP encap doesn't. ++ */ + hlist_for_each_entry(session_walk, g_head, global_hlist) +- if (session_walk->session_id == session->session_id) { ++ if (session_walk->session_id == session->session_id && ++ (session_walk->tunnel->encap == L2TP_ENCAPTYPE_IP || ++ tunnel->encap == L2TP_ENCAPTYPE_IP)) { + err = -EEXIST; + goto err_tlock_pnlock; + } +diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c +index 0583e2491770..3231030a73ed 100644 +--- a/net/netfilter/ipset/ip_set_core.c ++++ b/net/netfilter/ipset/ip_set_core.c +@@ -379,6 +379,8 @@ ip_set_elem_len(struct ip_set *set, struct nlattr *tb[], size_t len, + for (id = 0; id < IPSET_EXT_ID_MAX; id++) { + if (!add_extension(id, cadt_flags, tb)) + continue; ++ if (align < ip_set_extensions[id].align) ++ align = ip_set_extensions[id].align; + len = ALIGN(len, ip_set_extensions[id].align); + set->offset[id] = len; + set->extensions |= ip_set_extensions[id].type; +diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c +index f4aa2ab4713a..eb814ffc0902 100644 +--- a/net/sched/sch_fq.c ++++ b/net/sched/sch_fq.c +@@ -830,24 +830,20 @@ nla_put_failure: + static int fq_dump_stats(struct Qdisc *sch, struct gnet_dump *d) + { + struct fq_sched_data *q = qdisc_priv(sch); +- struct tc_fq_qd_stats st; +- +- sch_tree_lock(sch); +- +- st.gc_flows = q->stat_gc_flows; +- st.highprio_packets = q->stat_internal_packets; +- st.tcp_retrans = q->stat_tcp_retrans; +- st.throttled = q->stat_throttled; +- st.flows_plimit = q->stat_flows_plimit; +- st.pkts_too_long = q->stat_pkts_too_long; +- st.allocation_errors = q->stat_allocation_errors; +- st.time_next_delayed_flow = q->time_next_delayed_flow - ktime_get_ns(); +- st.flows = q->flows; +- st.inactive_flows = q->inactive_flows; +- st.throttled_flows = q->throttled_flows; +- st.pad = 0; +- +- sch_tree_unlock(sch); ++ u64 now = ktime_get_ns(); ++ struct tc_fq_qd_stats st = { ++ .gc_flows = q->stat_gc_flows, ++ .highprio_packets = q->stat_internal_packets, ++ .tcp_retrans = q->stat_tcp_retrans, ++ .throttled = q->stat_throttled, ++ .flows_plimit = q->stat_flows_plimit, ++ .pkts_too_long = q->stat_pkts_too_long, ++ .allocation_errors = q->stat_allocation_errors, ++ .flows = q->flows, ++ .inactive_flows = q->inactive_flows, ++ .throttled_flows = q->throttled_flows, ++ .time_next_delayed_flow = q->time_next_delayed_flow - now, ++ }; + + return gnet_stats_copy_app(d, &st, sizeof(st)); + } +diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c +index 09cd65434748..10c05fa0e6b3 100644 +--- a/net/sched/sch_generic.c ++++ b/net/sched/sch_generic.c +@@ -329,6 +329,7 @@ void __netdev_watchdog_up(struct net_device *dev) + dev_hold(dev); + } + } ++EXPORT_SYMBOL_GPL(__netdev_watchdog_up); + + static void dev_watchdog_up(struct net_device *dev) + { +diff --git a/net/sctp/associola.c b/net/sctp/associola.c +index f24d31f12cb4..aa38578fdfcd 100644 +--- a/net/sctp/associola.c ++++ b/net/sctp/associola.c +@@ -1575,12 +1575,15 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len) + int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, + sctp_scope_t scope, gfp_t gfp) + { ++ struct sock *sk = asoc->base.sk; + int flags; + + /* Use scoping rules to determine the subset of addresses from + * the endpoint. + */ +- flags = (PF_INET6 == asoc->base.sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0; ++ flags = (PF_INET6 == sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0; ++ if (!inet_v6_ipv6only(sk)) ++ flags |= SCTP_ADDR4_ALLOWED; + if (asoc->peer.ipv4_address) + flags |= SCTP_ADDR4_PEERSUPP; + if (asoc->peer.ipv6_address) +diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c +index 871cdf9567e6..664215448d09 100644 +--- a/net/sctp/bind_addr.c ++++ b/net/sctp/bind_addr.c +@@ -449,6 +449,7 @@ static int sctp_copy_one_addr(struct net *net, struct sctp_bind_addr *dest, + * well as the remote peer. + */ + if ((((AF_INET == addr->sa.sa_family) && ++ (flags & SCTP_ADDR4_ALLOWED) && + (flags & SCTP_ADDR4_PEERSUPP))) || + (((AF_INET6 == addr->sa.sa_family) && + (flags & SCTP_ADDR6_ALLOWED) && +diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c +index 9c6c42fd9f8a..b0e401dfe160 100644 +--- a/net/sctp/protocol.c ++++ b/net/sctp/protocol.c +@@ -210,6 +210,7 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp, + * sock as well as the remote peer. + */ + if ((((AF_INET == addr->a.sa.sa_family) && ++ (copy_flags & SCTP_ADDR4_ALLOWED) && + (copy_flags & SCTP_ADDR4_PEERSUPP))) || + (((AF_INET6 == addr->a.sa.sa_family) && + (copy_flags & SCTP_ADDR6_ALLOWED) && +diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c +index 2e0a6f92e563..8391c2785550 100644 +--- a/net/sunrpc/addr.c ++++ b/net/sunrpc/addr.c +@@ -81,11 +81,11 @@ static size_t rpc_ntop6(const struct sockaddr *sap, + + rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u", + IPV6_SCOPE_DELIMITER, sin6->sin6_scope_id); +- if (unlikely((size_t)rc > sizeof(scopebuf))) ++ if (unlikely((size_t)rc >= sizeof(scopebuf))) + return 0; + + len += rc; +- if (unlikely(len > buflen)) ++ if (unlikely(len >= buflen)) + return 0; + + strcat(buf, scopebuf); +diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c +index 9103dd15511c..12dd5cc499c1 100644 +--- a/net/sunrpc/rpc_pipe.c ++++ b/net/sunrpc/rpc_pipe.c +@@ -1347,6 +1347,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data) + q.len = strlen(gssd_dummy_clnt_dir[0].name); + clnt_dentry = d_hash_and_lookup(gssd_dentry, &q); + if (!clnt_dentry) { ++ __rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1); + pipe_dentry = ERR_PTR(-ENOENT); + goto out; + } +diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c +index ed9bbd383f7d..df7ecf9584f6 100644 +--- a/net/sunrpc/xdr.c ++++ b/net/sunrpc/xdr.c +@@ -1031,6 +1031,7 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf, + base = 0; + } else { + base -= buf->head[0].iov_len; ++ subbuf->head[0].iov_base = buf->head[0].iov_base; + subbuf->head[0].iov_len = 0; + } + +@@ -1043,6 +1044,8 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf, + base = 0; + } else { + base -= buf->page_len; ++ subbuf->pages = buf->pages; ++ subbuf->page_base = 0; + subbuf->page_len = 0; + } + +@@ -1054,6 +1057,7 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf, + base = 0; + } else { + base -= buf->tail[0].iov_len; ++ subbuf->tail[0].iov_base = buf->tail[0].iov_base; + subbuf->tail[0].iov_len = 0; + } + +diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include +index e61a5c29b08c..b6f055157b89 100644 +--- a/scripts/Kbuild.include ++++ b/scripts/Kbuild.include +@@ -81,20 +81,21 @@ cc-cross-prefix = \ + fi))) + + # output directory for tests below +-TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) ++TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$ + + # try-run + # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) + # Exit code chooses option. "$$TMP" is can be used as temporary file and + # is automatically cleaned up. + try-run = $(shell set -e; \ +- TMP="$(TMPOUT).$$$$.tmp"; \ +- TMPO="$(TMPOUT).$$$$.o"; \ ++ TMP=$(TMPOUT)/tmp; \ ++ TMPO=$(TMPOUT)/tmp.o; \ ++ mkdir -p $(TMPOUT); \ ++ trap "rm -rf $(TMPOUT)" EXIT; \ + if ($(1)) >/dev/null 2>&1; \ + then echo "$(2)"; \ + else echo "$(3)"; \ +- fi; \ +- rm -f "$$TMP" "$$TMPO") ++ fi) + + # as-option + # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) +diff --git a/scripts/mksysmap b/scripts/mksysmap +index a35acc0d0b82..9aa23d15862a 100755 +--- a/scripts/mksysmap ++++ b/scripts/mksysmap +@@ -41,4 +41,4 @@ + # so we just ignore them to let readprofile continue to work. + # (At least sparc64 has __crc_ in the middle). + +-$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > $2 ++$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)' > $2 +diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c +index 0a258c0602d1..55c869e0a3a0 100644 +--- a/security/selinux/ss/services.c ++++ b/security/selinux/ss/services.c +@@ -2622,8 +2622,12 @@ err: + if (*names) { + for (i = 0; i < *len; i++) + kfree((*names)[i]); ++ kfree(*names); + } + kfree(*values); ++ *len = 0; ++ *names = NULL; ++ *values = NULL; + goto out; + } + +diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c +index 718d5e3b7806..6c06d0645779 100644 +--- a/sound/isa/wavefront/wavefront_synth.c ++++ b/sound/isa/wavefront/wavefront_synth.c +@@ -1174,7 +1174,10 @@ wavefront_send_alias (snd_wavefront_t *dev, wavefront_patch_info *header) + "alias for %d\n", + header->number, + header->hdr.a.OriginalSample); +- ++ ++ if (header->number >= WF_MAX_SAMPLE) ++ return -EINVAL; ++ + munge_int32 (header->number, &alias_hdr[0], 2); + munge_int32 (header->hdr.a.OriginalSample, &alias_hdr[2], 2); + munge_int32 (*((unsigned int *)&header->hdr.a.sampleStartOffset), +@@ -1205,6 +1208,9 @@ wavefront_send_multisample (snd_wavefront_t *dev, wavefront_patch_info *header) + int num_samples; + unsigned char *msample_hdr; + ++ if (header->number >= WF_MAX_SAMPLE) ++ return -EINVAL; ++ + msample_hdr = kmalloc(WF_MSAMPLE_BYTES, GFP_KERNEL); + if (! msample_hdr) + return -ENOMEM; +diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c +index ffc000bc1f15..56a873ba08e4 100644 +--- a/sound/soc/fsl/fsl_asrc_dma.c ++++ b/sound/soc/fsl/fsl_asrc_dma.c +@@ -243,6 +243,7 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream, + ret = dmaengine_slave_config(pair->dma_chan[dir], &config_be); + if (ret) { + dev_err(dev, "failed to config DMA channel for Back-End\n"); ++ dma_release_channel(pair->dma_chan[dir]); + return ret; + } + +diff --git a/sound/usb/card.h b/sound/usb/card.h +index 71778ca4b26a..844c68863810 100644 +--- a/sound/usb/card.h ++++ b/sound/usb/card.h +@@ -80,6 +80,10 @@ struct snd_usb_endpoint { + dma_addr_t sync_dma; /* DMA address of syncbuf */ + + unsigned int pipe; /* the data i/o pipe */ ++ unsigned int framesize[2]; /* small/large frame sizes in samples */ ++ unsigned int sample_rem; /* remainder from division fs/fps */ ++ unsigned int sample_accum; /* sample accumulator */ ++ unsigned int fps; /* frames per second */ + unsigned int freqn; /* nominal sampling rate in fs/fps in Q16.16 format */ + unsigned int freqm; /* momentary sampling rate in fs/fps in Q16.16 format */ + int freqshift; /* how much to shift the feedback value to get Q16.16 */ +diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c +index 66648b4bdd28..666731317b33 100644 +--- a/sound/usb/endpoint.c ++++ b/sound/usb/endpoint.c +@@ -137,12 +137,12 @@ int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep) + + /* + * For streaming based on information derived from sync endpoints, +- * prepare_outbound_urb_sizes() will call next_packet_size() to ++ * prepare_outbound_urb_sizes() will call slave_next_packet_size() to + * determine the number of samples to be sent in the next packet. + * +- * For implicit feedback, next_packet_size() is unused. ++ * For implicit feedback, slave_next_packet_size() is unused. + */ +-int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep) ++int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep) + { + unsigned long flags; + int ret; +@@ -159,6 +159,29 @@ int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep) + return ret; + } + ++/* ++ * For adaptive and synchronous endpoints, prepare_outbound_urb_sizes() ++ * will call next_packet_size() to determine the number of samples to be ++ * sent in the next packet. ++ */ ++int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep) ++{ ++ int ret; ++ ++ if (ep->fill_max) ++ return ep->maxframesize; ++ ++ ep->sample_accum += ep->sample_rem; ++ if (ep->sample_accum >= ep->fps) { ++ ep->sample_accum -= ep->fps; ++ ret = ep->framesize[1]; ++ } else { ++ ret = ep->framesize[0]; ++ } ++ ++ return ret; ++} ++ + static void retire_outbound_urb(struct snd_usb_endpoint *ep, + struct snd_urb_ctx *urb_ctx) + { +@@ -203,6 +226,8 @@ static void prepare_silent_urb(struct snd_usb_endpoint *ep, + + if (ctx->packet_size[i]) + counts = ctx->packet_size[i]; ++ else if (ep->sync_master) ++ counts = snd_usb_endpoint_slave_next_packet_size(ep); + else + counts = snd_usb_endpoint_next_packet_size(ep); + +@@ -879,10 +904,17 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, + ep->maxpacksize = fmt->maxpacksize; + ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX); + +- if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) ++ if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) { + ep->freqn = get_usb_full_speed_rate(rate); +- else ++ ep->fps = 1000; ++ } else { + ep->freqn = get_usb_high_speed_rate(rate); ++ ep->fps = 8000; ++ } ++ ++ ep->sample_rem = rate % ep->fps; ++ ep->framesize[0] = rate / ep->fps; ++ ep->framesize[1] = (rate + (ep->fps - 1)) / ep->fps; + + /* calculate the frequency in 16.16 format */ + ep->freqm = ep->freqn; +@@ -941,6 +973,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) + ep->active_mask = 0; + ep->unlink_mask = 0; + ep->phase = 0; ++ ep->sample_accum = 0; + + snd_usb_endpoint_start_quirk(ep); + +diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h +index 584f295d7c77..4aad49cbeb5f 100644 +--- a/sound/usb/endpoint.h ++++ b/sound/usb/endpoint.h +@@ -27,6 +27,7 @@ void snd_usb_endpoint_release(struct snd_usb_endpoint *ep); + void snd_usb_endpoint_free(struct snd_usb_endpoint *ep); + + int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); ++int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep); + int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); + + void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c +index 9bbe84ce7d07..9b9d653d5e90 100644 +--- a/sound/usb/mixer.c ++++ b/sound/usb/mixer.c +@@ -584,8 +584,9 @@ static int check_matrix_bitmap(unsigned char *bmap, + * if failed, give up and free the control instance. + */ + +-int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list, +- struct snd_kcontrol *kctl) ++int snd_usb_mixer_add_list(struct usb_mixer_elem_list *list, ++ struct snd_kcontrol *kctl, ++ bool is_std_info) + { + struct usb_mixer_interface *mixer = list->mixer; + int err; +@@ -598,6 +599,7 @@ int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list, + return err; + } + list->kctl = kctl; ++ list->is_std_info = is_std_info; + list->next_id_elem = mixer->id_elems[list->id]; + mixer->id_elems[list->id] = list; + return 0; +@@ -2330,15 +2332,23 @@ void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid) + { + struct usb_mixer_elem_list *list; + +- for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem) ++ for_each_mixer_elem(list, mixer, unitid) { ++ struct usb_mixer_elem_info *info; ++ ++ if (!list->is_std_info) ++ continue; ++ info = mixer_elem_list_to_info(list); ++ /* invalidate cache, so the value is read from the device */ ++ info->cached = 0; + snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, + &list->kctl->id); ++ } + } + + static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer, + struct usb_mixer_elem_list *list) + { +- struct usb_mixer_elem_info *cval = (struct usb_mixer_elem_info *)list; ++ struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list); + static char *val_types[] = {"BOOLEAN", "INV_BOOLEAN", + "S8", "U8", "S16", "U16"}; + snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, " +@@ -2364,8 +2374,7 @@ static void snd_usb_mixer_proc_read(struct snd_info_entry *entry, + mixer->ignore_ctl_error); + snd_iprintf(buffer, "Card: %s\n", chip->card->longname); + for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { +- for (list = mixer->id_elems[unitid]; list; +- list = list->next_id_elem) { ++ for_each_mixer_elem(list, mixer, unitid) { + snd_iprintf(buffer, " Unit: %i\n", list->id); + if (list->kctl) + snd_iprintf(buffer, +@@ -2386,6 +2395,7 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer, + __u8 unitid = (index >> 8) & 0xff; + __u8 control = (value >> 8) & 0xff; + __u8 channel = value & 0xff; ++ unsigned int count = 0; + + if (channel >= MAX_CHANNELS) { + usb_audio_dbg(mixer->chip, +@@ -2394,14 +2404,22 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer, + return; + } + +- for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem) { ++ for_each_mixer_elem(list, mixer, unitid) ++ count++; ++ ++ if (count == 0) ++ return; ++ ++ for_each_mixer_elem(list, mixer, unitid) { + struct usb_mixer_elem_info *info; + + if (!list->kctl) + continue; ++ if (!list->is_std_info) ++ continue; + +- info = (struct usb_mixer_elem_info *)list; +- if (info->control != control) ++ info = mixer_elem_list_to_info(list); ++ if (count > 1 && info->control != control) + continue; + + switch (attribute) { +@@ -2620,7 +2638,7 @@ int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer) + + static int restore_mixer_value(struct usb_mixer_elem_list *list) + { +- struct usb_mixer_elem_info *cval = (struct usb_mixer_elem_info *)list; ++ struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list); + int c, err, idx; + + if (cval->cmask) { +@@ -2656,8 +2674,7 @@ int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume) + if (reset_resume) { + /* restore cached mixer values */ + for (id = 0; id < MAX_ID_ELEMS; id++) { +- for (list = mixer->id_elems[id]; list; +- list = list->next_id_elem) { ++ for_each_mixer_elem(list, mixer, id) { + if (list->resume) { + err = list->resume(list); + if (err < 0) +diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h +index 545d99b09706..7d16a9221070 100644 +--- a/sound/usb/mixer.h ++++ b/sound/usb/mixer.h +@@ -48,10 +48,17 @@ struct usb_mixer_elem_list { + struct usb_mixer_elem_list *next_id_elem; /* list of controls with same id */ + struct snd_kcontrol *kctl; + unsigned int id; ++ bool is_std_info; + usb_mixer_elem_dump_func_t dump; + usb_mixer_elem_resume_func_t resume; + }; + ++/* iterate over mixer element list of the given unit id */ ++#define for_each_mixer_elem(list, mixer, id) \ ++ for ((list) = (mixer)->id_elems[id]; (list); (list) = (list)->next_id_elem) ++#define mixer_elem_list_to_info(list) \ ++ container_of(list, struct usb_mixer_elem_info, head) ++ + struct usb_mixer_elem_info { + struct usb_mixer_elem_list head; + unsigned int control; /* CS or ICN (high byte) */ +@@ -79,8 +86,12 @@ void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid); + int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, + int request, int validx, int value_set); + +-int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list, +- struct snd_kcontrol *kctl); ++int snd_usb_mixer_add_list(struct usb_mixer_elem_list *list, ++ struct snd_kcontrol *kctl, ++ bool is_std_info); ++ ++#define snd_usb_mixer_add_control(list, kctl) \ ++ snd_usb_mixer_add_list(list, kctl, true) + + void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, + struct usb_mixer_interface *mixer, +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c +index 723b535ca2ec..9646513f4b4a 100644 +--- a/sound/usb/mixer_quirks.c ++++ b/sound/usb/mixer_quirks.c +@@ -168,7 +168,8 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer, + return -ENOMEM; + } + kctl->private_free = snd_usb_mixer_elem_free; +- return snd_usb_mixer_add_control(list, kctl); ++ /* don't use snd_usb_mixer_add_control() here, this is a special list element */ ++ return snd_usb_mixer_add_list(list, kctl, false); + } + + /* +@@ -1167,17 +1168,17 @@ void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, + { + struct usb_mixer_interface *mixer; + struct usb_mixer_elem_info *cval; +- int unitid = 12; /* SamleRate ExtensionUnit ID */ ++ int unitid = 12; /* SampleRate ExtensionUnit ID */ + + list_for_each_entry(mixer, &chip->mixer_list, list) { +- cval = (struct usb_mixer_elem_info *)mixer->id_elems[unitid]; +- if (cval) { ++ if (mixer->id_elems[unitid]) { ++ cval = mixer_elem_list_to_info(mixer->id_elems[unitid]); + snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, + cval->control << 8, + samplerate_id); + snd_usb_mixer_notify_id(mixer, unitid); ++ break; + } +- break; + } + } + +diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c +index 7438e7c4a842..2876cd9b35b3 100644 +--- a/sound/usb/mixer_scarlett.c ++++ b/sound/usb/mixer_scarlett.c +@@ -287,8 +287,7 @@ static int scarlett_ctl_switch_put(struct snd_kcontrol *kctl, + + static int scarlett_ctl_resume(struct usb_mixer_elem_list *list) + { +- struct usb_mixer_elem_info *elem = +- container_of(list, struct usb_mixer_elem_info, head); ++ struct usb_mixer_elem_info *elem = mixer_elem_list_to_info(list); + int i; + + for (i = 0; i < elem->channels; i++) +@@ -447,8 +446,7 @@ static int scarlett_ctl_enum_put(struct snd_kcontrol *kctl, + + static int scarlett_ctl_enum_resume(struct usb_mixer_elem_list *list) + { +- struct usb_mixer_elem_info *elem = +- container_of(list, struct usb_mixer_elem_info, head); ++ struct usb_mixer_elem_info *elem = mixer_elem_list_to_info(list); + + if (elem->cached) + snd_usb_set_cur_mix_value(elem, 0, 0, *elem->cache_val); +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c +index f84c55ecd0fb..53d91cae86f9 100644 +--- a/sound/usb/pcm.c ++++ b/sound/usb/pcm.c +@@ -1473,6 +1473,8 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, + for (i = 0; i < ctx->packets; i++) { + if (ctx->packet_size[i]) + counts = ctx->packet_size[i]; ++ else if (ep->sync_master) ++ counts = snd_usb_endpoint_slave_next_packet_size(ep); + else + counts = snd_usb_endpoint_next_packet_size(ep); + +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index b7a7bf0e566c..47979c9c3e29 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1162,6 +1162,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) + static bool is_marantz_denon_dac(unsigned int id) + { + switch (id) { ++ case USB_ID(0x154e, 0x1002): /* Denon DCD-1500RE */ + case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */ + case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */ + case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */ +diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c +index f256fac1e722..74dd196acdac 100644 +--- a/tools/perf/builtin-report.c ++++ b/tools/perf/builtin-report.c +@@ -334,8 +334,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report + if (evname != NULL) + ret += fprintf(fp, " of event '%s'", evname); + +- if (symbol_conf.show_ref_callgraph && +- strstr(evname, "call-graph=no")) { ++ if (symbol_conf.show_ref_callgraph && evname && strstr(evname, "call-graph=no")) { + ret += fprintf(fp, ", show reference callgraph"); + } + +diff --git a/tools/testing/selftests/networking/timestamping/timestamping.c b/tools/testing/selftests/networking/timestamping/timestamping.c +index 5cdfd743447b..900ed4b47899 100644 +--- a/tools/testing/selftests/networking/timestamping/timestamping.c ++++ b/tools/testing/selftests/networking/timestamping/timestamping.c +@@ -332,10 +332,16 @@ int main(int argc, char **argv) + int val; + socklen_t len; + struct timeval next; ++ size_t if_len; + + if (argc < 2) + usage(0); + interface = argv[1]; ++ if_len = strlen(interface); ++ if (if_len >= IFNAMSIZ) { ++ printf("interface name exceeds IFNAMSIZ\n"); ++ exit(1); ++ } + + for (i = 2; i < argc; i++) { + if (!strcasecmp(argv[i], "SO_TIMESTAMP")) +@@ -369,12 +375,12 @@ int main(int argc, char **argv) + bail("socket"); + + memset(&device, 0, sizeof(device)); +- strncpy(device.ifr_name, interface, sizeof(device.ifr_name)); ++ memcpy(device.ifr_name, interface, if_len + 1); + if (ioctl(sock, SIOCGIFADDR, &device) < 0) + bail("getting interface IP address"); + + memset(&hwtstamp, 0, sizeof(hwtstamp)); +- strncpy(hwtstamp.ifr_name, interface, sizeof(hwtstamp.ifr_name)); ++ memcpy(hwtstamp.ifr_name, interface, if_len + 1); + hwtstamp.ifr_data = (void *)&hwconfig; + memset(&hwconfig, 0, sizeof(hwconfig)); + hwconfig.tx_type = diff --git a/patch/kernel/rockpis-legacy/patch-4.4.229-230.patch b/patch/kernel/rockpis-legacy/patch-4.4.229-230.patch new file mode 100644 index 000000000..131ab2d59 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.229-230.patch @@ -0,0 +1,679 @@ +diff --git a/Makefile b/Makefile +index 99b211904ac5..847f2537d39d 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 229 ++SUBLEVEL = 230 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c +index 6abd6b41c13d..36472fc266fd 100644 +--- a/arch/mips/kernel/traps.c ++++ b/arch/mips/kernel/traps.c +@@ -2080,6 +2080,7 @@ static void configure_status(void) + + change_c0_status(ST0_CU|ST0_MX|ST0_RE|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX, + status_set); ++ back_to_back_c0_hazard(); + } + + /* configure HWRENA register */ +diff --git a/crypto/af_alg.c b/crypto/af_alg.c +index cf3975ee4fd8..c48ddeb6c328 100644 +--- a/crypto/af_alg.c ++++ b/crypto/af_alg.c +@@ -130,21 +130,15 @@ EXPORT_SYMBOL_GPL(af_alg_release); + void af_alg_release_parent(struct sock *sk) + { + struct alg_sock *ask = alg_sk(sk); +- unsigned int nokey = ask->nokey_refcnt; +- bool last = nokey && !ask->refcnt; ++ unsigned int nokey = atomic_read(&ask->nokey_refcnt); + + sk = ask->parent; + ask = alg_sk(sk); + +- local_bh_disable(); +- bh_lock_sock(sk); +- ask->nokey_refcnt -= nokey; +- if (!last) +- last = !--ask->refcnt; +- bh_unlock_sock(sk); +- local_bh_enable(); ++ if (nokey) ++ atomic_dec(&ask->nokey_refcnt); + +- if (last) ++ if (atomic_dec_and_test(&ask->refcnt)) + sock_put(sk); + } + EXPORT_SYMBOL_GPL(af_alg_release_parent); +@@ -189,7 +183,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) + + err = -EBUSY; + lock_sock(sk); +- if (ask->refcnt | ask->nokey_refcnt) ++ if (atomic_read(&ask->refcnt)) + goto unlock; + + swap(ask->type, type); +@@ -238,7 +232,7 @@ static int alg_setsockopt(struct socket *sock, int level, int optname, + int err = -EBUSY; + + lock_sock(sk); +- if (ask->refcnt) ++ if (atomic_read(&ask->refcnt) != atomic_read(&ask->nokey_refcnt)) + goto unlock; + + type = ask->type; +@@ -305,12 +299,14 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) + + sk2->sk_family = PF_ALG; + +- if (nokey || !ask->refcnt++) ++ if (atomic_inc_return_relaxed(&ask->refcnt) == 1) + sock_hold(sk); +- ask->nokey_refcnt += nokey; ++ if (nokey) { ++ atomic_inc(&ask->nokey_refcnt); ++ atomic_set(&alg_sk(sk2)->nokey_refcnt, 1); ++ } + alg_sk(sk2)->parent = sk; + alg_sk(sk2)->type = type; +- alg_sk(sk2)->nokey_refcnt = nokey; + + newsock->ops = type->ops; + newsock->state = SS_CONNECTED; +diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c +index faea9d728fd2..c50175ad5485 100644 +--- a/crypto/algif_aead.c ++++ b/crypto/algif_aead.c +@@ -528,7 +528,7 @@ static int aead_check_key(struct socket *sock) + struct alg_sock *ask = alg_sk(sk); + + lock_sock(sk); +- if (ask->refcnt) ++ if (!atomic_read(&ask->nokey_refcnt)) + goto unlock_child; + + psk = ask->parent; +@@ -540,11 +540,8 @@ static int aead_check_key(struct socket *sock) + if (!tfm->has_key) + goto unlock; + +- if (!pask->refcnt++) +- sock_hold(psk); +- +- ask->refcnt = 1; +- sock_put(psk); ++ atomic_dec(&pask->nokey_refcnt); ++ atomic_set(&ask->nokey_refcnt, 0); + + err = 0; + +diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c +index 8d8b3eeba725..fd23261f1d16 100644 +--- a/crypto/algif_hash.c ++++ b/crypto/algif_hash.c +@@ -252,7 +252,7 @@ static int hash_check_key(struct socket *sock) + struct alg_sock *ask = alg_sk(sk); + + lock_sock(sk); +- if (ask->refcnt) ++ if (!atomic_read(&ask->nokey_refcnt)) + goto unlock_child; + + psk = ask->parent; +@@ -264,11 +264,8 @@ static int hash_check_key(struct socket *sock) + if (!tfm->has_key) + goto unlock; + +- if (!pask->refcnt++) +- sock_hold(psk); +- +- ask->refcnt = 1; +- sock_put(psk); ++ atomic_dec(&pask->nokey_refcnt); ++ atomic_set(&ask->nokey_refcnt, 0); + + err = 0; + +diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c +index 9bd4691cc5c5..0e200bf5aa82 100644 +--- a/crypto/algif_skcipher.c ++++ b/crypto/algif_skcipher.c +@@ -774,7 +774,7 @@ static int skcipher_check_key(struct socket *sock) + struct alg_sock *ask = alg_sk(sk); + + lock_sock(sk); +- if (ask->refcnt) ++ if (!atomic_read(&ask->nokey_refcnt)) + goto unlock_child; + + psk = ask->parent; +@@ -786,11 +786,8 @@ static int skcipher_check_key(struct socket *sock) + if (!tfm->has_key) + goto unlock; + +- if (!pask->refcnt++) +- sock_hold(psk); +- +- ask->refcnt = 1; +- sock_put(psk); ++ atomic_dec(&pask->nokey_refcnt); ++ atomic_set(&ask->nokey_refcnt, 0); + + err = 0; + +diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c +index 1e5cd39d0cc2..bdc3efacd0d2 100644 +--- a/drivers/block/virtio_blk.c ++++ b/drivers/block/virtio_blk.c +@@ -757,6 +757,7 @@ out_put_disk: + put_disk(vblk->disk); + out_free_vq: + vdev->config->del_vqs(vdev); ++ kfree(vblk->vqs); + out_free_vblk: + kfree(vblk); + out_free_index: +diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c +index 932ba7676183..5f86075e34da 100644 +--- a/drivers/edac/amd64_edac.c ++++ b/drivers/edac/amd64_edac.c +@@ -248,6 +248,8 @@ static int get_scrub_rate(struct mem_ctl_info *mci) + + if (pvt->model == 0x60) + amd64_read_pci_cfg(pvt->F2, F15H_M60H_SCRCTRL, &scrubval); ++ else ++ amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval); + } else + amd64_read_pci_cfg(pvt->F3, SCRCTRL, &scrubval); + +diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c +index e27f7e12c05b..9b4ad6c74041 100644 +--- a/drivers/hwmon/acpi_power_meter.c ++++ b/drivers/hwmon/acpi_power_meter.c +@@ -895,7 +895,7 @@ static int acpi_power_meter_add(struct acpi_device *device) + + res = setup_attrs(resource); + if (res) +- goto exit_free; ++ goto exit_free_capability; + + resource->hwmon_dev = hwmon_device_register(&device->dev); + if (IS_ERR(resource->hwmon_dev)) { +@@ -908,6 +908,8 @@ static int acpi_power_meter_add(struct acpi_device *device) + + exit_remove: + remove_attrs(resource); ++exit_free_capability: ++ free_capabilities(resource); + exit_free: + kfree(resource); + exit: +diff --git a/drivers/hwmon/max6697.c b/drivers/hwmon/max6697.c +index f03a71722849..d4bb3d6aaf18 100644 +--- a/drivers/hwmon/max6697.c ++++ b/drivers/hwmon/max6697.c +@@ -46,8 +46,9 @@ static const u8 MAX6697_REG_CRIT[] = { + * Map device tree / platform data register bit map to chip bit map. + * Applies to alert register and over-temperature register. + */ +-#define MAX6697_MAP_BITS(reg) ((((reg) & 0x7e) >> 1) | \ ++#define MAX6697_ALERT_MAP_BITS(reg) ((((reg) & 0x7e) >> 1) | \ + (((reg) & 0x01) << 6) | ((reg) & 0x80)) ++#define MAX6697_OVERT_MAP_BITS(reg) (((reg) >> 1) | (((reg) & 0x01) << 7)) + + #define MAX6697_REG_STAT(n) (0x44 + (n)) + +@@ -586,12 +587,12 @@ static int max6697_init_chip(struct max6697_data *data, + return ret; + + ret = i2c_smbus_write_byte_data(client, MAX6697_REG_ALERT_MASK, +- MAX6697_MAP_BITS(pdata->alert_mask)); ++ MAX6697_ALERT_MAP_BITS(pdata->alert_mask)); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_byte_data(client, MAX6697_REG_OVERT_MASK, +- MAX6697_MAP_BITS(pdata->over_temperature_mask)); ++ MAX6697_OVERT_MAP_BITS(pdata->over_temperature_mask)); + if (ret < 0) + return ret; + +diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c +index e370804ec8bc..3a9db4626cb6 100644 +--- a/drivers/i2c/algos/i2c-algo-pca.c ++++ b/drivers/i2c/algos/i2c-algo-pca.c +@@ -326,7 +326,8 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, + DEB2("BUS ERROR - SDA Stuck low\n"); + pca_reset(adap); + goto out; +- case 0x90: /* Bus error - SCL stuck low */ ++ case 0x78: /* Bus error - SCL stuck low (PCA9665) */ ++ case 0x90: /* Bus error - SCL stuck low (PCA9564) */ + DEB2("BUS ERROR - SCL Stuck low\n"); + pca_reset(adap); + goto out; +diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c +index bc92a498ec03..9f19aa950bb1 100644 +--- a/drivers/usb/misc/usbtest.c ++++ b/drivers/usb/misc/usbtest.c +@@ -2703,6 +2703,7 @@ static void usbtest_disconnect(struct usb_interface *intf) + + usb_set_intfdata(intf, NULL); + dev_dbg(&intf->dev, "disconnect\n"); ++ kfree(dev->buf); + kfree(dev); + } + +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c +index 972475eeb2dd..b1125778b908 100644 +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -926,7 +926,7 @@ static noinline int cow_file_range(struct inode *inode, + u64 alloc_hint = 0; + u64 num_bytes; + unsigned long ram_size; +- u64 disk_num_bytes; ++ u64 min_alloc_size; + u64 cur_alloc_size; + u64 blocksize = root->sectorsize; + struct btrfs_key ins; +@@ -942,7 +942,6 @@ static noinline int cow_file_range(struct inode *inode, + + num_bytes = ALIGN(end - start + 1, blocksize); + num_bytes = max(blocksize, num_bytes); +- disk_num_bytes = num_bytes; + + /* if this is a small write inside eof, kick off defrag */ + if (num_bytes < 64 * 1024 && +@@ -969,18 +968,33 @@ static noinline int cow_file_range(struct inode *inode, + } + } + +- BUG_ON(disk_num_bytes > +- btrfs_super_total_bytes(root->fs_info->super_copy)); ++ BUG_ON(num_bytes > btrfs_super_total_bytes(root->fs_info->super_copy)); + + alloc_hint = get_extent_allocation_hint(inode, start, num_bytes); + btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0); + +- while (disk_num_bytes > 0) { ++ /* ++ * Relocation relies on the relocated extents to have exactly the same ++ * size as the original extents. Normally writeback for relocation data ++ * extents follows a NOCOW path because relocation preallocates the ++ * extents. However, due to an operation such as scrub turning a block ++ * group to RO mode, it may fallback to COW mode, so we must make sure ++ * an extent allocated during COW has exactly the requested size and can ++ * not be split into smaller extents, otherwise relocation breaks and ++ * fails during the stage where it updates the bytenr of file extent ++ * items. ++ */ ++ if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID) ++ min_alloc_size = num_bytes; ++ else ++ min_alloc_size = root->sectorsize; ++ ++ while (num_bytes > 0) { + unsigned long op; + +- cur_alloc_size = disk_num_bytes; ++ cur_alloc_size = num_bytes; + ret = btrfs_reserve_extent(root, cur_alloc_size, +- root->sectorsize, 0, alloc_hint, ++ min_alloc_size, 0, alloc_hint, + &ins, 1, 1); + if (ret < 0) + goto out_unlock; +@@ -1033,7 +1047,7 @@ static noinline int cow_file_range(struct inode *inode, + goto out_drop_extent_cache; + } + +- if (disk_num_bytes < cur_alloc_size) ++ if (num_bytes < cur_alloc_size) + break; + + /* we're not doing compressed IO, don't unlock the first +@@ -1050,8 +1064,10 @@ static noinline int cow_file_range(struct inode *inode, + start + ram_size - 1, locked_page, + EXTENT_LOCKED | EXTENT_DELALLOC, + op); +- disk_num_bytes -= cur_alloc_size; +- num_bytes -= cur_alloc_size; ++ if (num_bytes < cur_alloc_size) ++ num_bytes = 0; ++ else ++ num_bytes -= cur_alloc_size; + alloc_hint = ins.objectid + ins.offset; + start += cur_alloc_size; + } +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c +index 21ddfd77966e..f4ef8d6ea8ed 100644 +--- a/fs/cifs/connect.c ++++ b/fs/cifs/connect.c +@@ -4203,9 +4203,12 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) + vol_info->retry = master_tcon->retry; + vol_info->nocase = master_tcon->nocase; + vol_info->local_lease = master_tcon->local_lease; ++ vol_info->resilient = master_tcon->use_resilient; ++ vol_info->persistent = master_tcon->use_persistent; + vol_info->no_linux_ext = !master_tcon->unix_ext; + vol_info->sectype = master_tcon->ses->sectype; + vol_info->sign = master_tcon->ses->sign; ++ vol_info->seal = master_tcon->seal; + + rc = cifs_set_vol_auth(vol_info, master_tcon->ses); + if (rc) { +diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c +index c18c26a78453..a002e289a544 100644 +--- a/fs/cifs/inode.c ++++ b/fs/cifs/inode.c +@@ -1737,6 +1737,7 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry, + FILE_UNIX_BASIC_INFO *info_buf_target; + unsigned int xid; + int rc, tmprc; ++ bool new_target = d_really_is_negative(target_dentry); + + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; +@@ -1813,8 +1814,13 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry, + */ + + unlink_target: +- /* Try unlinking the target dentry if it's not negative */ +- if (d_really_is_positive(target_dentry) && (rc == -EACCES || rc == -EEXIST)) { ++ /* ++ * If the target dentry was created during the rename, try ++ * unlinking it if it's not negative ++ */ ++ if (new_target && ++ d_really_is_positive(target_dentry) && ++ (rc == -EACCES || rc == -EEXIST)) { + if (d_is_dir(target_dentry)) + tmprc = cifs_rmdir(target_dir, target_dentry); + else +diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h +index a2bfd7843f18..4bb6b98782e9 100644 +--- a/include/crypto/if_alg.h ++++ b/include/crypto/if_alg.h +@@ -30,8 +30,8 @@ struct alg_sock { + + struct sock *parent; + +- unsigned int refcnt; +- unsigned int nokey_refcnt; ++ atomic_t refcnt; ++ atomic_t nokey_refcnt; + + const struct af_alg_type *type; + void *private; +diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h +index c9e4731cf10b..7fc36ebc5de3 100644 +--- a/include/linux/sched/sysctl.h ++++ b/include/linux/sched/sysctl.h +@@ -81,6 +81,7 @@ extern unsigned int sysctl_sched_cfs_bandwidth_slice; + extern unsigned int sysctl_sched_autogroup_enabled; + #endif + ++extern int sysctl_sched_rr_timeslice; + extern int sched_rr_timeslice; + + extern int sched_rr_handler(struct ctl_table *table, int write, +diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c +index 9c939c6bf21c..321ccdbb7364 100644 +--- a/kernel/debug/debug_core.c ++++ b/kernel/debug/debug_core.c +@@ -488,6 +488,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, + arch_kgdb_ops.disable_hw_break(regs); + + acquirelock: ++ rcu_read_lock(); + /* + * Interrupts will be restored by the 'trap return' code, except when + * single stepping. +@@ -542,6 +543,7 @@ return_normal: + atomic_dec(&slaves_in_kgdb); + dbg_touch_watchdogs(); + local_irq_restore(flags); ++ rcu_read_unlock(); + return 0; + } + cpu_relax(); +@@ -560,6 +562,7 @@ return_normal: + raw_spin_unlock(&dbg_master_lock); + dbg_touch_watchdogs(); + local_irq_restore(flags); ++ rcu_read_unlock(); + + goto acquirelock; + } +@@ -677,6 +680,7 @@ kgdb_restore: + raw_spin_unlock(&dbg_master_lock); + dbg_touch_watchdogs(); + local_irq_restore(flags); ++ rcu_read_unlock(); + + return kgdb_info[cpu].ret_state; + } +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index 14a87c1f3a3a..4a0a754f24c8 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -8266,8 +8266,9 @@ int sched_rr_handler(struct ctl_table *table, int write, + /* make sure that internally we keep jiffies */ + /* also, writing zero resets timeslice to default */ + if (!ret && write) { +- sched_rr_timeslice = sched_rr_timeslice <= 0 ? +- RR_TIMESLICE : msecs_to_jiffies(sched_rr_timeslice); ++ sched_rr_timeslice = ++ sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE : ++ msecs_to_jiffies(sysctl_sched_rr_timeslice); + } + mutex_unlock(&mutex); + return ret; +diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c +index 801b4ec40702..5ee5740635f3 100644 +--- a/kernel/sched/rt.c ++++ b/kernel/sched/rt.c +@@ -9,6 +9,7 @@ + #include + + int sched_rr_timeslice = RR_TIMESLICE; ++int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE; + + static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun); + +diff --git a/kernel/sysctl.c b/kernel/sysctl.c +index c2dddd335d06..ecbb1b764a82 100644 +--- a/kernel/sysctl.c ++++ b/kernel/sysctl.c +@@ -412,7 +412,7 @@ static struct ctl_table kern_table[] = { + }, + { + .procname = "sched_rr_timeslice_ms", +- .data = &sched_rr_timeslice, ++ .data = &sysctl_sched_rr_timeslice, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sched_rr_handler, +diff --git a/mm/slub.c b/mm/slub.c +index bb5237c67cbc..a3870034bfcc 100644 +--- a/mm/slub.c ++++ b/mm/slub.c +@@ -5305,7 +5305,8 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) + */ + if (buffer) + buf = buffer; +- else if (root_cache->max_attr_size < ARRAY_SIZE(mbuf)) ++ else if (root_cache->max_attr_size < ARRAY_SIZE(mbuf) && ++ !IS_ENABLED(CONFIG_SLUB_STATS)) + buf = mbuf; + else { + buffer = (char *) get_zeroed_page(GFP_KERNEL); +diff --git a/mm/swap_state.c b/mm/swap_state.c +index d504adb7fa5f..9e587464e634 100644 +--- a/mm/swap_state.c ++++ b/mm/swap_state.c +@@ -19,6 +19,7 @@ + #include + + #include ++#include "internal.h" + + /* + * swapper_space is a fiction, retained to simplify the path through +@@ -319,7 +320,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, + /* + * call radix_tree_preload() while we can wait. + */ +- err = radix_tree_maybe_preload(gfp_mask & GFP_KERNEL); ++ err = radix_tree_maybe_preload(gfp_mask & GFP_RECLAIM_MASK); + if (err) + break; + +diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c +index 9511af04dc81..15495b956855 100644 +--- a/net/netfilter/nf_conntrack_h323_main.c ++++ b/net/netfilter/nf_conntrack_h323_main.c +@@ -1225,6 +1225,7 @@ static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = { + { + .name = "Q.931", + .me = THIS_MODULE, ++ .data_len = sizeof(struct nf_ct_h323_master), + .tuple.src.l3num = AF_INET6, + .tuple.src.u.tcp.port = cpu_to_be16(Q931_PORT), + .tuple.dst.protonum = IPPROTO_TCP, +diff --git a/sound/usb/card.h b/sound/usb/card.h +index 844c68863810..71778ca4b26a 100644 +--- a/sound/usb/card.h ++++ b/sound/usb/card.h +@@ -80,10 +80,6 @@ struct snd_usb_endpoint { + dma_addr_t sync_dma; /* DMA address of syncbuf */ + + unsigned int pipe; /* the data i/o pipe */ +- unsigned int framesize[2]; /* small/large frame sizes in samples */ +- unsigned int sample_rem; /* remainder from division fs/fps */ +- unsigned int sample_accum; /* sample accumulator */ +- unsigned int fps; /* frames per second */ + unsigned int freqn; /* nominal sampling rate in fs/fps in Q16.16 format */ + unsigned int freqm; /* momentary sampling rate in fs/fps in Q16.16 format */ + int freqshift; /* how much to shift the feedback value to get Q16.16 */ +diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c +index 666731317b33..66648b4bdd28 100644 +--- a/sound/usb/endpoint.c ++++ b/sound/usb/endpoint.c +@@ -137,12 +137,12 @@ int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep) + + /* + * For streaming based on information derived from sync endpoints, +- * prepare_outbound_urb_sizes() will call slave_next_packet_size() to ++ * prepare_outbound_urb_sizes() will call next_packet_size() to + * determine the number of samples to be sent in the next packet. + * +- * For implicit feedback, slave_next_packet_size() is unused. ++ * For implicit feedback, next_packet_size() is unused. + */ +-int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep) ++int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep) + { + unsigned long flags; + int ret; +@@ -159,29 +159,6 @@ int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep) + return ret; + } + +-/* +- * For adaptive and synchronous endpoints, prepare_outbound_urb_sizes() +- * will call next_packet_size() to determine the number of samples to be +- * sent in the next packet. +- */ +-int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep) +-{ +- int ret; +- +- if (ep->fill_max) +- return ep->maxframesize; +- +- ep->sample_accum += ep->sample_rem; +- if (ep->sample_accum >= ep->fps) { +- ep->sample_accum -= ep->fps; +- ret = ep->framesize[1]; +- } else { +- ret = ep->framesize[0]; +- } +- +- return ret; +-} +- + static void retire_outbound_urb(struct snd_usb_endpoint *ep, + struct snd_urb_ctx *urb_ctx) + { +@@ -226,8 +203,6 @@ static void prepare_silent_urb(struct snd_usb_endpoint *ep, + + if (ctx->packet_size[i]) + counts = ctx->packet_size[i]; +- else if (ep->sync_master) +- counts = snd_usb_endpoint_slave_next_packet_size(ep); + else + counts = snd_usb_endpoint_next_packet_size(ep); + +@@ -904,17 +879,10 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, + ep->maxpacksize = fmt->maxpacksize; + ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX); + +- if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) { ++ if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) + ep->freqn = get_usb_full_speed_rate(rate); +- ep->fps = 1000; +- } else { ++ else + ep->freqn = get_usb_high_speed_rate(rate); +- ep->fps = 8000; +- } +- +- ep->sample_rem = rate % ep->fps; +- ep->framesize[0] = rate / ep->fps; +- ep->framesize[1] = (rate + (ep->fps - 1)) / ep->fps; + + /* calculate the frequency in 16.16 format */ + ep->freqm = ep->freqn; +@@ -973,7 +941,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) + ep->active_mask = 0; + ep->unlink_mask = 0; + ep->phase = 0; +- ep->sample_accum = 0; + + snd_usb_endpoint_start_quirk(ep); + +diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h +index 4aad49cbeb5f..584f295d7c77 100644 +--- a/sound/usb/endpoint.h ++++ b/sound/usb/endpoint.h +@@ -27,7 +27,6 @@ void snd_usb_endpoint_release(struct snd_usb_endpoint *ep); + void snd_usb_endpoint_free(struct snd_usb_endpoint *ep); + + int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); +-int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep); + int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); + + void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c +index 53d91cae86f9..f84c55ecd0fb 100644 +--- a/sound/usb/pcm.c ++++ b/sound/usb/pcm.c +@@ -1473,8 +1473,6 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, + for (i = 0; i < ctx->packets; i++) { + if (ctx->packet_size[i]) + counts = ctx->packet_size[i]; +- else if (ep->sync_master) +- counts = snd_usb_endpoint_slave_next_packet_size(ep); + else + counts = snd_usb_endpoint_next_packet_size(ep); + diff --git a/patch/kernel/rockpis-legacy/patch-4.4.230-231.patch b/patch/kernel/rockpis-legacy/patch-4.4.230-231.patch new file mode 100644 index 000000000..fc5b825e3 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.230-231.patch @@ -0,0 +1,1715 @@ +diff --git a/Makefile b/Makefile +index 847f2537d39d..46178c83906c 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 230 ++SUBLEVEL = 231 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h +index 8ee9113b2f8b..b060eb8ad91b 100644 +--- a/arch/arc/include/asm/elf.h ++++ b/arch/arc/include/asm/elf.h +@@ -27,7 +27,7 @@ + #define R_ARC_S25W_PCREL 0x11 + + /*to set parameters in the core dumps */ +-#define ELF_ARCH EM_ARCOMPACT ++#define ELF_ARCH EM_ARC_INUSE + #define ELF_CLASS ELFCLASS32 + + #ifdef CONFIG_CPU_BIG_ENDIAN +diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S +index db1eee5fe502..5e3f1edf5a29 100644 +--- a/arch/arc/kernel/entry.S ++++ b/arch/arc/kernel/entry.S +@@ -168,7 +168,6 @@ END(EV_Extension) + tracesys: + ; save EFA in case tracer wants the PC of traced task + ; using ERET won't work since next-PC has already committed +- lr r12, [efa] + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11 + st r12, [r11, THREAD_FAULT_ADDR] ; thread.fault_address + +@@ -211,15 +210,9 @@ tracesys_exit: + ; Breakpoint TRAP + ; --------------------------------------------- + trap_with_param: +- +- ; stop_pc info by gdb needs this info +- lr r0, [efa] ++ mov r0, r12 ; EFA in case ptracer/gdb wants stop_pc + mov r1, sp + +- ; Now that we have read EFA, it is safe to do "fake" rtie +- ; and get out of CPU exception mode +- FAKE_RET_FROM_EXCPN +- + ; Save callee regs in case gdb wants to have a look + ; SP will grow up by size of CALLEE Reg-File + ; NOTE: clobbers r12 +@@ -246,6 +239,10 @@ ENTRY(EV_Trap) + + EXCEPTION_PROLOGUE + ++ lr r12, [efa] ++ ++ FAKE_RET_FROM_EXCPN ++ + ;============ TRAP 1 :breakpoints + ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR) + bmsk.f 0, r9, 7 +@@ -253,9 +250,6 @@ ENTRY(EV_Trap) + + ;============ TRAP (no param): syscall top level + +- ; First return from Exception to pure K mode (Exception/IRQs renabled) +- FAKE_RET_FROM_EXCPN +- + ; If syscall tracing ongoing, invoke pre-post-hooks + GET_CURR_THR_INFO_FLAGS r10 + btst r10, TIF_SYSCALL_TRACE +diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c +index f72743dc070d..606c21760f23 100644 +--- a/arch/arm64/kernel/kgdb.c ++++ b/arch/arm64/kernel/kgdb.c +@@ -238,7 +238,7 @@ static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) + if (user_mode(regs)) + return DBG_HOOK_ERROR; + +- kgdb_handle_exception(1, SIGTRAP, 0, regs); ++ kgdb_handle_exception(0, SIGTRAP, 0, regs); + return DBG_HOOK_HANDLED; + } + +diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c +index 345978cc105b..fbb99c430f13 100644 +--- a/arch/mips/kernel/time.c ++++ b/arch/mips/kernel/time.c +@@ -40,10 +40,8 @@ static unsigned long glb_lpj_ref_freq; + static int cpufreq_callback(struct notifier_block *nb, + unsigned long val, void *data) + { +- struct cpufreq_freqs *freq = data; +- struct cpumask *cpus = freq->policy->cpus; +- unsigned long lpj; + int cpu; ++ struct cpufreq_freqs *freq = data; + + /* + * Skip lpj numbers adjustment if the CPU-freq transition is safe for +@@ -64,6 +62,7 @@ static int cpufreq_callback(struct notifier_block *nb, + } + } + ++ cpu = freq->cpu; + /* + * Adjust global lpj variable and per-CPU udelay_val number in + * accordance with the new CPU frequency. +@@ -74,12 +73,8 @@ static int cpufreq_callback(struct notifier_block *nb, + glb_lpj_ref_freq, + freq->new); + +- for_each_cpu(cpu, cpus) { +- lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu), +- per_cpu(pcp_lpj_ref_freq, cpu), +- freq->new); +- cpu_data[cpu].udelay_val = (unsigned int)lpj; +- } ++ cpu_data[cpu].udelay_val = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu), ++ per_cpu(pcp_lpj_ref_freq, cpu), freq->new); + } + + return NOTIFY_OK; +diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h +index 7d9c5917da2b..737bc0a39463 100644 +--- a/arch/s390/include/asm/kvm_host.h ++++ b/arch/s390/include/asm/kvm_host.h +@@ -29,12 +29,12 @@ + #define KVM_USER_MEM_SLOTS 32 + + /* +- * These seem to be used for allocating ->chip in the routing table, +- * which we don't use. 4096 is an out-of-thin-air value. If we need +- * to look at ->chip later on, we'll need to revisit this. ++ * These seem to be used for allocating ->chip in the routing table, which we ++ * don't use. 1 is as small as we can get to reduce the needed memory. If we ++ * need to look at ->chip later on, we'll need to revisit this. + */ + #define KVM_NR_IRQCHIPS 1 +-#define KVM_IRQCHIP_NUM_PINS 4096 ++#define KVM_IRQCHIP_NUM_PINS 1 + #define KVM_HALT_POLL_NS_DEFAULT 0 + + #define SIGP_CTRL_C 0x80 +diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c +index a5b533aea958..2ff0fe32c015 100644 +--- a/arch/x86/kvm/mmu.c ++++ b/arch/x86/kvm/mmu.c +@@ -3679,7 +3679,7 @@ __reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, + nonleaf_bit8_rsvd | rsvd_bits(7, 7) | + rsvd_bits(maxphyaddr, 51); + rsvd_check->rsvd_bits_mask[0][2] = exb_bit_rsvd | +- nonleaf_bit8_rsvd | gbpages_bit_rsvd | ++ gbpages_bit_rsvd | + rsvd_bits(maxphyaddr, 51); + rsvd_check->rsvd_bits_mask[0][1] = exb_bit_rsvd | + rsvd_bits(maxphyaddr, 51); +diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c +index 5e0e29ee31d1..226ccb7891d4 100644 +--- a/drivers/char/virtio_console.c ++++ b/drivers/char/virtio_console.c +@@ -2155,6 +2155,7 @@ static struct virtio_device_id id_table[] = { + { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, + { 0 }, + }; ++MODULE_DEVICE_TABLE(virtio, id_table); + + static unsigned int features[] = { + VIRTIO_CONSOLE_F_SIZE, +@@ -2167,6 +2168,7 @@ static struct virtio_device_id rproc_serial_id_table[] = { + #endif + { 0 }, + }; ++MODULE_DEVICE_TABLE(virtio, rproc_serial_id_table); + + static unsigned int rproc_serial_features[] = { + }; +@@ -2319,6 +2321,5 @@ static void __exit fini(void) + module_init(init); + module_exit(fini); + +-MODULE_DEVICE_TABLE(virtio, id_table); + MODULE_DESCRIPTION("Virtio console driver"); + MODULE_LICENSE("GPL"); +diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c +index 915eec3cc279..c2bb8486d174 100644 +--- a/drivers/dma/fsl-edma.c ++++ b/drivers/dma/fsl-edma.c +@@ -671,6 +671,13 @@ static irqreturn_t fsl_edma_tx_handler(int irq, void *dev_id) + fsl_chan = &fsl_edma->chans[ch]; + + spin_lock(&fsl_chan->vchan.lock); ++ ++ if (!fsl_chan->edesc) { ++ /* terminate_all called before */ ++ spin_unlock(&fsl_chan->vchan.lock); ++ continue; ++ } ++ + if (!fsl_chan->edesc->iscyclic) { + list_del(&fsl_chan->edesc->vdesc.node); + vchan_cookie_complete(&fsl_chan->edesc->vdesc); +diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c +index 2ccf81168d1e..e7a245d7bdbc 100644 +--- a/drivers/gpu/drm/radeon/ci_dpm.c ++++ b/drivers/gpu/drm/radeon/ci_dpm.c +@@ -5554,6 +5554,7 @@ static int ci_parse_power_table(struct radeon_device *rdev) + if (!rdev->pm.dpm.ps) + return -ENOMEM; + power_state_offset = (u8 *)state_array->states; ++ rdev->pm.dpm.num_ps = 0; + for (i = 0; i < state_array->ucNumEntries; i++) { + u8 *idx; + power_state = (union pplib_power_state *)power_state_offset; +@@ -5563,10 +5564,8 @@ static int ci_parse_power_table(struct radeon_device *rdev) + if (!rdev->pm.power_state[i].clock_info) + return -EINVAL; + ps = kzalloc(sizeof(struct ci_ps), GFP_KERNEL); +- if (ps == NULL) { +- kfree(rdev->pm.dpm.ps); ++ if (ps == NULL) + return -ENOMEM; +- } + rdev->pm.dpm.ps[i].ps_priv = ps; + ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i], + non_clock_info, +@@ -5588,8 +5587,8 @@ static int ci_parse_power_table(struct radeon_device *rdev) + k++; + } + power_state_offset += 2 + power_state->v2.ucNumDPMLevels; ++ rdev->pm.dpm.num_ps = i + 1; + } +- rdev->pm.dpm.num_ps = state_array->ucNumEntries; + + /* fill in the vce power states */ + for (i = 0; i < RADEON_MAX_VCE_LEVELS; i++) { +diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c +index d6fa496d0ca2..d15e824e39df 100644 +--- a/drivers/hid/hid-magicmouse.c ++++ b/drivers/hid/hid-magicmouse.c +@@ -451,6 +451,12 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd + __set_bit(MSC_RAW, input->mscbit); + } + ++ /* ++ * hid-input may mark device as using autorepeat, but neither ++ * the trackpad, nor the mouse actually want it. ++ */ ++ __clear_bit(EV_REP, input->evbit); ++ + return 0; + } + +diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c +index 952fe692d764..0ddb0677e9c8 100644 +--- a/drivers/hwmon/emc2103.c ++++ b/drivers/hwmon/emc2103.c +@@ -452,7 +452,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da, + } + + result = read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg); +- if (result) { ++ if (result < 0) { + count = result; + goto err; + } +diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c +index eef3aa6007f1..ffd8f9772096 100644 +--- a/drivers/i2c/busses/i2c-eg20t.c ++++ b/drivers/i2c/busses/i2c-eg20t.c +@@ -189,6 +189,7 @@ static const struct pci_device_id pch_pcidev_id[] = { + { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_I2C), 1, }, + {0,} + }; ++MODULE_DEVICE_TABLE(pci, pch_pcidev_id); + + static irqreturn_t pch_i2c_handler(int irq, void *pData); + +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h +index fd1e79013cf8..bdc42923523e 100644 +--- a/drivers/input/serio/i8042-x86ia64io.h ++++ b/drivers/input/serio/i8042-x86ia64io.h +@@ -429,6 +429,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { + DMI_MATCH(DMI_PRODUCT_NAME, "076804U"), + }, + }, ++ { ++ /* Lenovo XiaoXin Air 12 */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "80UN"), ++ }, ++ }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), +diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c +index 6c9fc11efb87..e77185e143ab 100644 +--- a/drivers/message/fusion/mptscsih.c ++++ b/drivers/message/fusion/mptscsih.c +@@ -118,8 +118,6 @@ int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); + int mptscsih_resume(struct pci_dev *pdev); + #endif + +-#define SNS_LEN(scp) SCSI_SENSE_BUFFERSIZE +- + + /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ + /* +@@ -2427,7 +2425,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR + /* Copy the sense received into the scsi command block. */ + req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); + sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); +- memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); ++ memcpy(sc->sense_buffer, sense_data, MPT_SENSE_BUFFER_ALLOC); + + /* Log SMART data (asc = 0x5D, non-IM case only) if required. + */ +diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c +index e2474af7386a..ae0f6a1a4be0 100644 +--- a/drivers/misc/atmel-ssc.c ++++ b/drivers/misc/atmel-ssc.c +@@ -13,7 +13,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -21,7 +21,7 @@ + #include + + /* Serialize access to ssc_list and user count */ +-static DEFINE_SPINLOCK(user_lock); ++static DEFINE_MUTEX(user_lock); + static LIST_HEAD(ssc_list); + + struct ssc_device *ssc_request(unsigned int ssc_num) +@@ -29,7 +29,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num) + int ssc_valid = 0; + struct ssc_device *ssc; + +- spin_lock(&user_lock); ++ mutex_lock(&user_lock); + list_for_each_entry(ssc, &ssc_list, list) { + if (ssc->pdev->dev.of_node) { + if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc") +@@ -44,18 +44,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num) + } + + if (!ssc_valid) { +- spin_unlock(&user_lock); ++ mutex_unlock(&user_lock); + pr_err("ssc: ssc%d platform device is missing\n", ssc_num); + return ERR_PTR(-ENODEV); + } + + if (ssc->user) { +- spin_unlock(&user_lock); ++ mutex_unlock(&user_lock); + dev_dbg(&ssc->pdev->dev, "module busy\n"); + return ERR_PTR(-EBUSY); + } + ssc->user++; +- spin_unlock(&user_lock); ++ mutex_unlock(&user_lock); + + clk_prepare(ssc->clk); + +@@ -67,14 +67,14 @@ void ssc_free(struct ssc_device *ssc) + { + bool disable_clk = true; + +- spin_lock(&user_lock); ++ mutex_lock(&user_lock); + if (ssc->user) + ssc->user--; + else { + disable_clk = false; + dev_dbg(&ssc->pdev->dev, "device already free\n"); + } +- spin_unlock(&user_lock); ++ mutex_unlock(&user_lock); + + if (disable_clk) + clk_unprepare(ssc->clk); +@@ -194,9 +194,9 @@ static int ssc_probe(struct platform_device *pdev) + return -ENXIO; + } + +- spin_lock(&user_lock); ++ mutex_lock(&user_lock); + list_add_tail(&ssc->list, &ssc_list); +- spin_unlock(&user_lock); ++ mutex_unlock(&user_lock); + + platform_set_drvdata(pdev, ssc); + +@@ -210,9 +210,9 @@ static int ssc_remove(struct platform_device *pdev) + { + struct ssc_device *ssc = platform_get_drvdata(pdev); + +- spin_lock(&user_lock); ++ mutex_lock(&user_lock); + list_del(&ssc->list); +- spin_unlock(&user_lock); ++ mutex_unlock(&user_lock); + + return 0; + } +diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c +index 864c2dc728a9..4457adb16916 100644 +--- a/drivers/misc/mei/bus.c ++++ b/drivers/misc/mei/bus.c +@@ -626,9 +626,8 @@ static int mei_cl_device_remove(struct device *dev) + ret = cldrv->remove(cldev); + + module_put(THIS_MODULE); +- dev->driver = NULL; +- return ret; + ++ return ret; + } + + static ssize_t name_show(struct device *dev, struct device_attribute *a, +diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c +index d125d19a35e4..8278158715c1 100644 +--- a/drivers/mtd/nand/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/brcmnand/brcmnand.c +@@ -455,8 +455,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl) + } else { + ctrl->cs_offsets = brcmnand_cs_offsets; + +- /* v5.0 and earlier has a different CS0 offset layout */ +- if (ctrl->nand_version <= 0x0500) ++ /* v3.3-5.0 have a different CS0 offset layout */ ++ if (ctrl->nand_version >= 0x0303 && ++ ctrl->nand_version <= 0x0500) + ctrl->cs0_offsets = brcmnand_cs_offsets_cs0; + } + +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +index 3eebb57975e3..dd2c64e2db5c 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +@@ -295,6 +295,7 @@ static void bnxt_free_vf_resources(struct bnxt *bp) + } + } + ++ bp->pf.active_vfs = 0; + kfree(bp->pf.vf); + bp->pf.vf = NULL; + } +@@ -535,7 +536,6 @@ void bnxt_sriov_disable(struct bnxt *bp) + + bnxt_free_vf_resources(bp); + +- bp->pf.active_vfs = 0; + bp->pf.max_pf_rx_rings = bp->pf.max_rx_rings; + bp->pf.max_pf_tx_rings = bp->pf.max_tx_rings; + } +diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +index fd6492fd3dc0..9d07fa318ac3 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +@@ -3093,7 +3093,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info, + drv_fw = &fw_info->fw_hdr; + + /* Read the header of the firmware on the card */ +- ret = -t4_read_flash(adap, FLASH_FW_START, ++ ret = t4_read_flash(adap, FLASH_FW_START, + sizeof(*card_fw) / sizeof(uint32_t), + (uint32_t *)card_fw, 1); + if (ret == 0) { +@@ -3122,8 +3122,8 @@ int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info, + should_install_fs_fw(adap, card_fw_usable, + be32_to_cpu(fs_fw->fw_ver), + be32_to_cpu(card_fw->fw_ver))) { +- ret = -t4_fw_upgrade(adap, adap->mbox, fw_data, +- fw_size, 0); ++ ret = t4_fw_upgrade(adap, adap->mbox, fw_data, ++ fw_size, 0); + if (ret != 0) { + dev_err(adap->pdev_dev, + "failed to install firmware: %d\n", ret); +@@ -3154,7 +3154,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info, + FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c), + FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k), + FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k)); +- ret = EINVAL; ++ ret = -EINVAL; + goto bye; + } + +diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c +index b6b8aec73b28..e4299852974e 100644 +--- a/drivers/net/usb/smsc95xx.c ++++ b/drivers/net/usb/smsc95xx.c +@@ -1136,11 +1136,14 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) + + /* Init all registers */ + ret = smsc95xx_reset(dev); ++ if (ret) ++ goto free_pdata; + + /* detect device revision as different features may be available */ + ret = smsc95xx_read_reg(dev, ID_REV, &val); + if (ret < 0) +- return ret; ++ goto free_pdata; ++ + val >>= 16; + + if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) || +@@ -1157,6 +1160,10 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) + dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM; + dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; + return 0; ++ ++free_pdata: ++ kfree(pdata); ++ return ret; + } + + static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c +index e51f1a577897..e2ed30b03af5 100644 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.c ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c +@@ -639,9 +639,9 @@ err: + + static void ath9k_hif_usb_rx_cb(struct urb *urb) + { +- struct rx_buf *rx_buf = (struct rx_buf *)urb->context; +- struct hif_device_usb *hif_dev = rx_buf->hif_dev; +- struct sk_buff *skb = rx_buf->skb; ++ struct sk_buff *skb = (struct sk_buff *) urb->context; ++ struct hif_device_usb *hif_dev = ++ usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); + int ret; + + if (!skb) +@@ -681,15 +681,14 @@ resubmit: + return; + free: + kfree_skb(skb); +- kfree(rx_buf); + } + + static void ath9k_hif_usb_reg_in_cb(struct urb *urb) + { +- struct rx_buf *rx_buf = (struct rx_buf *)urb->context; +- struct hif_device_usb *hif_dev = rx_buf->hif_dev; +- struct sk_buff *skb = rx_buf->skb; ++ struct sk_buff *skb = (struct sk_buff *) urb->context; + struct sk_buff *nskb; ++ struct hif_device_usb *hif_dev = ++ usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); + int ret; + + if (!skb) +@@ -747,7 +746,6 @@ resubmit: + return; + free: + kfree_skb(skb); +- kfree(rx_buf); + urb->context = NULL; + } + +@@ -793,7 +791,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev) + init_usb_anchor(&hif_dev->mgmt_submitted); + + for (i = 0; i < MAX_TX_URB_NUM; i++) { +- tx_buf = kzalloc(sizeof(*tx_buf), GFP_KERNEL); ++ tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL); + if (!tx_buf) + goto err; + +@@ -830,9 +828,8 @@ static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev) + + static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) + { +- struct rx_buf *rx_buf = NULL; +- struct sk_buff *skb = NULL; + struct urb *urb = NULL; ++ struct sk_buff *skb = NULL; + int i, ret; + + init_usb_anchor(&hif_dev->rx_submitted); +@@ -840,12 +837,6 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) + + for (i = 0; i < MAX_RX_URB_NUM; i++) { + +- rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL); +- if (!rx_buf) { +- ret = -ENOMEM; +- goto err_rxb; +- } +- + /* Allocate URB */ + urb = usb_alloc_urb(0, GFP_KERNEL); + if (urb == NULL) { +@@ -860,14 +851,11 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) + goto err_skb; + } + +- rx_buf->hif_dev = hif_dev; +- rx_buf->skb = skb; +- + usb_fill_bulk_urb(urb, hif_dev->udev, + usb_rcvbulkpipe(hif_dev->udev, + USB_WLAN_RX_PIPE), + skb->data, MAX_RX_BUF_SIZE, +- ath9k_hif_usb_rx_cb, rx_buf); ++ ath9k_hif_usb_rx_cb, skb); + + /* Anchor URB */ + usb_anchor_urb(urb, &hif_dev->rx_submitted); +@@ -893,8 +881,6 @@ err_submit: + err_skb: + usb_free_urb(urb); + err_urb: +- kfree(rx_buf); +-err_rxb: + ath9k_hif_usb_dealloc_rx_urbs(hif_dev); + return ret; + } +@@ -906,21 +892,14 @@ static void ath9k_hif_usb_dealloc_reg_in_urbs(struct hif_device_usb *hif_dev) + + static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev) + { +- struct rx_buf *rx_buf = NULL; +- struct sk_buff *skb = NULL; + struct urb *urb = NULL; ++ struct sk_buff *skb = NULL; + int i, ret; + + init_usb_anchor(&hif_dev->reg_in_submitted); + + for (i = 0; i < MAX_REG_IN_URB_NUM; i++) { + +- rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL); +- if (!rx_buf) { +- ret = -ENOMEM; +- goto err_rxb; +- } +- + /* Allocate URB */ + urb = usb_alloc_urb(0, GFP_KERNEL); + if (urb == NULL) { +@@ -935,14 +914,11 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev) + goto err_skb; + } + +- rx_buf->hif_dev = hif_dev; +- rx_buf->skb = skb; +- + usb_fill_int_urb(urb, hif_dev->udev, + usb_rcvintpipe(hif_dev->udev, + USB_REG_IN_PIPE), + skb->data, MAX_REG_IN_BUF_SIZE, +- ath9k_hif_usb_reg_in_cb, rx_buf, 1); ++ ath9k_hif_usb_reg_in_cb, skb, 1); + + /* Anchor URB */ + usb_anchor_urb(urb, &hif_dev->reg_in_submitted); +@@ -968,8 +944,6 @@ err_submit: + err_skb: + usb_free_urb(urb); + err_urb: +- kfree(rx_buf); +-err_rxb: + ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev); + return ret; + } +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h +index 835264c36595..a95cdf562611 100644 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.h ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.h +@@ -84,11 +84,6 @@ struct tx_buf { + struct list_head list; + }; + +-struct rx_buf { +- struct sk_buff *skb; +- struct hif_device_usb *hif_dev; +-}; +- + #define HIF_USB_TX_STOP BIT(0) + #define HIF_USB_TX_FLUSH BIT(1) + +diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c +index 3709088d4d24..7969f5484aee 100644 +--- a/drivers/spi/spidev.c ++++ b/drivers/spi/spidev.c +@@ -635,15 +635,20 @@ err_find_dev: + static int spidev_release(struct inode *inode, struct file *filp) + { + struct spidev_data *spidev; ++ int dofree; + + mutex_lock(&device_list_lock); + spidev = filp->private_data; + filp->private_data = NULL; + ++ spin_lock_irq(&spidev->spi_lock); ++ /* ... after we unbound from the underlying device? */ ++ dofree = (spidev->spi == NULL); ++ spin_unlock_irq(&spidev->spi_lock); ++ + /* last close? */ + spidev->users--; + if (!spidev->users) { +- int dofree; + + kfree(spidev->tx_buffer); + spidev->tx_buffer = NULL; +@@ -651,19 +656,14 @@ static int spidev_release(struct inode *inode, struct file *filp) + kfree(spidev->rx_buffer); + spidev->rx_buffer = NULL; + +- spin_lock_irq(&spidev->spi_lock); +- if (spidev->spi) +- spidev->speed_hz = spidev->spi->max_speed_hz; +- +- /* ... after we unbound from the underlying device? */ +- dofree = (spidev->spi == NULL); +- spin_unlock_irq(&spidev->spi_lock); +- + if (dofree) + kfree(spidev); ++ else ++ spidev->speed_hz = spidev->spi->max_speed_hz; + } + #ifdef CONFIG_SPI_SLAVE +- spi_slave_abort(spidev->spi); ++ if (!dofree) ++ spi_slave_abort(spidev->spi); + #endif + mutex_unlock(&device_list_lock); + +@@ -769,13 +769,13 @@ static int spidev_remove(struct spi_device *spi) + { + struct spidev_data *spidev = spi_get_drvdata(spi); + ++ /* prevent new opens */ ++ mutex_lock(&device_list_lock); + /* make sure ops on existing fds can abort cleanly */ + spin_lock_irq(&spidev->spi_lock); + spidev->spi = NULL; + spin_unlock_irq(&spidev->spi_lock); + +- /* prevent new opens */ +- mutex_lock(&device_list_lock); + list_del(&spidev->device_entry); + device_destroy(spidev_class, spidev->devt); + clear_bit(MINOR(spidev->devt), minors); +diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c +index 63991c49ff23..79a8799b1262 100644 +--- a/drivers/staging/comedi/drivers/addi_apci_1500.c ++++ b/drivers/staging/comedi/drivers/addi_apci_1500.c +@@ -465,9 +465,9 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev, + unsigned int lo_mask = data[5] << shift; + unsigned int chan_mask = hi_mask | lo_mask; + unsigned int old_mask = (1 << shift) - 1; +- unsigned int pm = devpriv->pm[trig] & old_mask; +- unsigned int pt = devpriv->pt[trig] & old_mask; +- unsigned int pp = devpriv->pp[trig] & old_mask; ++ unsigned int pm; ++ unsigned int pt; ++ unsigned int pp; + + if (trig > 1) { + dev_dbg(dev->class_dev, +@@ -480,6 +480,10 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev, + return -EINVAL; + } + ++ pm = devpriv->pm[trig] & old_mask; ++ pt = devpriv->pt[trig] & old_mask; ++ pp = devpriv->pp[trig] & old_mask; ++ + switch (data[2]) { + case COMEDI_DIGITAL_TRIG_DISABLE: + /* clear trigger configuration */ +diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c +index f598ecddc8a7..b58a504240c4 100644 +--- a/drivers/uio/uio_pdrv_genirq.c ++++ b/drivers/uio/uio_pdrv_genirq.c +@@ -148,7 +148,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev) + if (!uioinfo->irq) { + ret = platform_get_irq(pdev, 0); + uioinfo->irq = ret; +- if (ret == -ENXIO && pdev->dev.of_node) ++ if (ret == -ENXIO) + uioinfo->irq = UIO_IRQ_NONE; + else if (ret < 0) { + dev_err(&pdev->dev, "failed to get IRQ\n"); +diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c +index 7311ed61e99a..029c8bc54b7a 100644 +--- a/drivers/usb/c67x00/c67x00-sched.c ++++ b/drivers/usb/c67x00/c67x00-sched.c +@@ -500,7 +500,7 @@ c67x00_giveback_urb(struct c67x00_hcd *c67x00, struct urb *urb, int status) + c67x00_release_urb(c67x00, urb); + usb_hcd_unlink_urb_from_ep(c67x00_hcd_to_hcd(c67x00), urb); + spin_unlock(&c67x00->lock); +- usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, urbp->status); ++ usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb, status); + spin_lock(&c67x00->lock); + } + +diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c +index dee22d8effda..e104c99b3a1f 100644 +--- a/drivers/usb/chipidea/core.c ++++ b/drivers/usb/chipidea/core.c +@@ -1122,6 +1122,29 @@ static void ci_controller_suspend(struct ci_hdrc *ci) + enable_irq(ci->irq); + } + ++/* ++ * Handle the wakeup interrupt triggered by extcon connector ++ * We need to call ci_irq again for extcon since the first ++ * interrupt (wakeup int) only let the controller be out of ++ * low power mode, but not handle any interrupts. ++ */ ++static void ci_extcon_wakeup_int(struct ci_hdrc *ci) ++{ ++ struct ci_hdrc_cable *cable_id, *cable_vbus; ++ u32 otgsc = hw_read_otgsc(ci, ~0); ++ ++ cable_id = &ci->platdata->id_extcon; ++ cable_vbus = &ci->platdata->vbus_extcon; ++ ++ if (!IS_ERR(cable_id->edev) && ci->is_otg && ++ (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) ++ ci_irq(ci->irq, ci); ++ ++ if (!IS_ERR(cable_vbus->edev) && ci->is_otg && ++ (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) ++ ci_irq(ci->irq, ci); ++} ++ + static int ci_controller_resume(struct device *dev) + { + struct ci_hdrc *ci = dev_get_drvdata(dev); +@@ -1148,6 +1171,7 @@ static int ci_controller_resume(struct device *dev) + enable_irq(ci->irq); + if (ci_otg_is_fsm_mode(ci)) + ci_otg_fsm_wakeup_by_srp(ci); ++ ci_extcon_wakeup_int(ci); + } + + return 0; +diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c +index d6fcead91b32..c095cde55329 100644 +--- a/drivers/usb/core/urb.c ++++ b/drivers/usb/core/urb.c +@@ -185,6 +185,31 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); + + /*-------------------------------------------------------------------*/ + ++static const int pipetypes[4] = { ++ PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT ++}; ++ ++/** ++ * usb_urb_ep_type_check - sanity check of endpoint in the given urb ++ * @urb: urb to be checked ++ * ++ * This performs a light-weight sanity check for the endpoint in the ++ * given urb. It returns 0 if the urb contains a valid endpoint, otherwise ++ * a negative error code. ++ */ ++int usb_urb_ep_type_check(const struct urb *urb) ++{ ++ const struct usb_host_endpoint *ep; ++ ++ ep = usb_pipe_endpoint(urb->dev, urb->pipe); ++ if (!ep) ++ return -EINVAL; ++ if (usb_pipetype(urb->pipe) != pipetypes[usb_endpoint_type(&ep->desc)]) ++ return -EINVAL; ++ return 0; ++} ++EXPORT_SYMBOL_GPL(usb_urb_ep_type_check); ++ + /** + * usb_submit_urb - issue an asynchronous transfer request for an endpoint + * @urb: pointer to the urb describing the request +@@ -324,9 +349,6 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); + */ + int usb_submit_urb(struct urb *urb, gfp_t mem_flags) + { +- static int pipetypes[4] = { +- PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT +- }; + int xfertype, max; + struct usb_device *dev; + struct usb_host_endpoint *ep; +@@ -445,7 +467,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) + */ + + /* Check that the pipe's type matches the endpoint's type */ +- if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) ++ if (usb_urb_ep_type_check(urb)) + dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", + usb_pipetype(urb->pipe), pipetypes[xfertype]); + +diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c +index 56200650b46b..bd7082f297bb 100644 +--- a/drivers/usb/host/ehci-platform.c ++++ b/drivers/usb/host/ehci-platform.c +@@ -375,11 +375,6 @@ static int ehci_platform_resume(struct device *dev) + } + + ehci_resume(hcd, priv->reset_on_resume); +- +- pm_runtime_disable(dev); +- pm_runtime_set_active(dev); +- pm_runtime_enable(dev); +- + return 0; + } + #endif /* CONFIG_PM_SLEEP */ +diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c +index 0e5580e6f35c..c2669f185f65 100644 +--- a/drivers/usb/host/ohci-platform.c ++++ b/drivers/usb/host/ohci-platform.c +@@ -339,11 +339,6 @@ static int ohci_platform_resume(struct device *dev) + } + + ohci_resume(hcd, false); +- +- pm_runtime_disable(dev); +- pm_runtime_set_active(dev); +- pm_runtime_enable(dev); +- + return 0; + } + #endif /* CONFIG_PM_SLEEP */ +diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c +index 510fb7853f92..c4c40e9d4247 100644 +--- a/drivers/usb/host/xhci-plat.c ++++ b/drivers/usb/host/xhci-plat.c +@@ -249,17 +249,8 @@ static int xhci_plat_resume(struct device *dev) + { + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct xhci_hcd *xhci = hcd_to_xhci(hcd); +- int ret; +- +- ret = xhci_resume(xhci, 0); +- if (ret) +- return ret; + +- pm_runtime_disable(dev); +- pm_runtime_set_active(dev); +- pm_runtime_enable(dev); +- +- return 0; ++ return xhci_resume(xhci, 0); + } + + static const struct dev_pm_ops xhci_plat_pm_ops = { +diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c +index e8a8c4fa944f..3ec59c2b4f65 100644 +--- a/drivers/usb/serial/ch341.c ++++ b/drivers/usb/serial/ch341.c +@@ -71,6 +71,7 @@ + + static const struct usb_device_id id_table[] = { + { USB_DEVICE(0x4348, 0x5523) }, ++ { USB_DEVICE(0x1a86, 0x7522) }, + { USB_DEVICE(0x1a86, 0x7523) }, + { USB_DEVICE(0x1a86, 0x5523) }, + { }, +diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c +index e92cd1eceefa..2c6587b5c329 100644 +--- a/drivers/usb/serial/cypress_m8.c ++++ b/drivers/usb/serial/cypress_m8.c +@@ -63,6 +63,7 @@ static const struct usb_device_id id_table_earthmate[] = { + + static const struct usb_device_id id_table_cyphidcomrs232[] = { + { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, ++ { USB_DEVICE(VENDOR_ID_SAI, PRODUCT_ID_CYPHIDCOM) }, + { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) }, + { USB_DEVICE(VENDOR_ID_FRWD, PRODUCT_ID_CYPHIDCOM_FRWD) }, + { } /* Terminating entry */ +@@ -77,6 +78,7 @@ static const struct usb_device_id id_table_combined[] = { + { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) }, + { USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) }, + { USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) }, ++ { USB_DEVICE(VENDOR_ID_SAI, PRODUCT_ID_CYPHIDCOM) }, + { USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) }, + { USB_DEVICE(VENDOR_ID_FRWD, PRODUCT_ID_CYPHIDCOM_FRWD) }, + { USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) }, +diff --git a/drivers/usb/serial/cypress_m8.h b/drivers/usb/serial/cypress_m8.h +index 119d2e17077b..6d9820bffc20 100644 +--- a/drivers/usb/serial/cypress_m8.h ++++ b/drivers/usb/serial/cypress_m8.h +@@ -24,6 +24,9 @@ + #define VENDOR_ID_CYPRESS 0x04b4 + #define PRODUCT_ID_CYPHIDCOM 0x5500 + ++/* Simply Automated HID->COM UPB PIM (using Cypress PID 0x5500) */ ++#define VENDOR_ID_SAI 0x17dd ++ + /* FRWD Dongle - a GPS sports watch */ + #define VENDOR_ID_FRWD 0x6737 + #define PRODUCT_ID_CYPHIDCOM_FRWD 0x0001 +diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c +index 7ed7d33d6c10..1a966f25b3ef 100644 +--- a/drivers/usb/serial/iuu_phoenix.c ++++ b/drivers/usb/serial/iuu_phoenix.c +@@ -717,14 +717,16 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, + struct iuu_private *priv = usb_get_serial_port_data(port); + unsigned long flags; + +- if (count > 256) +- return -ENOMEM; +- + spin_lock_irqsave(&priv->lock, flags); + ++ count = min(count, 256 - priv->writelen); ++ if (count == 0) ++ goto out; ++ + /* fill the buffer */ + memcpy(priv->writebuf + priv->writelen, buf, count); + priv->writelen += count; ++out: + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c +index 326e7109b8f8..52b1092ed57e 100644 +--- a/drivers/usb/serial/option.c ++++ b/drivers/usb/serial/option.c +@@ -248,6 +248,7 @@ static void option_instat_callback(struct urb *urb); + /* These Quectel products use Quectel's vendor ID */ + #define QUECTEL_PRODUCT_EC21 0x0121 + #define QUECTEL_PRODUCT_EC25 0x0125 ++#define QUECTEL_PRODUCT_EG95 0x0195 + #define QUECTEL_PRODUCT_BG96 0x0296 + #define QUECTEL_PRODUCT_EP06 0x0306 + +@@ -1095,6 +1096,8 @@ static const struct usb_device_id option_ids[] = { + .driver_info = RSVD(4) }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25), + .driver_info = RSVD(4) }, ++ { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95), ++ .driver_info = RSVD(4) }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), + .driver_info = RSVD(4) }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06), +@@ -2019,6 +2022,9 @@ static const struct usb_device_id option_ids[] = { + .driver_info = RSVD(4) | RSVD(5) }, + { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */ + .driver_info = RSVD(6) }, ++ { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */ ++ { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */ ++ { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1406, 0xff) }, /* GosunCn GM500 ECM/NCM */ + { } /* Terminating entry */ + }; + MODULE_DEVICE_TABLE(usb, option_ids); +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c +index 2c86c472f670..42b7409d4cc5 100644 +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -4861,25 +4861,28 @@ err: + static void check_buffer_tree_ref(struct extent_buffer *eb) + { + int refs; +- /* the ref bit is tricky. We have to make sure it is set +- * if we have the buffer dirty. Otherwise the +- * code to free a buffer can end up dropping a dirty +- * page ++ /* ++ * The TREE_REF bit is first set when the extent_buffer is added ++ * to the radix tree. It is also reset, if unset, when a new reference ++ * is created by find_extent_buffer. + * +- * Once the ref bit is set, it won't go away while the +- * buffer is dirty or in writeback, and it also won't +- * go away while we have the reference count on the +- * eb bumped. ++ * It is only cleared in two cases: freeing the last non-tree ++ * reference to the extent_buffer when its STALE bit is set or ++ * calling releasepage when the tree reference is the only reference. + * +- * We can't just set the ref bit without bumping the +- * ref on the eb because free_extent_buffer might +- * see the ref bit and try to clear it. If this happens +- * free_extent_buffer might end up dropping our original +- * ref by mistake and freeing the page before we are able +- * to add one more ref. ++ * In both cases, care is taken to ensure that the extent_buffer's ++ * pages are not under io. However, releasepage can be concurrently ++ * called with creating new references, which is prone to race ++ * conditions between the calls to check_buffer_tree_ref in those ++ * codepaths and clearing TREE_REF in try_release_extent_buffer. + * +- * So bump the ref count first, then set the bit. If someone +- * beat us to it, drop the ref we added. ++ * The actual lifetime of the extent_buffer in the radix tree is ++ * adequately protected by the refcount, but the TREE_REF bit and ++ * its corresponding reference are not. To protect against this ++ * class of races, we call check_buffer_tree_ref from the codepaths ++ * which trigger io after they set eb->io_pages. Note that once io is ++ * initiated, TREE_REF can no longer be cleared, so that is the ++ * moment at which any such race is best fixed. + */ + refs = atomic_read(&eb->refs); + if (refs >= 2 && test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags)) +@@ -5346,6 +5349,11 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, + clear_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags); + eb->read_mirror = 0; + atomic_set(&eb->io_pages, num_reads); ++ /* ++ * It is possible for releasepage to clear the TREE_REF bit before we ++ * set io_pages. See check_buffer_tree_ref for a more detailed comment. ++ */ ++ check_buffer_tree_ref(eb); + for (i = start_i; i < num_pages; i++) { + page = eb->pages[i]; + if (!PageUptodate(page)) { +diff --git a/fs/fuse/file.c b/fs/fuse/file.c +index 6ce6754168e0..f7d025d1684c 100644 +--- a/fs/fuse/file.c ++++ b/fs/fuse/file.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + + static const struct file_operations fuse_direct_io_file_operations; + +@@ -2517,7 +2518,16 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, + struct iovec *iov = iov_page; + + iov->iov_base = (void __user *)arg; +- iov->iov_len = _IOC_SIZE(cmd); ++ ++ switch (cmd) { ++ case FS_IOC_GETFLAGS: ++ case FS_IOC_SETFLAGS: ++ iov->iov_len = sizeof(int); ++ break; ++ default: ++ iov->iov_len = _IOC_SIZE(cmd); ++ break; ++ } + + if (_IOC_DIR(cmd) & _IOC_WRITE) { + in_iov = iov; +diff --git a/include/linux/usb.h b/include/linux/usb.h +index 02bffcc611c3..55ea5d625cdf 100644 +--- a/include/linux/usb.h ++++ b/include/linux/usb.h +@@ -1655,6 +1655,8 @@ static inline int usb_urb_dir_out(struct urb *urb) + return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; + } + ++int usb_urb_ep_type_check(const struct urb *urb); ++ + void *usb_alloc_coherent(struct usb_device *dev, size_t size, + gfp_t mem_flags, dma_addr_t *dma); + void usb_free_coherent(struct usb_device *dev, size_t size, +diff --git a/include/net/dst.h b/include/net/dst.h +index 2e6e3a14a21a..dc1f26da3c61 100644 +--- a/include/net/dst.h ++++ b/include/net/dst.h +@@ -470,7 +470,15 @@ static inline struct neighbour *dst_neigh_lookup(const struct dst_entry *dst, co + static inline struct neighbour *dst_neigh_lookup_skb(const struct dst_entry *dst, + struct sk_buff *skb) + { +- struct neighbour *n = dst->ops->neigh_lookup(dst, skb, NULL); ++ struct neighbour *n = NULL; ++ ++ /* The packets from tunnel devices (eg bareudp) may have only ++ * metadata in the dst pointer of skb. Hence a pointer check of ++ * neigh_lookup is needed. ++ */ ++ if (dst->ops->neigh_lookup) ++ n = dst->ops->neigh_lookup(dst, skb, NULL); ++ + return IS_ERR(n) ? NULL : n; + } + +diff --git a/include/net/genetlink.h b/include/net/genetlink.h +index 43c0e771f417..351766331519 100644 +--- a/include/net/genetlink.h ++++ b/include/net/genetlink.h +@@ -33,12 +33,6 @@ struct genl_info; + * do additional, common, filtering and return an error + * @post_doit: called after an operation's doit callback, it may + * undo operations done by pre_doit, for example release locks +- * @mcast_bind: a socket bound to the given multicast group (which +- * is given as the offset into the groups array) +- * @mcast_unbind: a socket was unbound from the given multicast group. +- * Note that unbind() will not be called symmetrically if the +- * generic netlink family is removed while there are still open +- * sockets. + * @attrbuf: buffer to store parsed attributes + * @family_list: family list + * @mcgrps: multicast groups used by this family (private) +@@ -61,8 +55,6 @@ struct genl_family { + void (*post_doit)(const struct genl_ops *ops, + struct sk_buff *skb, + struct genl_info *info); +- int (*mcast_bind)(struct net *net, int group); +- void (*mcast_unbind)(struct net *net, int group); + struct nlattr ** attrbuf; /* private */ + const struct genl_ops * ops; /* private */ + const struct genl_multicast_group *mcgrps; /* private */ +diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h +index a5c6e6da3d3d..57872c8f1151 100644 +--- a/include/sound/compress_driver.h ++++ b/include/sound/compress_driver.h +@@ -71,6 +71,7 @@ struct snd_compr_runtime { + * @direction: stream direction, playback/recording + * @metadata_set: metadata set flag, true when set + * @next_track: has userspace signal next track transition, true when set ++ * @partial_drain: undergoing partial_drain for stream, true when set + * @private_data: pointer to DSP private data + */ + struct snd_compr_stream { +@@ -81,6 +82,7 @@ struct snd_compr_stream { + enum snd_compr_direction direction; + bool metadata_set; + bool next_track; ++ bool partial_drain; + void *private_data; + }; + +@@ -178,7 +180,13 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) + if (snd_BUG_ON(!stream)) + return; + +- stream->runtime->state = SNDRV_PCM_STATE_SETUP; ++ /* for partial_drain case we are back to running state on success */ ++ if (stream->partial_drain) { ++ stream->runtime->state = SNDRV_PCM_STATE_RUNNING; ++ stream->partial_drain = false; /* clear this flag as well */ ++ } else { ++ stream->runtime->state = SNDRV_PCM_STATE_SETUP; ++ } + + wake_up(&stream->runtime->sleep); + } +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c +index 971e31e47bfd..15952d0e340b 100644 +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -5939,7 +5939,15 @@ static int detach_tasks(struct lb_env *env) + if (!can_migrate_task(p, env)) + goto next; + +- load = task_h_load(p); ++ /* ++ * Depending of the number of CPUs and tasks and the ++ * cgroup hierarchy, task_h_load() can return a null ++ * value. Make sure that env->imbalance decreases ++ * otherwise detach_tasks() will stop only after ++ * detaching up to loop_max tasks. ++ */ ++ load = max_t(unsigned long, task_h_load(p), 1); ++ + + if (sched_feat(LB_MIN) && load < 16 && !env->sd->nr_balance_failed) + goto next; +diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c +index 82c878224bfc..a3abd136b8e7 100644 +--- a/net/ipv4/ping.c ++++ b/net/ipv4/ping.c +@@ -802,6 +802,9 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) + RT_SCOPE_UNIVERSE, sk->sk_protocol, + inet_sk_flowi_flags(sk), faddr, saddr, 0, 0); + ++ fl4.fl4_icmp_type = user_icmph.type; ++ fl4.fl4_icmp_code = user_icmph.code; ++ + security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); + rt = ip_route_output_flow(net, &fl4, sk); + if (IS_ERR(rt)) { +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c +index 2ceda7ddaed5..4080cf1a369d 100644 +--- a/net/ipv4/tcp.c ++++ b/net/ipv4/tcp.c +@@ -2259,6 +2259,9 @@ int tcp_disconnect(struct sock *sk, int flags) + tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; + tp->snd_cwnd_cnt = 0; + tp->window_clamp = 0; ++ if (icsk->icsk_ca_ops->release) ++ icsk->icsk_ca_ops->release(sk); ++ memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); + tcp_set_ca_state(sk, TCP_CA_Open); + tcp_clear_retrans(tp); + tp->total_retrans = 0; +@@ -2593,10 +2596,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, + + #ifdef CONFIG_TCP_MD5SIG + case TCP_MD5SIG: +- if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) +- err = tp->af_specific->md5_parse(sk, optval, optlen); +- else +- err = -EINVAL; ++ err = tp->af_specific->md5_parse(sk, optval, optlen); + break; + #endif + case TCP_USER_TIMEOUT: +@@ -3085,9 +3085,12 @@ EXPORT_SYMBOL(tcp_md5_hash_skb_data); + + int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key) + { ++ u8 keylen = READ_ONCE(key->keylen); /* paired with WRITE_ONCE() in tcp_md5_do_add */ + struct scatterlist sg; + +- sg_init_one(&sg, key->key, key->keylen); ++ sg_init_one(&sg, key->key, keylen); ++ ++ /* tcp_md5_do_add() might change key->key under us */ + return crypto_hash_update(&hp->md5_desc, &sg, key->keylen); + } + EXPORT_SYMBOL(tcp_md5_hash_key); +diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c +index aafe68134763..f6b64efc22e8 100644 +--- a/net/ipv4/tcp_cong.c ++++ b/net/ipv4/tcp_cong.c +@@ -201,7 +201,7 @@ static void tcp_reinit_congestion_control(struct sock *sk, + icsk->icsk_ca_ops = ca; + icsk->icsk_ca_setsockopt = 1; + +- if (sk->sk_state != TCP_CLOSE) ++ if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) + tcp_init_congestion_control(sk); + } + +diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c +index 12d4d2758caf..3826745a160e 100644 +--- a/net/ipv4/tcp_ipv4.c ++++ b/net/ipv4/tcp_ipv4.c +@@ -931,9 +931,18 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, + + key = tcp_md5_do_lookup(sk, addr, family); + if (key) { +- /* Pre-existing entry - just update that one. */ ++ /* Pre-existing entry - just update that one. ++ * Note that the key might be used concurrently. ++ */ + memcpy(key->key, newkey, newkeylen); +- key->keylen = newkeylen; ++ ++ /* Pairs with READ_ONCE() in tcp_md5_hash_key(). ++ * Also note that a reader could catch new key->keylen value ++ * but old key->key[], this is the reason we use __GFP_ZERO ++ * at sock_kmalloc() time below these lines. ++ */ ++ WRITE_ONCE(key->keylen, newkeylen); ++ + return 0; + } + +@@ -950,7 +959,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, + rcu_assign_pointer(tp->md5sig_info, md5sig); + } + +- key = sock_kmalloc(sk, sizeof(*key), gfp); ++ key = sock_kmalloc(sk, sizeof(*key), gfp | __GFP_ZERO); + if (!key) + return -ENOMEM; + if (!tcp_alloc_md5sig_pool()) { +diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c +index 53c53b1c881c..653892ea8f14 100644 +--- a/net/l2tp/l2tp_core.c ++++ b/net/l2tp/l2tp_core.c +@@ -1139,6 +1139,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, + + /* Queue the packet to IP for output */ + skb->ignore_df = 1; ++ skb_dst_drop(skb); + #if IS_ENABLED(CONFIG_IPV6) + if (tunnel->sock->sk_family == PF_INET6 && !tunnel->v4mapped) + error = inet6_csk_xmit(tunnel->sock, skb, NULL); +@@ -1203,10 +1204,6 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len + goto out_unlock; + } + +- /* Get routing info from the tunnel socket */ +- skb_dst_drop(skb); +- skb_dst_set(skb, sk_dst_check(sk, 0)); +- + inet = inet_sk(sk); + fl = &inet->cork.fl; + switch (tunnel->encap) { +diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c +index 69f1558dfcb7..f613a1007107 100644 +--- a/net/llc/af_llc.c ++++ b/net/llc/af_llc.c +@@ -271,6 +271,10 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) + + if (!sock_flag(sk, SOCK_ZAPPED)) + goto out; ++ if (!addr->sllc_arphrd) ++ addr->sllc_arphrd = ARPHRD_ETHER; ++ if (addr->sllc_arphrd != ARPHRD_ETHER) ++ goto out; + rc = -ENODEV; + if (sk->sk_bound_dev_if) { + llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); +@@ -328,15 +332,15 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) + if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr))) + goto out; + rc = -EAFNOSUPPORT; +- if (unlikely(addr->sllc_family != AF_LLC)) ++ if (!addr->sllc_arphrd) ++ addr->sllc_arphrd = ARPHRD_ETHER; ++ if (unlikely(addr->sllc_family != AF_LLC || addr->sllc_arphrd != ARPHRD_ETHER)) + goto out; + rc = -ENODEV; + rcu_read_lock(); + if (sk->sk_bound_dev_if) { + llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if); + if (llc->dev) { +- if (!addr->sllc_arphrd) +- addr->sllc_arphrd = llc->dev->type; + if (is_zero_ether_addr(addr->sllc_mac)) + memcpy(addr->sllc_mac, llc->dev->dev_addr, + IFHWADDRLEN); +diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c +index d681dbaf00c1..3fc00c320a9f 100644 +--- a/net/netlink/genetlink.c ++++ b/net/netlink/genetlink.c +@@ -1007,63 +1007,11 @@ static struct genl_multicast_group genl_ctrl_groups[] = { + { .name = "notify", }, + }; + +-static int genl_bind(struct net *net, int group) +-{ +- int i, err = -ENOENT; +- +- down_read(&cb_lock); +- for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { +- struct genl_family *f; +- +- list_for_each_entry(f, genl_family_chain(i), family_list) { +- if (group >= f->mcgrp_offset && +- group < f->mcgrp_offset + f->n_mcgrps) { +- int fam_grp = group - f->mcgrp_offset; +- +- if (!f->netnsok && net != &init_net) +- err = -ENOENT; +- else if (f->mcast_bind) +- err = f->mcast_bind(net, fam_grp); +- else +- err = 0; +- break; +- } +- } +- } +- up_read(&cb_lock); +- +- return err; +-} +- +-static void genl_unbind(struct net *net, int group) +-{ +- int i; +- +- down_read(&cb_lock); +- for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { +- struct genl_family *f; +- +- list_for_each_entry(f, genl_family_chain(i), family_list) { +- if (group >= f->mcgrp_offset && +- group < f->mcgrp_offset + f->n_mcgrps) { +- int fam_grp = group - f->mcgrp_offset; +- +- if (f->mcast_unbind) +- f->mcast_unbind(net, fam_grp); +- break; +- } +- } +- } +- up_read(&cb_lock); +-} +- + static int __net_init genl_pernet_init(struct net *net) + { + struct netlink_kernel_cfg cfg = { + .input = genl_rcv, + .flags = NL_CFG_F_NONROOT_RECV, +- .bind = genl_bind, +- .unbind = genl_unbind, + }; + + /* we'll bump the group number right afterwards */ +diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c +index 07f5017cbea2..e788c7e1929b 100644 +--- a/sound/core/compress_offload.c ++++ b/sound/core/compress_offload.c +@@ -699,6 +699,9 @@ static int snd_compr_stop(struct snd_compr_stream *stream) + + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); + if (!retval) { ++ /* clear flags and stop any drain wait */ ++ stream->partial_drain = false; ++ stream->metadata_set = false; + snd_compr_drain_notify(stream); + stream->runtime->total_bytes_available = 0; + stream->runtime->total_bytes_transferred = 0; +@@ -809,6 +812,7 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) + if (stream->next_track == false) + return -EPERM; + ++ stream->partial_drain = true; + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); + if (retval) { + pr_debug("Partial drain returned failure\n"); +diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c +index 42920a243328..3f94746d587a 100644 +--- a/sound/drivers/opl3/opl3_synth.c ++++ b/sound/drivers/opl3/opl3_synth.c +@@ -104,6 +104,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file, + { + struct snd_dm_fm_info info; + ++ memset(&info, 0, sizeof(info)); ++ + info.fm_mode = opl3->fm_mode; + info.rhythm = opl3->rhythm; + if (copy_to_user(argp, &info, sizeof(struct snd_dm_fm_info))) +diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c +index 12d87204e373..7ac92d188f4f 100644 +--- a/sound/pci/hda/hda_auto_parser.c ++++ b/sound/pci/hda/hda_auto_parser.c +@@ -76,6 +76,12 @@ static int compare_input_type(const void *ap, const void *bp) + if (a->type != b->type) + return (int)(a->type - b->type); + ++ /* If has both hs_mic and hp_mic, pick the hs_mic ahead of hp_mic. */ ++ if (a->is_headset_mic && b->is_headphone_mic) ++ return -1; /* don't swap */ ++ else if (a->is_headphone_mic && b->is_headset_mic) ++ return 1; /* swap */ ++ + /* In case one has boost and the other one has not, + pick the one with boost first. */ + return (int)(b->has_boost_on_pin - a->has_boost_on_pin); +diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c +index f518fbbe88de..4250d26166a0 100644 +--- a/sound/usb/line6/capture.c ++++ b/sound/usb/line6/capture.c +@@ -269,6 +269,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) + urb->interval = LINE6_ISO_INTERVAL; + urb->error_count = 0; + urb->complete = audio_in_callback; ++ if (usb_urb_ep_type_check(urb)) ++ return -EINVAL; + } + + return 0; +diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c +index 97ed593f6010..500f0b455be9 100644 +--- a/sound/usb/line6/playback.c ++++ b/sound/usb/line6/playback.c +@@ -423,6 +423,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) + urb->interval = LINE6_ISO_INTERVAL; + urb->error_count = 0; + urb->complete = audio_out_callback; ++ if (usb_urb_ep_type_check(urb)) ++ return -EINVAL; + } + + return 0; +diff --git a/sound/usb/midi.c b/sound/usb/midi.c +index b21b76690b31..5c4a3d6c4234 100644 +--- a/sound/usb/midi.c ++++ b/sound/usb/midi.c +@@ -1475,6 +1475,8 @@ void snd_usbmidi_disconnect(struct list_head *p) + spin_unlock_irq(&umidi->disc_lock); + up_write(&umidi->disc_rwsem); + ++ del_timer_sync(&umidi->error_timer); ++ + for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { + struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i]; + if (ep->out) +@@ -1501,7 +1503,6 @@ void snd_usbmidi_disconnect(struct list_head *p) + ep->in = NULL; + } + } +- del_timer_sync(&umidi->error_timer); + } + EXPORT_SYMBOL(snd_usbmidi_disconnect); + +@@ -2258,16 +2259,22 @@ void snd_usbmidi_input_stop(struct list_head *p) + } + EXPORT_SYMBOL(snd_usbmidi_input_stop); + +-static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint *ep) ++static void snd_usbmidi_input_start_ep(struct snd_usb_midi *umidi, ++ struct snd_usb_midi_in_endpoint *ep) + { + unsigned int i; ++ unsigned long flags; + + if (!ep) + return; + for (i = 0; i < INPUT_URBS; ++i) { + struct urb *urb = ep->urbs[i]; +- urb->dev = ep->umidi->dev; +- snd_usbmidi_submit_urb(urb, GFP_KERNEL); ++ spin_lock_irqsave(&umidi->disc_lock, flags); ++ if (!atomic_read(&urb->use_count)) { ++ urb->dev = ep->umidi->dev; ++ snd_usbmidi_submit_urb(urb, GFP_ATOMIC); ++ } ++ spin_unlock_irqrestore(&umidi->disc_lock, flags); + } + } + +@@ -2283,7 +2290,7 @@ void snd_usbmidi_input_start(struct list_head *p) + if (umidi->input_running || !umidi->opened[1]) + return; + for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) +- snd_usbmidi_input_start_ep(umidi->endpoints[i].in); ++ snd_usbmidi_input_start_ep(umidi, umidi->endpoints[i].in); + umidi->input_running = 1; + } + EXPORT_SYMBOL(snd_usbmidi_input_start); +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h +index c892b4d1e733..ec56ce382061 100644 +--- a/sound/usb/quirks-table.h ++++ b/sound/usb/quirks-table.h +@@ -3323,4 +3323,56 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), + } + }, + ++/* ++ * MacroSilicon MS2109 based HDMI capture cards ++ * ++ * These claim 96kHz 1ch in the descriptors, but are actually 48kHz 2ch. ++ * They also need QUIRK_AUDIO_ALIGN_TRANSFER, which makes one wonder if ++ * they pretend to be 96kHz mono as a workaround for stereo being broken ++ * by that... ++ * ++ * They also have swapped L-R channels, but that's for userspace to deal ++ * with. ++ */ ++{ ++ USB_DEVICE(0x534d, 0x2109), ++ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { ++ .vendor_name = "MacroSilicon", ++ .product_name = "MS2109", ++ .ifnum = QUIRK_ANY_INTERFACE, ++ .type = QUIRK_COMPOSITE, ++ .data = &(const struct snd_usb_audio_quirk[]) { ++ { ++ .ifnum = 2, ++ .type = QUIRK_AUDIO_ALIGN_TRANSFER, ++ }, ++ { ++ .ifnum = 2, ++ .type = QUIRK_AUDIO_STANDARD_MIXER, ++ }, ++ { ++ .ifnum = 3, ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT, ++ .data = &(const struct audioformat) { ++ .formats = SNDRV_PCM_FMTBIT_S16_LE, ++ .channels = 2, ++ .iface = 3, ++ .altsetting = 1, ++ .altset_idx = 1, ++ .attributes = 0, ++ .endpoint = 0x82, ++ .ep_attr = USB_ENDPOINT_XFER_ISOC | ++ USB_ENDPOINT_SYNC_ASYNC, ++ .rates = SNDRV_PCM_RATE_CONTINUOUS, ++ .rate_min = 48000, ++ .rate_max = 48000, ++ } ++ }, ++ { ++ .ifnum = -1 ++ } ++ } ++ } ++}, ++ + #undef USB_DEVICE_VENDOR_SPEC +diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c +index 6ce624cb7001..699c0ec5b9bf 100644 +--- a/tools/perf/util/stat.c ++++ b/tools/perf/util/stat.c +@@ -318,8 +318,10 @@ int perf_stat_process_counter(struct perf_stat_config *config, + * interval mode, otherwise overall avg running + * averages will be shown for each interval. + */ +- if (config->interval) +- init_stats(ps->res_stats); ++ if (config->interval) { ++ for (i = 0; i < 3; i++) ++ init_stats(&ps->res_stats[i]); ++ } + + if (counter->per_pkg) + zero_per_pkg(counter); diff --git a/patch/kernel/rockpis-legacy/patch-4.4.231-232.patch b/patch/kernel/rockpis-legacy/patch-4.4.231-232.patch new file mode 100644 index 000000000..8390421a4 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.231-232.patch @@ -0,0 +1,1690 @@ +diff --git a/Makefile b/Makefile +index 46178c83906c..47a0a6c8272b 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 231 ++SUBLEVEL = 232 + EXTRAVERSION = + NAME = Blurry Fish Butt + +@@ -607,7 +607,7 @@ ifeq ($(cc-name),clang) + ifneq ($(CROSS_COMPILE),) + CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%)) + GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) +-CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR) ++CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) + GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) + endif + ifneq ($(GCC_TOOLCHAIN),) +diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c +index 8e7675e5ce4a..77fbcabcd9e3 100644 +--- a/arch/arm64/kernel/debug-monitors.c ++++ b/arch/arm64/kernel/debug-monitors.c +@@ -387,14 +387,14 @@ void user_rewind_single_step(struct task_struct *task) + * If single step is active for this thread, then set SPSR.SS + * to 1 to avoid returning to the active-pending state. + */ +- if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP)) ++ if (test_tsk_thread_flag(task, TIF_SINGLESTEP)) + set_regs_spsr_ss(task_pt_regs(task)); + } + NOKPROBE_SYMBOL(user_rewind_single_step); + + void user_fastforward_single_step(struct task_struct *task) + { +- if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP)) ++ if (test_tsk_thread_flag(task, TIF_SINGLESTEP)) + clear_regs_spsr_ss(task_pt_regs(task)); + } + +diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h +index 1d109990a022..cb2590821707 100644 +--- a/arch/parisc/include/asm/atomic.h ++++ b/arch/parisc/include/asm/atomic.h +@@ -208,6 +208,8 @@ atomic64_set(atomic64_t *v, s64 i) + _atomic_spin_unlock_irqrestore(v, flags); + } + ++#define atomic64_set_release(v, i) atomic64_set((v), (i)) ++ + static __inline__ s64 + atomic64_read(const atomic64_t *v) + { +diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c +index 31fad2cbd734..8fc842dae3b3 100644 +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -317,10 +317,10 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + sanitize_restored_xstate(tsk, &env, xfeatures, fx_only); + } + ++ local_bh_disable(); + fpu->fpstate_active = 1; +- preempt_disable(); + fpu__restore(fpu); +- preempt_enable(); ++ local_bh_enable(); + + return err; + } else { +diff --git a/arch/x86/math-emu/wm_sqrt.S b/arch/x86/math-emu/wm_sqrt.S +index d258f59564e1..3b40c98bbbd4 100644 +--- a/arch/x86/math-emu/wm_sqrt.S ++++ b/arch/x86/math-emu/wm_sqrt.S +@@ -208,7 +208,7 @@ sqrt_stage_2_finish: + + #ifdef PARANOID + /* It should be possible to get here only if the arg is ffff....ffff */ +- cmp $0xffffffff,FPU_fsqrt_arg_1 ++ cmpl $0xffffffff,FPU_fsqrt_arg_1 + jnz sqrt_stage_2_error + #endif /* PARANOID */ + +diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c +index 49ccbd9022f6..92f5a259e251 100644 +--- a/arch/xtensa/kernel/setup.c ++++ b/arch/xtensa/kernel/setup.c +@@ -716,7 +716,8 @@ c_start(struct seq_file *f, loff_t *pos) + static void * + c_next(struct seq_file *f, void *v, loff_t *pos) + { +- return NULL; ++ ++*pos; ++ return c_start(f, pos); + } + + static void +diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c +index e2dd9109df63..00f17b5ec9c9 100644 +--- a/arch/xtensa/kernel/xtensa_ksyms.c ++++ b/arch/xtensa/kernel/xtensa_ksyms.c +@@ -82,13 +82,13 @@ void __xtensa_libgcc_window_spill(void) + } + EXPORT_SYMBOL(__xtensa_libgcc_window_spill); + +-unsigned long __sync_fetch_and_and_4(unsigned long *p, unsigned long v) ++unsigned int __sync_fetch_and_and_4(volatile void *p, unsigned int v) + { + BUG(); + } + EXPORT_SYMBOL(__sync_fetch_and_and_4); + +-unsigned long __sync_fetch_and_or_4(unsigned long *p, unsigned long v) ++unsigned int __sync_fetch_and_or_4(volatile void *p, unsigned int v) + { + BUG(); + } +diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c +index 3f0a7e262d69..ad5712f68c3e 100644 +--- a/drivers/base/regmap/regmap-debugfs.c ++++ b/drivers/base/regmap/regmap-debugfs.c +@@ -194,6 +194,9 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, + if (*ppos < 0 || !count) + return -EINVAL; + ++ if (count > (PAGE_SIZE << (MAX_ORDER - 1))) ++ count = PAGE_SIZE << (MAX_ORDER - 1); ++ + buf = kmalloc(count, GFP_KERNEL); + if (!buf) + return -ENOMEM; +@@ -342,6 +345,9 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file, + if (*ppos < 0 || !count) + return -EINVAL; + ++ if (count > (PAGE_SIZE << (MAX_ORDER - 1))) ++ count = PAGE_SIZE << (MAX_ORDER - 1); ++ + buf = kmalloc(count, GFP_KERNEL); + if (!buf) + return -ENOMEM; +diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c +index 77cabde977ed..4a4efc6f54b5 100644 +--- a/drivers/base/regmap/regmap.c ++++ b/drivers/base/regmap/regmap.c +@@ -1106,7 +1106,7 @@ static int dev_get_regmap_match(struct device *dev, void *res, void *data) + + /* If the user didn't specify a name match any */ + if (data) +- return (*r)->name == data; ++ return !strcmp((*r)->name, data); + else + return 1; + } +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c +index 954f5b76bfcf..d44965f805fe 100644 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c +@@ -118,10 +118,10 @@ g94_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, + if (retries) + udelay(400); + +- /* transaction request, wait up to 1ms for it to complete */ ++ /* transaction request, wait up to 2ms for it to complete */ + nvkm_wr32(device, 0x00e4e4 + base, 0x00010000 | ctrl); + +- timeout = 1000; ++ timeout = 2000; + do { + ctrl = nvkm_rd32(device, 0x00e4e4 + base); + udelay(1); +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c +index bed231b56dbd..7cac8fe372b6 100644 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c +@@ -118,10 +118,10 @@ gm204_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, + if (retries) + udelay(400); + +- /* transaction request, wait up to 1ms for it to complete */ ++ /* transaction request, wait up to 2ms for it to complete */ + nvkm_wr32(device, 0x00d954 + base, 0x00010000 | ctrl); + +- timeout = 1000; ++ timeout = 2000; + do { + ctrl = nvkm_rd32(device, 0x00d954 + base); + udelay(1); +diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c +index 8ba9eadc2079..3fb9cbdac3bf 100644 +--- a/drivers/net/ethernet/marvell/sky2.c ++++ b/drivers/net/ethernet/marvell/sky2.c +@@ -215,7 +215,7 @@ io_error: + + static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) + { +- u16 v; ++ u16 v = 0; + __gm_phy_read(hw, port, reg, &v); + return v; + } +diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c +index 7405f537beca..8531a7201968 100644 +--- a/drivers/net/ethernet/smsc/smc91x.c ++++ b/drivers/net/ethernet/smsc/smc91x.c +@@ -2289,7 +2289,7 @@ static int smc_drv_probe(struct platform_device *pdev) + ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio, + "power", 0, 0, 100); + if (ret) +- return ret; ++ goto out_free_netdev; + + /* + * Optional reset GPIO configured? Minimum 100 ns reset needed +@@ -2298,7 +2298,7 @@ static int smc_drv_probe(struct platform_device *pdev) + ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio, + "reset", 0, 0, 100); + if (ret) +- return ret; ++ goto out_free_netdev; + + /* + * Need to wait for optional EEPROM to load, max 750 us according +diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c +index 313e006f74fe..6f3519123eb6 100644 +--- a/drivers/net/hippi/rrunner.c ++++ b/drivers/net/hippi/rrunner.c +@@ -1250,7 +1250,7 @@ static int rr_open(struct net_device *dev) + rrpriv->info = NULL; + } + if (rrpriv->rx_ctrl) { +- pci_free_consistent(pdev, sizeof(struct ring_ctrl), ++ pci_free_consistent(pdev, 256 * sizeof(struct ring_ctrl), + rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma); + rrpriv->rx_ctrl = NULL; + } +diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c +index 847c9fc10f9a..0da80adc545a 100644 +--- a/drivers/net/phy/dp83640.c ++++ b/drivers/net/phy/dp83640.c +@@ -1335,6 +1335,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) + dp83640->hwts_rx_en = 1; + dp83640->layer = PTP_CLASS_L4; + dp83640->version = PTP_CLASS_V1; ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; + break; + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: +@@ -1342,6 +1343,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) + dp83640->hwts_rx_en = 1; + dp83640->layer = PTP_CLASS_L4; + dp83640->version = PTP_CLASS_V2; ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; + break; + case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: + case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: +@@ -1349,6 +1351,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) + dp83640->hwts_rx_en = 1; + dp83640->layer = PTP_CLASS_L2; + dp83640->version = PTP_CLASS_V2; ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; + break; + case HWTSTAMP_FILTER_PTP_V2_EVENT: + case HWTSTAMP_FILTER_PTP_V2_SYNC: +@@ -1356,6 +1359,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr) + dp83640->hwts_rx_en = 1; + dp83640->layer = PTP_CLASS_L4 | PTP_CLASS_L2; + dp83640->version = PTP_CLASS_V2; ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; + break; + default: + return -ERANGE; +diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c +index 6b1d03b73eeb..6b734c7ffec3 100644 +--- a/drivers/net/usb/ax88172a.c ++++ b/drivers/net/usb/ax88172a.c +@@ -245,6 +245,7 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf) + ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); + if (ret < ETH_ALEN) { + netdev_err(dev->net, "Failed to read MAC address: %d\n", ret); ++ ret = -EIO; + goto free; + } + memcpy(dev->net->dev_addr, buf, ETH_ALEN); +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c +index 6676607164d6..f5657783fad4 100644 +--- a/drivers/net/wan/lapbether.c ++++ b/drivers/net/wan/lapbether.c +@@ -308,7 +308,6 @@ static void lapbeth_setup(struct net_device *dev) + dev->netdev_ops = &lapbeth_netdev_ops; + dev->destructor = free_netdev; + dev->type = ARPHRD_X25; +- dev->hard_header_len = 3; + dev->mtu = 1000; + dev->addr_len = 0; + } +@@ -329,6 +328,14 @@ static int lapbeth_new_device(struct net_device *dev) + if (!ndev) + goto out; + ++ /* When transmitting data: ++ * first this driver removes a pseudo header of 1 byte, ++ * then the lapb module prepends an LAPB header of at most 3 bytes, ++ * then this driver prepends a length field of 2 bytes, ++ * then the underlying Ethernet device prepends its own header. ++ */ ++ ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len; ++ + lapbeth = netdev_priv(ndev); + lapbeth->axdev = ndev; + +diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c +index cd39025d2abf..022487d90aa3 100644 +--- a/drivers/net/wan/x25_asy.c ++++ b/drivers/net/wan/x25_asy.c +@@ -186,7 +186,7 @@ static inline void x25_asy_unlock(struct x25_asy *sl) + netif_wake_queue(sl->dev); + } + +-/* Send one completely decapsulated IP datagram to the IP layer. */ ++/* Send an LAPB frame to the LAPB module to process. */ + + static void x25_asy_bump(struct x25_asy *sl) + { +@@ -198,13 +198,12 @@ static void x25_asy_bump(struct x25_asy *sl) + count = sl->rcount; + dev->stats.rx_bytes += count; + +- skb = dev_alloc_skb(count+1); ++ skb = dev_alloc_skb(count); + if (skb == NULL) { + netdev_warn(sl->dev, "memory squeeze, dropping packet\n"); + dev->stats.rx_dropped++; + return; + } +- skb_push(skb, 1); /* LAPB internal control */ + memcpy(skb_put(skb, count), sl->rbuff, count); + skb->protocol = x25_type_trans(skb, sl->dev); + err = lapb_data_received(skb->dev, skb); +@@ -212,7 +211,6 @@ static void x25_asy_bump(struct x25_asy *sl) + kfree_skb(skb); + printk(KERN_DEBUG "x25_asy: data received err - %d\n", err); + } else { +- netif_rx(skb); + dev->stats.rx_packets++; + } + } +@@ -358,12 +356,21 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb, + */ + + /* +- * Called when I frame data arrives. We did the work above - throw it +- * at the net layer. ++ * Called when I frame data arrive. We add a pseudo header for upper ++ * layers and pass it to upper layers. + */ + + static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) + { ++ if (skb_cow(skb, 1)) { ++ kfree_skb(skb); ++ return NET_RX_DROP; ++ } ++ skb_push(skb, 1); ++ skb->data[0] = X25_IFACE_DATA; ++ ++ skb->protocol = x25_type_trans(skb, dev); ++ + return netif_rx(skb); + } + +@@ -655,7 +662,7 @@ static void x25_asy_unesc(struct x25_asy *sl, unsigned char s) + switch (s) { + case X25_END: + if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && +- sl->rcount > 2) ++ sl->rcount >= 2) + x25_asy_bump(sl); + clear_bit(SLF_ESCAPE, &sl->flags); + sl->rcount = 0; +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c +index e2ed30b03af5..76d91859cfde 100644 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.c ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c +@@ -639,9 +639,9 @@ err: + + static void ath9k_hif_usb_rx_cb(struct urb *urb) + { +- struct sk_buff *skb = (struct sk_buff *) urb->context; +- struct hif_device_usb *hif_dev = +- usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); ++ struct rx_buf *rx_buf = (struct rx_buf *)urb->context; ++ struct hif_device_usb *hif_dev = rx_buf->hif_dev; ++ struct sk_buff *skb = rx_buf->skb; + int ret; + + if (!skb) +@@ -681,14 +681,15 @@ resubmit: + return; + free: + kfree_skb(skb); ++ kfree(rx_buf); + } + + static void ath9k_hif_usb_reg_in_cb(struct urb *urb) + { +- struct sk_buff *skb = (struct sk_buff *) urb->context; ++ struct rx_buf *rx_buf = (struct rx_buf *)urb->context; ++ struct hif_device_usb *hif_dev = rx_buf->hif_dev; ++ struct sk_buff *skb = rx_buf->skb; + struct sk_buff *nskb; +- struct hif_device_usb *hif_dev = +- usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); + int ret; + + if (!skb) +@@ -728,11 +729,13 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb) + return; + } + ++ rx_buf->skb = nskb; ++ + usb_fill_int_urb(urb, hif_dev->udev, + usb_rcvintpipe(hif_dev->udev, + USB_REG_IN_PIPE), + nskb->data, MAX_REG_IN_BUF_SIZE, +- ath9k_hif_usb_reg_in_cb, nskb, 1); ++ ath9k_hif_usb_reg_in_cb, rx_buf, 1); + } + + resubmit: +@@ -746,6 +749,7 @@ resubmit: + return; + free: + kfree_skb(skb); ++ kfree(rx_buf); + urb->context = NULL; + } + +@@ -791,7 +795,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev) + init_usb_anchor(&hif_dev->mgmt_submitted); + + for (i = 0; i < MAX_TX_URB_NUM; i++) { +- tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL); ++ tx_buf = kzalloc(sizeof(*tx_buf), GFP_KERNEL); + if (!tx_buf) + goto err; + +@@ -828,8 +832,9 @@ static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev) + + static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) + { +- struct urb *urb = NULL; ++ struct rx_buf *rx_buf = NULL; + struct sk_buff *skb = NULL; ++ struct urb *urb = NULL; + int i, ret; + + init_usb_anchor(&hif_dev->rx_submitted); +@@ -837,6 +842,12 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) + + for (i = 0; i < MAX_RX_URB_NUM; i++) { + ++ rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL); ++ if (!rx_buf) { ++ ret = -ENOMEM; ++ goto err_rxb; ++ } ++ + /* Allocate URB */ + urb = usb_alloc_urb(0, GFP_KERNEL); + if (urb == NULL) { +@@ -851,11 +862,14 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) + goto err_skb; + } + ++ rx_buf->hif_dev = hif_dev; ++ rx_buf->skb = skb; ++ + usb_fill_bulk_urb(urb, hif_dev->udev, + usb_rcvbulkpipe(hif_dev->udev, + USB_WLAN_RX_PIPE), + skb->data, MAX_RX_BUF_SIZE, +- ath9k_hif_usb_rx_cb, skb); ++ ath9k_hif_usb_rx_cb, rx_buf); + + /* Anchor URB */ + usb_anchor_urb(urb, &hif_dev->rx_submitted); +@@ -881,6 +895,8 @@ err_submit: + err_skb: + usb_free_urb(urb); + err_urb: ++ kfree(rx_buf); ++err_rxb: + ath9k_hif_usb_dealloc_rx_urbs(hif_dev); + return ret; + } +@@ -892,14 +908,21 @@ static void ath9k_hif_usb_dealloc_reg_in_urbs(struct hif_device_usb *hif_dev) + + static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev) + { +- struct urb *urb = NULL; ++ struct rx_buf *rx_buf = NULL; + struct sk_buff *skb = NULL; ++ struct urb *urb = NULL; + int i, ret; + + init_usb_anchor(&hif_dev->reg_in_submitted); + + for (i = 0; i < MAX_REG_IN_URB_NUM; i++) { + ++ rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL); ++ if (!rx_buf) { ++ ret = -ENOMEM; ++ goto err_rxb; ++ } ++ + /* Allocate URB */ + urb = usb_alloc_urb(0, GFP_KERNEL); + if (urb == NULL) { +@@ -914,11 +937,14 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev) + goto err_skb; + } + ++ rx_buf->hif_dev = hif_dev; ++ rx_buf->skb = skb; ++ + usb_fill_int_urb(urb, hif_dev->udev, + usb_rcvintpipe(hif_dev->udev, + USB_REG_IN_PIPE), + skb->data, MAX_REG_IN_BUF_SIZE, +- ath9k_hif_usb_reg_in_cb, skb, 1); ++ ath9k_hif_usb_reg_in_cb, rx_buf, 1); + + /* Anchor URB */ + usb_anchor_urb(urb, &hif_dev->reg_in_submitted); +@@ -944,6 +970,8 @@ err_submit: + err_skb: + usb_free_urb(urb); + err_urb: ++ kfree(rx_buf); ++err_rxb: + ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev); + return ret; + } +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h +index a95cdf562611..835264c36595 100644 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.h ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.h +@@ -84,6 +84,11 @@ struct tx_buf { + struct list_head list; + }; + ++struct rx_buf { ++ struct sk_buff *skb; ++ struct hif_device_usb *hif_dev; ++}; ++ + #define HIF_USB_TX_STOP BIT(0) + #define HIF_USB_TX_FLUSH BIT(1) + +diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h +index 7bfea47dbb47..f63417197a62 100644 +--- a/drivers/pinctrl/pinctrl-amd.h ++++ b/drivers/pinctrl/pinctrl-amd.h +@@ -249,7 +249,7 @@ static const struct amd_pingroup kerncz_groups[] = { + { + .name = "uart0", + .pins = uart0_pins, +- .npins = 9, ++ .npins = 5, + }, + { + .name = "uart1", +diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c +index 319868f3f674..083cd11ce7d7 100644 +--- a/drivers/scsi/scsi_transport_spi.c ++++ b/drivers/scsi/scsi_transport_spi.c +@@ -353,7 +353,7 @@ store_spi_transport_##field(struct device *dev, \ + struct spi_transport_attrs *tp \ + = (struct spi_transport_attrs *)&starget->starget_data; \ + \ +- if (i->f->set_##field) \ ++ if (!i->f->set_##field) \ + return -EINVAL; \ + val = simple_strtoul(buf, NULL, 0); \ + if (val > tp->max_##field) \ +diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c +index ccd1a91290bf..536a135cd00b 100644 +--- a/drivers/staging/comedi/drivers/addi_apci_1032.c ++++ b/drivers/staging/comedi/drivers/addi_apci_1032.c +@@ -115,14 +115,22 @@ static int apci1032_cos_insn_config(struct comedi_device *dev, + unsigned int *data) + { + struct apci1032_private *devpriv = dev->private; +- unsigned int shift, oldmask; ++ unsigned int shift, oldmask, himask, lomask; + + switch (data[0]) { + case INSN_CONFIG_DIGITAL_TRIG: + if (data[1] != 0) + return -EINVAL; + shift = data[3]; +- oldmask = (1U << shift) - 1; ++ if (shift < 32) { ++ oldmask = (1U << shift) - 1; ++ himask = data[4] << shift; ++ lomask = data[5] << shift; ++ } else { ++ oldmask = 0xffffffffu; ++ himask = 0; ++ lomask = 0; ++ } + switch (data[2]) { + case COMEDI_DIGITAL_TRIG_DISABLE: + devpriv->ctrl = 0; +@@ -145,8 +153,8 @@ static int apci1032_cos_insn_config(struct comedi_device *dev, + devpriv->mode2 &= oldmask; + } + /* configure specified channels */ +- devpriv->mode1 |= data[4] << shift; +- devpriv->mode2 |= data[5] << shift; ++ devpriv->mode1 |= himask; ++ devpriv->mode2 |= lomask; + break; + case COMEDI_DIGITAL_TRIG_ENABLE_LEVELS: + if (devpriv->ctrl != (APCI1032_CTRL_INT_ENA | +@@ -163,8 +171,8 @@ static int apci1032_cos_insn_config(struct comedi_device *dev, + devpriv->mode2 &= oldmask; + } + /* configure specified channels */ +- devpriv->mode1 |= data[4] << shift; +- devpriv->mode2 |= data[5] << shift; ++ devpriv->mode1 |= himask; ++ devpriv->mode2 |= lomask; + break; + default: + return -EINVAL; +diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c +index 79a8799b1262..c4e36fb6df9d 100644 +--- a/drivers/staging/comedi/drivers/addi_apci_1500.c ++++ b/drivers/staging/comedi/drivers/addi_apci_1500.c +@@ -461,13 +461,14 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev, + struct apci1500_private *devpriv = dev->private; + unsigned int trig = data[1]; + unsigned int shift = data[3]; +- unsigned int hi_mask = data[4] << shift; +- unsigned int lo_mask = data[5] << shift; +- unsigned int chan_mask = hi_mask | lo_mask; +- unsigned int old_mask = (1 << shift) - 1; ++ unsigned int hi_mask; ++ unsigned int lo_mask; ++ unsigned int chan_mask; ++ unsigned int old_mask; + unsigned int pm; + unsigned int pt; + unsigned int pp; ++ unsigned int invalid_chan; + + if (trig > 1) { + dev_dbg(dev->class_dev, +@@ -475,7 +476,20 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev, + return -EINVAL; + } + +- if (chan_mask > 0xffff) { ++ if (shift <= 16) { ++ hi_mask = data[4] << shift; ++ lo_mask = data[5] << shift; ++ old_mask = (1U << shift) - 1; ++ invalid_chan = (data[4] | data[5]) >> (16 - shift); ++ } else { ++ hi_mask = 0; ++ lo_mask = 0; ++ old_mask = 0xffff; ++ invalid_chan = data[4] | data[5]; ++ } ++ chan_mask = hi_mask | lo_mask; ++ ++ if (invalid_chan) { + dev_dbg(dev->class_dev, "invalid digital trigger channel\n"); + return -EINVAL; + } +diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c +index f1ccfbd4c578..340e55c69263 100644 +--- a/drivers/staging/comedi/drivers/addi_apci_1564.c ++++ b/drivers/staging/comedi/drivers/addi_apci_1564.c +@@ -288,14 +288,22 @@ static int apci1564_cos_insn_config(struct comedi_device *dev, + unsigned int *data) + { + struct apci1564_private *devpriv = dev->private; +- unsigned int shift, oldmask; ++ unsigned int shift, oldmask, himask, lomask; + + switch (data[0]) { + case INSN_CONFIG_DIGITAL_TRIG: + if (data[1] != 0) + return -EINVAL; + shift = data[3]; +- oldmask = (1U << shift) - 1; ++ if (shift < 32) { ++ oldmask = (1U << shift) - 1; ++ himask = data[4] << shift; ++ lomask = data[5] << shift; ++ } else { ++ oldmask = 0xffffffffu; ++ himask = 0; ++ lomask = 0; ++ } + switch (data[2]) { + case COMEDI_DIGITAL_TRIG_DISABLE: + devpriv->ctrl = 0; +@@ -319,8 +327,8 @@ static int apci1564_cos_insn_config(struct comedi_device *dev, + devpriv->mode2 &= oldmask; + } + /* configure specified channels */ +- devpriv->mode1 |= data[4] << shift; +- devpriv->mode2 |= data[5] << shift; ++ devpriv->mode1 |= himask; ++ devpriv->mode2 |= lomask; + break; + case COMEDI_DIGITAL_TRIG_ENABLE_LEVELS: + if (devpriv->ctrl != (APCI1564_DI_IRQ_ENA | +@@ -337,8 +345,8 @@ static int apci1564_cos_insn_config(struct comedi_device *dev, + devpriv->mode2 &= oldmask; + } + /* configure specified channels */ +- devpriv->mode1 |= data[4] << shift; +- devpriv->mode2 |= data[5] << shift; ++ devpriv->mode1 |= himask; ++ devpriv->mode2 |= lomask; + break; + default: + return -EINVAL; +diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c +index 62a817e4cd64..5b904cf07bd1 100644 +--- a/drivers/staging/comedi/drivers/ni_6527.c ++++ b/drivers/staging/comedi/drivers/ni_6527.c +@@ -341,7 +341,7 @@ static int ni6527_intr_insn_config(struct comedi_device *dev, + case COMEDI_DIGITAL_TRIG_ENABLE_EDGES: + /* check shift amount */ + shift = data[3]; +- if (shift >= s->n_chan) { ++ if (shift >= 32) { + mask = 0; + rising = 0; + falling = 0; +diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c +index 8abf3f87a2d5..6da5c66bb3d5 100644 +--- a/drivers/staging/wlan-ng/prism2usb.c ++++ b/drivers/staging/wlan-ng/prism2usb.c +@@ -60,11 +60,25 @@ static int prism2sta_probe_usb(struct usb_interface *interface, + const struct usb_device_id *id) + { + struct usb_device *dev; +- ++ const struct usb_endpoint_descriptor *epd; ++ const struct usb_host_interface *iface_desc = interface->cur_altsetting; + wlandevice_t *wlandev = NULL; + hfa384x_t *hw = NULL; + int result = 0; + ++ if (iface_desc->desc.bNumEndpoints != 2) { ++ result = -ENODEV; ++ goto failed; ++ } ++ ++ result = -EINVAL; ++ epd = &iface_desc->endpoint[1].desc; ++ if (!usb_endpoint_is_bulk_in(epd)) ++ goto failed; ++ epd = &iface_desc->endpoint[2].desc; ++ if (!usb_endpoint_is_bulk_out(epd)) ++ goto failed; ++ + dev = interface_to_usbdev(interface); + wlandev = create_wlan(); + if (wlandev == NULL) { +diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c +index 39126460c1f5..e9ea9005a984 100644 +--- a/drivers/tty/serial/8250/8250_core.c ++++ b/drivers/tty/serial/8250/8250_core.c +@@ -530,6 +530,7 @@ static void __init serial8250_isa_init_ports(void) + */ + up->mcr_mask = ~ALPHA_KLUDGE_MCR; + up->mcr_force = ALPHA_KLUDGE_MCR; ++ serial8250_set_defaults(up); + } + + /* chain base port ops to support Remote Supervisor Adapter */ +@@ -553,7 +554,6 @@ static void __init serial8250_isa_init_ports(void) + port->membase = old_serial_port[i].iomem_base; + port->iotype = old_serial_port[i].io_type; + port->regshift = old_serial_port[i].iomem_reg_shift; +- serial8250_set_defaults(up); + + port->irqflags |= irqflag; + if (serial8250_isa_config != NULL) +diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c +index 035810bbcd02..470ccf729d59 100644 +--- a/drivers/tty/serial/8250/8250_mtk.c ++++ b/drivers/tty/serial/8250/8250_mtk.c +@@ -47,8 +47,21 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, + struct uart_8250_port *up = + container_of(port, struct uart_8250_port, port); + ++ /* ++ * Store the requested baud rate before calling the generic 8250 ++ * set_termios method. Standard 8250 port expects bauds to be ++ * no higher than (uartclk / 16) so the baud will be clamped if it ++ * gets out of that bound. Mediatek 8250 port supports speed ++ * higher than that, therefore we'll get original baud rate back ++ * after calling the generic set_termios method and recalculate ++ * the speed later in this method. ++ */ ++ baud = tty_termios_baud_rate(termios); ++ + serial8250_do_set_termios(port, termios, old); + ++ tty_termios_encode_baud_rate(termios, baud, baud); ++ + /* + * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS) + * +@@ -91,6 +104,11 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, + */ + spin_lock_irqsave(&port->lock, flags); + ++ /* ++ * Update the per-port timeout. ++ */ ++ uart_update_timeout(port, termios->c_cflag, baud); ++ + /* set DLAB we have cval saved in up->lcr from the call to the core */ + serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); + serial_dl_write(up, quot); +diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c +index 594639e5cbf8..78168e1827b5 100644 +--- a/drivers/usb/gadget/udc/gr_udc.c ++++ b/drivers/usb/gadget/udc/gr_udc.c +@@ -2001,9 +2001,12 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit) + + if (num == 0) { + _req = gr_alloc_request(&ep->ep, GFP_ATOMIC); ++ if (!_req) ++ return -ENOMEM; ++ + buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC); +- if (!_req || !buf) { +- /* possible _req freed by gr_probe via gr_remove */ ++ if (!buf) { ++ gr_free_request(&ep->ep, _req); + return -ENOMEM; + } + +diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c +index 81c5d07a2af1..228bfa19b745 100644 +--- a/fs/btrfs/backref.c ++++ b/fs/btrfs/backref.c +@@ -1221,6 +1221,7 @@ static int __btrfs_find_all_roots(struct btrfs_trans_handle *trans, + if (ret < 0 && ret != -ENOENT) { + ulist_free(tmp); + ulist_free(*roots); ++ *roots = NULL; + return ret; + } + node = ulist_next(tmp, &uiter); +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c +index 55ce6543050d..dcae0cf4924b 100644 +--- a/fs/btrfs/volumes.c ++++ b/fs/btrfs/volumes.c +@@ -6693,6 +6693,14 @@ int btrfs_read_chunk_tree(struct btrfs_root *root) + mutex_lock(&uuid_mutex); + lock_chunks(root); + ++ /* ++ * It is possible for mount and umount to race in such a way that ++ * we execute this code path, but open_fs_devices failed to clear ++ * total_rw_bytes. We certainly want it cleared before reading the ++ * device items, so clear it here. ++ */ ++ root->fs_info->fs_devices->total_rw_bytes = 0; ++ + /* + * Read all device items, and then all the chunk items. All + * device items are found before any chunk item (their object id +diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c +index a002e289a544..c18c26a78453 100644 +--- a/fs/cifs/inode.c ++++ b/fs/cifs/inode.c +@@ -1737,7 +1737,6 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry, + FILE_UNIX_BASIC_INFO *info_buf_target; + unsigned int xid; + int rc, tmprc; +- bool new_target = d_really_is_negative(target_dentry); + + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; +@@ -1814,13 +1813,8 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry, + */ + + unlink_target: +- /* +- * If the target dentry was created during the rename, try +- * unlinking it if it's not negative +- */ +- if (new_target && +- d_really_is_positive(target_dentry) && +- (rc == -EACCES || rc == -EEXIST)) { ++ /* Try unlinking the target dentry if it's not negative */ ++ if (d_really_is_positive(target_dentry) && (rc == -EACCES || rc == -EEXIST)) { + if (d_is_dir(target_dentry)) + tmprc = cifs_rmdir(target_dir, target_dentry); + else +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c +index 4d76e9a97538..7789f0b9b999 100644 +--- a/fs/nfs/direct.c ++++ b/fs/nfs/direct.c +@@ -385,6 +385,8 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write) + if (write) + nfs_zap_mapping(inode, inode->i_mapping); + ++ inode_dio_end(inode); ++ + if (dreq->iocb) { + long res = (long) dreq->error; + if (!res) +@@ -394,10 +396,7 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write) + + complete_all(&dreq->completion); + +- igrab(inode); + nfs_direct_req_release(dreq); +- inode_dio_end(inode); +- iput(inode); + } + + static void nfs_direct_readpage_release(struct nfs_page *req) +@@ -538,10 +537,8 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq, + * generic layer handle the completion. + */ + if (requested_bytes == 0) { +- igrab(inode); +- nfs_direct_req_release(dreq); + inode_dio_end(inode); +- iput(inode); ++ nfs_direct_req_release(dreq); + return result < 0 ? result : -EIO; + } + +@@ -942,10 +939,8 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, + * generic layer handle the completion. + */ + if (requested_bytes == 0) { +- igrab(inode); +- nfs_direct_req_release(dreq); + inode_dio_end(inode); +- iput(inode); ++ nfs_direct_req_release(dreq); + return result < 0 ? result : -EIO; + } + +diff --git a/fs/nfs/file.c b/fs/nfs/file.c +index eaa6697d256e..dc875cd0e11d 100644 +--- a/fs/nfs/file.c ++++ b/fs/nfs/file.c +@@ -82,7 +82,6 @@ nfs_file_release(struct inode *inode, struct file *filp) + dprintk("NFS: release(%pD2)\n", filp); + + nfs_inc_stats(inode, NFSIOS_VFSRELEASE); +- inode_dio_wait(inode); + nfs_file_clear_open_context(filp); + return 0; + } +diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c +index d98ba57ef01a..c167bdaafc50 100644 +--- a/fs/xfs/libxfs/xfs_bmap.c ++++ b/fs/xfs/libxfs/xfs_bmap.c +@@ -793,6 +793,8 @@ xfs_bmap_extents_to_btree( + *logflagsp = 0; + if ((error = xfs_alloc_vextent(&args))) { + xfs_iroot_realloc(ip, -1, whichfork); ++ ASSERT(ifp->if_broot == NULL); ++ XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); + xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); + return error; + } +diff --git a/include/linux/tcp.h b/include/linux/tcp.h +index 085da1707cea..b9e591582be9 100644 +--- a/include/linux/tcp.h ++++ b/include/linux/tcp.h +@@ -211,7 +211,8 @@ struct tcp_sock { + u8 reord; /* reordering detected */ + } rack; + u16 advmss; /* Advertised MSS */ +- u8 unused; ++ u8 tlp_retrans:1, /* TLP is a retransmission */ ++ unused_1:7; + u8 nonagle : 4,/* Disable Nagle algorithm? */ + thin_lto : 1,/* Use linear timeouts for thin streams */ + thin_dupack : 1,/* Fast retransmit on first dupack */ +@@ -225,7 +226,7 @@ struct tcp_sock { + syn_data_acked:1,/* data in SYN is acked by SYN-ACK */ + save_syn:1, /* Save headers of SYN packet */ + is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */ +- u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */ ++ u32 tlp_high_seq; /* snd_nxt at the time of TLP */ + + /* RTT measurement */ + u32 srtt_us; /* smoothed round trip time << 3 in usecs */ +diff --git a/kernel/events/core.c b/kernel/events/core.c +index feff3ba98cc9..388ce03155b4 100644 +--- a/kernel/events/core.c ++++ b/kernel/events/core.c +@@ -3940,7 +3940,9 @@ EXPORT_SYMBOL_GPL(perf_event_read_value); + static int __perf_read_group_add(struct perf_event *leader, + u64 read_format, u64 *values) + { ++ struct perf_event_context *ctx = leader->ctx; + struct perf_event *sub; ++ unsigned long flags; + int n = 1; /* skip @nr */ + int ret; + +@@ -3970,12 +3972,15 @@ static int __perf_read_group_add(struct perf_event *leader, + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(leader); + ++ raw_spin_lock_irqsave(&ctx->lock, flags); ++ + list_for_each_entry(sub, &leader->sibling_list, group_entry) { + values[n++] += perf_event_count(sub); + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(sub); + } + ++ raw_spin_unlock_irqrestore(&ctx->lock, flags); + return 0; + } + +diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c +index e7dabb254404..d937fbbc3642 100644 +--- a/kernel/events/uprobes.c ++++ b/kernel/events/uprobes.c +@@ -1875,7 +1875,7 @@ static void handle_swbp(struct pt_regs *regs) + if (!uprobe) { + if (is_swbp > 0) { + /* No matching uprobe; signal SIGTRAP. */ +- send_sig(SIGTRAP, current, 0); ++ force_sig(SIGTRAP, current); + } else { + /* + * Either we raced with uprobe_unregister() or we can't +diff --git a/mm/memcontrol.c b/mm/memcontrol.c +index cb98a1889c8c..617feca8d094 100644 +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -4889,7 +4889,6 @@ static void __mem_cgroup_clear_mc(void) + if (!mem_cgroup_is_root(mc.to)) + page_counter_uncharge(&mc.to->memory, mc.moved_swap); + +- mem_cgroup_id_get_many(mc.to, mc.moved_swap); + css_put_many(&mc.to->css, mc.moved_swap); + + mc.moved_swap = 0; +@@ -5067,7 +5066,8 @@ put: /* get_mctgt_type() gets the page */ + ent = target.ent; + if (!mem_cgroup_move_swap_account(ent, mc.from, mc.to)) { + mc.precharge--; +- /* we fixup refcnts and charges later. */ ++ mem_cgroup_id_get_many(mc.to, 1); ++ /* we fixup other refcnts and charges later. */ + mc.moved_swap++; + } + break; +diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c +index 02be8ee23271..64fede18aa33 100644 +--- a/net/ax25/af_ax25.c ++++ b/net/ax25/af_ax25.c +@@ -1191,7 +1191,10 @@ static int __must_check ax25_connect(struct socket *sock, + if (addr_len > sizeof(struct sockaddr_ax25) && + fsa->fsa_ax25.sax25_ndigis != 0) { + /* Valid number of digipeaters ? */ +- if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) { ++ if (fsa->fsa_ax25.sax25_ndigis < 1 || ++ fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS || ++ addr_len < sizeof(struct sockaddr_ax25) + ++ sizeof(ax25_address) * fsa->fsa_ax25.sax25_ndigis) { + err = -EINVAL; + goto out_release; + } +@@ -1510,7 +1513,10 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)usax; + + /* Valid number of digipeaters ? */ +- if (usax->sax25_ndigis < 1 || usax->sax25_ndigis > AX25_MAX_DIGIS) { ++ if (usax->sax25_ndigis < 1 || ++ usax->sax25_ndigis > AX25_MAX_DIGIS || ++ addr_len < sizeof(struct sockaddr_ax25) + ++ sizeof(ax25_address) * usax->sax25_ndigis) { + err = -EINVAL; + goto out; + } +diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c +index 579d351f6ddd..c976fd132c3b 100644 +--- a/net/core/net-sysfs.c ++++ b/net/core/net-sysfs.c +@@ -999,7 +999,7 @@ static ssize_t show_trans_timeout(struct netdev_queue *queue, + trans_timeout = queue->trans_timeout; + spin_unlock_irq(&queue->_xmit_lock); + +- return sprintf(buf, "%lu", trans_timeout); ++ return sprintf(buf, fmt_ulong, trans_timeout); + } + + #ifdef CONFIG_XPS +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c +index e2066f2f19b4..9215ee1de494 100644 +--- a/net/ipv4/tcp_input.c ++++ b/net/ipv4/tcp_input.c +@@ -3517,10 +3517,8 @@ static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) + } + } + +-/* This routine deals with acks during a TLP episode. +- * We mark the end of a TLP episode on receiving TLP dupack or when +- * ack is after tlp_high_seq. +- * Ref: loss detection algorithm in draft-dukkipati-tcpm-tcp-loss-probe. ++/* This routine deals with acks during a TLP episode and ends an episode by ++ * resetting tlp_high_seq. Ref: TLP algorithm in draft-ietf-tcpm-rack + */ + static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag) + { +@@ -3529,7 +3527,10 @@ static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag) + if (before(ack, tp->tlp_high_seq)) + return; + +- if (flag & FLAG_DSACKING_ACK) { ++ if (!tp->tlp_retrans) { ++ /* TLP of new data has been acknowledged */ ++ tp->tlp_high_seq = 0; ++ } else if (flag & FLAG_DSACKING_ACK) { + /* This DSACK means original and TLP probe arrived; no loss */ + tp->tlp_high_seq = 0; + } else if (after(ack, tp->tlp_high_seq)) { +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c +index 6c8966dcf612..b218138874cc 100644 +--- a/net/ipv4/tcp_output.c ++++ b/net/ipv4/tcp_output.c +@@ -2271,6 +2271,11 @@ void tcp_send_loss_probe(struct sock *sk) + int pcount; + int mss = tcp_current_mss(sk); + ++ /* At most one outstanding TLP */ ++ if (tp->tlp_high_seq) ++ goto rearm_timer; ++ ++ tp->tlp_retrans = 0; + skb = tcp_send_head(sk); + if (skb) { + if (tcp_snd_wnd_test(tp, skb, mss)) { +@@ -2293,10 +2298,6 @@ void tcp_send_loss_probe(struct sock *sk) + return; + } + +- /* At most one outstanding TLP retransmission. */ +- if (tp->tlp_high_seq) +- goto rearm_timer; +- + if (skb_still_in_host_queue(sk, skb)) + goto rearm_timer; + +@@ -2317,10 +2318,12 @@ void tcp_send_loss_probe(struct sock *sk) + if (__tcp_retransmit_skb(sk, skb)) + goto rearm_timer; + ++ tp->tlp_retrans = 1; ++ ++probe_sent: + /* Record snd_nxt for loss detection. */ + tp->tlp_high_seq = tp->snd_nxt; + +-probe_sent: + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPLOSSPROBES); + /* Reset s.t. tcp_rearm_rto will restart timer from now */ + inet_csk(sk)->icsk_pending = 0; +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c +index bb306996c15e..5464fd210230 100644 +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -1558,7 +1558,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) + /* + * UDP-Lite specific tests, ignored on UDP sockets + */ +- if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { ++ if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { + + /* + * MIB statistics other than incrementing the error count are +diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c +index 546172bfaba1..6efe6b101d3f 100644 +--- a/net/ipv6/ip6_gre.c ++++ b/net/ipv6/ip6_gre.c +@@ -1355,15 +1355,16 @@ static void ip6gre_destroy_tunnels(struct net *net, struct list_head *head) + static int __net_init ip6gre_init_net(struct net *net) + { + struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); ++ struct net_device *ndev; + int err; + +- ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0", +- NET_NAME_UNKNOWN, +- ip6gre_tunnel_setup); +- if (!ign->fb_tunnel_dev) { ++ ndev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0", ++ NET_NAME_UNKNOWN, ip6gre_tunnel_setup); ++ if (!ndev) { + err = -ENOMEM; + goto err_alloc_dev; + } ++ ign->fb_tunnel_dev = ndev; + dev_net_set(ign->fb_tunnel_dev, net); + /* FB netdevice is special: we have one, and only one per netns. + * Allowing to move it to another netns is clearly unsafe. +@@ -1383,7 +1384,7 @@ static int __net_init ip6gre_init_net(struct net *net) + return 0; + + err_reg_dev: +- ip6gre_dev_free(ign->fb_tunnel_dev); ++ ip6gre_dev_free(ndev); + err_alloc_dev: + return err; + } +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c +index 73f111206e36..79c583004575 100644 +--- a/net/ipv6/udp.c ++++ b/net/ipv6/udp.c +@@ -672,7 +672,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) + /* + * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c). + */ +- if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { ++ if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) { + + if (up->pcrlen == 0) { /* full coverage was set */ + net_dbg_ratelimited("UDPLITE6: partial coverage %d while full coverage %d requested\n", +diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c +index a74a6ff18f91..886dce84e70c 100644 +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -1963,6 +1963,7 @@ static int ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) + + static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) + { ++ struct ieee80211_hdr *hdr = (void *)rx->skb->data; + struct sk_buff *skb = rx->skb; + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); + +@@ -1973,6 +1974,31 @@ static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) + if (status->flag & RX_FLAG_DECRYPTED) + return 0; + ++ /* check mesh EAPOL frames first */ ++ if (unlikely(rx->sta && ieee80211_vif_is_mesh(&rx->sdata->vif) && ++ ieee80211_is_data(fc))) { ++ struct ieee80211s_hdr *mesh_hdr; ++ u16 hdr_len = ieee80211_hdrlen(fc); ++ u16 ethertype_offset; ++ __be16 ethertype; ++ ++ if (!ether_addr_equal(hdr->addr1, rx->sdata->vif.addr)) ++ goto drop_check; ++ ++ /* make sure fixed part of mesh header is there, also checks skb len */ ++ if (!pskb_may_pull(rx->skb, hdr_len + 6)) ++ goto drop_check; ++ ++ mesh_hdr = (struct ieee80211s_hdr *)(skb->data + hdr_len); ++ ethertype_offset = hdr_len + ieee80211_get_mesh_hdrlen(mesh_hdr) + ++ sizeof(rfc1042_header); ++ ++ if (skb_copy_bits(rx->skb, ethertype_offset, ðertype, 2) == 0 && ++ ethertype == rx->sdata->control_port_protocol) ++ return 0; ++ } ++ ++drop_check: + /* Drop unencrypted frames if key is set. */ + if (unlikely(!ieee80211_has_protected(fc) && + !ieee80211_is_any_nullfunc(fc) && +diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c +index 14c4e12c47b0..a1997f9a447a 100644 +--- a/net/rxrpc/ar-output.c ++++ b/net/rxrpc/ar-output.c +@@ -533,7 +533,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, + /* this should be in poll */ + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); + +- if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) ++ if (sk->sk_shutdown & SEND_SHUTDOWN) + return -EPIPE; + + more = msg->msg_flags & MSG_MORE; +diff --git a/net/rxrpc/ar-recvmsg.c b/net/rxrpc/ar-recvmsg.c +index b92beded7459..cb9affdb1e87 100644 +--- a/net/rxrpc/ar-recvmsg.c ++++ b/net/rxrpc/ar-recvmsg.c +@@ -78,7 +78,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + release_sock(&rx->sk); + if (continue_call) + rxrpc_put_call(continue_call); +- return -ENODATA; ++ return -EAGAIN; + } + } + +diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh +index 4f5e76f76b9d..003968cb04d4 100755 +--- a/scripts/decode_stacktrace.sh ++++ b/scripts/decode_stacktrace.sh +@@ -63,8 +63,8 @@ parse_symbol() { + return + fi + +- # Strip out the base of the path +- code=${code#$basepath/} ++ # Strip out the base of the path on each line ++ code=$(while read -r line; do echo "${line#$basepath/}"; done <<< "$code") + + # In the case of inlines, move everything to same line + code=${code//$'\n'/' '} +diff --git a/sound/core/info.c b/sound/core/info.c +index 358a6947342d..8a6fa8fd0aab 100644 +--- a/sound/core/info.c ++++ b/sound/core/info.c +@@ -634,7 +634,9 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) + { + int c = -1; + +- if (snd_BUG_ON(!buffer || !buffer->buffer)) ++ if (snd_BUG_ON(!buffer)) ++ return 1; ++ if (!buffer->buffer) + return 1; + if (len <= 0 || buffer->stop || buffer->error) + return 1; +diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h +index 3f1b0f1df809..e4e31e82311d 100644 +--- a/sound/soc/codecs/rt5670.h ++++ b/sound/soc/codecs/rt5670.h +@@ -760,7 +760,7 @@ + #define RT5670_PWR_VREF2_BIT 4 + #define RT5670_PWR_FV2 (0x1 << 3) + #define RT5670_PWR_FV2_BIT 3 +-#define RT5670_LDO_SEL_MASK (0x3) ++#define RT5670_LDO_SEL_MASK (0x7) + #define RT5670_LDO_SEL_SFT 0 + + /* Power Management for Analog 2 (0x64) */ +diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c +index 20f0e27918dd..acd460303d1a 100644 +--- a/tools/perf/builtin-script.c ++++ b/tools/perf/builtin-script.c +@@ -1245,7 +1245,7 @@ static int is_directory(const char *base_path, const struct dirent *dent) + char path[PATH_MAX]; + struct stat st; + +- sprintf(path, "%s/%s", base_path, dent->d_name); ++ scnprintf(path, PATH_MAX, "%s/%s", base_path, dent->d_name); + if (stat(path, &st)) + return 0; + +@@ -1426,8 +1426,8 @@ static int list_available_scripts(const struct option *opt __maybe_unused, + return -1; + + for_each_lang(scripts_path, scripts_dir, lang_dirent) { +- snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, +- lang_dirent->d_name); ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, ++ lang_dirent->d_name); + lang_dir = opendir(lang_path); + if (!lang_dir) + continue; +@@ -1436,8 +1436,8 @@ static int list_available_scripts(const struct option *opt __maybe_unused, + script_root = get_script_root(script_dirent, REPORT_SUFFIX); + if (script_root) { + desc = script_desc__findnew(script_root); +- snprintf(script_path, MAXPATHLEN, "%s/%s", +- lang_path, script_dirent->d_name); ++ scnprintf(script_path, MAXPATHLEN, "%s/%s", ++ lang_path, script_dirent->d_name); + read_script_info(desc, script_path); + free(script_root); + } +@@ -1473,7 +1473,7 @@ static int check_ev_match(char *dir_name, char *scriptname, + int match, len; + FILE *fp; + +- sprintf(filename, "%s/bin/%s-record", dir_name, scriptname); ++ scnprintf(filename, MAXPATHLEN, "%s/bin/%s-record", dir_name, scriptname); + + fp = fopen(filename, "r"); + if (!fp) +@@ -1549,8 +1549,8 @@ int find_scripts(char **scripts_array, char **scripts_path_array) + } + + for_each_lang(scripts_path, scripts_dir, lang_dirent) { +- snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, +- lang_dirent->d_name); ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, ++ lang_dirent->d_name); + #ifdef NO_LIBPERL + if (strstr(lang_path, "perl")) + continue; +@@ -1605,8 +1605,8 @@ static char *get_script_path(const char *script_root, const char *suffix) + return NULL; + + for_each_lang(scripts_path, scripts_dir, lang_dirent) { +- snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, +- lang_dirent->d_name); ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, ++ lang_dirent->d_name); + lang_dir = opendir(lang_path); + if (!lang_dir) + continue; +@@ -1617,8 +1617,8 @@ static char *get_script_path(const char *script_root, const char *suffix) + free(__script_root); + closedir(lang_dir); + closedir(scripts_dir); +- snprintf(script_path, MAXPATHLEN, "%s/%s", +- lang_path, script_dirent->d_name); ++ scnprintf(script_path, MAXPATHLEN, "%s/%s", ++ lang_path, script_dirent->d_name); + return strdup(script_path); + } + free(__script_root); +diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c +index 79547c225c14..9c81fbfb16d2 100644 +--- a/tools/perf/tests/attr.c ++++ b/tools/perf/tests/attr.c +@@ -147,8 +147,8 @@ static int run_dir(const char *d, const char *perf) + if (verbose) + vcnt++; + +- snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s", +- d, d, perf, vcnt, v); ++ scnprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s", ++ d, d, perf, vcnt, v); + + return system(cmd) ? TEST_FAIL : TEST_OK; + } +diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c +index faa04e9d5d5f..b776831ceeea 100644 +--- a/tools/perf/tests/pmu.c ++++ b/tools/perf/tests/pmu.c +@@ -95,7 +95,7 @@ static char *test_format_dir_get(void) + struct test_format *format = &test_formats[i]; + FILE *file; + +- snprintf(name, PATH_MAX, "%s/%s", dir, format->name); ++ scnprintf(name, PATH_MAX, "%s/%s", dir, format->name); + + file = fopen(name, "w"); + if (!file) +diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c +index 1dd1949b0e79..1e1c37a17355 100644 +--- a/tools/perf/util/annotate.c ++++ b/tools/perf/util/annotate.c +@@ -1077,7 +1077,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize) + struct dso *dso = map->dso; + char *filename = dso__build_id_filename(dso, NULL, 0); + bool free_filename = true; +- char command[PATH_MAX * 2]; ++ char *command; + FILE *file; + int err = 0; + char symfs_filename[PATH_MAX]; +@@ -1192,7 +1192,7 @@ fallback: + strcpy(symfs_filename, tmp); + } + +- snprintf(command, sizeof(command), ++ err = asprintf(&command, + "%s %s%s --start-address=0x%016" PRIx64 + " --stop-address=0x%016" PRIx64 + " -l -d %s %s -C %s 2>/dev/null|grep -v %s|expand", +@@ -1205,6 +1205,11 @@ fallback: + symbol_conf.annotate_src ? "-S" : "", + symfs_filename, filename); + ++ if (err < 0) { ++ pr_err("Failure allocating memory for the command to run\n"); ++ goto out_remove_tmp; ++ } ++ + pr_debug("Executing: %s\n", command); + + file = popen(command, "r"); +@@ -1214,7 +1219,7 @@ fallback: + * If we were using debug info should retry with + * original binary. + */ +- goto out_remove_tmp; ++ goto out_free_command; + } + + nline = 0; +@@ -1237,6 +1242,9 @@ fallback: + + pclose(file); + ++out_free_command: ++ free(command); ++ + out_remove_tmp: + if (dso__needs_decompress(dso)) + unlink(symfs_filename); +diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c +index 32e12ecfe9c5..a32f0b34e3ed 100644 +--- a/tools/perf/util/cgroup.c ++++ b/tools/perf/util/cgroup.c +@@ -64,7 +64,7 @@ static int open_cgroup(char *name) + if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1)) + return -1; + +- snprintf(path, PATH_MAX, "%s/%s", mnt, name); ++ scnprintf(path, PATH_MAX, "%s/%s", mnt, name); + + fd = open(path, O_RDONLY); + if (fd == -1) +diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c +index 53ef006a951c..b301d779c4af 100644 +--- a/tools/perf/util/pager.c ++++ b/tools/perf/util/pager.c +@@ -16,10 +16,13 @@ static void pager_preexec(void) + * have real input + */ + fd_set in; ++ fd_set exception; + + FD_ZERO(&in); ++ FD_ZERO(&exception); + FD_SET(0, &in); +- select(1, &in, NULL, &in, NULL); ++ FD_SET(0, &exception); ++ select(1, &in, NULL, &exception, NULL); + + setenv("LESS", "FRSX", 0); + } +diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c +index 9351738df703..849ad278dd5d 100644 +--- a/tools/perf/util/parse-events.c ++++ b/tools/perf/util/parse-events.c +@@ -194,8 +194,8 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config) + + for_each_event(sys_dirent, evt_dir, evt_dirent) { + +- snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, +- evt_dirent->d_name); ++ scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, ++ evt_dirent->d_name); + fd = open(evt_path, O_RDONLY); + if (fd < 0) + continue; +diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c +index 4f650ebd564a..5245fbd09106 100644 +--- a/tools/perf/util/pmu.c ++++ b/tools/perf/util/pmu.c +@@ -302,7 +302,7 @@ static int pmu_aliases_parse(char *dir, struct list_head *head) + if (pmu_alias_info_file(name)) + continue; + +- snprintf(path, PATH_MAX, "%s/%s", dir, name); ++ scnprintf(path, PATH_MAX, "%s/%s", dir, name); + + file = fopen(path, "r"); + if (!file) { +diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c +index 0195b7e8c54a..4f05424096b6 100644 +--- a/tools/perf/util/probe-event.c ++++ b/tools/perf/util/probe-event.c +@@ -122,7 +122,7 @@ static struct symbol *__find_kernel_function(u64 addr, struct map **mapp) + return machine__find_kernel_function(host_machine, addr, mapp, NULL); + } + +-static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void) ++static struct ref_reloc_sym *kernel_get_ref_reloc_sym(struct map **pmap) + { + /* kmap->ref_reloc_sym should be set if host_machine is initialized */ + struct kmap *kmap; +@@ -134,6 +134,10 @@ static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void) + kmap = map__kmap(map); + if (!kmap) + return NULL; ++ ++ if (pmap) ++ *pmap = map; ++ + return kmap->ref_reloc_sym; + } + +@@ -145,7 +149,7 @@ static int kernel_get_symbol_address_by_name(const char *name, u64 *addr, + struct map *map; + + /* ref_reloc_sym is just a label. Need a special fix*/ +- reloc_sym = kernel_get_ref_reloc_sym(); ++ reloc_sym = kernel_get_ref_reloc_sym(NULL); + if (reloc_sym && strcmp(name, reloc_sym->name) == 0) + *addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr; + else { +@@ -618,6 +622,7 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs, + bool uprobe) + { + struct ref_reloc_sym *reloc_sym; ++ struct map *map; + char *tmp; + int i, skipped = 0; + +@@ -628,7 +633,7 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs, + if (module) + return add_module_to_probe_trace_events(tevs, ntevs, module); + +- reloc_sym = kernel_get_ref_reloc_sym(); ++ reloc_sym = kernel_get_ref_reloc_sym(&map); + if (!reloc_sym) { + pr_warning("Relocated base symbol is not found!\n"); + return -EINVAL; +@@ -637,9 +642,13 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs, + for (i = 0; i < ntevs; i++) { + if (!tevs[i].point.address || tevs[i].point.retprobe) + continue; +- /* If we found a wrong one, mark it by NULL symbol */ ++ /* ++ * If we found a wrong one, mark it by NULL symbol. ++ * Since addresses in debuginfo is same as objdump, we need ++ * to convert it to addresses on memory. ++ */ + if (kprobe_warn_out_range(tevs[i].point.symbol, +- tevs[i].point.address)) { ++ map__objdump_2mem(map, tevs[i].point.address))) { + tmp = NULL; + skipped++; + } else { +@@ -2553,7 +2562,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, + + /* Note that the symbols in the kmodule are not relocated */ + if (!pev->uprobes && !pp->retprobe && !pev->target) { +- reloc_sym = kernel_get_ref_reloc_sym(); ++ reloc_sym = kernel_get_ref_reloc_sym(NULL); + if (!reloc_sym) { + pr_warning("Relocated base symbol is not found!\n"); + ret = -EINVAL; +diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c +index b4db3f48e3b0..2853d4728ab9 100644 +--- a/tools/perf/util/srcline.c ++++ b/tools/perf/util/srcline.c +@@ -86,16 +86,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data) + bfd_vma pc, vma; + bfd_size_type size; + struct a2l_data *a2l = data; ++ flagword flags; + + if (a2l->found) + return; + +- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0) ++#ifdef bfd_get_section_flags ++ flags = bfd_get_section_flags(abfd, section); ++#else ++ flags = bfd_section_flags(section); ++#endif ++ if ((flags & SEC_ALLOC) == 0) + return; + + pc = a2l->addr; ++#ifdef bfd_get_section_vma + vma = bfd_get_section_vma(abfd, section); ++#else ++ vma = bfd_section_vma(section); ++#endif ++#ifdef bfd_get_section_size + size = bfd_get_section_size(section); ++#else ++ size = bfd_section_size(section); ++#endif + + if (pc < vma || pc >= vma + size) + return; diff --git a/patch/kernel/rockpis-legacy/patch-4.4.232-233-changed.patch b/patch/kernel/rockpis-legacy/patch-4.4.232-233-changed.patch new file mode 100644 index 000000000..0c6a9a423 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.232-233-changed.patch @@ -0,0 +1,4015 @@ +diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio +index 0439c2aaf7419..f20c783cb5c03 100644 +--- a/Documentation/ABI/testing/sysfs-bus-iio ++++ b/Documentation/ABI/testing/sysfs-bus-iio +@@ -1470,7 +1470,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_concentrationX_voc_raw + KernelVersion: 4.3 + Contact: linux-iio@vger.kernel.org + Description: +- Raw (unscaled no offset etc.) percentage reading of a substance. ++ Raw (unscaled no offset etc.) reading of a substance. Units ++ after application of scale and offset are percents. + + What: /sys/bus/iio/devices/iio:deviceX/in_resistance_raw + What: /sys/bus/iio/devices/iio:deviceX/in_resistanceX_raw +diff --git a/Makefile b/Makefile +index 47a0a6c8272bf..8f363a3bcaf81 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 232 ++SUBLEVEL = 233 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arm/include/asm/percpu.h b/arch/arm/include/asm/percpu.h +index a89b4076cde47..72821b4721add 100644 +--- a/arch/arm/include/asm/percpu.h ++++ b/arch/arm/include/asm/percpu.h +@@ -16,6 +16,8 @@ + #ifndef _ASM_ARM_PERCPU_H_ + #define _ASM_ARM_PERCPU_H_ + ++#include ++ + /* + * Same as asm-generic/percpu.h, except that we store the per cpu offset + * in the TPIDRPRW. TPIDRPRW only exists on V6K and V7 +diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c +index abcbea1ae30ba..78c6be1b27145 100644 +--- a/arch/arm/kernel/hw_breakpoint.c ++++ b/arch/arm/kernel/hw_breakpoint.c +@@ -688,6 +688,12 @@ static void disable_single_step(struct perf_event *bp) + arch_install_hw_breakpoint(bp); + } + ++static int watchpoint_fault_on_uaccess(struct pt_regs *regs, ++ struct arch_hw_breakpoint *info) ++{ ++ return !user_mode(regs) && info->ctrl.privilege == ARM_BREAKPOINT_USER; ++} ++ + static void watchpoint_handler(unsigned long addr, unsigned int fsr, + struct pt_regs *regs) + { +@@ -747,16 +753,27 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr, + } + + pr_debug("watchpoint fired: address = 0x%x\n", info->trigger); ++ ++ /* ++ * If we triggered a user watchpoint from a uaccess routine, ++ * then handle the stepping ourselves since userspace really ++ * can't help us with this. ++ */ ++ if (watchpoint_fault_on_uaccess(regs, info)) ++ goto step; ++ + perf_bp_event(wp, regs); + + /* +- * If no overflow handler is present, insert a temporary +- * mismatch breakpoint so we can single-step over the +- * watchpoint trigger. ++ * Defer stepping to the overflow handler if one is installed. ++ * Otherwise, insert a temporary mismatch breakpoint so that ++ * we can single-step over the watchpoint trigger. + */ +- if (!wp->overflow_handler) +- enable_single_step(wp, instruction_pointer(regs)); ++ if (wp->overflow_handler) ++ goto unlock; + ++step: ++ enable_single_step(wp, instruction_pointer(regs)); + unlock: + rcu_read_unlock(); + } +diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c +index 92b72375c4c72..6e8a50de40e2b 100644 +--- a/arch/arm/kernel/stacktrace.c ++++ b/arch/arm/kernel/stacktrace.c +@@ -19,6 +19,19 @@ + * A simple function epilogue looks like this: + * ldm sp, {fp, sp, pc} + * ++ * When compiled with clang, pc and sp are not pushed. A simple function ++ * prologue looks like this when built with clang: ++ * ++ * stmdb {..., fp, lr} ++ * add fp, sp, #x ++ * sub sp, sp, #y ++ * ++ * A simple function epilogue looks like this when built with clang: ++ * ++ * sub sp, fp, #x ++ * ldm {..., fp, pc} ++ * ++ * + * Note that with framepointer enabled, even the leaf functions have the same + * prologue and epilogue, therefore we can ignore the LR value in this case. + */ +@@ -31,6 +44,16 @@ int notrace unwind_frame(struct stackframe *frame) + low = frame->sp; + high = ALIGN(low, THREAD_SIZE); + ++#ifdef CONFIG_CC_IS_CLANG ++ /* check current frame pointer is within bounds */ ++ if (fp < low + 4 || fp > high - 4) ++ return -EINVAL; ++ ++ frame->sp = frame->fp; ++ frame->fp = *(unsigned long *)(fp); ++ frame->pc = frame->lr; ++ frame->lr = *(unsigned long *)(fp + 4); ++#else + /* check current frame pointer is within bounds */ + if (fp < low + 12 || fp > high - 4) + return -EINVAL; +@@ -39,6 +62,7 @@ int notrace unwind_frame(struct stackframe *frame) + frame->fp = *(unsigned long *)(fp - 12); + frame->sp = *(unsigned long *)(fp - 8); + frame->pc = *(unsigned long *)(fp - 4); ++#endif + + return 0; + } +diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c +index 84eefbc2b4f93..5923f2ca510be 100644 +--- a/arch/arm/mach-at91/pm.c ++++ b/arch/arm/mach-at91/pm.c +@@ -393,13 +393,13 @@ static void __init at91_pm_sram_init(void) + sram_pool = gen_pool_get(&pdev->dev, NULL); + if (!sram_pool) { + pr_warn("%s: sram pool unavailable!\n", __func__); +- return; ++ goto out_put_device; + } + + sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz); + if (!sram_base) { + pr_warn("%s: unable to alloc sram!\n", __func__); +- return; ++ goto out_put_device; + } + + sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base); +@@ -407,12 +407,17 @@ static void __init at91_pm_sram_init(void) + at91_pm_suspend_in_sram_sz, false); + if (!at91_suspend_sram_fn) { + pr_warn("SRAM: Could not map\n"); +- return; ++ goto out_put_device; + } + + /* Copy the pm suspend handler to SRAM */ + at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn, + &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); ++ return; ++ ++out_put_device: ++ put_device(&pdev->dev); ++ return; + } + + static void __init at91_pm_init(void) +diff --git a/arch/arm/mach-socfpga/pm.c b/arch/arm/mach-socfpga/pm.c +index c378ab0c24317..93f2245c97750 100644 +--- a/arch/arm/mach-socfpga/pm.c ++++ b/arch/arm/mach-socfpga/pm.c +@@ -60,14 +60,14 @@ static int socfpga_setup_ocram_self_refresh(void) + if (!ocram_pool) { + pr_warn("%s: ocram pool unavailable!\n", __func__); + ret = -ENODEV; +- goto put_node; ++ goto put_device; + } + + ocram_base = gen_pool_alloc(ocram_pool, socfpga_sdram_self_refresh_sz); + if (!ocram_base) { + pr_warn("%s: unable to alloc ocram!\n", __func__); + ret = -ENOMEM; +- goto put_node; ++ goto put_device; + } + + ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base); +@@ -78,7 +78,7 @@ static int socfpga_setup_ocram_self_refresh(void) + if (!suspend_ocram_base) { + pr_warn("%s: __arm_ioremap_exec failed!\n", __func__); + ret = -ENOMEM; +- goto put_node; ++ goto put_device; + } + + /* Copy the code that puts DDR in self refresh to ocram */ +@@ -92,6 +92,8 @@ static int socfpga_setup_ocram_self_refresh(void) + if (!socfpga_sdram_self_refresh_in_ocram) + ret = -EFAULT; + ++put_device: ++ put_device(&pdev->dev); + put_node: + of_node_put(np); + +diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c +index 4d2adfb32a2ab..358ca965cf824 100644 +--- a/arch/m68k/mac/iop.c ++++ b/arch/m68k/mac/iop.c +@@ -173,7 +173,7 @@ static __inline__ void iop_writeb(volatile struct mac_iop *iop, __u16 addr, __u8 + + static __inline__ void iop_stop(volatile struct mac_iop *iop) + { +- iop->status_ctrl &= ~IOP_RUN; ++ iop->status_ctrl = IOP_AUTOINC; + } + + static __inline__ void iop_start(volatile struct mac_iop *iop) +@@ -181,14 +181,9 @@ static __inline__ void iop_start(volatile struct mac_iop *iop) + iop->status_ctrl = IOP_RUN | IOP_AUTOINC; + } + +-static __inline__ void iop_bypass(volatile struct mac_iop *iop) +-{ +- iop->status_ctrl |= IOP_BYPASS; +-} +- + static __inline__ void iop_interrupt(volatile struct mac_iop *iop) + { +- iop->status_ctrl |= IOP_IRQ; ++ iop->status_ctrl = IOP_IRQ | IOP_RUN | IOP_AUTOINC; + } + + static int iop_alive(volatile struct mac_iop *iop) +@@ -239,7 +234,6 @@ void __init iop_preinit(void) + } else { + iop_base[IOP_NUM_SCC] = (struct mac_iop *) SCC_IOP_BASE_QUADRA; + } +- iop_base[IOP_NUM_SCC]->status_ctrl = 0x87; + iop_scc_present = 1; + } else { + iop_base[IOP_NUM_SCC] = NULL; +@@ -251,7 +245,7 @@ void __init iop_preinit(void) + } else { + iop_base[IOP_NUM_ISM] = (struct mac_iop *) ISM_IOP_BASE_QUADRA; + } +- iop_base[IOP_NUM_ISM]->status_ctrl = 0; ++ iop_stop(iop_base[IOP_NUM_ISM]); + iop_ism_present = 1; + } else { + iop_base[IOP_NUM_ISM] = NULL; +@@ -416,7 +410,8 @@ static void iop_handle_send(uint iop_num, uint chan) + iop_free_msg(msg2); + + iop_send_queue[iop_num][chan] = msg; +- if (msg) iop_do_send(msg); ++ if (msg && iop_readb(iop, IOP_ADDR_SEND_STATE + chan) == IOP_MSG_IDLE) ++ iop_do_send(msg); + } + + /* +@@ -497,16 +492,12 @@ int iop_send_message(uint iop_num, uint chan, void *privdata, + + if (!(q = iop_send_queue[iop_num][chan])) { + iop_send_queue[iop_num][chan] = msg; ++ iop_do_send(msg); + } else { + while (q->next) q = q->next; + q->next = msg; + } + +- if (iop_readb(iop_base[iop_num], +- IOP_ADDR_SEND_STATE + chan) == IOP_MSG_IDLE) { +- iop_do_send(msg); +- } +- + return 0; + } + +diff --git a/arch/mips/kernel/topology.c b/arch/mips/kernel/topology.c +index cf3eb61fad121..68da7613874aa 100644 +--- a/arch/mips/kernel/topology.c ++++ b/arch/mips/kernel/topology.c +@@ -19,7 +19,7 @@ static int __init topology_init(void) + for_each_present_cpu(i) { + struct cpu *c = &per_cpu(cpu_devices, i); + +- c->hotpluggable = 1; ++ c->hotpluggable = !!i; + ret = register_cpu(c, i); + if (ret) + printk(KERN_WARNING "topology_init: register_cpu %d " +diff --git a/arch/powerpc/include/asm/percpu.h b/arch/powerpc/include/asm/percpu.h +index 2cedefddba37f..61c78205a1d36 100644 +--- a/arch/powerpc/include/asm/percpu.h ++++ b/arch/powerpc/include/asm/percpu.h +@@ -9,8 +9,6 @@ + + #ifdef CONFIG_SMP + +-#include +- + #define __my_cpu_offset local_paca->data_offset + + #endif /* CONFIG_SMP */ +@@ -18,4 +16,6 @@ + + #include + ++#include ++ + #endif /* _ASM_POWERPC_PERCPU_H_ */ +diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c +index b457bfa284360..05c17429e5442 100644 +--- a/arch/powerpc/kernel/vdso.c ++++ b/arch/powerpc/kernel/vdso.c +@@ -702,7 +702,7 @@ int vdso_getcpu_init(void) + node = cpu_to_node(cpu); + WARN_ON_ONCE(node > 0xffff); + +- val = (cpu & 0xfff) | ((node & 0xffff) << 16); ++ val = (cpu & 0xffff) | ((node & 0xffff) << 16); + mtspr(SPRN_SPRG_VDSO_WRITE, val); + get_paca()->sprg_vdso = val; + +diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c +index 0e65d52eb56d3..2025e772fc9c9 100644 +--- a/arch/powerpc/platforms/pseries/hotplug-memory.c ++++ b/arch/powerpc/platforms/pseries/hotplug-memory.c +@@ -29,7 +29,7 @@ static bool rtas_hp_event; + unsigned long pseries_memory_block_size(void) + { + struct device_node *np; +- unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE; ++ u64 memblock_size = MIN_MEMORY_BLOCK_SIZE; + struct resource r; + + np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); +diff --git a/arch/sh/boards/mach-landisk/setup.c b/arch/sh/boards/mach-landisk/setup.c +index f1147caebacf0..af69fb7fef7c7 100644 +--- a/arch/sh/boards/mach-landisk/setup.c ++++ b/arch/sh/boards/mach-landisk/setup.c +@@ -85,6 +85,9 @@ device_initcall(landisk_devices_setup); + + static void __init landisk_setup(char **cmdline_p) + { ++ /* I/O port identity mapping */ ++ __set_io_port_base(0); ++ + /* LED ON */ + __raw_writeb(__raw_readb(PA_LED) | 0x03, PA_LED); + +diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S +index 5a9017ba26aba..3b0aa0ae43b4b 100644 +--- a/arch/sh/kernel/entry-common.S ++++ b/arch/sh/kernel/entry-common.S +@@ -203,7 +203,7 @@ syscall_trace_entry: + mov.l @(OFF_R7,r15), r7 ! arg3 + mov.l @(OFF_R3,r15), r3 ! syscall_nr + ! +- mov.l 2f, r10 ! Number of syscalls ++ mov.l 6f, r10 ! Number of syscalls + cmp/hs r10, r3 + bf syscall_call + mov #-ENOSYS, r0 +@@ -348,7 +348,7 @@ ENTRY(system_call) + tst r9, r8 + bf syscall_trace_entry + ! +- mov.l 2f, r8 ! Number of syscalls ++ mov.l 6f, r8 ! Number of syscalls + cmp/hs r8, r3 + bt syscall_badsys + ! +@@ -387,7 +387,7 @@ syscall_exit: + #if !defined(CONFIG_CPU_SH2) + 1: .long TRA + #endif +-2: .long NR_syscalls ++6: .long NR_syscalls + 3: .long sys_call_table + 7: .long do_syscall_trace_enter + 8: .long do_syscall_trace_leave +diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c +index 4e3b8a587c882..01a1ab8483ac5 100644 +--- a/arch/x86/kernel/i8259.c ++++ b/arch/x86/kernel/i8259.c +@@ -204,7 +204,7 @@ spurious_8259A_irq: + * lets ACK and report it. [once per IRQ] + */ + if (!(spurious_irq_mask & irqmask)) { +- printk(KERN_DEBUG ++ printk_deferred(KERN_DEBUG + "spurious 8259A interrupt: IRQ%d.\n", irq); + spurious_irq_mask |= irqmask; + } +diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c +index 4c2836dc825be..47d8a85c90ff5 100644 +--- a/drivers/acpi/acpica/exprep.c ++++ b/drivers/acpi/acpica/exprep.c +@@ -502,10 +502,6 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) + (u8)access_byte_width; + } + } +- /* An additional reference for the container */ +- +- acpi_ut_add_reference(obj_desc->field.region_obj); +- + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, + "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", + obj_desc->field.start_field_bit_offset, +diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c +index 1638312e3d8f9..9f8b088e21d7e 100644 +--- a/drivers/acpi/acpica/utdelete.c ++++ b/drivers/acpi/acpica/utdelete.c +@@ -590,11 +590,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) + next_object = object->buffer_field.buffer_obj; + break; + +- case ACPI_TYPE_LOCAL_REGION_FIELD: +- +- next_object = object->field.region_obj; +- break; +- + case ACPI_TYPE_LOCAL_BANK_FIELD: + + next_object = object->bank_field.bank_obj; +@@ -635,6 +630,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) + } + break; + ++ case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_REGION: + default: + +diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c +index 480fa6ffbc090..04fca6db273ef 100644 +--- a/drivers/atm/atmtcp.c ++++ b/drivers/atm/atmtcp.c +@@ -432,9 +432,15 @@ static int atmtcp_remove_persistent(int itf) + return -EMEDIUMTYPE; + } + dev_data = PRIV(dev); +- if (!dev_data->persist) return 0; ++ if (!dev_data->persist) { ++ atm_dev_put(dev); ++ return 0; ++ } + dev_data->persist = 0; +- if (PRIV(dev)->vcc) return 0; ++ if (PRIV(dev)->vcc) { ++ atm_dev_put(dev); ++ return 0; ++ } + kfree(dev_data); + atm_dev_put(dev); + atm_dev_deregister(dev); +diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c +index 76afc841232cf..3d11f5adb355e 100644 +--- a/drivers/char/agp/intel-gtt.c ++++ b/drivers/char/agp/intel-gtt.c +@@ -303,8 +303,10 @@ static int intel_gtt_setup_scratch_page(void) + if (intel_private.needs_dmar) { + dma_addr = pci_map_page(intel_private.pcidev, page, 0, + PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); +- if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) ++ if (pci_dma_mapping_error(intel_private.pcidev, dma_addr)) { ++ __free_page(page); + return -EINVAL; ++ } + + intel_private.scratch_page_dma = dma_addr; + } else +diff --git a/drivers/char/random.c b/drivers/char/random.c +index 661ed5ec546e5..7bb1e423eb190 100644 +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -923,6 +923,7 @@ void add_interrupt_randomness(int irq, int irq_flags) + + fast_mix(fast_pool); + add_interrupt_bench(cycles); ++ this_cpu_add(net_rand_state.s1, fast_pool->pool[cycles & 3]); + + if ((fast_pool->count < 64) && + !time_after(now, fast_pool->last + HZ)) +diff --git a/drivers/clk/sirf/clk-atlas6.c b/drivers/clk/sirf/clk-atlas6.c +index c5eaa9d162476..9af2d0dcd6a0f 100644 +--- a/drivers/clk/sirf/clk-atlas6.c ++++ b/drivers/clk/sirf/clk-atlas6.c +@@ -137,7 +137,7 @@ static void __init atlas6_clk_init(struct device_node *np) + + for (i = pll1; i < maxclk; i++) { + atlas6_clks[i] = clk_register(NULL, atlas6_clk_hw_array[i]); +- BUG_ON(!atlas6_clks[i]); ++ BUG_ON(IS_ERR(atlas6_clks[i])); + } + clk_register_clkdev(atlas6_clks[cpu], NULL, "cpu"); + clk_register_clkdev(atlas6_clks[io], NULL, "io"); +diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c +index c48f181e89415..923bb1988973b 100644 +--- a/drivers/crypto/qat/qat_common/qat_uclo.c ++++ b/drivers/crypto/qat/qat_common/qat_uclo.c +@@ -307,13 +307,18 @@ static int qat_uclo_create_batch_init_list(struct icp_qat_fw_loader_handle + } + return 0; + out_err: ++ /* Do not free the list head unless we allocated it. */ ++ tail_old = tail_old->next; ++ if (flag) { ++ kfree(*init_tab_base); ++ *init_tab_base = NULL; ++ } ++ + while (tail_old) { + mem_init = tail_old->next; + kfree(tail_old); + tail_old = mem_init; + } +- if (flag) +- kfree(*init_tab_base); + return -ENOMEM; + } + +diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c +index fb68a06ad6837..18991cfec2af4 100644 +--- a/drivers/edac/edac_device_sysfs.c ++++ b/drivers/edac/edac_device_sysfs.c +@@ -280,6 +280,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) + + /* Error exit stack */ + err_kobj_reg: ++ kobject_put(&edac_dev->kobj); + module_put(edac_dev->owner); + + err_mod_get: +diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c +index 24d877f6e5775..c56128402bc67 100644 +--- a/drivers/edac/edac_pci_sysfs.c ++++ b/drivers/edac/edac_pci_sysfs.c +@@ -394,7 +394,7 @@ static int edac_pci_main_kobj_setup(void) + + /* Error unwind statck */ + kobject_init_and_add_fail: +- kfree(edac_pci_top_main_kobj); ++ kobject_put(edac_pci_top_main_kobj); + + kzalloc_fail: + module_put(THIS_MODULE); +diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c +index 5fe34a9df3e6b..179ad7c35ae33 100644 +--- a/drivers/gpio/gpiolib-of.c ++++ b/drivers/gpio/gpiolib-of.c +@@ -91,7 +91,7 @@ struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, + &gg_data.gpiospec); + if (ret) { + pr_debug("%s: can't parse '%s' property of node '%s[%d]'\n", +- __func__, propname, np->full_name, index); ++ __func__, propname, np ? np->full_name : NULL, index); + return ERR_PTR(ret); + } + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +index e35e603710b4d..5bf98f0195fbd 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +@@ -428,9 +428,10 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file + return n ? -EFAULT : 0; + } + case AMDGPU_INFO_DEV_INFO: { +- struct drm_amdgpu_info_device dev_info = {}; ++ struct drm_amdgpu_info_device dev_info; + struct amdgpu_cu_info cu_info; + ++ memset(&dev_info, 0, sizeof(dev_info)); + dev_info.device_id = dev->pdev->device; + dev_info.chip_rev = adev->rev_id; + dev_info.external_rev = adev->external_rev_id; +diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c +index 3bcf8e6a85b35..5b0fdcd0b63fd 100644 +--- a/drivers/gpu/drm/drm_debugfs.c ++++ b/drivers/gpu/drm/drm_debugfs.c +@@ -290,13 +290,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf, + + buf[len] = '\0'; + +- if (!strcmp(buf, "on")) ++ if (sysfs_streq(buf, "on")) + connector->force = DRM_FORCE_ON; +- else if (!strcmp(buf, "digital")) ++ else if (sysfs_streq(buf, "digital")) + connector->force = DRM_FORCE_ON_DIGITAL; +- else if (!strcmp(buf, "off")) ++ else if (sysfs_streq(buf, "off")) + connector->force = DRM_FORCE_OFF; +- else if (!strcmp(buf, "unspecified")) ++ else if (sysfs_streq(buf, "unspecified")) + connector->force = DRM_FORCE_UNSPECIFIED; + else + return -EINVAL; +diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c +index 9147113139beb..67d5ead98a363 100644 +--- a/drivers/gpu/drm/drm_gem.c ++++ b/drivers/gpu/drm/drm_gem.c +@@ -652,9 +652,6 @@ err: + * @file_priv: drm file-private structure + * + * Open an object using the global name, returning a handle and the size. +- * +- * This handle (of course) holds a reference to the object, so the object +- * will not go away until the handle is deleted. + */ + int + drm_gem_open_ioctl(struct drm_device *dev, void *data, +@@ -679,14 +676,15 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data, + + /* drm_gem_handle_create_tail unlocks dev->object_name_lock. */ + ret = drm_gem_handle_create_tail(file_priv, obj, &handle); +- drm_gem_object_unreference_unlocked(obj); + if (ret) +- return ret; ++ goto err; + + args->handle = handle; + args->size = obj->size; + +- return 0; ++err: ++ drm_gem_object_unreference_unlocked(obj); ++ return ret; + } + + /** +diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c +index 91a61d2cca889..a90840e391100 100644 +--- a/drivers/gpu/drm/nouveau/nouveau_drm.c ++++ b/drivers/gpu/drm/nouveau/nouveau_drm.c +@@ -805,8 +805,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) + + /* need to bring up power immediately if opening device */ + ret = pm_runtime_get_sync(dev->dev); +- if (ret < 0 && ret != -EACCES) ++ if (ret < 0 && ret != -EACCES) { ++ pm_runtime_put_autosuspend(dev->dev); + return ret; ++ } + + get_task_comm(tmpname, current); + snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid)); +@@ -894,8 +896,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + long ret; + + ret = pm_runtime_get_sync(dev->dev); +- if (ret < 0 && ret != -EACCES) ++ if (ret < 0 && ret != -EACCES) { ++ pm_runtime_put_autosuspend(dev->dev); + return ret; ++ } + + switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) { + case DRM_NOUVEAU_NVIF: +diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c +index 343476d157266..edb3a23ded5d5 100644 +--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c ++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c +@@ -566,6 +566,7 @@ fini: + drm_fb_helper_fini(&fbcon->helper); + free: + kfree(fbcon); ++ drm->fbcon = NULL; + return ret; + } + +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c +index ae560f5977fca..e5db2a385cb65 100644 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c +@@ -42,8 +42,10 @@ nouveau_gem_object_del(struct drm_gem_object *gem) + int ret; + + ret = pm_runtime_get_sync(dev); +- if (WARN_ON(ret < 0 && ret != -EACCES)) ++ if (WARN_ON(ret < 0 && ret != -EACCES)) { ++ pm_runtime_put_autosuspend(dev); + return; ++ } + + if (gem->import_attach) + drm_prime_gem_destroy(gem, nvbo->bo.sg); +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c +index ecad4d7c6cd17..64b23bdebd1d1 100644 +--- a/drivers/gpu/drm/panel/panel-simple.c ++++ b/drivers/gpu/drm/panel/panel-simple.c +@@ -920,7 +920,7 @@ static const struct drm_display_mode lg_lb070wv8_mode = { + static const struct panel_desc lg_lb070wv8 = { + .modes = &lg_lb070wv8_mode, + .num_modes = 1, +- .bpc = 16, ++ .bpc = 8, + .size = { + .width = 151, + .height = 91, +diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c +index e7a245d7bdbcb..8e1bf9ed8efff 100644 +--- a/drivers/gpu/drm/radeon/ci_dpm.c ++++ b/drivers/gpu/drm/radeon/ci_dpm.c +@@ -4345,7 +4345,7 @@ static int ci_set_mc_special_registers(struct radeon_device *rdev, + table->mc_reg_table_entry[k].mc_data[j] |= 0x100; + } + j++; +- if (j > SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE) ++ if (j >= SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE) + return -EINVAL; + + if (!pi->mem_gddr5) { +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c +index 4572bfba017c5..17c73b8c90e71 100644 +--- a/drivers/gpu/drm/radeon/radeon_display.c ++++ b/drivers/gpu/drm/radeon/radeon_display.c +@@ -660,8 +660,10 @@ radeon_crtc_set_config(struct drm_mode_set *set) + dev = set->crtc->dev; + + ret = pm_runtime_get_sync(dev->dev); +- if (ret < 0) ++ if (ret < 0) { ++ pm_runtime_put_autosuspend(dev->dev); + return ret; ++ } + + ret = drm_crtc_helper_set_config(set); + +diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c +index 5b6a6f5b3619e..401403a3ea50c 100644 +--- a/drivers/gpu/drm/radeon/radeon_drv.c ++++ b/drivers/gpu/drm/radeon/radeon_drv.c +@@ -527,8 +527,10 @@ long radeon_drm_ioctl(struct file *filp, + long ret; + dev = file_priv->minor->dev; + ret = pm_runtime_get_sync(dev->dev); +- if (ret < 0) ++ if (ret < 0) { ++ pm_runtime_put_autosuspend(dev->dev); + return ret; ++ } + + ret = drm_ioctl(filp, cmd, arg); + +diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c +index d290a8a09036e..41caf7da90548 100644 +--- a/drivers/gpu/drm/radeon/radeon_kms.c ++++ b/drivers/gpu/drm/radeon/radeon_kms.c +@@ -631,8 +631,10 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) + file_priv->driver_priv = NULL; + + r = pm_runtime_get_sync(dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(dev->dev); + return r; ++ } + + /* new gpu have virtual address space support */ + if (rdev->family >= CHIP_CAYMAN) { +diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c +index 0af8bed7ce1ee..08d8f608be632 100644 +--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c ++++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c +@@ -177,12 +177,16 @@ static int panel_connector_get_modes(struct drm_connector *connector) + int i; + + for (i = 0; i < timings->num_timings; i++) { +- struct drm_display_mode *mode = drm_mode_create(dev); ++ struct drm_display_mode *mode; + struct videomode vm; + + if (videomode_from_timings(timings, &vm, i)) + break; + ++ mode = drm_mode_create(dev); ++ if (!mode) ++ break; ++ + drm_display_mode_from_videomode(&vm, mode); + + mode->type = DRM_MODE_TYPE_DRIVER; +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +index 9b97f70fbb3df..0b7427d474feb 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +@@ -2086,7 +2086,7 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv, + ++i; + } + +- if (i != unit) { ++ if (&con->head == &dev_priv->dev->mode_config.connector_list) { + DRM_ERROR("Could not find initial display unit.\n"); + return -EINVAL; + } +@@ -2108,13 +2108,13 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv, + break; + } + +- if (mode->type & DRM_MODE_TYPE_PREFERRED) +- *p_mode = mode; +- else { ++ if (&mode->head == &con->modes) { + WARN_ONCE(true, "Could not find initial preferred mode.\n"); + *p_mode = list_first_entry(&con->modes, + struct drm_display_mode, + head); ++ } else { ++ *p_mode = mode; + } + + return 0; +diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c +index 6d32e6da3110d..84deed6571bdf 100644 +--- a/drivers/i2c/busses/i2c-cadence.c ++++ b/drivers/i2c/busses/i2c-cadence.c +@@ -378,10 +378,8 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) + * Check for the message size against FIFO depth and set the + * 'hold bus' bit if it is greater than FIFO depth. + */ +- if ((id->recv_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag) ++ if (id->recv_count > CDNS_I2C_FIFO_DEPTH) + ctrl_reg |= CDNS_I2C_CR_HOLD; +- else +- ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD; + + cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); + +@@ -438,11 +436,8 @@ static void cdns_i2c_msend(struct cdns_i2c *id) + * Check for the message size against FIFO depth and set the + * 'hold bus' bit if it is greater than FIFO depth. + */ +- if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag) ++ if (id->send_count > CDNS_I2C_FIFO_DEPTH) + ctrl_reg |= CDNS_I2C_CR_HOLD; +- else +- ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD; +- + cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); + + /* Clear the interrupts in interrupt status register. */ +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index dfe1a53ce4ad3..ddfb08a3e6c20 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -386,13 +386,14 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) + rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR); + } + +- rcar_i2c_write(priv, ICSSR, ~SAR & 0xff); ++ /* Clear SSR, too, because of old STOPs to other clients than us */ ++ rcar_i2c_write(priv, ICSSR, ~(SAR | SSR) & 0xff); + } + + /* master sent stop */ + if (ssr_filtered & SSR) { + i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value); +- rcar_i2c_write(priv, ICSIER, SAR | SSR); ++ rcar_i2c_write(priv, ICSIER, SAR); + rcar_i2c_write(priv, ICSSR, ~SSR & 0xff); + } + +@@ -541,7 +542,7 @@ static int rcar_reg_slave(struct i2c_client *slave) + priv->slave = slave; + rcar_i2c_write(priv, ICSAR, slave->addr); + rcar_i2c_write(priv, ICSSR, 0); +- rcar_i2c_write(priv, ICSIER, SAR | SSR); ++ rcar_i2c_write(priv, ICSIER, SAR); + rcar_i2c_write(priv, ICSCR, SIE | SDBS); + + return 0; +diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c +index 11c32ac8234b2..779d0b9341c0d 100644 +--- a/drivers/input/mouse/sentelic.c ++++ b/drivers/input/mouse/sentelic.c +@@ -454,7 +454,7 @@ static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, + + fsp_reg_write_enable(psmouse, false); + +- return count; ++ return retval; + } + + PSMOUSE_DEFINE_WO_ATTR(setreg, S_IWUSR, NULL, fsp_attr_set_setreg); +diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c +index 9bc20e2119a35..82bf208295f4b 100644 +--- a/drivers/iommu/omap-iommu-debug.c ++++ b/drivers/iommu/omap-iommu-debug.c +@@ -101,8 +101,11 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf, + mutex_lock(&iommu_debug_lock); + + bytes = omap_iommu_dump_ctx(obj, p, count); ++ if (bytes < 0) ++ goto err; + bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes); + ++err: + mutex_unlock(&iommu_debug_lock); + kfree(buf); + +diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c +index 48872997d6b4b..533b255c27cd6 100644 +--- a/drivers/leds/leds-lm355x.c ++++ b/drivers/leds/leds-lm355x.c +@@ -177,18 +177,19 @@ static int lm355x_chip_init(struct lm355x_chip_data *chip) + /* input and output pins configuration */ + switch (chip->type) { + case CHIP_LM3554: +- reg_val = pdata->pin_tx2 | pdata->ntc_pin; ++ reg_val = (u32)pdata->pin_tx2 | (u32)pdata->ntc_pin; + ret = regmap_update_bits(chip->regmap, 0xE0, 0x28, reg_val); + if (ret < 0) + goto out; +- reg_val = pdata->pass_mode; ++ reg_val = (u32)pdata->pass_mode; + ret = regmap_update_bits(chip->regmap, 0xA0, 0x04, reg_val); + if (ret < 0) + goto out; + break; + + case CHIP_LM3556: +- reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode; ++ reg_val = (u32)pdata->pin_tx2 | (u32)pdata->ntc_pin | ++ (u32)pdata->pass_mode; + ret = regmap_update_bits(chip->regmap, 0x0A, 0xC4, reg_val); + if (ret < 0) + goto out; +diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c +index 158eae17031c4..1440436214291 100644 +--- a/drivers/md/bcache/bset.c ++++ b/drivers/md/bcache/bset.c +@@ -317,7 +317,7 @@ int bch_btree_keys_alloc(struct btree_keys *b, unsigned page_order, gfp_t gfp) + + b->page_order = page_order; + +- t->data = (void *) __get_free_pages(gfp, b->page_order); ++ t->data = (void *) __get_free_pages(__GFP_COMP|gfp, b->page_order); + if (!t->data) + goto err; + +diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c +index 634e9284b7bee..122d975220945 100644 +--- a/drivers/md/bcache/btree.c ++++ b/drivers/md/bcache/btree.c +@@ -795,7 +795,7 @@ int bch_btree_cache_alloc(struct cache_set *c) + mutex_init(&c->verify_lock); + + c->verify_ondisk = (void *) +- __get_free_pages(GFP_KERNEL, ilog2(bucket_pages(c))); ++ __get_free_pages(GFP_KERNEL|__GFP_COMP, ilog2(bucket_pages(c))); + + c->verify_data = mca_bucket_alloc(c, &ZERO_KEY, GFP_KERNEL); + +diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c +index 6f9db98f2dfd7..1d798938e9dfd 100644 +--- a/drivers/md/bcache/journal.c ++++ b/drivers/md/bcache/journal.c +@@ -838,8 +838,8 @@ int bch_journal_alloc(struct cache_set *c) + j->w[1].c = c; + + if (!(init_fifo(&j->pin, JOURNAL_PIN, GFP_KERNEL)) || +- !(j->w[0].data = (void *) __get_free_pages(GFP_KERNEL, JSET_BITS)) || +- !(j->w[1].data = (void *) __get_free_pages(GFP_KERNEL, JSET_BITS))) ++ !(j->w[0].data = (void *) __get_free_pages(GFP_KERNEL|__GFP_COMP, JSET_BITS)) || ++ !(j->w[1].data = (void *) __get_free_pages(GFP_KERNEL|__GFP_COMP, JSET_BITS))) + return -ENOMEM; + + return 0; +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c +index df8f1e69077f6..f7f8fb079d2a9 100644 +--- a/drivers/md/bcache/super.c ++++ b/drivers/md/bcache/super.c +@@ -1469,7 +1469,7 @@ void bch_cache_set_unregister(struct cache_set *c) + } + + #define alloc_bucket_pages(gfp, c) \ +- ((void *) __get_free_pages(__GFP_ZERO|gfp, ilog2(bucket_pages(c)))) ++ ((void *) __get_free_pages(__GFP_ZERO|__GFP_COMP|gfp, ilog2(bucket_pages(c)))) + + struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) + { +@@ -1778,7 +1778,14 @@ found: + sysfs_create_link(&c->kobj, &ca->kobj, buf)) + goto err; + +- if (ca->sb.seq > c->sb.seq) { ++ /* ++ * A special case is both ca->sb.seq and c->sb.seq are 0, ++ * such condition happens on a new created cache device whose ++ * super block is never flushed yet. In this case c->sb.version ++ * and other members should be updated too, otherwise we will ++ * have a mistaken super block version in cache set. ++ */ ++ if (ca->sb.seq > c->sb.seq || c->sb.seq == 0) { + c->sb.version = ca->sb.version; + memcpy(c->sb.set_uuid, ca->sb.set_uuid, 16); + c->sb.flags = ca->sb.flags; +diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c +index f061c81e15e1e..99cd843351c2b 100644 +--- a/drivers/md/raid5.c ++++ b/drivers/md/raid5.c +@@ -3345,6 +3345,7 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s, + * is missing/faulty, then we need to read everything we can. + */ + if (sh->raid_conf->level != 6 && ++ sh->raid_conf->rmw_level != PARITY_DISABLE_RMW && + sh->sector < sh->raid_conf->mddev->recovery_cp) + /* reconstruct-write isn't being forced */ + return 0; +@@ -4479,7 +4480,7 @@ static void handle_stripe(struct stripe_head *sh) + * or to load a block that is being partially written. + */ + if (s.to_read || s.non_overwrite +- || (conf->level == 6 && s.to_write && s.failed) ++ || (s.to_write && s.failed) + || (s.syncing && (s.uptodate + s.compute < disks)) + || s.replacing + || s.expanding) +diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c +index 247f0e7cb5f7f..5d634706a7eaa 100644 +--- a/drivers/media/firewire/firedtv-fw.c ++++ b/drivers/media/firewire/firedtv-fw.c +@@ -271,6 +271,8 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) + + name_len = fw_csr_string(unit->directory, CSR_MODEL, + name, sizeof(name)); ++ if (name_len < 0) ++ return name_len; + for (i = ARRAY_SIZE(model_names); --i; ) + if (strlen(model_names[i]) <= name_len && + strncmp(name, model_names[i], name_len) == 0) +diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c +index c1aa888af7054..83864a99d3a66 100644 +--- a/drivers/media/pci/cx23885/cx23888-ir.c ++++ b/drivers/media/pci/cx23885/cx23888-ir.c +@@ -1179,8 +1179,11 @@ int cx23888_ir_probe(struct cx23885_dev *dev) + return -ENOMEM; + + spin_lock_init(&state->rx_kfifo_lock); +- if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL)) ++ if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, ++ GFP_KERNEL)) { ++ kfree(state); + return -ENOMEM; ++ } + + state->dev = dev; + sd = &state->sd; +diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c +index 4f5586a4cbffa..31cc7d94064e3 100644 +--- a/drivers/media/platform/exynos4-is/media-dev.c ++++ b/drivers/media/platform/exynos4-is/media-dev.c +@@ -1172,6 +1172,9 @@ static int fimc_md_get_pinctrl(struct fimc_md *fmd) + + pctl->state_idle = pinctrl_lookup_state(pctl->pinctrl, + PINCTRL_STATE_IDLE); ++ if (IS_ERR(pctl->state_idle)) ++ return PTR_ERR(pctl->state_idle); ++ + return 0; + } + +diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c +index c9e8845de1b1d..c3336a2cbe145 100644 +--- a/drivers/media/platform/omap3isp/isppreview.c ++++ b/drivers/media/platform/omap3isp/isppreview.c +@@ -2285,7 +2285,7 @@ static int preview_init_entities(struct isp_prev_device *prev) + me->ops = &preview_media_ops; + ret = media_entity_init(me, PREV_PADS_NUM, pads, 0); + if (ret < 0) +- return ret; ++ goto error_handler_free; + + preview_init_formats(sd, NULL); + +@@ -2331,6 +2331,8 @@ error_video_out: + omap3isp_video_cleanup(&prev->video_in); + error_video_in: + media_entity_cleanup(&prev->subdev.entity); ++error_handler_free: ++ v4l2_ctrl_handler_free(&prev->ctrls); + return ret; + } + +diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c +index 672831d5ee32e..97a69cd6f1278 100644 +--- a/drivers/mfd/dln2.c ++++ b/drivers/mfd/dln2.c +@@ -294,7 +294,11 @@ static void dln2_rx(struct urb *urb) + len = urb->actual_length - sizeof(struct dln2_header); + + if (handle == DLN2_HANDLE_EVENT) { ++ unsigned long flags; ++ ++ spin_lock_irqsave(&dln2->event_cb_lock, flags); + dln2_run_event_callbacks(dln2, id, echo, data, len); ++ spin_unlock_irqrestore(&dln2->event_cb_lock, flags); + } else { + /* URB will be re-submitted in _dln2_transfer (free_rx_slot) */ + if (dln2_transfer_complete(dln2, urb, handle, echo)) +diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c +index 02006f7109a80..ce292d7766db2 100644 +--- a/drivers/misc/cxl/sysfs.c ++++ b/drivers/misc/cxl/sysfs.c +@@ -539,7 +539,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c + rc = kobject_init_and_add(&cr->kobj, &afu_config_record_type, + &afu->dev.kobj, "cr%i", cr->cr); + if (rc) +- goto err; ++ goto err1; + + rc = sysfs_create_bin_file(&cr->kobj, &cr->config_attr); + if (rc) +@@ -555,9 +555,6 @@ err2: + err1: + kobject_put(&cr->kobj); + return ERR_PTR(rc); +-err: +- kfree(cr); +- return ERR_PTR(rc); + } + + void cxl_sysfs_afu_remove(struct cxl_afu *afu) +diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c +index 0d244dac1ccb3..ce87d9506f6a4 100644 +--- a/drivers/mtd/mtdchar.c ++++ b/drivers/mtd/mtdchar.c +@@ -372,9 +372,6 @@ static int mtdchar_writeoob(struct file *file, struct mtd_info *mtd, + uint32_t retlen; + int ret = 0; + +- if (!(file->f_mode & FMODE_WRITE)) +- return -EPERM; +- + if (length > 4096) + return -EINVAL; + +@@ -608,6 +605,48 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) + return -EFAULT; + } + ++ /* ++ * Check the file mode to require "dangerous" commands to have write ++ * permissions. ++ */ ++ switch (cmd) { ++ /* "safe" commands */ ++ case MEMGETREGIONCOUNT: ++ case MEMGETREGIONINFO: ++ case MEMGETINFO: ++ case MEMREADOOB: ++ case MEMREADOOB64: ++ case MEMLOCK: ++ case MEMUNLOCK: ++ case MEMISLOCKED: ++ case MEMGETOOBSEL: ++ case MEMGETBADBLOCK: ++ case MEMSETBADBLOCK: ++ case OTPSELECT: ++ case OTPGETREGIONCOUNT: ++ case OTPGETREGIONINFO: ++ case OTPLOCK: ++ case ECCGETLAYOUT: ++ case ECCGETSTATS: ++ case MTDFILEMODE: ++ case BLKPG: ++ case BLKRRPART: ++ break; ++ ++ /* "dangerous" commands */ ++ case MEMERASE: ++ case MEMERASE64: ++ case MEMWRITEOOB: ++ case MEMWRITEOOB64: ++ case MEMWRITE: ++ if (!(file->f_mode & FMODE_WRITE)) ++ return -EPERM; ++ break; ++ ++ default: ++ return -ENOTTY; ++ } ++ + switch (cmd) { + case MEMGETREGIONCOUNT: + if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) +@@ -655,9 +694,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) + { + struct erase_info *erase; + +- if(!(file->f_mode & FMODE_WRITE)) +- return -EPERM; +- + erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); + if (!erase) + ret = -ENOMEM; +@@ -982,9 +1018,6 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) + ret = 0; + break; + } +- +- default: +- ret = -ENOTTY; + } + + return ret; +@@ -1028,6 +1061,11 @@ static long mtdchar_compat_ioctl(struct file *file, unsigned int cmd, + struct mtd_oob_buf32 buf; + struct mtd_oob_buf32 __user *buf_user = argp; + ++ if (!(file->f_mode & FMODE_WRITE)) { ++ ret = -EPERM; ++ break; ++ } ++ + if (copy_from_user(&buf, argp, sizeof(buf))) + ret = -EFAULT; + else +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c +index 426abfce1c3ff..a4aa4d10ca700 100644 +--- a/drivers/net/ethernet/intel/igb/igb_main.c ++++ b/drivers/net/ethernet/intel/igb/igb_main.c +@@ -5137,9 +5137,18 @@ static void igb_reset_task(struct work_struct *work) + struct igb_adapter *adapter; + adapter = container_of(work, struct igb_adapter, reset_task); + ++ rtnl_lock(); ++ /* If we're already down or resetting, just bail */ ++ if (test_bit(__IGB_DOWN, &adapter->state) || ++ test_bit(__IGB_RESETTING, &adapter->state)) { ++ rtnl_unlock(); ++ return; ++ } ++ + igb_dump(adapter); + netdev_err(adapter->netdev, "Reset adapter\n"); + igb_reinit_locked(adapter); ++ rtnl_unlock(); + } + + /** +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c +index 97f0d93caf994..085aaad902937 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core.c +@@ -1208,9 +1208,10 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb, + break; + } + } +- rcu_read_unlock(); +- if (!found) ++ if (!found) { ++ rcu_read_unlock(); + goto drop; ++ } + + pcpu_stats = this_cpu_ptr(mlxsw_core->pcpu_stats); + u64_stats_update_begin(&pcpu_stats->syncp); +@@ -1221,6 +1222,7 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb, + u64_stats_update_end(&pcpu_stats->syncp); + + rxl->func(skb, local_port, rxl_item->priv); ++ rcu_read_unlock(); + return; + + drop: +diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c +index 5b6320f9c935f..460b29ac5fd86 100644 +--- a/drivers/net/ethernet/renesas/ravb_main.c ++++ b/drivers/net/ethernet/renesas/ravb_main.c +@@ -1291,6 +1291,7 @@ static void ravb_tx_timeout_work(struct work_struct *work) + struct ravb_private *priv = container_of(work, struct ravb_private, + work); + struct net_device *ndev = priv->ndev; ++ int error; + + netif_tx_stop_all_queues(ndev); + +@@ -1298,15 +1299,36 @@ static void ravb_tx_timeout_work(struct work_struct *work) + ravb_ptp_stop(ndev); + + /* Wait for DMA stopping */ +- ravb_stop_dma(ndev); ++ if (ravb_stop_dma(ndev)) { ++ /* If ravb_stop_dma() fails, the hardware is still operating ++ * for TX and/or RX. So, this should not call the following ++ * functions because ravb_dmac_init() is possible to fail too. ++ * Also, this should not retry ravb_stop_dma() again and again ++ * here because it's possible to wait forever. So, this just ++ * re-enables the TX and RX and skip the following ++ * re-initialization procedure. ++ */ ++ ravb_rcv_snd_enable(ndev); ++ goto out; ++ } + + ravb_ring_free(ndev, RAVB_BE); + ravb_ring_free(ndev, RAVB_NC); + + /* Device init */ +- ravb_dmac_init(ndev); ++ error = ravb_dmac_init(ndev); ++ if (error) { ++ /* If ravb_dmac_init() fails, descriptors are freed. So, this ++ * should return here to avoid re-enabling the TX and RX in ++ * ravb_emac_init(). ++ */ ++ netdev_err(ndev, "%s: ravb_dmac_init() failed, error %d\n", ++ __func__, error); ++ return; ++ } + ravb_emac_init(ndev); + ++out: + /* Initialise PTP Clock driver */ + ravb_ptp_init(ndev, priv->pdev); + +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +index 15aabffd21a8b..ee5a7c05a0e67 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +@@ -360,6 +360,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) + plat_dat->has_gmac = true; + plat_dat->bsp_priv = gmac; + plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed; ++ plat_dat->multicast_filter_bins = 0; + + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); + } +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +index b535f6c378386..ac08031c481fa 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +@@ -146,6 +146,9 @@ static void dwmac1000_set_filter(struct mac_device_info *hw, + value = GMAC_FRAME_FILTER_PR; + } else if (dev->flags & IFF_ALLMULTI) { + value = GMAC_FRAME_FILTER_PM; /* pass all multi */ ++ } else if (!netdev_mc_empty(dev) && (mcbitslog2 == 0)) { ++ /* Fall back to all multicast if we've no filter */ ++ value = GMAC_FRAME_FILTER_PM; + } else if (!netdev_mc_empty(dev)) { + struct netdev_hw_addr *ha; + +diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c +index 8e53211aedd82..53600e28d93b7 100644 +--- a/drivers/net/ethernet/toshiba/spider_net.c ++++ b/drivers/net/ethernet/toshiba/spider_net.c +@@ -297,8 +297,8 @@ spider_net_free_chain(struct spider_net_card *card, + descr = descr->next; + } while (descr != chain->ring); + +- dma_free_coherent(&card->pdev->dev, chain->num_desc, +- chain->hwring, chain->dma_addr); ++ dma_free_coherent(&card->pdev->dev, chain->num_desc * sizeof(struct spider_net_hw_descr), ++ chain->hwring, chain->dma_addr); + } + + /** +diff --git a/drivers/net/phy/mdio-bcm-unimac.c b/drivers/net/phy/mdio-bcm-unimac.c +index 4bde5e728fe0a..fd8692b477c96 100644 +--- a/drivers/net/phy/mdio-bcm-unimac.c ++++ b/drivers/net/phy/mdio-bcm-unimac.c +@@ -177,6 +177,8 @@ static int unimac_mdio_probe(struct platform_device *pdev) + return -ENOMEM; + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (!r) ++ return -EINVAL; + + /* Just ioremap, as this MDIO block is usually integrated into an + * Ethernet MAC controller register range +diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c +index cbbff16d438f5..efd4bf06f6ada 100644 +--- a/drivers/net/usb/hso.c ++++ b/drivers/net/usb/hso.c +@@ -2280,12 +2280,14 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, + + minor = get_free_serial_index(); + if (minor < 0) +- goto exit; ++ goto exit2; + + /* register our minor number */ + serial->parent->dev = tty_port_register_device_attr(&serial->port, + tty_drv, minor, &serial->parent->interface->dev, + serial->parent, hso_serial_dev_groups); ++ if (IS_ERR(serial->parent->dev)) ++ goto exit2; + dev = serial->parent->dev; + + /* fill in specific data for later use */ +@@ -2335,6 +2337,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, + return 0; + exit: + hso_serial_tty_unregister(serial); ++exit2: + hso_serial_common_free(serial); + return -1; + } +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c +index 75a3865a80d23..1439863e9061d 100644 +--- a/drivers/net/usb/lan78xx.c ++++ b/drivers/net/usb/lan78xx.c +@@ -251,10 +251,6 @@ struct lan78xx_net { + struct tasklet_struct bh; + struct delayed_work wq; + +- struct usb_host_endpoint *ep_blkin; +- struct usb_host_endpoint *ep_blkout; +- struct usb_host_endpoint *ep_intr; +- + int msg_enable; + + struct urb *urb_intr; +@@ -2180,77 +2176,12 @@ netdev_tx_t lan78xx_start_xmit(struct sk_buff *skb, struct net_device *net) + return NETDEV_TX_OK; + } + +-int lan78xx_get_endpoints(struct lan78xx_net *dev, struct usb_interface *intf) +-{ +- int tmp; +- struct usb_host_interface *alt = NULL; +- struct usb_host_endpoint *in = NULL, *out = NULL; +- struct usb_host_endpoint *status = NULL; +- +- for (tmp = 0; tmp < intf->num_altsetting; tmp++) { +- unsigned ep; +- +- in = NULL; +- out = NULL; +- status = NULL; +- alt = intf->altsetting + tmp; +- +- for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { +- struct usb_host_endpoint *e; +- int intr = 0; +- +- e = alt->endpoint + ep; +- switch (e->desc.bmAttributes) { +- case USB_ENDPOINT_XFER_INT: +- if (!usb_endpoint_dir_in(&e->desc)) +- continue; +- intr = 1; +- /* FALLTHROUGH */ +- case USB_ENDPOINT_XFER_BULK: +- break; +- default: +- continue; +- } +- if (usb_endpoint_dir_in(&e->desc)) { +- if (!intr && !in) +- in = e; +- else if (intr && !status) +- status = e; +- } else { +- if (!out) +- out = e; +- } +- } +- if (in && out) +- break; +- } +- if (!alt || !in || !out) +- return -EINVAL; +- +- dev->pipe_in = usb_rcvbulkpipe(dev->udev, +- in->desc.bEndpointAddress & +- USB_ENDPOINT_NUMBER_MASK); +- dev->pipe_out = usb_sndbulkpipe(dev->udev, +- out->desc.bEndpointAddress & +- USB_ENDPOINT_NUMBER_MASK); +- dev->ep_intr = status; +- +- return 0; +-} +- + static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf) + { + struct lan78xx_priv *pdata = NULL; + int ret; + int i; + +- ret = lan78xx_get_endpoints(dev, intf); +- if (ret) { +- netdev_warn(dev->net, "lan78xx_get_endpoints failed: %d\n", +- ret); +- return ret; +- } +- + dev->data[0] = (unsigned long)kzalloc(sizeof(*pdata), GFP_KERNEL); + + pdata = (struct lan78xx_priv *)(dev->data[0]); +@@ -2926,6 +2857,7 @@ static const struct net_device_ops lan78xx_netdev_ops = { + static int lan78xx_probe(struct usb_interface *intf, + const struct usb_device_id *id) + { ++ struct usb_host_endpoint *ep_blkin, *ep_blkout, *ep_intr; + struct lan78xx_net *dev; + struct net_device *netdev; + struct usb_device *udev; +@@ -2969,6 +2901,34 @@ static int lan78xx_probe(struct usb_interface *intf, + netdev->watchdog_timeo = TX_TIMEOUT_JIFFIES; + netdev->ethtool_ops = &lan78xx_ethtool_ops; + ++ if (intf->cur_altsetting->desc.bNumEndpoints < 3) { ++ ret = -ENODEV; ++ goto out2; ++ } ++ ++ dev->pipe_in = usb_rcvbulkpipe(udev, BULK_IN_PIPE); ++ ep_blkin = usb_pipe_endpoint(udev, dev->pipe_in); ++ if (!ep_blkin || !usb_endpoint_is_bulk_in(&ep_blkin->desc)) { ++ ret = -ENODEV; ++ goto out2; ++ } ++ ++ dev->pipe_out = usb_sndbulkpipe(udev, BULK_OUT_PIPE); ++ ep_blkout = usb_pipe_endpoint(udev, dev->pipe_out); ++ if (!ep_blkout || !usb_endpoint_is_bulk_out(&ep_blkout->desc)) { ++ ret = -ENODEV; ++ goto out2; ++ } ++ ++ ep_intr = &intf->cur_altsetting->endpoint[2]; ++ if (!usb_endpoint_is_int_in(&ep_intr->desc)) { ++ ret = -ENODEV; ++ goto out2; ++ } ++ ++ dev->pipe_intr = usb_rcvintpipe(dev->udev, ++ usb_endpoint_num(&ep_intr->desc)); ++ + ret = lan78xx_bind(dev, intf); + if (ret < 0) + goto out2; +@@ -2978,18 +2938,7 @@ static int lan78xx_probe(struct usb_interface *intf, + netdev->mtu = dev->hard_mtu - netdev->hard_header_len; + netif_set_gso_max_size(netdev, MAX_SINGLE_PACKET_SIZE - MAX_HEADER); + +- dev->ep_blkin = (intf->cur_altsetting)->endpoint + 0; +- dev->ep_blkout = (intf->cur_altsetting)->endpoint + 1; +- dev->ep_intr = (intf->cur_altsetting)->endpoint + 2; +- +- dev->pipe_in = usb_rcvbulkpipe(udev, BULK_IN_PIPE); +- dev->pipe_out = usb_sndbulkpipe(udev, BULK_OUT_PIPE); +- +- dev->pipe_intr = usb_rcvintpipe(dev->udev, +- dev->ep_intr->desc.bEndpointAddress & +- USB_ENDPOINT_NUMBER_MASK); +- period = dev->ep_intr->desc.bInterval; +- ++ period = ep_intr->desc.bInterval; + maxp = usb_maxpacket(dev->udev, dev->pipe_intr, 0); + buf = kmalloc(maxp, GFP_KERNEL); + if (buf) { +@@ -3001,6 +2950,7 @@ static int lan78xx_probe(struct usb_interface *intf, + usb_fill_int_urb(dev->urb_intr, dev->udev, + dev->pipe_intr, buf, maxp, + intr_complete, dev, period); ++ dev->urb_intr->transfer_flags |= URB_FREE_BUFFER; + } + } + +diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c +index c12f2984d7eff..50ede6b8b874d 100644 +--- a/drivers/net/vxlan.c ++++ b/drivers/net/vxlan.c +@@ -921,6 +921,7 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, + struct vxlan_fdb *f; + int err; + ++ rcu_read_lock(); + hlist_for_each_entry_rcu(f, &vxlan->fdb_head[h], hlist) { + struct vxlan_rdst *rd; + +@@ -933,12 +934,15 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, + cb->nlh->nlmsg_seq, + RTM_NEWNEIGH, + NLM_F_MULTI, rd); +- if (err < 0) ++ if (err < 0) { ++ rcu_read_unlock(); + goto out; ++ } + skip: + ++idx; + } + } ++ rcu_read_unlock(); + } + out: + return idx; +@@ -2070,7 +2074,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, + return; + } + +- tos = ip_tunnel_ecn_encap(RT_TOS(tos), old_iph, skb); ++ tos = ip_tunnel_ecn_encap(tos, old_iph, skb); + ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); + err = vxlan_xmit_skb(rt, sk, skb, fl4.saddr, + dst->sin.sin_addr.s_addr, tos, ttl, df, +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c +index f5657783fad4e..6eb0f7a85e531 100644 +--- a/drivers/net/wan/lapbether.c ++++ b/drivers/net/wan/lapbether.c +@@ -160,6 +160,12 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb, + if (!netif_running(dev)) + goto drop; + ++ /* There should be a pseudo header of 1 byte added by upper layers. ++ * Check to make sure it is there before reading it. ++ */ ++ if (skb->len < 1) ++ goto drop; ++ + switch (skb->data[0]) { + case X25_IFACE_DATA: + break; +@@ -308,6 +314,7 @@ static void lapbeth_setup(struct net_device *dev) + dev->netdev_ops = &lapbeth_netdev_ops; + dev->destructor = free_netdev; + dev->type = ARPHRD_X25; ++ dev->hard_header_len = 0; + dev->mtu = 1000; + dev->addr_len = 0; + } +@@ -334,7 +341,8 @@ static int lapbeth_new_device(struct net_device *dev) + * then this driver prepends a length field of 2 bytes, + * then the underlying Ethernet device prepends its own header. + */ +- ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len; ++ ndev->needed_headroom = -1 + 3 + 2 + dev->hard_header_len ++ + dev->needed_headroom; + + lapbeth = netdev_priv(ndev); + lapbeth->axdev = ndev; +diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c +index 257b6ee51e54b..1af216aa5adae 100644 +--- a/drivers/net/wireless/ath/ath9k/htc_hst.c ++++ b/drivers/net/wireless/ath/ath9k/htc_hst.c +@@ -175,6 +175,7 @@ static int htc_config_pipe_credits(struct htc_target *target) + time_left = wait_for_completion_timeout(&target->cmd_wait, HZ); + if (!time_left) { + dev_err(target->dev, "HTC credit config timeout\n"); ++ kfree_skb(skb); + return -ETIMEDOUT; + } + +@@ -211,6 +212,7 @@ static int htc_setup_complete(struct htc_target *target) + time_left = wait_for_completion_timeout(&target->cmd_wait, HZ); + if (!time_left) { + dev_err(target->dev, "HTC start timeout\n"); ++ kfree_skb(skb); + return -ETIMEDOUT; + } + +@@ -284,6 +286,7 @@ int htc_connect_service(struct htc_target *target, + if (!time_left) { + dev_err(target->dev, "Service connection timeout for: %d\n", + service_connreq->service_id); ++ kfree_skb(skb); + return -ETIMEDOUT; + } + +diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c +index 8f14897ae5a33..f100533eb7adc 100644 +--- a/drivers/net/wireless/ath/ath9k/wmi.c ++++ b/drivers/net/wireless/ath/ath9k/wmi.c +@@ -340,6 +340,7 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id, + ath_dbg(common, WMI, "Timeout waiting for WMI command: %s\n", + wmi_cmd_to_name(cmd_id)); + mutex_unlock(&wmi->op_mutex); ++ kfree_skb(skb); + return -ETIMEDOUT; + } + +diff --git a/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h +index 4320c4cae53e1..7eb9f31dde1a2 100644 +--- a/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h ++++ b/drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h +@@ -30,7 +30,7 @@ + #define BRCMF_ARP_OL_PEER_AUTO_REPLY 0x00000008 + + #define BRCMF_BSS_INFO_VERSION 109 /* curr ver of brcmf_bss_info_le struct */ +-#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0002 ++#define BRCMF_BSS_RSSI_ON_CHANNEL 0x0004 + + #define BRCMF_STA_WME 0x00000002 /* WMM association */ + #define BRCMF_STA_AUTHE 0x00000008 /* Authenticated */ +diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c +index 544ab3750ea6e..c56febdae1349 100644 +--- a/drivers/net/wireless/iwlegacy/common.c ++++ b/drivers/net/wireless/iwlegacy/common.c +@@ -4294,8 +4294,8 @@ il_apm_init(struct il_priv *il) + * power savings, even without L1. + */ + if (il->cfg->set_l0s) { +- pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); +- if (lctl & PCI_EXP_LNKCTL_ASPM_L1) { ++ ret = pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl); ++ if (!ret && (lctl & PCI_EXP_LNKCTL_ASPM_L1)) { + /* L1-ASPM enabled; disable(!) L0S */ + il_set_bit(il, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); +diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c +index 9ac7aa2431b41..9e3853c8a22da 100644 +--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c ++++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c +@@ -592,6 +592,11 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv, + { + struct host_cmd_ds_802_11_key_material *key = + &resp->params.key_material; ++ int len; ++ ++ len = le16_to_cpu(key->key_param_set.key_len); ++ if (len > sizeof(key->key_param_set.key)) ++ return -EINVAL; + + if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) { + if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) { +@@ -605,9 +610,8 @@ static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv, + + memset(priv->aes_key.key_param_set.key, 0, + sizeof(key->key_param_set.key)); +- priv->aes_key.key_param_set.key_len = key->key_param_set.key_len; +- memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, +- le16_to_cpu(priv->aes_key.key_param_set.key_len)); ++ priv->aes_key.key_param_set.key_len = cpu_to_le16(len); ++ memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, len); + + return 0; + } +@@ -622,9 +626,14 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv, + struct host_cmd_ds_command *resp) + { + struct host_cmd_ds_802_11_key_material_v2 *key_v2; +- __le16 len; ++ int len; + + key_v2 = &resp->params.key_material_v2; ++ ++ len = le16_to_cpu(key_v2->key_param_set.key_params.aes.key_len); ++ if (len > WLAN_KEY_LEN_CCMP) ++ return -EINVAL; ++ + if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) { + if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) { + mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n"); +@@ -640,10 +649,9 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv, + memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0, + WLAN_KEY_LEN_CCMP); + priv->aes_key_v2.key_param_set.key_params.aes.key_len = +- key_v2->key_param_set.key_params.aes.key_len; +- len = priv->aes_key_v2.key_param_set.key_params.aes.key_len; ++ cpu_to_le16(len); + memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key, +- key_v2->key_param_set.key_params.aes.key, le16_to_cpu(len)); ++ key_v2->key_param_set.key_params.aes.key, len); + + return 0; + } +diff --git a/drivers/net/wireless/ti/wl1251/event.c b/drivers/net/wireless/ti/wl1251/event.c +index c98630394a1a2..26bf3e2b750d6 100644 +--- a/drivers/net/wireless/ti/wl1251/event.c ++++ b/drivers/net/wireless/ti/wl1251/event.c +@@ -80,7 +80,7 @@ static int wl1251_event_ps_report(struct wl1251 *wl, + break; + } + +- return 0; ++ return ret; + } + + static void wl1251_event_mbox_dump(struct event_mailbox *mbox) +diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c +index 02b6a6c108400..7d4c0c46a889d 100644 +--- a/drivers/net/xen-netfront.c ++++ b/drivers/net/xen-netfront.c +@@ -62,6 +62,8 @@ module_param_named(max_queues, xennet_max_queues, uint, 0644); + MODULE_PARM_DESC(max_queues, + "Maximum number of queues per virtual interface"); + ++#define XENNET_TIMEOUT (5 * HZ) ++ + static const struct ethtool_ops xennet_ethtool_ops; + + struct netfront_cb { +@@ -1349,12 +1351,15 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) + + netif_carrier_off(netdev); + +- xenbus_switch_state(dev, XenbusStateInitialising); +- wait_event(module_wq, +- xenbus_read_driver_state(dev->otherend) != +- XenbusStateClosed && +- xenbus_read_driver_state(dev->otherend) != +- XenbusStateUnknown); ++ do { ++ xenbus_switch_state(dev, XenbusStateInitialising); ++ err = wait_event_timeout(module_wq, ++ xenbus_read_driver_state(dev->otherend) != ++ XenbusStateClosed && ++ xenbus_read_driver_state(dev->otherend) != ++ XenbusStateUnknown, XENNET_TIMEOUT); ++ } while (!err); ++ + return netdev; + + exit: +@@ -2166,28 +2171,43 @@ static const struct attribute_group xennet_dev_group = { + }; + #endif /* CONFIG_SYSFS */ + +-static int xennet_remove(struct xenbus_device *dev) ++static void xennet_bus_close(struct xenbus_device *dev) + { +- struct netfront_info *info = dev_get_drvdata(&dev->dev); +- +- dev_dbg(&dev->dev, "%s\n", dev->nodename); ++ int ret; + +- if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) { ++ if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed) ++ return; ++ do { + xenbus_switch_state(dev, XenbusStateClosing); +- wait_event(module_wq, +- xenbus_read_driver_state(dev->otherend) == +- XenbusStateClosing || +- xenbus_read_driver_state(dev->otherend) == +- XenbusStateUnknown); ++ ret = wait_event_timeout(module_wq, ++ xenbus_read_driver_state(dev->otherend) == ++ XenbusStateClosing || ++ xenbus_read_driver_state(dev->otherend) == ++ XenbusStateClosed || ++ xenbus_read_driver_state(dev->otherend) == ++ XenbusStateUnknown, ++ XENNET_TIMEOUT); ++ } while (!ret); ++ ++ if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed) ++ return; + ++ do { + xenbus_switch_state(dev, XenbusStateClosed); +- wait_event(module_wq, +- xenbus_read_driver_state(dev->otherend) == +- XenbusStateClosed || +- xenbus_read_driver_state(dev->otherend) == +- XenbusStateUnknown); +- } ++ ret = wait_event_timeout(module_wq, ++ xenbus_read_driver_state(dev->otherend) == ++ XenbusStateClosed || ++ xenbus_read_driver_state(dev->otherend) == ++ XenbusStateUnknown, ++ XENNET_TIMEOUT); ++ } while (!ret); ++} ++ ++static int xennet_remove(struct xenbus_device *dev) ++{ ++ struct netfront_info *info = dev_get_drvdata(&dev->dev); + ++ xennet_bus_close(dev); + xennet_disconnect_backend(info); + + if (info->netdev->reg_state == NETREG_REGISTERED) +diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c +index 0d866ca295e3f..cafab107ba9bc 100644 +--- a/drivers/nfc/s3fwrn5/core.c ++++ b/drivers/nfc/s3fwrn5/core.c +@@ -209,6 +209,7 @@ int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb, + case S3FWRN5_MODE_FW: + return s3fwrn5_fw_recv_frame(ndev, skb); + default: ++ kfree_skb(skb); + return -ENODEV; + } + } +diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c +index f3b9746157f81..b854de39c7ffa 100644 +--- a/drivers/parisc/sba_iommu.c ++++ b/drivers/parisc/sba_iommu.c +@@ -1277,7 +1277,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) + ** (one that doesn't overlap memory or LMMIO space) in the + ** IBASE and IMASK registers. + */ +- ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE); ++ ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE) & ~0x1fffffULL; + iova_space_size = ~(READ_REG(ioc->ioc_hpa + IOC_IMASK) & 0xFFFFFFFFUL) + 1; + + if ((ioc->ibase < 0xfed00000UL) && ((ioc->ibase + iova_space_size) > 0xfee00000UL)) { +diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c +index 572ca192cb1fd..6727471ea5b40 100644 +--- a/drivers/pci/hotplug/acpiphp_glue.c ++++ b/drivers/pci/hotplug/acpiphp_glue.c +@@ -136,13 +136,21 @@ static struct acpiphp_context *acpiphp_grab_context(struct acpi_device *adev) + struct acpiphp_context *context; + + acpi_lock_hp_context(); ++ + context = acpiphp_get_context(adev); +- if (!context || context->func.parent->is_going_away) { +- acpi_unlock_hp_context(); +- return NULL; ++ if (!context) ++ goto unlock; ++ ++ if (context->func.parent->is_going_away) { ++ acpiphp_put_context(context); ++ context = NULL; ++ goto unlock; + } ++ + get_bridge(context->func.parent); + acpiphp_put_context(context); ++ ++unlock: + acpi_unlock_hp_context(); + return context; + } +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c +index 966b6947e5656..a098f8324afd0 100644 +--- a/drivers/pci/pcie/aspm.c ++++ b/drivers/pci/pcie/aspm.c +@@ -807,6 +807,7 @@ static int pcie_aspm_get_policy(char *buffer, struct kernel_param *kp) + cnt += sprintf(buffer + cnt, "[%s] ", policy_str[i]); + else + cnt += sprintf(buffer + cnt, "%s ", policy_str[i]); ++ cnt += sprintf(buffer + cnt, "\n"); + return cnt; + } + +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index ab161bbeb4d41..bdaeccafa261b 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -2273,6 +2273,19 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_ + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0xa238, quirk_disable_msi); + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x5a3f, quirk_disable_msi); + ++static void quirk_disable_aspm_l0s_l1(struct pci_dev *dev) ++{ ++ dev_info(&dev->dev, "Disabling ASPM L0s/L1\n"); ++ pci_disable_link_state(dev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); ++} ++ ++/* ++ * ASM1083/1085 PCIe-PCI bridge devices cause AER timeout errors on the ++ * upstream PCIe root port when ASPM is enabled. At least L0s mode is affected; ++ * disable both L0s and L1 for now to be safe. ++ */ ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASMEDIA, 0x1080, quirk_disable_aspm_l0s_l1); ++ + /* + * The APC bridge device in AMD 780 family northbridges has some random + * OEM subsystem ID in its vendor ID register (erratum 18), so instead +diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c +index 73d8d47ea465a..17714793c08e4 100644 +--- a/drivers/pinctrl/pinctrl-single.c ++++ b/drivers/pinctrl/pinctrl-single.c +@@ -1071,7 +1071,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np, + + /* If pinconf isn't supported, don't parse properties in below. */ + if (!PCS_HAS_PINCONF) +- return 0; ++ return -ENOTSUPP; + + /* cacluate how much properties are supported in current node */ + for (i = 0; i < ARRAY_SIZE(prop2); i++) { +@@ -1083,7 +1083,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np, + nconfs++; + } + if (!nconfs) +- return 0; ++ return -ENOTSUPP; + + func->conf = devm_kzalloc(pcs->dev, + sizeof(struct pcs_conf_vals) * nconfs, +@@ -1196,9 +1196,12 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, + + if (PCS_HAS_PINCONF) { + res = pcs_parse_pinconf(pcs, np, function, map); +- if (res) ++ if (res == 0) ++ *num_maps = 2; ++ else if (res == -ENOTSUPP) ++ *num_maps = 1; ++ else + goto free_pingroups; +- *num_maps = 2; + } else { + *num_maps = 1; + } +diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/88pm860x_battery.c +index 63c57dc82ac1d..4eda5065b5bbc 100644 +--- a/drivers/power/88pm860x_battery.c ++++ b/drivers/power/88pm860x_battery.c +@@ -436,7 +436,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) + int ret; + int data; + int bat_remove; +- int soc; ++ int soc = 0; + + /* measure enable on GPADC1 */ + data = MEAS1_GP1; +@@ -499,7 +499,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) + } + mutex_unlock(&info->lock); + +- calc_soc(info, OCV_MODE_ACTIVE, &soc); ++ ret = calc_soc(info, OCV_MODE_ACTIVE, &soc); ++ if (ret < 0) ++ goto out; + + data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG); + bat_remove = data & BAT_WU_LOG; +diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c +index 97211f7f0cf02..ed4b0f6e2d6ad 100644 +--- a/drivers/s390/net/qeth_l2_main.c ++++ b/drivers/s390/net/qeth_l2_main.c +@@ -1669,6 +1669,10 @@ static void qeth_bridge_state_change(struct qeth_card *card, + int extrasize; + + QETH_CARD_TEXT(card, 2, "brstchng"); ++ if (qports->num_entries == 0) { ++ QETH_CARD_TEXT(card, 2, "BPempty"); ++ return; ++ } + if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) { + QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length); + return; +diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c +index faa1bee07c8ac..0c83a155ceebc 100644 +--- a/drivers/scsi/arm/cumana_2.c ++++ b/drivers/scsi/arm/cumana_2.c +@@ -454,7 +454,7 @@ static int cumanascsi2_probe(struct expansion_card *ec, + + if (info->info.scsi.dma != NO_DMA) + free_dma(info->info.scsi.dma); +- free_irq(ec->irq, host); ++ free_irq(ec->irq, info); + + out_release: + fas216_release(host); +diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c +index a8ad6880dd914..cf01442d91363 100644 +--- a/drivers/scsi/arm/eesox.c ++++ b/drivers/scsi/arm/eesox.c +@@ -575,7 +575,7 @@ static int eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) + + if (info->info.scsi.dma != NO_DMA) + free_dma(info->info.scsi.dma); +- free_irq(ec->irq, host); ++ free_irq(ec->irq, info); + + out_remove: + fas216_remove(host); +diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c +index 5e1b73e1b743e..b6724ba9b36e7 100644 +--- a/drivers/scsi/arm/powertec.c ++++ b/drivers/scsi/arm/powertec.c +@@ -382,7 +382,7 @@ static int powertecscsi_probe(struct expansion_card *ec, + + if (info->info.scsi.dma != NO_DMA) + free_dma(info->info.scsi.dma); +- free_irq(ec->irq, host); ++ free_irq(ec->irq, info); + + out_release: + fas216_release(host); +diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c +index 555367f002282..18ed4b44bc513 100644 +--- a/drivers/scsi/mesh.c ++++ b/drivers/scsi/mesh.c +@@ -1044,6 +1044,8 @@ static void handle_error(struct mesh_state *ms) + while ((in_8(&mr->bus_status1) & BS1_RST) != 0) + udelay(1); + printk("done\n"); ++ if (ms->dma_started) ++ halt_dma(ms); + handle_reset(ms); + /* request_q is empty, no point in mesh_start() */ + return; +@@ -1356,7 +1358,8 @@ static void halt_dma(struct mesh_state *ms) + ms->conn_tgt, ms->data_ptr, scsi_bufflen(cmd), + ms->tgts[ms->conn_tgt].data_goes_out); + } +- scsi_dma_unmap(cmd); ++ if (cmd) ++ scsi_dma_unmap(cmd); + ms->dma_started = 0; + } + +@@ -1711,6 +1714,9 @@ static int mesh_host_reset(struct scsi_cmnd *cmd) + + spin_lock_irqsave(ms->host->host_lock, flags); + ++ if (ms->dma_started) ++ halt_dma(ms); ++ + /* Reset the controller & dbdma channel */ + out_le32(&md->control, (RUN|PAUSE|FLUSH|WAKE) << 16); /* stop dma */ + out_8(&mr->exception, 0xff); /* clear all exception bits */ +diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c +index e9bd8d4abca00..f09a74d79c9eb 100644 +--- a/drivers/usb/gadget/udc/bdc/bdc_core.c ++++ b/drivers/usb/gadget/udc/bdc/bdc_core.c +@@ -286,6 +286,7 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit) + * in that case reinit is passed as 1 + */ + if (reinit) { ++ int i; + /* Enable interrupts */ + temp = bdc_readl(bdc->regs, BDC_BDCSC); + temp |= BDC_GIE; +@@ -295,6 +296,9 @@ static void bdc_mem_init(struct bdc *bdc, bool reinit) + /* Initialize SRR to 0 */ + memset(bdc->srr.sr_bds, 0, + NUM_SR_ENTRIES * sizeof(struct bdc_bd)); ++ /* clear ep flags to avoid post disconnect stops/deconfigs */ ++ for (i = 1; i < bdc->num_eps; ++i) ++ bdc->bdc_ep_array[i]->flags = 0; + } else { + /* One time initiaization only */ + /* Enable status report function pointers */ +diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c +index 3a65272fbed86..9f5f18891ba85 100644 +--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c ++++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c +@@ -621,7 +621,6 @@ int bdc_ep_enable(struct bdc_ep *ep) + } + bdc_dbg_bd_list(bdc, ep); + /* only for ep0: config ep is called for ep0 from connect event */ +- ep->flags |= BDC_EP_ENABLED; + if (ep->ep_num == 1) + return ret; + +@@ -767,10 +766,13 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req) + __func__, ep->name, start_bdi, end_bdi); + dev_dbg(bdc->dev, "ep_dequeue ep=%p ep->desc=%p\n", + ep, (void *)ep->usb_ep.desc); +- /* Stop the ep to see where the HW is ? */ +- ret = bdc_stop_ep(bdc, ep->ep_num); +- /* if there is an issue with stopping ep, then no need to go further */ +- if (ret) ++ /* if still connected, stop the ep to see where the HW is ? */ ++ if (!(bdc_readl(bdc->regs, BDC_USPC) & BDC_PST_MASK)) { ++ ret = bdc_stop_ep(bdc, ep->ep_num); ++ /* if there is an issue, then no need to go further */ ++ if (ret) ++ return 0; ++ } else + return 0; + + /* +@@ -1921,7 +1923,9 @@ static int bdc_gadget_ep_disable(struct usb_ep *_ep) + __func__, ep->name, ep->flags); + + if (!(ep->flags & BDC_EP_ENABLED)) { +- dev_warn(bdc->dev, "%s is already disabled\n", ep->name); ++ if (bdc->gadget.speed != USB_SPEED_UNKNOWN) ++ dev_warn(bdc->dev, "%s is already disabled\n", ++ ep->name); + return 0; + } + spin_lock_irqsave(&bdc->lock, flags); +diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c +index 3a8d056a5d16b..48dd0da21e2b4 100644 +--- a/drivers/usb/gadget/udc/net2280.c ++++ b/drivers/usb/gadget/udc/net2280.c +@@ -3712,8 +3712,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id) + return 0; + + done: +- if (dev) ++ if (dev) { + net2280_remove(pdev); ++ kfree(dev); ++ } + return retval; + } + +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index 8388f88ce6356..0afea511eb376 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -2051,12 +2051,11 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port, + #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) + + static int ftdi_process_packet(struct usb_serial_port *port, +- struct ftdi_private *priv, char *packet, int len) ++ struct ftdi_private *priv, unsigned char *buf, int len) + { ++ unsigned char status; + int i; +- char status; + char flag; +- char *ch; + + if (len < 2) { + dev_dbg(&port->dev, "malformed packet\n"); +@@ -2066,7 +2065,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, + /* Compare new line status to the old one, signal if different/ + N.B. packet may be processed more than once, but differences + are only processed once. */ +- status = packet[0] & FTDI_STATUS_B0_MASK; ++ status = buf[0] & FTDI_STATUS_B0_MASK; + if (status != priv->prev_status) { + char diff_status = status ^ priv->prev_status; + +@@ -2092,13 +2091,12 @@ static int ftdi_process_packet(struct usb_serial_port *port, + } + + /* save if the transmitter is empty or not */ +- if (packet[1] & FTDI_RS_TEMT) ++ if (buf[1] & FTDI_RS_TEMT) + priv->transmit_empty = 1; + else + priv->transmit_empty = 0; + +- len -= 2; +- if (!len) ++ if (len == 2) + return 0; /* status only */ + + /* +@@ -2106,40 +2104,41 @@ static int ftdi_process_packet(struct usb_serial_port *port, + * data payload to avoid over-reporting. + */ + flag = TTY_NORMAL; +- if (packet[1] & FTDI_RS_ERR_MASK) { ++ if (buf[1] & FTDI_RS_ERR_MASK) { + /* Break takes precedence over parity, which takes precedence + * over framing errors */ +- if (packet[1] & FTDI_RS_BI) { ++ if (buf[1] & FTDI_RS_BI) { + flag = TTY_BREAK; + port->icount.brk++; + usb_serial_handle_break(port); +- } else if (packet[1] & FTDI_RS_PE) { ++ } else if (buf[1] & FTDI_RS_PE) { + flag = TTY_PARITY; + port->icount.parity++; +- } else if (packet[1] & FTDI_RS_FE) { ++ } else if (buf[1] & FTDI_RS_FE) { + flag = TTY_FRAME; + port->icount.frame++; + } + /* Overrun is special, not associated with a char */ +- if (packet[1] & FTDI_RS_OE) { ++ if (buf[1] & FTDI_RS_OE) { + port->icount.overrun++; + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); + } + } + +- port->icount.rx += len; +- ch = packet + 2; ++ port->icount.rx += len - 2; + + if (port->port.console && port->sysrq) { +- for (i = 0; i < len; i++, ch++) { +- if (!usb_serial_handle_sysrq_char(port, *ch)) +- tty_insert_flip_char(&port->port, *ch, flag); ++ for (i = 2; i < len; i++) { ++ if (usb_serial_handle_sysrq_char(port, buf[i])) ++ continue; ++ tty_insert_flip_char(&port->port, buf[i], flag); + } + } else { +- tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); ++ tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, ++ len - 2); + } + +- return len; ++ return len - 2; + } + + static void ftdi_process_read_urb(struct urb *urb) +diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c +index c59e6d4a8a612..11fb4d78e2dbc 100644 +--- a/drivers/usb/serial/qcserial.c ++++ b/drivers/usb/serial/qcserial.c +@@ -159,6 +159,7 @@ static const struct usb_device_id id_table[] = { + {DEVICE_SWI(0x1199, 0x9056)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9060)}, /* Sierra Wireless Modem */ + {DEVICE_SWI(0x1199, 0x9061)}, /* Sierra Wireless Modem */ ++ {DEVICE_SWI(0x1199, 0x9062)}, /* Sierra Wireless EM7305 QDL */ + {DEVICE_SWI(0x1199, 0x9063)}, /* Sierra Wireless EM7305 */ + {DEVICE_SWI(0x1199, 0x9070)}, /* Sierra Wireless MC74xx */ + {DEVICE_SWI(0x1199, 0x9071)}, /* Sierra Wireless MC74xx */ +diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c +index dbfe4eecf12e5..05d1d36a56654 100644 +--- a/drivers/video/console/bitblit.c ++++ b/drivers/video/console/bitblit.c +@@ -216,7 +216,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, + region.color = 0; + region.rop = ROP_COPY; + +- if (rw && !bottom_only) { ++ if ((int) rw > 0 && !bottom_only) { + region.dx = info->var.xoffset + rs; + region.dy = 0; + region.width = rw; +@@ -224,7 +224,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, + info->fbops->fb_fillrect(info, ®ion); + } + +- if (bh) { ++ if ((int) bh > 0) { + region.dx = info->var.xoffset; + region.dy = info->var.yoffset + bs; + region.width = rs; +diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c +index 5a3cbf6dff4d9..34da8bba9273a 100644 +--- a/drivers/video/console/fbcon_ccw.c ++++ b/drivers/video/console/fbcon_ccw.c +@@ -201,7 +201,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, + region.color = 0; + region.rop = ROP_COPY; + +- if (rw && !bottom_only) { ++ if ((int) rw > 0 && !bottom_only) { + region.dx = 0; + region.dy = info->var.yoffset; + region.height = rw; +@@ -209,7 +209,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, + info->fbops->fb_fillrect(info, ®ion); + } + +- if (bh) { ++ if ((int) bh > 0) { + region.dx = info->var.xoffset + bs; + region.dy = 0; + region.height = info->var.yres_virtual; +diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c +index e7ee44db4e98b..0b552b3fc22ab 100644 +--- a/drivers/video/console/fbcon_cw.c ++++ b/drivers/video/console/fbcon_cw.c +@@ -184,7 +184,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, + region.color = 0; + region.rop = ROP_COPY; + +- if (rw && !bottom_only) { ++ if ((int) rw > 0 && !bottom_only) { + region.dx = 0; + region.dy = info->var.yoffset + rs; + region.height = rw; +@@ -192,7 +192,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, + info->fbops->fb_fillrect(info, ®ion); + } + +- if (bh) { ++ if ((int) bh > 0) { + region.dx = info->var.xoffset; + region.dy = info->var.yoffset; + region.height = info->var.yres; +diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c +index 19e3714abfe8f..7f62efe2da526 100644 +--- a/drivers/video/console/fbcon_ud.c ++++ b/drivers/video/console/fbcon_ud.c +@@ -231,7 +231,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, + region.color = 0; + region.rop = ROP_COPY; + +- if (rw && !bottom_only) { ++ if ((int) rw > 0 && !bottom_only) { + region.dy = 0; + region.dx = info->var.xoffset; + region.width = rw; +@@ -239,7 +239,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, + info->fbops->fb_fillrect(info, ®ion); + } + +- if (bh) { ++ if ((int) bh > 0) { + region.dy = info->var.yoffset; + region.dx = info->var.xoffset; + region.height = bh; +diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c +index bb4e96255974a..bd0c6e53bec19 100644 +--- a/drivers/video/console/newport_con.c ++++ b/drivers/video/console/newport_con.c +@@ -31,6 +31,8 @@ + #include + #include + ++#define NEWPORT_LEN 0x10000 ++ + #define FONT_DATA ((unsigned char *)font_vga_8x16.data) + + /* borrowed from fbcon.c */ +@@ -42,6 +44,7 @@ + static unsigned char *font_data[MAX_NR_CONSOLES]; + + static struct newport_regs *npregs; ++static unsigned long newport_addr; + + static int logo_active; + static int topscan; +@@ -743,7 +746,6 @@ const struct consw newport_con = { + static int newport_probe(struct gio_device *dev, + const struct gio_device_id *id) + { +- unsigned long newport_addr; + int err; + + if (!dev->resource.start) +@@ -753,7 +755,7 @@ static int newport_probe(struct gio_device *dev, + return -EBUSY; /* we only support one Newport as console */ + + newport_addr = dev->resource.start + 0xF0000; +- if (!request_mem_region(newport_addr, 0x10000, "Newport")) ++ if (!request_mem_region(newport_addr, NEWPORT_LEN, "Newport")) + return -ENODEV; + + npregs = (struct newport_regs *)/* ioremap cannot fail */ +@@ -761,6 +763,11 @@ static int newport_probe(struct gio_device *dev, + console_lock(); + err = do_take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1); + console_unlock(); ++ ++ if (err) { ++ iounmap((void *)npregs); ++ release_mem_region(newport_addr, NEWPORT_LEN); ++ } + return err; + } + +@@ -768,6 +775,7 @@ static void newport_remove(struct gio_device *dev) + { + give_up_console(&newport_con); + iounmap((void *)npregs); ++ release_mem_region(newport_addr, NEWPORT_LEN); + } + + static struct gio_device_id newport_ids[] = { +diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c +index e5231dd55e6ed..edf0af8dd0a42 100644 +--- a/drivers/video/console/vgacon.c ++++ b/drivers/video/console/vgacon.c +@@ -220,6 +220,10 @@ static void vgacon_scrollback_update(struct vc_data *c, int t, int count) + p = (void *) (c->vc_origin + t * c->vc_size_row); + + while (count--) { ++ if ((vgacon_scrollback_tail + c->vc_size_row) > ++ vgacon_scrollback_size) ++ vgacon_scrollback_tail = 0; ++ + scr_memcpyw(vgacon_scrollback + vgacon_scrollback_tail, + p, c->vc_size_row); + vgacon_scrollback_cnt++; +diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c +index db023a97d1eae..e243254a57214 100644 +--- a/drivers/video/fbdev/neofb.c ++++ b/drivers/video/fbdev/neofb.c +@@ -1820,6 +1820,7 @@ static int neo_scan_monitor(struct fb_info *info) + #else + printk(KERN_ERR + "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n"); ++ kfree(info->monspecs.modedb); + return -1; + #endif + default: +diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c +index 589ac7e754130..c8ee58e0ae3ec 100644 +--- a/drivers/video/fbdev/sm712fb.c ++++ b/drivers/video/fbdev/sm712fb.c +@@ -1428,6 +1428,8 @@ static int smtc_map_smem(struct smtcfb_info *sfb, + static void smtc_unmap_smem(struct smtcfb_info *sfb) + { + if (sfb && sfb->fb->screen_base) { ++ if (sfb->chip_id == 0x720) ++ sfb->fb->screen_base -= 0x00200000; + iounmap(sfb->fb->screen_base); + sfb->fb->screen_base = NULL; + } +diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c +index d6f5a74df9738..dff07318d1fb5 100644 +--- a/drivers/xen/balloon.c ++++ b/drivers/xen/balloon.c +@@ -623,11 +623,13 @@ static int add_ballooned_pages(int nr_pages) + if (xen_hotplug_unpopulated) { + st = reserve_additional_memory(); + if (st != BP_ECANCELED) { ++ int rc; ++ + mutex_unlock(&balloon_mutex); +- wait_event(balloon_wq, ++ rc = wait_event_interruptible(balloon_wq, + !list_empty(&ballooned_pages)); + mutex_lock(&balloon_mutex); +- return 0; ++ return rc ? -ENOMEM : 0; + } + } + +@@ -683,6 +685,12 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) + out_undo: + mutex_unlock(&balloon_mutex); + free_xenballooned_pages(pgno, pages); ++ /* ++ * NB: free_xenballooned_pages will only subtract pgno pages, but since ++ * target_unpopulated is incremented with nr_pages at the start we need ++ * to remove the remaining ones also, or accounting will be screwed. ++ */ ++ balloon_stats.target_unpopulated -= nr_pages - pgno; + return ret; + } + EXPORT_SYMBOL(alloc_xenballooned_pages); +diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c +index 1e9bb8db7b48b..3a56f4fa59f95 100644 +--- a/fs/9p/v9fs.c ++++ b/fs/9p/v9fs.c +@@ -457,10 +457,9 @@ void v9fs_session_close(struct v9fs_session_info *v9ses) + } + + #ifdef CONFIG_9P_FSCACHE +- if (v9ses->fscache) { ++ if (v9ses->fscache) + v9fs_cache_session_put_cookie(v9ses); +- kfree(v9ses->cachetag); +- } ++ kfree(v9ses->cachetag); + #endif + kfree(v9ses->uname); + kfree(v9ses->aname); +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c +index 42b7409d4cc55..2f9f738ecf84a 100644 +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -4437,6 +4437,8 @@ int try_release_extent_mapping(struct extent_map_tree *map, + + /* once for us */ + free_extent_map(em); ++ ++ cond_resched(); /* Allow large-extent preemption. */ + } + } + return try_release_extent_state(map, tree, page, mask); +diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c +index e5351d9a8dfbe..05b1b0f99f0bc 100644 +--- a/fs/btrfs/free-space-cache.c ++++ b/fs/btrfs/free-space-cache.c +@@ -2158,7 +2158,7 @@ out: + static bool try_merge_free_space(struct btrfs_free_space_ctl *ctl, + struct btrfs_free_space *info, bool update_stat) + { +- struct btrfs_free_space *left_info; ++ struct btrfs_free_space *left_info = NULL; + struct btrfs_free_space *right_info; + bool merged = false; + u64 offset = info->offset; +@@ -2173,7 +2173,7 @@ static bool try_merge_free_space(struct btrfs_free_space_ctl *ctl, + if (right_info && rb_prev(&right_info->offset_index)) + left_info = rb_entry(rb_prev(&right_info->offset_index), + struct btrfs_free_space, offset_index); +- else ++ else if (!right_info) + left_info = tree_search_offset(ctl, offset - 1, 0, 0); + + if (right_info && !right_info->bitmap) { +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c +index 3779a660988a5..820d3b5bc4150 100644 +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -3733,11 +3733,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, + log->fs_info->csum_root, + ds + cs, ds + cs + cl - 1, + &ordered_sums, 0); +- if (ret) { +- btrfs_release_path(dst_path); +- kfree(ins_data); +- return ret; +- } ++ if (ret) ++ break; + } + } + } +@@ -3750,7 +3747,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, + * we have to do this after the loop above to avoid changing the + * log tree while trying to change the log tree. + */ +- ret = 0; + while (!list_empty(&ordered_sums)) { + struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next, + struct btrfs_ordered_sum, +diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c +index b14bb2c460426..499f54f99891c 100644 +--- a/fs/dlm/lockspace.c ++++ b/fs/dlm/lockspace.c +@@ -626,6 +626,9 @@ static int new_lockspace(const char *name, const char *cluster, + wait_event(ls->ls_recover_lock_wait, + test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags)); + ++ /* let kobject handle freeing of ls if there's an error */ ++ do_unreg = 1; ++ + ls->ls_kobj.kset = dlm_kset; + error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL, + "%s", ls->ls_name); +@@ -633,9 +636,6 @@ static int new_lockspace(const char *name, const char *cluster, + goto out_recoverd; + kobject_uevent(&ls->ls_kobj, KOBJ_ADD); + +- /* let kobject handle freeing of ls if there's an error */ +- do_unreg = 1; +- + /* This uevent triggers dlm_controld in userspace to add us to the + group of nodes that are members of this lockspace (managed by the + cluster infrastructure.) Once it's done that, it tells us who the +diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c +index efe5fb21c5332..d9ef354b821a2 100644 +--- a/fs/ext2/ialloc.c ++++ b/fs/ext2/ialloc.c +@@ -79,6 +79,7 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir) + if (dir) + le16_add_cpu(&desc->bg_used_dirs_count, -1); + spin_unlock(sb_bgl_lock(EXT2_SB(sb), group)); ++ percpu_counter_inc(&EXT2_SB(sb)->s_freeinodes_counter); + if (dir) + percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter); + mark_buffer_dirty(bh); +@@ -525,7 +526,7 @@ got: + goto fail; + } + +- percpu_counter_add(&sbi->s_freeinodes_counter, -1); ++ percpu_counter_dec(&sbi->s_freeinodes_counter); + if (S_ISDIR(mode)) + percpu_counter_inc(&sbi->s_dirs_counter); + +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c +index 8e7997010ba12..881601691bd4a 100644 +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -3353,6 +3353,13 @@ static ssize_t ext4_direct_IO(struct kiocb *iocb, struct iov_iter *iter, + size_t count = iov_iter_count(iter); + ssize_t ret; + ++ if (iov_iter_rw(iter) == READ) { ++ loff_t size = i_size_read(inode); ++ ++ if (offset >= size) ++ return 0; ++ } ++ + #ifdef CONFIG_EXT4_FS_ENCRYPTION + if (ext4_encrypted_inode(inode) && S_ISREG(inode->i_mode)) + return 0; +diff --git a/fs/minix/inode.c b/fs/minix/inode.c +index 086cd0a61e801..8d9bc0344cf32 100644 +--- a/fs/minix/inode.c ++++ b/fs/minix/inode.c +@@ -155,6 +155,23 @@ static int minix_remount (struct super_block * sb, int * flags, char * data) + return 0; + } + ++static bool minix_check_superblock(struct minix_sb_info *sbi) ++{ ++ if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0) ++ return false; ++ ++ /* ++ * s_max_size must not exceed the block mapping limitation. This check ++ * is only needed for V1 filesystems, since V2/V3 support an extra level ++ * of indirect blocks which places the limit well above U32_MAX. ++ */ ++ if (sbi->s_version == MINIX_V1 && ++ sbi->s_max_size > (7 + 512 + 512*512) * BLOCK_SIZE) ++ return false; ++ ++ return true; ++} ++ + static int minix_fill_super(struct super_block *s, void *data, int silent) + { + struct buffer_head *bh; +@@ -233,11 +250,12 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) + } else + goto out_no_fs; + ++ if (!minix_check_superblock(sbi)) ++ goto out_illegal_sb; ++ + /* + * Allocate the buffer map to keep the superblock small. + */ +- if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0) +- goto out_illegal_sb; + i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh); + map = kzalloc(i, GFP_KERNEL); + if (!map) +@@ -472,6 +490,13 @@ static struct inode *V1_minix_iget(struct inode *inode) + iget_failed(inode); + return ERR_PTR(-EIO); + } ++ if (raw_inode->i_nlinks == 0) { ++ printk("MINIX-fs: deleted inode referenced: %lu\n", ++ inode->i_ino); ++ brelse(bh); ++ iget_failed(inode); ++ return ERR_PTR(-ESTALE); ++ } + inode->i_mode = raw_inode->i_mode; + i_uid_write(inode, raw_inode->i_uid); + i_gid_write(inode, raw_inode->i_gid); +@@ -505,6 +530,13 @@ static struct inode *V2_minix_iget(struct inode *inode) + iget_failed(inode); + return ERR_PTR(-EIO); + } ++ if (raw_inode->i_nlinks == 0) { ++ printk("MINIX-fs: deleted inode referenced: %lu\n", ++ inode->i_ino); ++ brelse(bh); ++ iget_failed(inode); ++ return ERR_PTR(-ESTALE); ++ } + inode->i_mode = raw_inode->i_mode; + i_uid_write(inode, raw_inode->i_uid); + i_gid_write(inode, raw_inode->i_gid); +diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c +index a731cabf1540e..3816427e89382 100644 +--- a/fs/minix/itree_common.c ++++ b/fs/minix/itree_common.c +@@ -74,6 +74,7 @@ static int alloc_branch(struct inode *inode, + int n = 0; + int i; + int parent = minix_new_block(inode); ++ int err = -ENOSPC; + + branch[0].key = cpu_to_block(parent); + if (parent) for (n = 1; n < num; n++) { +@@ -84,6 +85,11 @@ static int alloc_branch(struct inode *inode, + break; + branch[n].key = cpu_to_block(nr); + bh = sb_getblk(inode->i_sb, parent); ++ if (!bh) { ++ minix_free_block(inode, nr); ++ err = -ENOMEM; ++ break; ++ } + lock_buffer(bh); + memset(bh->b_data, 0, bh->b_size); + branch[n].bh = bh; +@@ -102,7 +108,7 @@ static int alloc_branch(struct inode *inode, + bforget(branch[i].bh); + for (i = 0; i < n; i++) + minix_free_block(inode, block_to_cpu(branch[i].key)); +- return -ENOSPC; ++ return err; + } + + static inline int splice_branch(struct inode *inode, +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index 0308b56896382..ca1702cefb852 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -4916,8 +4916,6 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf, + return ret; + if (!(fattr.valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL)) + return -ENOENT; +- if (buflen < label.len) +- return -ERANGE; + return 0; + } + +@@ -6296,10 +6294,6 @@ static size_t nfs4_xattr_list_nfs4_acl(const struct xattr_handler *handler, + } + + #ifdef CONFIG_NFS_V4_SECURITY_LABEL +-static inline int nfs4_server_supports_labels(struct nfs_server *server) +-{ +- return server->caps & NFS_CAP_SECURITY_LABEL; +-} + + static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, + struct dentry *dentry, const char *key, +@@ -6321,29 +6315,34 @@ static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler, + return -EOPNOTSUPP; + } + +-static size_t nfs4_xattr_list_nfs4_label(const struct xattr_handler *handler, +- struct dentry *dentry, char *list, +- size_t list_len, const char *name, +- size_t name_len) ++static ssize_t ++nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len) + { +- size_t len = 0; ++ int len = 0; + +- if (nfs_server_capable(d_inode(dentry), NFS_CAP_SECURITY_LABEL)) { +- len = security_inode_listsecurity(d_inode(dentry), NULL, 0); +- if (list && len <= list_len) +- security_inode_listsecurity(d_inode(dentry), list, len); ++ if (nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) { ++ len = security_inode_listsecurity(inode, list, list_len); ++ if (list_len && len > list_len) ++ return -ERANGE; + } + return len; + } + + static const struct xattr_handler nfs4_xattr_nfs4_label_handler = { + .prefix = XATTR_SECURITY_PREFIX, +- .list = nfs4_xattr_list_nfs4_label, + .get = nfs4_xattr_get_nfs4_label, + .set = nfs4_xattr_set_nfs4_label, + }; +-#endif + ++#else ++ ++static ssize_t ++nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len) ++{ ++ return 0; ++} ++ ++#endif + + /* + * nfs_fhget will use either the mounted_on_fileid or the fileid +@@ -8773,6 +8772,24 @@ const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = { + #endif + }; + ++ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size) ++{ ++ ssize_t error, error2; ++ ++ error = generic_listxattr(dentry, list, size); ++ if (error < 0) ++ return error; ++ if (list) { ++ list += error; ++ size -= error; ++ } ++ ++ error2 = nfs4_listxattr_nfs4_label(d_inode(dentry), list, size); ++ if (error2 < 0) ++ return error2; ++ return error + error2; ++} ++ + static const struct inode_operations nfs4_dir_inode_operations = { + .create = nfs_create, + .lookup = nfs_lookup, +@@ -8789,7 +8806,7 @@ static const struct inode_operations nfs4_dir_inode_operations = { + .setattr = nfs_setattr, + .getxattr = generic_getxattr, + .setxattr = generic_setxattr, +- .listxattr = generic_listxattr, ++ .listxattr = nfs4_listxattr, + .removexattr = generic_removexattr, + }; + +@@ -8799,7 +8816,7 @@ static const struct inode_operations nfs4_file_inode_operations = { + .setattr = nfs_setattr, + .getxattr = generic_getxattr, + .setxattr = generic_setxattr, +- .listxattr = generic_listxattr, ++ .listxattr = nfs4_listxattr, + .removexattr = generic_removexattr, + }; + +diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c +index 15cd9db6d616d..28c1b765e4444 100644 +--- a/fs/nfs/nfs4xdr.c ++++ b/fs/nfs/nfs4xdr.c +@@ -4158,7 +4158,11 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, + goto out_overflow; + if (len < NFS4_MAXLABELLEN) { + if (label) { +- memcpy(label->label, p, len); ++ if (label->len) { ++ if (label->len < len) ++ return -ERANGE; ++ memcpy(label->label, p, len); ++ } + label->len = len; + label->pi = pi; + label->lfs = lfs; +diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h +index 2495066a9ca3f..9e7f39b17e679 100644 +--- a/fs/ocfs2/ocfs2.h ++++ b/fs/ocfs2/ocfs2.h +@@ -337,8 +337,8 @@ struct ocfs2_super + spinlock_t osb_lock; + u32 s_next_generation; + unsigned long osb_flags; +- s16 s_inode_steal_slot; +- s16 s_meta_steal_slot; ++ u16 s_inode_steal_slot; ++ u16 s_meta_steal_slot; + atomic_t s_num_inodes_stolen; + atomic_t s_num_meta_stolen; + +diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c +index 28cc343bf6e3b..41a67c9b37e02 100644 +--- a/fs/ocfs2/suballoc.c ++++ b/fs/ocfs2/suballoc.c +@@ -895,9 +895,9 @@ static void __ocfs2_set_steal_slot(struct ocfs2_super *osb, int slot, int type) + { + spin_lock(&osb->osb_lock); + if (type == INODE_ALLOC_SYSTEM_INODE) +- osb->s_inode_steal_slot = slot; ++ osb->s_inode_steal_slot = (u16)slot; + else if (type == EXTENT_ALLOC_SYSTEM_INODE) +- osb->s_meta_steal_slot = slot; ++ osb->s_meta_steal_slot = (u16)slot; + spin_unlock(&osb->osb_lock); + } + +diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c +index 4f5141350af86..d97403bb36226 100644 +--- a/fs/ocfs2/super.c ++++ b/fs/ocfs2/super.c +@@ -96,7 +96,7 @@ struct mount_options + unsigned long commit_interval; + unsigned long mount_opt; + unsigned int atime_quantum; +- signed short slot; ++ unsigned short slot; + int localalloc_opt; + unsigned int resv_level; + int dir_resv_level; +@@ -1372,7 +1372,7 @@ static int ocfs2_parse_options(struct super_block *sb, + goto bail; + } + if (option) +- mopt->slot = (s16)option; ++ mopt->slot = (u16)option; + break; + case Opt_commit: + option = 0; +diff --git a/fs/ufs/super.c b/fs/ufs/super.c +index 10f364490833e..be68b48de1cc6 100644 +--- a/fs/ufs/super.c ++++ b/fs/ufs/super.c +@@ -99,7 +99,7 @@ static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gene + struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; + struct inode *inode; + +- if (ino < UFS_ROOTINO || ino > uspi->s_ncg * uspi->s_ipg) ++ if (ino < UFS_ROOTINO || ino > (u64)uspi->s_ncg * uspi->s_ipg) + return ERR_PTR(-ESTALE); + + inode = ufs_iget(sb, ino); +diff --git a/fs/xattr.c b/fs/xattr.c +index 09441c396798d..5ba5565609eed 100644 +--- a/fs/xattr.c ++++ b/fs/xattr.c +@@ -735,6 +735,8 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) + + if (!buffer) { + for_each_xattr_handler(handlers, handler) { ++ if (!handler->list) ++ continue; + size += handler->list(handler, dentry, NULL, 0, + NULL, 0); + } +@@ -742,6 +744,8 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) + char *buf = buffer; + + for_each_xattr_handler(handlers, handler) { ++ if (!handler->list) ++ continue; + size = handler->list(handler, dentry, buf, buffer_size, + NULL, 0); + if (size > buffer_size) +diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c +index 01a5ecfedfcf1..445a3f2f871fb 100644 +--- a/fs/xfs/libxfs/xfs_attr_leaf.c ++++ b/fs/xfs/libxfs/xfs_attr_leaf.c +@@ -779,9 +779,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) + ASSERT(blkno == 0); + error = xfs_attr3_leaf_create(args, blkno, &bp); + if (error) { +- error = xfs_da_shrink_inode(args, 0, bp); +- bp = NULL; +- if (error) ++ /* xfs_attr3_leaf_create may not have instantiated a block */ ++ if (bp && (xfs_da_shrink_inode(args, 0, bp) != 0)) + goto out; + xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */ + memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */ +diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h +index 27dbab59f034c..d86ac620f0aac 100644 +--- a/include/linux/intel-iommu.h ++++ b/include/linux/intel-iommu.h +@@ -317,8 +317,8 @@ enum { + + #define QI_DEV_EIOTLB_ADDR(a) ((u64)(a) & VTD_PAGE_MASK) + #define QI_DEV_EIOTLB_SIZE (((u64)1) << 11) +-#define QI_DEV_EIOTLB_GLOB(g) ((u64)g) +-#define QI_DEV_EIOTLB_PASID(p) (((u64)p) << 32) ++#define QI_DEV_EIOTLB_GLOB(g) ((u64)(g) & 0x1) ++#define QI_DEV_EIOTLB_PASID(p) ((u64)((p) & 0xfffff) << 32) + #define QI_DEV_EIOTLB_SID(sid) ((u64)((sid) & 0xffff) << 16) + #define QI_DEV_EIOTLB_QDEP(qd) ((u64)((qd) & 0x1f) << 4) + #define QI_DEV_EIOTLB_PFSID(pfsid) (((u64)(pfsid & 0xf) << 12) | \ +diff --git a/include/linux/prandom.h b/include/linux/prandom.h +new file mode 100644 +index 0000000000000..aa16e6468f91e +--- /dev/null ++++ b/include/linux/prandom.h +@@ -0,0 +1,78 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * include/linux/prandom.h ++ * ++ * Include file for the fast pseudo-random 32-bit ++ * generation. ++ */ ++#ifndef _LINUX_PRANDOM_H ++#define _LINUX_PRANDOM_H ++ ++#include ++#include ++ ++u32 prandom_u32(void); ++void prandom_bytes(void *buf, size_t nbytes); ++void prandom_seed(u32 seed); ++void prandom_reseed_late(void); ++ ++struct rnd_state { ++ __u32 s1, s2, s3, s4; ++}; ++ ++DECLARE_PER_CPU(struct rnd_state, net_rand_state); ++ ++u32 prandom_u32_state(struct rnd_state *state); ++void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes); ++void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state); ++ ++#define prandom_init_once(pcpu_state) \ ++ DO_ONCE(prandom_seed_full_state, (pcpu_state)) ++ ++/** ++ * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro) ++ * @ep_ro: right open interval endpoint ++ * ++ * Returns a pseudo-random number that is in interval [0, ep_ro). Note ++ * that the result depends on PRNG being well distributed in [0, ~0U] ++ * u32 space. Here we use maximally equidistributed combined Tausworthe ++ * generator, that is, prandom_u32(). This is useful when requesting a ++ * random index of an array containing ep_ro elements, for example. ++ * ++ * Returns: pseudo-random number in interval [0, ep_ro) ++ */ ++static inline u32 prandom_u32_max(u32 ep_ro) ++{ ++ return (u32)(((u64) prandom_u32() * ep_ro) >> 32); ++} ++ ++/* ++ * Handle minimum values for seeds ++ */ ++static inline u32 __seed(u32 x, u32 m) ++{ ++ return (x < m) ? x + m : x; ++} ++ ++/** ++ * prandom_seed_state - set seed for prandom_u32_state(). ++ * @state: pointer to state structure to receive the seed. ++ * @seed: arbitrary 64-bit value to use as a seed. ++ */ ++static inline void prandom_seed_state(struct rnd_state *state, u64 seed) ++{ ++ u32 i = (seed >> 32) ^ (seed << 10) ^ seed; ++ ++ state->s1 = __seed(i, 2U); ++ state->s2 = __seed(i, 8U); ++ state->s3 = __seed(i, 16U); ++ state->s4 = __seed(i, 128U); ++} ++ ++/* Pseudo random number generator from numerical recipes. */ ++static inline u32 next_pseudo_random32(u32 seed) ++{ ++ return seed * 1664525 + 1013904223; ++} ++ ++#endif +diff --git a/include/linux/random.h b/include/linux/random.h +index 9c29122037f95..2fa4207fd0677 100644 +--- a/include/linux/random.h ++++ b/include/linux/random.h +@@ -37,61 +37,12 @@ unsigned int get_random_int(void); + unsigned long get_random_long(void); + unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len); + +-u32 prandom_u32(void); +-void prandom_bytes(void *buf, size_t nbytes); +-void prandom_seed(u32 seed); +-void prandom_reseed_late(void); +- +-struct rnd_state { +- __u32 s1, s2, s3, s4; +-}; +- +-u32 prandom_u32_state(struct rnd_state *state); +-void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes); +-void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state); +- +-#define prandom_init_once(pcpu_state) \ +- DO_ONCE(prandom_seed_full_state, (pcpu_state)) +- +-/** +- * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro) +- * @ep_ro: right open interval endpoint +- * +- * Returns a pseudo-random number that is in interval [0, ep_ro). Note +- * that the result depends on PRNG being well distributed in [0, ~0U] +- * u32 space. Here we use maximally equidistributed combined Tausworthe +- * generator, that is, prandom_u32(). This is useful when requesting a +- * random index of an array containing ep_ro elements, for example. +- * +- * Returns: pseudo-random number in interval [0, ep_ro) +- */ +-static inline u32 prandom_u32_max(u32 ep_ro) +-{ +- return (u32)(((u64) prandom_u32() * ep_ro) >> 32); +-} +- + /* +- * Handle minimum values for seeds ++ * This is designed to be standalone for just prandom ++ * users, but for now we include it from ++ * for legacy reasons. + */ +-static inline u32 __seed(u32 x, u32 m) +-{ +- return (x < m) ? x + m : x; +-} +- +-/** +- * prandom_seed_state - set seed for prandom_u32_state(). +- * @state: pointer to state structure to receive the seed. +- * @seed: arbitrary 64-bit value to use as a seed. +- */ +-static inline void prandom_seed_state(struct rnd_state *state, u64 seed) +-{ +- u32 i = (seed >> 32) ^ (seed << 10) ^ seed; +- +- state->s1 = __seed(i, 2U); +- state->s2 = __seed(i, 8U); +- state->s3 = __seed(i, 16U); +- state->s4 = __seed(i, 128U); +-} ++#include + + #ifdef CONFIG_ARCH_RANDOM + # include +@@ -122,10 +73,4 @@ static inline int arch_has_random_seed(void) + } + #endif + +-/* Pseudo random number generator from numerical recipes. */ +-static inline u32 next_pseudo_random32(u32 seed) +-{ +- return seed * 1664525 + 1013904223; +-} +- + #endif /* _LINUX_RANDOM_H */ +diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h +index 27e32b2b602fc..d7875d312f1f9 100644 +--- a/include/linux/tracepoint.h ++++ b/include/linux/tracepoint.h +@@ -328,7 +328,7 @@ extern void syscall_unregfunc(void); + static const char *___tp_str __tracepoint_string = str; \ + ___tp_str; \ + }) +-#define __tracepoint_string __attribute__((section("__tracepoint_str"))) ++#define __tracepoint_string __attribute__((section("__tracepoint_str"), used)) + #else + /* + * tracepoint_string() is used to save the string address for userspace +diff --git a/include/net/addrconf.h b/include/net/addrconf.h +index 27a1833c7b00f..efe48a27b7aba 100644 +--- a/include/net/addrconf.h ++++ b/include/net/addrconf.h +@@ -239,6 +239,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, + const struct in6_addr *addr); + int ipv6_sock_ac_drop(struct sock *sk, int ifindex, + const struct in6_addr *addr); ++void __ipv6_sock_ac_close(struct sock *sk); + void ipv6_sock_ac_close(struct sock *sk); + + int __ipv6_dev_ac_inc(struct inet6_dev *idev, const struct in6_addr *addr); +diff --git a/kernel/kprobes.c b/kernel/kprobes.c +index 5bda113a3116c..9241a29a1f9de 100644 +--- a/kernel/kprobes.c ++++ b/kernel/kprobes.c +@@ -2029,6 +2029,13 @@ static void kill_kprobe(struct kprobe *p) + * the original probed function (which will be freed soon) any more. + */ + arch_remove_kprobe(p); ++ ++ /* ++ * The module is going away. We should disarm the kprobe which ++ * is using ftrace. ++ */ ++ if (kprobe_ftrace(p)) ++ disarm_kprobe_ftrace(p); + } + + /* Disable one kprobe */ +diff --git a/kernel/time/timer.c b/kernel/time/timer.c +index 3d7588a2e97c6..43bee4993187c 100644 +--- a/kernel/time/timer.c ++++ b/kernel/time/timer.c +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -1431,6 +1432,13 @@ void update_process_times(int user_tick) + #endif + scheduler_tick(); + run_posix_cpu_timers(p); ++ ++ /* The current CPU might make use of net randoms without receiving IRQs ++ * to renew them often enough. Let's update the net_rand_state from a ++ * non-constant value that's not affine to the number of calls to make ++ * sure it's updated when there's some activity (we don't care in idle). ++ */ ++ this_cpu_add(net_rand_state.s1, rol32(jiffies, 24) + user_tick); + } + + /* +diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c +index c6368ae93fe6e..f50d63f67899a 100644 +--- a/lib/dynamic_debug.c ++++ b/lib/dynamic_debug.c +@@ -85,22 +85,22 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = { + { _DPRINTK_FLAGS_NONE, '_' }, + }; + ++struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; }; ++ + /* format a string into buf[] which describes the _ddebug's flags */ +-static char *ddebug_describe_flags(struct _ddebug *dp, char *buf, +- size_t maxlen) ++static char *ddebug_describe_flags(unsigned int flags, struct flagsbuf *fb) + { +- char *p = buf; ++ char *p = fb->buf; + int i; + +- BUG_ON(maxlen < 6); + for (i = 0; i < ARRAY_SIZE(opt_array); ++i) +- if (dp->flags & opt_array[i].flag) ++ if (flags & opt_array[i].flag) + *p++ = opt_array[i].opt_char; +- if (p == buf) ++ if (p == fb->buf) + *p++ = '_'; + *p = '\0'; + +- return buf; ++ return fb->buf; + } + + #define vpr_info(fmt, ...) \ +@@ -142,7 +142,7 @@ static int ddebug_change(const struct ddebug_query *query, + struct ddebug_table *dt; + unsigned int newflags; + unsigned int nfound = 0; +- char flagbuf[10]; ++ struct flagsbuf fbuf; + + /* search for matching ddebugs */ + mutex_lock(&ddebug_lock); +@@ -192,8 +192,7 @@ static int ddebug_change(const struct ddebug_query *query, + vpr_info("changed %s:%d [%s]%s =%s\n", + trim_prefix(dp->filename), dp->lineno, + dt->mod_name, dp->function, +- ddebug_describe_flags(dp, flagbuf, +- sizeof(flagbuf))); ++ ddebug_describe_flags(dp->flags, &fbuf)); + } + } + mutex_unlock(&ddebug_lock); +@@ -777,7 +776,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) + { + struct ddebug_iter *iter = m->private; + struct _ddebug *dp = p; +- char flagsbuf[10]; ++ struct flagsbuf flags; + + vpr_info("called m=%p p=%p\n", m, p); + +@@ -790,7 +789,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) + seq_printf(m, "%s:%u [%s]%s =%s \"", + trim_prefix(dp->filename), dp->lineno, + iter->table->mod_name, dp->function, +- ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); ++ ddebug_describe_flags(dp->flags, &flags)); + seq_escape(m, dp->format, "\t\r\n\""); + seq_puts(m, "\"\n"); + +diff --git a/lib/random32.c b/lib/random32.c +index 12111910ccd07..8072ccd9eed58 100644 +--- a/lib/random32.c ++++ b/lib/random32.c +@@ -47,7 +47,7 @@ static inline void prandom_state_selftest(void) + } + #endif + +-static DEFINE_PER_CPU(struct rnd_state, net_rand_state); ++DEFINE_PER_CPU(struct rnd_state, net_rand_state); + + /** + * prandom_u32_state - seeded pseudo-random number generator. +diff --git a/mm/mmap.c b/mm/mmap.c +index a24e424770012..135cccce41f88 100644 +--- a/mm/mmap.c ++++ b/mm/mmap.c +@@ -2954,6 +2954,7 @@ void exit_mmap(struct mm_struct *mm) + if (vma->vm_flags & VM_ACCOUNT) + nr_accounted += vma_pages(vma); + vma = remove_vma(vma); ++ cond_resched(); + } + vm_unacct_memory(nr_accounted); + } +diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c +index 2f68ffda3715b..eab058f93ec97 100644 +--- a/net/9p/trans_fd.c ++++ b/net/9p/trans_fd.c +@@ -793,20 +793,28 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd) + return -ENOMEM; + + ts->rd = fget(rfd); ++ if (!ts->rd) ++ goto out_free_ts; ++ if (!(ts->rd->f_mode & FMODE_READ)) ++ goto out_put_rd; + ts->wr = fget(wfd); +- if (!ts->rd || !ts->wr) { +- if (ts->rd) +- fput(ts->rd); +- if (ts->wr) +- fput(ts->wr); +- kfree(ts); +- return -EIO; +- } ++ if (!ts->wr) ++ goto out_put_rd; ++ if (!(ts->wr->f_mode & FMODE_WRITE)) ++ goto out_put_wr; + + client->trans = ts; + client->status = Connected; + + return 0; ++ ++out_put_wr: ++ fput(ts->wr); ++out_put_rd: ++ fput(ts->rd); ++out_free_ts: ++ kfree(ts); ++ return -EIO; + } + + static int p9_socket_open(struct p9_client *client, struct socket *csocket) +diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c +index 4cd6b8d811ffa..11602902884ba 100644 +--- a/net/bluetooth/6lowpan.c ++++ b/net/bluetooth/6lowpan.c +@@ -57,6 +57,7 @@ static bool enable_6lowpan; + /* We are listening incoming connections via this channel + */ + static struct l2cap_chan *listen_chan; ++static DEFINE_MUTEX(set_lock); + + struct lowpan_peer { + struct list_head list; +@@ -1195,12 +1196,14 @@ static void do_enable_set(struct work_struct *work) + + enable_6lowpan = set_enable->flag; + ++ mutex_lock(&set_lock); + if (listen_chan) { + l2cap_chan_close(listen_chan, 0); + l2cap_chan_put(listen_chan); + } + + listen_chan = bt_6lowpan_listen(); ++ mutex_unlock(&set_lock); + + kfree(set_enable); + } +@@ -1252,11 +1255,13 @@ static ssize_t lowpan_control_write(struct file *fp, + if (ret == -EINVAL) + return ret; + ++ mutex_lock(&set_lock); + if (listen_chan) { + l2cap_chan_close(listen_chan, 0); + l2cap_chan_put(listen_chan); + listen_chan = NULL; + } ++ mutex_unlock(&set_lock); + + if (conn) { + struct lowpan_peer *peer; +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c +index 1d957c7f17836..16cf5633eae3e 100644 +--- a/net/bluetooth/hci_event.c ++++ b/net/bluetooth/hci_event.c +@@ -2094,7 +2094,7 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) + + BT_DBG("%s num_rsp %d", hdev->name, num_rsp); + +- if (!num_rsp) ++ if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1) + return; + + if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) +@@ -3609,6 +3609,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, + struct inquiry_info_with_rssi_and_pscan_mode *info; + info = (void *) (skb->data + 1); + ++ if (skb->len < num_rsp * sizeof(*info) + 1) ++ goto unlock; ++ + for (; num_rsp; num_rsp--, info++) { + u32 flags; + +@@ -3630,6 +3633,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, + } else { + struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); + ++ if (skb->len < num_rsp * sizeof(*info) + 1) ++ goto unlock; ++ + for (; num_rsp; num_rsp--, info++) { + u32 flags; + +@@ -3650,6 +3656,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, + } + } + ++unlock: + hci_dev_unlock(hdev); + } + +@@ -3812,7 +3819,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, + + BT_DBG("%s num_rsp %d", hdev->name, num_rsp); + +- if (!num_rsp) ++ if (!num_rsp || skb->len < num_rsp * sizeof(*info) + 1) + return; + + if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) +diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c +index 09b01b888583e..9ec666dbdfc75 100644 +--- a/net/ipv4/fib_trie.c ++++ b/net/ipv4/fib_trie.c +@@ -1696,7 +1696,7 @@ struct fib_table *fib_trie_unmerge(struct fib_table *oldtb) + while ((l = leaf_walk_rcu(&tp, key)) != NULL) { + struct key_vector *local_l = NULL, *local_tp; + +- hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) { ++ hlist_for_each_entry(fa, &l->leaf, fa_list) { + struct fib_alias *new_fa; + + if (local_tb->tb_id != fa->tb_id) +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c +index 5464fd2102302..0d9f9d6251245 100644 +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -1589,8 +1589,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) + } + } + +- if (rcu_access_pointer(sk->sk_filter) && +- udp_lib_checksum_complete(skb)) ++ if (udp_lib_checksum_complete(skb)) + goto csum_error; + + if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { +diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c +index 514ac259f5433..b831e9b2e9063 100644 +--- a/net/ipv6/anycast.c ++++ b/net/ipv6/anycast.c +@@ -170,7 +170,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr) + return 0; + } + +-void ipv6_sock_ac_close(struct sock *sk) ++void __ipv6_sock_ac_close(struct sock *sk) + { + struct ipv6_pinfo *np = inet6_sk(sk); + struct net_device *dev = NULL; +@@ -178,10 +178,7 @@ void ipv6_sock_ac_close(struct sock *sk) + struct net *net = sock_net(sk); + int prev_index; + +- if (!np->ipv6_ac_list) +- return; +- +- rtnl_lock(); ++ ASSERT_RTNL(); + pac = np->ipv6_ac_list; + np->ipv6_ac_list = NULL; + +@@ -198,6 +195,16 @@ void ipv6_sock_ac_close(struct sock *sk) + sock_kfree_s(sk, pac, sizeof(*pac)); + pac = next; + } ++} ++ ++void ipv6_sock_ac_close(struct sock *sk) ++{ ++ struct ipv6_pinfo *np = inet6_sk(sk); ++ ++ if (!np->ipv6_ac_list) ++ return; ++ rtnl_lock(); ++ __ipv6_sock_ac_close(sk); + rtnl_unlock(); + } + +diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c +index f072a4c4575c6..96563990d6544 100644 +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -972,26 +972,28 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, + + /* NBMA tunnel */ + if (ipv6_addr_any(&t->parms.raddr)) { +- struct in6_addr *addr6; +- struct neighbour *neigh; +- int addr_type; ++ if (skb->protocol == htons(ETH_P_IPV6)) { ++ struct in6_addr *addr6; ++ struct neighbour *neigh; ++ int addr_type; + +- if (!skb_dst(skb)) +- goto tx_err_link_failure; ++ if (!skb_dst(skb)) ++ goto tx_err_link_failure; + +- neigh = dst_neigh_lookup(skb_dst(skb), +- &ipv6_hdr(skb)->daddr); +- if (!neigh) +- goto tx_err_link_failure; ++ neigh = dst_neigh_lookup(skb_dst(skb), ++ &ipv6_hdr(skb)->daddr); ++ if (!neigh) ++ goto tx_err_link_failure; + +- addr6 = (struct in6_addr *)&neigh->primary_key; +- addr_type = ipv6_addr_type(addr6); ++ addr6 = (struct in6_addr *)&neigh->primary_key; ++ addr_type = ipv6_addr_type(addr6); + +- if (addr_type == IPV6_ADDR_ANY) +- addr6 = &ipv6_hdr(skb)->daddr; ++ if (addr_type == IPV6_ADDR_ANY) ++ addr6 = &ipv6_hdr(skb)->daddr; + +- memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); +- neigh_release(neigh); ++ memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); ++ neigh_release(neigh); ++ } + } else if (!fl6->flowi6_mark) + dst = dst_cache_get(&t->dst_cache); + +diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c +index 416b3660f818b..4a75013a2ede0 100644 +--- a/net/ipv6/ipv6_sockglue.c ++++ b/net/ipv6/ipv6_sockglue.c +@@ -207,6 +207,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, + + fl6_free_socklist(sk); + __ipv6_sock_mc_close(sk); ++ __ipv6_sock_ac_close(sk); + + /* + * Sock is moving from IPv6 to IPv4 (sk_prot), so +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c +index 79c583004575a..be570cd7c9aed 100644 +--- a/net/ipv6/udp.c ++++ b/net/ipv6/udp.c +@@ -686,10 +686,8 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) + } + } + +- if (rcu_access_pointer(sk->sk_filter)) { +- if (udp_lib_checksum_complete(skb)) +- goto csum_error; +- } ++ if (udp_lib_checksum_complete(skb)) ++ goto csum_error; + + if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { + UDP6_INC_STATS_BH(sock_net(sk), +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c +index cf3917c6da0a6..8360fda24bca0 100644 +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -1766,6 +1766,7 @@ static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) + ieee80211_stop_mesh(sdata); + mutex_lock(&sdata->local->mtx); + ieee80211_vif_release_channel(sdata); ++ kfree(sdata->u.mesh.ie); + mutex_unlock(&sdata->local->mtx); + + return 0; +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c +index a1f6cd1a496b5..bbddab248c489 100644 +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -906,7 +906,7 @@ static void __sta_info_destroy_part2(struct sta_info *sta) + might_sleep(); + lockdep_assert_held(&local->sta_mtx); + +- while (sta->sta_state == IEEE80211_STA_AUTHORIZED) { ++ if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { + ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); + WARN_ON_ONCE(ret); + } +diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c +index e386e6c90b179..574af981806fa 100644 +--- a/net/nfc/rawsock.c ++++ b/net/nfc/rawsock.c +@@ -344,10 +344,13 @@ static int rawsock_create(struct net *net, struct socket *sock, + if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW)) + return -ESOCKTNOSUPPORT; + +- if (sock->type == SOCK_RAW) ++ if (sock->type == SOCK_RAW) { ++ if (!capable(CAP_NET_RAW)) ++ return -EPERM; + sock->ops = &rawsock_raw_ops; +- else ++ } else { + sock->ops = &rawsock_ops; ++ } + + sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto, kern); + if (!sk) +diff --git a/net/rds/recv.c b/net/rds/recv.c +index 6275de19689c2..9bf812509e0e9 100644 +--- a/net/rds/recv.c ++++ b/net/rds/recv.c +@@ -301,12 +301,13 @@ static int rds_still_queued(struct rds_sock *rs, struct rds_incoming *inc, + int rds_notify_queue_get(struct rds_sock *rs, struct msghdr *msghdr) + { + struct rds_notifier *notifier; +- struct rds_rdma_notify cmsg = { 0 }; /* fill holes with zero */ ++ struct rds_rdma_notify cmsg; + unsigned int count = 0, max_messages = ~0U; + unsigned long flags; + LIST_HEAD(copy); + int err = 0; + ++ memset(&cmsg, 0, sizeof(cmsg)); /* fill holes with zero */ + + /* put_cmsg copies to user space and thus may sleep. We can't do this + * with rs_lock held, so first grab as many notifications as we can stuff +diff --git a/net/socket.c b/net/socket.c +index 88086d18c2086..1392461d391ad 100644 +--- a/net/socket.c ++++ b/net/socket.c +@@ -456,7 +456,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) + if (f.file) { + sock = sock_from_file(f.file, err); + if (likely(sock)) { +- *fput_needed = f.flags; ++ *fput_needed = f.flags & FDPUT_FPUT; + return sock; + } + fdput(f); +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c +index c6c168f20b0f2..55de35c4434a8 100644 +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -10180,13 +10180,13 @@ static int nl80211_vendor_cmd(struct sk_buff *skb, struct genl_info *info) + if (!wdev->netdev && !wdev->p2p_started) + return -ENETDOWN; + } +- +- if (!vcmd->doit) +- return -EOPNOTSUPP; + } else { + wdev = NULL; + } + ++ if (!vcmd->doit) ++ return -EOPNOTSUPP; ++ + if (info->attrs[NL80211_ATTR_VENDOR_DATA]) { + data = nla_data(info->attrs[NL80211_ATTR_VENDOR_DATA]); + len = nla_len(info->attrs[NL80211_ATTR_VENDOR_DATA]); +diff --git a/net/x25/x25_subr.c b/net/x25/x25_subr.c +index 6b5af65f491fb..a3163645b5bd3 100644 +--- a/net/x25/x25_subr.c ++++ b/net/x25/x25_subr.c +@@ -368,6 +368,12 @@ void x25_disconnect(struct sock *sk, int reason, unsigned char cause, + sk->sk_state_change(sk); + sock_set_flag(sk, SOCK_DEAD); + } ++ if (x25->neighbour) { ++ read_lock_bh(&x25_list_lock); ++ x25_neigh_put(x25->neighbour); ++ x25->neighbour = NULL; ++ read_unlock_bh(&x25_list_lock); ++ } + } + + /* +diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c +index 716433e630529..d37c1963e8ca3 100644 +--- a/security/smack/smack_lsm.c ++++ b/security/smack/smack_lsm.c +@@ -1513,8 +1513,6 @@ static int smack_inode_getsecurity(const struct inode *inode, + * @inode: the object + * @buffer: where they go + * @buffer_size: size of buffer +- * +- * Returns 0 on success, -EINVAL otherwise + */ + static int smack_inode_listsecurity(struct inode *inode, char *buffer, + size_t buffer_size) +diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c +index d186d24ac6490..df082648eb0aa 100644 +--- a/security/smack/smackfs.c ++++ b/security/smack/smackfs.c +@@ -918,7 +918,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, + } + + ret = sscanf(rule, "%d", &maplevel); +- if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL) ++ if (ret != 1 || maplevel < 0 || maplevel > SMACK_CIPSO_MAXLEVEL) + goto out; + + rule += SMK_DIGITLEN; +@@ -939,6 +939,10 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, + + for (i = 0; i < catlen; i++) { + rule += SMK_DIGITLEN; ++ if (rule > data + count) { ++ rc = -EOVERFLOW; ++ goto out; ++ } + ret = sscanf(rule, "%u", &cat); + if (ret != 1 || cat > SMACK_CIPSO_MAXCATNUM) + goto out; +@@ -2791,7 +2795,6 @@ static int smk_open_relabel_self(struct inode *inode, struct file *file) + static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) + { +- struct task_smack *tsp = current_security(); + char *data; + int rc; + LIST_HEAD(list_tmp); +@@ -2821,11 +2824,21 @@ static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf, + kfree(data); + + if (!rc || (rc == -EINVAL && list_empty(&list_tmp))) { ++ struct cred *new; ++ struct task_smack *tsp; ++ ++ new = prepare_creds(); ++ if (!new) { ++ rc = -ENOMEM; ++ goto out; ++ } ++ tsp = new->security; + smk_destroy_label_list(&tsp->smk_relabel); + list_splice(&list_tmp, &tsp->smk_relabel); ++ commit_creds(new); + return count; + } +- ++out: + smk_destroy_label_list(&list_tmp); + return rc; + } +diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c +index cb23899100eed..8044775999eda 100644 +--- a/sound/core/seq/oss/seq_oss.c ++++ b/sound/core/seq/oss/seq_oss.c +@@ -180,10 +180,16 @@ static long + odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + { + struct seq_oss_devinfo *dp; ++ long rc; ++ + dp = file->private_data; + if (snd_BUG_ON(!dp)) + return -ENXIO; +- return snd_seq_oss_ioctl(dp, cmd, arg); ++ ++ mutex_lock(®ister_mutex); ++ rc = snd_seq_oss_ioctl(dp, cmd, arg); ++ mutex_unlock(®ister_mutex); ++ return rc; + } + + #ifdef CONFIG_COMPAT +diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c +index d73ee11a32bd0..db14ee43e461a 100644 +--- a/sound/pci/echoaudio/echoaudio.c ++++ b/sound/pci/echoaudio/echoaudio.c +@@ -2215,7 +2215,6 @@ static int snd_echo_resume(struct device *dev) + if (err < 0) { + kfree(commpage_bak); + dev_err(dev, "resume init_hw err=%d\n", err); +- snd_echo_free(chip); + return err; + } + +@@ -2242,7 +2241,6 @@ static int snd_echo_resume(struct device *dev) + if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, + KBUILD_MODNAME, chip)) { + dev_err(chip->card->dev, "cannot grab irq\n"); +- snd_echo_free(chip); + return -EBUSY; + } + chip->irq = pci->irq; +diff --git a/sound/usb/card.h b/sound/usb/card.h +index 71778ca4b26aa..b24f2efea1cb4 100644 +--- a/sound/usb/card.h ++++ b/sound/usb/card.h +@@ -125,6 +125,7 @@ struct snd_usb_substream { + unsigned int tx_length_quirk:1; /* add length specifier to transfers */ + unsigned int fmt_type; /* USB audio format type (1-3) */ + unsigned int pkt_offset_adj; /* Bytes to drop from beginning of packets (for non-compliant devices) */ ++ unsigned int stream_offset_adj; /* Bytes to drop from beginning of stream (for non-compliant devices) */ + + unsigned int running: 1; /* running status */ + +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c +index 9646513f4b4ad..d0cd3ae0804d8 100644 +--- a/sound/usb/mixer_quirks.c ++++ b/sound/usb/mixer_quirks.c +@@ -195,6 +195,7 @@ static const struct rc_config { + { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */ + { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ + { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ ++ { USB_ID(0x041e, 0x3263), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ + { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ + }; + +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c +index f84c55ecd0fb4..c97d9a537f763 100644 +--- a/sound/usb/pcm.c ++++ b/sound/usb/pcm.c +@@ -1302,6 +1302,12 @@ static void retire_capture_urb(struct snd_usb_substream *subs, + // continue; + } + bytes = urb->iso_frame_desc[i].actual_length; ++ if (subs->stream_offset_adj > 0) { ++ unsigned int adj = min(subs->stream_offset_adj, bytes); ++ cp += adj; ++ bytes -= adj; ++ subs->stream_offset_adj -= adj; ++ } + frames = bytes / stride; + if (!subs->txfr_quirk) + bytes = frames * stride; +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h +index ec56ce3820619..689fd3103e5b6 100644 +--- a/sound/usb/quirks-table.h ++++ b/sound/usb/quirks-table.h +@@ -3335,7 +3335,13 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), + * with. + */ + { +- USB_DEVICE(0x534d, 0x2109), ++ .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ++ USB_DEVICE_ID_MATCH_INT_CLASS | ++ USB_DEVICE_ID_MATCH_INT_SUBCLASS, ++ .idVendor = 0x534d, ++ .idProduct = 0x2109, ++ .bInterfaceClass = USB_CLASS_AUDIO, ++ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + .vendor_name = "MacroSilicon", + .product_name = "MS2109", +@@ -3374,5 +3380,61 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), + } + } + }, ++{ ++ /* ++ * PIONEER DJ DDJ-RB ++ * PCM is 4 channels out, 2 dummy channels in @ 44.1 fixed ++ * The feedback for the output is the dummy input. ++ */ ++ USB_DEVICE_VENDOR_SPEC(0x2b73, 0x000e), ++ .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_FIXED_ENDPOINT, ++ .data = &(const struct audioformat) { ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE, ++ .channels = 4, ++ .iface = 0, ++ .altsetting = 1, ++ .altset_idx = 1, ++ .endpoint = 0x01, ++ .ep_attr = USB_ENDPOINT_XFER_ISOC| ++ USB_ENDPOINT_SYNC_ASYNC, ++ .rates = SNDRV_PCM_RATE_44100, ++ .rate_min = 44100, ++ .rate_max = 44100, ++ .nr_rates = 1, ++ .rate_table = (unsigned int[]) { 44100 } ++ } ++ }, ++ { ++ .ifnum = 0, ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT, ++ .data = &(const struct audioformat) { ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE, ++ .channels = 2, ++ .iface = 0, ++ .altsetting = 1, ++ .altset_idx = 1, ++ .endpoint = 0x82, ++ .ep_attr = USB_ENDPOINT_XFER_ISOC| ++ USB_ENDPOINT_SYNC_ASYNC| ++ USB_ENDPOINT_USAGE_IMPLICIT_FB, ++ .rates = SNDRV_PCM_RATE_44100, ++ .rate_min = 44100, ++ .rate_max = 44100, ++ .nr_rates = 1, ++ .rate_table = (unsigned int[]) { 44100 } ++ } ++ }, ++ { ++ .ifnum = -1 ++ } ++ } ++ } ++}, + + #undef USB_DEVICE_VENDOR_SPEC +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index 47979c9c3e290..59529a9cab614 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1122,6 +1122,9 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs, + case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */ + set_format_emu_quirk(subs, fmt); + break; ++ case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */ ++ subs->stream_offset_adj = 2; ++ break; + } + } + +diff --git a/sound/usb/stream.c b/sound/usb/stream.c +index 3b23102230c03..1ffc32fd3a9eb 100644 +--- a/sound/usb/stream.c ++++ b/sound/usb/stream.c +@@ -95,6 +95,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as, + subs->tx_length_quirk = as->chip->tx_length_quirk; + subs->speed = snd_usb_get_speed(subs->dev); + subs->pkt_offset_adj = 0; ++ subs->stream_offset_adj = 0; + + snd_usb_set_pcm_ops(as->pcm, stream); + +diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c +index 9954b069b3ca2..86455408c7e12 100644 +--- a/tools/lib/traceevent/event-parse.c ++++ b/tools/lib/traceevent/event-parse.c +@@ -2752,6 +2752,7 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg, + if (read_expected(EVENT_DELIM, ")") < 0) + goto out_err; + ++ free_token(token); + type = read_token(&token); + *tok = token; + diff --git a/patch/kernel/rockpis-legacy/patch-4.4.233-234.patch b/patch/kernel/rockpis-legacy/patch-4.4.233-234.patch new file mode 100644 index 000000000..2762e22cc --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.233-234.patch @@ -0,0 +1,934 @@ +diff --git a/Makefile b/Makefile +index 8f363a3bcaf81..573b646a19936 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 233 ++SUBLEVEL = 234 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h +index ff4049155c840..355aec0867f4d 100644 +--- a/arch/alpha/include/asm/io.h ++++ b/arch/alpha/include/asm/io.h +@@ -491,10 +491,10 @@ extern inline void writeq(u64 b, volatile void __iomem *addr) + } + #endif + +-#define ioread16be(p) be16_to_cpu(ioread16(p)) +-#define ioread32be(p) be32_to_cpu(ioread32(p)) +-#define iowrite16be(v,p) iowrite16(cpu_to_be16(v), (p)) +-#define iowrite32be(v,p) iowrite32(cpu_to_be32(v), (p)) ++#define ioread16be(p) swab16(ioread16(p)) ++#define ioread32be(p) swab32(ioread32(p)) ++#define iowrite16be(v,p) iowrite16(swab16(v), (p)) ++#define iowrite32be(v,p) iowrite32(swab32(v), (p)) + + #define inb_p inb + #define inw_p inw +diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c +index e0267532bd4e0..edd392fdc14bb 100644 +--- a/arch/arm/kvm/mmu.c ++++ b/arch/arm/kvm/mmu.c +@@ -300,14 +300,6 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp, + next = kvm_pgd_addr_end(addr, end); + if (!pgd_none(*pgd)) + unmap_puds(kvm, pgd, addr, next); +- /* +- * If we are dealing with a large range in +- * stage2 table, release the kvm->mmu_lock +- * to prevent starvation and lockup detector +- * warnings. +- */ +- if (kvm && (next != end)) +- cond_resched_lock(&kvm->mmu_lock); + } while (pgd++, addr = next, addr != end); + } + +diff --git a/arch/m68k/include/asm/m53xxacr.h b/arch/m68k/include/asm/m53xxacr.h +index 3177ce8331d69..baee0c77b9818 100644 +--- a/arch/m68k/include/asm/m53xxacr.h ++++ b/arch/m68k/include/asm/m53xxacr.h +@@ -88,9 +88,9 @@ + * coherency though in all cases. And for copyback caches we will need + * to push cached data as well. + */ +-#define CACHE_INIT CACR_CINVA +-#define CACHE_INVALIDATE CACR_CINVA +-#define CACHE_INVALIDATED CACR_CINVA ++#define CACHE_INIT (CACHE_MODE + CACR_CINVA - CACR_EC) ++#define CACHE_INVALIDATE (CACHE_MODE + CACR_CINVA) ++#define CACHE_INVALIDATED (CACHE_MODE + CACR_CINVA) + + #define ACR0_MODE ((CONFIG_RAMBASE & 0xff000000) + \ + (0x000f0000) + \ +diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c +index d1f860ca03ade..101c202c813c8 100644 +--- a/arch/powerpc/mm/fault.c ++++ b/arch/powerpc/mm/fault.c +@@ -192,6 +192,9 @@ static int mm_fault_error(struct pt_regs *regs, unsigned long addr, int fault) + return MM_FAULT_CONTINUE; + } + ++// This comes from 64-bit struct rt_sigframe + __SIGNAL_FRAMESIZE ++#define SIGFRAME_MAX_SIZE (4096 + 128) ++ + /* + * For 600- and 800-family processors, the error_code parameter is DSISR + * for a data fault, SRR1 for an instruction fault. For 400-family processors +@@ -341,7 +344,7 @@ retry: + /* + * N.B. The POWER/Open ABI allows programs to access up to + * 288 bytes below the stack pointer. +- * The kernel signal delivery code writes up to about 1.5kB ++ * The kernel signal delivery code writes up to about 4kB + * below the stack pointer (r1) before decrementing it. + * The exec code can write slightly over 640kB to the stack + * before setting the user r1. Thus we allow the stack to +@@ -365,7 +368,7 @@ retry: + * between the last mapped region and the stack will + * expand the stack rather than segfaulting. + */ +- if (address + 2048 < uregs->gpr[1] && !store_update_sp) ++ if (address + SIGFRAME_MAX_SIZE < uregs->gpr[1] && !store_update_sp) + goto bad_area; + } + if (expand_stack(vma, address)) +diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c +index 31ca56e593f58..b9dc2ef64ed88 100644 +--- a/drivers/gpu/drm/imx/imx-ldb.c ++++ b/drivers/gpu/drm/imx/imx-ldb.c +@@ -305,6 +305,7 @@ static void imx_ldb_encoder_disable(struct drm_encoder *encoder) + { + struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); + struct imx_ldb *ldb = imx_ldb_ch->ldb; ++ int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; + int mux, ret; + + /* +@@ -321,14 +322,14 @@ static void imx_ldb_encoder_disable(struct drm_encoder *encoder) + + drm_panel_disable(imx_ldb_ch->panel); + +- if (imx_ldb_ch == &ldb->channel[0]) ++ if (imx_ldb_ch == &ldb->channel[0] || dual) + ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK; +- else if (imx_ldb_ch == &ldb->channel[1]) ++ if (imx_ldb_ch == &ldb->channel[1] || dual) + ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK; + + regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl); + +- if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) { ++ if (dual) { + clk_disable_unprepare(ldb->clk[0]); + clk_disable_unprepare(ldb->clk[1]); + } +diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c +index ad18dab0ac476..5bd9633541b07 100644 +--- a/drivers/input/mouse/psmouse-base.c ++++ b/drivers/input/mouse/psmouse-base.c +@@ -1911,7 +1911,7 @@ static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp) + { + int type = *((unsigned int *)kp->arg); + +- return sprintf(buffer, "%s", psmouse_protocol_by_type(type)->name); ++ return sprintf(buffer, "%s\n", psmouse_protocol_by_type(type)->name); + } + + static int __init psmouse_init(void) +diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c +index e9674b40007c1..6107c469efa07 100644 +--- a/drivers/media/pci/ttpci/budget-core.c ++++ b/drivers/media/pci/ttpci/budget-core.c +@@ -386,20 +386,25 @@ static int budget_register(struct budget *budget) + ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->hw_frontend); + + if (ret < 0) +- return ret; ++ goto err_release_dmx; + + budget->mem_frontend.source = DMX_MEMORY_FE; + ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->mem_frontend); + if (ret < 0) +- return ret; ++ goto err_release_dmx; + + ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &budget->hw_frontend); + if (ret < 0) +- return ret; ++ goto err_release_dmx; + + dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx); + + return 0; ++ ++err_release_dmx: ++ dvb_dmxdev_release(&budget->dmxdev); ++ dvb_dmx_release(&budget->demux); ++ return ret; + } + + static void budget_unregister(struct budget *budget) +diff --git a/drivers/media/platform/davinci/vpss.c b/drivers/media/platform/davinci/vpss.c +index c2c68988e38ac..9884b34d6f406 100644 +--- a/drivers/media/platform/davinci/vpss.c ++++ b/drivers/media/platform/davinci/vpss.c +@@ -519,19 +519,31 @@ static void vpss_exit(void) + + static int __init vpss_init(void) + { ++ int ret; ++ + if (!request_mem_region(VPSS_CLK_CTRL, 4, "vpss_clock_control")) + return -EBUSY; + + oper_cfg.vpss_regs_base2 = ioremap(VPSS_CLK_CTRL, 4); + if (unlikely(!oper_cfg.vpss_regs_base2)) { +- release_mem_region(VPSS_CLK_CTRL, 4); +- return -ENOMEM; ++ ret = -ENOMEM; ++ goto err_ioremap; + } + + writel(VPSS_CLK_CTRL_VENCCLKEN | +- VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2); ++ VPSS_CLK_CTRL_DACCLKEN, oper_cfg.vpss_regs_base2); ++ ++ ret = platform_driver_register(&vpss_driver); ++ if (ret) ++ goto err_pd_register; ++ ++ return 0; + +- return platform_driver_register(&vpss_driver); ++err_pd_register: ++ iounmap(oper_cfg.vpss_regs_base2); ++err_ioremap: ++ release_mem_region(VPSS_CLK_CTRL, 4); ++ return ret; + } + subsys_initcall(vpss_init); + module_exit(vpss_exit); +diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c +index 880a9068ca126..ef06af4e3611d 100644 +--- a/drivers/scsi/libfc/fc_disc.c ++++ b/drivers/scsi/libfc/fc_disc.c +@@ -595,8 +595,12 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, + mutex_lock(&disc->disc_mutex); + if (PTR_ERR(fp) == -FC_EX_CLOSED) + goto out; +- if (IS_ERR(fp)) +- goto redisc; ++ if (IS_ERR(fp)) { ++ mutex_lock(&disc->disc_mutex); ++ fc_disc_restart(disc); ++ mutex_unlock(&disc->disc_mutex); ++ goto out; ++ } + + cp = fc_frame_payload_get(fp, sizeof(*cp)); + if (!cp) +@@ -621,7 +625,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, + new_rdata->disc_id = disc->disc_id; + lport->tt.rport_login(new_rdata); + } +- goto out; ++ goto free_fp; + } + rdata->disc_id = disc->disc_id; + lport->tt.rport_login(rdata); +@@ -635,6 +639,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, + redisc: + fc_disc_restart(disc); + } ++free_fp: ++ fc_frame_free(fp); + out: + mutex_unlock(&disc->disc_mutex); + kref_put(&rdata->kref, lport->tt.rport_destroy); +diff --git a/drivers/video/fbdev/omap2/dss/dss.c b/drivers/video/fbdev/omap2/dss/dss.c +index 9200a8668b498..a57c3a5f4bf8b 100644 +--- a/drivers/video/fbdev/omap2/dss/dss.c ++++ b/drivers/video/fbdev/omap2/dss/dss.c +@@ -843,7 +843,7 @@ static const struct dss_features omap34xx_dss_feats = { + }; + + static const struct dss_features omap3630_dss_feats = { +- .fck_div_max = 32, ++ .fck_div_max = 31, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll4_ck", + .dpi_select_source = &dss_dpi_select_source_omap2_omap3, +diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c +index a01a41a412693..6b3565feddb21 100644 +--- a/drivers/virtio/virtio_ring.c ++++ b/drivers/virtio/virtio_ring.c +@@ -603,6 +603,9 @@ bool virtqueue_poll(struct virtqueue *_vq, unsigned last_used_idx) + { + struct vring_virtqueue *vq = to_vvq(_vq); + ++ if (unlikely(vq->broken)) ++ return false; ++ + virtio_mb(vq->weak_barriers); + return (u16)last_used_idx != virtio16_to_cpu(_vq->vdev, vq->vring.used->idx); + } +diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c +index 2048aad91add8..2b12ef019ae02 100644 +--- a/drivers/watchdog/f71808e_wdt.c ++++ b/drivers/watchdog/f71808e_wdt.c +@@ -642,9 +642,9 @@ static int __init watchdog_init(int sioaddr) + * into the module have been registered yet. + */ + watchdog.sioaddr = sioaddr; +- watchdog.ident.options = WDIOC_SETTIMEOUT +- | WDIOF_MAGICCLOSE +- | WDIOF_KEEPALIVEPING; ++ watchdog.ident.options = WDIOF_MAGICCLOSE ++ | WDIOF_KEEPALIVEPING ++ | WDIOF_CARDRESET; + + snprintf(watchdog.ident.identity, + sizeof(watchdog.ident.identity), "%s watchdog", +diff --git a/drivers/xen/preempt.c b/drivers/xen/preempt.c +index 5f6b77ea34fb5..128375ff80b8c 100644 +--- a/drivers/xen/preempt.c ++++ b/drivers/xen/preempt.c +@@ -31,7 +31,7 @@ EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall); + asmlinkage __visible void xen_maybe_preempt_hcall(void) + { + if (unlikely(__this_cpu_read(xen_in_preemptible_hcall) +- && need_resched())) { ++ && need_resched() && !preempt_count())) { + /* + * Clear flag as we may be rescheduled on a different + * cpu. +diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h +index 0b06d4942da77..8fb9a1e0048be 100644 +--- a/fs/btrfs/ctree.h ++++ b/fs/btrfs/ctree.h +@@ -4096,6 +4096,8 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); + /* super.c */ + int btrfs_parse_options(struct btrfs_root *root, char *options); + int btrfs_sync_fs(struct super_block *sb, int wait); ++char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info, ++ u64 subvol_objectid); + + #ifdef CONFIG_PRINTK + __printf(2, 3) +diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c +index 2513a7f533342..92f80ed642194 100644 +--- a/fs/btrfs/export.c ++++ b/fs/btrfs/export.c +@@ -55,9 +55,9 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len, + return type; + } + +-static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, +- u64 root_objectid, u32 generation, +- int check_generation) ++struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, ++ u64 root_objectid, u32 generation, ++ int check_generation) + { + struct btrfs_fs_info *fs_info = btrfs_sb(sb); + struct btrfs_root *root; +@@ -150,7 +150,7 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh, + return btrfs_get_dentry(sb, objectid, root_objectid, generation, 1); + } + +-static struct dentry *btrfs_get_parent(struct dentry *child) ++struct dentry *btrfs_get_parent(struct dentry *child) + { + struct inode *dir = d_inode(child); + struct btrfs_root *root = BTRFS_I(dir)->root; +diff --git a/fs/btrfs/export.h b/fs/btrfs/export.h +index 074348a95841f..7a305e5549991 100644 +--- a/fs/btrfs/export.h ++++ b/fs/btrfs/export.h +@@ -16,4 +16,9 @@ struct btrfs_fid { + u64 parent_root_objectid; + } __attribute__ ((packed)); + ++struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, ++ u64 root_objectid, u32 generation, ++ int check_generation); ++struct dentry *btrfs_get_parent(struct dentry *child); ++ + #endif +diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c +index 404051bf5cba9..77e6ce0e1e351 100644 +--- a/fs/btrfs/super.c ++++ b/fs/btrfs/super.c +@@ -843,8 +843,8 @@ out: + return error; + } + +-static char *get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info, +- u64 subvol_objectid) ++char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info, ++ u64 subvol_objectid) + { + struct btrfs_root *root = fs_info->tree_root; + struct btrfs_root *fs_root; +@@ -1120,6 +1120,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) + struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb); + struct btrfs_root *root = info->tree_root; + char *compress_type; ++ const char *subvol_name; + + if (btrfs_test_opt(root, DEGRADED)) + seq_puts(seq, ",degraded"); +@@ -1204,8 +1205,13 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) + #endif + seq_printf(seq, ",subvolid=%llu", + BTRFS_I(d_inode(dentry))->root->root_key.objectid); +- seq_puts(seq, ",subvol="); +- seq_dentry(seq, dentry, " \t\n\\"); ++ subvol_name = btrfs_get_subvol_name_from_objectid(info, ++ BTRFS_I(d_inode(dentry))->root->root_key.objectid); ++ if (!IS_ERR(subvol_name)) { ++ seq_puts(seq, ",subvol="); ++ seq_escape(seq, subvol_name, " \t\n\\"); ++ kfree(subvol_name); ++ } + return 0; + } + +@@ -1323,8 +1329,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid, + goto out; + } + } +- subvol_name = get_subvol_name_from_objectid(btrfs_sb(mnt->mnt_sb), +- subvol_objectid); ++ subvol_name = btrfs_get_subvol_name_from_objectid( ++ btrfs_sb(mnt->mnt_sb), subvol_objectid); + if (IS_ERR(subvol_name)) { + root = ERR_CAST(subvol_name); + subvol_name = NULL; +diff --git a/fs/eventpoll.c b/fs/eventpoll.c +index 240d9ceb8d0c6..b8959d0d4c723 100644 +--- a/fs/eventpoll.c ++++ b/fs/eventpoll.c +@@ -1719,9 +1719,11 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) + * not already there, and calling reverse_path_check() + * during ep_insert(). + */ +- if (list_empty(&epi->ffd.file->f_tfile_llink)) ++ if (list_empty(&epi->ffd.file->f_tfile_llink)) { ++ get_file(epi->ffd.file); + list_add(&epi->ffd.file->f_tfile_llink, + &tfile_check_list); ++ } + } + } + mutex_unlock(&ep->mtx); +@@ -1765,6 +1767,7 @@ static void clear_tfile_check_list(void) + file = list_first_entry(&tfile_check_list, struct file, + f_tfile_llink); + list_del_init(&file->f_tfile_llink); ++ fput(file); + } + INIT_LIST_HEAD(&tfile_check_list); + } +@@ -1902,13 +1905,13 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, + mutex_lock(&epmutex); + if (is_file_epoll(tf.file)) { + error = -ELOOP; +- if (ep_loop_check(ep, tf.file) != 0) { +- clear_tfile_check_list(); ++ if (ep_loop_check(ep, tf.file) != 0) + goto error_tgt_fput; +- } +- } else ++ } else { ++ get_file(tf.file); + list_add(&tf.file->f_tfile_llink, + &tfile_check_list); ++ } + mutex_lock_nested(&ep->mtx, 0); + if (is_file_epoll(tf.file)) { + tep = tf.file->private_data; +@@ -1932,8 +1935,6 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, + error = ep_insert(ep, &epds, tf.file, fd, full_check); + } else + error = -EEXIST; +- if (full_check) +- clear_tfile_check_list(); + break; + case EPOLL_CTL_DEL: + if (epi) +@@ -1954,8 +1955,10 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, + mutex_unlock(&ep->mtx); + + error_tgt_fput: +- if (full_check) ++ if (full_check) { ++ clear_tfile_check_list(); + mutex_unlock(&epmutex); ++ } + + fdput(tf); + error_fput: +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c +index 566a8b08ccdd6..061b026e464c5 100644 +--- a/fs/ext4/namei.c ++++ b/fs/ext4/namei.c +@@ -1226,19 +1226,18 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block) + } + + /* +- * NOTE! unlike strncmp, ext4_match returns 1 for success, 0 for failure. ++ * Test whether a directory entry matches the filename being searched for. + * +- * `len <= EXT4_NAME_LEN' is guaranteed by caller. +- * `de != NULL' is guaranteed by caller. ++ * Return: %true if the directory entry matches, otherwise %false. + */ +-static inline int ext4_match(struct ext4_filename *fname, +- struct ext4_dir_entry_2 *de) ++static inline bool ext4_match(const struct ext4_filename *fname, ++ const struct ext4_dir_entry_2 *de) + { + const void *name = fname_name(fname); + u32 len = fname_len(fname); + + if (!de->inode) +- return 0; ++ return false; + + #ifdef CONFIG_EXT4_FS_ENCRYPTION + if (unlikely(!name)) { +@@ -1270,48 +1269,31 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, + struct ext4_dir_entry_2 * de; + char * dlimit; + int de_len; +- int res; + + de = (struct ext4_dir_entry_2 *)search_buf; + dlimit = search_buf + buf_size; + while ((char *) de < dlimit) { + /* this code is executed quadratically often */ + /* do minimal checking `by hand' */ +- if ((char *) de + de->name_len <= dlimit) { +- res = ext4_match(fname, de); +- if (res < 0) { +- res = -1; +- goto return_result; +- } +- if (res > 0) { +- /* found a match - just to be sure, do +- * a full check */ +- if (ext4_check_dir_entry(dir, NULL, de, bh, +- bh->b_data, +- bh->b_size, offset)) { +- res = -1; +- goto return_result; +- } +- *res_dir = de; +- res = 1; +- goto return_result; +- } +- ++ if ((char *) de + de->name_len <= dlimit && ++ ext4_match(fname, de)) { ++ /* found a match - just to be sure, do ++ * a full check */ ++ if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf, ++ buf_size, offset)) ++ return -1; ++ *res_dir = de; ++ return 1; + } + /* prevent looping on a bad block */ + de_len = ext4_rec_len_from_disk(de->rec_len, + dir->i_sb->s_blocksize); +- if (de_len <= 0) { +- res = -1; +- goto return_result; +- } ++ if (de_len <= 0) ++ return -1; + offset += de_len; + de = (struct ext4_dir_entry_2 *) ((char *) de + de_len); + } +- +- res = 0; +-return_result: +- return res; ++ return 0; + } + + static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block, +@@ -1748,7 +1730,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, + blocksize, hinfo, map); + map -= count; + dx_sort_map(map, count); +- /* Split the existing block in the middle, size-wise */ ++ /* Ensure that neither split block is over half full */ + size = 0; + move = 0; + for (i = count-1; i >= 0; i--) { +@@ -1758,8 +1740,18 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, + size += map[i].size; + move++; + } +- /* map index at which we will split */ +- split = count - move; ++ /* ++ * map index at which we will split ++ * ++ * If the sum of active entries didn't exceed half the block size, just ++ * split it in half by count; each resulting block will have at least ++ * half the space free. ++ */ ++ if (i > 0) ++ split = count - move; ++ else ++ split = count/2; ++ + hash2 = map[split].hash; + continued = hash2 == map[split - 1].hash; + dxtrace(printk(KERN_INFO "Split block %lu at %x, %i/%i\n", +@@ -1824,24 +1816,15 @@ int ext4_find_dest_de(struct inode *dir, struct inode *inode, + int nlen, rlen; + unsigned int offset = 0; + char *top; +- int res; + + de = (struct ext4_dir_entry_2 *)buf; + top = buf + buf_size - reclen; + while ((char *) de <= top) { + if (ext4_check_dir_entry(dir, NULL, de, bh, +- buf, buf_size, offset)) { +- res = -EFSCORRUPTED; +- goto return_result; +- } +- /* Provide crypto context and crypto buffer to ext4 match */ +- res = ext4_match(fname, de); +- if (res < 0) +- goto return_result; +- if (res > 0) { +- res = -EEXIST; +- goto return_result; +- } ++ buf, buf_size, offset)) ++ return -EFSCORRUPTED; ++ if (ext4_match(fname, de)) ++ return -EEXIST; + nlen = EXT4_DIR_REC_LEN(de->name_len); + rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); + if ((de->inode ? rlen - nlen : rlen) >= reclen) +@@ -1849,15 +1832,11 @@ int ext4_find_dest_de(struct inode *dir, struct inode *inode, + de = (struct ext4_dir_entry_2 *)((char *)de + rlen); + offset += rlen; + } +- + if ((char *) de > top) +- res = -ENOSPC; +- else { +- *dest_de = de; +- res = 0; +- } +-return_result: +- return res; ++ return -ENOSPC; ++ ++ *dest_de = de; ++ return 0; + } + + int ext4_insert_dentry(struct inode *dir, +@@ -2343,7 +2322,7 @@ int ext4_generic_delete_entry(handle_t *handle, + de = (struct ext4_dir_entry_2 *)entry_buf; + while (i < buf_size - csum_size) { + if (ext4_check_dir_entry(dir, NULL, de, bh, +- bh->b_data, bh->b_size, i)) ++ entry_buf, buf_size, i)) + return -EFSCORRUPTED; + if (de == de_del) { + if (pde) +diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c +index e273171696972..7a3368929245d 100644 +--- a/fs/jffs2/dir.c ++++ b/fs/jffs2/dir.c +@@ -588,10 +588,14 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) + int ret; + uint32_t now = get_seconds(); + ++ mutex_lock(&f->sem); + for (fd = f->dents ; fd; fd = fd->next) { +- if (fd->ino) ++ if (fd->ino) { ++ mutex_unlock(&f->sem); + return -ENOTEMPTY; ++ } + } ++ mutex_unlock(&f->sem); + + ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, + dentry->d_name.len, f, now); +diff --git a/fs/romfs/storage.c b/fs/romfs/storage.c +index f86f51f99aceb..1dcadd22b440d 100644 +--- a/fs/romfs/storage.c ++++ b/fs/romfs/storage.c +@@ -221,10 +221,8 @@ int romfs_dev_read(struct super_block *sb, unsigned long pos, + size_t limit; + + limit = romfs_maxsize(sb); +- if (pos >= limit) ++ if (pos >= limit || buflen > limit - pos) + return -EIO; +- if (buflen > limit - pos) +- buflen = limit - pos; + + #ifdef CONFIG_ROMFS_ON_MTD + if (sb->s_mtd) +diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h +index be692e59938db..c457b010c623d 100644 +--- a/fs/xfs/xfs_sysfs.h ++++ b/fs/xfs/xfs_sysfs.h +@@ -44,9 +44,11 @@ xfs_sysfs_init( + struct xfs_kobj *parent_kobj, + const char *name) + { ++ struct kobject *parent; ++ ++ parent = parent_kobj ? &parent_kobj->kobject : NULL; + init_completion(&kobj->complete); +- return kobject_init_and_add(&kobj->kobject, ktype, +- &parent_kobj->kobject, "%s", name); ++ return kobject_init_and_add(&kobj->kobject, ktype, parent, "%s", name); + } + + static inline void +diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c +index ce78534a047ee..bb8de2dddabe2 100644 +--- a/fs/xfs/xfs_trans_dquot.c ++++ b/fs/xfs/xfs_trans_dquot.c +@@ -662,7 +662,7 @@ xfs_trans_dqresv( + } + } + if (ninos > 0) { +- total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos; ++ total_count = dqp->q_res_icount + ninos; + timer = be32_to_cpu(dqp->q_core.d_itimer); + warns = be16_to_cpu(dqp->q_core.d_iwarns); + warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit; +diff --git a/include/linux/mm.h b/include/linux/mm.h +index 03cf5526e4456..2b17d2fca4299 100644 +--- a/include/linux/mm.h ++++ b/include/linux/mm.h +@@ -1123,6 +1123,10 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, + * followed by taking the mmap_sem for writing before modifying the + * vmas or anything the coredump pretends not to change from under it. + * ++ * It also has to be called when mmgrab() is used in the context of ++ * the process, but then the mm_count refcount is transferred outside ++ * the context of the process to run down_write() on that pinned mm. ++ * + * NOTE: find_extend_vma() called from GUP context is the only place + * that can modify the "mm" (notably the vm_start/end) under mmap_sem + * for reading and outside the context of the process, so it is also +diff --git a/include/net/sock.h b/include/net/sock.h +index 426a57874964c..31198b32d9122 100644 +--- a/include/net/sock.h ++++ b/include/net/sock.h +@@ -779,6 +779,8 @@ static inline int sk_memalloc_socks(void) + { + return static_key_false(&memalloc_socks); + } ++ ++void __receive_sock(struct file *file); + #else + + static inline int sk_memalloc_socks(void) +@@ -786,6 +788,8 @@ static inline int sk_memalloc_socks(void) + return 0; + } + ++static inline void __receive_sock(struct file *file) ++{ } + #endif + + static inline gfp_t sk_gfp_atomic(const struct sock *sk, gfp_t gfp_mask) +diff --git a/mm/huge_memory.c b/mm/huge_memory.c +index 465786cd6490e..f38d24bb8a1bc 100644 +--- a/mm/huge_memory.c ++++ b/mm/huge_memory.c +@@ -2136,7 +2136,7 @@ static void insert_to_mm_slots_hash(struct mm_struct *mm, + + static inline int khugepaged_test_exit(struct mm_struct *mm) + { +- return atomic_read(&mm->mm_users) == 0; ++ return atomic_read(&mm->mm_users) == 0 || !mmget_still_valid(mm); + } + + int __khugepaged_enter(struct mm_struct *mm) +@@ -2149,7 +2149,7 @@ int __khugepaged_enter(struct mm_struct *mm) + return -ENOMEM; + + /* __khugepaged_exit() must not run from under us */ +- VM_BUG_ON_MM(khugepaged_test_exit(mm), mm); ++ VM_BUG_ON_MM(atomic_read(&mm->mm_users) == 0, mm); + if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags))) { + free_mm_slot(mm_slot); + return 0; +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index 3a1501e854832..baac9a09ec0a1 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -4257,6 +4257,7 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) + return false; + } + ++#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a)) + /* + * Determine if start,end range within vma could be mapped by shared pmd. + * If yes, adjust start and end to cover range associated with possible +@@ -4265,25 +4266,21 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) + void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, + unsigned long *start, unsigned long *end) + { +- unsigned long check_addr = *start; ++ unsigned long a_start, a_end; + + if (!(vma->vm_flags & VM_MAYSHARE)) + return; + +- for (check_addr = *start; check_addr < *end; check_addr += PUD_SIZE) { +- unsigned long a_start = check_addr & PUD_MASK; +- unsigned long a_end = a_start + PUD_SIZE; ++ /* Extend the range to be PUD aligned for a worst case scenario */ ++ a_start = ALIGN_DOWN(*start, PUD_SIZE); ++ a_end = ALIGN(*end, PUD_SIZE); + +- /* +- * If sharing is possible, adjust start/end if necessary. +- */ +- if (range_in_vma(vma, a_start, a_end)) { +- if (a_start < *start) +- *start = a_start; +- if (a_end > *end) +- *end = a_end; +- } +- } ++ /* ++ * Intersect the range with the vma range, since pmd sharing won't be ++ * across vma after all ++ */ ++ *start = max(vma->vm_start, a_start); ++ *end = min(vma->vm_end, a_end); + } + + /* +diff --git a/mm/page_alloc.c b/mm/page_alloc.c +index df589416ace6c..14bab5fa1b656 100644 +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -843,6 +843,11 @@ static void free_pcppages_bulk(struct zone *zone, int count, + if (nr_scanned) + __mod_zone_page_state(zone, NR_PAGES_SCANNED, -nr_scanned); + ++ /* ++ * Ensure proper count is passed which otherwise would stuck in the ++ * below while (list_empty(list)) loop. ++ */ ++ count = min(pcp->count, count); + while (to_free) { + struct page *page; + struct list_head *list; +@@ -6285,7 +6290,7 @@ int __meminit init_per_zone_wmark_min(void) + setup_per_zone_inactive_ratio(); + return 0; + } +-core_initcall(init_per_zone_wmark_min) ++postcore_initcall(init_per_zone_wmark_min) + + /* + * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so +diff --git a/net/compat.c b/net/compat.c +index d676840104556..20c5e5f215f23 100644 +--- a/net/compat.c ++++ b/net/compat.c +@@ -284,6 +284,7 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm) + break; + } + /* Bump the usage count and install the file. */ ++ __receive_sock(fp[i]); + fd_install(new_fd, get_file(fp[i])); + } + +diff --git a/net/core/sock.c b/net/core/sock.c +index 120d5058d81ae..82f9a7dbea6fe 100644 +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2275,6 +2275,27 @@ int sock_no_mmap(struct file *file, struct socket *sock, struct vm_area_struct * + } + EXPORT_SYMBOL(sock_no_mmap); + ++/* ++ * When a file is received (via SCM_RIGHTS, etc), we must bump the ++ * various sock-based usage counts. ++ */ ++void __receive_sock(struct file *file) ++{ ++ struct socket *sock; ++ int error; ++ ++ /* ++ * The resulting value of "error" is ignored here since we only ++ * need to take action when the file is a socket and testing ++ * "sock" for NULL is sufficient. ++ */ ++ sock = sock_from_file(file, &error); ++ if (sock) { ++ sock_update_netprioidx(sock->sk); ++ sock_update_classid(sock->sk); ++ } ++} ++ + ssize_t sock_no_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags) + { + ssize_t res; +diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c +index 1d9dfb92b3b48..edb244331e6e9 100644 +--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c ++++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c +@@ -338,7 +338,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, + + ret_val = power_up_sst(stream); + if (ret_val < 0) +- return ret_val; ++ goto out_power_up; + + /* Make sure, that the period size is always even */ + snd_pcm_hw_constraint_step(substream->runtime, 0, +@@ -347,8 +347,9 @@ static int sst_media_open(struct snd_pcm_substream *substream, + return snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + out_ops: +- kfree(stream); + mutex_unlock(&sst_lock); ++out_power_up: ++ kfree(stream); + return ret_val; + } + +diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c +index c694f10d004cc..1b73537af91db 100644 +--- a/tools/perf/util/probe-finder.c ++++ b/tools/perf/util/probe-finder.c +@@ -1274,7 +1274,7 @@ int debuginfo__find_trace_events(struct debuginfo *dbg, + tf.ntevs = 0; + + ret = debuginfo__find_probes(dbg, &tf.pf); +- if (ret < 0) { ++ if (ret < 0 || tf.ntevs == 0) { + for (i = 0; i < tf.ntevs; i++) + clear_probe_trace_event(&tf.tevs[i]); + zfree(tevs); diff --git a/patch/kernel/rockpis-legacy/patch-4.4.234-235.patch b/patch/kernel/rockpis-legacy/patch-4.4.234-235.patch new file mode 100644 index 000000000..87c263d3d --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.234-235.patch @@ -0,0 +1,2129 @@ +diff --git a/Makefile b/Makefile +index 573b646a19936..a32490d4471f3 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 234 ++SUBLEVEL = 235 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c +index 530a36f465ced..afcc86726448e 100644 +--- a/arch/mips/vdso/genvdso.c ++++ b/arch/mips/vdso/genvdso.c +@@ -126,6 +126,7 @@ static void *map_vdso(const char *path, size_t *_size) + if (fstat(fd, &stat) != 0) { + fprintf(stderr, "%s: Failed to stat '%s': %s\n", program_name, + path, strerror(errno)); ++ close(fd); + return NULL; + } + +@@ -134,6 +135,7 @@ static void *map_vdso(const char *path, size_t *_size) + if (addr == MAP_FAILED) { + fprintf(stderr, "%s: Failed to map '%s': %s\n", program_name, + path, strerror(errno)); ++ close(fd); + return NULL; + } + +@@ -143,6 +145,7 @@ static void *map_vdso(const char *path, size_t *_size) + if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) { + fprintf(stderr, "%s: '%s' is not an ELF file\n", program_name, + path); ++ close(fd); + return NULL; + } + +@@ -154,6 +157,7 @@ static void *map_vdso(const char *path, size_t *_size) + default: + fprintf(stderr, "%s: '%s' has invalid ELF class\n", + program_name, path); ++ close(fd); + return NULL; + } + +@@ -165,6 +169,7 @@ static void *map_vdso(const char *path, size_t *_size) + default: + fprintf(stderr, "%s: '%s' has invalid ELF data order\n", + program_name, path); ++ close(fd); + return NULL; + } + +@@ -172,15 +177,18 @@ static void *map_vdso(const char *path, size_t *_size) + fprintf(stderr, + "%s: '%s' has invalid ELF machine (expected EM_MIPS)\n", + program_name, path); ++ close(fd); + return NULL; + } else if (swap_uint16(ehdr->e_type) != ET_DYN) { + fprintf(stderr, + "%s: '%s' has invalid ELF type (expected ET_DYN)\n", + program_name, path); ++ close(fd); + return NULL; + } + + *_size = stat.st_size; ++ close(fd); + return addr; + } + +@@ -284,10 +292,12 @@ int main(int argc, char **argv) + /* Calculate and write symbol offsets to */ + if (!get_symbols(dbg_vdso_path, dbg_vdso)) { + unlink(out_path); ++ fclose(out_file); + return EXIT_FAILURE; + } + + fprintf(out_file, "};\n"); ++ fclose(out_file); + + return EXIT_SUCCESS; + } +diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig +index 429fc59d2a476..9acca9c79ef62 100644 +--- a/arch/powerpc/platforms/cell/Kconfig ++++ b/arch/powerpc/platforms/cell/Kconfig +@@ -50,6 +50,7 @@ config SPU_FS + tristate "SPU file system" + default m + depends on PPC_CELL ++ depends on COREDUMP + select SPU_BASE + select MEMORY_HOTPLUG + help +diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c +index 9e817c1b78087..1fa8e492ce27d 100644 +--- a/arch/powerpc/platforms/pseries/ras.c ++++ b/arch/powerpc/platforms/pseries/ras.c +@@ -90,7 +90,6 @@ static void handle_system_shutdown(char event_modifier) + pr_emerg("Loss of power reported by firmware, system is " + "running on UPS/battery"); + pr_emerg("Check RTAS error log for details"); +- orderly_poweroff(true); + break; + + case EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS: +diff --git a/drivers/base/core.c b/drivers/base/core.c +index 64b59552e7444..ddc9dd971674c 100644 +--- a/drivers/base/core.c ++++ b/drivers/base/core.c +@@ -2344,17 +2344,21 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) + */ + void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) + { +- if (fwnode) { +- struct fwnode_handle *fn = dev->fwnode; ++ struct fwnode_handle *fn = dev->fwnode; + ++ if (fwnode) { + if (fwnode_is_primary(fn)) + fn = fn->secondary; + + fwnode->secondary = fn; + dev->fwnode = fwnode; + } else { +- dev->fwnode = fwnode_is_primary(dev->fwnode) ? +- dev->fwnode->secondary : NULL; ++ if (fwnode_is_primary(fn)) { ++ dev->fwnode = fn->secondary; ++ fn->secondary = NULL; ++ } else { ++ dev->fwnode = NULL; ++ } + } + } + EXPORT_SYMBOL_GPL(set_primary_fwnode); +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c +index 8efdb823826c8..79724fd0a8989 100644 +--- a/drivers/base/power/main.c ++++ b/drivers/base/power/main.c +@@ -1361,13 +1361,17 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) + } + + /* +- * If a device configured to wake up the system from sleep states +- * has been suspended at run time and there's a resume request pending +- * for it, this is equivalent to the device signaling wakeup, so the +- * system suspend operation should be aborted. ++ * Wait for possible runtime PM transitions of the device in progress ++ * to complete and if there's a runtime resume request pending for it, ++ * resume it before proceeding with invoking the system-wide suspend ++ * callbacks for it. ++ * ++ * If the system-wide suspend callbacks below change the configuration ++ * of the device, they must disable runtime PM for it or otherwise ++ * ensure that its runtime-resume callbacks will not be confused by that ++ * change in case they are invoked going forward. + */ +- if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) +- pm_wakeup_event(dev, 0); ++ pm_runtime_barrier(dev); + + if (pm_wakeup_pending()) { + dev->power.direct_complete = false; +diff --git a/drivers/edac/ie31200_edac.c b/drivers/edac/ie31200_edac.c +index 18d77ace4813c..30f83fb6b145a 100644 +--- a/drivers/edac/ie31200_edac.c ++++ b/drivers/edac/ie31200_edac.c +@@ -131,6 +131,8 @@ + #define IE31200_PAGES(n) (n << (28 - PAGE_SHIFT)) + + static int nr_channels; ++static struct pci_dev *mci_pdev; ++static int ie31200_registered = 1; + + struct ie31200_priv { + void __iomem *window; +@@ -456,12 +458,16 @@ fail_free: + static int ie31200_init_one(struct pci_dev *pdev, + const struct pci_device_id *ent) + { +- edac_dbg(0, "MC:\n"); ++ int rc; + ++ edac_dbg(0, "MC:\n"); + if (pci_enable_device(pdev) < 0) + return -EIO; ++ rc = ie31200_probe1(pdev, ent->driver_data); ++ if (rc == 0 && !mci_pdev) ++ mci_pdev = pci_dev_get(pdev); + +- return ie31200_probe1(pdev, ent->driver_data); ++ return rc; + } + + static void ie31200_remove_one(struct pci_dev *pdev) +@@ -470,6 +476,8 @@ static void ie31200_remove_one(struct pci_dev *pdev) + struct ie31200_priv *priv; + + edac_dbg(0, "\n"); ++ pci_dev_put(mci_pdev); ++ mci_pdev = NULL; + mci = edac_mc_del_mc(&pdev->dev); + if (!mci) + return; +@@ -515,17 +523,53 @@ static struct pci_driver ie31200_driver = { + + static int __init ie31200_init(void) + { ++ int pci_rc, i; ++ + edac_dbg(3, "MC:\n"); + /* Ensure that the OPSTATE is set correctly for POLL or NMI */ + opstate_init(); + +- return pci_register_driver(&ie31200_driver); ++ pci_rc = pci_register_driver(&ie31200_driver); ++ if (pci_rc < 0) ++ goto fail0; ++ ++ if (!mci_pdev) { ++ ie31200_registered = 0; ++ for (i = 0; ie31200_pci_tbl[i].vendor != 0; i++) { ++ mci_pdev = pci_get_device(ie31200_pci_tbl[i].vendor, ++ ie31200_pci_tbl[i].device, ++ NULL); ++ if (mci_pdev) ++ break; ++ } ++ if (!mci_pdev) { ++ edac_dbg(0, "ie31200 pci_get_device fail\n"); ++ pci_rc = -ENODEV; ++ goto fail1; ++ } ++ pci_rc = ie31200_init_one(mci_pdev, &ie31200_pci_tbl[i]); ++ if (pci_rc < 0) { ++ edac_dbg(0, "ie31200 init fail\n"); ++ pci_rc = -ENODEV; ++ goto fail1; ++ } ++ } ++ return 0; ++ ++fail1: ++ pci_unregister_driver(&ie31200_driver); ++fail0: ++ pci_dev_put(mci_pdev); ++ ++ return pci_rc; + } + + static void __exit ie31200_exit(void) + { + edac_dbg(3, "MC:\n"); + pci_unregister_driver(&ie31200_driver); ++ if (!ie31200_registered) ++ ie31200_remove_one(mci_pdev); + } + + module_init(ie31200_init); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +index 1f0e6ede120c4..1b3fda2331bee 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +@@ -734,8 +734,10 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + if (encoder) { +@@ -863,8 +865,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + encoder = amdgpu_connector_best_single_encoder(connector); +@@ -986,8 +990,10 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { +@@ -1360,8 +1366,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +index c555781685ea8..d3ee8f19f1ef9 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +@@ -296,7 +296,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set) + + ret = pm_runtime_get_sync(dev->dev); + if (ret < 0) +- return ret; ++ goto out; + + ret = drm_crtc_helper_set_config(set); + +@@ -311,7 +311,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set) + take the current one */ + if (active && !adev->have_disp_power_ref) { + adev->have_disp_power_ref = true; +- return ret; ++ goto out; + } + /* if we have no active crtcs, then drop the power ref + we got before */ +@@ -320,6 +320,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set) + adev->have_disp_power_ref = false; + } + ++out: + /* drop the power reference we got coming in here */ + pm_runtime_put_autosuspend(dev->dev); + return ret; +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +index 8d6668cedf6db..eb3c54e1f1ca8 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +@@ -443,11 +443,12 @@ long amdgpu_drm_ioctl(struct file *filp, + dev = file_priv->minor->dev; + ret = pm_runtime_get_sync(dev->dev); + if (ret < 0) +- return ret; ++ goto out; + + ret = drm_ioctl(filp, cmd, arg); + + pm_runtime_mark_last_busy(dev->dev); ++out: + pm_runtime_put_autosuspend(dev->dev); + return ret; + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +index 5bf98f0195fbd..6025c69871a86 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +@@ -522,7 +522,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) + + r = pm_runtime_get_sync(dev->dev); + if (r < 0) +- return r; ++ goto pm_put; + + fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); + if (unlikely(!fpriv)) +@@ -540,6 +540,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) + file_priv->driver_priv = fpriv; + + pm_runtime_mark_last_busy(dev->dev); ++pm_put: + pm_runtime_put_autosuspend(dev->dev); + return 0; + +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +index 2acbd43f9a531..965489b20429c 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +@@ -841,8 +841,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev, + + ret = kobject_init_and_add(dev->kobj_node, &node_type, + sys_props.kobj_nodes, "%d", id); +- if (ret < 0) ++ if (ret < 0) { ++ kobject_put(dev->kobj_node); + return ret; ++ } + + dev->kobj_mem = kobject_create_and_add("mem_banks", dev->kobj_node); + if (!dev->kobj_mem) +@@ -885,8 +887,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev, + return -ENOMEM; + ret = kobject_init_and_add(mem->kobj, &mem_type, + dev->kobj_mem, "%d", i); +- if (ret < 0) ++ if (ret < 0) { ++ kobject_put(mem->kobj); + return ret; ++ } + + mem->attr.name = "properties"; + mem->attr.mode = KFD_SYSFS_FILE_MODE; +@@ -904,8 +908,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev, + return -ENOMEM; + ret = kobject_init_and_add(cache->kobj, &cache_type, + dev->kobj_cache, "%d", i); +- if (ret < 0) ++ if (ret < 0) { ++ kobject_put(cache->kobj); + return ret; ++ } + + cache->attr.name = "properties"; + cache->attr.mode = KFD_SYSFS_FILE_MODE; +@@ -923,8 +929,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev, + return -ENOMEM; + ret = kobject_init_and_add(iolink->kobj, &iolink_type, + dev->kobj_iolink, "%d", i); +- if (ret < 0) ++ if (ret < 0) { ++ kobject_put(iolink->kobj); + return ret; ++ } + + iolink->attr.name = "properties"; + iolink->attr.mode = KFD_SYSFS_FILE_MODE; +@@ -976,8 +984,10 @@ static int kfd_topology_update_sysfs(void) + ret = kobject_init_and_add(sys_props.kobj_topology, + &sysprops_type, &kfd_device->kobj, + "topology"); +- if (ret < 0) ++ if (ret < 0) { ++ kobject_put(sys_props.kobj_topology); + return ret; ++ } + + sys_props.kobj_nodes = kobject_create_and_add("nodes", + sys_props.kobj_topology); +diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c +index 1855b475cc0b2..42be04813b682 100644 +--- a/drivers/gpu/drm/nouveau/nouveau_connector.c ++++ b/drivers/gpu/drm/nouveau/nouveau_connector.c +@@ -263,8 +263,10 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) + pm_runtime_get_noresume(dev->dev); + } else { + ret = pm_runtime_get_sync(dev->dev); +- if (ret < 0 && ret != -EACCES) ++ if (ret < 0 && ret != -EACCES) { ++ pm_runtime_put_autosuspend(dev->dev); + return conn_status; ++ } + } + + nv_encoder = nouveau_connector_ddc_detect(connector); +diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c +index edb3a23ded5d5..11183839f6fad 100644 +--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c ++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c +@@ -184,8 +184,10 @@ nouveau_fbcon_open(struct fb_info *info, int user) + struct nouveau_fbdev *fbcon = info->par; + struct nouveau_drm *drm = nouveau_drm(fbcon->dev); + int ret = pm_runtime_get_sync(drm->dev->dev); +- if (ret < 0 && ret != -EACCES) ++ if (ret < 0 && ret != -EACCES) { ++ pm_runtime_put(drm->dev->dev); + return ret; ++ } + return 0; + } + +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c +index bebcef2ce6b88..a9f1d99bb6f99 100644 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c +@@ -886,8 +886,10 @@ radeon_lvds_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + if (encoder) { +@@ -1021,8 +1023,10 @@ radeon_vga_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + encoder = radeon_best_single_encoder(connector); +@@ -1158,8 +1162,10 @@ radeon_tv_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + encoder = radeon_best_single_encoder(connector); +@@ -1241,8 +1247,10 @@ radeon_dvi_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + if (radeon_connector->detected_hpd_without_ddc) { +@@ -1681,8 +1689,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force) + + if (!drm_kms_helper_is_poll_worker()) { + r = pm_runtime_get_sync(connector->dev->dev); +- if (r < 0) ++ if (r < 0) { ++ pm_runtime_put_autosuspend(connector->dev->dev); + return connector_status_disconnected; ++ } + } + + if (!force && radeon_check_hpd_status_unchanged(connector)) { +diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c +index dbdd265075daf..7bce23a43907e 100644 +--- a/drivers/hid/usbhid/hiddev.c ++++ b/drivers/hid/usbhid/hiddev.c +@@ -554,12 +554,16 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, + + switch (cmd) { + case HIDIOCGUSAGE: ++ if (uref->usage_index >= field->report_count) ++ goto inval; + uref->value = field->value[uref->usage_index]; + if (copy_to_user(user_arg, uref, sizeof(*uref))) + goto fault; + goto goodreturn; + + case HIDIOCSUSAGE: ++ if (uref->usage_index >= field->report_count) ++ goto inval; + field->value[uref->usage_index] = uref->value; + goto goodreturn; + +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c +index ddfb08a3e6c20..00b3178c36a7a 100644 +--- a/drivers/i2c/busses/i2c-rcar.c ++++ b/drivers/i2c/busses/i2c-rcar.c +@@ -393,6 +393,7 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) + /* master sent stop */ + if (ssr_filtered & SSR) { + i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value); ++ rcar_i2c_write(priv, ICSCR, SIE | SDBS); /* clear our NACK */ + rcar_i2c_write(priv, ICSIER, SAR); + rcar_i2c_write(priv, ICSSR, ~SSR & 0xff); + } +diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c +index f89364951ebdf..fb13cc3c591da 100644 +--- a/drivers/media/pci/ttpci/av7110.c ++++ b/drivers/media/pci/ttpci/av7110.c +@@ -426,14 +426,15 @@ static void debiirq(unsigned long cookie) + case DATA_CI_GET: + { + u8 *data = av7110->debi_virt; ++ u8 data_0 = data[0]; + +- if ((data[0] < 2) && data[2] == 0xff) { ++ if (data_0 < 2 && data[2] == 0xff) { + int flags = 0; + if (data[5] > 0) + flags |= CA_CI_MODULE_PRESENT; + if (data[5] > 5) + flags |= CA_CI_MODULE_READY; +- av7110->ci_slot[data[0]].flags = flags; ++ av7110->ci_slot[data_0].flags = flags; + } else + ci_get_data(&av7110->ci_rbuffer, + av7110->debi_virt, +diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c +index c1e573b7cc6fb..50122ac2ac028 100644 +--- a/drivers/media/platform/davinci/vpif_capture.c ++++ b/drivers/media/platform/davinci/vpif_capture.c +@@ -1417,8 +1417,6 @@ probe_out: + /* Unregister video device */ + video_unregister_device(&ch->video_dev); + } +- kfree(vpif_obj.sd); +- v4l2_device_unregister(&vpif_obj.v4l2_dev); + + return err; + } +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c +index e31b4c7d2522b..aaf75d5e6e480 100644 +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -1940,7 +1940,8 @@ static int bond_release_and_destroy(struct net_device *bond_dev, + int ret; + + ret = bond_release(bond_dev, slave_dev); +- if (ret == 0 && !bond_has_slaves(bond)) { ++ if (ret == 0 && !bond_has_slaves(bond) && ++ bond_dev->reg_state != NETREG_UNREGISTERING) { + bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; + netdev_info(bond_dev, "Destroying bond %s\n", + bond_dev->name); +@@ -4057,13 +4058,23 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) + return ret; + } + ++static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed) ++{ ++ if (speed == 0 || speed == SPEED_UNKNOWN) ++ speed = slave->speed; ++ else ++ speed = min(speed, slave->speed); ++ ++ return speed; ++} ++ + static int bond_ethtool_get_settings(struct net_device *bond_dev, + struct ethtool_cmd *ecmd) + { + struct bonding *bond = netdev_priv(bond_dev); +- unsigned long speed = 0; + struct list_head *iter; + struct slave *slave; ++ u32 speed = 0; + + ecmd->duplex = DUPLEX_UNKNOWN; + ecmd->port = PORT_OTHER; +@@ -4075,8 +4086,13 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev, + */ + bond_for_each_slave(bond, slave, iter) { + if (bond_slave_can_tx(slave)) { +- if (slave->speed != SPEED_UNKNOWN) +- speed += slave->speed; ++ if (slave->speed != SPEED_UNKNOWN) { ++ if (BOND_MODE(bond) == BOND_MODE_BROADCAST) ++ speed = bond_mode_bcast_speed(slave, ++ speed); ++ else ++ speed += slave->speed; ++ } + if (ecmd->duplex == DUPLEX_UNKNOWN && + slave->duplex != DUPLEX_UNKNOWN) + ecmd->duplex = slave->duplex; +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c +index 37cc1f838dd8b..96310e2ee5458 100644 +--- a/drivers/net/ethernet/freescale/gianfar.c ++++ b/drivers/net/ethernet/freescale/gianfar.c +@@ -845,8 +845,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) + continue; + + err = gfar_parse_group(child, priv, model); +- if (err) ++ if (err) { ++ of_node_put(child); + goto err_grp_init; ++ } + } + } else { /* SQ_SG_MODE */ + err = gfar_parse_group(np, priv, model); +diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c +index b4d5f53c97d35..b7a122a1b89a1 100644 +--- a/drivers/net/ipvlan/ipvlan_main.c ++++ b/drivers/net/ipvlan/ipvlan_main.c +@@ -87,12 +87,21 @@ static void ipvlan_port_destroy(struct net_device *dev) + static struct lock_class_key ipvlan_netdev_xmit_lock_key; + static struct lock_class_key ipvlan_netdev_addr_lock_key; + ++#define IPVLAN_ALWAYS_ON_OFLOADS \ ++ (NETIF_F_SG | NETIF_F_HW_CSUM | \ ++ NETIF_F_GSO_ROBUST | NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL) ++ ++#define IPVLAN_ALWAYS_ON \ ++ (IPVLAN_ALWAYS_ON_OFLOADS | NETIF_F_LLTX | NETIF_F_VLAN_CHALLENGED) ++ + #define IPVLAN_FEATURES \ + (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \ + NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \ + NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_RXCSUM | \ + NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER) + ++ /* NETIF_F_GSO_ENCAP_ALL NETIF_F_GSO_SOFTWARE Newly added */ ++ + #define IPVLAN_STATE_MASK \ + ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT)) + +@@ -117,7 +126,9 @@ static int ipvlan_init(struct net_device *dev) + dev->state = (dev->state & ~IPVLAN_STATE_MASK) | + (phy_dev->state & IPVLAN_STATE_MASK); + dev->features = phy_dev->features & IPVLAN_FEATURES; +- dev->features |= NETIF_F_LLTX; ++ dev->features |= IPVLAN_ALWAYS_ON; ++ dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES; ++ dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS; + dev->gso_max_size = phy_dev->gso_max_size; + dev->hard_header_len = phy_dev->hard_header_len; + +@@ -201,7 +212,14 @@ static netdev_features_t ipvlan_fix_features(struct net_device *dev, + { + struct ipvl_dev *ipvlan = netdev_priv(dev); + +- return features & (ipvlan->sfeatures | ~IPVLAN_FEATURES); ++ features |= NETIF_F_ALL_FOR_ALL; ++ features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES); ++ features = netdev_increment_features(ipvlan->phy_dev->features, ++ features, features); ++ features |= IPVLAN_ALWAYS_ON; ++ features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON); ++ ++ return features; + } + + static void ipvlan_change_rx_flags(struct net_device *dev, int change) +@@ -590,9 +608,8 @@ static int ipvlan_device_event(struct notifier_block *unused, + + case NETDEV_FEAT_CHANGE: + list_for_each_entry(ipvlan, &port->ipvlans, pnode) { +- ipvlan->dev->features = dev->features & IPVLAN_FEATURES; + ipvlan->dev->gso_max_size = dev->gso_max_size; +- netdev_features_change(ipvlan->dev); ++ netdev_update_features(ipvlan->dev); + } + break; + +diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h +index 713c2bcea1782..8ec5c579d7fa8 100644 +--- a/drivers/net/wireless/ath/ath10k/hw.h ++++ b/drivers/net/wireless/ath/ath10k/hw.h +@@ -429,7 +429,7 @@ enum ath10k_hw_rate_cck { + + #define TARGET_10_4_TX_DBG_LOG_SIZE 1024 + #define TARGET_10_4_NUM_WDS_ENTRIES 32 +-#define TARGET_10_4_DMA_BURST_SIZE 0 ++#define TARGET_10_4_DMA_BURST_SIZE 1 + #define TARGET_10_4_MAC_AGGR_DELIM 0 + #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1 + #define TARGET_10_4_VOW_CONFIG 0 +diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c +index 9408c1f8e3977..f01ef8ecfaf39 100644 +--- a/drivers/net/wireless/realtek/rtlwifi/usb.c ++++ b/drivers/net/wireless/realtek/rtlwifi/usb.c +@@ -755,8 +755,11 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw) + + usb_anchor_urb(urb, &rtlusb->rx_submitted); + err = usb_submit_urb(urb, GFP_KERNEL); +- if (err) ++ if (err) { ++ usb_unanchor_urb(urb); ++ usb_free_urb(urb); + goto err_out; ++ } + usb_free_urb(urb); + } + return 0; +diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c +index 429d34c348b9f..01a343ad7155c 100644 +--- a/drivers/pci/slot.c ++++ b/drivers/pci/slot.c +@@ -303,13 +303,16 @@ placeholder: + slot_name = make_slot_name(name); + if (!slot_name) { + err = -ENOMEM; ++ kfree(slot); + goto err; + } + + err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL, + "%s", slot_name); +- if (err) ++ if (err) { ++ kobject_put(&slot->kobj); + goto err; ++ } + + INIT_LIST_HEAD(&slot->list); + list_add(&slot->list, &parent->slots); +@@ -328,7 +331,6 @@ out: + mutex_unlock(&pci_slot_mutex); + return slot; + err: +- kfree(slot); + slot = ERR_PTR(err); + goto out; + } +diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c +index 8ecc956ecb59c..370a3a2c6de73 100644 +--- a/drivers/s390/cio/css.c ++++ b/drivers/s390/cio/css.c +@@ -529,6 +529,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void *data) + rc = css_evaluate_known_subchannel(sch, 1); + if (rc == -EAGAIN) + css_schedule_eval(sch->schid); ++ /* ++ * The loop might take long time for platforms with lots of ++ * known devices. Allow scheduling here. ++ */ ++ cond_resched(); + } + return 0; + } +diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c +index 3bc610d160f57..53afdbe17d71d 100644 +--- a/drivers/scsi/fcoe/fcoe_ctlr.c ++++ b/drivers/scsi/fcoe/fcoe_ctlr.c +@@ -264,9 +264,9 @@ static void fcoe_sysfs_fcf_del(struct fcoe_fcf *new) + WARN_ON(!fcf_dev); + new->fcf_dev = NULL; + fcoe_fcf_device_delete(fcf_dev); +- kfree(new); + mutex_unlock(&cdev->lock); + } ++ kfree(new); + } + + /** +diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c +index 861c57bc4520a..72248712949e0 100644 +--- a/drivers/scsi/lpfc/lpfc_vport.c ++++ b/drivers/scsi/lpfc/lpfc_vport.c +@@ -615,27 +615,16 @@ lpfc_vport_delete(struct fc_vport *fc_vport) + vport->port_state < LPFC_VPORT_READY) + return -EAGAIN; + } ++ + /* +- * This is a bit of a mess. We want to ensure the shost doesn't get +- * torn down until we're done with the embedded lpfc_vport structure. +- * +- * Beyond holding a reference for this function, we also need a +- * reference for outstanding I/O requests we schedule during delete +- * processing. But once we scsi_remove_host() we can no longer obtain +- * a reference through scsi_host_get(). +- * +- * So we take two references here. We release one reference at the +- * bottom of the function -- after delinking the vport. And we +- * release the other at the completion of the unreg_vpi that get's +- * initiated after we've disposed of all other resources associated +- * with the port. ++ * Take early refcount for outstanding I/O requests we schedule during ++ * delete processing for unreg_vpi. Always keep this before ++ * scsi_remove_host() as we can no longer obtain a reference through ++ * scsi_host_get() after scsi_host_remove as shost is set to SHOST_DEL. + */ + if (!scsi_host_get(shost)) + return VPORT_INVAL; +- if (!scsi_host_get(shost)) { +- scsi_host_put(shost); +- return VPORT_INVAL; +- } ++ + lpfc_free_sysfs_attr(vport); + + lpfc_debugfs_terminate(vport); +@@ -783,8 +772,9 @@ skip_logo: + if (!(vport->vpi_state & LPFC_VPI_REGISTERED) || + lpfc_mbx_unreg_vpi(vport)) + scsi_host_put(shost); +- } else ++ } else { + scsi_host_put(shost); ++ } + + lpfc_free_vpi(phba, vport->vpi); + vport->work_port_events = 0; +diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c +index de10b461ec7ef..4903640316480 100644 +--- a/drivers/scsi/scsi_transport_iscsi.c ++++ b/drivers/scsi/scsi_transport_iscsi.c +@@ -3192,7 +3192,7 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport, + pr_err("%s could not find host no %u\n", + __func__, ev->u.set_flashnode.host_no); + err = -ENODEV; +- goto put_host; ++ goto exit_set_fnode; + } + + idx = ev->u.set_flashnode.flashnode_idx; +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c +index d15cd7a02f9b4..d7a0a64f64536 100644 +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -575,6 +575,7 @@ unblock_reqs: + int ufshcd_hold(struct ufs_hba *hba, bool async) + { + int rc = 0; ++ bool flush_result; + unsigned long flags; + + if (!ufshcd_is_clkgating_allowed(hba)) +@@ -601,7 +602,9 @@ start: + break; + } + spin_unlock_irqrestore(hba->host->host_lock, flags); +- flush_work(&hba->clk_gating.ungate_work); ++ flush_result = flush_work(&hba->clk_gating.ungate_work); ++ if (hba->clk_gating.is_suspended && !flush_result) ++ goto out; + spin_lock_irqsave(hba->host->host_lock, flags); + goto start; + } +diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c +index c43c942e1f876..bccde58bc5e30 100644 +--- a/drivers/target/target_core_user.c ++++ b/drivers/target/target_core_user.c +@@ -590,7 +590,14 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev *udev) + struct tcmu_cmd_entry *entry = (void *) mb + CMDR_OFF + udev->cmdr_last_cleaned; + struct tcmu_cmd *cmd; + +- tcmu_flush_dcache_range(entry, sizeof(*entry)); ++ /* ++ * Flush max. up to end of cmd ring since current entry might ++ * be a padding that is shorter than sizeof(*entry) ++ */ ++ size_t ring_left = head_to_end(udev->cmdr_last_cleaned, ++ udev->cmdr_size); ++ tcmu_flush_dcache_range(entry, ring_left < sizeof(*entry) ? ++ ring_left : sizeof(*entry)); + + if (tcmu_hdr_get_op(entry->hdr.len_op) == TCMU_OP_PAD) { + UPDATE_HEAD(udev->cmdr_last_cleaned, +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c +index d42d66b72d5a8..fef1b9335f604 100644 +--- a/drivers/tty/serial/8250/8250_port.c ++++ b/drivers/tty/serial/8250/8250_port.c +@@ -1902,6 +1902,10 @@ int serial8250_do_startup(struct uart_port *port) + + if (port->irq) { + unsigned char iir1; ++ ++ if (port->irqflags & IRQF_SHARED) ++ disable_irq_nosync(port->irq); ++ + /* + * Test for UARTs that do not reassert THRE when the + * transmitter is idle and the interrupt has already +@@ -1911,8 +1915,6 @@ int serial8250_do_startup(struct uart_port *port) + * allow register changes to become visible. + */ + spin_lock_irqsave(&port->lock, flags); +- if (up->port.irqflags & IRQF_SHARED) +- disable_irq_nosync(port->irq); + + wait_for_xmitr(up, UART_LSR_THRE); + serial_port_out_sync(port, UART_IER, UART_IER_THRI); +@@ -1924,9 +1926,10 @@ int serial8250_do_startup(struct uart_port *port) + iir = serial_port_in(port, UART_IIR); + serial_port_out(port, UART_IER, 0); + ++ spin_unlock_irqrestore(&port->lock, flags); ++ + if (port->irqflags & IRQF_SHARED) + enable_irq(port->irq); +- spin_unlock_irqrestore(&port->lock, flags); + + /* + * If the interrupt is not reasserted, or we otherwise +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c +index c5da46f7b9093..562f2a40e083c 100644 +--- a/drivers/tty/serial/amba-pl011.c ++++ b/drivers/tty/serial/amba-pl011.c +@@ -2332,7 +2332,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap, + + static int pl011_register_port(struct uart_amba_port *uap) + { +- int ret; ++ int ret, i; + + /* Ensure interrupts from this UART are masked and cleared */ + writew(0, uap->port.membase + UART011_IMSC); +@@ -2343,6 +2343,9 @@ static int pl011_register_port(struct uart_amba_port *uap) + if (ret < 0) { + dev_err(uap->port.dev, + "Failed to register AMBA-PL011 driver\n"); ++ for (i = 0; i < ARRAY_SIZE(amba_ports); i++) ++ if (amba_ports[i] == uap) ++ amba_ports[i] = NULL; + return ret; + } + } +diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c +index 8d485f82443ed..70a51d0bc6044 100644 +--- a/drivers/tty/serial/samsung.c ++++ b/drivers/tty/serial/samsung.c +@@ -1719,9 +1719,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, + ourport->tx_irq = ret + 1; + } + +- ret = platform_get_irq(platdev, 1); +- if (ret > 0) +- ourport->tx_irq = ret; ++ if (!s3c24xx_serial_has_interrupt_mask(port)) { ++ ret = platform_get_irq(platdev, 1); ++ if (ret > 0) ++ ourport->tx_irq = ret; ++ } + /* + * DMA is currently supported only on DT platforms, if DMA properties + * are specified. +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c +index 4785ae061b659..0e4f54832fc79 100644 +--- a/drivers/tty/vt/vt.c ++++ b/drivers/tty/vt/vt.c +@@ -864,7 +864,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, + unsigned int old_rows, old_row_size; + unsigned int new_cols, new_rows, new_row_size, new_screen_size; + unsigned int user; +- unsigned short *newscreen; ++ unsigned short *oldscreen, *newscreen; + + WARN_CONSOLE_UNLOCKED(); + +@@ -946,10 +946,11 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, + if (new_scr_end > new_origin) + scr_memsetw((void *)new_origin, vc->vc_video_erase_char, + new_scr_end - new_origin); +- kfree(vc->vc_screenbuf); ++ oldscreen = vc->vc_screenbuf; + vc->vc_screenbuf = newscreen; + vc->vc_screenbuf_size = new_screen_size; + set_origin(vc); ++ kfree(oldscreen); + + /* do part of a reset_terminal() */ + vc->vc_top = 0; +diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c +index 9353789e43372..b0f0771a57298 100644 +--- a/drivers/tty/vt/vt_ioctl.c ++++ b/drivers/tty/vt/vt_ioctl.c +@@ -896,12 +896,22 @@ int vt_ioctl(struct tty_struct *tty, + console_lock(); + vcp = vc_cons[i].d; + if (vcp) { ++ int ret; ++ int save_scan_lines = vcp->vc_scan_lines; ++ int save_font_height = vcp->vc_font.height; ++ + if (v.v_vlin) + vcp->vc_scan_lines = v.v_vlin; + if (v.v_clin) + vcp->vc_font.height = v.v_clin; + vcp->vc_resize_user = 1; +- vc_resize(vcp, v.v_cols, v.v_rows); ++ ret = vc_resize(vcp, v.v_cols, v.v_rows); ++ if (ret) { ++ vcp->vc_scan_lines = save_scan_lines; ++ vcp->vc_font.height = save_font_height; ++ console_unlock(); ++ return ret; ++ } + } + console_unlock(); + } +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c +index e6e0f786547bf..eed7c8d8e3d4f 100644 +--- a/drivers/usb/core/quirks.c ++++ b/drivers/usb/core/quirks.c +@@ -299,6 +299,8 @@ static const struct usb_device_id usb_quirk_list[] = { + + { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM }, + ++ { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM }, ++ + /* DJI CineSSD */ + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, + +diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c +index 6865b919403f7..2ed062a2e93b4 100644 +--- a/drivers/usb/host/ohci-exynos.c ++++ b/drivers/usb/host/ohci-exynos.c +@@ -166,9 +166,8 @@ skip_phy: + hcd->rsrc_len = resource_size(res); + + irq = platform_get_irq(pdev, 0); +- if (!irq) { +- dev_err(&pdev->dev, "Failed to get IRQ\n"); +- err = -ENODEV; ++ if (irq < 0) { ++ err = irq; + goto fail_io; + } + +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c +index 3ef80c2c0dcc1..6891738278bcb 100644 +--- a/drivers/usb/host/xhci-hub.c ++++ b/drivers/usb/host/xhci-hub.c +@@ -599,15 +599,6 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, + { + u32 pls = status_reg & PORT_PLS_MASK; + +- /* resume state is a xHCI internal state. +- * Do not report it to usb core, instead, pretend to be U3, +- * thus usb core knows it's not ready for transfer +- */ +- if (pls == XDEV_RESUME) { +- *status |= USB_SS_PORT_LS_U3; +- return; +- } +- + /* When the CAS bit is set then warm reset + * should be performed on port + */ +@@ -629,6 +620,16 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, + */ + pls |= USB_PORT_STAT_CONNECTION; + } else { ++ /* ++ * Resume state is an xHCI internal state. Do not report it to ++ * usb core, instead, pretend to be U3, thus usb core knows ++ * it's not ready for transfer. ++ */ ++ if (pls == XDEV_RESUME) { ++ *status |= USB_SS_PORT_LS_U3; ++ return; ++ } ++ + /* + * If CAS bit isn't set but the Port is already at + * Compliance Mode, fake a connection so the USB core +diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c +index 383fa007348f4..bda82e63c1a93 100644 +--- a/drivers/usb/misc/lvstest.c ++++ b/drivers/usb/misc/lvstest.c +@@ -396,7 +396,7 @@ static int lvs_rh_probe(struct usb_interface *intf, + USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT); + if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) { + dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret); +- return ret; ++ return ret < 0 ? ret : -EINVAL; + } + + /* submit urb to poll interrupt endpoint */ +diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c +index 22da70fada5e5..971f1165dc4bb 100644 +--- a/drivers/usb/misc/sisusbvga/sisusb.c ++++ b/drivers/usb/misc/sisusbvga/sisusb.c +@@ -790,7 +790,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, + u8 swap8, fromkern = kernbuffer ? 1 : 0; + u16 swap16; + u32 swap32, flag = (length >> 28) & 1; +- char buf[4]; ++ u8 buf[4]; + + /* if neither kernbuffer not userbuffer are given, assume + * data in obuf +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c +index 44c6ced5d4422..b17aeaafbb7c3 100644 +--- a/drivers/usb/misc/yurex.c ++++ b/drivers/usb/misc/yurex.c +@@ -510,7 +510,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, + prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE); + dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__, + dev->cntl_buffer[0]); +- retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL); ++ retval = usb_submit_urb(dev->cntl_urb, GFP_ATOMIC); + if (retval >= 0) + timeout = schedule_timeout(YUREX_WRITE_TIMEOUT); + finish_wait(&dev->waitq, &wait); +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h +index ccf2d50e0d2e3..2c2ac15d25549 100644 +--- a/drivers/usb/storage/unusual_devs.h ++++ b/drivers/usb/storage/unusual_devs.h +@@ -2213,7 +2213,7 @@ UNUSUAL_DEV( 0x357d, 0x7788, 0x0114, 0x0114, + "JMicron", + "USB to ATA/ATAPI Bridge", + USB_SC_DEVICE, USB_PR_DEVICE, NULL, +- US_FL_BROKEN_FUA ), ++ US_FL_BROKEN_FUA | US_FL_IGNORE_UAS ), + + /* Reported by Andrey Rahmatullin */ + UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100, +diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h +index cb0af57aad6eb..b7171c19fca20 100644 +--- a/drivers/usb/storage/unusual_uas.h ++++ b/drivers/usb/storage/unusual_uas.h +@@ -40,6 +40,13 @@ + * and don't forget to CC: the USB development list + */ + ++/* Reported-by: Till Dörges */ ++UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999, ++ "Sony", ++ "PSZ-HA*", ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL, ++ US_FL_NO_REPORT_OPCODES), ++ + /* Reported-by: Julian Groß */ + UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999, + "LaCie", +@@ -155,6 +162,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999, + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_BROKEN_FUA), + ++/* Reported-by: Thinh Nguyen */ ++UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x9999, ++ "PNY", ++ "Pro Elite SSD", ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL, ++ US_FL_NO_ATA_1X), ++ + /* Reported-by: Hans de Goede */ + UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999, + "VIA", +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c +index c03c5b9602bb3..fe0663787b3c9 100644 +--- a/drivers/video/console/fbcon.c ++++ b/drivers/video/console/fbcon.c +@@ -2117,6 +2117,9 @@ static void updatescrollmode(struct display *p, + } + } + ++#define PITCH(w) (((w) + 7) >> 3) ++#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */ ++ + static int fbcon_resize(struct vc_data *vc, unsigned int width, + unsigned int height, unsigned int user) + { +@@ -2126,6 +2129,24 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, + struct fb_var_screeninfo var = info->var; + int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; + ++ if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) { ++ int size; ++ int pitch = PITCH(vc->vc_font.width); ++ ++ /* ++ * If user font, ensure that a possible change to user font ++ * height or width will not allow a font data out-of-bounds access. ++ * NOTE: must use original charcount in calculation as font ++ * charcount can change and cannot be used to determine the ++ * font data allocated size. ++ */ ++ if (pitch <= 0) ++ return -EINVAL; ++ size = CALC_FONTSZ(vc->vc_font.height, pitch, FNTCHARCNT(vc->vc_font.data)); ++ if (size > FNTSIZE(vc->vc_font.data)) ++ return -EINVAL; ++ } ++ + virt_w = FBCON_SWAP(ops->rotate, width, height); + virt_h = FBCON_SWAP(ops->rotate, height, width); + virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width, +@@ -2587,7 +2608,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne + int size; + int i, csum; + u8 *new_data, *data = font->data; +- int pitch = (font->width+7) >> 3; ++ int pitch = PITCH(font->width); + + /* Is there a reason why fbconsole couldn't handle any charcount >256? + * If not this check should be changed to charcount < 256 */ +@@ -2603,7 +2624,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne + if (fbcon_invalid_charcount(info, charcount)) + return -EINVAL; + +- size = h * pitch * charcount; ++ size = CALC_FONTSZ(h, pitch, charcount); + + new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER); + +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c +index 878a40950a3a1..e4dd991e2888b 100644 +--- a/drivers/xen/events/events_base.c ++++ b/drivers/xen/events/events_base.c +@@ -155,7 +155,7 @@ int get_evtchn_to_irq(unsigned evtchn) + /* Get info for IRQ */ + struct irq_info *info_for_irq(unsigned irq) + { +- return irq_get_handler_data(irq); ++ return irq_get_chip_data(irq); + } + + /* Constructors for packed IRQ information. */ +@@ -384,7 +384,7 @@ static void xen_irq_init(unsigned irq) + info->type = IRQT_UNBOUND; + info->refcnt = -1; + +- irq_set_handler_data(irq, info); ++ irq_set_chip_data(irq, info); + + list_add_tail(&info->list, &xen_irq_list_head); + } +@@ -433,14 +433,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi) + + static void xen_free_irq(unsigned irq) + { +- struct irq_info *info = irq_get_handler_data(irq); ++ struct irq_info *info = irq_get_chip_data(irq); + + if (WARN_ON(!info)) + return; + + list_del(&info->list); + +- irq_set_handler_data(irq, NULL); ++ irq_set_chip_data(irq, NULL); + + WARN_ON(info->refcnt > 0); + +@@ -610,7 +610,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); + static void __unbind_from_irq(unsigned int irq) + { + int evtchn = evtchn_from_irq(irq); +- struct irq_info *info = irq_get_handler_data(irq); ++ struct irq_info *info = irq_get_chip_data(irq); + + if (info->refcnt > 0) { + info->refcnt--; +@@ -1114,7 +1114,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi, + + void unbind_from_irqhandler(unsigned int irq, void *dev_id) + { +- struct irq_info *info = irq_get_handler_data(irq); ++ struct irq_info *info = irq_get_chip_data(irq); + + if (WARN_ON(!info)) + return; +@@ -1148,7 +1148,7 @@ int evtchn_make_refcounted(unsigned int evtchn) + if (irq == -1) + return -ENOENT; + +- info = irq_get_handler_data(irq); ++ info = irq_get_chip_data(irq); + + if (!info) + return -ENOENT; +@@ -1176,7 +1176,7 @@ int evtchn_get(unsigned int evtchn) + if (irq == -1) + goto done; + +- info = irq_get_handler_data(irq); ++ info = irq_get_chip_data(irq); + + if (!info) + goto done; +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c +index 820d3b5bc4150..8f0f91de436d5 100644 +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -3169,11 +3169,13 @@ fail: + btrfs_free_path(path); + out_unlock: + mutex_unlock(&BTRFS_I(dir)->log_mutex); +- if (ret == -ENOSPC) { ++ if (err == -ENOSPC) { + btrfs_set_log_full_commit(root->fs_info, trans); +- ret = 0; +- } else if (ret < 0) +- btrfs_abort_transaction(trans, root, ret); ++ err = 0; ++ } else if (err < 0 && err != -ENOENT) { ++ /* ENOENT can be returned if the entry hasn't been fsynced yet */ ++ btrfs_abort_transaction(trans, root, err); ++ } + + btrfs_end_log_trans(root); + +diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c +index a5de8e22629ba..b7fd7d69be075 100644 +--- a/fs/ceph/mds_client.c ++++ b/fs/ceph/mds_client.c +@@ -3428,6 +3428,9 @@ static void delayed_work(struct work_struct *work) + dout("mdsc delayed_work\n"); + ceph_check_delayed_caps(mdsc); + ++ if (mdsc->stopping) ++ return; ++ + mutex_lock(&mdsc->mutex); + renew_interval = mdsc->mdsmap->m_session_timeout >> 2; + renew_caps = time_after_eq(jiffies, HZ*renew_interval + +@@ -3752,7 +3755,16 @@ void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc) + static void ceph_mdsc_stop(struct ceph_mds_client *mdsc) + { + dout("stop\n"); +- cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */ ++ /* ++ * Make sure the delayed work stopped before releasing ++ * the resources. ++ * ++ * Because the cancel_delayed_work_sync() will only ++ * guarantee that the work finishes executing. But the ++ * delayed work will re-arm itself again after that. ++ */ ++ flush_delayed_work(&mdsc->delayed_work); ++ + if (mdsc->mdsmap) + ceph_mdsmap_destroy(mdsc->mdsmap); + kfree(mdsc->sessions); +diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c +index a2a2405571ccc..66a9c9dab8316 100644 +--- a/fs/fs-writeback.c ++++ b/fs/fs-writeback.c +@@ -45,7 +45,6 @@ struct wb_completion { + struct wb_writeback_work { + long nr_pages; + struct super_block *sb; +- unsigned long *older_than_this; + enum writeback_sync_modes sync_mode; + unsigned int tagged_writepages:1; + unsigned int for_kupdate:1; +@@ -160,7 +159,9 @@ static void inode_io_list_del_locked(struct inode *inode, + struct bdi_writeback *wb) + { + assert_spin_locked(&wb->list_lock); ++ assert_spin_locked(&inode->i_lock); + ++ inode->i_state &= ~I_SYNC_QUEUED; + list_del_init(&inode->i_io_list); + wb_io_lists_depopulated(wb); + } +@@ -1034,7 +1035,9 @@ void inode_io_list_del(struct inode *inode) + struct bdi_writeback *wb; + + wb = inode_to_wb_and_lock_list(inode); ++ spin_lock(&inode->i_lock); + inode_io_list_del_locked(inode, wb); ++ spin_unlock(&inode->i_lock); + spin_unlock(&wb->list_lock); + } + +@@ -1047,8 +1050,10 @@ void inode_io_list_del(struct inode *inode) + * the case then the inode must have been redirtied while it was being written + * out and we don't reset its dirtied_when. + */ +-static void redirty_tail(struct inode *inode, struct bdi_writeback *wb) ++static void redirty_tail_locked(struct inode *inode, struct bdi_writeback *wb) + { ++ assert_spin_locked(&inode->i_lock); ++ + if (!list_empty(&wb->b_dirty)) { + struct inode *tail; + +@@ -1057,6 +1062,14 @@ static void redirty_tail(struct inode *inode, struct bdi_writeback *wb) + inode->dirtied_when = jiffies; + } + inode_io_list_move_locked(inode, wb, &wb->b_dirty); ++ inode->i_state &= ~I_SYNC_QUEUED; ++} ++ ++static void redirty_tail(struct inode *inode, struct bdi_writeback *wb) ++{ ++ spin_lock(&inode->i_lock); ++ redirty_tail_locked(inode, wb); ++ spin_unlock(&inode->i_lock); + } + + /* +@@ -1095,16 +1108,13 @@ static bool inode_dirtied_after(struct inode *inode, unsigned long t) + #define EXPIRE_DIRTY_ATIME 0x0001 + + /* +- * Move expired (dirtied before work->older_than_this) dirty inodes from ++ * Move expired (dirtied before dirtied_before) dirty inodes from + * @delaying_queue to @dispatch_queue. + */ + static int move_expired_inodes(struct list_head *delaying_queue, + struct list_head *dispatch_queue, +- int flags, +- struct wb_writeback_work *work) ++ int flags, unsigned long dirtied_before) + { +- unsigned long *older_than_this = NULL; +- unsigned long expire_time; + LIST_HEAD(tmp); + struct list_head *pos, *node; + struct super_block *sb = NULL; +@@ -1112,21 +1122,17 @@ static int move_expired_inodes(struct list_head *delaying_queue, + int do_sb_sort = 0; + int moved = 0; + +- if ((flags & EXPIRE_DIRTY_ATIME) == 0) +- older_than_this = work->older_than_this; +- else if (!work->for_sync) { +- expire_time = jiffies - (dirtytime_expire_interval * HZ); +- older_than_this = &expire_time; +- } + while (!list_empty(delaying_queue)) { + inode = wb_inode(delaying_queue->prev); +- if (older_than_this && +- inode_dirtied_after(inode, *older_than_this)) ++ if (inode_dirtied_after(inode, dirtied_before)) + break; + list_move(&inode->i_io_list, &tmp); + moved++; ++ spin_lock(&inode->i_lock); + if (flags & EXPIRE_DIRTY_ATIME) +- set_bit(__I_DIRTY_TIME_EXPIRED, &inode->i_state); ++ inode->i_state |= I_DIRTY_TIME_EXPIRED; ++ inode->i_state |= I_SYNC_QUEUED; ++ spin_unlock(&inode->i_lock); + if (sb_is_blkdev_sb(inode->i_sb)) + continue; + if (sb && sb != inode->i_sb) +@@ -1164,18 +1170,22 @@ out: + * | + * +--> dequeue for IO + */ +-static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work) ++static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work, ++ unsigned long dirtied_before) + { + int moved; ++ unsigned long time_expire_jif = dirtied_before; + + assert_spin_locked(&wb->list_lock); + list_splice_init(&wb->b_more_io, &wb->b_io); +- moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, work); ++ moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, dirtied_before); ++ if (!work->for_sync) ++ time_expire_jif = jiffies - dirtytime_expire_interval * HZ; + moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io, +- EXPIRE_DIRTY_ATIME, work); ++ EXPIRE_DIRTY_ATIME, time_expire_jif); + if (moved) + wb_io_lists_populated(wb); +- trace_writeback_queue_io(wb, work, moved); ++ trace_writeback_queue_io(wb, work, dirtied_before, moved); + } + + static int write_inode(struct inode *inode, struct writeback_control *wbc) +@@ -1269,7 +1279,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, + * writeback is not making progress due to locked + * buffers. Skip this inode for now. + */ +- redirty_tail(inode, wb); ++ redirty_tail_locked(inode, wb); + return; + } + +@@ -1289,7 +1299,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, + * retrying writeback of the dirty page/inode + * that cannot be performed immediately. + */ +- redirty_tail(inode, wb); ++ redirty_tail_locked(inode, wb); + } + } else if (inode->i_state & I_DIRTY) { + /* +@@ -1297,10 +1307,11 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, + * such as delayed allocation during submission or metadata + * updates after data IO completion. + */ +- redirty_tail(inode, wb); ++ redirty_tail_locked(inode, wb); + } else if (inode->i_state & I_DIRTY_TIME) { + inode->dirtied_when = jiffies; + inode_io_list_move_locked(inode, wb, &wb->b_dirty_time); ++ inode->i_state &= ~I_SYNC_QUEUED; + } else { + /* The inode is clean. Remove from writeback lists. */ + inode_io_list_del_locked(inode, wb); +@@ -1543,8 +1554,8 @@ static long writeback_sb_inodes(struct super_block *sb, + */ + spin_lock(&inode->i_lock); + if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) { ++ redirty_tail_locked(inode, wb); + spin_unlock(&inode->i_lock); +- redirty_tail(inode, wb); + continue; + } + if ((inode->i_state & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) { +@@ -1685,7 +1696,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, + blk_start_plug(&plug); + spin_lock(&wb->list_lock); + if (list_empty(&wb->b_io)) +- queue_io(wb, &work); ++ queue_io(wb, &work, jiffies); + __writeback_inodes_wb(wb, &work); + spin_unlock(&wb->list_lock); + blk_finish_plug(&plug); +@@ -1705,7 +1716,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, + * takes longer than a dirty_writeback_interval interval, then leave a + * one-second gap. + * +- * older_than_this takes precedence over nr_to_write. So we'll only write back ++ * dirtied_before takes precedence over nr_to_write. So we'll only write back + * all dirty pages if they are all attached to "old" mappings. + */ + static long wb_writeback(struct bdi_writeback *wb, +@@ -1713,14 +1724,11 @@ static long wb_writeback(struct bdi_writeback *wb, + { + unsigned long wb_start = jiffies; + long nr_pages = work->nr_pages; +- unsigned long oldest_jif; ++ unsigned long dirtied_before = jiffies; + struct inode *inode; + long progress; + struct blk_plug plug; + +- oldest_jif = jiffies; +- work->older_than_this = &oldest_jif; +- + blk_start_plug(&plug); + spin_lock(&wb->list_lock); + for (;;) { +@@ -1754,14 +1762,14 @@ static long wb_writeback(struct bdi_writeback *wb, + * safe. + */ + if (work->for_kupdate) { +- oldest_jif = jiffies - ++ dirtied_before = jiffies - + msecs_to_jiffies(dirty_expire_interval * 10); + } else if (work->for_background) +- oldest_jif = jiffies; ++ dirtied_before = jiffies; + + trace_writeback_start(wb, work); + if (list_empty(&wb->b_io)) +- queue_io(wb, work); ++ queue_io(wb, work, dirtied_before); + if (work->sb) + progress = writeback_sb_inodes(work->sb, wb, work); + else +@@ -2128,11 +2136,12 @@ void __mark_inode_dirty(struct inode *inode, int flags) + inode->i_state |= flags; + + /* +- * If the inode is being synced, just update its dirty state. +- * The unlocker will place the inode on the appropriate +- * superblock list, based upon its state. ++ * If the inode is queued for writeback by flush worker, just ++ * update its dirty state. Once the flush worker is done with ++ * the inode it will place it on the appropriate superblock ++ * list, based upon its state. + */ +- if (inode->i_state & I_SYNC) ++ if (inode->i_state & I_SYNC_QUEUED) + goto out_unlock_inode; + + /* +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c +index 3233e5ac9774f..ce2bf9d74224c 100644 +--- a/fs/jbd2/transaction.c ++++ b/fs/jbd2/transaction.c +@@ -1906,6 +1906,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh) + */ + static void __jbd2_journal_unfile_buffer(struct journal_head *jh) + { ++ J_ASSERT_JH(jh, jh->b_transaction != NULL); ++ J_ASSERT_JH(jh, jh->b_next_transaction == NULL); ++ + __jbd2_journal_temp_unlink_buffer(jh); + jh->b_transaction = NULL; + jbd2_journal_put_journal_head(jh); +@@ -1997,6 +2000,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal, + { + struct buffer_head *head; + struct buffer_head *bh; ++ bool has_write_io_error = false; + int ret = 0; + + J_ASSERT(PageLocked(page)); +@@ -2021,11 +2025,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal, + jbd_unlock_bh_state(bh); + if (buffer_jbd(bh)) + goto busy; ++ ++ /* ++ * If we free a metadata buffer which has been failed to ++ * write out, the jbd2 checkpoint procedure will not detect ++ * this failure and may lead to filesystem inconsistency ++ * after cleanup journal tail. ++ */ ++ if (buffer_write_io_error(bh)) { ++ pr_err("JBD2: Error while async write back metadata bh %llu.", ++ (unsigned long long)bh->b_blocknr); ++ has_write_io_error = true; ++ } + } while ((bh = bh->b_this_page) != head); + + ret = try_to_free_buffers(page); + + busy: ++ if (has_write_io_error) ++ jbd2_journal_abort(journal, -EIO); ++ + return ret; + } + +@@ -2453,6 +2472,13 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh) + + was_dirty = test_clear_buffer_jbddirty(bh); + __jbd2_journal_temp_unlink_buffer(jh); ++ ++ /* ++ * b_transaction must be set, otherwise the new b_transaction won't ++ * be holding jh reference ++ */ ++ J_ASSERT_JH(jh, jh->b_transaction != NULL); ++ + /* + * We set b_transaction here because b_next_transaction will inherit + * our jh reference and thus __jbd2_journal_file_buffer() must not +diff --git a/include/linux/fs.h b/include/linux/fs.h +index 842a6a28b0e89..cdcef9b3bc60a 100644 +--- a/include/linux/fs.h ++++ b/include/linux/fs.h +@@ -1882,6 +1882,10 @@ struct super_operations { + * wb stat updates to grab mapping->tree_lock. See + * inode_switch_wb_work_fn() for details. + * ++ * I_SYNC_QUEUED Inode is queued in b_io or b_more_io writeback lists. ++ * Used to detect that mark_inode_dirty() should not move ++ * inode between dirty lists. ++ * + * Q: What is the difference between I_WILL_FREE and I_FREEING? + */ + #define I_DIRTY_SYNC (1 << 0) +@@ -1899,9 +1903,9 @@ struct super_operations { + #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP) + #define I_LINKABLE (1 << 10) + #define I_DIRTY_TIME (1 << 11) +-#define __I_DIRTY_TIME_EXPIRED 12 +-#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) ++#define I_DIRTY_TIME_EXPIRED (1 << 12) + #define I_WB_SWITCH (1 << 13) ++#define I_SYNC_QUEUED (1 << 17) + + #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) + #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME) +diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h +index fff846b512e6e..2609b1c3549e2 100644 +--- a/include/trace/events/writeback.h ++++ b/include/trace/events/writeback.h +@@ -390,8 +390,9 @@ DEFINE_WBC_EVENT(wbc_writepage); + TRACE_EVENT(writeback_queue_io, + TP_PROTO(struct bdi_writeback *wb, + struct wb_writeback_work *work, ++ unsigned long dirtied_before, + int moved), +- TP_ARGS(wb, work, moved), ++ TP_ARGS(wb, work, dirtied_before, moved), + TP_STRUCT__entry( + __array(char, name, 32) + __field(unsigned long, older) +@@ -401,19 +402,17 @@ TRACE_EVENT(writeback_queue_io, + __dynamic_array(char, cgroup, __trace_wb_cgroup_size(wb)) + ), + TP_fast_assign( +- unsigned long *older_than_this = work->older_than_this; + strncpy(__entry->name, dev_name(wb->bdi->dev), 32); +- __entry->older = older_than_this ? *older_than_this : 0; +- __entry->age = older_than_this ? +- (jiffies - *older_than_this) * 1000 / HZ : -1; ++ __entry->older = dirtied_before; ++ __entry->age = (jiffies - dirtied_before) * 1000 / HZ; + __entry->moved = moved; + __entry->reason = work->reason; + __trace_wb_assign_cgroup(__get_str(cgroup), wb); + ), + TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup=%s", + __entry->name, +- __entry->older, /* older_than_this in jiffies */ +- __entry->age, /* older_than_this in relative milliseconds */ ++ __entry->older, /* dirtied_before in jiffies */ ++ __entry->age, /* dirtied_before in relative milliseconds */ + __entry->moved, + __print_symbolic(__entry->reason, WB_WORK_REASON), + __get_str(cgroup) +diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c +index 35b34eccdd109..9484f934aa349 100644 +--- a/kernel/locking/lockdep_proc.c ++++ b/kernel/locking/lockdep_proc.c +@@ -423,7 +423,7 @@ static void seq_lock_time(struct seq_file *m, struct lock_time *lt) + seq_time(m, lt->min); + seq_time(m, lt->max); + seq_time(m, lt->total); +- seq_time(m, lt->nr ? div_s64(lt->total, lt->nr) : 0); ++ seq_time(m, lt->nr ? div64_u64(lt->total, lt->nr) : 0); + } + + static void seq_stats(struct seq_file *m, struct lock_stat_data *data) +diff --git a/net/core/skbuff.c b/net/core/skbuff.c +index 4e944fe986271..e87ec3659ef61 100644 +--- a/net/core/skbuff.c ++++ b/net/core/skbuff.c +@@ -4370,8 +4370,8 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb) + skb = skb_share_check(skb, GFP_ATOMIC); + if (unlikely(!skb)) + goto err_free; +- +- if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) ++ /* We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). */ ++ if (unlikely(!pskb_may_pull(skb, VLAN_HLEN + sizeof(unsigned short)))) + goto err_free; + + vhdr = (struct vlan_hdr *)skb->data; +diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c +index 8d2e54c4bda6b..0975a28f8686c 100644 +--- a/net/tipc/netlink_compat.c ++++ b/net/tipc/netlink_compat.c +@@ -250,8 +250,9 @@ err_out: + static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, + struct tipc_nl_compat_msg *msg) + { +- int err; ++ struct nlmsghdr *nlh; + struct sk_buff *arg; ++ int err; + + if (msg->req_type && (!msg->req_size || + !TLV_CHECK_TYPE(msg->req, msg->req_type))) +@@ -280,6 +281,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, + return -ENOMEM; + } + ++ nlh = nlmsg_put(arg, 0, 0, tipc_genl_family.id, 0, NLM_F_MULTI); ++ if (!nlh) { ++ kfree_skb(arg); ++ kfree_skb(msg->rep); ++ msg->rep = NULL; ++ return -EMSGSIZE; ++ } ++ nlmsg_end(arg, nlh); ++ + err = __tipc_nl_compat_dumpit(cmd, msg, arg); + if (err) { + kfree_skb(msg->rep); +diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c +index 2706f271a83b0..8a174c170e0aa 100644 +--- a/sound/pci/cs46xx/cs46xx_lib.c ++++ b/sound/pci/cs46xx/cs46xx_lib.c +@@ -780,7 +780,7 @@ static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned + rate = 48000 / 9; + + /* +- * We can not capture at at rate greater than the Input Rate (48000). ++ * We can not capture at a rate greater than the Input Rate (48000). + * Return an error if an attempt is made to stray outside that limit. + */ + if (rate > 48000) +diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c +index 7488e1b7a7707..4e726d39b05d1 100644 +--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c ++++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c +@@ -1742,7 +1742,7 @@ int cs46xx_iec958_pre_open (struct snd_cs46xx *chip) + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + + if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) { +- /* remove AsynchFGTxSCB and and PCMSerialInput_II */ ++ /* remove AsynchFGTxSCB and PCMSerialInput_II */ + cs46xx_dsp_disable_spdif_out (chip); + + /* save state */ +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c +index 825d9b27dbe12..4962a9d8a572b 100644 +--- a/sound/pci/hda/hda_codec.c ++++ b/sound/pci/hda/hda_codec.c +@@ -3496,7 +3496,7 @@ EXPORT_SYMBOL_GPL(snd_hda_set_power_save); + * @nid: NID to check / update + * + * Check whether the given NID is in the amp list. If it's in the list, +- * check the current AMP status, and update the the power-status according ++ * check the current AMP status, and update the power-status according + * to the mute status. + * + * This function is supposed to be set or called from the check_power_status +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c +index 869c322ddae31..7cd1047a4edf3 100644 +--- a/sound/pci/hda/hda_generic.c ++++ b/sound/pci/hda/hda_generic.c +@@ -837,7 +837,7 @@ static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, + } + } + +-/* sync power of each widget in the the given path */ ++/* sync power of each widget in the given path */ + static hda_nid_t path_power_update(struct hda_codec *codec, + struct nid_path *path, + bool allow_powerdown) +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c +index d1a6d20ace0da..80b72d0702c5e 100644 +--- a/sound/pci/hda/patch_sigmatel.c ++++ b/sound/pci/hda/patch_sigmatel.c +@@ -862,7 +862,7 @@ static int stac_auto_create_beep_ctls(struct hda_codec *codec, + static struct snd_kcontrol_new beep_vol_ctl = + HDA_CODEC_VOLUME(NULL, 0, 0, 0); + +- /* check for mute support for the the amp */ ++ /* check for mute support for the amp */ + if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { + const struct snd_kcontrol_new *temp; + if (spec->anabeep_nid == nid) +diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c +index 3919aed39ca03..5e52086d7b986 100644 +--- a/sound/pci/ice1712/prodigy192.c ++++ b/sound/pci/ice1712/prodigy192.c +@@ -31,7 +31,7 @@ + * Experimentally I found out that only a combination of + * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 - + * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct +- * sampling rate. That means the the FPGA doubles the ++ * sampling rate. That means that the FPGA doubles the + * MCK01 rate. + * + * Copyright (c) 2003 Takashi Iwai +diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c +index 4cf3200e988b0..df44135e1b0c9 100644 +--- a/sound/pci/oxygen/xonar_dg.c ++++ b/sound/pci/oxygen/xonar_dg.c +@@ -39,7 +39,7 @@ + * GPIO 4 <- headphone detect + * GPIO 5 -> enable ADC analog circuit for the left channel + * GPIO 6 -> enable ADC analog circuit for the right channel +- * GPIO 7 -> switch green rear output jack between CS4245 and and the first ++ * GPIO 7 -> switch green rear output jack between CS4245 and the first + * channel of CS4361 (mechanical relay) + * GPIO 8 -> enable output to speakers + * +diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c +index fef3b9a21a667..e441e23a37e4f 100644 +--- a/sound/soc/tegra/tegra30_ahub.c ++++ b/sound/soc/tegra/tegra30_ahub.c +@@ -656,8 +656,10 @@ static int tegra30_ahub_resume(struct device *dev) + int ret; + + ret = pm_runtime_get_sync(dev); +- if (ret < 0) ++ if (ret < 0) { ++ pm_runtime_put(dev); + return ret; ++ } + ret = regcache_sync(ahub->regmap_ahub); + ret |= regcache_sync(ahub->regmap_apbif); + pm_runtime_put(dev); +diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c +index 8e55583aa104e..516f37896092c 100644 +--- a/sound/soc/tegra/tegra30_i2s.c ++++ b/sound/soc/tegra/tegra30_i2s.c +@@ -552,8 +552,10 @@ static int tegra30_i2s_resume(struct device *dev) + int ret; + + ret = pm_runtime_get_sync(dev); +- if (ret < 0) ++ if (ret < 0) { ++ pm_runtime_put(dev); + return ret; ++ } + ret = regcache_sync(i2s->regmap); + pm_runtime_put(dev); + +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h +index 689fd3103e5b6..a917b7e02d312 100644 +--- a/sound/usb/quirks-table.h ++++ b/sound/usb/quirks-table.h +@@ -3331,8 +3331,8 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), + * they pretend to be 96kHz mono as a workaround for stereo being broken + * by that... + * +- * They also have swapped L-R channels, but that's for userspace to deal +- * with. ++ * They also have an issue with initial stream alignment that causes the ++ * channels to be swapped and out of phase, which is dealt with in quirks.c. + */ + { + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c +index 94110b1dcd3d8..031baa43646fb 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c +@@ -91,8 +91,6 @@ int back_to_back_ebbs(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + event_close(&event); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +index 7c57a8d79535d..361e0be9df9ae 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c +@@ -42,8 +42,6 @@ int cycles(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + event_close(&event); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c +index ecf5ee3283a3e..fe7d0dc2a1a26 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c +@@ -99,8 +99,6 @@ int cycles_with_freeze(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + printf("EBBs while frozen %d\n", ebbs_while_frozen); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c +index c0faba520b35c..b9b30f974b5ea 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c +@@ -71,8 +71,6 @@ int cycles_with_mmcr2(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + event_close(&event); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c +index 9729d9f902187..4154498bc5dc5 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c +@@ -398,8 +398,6 @@ int ebb_child(union pipe read_pipe, union pipe write_pipe) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + event_close(&event); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c +index a991d2ea8d0a1..174e4f4dae6c0 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c +@@ -38,8 +38,6 @@ static int victim_child(union pipe read_pipe, union pipe write_pipe) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + FAIL_IF(ebb_state.stats.ebb_count == 0); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c +index eb8acb78bc6c1..531083accfcad 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c +@@ -75,7 +75,6 @@ static int test_body(void) + ebb_freeze_pmcs(); + ebb_global_disable(); + +- count_pmc(4, sample_period); + mtspr(SPRN_PMC4, 0xdead); + + dump_summary_ebb_state(); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c +index 6ff8c8ff27d66..035c02273cd49 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c +@@ -70,13 +70,6 @@ int multi_counter(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- count_pmc(2, sample_period); +- count_pmc(3, sample_period); +- count_pmc(4, sample_period); +- count_pmc(5, sample_period); +- count_pmc(6, sample_period); +- + dump_ebb_state(); + + for (i = 0; i < 6; i++) +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c +index 037cb6154f360..3e9d4ac965c85 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c +@@ -61,8 +61,6 @@ static int cycles_child(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_summary_ebb_state(); + + event_close(&event); +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c +index c5fa64790c22e..d90891fe96a32 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c +@@ -82,8 +82,6 @@ static int test_body(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(1, sample_period); +- + dump_ebb_state(); + + if (mmcr0_mismatch) +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c +index 30e1ac62e8cb4..8ca92b9ee5b01 100644 +--- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c ++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c +@@ -76,8 +76,6 @@ int pmc56_overflow(void) + ebb_global_disable(); + ebb_freeze_pmcs(); + +- count_pmc(2, sample_period); +- + dump_ebb_state(); + + printf("PMC5/6 overflow %d\n", pmc56_overflowed); diff --git a/patch/kernel/rockpis-legacy/patch-4.4.235-236-changed.patch b/patch/kernel/rockpis-legacy/patch-4.4.235-236-changed.patch new file mode 100644 index 000000000..edf469e59 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.235-236-changed.patch @@ -0,0 +1,2361 @@ +diff --git a/Documentation/filesystems/affs.txt b/Documentation/filesystems/affs.txt +index 71b63c2b98410..a8f1a58e36922 100644 +--- a/Documentation/filesystems/affs.txt ++++ b/Documentation/filesystems/affs.txt +@@ -93,13 +93,15 @@ The Amiga protection flags RWEDRWEDHSPARWED are handled as follows: + + - R maps to r for user, group and others. On directories, R implies x. + +- - If both W and D are allowed, w will be set. ++ - W maps to w. + + - E maps to x. + +- - H and P are always retained and ignored under Linux. ++ - D is ignored. + +- - A is always reset when a file is written to. ++ - H, S and P are always retained and ignored under Linux. ++ ++ - A is cleared when a file is written to. + + User id and group id will be used unless set[gu]id are given as mount + options. Since most of the Amiga file systems are single user systems +@@ -111,11 +113,13 @@ Linux -> Amiga: + + The Linux rwxrwxrwx file mode is handled as follows: + +- - r permission will set R for user, group and others. ++ - r permission will allow R for user, group and others. ++ ++ - w permission will allow W for user, group and others. + +- - w permission will set W and D for user, group and others. ++ - x permission of the user will allow E for plain files. + +- - x permission of the user will set E for plain files. ++ - D will be allowed for user, group and others. + + - All other flags (suid, sgid, ...) are ignored and will + not be retained. +diff --git a/Makefile b/Makefile +index a32490d4471f3..b954cb21fddc7 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 235 ++SUBLEVEL = 236 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h +index 6d6556ca24aa2..f715419a72cf0 100644 +--- a/arch/s390/include/asm/percpu.h ++++ b/arch/s390/include/asm/percpu.h +@@ -28,7 +28,7 @@ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ old__, new__, prev__; \ + pcp_op_T__ *ptr__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + ptr__ = raw_cpu_ptr(&(pcp)); \ + prev__ = *ptr__; \ + do { \ +@@ -36,7 +36,7 @@ + new__ = old__ op (val); \ + prev__ = cmpxchg(ptr__, old__, new__); \ + } while (prev__ != old__); \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + new__; \ + }) + +@@ -67,7 +67,7 @@ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ val__ = (val); \ + pcp_op_T__ old__, *ptr__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + ptr__ = raw_cpu_ptr(&(pcp)); \ + if (__builtin_constant_p(val__) && \ + ((szcast)val__ > -129) && ((szcast)val__ < 128)) { \ +@@ -83,7 +83,7 @@ + : [val__] "d" (val__) \ + : "cc"); \ + } \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + } + + #define this_cpu_add_4(pcp, val) arch_this_cpu_add(pcp, val, "laa", "asi", int) +@@ -94,14 +94,14 @@ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ val__ = (val); \ + pcp_op_T__ old__, *ptr__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + ptr__ = raw_cpu_ptr(&(pcp)); \ + asm volatile( \ + op " %[old__],%[val__],%[ptr__]\n" \ + : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__) \ + : [val__] "d" (val__) \ + : "cc"); \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + old__ + val__; \ + }) + +@@ -113,14 +113,14 @@ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ val__ = (val); \ + pcp_op_T__ old__, *ptr__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + ptr__ = raw_cpu_ptr(&(pcp)); \ + asm volatile( \ + op " %[old__],%[val__],%[ptr__]\n" \ + : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__) \ + : [val__] "d" (val__) \ + : "cc"); \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + } + + #define this_cpu_and_4(pcp, val) arch_this_cpu_to_op(pcp, val, "lan") +@@ -135,10 +135,10 @@ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ ret__; \ + pcp_op_T__ *ptr__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + ptr__ = raw_cpu_ptr(&(pcp)); \ + ret__ = cmpxchg(ptr__, oval, nval); \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + ret__; \ + }) + +@@ -151,10 +151,10 @@ + ({ \ + typeof(pcp) *ptr__; \ + typeof(pcp) ret__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + ptr__ = raw_cpu_ptr(&(pcp)); \ + ret__ = xchg(ptr__, nval); \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + ret__; \ + }) + +@@ -170,11 +170,11 @@ + typeof(pcp1) *p1__; \ + typeof(pcp2) *p2__; \ + int ret__; \ +- preempt_disable(); \ ++ preempt_disable_notrace(); \ + p1__ = raw_cpu_ptr(&(pcp1)); \ + p2__ = raw_cpu_ptr(&(pcp2)); \ + ret__ = __cmpxchg_double(p1__, p2__, o1__, o2__, n1__, n2__); \ +- preempt_enable(); \ ++ preempt_enable_notrace(); \ + ret__; \ + }) + +diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c +index 941ace0521306..5276074d0e364 100644 +--- a/drivers/dma/at_hdmac.c ++++ b/drivers/dma/at_hdmac.c +@@ -1817,6 +1817,8 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec, + return NULL; + + dmac_pdev = of_find_device_by_node(dma_spec->np); ++ if (!dmac_pdev) ++ return NULL; + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); +diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c +index 1e1f2986eba8f..86c591481dfe9 100644 +--- a/drivers/dma/of-dma.c ++++ b/drivers/dma/of-dma.c +@@ -72,12 +72,12 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec, + return NULL; + + chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target); +- if (chan) { +- chan->router = ofdma->dma_router; +- chan->route_data = route_data; +- } else { ++ if (IS_ERR_OR_NULL(chan)) { + ofdma->dma_router->route_free(ofdma->dma_router->dev, + route_data); ++ } else { ++ chan->router = ofdma->dma_router; ++ chan->route_data = route_data; + } + + /* +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c +index 799c182c3eacc..9aa57b37381a9 100644 +--- a/drivers/dma/pl330.c ++++ b/drivers/dma/pl330.c +@@ -2629,6 +2629,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, + while (burst != (1 << desc->rqcfg.brst_size)) + desc->rqcfg.brst_size++; + ++ desc->rqcfg.brst_len = get_burst_len(desc, len); + /* + * If burst size is smaller than bus width then make sure we only + * transfer one at a time to avoid a burst stradling an MFIFO entry. +@@ -2636,7 +2637,6 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, + if (desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width) + desc->rqcfg.brst_len = 1; + +- desc->rqcfg.brst_len = get_burst_len(desc, len); + desc->bytes_requested = len; + + desc->txd.flags = flags; +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c +index 325adbef134cc..9425c789b0974 100644 +--- a/drivers/hid/hid-core.c ++++ b/drivers/hid/hid-core.c +@@ -1367,6 +1367,17 @@ static void hid_output_field(const struct hid_device *hid, + } + } + ++/* ++ * Compute the size of a report. ++ */ ++static size_t hid_compute_report_size(struct hid_report *report) ++{ ++ if (report->size) ++ return ((report->size - 1) >> 3) + 1; ++ ++ return 0; ++} ++ + /* + * Create a report. 'data' has to be allocated using + * hid_alloc_report_buf() so that it has proper size. +@@ -1379,7 +1390,7 @@ void hid_output_report(struct hid_report *report, __u8 *data) + if (report->id > 0) + *data++ = report->id; + +- memset(data, 0, ((report->size - 1) >> 3) + 1); ++ memset(data, 0, hid_compute_report_size(report)); + for (n = 0; n < report->maxfield; n++) + hid_output_field(report->device, report->field[n], data); + } +@@ -1506,7 +1517,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, + csize--; + } + +- rsize = ((report->size - 1) >> 3) + 1; ++ rsize = hid_compute_report_size(report); + + if (report_enum->numbered && rsize >= HID_MAX_BUFFER_SIZE) + rsize = HID_MAX_BUFFER_SIZE - 1; +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c +index 3331bf8ad85e6..c033d12070c3d 100644 +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -994,6 +994,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel + } + + mapped: ++ /* Mapping failed, bail out */ ++ if (!bit) ++ return; ++ + if (device->driver->input_mapped && + device->driver->input_mapped(device, hidinput, field, usage, + &bit, &max) < 0) { +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c +index 56c4a81d3ea24..5187f3975c655 100644 +--- a/drivers/hid/hid-multitouch.c ++++ b/drivers/hid/hid-multitouch.c +@@ -569,6 +569,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, + case HID_UP_BUTTON: + code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE); + hid_map_usage(hi, usage, bit, max, EV_KEY, code); ++ if (!*bit) ++ return -1; + input_set_capability(hi->input, EV_KEY, code); + return 1; + +diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c +index 0af7fd311979d..587fc5c686b3c 100644 +--- a/drivers/hwmon/applesmc.c ++++ b/drivers/hwmon/applesmc.c +@@ -758,15 +758,18 @@ static ssize_t applesmc_light_show(struct device *dev, + } + + ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length); ++ if (ret) ++ goto out; + /* newer macbooks report a single 10-bit bigendian value */ + if (data_length == 10) { + left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2; + goto out; + } + left = buffer[2]; ++ ++ ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length); + if (ret) + goto out; +- ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length); + right = buffer[2]; + + out: +@@ -814,12 +817,11 @@ static ssize_t applesmc_show_fan_speed(struct device *dev, + sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr)); + + ret = applesmc_read_key(newkey, buffer, 2); +- speed = ((buffer[0] << 8 | buffer[1]) >> 2); +- + if (ret) + return ret; +- else +- return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed); ++ ++ speed = ((buffer[0] << 8 | buffer[1]) >> 2); ++ return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed); + } + + static ssize_t applesmc_store_fan_speed(struct device *dev, +@@ -854,12 +856,11 @@ static ssize_t applesmc_show_fan_manual(struct device *dev, + u8 buffer[2]; + + ret = applesmc_read_key(FANS_MANUAL, buffer, 2); +- manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01; +- + if (ret) + return ret; +- else +- return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual); ++ ++ manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01; ++ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual); + } + + static ssize_t applesmc_store_fan_manual(struct device *dev, +@@ -875,10 +876,11 @@ static ssize_t applesmc_store_fan_manual(struct device *dev, + return -EINVAL; + + ret = applesmc_read_key(FANS_MANUAL, buffer, 2); +- val = (buffer[0] << 8 | buffer[1]); + if (ret) + goto out; + ++ val = (buffer[0] << 8 | buffer[1]); ++ + if (input) + val = val | (0x01 << to_index(attr)); + else +@@ -954,13 +956,12 @@ static ssize_t applesmc_key_count_show(struct device *dev, + u32 count; + + ret = applesmc_read_key(KEY_COUNT_KEY, buffer, 4); +- count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) + +- ((u32)buffer[2]<<8) + buffer[3]; +- + if (ret) + return ret; +- else +- return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count); ++ ++ count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) + ++ ((u32)buffer[2]<<8) + buffer[3]; ++ return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count); + } + + static ssize_t applesmc_key_at_index_read_show(struct device *dev, +diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c +index ac596928f6b40..ce125ec23d2a5 100644 +--- a/drivers/iommu/intel_irq_remapping.c ++++ b/drivers/iommu/intel_irq_remapping.c +@@ -486,12 +486,18 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu) + + /* Enable interrupt-remapping */ + iommu->gcmd |= DMA_GCMD_IRE; +- iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format MSIs */ + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); +- + IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, + readl, (sts & DMA_GSTS_IRES), sts); + ++ /* Block compatibility-format MSIs */ ++ if (sts & DMA_GSTS_CFIS) { ++ iommu->gcmd &= ~DMA_GCMD_CFI; ++ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); ++ IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, ++ readl, !(sts & DMA_GSTS_CFIS), sts); ++ } ++ + /* + * With CFI clear in the Global Command register, we should be + * protected from dangerous (i.e. compatibility) interrupts +diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c +index 905badc6cb179..216675b96e029 100644 +--- a/drivers/md/dm-cache-metadata.c ++++ b/drivers/md/dm-cache-metadata.c +@@ -501,12 +501,16 @@ static int __create_persistent_data_objects(struct dm_cache_metadata *cmd, + CACHE_MAX_CONCURRENT_LOCKS); + if (IS_ERR(cmd->bm)) { + DMERR("could not create block manager"); +- return PTR_ERR(cmd->bm); ++ r = PTR_ERR(cmd->bm); ++ cmd->bm = NULL; ++ return r; + } + + r = __open_or_format_metadata(cmd, may_format_device); +- if (r) ++ if (r) { + dm_block_manager_destroy(cmd->bm); ++ cmd->bm = NULL; ++ } + + return r; + } +diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c +index 2711aa965445c..266d366fc2f08 100644 +--- a/drivers/md/dm-thin-metadata.c ++++ b/drivers/md/dm-thin-metadata.c +@@ -700,12 +700,16 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool f + THIN_MAX_CONCURRENT_LOCKS); + if (IS_ERR(pmd->bm)) { + DMERR("could not create block manager"); +- return PTR_ERR(pmd->bm); ++ r = PTR_ERR(pmd->bm); ++ pmd->bm = NULL; ++ return r; + } + + r = __open_or_format_metadata(pmd, format_device); +- if (r) ++ if (r) { + dm_block_manager_destroy(pmd->bm); ++ pmd->bm = NULL; ++ } + + return r; + } +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +index a3949c1a0c234..2da1c22946450 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -4612,18 +4612,18 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) + } + } + +- bnxt_enable_napi(bp); +- + rc = bnxt_init_nic(bp, irq_re_init); + if (rc) { + netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); +- goto open_err; ++ goto open_err_irq; + } + ++ bnxt_enable_napi(bp); ++ + if (link_re_init) { + rc = bnxt_update_phy_setting(bp); + if (rc) +- goto open_err; ++ netdev_warn(bp->dev, "failed to update phy settings\n"); + } + + if (irq_re_init) { +@@ -4644,9 +4644,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) + + return 0; + +-open_err: +- bnxt_disable_napi(bp); +- + open_err_irq: + bnxt_del_napi(bp); + +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +index 45bd628eaf3aa..416fb16686a61 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +@@ -991,6 +991,9 @@ static int bnxt_get_nvram_directory(struct net_device *dev, u32 len, u8 *data) + if (rc != 0) + return rc; + ++ if (!dir_entries || !entry_length) ++ return -EIO; ++ + /* Insert 2 bytes of directory info (count and size of entries) */ + if (len < 2) + return -EINVAL; +diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c +index e198427d0f292..2ee2b6e858283 100644 +--- a/drivers/net/ethernet/broadcom/tg3.c ++++ b/drivers/net/ethernet/broadcom/tg3.c +@@ -7203,8 +7203,8 @@ static inline void tg3_reset_task_schedule(struct tg3 *tp) + + static inline void tg3_reset_task_cancel(struct tg3 *tp) + { +- cancel_work_sync(&tp->reset_task); +- tg3_flag_clear(tp, RESET_TASK_PENDING); ++ if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags)) ++ cancel_work_sync(&tp->reset_task); + tg3_flag_clear(tp, TX_RECOVERY_PENDING); + } + +@@ -11176,18 +11176,27 @@ static void tg3_reset_task(struct work_struct *work) + + tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); + err = tg3_init_hw(tp, true); +- if (err) ++ if (err) { ++ tg3_full_unlock(tp); ++ tp->irq_sync = 0; ++ tg3_napi_enable(tp); ++ /* Clear this flag so that tg3_reset_task_cancel() will not ++ * call cancel_work_sync() and wait forever. ++ */ ++ tg3_flag_clear(tp, RESET_TASK_PENDING); ++ dev_close(tp->dev); + goto out; ++ } + + tg3_netif_start(tp); + +-out: + tg3_full_unlock(tp); + + if (!err) + tg3_phy_start(tp); + + tg3_flag_clear(tp, RESET_TASK_PENDING); ++out: + rtnl_unlock(); + } + +diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c +index 53833c06696fb..00a105c63567f 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/mr.c ++++ b/drivers/net/ethernet/mellanox/mlx4/mr.c +@@ -114,7 +114,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order) + goto err_out; + + for (i = 0; i <= buddy->max_order; ++i) { +- s = BITS_TO_LONGS(1 << (buddy->max_order - i)); ++ s = BITS_TO_LONGS(1UL << (buddy->max_order - i)); + buddy->bits[i] = kcalloc(s, sizeof (long), GFP_KERNEL | __GFP_NOWARN); + if (!buddy->bits[i]) { + buddy->bits[i] = vzalloc(s * sizeof(long)); +diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c +index 460b29ac5fd86..d5bf0f2753079 100644 +--- a/drivers/net/ethernet/renesas/ravb_main.c ++++ b/drivers/net/ethernet/renesas/ravb_main.c +@@ -1214,12 +1214,64 @@ static const struct ethtool_ops ravb_ethtool_ops = { + .get_ts_info = ravb_get_ts_info, + }; + ++/* MDIO bus init function */ ++static int ravb_mdio_init(struct ravb_private *priv) ++{ ++ struct platform_device *pdev = priv->pdev; ++ struct device *dev = &pdev->dev; ++ int error; ++ ++ /* Bitbang init */ ++ priv->mdiobb.ops = &bb_ops; ++ ++ /* MII controller setting */ ++ priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); ++ if (!priv->mii_bus) ++ return -ENOMEM; ++ ++ /* Hook up MII support for ethtool */ ++ priv->mii_bus->name = "ravb_mii"; ++ priv->mii_bus->parent = dev; ++ snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", ++ pdev->name, pdev->id); ++ ++ /* Register MDIO bus */ ++ error = of_mdiobus_register(priv->mii_bus, dev->of_node); ++ if (error) ++ goto out_free_bus; ++ ++ return 0; ++ ++out_free_bus: ++ free_mdio_bitbang(priv->mii_bus); ++ return error; ++} ++ ++/* MDIO bus release function */ ++static int ravb_mdio_release(struct ravb_private *priv) ++{ ++ /* Unregister mdio bus */ ++ mdiobus_unregister(priv->mii_bus); ++ ++ /* Free bitbang info */ ++ free_mdio_bitbang(priv->mii_bus); ++ ++ return 0; ++} ++ + /* Network device open function for Ethernet AVB */ + static int ravb_open(struct net_device *ndev) + { + struct ravb_private *priv = netdev_priv(ndev); + int error; + ++ /* MDIO bus init */ ++ error = ravb_mdio_init(priv); ++ if (error) { ++ netdev_err(ndev, "failed to initialize MDIO\n"); ++ return error; ++ } ++ + napi_enable(&priv->napi[RAVB_BE]); + napi_enable(&priv->napi[RAVB_NC]); + +@@ -1268,6 +1320,7 @@ out_free_irq: + out_napi_off: + napi_disable(&priv->napi[RAVB_NC]); + napi_disable(&priv->napi[RAVB_BE]); ++ ravb_mdio_release(priv); + return error; + } + +@@ -1561,6 +1614,8 @@ static int ravb_close(struct net_device *ndev) + ravb_ring_free(ndev, RAVB_BE); + ravb_ring_free(ndev, RAVB_NC); + ++ ravb_mdio_release(priv); ++ + return 0; + } + +@@ -1664,51 +1719,6 @@ static const struct net_device_ops ravb_netdev_ops = { + .ndo_change_mtu = eth_change_mtu, + }; + +-/* MDIO bus init function */ +-static int ravb_mdio_init(struct ravb_private *priv) +-{ +- struct platform_device *pdev = priv->pdev; +- struct device *dev = &pdev->dev; +- int error; +- +- /* Bitbang init */ +- priv->mdiobb.ops = &bb_ops; +- +- /* MII controller setting */ +- priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); +- if (!priv->mii_bus) +- return -ENOMEM; +- +- /* Hook up MII support for ethtool */ +- priv->mii_bus->name = "ravb_mii"; +- priv->mii_bus->parent = dev; +- snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", +- pdev->name, pdev->id); +- +- /* Register MDIO bus */ +- error = of_mdiobus_register(priv->mii_bus, dev->of_node); +- if (error) +- goto out_free_bus; +- +- return 0; +- +-out_free_bus: +- free_mdio_bitbang(priv->mii_bus); +- return error; +-} +- +-/* MDIO bus release function */ +-static int ravb_mdio_release(struct ravb_private *priv) +-{ +- /* Unregister mdio bus */ +- mdiobus_unregister(priv->mii_bus); +- +- /* Free bitbang info */ +- free_mdio_bitbang(priv->mii_bus); +- +- return 0; +-} +- + static const struct of_device_id ravb_match_table[] = { + { .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 }, + { .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 }, +@@ -1847,13 +1857,6 @@ static int ravb_probe(struct platform_device *pdev) + eth_hw_addr_random(ndev); + } + +- /* MDIO bus init */ +- error = ravb_mdio_init(priv); +- if (error) { +- dev_err(&pdev->dev, "failed to initialize MDIO\n"); +- goto out_dma_free; +- } +- + netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64); + netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64); + +@@ -1873,8 +1876,6 @@ static int ravb_probe(struct platform_device *pdev) + out_napi_del: + netif_napi_del(&priv->napi[RAVB_NC]); + netif_napi_del(&priv->napi[RAVB_BE]); +- ravb_mdio_release(priv); +-out_dma_free: + dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, + priv->desc_bat_dma); + out_release: +@@ -1899,7 +1900,6 @@ static int ravb_remove(struct platform_device *pdev) + unregister_netdev(ndev); + netif_napi_del(&priv->napi[RAVB_NC]); + netif_napi_del(&priv->napi[RAVB_BE]); +- ravb_mdio_release(priv); + pm_runtime_disable(&pdev->dev); + free_netdev(ndev); + platform_set_drvdata(pdev, NULL); +diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c +index 2092ef6431f20..712765976a221 100644 +--- a/drivers/net/usb/asix_common.c ++++ b/drivers/net/usb/asix_common.c +@@ -251,7 +251,7 @@ int asix_read_phy_addr(struct usbnet *dev, int internal) + + netdev_dbg(dev->net, "asix_get_phy_addr()\n"); + +- if (ret < 0) { ++ if (ret < 2) { + netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret); + goto out; + } +diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c +index 0b4bdd39106b0..fb18801d0fe7b 100644 +--- a/drivers/net/usb/dm9601.c ++++ b/drivers/net/usb/dm9601.c +@@ -624,6 +624,10 @@ static const struct usb_device_id products[] = { + USB_DEVICE(0x0a46, 0x1269), /* DM9621A USB to Fast Ethernet Adapter */ + .driver_info = (unsigned long)&dm9601_info, + }, ++ { ++ USB_DEVICE(0x0586, 0x3427), /* ZyXEL Keenetic Plus DSL xDSL modem */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, + {}, // END + }; + +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c +index 4391430e25273..14eca1f80ce36 100644 +--- a/drivers/net/usb/qmi_wwan.c ++++ b/drivers/net/usb/qmi_wwan.c +@@ -14,7 +14,9 @@ + #include + #include + #include ++#include + #include ++#include + #include + #include + #include +@@ -48,11 +50,104 @@ + struct qmi_wwan_state { + struct usb_driver *subdriver; + atomic_t pmcount; +- unsigned long unused; ++ unsigned long flags; + struct usb_interface *control; + struct usb_interface *data; + }; + ++enum qmi_wwan_flags { ++ QMI_WWAN_FLAG_RAWIP = 1 << 0, ++}; ++ ++enum qmi_wwan_quirks { ++ QMI_WWAN_QUIRK_DTR = 1 << 0, /* needs "set DTR" request */ ++}; ++ ++static void qmi_wwan_netdev_setup(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct qmi_wwan_state *info = (void *)&dev->data; ++ ++ if (info->flags & QMI_WWAN_FLAG_RAWIP) { ++ net->header_ops = NULL; /* No header */ ++ net->type = ARPHRD_NONE; ++ net->hard_header_len = 0; ++ net->addr_len = 0; ++ net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; ++ netdev_dbg(net, "mode: raw IP\n"); ++ } else if (!net->header_ops) { /* don't bother if already set */ ++ ether_setup(net); ++ netdev_dbg(net, "mode: Ethernet\n"); ++ } ++ ++ /* recalculate buffers after changing hard_header_len */ ++ usbnet_change_mtu(net, net->mtu); ++} ++ ++static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf) ++{ ++ struct usbnet *dev = netdev_priv(to_net_dev(d)); ++ struct qmi_wwan_state *info = (void *)&dev->data; ++ ++ return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N'); ++} ++ ++static ssize_t raw_ip_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len) ++{ ++ struct usbnet *dev = netdev_priv(to_net_dev(d)); ++ struct qmi_wwan_state *info = (void *)&dev->data; ++ bool enable; ++ int ret; ++ ++ if (strtobool(buf, &enable)) ++ return -EINVAL; ++ ++ /* no change? */ ++ if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP)) ++ return len; ++ ++ if (!rtnl_trylock()) ++ return restart_syscall(); ++ ++ /* we don't want to modify a running netdev */ ++ if (netif_running(dev->net)) { ++ netdev_err(dev->net, "Cannot change a running device\n"); ++ ret = -EBUSY; ++ goto err; ++ } ++ ++ /* let other drivers deny the change */ ++ ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net); ++ ret = notifier_to_errno(ret); ++ if (ret) { ++ netdev_err(dev->net, "Type change was refused\n"); ++ goto err; ++ } ++ ++ if (enable) ++ info->flags |= QMI_WWAN_FLAG_RAWIP; ++ else ++ info->flags &= ~QMI_WWAN_FLAG_RAWIP; ++ qmi_wwan_netdev_setup(dev->net); ++ call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net); ++ ret = len; ++err: ++ rtnl_unlock(); ++ return ret; ++} ++ ++static DEVICE_ATTR_RW(raw_ip); ++ ++static struct attribute *qmi_wwan_sysfs_attrs[] = { ++ &dev_attr_raw_ip.attr, ++ NULL, ++}; ++ ++static struct attribute_group qmi_wwan_sysfs_attr_group = { ++ .name = "qmi", ++ .attrs = qmi_wwan_sysfs_attrs, ++}; ++ + /* default ethernet address used by the modem */ + static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3}; + +@@ -80,6 +175,8 @@ static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00}; + */ + static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb) + { ++ struct qmi_wwan_state *info = (void *)&dev->data; ++ bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP; + __be16 proto; + + /* This check is no longer done by usbnet */ +@@ -94,15 +191,25 @@ static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb) + proto = htons(ETH_P_IPV6); + break; + case 0x00: ++ if (rawip) ++ return 0; + if (is_multicast_ether_addr(skb->data)) + return 1; + /* possibly bogus destination - rewrite just in case */ + skb_reset_mac_header(skb); + goto fix_dest; + default: ++ if (rawip) ++ return 0; + /* pass along other packets without modifications */ + return 1; + } ++ if (rawip) { ++ skb->dev = dev->net; /* normally set by eth_type_trans */ ++ skb->protocol = proto; ++ return 1; ++ } ++ + if (skb_headroom(skb) < ETH_HLEN) + return 0; + skb_push(skb, ETH_HLEN); +@@ -223,6 +330,20 @@ err: + return rv; + } + ++/* Send CDC SetControlLineState request, setting or clearing the DTR. ++ * "Required for Autoconnect and 9x30 to wake up" according to the ++ * GobiNet driver. The requirement has been verified on an MDM9230 ++ * based Sierra Wireless MC7455 ++ */ ++static int qmi_wwan_change_dtr(struct usbnet *dev, bool on) ++{ ++ u8 intf = dev->intf->cur_altsetting->desc.bInterfaceNumber; ++ ++ return usbnet_write_cmd(dev, USB_CDC_REQ_SET_CONTROL_LINE_STATE, ++ USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, ++ on ? 0x01 : 0x00, intf, NULL, 0); ++} ++ + static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) + { + int status = -1; +@@ -257,7 +378,10 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) + "bogus CDC Union: master=%u, slave=%u\n", + cdc_union->bMasterInterface0, + cdc_union->bSlaveInterface0); +- goto err; ++ ++ /* ignore and continue... */ ++ cdc_union = NULL; ++ info->data = intf; + } + } + +@@ -280,6 +404,29 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) + usb_driver_release_interface(driver, info->data); + } + ++ /* disabling remote wakeup on MDM9x30 devices has the same ++ * effect as clearing DTR. The device will not respond to QMI ++ * requests until we set DTR again. This is similar to a ++ * QMI_CTL SYNC request, clearing a lot of firmware state ++ * including the client ID allocations. ++ * ++ * Our usage model allows a session to span multiple ++ * open/close events, so we must prevent the firmware from ++ * clearing out state the clients might need. ++ * ++ * MDM9x30 is the first QMI chipset with USB3 support. Abuse ++ * this fact to enable the quirk for all USB3 devices. ++ * ++ * There are also chipsets with the same "set DTR" requirement ++ * but without USB3 support. Devices based on these chips ++ * need a quirk flag in the device ID table. ++ */ ++ if (dev->driver_info->data & QMI_WWAN_QUIRK_DTR || ++ le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) { ++ qmi_wwan_manage_power(dev, 1); ++ qmi_wwan_change_dtr(dev, true); ++ } ++ + /* Never use the same address on both ends of the link, even if the + * buggy firmware told us to. Or, if device is assigned the well-known + * buggy firmware MAC address, replace it with a random address, +@@ -294,6 +441,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) + dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */ + } + dev->net->netdev_ops = &qmi_wwan_netdev_ops; ++ dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group; + err: + return status; + } +@@ -307,6 +455,12 @@ static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf) + if (info->subdriver && info->subdriver->disconnect) + info->subdriver->disconnect(info->control); + ++ /* disable MDM9x30 quirk */ ++ if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) { ++ qmi_wwan_change_dtr(dev, false); ++ qmi_wwan_manage_power(dev, 0); ++ } ++ + /* allow user to unbind using either control or data */ + if (intf == info->control) + other = info->data; +@@ -381,6 +535,16 @@ static const struct driver_info qmi_wwan_info = { + .rx_fixup = qmi_wwan_rx_fixup, + }; + ++static const struct driver_info qmi_wwan_info_quirk_dtr = { ++ .description = "WWAN/QMI device", ++ .flags = FLAG_WWAN, ++ .bind = qmi_wwan_bind, ++ .unbind = qmi_wwan_unbind, ++ .manage_power = qmi_wwan_manage_power, ++ .rx_fixup = qmi_wwan_rx_fixup, ++ .data = QMI_WWAN_QUIRK_DTR, ++}; ++ + #define HUAWEI_VENDOR_ID 0x12D1 + + /* map QMI/wwan function by a fixed interface number */ +@@ -388,6 +552,11 @@ static const struct driver_info qmi_wwan_info = { + USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ + .driver_info = (unsigned long)&qmi_wwan_info + ++/* devices requiring "set DTR" quirk */ ++#define QMI_QUIRK_SET_DTR(vend, prod, num) \ ++ USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ ++ .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr ++ + /* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */ + #define QMI_GOBI1K_DEVICE(vend, prod) \ + QMI_FIXED_INTF(vend, prod, 3) +@@ -717,6 +886,7 @@ static const struct usb_device_id products[] = { + {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ + {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ + {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */ ++ {QMI_FIXED_INTF(0x2001, 0x7e3d, 4)}, /* D-Link DWM-222 A2 */ + {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */ + {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */ + {QMI_FIXED_INTF(0x2020, 0x2060, 4)}, /* BroadMobi BM818 */ +@@ -750,8 +920,11 @@ static const struct usb_device_id products[] = { + {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ + {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ + {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ ++ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ ++ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1050, 2)}, /* Telit FN980 */ ++ {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ + {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ +- {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ ++ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ + {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ + {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ + {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ +@@ -762,16 +935,22 @@ static const struct usb_device_id products[] = { + {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)}, /* Olivetti Olicard 500 */ + {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */ + {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */ ++ {QMI_FIXED_INTF(0x1e2d, 0x0082, 4)}, /* Cinterion PHxx,PXxx (2 RmNet) */ ++ {QMI_FIXED_INTF(0x1e2d, 0x0082, 5)}, /* Cinterion PHxx,PXxx (2 RmNet) */ ++ {QMI_FIXED_INTF(0x1e2d, 0x0083, 4)}, /* Cinterion PHxx,PXxx (1 RmNet + USB Audio)*/ + {QMI_FIXED_INTF(0x413c, 0x81a2, 8)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ + {QMI_FIXED_INTF(0x413c, 0x81a3, 8)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ + {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ + {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */ + {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ + {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ ++ {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ + {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ + {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ + {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ + {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)}, /* SIMCom 7230E */ ++ {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ ++ {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */ + + /* 4. Gobi 1000 devices */ + {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ +diff --git a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c +index d255d33da9eb3..02e71d461d5c5 100644 +--- a/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c ++++ b/drivers/thermal/ti-soc-thermal/omap4-thermal-data.c +@@ -49,20 +49,21 @@ static struct temp_sensor_data omap4430_mpu_temp_sensor_data = { + + /* + * Temperature values in milli degree celsius +- * ADC code values from 530 to 923 ++ * ADC code values from 13 to 107, see TRM ++ * "18.4.10.2.3 ADC Codes Versus Temperature". + */ + static const int + omap4430_adc_to_temp[OMAP4430_ADC_END_VALUE - OMAP4430_ADC_START_VALUE + 1] = { +- -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, -22000, +- -20000, -18000, -17000, -15000, -13000, -12000, -10000, -8000, -6000, +- -5000, -3000, -1000, 0, 2000, 3000, 5000, 6000, 8000, 10000, 12000, +- 13000, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28000, 30000, +- 32000, 33000, 35000, 37000, 38000, 40000, 42000, 43000, 45000, 47000, +- 48000, 50000, 52000, 53000, 55000, 57000, 58000, 60000, 62000, 64000, +- 66000, 68000, 70000, 71000, 73000, 75000, 77000, 78000, 80000, 82000, +- 83000, 85000, 87000, 88000, 90000, 92000, 93000, 95000, 97000, 98000, +- 100000, 102000, 103000, 105000, 107000, 109000, 111000, 113000, 115000, +- 117000, 118000, 120000, 122000, 123000, ++ -40000, -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, ++ -22000, -20000, -18500, -17000, -15000, -13500, -12000, -10000, -8000, ++ -6500, -5000, -3500, -1500, 0, 2000, 3500, 5000, 6500, 8500, 10000, ++ 12000, 13500, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28500, ++ 30000, 32000, 33500, 35000, 37000, 38500, 40000, 42000, 43500, 45000, ++ 47000, 48500, 50000, 52000, 53500, 55000, 57000, 58500, 60000, 62000, ++ 64000, 66000, 68000, 70000, 71500, 73500, 75000, 77000, 78500, 80000, ++ 82000, 83500, 85000, 87000, 88500, 90000, 92000, 93500, 95000, 97000, ++ 98500, 100000, 102000, 103500, 105000, 107000, 109000, 111000, 113000, ++ 115000, 117000, 118500, 120000, 122000, 123500, 125000, + }; + + /* OMAP4430 data */ +diff --git a/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h b/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h +index 6f2de3a3356d4..86850082b24b9 100644 +--- a/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h ++++ b/drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h +@@ -67,9 +67,13 @@ + * and thresholds for OMAP4430. + */ + +-/* ADC conversion table limits */ +-#define OMAP4430_ADC_START_VALUE 0 +-#define OMAP4430_ADC_END_VALUE 127 ++/* ++ * ADC conversion table limits. Ignore values outside the TRM listed ++ * range to avoid bogus thermal shutdowns. See omap4430 TRM chapter ++ * "18.4.10.2.3 ADC Codes Versus Temperature". ++ */ ++#define OMAP4430_ADC_START_VALUE 13 ++#define OMAP4430_ADC_END_VALUE 107 + /* bandgap clock limits (no control on 4430) */ + #define OMAP4430_MAX_FREQ 32768 + #define OMAP4430_MIN_FREQ 32768 +diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c +index df27cefb2fa35..266f446ba331c 100644 +--- a/drivers/xen/xenbus/xenbus_client.c ++++ b/drivers/xen/xenbus/xenbus_client.c +@@ -384,8 +384,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, + int i, j; + + for (i = 0; i < nr_pages; i++) { +- err = gnttab_grant_foreign_access(dev->otherend_id, +- virt_to_gfn(vaddr), 0); ++ unsigned long gfn; ++ ++ if (is_vmalloc_addr(vaddr)) ++ gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr)); ++ else ++ gfn = virt_to_gfn(vaddr); ++ ++ err = gnttab_grant_foreign_access(dev->otherend_id, gfn, 0); + if (err < 0) { + xenbus_dev_fatal(dev, err, + "granting access to ring page"); +diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c +index 5fa92bc790ef7..c1b344e56e855 100644 +--- a/fs/affs/amigaffs.c ++++ b/fs/affs/amigaffs.c +@@ -390,23 +390,23 @@ prot_to_mode(u32 prot) + umode_t mode = 0; + + if (!(prot & FIBF_NOWRITE)) +- mode |= S_IWUSR; ++ mode |= 0200; + if (!(prot & FIBF_NOREAD)) +- mode |= S_IRUSR; ++ mode |= 0400; + if (!(prot & FIBF_NOEXECUTE)) +- mode |= S_IXUSR; ++ mode |= 0100; + if (prot & FIBF_GRP_WRITE) +- mode |= S_IWGRP; ++ mode |= 0020; + if (prot & FIBF_GRP_READ) +- mode |= S_IRGRP; ++ mode |= 0040; + if (prot & FIBF_GRP_EXECUTE) +- mode |= S_IXGRP; ++ mode |= 0010; + if (prot & FIBF_OTR_WRITE) +- mode |= S_IWOTH; ++ mode |= 0002; + if (prot & FIBF_OTR_READ) +- mode |= S_IROTH; ++ mode |= 0004; + if (prot & FIBF_OTR_EXECUTE) +- mode |= S_IXOTH; ++ mode |= 0001; + + return mode; + } +@@ -417,24 +417,51 @@ mode_to_prot(struct inode *inode) + u32 prot = AFFS_I(inode)->i_protect; + umode_t mode = inode->i_mode; + +- if (!(mode & S_IXUSR)) ++ /* ++ * First, clear all RWED bits for owner, group, other. ++ * Then, recalculate them afresh. ++ * ++ * We'll always clear the delete-inhibit bit for the owner, as that is ++ * the classic single-user mode AmigaOS protection bit and we need to ++ * stay compatible with all scenarios. ++ * ++ * Since multi-user AmigaOS is an extension, we'll only set the ++ * delete-allow bit if any of the other bits in the same user class ++ * (group/other) are used. ++ */ ++ prot &= ~(FIBF_NOEXECUTE | FIBF_NOREAD ++ | FIBF_NOWRITE | FIBF_NODELETE ++ | FIBF_GRP_EXECUTE | FIBF_GRP_READ ++ | FIBF_GRP_WRITE | FIBF_GRP_DELETE ++ | FIBF_OTR_EXECUTE | FIBF_OTR_READ ++ | FIBF_OTR_WRITE | FIBF_OTR_DELETE); ++ ++ /* Classic single-user AmigaOS flags. These are inverted. */ ++ if (!(mode & 0100)) + prot |= FIBF_NOEXECUTE; +- if (!(mode & S_IRUSR)) ++ if (!(mode & 0400)) + prot |= FIBF_NOREAD; +- if (!(mode & S_IWUSR)) ++ if (!(mode & 0200)) + prot |= FIBF_NOWRITE; +- if (mode & S_IXGRP) ++ ++ /* Multi-user extended flags. Not inverted. */ ++ if (mode & 0010) + prot |= FIBF_GRP_EXECUTE; +- if (mode & S_IRGRP) ++ if (mode & 0040) + prot |= FIBF_GRP_READ; +- if (mode & S_IWGRP) ++ if (mode & 0020) + prot |= FIBF_GRP_WRITE; +- if (mode & S_IXOTH) ++ if (mode & 0070) ++ prot |= FIBF_GRP_DELETE; ++ ++ if (mode & 0001) + prot |= FIBF_OTR_EXECUTE; +- if (mode & S_IROTH) ++ if (mode & 0004) + prot |= FIBF_OTR_READ; +- if (mode & S_IWOTH) ++ if (mode & 0002) + prot |= FIBF_OTR_WRITE; ++ if (mode & 0007) ++ prot |= FIBF_OTR_DELETE; + + AFFS_I(inode)->i_protect = prot; + } +diff --git a/fs/affs/file.c b/fs/affs/file.c +index 659c579c4588b..38e0fd4caf2bb 100644 +--- a/fs/affs/file.c ++++ b/fs/affs/file.c +@@ -426,6 +426,24 @@ static int affs_write_begin(struct file *file, struct address_space *mapping, + return ret; + } + ++static int affs_write_end(struct file *file, struct address_space *mapping, ++ loff_t pos, unsigned int len, unsigned int copied, ++ struct page *page, void *fsdata) ++{ ++ struct inode *inode = mapping->host; ++ int ret; ++ ++ ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); ++ ++ /* Clear Archived bit on file writes, as AmigaOS would do */ ++ if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) { ++ AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED; ++ mark_inode_dirty(inode); ++ } ++ ++ return ret; ++} ++ + static sector_t _affs_bmap(struct address_space *mapping, sector_t block) + { + return generic_block_bmap(mapping,block,affs_get_block); +@@ -435,7 +453,7 @@ const struct address_space_operations affs_aops = { + .readpage = affs_readpage, + .writepage = affs_writepage, + .write_begin = affs_write_begin, +- .write_end = generic_write_end, ++ .write_end = affs_write_end, + .direct_IO = affs_direct_IO, + .bmap = _affs_bmap + }; +@@ -793,6 +811,12 @@ done: + if (tmp > inode->i_size) + inode->i_size = AFFS_I(inode)->mmu_private = tmp; + ++ /* Clear Archived bit on file writes, as AmigaOS would do */ ++ if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) { ++ AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED; ++ mark_inode_dirty(inode); ++ } ++ + err_first_bh: + unlock_page(page); + page_cache_release(page); +diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c +index 8eac5f75bca36..3fa0515d76851 100644 +--- a/fs/btrfs/ctree.c ++++ b/fs/btrfs/ctree.c +@@ -1372,7 +1372,8 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, + btrfs_tree_read_unlock_blocking(eb); + free_extent_buffer(eb); + +- extent_buffer_get(eb_rewin); ++ btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb_rewin), ++ eb_rewin, btrfs_header_level(eb_rewin)); + btrfs_tree_read_lock(eb_rewin); + __tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm); + WARN_ON(btrfs_header_nritems(eb_rewin) > +@@ -1441,8 +1442,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq) + + if (!eb) + return NULL; +- extent_buffer_get(eb); +- btrfs_tree_read_lock(eb); + if (old_root) { + btrfs_set_header_bytenr(eb, eb->start); + btrfs_set_header_backref_rev(eb, BTRFS_MIXED_BACKREF_REV); +@@ -1450,6 +1449,9 @@ get_old_root(struct btrfs_root *root, u64 time_seq) + btrfs_set_header_level(eb, old_root->level); + btrfs_set_header_generation(eb, old_generation); + } ++ btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb), eb, ++ btrfs_header_level(eb)); ++ btrfs_tree_read_lock(eb); + if (tm) + __tree_mod_log_rewind(root->fs_info, eb, time_seq, tm); + else +diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c +index 2f9f738ecf84a..97a80238fdee3 100644 +--- a/fs/btrfs/extent_io.c ++++ b/fs/btrfs/extent_io.c +@@ -5431,9 +5431,9 @@ void read_extent_buffer(const struct extent_buffer *eb, void *dstv, + } + } + +-int read_extent_buffer_to_user(const struct extent_buffer *eb, +- void __user *dstv, +- unsigned long start, unsigned long len) ++int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb, ++ void __user *dstv, ++ unsigned long start, unsigned long len) + { + size_t cur; + size_t offset; +@@ -5454,7 +5454,7 @@ int read_extent_buffer_to_user(const struct extent_buffer *eb, + + cur = min(len, (PAGE_CACHE_SIZE - offset)); + kaddr = page_address(page); +- if (copy_to_user(dst, kaddr + offset, cur)) { ++ if (probe_user_write(dst, kaddr + offset, cur)) { + ret = -EFAULT; + break; + } +diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h +index 751435967724e..9631be7fc9e24 100644 +--- a/fs/btrfs/extent_io.h ++++ b/fs/btrfs/extent_io.h +@@ -313,9 +313,9 @@ int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv, + void read_extent_buffer(const struct extent_buffer *eb, void *dst, + unsigned long start, + unsigned long len); +-int read_extent_buffer_to_user(const struct extent_buffer *eb, +- void __user *dst, unsigned long start, +- unsigned long len); ++int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb, ++ void __user *dst, unsigned long start, ++ unsigned long len); + void write_extent_buffer(struct extent_buffer *eb, const void *src, + unsigned long start, unsigned long len); + void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c +index 245a50f490f63..91a45ef69152d 100644 +--- a/fs/btrfs/ioctl.c ++++ b/fs/btrfs/ioctl.c +@@ -2017,9 +2017,14 @@ static noinline int copy_to_sk(struct btrfs_root *root, + sh.len = item_len; + sh.transid = found_transid; + +- /* copy search result header */ +- if (copy_to_user(ubuf + *sk_offset, &sh, sizeof(sh))) { +- ret = -EFAULT; ++ /* ++ * Copy search result header. If we fault then loop again so we ++ * can fault in the pages and -EFAULT there if there's a ++ * problem. Otherwise we'll fault and then copy the buffer in ++ * properly this next time through ++ */ ++ if (probe_user_write(ubuf + *sk_offset, &sh, sizeof(sh))) { ++ ret = 0; + goto out; + } + +@@ -2027,10 +2032,14 @@ static noinline int copy_to_sk(struct btrfs_root *root, + + if (item_len) { + char __user *up = ubuf + *sk_offset; +- /* copy the item */ +- if (read_extent_buffer_to_user(leaf, up, +- item_off, item_len)) { +- ret = -EFAULT; ++ /* ++ * Copy the item, same behavior as above, but reset the ++ * * sk_offset so we copy the full thing again. ++ */ ++ if (read_extent_buffer_to_user_nofault(leaf, up, ++ item_off, item_len)) { ++ ret = 0; ++ *sk_offset -= sizeof(sh); + goto out; + } + +@@ -2120,6 +2129,10 @@ static noinline int search_ioctl(struct inode *inode, + key.offset = sk->min_offset; + + while (1) { ++ ret = fault_in_pages_writeable(ubuf, *buf_size - sk_offset); ++ if (ret) ++ break; ++ + ret = btrfs_search_forward(root, &key, path, sk->min_transid); + if (ret != 0) { + if (ret > 0) +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c +index dcae0cf4924b7..2d10b818399b1 100644 +--- a/fs/btrfs/volumes.c ++++ b/fs/btrfs/volumes.c +@@ -4065,6 +4065,7 @@ static int btrfs_uuid_scan_kthread(void *data) + goto skip; + } + update_tree: ++ btrfs_release_path(path); + if (!btrfs_is_empty_uuid(root_item.uuid)) { + ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, + root_item.uuid, +@@ -4090,6 +4091,7 @@ update_tree: + } + + skip: ++ btrfs_release_path(path); + if (trans) { + ret = btrfs_end_transaction(trans, fs_info->uuid_root); + trans = NULL; +@@ -4097,7 +4099,6 @@ skip: + break; + } + +- btrfs_release_path(path); + if (key.offset < (u64)-1) { + key.offset++; + } else if (key.type < BTRFS_ROOT_ITEM_KEY) { +diff --git a/fs/ceph/file.c b/fs/ceph/file.c +index c8222bfe1e566..3e6ebe40f06fb 100644 +--- a/fs/ceph/file.c ++++ b/fs/ceph/file.c +@@ -1433,6 +1433,7 @@ const struct file_operations ceph_file_fops = { + .mmap = ceph_mmap, + .fsync = ceph_fsync, + .lock = ceph_lock, ++ .setlease = simple_nosetlease, + .flock = ceph_flock, + .splice_read = generic_file_splice_read, + .splice_write = iter_file_splice_write, +diff --git a/fs/eventpoll.c b/fs/eventpoll.c +index b8959d0d4c723..e5324642023d6 100644 +--- a/fs/eventpoll.c ++++ b/fs/eventpoll.c +@@ -1720,9 +1720,9 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) + * during ep_insert(). + */ + if (list_empty(&epi->ffd.file->f_tfile_llink)) { +- get_file(epi->ffd.file); +- list_add(&epi->ffd.file->f_tfile_llink, +- &tfile_check_list); ++ if (get_file_rcu(epi->ffd.file)) ++ list_add(&epi->ffd.file->f_tfile_llink, ++ &tfile_check_list); + } + } + } +diff --git a/include/linux/hid.h b/include/linux/hid.h +index 2149f650982ea..d93ba6014e3c5 100644 +--- a/include/linux/hid.h ++++ b/include/linux/hid.h +@@ -866,34 +866,49 @@ static inline void hid_device_io_stop(struct hid_device *hid) { + * @max: maximal valid usage->code to consider later (out parameter) + * @type: input event type (EV_KEY, EV_REL, ...) + * @c: code which corresponds to this usage and type ++ * ++ * The value pointed to by @bit will be set to NULL if either @type is ++ * an unhandled event type, or if @c is out of range for @type. This ++ * can be used as an error condition. + */ + static inline void hid_map_usage(struct hid_input *hidinput, + struct hid_usage *usage, unsigned long **bit, int *max, +- __u8 type, __u16 c) ++ __u8 type, unsigned int c) + { + struct input_dev *input = hidinput->input; +- +- usage->type = type; +- usage->code = c; ++ unsigned long *bmap = NULL; ++ unsigned int limit = 0; + + switch (type) { + case EV_ABS: +- *bit = input->absbit; +- *max = ABS_MAX; ++ bmap = input->absbit; ++ limit = ABS_MAX; + break; + case EV_REL: +- *bit = input->relbit; +- *max = REL_MAX; ++ bmap = input->relbit; ++ limit = REL_MAX; + break; + case EV_KEY: +- *bit = input->keybit; +- *max = KEY_MAX; ++ bmap = input->keybit; ++ limit = KEY_MAX; + break; + case EV_LED: +- *bit = input->ledbit; +- *max = LED_MAX; ++ bmap = input->ledbit; ++ limit = LED_MAX; + break; + } ++ ++ if (unlikely(c > limit || !bmap)) { ++ pr_warn_ratelimited("%s: Invalid code %d type %d\n", ++ input->name, c, type); ++ *bit = NULL; ++ return; ++ } ++ ++ usage->type = type; ++ usage->code = c; ++ *max = limit; ++ *bit = bmap; + } + + /** +@@ -907,7 +922,8 @@ static inline void hid_map_usage_clear(struct hid_input *hidinput, + __u8 type, __u16 c) + { + hid_map_usage(hidinput, usage, bit, max, type, c); +- clear_bit(c, *bit); ++ if (*bit) ++ clear_bit(usage->code, *bit); + } + + /** +diff --git a/include/linux/log2.h b/include/linux/log2.h +index c373295f359fa..cca606609e1bc 100644 +--- a/include/linux/log2.h ++++ b/include/linux/log2.h +@@ -159,7 +159,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) + #define roundup_pow_of_two(n) \ + ( \ + __builtin_constant_p(n) ? ( \ +- (n == 1) ? 1 : \ ++ ((n) == 1) ? 1 : \ + (1UL << (ilog2((n) - 1) + 1)) \ + ) : \ + __roundup_pow_of_two(n) \ +diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h +index 15c7b5420d8aa..c82dcea216b15 100644 +--- a/include/linux/uaccess.h ++++ b/include/linux/uaccess.h +@@ -90,6 +90,17 @@ static inline unsigned long __copy_from_user_nocache(void *to, + extern long probe_kernel_read(void *dst, const void *src, size_t size); + extern long __probe_kernel_read(void *dst, const void *src, size_t size); + ++/* ++ * probe_user_read(): safely attempt to read from a location in user space ++ * @dst: pointer to the buffer that shall take the data ++ * @src: address to read from ++ * @size: size of the data chunk ++ * ++ * Safely read from address @src to the buffer at @dst. If a kernel fault ++ * happens, handle that and return -EFAULT. ++ */ ++extern long probe_user_read(void *dst, const void __user *src, size_t size); ++ + /* + * probe_kernel_write(): safely attempt to write to a location + * @dst: address to write to +@@ -102,7 +113,22 @@ extern long __probe_kernel_read(void *dst, const void *src, size_t size); + extern long notrace probe_kernel_write(void *dst, const void *src, size_t size); + extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size); + ++/* ++ * probe_user_write(): safely attempt to write to a location in user space ++ * @dst: address to write to ++ * @src: pointer to the data that shall be written ++ * @size: size of the data chunk ++ * ++ * Safely write to address @dst from the buffer at @src. If a kernel fault ++ * happens, handle that and return -EFAULT. ++ */ ++extern long notrace probe_user_write(void __user *dst, const void *src, size_t size); ++extern long notrace __probe_user_write(void __user *dst, const void *src, size_t size); ++ + extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); ++extern long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, ++ long count); ++extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count); + + /** + * probe_kernel_address(): safely attempt to read from a location +diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h +index 72599bbc82558..a77a37c6349d9 100644 +--- a/include/net/inet_connection_sock.h ++++ b/include/net/inet_connection_sock.h +@@ -319,5 +319,9 @@ int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname, + int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, + char __user *optval, unsigned int optlen); + ++/* update the fast reuse flag when adding a socket */ ++void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, ++ struct sock *sk); ++ + struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu); + #endif /* _INET_CONNECTION_SOCK_H */ +diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h +index b96df7499600f..bee9031a40066 100644 +--- a/include/net/netfilter/nf_tables.h ++++ b/include/net/netfilter/nf_tables.h +@@ -74,6 +74,8 @@ struct nft_regs { + static inline void nft_data_copy(u32 *dst, const struct nft_data *src, + unsigned int len) + { ++ if (len % NFT_REG32_SIZE) ++ dst[len / NFT_REG32_SIZE] = 0; + memcpy(dst, src, len); + } + +diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h +index d8c8a7c9d88a7..b0a1c33d4a153 100644 +--- a/include/uapi/linux/netfilter/nf_tables.h ++++ b/include/uapi/linux/netfilter/nf_tables.h +@@ -111,7 +111,7 @@ enum nf_tables_msg_types { + * @NFTA_LIST_ELEM: list element (NLA_NESTED) + */ + enum nft_list_attributes { +- NFTA_LIST_UNPEC, ++ NFTA_LIST_UNSPEC, + NFTA_LIST_ELEM, + __NFTA_LIST_MAX + }; +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index baac9a09ec0a1..44970b17f4fe7 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -2812,6 +2812,22 @@ static unsigned int cpuset_mems_nr(unsigned int *array) + } + + #ifdef CONFIG_SYSCTL ++static int proc_hugetlb_doulongvec_minmax(struct ctl_table *table, int write, ++ void *buffer, size_t *length, ++ loff_t *ppos, unsigned long *out) ++{ ++ struct ctl_table dup_table; ++ ++ /* ++ * In order to avoid races with __do_proc_doulongvec_minmax(), we ++ * can duplicate the @table and alter the duplicate of it. ++ */ ++ dup_table = *table; ++ dup_table.data = out; ++ ++ return proc_doulongvec_minmax(&dup_table, write, buffer, length, ppos); ++} ++ + static int hugetlb_sysctl_handler_common(bool obey_mempolicy, + struct ctl_table *table, int write, + void __user *buffer, size_t *length, loff_t *ppos) +@@ -2823,9 +2839,8 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy, + if (!hugepages_supported()) + return -ENOTSUPP; + +- table->data = &tmp; +- table->maxlen = sizeof(unsigned long); +- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); ++ ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos, ++ &tmp); + if (ret) + goto out; + +@@ -2869,9 +2884,8 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, + if (write && hstate_is_gigantic(h)) + return -EINVAL; + +- table->data = &tmp; +- table->maxlen = sizeof(unsigned long); +- ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); ++ ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos, ++ &tmp); + if (ret) + goto out; + +diff --git a/mm/maccess.c b/mm/maccess.c +index d159b1c96e484..18717e893a758 100644 +--- a/mm/maccess.c ++++ b/mm/maccess.c +@@ -5,8 +5,32 @@ + #include + #include + ++static __always_inline long ++probe_read_common(void *dst, const void __user *src, size_t size) ++{ ++ long ret; ++ ++ pagefault_disable(); ++ ret = __copy_from_user_inatomic(dst, src, size); ++ pagefault_enable(); ++ ++ return ret ? -EFAULT : 0; ++} ++ ++static __always_inline long ++probe_write_common(void __user *dst, const void *src, size_t size) ++{ ++ long ret; ++ ++ pagefault_disable(); ++ ret = __copy_to_user_inatomic(dst, src, size); ++ pagefault_enable(); ++ ++ return ret ? -EFAULT : 0; ++} ++ + /** +- * probe_kernel_read(): safely attempt to read from a location ++ * probe_kernel_read(): safely attempt to read from a kernel-space location + * @dst: pointer to the buffer that shall take the data + * @src: address to read from + * @size: size of the data chunk +@@ -29,16 +53,40 @@ long __probe_kernel_read(void *dst, const void *src, size_t size) + mm_segment_t old_fs = get_fs(); + + set_fs(KERNEL_DS); +- pagefault_disable(); +- ret = __copy_from_user_inatomic(dst, +- (__force const void __user *)src, size); +- pagefault_enable(); ++ ret = probe_read_common(dst, (__force const void __user *)src, size); + set_fs(old_fs); + +- return ret ? -EFAULT : 0; ++ return ret; + } + EXPORT_SYMBOL_GPL(probe_kernel_read); + ++/** ++ * probe_user_read(): safely attempt to read from a user-space location ++ * @dst: pointer to the buffer that shall take the data ++ * @src: address to read from. This must be a user address. ++ * @size: size of the data chunk ++ * ++ * Safely read from user address @src to the buffer at @dst. If a kernel fault ++ * happens, handle that and return -EFAULT. ++ */ ++ ++long __weak probe_user_read(void *dst, const void __user *src, size_t size) ++ __attribute__((alias("__probe_user_read"))); ++ ++long __probe_user_read(void *dst, const void __user *src, size_t size) ++{ ++ long ret = -EFAULT; ++ mm_segment_t old_fs = get_fs(); ++ ++ set_fs(USER_DS); ++ if (access_ok(VERIFY_READ, src, size)) ++ ret = probe_read_common(dst, src, size); ++ set_fs(old_fs); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(probe_user_read); ++ + /** + * probe_kernel_write(): safely attempt to write to a location + * @dst: address to write to +@@ -48,6 +96,7 @@ EXPORT_SYMBOL_GPL(probe_kernel_read); + * Safely write to address @dst from the buffer at @src. If a kernel fault + * happens, handle that and return -EFAULT. + */ ++ + long __weak probe_kernel_write(void *dst, const void *src, size_t size) + __attribute__((alias("__probe_kernel_write"))); + +@@ -57,15 +106,40 @@ long __probe_kernel_write(void *dst, const void *src, size_t size) + mm_segment_t old_fs = get_fs(); + + set_fs(KERNEL_DS); +- pagefault_disable(); +- ret = __copy_to_user_inatomic((__force void __user *)dst, src, size); +- pagefault_enable(); ++ ret = probe_write_common((__force void __user *)dst, src, size); + set_fs(old_fs); + +- return ret ? -EFAULT : 0; ++ return ret; + } + EXPORT_SYMBOL_GPL(probe_kernel_write); + ++/** ++ * probe_user_write(): safely attempt to write to a user-space location ++ * @dst: address to write to ++ * @src: pointer to the data that shall be written ++ * @size: size of the data chunk ++ * ++ * Safely write to address @dst from the buffer at @src. If a kernel fault ++ * happens, handle that and return -EFAULT. ++ */ ++ ++long __weak probe_user_write(void __user *dst, const void *src, size_t size) ++ __attribute__((alias("__probe_user_write"))); ++ ++long __probe_user_write(void __user *dst, const void *src, size_t size) ++{ ++ long ret = -EFAULT; ++ mm_segment_t old_fs = get_fs(); ++ ++ set_fs(USER_DS); ++ if (access_ok(VERIFY_WRITE, dst, size)) ++ ret = probe_write_common(dst, src, size); ++ set_fs(old_fs); ++ ++ return ret; ++} ++EXPORT_SYMBOL_GPL(probe_user_write); ++ + /** + * strncpy_from_unsafe: - Copy a NUL terminated string from unsafe address. + * @dst: Destination address, in kernel space. This buffer must be at +@@ -106,3 +180,76 @@ long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count) + + return ret ? -EFAULT : src - unsafe_addr; + } ++ ++/** ++ * strncpy_from_unsafe_user: - Copy a NUL terminated string from unsafe user ++ * address. ++ * @dst: Destination address, in kernel space. This buffer must be at ++ * least @count bytes long. ++ * @unsafe_addr: Unsafe user address. ++ * @count: Maximum number of bytes to copy, including the trailing NUL. ++ * ++ * Copies a NUL-terminated string from unsafe user address to kernel buffer. ++ * ++ * On success, returns the length of the string INCLUDING the trailing NUL. ++ * ++ * If access fails, returns -EFAULT (some data may have been copied ++ * and the trailing NUL added). ++ * ++ * If @count is smaller than the length of the string, copies @count-1 bytes, ++ * sets the last byte of @dst buffer to NUL and returns @count. ++ */ ++long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, ++ long count) ++{ ++ mm_segment_t old_fs = get_fs(); ++ long ret; ++ ++ if (unlikely(count <= 0)) ++ return 0; ++ ++ set_fs(USER_DS); ++ pagefault_disable(); ++ ret = strncpy_from_user(dst, unsafe_addr, count); ++ pagefault_enable(); ++ set_fs(old_fs); ++ ++ if (ret >= count) { ++ ret = count; ++ dst[ret - 1] = '\0'; ++ } else if (ret > 0) { ++ ret++; ++ } ++ ++ return ret; ++} ++ ++/** ++ * strnlen_unsafe_user: - Get the size of a user string INCLUDING final NUL. ++ * @unsafe_addr: The string to measure. ++ * @count: Maximum count (including NUL) ++ * ++ * Get the size of a NUL-terminated string in user space without pagefault. ++ * ++ * Returns the size of the string INCLUDING the terminating NUL. ++ * ++ * If the string is too long, returns a number larger than @count. User ++ * has to check the return value against "> count". ++ * On exception (or invalid count), returns 0. ++ * ++ * Unlike strnlen_user, this can be used from IRQ handler etc. because ++ * it disables pagefaults. ++ */ ++long strnlen_unsafe_user(const void __user *unsafe_addr, long count) ++{ ++ mm_segment_t old_fs = get_fs(); ++ int ret; ++ ++ set_fs(USER_DS); ++ pagefault_disable(); ++ ret = strnlen_user(unsafe_addr, count); ++ pagefault_enable(); ++ set_fs(old_fs); ++ ++ return ret; ++} +diff --git a/mm/page_alloc.c b/mm/page_alloc.c +index 14bab5fa1b656..3570aaf2a6204 100644 +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -835,7 +835,6 @@ static void free_pcppages_bulk(struct zone *zone, int count, + { + int migratetype = 0; + int batch_free = 0; +- int to_free = count; + unsigned long nr_scanned; + + spin_lock(&zone->lock); +@@ -848,7 +847,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, + * below while (list_empty(list)) loop. + */ + count = min(pcp->count, count); +- while (to_free) { ++ while (count) { + struct page *page; + struct list_head *list; + +@@ -868,7 +867,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, + + /* This is the only non-empty list. Free them all. */ + if (batch_free == MIGRATE_PCPTYPES) +- batch_free = to_free; ++ batch_free = count; + + do { + int mt; /* migratetype of the to-be-freed page */ +@@ -886,7 +885,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, + + __free_one_page(page, page_to_pfn(page), zone, 0, mt); + trace_mm_page_pcpu_drain(page, 0, mt); +- } while (--to_free && --batch_free && !list_empty(list)); ++ } while (--count && --batch_free && !list_empty(list)); + } + spin_unlock(&zone->lock); + } +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c +index cea7fdeac5aa2..9aa5daa551273 100644 +--- a/net/batman-adv/bridge_loop_avoidance.c ++++ b/net/batman-adv/bridge_loop_avoidance.c +@@ -380,7 +380,10 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac, + skb->len + ETH_HLEN); + soft_iface->last_rx = jiffies; + +- netif_rx(skb); ++ if (in_interrupt()) ++ netif_rx(skb); ++ else ++ netif_rx_ni(skb); + out: + if (primary_if) + batadv_hardif_free_ref(primary_if); +diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c +index a88b529b7ca08..5fdb88f72b68f 100644 +--- a/net/batman-adv/gateway_client.c ++++ b/net/batman-adv/gateway_client.c +@@ -757,8 +757,10 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len, + + chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET; + /* store the client address if the message is going to a client */ +- if (ret == BATADV_DHCP_TO_CLIENT && +- pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) { ++ if (ret == BATADV_DHCP_TO_CLIENT) { ++ if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) ++ return BATADV_DHCP_NO; ++ + /* check if the DHCP packet carries an Ethernet DHCP */ + p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET; + if (*p != BATADV_DHCP_HTYPE_ETHERNET) +diff --git a/net/core/dev.c b/net/core/dev.c +index 09115c68f29dc..59157e9686fb2 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -4849,13 +4849,14 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi, + pr_err_once("netif_napi_add() called with weight %d on device %s\n", + weight, dev->name); + napi->weight = weight; +- list_add(&napi->dev_list, &dev->napi_list); + napi->dev = dev; + #ifdef CONFIG_NETPOLL + spin_lock_init(&napi->poll_lock); + napi->poll_owner = -1; + #endif + set_bit(NAPI_STATE_SCHED, &napi->state); ++ set_bit(NAPI_STATE_NPSVC, &napi->state); ++ list_add_rcu(&napi->dev_list, &dev->napi_list); + } + EXPORT_SYMBOL(netif_napi_add); + +diff --git a/net/core/netpoll.c b/net/core/netpoll.c +index 0d7c2cc1ff09d..f2610f8f171ca 100644 +--- a/net/core/netpoll.c ++++ b/net/core/netpoll.c +@@ -178,7 +178,7 @@ static void poll_napi(struct net_device *dev) + { + struct napi_struct *napi; + +- list_for_each_entry(napi, &dev->napi_list, dev_list) { ++ list_for_each_entry_rcu(napi, &dev->napi_list, dev_list) { + if (napi->poll_owner != smp_processor_id() && + spin_trylock(&napi->poll_lock)) { + poll_one_napi(napi); +diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c +index 6c9158805b57d..9678dd8d70c3f 100644 +--- a/net/ipv4/inet_connection_sock.c ++++ b/net/ipv4/inet_connection_sock.c +@@ -87,6 +87,31 @@ int inet_csk_bind_conflict(const struct sock *sk, + } + EXPORT_SYMBOL_GPL(inet_csk_bind_conflict); + ++void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, ++ struct sock *sk) ++{ ++ kuid_t uid = sock_i_uid(sk); ++ ++ if (hlist_empty(&tb->owners)) { ++ if (sk->sk_reuse && sk->sk_state != TCP_LISTEN) ++ tb->fastreuse = 1; ++ else ++ tb->fastreuse = 0; ++ if (sk->sk_reuseport) { ++ tb->fastreuseport = 1; ++ tb->fastuid = uid; ++ } else ++ tb->fastreuseport = 0; ++ } else { ++ if (tb->fastreuse && ++ (!sk->sk_reuse || sk->sk_state == TCP_LISTEN)) ++ tb->fastreuse = 0; ++ if (tb->fastreuseport && ++ (!sk->sk_reuseport || !uid_eq(tb->fastuid, uid))) ++ tb->fastreuseport = 0; ++ } ++} ++ + /* Obtain a reference to a local port for the given sock, + * if snum is zero it means select any available local port. + */ +@@ -216,24 +241,9 @@ tb_not_found: + if (!tb && (tb = inet_bind_bucket_create(hashinfo->bind_bucket_cachep, + net, head, snum)) == NULL) + goto fail_unlock; +- if (hlist_empty(&tb->owners)) { +- if (sk->sk_reuse && sk->sk_state != TCP_LISTEN) +- tb->fastreuse = 1; +- else +- tb->fastreuse = 0; +- if (sk->sk_reuseport) { +- tb->fastreuseport = 1; +- tb->fastuid = uid; +- } else +- tb->fastreuseport = 0; +- } else { +- if (tb->fastreuse && +- (!sk->sk_reuse || sk->sk_state == TCP_LISTEN)) +- tb->fastreuse = 0; +- if (tb->fastreuseport && +- (!sk->sk_reuseport || !uid_eq(tb->fastuid, uid))) +- tb->fastreuseport = 0; +- } ++ ++ inet_csk_update_fastreuse(tb, sk); ++ + success: + if (!inet_csk(sk)->icsk_bind_hash) + inet_bind_hash(sk, tb, snum); +diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c +index ccc5980797fcd..738cd5c822b1b 100644 +--- a/net/ipv4/inet_hashtables.c ++++ b/net/ipv4/inet_hashtables.c +@@ -160,6 +160,7 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child) + return -ENOMEM; + } + } ++ inet_csk_update_fastreuse(tb, child); + } + inet_bind_hash(child, tb, port); + spin_unlock(&head->lock); +diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c +index 09b4b07eb6764..ab3e7b14de09b 100644 +--- a/net/netfilter/nft_payload.c ++++ b/net/netfilter/nft_payload.c +@@ -74,7 +74,9 @@ static void nft_payload_eval(const struct nft_expr *expr, + u32 *dest = ®s->data[priv->dreg]; + int offset; + +- dest[priv->len / NFT_REG32_SIZE] = 0; ++ if (priv->len % NFT_REG32_SIZE) ++ dest[priv->len / NFT_REG32_SIZE] = 0; ++ + switch (priv->base) { + case NFT_PAYLOAD_LL_HEADER: + if (!skb_mac_header_was_set(skb)) +diff --git a/net/sctp/socket.c b/net/sctp/socket.c +index 5803d0807e9a2..62ba9a49c1265 100644 +--- a/net/sctp/socket.c ++++ b/net/sctp/socket.c +@@ -6206,8 +6206,6 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) + + pr_debug("%s: begins, snum:%d\n", __func__, snum); + +- local_bh_disable(); +- + if (snum == 0) { + /* Search for an available port. */ + int low, high, remaining, index; +@@ -6226,20 +6224,21 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) + continue; + index = sctp_phashfn(sock_net(sk), rover); + head = &sctp_port_hashtable[index]; +- spin_lock(&head->lock); ++ spin_lock_bh(&head->lock); + sctp_for_each_hentry(pp, &head->chain) + if ((pp->port == rover) && + net_eq(sock_net(sk), pp->net)) + goto next; + break; + next: +- spin_unlock(&head->lock); ++ spin_unlock_bh(&head->lock); ++ cond_resched(); + } while (--remaining > 0); + + /* Exhausted local port range during search? */ + ret = 1; + if (remaining <= 0) +- goto fail; ++ return ret; + + /* OK, here is the one we will use. HEAD (the port + * hash table list entry) is non-NULL and we hold it's +@@ -6254,7 +6253,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) + * port iterator, pp being NULL. + */ + head = &sctp_port_hashtable[sctp_phashfn(sock_net(sk), snum)]; +- spin_lock(&head->lock); ++ spin_lock_bh(&head->lock); + sctp_for_each_hentry(pp, &head->chain) { + if ((pp->port == snum) && net_eq(pp->net, sock_net(sk))) + goto pp_found; +@@ -6338,10 +6337,7 @@ success: + ret = 0; + + fail_unlock: +- spin_unlock(&head->lock); +- +-fail: +- local_bh_enable(); ++ spin_unlock_bh(&head->lock); + return ret; + } + +diff --git a/net/wireless/reg.c b/net/wireless/reg.c +index 437ec52d5e71f..474923175b108 100644 +--- a/net/wireless/reg.c ++++ b/net/wireless/reg.c +@@ -2383,6 +2383,9 @@ int regulatory_hint_user(const char *alpha2, + if (WARN_ON(!alpha2)) + return -EINVAL; + ++ if (!is_world_regdom(alpha2) && !is_an_alpha2(alpha2)) ++ return -EINVAL; ++ + request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); + if (!request) + return -ENOMEM; +diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl +index 6ac6550d751c1..8835a4775d205 100755 +--- a/scripts/checkpatch.pl ++++ b/scripts/checkpatch.pl +@@ -2195,8 +2195,8 @@ sub process { + + # Check if the commit log has what seems like a diff which can confuse patch + if ($in_commit_log && !$commit_log_has_diff && +- (($line =~ m@^\s+diff\b.*a/[\w/]+@ && +- $line =~ m@^\s+diff\b.*a/([\w/]+)\s+b/$1\b@) || ++ (($line =~ m@^\s+diff\b.*a/([\w/]+)@ && ++ $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) || + $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ || + $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) { + ERROR("DIFF_IN_COMMIT_MSG", +diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c +index 3788906421a73..fe27034f28460 100644 +--- a/sound/core/oss/mulaw.c ++++ b/sound/core/oss/mulaw.c +@@ -329,8 +329,8 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug, + snd_BUG(); + return -EINVAL; + } +- if (snd_BUG_ON(!snd_pcm_format_linear(format->format))) +- return -ENXIO; ++ if (!snd_pcm_format_linear(format->format)) ++ return -EINVAL; + + err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", + src_format, dst_format, +diff --git a/sound/firewire/digi00x/digi00x.c b/sound/firewire/digi00x/digi00x.c +index 1f33b7a1fca4c..659e8224a4dee 100644 +--- a/sound/firewire/digi00x/digi00x.c ++++ b/sound/firewire/digi00x/digi00x.c +@@ -13,7 +13,9 @@ MODULE_AUTHOR("Takashi Sakamoto "); + MODULE_LICENSE("GPL v2"); + + #define VENDOR_DIGIDESIGN 0x00a07e +-#define MODEL_DIGI00X 0x000002 ++#define MODEL_CONSOLE 0x000001 ++#define MODEL_RACK 0x000002 ++#define SPEC_VERSION 0x000001 + + static int name_card(struct snd_dg00x *dg00x) + { +@@ -75,6 +77,8 @@ static int snd_dg00x_probe(struct fw_unit *unit, + spin_lock_init(&dg00x->lock); + init_waitqueue_head(&dg00x->hwdep_wait); + ++ dg00x->is_console = entry->model_id == MODEL_CONSOLE; ++ + err = name_card(dg00x); + if (err < 0) + goto error; +@@ -136,9 +140,19 @@ static const struct ieee1394_device_id snd_dg00x_id_table[] = { + /* Both of 002/003 use the same ID. */ + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | ++ IEEE1394_MATCH_VERSION | ++ IEEE1394_MATCH_MODEL_ID, ++ .vendor_id = VENDOR_DIGIDESIGN, ++ .version = SPEC_VERSION, ++ .model_id = MODEL_CONSOLE, ++ }, ++ { ++ .match_flags = IEEE1394_MATCH_VENDOR_ID | ++ IEEE1394_MATCH_VERSION | + IEEE1394_MATCH_MODEL_ID, + .vendor_id = VENDOR_DIGIDESIGN, +- .model_id = MODEL_DIGI00X, ++ .version = SPEC_VERSION, ++ .model_id = MODEL_RACK, + }, + {} + }; +diff --git a/sound/firewire/digi00x/digi00x.h b/sound/firewire/digi00x/digi00x.h +index 907e739936777..d641a0cf077a3 100644 +--- a/sound/firewire/digi00x/digi00x.h ++++ b/sound/firewire/digi00x/digi00x.h +@@ -57,6 +57,7 @@ struct snd_dg00x { + /* For asynchronous MIDI controls. */ + struct snd_rawmidi_substream *in_control; + struct snd_fw_async_midi_port out_control; ++ bool is_console; + }; + + #define DG00X_ADDR_BASE 0xffffe0000000ull +diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c +index ee0bc18395088..a4143f45c7f7a 100644 +--- a/sound/firewire/tascam/tascam.c ++++ b/sound/firewire/tascam/tascam.c +@@ -172,11 +172,39 @@ static void snd_tscm_remove(struct fw_unit *unit) + } + + static const struct ieee1394_device_id snd_tscm_id_table[] = { ++ // Tascam, FW-1884. + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | +- IEEE1394_MATCH_SPECIFIER_ID, ++ IEEE1394_MATCH_SPECIFIER_ID | ++ IEEE1394_MATCH_VERSION, + .vendor_id = 0x00022e, + .specifier_id = 0x00022e, ++ .version = 0x800000, ++ }, ++ // Tascam, FE-8 (.version = 0x800001) ++ // This kernel module doesn't support FE-8 because the most of features ++ // can be implemented in userspace without any specific support of this ++ // module. ++ // ++ // .version = 0x800002 is unknown. ++ // ++ // Tascam, FW-1082. ++ { ++ .match_flags = IEEE1394_MATCH_VENDOR_ID | ++ IEEE1394_MATCH_SPECIFIER_ID | ++ IEEE1394_MATCH_VERSION, ++ .vendor_id = 0x00022e, ++ .specifier_id = 0x00022e, ++ .version = 0x800003, ++ }, ++ // Tascam, FW-1804. ++ { ++ .match_flags = IEEE1394_MATCH_VENDOR_ID | ++ IEEE1394_MATCH_SPECIFIER_ID | ++ IEEE1394_MATCH_VERSION, ++ .vendor_id = 0x00022e, ++ .specifier_id = 0x00022e, ++ .version = 0x800004, + }, + /* FE-08 requires reverse-engineering because it just has faders. */ + {} +diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c +index d3cd95633ee2c..e7ee51b7aa6b0 100644 +--- a/sound/pci/ca0106/ca0106_main.c ++++ b/sound/pci/ca0106/ca0106_main.c +@@ -551,7 +551,8 @@ static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id, + else + /* Power down */ + chip->spi_dac_reg[reg] |= bit; +- return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); ++ if (snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]) != 0) ++ return -ENXIO; + } + return 0; + } +diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt +index e630a7d2c3483..e4eee57ad2299 100644 +--- a/tools/perf/Documentation/perf-record.txt ++++ b/tools/perf/Documentation/perf-record.txt +@@ -33,6 +33,10 @@ OPTIONS + - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a + hexadecimal event descriptor. + ++ - a symbolic or raw PMU event followed by an optional colon ++ and a list of event modifiers, e.g., cpu-cycles:p. See the ++ linkperf:perf-list[1] man page for details on event modifiers. ++ + - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where + 'param1', 'param2', etc are defined as formats for the PMU in + /sys/bus/event_sources/devices//format/*. +diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt +index 90c3558c2c12f..ee7fe04fc4b6c 100644 +--- a/tools/perf/Documentation/perf-stat.txt ++++ b/tools/perf/Documentation/perf-stat.txt +@@ -32,6 +32,10 @@ OPTIONS + - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a + hexadecimal event descriptor. + ++ - a symbolic or raw PMU event followed by an optional colon ++ and a list of event modifiers, e.g., cpu-cycles:p. See the ++ linkperf:perf-list[1] man page for details on event modifiers. ++ + - a symbolically formed event like 'pmu/param1=0x3,param2/' where + param1 and param2 are defined as formats for the PMU in + /sys/bus/event_sources/devices//format/* diff --git a/patch/kernel/rockpis-legacy/patch-4.4.236-237.patch b/patch/kernel/rockpis-legacy/patch-4.4.236-237.patch new file mode 100644 index 000000000..9472d2063 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.236-237.patch @@ -0,0 +1,2002 @@ +diff --git a/Makefile b/Makefile +index b954cb21fddc7..003334dad3c3f 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 236 ++SUBLEVEL = 237 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi b/arch/arm/boot/dts/socfpga_arria10.dtsi +index cce9e50acf68a..b648b1b253c5e 100644 +--- a/arch/arm/boot/dts/socfpga_arria10.dtsi ++++ b/arch/arm/boot/dts/socfpga_arria10.dtsi +@@ -652,7 +652,7 @@ + timer3: timer3@ffd00100 { + compatible = "snps,dw-apb-timer"; + interrupts = <0 118 IRQ_TYPE_LEVEL_HIGH>; +- reg = <0xffd01000 0x100>; ++ reg = <0xffd00100 0x100>; + clocks = <&l4_sys_free_clk>; + clock-names = "timer"; + }; +diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig +index 596cbda9cb3d3..9d8bc19edc48e 100644 +--- a/arch/mips/Kconfig ++++ b/arch/mips/Kconfig +@@ -817,6 +817,7 @@ config SNI_RM + select I8253 + select I8259 + select ISA ++ select MIPS_L1_CACHE_SHIFT_6 + select SWAP_IO_SPACE if CPU_BIG_ENDIAN + select SYS_HAS_CPU_R4X00 + select SYS_HAS_CPU_R5000 +diff --git a/arch/mips/sni/a20r.c b/arch/mips/sni/a20r.c +index f9407e1704762..c6af7047eb0d2 100644 +--- a/arch/mips/sni/a20r.c ++++ b/arch/mips/sni/a20r.c +@@ -143,7 +143,10 @@ static struct platform_device sc26xx_pdev = { + }, + }; + +-static u32 a20r_ack_hwint(void) ++/* ++ * Trigger chipset to update CPU's CAUSE IP field ++ */ ++static u32 a20r_update_cause_ip(void) + { + u32 status = read_c0_status(); + +@@ -205,12 +208,14 @@ static void a20r_hwint(void) + int irq; + + clear_c0_status(IE_IRQ0); +- status = a20r_ack_hwint(); ++ status = a20r_update_cause_ip(); + cause = read_c0_cause(); + + irq = ffs(((cause & status) >> 8) & 0xf8); + if (likely(irq > 0)) + do_IRQ(SNI_A20R_IRQ_BASE + irq - 1); ++ ++ a20r_update_cause_ip(); + set_c0_status(IE_IRQ0); + } + +diff --git a/arch/powerpc/configs/pasemi_defconfig b/arch/powerpc/configs/pasemi_defconfig +index 8f94782eb9071..dc57fa11c687f 100644 +--- a/arch/powerpc/configs/pasemi_defconfig ++++ b/arch/powerpc/configs/pasemi_defconfig +@@ -115,7 +115,6 @@ CONFIG_FB_NVIDIA=y + CONFIG_FB_NVIDIA_I2C=y + CONFIG_FB_RADEON=y + # CONFIG_LCD_CLASS_DEVICE is not set +-CONFIG_VGACON_SOFT_SCROLLBACK=y + CONFIG_LOGO=y + CONFIG_SOUND=y + CONFIG_SND=y +diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig +index e5d2c3dc07f1d..c82bda4d27df3 100644 +--- a/arch/powerpc/configs/ppc6xx_defconfig ++++ b/arch/powerpc/configs/ppc6xx_defconfig +@@ -797,7 +797,6 @@ CONFIG_FB_TRIDENT=m + CONFIG_FB_SM501=m + CONFIG_FB_IBM_GXT4500=y + CONFIG_LCD_PLATFORM=m +-CONFIG_VGACON_SOFT_SCROLLBACK=y + CONFIG_FRAMEBUFFER_CONSOLE=y + CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y + CONFIG_LOGO=y +diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c +index 41a7d9d49a5a3..3d3e8795e934f 100644 +--- a/arch/powerpc/kernel/dma-iommu.c ++++ b/arch/powerpc/kernel/dma-iommu.c +@@ -99,7 +99,8 @@ static u64 dma_iommu_get_required_mask(struct device *dev) + if (!tbl) + return 0; + +- mask = 1ULL < (fls_long(tbl->it_offset + tbl->it_size) - 1); ++ mask = 1ULL << (fls_long(tbl->it_offset + tbl->it_size) + ++ tbl->it_page_shift - 1); + mask += mask - 1; + + return mask; +diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig +index 028be48c88397..a628b2474e6d4 100644 +--- a/arch/x86/configs/i386_defconfig ++++ b/arch/x86/configs/i386_defconfig +@@ -218,7 +218,6 @@ CONFIG_FB_MODE_HELPERS=y + CONFIG_FB_TILEBLITTING=y + CONFIG_FB_EFI=y + # CONFIG_LCD_CLASS_DEVICE is not set +-CONFIG_VGACON_SOFT_SCROLLBACK=y + CONFIG_LOGO=y + # CONFIG_LOGO_LINUX_MONO is not set + # CONFIG_LOGO_LINUX_VGA16 is not set +@@ -248,6 +247,7 @@ CONFIG_USB_HIDDEV=y + CONFIG_USB=y + CONFIG_USB_ANNOUNCE_NEW_DEVICES=y + CONFIG_USB_MON=y ++CONFIG_USB_XHCI_HCD=y + CONFIG_USB_EHCI_HCD=y + CONFIG_USB_EHCI_TT_NEWSCHED=y + CONFIG_USB_OHCI_HCD=y +diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig +index cb5b3ab5beecc..649f7d604b12a 100644 +--- a/arch/x86/configs/x86_64_defconfig ++++ b/arch/x86/configs/x86_64_defconfig +@@ -212,7 +212,6 @@ CONFIG_FB_MODE_HELPERS=y + CONFIG_FB_TILEBLITTING=y + CONFIG_FB_EFI=y + # CONFIG_LCD_CLASS_DEVICE is not set +-CONFIG_VGACON_SOFT_SCROLLBACK=y + CONFIG_LOGO=y + # CONFIG_LOGO_LINUX_MONO is not set + # CONFIG_LOGO_LINUX_VGA16 is not set +@@ -242,6 +241,7 @@ CONFIG_USB_HIDDEV=y + CONFIG_USB=y + CONFIG_USB_ANNOUNCE_NEW_DEVICES=y + CONFIG_USB_MON=y ++CONFIG_USB_XHCI_HCD=y + CONFIG_USB_EHCI_HCD=y + CONFIG_USB_EHCI_TT_NEWSCHED=y + CONFIG_USB_OHCI_HCD=y +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c +index 22da8f87bd641..6646edaa5123c 100644 +--- a/arch/x86/kvm/vmx.c ++++ b/arch/x86/kvm/vmx.c +@@ -8235,6 +8235,7 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu) + (exit_reason != EXIT_REASON_EXCEPTION_NMI && + exit_reason != EXIT_REASON_EPT_VIOLATION && + exit_reason != EXIT_REASON_PML_FULL && ++ exit_reason != EXIT_REASON_APIC_ACCESS && + exit_reason != EXIT_REASON_TASK_SWITCH)) { + vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; + vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_DELIVERY_EV; +diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c +index 04b39d0da8681..70708608ab1e7 100644 +--- a/drivers/atm/firestream.c ++++ b/drivers/atm/firestream.c +@@ -1009,6 +1009,7 @@ static int fs_open(struct atm_vcc *atm_vcc) + error = make_rate (pcr, r, &tmc0, NULL); + if (error) { + kfree(tc); ++ kfree(vcc); + return error; + } + } +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c +index e0699a20859f7..445ca973edd6d 100644 +--- a/drivers/block/rbd.c ++++ b/drivers/block/rbd.c +@@ -3945,6 +3945,9 @@ static ssize_t rbd_image_refresh(struct device *dev, + struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); + int ret; + ++ if (!capable(CAP_SYS_ADMIN)) ++ return -EPERM; ++ + ret = rbd_dev_refresh(rbd_dev); + if (ret) + return ret; +@@ -5404,6 +5407,9 @@ static ssize_t do_rbd_add(struct bus_type *bus, + bool read_only; + int rc; + ++ if (!capable(CAP_SYS_ADMIN)) ++ return -EPERM; ++ + if (!try_module_get(THIS_MODULE)) + return -ENODEV; + +@@ -5548,6 +5554,9 @@ static ssize_t do_rbd_remove(struct bus_type *bus, + bool already = false; + int ret; + ++ if (!capable(CAP_SYS_ADMIN)) ++ return -EPERM; ++ + ret = kstrtoul(buf, 10, &ul); + if (ret) + return ret; +diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c +index 3a9db4626cb60..1886588b9ea3e 100644 +--- a/drivers/i2c/algos/i2c-algo-pca.c ++++ b/drivers/i2c/algos/i2c-algo-pca.c +@@ -50,8 +50,22 @@ static void pca_reset(struct i2c_algo_pca_data *adap) + pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_IPRESET); + pca_outw(adap, I2C_PCA_IND, 0xA5); + pca_outw(adap, I2C_PCA_IND, 0x5A); ++ ++ /* ++ * After a reset we need to re-apply any configuration ++ * (calculated in pca_init) to get the bus in a working state. ++ */ ++ pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_IMODE); ++ pca_outw(adap, I2C_PCA_IND, adap->bus_settings.mode); ++ pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_ISCLL); ++ pca_outw(adap, I2C_PCA_IND, adap->bus_settings.tlow); ++ pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_ISCLH); ++ pca_outw(adap, I2C_PCA_IND, adap->bus_settings.thi); ++ ++ pca_set_con(adap, I2C_PCA_CON_ENSIO); + } else { + adap->reset_chip(adap->data); ++ pca_set_con(adap, I2C_PCA_CON_ENSIO | adap->bus_settings.clock_freq); + } + } + +@@ -435,13 +449,14 @@ static int pca_init(struct i2c_adapter *adap) + " Use the nominal frequency.\n", adap->name); + } + +- pca_reset(pca_data); +- + clock = pca_clock(pca_data); + printk(KERN_INFO "%s: Clock frequency is %dkHz\n", + adap->name, freqs[clock]); + +- pca_set_con(pca_data, I2C_PCA_CON_ENSIO | clock); ++ /* Store settings as these will be needed when the PCA chip is reset */ ++ pca_data->bus_settings.clock_freq = clock; ++ ++ pca_reset(pca_data); + } else { + int clock; + int mode; +@@ -508,19 +523,15 @@ static int pca_init(struct i2c_adapter *adap) + thi = tlow * min_thi / min_tlow; + } + ++ /* Store settings as these will be needed when the PCA chip is reset */ ++ pca_data->bus_settings.mode = mode; ++ pca_data->bus_settings.tlow = tlow; ++ pca_data->bus_settings.thi = thi; ++ + pca_reset(pca_data); + + printk(KERN_INFO + "%s: Clock frequency is %dHz\n", adap->name, clock * 100); +- +- pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_IMODE); +- pca_outw(pca_data, I2C_PCA_IND, mode); +- pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_ISCLL); +- pca_outw(pca_data, I2C_PCA_IND, tlow); +- pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_ISCLH); +- pca_outw(pca_data, I2C_PCA_IND, thi); +- +- pca_set_con(pca_data, I2C_PCA_CON_ENSIO); + } + udelay(500); /* 500 us for oscillator to stabilise */ + +diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c +index ec7ddf8673497..e5e231b6476e7 100644 +--- a/drivers/iio/accel/bmc150-accel-core.c ++++ b/drivers/iio/accel/bmc150-accel-core.c +@@ -198,6 +198,14 @@ struct bmc150_accel_data { + struct mutex mutex; + u8 fifo_mode, watermark; + s16 buffer[8]; ++ /* ++ * Ensure there is sufficient space and correct alignment for ++ * the timestamp if enabled ++ */ ++ struct { ++ __le16 channels[3]; ++ s64 ts __aligned(8); ++ } scan; + u8 bw_bits; + u32 slope_dur; + u32 slope_thres; +@@ -924,15 +932,16 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev, + * now. + */ + for (i = 0; i < count; i++) { +- u16 sample[8]; + int j, bit; + + j = 0; + for_each_set_bit(bit, indio_dev->active_scan_mask, + indio_dev->masklength) +- memcpy(&sample[j++], &buffer[i * 3 + bit], 2); ++ memcpy(&data->scan.channels[j++], &buffer[i * 3 + bit], ++ sizeof(data->scan.channels[0])); + +- iio_push_to_buffers_with_timestamp(indio_dev, sample, tstamp); ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, ++ tstamp); + + tstamp += sample_period; + } +diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c +index 1eccc2dcf14cd..d44c1b3a131cf 100644 +--- a/drivers/iio/accel/mma8452.c ++++ b/drivers/iio/accel/mma8452.c +@@ -96,6 +96,12 @@ struct mma8452_data { + u8 ctrl_reg1; + u8 data_cfg; + const struct mma_chip_info *chip_info; ++ ++ /* Ensure correct alignment of time stamp when present */ ++ struct { ++ __be16 channels[3]; ++ s64 ts __aligned(8); ++ } buffer; + }; + + /** +@@ -700,14 +706,13 @@ static irqreturn_t mma8452_trigger_handler(int irq, void *p) + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct mma8452_data *data = iio_priv(indio_dev); +- u8 buffer[16]; /* 3 16-bit channels + padding + ts */ + int ret; + +- ret = mma8452_read(data, (__be16 *)buffer); ++ ret = mma8452_read(data, data->buffer.channels); + if (ret < 0) + goto done; + +- iio_push_to_buffers_with_timestamp(indio_dev, buffer, ++ iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, + iio_get_time_ns()); + + done: +diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c +index 3555122008b44..26fc1021a2c27 100644 +--- a/drivers/iio/adc/mcp3422.c ++++ b/drivers/iio/adc/mcp3422.c +@@ -98,16 +98,12 @@ static int mcp3422_update_config(struct mcp3422 *adc, u8 newconfig) + { + int ret; + +- mutex_lock(&adc->lock); +- + ret = i2c_master_send(adc->i2c, &newconfig, 1); + if (ret > 0) { + adc->config = newconfig; + ret = 0; + } + +- mutex_unlock(&adc->lock); +- + return ret; + } + +@@ -140,6 +136,8 @@ static int mcp3422_read_channel(struct mcp3422 *adc, + u8 config; + u8 req_channel = channel->channel; + ++ mutex_lock(&adc->lock); ++ + if (req_channel != MCP3422_CHANNEL(adc->config)) { + config = adc->config; + config &= ~MCP3422_CHANNEL_MASK; +@@ -147,12 +145,18 @@ static int mcp3422_read_channel(struct mcp3422 *adc, + config &= ~MCP3422_PGA_MASK; + config |= MCP3422_PGA_VALUE(adc->pga[req_channel]); + ret = mcp3422_update_config(adc, config); +- if (ret < 0) ++ if (ret < 0) { ++ mutex_unlock(&adc->lock); + return ret; ++ } + msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]); + } + +- return mcp3422_read(adc, value, &config); ++ ret = mcp3422_read(adc, value, &config); ++ ++ mutex_unlock(&adc->lock); ++ ++ return ret; + } + + static int mcp3422_read_raw(struct iio_dev *iio, +diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c +index b9d1e5c58ec54..9f5825f4fc0ee 100644 +--- a/drivers/iio/light/ltr501.c ++++ b/drivers/iio/light/ltr501.c +@@ -1218,13 +1218,16 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ltr501_data *data = iio_priv(indio_dev); +- u16 buf[8]; ++ struct { ++ u16 channels[3]; ++ s64 ts __aligned(8); ++ } scan; + __le16 als_buf[2]; + u8 mask = 0; + int j = 0; + int ret, psdata; + +- memset(buf, 0, sizeof(buf)); ++ memset(&scan, 0, sizeof(scan)); + + /* figure out which data needs to be ready */ + if (test_bit(0, indio_dev->active_scan_mask) || +@@ -1243,9 +1246,9 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) + if (ret < 0) + return ret; + if (test_bit(0, indio_dev->active_scan_mask)) +- buf[j++] = le16_to_cpu(als_buf[1]); ++ scan.channels[j++] = le16_to_cpu(als_buf[1]); + if (test_bit(1, indio_dev->active_scan_mask)) +- buf[j++] = le16_to_cpu(als_buf[0]); ++ scan.channels[j++] = le16_to_cpu(als_buf[0]); + } + + if (mask & LTR501_STATUS_PS_RDY) { +@@ -1253,10 +1256,10 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) + &psdata, 2); + if (ret < 0) + goto done; +- buf[j++] = psdata & LTR501_PS_DATA_MASK; ++ scan.channels[j++] = psdata & LTR501_PS_DATA_MASK; + } + +- iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); ++ iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns()); + + done: + iio_trigger_notify_done(indio_dev->trig); +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h +index bdc42923523e8..e5799639fb544 100644 +--- a/drivers/input/serio/i8042-x86ia64io.h ++++ b/drivers/input/serio/i8042-x86ia64io.h +@@ -552,6 +552,14 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"), + }, + }, ++ { ++ /* Entroware Proteus */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Entroware"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Proteus"), ++ DMI_MATCH(DMI_PRODUCT_VERSION, "EL07R4"), ++ }, ++ }, + { } + }; + +@@ -752,6 +760,14 @@ static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = { + DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"), + }, + }, ++ { ++ /* Entroware Proteus */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Entroware"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Proteus"), ++ DMI_MATCH(DMI_PRODUCT_VERSION, "EL07R4"), ++ }, ++ }, + { } + }; + +diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c +index 3f20808b5ff82..f8ed079d8bc3e 100644 +--- a/drivers/net/wan/hdlc_cisco.c ++++ b/drivers/net/wan/hdlc_cisco.c +@@ -377,6 +377,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr) + memcpy(&state(hdlc)->settings, &new_settings, size); + spin_lock_init(&state(hdlc)->lock); + dev->header_ops = &cisco_header_ops; ++ dev->hard_header_len = sizeof(struct hdlc_header); + dev->type = ARPHRD_CISCO; + netif_dormant_on(dev); + return 0; +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c +index 6eb0f7a85e531..c6db9a4e7c457 100644 +--- a/drivers/net/wan/lapbether.c ++++ b/drivers/net/wan/lapbether.c +@@ -213,6 +213,8 @@ static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb) + + skb->dev = dev = lapbeth->ethdev; + ++ skb_reset_network_header(skb); ++ + dev_hard_header(skb, dev, ETH_P_DEC, bcast_addr, NULL, 0); + + dev_queue_xmit(skb); +@@ -343,6 +345,7 @@ static int lapbeth_new_device(struct net_device *dev) + */ + ndev->needed_headroom = -1 + 3 + 2 + dev->hard_header_len + + dev->needed_headroom; ++ ndev->needed_tailroom = dev->needed_tailroom; + + lapbeth = netdev_priv(ndev); + lapbeth->axdev = ndev; +diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig +index 3e3be57e9a1a1..4d0c1a40a6e65 100644 +--- a/drivers/rapidio/Kconfig ++++ b/drivers/rapidio/Kconfig +@@ -25,7 +25,7 @@ config RAPIDIO_ENABLE_RX_TX_PORTS + config RAPIDIO_DMA_ENGINE + bool "DMA Engine support for RapidIO" + depends on RAPIDIO +- select DMADEVICES ++ depends on DMADEVICES + select DMA_ENGINE + help + Say Y here if you want to use DMA Engine frameork for RapidIO data +diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c +index 6f5e2720ffad1..68b33abeaa5fa 100644 +--- a/drivers/scsi/libsas/sas_ata.c ++++ b/drivers/scsi/libsas/sas_ata.c +@@ -224,7 +224,10 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) + task->num_scatter = si; + } + +- task->data_dir = qc->dma_dir; ++ if (qc->tf.protocol == ATA_PROT_NODATA) ++ task->data_dir = DMA_NONE; ++ else ++ task->data_dir = qc->dma_dir; + task->scatter = qc->sg; + task->ata_task.retry_count = 1; + task->task_state_flags = SAS_TASK_STATE_PENDING; +diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c +index 315dd25a0c44e..5be938b47f48b 100644 +--- a/drivers/scsi/lpfc/lpfc_els.c ++++ b/drivers/scsi/lpfc/lpfc_els.c +@@ -3841,7 +3841,9 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + out: + if (ndlp && NLP_CHK_NODE_ACT(ndlp) && shost) { + spin_lock_irq(shost->host_lock); +- ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); ++ if (mbox) ++ ndlp->nlp_flag &= ~NLP_ACC_REGLOGIN; ++ ndlp->nlp_flag &= ~NLP_RM_DFLT_RPI; + spin_unlock_irq(shost->host_lock); + + /* If the node is not being used by another discovery thread, +diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c +index 3862d8b1defe3..ee6c941123e10 100644 +--- a/drivers/scsi/pm8001/pm8001_sas.c ++++ b/drivers/scsi/pm8001/pm8001_sas.c +@@ -792,7 +792,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, + + res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); + if (res) +- return res; ++ goto ex_err; + ccb = &pm8001_ha->ccb_info[ccb_tag]; + ccb->device = pm8001_dev; + ccb->ccb_tag = ccb_tag; +diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c +index 3903f681ef6c6..2772c7179a61f 100644 +--- a/drivers/staging/wlan-ng/hfa384x_usb.c ++++ b/drivers/staging/wlan-ng/hfa384x_usb.c +@@ -530,13 +530,8 @@ static void hfa384x_usb_defer(struct work_struct *data) + ----------------------------------------------------------------*/ + void hfa384x_create(hfa384x_t *hw, struct usb_device *usb) + { +- memset(hw, 0, sizeof(hfa384x_t)); + hw->usb = usb; + +- /* set up the endpoints */ +- hw->endp_in = usb_rcvbulkpipe(usb, 1); +- hw->endp_out = usb_sndbulkpipe(usb, 2); +- + /* Set up the waitq */ + init_waitqueue_head(&hw->cmdq); + +diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c +index 6da5c66bb3d5c..f4276943dc972 100644 +--- a/drivers/staging/wlan-ng/prism2usb.c ++++ b/drivers/staging/wlan-ng/prism2usb.c +@@ -60,23 +60,14 @@ static int prism2sta_probe_usb(struct usb_interface *interface, + const struct usb_device_id *id) + { + struct usb_device *dev; +- const struct usb_endpoint_descriptor *epd; +- const struct usb_host_interface *iface_desc = interface->cur_altsetting; ++ struct usb_endpoint_descriptor *bulk_in, *bulk_out; ++ struct usb_host_interface *iface_desc = interface->cur_altsetting; + wlandevice_t *wlandev = NULL; + hfa384x_t *hw = NULL; + int result = 0; + +- if (iface_desc->desc.bNumEndpoints != 2) { +- result = -ENODEV; +- goto failed; +- } +- +- result = -EINVAL; +- epd = &iface_desc->endpoint[1].desc; +- if (!usb_endpoint_is_bulk_in(epd)) +- goto failed; +- epd = &iface_desc->endpoint[2].desc; +- if (!usb_endpoint_is_bulk_out(epd)) ++ result = usb_find_common_endpoints(iface_desc, &bulk_in, &bulk_out, NULL, NULL); ++ if (result) + goto failed; + + dev = interface_to_usbdev(interface); +@@ -95,6 +86,8 @@ static int prism2sta_probe_usb(struct usb_interface *interface, + } + + /* Initialize the hw data */ ++ hw->endp_in = usb_rcvbulkpipe(dev, bulk_in->bEndpointAddress); ++ hw->endp_out = usb_sndbulkpipe(dev, bulk_out->bEndpointAddress); + hfa384x_create(hw, dev); + hw->wlandev = wlandev; + +diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c +index 63e54beed196b..f10bcd0563c06 100644 +--- a/drivers/target/iscsi/iscsi_target_login.c ++++ b/drivers/target/iscsi/iscsi_target_login.c +@@ -1139,7 +1139,7 @@ iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) + } + + void iscsi_target_login_sess_out(struct iscsi_conn *conn, +- struct iscsi_np *np, bool zero_tsih, bool new_sess) ++ bool zero_tsih, bool new_sess) + { + if (!new_sess) + goto old_sess_out; +@@ -1161,7 +1161,6 @@ void iscsi_target_login_sess_out(struct iscsi_conn *conn, + conn->sess = NULL; + + old_sess_out: +- iscsi_stop_login_thread_timer(np); + /* + * If login negotiation fails check if the Time2Retain timer + * needs to be restarted. +@@ -1407,8 +1406,9 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) + new_sess_out: + new_sess = true; + old_sess_out: ++ iscsi_stop_login_thread_timer(np); + tpg_np = conn->tpg_np; +- iscsi_target_login_sess_out(conn, np, zero_tsih, new_sess); ++ iscsi_target_login_sess_out(conn, zero_tsih, new_sess); + new_sess = false; + + if (tpg) { +diff --git a/drivers/target/iscsi/iscsi_target_login.h b/drivers/target/iscsi/iscsi_target_login.h +index b597aa2c61a1c..e9daabbb4f545 100644 +--- a/drivers/target/iscsi/iscsi_target_login.h ++++ b/drivers/target/iscsi/iscsi_target_login.h +@@ -14,8 +14,7 @@ extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); + extern void iscsit_free_conn(struct iscsi_np *, struct iscsi_conn *); + extern int iscsit_start_kthreads(struct iscsi_conn *); + extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8); +-extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *, +- bool, bool); ++extern void iscsi_target_login_sess_out(struct iscsi_conn *, bool, bool); + extern int iscsi_target_login_thread(void *); + + #endif /*** ISCSI_TARGET_LOGIN_H ***/ +diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c +index 58c629aec73ca..31c3e37c41e52 100644 +--- a/drivers/target/iscsi/iscsi_target_nego.c ++++ b/drivers/target/iscsi/iscsi_target_nego.c +@@ -547,12 +547,11 @@ static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned in + + static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login *login) + { +- struct iscsi_np *np = login->np; + bool zero_tsih = login->zero_tsih; + + iscsi_remove_failed_auth_entry(conn); + iscsi_target_nego_release(conn); +- iscsi_target_login_sess_out(conn, np, zero_tsih, true); ++ iscsi_target_login_sess_out(conn, zero_tsih, true); + } + + static void iscsi_target_login_timeout(unsigned long data) +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c +index b032add927224..72f6cde146b5c 100644 +--- a/drivers/tty/serial/8250/8250_pci.c ++++ b/drivers/tty/serial/8250/8250_pci.c +@@ -5904,6 +5904,17 @@ static struct pci_device_id serial_pci_tbl[] = { + 0, + 0, pbn_exar_XR17V358 }, + ++ /* ++ * Realtek RealManage ++ */ ++ { PCI_VENDOR_ID_REALTEK, 0x816a, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, pbn_b0_1_115200 }, ++ ++ { PCI_VENDOR_ID_REALTEK, 0x816b, ++ PCI_ANY_ID, PCI_ANY_ID, ++ 0, 0, pbn_b0_1_115200 }, ++ + /* Fintek PCI serial cards */ + { PCI_DEVICE(0x1c29, 0x1104), .driver_data = pbn_fintek_4 }, + { PCI_DEVICE(0x1c29, 0x1108), .driver_data = pbn_fintek_8 }, +diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c +index c578d64edc153..71c2ae4b81067 100644 +--- a/drivers/usb/class/usblp.c ++++ b/drivers/usb/class/usblp.c +@@ -840,6 +840,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo + if (rv < 0) + return rv; + ++ if (!usblp->present) { ++ count = -ENODEV; ++ goto done; ++ } ++ + if ((avail = usblp->rstatus) < 0) { + printk(KERN_ERR "usblp%d: error %d reading from printer\n", + usblp->minor, (int)avail); +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c +index f083ecfddd1b1..e568325cb6e15 100644 +--- a/drivers/usb/core/message.c ++++ b/drivers/usb/core/message.c +@@ -1141,6 +1141,34 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf, + } + } + ++/* ++ * usb_disable_device_endpoints -- Disable all endpoints for a device ++ * @dev: the device whose endpoints are being disabled ++ * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. ++ */ ++static void usb_disable_device_endpoints(struct usb_device *dev, int skip_ep0) ++{ ++ struct usb_hcd *hcd = bus_to_hcd(dev->bus); ++ int i; ++ ++ if (hcd->driver->check_bandwidth) { ++ /* First pass: Cancel URBs, leave endpoint pointers intact. */ ++ for (i = skip_ep0; i < 16; ++i) { ++ usb_disable_endpoint(dev, i, false); ++ usb_disable_endpoint(dev, i + USB_DIR_IN, false); ++ } ++ /* Remove endpoints from the host controller internal state */ ++ mutex_lock(hcd->bandwidth_mutex); ++ usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); ++ mutex_unlock(hcd->bandwidth_mutex); ++ } ++ /* Second pass: remove endpoint pointers */ ++ for (i = skip_ep0; i < 16; ++i) { ++ usb_disable_endpoint(dev, i, true); ++ usb_disable_endpoint(dev, i + USB_DIR_IN, true); ++ } ++} ++ + /** + * usb_disable_device - Disable all the endpoints for a USB device + * @dev: the device whose endpoints are being disabled +@@ -1200,22 +1227,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) + + dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__, + skip_ep0 ? "non-ep0" : "all"); +- if (hcd->driver->check_bandwidth) { +- /* First pass: Cancel URBs, leave endpoint pointers intact. */ +- for (i = skip_ep0; i < 16; ++i) { +- usb_disable_endpoint(dev, i, false); +- usb_disable_endpoint(dev, i + USB_DIR_IN, false); +- } +- /* Remove endpoints from the host controller internal state */ +- mutex_lock(hcd->bandwidth_mutex); +- usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); +- mutex_unlock(hcd->bandwidth_mutex); +- /* Second pass: remove endpoint pointers */ +- } +- for (i = skip_ep0; i < 16; ++i) { +- usb_disable_endpoint(dev, i, true); +- usb_disable_endpoint(dev, i + USB_DIR_IN, true); +- } ++ ++ usb_disable_device_endpoints(dev, skip_ep0); + } + + /** +@@ -1458,6 +1471,9 @@ EXPORT_SYMBOL_GPL(usb_set_interface); + * The caller must own the device lock. + * + * Return: Zero on success, else a negative error code. ++ * ++ * If this routine fails the device will probably be in an unusable state ++ * with endpoints disabled, and interfaces only partially enabled. + */ + int usb_reset_configuration(struct usb_device *dev) + { +@@ -1473,10 +1489,7 @@ int usb_reset_configuration(struct usb_device *dev) + * calls during probe() are fine + */ + +- for (i = 1; i < 16; ++i) { +- usb_disable_endpoint(dev, i, true); +- usb_disable_endpoint(dev, i + USB_DIR_IN, true); +- } ++ usb_disable_device_endpoints(dev, 1); /* skip ep0*/ + + config = dev->actconfig; + retval = 0; +@@ -1489,34 +1502,10 @@ int usb_reset_configuration(struct usb_device *dev) + mutex_unlock(hcd->bandwidth_mutex); + return -ENOMEM; + } +- /* Make sure we have enough bandwidth for each alternate setting 0 */ +- for (i = 0; i < config->desc.bNumInterfaces; i++) { +- struct usb_interface *intf = config->interface[i]; +- struct usb_host_interface *alt; + +- alt = usb_altnum_to_altsetting(intf, 0); +- if (!alt) +- alt = &intf->altsetting[0]; +- if (alt != intf->cur_altsetting) +- retval = usb_hcd_alloc_bandwidth(dev, NULL, +- intf->cur_altsetting, alt); +- if (retval < 0) +- break; +- } +- /* If not, reinstate the old alternate settings */ ++ /* xHCI adds all endpoints in usb_hcd_alloc_bandwidth */ ++ retval = usb_hcd_alloc_bandwidth(dev, config, NULL, NULL); + if (retval < 0) { +-reset_old_alts: +- for (i--; i >= 0; i--) { +- struct usb_interface *intf = config->interface[i]; +- struct usb_host_interface *alt; +- +- alt = usb_altnum_to_altsetting(intf, 0); +- if (!alt) +- alt = &intf->altsetting[0]; +- if (alt != intf->cur_altsetting) +- usb_hcd_alloc_bandwidth(dev, NULL, +- alt, intf->cur_altsetting); +- } + usb_enable_lpm(dev); + mutex_unlock(hcd->bandwidth_mutex); + return retval; +@@ -1525,8 +1514,12 @@ reset_old_alts: + USB_REQ_SET_CONFIGURATION, 0, + config->desc.bConfigurationValue, 0, + NULL, 0, USB_CTRL_SET_TIMEOUT); +- if (retval < 0) +- goto reset_old_alts; ++ if (retval < 0) { ++ usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); ++ usb_enable_lpm(dev); ++ mutex_unlock(hcd->bandwidth_mutex); ++ return retval; ++ } + mutex_unlock(hcd->bandwidth_mutex); + + /* re-init hc/hcd interface/endpoint state */ +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c +index eed7c8d8e3d4f..dd72e85f2e176 100644 +--- a/drivers/usb/core/quirks.c ++++ b/drivers/usb/core/quirks.c +@@ -236,6 +236,10 @@ static const struct usb_device_id usb_quirk_list[] = { + /* Generic RTL8153 based ethernet adapters */ + { USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM }, + ++ /* SONiX USB DEVICE Touchpad */ ++ { USB_DEVICE(0x0c45, 0x7056), .driver_info = ++ USB_QUIRK_IGNORE_REMOTE_WAKEUP }, ++ + /* Action Semiconductor flash disk */ + { USB_DEVICE(0x10d6, 0x2200), .driver_info = + USB_QUIRK_STRING_FETCH_255 }, +diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c +index 36e5098e4e6f6..415e9cf407ba5 100644 +--- a/drivers/usb/core/usb.c ++++ b/drivers/usb/core/usb.c +@@ -76,6 +76,89 @@ MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); + #endif + + ++/** ++ * usb_find_common_endpoints() -- look up common endpoint descriptors ++ * @alt: alternate setting to search ++ * @bulk_in: pointer to descriptor pointer, or NULL ++ * @bulk_out: pointer to descriptor pointer, or NULL ++ * @int_in: pointer to descriptor pointer, or NULL ++ * @int_out: pointer to descriptor pointer, or NULL ++ * ++ * Search the alternate setting's endpoint descriptors for the first bulk-in, ++ * bulk-out, interrupt-in and interrupt-out endpoints and return them in the ++ * provided pointers (unless they are NULL). ++ * ++ * If a requested endpoint is not found, the corresponding pointer is set to ++ * NULL. ++ * ++ * Return: Zero if all requested descriptors were found, or -ENXIO otherwise. ++ */ ++int usb_find_common_endpoints(struct usb_host_interface *alt, ++ struct usb_endpoint_descriptor **bulk_in, ++ struct usb_endpoint_descriptor **bulk_out, ++ struct usb_endpoint_descriptor **int_in, ++ struct usb_endpoint_descriptor **int_out) ++{ ++ struct usb_endpoint_descriptor *epd; ++ int i; ++ ++ if (bulk_in) ++ *bulk_in = NULL; ++ if (bulk_out) ++ *bulk_out = NULL; ++ if (int_in) ++ *int_in = NULL; ++ if (int_out) ++ *int_out = NULL; ++ ++ for (i = 0; i < alt->desc.bNumEndpoints; ++i) { ++ epd = &alt->endpoint[i].desc; ++ ++ switch (usb_endpoint_type(epd)) { ++ case USB_ENDPOINT_XFER_BULK: ++ if (usb_endpoint_dir_in(epd)) { ++ if (bulk_in && !*bulk_in) { ++ *bulk_in = epd; ++ break; ++ } ++ } else { ++ if (bulk_out && !*bulk_out) { ++ *bulk_out = epd; ++ break; ++ } ++ } ++ ++ continue; ++ case USB_ENDPOINT_XFER_INT: ++ if (usb_endpoint_dir_in(epd)) { ++ if (int_in && !*int_in) { ++ *int_in = epd; ++ break; ++ } ++ } else { ++ if (int_out && !*int_out) { ++ *int_out = epd; ++ break; ++ } ++ } ++ ++ continue; ++ default: ++ continue; ++ } ++ ++ if ((!bulk_in || *bulk_in) && ++ (!bulk_out || *bulk_out) && ++ (!int_in || *int_in) && ++ (!int_out || *int_out)) { ++ return 0; ++ } ++ } ++ ++ return -ENXIO; ++} ++EXPORT_SYMBOL_GPL(usb_find_common_endpoints); ++ + /** + * usb_find_alt_setting() - Given a configuration, find the alternate setting + * for the given interface. +diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c +index f7661d9750fdc..330e05acf5f75 100644 +--- a/drivers/usb/host/ehci-hcd.c ++++ b/drivers/usb/host/ehci-hcd.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c +index 086a7115d263c..4dc93547e9278 100644 +--- a/drivers/usb/host/ehci-hub.c ++++ b/drivers/usb/host/ehci-hub.c +@@ -27,7 +27,6 @@ + */ + + /*-------------------------------------------------------------------------*/ +-#include + + #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) + +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index 0afea511eb376..25e76d4c15054 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -708,6 +708,7 @@ static const struct usb_device_id id_table_combined[] = { + { USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_MTDEVBOARD_PID) }, ++ { USB_DEVICE(XSENS_VID, XSENS_MTIUSBCONVERTER_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) }, + { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h +index 32a40ab9a3852..c33e06752b5f0 100644 +--- a/drivers/usb/serial/ftdi_sio_ids.h ++++ b/drivers/usb/serial/ftdi_sio_ids.h +@@ -159,6 +159,7 @@ + #define XSENS_AWINDA_DONGLE_PID 0x0102 + #define XSENS_MTW_PID 0x0200 /* Xsens MTw */ + #define XSENS_MTDEVBOARD_PID 0x0300 /* Motion Tracker Development Board */ ++#define XSENS_MTIUSBCONVERTER_PID 0x0301 /* MTi USB converter */ + #define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */ + + /* Xsens devices using FTDI VID */ +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c +index 52b1092ed57ed..8cff50ef4fd14 100644 +--- a/drivers/usb/serial/option.c ++++ b/drivers/usb/serial/option.c +@@ -1808,6 +1808,8 @@ static const struct usb_device_id option_ids[] = { + { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) }, /* Simcom SIM7500/SIM7600 MBIM mode */ + { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff), /* Simcom SIM7500/SIM7600 RNDIS mode */ + .driver_info = RSVD(7) }, ++ { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9205, 0xff) }, /* Simcom SIM7070/SIM7080/SIM7090 AT+ECM mode */ ++ { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9206, 0xff) }, /* Simcom SIM7070/SIM7080/SIM7090 AT-only mode */ + { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200), + .driver_info = NCTRL(0) | NCTRL(1) | RSVD(4) }, + { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D), +diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c +index 698ba127b6352..34dcd2e1b4fe9 100644 +--- a/drivers/usb/storage/uas.c ++++ b/drivers/usb/storage/uas.c +@@ -646,8 +646,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, + if (devinfo->resetting) { + cmnd->result = DID_ERROR << 16; + cmnd->scsi_done(cmnd); +- spin_unlock_irqrestore(&devinfo->lock, flags); +- return 0; ++ goto zombie; + } + + /* Find a free uas-tag */ +@@ -682,6 +681,16 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, + cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB); + + err = uas_submit_urbs(cmnd, devinfo, GFP_ATOMIC); ++ /* ++ * in case of fatal errors the SCSI layer is peculiar ++ * a command that has finished is a success for the purpose ++ * of queueing, no matter how fatal the error ++ */ ++ if (err == -ENODEV) { ++ cmnd->result = DID_ERROR << 16; ++ cmnd->scsi_done(cmnd); ++ goto zombie; ++ } + if (err) { + /* If we did nothing, give up now */ + if (cmdinfo->state & SUBMIT_STATUS_URB) { +@@ -692,6 +701,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, + } + + devinfo->cmnd[idx] = cmnd; ++zombie: + spin_unlock_irqrestore(&devinfo->lock, flags); + return 0; + } +diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig +index 38da6e2991491..c31715019cb43 100644 +--- a/drivers/video/console/Kconfig ++++ b/drivers/video/console/Kconfig +@@ -22,31 +22,6 @@ config VGA_CONSOLE + + Say Y. + +-config VGACON_SOFT_SCROLLBACK +- bool "Enable Scrollback Buffer in System RAM" +- depends on VGA_CONSOLE +- default n +- help +- The scrollback buffer of the standard VGA console is located in +- the VGA RAM. The size of this RAM is fixed and is quite small. +- If you require a larger scrollback buffer, this can be placed in +- System RAM which is dynamically allocated during initialization. +- Placing the scrollback buffer in System RAM will slightly slow +- down the console. +- +- If you want this feature, say 'Y' here and enter the amount of +- RAM to allocate for this buffer. If unsure, say 'N'. +- +-config VGACON_SOFT_SCROLLBACK_SIZE +- int "Scrollback Buffer Size (in KB)" +- depends on VGACON_SOFT_SCROLLBACK +- range 1 1024 +- default "64" +- help +- Enter the amount of System RAM to allocate for the scrollback +- buffer. Each 64KB will give you approximately 16 80x25 +- screenfuls of scrollback buffer +- + config MDA_CONSOLE + depends on !M68K && !PARISC && ISA + tristate "MDA text console (dual-headed)" +diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c +index 05d1d36a56654..a7ab8323304da 100644 +--- a/drivers/video/console/bitblit.c ++++ b/drivers/video/console/bitblit.c +@@ -234,7 +234,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, + } + + static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, +- int softback_lines, int fg, int bg) ++ int fg, int bg) + { + struct fb_cursor cursor; + struct fbcon_ops *ops = info->fbcon_par; +@@ -247,15 +247,6 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, + + cursor.set = 0; + +- if (softback_lines) { +- if (y + softback_lines >= vc->vc_rows) { +- mode = CM_ERASE; +- ops->cursor_flash = 0; +- return; +- } else +- y += softback_lines; +- } +- + c = scr_readw((u16 *) vc->vc_pos); + attribute = get_attribute(info, c); + src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c +index fe0663787b3c9..e57fa26bcff19 100644 +--- a/drivers/video/console/fbcon.c ++++ b/drivers/video/console/fbcon.c +@@ -101,12 +101,6 @@ static int logo_lines; + /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO + enums. */ + static int logo_shown = FBCON_LOGO_CANSHOW; +-/* Software scrollback */ +-static int fbcon_softback_size = 32768; +-static unsigned long softback_buf, softback_curr; +-static unsigned long softback_in; +-static unsigned long softback_top, softback_end; +-static int softback_lines; + /* console mappings */ + static int first_fb_vc; + static int last_fb_vc = MAX_NR_CONSOLES - 1; +@@ -140,8 +134,6 @@ static int fbcon_has_sysfs; + + static const struct consw fb_con; + +-#define CM_SOFTBACK (8) +- + #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row) + + static int fbcon_set_origin(struct vc_data *); +@@ -171,7 +163,6 @@ static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, + static int fbcon_switch(struct vc_data *vc); + static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch); + static int fbcon_set_palette(struct vc_data *vc, unsigned char *table); +-static int fbcon_scrolldelta(struct vc_data *vc, int lines); + + /* + * Internal routines +@@ -350,18 +341,6 @@ static int get_color(struct vc_data *vc, struct fb_info *info, + return color; + } + +-static void fbcon_update_softback(struct vc_data *vc) +-{ +- int l = fbcon_softback_size / vc->vc_size_row; +- +- if (l > 5) +- softback_end = softback_buf + l * vc->vc_size_row; +- else +- /* Smaller scrollback makes no sense, and 0 would screw +- the operation totally */ +- softback_top = 0; +-} +- + static void fb_flashcursor(struct work_struct *work) + { + struct fb_info *info = container_of(work, struct fb_info, queue); +@@ -391,7 +370,7 @@ static void fb_flashcursor(struct work_struct *work) + c = scr_readw((u16 *) vc->vc_pos); + mode = (!ops->cursor_flash || ops->cursor_state.enable) ? + CM_ERASE : CM_DRAW; +- ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), ++ ops->cursor(vc, info, mode, get_color(vc, info, c, 1), + get_color(vc, info, c, 0)); + console_unlock(); + } +@@ -451,13 +430,7 @@ static int __init fb_console_setup(char *this_opt) + } + + if (!strncmp(options, "scrollback:", 11)) { +- options += 11; +- if (*options) { +- fbcon_softback_size = simple_strtoul(options, &options, 0); +- if (*options == 'k' || *options == 'K') { +- fbcon_softback_size *= 1024; +- } +- } ++ pr_warn("Ignoring scrollback size option\n"); + continue; + } + +@@ -962,31 +935,6 @@ static const char *fbcon_startup(void) + p->con_rotate = initial_rotation; + set_blitting_type(vc, info); + +- if (info->fix.type != FB_TYPE_TEXT) { +- if (fbcon_softback_size) { +- if (!softback_buf) { +- softback_buf = +- (unsigned long) +- kmalloc(fbcon_softback_size, +- GFP_KERNEL); +- if (!softback_buf) { +- fbcon_softback_size = 0; +- softback_top = 0; +- } +- } +- } else { +- if (softback_buf) { +- kfree((void *) softback_buf); +- softback_buf = 0; +- softback_top = 0; +- } +- } +- if (softback_buf) +- softback_in = softback_top = softback_curr = +- softback_buf; +- softback_lines = 0; +- } +- + /* Setup default font */ + if (!p->fontdata && !vc->vc_font.data) { + if (!fontname[0] || !(font = find_font(fontname))) +@@ -1149,9 +1097,6 @@ static void fbcon_init(struct vc_data *vc, int init) + if (logo) + fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows); + +- if (vc == svc && softback_buf) +- fbcon_update_softback(vc); +- + if (ops->rotate_font && ops->rotate_font(info, vc)) { + ops->rotate = FB_ROTATE_UR; + set_blitting_type(vc, info); +@@ -1311,7 +1256,6 @@ static void fbcon_cursor(struct vc_data *vc, int mode) + { + struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; + struct fbcon_ops *ops = info->fbcon_par; +- int y; + int c = scr_readw((u16 *) vc->vc_pos); + + ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms); +@@ -1325,16 +1269,8 @@ static void fbcon_cursor(struct vc_data *vc, int mode) + fbcon_add_cursor_timer(info); + + ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1; +- if (mode & CM_SOFTBACK) { +- mode &= ~CM_SOFTBACK; +- y = softback_lines; +- } else { +- if (softback_lines) +- fbcon_set_origin(vc); +- y = 0; +- } + +- ops->cursor(vc, info, mode, y, get_color(vc, info, c, 1), ++ ops->cursor(vc, info, mode, get_color(vc, info, c, 1), + get_color(vc, info, c, 0)); + } + +@@ -1405,8 +1341,6 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, + + if (CON_IS_VISIBLE(vc)) { + update_screen(vc); +- if (softback_buf) +- fbcon_update_softback(vc); + } + } + +@@ -1544,99 +1478,6 @@ static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count) + scrollback_current = 0; + } + +-static void fbcon_redraw_softback(struct vc_data *vc, struct display *p, +- long delta) +-{ +- int count = vc->vc_rows; +- unsigned short *d, *s; +- unsigned long n; +- int line = 0; +- +- d = (u16 *) softback_curr; +- if (d == (u16 *) softback_in) +- d = (u16 *) vc->vc_origin; +- n = softback_curr + delta * vc->vc_size_row; +- softback_lines -= delta; +- if (delta < 0) { +- if (softback_curr < softback_top && n < softback_buf) { +- n += softback_end - softback_buf; +- if (n < softback_top) { +- softback_lines -= +- (softback_top - n) / vc->vc_size_row; +- n = softback_top; +- } +- } else if (softback_curr >= softback_top +- && n < softback_top) { +- softback_lines -= +- (softback_top - n) / vc->vc_size_row; +- n = softback_top; +- } +- } else { +- if (softback_curr > softback_in && n >= softback_end) { +- n += softback_buf - softback_end; +- if (n > softback_in) { +- n = softback_in; +- softback_lines = 0; +- } +- } else if (softback_curr <= softback_in && n > softback_in) { +- n = softback_in; +- softback_lines = 0; +- } +- } +- if (n == softback_curr) +- return; +- softback_curr = n; +- s = (u16 *) softback_curr; +- if (s == (u16 *) softback_in) +- s = (u16 *) vc->vc_origin; +- while (count--) { +- unsigned short *start; +- unsigned short *le; +- unsigned short c; +- int x = 0; +- unsigned short attr = 1; +- +- start = s; +- le = advance_row(s, 1); +- do { +- c = scr_readw(s); +- if (attr != (c & 0xff00)) { +- attr = c & 0xff00; +- if (s > start) { +- fbcon_putcs(vc, start, s - start, +- line, x); +- x += s - start; +- start = s; +- } +- } +- if (c == scr_readw(d)) { +- if (s > start) { +- fbcon_putcs(vc, start, s - start, +- line, x); +- x += s - start + 1; +- start = s + 1; +- } else { +- x++; +- start++; +- } +- } +- s++; +- d++; +- } while (s < le); +- if (s > start) +- fbcon_putcs(vc, start, s - start, line, x); +- line++; +- if (d == (u16 *) softback_end) +- d = (u16 *) softback_buf; +- if (d == (u16 *) softback_in) +- d = (u16 *) vc->vc_origin; +- if (s == (u16 *) softback_end) +- s = (u16 *) softback_buf; +- if (s == (u16 *) softback_in) +- s = (u16 *) vc->vc_origin; +- } +-} +- + static void fbcon_redraw_move(struct vc_data *vc, struct display *p, + int line, int count, int dy) + { +@@ -1776,31 +1617,6 @@ static void fbcon_redraw(struct vc_data *vc, struct display *p, + } + } + +-static inline void fbcon_softback_note(struct vc_data *vc, int t, +- int count) +-{ +- unsigned short *p; +- +- if (vc->vc_num != fg_console) +- return; +- p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row); +- +- while (count) { +- scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row); +- count--; +- p = advance_row(p, 1); +- softback_in += vc->vc_size_row; +- if (softback_in == softback_end) +- softback_in = softback_buf; +- if (softback_in == softback_top) { +- softback_top += vc->vc_size_row; +- if (softback_top == softback_end) +- softback_top = softback_buf; +- } +- } +- softback_curr = softback_in; +-} +- + static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, + int count) + { +@@ -1823,8 +1639,6 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, + case SM_UP: + if (count > vc->vc_rows) /* Maximum realistic size */ + count = vc->vc_rows; +- if (softback_top) +- fbcon_softback_note(vc, t, count); + if (logo_shown >= 0) + goto redraw_up; + switch (p->scrollmode) { +@@ -2129,7 +1943,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, + struct fb_var_screeninfo var = info->var; + int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; + +- if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) { ++ if (p->userfont && FNTSIZE(vc->vc_font.data)) { + int size; + int pitch = PITCH(vc->vc_font.width); + +@@ -2195,14 +2009,6 @@ static int fbcon_switch(struct vc_data *vc) + info = registered_fb[con2fb_map[vc->vc_num]]; + ops = info->fbcon_par; + +- if (softback_top) { +- if (softback_lines) +- fbcon_set_origin(vc); +- softback_top = softback_curr = softback_in = softback_buf; +- softback_lines = 0; +- fbcon_update_softback(vc); +- } +- + if (logo_shown >= 0) { + struct vc_data *conp2 = vc_cons[logo_shown].d; + +@@ -2536,9 +2342,6 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, + int cnt; + char *old_data = NULL; + +- if (CON_IS_VISIBLE(vc) && softback_lines) +- fbcon_set_origin(vc); +- + resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); + if (p->userfont) + old_data = vc->vc_font.data; +@@ -2564,8 +2367,6 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, + cols /= w; + rows /= h; + vc_resize(vc, cols, rows); +- if (CON_IS_VISIBLE(vc) && softback_buf) +- fbcon_update_softback(vc); + } else if (CON_IS_VISIBLE(vc) + && vc->vc_mode == KD_TEXT) { + fbcon_clear_margins(vc, 0); +@@ -2723,19 +2524,7 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table) + + static u16 *fbcon_screen_pos(struct vc_data *vc, int offset) + { +- unsigned long p; +- int line; +- +- if (vc->vc_num != fg_console || !softback_lines) +- return (u16 *) (vc->vc_origin + offset); +- line = offset / vc->vc_size_row; +- if (line >= softback_lines) +- return (u16 *) (vc->vc_origin + offset - +- softback_lines * vc->vc_size_row); +- p = softback_curr + offset; +- if (p >= softback_end) +- p += softback_buf - softback_end; +- return (u16 *) p; ++ return (u16 *) (vc->vc_origin + offset); + } + + static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos, +@@ -2749,22 +2538,7 @@ static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos, + + x = offset % vc->vc_cols; + y = offset / vc->vc_cols; +- if (vc->vc_num == fg_console) +- y += softback_lines; + ret = pos + (vc->vc_cols - x) * 2; +- } else if (vc->vc_num == fg_console && softback_lines) { +- unsigned long offset = pos - softback_curr; +- +- if (pos < softback_curr) +- offset += softback_end - softback_buf; +- offset /= 2; +- x = offset % vc->vc_cols; +- y = offset / vc->vc_cols; +- ret = pos + (vc->vc_cols - x) * 2; +- if (ret == softback_end) +- ret = softback_buf; +- if (ret == softback_in) +- ret = vc->vc_origin; + } else { + /* Should not happen */ + x = y = 0; +@@ -2792,107 +2566,11 @@ static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt) + a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | + (((a) & 0x0700) << 4); + scr_writew(a, p++); +- if (p == (u16 *) softback_end) +- p = (u16 *) softback_buf; +- if (p == (u16 *) softback_in) +- p = (u16 *) vc->vc_origin; + } + } + +-static int fbcon_scrolldelta(struct vc_data *vc, int lines) +-{ +- struct fb_info *info = registered_fb[con2fb_map[fg_console]]; +- struct fbcon_ops *ops = info->fbcon_par; +- struct display *disp = &fb_display[fg_console]; +- int offset, limit, scrollback_old; +- +- if (softback_top) { +- if (vc->vc_num != fg_console) +- return 0; +- if (vc->vc_mode != KD_TEXT || !lines) +- return 0; +- if (logo_shown >= 0) { +- struct vc_data *conp2 = vc_cons[logo_shown].d; +- +- if (conp2->vc_top == logo_lines +- && conp2->vc_bottom == conp2->vc_rows) +- conp2->vc_top = 0; +- if (logo_shown == vc->vc_num) { +- unsigned long p, q; +- int i; +- +- p = softback_in; +- q = vc->vc_origin + +- logo_lines * vc->vc_size_row; +- for (i = 0; i < logo_lines; i++) { +- if (p == softback_top) +- break; +- if (p == softback_buf) +- p = softback_end; +- p -= vc->vc_size_row; +- q -= vc->vc_size_row; +- scr_memcpyw((u16 *) q, (u16 *) p, +- vc->vc_size_row); +- } +- softback_in = softback_curr = p; +- update_region(vc, vc->vc_origin, +- logo_lines * vc->vc_cols); +- } +- logo_shown = FBCON_LOGO_CANSHOW; +- } +- fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK); +- fbcon_redraw_softback(vc, disp, lines); +- fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK); +- return 0; +- } +- +- if (!scrollback_phys_max) +- return -ENOSYS; +- +- scrollback_old = scrollback_current; +- scrollback_current -= lines; +- if (scrollback_current < 0) +- scrollback_current = 0; +- else if (scrollback_current > scrollback_max) +- scrollback_current = scrollback_max; +- if (scrollback_current == scrollback_old) +- return 0; +- +- if (fbcon_is_inactive(vc, info)) +- return 0; +- +- fbcon_cursor(vc, CM_ERASE); +- +- offset = disp->yscroll - scrollback_current; +- limit = disp->vrows; +- switch (disp->scrollmode) { +- case SCROLL_WRAP_MOVE: +- info->var.vmode |= FB_VMODE_YWRAP; +- break; +- case SCROLL_PAN_MOVE: +- case SCROLL_PAN_REDRAW: +- limit -= vc->vc_rows; +- info->var.vmode &= ~FB_VMODE_YWRAP; +- break; +- } +- if (offset < 0) +- offset += limit; +- else if (offset >= limit) +- offset -= limit; +- +- ops->var.xoffset = 0; +- ops->var.yoffset = offset * vc->vc_font.height; +- ops->update_start(info); +- +- if (!scrollback_current) +- fbcon_cursor(vc, CM_DRAW); +- return 0; +-} +- + static int fbcon_set_origin(struct vc_data *vc) + { +- if (softback_lines) +- fbcon_scrolldelta(vc, softback_lines); + return 0; + } + +@@ -2956,8 +2634,6 @@ static void fbcon_modechanged(struct fb_info *info) + + fbcon_set_palette(vc, color_table); + update_screen(vc); +- if (softback_buf) +- fbcon_update_softback(vc); + } + } + +@@ -3378,7 +3054,6 @@ static const struct consw fb_con = { + .con_font_default = fbcon_set_def_font, + .con_font_copy = fbcon_copy_font, + .con_set_palette = fbcon_set_palette, +- .con_scrolldelta = fbcon_scrolldelta, + .con_set_origin = fbcon_set_origin, + .con_invert_region = fbcon_invert_region, + .con_screen_pos = fbcon_screen_pos, +@@ -3587,9 +3262,6 @@ static void fbcon_exit(void) + if (fbcon_has_exited) + return; + +- kfree((void *)softback_buf); +- softback_buf = 0UL; +- + for (i = 0; i < FB_MAX; i++) { + int pending = 0; + +diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h +index 7aaa4eabbba05..5ebdccd070eb8 100644 +--- a/drivers/video/console/fbcon.h ++++ b/drivers/video/console/fbcon.h +@@ -62,7 +62,7 @@ struct fbcon_ops { + void (*clear_margins)(struct vc_data *vc, struct fb_info *info, + int bottom_only); + void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode, +- int softback_lines, int fg, int bg); ++ int fg, int bg); + int (*update_start)(struct fb_info *info); + int (*rotate_font)(struct fb_info *info, struct vc_data *vc); + struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */ +diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c +index 34da8bba9273a..5867027520058 100644 +--- a/drivers/video/console/fbcon_ccw.c ++++ b/drivers/video/console/fbcon_ccw.c +@@ -219,7 +219,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, + } + + static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, +- int softback_lines, int fg, int bg) ++ int fg, int bg) + { + struct fb_cursor cursor; + struct fbcon_ops *ops = info->fbcon_par; +@@ -236,15 +236,6 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, + + cursor.set = 0; + +- if (softback_lines) { +- if (y + softback_lines >= vc->vc_rows) { +- mode = CM_ERASE; +- ops->cursor_flash = 0; +- return; +- } else +- y += softback_lines; +- } +- + c = scr_readw((u16 *) vc->vc_pos); + attribute = get_attribute(info, c); + src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.width)); +diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c +index 0b552b3fc22ab..f5a1134049f83 100644 +--- a/drivers/video/console/fbcon_cw.c ++++ b/drivers/video/console/fbcon_cw.c +@@ -202,7 +202,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, + } + + static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, +- int softback_lines, int fg, int bg) ++ int fg, int bg) + { + struct fb_cursor cursor; + struct fbcon_ops *ops = info->fbcon_par; +@@ -219,15 +219,6 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, + + cursor.set = 0; + +- if (softback_lines) { +- if (y + softback_lines >= vc->vc_rows) { +- mode = CM_ERASE; +- ops->cursor_flash = 0; +- return; +- } else +- y += softback_lines; +- } +- + c = scr_readw((u16 *) vc->vc_pos); + attribute = get_attribute(info, c); + src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.width)); +diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c +index 7f62efe2da526..cf8dac9ca2bbf 100644 +--- a/drivers/video/console/fbcon_ud.c ++++ b/drivers/video/console/fbcon_ud.c +@@ -249,7 +249,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, + } + + static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, +- int softback_lines, int fg, int bg) ++ int fg, int bg) + { + struct fb_cursor cursor; + struct fbcon_ops *ops = info->fbcon_par; +@@ -267,15 +267,6 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, + + cursor.set = 0; + +- if (softback_lines) { +- if (y + softback_lines >= vc->vc_rows) { +- mode = CM_ERASE; +- ops->cursor_flash = 0; +- return; +- } else +- y += softback_lines; +- } +- + c = scr_readw((u16 *) vc->vc_pos); + attribute = get_attribute(info, c); + src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.height)); +diff --git a/drivers/video/console/tileblit.c b/drivers/video/console/tileblit.c +index 15e8e1a89c45d..3c0b242dba5f0 100644 +--- a/drivers/video/console/tileblit.c ++++ b/drivers/video/console/tileblit.c +@@ -80,7 +80,7 @@ static void tile_clear_margins(struct vc_data *vc, struct fb_info *info, + } + + static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode, +- int softback_lines, int fg, int bg) ++ int fg, int bg) + { + struct fb_tilecursor cursor; + int use_sw = (vc->vc_cursor_type & 0x10); +diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c +index 283d335a759fe..1acdb41a8a7c3 100644 +--- a/drivers/video/fbdev/vga16fb.c ++++ b/drivers/video/fbdev/vga16fb.c +@@ -1122,7 +1122,7 @@ static void vga_8planes_imageblit(struct fb_info *info, const struct fb_image *i + char oldop = setop(0); + char oldsr = setsr(0); + char oldmask = selectmask(); +- const char *cdat = image->data; ++ const unsigned char *cdat = image->data; + u32 dx = image->dx; + char __iomem *where; + int y; +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c +index 91a45ef69152d..67366515a29d2 100644 +--- a/fs/btrfs/ioctl.c ++++ b/fs/btrfs/ioctl.c +@@ -2129,7 +2129,8 @@ static noinline int search_ioctl(struct inode *inode, + key.offset = sk->min_offset; + + while (1) { +- ret = fault_in_pages_writeable(ubuf, *buf_size - sk_offset); ++ ret = fault_in_pages_writeable(ubuf + sk_offset, ++ *buf_size - sk_offset); + if (ret) + break; + +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index ca1702cefb852..64d15c2662db6 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -6171,7 +6171,12 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, + err = nfs4_set_lock_state(state, fl); + if (err != 0) + return err; +- err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); ++ do { ++ err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); ++ if (err != -NFS4ERR_DELAY) ++ break; ++ ssleep(1); ++ } while (err == -NFS4ERR_DELAY); + return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err); + } + +diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c +index 445a3f2f871fb..da8747b870df3 100644 +--- a/fs/xfs/libxfs/xfs_attr_leaf.c ++++ b/fs/xfs/libxfs/xfs_attr_leaf.c +@@ -514,8 +514,8 @@ xfs_attr_shortform_create(xfs_da_args_t *args) + ASSERT(ifp->if_flags & XFS_IFINLINE); + } + xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); +- hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; +- hdr->count = 0; ++ hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data; ++ memset(hdr, 0, sizeof(*hdr)); + hdr->totsize = cpu_to_be16(sizeof(*hdr)); + xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); + } +diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h +index a3c3ecd59f08c..7a43afd273655 100644 +--- a/include/linux/i2c-algo-pca.h ++++ b/include/linux/i2c-algo-pca.h +@@ -52,6 +52,20 @@ + #define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */ + #define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */ + ++/** ++ * struct pca_i2c_bus_settings - The configured PCA i2c bus settings ++ * @mode: Configured i2c bus mode ++ * @tlow: Configured SCL LOW period ++ * @thi: Configured SCL HIGH period ++ * @clock_freq: The configured clock frequency ++ */ ++struct pca_i2c_bus_settings { ++ int mode; ++ int tlow; ++ int thi; ++ int clock_freq; ++}; ++ + struct i2c_algo_pca_data { + void *data; /* private low level data */ + void (*write_byte) (void *data, int reg, int val); +@@ -63,6 +77,7 @@ struct i2c_algo_pca_data { + * For PCA9665, use the frequency you want here. */ + unsigned int i2c_clock; + unsigned int chip; ++ struct pca_i2c_bus_settings bus_settings; + }; + + int i2c_pca_add_bus(struct i2c_adapter *); +diff --git a/include/linux/usb.h b/include/linux/usb.h +index 55ea5d625cdf3..6ea595997df25 100644 +--- a/include/linux/usb.h ++++ b/include/linux/usb.h +@@ -97,6 +97,41 @@ enum usb_interface_condition { + USB_INTERFACE_UNBINDING, + }; + ++int __must_check ++usb_find_common_endpoints(struct usb_host_interface *alt, ++ struct usb_endpoint_descriptor **bulk_in, ++ struct usb_endpoint_descriptor **bulk_out, ++ struct usb_endpoint_descriptor **int_in, ++ struct usb_endpoint_descriptor **int_out); ++ ++static inline int __must_check ++usb_find_bulk_in_endpoint(struct usb_host_interface *alt, ++ struct usb_endpoint_descriptor **bulk_in) ++{ ++ return usb_find_common_endpoints(alt, bulk_in, NULL, NULL, NULL); ++} ++ ++static inline int __must_check ++usb_find_bulk_out_endpoint(struct usb_host_interface *alt, ++ struct usb_endpoint_descriptor **bulk_out) ++{ ++ return usb_find_common_endpoints(alt, NULL, bulk_out, NULL, NULL); ++} ++ ++static inline int __must_check ++usb_find_int_in_endpoint(struct usb_host_interface *alt, ++ struct usb_endpoint_descriptor **int_in) ++{ ++ return usb_find_common_endpoints(alt, NULL, NULL, int_in, NULL); ++} ++ ++static inline int __must_check ++usb_find_int_out_endpoint(struct usb_host_interface *alt, ++ struct usb_endpoint_descriptor **int_out) ++{ ++ return usb_find_common_endpoints(alt, NULL, NULL, NULL, int_out); ++} ++ + /** + * struct usb_interface - what usb device drivers talk to + * @altsetting: array of interface structures, one for each alternate +diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c +index 46a18e72bce61..6d5ef6220afe7 100644 +--- a/kernel/gcov/gcc_4_7.c ++++ b/kernel/gcov/gcc_4_7.c +@@ -18,7 +18,9 @@ + #include + #include "gcov.h" + +-#if (__GNUC__ >= 7) ++#if (__GNUC__ >= 10) ++#define GCOV_COUNTERS 8 ++#elif (__GNUC__ >= 7) + #define GCOV_COUNTERS 9 + #elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #define GCOV_COUNTERS 10 +diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c +index c89626b2afffb..696381a516341 100644 +--- a/net/sunrpc/rpcb_clnt.c ++++ b/net/sunrpc/rpcb_clnt.c +@@ -977,8 +977,8 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr, + p = xdr_inline_decode(xdr, len); + if (unlikely(p == NULL)) + goto out_fail; +- dprintk("RPC: %5u RPCB_%s reply: %s\n", req->rq_task->tk_pid, +- req->rq_task->tk_msg.rpc_proc->p_name, (char *)p); ++ dprintk("RPC: %5u RPCB_%s reply: %*pE\n", req->rq_task->tk_pid, ++ req->rq_task->tk_msg.rpc_proc->p_name, len, (char *)p); + + if (rpc_uaddr2sockaddr(req->rq_xprt->xprt_net, (char *)p, len, + sap, sizeof(address)) == 0) +diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c +index e361024eabb63..020ec48f39048 100644 +--- a/sound/hda/hdac_device.c ++++ b/sound/hda/hdac_device.c +@@ -123,6 +123,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_init); + void snd_hdac_device_exit(struct hdac_device *codec) + { + pm_runtime_put_noidle(&codec->dev); ++ /* keep balance of runtime PM child_count in parent device */ ++ pm_runtime_set_suspended(&codec->dev); + snd_hdac_bus_remove_device(codec->bus, codec); + kfree(codec->vendor_name); + kfree(codec->chip_name); +diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c +index b776831ceeeac..4ca6d4dc86612 100644 +--- a/tools/perf/tests/pmu.c ++++ b/tools/perf/tests/pmu.c +@@ -169,6 +169,7 @@ int test__pmu(void) + ret = 0; + } while (0); + ++ perf_pmu__del_formats(&formats); + test_format_dir_put(format); + return ret; + } +diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c +index 5245fbd091067..8d99b6d9c36ae 100644 +--- a/tools/perf/util/pmu.c ++++ b/tools/perf/util/pmu.c +@@ -921,6 +921,17 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to) + set_bit(b, bits); + } + ++void perf_pmu__del_formats(struct list_head *formats) ++{ ++ struct perf_pmu_format *fmt, *tmp; ++ ++ list_for_each_entry_safe(fmt, tmp, formats, list) { ++ list_del(&fmt->list); ++ free(fmt->name); ++ free(fmt); ++ } ++} ++ + static int sub_non_neg(int a, int b) + { + if (b > a) +diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h +index 5d7e84466bee5..6789b1efc7d6e 100644 +--- a/tools/perf/util/pmu.h ++++ b/tools/perf/util/pmu.h +@@ -66,6 +66,7 @@ int perf_pmu__new_format(struct list_head *list, char *name, + int config, unsigned long *bits); + void perf_pmu__set_format(unsigned long *bits, long from, long to); + int perf_pmu__format_parse(char *dir, struct list_head *head); ++void perf_pmu__del_formats(struct list_head *formats); + + struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); + diff --git a/patch/kernel/rockpis-legacy/patch-4.4.237-238.patch b/patch/kernel/rockpis-legacy/patch-4.4.237-238.patch new file mode 100644 index 000000000..feef36622 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.237-238.patch @@ -0,0 +1,2701 @@ +diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl +index d7fcdc5a43792..9b55778ab024f 100644 +--- a/Documentation/DocBook/libata.tmpl ++++ b/Documentation/DocBook/libata.tmpl +@@ -324,7 +324,7 @@ Many legacy IDE drivers use ata_bmdma_status() as the bmdma_status() hook. + + High-level taskfile hooks + +-void (*qc_prep) (struct ata_queued_cmd *qc); ++enum ata_completion_errors (*qc_prep) (struct ata_queued_cmd *qc); + int (*qc_issue) (struct ata_queued_cmd *qc); + + +diff --git a/Documentation/devicetree/bindings/sound/wm8994.txt b/Documentation/devicetree/bindings/sound/wm8994.txt +index e045e90a0924b..0f03b8228d080 100644 +--- a/Documentation/devicetree/bindings/sound/wm8994.txt ++++ b/Documentation/devicetree/bindings/sound/wm8994.txt +@@ -14,9 +14,15 @@ Required properties: + - #gpio-cells : Must be 2. The first cell is the pin number and the + second cell is used to specify optional parameters (currently unused). + +- - AVDD2-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply, +- SPKVDD1-supply, SPKVDD2-supply : power supplies for the device, as covered +- in Documentation/devicetree/bindings/regulator/regulator.txt ++ - power supplies for the device, as covered in ++ Documentation/devicetree/bindings/regulator/regulator.txt, depending ++ on compatible: ++ - for wlf,wm1811 and wlf,wm8958: ++ AVDD1-supply, AVDD2-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, ++ DCVDD-supply, CPVDD-supply, SPKVDD1-supply, SPKVDD2-supply ++ - for wlf,wm8994: ++ AVDD1-supply, AVDD2-supply, DBVDD-supply, DCVDD-supply, CPVDD-supply, ++ SPKVDD1-supply, SPKVDD2-supply + + Optional properties: + +@@ -68,11 +74,11 @@ codec: wm8994@1a { + + lineout1-se; + ++ AVDD1-supply = <®ulator>; + AVDD2-supply = <®ulator>; + CPVDD-supply = <®ulator>; +- DBVDD1-supply = <®ulator>; +- DBVDD2-supply = <®ulator>; +- DBVDD3-supply = <®ulator>; ++ DBVDD-supply = <®ulator>; ++ DCVDD-supply = <®ulator>; + SPKVDD1-supply = <®ulator>; + SPKVDD2-supply = <®ulator>; + }; +diff --git a/Makefile b/Makefile +index 003334dad3c3f..209fe98a591cd 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 237 ++SUBLEVEL = 238 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c +index e90fe903613ea..4e5f04d333188 100644 +--- a/arch/m68k/q40/config.c ++++ b/arch/m68k/q40/config.c +@@ -303,6 +303,7 @@ static int q40_get_rtc_pll(struct rtc_pll_info *pll) + { + int tmp = Q40_RTC_CTRL; + ++ pll->pll_ctrl = 0; + pll->pll_value = tmp & Q40_RTC_PLL_MASK; + if (tmp & Q40_RTC_PLL_SIGN) + pll->pll_value = -pll->pll_value; +diff --git a/arch/mips/include/asm/cpu-type.h b/arch/mips/include/asm/cpu-type.h +index abee2bfd10dc1..cea0bbb71590f 100644 +--- a/arch/mips/include/asm/cpu-type.h ++++ b/arch/mips/include/asm/cpu-type.h +@@ -46,6 +46,7 @@ static inline int __pure __get_cpu_type(const int cpu_type) + case CPU_34K: + case CPU_1004K: + case CPU_74K: ++ case CPU_1074K: + case CPU_M14KC: + case CPU_M14KEC: + case CPU_INTERAPTIV: +diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c +index 47692c78d09c5..fdc5e76e1f6b0 100644 +--- a/arch/s390/kernel/setup.c ++++ b/arch/s390/kernel/setup.c +@@ -513,7 +513,7 @@ static struct notifier_block kdump_mem_nb = { + /* + * Make sure that the area behind memory_end is protected + */ +-static void reserve_memory_end(void) ++static void __init reserve_memory_end(void) + { + #ifdef CONFIG_CRASH_DUMP + if (ipl_info.type == IPL_TYPE_FCP_DUMP && +@@ -531,7 +531,7 @@ static void reserve_memory_end(void) + /* + * Make sure that oldmem, where the dump is stored, is protected + */ +-static void reserve_oldmem(void) ++static void __init reserve_oldmem(void) + { + #ifdef CONFIG_CRASH_DUMP + if (OLDMEM_BASE) +@@ -543,7 +543,7 @@ static void reserve_oldmem(void) + /* + * Make sure that oldmem, where the dump is stored, is protected + */ +-static void remove_oldmem(void) ++static void __init remove_oldmem(void) + { + #ifdef CONFIG_CRASH_DUMP + if (OLDMEM_BASE) +diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h +index 664e8505ccd63..2f84887e8934c 100644 +--- a/arch/x86/include/asm/nospec-branch.h ++++ b/arch/x86/include/asm/nospec-branch.h +@@ -275,7 +275,7 @@ DECLARE_STATIC_KEY_FALSE(mds_idle_clear); + * combination with microcode which triggers a CPU buffer flush when the + * instruction is executed. + */ +-static inline void mds_clear_cpu_buffers(void) ++static __always_inline void mds_clear_cpu_buffers(void) + { + static const u16 ds = __KERNEL_DS; + +@@ -296,7 +296,7 @@ static inline void mds_clear_cpu_buffers(void) + * + * Clear CPU buffers if the corresponding static key is enabled + */ +-static inline void mds_user_clear_cpu_buffers(void) ++static __always_inline void mds_user_clear_cpu_buffers(void) + { + if (static_branch_likely(&mds_user_clear)) + mds_clear_cpu_buffers(); +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index 61fc92f92e0a0..ef920da075184 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -4013,10 +4013,13 @@ long kvm_arch_vm_ioctl(struct file *filp, + r = -EFAULT; + if (copy_from_user(&u.ps, argp, sizeof u.ps)) + goto out; ++ mutex_lock(&kvm->lock); + r = -ENXIO; + if (!kvm->arch.vpit) +- goto out; ++ goto set_pit_out; + r = kvm_vm_ioctl_set_pit(kvm, &u.ps); ++set_pit_out: ++ mutex_unlock(&kvm->lock); + break; + } + case KVM_GET_PIT2: { +@@ -4036,10 +4039,13 @@ long kvm_arch_vm_ioctl(struct file *filp, + r = -EFAULT; + if (copy_from_user(&u.ps2, argp, sizeof(u.ps2))) + goto out; ++ mutex_lock(&kvm->lock); + r = -ENXIO; + if (!kvm->arch.vpit) +- goto out; ++ goto set_pit2_out; + r = kvm_vm_ioctl_set_pit2(kvm, &u.ps2); ++set_pit2_out: ++ mutex_unlock(&kvm->lock); + break; + } + case KVM_REINJECT_CONTROL: { +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c +index 43f20328f830e..3096c087b7328 100644 +--- a/drivers/acpi/ec.c ++++ b/drivers/acpi/ec.c +@@ -943,29 +943,21 @@ void acpi_ec_unblock_transactions_early(void) + /* -------------------------------------------------------------------------- + Event Management + -------------------------------------------------------------------------- */ +-static struct acpi_ec_query_handler * +-acpi_ec_get_query_handler(struct acpi_ec_query_handler *handler) +-{ +- if (handler) +- kref_get(&handler->kref); +- return handler; +-} +- + static struct acpi_ec_query_handler * + acpi_ec_get_query_handler_by_value(struct acpi_ec *ec, u8 value) + { + struct acpi_ec_query_handler *handler; +- bool found = false; + + mutex_lock(&ec->mutex); + list_for_each_entry(handler, &ec->list, node) { + if (value == handler->query_bit) { +- found = true; +- break; ++ kref_get(&handler->kref); ++ mutex_unlock(&ec->mutex); ++ return handler; + } + } + mutex_unlock(&ec->mutex); +- return found ? acpi_ec_get_query_handler(handler) : NULL; ++ return NULL; + } + + static void acpi_ec_query_handler_release(struct kref *kref) +diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c +index ed6a30cd681a0..98581ae397c12 100644 +--- a/drivers/ata/acard-ahci.c ++++ b/drivers/ata/acard-ahci.c +@@ -72,7 +72,7 @@ struct acard_sg { + __le32 size; /* bit 31 (EOT) max==0x10000 (64k) */ + }; + +-static void acard_ahci_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors acard_ahci_qc_prep(struct ata_queued_cmd *qc); + static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc); + static int acard_ahci_port_start(struct ata_port *ap); + static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +@@ -257,7 +257,7 @@ static unsigned int acard_ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl) + return si; + } + +-static void acard_ahci_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors acard_ahci_qc_prep(struct ata_queued_cmd *qc) + { + struct ata_port *ap = qc->ap; + struct ahci_port_priv *pp = ap->private_data; +@@ -295,6 +295,8 @@ static void acard_ahci_qc_prep(struct ata_queued_cmd *qc) + opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH; + + ahci_fill_cmd_slot(pp, qc->tag, opts); ++ ++ return AC_ERR_OK; + } + + static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c +index 1241cecfcfcad..48338da2ecdfa 100644 +--- a/drivers/ata/libahci.c ++++ b/drivers/ata/libahci.c +@@ -71,7 +71,7 @@ static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); + static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); + static int ahci_port_start(struct ata_port *ap); + static void ahci_port_stop(struct ata_port *ap); +-static void ahci_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors ahci_qc_prep(struct ata_queued_cmd *qc); + static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc); + static void ahci_freeze(struct ata_port *ap); + static void ahci_thaw(struct ata_port *ap); +@@ -1535,7 +1535,7 @@ static int ahci_pmp_qc_defer(struct ata_queued_cmd *qc) + return sata_pmp_qc_defer_cmd_switch(qc); + } + +-static void ahci_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors ahci_qc_prep(struct ata_queued_cmd *qc) + { + struct ata_port *ap = qc->ap; + struct ahci_port_priv *pp = ap->private_data; +@@ -1571,6 +1571,8 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) + opts |= AHCI_CMD_ATAPI | AHCI_CMD_PREFETCH; + + ahci_fill_cmd_slot(pp, qc->tag, opts); ++ ++ return AC_ERR_OK; + } + + static void ahci_fbs_dec_intr(struct ata_port *ap) +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c +index 17cebfe5acc82..8ed3f6d75ff13 100644 +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -4713,7 +4713,10 @@ int ata_std_qc_defer(struct ata_queued_cmd *qc) + return ATA_DEFER_LINK; + } + +-void ata_noop_qc_prep(struct ata_queued_cmd *qc) { } ++enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc) ++{ ++ return AC_ERR_OK; ++} + + /** + * ata_sg_init - Associate command with scatter-gather table. +@@ -5126,7 +5129,9 @@ void ata_qc_issue(struct ata_queued_cmd *qc) + return; + } + +- ap->ops->qc_prep(qc); ++ qc->err_mask |= ap->ops->qc_prep(qc); ++ if (unlikely(qc->err_mask)) ++ goto err; + trace_ata_qc_issue(qc); + qc->err_mask |= ap->ops->qc_issue(qc); + if (unlikely(qc->err_mask)) +diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c +index 1d8901fc0bfa9..0c69bc1d30c62 100644 +--- a/drivers/ata/libata-sff.c ++++ b/drivers/ata/libata-sff.c +@@ -2741,12 +2741,14 @@ static void ata_bmdma_fill_sg_dumb(struct ata_queued_cmd *qc) + * LOCKING: + * spin_lock_irqsave(host lock) + */ +-void ata_bmdma_qc_prep(struct ata_queued_cmd *qc) ++enum ata_completion_errors ata_bmdma_qc_prep(struct ata_queued_cmd *qc) + { + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + ata_bmdma_fill_sg(qc); ++ ++ return AC_ERR_OK; + } + EXPORT_SYMBOL_GPL(ata_bmdma_qc_prep); + +@@ -2759,12 +2761,14 @@ EXPORT_SYMBOL_GPL(ata_bmdma_qc_prep); + * LOCKING: + * spin_lock_irqsave(host lock) + */ +-void ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc) ++enum ata_completion_errors ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc) + { + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + ata_bmdma_fill_sg_dumb(qc); ++ ++ return AC_ERR_OK; + } + EXPORT_SYMBOL_GPL(ata_bmdma_dumb_qc_prep); + +diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c +index e3d4b059fcd14..f1a20d1a65be0 100644 +--- a/drivers/ata/pata_macio.c ++++ b/drivers/ata/pata_macio.c +@@ -507,7 +507,7 @@ static int pata_macio_cable_detect(struct ata_port *ap) + return ATA_CBL_PATA40; + } + +-static void pata_macio_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors pata_macio_qc_prep(struct ata_queued_cmd *qc) + { + unsigned int write = (qc->tf.flags & ATA_TFLAG_WRITE); + struct ata_port *ap = qc->ap; +@@ -520,7 +520,7 @@ static void pata_macio_qc_prep(struct ata_queued_cmd *qc) + __func__, qc, qc->flags, write, qc->dev->devno); + + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + table = (struct dbdma_cmd *) priv->dma_table_cpu; + +@@ -565,6 +565,8 @@ static void pata_macio_qc_prep(struct ata_queued_cmd *qc) + table->command = cpu_to_le16(DBDMA_STOP); + + dev_dbgdma(priv->dev, "%s: %d DMA list entries\n", __func__, pi); ++ ++ return AC_ERR_OK; + } + + +diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c +index f6c46e9a4dc0f..d7186a503e358 100644 +--- a/drivers/ata/pata_pxa.c ++++ b/drivers/ata/pata_pxa.c +@@ -59,25 +59,27 @@ static void pxa_ata_dma_irq(void *d) + /* + * Prepare taskfile for submission. + */ +-static void pxa_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors pxa_qc_prep(struct ata_queued_cmd *qc) + { + struct pata_pxa_data *pd = qc->ap->private_data; + struct dma_async_tx_descriptor *tx; + enum dma_transfer_direction dir; + + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + dir = (qc->dma_dir == DMA_TO_DEVICE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); + tx = dmaengine_prep_slave_sg(pd->dma_chan, qc->sg, qc->n_elem, dir, + DMA_PREP_INTERRUPT); + if (!tx) { + ata_dev_err(qc->dev, "prep_slave_sg() failed\n"); +- return; ++ return AC_ERR_OK; + } + tx->callback = pxa_ata_dma_irq; + tx->callback_param = pd; + pd->dma_cookie = dmaengine_submit(tx); ++ ++ return AC_ERR_OK; + } + + /* +diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c +index 64d682c6ee57e..11da13bea2c93 100644 +--- a/drivers/ata/pdc_adma.c ++++ b/drivers/ata/pdc_adma.c +@@ -132,7 +132,7 @@ static int adma_ata_init_one(struct pci_dev *pdev, + const struct pci_device_id *ent); + static int adma_port_start(struct ata_port *ap); + static void adma_port_stop(struct ata_port *ap); +-static void adma_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors adma_qc_prep(struct ata_queued_cmd *qc); + static unsigned int adma_qc_issue(struct ata_queued_cmd *qc); + static int adma_check_atapi_dma(struct ata_queued_cmd *qc); + static void adma_freeze(struct ata_port *ap); +@@ -311,7 +311,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc) + return i; + } + +-static void adma_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors adma_qc_prep(struct ata_queued_cmd *qc) + { + struct adma_port_priv *pp = qc->ap->private_data; + u8 *buf = pp->pkt; +@@ -322,7 +322,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc) + + adma_enter_reg_mode(qc->ap); + if (qc->tf.protocol != ATA_PROT_DMA) +- return; ++ return AC_ERR_OK; + + buf[i++] = 0; /* Response flags */ + buf[i++] = 0; /* reserved */ +@@ -387,6 +387,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc) + printk("%s\n", obuf); + } + #endif ++ return AC_ERR_OK; + } + + static inline void adma_packet_start(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c +index a723ae9297831..100b5a3621ef3 100644 +--- a/drivers/ata/sata_fsl.c ++++ b/drivers/ata/sata_fsl.c +@@ -513,7 +513,7 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc, + return num_prde; + } + +-static void sata_fsl_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors sata_fsl_qc_prep(struct ata_queued_cmd *qc) + { + struct ata_port *ap = qc->ap; + struct sata_fsl_port_priv *pp = ap->private_data; +@@ -559,6 +559,8 @@ static void sata_fsl_qc_prep(struct ata_queued_cmd *qc) + + VPRINTK("SATA FSL : xx_qc_prep, di = 0x%x, ttl = %d, num_prde = %d\n", + desc_info, ttl_dwords, num_prde); ++ ++ return AC_ERR_OK; + } + + static unsigned int sata_fsl_qc_issue(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c +index e81a8217f1ff7..349a175f02675 100644 +--- a/drivers/ata/sata_inic162x.c ++++ b/drivers/ata/sata_inic162x.c +@@ -472,7 +472,7 @@ static void inic_fill_sg(struct inic_prd *prd, struct ata_queued_cmd *qc) + prd[-1].flags |= PRD_END; + } + +-static void inic_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors inic_qc_prep(struct ata_queued_cmd *qc) + { + struct inic_port_priv *pp = qc->ap->private_data; + struct inic_pkt *pkt = pp->pkt; +@@ -532,6 +532,8 @@ static void inic_qc_prep(struct ata_queued_cmd *qc) + inic_fill_sg(prd, qc); + + pp->cpb_tbl[0] = pp->pkt_dma; ++ ++ return AC_ERR_OK; + } + + static unsigned int inic_qc_issue(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c +index 729f26322095e..5718dc94c90cb 100644 +--- a/drivers/ata/sata_mv.c ++++ b/drivers/ata/sata_mv.c +@@ -605,8 +605,8 @@ static int mv5_scr_write(struct ata_link *link, unsigned int sc_reg_in, u32 val) + static int mv_port_start(struct ata_port *ap); + static void mv_port_stop(struct ata_port *ap); + static int mv_qc_defer(struct ata_queued_cmd *qc); +-static void mv_qc_prep(struct ata_queued_cmd *qc); +-static void mv_qc_prep_iie(struct ata_queued_cmd *qc); ++static enum ata_completion_errors mv_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors mv_qc_prep_iie(struct ata_queued_cmd *qc); + static unsigned int mv_qc_issue(struct ata_queued_cmd *qc); + static int mv_hardreset(struct ata_link *link, unsigned int *class, + unsigned long deadline); +@@ -2046,7 +2046,7 @@ static void mv_rw_multi_errata_sata24(struct ata_queued_cmd *qc) + * LOCKING: + * Inherited from caller. + */ +-static void mv_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors mv_qc_prep(struct ata_queued_cmd *qc) + { + struct ata_port *ap = qc->ap; + struct mv_port_priv *pp = ap->private_data; +@@ -2058,15 +2058,15 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) + switch (tf->protocol) { + case ATA_PROT_DMA: + if (tf->command == ATA_CMD_DSM) +- return; ++ return AC_ERR_OK; + /* fall-thru */ + case ATA_PROT_NCQ: + break; /* continue below */ + case ATA_PROT_PIO: + mv_rw_multi_errata_sata24(qc); +- return; ++ return AC_ERR_OK; + default: +- return; ++ return AC_ERR_OK; + } + + /* Fill in command request block +@@ -2113,12 +2113,10 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) + * non-NCQ mode are: [RW] STREAM DMA and W DMA FUA EXT, none + * of which are defined/used by Linux. If we get here, this + * driver needs work. +- * +- * FIXME: modify libata to give qc_prep a return value and +- * return error here. + */ +- BUG_ON(tf->command); +- break; ++ ata_port_err(ap, "%s: unsupported command: %.2x\n", __func__, ++ tf->command); ++ return AC_ERR_INVALID; + } + mv_crqb_pack_cmd(cw++, tf->nsect, ATA_REG_NSECT, 0); + mv_crqb_pack_cmd(cw++, tf->hob_lbal, ATA_REG_LBAL, 0); +@@ -2131,8 +2129,10 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) + mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */ + + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + mv_fill_sg(qc); ++ ++ return AC_ERR_OK; + } + + /** +@@ -2147,7 +2147,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) + * LOCKING: + * Inherited from caller. + */ +-static void mv_qc_prep_iie(struct ata_queued_cmd *qc) ++static enum ata_completion_errors mv_qc_prep_iie(struct ata_queued_cmd *qc) + { + struct ata_port *ap = qc->ap; + struct mv_port_priv *pp = ap->private_data; +@@ -2158,9 +2158,9 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc) + + if ((tf->protocol != ATA_PROT_DMA) && + (tf->protocol != ATA_PROT_NCQ)) +- return; ++ return AC_ERR_OK; + if (tf->command == ATA_CMD_DSM) +- return; /* use bmdma for this */ ++ return AC_ERR_OK; /* use bmdma for this */ + + /* Fill in Gen IIE command request block */ + if (!(tf->flags & ATA_TFLAG_WRITE)) +@@ -2201,8 +2201,10 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc) + ); + + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + mv_fill_sg(qc); ++ ++ return AC_ERR_OK; + } + + /** +diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c +index 734f563b8d37b..bb098c4ae1775 100644 +--- a/drivers/ata/sata_nv.c ++++ b/drivers/ata/sata_nv.c +@@ -313,7 +313,7 @@ static void nv_ck804_freeze(struct ata_port *ap); + static void nv_ck804_thaw(struct ata_port *ap); + static int nv_adma_slave_config(struct scsi_device *sdev); + static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); +-static void nv_adma_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors nv_adma_qc_prep(struct ata_queued_cmd *qc); + static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc); + static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance); + static void nv_adma_irq_clear(struct ata_port *ap); +@@ -335,7 +335,7 @@ static void nv_mcp55_freeze(struct ata_port *ap); + static void nv_swncq_error_handler(struct ata_port *ap); + static int nv_swncq_slave_config(struct scsi_device *sdev); + static int nv_swncq_port_start(struct ata_port *ap); +-static void nv_swncq_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors nv_swncq_qc_prep(struct ata_queued_cmd *qc); + static void nv_swncq_fill_sg(struct ata_queued_cmd *qc); + static unsigned int nv_swncq_qc_issue(struct ata_queued_cmd *qc); + static void nv_swncq_irq_clear(struct ata_port *ap, u16 fis); +@@ -1382,7 +1382,7 @@ static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc) + return 1; + } + +-static void nv_adma_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors nv_adma_qc_prep(struct ata_queued_cmd *qc) + { + struct nv_adma_port_priv *pp = qc->ap->private_data; + struct nv_adma_cpb *cpb = &pp->cpb[qc->tag]; +@@ -1394,7 +1394,7 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) + (qc->flags & ATA_QCFLAG_DMAMAP)); + nv_adma_register_mode(qc->ap); + ata_bmdma_qc_prep(qc); +- return; ++ return AC_ERR_OK; + } + + cpb->resp_flags = NV_CPB_RESP_DONE; +@@ -1426,6 +1426,8 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) + cpb->ctl_flags = ctl_flags; + wmb(); + cpb->resp_flags = 0; ++ ++ return AC_ERR_OK; + } + + static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) +@@ -1989,17 +1991,19 @@ static int nv_swncq_port_start(struct ata_port *ap) + return 0; + } + +-static void nv_swncq_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors nv_swncq_qc_prep(struct ata_queued_cmd *qc) + { + if (qc->tf.protocol != ATA_PROT_NCQ) { + ata_bmdma_qc_prep(qc); +- return; ++ return AC_ERR_OK; + } + + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + nv_swncq_fill_sg(qc); ++ ++ return AC_ERR_OK; + } + + static void nv_swncq_fill_sg(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c +index 0fa211e2831cd..8ad8b376a642c 100644 +--- a/drivers/ata/sata_promise.c ++++ b/drivers/ata/sata_promise.c +@@ -155,7 +155,7 @@ static int pdc_sata_scr_write(struct ata_link *link, unsigned int sc_reg, u32 va + static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); + static int pdc_common_port_start(struct ata_port *ap); + static int pdc_sata_port_start(struct ata_port *ap); +-static void pdc_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors pdc_qc_prep(struct ata_queued_cmd *qc); + static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); + static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); + static int pdc_check_atapi_dma(struct ata_queued_cmd *qc); +@@ -649,7 +649,7 @@ static void pdc_fill_sg(struct ata_queued_cmd *qc) + prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); + } + +-static void pdc_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors pdc_qc_prep(struct ata_queued_cmd *qc) + { + struct pdc_port_priv *pp = qc->ap->private_data; + unsigned int i; +@@ -681,6 +681,8 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc) + default: + break; + } ++ ++ return AC_ERR_OK; + } + + static int pdc_is_sataii_tx4(unsigned long flags) +diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c +index af987a4f33d19..80ff3bbfc8269 100644 +--- a/drivers/ata/sata_qstor.c ++++ b/drivers/ata/sata_qstor.c +@@ -116,7 +116,7 @@ static int qs_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); + static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); + static int qs_port_start(struct ata_port *ap); + static void qs_host_stop(struct ata_host *host); +-static void qs_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors qs_qc_prep(struct ata_queued_cmd *qc); + static unsigned int qs_qc_issue(struct ata_queued_cmd *qc); + static int qs_check_atapi_dma(struct ata_queued_cmd *qc); + static void qs_freeze(struct ata_port *ap); +@@ -276,7 +276,7 @@ static unsigned int qs_fill_sg(struct ata_queued_cmd *qc) + return si; + } + +-static void qs_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors qs_qc_prep(struct ata_queued_cmd *qc) + { + struct qs_port_priv *pp = qc->ap->private_data; + u8 dflags = QS_DF_PORD, *buf = pp->pkt; +@@ -288,7 +288,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc) + + qs_enter_reg_mode(qc->ap); + if (qc->tf.protocol != ATA_PROT_DMA) +- return; ++ return AC_ERR_OK; + + nelem = qs_fill_sg(qc); + +@@ -311,6 +311,8 @@ static void qs_qc_prep(struct ata_queued_cmd *qc) + + /* frame information structure (FIS) */ + ata_tf_to_fis(&qc->tf, 0, 1, &buf[32]); ++ ++ return AC_ERR_OK; + } + + static inline void qs_packet_start(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c +index 21b80f5ee0920..4199f7a39be0b 100644 +--- a/drivers/ata/sata_rcar.c ++++ b/drivers/ata/sata_rcar.c +@@ -551,12 +551,14 @@ static void sata_rcar_bmdma_fill_sg(struct ata_queued_cmd *qc) + prd[si - 1].addr |= cpu_to_le32(SATA_RCAR_DTEND); + } + +-static void sata_rcar_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors sata_rcar_qc_prep(struct ata_queued_cmd *qc) + { + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + sata_rcar_bmdma_fill_sg(qc); ++ ++ return AC_ERR_OK; + } + + static void sata_rcar_bmdma_setup(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c +index 29bcff086bced..73156a301912f 100644 +--- a/drivers/ata/sata_sil.c ++++ b/drivers/ata/sata_sil.c +@@ -119,7 +119,7 @@ static void sil_dev_config(struct ata_device *dev); + static int sil_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); + static int sil_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); + static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed); +-static void sil_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors sil_qc_prep(struct ata_queued_cmd *qc); + static void sil_bmdma_setup(struct ata_queued_cmd *qc); + static void sil_bmdma_start(struct ata_queued_cmd *qc); + static void sil_bmdma_stop(struct ata_queued_cmd *qc); +@@ -333,12 +333,14 @@ static void sil_fill_sg(struct ata_queued_cmd *qc) + last_prd->flags_len |= cpu_to_le32(ATA_PRD_EOT); + } + +-static void sil_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors sil_qc_prep(struct ata_queued_cmd *qc) + { + if (!(qc->flags & ATA_QCFLAG_DMAMAP)) +- return; ++ return AC_ERR_OK; + + sil_fill_sg(qc); ++ ++ return AC_ERR_OK; + } + + static unsigned char sil_get_device_cache_line(struct pci_dev *pdev) +diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c +index 4b1995e2d044b..ffa3bf724054d 100644 +--- a/drivers/ata/sata_sil24.c ++++ b/drivers/ata/sata_sil24.c +@@ -336,7 +336,7 @@ static void sil24_dev_config(struct ata_device *dev); + static int sil24_scr_read(struct ata_link *link, unsigned sc_reg, u32 *val); + static int sil24_scr_write(struct ata_link *link, unsigned sc_reg, u32 val); + static int sil24_qc_defer(struct ata_queued_cmd *qc); +-static void sil24_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors sil24_qc_prep(struct ata_queued_cmd *qc); + static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); + static bool sil24_qc_fill_rtf(struct ata_queued_cmd *qc); + static void sil24_pmp_attach(struct ata_port *ap); +@@ -840,7 +840,7 @@ static int sil24_qc_defer(struct ata_queued_cmd *qc) + return ata_std_qc_defer(qc); + } + +-static void sil24_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors sil24_qc_prep(struct ata_queued_cmd *qc) + { + struct ata_port *ap = qc->ap; + struct sil24_port_priv *pp = ap->private_data; +@@ -884,6 +884,8 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) + + if (qc->flags & ATA_QCFLAG_DMAMAP) + sil24_fill_sg(qc, sge); ++ ++ return AC_ERR_OK; + } + + static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc) +diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c +index fab504fd9cfd7..a7cd2c7ee1388 100644 +--- a/drivers/ata/sata_sx4.c ++++ b/drivers/ata/sata_sx4.c +@@ -218,7 +218,7 @@ static void pdc_error_handler(struct ata_port *ap); + static void pdc_freeze(struct ata_port *ap); + static void pdc_thaw(struct ata_port *ap); + static int pdc_port_start(struct ata_port *ap); +-static void pdc20621_qc_prep(struct ata_queued_cmd *qc); ++static enum ata_completion_errors pdc20621_qc_prep(struct ata_queued_cmd *qc); + static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); + static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); + static unsigned int pdc20621_dimm_init(struct ata_host *host); +@@ -546,7 +546,7 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc) + VPRINTK("ata pkt buf ofs %u, mmio copied\n", i); + } + +-static void pdc20621_qc_prep(struct ata_queued_cmd *qc) ++static enum ata_completion_errors pdc20621_qc_prep(struct ata_queued_cmd *qc) + { + switch (qc->tf.protocol) { + case ATA_PROT_DMA: +@@ -558,6 +558,8 @@ static void pdc20621_qc_prep(struct ata_queued_cmd *qc) + default: + break; + } ++ ++ return AC_ERR_OK; + } + + static void __pdc20621_push_hdma(struct ata_queued_cmd *qc, +diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c +index ad591a2f7c822..340a1ee79d280 100644 +--- a/drivers/atm/eni.c ++++ b/drivers/atm/eni.c +@@ -2242,7 +2242,7 @@ static int eni_init_one(struct pci_dev *pci_dev, + + rc = dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32)); + if (rc < 0) +- goto out; ++ goto err_disable; + + rc = -ENOMEM; + eni_dev = kmalloc(sizeof(struct eni_dev), GFP_KERNEL); +diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c +index 100cd1de9939d..59e1e94d12c01 100644 +--- a/drivers/char/tlclk.c ++++ b/drivers/char/tlclk.c +@@ -777,17 +777,21 @@ static int __init tlclk_init(void) + { + int ret; + ++ telclk_interrupt = (inb(TLCLK_REG7) & 0x0f); ++ ++ alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL); ++ if (!alarm_events) { ++ ret = -ENOMEM; ++ goto out1; ++ } ++ + ret = register_chrdev(tlclk_major, "telco_clock", &tlclk_fops); + if (ret < 0) { + printk(KERN_ERR "tlclk: can't get major %d.\n", tlclk_major); ++ kfree(alarm_events); + return ret; + } + tlclk_major = ret; +- alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL); +- if (!alarm_events) { +- ret = -ENOMEM; +- goto out1; +- } + + /* Read telecom clock IRQ number (Set by BIOS) */ + if (!request_region(TLCLK_BASE, 8, "telco_clock")) { +@@ -796,7 +800,6 @@ static int __init tlclk_init(void) + ret = -EBUSY; + goto out2; + } +- telclk_interrupt = (inb(TLCLK_REG7) & 0x0f); + + if (0x0F == telclk_interrupt ) { /* not MCPBL0010 ? */ + printk(KERN_ERR "telclk_interrupt = 0x%x non-mcpbl0010 hw.\n", +@@ -837,8 +840,8 @@ out3: + release_region(TLCLK_BASE, 8); + out2: + kfree(alarm_events); +-out1: + unregister_chrdev(tlclk_major, "telco_clock"); ++out1: + return ret; + } + +diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c +index 3e6a22658b63b..d4cc1a1ac1f73 100644 +--- a/drivers/char/tpm/tpm_ibmvtpm.c ++++ b/drivers/char/tpm/tpm_ibmvtpm.c +@@ -543,6 +543,7 @@ static irqreturn_t ibmvtpm_interrupt(int irq, void *vtpm_instance) + */ + while ((crq = ibmvtpm_crq_get_next(ibmvtpm)) != NULL) { + ibmvtpm_crq_process(crq, ibmvtpm); ++ wake_up_interruptible(&ibmvtpm->crq_queue.wq); + crq->valid = 0; + smp_wmb(); + } +@@ -589,6 +590,7 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, + } + + crq_q->num_entry = CRQ_RES_BUF_SIZE / sizeof(*crq_q->crq_addr); ++ init_waitqueue_head(&crq_q->wq); + ibmvtpm->crq_dma_handle = dma_map_single(dev, crq_q->crq_addr, + CRQ_RES_BUF_SIZE, + DMA_BIDIRECTIONAL); +@@ -641,6 +643,13 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, + if (rc) + goto init_irq_cleanup; + ++ if (!wait_event_timeout(ibmvtpm->crq_queue.wq, ++ ibmvtpm->rtce_buf != NULL, ++ HZ)) { ++ dev_err(dev, "CRQ response timed out\n"); ++ goto init_irq_cleanup; ++ } ++ + return tpm_chip_register(chip); + init_irq_cleanup: + do { +diff --git a/drivers/char/tpm/tpm_ibmvtpm.h b/drivers/char/tpm/tpm_ibmvtpm.h +index 6af92890518f8..1a8c3b698f104 100644 +--- a/drivers/char/tpm/tpm_ibmvtpm.h ++++ b/drivers/char/tpm/tpm_ibmvtpm.h +@@ -31,6 +31,7 @@ struct ibmvtpm_crq_queue { + struct ibmvtpm_crq *crq_addr; + u32 index; + u32 num_entry; ++ wait_queue_head_t wq; + }; + + struct ibmvtpm_dev { +diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c +index 64a2e02b87d78..0b0de6a049afb 100644 +--- a/drivers/devfreq/tegra-devfreq.c ++++ b/drivers/devfreq/tegra-devfreq.c +@@ -79,6 +79,8 @@ + + #define KHZ 1000 + ++#define KHZ_MAX (ULONG_MAX / KHZ) ++ + /* Assume that the bus is saturated if the utilization is 25% */ + #define BUS_SATURATION_RATIO 25 + +@@ -179,7 +181,7 @@ struct tegra_actmon_emc_ratio { + }; + + static struct tegra_actmon_emc_ratio actmon_emc_ratios[] = { +- { 1400000, ULONG_MAX }, ++ { 1400000, KHZ_MAX }, + { 1200000, 750000 }, + { 1100000, 600000 }, + { 1000000, 500000 }, +diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c +index b5cf5d36de2b4..68c460a2b16ea 100644 +--- a/drivers/dma/tegra20-apb-dma.c ++++ b/drivers/dma/tegra20-apb-dma.c +@@ -1207,8 +1207,7 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) + + dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id); + +- if (tdc->busy) +- tegra_dma_terminate_all(dc); ++ tegra_dma_terminate_all(dc); + + spin_lock_irqsave(&tdc->lock, flags); + list_splice_init(&tdc->pending_sg_req, &sg_req_list); +diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c +index 1b50e6c13fb3f..5fbf99d600587 100644 +--- a/drivers/gpu/drm/amd/amdgpu/atom.c ++++ b/drivers/gpu/drm/amd/amdgpu/atom.c +@@ -748,8 +748,8 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg) + cjiffies = jiffies; + if (time_after(cjiffies, ctx->last_jump_jiffies)) { + cjiffies -= ctx->last_jump_jiffies; +- if ((jiffies_to_msecs(cjiffies) > 5000)) { +- DRM_ERROR("atombios stuck in loop for more than 5secs aborting\n"); ++ if ((jiffies_to_msecs(cjiffies) > 10000)) { ++ DRM_ERROR("atombios stuck in loop for more than 10secs aborting\n"); + ctx->abort = true; + } + } else { +diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c b/drivers/gpu/drm/gma500/cdv_intel_display.c +index 7d47b3d5cc0d0..54d554d720004 100644 +--- a/drivers/gpu/drm/gma500/cdv_intel_display.c ++++ b/drivers/gpu/drm/gma500/cdv_intel_display.c +@@ -415,6 +415,8 @@ static bool cdv_intel_find_dp_pll(const struct gma_limit_t *limit, + struct gma_crtc *gma_crtc = to_gma_crtc(crtc); + struct gma_clock_t clock; + ++ memset(&clock, 0, sizeof(clock)); ++ + switch (refclk) { + case 27000: + if (target < 200000) { +diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c +index 3e4d3d5560bf1..6315f77b4a58c 100644 +--- a/drivers/infiniband/core/ucma.c ++++ b/drivers/infiniband/core/ucma.c +@@ -1295,13 +1295,13 @@ static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf, + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + ++ if (unlikely(cmd.optlen > KMALLOC_MAX_SIZE)) ++ return -EINVAL; ++ + ctx = ucma_get_ctx(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + +- if (unlikely(cmd.optlen > KMALLOC_MAX_SIZE)) +- return -EINVAL; +- + optval = memdup_user((void __user *) (unsigned long) cmd.optval, + cmd.optlen); + if (IS_ERR(optval)) { +diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h +index 7fe7df56fa334..f0939fc1cfe55 100644 +--- a/drivers/md/bcache/bcache.h ++++ b/drivers/md/bcache/bcache.h +@@ -547,6 +547,7 @@ struct cache_set { + */ + wait_queue_head_t btree_cache_wait; + struct task_struct *btree_cache_alloc_lock; ++ spinlock_t btree_cannibalize_lock; + + /* + * When we free a btree node, we increment the gen of the bucket the +diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c +index 122d975220945..bdf6071c1b184 100644 +--- a/drivers/md/bcache/btree.c ++++ b/drivers/md/bcache/btree.c +@@ -841,15 +841,17 @@ out: + + static int mca_cannibalize_lock(struct cache_set *c, struct btree_op *op) + { +- struct task_struct *old; +- +- old = cmpxchg(&c->btree_cache_alloc_lock, NULL, current); +- if (old && old != current) { ++ spin_lock(&c->btree_cannibalize_lock); ++ if (likely(c->btree_cache_alloc_lock == NULL)) { ++ c->btree_cache_alloc_lock = current; ++ } else if (c->btree_cache_alloc_lock != current) { + if (op) + prepare_to_wait(&c->btree_cache_wait, &op->wait, + TASK_UNINTERRUPTIBLE); ++ spin_unlock(&c->btree_cannibalize_lock); + return -EINTR; + } ++ spin_unlock(&c->btree_cannibalize_lock); + + return 0; + } +@@ -884,10 +886,12 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct btree_op *op, + */ + static void bch_cannibalize_unlock(struct cache_set *c) + { ++ spin_lock(&c->btree_cannibalize_lock); + if (c->btree_cache_alloc_lock == current) { + c->btree_cache_alloc_lock = NULL; + wake_up(&c->btree_cache_wait); + } ++ spin_unlock(&c->btree_cannibalize_lock); + } + + static struct btree *mca_alloc(struct cache_set *c, struct btree_op *op, +diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c +index f7f8fb079d2a9..d73f9ea776861 100644 +--- a/drivers/md/bcache/super.c ++++ b/drivers/md/bcache/super.c +@@ -1511,6 +1511,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) + sema_init(&c->sb_write_mutex, 1); + mutex_init(&c->bucket_lock); + init_waitqueue_head(&c->btree_cache_wait); ++ spin_lock_init(&c->btree_cannibalize_lock); + init_waitqueue_head(&c->bucket_wait); + init_waitqueue_head(&c->gc_wait); + sema_init(&c->uuid_write_mutex, 1); +diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c +index 119d47596ac81..b81887c4f72a9 100644 +--- a/drivers/media/dvb-frontends/tda10071.c ++++ b/drivers/media/dvb-frontends/tda10071.c +@@ -483,10 +483,11 @@ static int tda10071_read_status(struct dvb_frontend *fe, enum fe_status *status) + goto error; + + if (dev->delivery_system == SYS_DVBS) { +- dev->dvbv3_ber = buf[0] << 24 | buf[1] << 16 | +- buf[2] << 8 | buf[3] << 0; +- dev->post_bit_error += buf[0] << 24 | buf[1] << 16 | +- buf[2] << 8 | buf[3] << 0; ++ u32 bit_error = buf[0] << 24 | buf[1] << 16 | ++ buf[2] << 8 | buf[3] << 0; ++ ++ dev->dvbv3_ber = bit_error; ++ dev->post_bit_error += bit_error; + c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; + c->post_bit_error.stat[0].uvalue = dev->post_bit_error; + dev->block_error += buf[4] << 8 | buf[5] << 0; +diff --git a/drivers/media/usb/go7007/go7007-usb.c b/drivers/media/usb/go7007/go7007-usb.c +index 4857c467e76cd..4490786936a02 100644 +--- a/drivers/media/usb/go7007/go7007-usb.c ++++ b/drivers/media/usb/go7007/go7007-usb.c +@@ -1052,6 +1052,7 @@ static int go7007_usb_probe(struct usb_interface *intf, + struct go7007_usb *usb; + const struct go7007_usb_board *board; + struct usb_device *usbdev = interface_to_usbdev(intf); ++ struct usb_host_endpoint *ep; + unsigned num_i2c_devs; + char *name; + int video_pipe, i, v_urb_len; +@@ -1147,7 +1148,8 @@ static int go7007_usb_probe(struct usb_interface *intf, + if (usb->intr_urb->transfer_buffer == NULL) + goto allocfail; + +- if (go->board_id == GO7007_BOARDID_SENSORAY_2250) ++ ep = usb->usbdev->ep_in[4]; ++ if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK) + usb_fill_bulk_urb(usb->intr_urb, usb->usbdev, + usb_rcvbulkpipe(usb->usbdev, 4), + usb->intr_urb->transfer_buffer, 2*sizeof(u16), +diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c +index 215bb5eeb5acf..c57e375fad6ed 100644 +--- a/drivers/mfd/mfd-core.c ++++ b/drivers/mfd/mfd-core.c +@@ -31,6 +31,11 @@ int mfd_cell_enable(struct platform_device *pdev) + const struct mfd_cell *cell = mfd_get_cell(pdev); + int err = 0; + ++ if (!cell->enable) { ++ dev_dbg(&pdev->dev, "No .enable() call-back registered\n"); ++ return 0; ++ } ++ + /* only call enable hook if the cell wasn't previously enabled */ + if (atomic_inc_return(cell->usage_count) == 1) + err = cell->enable(pdev); +@@ -48,6 +53,11 @@ int mfd_cell_disable(struct platform_device *pdev) + const struct mfd_cell *cell = mfd_get_cell(pdev); + int err = 0; + ++ if (!cell->disable) { ++ dev_dbg(&pdev->dev, "No .disable() call-back registered\n"); ++ return 0; ++ } ++ + /* only disable if no other clients are using it */ + if (atomic_dec_return(cell->usage_count) == 0) + err = cell->disable(pdev); +diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c +index 972935f1b2f7e..3a3da0eeef1fb 100644 +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -724,7 +724,6 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd) + kfree(mtd->eraseregions); + kfree(mtd); + kfree(cfi->cmdset_priv); +- kfree(cfi->cfiq); + return NULL; + } + +diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c +index 08f62987cc37c..ffbc9b304beb2 100644 +--- a/drivers/mtd/cmdlinepart.c ++++ b/drivers/mtd/cmdlinepart.c +@@ -228,12 +228,29 @@ static int mtdpart_setup_real(char *s) + struct cmdline_mtd_partition *this_mtd; + struct mtd_partition *parts; + int mtd_id_len, num_parts; +- char *p, *mtd_id; ++ char *p, *mtd_id, *semicol; ++ ++ /* ++ * Replace the first ';' by a NULL char so strrchr can work ++ * properly. ++ */ ++ semicol = strchr(s, ';'); ++ if (semicol) ++ *semicol = '\0'; + + mtd_id = s; + +- /* fetch */ +- p = strchr(s, ':'); ++ /* ++ * fetch . We use strrchr to ignore all ':' that could ++ * be present in the MTD name, only the last one is interpreted ++ * as an / separator. ++ */ ++ p = strrchr(s, ':'); ++ ++ /* Restore the ';' now. */ ++ if (semicol) ++ *semicol = ';'; ++ + if (!p) { + pr_err("no mtd-id\n"); + return -EINVAL; +diff --git a/drivers/mtd/nand/omap_elm.c b/drivers/mtd/nand/omap_elm.c +index 235ec7992b4cf..e46b11847082a 100644 +--- a/drivers/mtd/nand/omap_elm.c ++++ b/drivers/mtd/nand/omap_elm.c +@@ -421,6 +421,7 @@ static int elm_probe(struct platform_device *pdev) + pm_runtime_enable(&pdev->dev); + if (pm_runtime_get_sync(&pdev->dev) < 0) { + ret = -EINVAL; ++ pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + dev_err(&pdev->dev, "can't enable clock\n"); + return ret; +diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c +index f958188207fd6..e57aca6239f8e 100644 +--- a/drivers/net/ethernet/intel/e1000/e1000_main.c ++++ b/drivers/net/ethernet/intel/e1000/e1000_main.c +@@ -568,8 +568,13 @@ void e1000_reinit_locked(struct e1000_adapter *adapter) + WARN_ON(in_interrupt()); + while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) + msleep(1); +- e1000_down(adapter); +- e1000_up(adapter); ++ ++ /* only run the task if not already down */ ++ if (!test_bit(__E1000_DOWN, &adapter->flags)) { ++ e1000_down(adapter); ++ e1000_up(adapter); ++ } ++ + clear_bit(__E1000_RESETTING, &adapter->flags); + } + +@@ -1456,10 +1461,15 @@ static int e1000_close(struct net_device *netdev) + struct e1000_hw *hw = &adapter->hw; + int count = E1000_CHECK_RESET_COUNT; + +- while (test_bit(__E1000_RESETTING, &adapter->flags) && count--) ++ while (test_and_set_bit(__E1000_RESETTING, &adapter->flags) && count--) + usleep_range(10000, 20000); + +- WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); ++ WARN_ON(count < 0); ++ ++ /* signal that we're down so that the reset task will no longer run */ ++ set_bit(__E1000_DOWN, &adapter->flags); ++ clear_bit(__E1000_RESETTING, &adapter->flags); ++ + e1000_down(adapter); + e1000_power_down_phy(adapter); + e1000_free_irq(adapter); +diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c +index 4842344a96f1d..a2559f213daed 100644 +--- a/drivers/net/wan/hdlc_ppp.c ++++ b/drivers/net/wan/hdlc_ppp.c +@@ -386,11 +386,8 @@ static void ppp_cp_parse_cr(struct net_device *dev, u16 pid, u8 id, + } + + for (opt = data; len; len -= opt[1], opt += opt[1]) { +- if (len < 2 || len < opt[1]) { +- dev->stats.rx_errors++; +- kfree(out); +- return; /* bad packet, drop silently */ +- } ++ if (len < 2 || opt[1] < 2 || len < opt[1]) ++ goto err_out; + + if (pid == PID_LCP) + switch (opt[0]) { +@@ -398,6 +395,8 @@ static void ppp_cp_parse_cr(struct net_device *dev, u16 pid, u8 id, + continue; /* MRU always OK and > 1500 bytes? */ + + case LCP_OPTION_ACCM: /* async control character map */ ++ if (opt[1] < sizeof(valid_accm)) ++ goto err_out; + if (!memcmp(opt, valid_accm, + sizeof(valid_accm))) + continue; +@@ -409,6 +408,8 @@ static void ppp_cp_parse_cr(struct net_device *dev, u16 pid, u8 id, + } + break; + case LCP_OPTION_MAGIC: ++ if (len < 6) ++ goto err_out; + if (opt[1] != 6 || (!opt[2] && !opt[3] && + !opt[4] && !opt[5])) + break; /* reject invalid magic number */ +@@ -427,6 +428,11 @@ static void ppp_cp_parse_cr(struct net_device *dev, u16 pid, u8 id, + ppp_cp_event(dev, pid, RCR_GOOD, CP_CONF_ACK, id, req_len, data); + + kfree(out); ++ return; ++ ++err_out: ++ dev->stats.rx_errors++; ++ kfree(out); + } + + static int ppp_rx(struct sk_buff *skb) +diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c +index 5bf22057459e6..bc6330b437958 100644 +--- a/drivers/net/wireless/ath/ar5523/ar5523.c ++++ b/drivers/net/wireless/ath/ar5523/ar5523.c +@@ -1774,6 +1774,8 @@ static struct usb_device_id ar5523_id_table[] = { + AR5523_DEVICE_UX(0x0846, 0x4300), /* Netgear / WG111U */ + AR5523_DEVICE_UG(0x0846, 0x4250), /* Netgear / WG111T */ + AR5523_DEVICE_UG(0x0846, 0x5f00), /* Netgear / WPN111 */ ++ AR5523_DEVICE_UG(0x083a, 0x4506), /* SMC / EZ Connect ++ SMCWUSBT-G2 */ + AR5523_DEVICE_UG(0x157e, 0x3006), /* Umedia / AR5523_1 */ + AR5523_DEVICE_UX(0x157e, 0x3205), /* Umedia / AR5523_2 */ + AR5523_DEVICE_UG(0x157e, 0x3006), /* Umedia / TEW444UBEU */ +diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h +index 9a5eb9ed89215..233af2292366d 100644 +--- a/drivers/net/wireless/mwifiex/fw.h ++++ b/drivers/net/wireless/mwifiex/fw.h +@@ -848,7 +848,7 @@ struct mwifiex_tkip_param { + struct mwifiex_aes_param { + u8 pn[WPA_PN_SIZE]; + __le16 key_len; +- u8 key[WLAN_KEY_LEN_CCMP]; ++ u8 key[WLAN_KEY_LEN_CCMP_256]; + } __packed; + + struct mwifiex_wapi_param { +diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c +index 9e3853c8a22da..32b0b06b74f1d 100644 +--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c ++++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c +@@ -631,7 +631,7 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv, + key_v2 = &resp->params.key_material_v2; + + len = le16_to_cpu(key_v2->key_param_set.key_params.aes.key_len); +- if (len > WLAN_KEY_LEN_CCMP) ++ if (len > sizeof(key_v2->key_param_set.key_params.aes.key)) + return -EINVAL; + + if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) { +@@ -647,7 +647,7 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv, + return 0; + + memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0, +- WLAN_KEY_LEN_CCMP); ++ sizeof(key_v2->key_param_set.key_params.aes.key)); + priv->aes_key_v2.key_param_set.key_params.aes.key_len = + cpu_to_le16(len); + memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key, +diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c +index 004d320767e4d..bb36cfd4e3e90 100644 +--- a/drivers/phy/phy-s5pv210-usb2.c ++++ b/drivers/phy/phy-s5pv210-usb2.c +@@ -142,6 +142,10 @@ static void s5pv210_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) + udelay(10); + rst &= ~rstbits; + writel(rst, drv->reg_phy + S5PV210_UPHYRST); ++ /* The following delay is necessary for the reset sequence to be ++ * completed ++ */ ++ udelay(80); + } else { + pwr = readl(drv->reg_phy + S5PV210_UPHYPWR); + pwr |= phypwr; +diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c +index de33801ca31ea..0614d05a990a6 100644 +--- a/drivers/scsi/aacraid/aachba.c ++++ b/drivers/scsi/aacraid/aachba.c +@@ -1938,13 +1938,13 @@ static int aac_read(struct scsi_cmnd * scsicmd) + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | + SAM_STAT_CHECK_CONDITION; + set_sense(&dev->fsa_dev[cid].sense_data, +- HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, ++ ILLEGAL_REQUEST, SENCODE_LBA_OUT_OF_RANGE, + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); + memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, + min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), + SCSI_SENSE_BUFFERSIZE)); + scsicmd->scsi_done(scsicmd); +- return 1; ++ return 0; + } + + dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n", +@@ -2035,13 +2035,13 @@ static int aac_write(struct scsi_cmnd * scsicmd) + scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | + SAM_STAT_CHECK_CONDITION; + set_sense(&dev->fsa_dev[cid].sense_data, +- HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, ++ ILLEGAL_REQUEST, SENCODE_LBA_OUT_OF_RANGE, + ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0); + memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, + min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data), + SCSI_SENSE_BUFFERSIZE)); + scsicmd->scsi_done(scsicmd); +- return 1; ++ return 0; + } + + dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n", +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c +index 7a94c2d352390..97c0d79a2601f 100644 +--- a/drivers/scsi/lpfc/lpfc_sli.c ++++ b/drivers/scsi/lpfc/lpfc_sli.c +@@ -15445,6 +15445,10 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) + list_add_tail(&iocbq->list, &first_iocbq->list); + } + } ++ /* Free the sequence's header buffer */ ++ if (!first_iocbq) ++ lpfc_in_buf_free(vport->phba, &seq_dmabuf->dbuf); ++ + return first_iocbq; + } + +diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c +index e9ea9005a984e..f24fa99da69f5 100644 +--- a/drivers/tty/serial/8250/8250_core.c ++++ b/drivers/tty/serial/8250/8250_core.c +@@ -1037,8 +1037,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up) + + ret = uart_add_one_port(&serial8250_reg, + &uart->port); +- if (ret == 0) +- ret = uart->port.line; ++ if (ret) ++ goto err; ++ ++ ret = uart->port.line; + } else { + dev_info(uart->port.dev, + "skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n", +@@ -1052,6 +1054,11 @@ int serial8250_register_8250_port(struct uart_8250_port *up) + mutex_unlock(&serial_mutex); + + return ret; ++ ++err: ++ uart->port.dev = NULL; ++ mutex_unlock(&serial_mutex); ++ return ret; + } + EXPORT_SYMBOL(serial8250_register_8250_port); + +diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c +index c4383573cf668..0377b35d62b80 100644 +--- a/drivers/tty/serial/8250/8250_omap.c ++++ b/drivers/tty/serial/8250/8250_omap.c +@@ -1188,11 +1188,11 @@ static int omap8250_probe(struct platform_device *pdev) + spin_lock_init(&priv->rx_dma_lock); + + device_init_wakeup(&pdev->dev, true); ++ pm_runtime_enable(&pdev->dev); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, -1); + + pm_runtime_irq_safe(&pdev->dev); +- pm_runtime_enable(&pdev->dev); + + pm_runtime_get_sync(&pdev->dev); + +diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c +index 70a51d0bc6044..42aa37515e9bd 100644 +--- a/drivers/tty/serial/samsung.c ++++ b/drivers/tty/serial/samsung.c +@@ -1151,14 +1151,14 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, + struct s3c24xx_uart_info *info = ourport->info; + struct clk *clk; + unsigned long rate; +- unsigned int cnt, baud, quot, clk_sel, best_quot = 0; ++ unsigned int cnt, baud, quot, best_quot = 0; + char clkname[MAX_CLK_NAME_LENGTH]; + int calc_deviation, deviation = (1 << 30) - 1; + +- clk_sel = (ourport->cfg->clk_sel) ? ourport->cfg->clk_sel : +- ourport->info->def_clk_sel; + for (cnt = 0; cnt < info->num_clks; cnt++) { +- if (!(clk_sel & (1 << cnt))) ++ /* Keep selected clock if provided */ ++ if (ourport->cfg->clk_sel && ++ !(ourport->cfg->clk_sel & (1 << cnt))) + continue; + + sprintf(clkname, "clk_uart_baud%d", cnt); +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c +index 0e4f54832fc79..01aeffcdf9849 100644 +--- a/drivers/tty/vt/vt.c ++++ b/drivers/tty/vt/vt.c +@@ -2484,7 +2484,7 @@ static void console_callback(struct work_struct *ignored) + if (scrollback_delta) { + struct vc_data *vc = vc_cons[fg_console].d; + clear_selection(); +- if (vc->vc_mode == KD_TEXT) ++ if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) + vc->vc_sw->con_scrolldelta(vc, scrollback_delta); + scrollback_delta = 0; + } +diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c +index 849806a75f1ce..b29610899c9f6 100644 +--- a/drivers/usb/host/ehci-mv.c ++++ b/drivers/usb/host/ehci-mv.c +@@ -196,12 +196,10 @@ static int mv_ehci_probe(struct platform_device *pdev) + hcd->rsrc_len = resource_size(r); + hcd->regs = ehci_mv->op_regs; + +- hcd->irq = platform_get_irq(pdev, 0); +- if (!hcd->irq) { +- dev_err(&pdev->dev, "Cannot get irq."); +- retval = -ENODEV; ++ retval = platform_get_irq(pdev, 0); ++ if (retval < 0) + goto err_disable_clk; +- } ++ hcd->irq = retval; + + ehci = hcd_to_ehci(hcd); + ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs; +diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c +index 7a82735d53087..8276ef7f3e834 100644 +--- a/drivers/vfio/pci/vfio_pci.c ++++ b/drivers/vfio/pci/vfio_pci.c +@@ -255,6 +255,19 @@ static void vfio_pci_release(void *device_data) + if (!(--vdev->refcnt)) { + vfio_spapr_pci_eeh_release(vdev->pdev); + vfio_pci_disable(vdev); ++ mutex_lock(&vdev->igate); ++ if (vdev->err_trigger) { ++ eventfd_ctx_put(vdev->err_trigger); ++ vdev->err_trigger = NULL; ++ } ++ mutex_unlock(&vdev->igate); ++ ++ mutex_lock(&vdev->igate); ++ if (vdev->req_trigger) { ++ eventfd_ctx_put(vdev->req_trigger); ++ vdev->req_trigger = NULL; ++ } ++ mutex_unlock(&vdev->igate); + } + + mutex_unlock(&driver_lock); +diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c +index 8b6f6d5fdd68b..43186fa8a13c9 100644 +--- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c ++++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c +@@ -194,7 +194,7 @@ static int __init omapdss_boot_init(void) + dss = of_find_matching_node(NULL, omapdss_of_match); + + if (dss == NULL || !of_device_is_available(dss)) +- return 0; ++ goto put_node; + + omapdss_walk_device(dss, true); + +@@ -221,6 +221,8 @@ static int __init omapdss_boot_init(void) + kfree(n); + } + ++put_node: ++ of_node_put(dss); + return 0; + } + +diff --git a/fs/block_dev.c b/fs/block_dev.c +index b2ebfd96785b7..a71d442ef7d0e 100644 +--- a/fs/block_dev.c ++++ b/fs/block_dev.c +@@ -1515,6 +1515,16 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) + struct gendisk *disk = bdev->bd_disk; + struct block_device *victim = NULL; + ++ /* ++ * Sync early if it looks like we're the last one. If someone else ++ * opens the block device between now and the decrement of bd_openers ++ * then we did a sync that we didn't need to, but that's not the end ++ * of the world and we want to avoid long (could be several minute) ++ * syncs while holding the mutex. ++ */ ++ if (bdev->bd_openers == 1) ++ sync_blockdev(bdev); ++ + mutex_lock_nested(&bdev->bd_mutex, for_part); + if (for_part) + bdev->bd_part_count--; +diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c +index 3d0497421e62b..49e693232916f 100644 +--- a/fs/ceph/caps.c ++++ b/fs/ceph/caps.c +@@ -1777,12 +1777,24 @@ ack: + if (mutex_trylock(&session->s_mutex) == 0) { + dout("inverting session/ino locks on %p\n", + session); ++ session = ceph_get_mds_session(session); + spin_unlock(&ci->i_ceph_lock); + if (took_snap_rwsem) { + up_read(&mdsc->snap_rwsem); + took_snap_rwsem = 0; + } +- mutex_lock(&session->s_mutex); ++ if (session) { ++ mutex_lock(&session->s_mutex); ++ ceph_put_mds_session(session); ++ } else { ++ /* ++ * Because we take the reference while ++ * holding the i_ceph_lock, it should ++ * never be NULL. Throw a warning if it ++ * ever is. ++ */ ++ WARN_ON_ONCE(true); ++ } + goto retry; + } + } +diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c +index 8142f6bf3d310..fc265f4b839ae 100644 +--- a/fs/fuse/dev.c ++++ b/fs/fuse/dev.c +@@ -850,7 +850,6 @@ static int fuse_check_page(struct page *page) + { + if (page_mapcount(page) || + page->mapping != NULL || +- page_count(page) != 1 || + (page->flags & PAGE_FLAGS_CHECK_AT_PREP & + ~(1 << PG_locked | + 1 << PG_referenced | +diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c +index 97be412153328..9213a9e046ae0 100644 +--- a/fs/ubifs/io.c ++++ b/fs/ubifs/io.c +@@ -237,7 +237,7 @@ int ubifs_is_mapped(const struct ubifs_info *c, int lnum) + int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, + int offs, int quiet, int must_chk_crc) + { +- int err = -EINVAL, type, node_len; ++ int err = -EINVAL, type, node_len, dump_node = 1; + uint32_t crc, node_crc, magic; + const struct ubifs_ch *ch = buf; + +@@ -290,10 +290,22 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, + out_len: + if (!quiet) + ubifs_err(c, "bad node length %d", node_len); ++ if (type == UBIFS_DATA_NODE && node_len > UBIFS_DATA_NODE_SZ) ++ dump_node = 0; + out: + if (!quiet) { + ubifs_err(c, "bad node at LEB %d:%d", lnum, offs); +- ubifs_dump_node(c, buf); ++ if (dump_node) { ++ ubifs_dump_node(c, buf); ++ } else { ++ int safe_len = min3(node_len, c->leb_size - offs, ++ (int)UBIFS_MAX_DATA_NODE_SZ); ++ pr_err("\tprevent out-of-bounds memory access\n"); ++ pr_err("\ttruncated data node length %d\n", safe_len); ++ pr_err("\tcorrupted data node:\n"); ++ print_hex_dump(KERN_ERR, "\t", DUMP_PREFIX_OFFSET, 32, 1, ++ buf, safe_len, 0); ++ } + dump_stack(); + } + return err; +diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c +index da8747b870df3..4539ff4d351f9 100644 +--- a/fs/xfs/libxfs/xfs_attr_leaf.c ++++ b/fs/xfs/libxfs/xfs_attr_leaf.c +@@ -1326,7 +1326,9 @@ xfs_attr3_leaf_add_work( + for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) { + if (ichdr->freemap[i].base == tmp) { + ichdr->freemap[i].base += sizeof(xfs_attr_leaf_entry_t); +- ichdr->freemap[i].size -= sizeof(xfs_attr_leaf_entry_t); ++ ichdr->freemap[i].size -= ++ min_t(uint16_t, ichdr->freemap[i].size, ++ sizeof(xfs_attr_leaf_entry_t)); + } + } + ichdr->usedbytes += xfs_attr_leaf_entsize(leaf, args->index); +diff --git a/include/linux/libata.h b/include/linux/libata.h +index af561d33221d6..ec49344f7555d 100644 +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -500,6 +500,7 @@ enum hsm_task_states { + }; + + enum ata_completion_errors { ++ AC_ERR_OK = 0, /* no error */ + AC_ERR_DEV = (1 << 0), /* device reported error */ + AC_ERR_HSM = (1 << 1), /* host state machine violation */ + AC_ERR_TIMEOUT = (1 << 2), /* timeout */ +@@ -896,9 +897,9 @@ struct ata_port_operations { + /* + * Command execution + */ +- int (*qc_defer)(struct ata_queued_cmd *qc); +- int (*check_atapi_dma)(struct ata_queued_cmd *qc); +- void (*qc_prep)(struct ata_queued_cmd *qc); ++ int (*qc_defer)(struct ata_queued_cmd *qc); ++ int (*check_atapi_dma)(struct ata_queued_cmd *qc); ++ enum ata_completion_errors (*qc_prep)(struct ata_queued_cmd *qc); + unsigned int (*qc_issue)(struct ata_queued_cmd *qc); + bool (*qc_fill_rtf)(struct ata_queued_cmd *qc); + +@@ -1190,7 +1191,7 @@ extern int ata_xfer_mode2shift(unsigned long xfer_mode); + extern const char *ata_mode_string(unsigned long xfer_mask); + extern unsigned long ata_id_xfermask(const u16 *id); + extern int ata_std_qc_defer(struct ata_queued_cmd *qc); +-extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); ++extern enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc); + extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, + unsigned int n_elem); + extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); +@@ -1881,9 +1882,9 @@ extern const struct ata_port_operations ata_bmdma_port_ops; + .sg_tablesize = LIBATA_MAX_PRD, \ + .dma_boundary = ATA_DMA_BOUNDARY + +-extern void ata_bmdma_qc_prep(struct ata_queued_cmd *qc); ++extern enum ata_completion_errors ata_bmdma_qc_prep(struct ata_queued_cmd *qc); + extern unsigned int ata_bmdma_qc_issue(struct ata_queued_cmd *qc); +-extern void ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc); ++extern enum ata_completion_errors ata_bmdma_dumb_qc_prep(struct ata_queued_cmd *qc); + extern unsigned int ata_bmdma_port_intr(struct ata_port *ap, + struct ata_queued_cmd *qc); + extern irqreturn_t ata_bmdma_interrupt(int irq, void *dev_instance); +diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h +index 676d3d2a1a0a9..d8bae7cb86f39 100644 +--- a/include/linux/mtd/map.h ++++ b/include/linux/mtd/map.h +@@ -307,7 +307,7 @@ void map_destroy(struct mtd_info *mtd); + ({ \ + int i, ret = 1; \ + for (i = 0; i < map_words(map); i++) { \ +- if (((val1).x[i] & (val2).x[i]) != (val2).x[i]) { \ ++ if (((val1).x[i] & (val2).x[i]) != (val3).x[i]) { \ + ret = 0; \ + break; \ + } \ +diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h +index e0582106ef4fa..a10f363784178 100644 +--- a/include/linux/seqlock.h ++++ b/include/linux/seqlock.h +@@ -242,6 +242,13 @@ static inline void raw_write_seqcount_end(seqcount_t *s) + * usual consistency guarantee. It is one wmb cheaper, because we can + * collapse the two back-to-back wmb()s. + * ++ * Note that, writes surrounding the barrier should be declared atomic (e.g. ++ * via WRITE_ONCE): a) to ensure the writes become visible to other threads ++ * atomically, avoiding compiler optimizations; b) to document which writes are ++ * meant to propagate to the reader critical section. This is necessary because ++ * neither writes before and after the barrier are enclosed in a seq-writer ++ * critical section that would ensure readers are aware of ongoing writes. ++ * + * seqcount_t seq; + * bool X = true, Y = false; + * +@@ -261,11 +268,11 @@ static inline void raw_write_seqcount_end(seqcount_t *s) + * + * void write(void) + * { +- * Y = true; ++ * WRITE_ONCE(Y, true); + * + * raw_write_seqcount_barrier(seq); + * +- * X = false; ++ * WRITE_ONCE(X, false); + * } + */ + static inline void raw_write_seqcount_barrier(seqcount_t *s) +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h +index 735ff1525f485..95feb153fe9a8 100644 +--- a/include/linux/skbuff.h ++++ b/include/linux/skbuff.h +@@ -1438,6 +1438,18 @@ static inline __u32 skb_queue_len(const struct sk_buff_head *list_) + return list_->qlen; + } + ++/** ++ * skb_queue_len_lockless - get queue length ++ * @list_: list to measure ++ * ++ * Return the length of an &sk_buff queue. ++ * This variant can be used in lockless contexts. ++ */ ++static inline __u32 skb_queue_len_lockless(const struct sk_buff_head *list_) ++{ ++ return READ_ONCE(list_->qlen); ++} ++ + /** + * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head + * @list: queue to initialize +@@ -1641,7 +1653,7 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list) + { + struct sk_buff *next, *prev; + +- list->qlen--; ++ WRITE_ONCE(list->qlen, list->qlen - 1); + next = skb->next; + prev = skb->prev; + skb->next = skb->prev = NULL; +@@ -2651,7 +2663,7 @@ static inline int skb_padto(struct sk_buff *skb, unsigned int len) + * is untouched. Otherwise it is extended. Returns zero on + * success. The skb is freed on error. + */ +-static inline int skb_put_padto(struct sk_buff *skb, unsigned int len) ++static inline int __must_check skb_put_padto(struct sk_buff *skb, unsigned int len) + { + unsigned int size = skb->len; + +diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c +index f45a9a5d3e47a..af453f3c2b3dd 100644 +--- a/kernel/audit_watch.c ++++ b/kernel/audit_watch.c +@@ -316,8 +316,6 @@ static void audit_update_watch(struct audit_parent *parent, + if (oentry->rule.exe) + audit_remove_mark(oentry->rule.exe); + +- audit_watch_log_rule_change(r, owatch, "updated_rules"); +- + call_rcu(&oentry->rcu, audit_free_rule_rcu); + } + +diff --git a/kernel/kprobes.c b/kernel/kprobes.c +index 9241a29a1f9de..33c37dbc56a05 100644 +--- a/kernel/kprobes.c ++++ b/kernel/kprobes.c +@@ -2012,6 +2012,9 @@ static void kill_kprobe(struct kprobe *p) + { + struct kprobe *kp; + ++ if (WARN_ON_ONCE(kprobe_gone(p))) ++ return; ++ + p->flags |= KPROBE_FLAG_GONE; + if (kprobe_aggrprobe(p)) { + /* +@@ -2032,9 +2035,10 @@ static void kill_kprobe(struct kprobe *p) + + /* + * The module is going away. We should disarm the kprobe which +- * is using ftrace. ++ * is using ftrace, because ftrace framework is still available at ++ * MODULE_STATE_GOING notification. + */ +- if (kprobe_ftrace(p)) ++ if (kprobe_ftrace(p) && !kprobe_disabled(p) && !kprobes_all_disarmed) + disarm_kprobe_ftrace(p); + } + +@@ -2154,7 +2158,10 @@ static int kprobes_module_callback(struct notifier_block *nb, + mutex_lock(&kprobe_mutex); + for (i = 0; i < KPROBE_TABLE_SIZE; i++) { + head = &kprobe_table[i]; +- hlist_for_each_entry_rcu(p, head, hlist) ++ hlist_for_each_entry_rcu(p, head, hlist) { ++ if (kprobe_gone(p)) ++ continue; ++ + if (within_module_init((unsigned long)p->addr, mod) || + (checkcore && + within_module_core((unsigned long)p->addr, mod))) { +@@ -2165,6 +2172,7 @@ static int kprobes_module_callback(struct notifier_block *nb, + */ + kill_kprobe(p); + } ++ } + } + mutex_unlock(&kprobe_mutex); + return NOTIFY_DONE; +diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c +index e53a976ca28ea..b55dfb3e801f9 100644 +--- a/kernel/printk/printk.c ++++ b/kernel/printk/printk.c +@@ -2032,6 +2032,9 @@ static int __init console_setup(char *str) + char *s, *options, *brl_options = NULL; + int idx; + ++ if (str[0] == 0) ++ return 1; ++ + if (_braille_console_setup(&str, &brl_options)) + return 1; + +diff --git a/kernel/sys.c b/kernel/sys.c +index 1855f1bf113e4..e98664039cb23 100644 +--- a/kernel/sys.c ++++ b/kernel/sys.c +@@ -1183,11 +1183,13 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) + + SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) + { +- struct oldold_utsname tmp = {}; ++ struct oldold_utsname tmp; + + if (!name) + return -EFAULT; + ++ memset(&tmp, 0, sizeof(tmp)); ++ + down_read(&uts_sem); + memcpy(&tmp.sysname, &utsname()->sysname, __OLD_UTS_LEN); + memcpy(&tmp.nodename, &utsname()->nodename, __OLD_UTS_LEN); +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c +index e4c6f89b6b11f..89ed01911a9a2 100644 +--- a/kernel/trace/ftrace.c ++++ b/kernel/trace/ftrace.c +@@ -2823,8 +2823,11 @@ static int referenced_filters(struct dyn_ftrace *rec) + int cnt = 0; + + for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) { +- if (ops_references_rec(ops, rec)) +- cnt++; ++ if (ops_references_rec(ops, rec)) { ++ cnt++; ++ if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) ++ rec->flags |= FTRACE_FL_REGS; ++ } + } + + return cnt; +@@ -2874,7 +2877,7 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs) + p = &pg->records[i]; + if (test) + cnt += referenced_filters(p); +- p->flags = cnt; ++ p->flags += cnt; + + /* + * Do the initial record conversion from mcount jump +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index 06efd18bf3e38..e4a0c0308b507 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -2271,6 +2271,9 @@ int trace_array_printk(struct trace_array *tr, + if (!(global_trace.trace_flags & TRACE_ITER_PRINTK)) + return 0; + ++ if (!tr) ++ return -ENOENT; ++ + va_start(ap, fmt); + ret = trace_array_vprintk(tr, ip, fmt, ap); + va_end(ap); +@@ -7260,7 +7263,7 @@ __init static int tracer_alloc_buffers(void) + goto out_free_buffer_mask; + + /* Only allocate trace_printk buffers if a trace_printk exists */ +- if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) ++ if (&__stop___trace_bprintk_fmt != &__start___trace_bprintk_fmt) + /* Must be called before global_trace.buffer is allocated */ + trace_printk_init_buffers(); + +diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h +index ee7b94a4810af..246db27dbdc99 100644 +--- a/kernel/trace/trace_entries.h ++++ b/kernel/trace/trace_entries.h +@@ -178,7 +178,7 @@ FTRACE_ENTRY(kernel_stack, stack_entry, + + F_STRUCT( + __field( int, size ) +- __dynamic_array(unsigned long, caller ) ++ __array( unsigned long, caller, FTRACE_STACK_ENTRIES ) + ), + + F_printk("\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n\t=> (" IP_FMT ")\n" +diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c +index bd4c0bb61ad72..9d6e755d17546 100644 +--- a/kernel/trace/trace_events.c ++++ b/kernel/trace/trace_events.c +@@ -755,6 +755,8 @@ static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set) + char *event = NULL, *sub = NULL, *match; + int ret; + ++ if (!tr) ++ return -ENOENT; + /* + * The buf format can be : + * *: means any event by that name. +diff --git a/lib/string.c b/lib/string.c +index c7cf65ac42ad7..c9983dc01e727 100644 +--- a/lib/string.c ++++ b/lib/string.c +@@ -235,6 +235,30 @@ ssize_t strscpy(char *dest, const char *src, size_t count) + EXPORT_SYMBOL(strscpy); + #endif + ++/** ++ * stpcpy - copy a string from src to dest returning a pointer to the new end ++ * of dest, including src's %NUL-terminator. May overrun dest. ++ * @dest: pointer to end of string being copied into. Must be large enough ++ * to receive copy. ++ * @src: pointer to the beginning of string being copied from. Must not overlap ++ * dest. ++ * ++ * stpcpy differs from strcpy in a key way: the return value is a pointer ++ * to the new %NUL-terminating character in @dest. (For strcpy, the return ++ * value is a pointer to the start of @dest). This interface is considered ++ * unsafe as it doesn't perform bounds checking of the inputs. As such it's ++ * not recommended for usage. Instead, its definition is provided in case ++ * the compiler lowers other libcalls to stpcpy. ++ */ ++char *stpcpy(char *__restrict__ dest, const char *__restrict__ src); ++char *stpcpy(char *__restrict__ dest, const char *__restrict__ src) ++{ ++ while ((*dest++ = *src++) != '\0') ++ /* nothing */; ++ return --dest; ++} ++EXPORT_SYMBOL(stpcpy); ++ + #ifndef __HAVE_ARCH_STRCAT + /** + * strcat - Append one %NUL-terminated string to another +diff --git a/mm/filemap.c b/mm/filemap.c +index f217120973ebe..3d0a0e409cbf5 100644 +--- a/mm/filemap.c ++++ b/mm/filemap.c +@@ -2313,6 +2313,14 @@ filler: + unlock_page(page); + goto out; + } ++ ++ /* ++ * A previous I/O error may have been due to temporary ++ * failures. ++ * Clear page error before actual read, PG_error will be ++ * set again if read page fails. ++ */ ++ ClearPageError(page); + goto filler; + + out: +diff --git a/mm/mmap.c b/mm/mmap.c +index 135cccce41f88..d48a654cbd237 100644 +--- a/mm/mmap.c ++++ b/mm/mmap.c +@@ -1993,6 +1993,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, + info.low_limit = mm->mmap_base; + info.high_limit = TASK_SIZE; + info.align_mask = 0; ++ info.align_offset = 0; + return vm_unmapped_area(&info); + } + #endif +@@ -2034,6 +2035,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, + info.low_limit = max(PAGE_SIZE, mmap_min_addr); + info.high_limit = mm->mmap_base; + info.align_mask = 0; ++ info.align_offset = 0; + addr = vm_unmapped_area(&info); + + /* +diff --git a/mm/pagewalk.c b/mm/pagewalk.c +index c2cbd26201696..a024667a9c041 100644 +--- a/mm/pagewalk.c ++++ b/mm/pagewalk.c +@@ -14,9 +14,9 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, + err = walk->pte_entry(pte, addr, addr + PAGE_SIZE, walk); + if (err) + break; +- addr += PAGE_SIZE; +- if (addr == end) ++ if (addr >= end - PAGE_SIZE) + break; ++ addr += PAGE_SIZE; + pte++; + } + +diff --git a/net/atm/lec.c b/net/atm/lec.c +index e4afac94ff158..a38680e194436 100644 +--- a/net/atm/lec.c ++++ b/net/atm/lec.c +@@ -1290,6 +1290,12 @@ static void lec_arp_clear_vccs(struct lec_arp_table *entry) + entry->vcc = NULL; + } + if (entry->recv_vcc) { ++ struct atm_vcc *vcc = entry->recv_vcc; ++ struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); ++ ++ kfree(vpriv); ++ vcc->user_back = NULL; ++ + entry->recv_vcc->push = entry->old_recv_push; + vcc_release_async(entry->recv_vcc, -EPIPE); + entry->recv_vcc = NULL; +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c +index 9aa5daa551273..1267cbb1a329a 100644 +--- a/net/batman-adv/bridge_loop_avoidance.c ++++ b/net/batman-adv/bridge_loop_avoidance.c +@@ -73,11 +73,12 @@ static inline u32 batadv_choose_claim(const void *data, u32 size) + /* return the index of the backbone gateway */ + static inline u32 batadv_choose_backbone_gw(const void *data, u32 size) + { +- const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data; ++ const struct batadv_bla_backbone_gw *gw; + u32 hash = 0; + +- hash = jhash(&claim->addr, sizeof(claim->addr), hash); +- hash = jhash(&claim->vid, sizeof(claim->vid), hash); ++ gw = (struct batadv_bla_backbone_gw *)data; ++ hash = jhash(&gw->orig, sizeof(gw->orig), hash); ++ hash = jhash(&gw->vid, sizeof(gw->vid), hash); + + return hash % size; + } +diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c +index b3e8b0e3073c2..e470410abb44d 100644 +--- a/net/batman-adv/routing.c ++++ b/net/batman-adv/routing.c +@@ -782,6 +782,10 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, + vid = batadv_get_vid(skb, hdr_len); + ethhdr = (struct ethhdr *)(skb->data + hdr_len); + ++ /* do not reroute multicast frames in a unicast header */ ++ if (is_multicast_ether_addr(ethhdr->h_dest)) ++ return true; ++ + /* check if the destination client was served by this node and it is now + * roaming. In this case, it means that the node has got a ROAM_ADV + * message and that it knows the new destination in the mesh to re-route +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c +index 16cf5633eae3e..03319ab8a7c6e 100644 +--- a/net/bluetooth/hci_event.c ++++ b/net/bluetooth/hci_event.c +@@ -41,12 +41,27 @@ + + /* Handle HCI Event packets */ + +-static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) ++static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb, ++ u8 *new_status) + { + __u8 status = *((__u8 *) skb->data); + + BT_DBG("%s status 0x%2.2x", hdev->name, status); + ++ /* It is possible that we receive Inquiry Complete event right ++ * before we receive Inquiry Cancel Command Complete event, in ++ * which case the latter event should have status of Command ++ * Disallowed (0x0c). This should not be treated as error, since ++ * we actually achieve what Inquiry Cancel wants to achieve, ++ * which is to end the last Inquiry session. ++ */ ++ if (status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { ++ bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); ++ status = 0x00; ++ } ++ ++ *new_status = status; ++ + if (status) + return; + +@@ -2758,7 +2773,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, + + switch (*opcode) { + case HCI_OP_INQUIRY_CANCEL: +- hci_cc_inquiry_cancel(hdev, skb); ++ hci_cc_inquiry_cancel(hdev, skb, status); + break; + + case HCI_OP_PERIODIC_INQ: +@@ -5230,6 +5245,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) + u8 status = 0, event = hdr->evt, req_evt = 0; + u16 opcode = HCI_OP_NOP; + ++ if (!event) { ++ bt_dev_warn(hdev, "Received unexpected HCI Event 00000000"); ++ goto done; ++ } ++ + if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) { + struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; + opcode = __le16_to_cpu(cmd_hdr->opcode); +@@ -5441,6 +5461,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) + req_complete_skb(hdev, status, opcode, orig_skb); + } + ++done: + kfree_skb(orig_skb); + kfree_skb(skb); + hdev->stat.evt_rx++; +diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c +index 0e31bbe1256cd..f2db50da8ce2e 100644 +--- a/net/bluetooth/l2cap_core.c ++++ b/net/bluetooth/l2cap_core.c +@@ -403,6 +403,9 @@ static void l2cap_chan_timeout(struct work_struct *work) + BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); + + mutex_lock(&conn->chan_lock); ++ /* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling ++ * this work. No need to call l2cap_chan_hold(chan) here again. ++ */ + l2cap_chan_lock(chan); + + if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) +@@ -415,12 +418,12 @@ static void l2cap_chan_timeout(struct work_struct *work) + + l2cap_chan_close(chan, reason); + +- l2cap_chan_unlock(chan); +- + chan->ops->close(chan); +- mutex_unlock(&conn->chan_lock); + ++ l2cap_chan_unlock(chan); + l2cap_chan_put(chan); ++ ++ mutex_unlock(&conn->chan_lock); + } + + struct l2cap_chan *l2cap_chan_create(void) +@@ -1714,9 +1717,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) + + l2cap_chan_del(chan, err); + +- l2cap_chan_unlock(chan); +- + chan->ops->close(chan); ++ ++ l2cap_chan_unlock(chan); + l2cap_chan_put(chan); + } + +@@ -4093,7 +4096,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, + return 0; + } + +- if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { ++ if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2 && ++ chan->state != BT_CONNECTED) { + cmd_reject_invalid_cid(conn, cmd->ident, chan->scid, + chan->dcid); + goto unlock; +@@ -4316,6 +4320,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, + return 0; + } + ++ l2cap_chan_hold(chan); + l2cap_chan_lock(chan); + + rsp.dcid = cpu_to_le16(chan->scid); +@@ -4324,12 +4329,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, + + chan->ops->set_shutdown(chan); + +- l2cap_chan_hold(chan); + l2cap_chan_del(chan, ECONNRESET); + +- l2cap_chan_unlock(chan); +- + chan->ops->close(chan); ++ ++ l2cap_chan_unlock(chan); + l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); +@@ -4361,20 +4365,21 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, + return 0; + } + ++ l2cap_chan_hold(chan); + l2cap_chan_lock(chan); + + if (chan->state != BT_DISCONN) { + l2cap_chan_unlock(chan); ++ l2cap_chan_put(chan); + mutex_unlock(&conn->chan_lock); + return 0; + } + +- l2cap_chan_hold(chan); + l2cap_chan_del(chan, 0); + +- l2cap_chan_unlock(chan); +- + chan->ops->close(chan); ++ ++ l2cap_chan_unlock(chan); + l2cap_chan_put(chan); + + mutex_unlock(&conn->chan_lock); +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c +index d9bbbded49ef8..e562385d9440e 100644 +--- a/net/bluetooth/l2cap_sock.c ++++ b/net/bluetooth/l2cap_sock.c +@@ -1038,7 +1038,7 @@ done: + } + + /* Kill socket (only if zapped and orphan) +- * Must be called on unlocked socket. ++ * Must be called on unlocked socket, with l2cap channel lock. + */ + static void l2cap_sock_kill(struct sock *sk) + { +@@ -1189,6 +1189,7 @@ static int l2cap_sock_release(struct socket *sock) + { + struct sock *sk = sock->sk; + int err; ++ struct l2cap_chan *chan; + + BT_DBG("sock %p, sk %p", sock, sk); + +@@ -1198,9 +1199,17 @@ static int l2cap_sock_release(struct socket *sock) + bt_sock_unlink(&l2cap_sk_list, sk); + + err = l2cap_sock_shutdown(sock, 2); ++ chan = l2cap_pi(sk)->chan; ++ ++ l2cap_chan_hold(chan); ++ l2cap_chan_lock(chan); + + sock_orphan(sk); + l2cap_sock_kill(sk); ++ ++ l2cap_chan_unlock(chan); ++ l2cap_chan_put(chan); ++ + return err; + } + +@@ -1218,12 +1227,15 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) + BT_DBG("child chan %p state %s", chan, + state_to_string(chan->state)); + ++ l2cap_chan_hold(chan); + l2cap_chan_lock(chan); ++ + __clear_chan_timer(chan); + l2cap_chan_close(chan, ECONNRESET); +- l2cap_chan_unlock(chan); +- + l2cap_sock_kill(sk); ++ ++ l2cap_chan_unlock(chan); ++ l2cap_chan_put(chan); + } + } + +diff --git a/net/core/neighbour.c b/net/core/neighbour.c +index 9849f1f4cf4f7..40d33431bc585 100644 +--- a/net/core/neighbour.c ++++ b/net/core/neighbour.c +@@ -2798,6 +2798,7 @@ static void *neigh_stat_seq_next(struct seq_file *seq, void *v, loff_t *pos) + *pos = cpu+1; + return per_cpu_ptr(tbl->stats, cpu); + } ++ (*pos)++; + return NULL; + } + +diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c +index d940c9e0eb024..0355f125d8361 100644 +--- a/net/ipv4/ip_output.c ++++ b/net/ipv4/ip_output.c +@@ -73,6 +73,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1597,7 +1598,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, + if (IS_ERR(rt)) + return; + +- inet_sk(sk)->tos = arg->tos; ++ inet_sk(sk)->tos = arg->tos & ~INET_ECN_MASK; + + sk->sk_priority = skb->priority; + sk->sk_protocol = ip_hdr(skb)->protocol; +diff --git a/net/ipv4/route.c b/net/ipv4/route.c +index 542f6e0f438f1..ea1c319100a5d 100644 +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -271,6 +271,7 @@ static void *rt_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos) + *pos = cpu+1; + return &per_cpu(rt_cache_stat, cpu); + } ++ (*pos)++; + return NULL; + + } +diff --git a/net/key/af_key.c b/net/key/af_key.c +index d2ec620319d76..76a008b1cbe5f 100644 +--- a/net/key/af_key.c ++++ b/net/key/af_key.c +@@ -1873,6 +1873,13 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms + if (ext_hdrs[SADB_X_EXT_FILTER - 1]) { + struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1]; + ++ if ((xfilter->sadb_x_filter_splen >= ++ (sizeof(xfrm_address_t) << 3)) || ++ (xfilter->sadb_x_filter_dplen >= ++ (sizeof(xfrm_address_t) << 3))) { ++ mutex_unlock(&pfk->dump_lock); ++ return -EINVAL; ++ } + filter = kmalloc(sizeof(*filter), GFP_KERNEL); + if (filter == NULL) { + mutex_unlock(&pfk->dump_lock); +diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c +index 2b8e80c721db1..a7cd031656801 100644 +--- a/net/sunrpc/svc_xprt.c ++++ b/net/sunrpc/svc_xprt.c +@@ -97,8 +97,17 @@ void svc_unreg_xprt_class(struct svc_xprt_class *xcl) + } + EXPORT_SYMBOL_GPL(svc_unreg_xprt_class); + +-/* +- * Format the transport list for printing ++/** ++ * svc_print_xprts - Format the transport list for printing ++ * @buf: target buffer for formatted address ++ * @maxlen: length of target buffer ++ * ++ * Fills in @buf with a string containing a list of transport names, each name ++ * terminated with '\n'. If the buffer is too small, some entries may be ++ * missing, but it is guaranteed that all lines in the output buffer are ++ * complete. ++ * ++ * Returns positive length of the filled-in string. + */ + int svc_print_xprts(char *buf, int maxlen) + { +@@ -111,9 +120,9 @@ int svc_print_xprts(char *buf, int maxlen) + list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) { + int slen; + +- sprintf(tmpstr, "%s %d\n", xcl->xcl_name, xcl->xcl_max_payload); +- slen = strlen(tmpstr); +- if (len + slen > maxlen) ++ slen = snprintf(tmpstr, sizeof(tmpstr), "%s %d\n", ++ xcl->xcl_name, xcl->xcl_max_payload); ++ if (slen >= sizeof(tmpstr) || len + slen >= maxlen) + break; + len += slen; + strcat(buf, tmpstr); +diff --git a/net/tipc/msg.c b/net/tipc/msg.c +index 67bddcb2ff466..fc1aa8bcb185d 100644 +--- a/net/tipc/msg.c ++++ b/net/tipc/msg.c +@@ -138,7 +138,8 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) + if (fragid == FIRST_FRAGMENT) { + if (unlikely(head)) + goto err; +- if (unlikely(skb_unclone(frag, GFP_ATOMIC))) ++ frag = skb_unshare(frag, GFP_ATOMIC); ++ if (unlikely(!frag)) + goto err; + head = *headbuf = frag; + *buf = NULL; +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c +index b5e2ef242efe7..ac78c5ac82846 100644 +--- a/net/unix/af_unix.c ++++ b/net/unix/af_unix.c +@@ -191,11 +191,17 @@ static inline int unix_may_send(struct sock *sk, struct sock *osk) + return unix_peer(osk) == NULL || unix_our_peer(sk, osk); + } + +-static inline int unix_recvq_full(struct sock const *sk) ++static inline int unix_recvq_full(const struct sock *sk) + { + return skb_queue_len(&sk->sk_receive_queue) > sk->sk_max_ack_backlog; + } + ++static inline int unix_recvq_full_lockless(const struct sock *sk) ++{ ++ return skb_queue_len_lockless(&sk->sk_receive_queue) > ++ READ_ONCE(sk->sk_max_ack_backlog); ++} ++ + struct sock *unix_peer_get(struct sock *s) + { + struct sock *peer; +@@ -1792,7 +1798,8 @@ restart_locked: + * - unix_peer(sk) == sk by time of get but disconnected before lock + */ + if (other != sk && +- unlikely(unix_peer(other) != sk && unix_recvq_full(other))) { ++ unlikely(unix_peer(other) != sk && ++ unix_recvq_full_lockless(other))) { + if (timeo) { + timeo = unix_wait_for_peer(other, timeo); + +diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c +index c02da25d7b631..7778e28cce9d7 100644 +--- a/security/selinux/selinuxfs.c ++++ b/security/selinux/selinuxfs.c +@@ -1370,6 +1370,7 @@ static struct avc_cache_stats *sel_avc_get_stat_idx(loff_t *idx) + *idx = cpu + 1; + return &per_cpu(avc_cache_stats, cpu); + } ++ (*idx)++; + return NULL; + } + +diff --git a/sound/hda/hdac_bus.c b/sound/hda/hdac_bus.c +index 0e81ea89a5965..e3f68a76d90eb 100644 +--- a/sound/hda/hdac_bus.c ++++ b/sound/hda/hdac_bus.c +@@ -155,6 +155,7 @@ static void process_unsol_events(struct work_struct *work) + struct hdac_driver *drv; + unsigned int rp, caddr, res; + ++ spin_lock_irq(&bus->reg_lock); + while (bus->unsol_rp != bus->unsol_wp) { + rp = (bus->unsol_rp + 1) % HDA_UNSOL_QUEUE_SIZE; + bus->unsol_rp = rp; +@@ -166,10 +167,13 @@ static void process_unsol_events(struct work_struct *work) + codec = bus->caddr_tbl[caddr & 0x0f]; + if (!codec || !codec->dev.driver) + continue; ++ spin_unlock_irq(&bus->reg_lock); + drv = drv_to_hdac_driver(codec->dev.driver); + if (drv->unsol_event) + drv->unsol_event(codec, res); ++ spin_lock_irq(&bus->reg_lock); + } ++ spin_unlock_irq(&bus->reg_lock); + } + + /** +diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c +index 7a32abbe0cef8..4bdcb7443b1f5 100644 +--- a/sound/pci/asihpi/hpioctl.c ++++ b/sound/pci/asihpi/hpioctl.c +@@ -346,7 +346,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, + struct hpi_message hm; + struct hpi_response hr; + struct hpi_adapter adapter; +- struct hpi_pci pci; ++ struct hpi_pci pci = { 0 }; + + memset(&adapter, 0, sizeof(adapter)); + +@@ -502,7 +502,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, + return 0; + + err: +- for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { ++ while (--idx >= 0) { + if (pci.ap_mem_base[idx]) { + iounmap(pci.ap_mem_base[idx]); + pci.ap_mem_base[idx] = NULL; +diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c +index dbfdfe99c69df..231c7d97333c7 100644 +--- a/sound/soc/kirkwood/kirkwood-dma.c ++++ b/sound/soc/kirkwood/kirkwood-dma.c +@@ -136,7 +136,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) + err = request_irq(priv->irq, kirkwood_dma_irq, IRQF_SHARED, + "kirkwood-i2s", priv); + if (err) +- return -EBUSY; ++ return err; + + /* + * Enable Error interrupts. We're only ack'ing them but +diff --git a/sound/usb/midi.c b/sound/usb/midi.c +index 5c4a3d6c42341..934540042bc2e 100644 +--- a/sound/usb/midi.c ++++ b/sound/usb/midi.c +@@ -1803,6 +1803,28 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi *umidi, + return 0; + } + ++static struct usb_ms_endpoint_descriptor *find_usb_ms_endpoint_descriptor( ++ struct usb_host_endpoint *hostep) ++{ ++ unsigned char *extra = hostep->extra; ++ int extralen = hostep->extralen; ++ ++ while (extralen > 3) { ++ struct usb_ms_endpoint_descriptor *ms_ep = ++ (struct usb_ms_endpoint_descriptor *)extra; ++ ++ if (ms_ep->bLength > 3 && ++ ms_ep->bDescriptorType == USB_DT_CS_ENDPOINT && ++ ms_ep->bDescriptorSubtype == UAC_MS_GENERAL) ++ return ms_ep; ++ if (!extra[0]) ++ break; ++ extralen -= extra[0]; ++ extra += extra[0]; ++ } ++ return NULL; ++} ++ + /* + * Returns MIDIStreaming device capabilities. + */ +@@ -1840,11 +1862,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi *umidi, + ep = get_ep_desc(hostep); + if (!usb_endpoint_xfer_bulk(ep) && !usb_endpoint_xfer_int(ep)) + continue; +- ms_ep = (struct usb_ms_endpoint_descriptor *)hostep->extra; +- if (hostep->extralen < 4 || +- ms_ep->bLength < 4 || +- ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || +- ms_ep->bDescriptorSubtype != UAC_MS_GENERAL) ++ ms_ep = find_usb_ms_endpoint_descriptor(hostep); ++ if (!ms_ep) + continue; + if (usb_endpoint_dir_out(ep)) { + if (endpoints[epidx].out_ep) { +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c +index 2070c02de3af5..ea55cb6b614f4 100644 +--- a/tools/perf/util/symbol-elf.c ++++ b/tools/perf/util/symbol-elf.c +@@ -1390,6 +1390,7 @@ struct kcore_copy_info { + u64 first_symbol; + u64 last_symbol; + u64 first_module; ++ u64 first_module_symbol; + u64 last_module_symbol; + struct phdr_data kernel_map; + struct phdr_data modules_map; +@@ -1404,6 +1405,8 @@ static int kcore_copy__process_kallsyms(void *arg, const char *name, char type, + return 0; + + if (strchr(name, '[')) { ++ if (!kci->first_module_symbol || start < kci->first_module_symbol) ++ kci->first_module_symbol = start; + if (start > kci->last_module_symbol) + kci->last_module_symbol = start; + return 0; +@@ -1528,6 +1531,10 @@ static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir, + kci->etext += page_size; + } + ++ if (kci->first_module_symbol && ++ (!kci->first_module || kci->first_module_symbol < kci->first_module)) ++ kci->first_module = kci->first_module_symbol; ++ + kci->first_module = round_down(kci->first_module, page_size); + + if (kci->last_module_symbol) { +diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c +index 82f3a9d78cab4..ba8e8840b94b2 100644 +--- a/virt/kvm/kvm_main.c ++++ b/virt/kvm/kvm_main.c +@@ -3392,7 +3392,7 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, + void kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, + struct kvm_io_device *dev) + { +- int i; ++ int i, j; + struct kvm_io_bus *new_bus, *bus; + + bus = kvm->buses[bus_idx]; +@@ -3409,17 +3409,20 @@ void kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, + + new_bus = kmalloc(sizeof(*bus) + ((bus->dev_count - 1) * + sizeof(struct kvm_io_range)), GFP_KERNEL); +- if (!new_bus) { ++ if (new_bus) { ++ memcpy(new_bus, bus, sizeof(*bus) + i * sizeof(struct kvm_io_range)); ++ new_bus->dev_count--; ++ memcpy(new_bus->range + i, bus->range + i + 1, ++ (new_bus->dev_count - i) * sizeof(struct kvm_io_range)); ++ } else { + pr_err("kvm: failed to shrink bus, removing it completely\n"); +- goto broken; ++ for (j = 0; j < bus->dev_count; j++) { ++ if (j == i) ++ continue; ++ kvm_iodevice_destructor(bus->range[j].dev); ++ } + } + +- memcpy(new_bus, bus, sizeof(*bus) + i * sizeof(struct kvm_io_range)); +- new_bus->dev_count--; +- memcpy(new_bus->range + i, bus->range + i + 1, +- (new_bus->dev_count - i) * sizeof(struct kvm_io_range)); +- +-broken: + rcu_assign_pointer(kvm->buses[bus_idx], new_bus); + synchronize_srcu_expedited(&kvm->srcu); + kfree(bus); diff --git a/patch/kernel/rockpis-legacy/patch-4.4.238-239.patch b/patch/kernel/rockpis-legacy/patch-4.4.238-239.patch new file mode 100644 index 000000000..bc1e212ec --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.238-239.patch @@ -0,0 +1,1487 @@ +diff --git a/Makefile b/Makefile +index 209fe98a591cd..74072b5a958b2 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 238 ++SUBLEVEL = 239 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/drivers/base/dd.c b/drivers/base/dd.c +index 04a923186081f..6bb3a425bbd3e 100644 +--- a/drivers/base/dd.c ++++ b/drivers/base/dd.c +@@ -285,7 +285,8 @@ static int really_probe(struct device *dev, struct device_driver *drv) + drv->bus->name, __func__, drv->name, dev_name(dev)); + if (!list_empty(&dev->devres_head)) { + dev_crit(dev, "Resources present before probing\n"); +- return -EBUSY; ++ ret = -EBUSY; ++ goto done; + } + + dev->driver = drv; +@@ -363,7 +364,7 @@ probe_failed: + ret = 0; + done: + atomic_dec(&probe_count); +- wake_up(&probe_waitqueue); ++ wake_up_all(&probe_waitqueue); + return ret; + } + +diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c +index 6c8e45e007c84..8edbb20ccff5e 100644 +--- a/drivers/clk/samsung/clk-exynos4.c ++++ b/drivers/clk/samsung/clk-exynos4.c +@@ -1059,7 +1059,7 @@ static struct samsung_gate_clock exynos4210_gate_clks[] __initdata = { + GATE(CLK_PCIE, "pcie", "aclk133", GATE_IP_FSYS, 14, 0, 0), + GATE(CLK_SMMU_PCIE, "smmu_pcie", "aclk133", GATE_IP_FSYS, 18, 0, 0), + GATE(CLK_MODEMIF, "modemif", "aclk100", GATE_IP_PERIL, 28, 0, 0), +- GATE(CLK_CHIPID, "chipid", "aclk100", E4210_GATE_IP_PERIR, 0, 0, 0), ++ GATE(CLK_CHIPID, "chipid", "aclk100", E4210_GATE_IP_PERIR, 0, CLK_IGNORE_UNUSED, 0), + GATE(CLK_SYSREG, "sysreg", "aclk100", E4210_GATE_IP_PERIR, 0, + CLK_IGNORE_UNUSED, 0), + GATE(CLK_HDMI_CEC, "hdmi_cec", "aclk100", E4210_GATE_IP_PERIR, 11, 0, +@@ -1100,7 +1100,7 @@ static struct samsung_gate_clock exynos4x12_gate_clks[] __initdata = { + 0), + GATE(CLK_TSADC, "tsadc", "aclk133", E4X12_GATE_BUS_FSYS1, 16, 0, 0), + GATE(CLK_MIPI_HSI, "mipi_hsi", "aclk133", GATE_IP_FSYS, 10, 0, 0), +- GATE(CLK_CHIPID, "chipid", "aclk100", E4X12_GATE_IP_PERIR, 0, 0, 0), ++ GATE(CLK_CHIPID, "chipid", "aclk100", E4X12_GATE_IP_PERIR, 0, CLK_IGNORE_UNUSED, 0), + GATE(CLK_SYSREG, "sysreg", "aclk100", E4X12_GATE_IP_PERIR, 1, + CLK_IGNORE_UNUSED, 0), + GATE(CLK_HDMI_CEC, "hdmi_cec", "aclk100", E4X12_GATE_IP_PERIR, 11, 0, +diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c +index d1d585ddb9ab7..dd19805d587de 100644 +--- a/drivers/gpio/gpio-tc3589x.c ++++ b/drivers/gpio/gpio-tc3589x.c +@@ -157,7 +157,7 @@ static void tc3589x_gpio_irq_sync_unlock(struct irq_data *d) + continue; + + tc3589x_gpio->oldregs[i][j] = new; +- tc3589x_reg_write(tc3589x, regmap[i] + j * 8, new); ++ tc3589x_reg_write(tc3589x, regmap[i] + j, new); + } + } + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +index d3ee8f19f1ef9..5ff941bbfb5bc 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +@@ -311,7 +311,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set) + take the current one */ + if (active && !adev->have_disp_power_ref) { + adev->have_disp_power_ref = true; +- goto out; ++ return ret; + } + /* if we have no active crtcs, then drop the power ref + we got before */ +diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c +index b167ab25310a3..34a35e927fc6d 100644 +--- a/drivers/i2c/busses/i2c-cpm.c ++++ b/drivers/i2c/busses/i2c-cpm.c +@@ -74,6 +74,9 @@ struct i2c_ram { + char res1[4]; /* Reserved */ + ushort rpbase; /* Relocation pointer */ + char res2[2]; /* Reserved */ ++ /* The following elements are only for CPM2 */ ++ char res3[4]; /* Reserved */ ++ uint sdmatmp; /* Internal */ + }; + + #define I2COM_START 0x80 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h +index e5799639fb544..82ff44637ed78 100644 +--- a/drivers/input/serio/i8042-x86ia64io.h ++++ b/drivers/input/serio/i8042-x86ia64io.h +@@ -797,6 +797,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nopnp_table[] = { + DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"), + }, + }, ++ { ++ /* Acer Aspire 5 A515 */ ++ .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "Grumpy_PK"), ++ DMI_MATCH(DMI_BOARD_VENDOR, "PK"), ++ }, ++ }, + { } + }; + +diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c +index 29a31eb9ace3e..02df8d9dc842a 100644 +--- a/drivers/iommu/exynos-iommu.c ++++ b/drivers/iommu/exynos-iommu.c +@@ -1158,13 +1158,17 @@ static int exynos_iommu_of_xlate(struct device *dev, + return -ENODEV; + + data = platform_get_drvdata(sysmmu); +- if (!data) ++ if (!data) { ++ put_device(&sysmmu->dev); + return -ENODEV; ++ } + + if (!owner) { + owner = kzalloc(sizeof(*owner), GFP_KERNEL); +- if (!owner) ++ if (!owner) { ++ put_device(&sysmmu->dev); + return -ENOMEM; ++ } + + INIT_LIST_HEAD(&owner->controllers); + dev->archdata.iommu = owner; +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c +index 8406f346b0be5..09864226428b2 100644 +--- a/drivers/mtd/nand/nand_base.c ++++ b/drivers/mtd/nand/nand_base.c +@@ -4427,18 +4427,14 @@ int nand_scan(struct mtd_info *mtd, int maxchips) + EXPORT_SYMBOL(nand_scan); + + /** +- * nand_release - [NAND Interface] Free resources held by the NAND device +- * @mtd: MTD device structure ++ * nand_cleanup - [NAND Interface] Free resources held by the NAND device ++ * @chip: NAND chip object + */ +-void nand_release(struct mtd_info *mtd) ++void nand_cleanup(struct nand_chip *chip) + { +- struct nand_chip *chip = mtd->priv; +- + if (chip->ecc.mode == NAND_ECC_SOFT_BCH) + nand_bch_free((struct nand_bch_control *)chip->ecc.priv); + +- mtd_device_unregister(mtd); +- + /* Free bad block table memory */ + kfree(chip->bbt); + if (!(chip->options & NAND_OWN_BUFFERS)) +@@ -4449,6 +4445,18 @@ void nand_release(struct mtd_info *mtd) + & NAND_BBT_DYNAMICSTRUCT) + kfree(chip->badblock_pattern); + } ++EXPORT_SYMBOL_GPL(nand_cleanup); ++ ++/** ++ * nand_release - [NAND Interface] Unregister the MTD device and free resources ++ * held by the NAND device ++ * @mtd: MTD device structure ++ */ ++void nand_release(struct mtd_info *mtd) ++{ ++ mtd_device_unregister(mtd); ++ nand_cleanup(mtd->priv); ++} + EXPORT_SYMBOL_GPL(nand_release); + + static int __init nand_base_init(void) +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c +index aaf75d5e6e480..5811235a64c89 100644 +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -1132,6 +1132,7 @@ static void bond_setup_by_slave(struct net_device *bond_dev, + + bond_dev->type = slave_dev->type; + bond_dev->hard_header_len = slave_dev->hard_header_len; ++ bond_dev->needed_headroom = slave_dev->needed_headroom; + bond_dev->addr_len = slave_dev->addr_len; + + memcpy(bond_dev->broadcast, slave_dev->broadcast, +diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c +index cadcee645f74e..11ce50a057998 100644 +--- a/drivers/net/ethernet/dec/tulip/de2104x.c ++++ b/drivers/net/ethernet/dec/tulip/de2104x.c +@@ -91,7 +91,7 @@ MODULE_PARM_DESC (rx_copybreak, "de2104x Breakpoint at which Rx packets are copi + #define DSL CONFIG_DE2104X_DSL + #endif + +-#define DE_RX_RING_SIZE 64 ++#define DE_RX_RING_SIZE 128 + #define DE_TX_RING_SIZE 64 + #define DE_RING_BYTES \ + ((sizeof(struct de_desc) * DE_RX_RING_SIZE) + \ +diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c +index d5bf0f2753079..460b29ac5fd86 100644 +--- a/drivers/net/ethernet/renesas/ravb_main.c ++++ b/drivers/net/ethernet/renesas/ravb_main.c +@@ -1214,64 +1214,12 @@ static const struct ethtool_ops ravb_ethtool_ops = { + .get_ts_info = ravb_get_ts_info, + }; + +-/* MDIO bus init function */ +-static int ravb_mdio_init(struct ravb_private *priv) +-{ +- struct platform_device *pdev = priv->pdev; +- struct device *dev = &pdev->dev; +- int error; +- +- /* Bitbang init */ +- priv->mdiobb.ops = &bb_ops; +- +- /* MII controller setting */ +- priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); +- if (!priv->mii_bus) +- return -ENOMEM; +- +- /* Hook up MII support for ethtool */ +- priv->mii_bus->name = "ravb_mii"; +- priv->mii_bus->parent = dev; +- snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", +- pdev->name, pdev->id); +- +- /* Register MDIO bus */ +- error = of_mdiobus_register(priv->mii_bus, dev->of_node); +- if (error) +- goto out_free_bus; +- +- return 0; +- +-out_free_bus: +- free_mdio_bitbang(priv->mii_bus); +- return error; +-} +- +-/* MDIO bus release function */ +-static int ravb_mdio_release(struct ravb_private *priv) +-{ +- /* Unregister mdio bus */ +- mdiobus_unregister(priv->mii_bus); +- +- /* Free bitbang info */ +- free_mdio_bitbang(priv->mii_bus); +- +- return 0; +-} +- + /* Network device open function for Ethernet AVB */ + static int ravb_open(struct net_device *ndev) + { + struct ravb_private *priv = netdev_priv(ndev); + int error; + +- /* MDIO bus init */ +- error = ravb_mdio_init(priv); +- if (error) { +- netdev_err(ndev, "failed to initialize MDIO\n"); +- return error; +- } +- + napi_enable(&priv->napi[RAVB_BE]); + napi_enable(&priv->napi[RAVB_NC]); + +@@ -1320,7 +1268,6 @@ out_free_irq: + out_napi_off: + napi_disable(&priv->napi[RAVB_NC]); + napi_disable(&priv->napi[RAVB_BE]); +- ravb_mdio_release(priv); + return error; + } + +@@ -1614,8 +1561,6 @@ static int ravb_close(struct net_device *ndev) + ravb_ring_free(ndev, RAVB_BE); + ravb_ring_free(ndev, RAVB_NC); + +- ravb_mdio_release(priv); +- + return 0; + } + +@@ -1719,6 +1664,51 @@ static const struct net_device_ops ravb_netdev_ops = { + .ndo_change_mtu = eth_change_mtu, + }; + ++/* MDIO bus init function */ ++static int ravb_mdio_init(struct ravb_private *priv) ++{ ++ struct platform_device *pdev = priv->pdev; ++ struct device *dev = &pdev->dev; ++ int error; ++ ++ /* Bitbang init */ ++ priv->mdiobb.ops = &bb_ops; ++ ++ /* MII controller setting */ ++ priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb); ++ if (!priv->mii_bus) ++ return -ENOMEM; ++ ++ /* Hook up MII support for ethtool */ ++ priv->mii_bus->name = "ravb_mii"; ++ priv->mii_bus->parent = dev; ++ snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", ++ pdev->name, pdev->id); ++ ++ /* Register MDIO bus */ ++ error = of_mdiobus_register(priv->mii_bus, dev->of_node); ++ if (error) ++ goto out_free_bus; ++ ++ return 0; ++ ++out_free_bus: ++ free_mdio_bitbang(priv->mii_bus); ++ return error; ++} ++ ++/* MDIO bus release function */ ++static int ravb_mdio_release(struct ravb_private *priv) ++{ ++ /* Unregister mdio bus */ ++ mdiobus_unregister(priv->mii_bus); ++ ++ /* Free bitbang info */ ++ free_mdio_bitbang(priv->mii_bus); ++ ++ return 0; ++} ++ + static const struct of_device_id ravb_match_table[] = { + { .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 }, + { .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 }, +@@ -1857,6 +1847,13 @@ static int ravb_probe(struct platform_device *pdev) + eth_hw_addr_random(ndev); + } + ++ /* MDIO bus init */ ++ error = ravb_mdio_init(priv); ++ if (error) { ++ dev_err(&pdev->dev, "failed to initialize MDIO\n"); ++ goto out_dma_free; ++ } ++ + netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64); + netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64); + +@@ -1876,6 +1873,8 @@ static int ravb_probe(struct platform_device *pdev) + out_napi_del: + netif_napi_del(&priv->napi[RAVB_NC]); + netif_napi_del(&priv->napi[RAVB_BE]); ++ ravb_mdio_release(priv); ++out_dma_free: + dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, + priv->desc_bat_dma); + out_release: +@@ -1900,6 +1899,7 @@ static int ravb_remove(struct platform_device *pdev) + unregister_netdev(ndev); + netif_napi_del(&priv->napi[RAVB_NC]); + netif_napi_del(&priv->napi[RAVB_BE]); ++ ravb_mdio_release(priv); + pm_runtime_disable(&pdev->dev); + free_netdev(ndev); + platform_set_drvdata(pdev, NULL); +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +index fbf701e5f1e9f..6fe441696882d 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +@@ -616,23 +616,16 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev, + struct stmmac_priv *priv = netdev_priv(dev); + int ret; + +- if (!edata->eee_enabled) { ++ if (!priv->dma_cap.eee) ++ return -EOPNOTSUPP; ++ ++ if (!edata->eee_enabled) + stmmac_disable_eee_mode(priv); +- } else { +- /* We are asking for enabling the EEE but it is safe +- * to verify all by invoking the eee_init function. +- * In case of failure it will return an error. +- */ +- edata->eee_enabled = stmmac_eee_init(priv); +- if (!edata->eee_enabled) +- return -EOPNOTSUPP; +- } + + ret = phy_ethtool_set_eee(dev->phydev, edata); + if (ret) + return ret; + +- priv->eee_enabled = edata->eee_enabled; + priv->tx_lpi_timer = edata->tx_lpi_timer; + return 0; + } +diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c +index d0943415aeff1..2ed1453b92241 100644 +--- a/drivers/net/team/team.c ++++ b/drivers/net/team/team.c +@@ -285,7 +285,7 @@ inst_rollback: + for (i--; i >= 0; i--) + __team_option_inst_del_option(team, dst_opts[i]); + +- i = option_count - 1; ++ i = option_count; + alloc_rollback: + for (i--; i >= 0; i--) + kfree(dst_opts[i]); +@@ -2038,6 +2038,7 @@ static void team_setup_by_port(struct net_device *dev, + dev->header_ops = port_dev->header_ops; + dev->type = port_dev->type; + dev->hard_header_len = port_dev->hard_header_len; ++ dev->needed_headroom = port_dev->needed_headroom; + dev->addr_len = port_dev->addr_len; + dev->mtu = port_dev->mtu; + memcpy(dev->broadcast, port_dev->broadcast, port_dev->addr_len); +diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c +index 524a47a281207..b20b380d91bf6 100644 +--- a/drivers/net/usb/rndis_host.c ++++ b/drivers/net/usb/rndis_host.c +@@ -213,7 +213,7 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen) + dev_dbg(&info->control->dev, + "rndis response error, code %d\n", retval); + } +- msleep(20); ++ msleep(40); + } + dev_dbg(&info->control->dev, "rndis response timeout\n"); + return -ETIMEDOUT; +diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c +index 58b1e18fdd64d..7230f1e8210ff 100644 +--- a/drivers/net/usb/rtl8150.c ++++ b/drivers/net/usb/rtl8150.c +@@ -277,12 +277,20 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg) + return 1; + } + +-static inline void set_ethernet_addr(rtl8150_t * dev) ++static void set_ethernet_addr(rtl8150_t *dev) + { +- u8 node_id[6]; ++ u8 node_id[ETH_ALEN]; ++ int ret; ++ ++ ret = get_registers(dev, IDR, sizeof(node_id), node_id); + +- get_registers(dev, IDR, sizeof(node_id), node_id); +- memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id)); ++ if (ret == sizeof(node_id)) { ++ ether_addr_copy(dev->netdev->dev_addr, node_id); ++ } else { ++ eth_hw_addr_random(dev->netdev); ++ netdev_notice(dev->netdev, "Assigned a random MAC address: %pM\n", ++ dev->netdev->dev_addr); ++ } + } + + static int rtl8150_set_mac_address(struct net_device *netdev, void *p) +diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c +index f8ed079d8bc3e..7a6f851d9843a 100644 +--- a/drivers/net/wan/hdlc_cisco.c ++++ b/drivers/net/wan/hdlc_cisco.c +@@ -120,6 +120,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type, + skb_put(skb, sizeof(struct cisco_packet)); + skb->priority = TC_PRIO_CONTROL; + skb->dev = dev; ++ skb->protocol = htons(ETH_P_HDLC); + skb_reset_network_header(skb); + + dev_queue_xmit(skb); +diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c +index 89541cc90e877..74d46f7e77eaa 100644 +--- a/drivers/net/wan/hdlc_fr.c ++++ b/drivers/net/wan/hdlc_fr.c +@@ -435,6 +435,8 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) + if (pvc->state.fecn) /* TX Congestion counter */ + dev->stats.tx_compressed++; + skb->dev = pvc->frad; ++ skb->protocol = htons(ETH_P_HDLC); ++ skb_reset_network_header(skb); + dev_queue_xmit(skb); + return NETDEV_TX_OK; + } +@@ -557,6 +559,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) + skb_put(skb, i); + skb->priority = TC_PRIO_CONTROL; + skb->dev = dev; ++ skb->protocol = htons(ETH_P_HDLC); + skb_reset_network_header(skb); + + dev_queue_xmit(skb); +diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c +index a2559f213daed..473a9b8ec9ba5 100644 +--- a/drivers/net/wan/hdlc_ppp.c ++++ b/drivers/net/wan/hdlc_ppp.c +@@ -254,6 +254,7 @@ static void ppp_tx_cp(struct net_device *dev, u16 pid, u8 code, + + skb->priority = TC_PRIO_CONTROL; + skb->dev = dev; ++ skb->protocol = htons(ETH_P_HDLC); + skb_reset_network_header(skb); + skb_queue_tail(&tx_queue, skb); + } +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c +index c6db9a4e7c457..ef746ba74ab4c 100644 +--- a/drivers/net/wan/lapbether.c ++++ b/drivers/net/wan/lapbether.c +@@ -201,8 +201,6 @@ static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb) + struct net_device *dev; + int size = skb->len; + +- skb->protocol = htons(ETH_P_X25); +- + ptr = skb_push(skb, 2); + + *ptr++ = size % 256; +@@ -213,6 +211,8 @@ static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb) + + skb->dev = dev = lapbeth->ethdev; + ++ skb->protocol = htons(ETH_P_DEC); ++ + skb_reset_network_header(skb); + + dev_hard_header(skb, dev, ETH_P_DEC, bcast_addr, NULL, 0); +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index 0bed4733c4f04..9180b24ba60af 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -2474,7 +2474,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn, + */ + static int hotkey_kthread(void *data) + { +- struct tp_nvram_state s[2]; ++ struct tp_nvram_state s[2] = { 0 }; + u32 poll_mask, event_mask; + unsigned int si, so; + unsigned long t; +@@ -6362,8 +6362,10 @@ static int __init tpacpi_query_bcl_levels(acpi_handle handle) + list_for_each_entry(child, &device->children, node) { + acpi_status status = acpi_evaluate_object(child->handle, "_BCL", + NULL, &buffer); +- if (ACPI_FAILURE(status)) ++ if (ACPI_FAILURE(status)) { ++ buffer.length = ACPI_ALLOCATE_BUFFER; + continue; ++ } + + obj = (union acpi_object *)buffer.pointer; + if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c +index e57fa26bcff19..29bb679216395 100644 +--- a/drivers/video/console/fbcon.c ++++ b/drivers/video/console/fbcon.c +@@ -2234,6 +2234,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) + + if (font->width <= 8) { + j = vc->vc_font.height; ++ if (font->charcount * j > FNTSIZE(fontdata)) ++ return -EINVAL; ++ + for (i = 0; i < font->charcount; i++) { + memcpy(data, fontdata, j); + memset(data + j, 0, 32 - j); +@@ -2242,6 +2245,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) + } + } else if (font->width <= 16) { + j = vc->vc_font.height * 2; ++ if (font->charcount * j > FNTSIZE(fontdata)) ++ return -EINVAL; ++ + for (i = 0; i < font->charcount; i++) { + memcpy(data, fontdata, j); + memset(data + j, 0, 64 - j); +@@ -2249,6 +2255,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) + fontdata += j; + } + } else if (font->width <= 24) { ++ if (font->charcount * (vc->vc_font.height * sizeof(u32)) > FNTSIZE(fontdata)) ++ return -EINVAL; ++ + for (i = 0; i < font->charcount; i++) { + for (j = 0; j < vc->vc_font.height; j++) { + *data++ = fontdata[0]; +@@ -2261,6 +2270,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) + } + } else { + j = vc->vc_font.height * 4; ++ if (font->charcount * j > FNTSIZE(fontdata)) ++ return -EINVAL; ++ + for (i = 0; i < font->charcount; i++) { + memcpy(data, fontdata, j); + memset(data + j, 0, 128 - j); +diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h +index 5ebdccd070eb8..701eecab33171 100644 +--- a/drivers/video/console/fbcon.h ++++ b/drivers/video/console/fbcon.h +@@ -151,13 +151,6 @@ static inline int attr_col_ec(int shift, struct vc_data *vc, + #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0) + #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1) + +-/* Font */ +-#define REFCOUNT(fd) (((int *)(fd))[-1]) +-#define FNTSIZE(fd) (((int *)(fd))[-2]) +-#define FNTCHARCNT(fd) (((int *)(fd))[-3]) +-#define FNTSUM(fd) (((int *)(fd))[-4]) +-#define FONT_EXTRA_WORDS 4 +- + /* + * Scroll Method + */ +diff --git a/drivers/video/console/fbcon_rotate.c b/drivers/video/console/fbcon_rotate.c +index db6528f2d3f29..0e33210819454 100644 +--- a/drivers/video/console/fbcon_rotate.c ++++ b/drivers/video/console/fbcon_rotate.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + #include "fbcon.h" + #include "fbcon_rotate.h" +diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c +index bd0c6e53bec19..740284a4554c2 100644 +--- a/drivers/video/console/newport_con.c ++++ b/drivers/video/console/newport_con.c +@@ -35,12 +35,6 @@ + + #define FONT_DATA ((unsigned char *)font_vga_8x16.data) + +-/* borrowed from fbcon.c */ +-#define REFCOUNT(fd) (((int *)(fd))[-1]) +-#define FNTSIZE(fd) (((int *)(fd))[-2]) +-#define FNTCHARCNT(fd) (((int *)(fd))[-3]) +-#define FONT_EXTRA_WORDS 3 +- + static unsigned char *font_data[MAX_NR_CONSOLES]; + + static struct newport_regs *npregs; +@@ -522,6 +516,7 @@ static int newport_set_font(int unit, struct console_font *op) + FNTSIZE(new_data) = size; + FNTCHARCNT(new_data) = op->charcount; + REFCOUNT(new_data) = 0; /* usage counter */ ++ FNTSUM(new_data) = 0; + + p = new_data; + for (i = 0; i < op->charcount; i++) { +diff --git a/drivers/video/console/tileblit.c b/drivers/video/console/tileblit.c +index 3c0b242dba5f0..691717276c3e2 100644 +--- a/drivers/video/console/tileblit.c ++++ b/drivers/video/console/tileblit.c +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + #include + #include "fbcon.h" + +diff --git a/fs/eventpoll.c b/fs/eventpoll.c +index e5324642023d6..2ef15a4018d01 100644 +--- a/fs/eventpoll.c ++++ b/fs/eventpoll.c +@@ -217,8 +217,7 @@ struct eventpoll { + struct file *file; + + /* used to optimize loop detection check */ +- int visited; +- struct list_head visited_list_link; ++ u64 gen; + }; + + /* Wait structure used by the poll hooks */ +@@ -262,6 +261,8 @@ static long max_user_watches __read_mostly; + */ + static DEFINE_MUTEX(epmutex); + ++static u64 loop_check_gen = 0; ++ + /* Used to check for epoll file descriptor inclusion loops */ + static struct nested_calls poll_loop_ncalls; + +@@ -277,9 +278,6 @@ static struct kmem_cache *epi_cache __read_mostly; + /* Slab cache used to allocate "struct eppoll_entry" */ + static struct kmem_cache *pwq_cache __read_mostly; + +-/* Visited nodes during ep_loop_check(), so we can unset them when we finish */ +-static LIST_HEAD(visited_list); +- + /* + * List of files with newly added links, where we may need to limit the number + * of emanating paths. Protected by the epmutex. +@@ -1234,7 +1232,7 @@ static int reverse_path_check(void) + + static int ep_create_wakeup_source(struct epitem *epi) + { +- const char *name; ++ struct name_snapshot n; + struct wakeup_source *ws; + + if (!epi->ep->ws) { +@@ -1243,8 +1241,9 @@ static int ep_create_wakeup_source(struct epitem *epi) + return -ENOMEM; + } + +- name = epi->ffd.file->f_path.dentry->d_name.name; +- ws = wakeup_source_register(name); ++ take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry); ++ ws = wakeup_source_register(n.name); ++ release_dentry_name_snapshot(&n); + + if (!ws) + return -ENOMEM; +@@ -1304,6 +1303,22 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, + RCU_INIT_POINTER(epi->ws, NULL); + } + ++ /* Add the current item to the list of active epoll hook for this file */ ++ spin_lock(&tfile->f_lock); ++ list_add_tail_rcu(&epi->fllink, &tfile->f_ep_links); ++ spin_unlock(&tfile->f_lock); ++ ++ /* ++ * Add the current item to the RB tree. All RB tree operations are ++ * protected by "mtx", and ep_insert() is called with "mtx" held. ++ */ ++ ep_rbtree_insert(ep, epi); ++ ++ /* now check if we've created too many backpaths */ ++ error = -EINVAL; ++ if (full_check && reverse_path_check()) ++ goto error_remove_epi; ++ + /* Initialize the poll table using the queue callback */ + epq.epi = epi; + init_poll_funcptr(&epq.pt, ep_ptable_queue_proc); +@@ -1326,22 +1341,6 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, + if (epi->nwait < 0) + goto error_unregister; + +- /* Add the current item to the list of active epoll hook for this file */ +- spin_lock(&tfile->f_lock); +- list_add_tail_rcu(&epi->fllink, &tfile->f_ep_links); +- spin_unlock(&tfile->f_lock); +- +- /* +- * Add the current item to the RB tree. All RB tree operations are +- * protected by "mtx", and ep_insert() is called with "mtx" held. +- */ +- ep_rbtree_insert(ep, epi); +- +- /* now check if we've created too many backpaths */ +- error = -EINVAL; +- if (full_check && reverse_path_check()) +- goto error_remove_epi; +- + /* We have to drop the new item inside our item list to keep track of it */ + spin_lock_irqsave(&ep->lock, flags); + +@@ -1367,6 +1366,8 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, + + return 0; + ++error_unregister: ++ ep_unregister_pollwait(ep, epi); + error_remove_epi: + spin_lock(&tfile->f_lock); + list_del_rcu(&epi->fllink); +@@ -1374,9 +1375,6 @@ error_remove_epi: + + rb_erase(&epi->rbn, &ep->rbr); + +-error_unregister: +- ep_unregister_pollwait(ep, epi); +- + /* + * We need to do this because an event could have been arrived on some + * allocated wait queue. Note that we don't care about the ep->ovflist +@@ -1697,13 +1695,12 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) + struct epitem *epi; + + mutex_lock_nested(&ep->mtx, call_nests + 1); +- ep->visited = 1; +- list_add(&ep->visited_list_link, &visited_list); ++ ep->gen = loop_check_gen; + for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { + epi = rb_entry(rbp, struct epitem, rbn); + if (unlikely(is_file_epoll(epi->ffd.file))) { + ep_tovisit = epi->ffd.file->private_data; +- if (ep_tovisit->visited) ++ if (ep_tovisit->gen == loop_check_gen) + continue; + error = ep_call_nested(&poll_loop_ncalls, EP_MAX_NESTS, + ep_loop_check_proc, epi->ffd.file, +@@ -1744,18 +1741,8 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) + */ + static int ep_loop_check(struct eventpoll *ep, struct file *file) + { +- int ret; +- struct eventpoll *ep_cur, *ep_next; +- +- ret = ep_call_nested(&poll_loop_ncalls, EP_MAX_NESTS, ++ return ep_call_nested(&poll_loop_ncalls, EP_MAX_NESTS, + ep_loop_check_proc, file, ep, current); +- /* clear visited list */ +- list_for_each_entry_safe(ep_cur, ep_next, &visited_list, +- visited_list_link) { +- ep_cur->visited = 0; +- list_del(&ep_cur->visited_list_link); +- } +- return ret; + } + + static void clear_tfile_check_list(void) +@@ -1899,6 +1886,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, + mutex_lock_nested(&ep->mtx, 0); + if (op == EPOLL_CTL_ADD) { + if (!list_empty(&f.file->f_ep_links) || ++ ep->gen == loop_check_gen || + is_file_epoll(tf.file)) { + full_check = 1; + mutex_unlock(&ep->mtx); +@@ -1957,6 +1945,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd, + error_tgt_fput: + if (full_check) { + clear_tfile_check_list(); ++ loop_check_gen++; + mutex_unlock(&epmutex); + } + +diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c +index 21e5fcbcb2272..ba7e98d8ce098 100644 +--- a/fs/nfs/dir.c ++++ b/fs/nfs/dir.c +@@ -562,6 +562,9 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en + xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE); + + do { ++ if (entry->label) ++ entry->label->len = NFS4_MAXLABELLEN; ++ + status = xdr_decode(desc, entry, &stream); + if (status != 0) { + if (status == -EAGAIN) +diff --git a/include/linux/font.h b/include/linux/font.h +index d6821769dd1e1..f85e70bd4793e 100644 +--- a/include/linux/font.h ++++ b/include/linux/font.h +@@ -57,4 +57,17 @@ extern const struct font_desc *get_default_font(int xres, int yres, + /* Max. length for the name of a predefined font */ + #define MAX_FONT_NAME 32 + ++/* Extra word getters */ ++#define REFCOUNT(fd) (((int *)(fd))[-1]) ++#define FNTSIZE(fd) (((int *)(fd))[-2]) ++#define FNTCHARCNT(fd) (((int *)(fd))[-3]) ++#define FNTSUM(fd) (((int *)(fd))[-4]) ++ ++#define FONT_EXTRA_WORDS 4 ++ ++struct font_data { ++ unsigned int extra[FONT_EXTRA_WORDS]; ++ const unsigned char data[]; ++} __packed; ++ + #endif /* _VIDEO_FONT_H */ +diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h +index 93fc372007937..1a066faf7b801 100644 +--- a/include/linux/mtd/nand.h ++++ b/include/linux/mtd/nand.h +@@ -38,7 +38,7 @@ extern int nand_scan_ident(struct mtd_info *mtd, int max_chips, + struct nand_flash_dev *table); + extern int nand_scan_tail(struct mtd_info *mtd); + +-/* Free resources held by the NAND device */ ++/* Unregister the MTD device and free resources held by the NAND device */ + extern void nand_release(struct mtd_info *mtd); + + /* Internal helper for board drivers which need to override command function */ +@@ -1029,4 +1029,8 @@ int nand_check_erased_ecc_chunk(void *data, int datalen, + void *ecc, int ecclen, + void *extraoob, int extraooblen, + int threshold); ++ ++/* Free resources held by the NAND device */ ++void nand_cleanup(struct nand_chip *chip); ++ + #endif /* __LINUX_MTD_NAND_H */ +diff --git a/include/net/xfrm.h b/include/net/xfrm.h +index 89685c7bc7c0f..7a9c18deaa512 100644 +--- a/include/net/xfrm.h ++++ b/include/net/xfrm.h +@@ -1730,21 +1730,17 @@ static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay + static inline int xfrm_replay_clone(struct xfrm_state *x, + struct xfrm_state *orig) + { +- x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn), ++ ++ x->replay_esn = kmemdup(orig->replay_esn, ++ xfrm_replay_state_esn_len(orig->replay_esn), + GFP_KERNEL); + if (!x->replay_esn) + return -ENOMEM; +- +- x->replay_esn->bmp_len = orig->replay_esn->bmp_len; +- x->replay_esn->replay_window = orig->replay_esn->replay_window; +- +- x->preplay_esn = kmemdup(x->replay_esn, +- xfrm_replay_state_esn_len(x->replay_esn), ++ x->preplay_esn = kmemdup(orig->preplay_esn, ++ xfrm_replay_state_esn_len(orig->preplay_esn), + GFP_KERNEL); +- if (!x->preplay_esn) { +- kfree(x->replay_esn); ++ if (!x->preplay_esn) + return -ENOMEM; +- } + + return 0; + } +diff --git a/kernel/kmod.c b/kernel/kmod.c +index e4e5e98002fe3..3f3bbae4cec33 100644 +--- a/kernel/kmod.c ++++ b/kernel/kmod.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -222,6 +223,14 @@ static int call_usermodehelper_exec_async(void *data) + flush_signal_handlers(current, 1); + spin_unlock_irq(¤t->sighand->siglock); + ++ /* ++ * Initial kernel threads share ther FS with init, in order to ++ * get the init root directory. But we've now created a new ++ * thread that is going to execve a user process and has its own ++ * 'struct fs_struct'. Reset umask to the default. ++ */ ++ current->fs->umask = 0022; ++ + /* + * Our parent (unbound workqueue) runs with elevated scheduling + * priority. Avoid propagating that into the userspace child. +diff --git a/lib/fonts/font_10x18.c b/lib/fonts/font_10x18.c +index 6be72bb218ee4..87e904f550c15 100644 +--- a/lib/fonts/font_10x18.c ++++ b/lib/fonts/font_10x18.c +@@ -7,8 +7,8 @@ + + #define FONTDATAMAX 9216 + +-static const unsigned char fontdata_10x18[FONTDATAMAX] = { +- ++static struct font_data fontdata_10x18 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, 0x00, /* 0000000000 */ + 0x00, 0x00, /* 0000000000 */ +@@ -5128,8 +5128,7 @@ static const unsigned char fontdata_10x18[FONTDATAMAX] = { + 0x00, 0x00, /* 0000000000 */ + 0x00, 0x00, /* 0000000000 */ + 0x00, 0x00, /* 0000000000 */ +- +-}; ++} }; + + + const struct font_desc font_10x18 = { +@@ -5137,7 +5136,7 @@ const struct font_desc font_10x18 = { + .name = "10x18", + .width = 10, + .height = 18, +- .data = fontdata_10x18, ++ .data = fontdata_10x18.data, + #ifdef __sparc__ + .pref = 5, + #else +diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c +index b20620904d314..896ffa987c97b 100644 +--- a/lib/fonts/font_6x10.c ++++ b/lib/fonts/font_6x10.c +@@ -1,7 +1,9 @@ + #include + +-static const unsigned char fontdata_6x10[] = { ++#define FONTDATAMAX 2560 + ++static struct font_data fontdata_6x10 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +@@ -3073,14 +3075,13 @@ static const unsigned char fontdata_6x10[] = { + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +- +-}; ++} }; + + const struct font_desc font_6x10 = { + .idx = FONT6x10_IDX, + .name = "6x10", + .width = 6, + .height = 10, +- .data = fontdata_6x10, ++ .data = fontdata_6x10.data, + .pref = 0, + }; +diff --git a/lib/fonts/font_6x11.c b/lib/fonts/font_6x11.c +index 46e86e67aa6aa..eb46a59307d2e 100644 +--- a/lib/fonts/font_6x11.c ++++ b/lib/fonts/font_6x11.c +@@ -8,8 +8,8 @@ + + #define FONTDATAMAX (11*256) + +-static const unsigned char fontdata_6x11[FONTDATAMAX] = { +- ++static struct font_data fontdata_6x11 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +@@ -3337,8 +3337,7 @@ static const unsigned char fontdata_6x11[FONTDATAMAX] = { + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +- +-}; ++} }; + + + const struct font_desc font_vga_6x11 = { +@@ -3346,7 +3345,7 @@ const struct font_desc font_vga_6x11 = { + .name = "ProFont6x11", + .width = 6, + .height = 11, +- .data = fontdata_6x11, ++ .data = fontdata_6x11.data, + /* Try avoiding this font if possible unless on MAC */ + .pref = -2000, + }; +diff --git a/lib/fonts/font_7x14.c b/lib/fonts/font_7x14.c +index 3b7dbf9c060b3..c88b3bba001bd 100644 +--- a/lib/fonts/font_7x14.c ++++ b/lib/fonts/font_7x14.c +@@ -7,8 +7,8 @@ + + #define FONTDATAMAX 3584 + +-static const unsigned char fontdata_7x14[FONTDATAMAX] = { +- ++static struct font_data fontdata_7x14 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 0000000 */ + 0x00, /* 0000000 */ +@@ -4104,8 +4104,7 @@ static const unsigned char fontdata_7x14[FONTDATAMAX] = { + 0x00, /* 0000000 */ + 0x00, /* 0000000 */ + 0x00, /* 0000000 */ +- +-}; ++} }; + + + const struct font_desc font_7x14 = { +@@ -4113,6 +4112,6 @@ const struct font_desc font_7x14 = { + .name = "7x14", + .width = 7, + .height = 14, +- .data = fontdata_7x14, ++ .data = fontdata_7x14.data, + .pref = 0, + }; +diff --git a/lib/fonts/font_8x16.c b/lib/fonts/font_8x16.c +index 00a0c67a5c7d0..ba53e2643670b 100644 +--- a/lib/fonts/font_8x16.c ++++ b/lib/fonts/font_8x16.c +@@ -9,8 +9,8 @@ + + #define FONTDATAMAX 4096 + +-static const unsigned char fontdata_8x16[FONTDATAMAX] = { +- ++static struct font_data fontdata_8x16 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +@@ -4618,8 +4618,7 @@ static const unsigned char fontdata_8x16[FONTDATAMAX] = { + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +- +-}; ++} }; + + + const struct font_desc font_vga_8x16 = { +@@ -4627,7 +4626,7 @@ const struct font_desc font_vga_8x16 = { + .name = "VGA8x16", + .width = 8, + .height = 16, +- .data = fontdata_8x16, ++ .data = fontdata_8x16.data, + .pref = 0, + }; + EXPORT_SYMBOL(font_vga_8x16); +diff --git a/lib/fonts/font_8x8.c b/lib/fonts/font_8x8.c +index 9f56efe2cee72..4d28b81e8237c 100644 +--- a/lib/fonts/font_8x8.c ++++ b/lib/fonts/font_8x8.c +@@ -8,8 +8,8 @@ + + #define FONTDATAMAX 2048 + +-static const unsigned char fontdata_8x8[FONTDATAMAX] = { +- ++static struct font_data fontdata_8x8 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +@@ -2569,8 +2569,7 @@ static const unsigned char fontdata_8x8[FONTDATAMAX] = { + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +- +-}; ++} }; + + + const struct font_desc font_vga_8x8 = { +@@ -2578,6 +2577,6 @@ const struct font_desc font_vga_8x8 = { + .name = "VGA8x8", + .width = 8, + .height = 8, +- .data = fontdata_8x8, ++ .data = fontdata_8x8.data, + .pref = 0, + }; +diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c +index 639e31ae1100a..957398b762d38 100644 +--- a/lib/fonts/font_acorn_8x8.c ++++ b/lib/fonts/font_acorn_8x8.c +@@ -2,7 +2,10 @@ + + #include + +-static const unsigned char acorndata_8x8[] = { ++#define FONTDATAMAX 2048 ++ ++static struct font_data acorndata_8x8 = { ++{ 0, 0, FONTDATAMAX, 0 }, { + /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */ + /* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */ + /* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */ +@@ -259,14 +262,14 @@ static const unsigned char acorndata_8x8[] = { + /* FD */ 0x38, 0x04, 0x18, 0x20, 0x3c, 0x00, 0x00, 0x00, + /* FE */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, + /* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +-}; ++} }; + + const struct font_desc font_acorn_8x8 = { + .idx = ACORN8x8_IDX, + .name = "Acorn8x8", + .width = 8, + .height = 8, +- .data = acorndata_8x8, ++ .data = acorndata_8x8.data, + #ifdef CONFIG_ARCH_ACORN + .pref = 20, + #else +diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c +index 838caa1cfef70..1449876c6a270 100644 +--- a/lib/fonts/font_mini_4x6.c ++++ b/lib/fonts/font_mini_4x6.c +@@ -43,8 +43,8 @@ __END__; + + #define FONTDATAMAX 1536 + +-static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = { +- ++static struct font_data fontdata_mini_4x6 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /*{*/ + /* Char 0: ' ' */ + 0xee, /*= [*** ] */ +@@ -2145,14 +2145,14 @@ static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = { + 0xee, /*= [*** ] */ + 0x00, /*= [ ] */ + /*}*/ +-}; ++} }; + + const struct font_desc font_mini_4x6 = { + .idx = MINI4x6_IDX, + .name = "MINI4x6", + .width = 4, + .height = 6, +- .data = fontdata_mini_4x6, ++ .data = fontdata_mini_4x6.data, + .pref = 3, + }; + +diff --git a/lib/fonts/font_pearl_8x8.c b/lib/fonts/font_pearl_8x8.c +index dc6ad539ca4e4..4649314333bb0 100644 +--- a/lib/fonts/font_pearl_8x8.c ++++ b/lib/fonts/font_pearl_8x8.c +@@ -13,8 +13,8 @@ + + #define FONTDATAMAX 2048 + +-static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = { +- ++static struct font_data fontdata_pearl8x8 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +@@ -2574,14 +2574,13 @@ static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = { + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ +- +-}; ++} }; + + const struct font_desc font_pearl_8x8 = { + .idx = PEARL8x8_IDX, + .name = "PEARL8x8", + .width = 8, + .height = 8, +- .data = fontdata_pearl8x8, ++ .data = fontdata_pearl8x8.data, + .pref = 2, + }; +diff --git a/lib/fonts/font_sun12x22.c b/lib/fonts/font_sun12x22.c +index d3643853c33af..c6967cdf4207b 100644 +--- a/lib/fonts/font_sun12x22.c ++++ b/lib/fonts/font_sun12x22.c +@@ -2,8 +2,8 @@ + + #define FONTDATAMAX 11264 + +-static const unsigned char fontdata_sun12x22[FONTDATAMAX] = { +- ++static struct font_data fontdata_sun12x22 = { ++ { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, 0x00, /* 000000000000 */ + 0x00, 0x00, /* 000000000000 */ +@@ -6147,8 +6147,7 @@ static const unsigned char fontdata_sun12x22[FONTDATAMAX] = { + 0x00, 0x00, /* 000000000000 */ + 0x00, 0x00, /* 000000000000 */ + 0x00, 0x00, /* 000000000000 */ +- +-}; ++} }; + + + const struct font_desc font_sun_12x22 = { +@@ -6156,7 +6155,7 @@ const struct font_desc font_sun_12x22 = { + .name = "SUN12x22", + .width = 12, + .height = 22, +- .data = fontdata_sun12x22, ++ .data = fontdata_sun12x22.data, + #ifdef __sparc__ + .pref = 5, + #else +diff --git a/lib/fonts/font_sun8x16.c b/lib/fonts/font_sun8x16.c +index 268151325b83e..7d979e5788999 100644 +--- a/lib/fonts/font_sun8x16.c ++++ b/lib/fonts/font_sun8x16.c +@@ -2,7 +2,8 @@ + + #define FONTDATAMAX 4096 + +-static const unsigned char fontdata_sun8x16[FONTDATAMAX] = { ++static struct font_data fontdata_sun8x16 = { ++{ 0, 0, FONTDATAMAX, 0 }, { + /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, + /* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00, +@@ -259,14 +260,14 @@ static const unsigned char fontdata_sun8x16[FONTDATAMAX] = { + /* */ 0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* */ 0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00, + /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +-}; ++} }; + + const struct font_desc font_sun_8x16 = { + .idx = SUN8x16_IDX, + .name = "SUN8x16", + .width = 8, + .height = 16, +- .data = fontdata_sun8x16, ++ .data = fontdata_sun8x16.data, + #ifdef __sparc__ + .pref = 10, + #else +diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c +index f324a11244189..b349b8410ec80 100644 +--- a/net/netfilter/nf_conntrack_netlink.c ++++ b/net/netfilter/nf_conntrack_netlink.c +@@ -1022,6 +1022,8 @@ ctnetlink_parse_tuple(const struct nlattr * const cda[], + if (!tb[CTA_TUPLE_IP]) + return -EINVAL; + ++ if (l3num != NFPROTO_IPV4 && l3num != NFPROTO_IPV6) ++ return -EOPNOTSUPP; + tuple->src.l3num = l3num; + + err = ctnetlink_parse_tuple_ip(tb[CTA_TUPLE_IP], tuple); +diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c +index 91d43ab3a9610..ea615e53eab28 100644 +--- a/net/rxrpc/ar-key.c ++++ b/net/rxrpc/ar-key.c +@@ -897,7 +897,7 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen) + + _enter(""); + +- if (optlen <= 0 || optlen > PAGE_SIZE - 1) ++ if (optlen <= 0 || optlen > PAGE_SIZE - 1 || rx->securities) + return -EINVAL; + + description = kmalloc(optlen + 1, GFP_KERNEL); +@@ -1114,7 +1114,8 @@ static long rxrpc_read(const struct key *key, + break; + + default: /* we have a ticket we can't encode */ +- BUG(); ++ pr_err("Unsupported key token type (%u)\n", ++ token->security_index); + continue; + } + +@@ -1149,6 +1150,14 @@ static long rxrpc_read(const struct key *key, + goto fault; \ + xdr += (_l + 3) >> 2; \ + } while(0) ++#define ENCODE_BYTES(l, s) \ ++ do { \ ++ u32 _l = (l); \ ++ memcpy(xdr, (s), _l); \ ++ if (_l & 3) \ ++ memcpy((u8 *)xdr + _l, &zero, 4 - (_l & 3)); \ ++ xdr += (_l + 3) >> 2; \ ++ } while(0) + #define ENCODE64(x) \ + do { \ + __be64 y = cpu_to_be64(x); \ +@@ -1177,7 +1186,7 @@ static long rxrpc_read(const struct key *key, + case RXRPC_SECURITY_RXKAD: + ENCODE(token->kad->vice_id); + ENCODE(token->kad->kvno); +- ENCODE_DATA(8, token->kad->session_key); ++ ENCODE_BYTES(8, token->kad->session_key); + ENCODE(token->kad->start); + ENCODE(token->kad->expiry); + ENCODE(token->kad->primary_flag); +@@ -1227,7 +1236,6 @@ static long rxrpc_read(const struct key *key, + break; + + default: +- BUG(); + break; + } + +diff --git a/net/sctp/auth.c b/net/sctp/auth.c +index 1543e39f47c33..04cd87d26ed1b 100644 +--- a/net/sctp/auth.c ++++ b/net/sctp/auth.c +@@ -496,6 +496,7 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) + out_err: + /* Clean up any successful allocations */ + sctp_auth_destroy_hmacs(ep->auth_hmacs); ++ ep->auth_hmacs = NULL; + return -ENOMEM; + } + +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c +index 55de35c4434a8..95366e35ab134 100644 +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -3101,6 +3101,9 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) + if (err) + return err; + ++ if (key.idx < 0) ++ return -EINVAL; ++ + if (info->attrs[NL80211_ATTR_MAC]) + mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); + +diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c +index d3595f1d00f25..5bb5950d6276b 100644 +--- a/net/xfrm/xfrm_state.c ++++ b/net/xfrm/xfrm_state.c +@@ -742,7 +742,8 @@ static void xfrm_state_look_at(struct xfrm_policy *pol, struct xfrm_state *x, + */ + if (x->km.state == XFRM_STATE_VALID) { + if ((x->sel.family && +- !xfrm_selector_match(&x->sel, fl, x->sel.family)) || ++ (x->sel.family != family || ++ !xfrm_selector_match(&x->sel, fl, family))) || + !security_xfrm_state_pol_flow_match(x, pol, fl)) + return; + +@@ -755,7 +756,9 @@ static void xfrm_state_look_at(struct xfrm_policy *pol, struct xfrm_state *x, + *acq_in_progress = 1; + } else if (x->km.state == XFRM_STATE_ERROR || + x->km.state == XFRM_STATE_EXPIRED) { +- if (xfrm_selector_match(&x->sel, fl, x->sel.family) && ++ if ((!x->sel.family || ++ (x->sel.family == family && ++ xfrm_selector_match(&x->sel, fl, family))) && + security_xfrm_state_pol_flow_match(x, pol, fl)) + *error = -ESRCH; + } +@@ -791,7 +794,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, + tmpl->mode == x->props.mode && + tmpl->id.proto == x->id.proto && + (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) +- xfrm_state_look_at(pol, x, fl, encap_family, ++ xfrm_state_look_at(pol, x, fl, family, + &best, &acquire_in_progress, &error); + } + if (best || acquire_in_progress) +@@ -807,7 +810,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, + tmpl->mode == x->props.mode && + tmpl->id.proto == x->id.proto && + (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) +- xfrm_state_look_at(pol, x, fl, encap_family, ++ xfrm_state_look_at(pol, x, fl, family, + &best, &acquire_in_progress, &error); + } + +@@ -1207,7 +1210,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig) + x->tfcpad = orig->tfcpad; + x->replay_maxdiff = orig->replay_maxdiff; + x->replay_maxage = orig->replay_maxage; +- x->curlft.add_time = orig->curlft.add_time; ++ memcpy(&x->curlft, &orig->curlft, sizeof(x->curlft)); + x->km.state = orig->km.state; + x->km.seq = orig->km.seq; + x->replay = orig->replay; +diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c +index 4e64ba8163bb1..7d6dd799bbcdc 100644 +--- a/tools/perf/builtin-top.c ++++ b/tools/perf/builtin-top.c +@@ -626,7 +626,9 @@ repeat: + delay_msecs = top->delay_secs * 1000; + set_term_quiet_input(&save); + /* trash return*/ +- getc(stdin); ++ clearerr(stdin); ++ if (poll(&stdin_poll, 1, 0) > 0) ++ getc(stdin); + + while (!done) { + perf_top__print_sym_table(top); diff --git a/patch/kernel/rockpis-legacy/patch-4.4.239-240.patch b/patch/kernel/rockpis-legacy/patch-4.4.239-240.patch new file mode 100644 index 000000000..193704649 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.239-240.patch @@ -0,0 +1,555 @@ +diff --git a/Makefile b/Makefile +index 74072b5a958b2..69e7cd30e6465 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 239 ++SUBLEVEL = 240 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c +index 367b6661ee041..4dda526bd21b8 100644 +--- a/drivers/crypto/qat/qat_common/qat_algs.c ++++ b/drivers/crypto/qat/qat_common/qat_algs.c +@@ -822,6 +822,11 @@ static int qat_alg_aead_dec(struct aead_request *areq) + struct icp_qat_fw_la_bulk_req *msg; + int digst_size = crypto_aead_authsize(aead_tfm); + int ret, ctr = 0; ++ u32 cipher_len; ++ ++ cipher_len = areq->cryptlen - digst_size; ++ if (cipher_len % AES_BLOCK_SIZE != 0) ++ return -EINVAL; + + ret = qat_alg_sgl_to_bufl(ctx->inst, areq->src, areq->dst, qat_req); + if (unlikely(ret)) +@@ -836,7 +841,7 @@ static int qat_alg_aead_dec(struct aead_request *areq) + qat_req->req.comn_mid.src_data_addr = qat_req->buf.blp; + qat_req->req.comn_mid.dest_data_addr = qat_req->buf.bloutp; + cipher_param = (void *)&qat_req->req.serv_specif_rqpars; +- cipher_param->cipher_length = areq->cryptlen - digst_size; ++ cipher_param->cipher_length = cipher_len; + cipher_param->cipher_offset = areq->assoclen; + memcpy(cipher_param->u.cipher_IV_array, areq->iv, AES_BLOCK_SIZE); + auth_param = (void *)((uint8_t *)cipher_param + sizeof(*cipher_param)); +@@ -865,6 +870,9 @@ static int qat_alg_aead_enc(struct aead_request *areq) + uint8_t *iv = areq->iv; + int ret, ctr = 0; + ++ if (areq->cryptlen % AES_BLOCK_SIZE != 0) ++ return -EINVAL; ++ + ret = qat_alg_sgl_to_bufl(ctx->inst, areq->src, areq->dst, qat_req); + if (unlikely(ret)) + return ret; +diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c +index a2eb87d74656f..8a1440a573a33 100644 +--- a/drivers/media/usb/usbtv/usbtv-core.c ++++ b/drivers/media/usb/usbtv/usbtv-core.c +@@ -96,7 +96,8 @@ static int usbtv_probe(struct usb_interface *intf, + + usbtv_audio_fail: + /* we must not free at this point */ +- usb_get_dev(usbtv->udev); ++ v4l2_device_get(&usbtv->v4l2_dev); ++ /* this will undo the v4l2_device_get() */ + usbtv_video_free(usbtv); + + usbtv_video_fail: +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c +index 57001f8f727a3..6ed2959ce4dc0 100644 +--- a/drivers/spi/spi.c ++++ b/drivers/spi/spi.c +@@ -1917,13 +1917,13 @@ static int __unregister(struct device *dev, void *null) + */ + void spi_unregister_master(struct spi_master *master) + { ++ device_for_each_child(&master->dev, NULL, __unregister); ++ + if (master->queued) { + if (spi_destroy_queue(master)) + dev_err(&master->dev, "queue remove failed\n"); + } + +- device_for_each_child(&master->dev, NULL, __unregister); +- + mutex_lock(&board_lock); + list_del(&master->list); + mutex_unlock(&board_lock); +diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c +index 95e53cfd76a41..51f9a7800edf5 100644 +--- a/drivers/staging/comedi/drivers/vmk80xx.c ++++ b/drivers/staging/comedi/drivers/vmk80xx.c +@@ -676,6 +676,9 @@ static int vmk80xx_find_usb_endpoints(struct comedi_device *dev) + if (!devpriv->ep_rx || !devpriv->ep_tx) + return -ENODEV; + ++ if (!usb_endpoint_maxp(devpriv->ep_rx) || !usb_endpoint_maxp(devpriv->ep_tx)) ++ return -EINVAL; ++ + return 0; + } + +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index 25e76d4c15054..5b42b8d760cb4 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -1032,6 +1032,11 @@ static const struct usb_device_id id_table_combined[] = { + /* U-Blox devices */ + { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ZED_PID) }, + { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ODIN_PID) }, ++ /* FreeCalypso USB adapters */ ++ { USB_DEVICE(FTDI_VID, FTDI_FALCONIA_JTAG_BUF_PID), ++ .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, ++ { USB_DEVICE(FTDI_VID, FTDI_FALCONIA_JTAG_UNBUF_PID), ++ .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, + { } /* Terminating entry */ + }; + +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h +index c33e06752b5f0..f3302516a1e4f 100644 +--- a/drivers/usb/serial/ftdi_sio_ids.h ++++ b/drivers/usb/serial/ftdi_sio_ids.h +@@ -38,6 +38,13 @@ + + #define FTDI_LUMEL_PD12_PID 0x6002 + ++/* ++ * Custom USB adapters made by Falconia Partners LLC ++ * for FreeCalypso project, ID codes allocated to Falconia by FTDI. ++ */ ++#define FTDI_FALCONIA_JTAG_BUF_PID 0x7150 ++#define FTDI_FALCONIA_JTAG_UNBUF_PID 0x7151 ++ + /* Sienna Serial Interface by Secyourit GmbH */ + #define FTDI_SIENNA_PID 0x8348 + +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c +index 8cff50ef4fd14..5017d37afe392 100644 +--- a/drivers/usb/serial/option.c ++++ b/drivers/usb/serial/option.c +@@ -529,6 +529,7 @@ static void option_instat_callback(struct urb *urb); + /* Cellient products */ + #define CELLIENT_VENDOR_ID 0x2692 + #define CELLIENT_PRODUCT_MEN200 0x9005 ++#define CELLIENT_PRODUCT_MPL200 0x9025 + + /* Hyundai Petatel Inc. products */ + #define PETATEL_VENDOR_ID 0x1ff4 +@@ -1171,6 +1172,8 @@ static const struct usb_device_id option_ids[] = { + .driver_info = NCTRL(2) | RSVD(3) }, + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1053, 0xff), /* Telit FN980 (ECM) */ + .driver_info = NCTRL(0) | RSVD(1) }, ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1054, 0xff), /* Telit FT980-KS */ ++ .driver_info = NCTRL(2) | RSVD(3) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), + .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), +@@ -1967,6 +1970,8 @@ static const struct usb_device_id option_ids[] = { + { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) }, + { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) }, + { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, ++ { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MPL200), ++ .driver_info = RSVD(1) | RSVD(4) }, + { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600A) }, + { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600E) }, + { USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, TPLINK_PRODUCT_LTE, 0xff, 0x00, 0x00) }, /* TP-Link LTE Module */ +diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c +index 4fcded2971d1d..bf5533d6d83bd 100644 +--- a/drivers/usb/serial/pl2303.c ++++ b/drivers/usb/serial/pl2303.c +@@ -89,6 +89,7 @@ static const struct usb_device_id id_table[] = { + { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, + { USB_DEVICE(HP_VENDOR_ID, HP_LD220TA_PRODUCT_ID) }, + { USB_DEVICE(HP_VENDOR_ID, HP_LD381_PRODUCT_ID) }, ++ { USB_DEVICE(HP_VENDOR_ID, HP_LD381GC_PRODUCT_ID) }, + { USB_DEVICE(HP_VENDOR_ID, HP_LD960_PRODUCT_ID) }, + { USB_DEVICE(HP_VENDOR_ID, HP_LD960TA_PRODUCT_ID) }, + { USB_DEVICE(HP_VENDOR_ID, HP_LCM220_PRODUCT_ID) }, +diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h +index 54d2fb974a418..9d27c076f477e 100644 +--- a/drivers/usb/serial/pl2303.h ++++ b/drivers/usb/serial/pl2303.h +@@ -125,6 +125,7 @@ + + /* Hewlett-Packard POS Pole Displays */ + #define HP_VENDOR_ID 0x03f0 ++#define HP_LD381GC_PRODUCT_ID 0x0183 + #define HP_LM920_PRODUCT_ID 0x026b + #define HP_TD620_PRODUCT_ID 0x0956 + #define HP_LD960_PRODUCT_ID 0x0b39 +diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c +index 60ba35087d126..cfb4691d92741 100644 +--- a/fs/reiserfs/inode.c ++++ b/fs/reiserfs/inode.c +@@ -1553,11 +1553,7 @@ void reiserfs_read_locked_inode(struct inode *inode, + * set version 1, version 2 could be used too, because stat data + * key is the same in both versions + */ +- key.version = KEY_FORMAT_3_5; +- key.on_disk_key.k_dir_id = dirino; +- key.on_disk_key.k_objectid = inode->i_ino; +- key.on_disk_key.k_offset = 0; +- key.on_disk_key.k_type = 0; ++ _make_cpu_key(&key, KEY_FORMAT_3_5, dirino, inode->i_ino, 0, 0, 3); + + /* look for the object's stat data */ + retval = search_item(inode->i_sb, &key, &path_to_sd); +diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c +index d424b3d4bf3b4..92d39cbc2d64d 100644 +--- a/fs/reiserfs/xattr.c ++++ b/fs/reiserfs/xattr.c +@@ -656,6 +656,13 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer, + if (get_inode_sd_version(inode) == STAT_DATA_V1) + return -EOPNOTSUPP; + ++ /* ++ * priv_root needn't be initialized during mount so allow initial ++ * lookups to succeed. ++ */ ++ if (!REISERFS_SB(inode->i_sb)->priv_root) ++ return 0; ++ + dentry = xattr_lookup(inode, name, XATTR_REPLACE); + if (IS_ERR(dentry)) { + err = PTR_ERR(dentry); +diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h +index 7c0c83dfe86e3..5aaf6cdb121a1 100644 +--- a/include/net/bluetooth/hci_core.h ++++ b/include/net/bluetooth/hci_core.h +@@ -1235,16 +1235,34 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) + conn->security_cfm_cb(conn, status); + } + +-static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, +- __u8 encrypt) ++static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) + { + struct hci_cb *cb; ++ __u8 encrypt; ++ ++ if (conn->state == BT_CONFIG) { ++ if (!status) ++ conn->state = BT_CONNECTED; + +- if (conn->sec_level == BT_SECURITY_SDP) +- conn->sec_level = BT_SECURITY_LOW; ++ hci_connect_cfm(conn, status); ++ hci_conn_drop(conn); ++ return; ++ } + +- if (conn->pending_sec_level > conn->sec_level) +- conn->sec_level = conn->pending_sec_level; ++ if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags)) ++ encrypt = 0x00; ++ else if (test_bit(HCI_CONN_AES_CCM, &conn->flags)) ++ encrypt = 0x02; ++ else ++ encrypt = 0x01; ++ ++ if (!status) { ++ if (conn->sec_level == BT_SECURITY_SDP) ++ conn->sec_level = BT_SECURITY_LOW; ++ ++ if (conn->pending_sec_level > conn->sec_level) ++ conn->sec_level = conn->pending_sec_level; ++ } + + mutex_lock(&hci_cb_list_lock); + list_for_each_entry(cb, &hci_cb_list, list) { +diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c +index 5f123c3320a7b..8f918155685db 100644 +--- a/net/bluetooth/a2mp.c ++++ b/net/bluetooth/a2mp.c +@@ -233,6 +233,9 @@ static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, + struct a2mp_info_req req; + + found = true; ++ ++ memset(&req, 0, sizeof(req)); ++ + req.id = cl->id; + a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), + sizeof(req), &req); +@@ -312,6 +315,8 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, + if (!hdev || hdev->dev_type != HCI_AMP) { + struct a2mp_info_rsp rsp; + ++ memset(&rsp, 0, sizeof(rsp)); ++ + rsp.id = req->id; + rsp.status = A2MP_STATUS_INVALID_CTRL_ID; + +@@ -355,6 +360,8 @@ static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, + if (!ctrl) + return -ENOMEM; + ++ memset(&req, 0, sizeof(req)); ++ + req.id = rsp->id; + a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), + &req); +@@ -383,6 +390,8 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, + struct a2mp_amp_assoc_rsp rsp; + rsp.id = req->id; + ++ memset(&rsp, 0, sizeof(rsp)); ++ + if (tmp) { + rsp.status = A2MP_STATUS_COLLISION_OCCURED; + amp_mgr_put(tmp); +@@ -471,7 +480,6 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, + struct a2mp_cmd *hdr) + { + struct a2mp_physlink_req *req = (void *) skb->data; +- + struct a2mp_physlink_rsp rsp; + struct hci_dev *hdev; + struct hci_conn *hcon; +@@ -482,6 +490,8 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, + + BT_DBG("local_id %d, remote_id %d", req->local_id, req->remote_id); + ++ memset(&rsp, 0, sizeof(rsp)); ++ + rsp.local_id = req->remote_id; + rsp.remote_id = req->local_id; + +@@ -560,6 +570,8 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, + + BT_DBG("local_id %d remote_id %d", req->local_id, req->remote_id); + ++ memset(&rsp, 0, sizeof(rsp)); ++ + rsp.local_id = req->remote_id; + rsp.remote_id = req->local_id; + rsp.status = A2MP_STATUS_SUCCESS; +@@ -682,6 +694,8 @@ static int a2mp_chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) + if (err) { + struct a2mp_cmd_rej rej; + ++ memset(&rej, 0, sizeof(rej)); ++ + rej.reason = cpu_to_le16(0); + hdr = (void *) skb->data; + +@@ -905,6 +919,8 @@ void a2mp_send_getinfo_rsp(struct hci_dev *hdev) + + BT_DBG("%s mgr %p", hdev->name, mgr); + ++ memset(&rsp, 0, sizeof(rsp)); ++ + rsp.id = hdev->id; + rsp.status = A2MP_STATUS_INVALID_CTRL_ID; + +@@ -1002,6 +1018,8 @@ void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status) + if (!mgr) + return; + ++ memset(&rsp, 0, sizeof(rsp)); ++ + hs_hcon = hci_conn_hash_lookup_state(hdev, AMP_LINK, BT_CONNECT); + if (!hs_hcon) { + rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION; +@@ -1034,6 +1052,8 @@ void a2mp_discover_amp(struct l2cap_chan *chan) + + mgr->bredr_chan = chan; + ++ memset(&req, 0, sizeof(req)); ++ + req.mtu = cpu_to_le16(L2CAP_A2MP_DEFAULT_MTU); + req.ext_feat = 0; + a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); +diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c +index 114bcf6ea9168..2c94e3cd3545f 100644 +--- a/net/bluetooth/hci_conn.c ++++ b/net/bluetooth/hci_conn.c +@@ -1173,6 +1173,23 @@ int hci_conn_check_link_mode(struct hci_conn *conn) + return 0; + } + ++ /* AES encryption is required for Level 4: ++ * ++ * BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C ++ * page 1319: ++ * ++ * 128-bit equivalent strength for link and encryption keys ++ * required using FIPS approved algorithms (E0 not allowed, ++ * SAFER+ not allowed, and P-192 not allowed; encryption key ++ * not shortened) ++ */ ++ if (conn->sec_level == BT_SECURITY_FIPS && ++ !test_bit(HCI_CONN_AES_CCM, &conn->flags)) { ++ bt_dev_err(conn->hdev, ++ "Invalid security: Missing AES-CCM usage"); ++ return 0; ++ } ++ + if (hci_conn_ssp_enabled(conn) && + !test_bit(HCI_CONN_ENCRYPT, &conn->flags)) + return 0; +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c +index 03319ab8a7c6e..7cee89fddcd50 100644 +--- a/net/bluetooth/hci_event.c ++++ b/net/bluetooth/hci_event.c +@@ -1133,6 +1133,9 @@ static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr, + { + struct discovery_state *d = &hdev->discovery; + ++ if (len > HCI_MAX_AD_LENGTH) ++ return; ++ + bacpy(&d->last_adv_addr, bdaddr); + d->last_adv_addr_type = bdaddr_type; + d->last_adv_rssi = rssi; +@@ -2479,7 +2482,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) + &cp); + } else { + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); +- hci_encrypt_cfm(conn, ev->status, 0x00); ++ hci_encrypt_cfm(conn, ev->status); + } + } + +@@ -2565,22 +2568,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status, + conn->enc_key_size = rp->key_size; + } + +- if (conn->state == BT_CONFIG) { +- conn->state = BT_CONNECTED; +- hci_connect_cfm(conn, 0); +- hci_conn_drop(conn); +- } else { +- u8 encrypt; +- +- if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags)) +- encrypt = 0x00; +- else if (test_bit(HCI_CONN_AES_CCM, &conn->flags)) +- encrypt = 0x02; +- else +- encrypt = 0x01; +- +- hci_encrypt_cfm(conn, 0, encrypt); +- } ++ hci_encrypt_cfm(conn, 0); + + unlock: + hci_dev_unlock(hdev); +@@ -2627,24 +2615,20 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) + + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); + ++ /* Check link security requirements are met */ ++ if (!hci_conn_check_link_mode(conn)) ++ ev->status = HCI_ERROR_AUTH_FAILURE; ++ + if (ev->status && conn->state == BT_CONNECTED) { ++ /* Notify upper layers so they can cleanup before ++ * disconnecting. ++ */ ++ hci_encrypt_cfm(conn, ev->status); + hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); + hci_conn_drop(conn); + goto unlock; + } + +- /* In Secure Connections Only mode, do not allow any connections +- * that are not encrypted with AES-CCM using a P-256 authenticated +- * combination key. +- */ +- if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && +- (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || +- conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { +- hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); +- hci_conn_drop(conn); +- goto unlock; +- } +- + /* Try reading the encryption key size for encrypted ACL links */ + if (!ev->status && ev->encrypt && conn->type == ACL_LINK) { + struct hci_cp_read_enc_key_size cp; +@@ -2674,14 +2658,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) + } + + notify: +- if (conn->state == BT_CONFIG) { +- if (!ev->status) +- conn->state = BT_CONNECTED; +- +- hci_connect_cfm(conn, ev->status); +- hci_conn_drop(conn); +- } else +- hci_encrypt_cfm(conn, ev->status, ev->encrypt); ++ hci_encrypt_cfm(conn, ev->status); + + unlock: + hci_dev_unlock(hdev); +@@ -4752,6 +4729,11 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, + u32 flags; + u8 *ptr, real_len; + ++ if (len > HCI_MAX_AD_LENGTH) { ++ pr_err_ratelimited("legacy adv larger than 31 bytes"); ++ return; ++ } ++ + /* Find the end of the data in case the report contains padded zero + * bytes at the end causing an invalid length value. + * +@@ -4812,7 +4794,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, + */ + conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type, + direct_addr); +- if (conn && type == LE_ADV_IND) { ++ if (conn && type == LE_ADV_IND && len <= HCI_MAX_AD_LENGTH) { + /* Store report for later inclusion by + * mgmt_device_connected + */ +@@ -4937,10 +4919,14 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb) + struct hci_ev_le_advertising_info *ev = ptr; + s8 rssi; + +- rssi = ev->data[ev->length]; +- process_adv_report(hdev, ev->evt_type, &ev->bdaddr, +- ev->bdaddr_type, NULL, 0, rssi, +- ev->data, ev->length); ++ if (ev->length <= HCI_MAX_AD_LENGTH) { ++ rssi = ev->data[ev->length]; ++ process_adv_report(hdev, ev->evt_type, &ev->bdaddr, ++ ev->bdaddr_type, NULL, 0, rssi, ++ ev->data, ev->length); ++ } else { ++ bt_dev_err(hdev, "Dropping invalid advertising data"); ++ } + + ptr += sizeof(*ev) + ev->length + 1; + } +diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c +index ecc3da6a14a18..ee761fb095594 100644 +--- a/net/bluetooth/mgmt.c ++++ b/net/bluetooth/mgmt.c +@@ -628,7 +628,8 @@ static u32 get_supported_settings(struct hci_dev *hdev) + + if (lmp_ssp_capable(hdev)) { + settings |= MGMT_SETTING_SSP; +- settings |= MGMT_SETTING_HS; ++ if (IS_ENABLED(CONFIG_BT_HS)) ++ settings |= MGMT_SETTING_HS; + } + + if (lmp_sc_capable(hdev)) +@@ -2281,6 +2282,10 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data, + + BT_DBG("request for %s", hdev->name); + ++ if (!IS_ENABLED(CONFIG_BT_HS)) ++ return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, ++ MGMT_STATUS_NOT_SUPPORTED); ++ + status = mgmt_bredr_support(hdev); + if (status) + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, diff --git a/patch/kernel/rockpis-legacy/patch-4.4.240-241.patch b/patch/kernel/rockpis-legacy/patch-4.4.240-241.patch new file mode 100644 index 000000000..5bea12883 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.240-241.patch @@ -0,0 +1,3167 @@ +diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt +index 21ad4f3cece89..eac939abe6c4c 100644 +--- a/Documentation/networking/ip-sysctl.txt ++++ b/Documentation/networking/ip-sysctl.txt +@@ -868,12 +868,14 @@ icmp_ratelimit - INTEGER + icmp_msgs_per_sec - INTEGER + Limit maximal number of ICMP packets sent per second from this host. + Only messages whose type matches icmp_ratemask (see below) are +- controlled by this limit. ++ controlled by this limit. For security reasons, the precise count ++ of messages per second is randomized. + Default: 1000 + + icmp_msgs_burst - INTEGER + icmp_msgs_per_sec controls number of ICMP packets sent per second, + while icmp_msgs_burst controls the burst size of these packets. ++ For security reasons, the precise burst size is randomized. + Default: 50 + + icmp_ratemask - INTEGER +diff --git a/Makefile b/Makefile +index 69e7cd30e6465..f475808037540 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 240 ++SUBLEVEL = 241 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c +index 493692d838c67..0b6f8a93d8c60 100644 +--- a/arch/arm/mm/cache-l2x0.c ++++ b/arch/arm/mm/cache-l2x0.c +@@ -1228,20 +1228,28 @@ static void __init l2c310_of_parse(const struct device_node *np, + + ret = of_property_read_u32(np, "prefetch-data", &val); + if (ret == 0) { +- if (val) ++ if (val) { + prefetch |= L310_PREFETCH_CTRL_DATA_PREFETCH; +- else ++ *aux_val |= L310_PREFETCH_CTRL_DATA_PREFETCH; ++ } else { + prefetch &= ~L310_PREFETCH_CTRL_DATA_PREFETCH; ++ *aux_val &= ~L310_PREFETCH_CTRL_DATA_PREFETCH; ++ } ++ *aux_mask &= ~L310_PREFETCH_CTRL_DATA_PREFETCH; + } else if (ret != -EINVAL) { + pr_err("L2C-310 OF prefetch-data property value is missing\n"); + } + + ret = of_property_read_u32(np, "prefetch-instr", &val); + if (ret == 0) { +- if (val) ++ if (val) { + prefetch |= L310_PREFETCH_CTRL_INSTR_PREFETCH; +- else ++ *aux_val |= L310_PREFETCH_CTRL_INSTR_PREFETCH; ++ } else { + prefetch &= ~L310_PREFETCH_CTRL_INSTR_PREFETCH; ++ *aux_val &= ~L310_PREFETCH_CTRL_INSTR_PREFETCH; ++ } ++ *aux_mask &= ~L310_PREFETCH_CTRL_INSTR_PREFETCH; + } else if (ret != -EINVAL) { + pr_err("L2C-310 OF prefetch-instr property value is missing\n"); + } +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +index 172402cc1a0f5..ae2cbbdb634e4 100644 +--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi ++++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +@@ -191,7 +191,7 @@ + }; + + i2c0: i2c@ff020000 { +- compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10"; ++ compatible = "cdns,i2c-r1p14"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 17 4>; +@@ -202,7 +202,7 @@ + }; + + i2c1: i2c@ff030000 { +- compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10"; ++ compatible = "cdns,i2c-r1p14"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 18 4>; +diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h +index ca372bbc0ffee..dd262f09a99ed 100644 +--- a/arch/powerpc/include/asm/reg.h ++++ b/arch/powerpc/include/asm/reg.h +@@ -647,7 +647,7 @@ + #define THRM1_TIN (1 << 31) + #define THRM1_TIV (1 << 30) + #define THRM1_THRES(x) ((x&0x7f)<<23) +-#define THRM3_SITV(x) ((x&0x3fff)<<1) ++#define THRM3_SITV(x) ((x & 0x1fff) << 1) + #define THRM1_TID (1<<2) + #define THRM1_TIE (1<<1) + #define THRM1_V (1<<0) +diff --git a/arch/powerpc/kernel/tau_6xx.c b/arch/powerpc/kernel/tau_6xx.c +index a753b72efbc0c..70c9d134a9d44 100644 +--- a/arch/powerpc/kernel/tau_6xx.c ++++ b/arch/powerpc/kernel/tau_6xx.c +@@ -37,8 +37,6 @@ static struct tau_temp + + struct timer_list tau_timer; + +-#undef DEBUG +- + /* TODO: put these in a /proc interface, with some sanity checks, and maybe + * dynamic adjustment to minimize # of interrupts */ + /* configurable values for step size and how much to expand the window when +@@ -71,47 +69,33 @@ void set_thresholds(unsigned long cpu) + + void TAUupdate(int cpu) + { +- unsigned thrm; +- +-#ifdef DEBUG +- printk("TAUupdate "); +-#endif ++ u32 thrm; ++ u32 bits = THRM1_TIV | THRM1_TIN | THRM1_V; + + /* if both thresholds are crossed, the step_sizes cancel out + * and the window winds up getting expanded twice. */ +- if((thrm = mfspr(SPRN_THRM1)) & THRM1_TIV){ /* is valid? */ +- if(thrm & THRM1_TIN){ /* crossed low threshold */ +- if (tau[cpu].low >= step_size){ +- tau[cpu].low -= step_size; +- tau[cpu].high -= (step_size - window_expand); +- } +- tau[cpu].grew = 1; +-#ifdef DEBUG +- printk("low threshold crossed "); +-#endif ++ thrm = mfspr(SPRN_THRM1); ++ if ((thrm & bits) == bits) { ++ mtspr(SPRN_THRM1, 0); ++ ++ if (tau[cpu].low >= step_size) { ++ tau[cpu].low -= step_size; ++ tau[cpu].high -= (step_size - window_expand); + } ++ tau[cpu].grew = 1; ++ pr_debug("%s: low threshold crossed\n", __func__); + } +- if((thrm = mfspr(SPRN_THRM2)) & THRM1_TIV){ /* is valid? */ +- if(thrm & THRM1_TIN){ /* crossed high threshold */ +- if (tau[cpu].high <= 127-step_size){ +- tau[cpu].low += (step_size - window_expand); +- tau[cpu].high += step_size; +- } +- tau[cpu].grew = 1; +-#ifdef DEBUG +- printk("high threshold crossed "); +-#endif ++ thrm = mfspr(SPRN_THRM2); ++ if ((thrm & bits) == bits) { ++ mtspr(SPRN_THRM2, 0); ++ ++ if (tau[cpu].high <= 127 - step_size) { ++ tau[cpu].low += (step_size - window_expand); ++ tau[cpu].high += step_size; + } ++ tau[cpu].grew = 1; ++ pr_debug("%s: high threshold crossed\n", __func__); + } +- +-#ifdef DEBUG +- printk("grew = %d\n", tau[cpu].grew); +-#endif +- +-#ifndef CONFIG_TAU_INT /* tau_timeout will do this if not using interrupts */ +- set_thresholds(cpu); +-#endif +- + } + + #ifdef CONFIG_TAU_INT +@@ -136,18 +120,18 @@ void TAUException(struct pt_regs * regs) + static void tau_timeout(void * info) + { + int cpu; +- unsigned long flags; + int size; + int shrink; + +- /* disabling interrupts *should* be okay */ +- local_irq_save(flags); + cpu = smp_processor_id(); + + #ifndef CONFIG_TAU_INT + TAUupdate(cpu); + #endif + ++ /* Stop thermal sensor comparisons and interrupts */ ++ mtspr(SPRN_THRM3, 0); ++ + size = tau[cpu].high - tau[cpu].low; + if (size > min_window && ! tau[cpu].grew) { + /* do an exponential shrink of half the amount currently over size */ +@@ -169,22 +153,12 @@ static void tau_timeout(void * info) + + set_thresholds(cpu); + +- /* +- * Do the enable every time, since otherwise a bunch of (relatively) +- * complex sleep code needs to be added. One mtspr every time +- * tau_timeout is called is probably not a big deal. +- * +- * Enable thermal sensor and set up sample interval timer +- * need 20 us to do the compare.. until a nice 'cpu_speed' function +- * call is implemented, just assume a 500 mhz clock. It doesn't really +- * matter if we take too long for a compare since it's all interrupt +- * driven anyway. +- * +- * use a extra long time.. (60 us @ 500 mhz) ++ /* Restart thermal sensor comparisons and interrupts. ++ * The "PowerPC 740 and PowerPC 750 Microprocessor Datasheet" ++ * recommends that "the maximum value be set in THRM3 under all ++ * conditions." + */ +- mtspr(SPRN_THRM3, THRM3_SITV(500*60) | THRM3_E); +- +- local_irq_restore(flags); ++ mtspr(SPRN_THRM3, THRM3_SITV(0x1fff) | THRM3_E); + } + + static void tau_timeout_smp(unsigned long unused) +diff --git a/arch/powerpc/perf/hv-gpci-requests.h b/arch/powerpc/perf/hv-gpci-requests.h +index acd17648cd188..5ea24d16a74a1 100644 +--- a/arch/powerpc/perf/hv-gpci-requests.h ++++ b/arch/powerpc/perf/hv-gpci-requests.h +@@ -94,7 +94,7 @@ REQUEST(__field(0, 8, partition_id) + + #define REQUEST_NAME system_performance_capabilities + #define REQUEST_NUM 0x40 +-#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" ++#define REQUEST_IDX_KIND "starting_index=0xffffffff" + #include I(REQUEST_BEGIN) + REQUEST(__field(0, 1, perf_collect_privileged) + __field(0x1, 1, capability_mask) +@@ -222,7 +222,7 @@ REQUEST(__field(0, 2, partition_id) + + #define REQUEST_NAME system_hypervisor_times + #define REQUEST_NUM 0xF0 +-#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" ++#define REQUEST_IDX_KIND "starting_index=0xffffffff" + #include I(REQUEST_BEGIN) + REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors) + __count(0x8, 8, time_spent_processing_virtual_processor_timers) +@@ -233,7 +233,7 @@ REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors) + + #define REQUEST_NAME system_tlbie_count_and_time + #define REQUEST_NUM 0xF4 +-#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" ++#define REQUEST_IDX_KIND "starting_index=0xffffffff" + #include I(REQUEST_BEGIN) + REQUEST(__count(0, 8, tlbie_instructions_issued) + /* +diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig +index b7f9c408bf24f..0a0281a21ea50 100644 +--- a/arch/powerpc/platforms/Kconfig ++++ b/arch/powerpc/platforms/Kconfig +@@ -242,7 +242,7 @@ config TAU + temp is actually what /proc/cpuinfo says it is. + + config TAU_INT +- bool "Interrupt driven TAU driver (DANGEROUS)" ++ bool "Interrupt driven TAU driver (EXPERIMENTAL)" + depends on TAU + ---help--- + The TAU supports an interrupt driven mode which causes an interrupt +@@ -250,12 +250,7 @@ config TAU_INT + to get notified the temp has exceeded a range. With this option off, + a timer is used to re-check the temperature periodically. + +- However, on some cpus it appears that the TAU interrupt hardware +- is buggy and can cause a situation which would lead unexplained hard +- lockups. +- +- Unless you are extending the TAU driver, or enjoy kernel/hardware +- debugging, leave this option off. ++ If in doubt, say N here. + + config TAU_AVERAGE + bool "Average high and low temp" +diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c +index 4c827826c05eb..e21e2c0af69d2 100644 +--- a/arch/powerpc/platforms/powernv/opal-dump.c ++++ b/arch/powerpc/platforms/powernv/opal-dump.c +@@ -319,15 +319,14 @@ static ssize_t dump_attr_read(struct file *filep, struct kobject *kobj, + return count; + } + +-static struct dump_obj *create_dump_obj(uint32_t id, size_t size, +- uint32_t type) ++static void create_dump_obj(uint32_t id, size_t size, uint32_t type) + { + struct dump_obj *dump; + int rc; + + dump = kzalloc(sizeof(*dump), GFP_KERNEL); + if (!dump) +- return NULL; ++ return; + + dump->kobj.kset = dump_kset; + +@@ -347,21 +346,39 @@ static struct dump_obj *create_dump_obj(uint32_t id, size_t size, + rc = kobject_add(&dump->kobj, NULL, "0x%x-0x%x", type, id); + if (rc) { + kobject_put(&dump->kobj); +- return NULL; ++ return; + } + ++ /* ++ * As soon as the sysfs file for this dump is created/activated there is ++ * a chance the opal_errd daemon (or any userspace) might read and ++ * acknowledge the dump before kobject_uevent() is called. If that ++ * happens then there is a potential race between ++ * dump_ack_store->kobject_put() and kobject_uevent() which leads to a ++ * use-after-free of a kernfs object resulting in a kernel crash. ++ * ++ * To avoid that, we need to take a reference on behalf of the bin file, ++ * so that our reference remains valid while we call kobject_uevent(). ++ * We then drop our reference before exiting the function, leaving the ++ * bin file to drop the last reference (if it hasn't already). ++ */ ++ ++ /* Take a reference for the bin file */ ++ kobject_get(&dump->kobj); + rc = sysfs_create_bin_file(&dump->kobj, &dump->dump_attr); +- if (rc) { ++ if (rc == 0) { ++ kobject_uevent(&dump->kobj, KOBJ_ADD); ++ ++ pr_info("%s: New platform dump. ID = 0x%x Size %u\n", ++ __func__, dump->id, dump->size); ++ } else { ++ /* Drop reference count taken for bin file */ + kobject_put(&dump->kobj); +- return NULL; + } + +- pr_info("%s: New platform dump. ID = 0x%x Size %u\n", +- __func__, dump->id, dump->size); +- +- kobject_uevent(&dump->kobj, KOBJ_ADD); +- +- return dump; ++ /* Drop our reference */ ++ kobject_put(&dump->kobj); ++ return; + } + + static irqreturn_t process_dump(int irq, void *data) +diff --git a/arch/powerpc/platforms/pseries/rng.c b/arch/powerpc/platforms/pseries/rng.c +index 31ca557af60bc..262b8c5e1b9d0 100644 +--- a/arch/powerpc/platforms/pseries/rng.c ++++ b/arch/powerpc/platforms/pseries/rng.c +@@ -40,6 +40,7 @@ static __init int rng_init(void) + + ppc_md.get_random_seed = pseries_get_random_long; + ++ of_node_put(dn); + return 0; + } + machine_subsys_initcall(pseries, rng_init); +diff --git a/arch/powerpc/sysdev/xics/icp-hv.c b/arch/powerpc/sysdev/xics/icp-hv.c +index c1917cf67c3de..3205e64c452bd 100644 +--- a/arch/powerpc/sysdev/xics/icp-hv.c ++++ b/arch/powerpc/sysdev/xics/icp-hv.c +@@ -179,6 +179,7 @@ int icp_hv_init(void) + + icp_ops = &icp_hv_ops; + ++ of_node_put(np); + return 0; + } + +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c +index 466028623e1a0..0c1e249a7ab69 100644 +--- a/arch/x86/kvm/emulate.c ++++ b/arch/x86/kvm/emulate.c +@@ -3524,7 +3524,7 @@ static int em_rdpid(struct x86_emulate_ctxt *ctxt) + u64 tsc_aux = 0; + + if (ctxt->ops->get_msr(ctxt, MSR_TSC_AUX, &tsc_aux)) +- return emulate_gp(ctxt, 0); ++ return emulate_ud(ctxt); + ctxt->dst.val = tsc_aux; + return X86EMUL_CONTINUE; + } +diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c +index 0f1c6fc3ddd88..47770ccab6d77 100644 +--- a/arch/x86/mm/dump_pagetables.c ++++ b/arch/x86/mm/dump_pagetables.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -407,6 +408,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, + } else + note_page(m, &st, __pgprot(0), 1); + ++ cond_resched(); + start++; + } + +diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c +index 57e6c45724e73..1930a1d1a1892 100644 +--- a/drivers/cpufreq/powernv-cpufreq.c ++++ b/drivers/cpufreq/powernv-cpufreq.c +@@ -410,12 +410,15 @@ static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb, + unsigned long action, void *unused) + { + int cpu; +- struct cpufreq_policy cpu_policy; ++ struct cpufreq_policy *cpu_policy; + + rebooting = true; + for_each_online_cpu(cpu) { +- cpufreq_get_policy(&cpu_policy, cpu); +- powernv_cpufreq_target_index(&cpu_policy, get_nominal_index()); ++ cpu_policy = cpufreq_cpu_get(cpu); ++ if (!cpu_policy) ++ continue; ++ powernv_cpufreq_target_index(cpu_policy, get_nominal_index()); ++ cpufreq_cpu_put(cpu_policy); + } + + return NOTIFY_DONE; +diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c +index 8f27903532812..13657105cfb93 100644 +--- a/drivers/crypto/ixp4xx_crypto.c ++++ b/drivers/crypto/ixp4xx_crypto.c +@@ -533,7 +533,7 @@ static void release_ixp_crypto(struct device *dev) + + if (crypt_virt) { + dma_free_coherent(dev, +- NPE_QLEN_TOTAL * sizeof( struct crypt_ctl), ++ NPE_QLEN * sizeof(struct crypt_ctl), + crypt_virt, crypt_phys); + } + return; +diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c +index 48adb2a0903e5..7e9a44cee4250 100644 +--- a/drivers/crypto/omap-sham.c ++++ b/drivers/crypto/omap-sham.c +@@ -453,6 +453,9 @@ static void omap_sham_write_ctrl_omap4(struct omap_sham_dev *dd, size_t length, + struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); + u32 val, mask; + ++ if (likely(ctx->digcnt)) ++ omap_sham_write(dd, SHA_REG_DIGCNT(dd), ctx->digcnt); ++ + /* + * Setting ALGO_CONST only for the first iteration and + * CLOSE_HASH only for the last one. Note that flags mode bits +diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c +index 40917775dca1c..59d10f48ed6ab 100644 +--- a/drivers/edac/i5100_edac.c ++++ b/drivers/edac/i5100_edac.c +@@ -1075,16 +1075,15 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id) + PCI_DEVICE_ID_INTEL_5100_19, 0); + if (!einj) { + ret = -ENODEV; +- goto bail_einj; ++ goto bail_mc_free; + } + + rc = pci_enable_device(einj); + if (rc < 0) { + ret = rc; +- goto bail_disable_einj; ++ goto bail_einj; + } + +- + mci->pdev = &pdev->dev; + + priv = mci->pvt_info; +@@ -1151,14 +1150,14 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id) + bail_scrub: + priv->scrub_enable = 0; + cancel_delayed_work_sync(&(priv->i5100_scrubbing)); +- edac_mc_free(mci); +- +-bail_disable_einj: + pci_disable_device(einj); + + bail_einj: + pci_dev_put(einj); + ++bail_mc_free: ++ edac_mc_free(mci); ++ + bail_disable_ch1: + pci_disable_device(ch1mm); + +diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c +index d3de377dc857e..25c68e4dc7a53 100644 +--- a/drivers/gpu/drm/gma500/cdv_intel_dp.c ++++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c +@@ -2120,7 +2120,7 @@ cdv_intel_dp_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev + intel_dp->dpcd, + sizeof(intel_dp->dpcd)); + cdv_intel_edp_panel_vdd_off(gma_encoder); +- if (ret == 0) { ++ if (ret <= 0) { + /* if this fails, presume the device is a ghost */ + DRM_INFO("failed to retrieve link info, disabling eDP\n"); + cdv_intel_dp_encoder_destroy(encoder); +diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c +index 06496a1281622..476b9993b0682 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_kms.c ++++ b/drivers/gpu/drm/virtio/virtgpu_kms.c +@@ -113,8 +113,10 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev, + vgdev->capsets[i].id > 0, 5 * HZ); + if (ret == 0) { + DRM_ERROR("timed out waiting for cap set %d\n", i); ++ spin_lock(&vgdev->display_info_lock); + kfree(vgdev->capsets); + vgdev->capsets = NULL; ++ spin_unlock(&vgdev->display_info_lock); + return; + } + DRM_INFO("cap set %d: id %d, max-version %d, max-size %d\n", +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c +index 772a5a3b0ce1a..18e8fcad6690b 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c +@@ -596,9 +596,13 @@ static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev, + int i = le32_to_cpu(cmd->capset_index); + + spin_lock(&vgdev->display_info_lock); +- vgdev->capsets[i].id = le32_to_cpu(resp->capset_id); +- vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version); +- vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size); ++ if (vgdev->capsets) { ++ vgdev->capsets[i].id = le32_to_cpu(resp->capset_id); ++ vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version); ++ vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size); ++ } else { ++ DRM_ERROR("invalid capset memory."); ++ } + spin_unlock(&vgdev->display_info_lock); + wake_up(&vgdev->resp_wq); + } +diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c +index c29265055ac1a..6c2b821c8d8b5 100644 +--- a/drivers/hid/hid-roccat-kone.c ++++ b/drivers/hid/hid-roccat-kone.c +@@ -299,31 +299,40 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, + struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); + struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); + int retval = 0, difference, old_profile; ++ struct kone_settings *settings = (struct kone_settings *)buf; + + /* I need to get my data in one piece */ + if (off != 0 || count != sizeof(struct kone_settings)) + return -EINVAL; + + mutex_lock(&kone->kone_lock); +- difference = memcmp(buf, &kone->settings, sizeof(struct kone_settings)); ++ difference = memcmp(settings, &kone->settings, ++ sizeof(struct kone_settings)); + if (difference) { +- retval = kone_set_settings(usb_dev, +- (struct kone_settings const *)buf); +- if (retval) { +- mutex_unlock(&kone->kone_lock); +- return retval; ++ if (settings->startup_profile < 1 || ++ settings->startup_profile > 5) { ++ retval = -EINVAL; ++ goto unlock; + } + ++ retval = kone_set_settings(usb_dev, settings); ++ if (retval) ++ goto unlock; ++ + old_profile = kone->settings.startup_profile; +- memcpy(&kone->settings, buf, sizeof(struct kone_settings)); ++ memcpy(&kone->settings, settings, sizeof(struct kone_settings)); + + kone_profile_activated(kone, kone->settings.startup_profile); + + if (kone->settings.startup_profile != old_profile) + kone_profile_report(kone, kone->settings.startup_profile); + } ++unlock: + mutex_unlock(&kone->kone_lock); + ++ if (retval) ++ return retval; ++ + return sizeof(struct kone_settings); + } + static BIN_ATTR(settings, 0660, kone_sysfs_read_settings, +diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c +index 5dc920fe13269..c8c586c78d071 100644 +--- a/drivers/infiniband/hw/mlx4/cm.c ++++ b/drivers/infiniband/hw/mlx4/cm.c +@@ -309,6 +309,9 @@ static void schedule_delayed(struct ib_device *ibdev, struct id_map_entry *id) + if (!sriov->is_going_down) { + id->scheduled_delete = 1; + schedule_delayed_work(&id->timeout, CM_CLEANUP_CACHE_TIMEOUT); ++ } else if (id->scheduled_delete) { ++ /* Adjust timeout if already scheduled */ ++ mod_delayed_work(system_wq, &id->timeout, CM_CLEANUP_CACHE_TIMEOUT); + } + spin_unlock_irqrestore(&sriov->going_down_lock, flags); + spin_unlock(&sriov->id_map_lock); +diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c +index f77b295e0123e..01788a78041b3 100644 +--- a/drivers/input/keyboard/ep93xx_keypad.c ++++ b/drivers/input/keyboard/ep93xx_keypad.c +@@ -257,8 +257,8 @@ static int ep93xx_keypad_probe(struct platform_device *pdev) + } + + keypad->irq = platform_get_irq(pdev, 0); +- if (!keypad->irq) { +- err = -ENXIO; ++ if (keypad->irq < 0) { ++ err = keypad->irq; + goto failed_free; + } + +diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c +index 3d2c60c8de830..c6a468dfdfb48 100644 +--- a/drivers/input/keyboard/omap4-keypad.c ++++ b/drivers/input/keyboard/omap4-keypad.c +@@ -253,10 +253,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) + } + + irq = platform_get_irq(pdev, 0); +- if (!irq) { +- dev_err(&pdev->dev, "no keyboard irq assigned\n"); +- return -EINVAL; +- } ++ if (irq < 0) ++ return irq; + + keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL); + if (!keypad_data) { +diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c +index 04b96fe393397..46512b4d686a8 100644 +--- a/drivers/input/serio/sun4i-ps2.c ++++ b/drivers/input/serio/sun4i-ps2.c +@@ -210,7 +210,6 @@ static int sun4i_ps2_probe(struct platform_device *pdev) + struct sun4i_ps2data *drvdata; + struct serio *serio; + struct device *dev = &pdev->dev; +- unsigned int irq; + int error; + + drvdata = kzalloc(sizeof(struct sun4i_ps2data), GFP_KERNEL); +@@ -263,14 +262,12 @@ static int sun4i_ps2_probe(struct platform_device *pdev) + writel(0, drvdata->reg_base + PS2_REG_GCTL); + + /* Get IRQ for the device */ +- irq = platform_get_irq(pdev, 0); +- if (!irq) { +- dev_err(dev, "no IRQ found\n"); +- error = -ENXIO; ++ drvdata->irq = platform_get_irq(pdev, 0); ++ if (drvdata->irq < 0) { ++ error = drvdata->irq; + goto err_disable_clk; + } + +- drvdata->irq = irq; + drvdata->serio = serio; + drvdata->dev = dev; + +diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c +index 8275267eac254..4be7ddc04af0f 100644 +--- a/drivers/input/touchscreen/imx6ul_tsc.c ++++ b/drivers/input/touchscreen/imx6ul_tsc.c +@@ -490,20 +490,25 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev) + + mutex_lock(&input_dev->mutex); + +- if (input_dev->users) { +- retval = clk_prepare_enable(tsc->adc_clk); +- if (retval) +- goto out; +- +- retval = clk_prepare_enable(tsc->tsc_clk); +- if (retval) { +- clk_disable_unprepare(tsc->adc_clk); +- goto out; +- } ++ if (!input_dev->users) ++ goto out; + +- retval = imx6ul_tsc_init(tsc); ++ retval = clk_prepare_enable(tsc->adc_clk); ++ if (retval) ++ goto out; ++ ++ retval = clk_prepare_enable(tsc->tsc_clk); ++ if (retval) { ++ clk_disable_unprepare(tsc->adc_clk); ++ goto out; + } + ++ retval = imx6ul_tsc_init(tsc); ++ if (retval) { ++ clk_disable_unprepare(tsc->tsc_clk); ++ clk_disable_unprepare(tsc->adc_clk); ++ goto out; ++ } + out: + mutex_unlock(&input_dev->mutex); + return retval; +diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/firedtv-fw.c +index 5d634706a7eaa..382f290c3f4d5 100644 +--- a/drivers/media/firewire/firedtv-fw.c ++++ b/drivers/media/firewire/firedtv-fw.c +@@ -271,8 +271,10 @@ static int node_probe(struct fw_unit *unit, const struct ieee1394_device_id *id) + + name_len = fw_csr_string(unit->directory, CSR_MODEL, + name, sizeof(name)); +- if (name_len < 0) +- return name_len; ++ if (name_len < 0) { ++ err = name_len; ++ goto fail_free; ++ } + for (i = ARRAY_SIZE(model_names); --i; ) + if (strlen(model_names[i]) <= name_len && + strncmp(name, model_names[i], name_len) == 0) +diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c +index 6404c0d93e7af..514267680dc96 100644 +--- a/drivers/media/i2c/m5mols/m5mols_core.c ++++ b/drivers/media/i2c/m5mols/m5mols_core.c +@@ -754,7 +754,8 @@ static int m5mols_sensor_power(struct m5mols_info *info, bool enable) + + ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies); + if (ret) { +- info->set_power(&client->dev, 0); ++ if (info->set_power) ++ info->set_power(&client->dev, 0); + return ret; + } + +diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c +index 51dbef2f9a489..10c9c078af014 100644 +--- a/drivers/media/pci/bt8xx/bttv-driver.c ++++ b/drivers/media/pci/bt8xx/bttv-driver.c +@@ -4053,11 +4053,13 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) + btv->id = dev->device; + if (pci_enable_device(dev)) { + pr_warn("%d: Can't enable device\n", btv->c.nr); +- return -EIO; ++ result = -EIO; ++ goto free_mem; + } + if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) { + pr_warn("%d: No suitable DMA available\n", btv->c.nr); +- return -EIO; ++ result = -EIO; ++ goto free_mem; + } + if (!request_mem_region(pci_resource_start(dev,0), + pci_resource_len(dev,0), +@@ -4065,7 +4067,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) + pr_warn("%d: can't request iomem (0x%llx)\n", + btv->c.nr, + (unsigned long long)pci_resource_start(dev, 0)); +- return -EBUSY; ++ result = -EBUSY; ++ goto free_mem; + } + pci_set_master(dev); + pci_set_command(dev); +@@ -4251,6 +4254,10 @@ fail0: + release_mem_region(pci_resource_start(btv->c.pci,0), + pci_resource_len(btv->c.pci,0)); + pci_disable_device(btv->c.pci); ++ ++free_mem: ++ bttvs[btv->c.nr] = NULL; ++ kfree(btv); + return result; + } + +diff --git a/drivers/media/pci/saa7134/saa7134-tvaudio.c b/drivers/media/pci/saa7134/saa7134-tvaudio.c +index 21a579309575d..02407983ce236 100644 +--- a/drivers/media/pci/saa7134/saa7134-tvaudio.c ++++ b/drivers/media/pci/saa7134/saa7134-tvaudio.c +@@ -696,7 +696,8 @@ int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value) + { + int err; + +- audio_dbg(2, "dsp write reg 0x%x = 0x%06x\n", reg << 2, value); ++ audio_dbg(2, "dsp write reg 0x%x = 0x%06x\n", ++ (reg << 2) & 0xffffffff, value); + err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_WRR); + if (err < 0) + return err; +diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c +index 5d78f5716f3b8..ad280c5258b34 100644 +--- a/drivers/media/platform/exynos4-is/fimc-isp.c ++++ b/drivers/media/platform/exynos4-is/fimc-isp.c +@@ -311,8 +311,10 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on) + + if (on) { + ret = pm_runtime_get_sync(&is->pdev->dev); +- if (ret < 0) ++ if (ret < 0) { ++ pm_runtime_put(&is->pdev->dev); + return ret; ++ } + set_bit(IS_ST_PWR_ON, &is->state); + + ret = fimc_is_start_firmware(is); +diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c +index 60660c3a5de0d..65b33470a1b1b 100644 +--- a/drivers/media/platform/exynos4-is/fimc-lite.c ++++ b/drivers/media/platform/exynos4-is/fimc-lite.c +@@ -487,7 +487,7 @@ static int fimc_lite_open(struct file *file) + set_bit(ST_FLITE_IN_USE, &fimc->state); + ret = pm_runtime_get_sync(&fimc->pdev->dev); + if (ret < 0) +- goto unlock; ++ goto err_pm; + + ret = v4l2_fh_open(file); + if (ret < 0) +diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c +index 31cc7d94064e3..76fadd3e3ada2 100644 +--- a/drivers/media/platform/exynos4-is/media-dev.c ++++ b/drivers/media/platform/exynos4-is/media-dev.c +@@ -413,8 +413,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) + return -ENXIO; + + ret = pm_runtime_get_sync(fmd->pmf); +- if (ret < 0) ++ if (ret < 0) { ++ pm_runtime_put(fmd->pmf); + return ret; ++ } + + fmd->num_sensors = 0; + +@@ -1170,11 +1172,9 @@ static int fimc_md_get_pinctrl(struct fimc_md *fmd) + if (IS_ERR(pctl->state_default)) + return PTR_ERR(pctl->state_default); + ++ /* PINCTRL_STATE_IDLE is optional */ + pctl->state_idle = pinctrl_lookup_state(pctl->pinctrl, + PINCTRL_STATE_IDLE); +- if (IS_ERR(pctl->state_idle)) +- return PTR_ERR(pctl->state_idle); +- + return 0; + } + +diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c +index 4b85105dc159b..4f7a0f59f36c2 100644 +--- a/drivers/media/platform/exynos4-is/mipi-csis.c ++++ b/drivers/media/platform/exynos4-is/mipi-csis.c +@@ -513,8 +513,10 @@ static int s5pcsis_s_stream(struct v4l2_subdev *sd, int enable) + if (enable) { + s5pcsis_clear_counters(state); + ret = pm_runtime_get_sync(&state->pdev->dev); +- if (ret && ret != 1) ++ if (ret && ret != 1) { ++ pm_runtime_put_noidle(&state->pdev->dev); + return ret; ++ } + } + + mutex_lock(&state->lock); +diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c +index f41e0d08de93e..4c6842202e47c 100644 +--- a/drivers/media/platform/omap3isp/isp.c ++++ b/drivers/media/platform/omap3isp/isp.c +@@ -2388,8 +2388,10 @@ static int isp_probe(struct platform_device *pdev) + mem = platform_get_resource(pdev, IORESOURCE_MEM, i); + isp->mmio_base[map_idx] = + devm_ioremap_resource(isp->dev, mem); +- if (IS_ERR(isp->mmio_base[map_idx])) +- return PTR_ERR(isp->mmio_base[map_idx]); ++ if (IS_ERR(isp->mmio_base[map_idx])) { ++ ret = PTR_ERR(isp->mmio_base[map_idx]); ++ goto error; ++ } + } + + ret = isp_get_clocks(isp); +diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c +index a00dfaa1b945d..6c97063cb3b3f 100644 +--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c ++++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c +@@ -1369,7 +1369,7 @@ static int bdisp_probe(struct platform_device *pdev) + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "failed to set PM\n"); +- goto err_dbg; ++ goto err_pm; + } + + /* Continuous memory allocator */ +@@ -1406,7 +1406,6 @@ err_vb2_dma: + vb2_dma_contig_cleanup_ctx(bdisp->alloc_ctx); + err_pm: + pm_runtime_put(dev); +-err_dbg: + bdisp_debugfs_remove(bdisp); + err_v4l2: + v4l2_device_unregister(&bdisp->v4l2_dev); +diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c +index b5f8c425cd2ef..8a3714bfb77e8 100644 +--- a/drivers/media/platform/ti-vpe/vpe.c ++++ b/drivers/media/platform/ti-vpe/vpe.c +@@ -2135,6 +2135,8 @@ static int vpe_runtime_get(struct platform_device *pdev) + + r = pm_runtime_get_sync(&pdev->dev); + WARN_ON(r < 0); ++ if (r) ++ pm_runtime_put_noidle(&pdev->dev); + return r < 0 ? r : 0; + } + +diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c +index a35631891cc00..3c3f4c4f6be40 100644 +--- a/drivers/media/rc/ati_remote.c ++++ b/drivers/media/rc/ati_remote.c +@@ -843,6 +843,10 @@ static int ati_remote_probe(struct usb_interface *interface, + err("%s: endpoint_in message size==0? \n", __func__); + return -ENODEV; + } ++ if (!usb_endpoint_is_int_out(endpoint_out)) { ++ err("%s: Unexpected endpoint_out\n", __func__); ++ return -ENODEV; ++ } + + ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); + rc_dev = rc_allocate_device(); +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c +index 0e7d16fe84d42..a0a544628053d 100644 +--- a/drivers/media/usb/uvc/uvc_v4l2.c ++++ b/drivers/media/usb/uvc/uvc_v4l2.c +@@ -242,11 +242,41 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, + if (ret < 0) + goto done; + ++ /* After the probe, update fmt with the values returned from ++ * negotiation with the device. ++ */ ++ for (i = 0; i < stream->nformats; ++i) { ++ if (probe->bFormatIndex == stream->format[i].index) { ++ format = &stream->format[i]; ++ break; ++ } ++ } ++ ++ if (i == stream->nformats) { ++ uvc_trace(UVC_TRACE_FORMAT, "Unknown bFormatIndex %u\n", ++ probe->bFormatIndex); ++ return -EINVAL; ++ } ++ ++ for (i = 0; i < format->nframes; ++i) { ++ if (probe->bFrameIndex == format->frame[i].bFrameIndex) { ++ frame = &format->frame[i]; ++ break; ++ } ++ } ++ ++ if (i == format->nframes) { ++ uvc_trace(UVC_TRACE_FORMAT, "Unknown bFrameIndex %u\n", ++ probe->bFrameIndex); ++ return -EINVAL; ++ } ++ + fmt->fmt.pix.width = frame->wWidth; + fmt->fmt.pix.height = frame->wHeight; + fmt->fmt.pix.field = V4L2_FIELD_NONE; + fmt->fmt.pix.bytesperline = format->bpp * frame->wWidth / 8; + fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize; ++ fmt->fmt.pix.pixelformat = format->fcc; + fmt->fmt.pix.colorspace = format->colorspace; + fmt->fmt.pix.priv = 0; + +diff --git a/drivers/memory/fsl-corenet-cf.c b/drivers/memory/fsl-corenet-cf.c +index 662d050243bec..2fbf8d09af36b 100644 +--- a/drivers/memory/fsl-corenet-cf.c ++++ b/drivers/memory/fsl-corenet-cf.c +@@ -215,10 +215,8 @@ static int ccf_probe(struct platform_device *pdev) + dev_set_drvdata(&pdev->dev, ccf); + + irq = platform_get_irq(pdev, 0); +- if (!irq) { +- dev_err(&pdev->dev, "%s: no irq\n", __func__); +- return -ENXIO; +- } ++ if (irq < 0) ++ return irq; + + ret = devm_request_irq(&pdev->dev, irq, ccf_irq, 0, pdev->name, ccf); + if (ret) { +diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c +index 49691a8c74ee9..af187c91fc33b 100644 +--- a/drivers/memory/omap-gpmc.c ++++ b/drivers/memory/omap-gpmc.c +@@ -928,7 +928,7 @@ static int gpmc_cs_remap(int cs, u32 base) + int ret; + u32 old_base, size; + +- if (cs > gpmc_cs_num) { ++ if (cs >= gpmc_cs_num) { + pr_err("%s: requested chip-select is disabled\n", __func__); + return -ENODEV; + } +@@ -963,7 +963,7 @@ int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) + struct resource *res = &gpmc->mem; + int r = -1; + +- if (cs > gpmc_cs_num) { ++ if (cs >= gpmc_cs_num) { + pr_err("%s: requested chip-select is disabled\n", __func__); + return -ENODEV; + } +diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c +index 98029ee0959e3..be61f8606a045 100644 +--- a/drivers/mfd/rtsx_pcr.c ++++ b/drivers/mfd/rtsx_pcr.c +@@ -1255,12 +1255,14 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, + ret = mfd_add_devices(&pcidev->dev, pcr->id, rtsx_pcr_cells, + ARRAY_SIZE(rtsx_pcr_cells), NULL, 0, NULL); + if (ret < 0) +- goto disable_irq; ++ goto free_slots; + + schedule_delayed_work(&pcr->idle_work, msecs_to_jiffies(200)); + + return 0; + ++free_slots: ++ kfree(pcr->slots); + disable_irq: + free_irq(pcr->irq, (void *)pcr); + disable_msi: +diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c +index fbec711c41956..0fe273d2f6190 100644 +--- a/drivers/mfd/sm501.c ++++ b/drivers/mfd/sm501.c +@@ -1430,8 +1430,14 @@ static int sm501_plat_probe(struct platform_device *dev) + goto err_claim; + } + +- return sm501_init_dev(sm); ++ ret = sm501_init_dev(sm); ++ if (ret) ++ goto err_unmap; ++ ++ return 0; + ++ err_unmap: ++ iounmap(sm->regs); + err_claim: + release_resource(sm->regs_claim); + kfree(sm->regs_claim); +diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c +index 71c69e1c4ac05..4188b88c20a4a 100644 +--- a/drivers/misc/mic/scif/scif_rma.c ++++ b/drivers/misc/mic/scif/scif_rma.c +@@ -1403,6 +1403,8 @@ retry: + NULL); + up_write(&mm->mmap_sem); + if (nr_pages != pinned_pages->nr_pages) { ++ if (pinned_pages->nr_pages < 0) ++ pinned_pages->nr_pages = 0; + if (try_upgrade) { + if (ulimit) + __scif_dec_pinned_vm_lock(mm, +@@ -1423,7 +1425,6 @@ retry: + + if (pinned_pages->nr_pages < nr_pages) { + err = -EFAULT; +- pinned_pages->nr_pages = nr_pages; + goto dec_pinned; + } + +@@ -1436,7 +1437,6 @@ dec_pinned: + __scif_dec_pinned_vm_lock(mm, nr_pages, 0); + /* Something went wrong! Rollback */ + error_unmap: +- pinned_pages->nr_pages = nr_pages; + scif_destroy_pinned_pages(pinned_pages); + *pages = NULL; + dev_dbg(scif_info.mdev.this_device, +diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c +index 3877f534fd3f4..e57340e980c4b 100644 +--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c ++++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c +@@ -758,8 +758,9 @@ static int qp_host_get_user_memory(u64 produce_uva, + if (retval < (int)produce_q->kernel_if->num_pages) { + pr_debug("get_user_pages_fast(produce) failed (retval=%d)", + retval); +- qp_release_pages(produce_q->kernel_if->u.h.header_page, +- retval, false); ++ if (retval > 0) ++ qp_release_pages(produce_q->kernel_if->u.h.header_page, ++ retval, false); + err = VMCI_ERROR_NO_MEM; + goto out; + } +@@ -770,8 +771,9 @@ static int qp_host_get_user_memory(u64 produce_uva, + if (retval < (int)consume_q->kernel_if->num_pages) { + pr_debug("get_user_pages_fast(consume) failed (retval=%d)", + retval); +- qp_release_pages(consume_q->kernel_if->u.h.header_page, +- retval, false); ++ if (retval > 0) ++ qp_release_pages(consume_q->kernel_if->u.h.header_page, ++ retval, false); + qp_release_pages(produce_q->kernel_if->u.h.header_page, + produce_q->kernel_if->num_pages, false); + err = VMCI_ERROR_NO_MEM; +diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c +index 8e94e555b788d..8651bd30863d4 100644 +--- a/drivers/mmc/core/sdio_cis.c ++++ b/drivers/mmc/core/sdio_cis.c +@@ -30,6 +30,9 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, + unsigned i, nr_strings; + char **buffer, *string; + ++ if (size < 2) ++ return 0; ++ + /* Find all null-terminated (including zero length) strings in + the TPLLV1_INFO field. Trailing garbage is ignored. */ + buf += 2; +diff --git a/drivers/mtd/lpddr/lpddr2_nvm.c b/drivers/mtd/lpddr/lpddr2_nvm.c +index 2342277c9bcb0..5e36366d9b36d 100644 +--- a/drivers/mtd/lpddr/lpddr2_nvm.c ++++ b/drivers/mtd/lpddr/lpddr2_nvm.c +@@ -408,6 +408,17 @@ static int lpddr2_nvm_lock(struct mtd_info *mtd, loff_t start_add, + return lpddr2_nvm_do_block_op(mtd, start_add, len, LPDDR2_NVM_LOCK); + } + ++static const struct mtd_info lpddr2_nvm_mtd_info = { ++ .type = MTD_RAM, ++ .writesize = 1, ++ .flags = (MTD_CAP_NVRAM | MTD_POWERUP_LOCK), ++ ._read = lpddr2_nvm_read, ++ ._write = lpddr2_nvm_write, ++ ._erase = lpddr2_nvm_erase, ++ ._unlock = lpddr2_nvm_unlock, ++ ._lock = lpddr2_nvm_lock, ++}; ++ + /* + * lpddr2_nvm driver probe method + */ +@@ -448,6 +459,7 @@ static int lpddr2_nvm_probe(struct platform_device *pdev) + .pfow_base = OW_BASE_ADDRESS, + .fldrv_priv = pcm_data, + }; ++ + if (IS_ERR(map->virt)) + return PTR_ERR(map->virt); + +@@ -459,22 +471,13 @@ static int lpddr2_nvm_probe(struct platform_device *pdev) + return PTR_ERR(pcm_data->ctl_regs); + + /* Populate mtd_info data structure */ +- *mtd = (struct mtd_info) { +- .dev = { .parent = &pdev->dev }, +- .name = pdev->dev.init_name, +- .type = MTD_RAM, +- .priv = map, +- .size = resource_size(add_range), +- .erasesize = ERASE_BLOCKSIZE * pcm_data->bus_width, +- .writesize = 1, +- .writebufsize = WRITE_BUFFSIZE * pcm_data->bus_width, +- .flags = (MTD_CAP_NVRAM | MTD_POWERUP_LOCK), +- ._read = lpddr2_nvm_read, +- ._write = lpddr2_nvm_write, +- ._erase = lpddr2_nvm_erase, +- ._unlock = lpddr2_nvm_unlock, +- ._lock = lpddr2_nvm_lock, +- }; ++ *mtd = lpddr2_nvm_mtd_info; ++ mtd->dev.parent = &pdev->dev; ++ mtd->name = pdev->dev.init_name; ++ mtd->priv = map; ++ mtd->size = resource_size(add_range); ++ mtd->erasesize = ERASE_BLOCKSIZE * pcm_data->bus_width; ++ mtd->writebufsize = WRITE_BUFFSIZE * pcm_data->bus_width; + + /* Verify the presence of the device looking for PFOW string */ + if (!lpddr2_nvm_pfow_present(map)) { +diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c +index 97bb8f6304d4f..09165eaac7a15 100644 +--- a/drivers/mtd/mtdoops.c ++++ b/drivers/mtd/mtdoops.c +@@ -313,12 +313,13 @@ static void mtdoops_do_dump(struct kmsg_dumper *dumper, + kmsg_dump_get_buffer(dumper, true, cxt->oops_buf + MTDOOPS_HEADER_SIZE, + record_size - MTDOOPS_HEADER_SIZE, NULL); + +- /* Panics must be written immediately */ +- if (reason != KMSG_DUMP_OOPS) ++ if (reason != KMSG_DUMP_OOPS) { ++ /* Panics must be written immediately */ + mtdoops_write(cxt, 1); +- +- /* For other cases, schedule work to write it "nicely" */ +- schedule_work(&cxt->work_write); ++ } else { ++ /* For other cases, schedule work to write it "nicely" */ ++ schedule_work(&cxt->work_write); ++ } + } + + static void mtdoops_notify_add(struct mtd_info *mtd) +diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h +index 7ba6d530b0c0a..230a4157ae9d0 100644 +--- a/drivers/net/ethernet/cisco/enic/enic.h ++++ b/drivers/net/ethernet/cisco/enic/enic.h +@@ -163,6 +163,7 @@ struct enic { + u16 num_vfs; + #endif + spinlock_t enic_api_lock; ++ bool enic_api_busy; + struct enic_port_profile *pp; + + /* work queue cache line section */ +diff --git a/drivers/net/ethernet/cisco/enic/enic_api.c b/drivers/net/ethernet/cisco/enic/enic_api.c +index b161f24522b87..b028ea2dec2b9 100644 +--- a/drivers/net/ethernet/cisco/enic/enic_api.c ++++ b/drivers/net/ethernet/cisco/enic/enic_api.c +@@ -34,6 +34,12 @@ int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf, + struct vnic_dev *vdev = enic->vdev; + + spin_lock(&enic->enic_api_lock); ++ while (enic->enic_api_busy) { ++ spin_unlock(&enic->enic_api_lock); ++ cpu_relax(); ++ spin_lock(&enic->enic_api_lock); ++ } ++ + spin_lock_bh(&enic->devcmd_lock); + + vnic_dev_cmd_proxy_by_index_start(vdev, vf); +diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c +index 3fd1cba0c7ec3..5c74e55b75e52 100644 +--- a/drivers/net/ethernet/cisco/enic/enic_main.c ++++ b/drivers/net/ethernet/cisco/enic/enic_main.c +@@ -1938,8 +1938,6 @@ static int enic_dev_wait(struct vnic_dev *vdev, + int done; + int err; + +- BUG_ON(in_interrupt()); +- + err = start(vdev, arg); + if (err) + return err; +@@ -2116,6 +2114,13 @@ static int enic_set_rss_nic_cfg(struct enic *enic) + rss_hash_bits, rss_base_cpu, rss_enable); + } + ++static void enic_set_api_busy(struct enic *enic, bool busy) ++{ ++ spin_lock(&enic->enic_api_lock); ++ enic->enic_api_busy = busy; ++ spin_unlock(&enic->enic_api_lock); ++} ++ + static void enic_reset(struct work_struct *work) + { + struct enic *enic = container_of(work, struct enic, reset); +@@ -2125,7 +2130,9 @@ static void enic_reset(struct work_struct *work) + + rtnl_lock(); + +- spin_lock(&enic->enic_api_lock); ++ /* Stop any activity from infiniband */ ++ enic_set_api_busy(enic, true); ++ + enic_stop(enic->netdev); + enic_dev_soft_reset(enic); + enic_reset_addr_lists(enic); +@@ -2133,7 +2140,10 @@ static void enic_reset(struct work_struct *work) + enic_set_rss_nic_cfg(enic); + enic_dev_set_ig_vlan_rewrite_mode(enic); + enic_open(enic->netdev); +- spin_unlock(&enic->enic_api_lock); ++ ++ /* Allow infiniband to fiddle with the device again */ ++ enic_set_api_busy(enic, false); ++ + call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev); + + rtnl_unlock(); +@@ -2145,7 +2155,9 @@ static void enic_tx_hang_reset(struct work_struct *work) + + rtnl_lock(); + +- spin_lock(&enic->enic_api_lock); ++ /* Stop any activity from infiniband */ ++ enic_set_api_busy(enic, true); ++ + enic_dev_hang_notify(enic); + enic_stop(enic->netdev); + enic_dev_hang_reset(enic); +@@ -2154,7 +2166,10 @@ static void enic_tx_hang_reset(struct work_struct *work) + enic_set_rss_nic_cfg(enic); + enic_dev_set_ig_vlan_rewrite_mode(enic); + enic_open(enic->netdev); +- spin_unlock(&enic->enic_api_lock); ++ ++ /* Allow infiniband to fiddle with the device again */ ++ enic_set_api_busy(enic, false); ++ + call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev); + + rtnl_unlock(); +diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c +index b46fc37c1a947..18d17a7bba6c6 100644 +--- a/drivers/net/ethernet/ibm/ibmveth.c ++++ b/drivers/net/ethernet/ibm/ibmveth.c +@@ -1254,6 +1254,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) + int offset = ibmveth_rxq_frame_offset(adapter); + int csum_good = ibmveth_rxq_csum_good(adapter); + int lrg_pkt = ibmveth_rxq_large_packet(adapter); ++ __sum16 iph_check = 0; + + skb = ibmveth_rxq_get_buffer(adapter); + +@@ -1305,7 +1306,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) + } + } + +- if (length > netdev->mtu + ETH_HLEN) { ++ /* PHYP without PLSO support places a -1 in the ip ++ * checksum for large send frames. ++ */ ++ if (skb->protocol == cpu_to_be16(ETH_P_IP)) { ++ struct iphdr *iph = (struct iphdr *)skb->data; ++ ++ iph_check = iph->check; ++ } ++ ++ if ((length > netdev->mtu + ETH_HLEN) || ++ lrg_pkt || iph_check == 0xffff) { + ibmveth_rx_mss_helper(skb, mss, lrg_pkt); + adapter->rx_large_packets++; + } +diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c +index 07eabf72c480c..b491de946a0e6 100644 +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -1188,7 +1188,7 @@ out: + return rc; + + probe_err_register: +- kfree(lp->td_ring); ++ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring)); + probe_err_td_ring: + iounmap(lp->tx_dma_regs); + probe_err_dma_tx: +@@ -1208,6 +1208,7 @@ static int korina_remove(struct platform_device *pdev) + iounmap(lp->eth_regs); + iounmap(lp->rx_dma_regs); + iounmap(lp->tx_dma_regs); ++ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring)); + + unregister_netdev(bif->dev); + free_netdev(bif->dev); +diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c +index 8f40e121f7d49..f3a685d3f6497 100644 +--- a/drivers/net/ethernet/realtek/r8169.c ++++ b/drivers/net/ethernet/realtek/r8169.c +@@ -4452,6 +4452,62 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) + rtl_unlock_work(tp); + } + ++static void rtl_init_rxcfg(struct rtl8169_private *tp) ++{ ++ void __iomem *ioaddr = tp->mmio_addr; ++ ++ switch (tp->mac_version) { ++ case RTL_GIGA_MAC_VER_01: ++ case RTL_GIGA_MAC_VER_02: ++ case RTL_GIGA_MAC_VER_03: ++ case RTL_GIGA_MAC_VER_04: ++ case RTL_GIGA_MAC_VER_05: ++ case RTL_GIGA_MAC_VER_06: ++ case RTL_GIGA_MAC_VER_10: ++ case RTL_GIGA_MAC_VER_11: ++ case RTL_GIGA_MAC_VER_12: ++ case RTL_GIGA_MAC_VER_13: ++ case RTL_GIGA_MAC_VER_14: ++ case RTL_GIGA_MAC_VER_15: ++ case RTL_GIGA_MAC_VER_16: ++ case RTL_GIGA_MAC_VER_17: ++ RTL_W32(RxConfig, RX_FIFO_THRESH | RX_DMA_BURST); ++ break; ++ case RTL_GIGA_MAC_VER_18: ++ case RTL_GIGA_MAC_VER_19: ++ case RTL_GIGA_MAC_VER_20: ++ case RTL_GIGA_MAC_VER_21: ++ case RTL_GIGA_MAC_VER_22: ++ case RTL_GIGA_MAC_VER_23: ++ case RTL_GIGA_MAC_VER_24: ++ case RTL_GIGA_MAC_VER_34: ++ case RTL_GIGA_MAC_VER_35: ++ RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST); ++ break; ++ case RTL_GIGA_MAC_VER_40: ++ RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); ++ break; ++ case RTL_GIGA_MAC_VER_41: ++ case RTL_GIGA_MAC_VER_42: ++ case RTL_GIGA_MAC_VER_43: ++ case RTL_GIGA_MAC_VER_44: ++ case RTL_GIGA_MAC_VER_45: ++ case RTL_GIGA_MAC_VER_46: ++ case RTL_GIGA_MAC_VER_47: ++ case RTL_GIGA_MAC_VER_48: ++ RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); ++ break; ++ case RTL_GIGA_MAC_VER_49: ++ case RTL_GIGA_MAC_VER_50: ++ case RTL_GIGA_MAC_VER_51: ++ RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); ++ break; ++ default: ++ RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST); ++ break; ++ } ++} ++ + static int rtl_set_mac_address(struct net_device *dev, void *p) + { + struct rtl8169_private *tp = netdev_priv(dev); +@@ -4464,6 +4520,10 @@ static int rtl_set_mac_address(struct net_device *dev, void *p) + + rtl_rar_set(tp, dev->dev_addr); + ++ /* Reportedly at least Asus X453MA truncates packets otherwise */ ++ if (tp->mac_version == RTL_GIGA_MAC_VER_37) ++ rtl_init_rxcfg(tp); ++ + return 0; + } + +@@ -4901,62 +4961,6 @@ static void rtl_init_pll_power_ops(struct rtl8169_private *tp) + } + } + +-static void rtl_init_rxcfg(struct rtl8169_private *tp) +-{ +- void __iomem *ioaddr = tp->mmio_addr; +- +- switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_01: +- case RTL_GIGA_MAC_VER_02: +- case RTL_GIGA_MAC_VER_03: +- case RTL_GIGA_MAC_VER_04: +- case RTL_GIGA_MAC_VER_05: +- case RTL_GIGA_MAC_VER_06: +- case RTL_GIGA_MAC_VER_10: +- case RTL_GIGA_MAC_VER_11: +- case RTL_GIGA_MAC_VER_12: +- case RTL_GIGA_MAC_VER_13: +- case RTL_GIGA_MAC_VER_14: +- case RTL_GIGA_MAC_VER_15: +- case RTL_GIGA_MAC_VER_16: +- case RTL_GIGA_MAC_VER_17: +- RTL_W32(RxConfig, RX_FIFO_THRESH | RX_DMA_BURST); +- break; +- case RTL_GIGA_MAC_VER_18: +- case RTL_GIGA_MAC_VER_19: +- case RTL_GIGA_MAC_VER_20: +- case RTL_GIGA_MAC_VER_21: +- case RTL_GIGA_MAC_VER_22: +- case RTL_GIGA_MAC_VER_23: +- case RTL_GIGA_MAC_VER_24: +- case RTL_GIGA_MAC_VER_34: +- case RTL_GIGA_MAC_VER_35: +- RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST); +- break; +- case RTL_GIGA_MAC_VER_40: +- RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); +- break; +- case RTL_GIGA_MAC_VER_41: +- case RTL_GIGA_MAC_VER_42: +- case RTL_GIGA_MAC_VER_43: +- case RTL_GIGA_MAC_VER_44: +- case RTL_GIGA_MAC_VER_45: +- case RTL_GIGA_MAC_VER_46: +- case RTL_GIGA_MAC_VER_47: +- case RTL_GIGA_MAC_VER_48: +- RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); +- break; +- case RTL_GIGA_MAC_VER_49: +- case RTL_GIGA_MAC_VER_50: +- case RTL_GIGA_MAC_VER_51: +- RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); +- break; +- default: +- RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST); +- break; +- } +-} +- + static void rtl8169_init_ring_indexes(struct rtl8169_private *tp) + { + tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0; +diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c +index 51f6cee8aab2d..b9216c3d49463 100644 +--- a/drivers/net/wan/hdlc.c ++++ b/drivers/net/wan/hdlc.c +@@ -57,7 +57,15 @@ int hdlc_change_mtu(struct net_device *dev, int new_mtu) + static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *p, struct net_device *orig_dev) + { +- struct hdlc_device *hdlc = dev_to_hdlc(dev); ++ struct hdlc_device *hdlc; ++ ++ /* First make sure "dev" is an HDLC device */ ++ if (!(dev->priv_flags & IFF_WAN_HDLC)) { ++ kfree_skb(skb); ++ return NET_RX_SUCCESS; ++ } ++ ++ hdlc = dev_to_hdlc(dev); + + if (!net_eq(dev_net(dev), &init_net)) { + kfree_skb(skb); +diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c +index 3ab72b3082dee..bb7c362b23ad5 100644 +--- a/drivers/net/wan/hdlc_raw_eth.c ++++ b/drivers/net/wan/hdlc_raw_eth.c +@@ -101,6 +101,7 @@ static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr) + old_qlen = dev->tx_queue_len; + ether_setup(dev); + dev->tx_queue_len = old_qlen; ++ dev->priv_flags &= ~IFF_TX_SKB_SHARING; + eth_hw_addr_random(dev); + netif_dormant_off(dev); + return 0; +diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c +index a65b5d7f59f44..1c6c422dbad64 100644 +--- a/drivers/net/wireless/ath/ath10k/htt_rx.c ++++ b/drivers/net/wireless/ath/ath10k/htt_rx.c +@@ -99,6 +99,14 @@ static int __ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num) + BUILD_BUG_ON(HTT_RX_RING_FILL_LEVEL >= HTT_RX_RING_SIZE / 2); + + idx = __le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr); ++ ++ if (idx < 0 || idx >= htt->rx_ring.size) { ++ ath10k_err(htt->ar, "rx ring index is not valid, firmware malfunctioning?\n"); ++ idx &= htt->rx_ring.size_mask; ++ ret = -ENOMEM; ++ goto fail; ++ } ++ + while (num > 0) { + skb = dev_alloc_skb(HTT_RX_BUF_SIZE + HTT_RX_DESC_ALIGN); + if (!skb) { +diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c +index 1af3fed5a72ca..1a68518279689 100644 +--- a/drivers/net/wireless/ath/ath6kl/main.c ++++ b/drivers/net/wireless/ath/ath6kl/main.c +@@ -430,6 +430,9 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, + + ath6kl_dbg(ATH6KL_DBG_TRC, "new station %pM aid=%d\n", mac_addr, aid); + ++ if (aid < 1 || aid > AP_MAX_NUM_STA) ++ return; ++ + if (assoc_req_len > sizeof(struct ieee80211_hdr_3addr)) { + struct ieee80211_mgmt *mgmt = + (struct ieee80211_mgmt *) assoc_info; +diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c +index b2ec254f154e0..7e1010475cfb2 100644 +--- a/drivers/net/wireless/ath/ath6kl/wmi.c ++++ b/drivers/net/wireless/ath/ath6kl/wmi.c +@@ -2644,6 +2644,11 @@ int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, + return -EINVAL; + } + ++ if (tsid >= 16) { ++ ath6kl_err("invalid tsid: %d\n", tsid); ++ return -EINVAL; ++ } ++ + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c +index 76d91859cfde9..75072a8f8cf42 100644 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.c ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c +@@ -445,10 +445,19 @@ static void hif_usb_stop(void *hif_handle) + spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + + /* The pending URBs have to be canceled. */ ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + list_for_each_entry_safe(tx_buf, tx_buf_tmp, + &hif_dev->tx.tx_pending, list) { ++ usb_get_urb(tx_buf->urb); ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + usb_kill_urb(tx_buf->urb); ++ list_del(&tx_buf->list); ++ usb_free_urb(tx_buf->urb); ++ kfree(tx_buf->buf); ++ kfree(tx_buf); ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + } ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + + usb_kill_anchored_urbs(&hif_dev->mgmt_submitted); + } +@@ -758,27 +767,37 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev) + struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL; + unsigned long flags; + ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + list_for_each_entry_safe(tx_buf, tx_buf_tmp, + &hif_dev->tx.tx_buf, list) { ++ usb_get_urb(tx_buf->urb); ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + usb_kill_urb(tx_buf->urb); + list_del(&tx_buf->list); + usb_free_urb(tx_buf->urb); + kfree(tx_buf->buf); + kfree(tx_buf); ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + } ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + + spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + hif_dev->tx.flags |= HIF_USB_TX_FLUSH; + spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + list_for_each_entry_safe(tx_buf, tx_buf_tmp, + &hif_dev->tx.tx_pending, list) { ++ usb_get_urb(tx_buf->urb); ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + usb_kill_urb(tx_buf->urb); + list_del(&tx_buf->list); + usb_free_urb(tx_buf->urb); + kfree(tx_buf->buf); + kfree(tx_buf); ++ spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); + } ++ spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); + + usb_kill_anchored_urbs(&hif_dev->mgmt_submitted); + } +diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c +index 1af216aa5adae..625823e45d8f0 100644 +--- a/drivers/net/wireless/ath/ath9k/htc_hst.c ++++ b/drivers/net/wireless/ath/ath9k/htc_hst.c +@@ -346,6 +346,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle, + + if (skb) { + htc_hdr = (struct htc_frame_hdr *) skb->data; ++ if (htc_hdr->endpoint_id >= ARRAY_SIZE(htc_handle->endpoint)) ++ goto ret; + endpoint = &htc_handle->endpoint[htc_hdr->endpoint_id]; + skb_pull(skb, sizeof(struct htc_frame_hdr)); + +diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c +index a27279c2c6950..274d114962e8a 100644 +--- a/drivers/net/wireless/ath/wcn36xx/main.c ++++ b/drivers/net/wireless/ath/wcn36xx/main.c +@@ -156,7 +156,7 @@ static struct ieee80211_supported_band wcn_band_5ghz = { + .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, + .mcs = { + .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, +- .rx_highest = cpu_to_le16(72), ++ .rx_highest = cpu_to_le16(150), + .tx_params = IEEE80211_HT_MCS_TX_DEFINED, + } + } +diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c +index f944f356d9c51..cacb43573f579 100644 +--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c ++++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c +@@ -1530,6 +1530,8 @@ fail: + BRCMF_TX_IOCTL_MAX_MSG_SIZE, + msgbuf->ioctbuf, + msgbuf->ioctbuf_handle); ++ if (msgbuf->txflow_wq) ++ destroy_workqueue(msgbuf->txflow_wq); + kfree(msgbuf); + } + return -ENOMEM; +diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c +index 93d4cde0eb313..c9f48ec46f4a1 100644 +--- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c ++++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c +@@ -5090,8 +5090,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) + pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft; + pi->pi_fptr.detach = wlc_phy_detach_lcnphy; + +- if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) ++ if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) { ++ kfree(pi->u.pi_lcnphy); + return false; ++ } + + if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { + if (pi_lcn->lcnphy_tempsense_option == 3) { +diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c +index e7c8972431d34..e54dd4b7face6 100644 +--- a/drivers/net/wireless/mwifiex/scan.c ++++ b/drivers/net/wireless/mwifiex/scan.c +@@ -1862,7 +1862,7 @@ mwifiex_parse_single_response_buf(struct mwifiex_private *priv, u8 **bss_info, + chan, CFG80211_BSS_FTYPE_UNKNOWN, + bssid, timestamp, + cap_info_bitmap, beacon_period, +- ie_buf, ie_len, rssi, GFP_KERNEL); ++ ie_buf, ie_len, rssi, GFP_ATOMIC); + if (bss) { + bss_priv = (struct mwifiex_bss_priv *)bss->priv; + bss_priv->band = band; +diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c +index 78a8474e1a3dc..abfe4e8700ed3 100644 +--- a/drivers/net/wireless/mwifiex/sdio.c ++++ b/drivers/net/wireless/mwifiex/sdio.c +@@ -1928,6 +1928,8 @@ error: + kfree(card->mpa_rx.buf); + card->mpa_tx.buf_size = 0; + card->mpa_rx.buf_size = 0; ++ card->mpa_tx.buf = NULL; ++ card->mpa_rx.buf = NULL; + } + + return ret; +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c +index 8254d4b22c50b..b8d387edde65c 100644 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c +@@ -5135,7 +5135,6 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) + ret = usb_submit_urb(urb, GFP_KERNEL); + if (ret) { + usb_unanchor_urb(urb); +- usb_free_urb(urb); + goto error; + } + +@@ -5144,6 +5143,7 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) + rtl8xxxu_write32(priv, REG_USB_HIMR, val32); + + error: ++ usb_free_urb(urb); + return ret; + } + +@@ -5424,6 +5424,7 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) + struct rtl8xxxu_priv *priv = hw->priv; + struct rtl8xxxu_rx_urb *rx_urb; + struct rtl8xxxu_tx_urb *tx_urb; ++ struct sk_buff *skb; + unsigned long flags; + int ret, i; + +@@ -5472,6 +5473,13 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) + rx_urb->hw = hw; + + ret = rtl8xxxu_submit_rx_urb(priv, rx_urb); ++ if (ret) { ++ if (ret != -ENOMEM) { ++ skb = (struct sk_buff *)rx_urb->urb.context; ++ dev_kfree_skb(skb); ++ } ++ rtl8xxxu_queue_rx_urb(priv, rx_urb); ++ } + } + exit: + /* +diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c +index dab195f04da78..06ca0495f3e8e 100644 +--- a/drivers/scsi/csiostor/csio_hw.c ++++ b/drivers/scsi/csiostor/csio_hw.c +@@ -1973,7 +1973,7 @@ static int csio_hw_prep_fw(struct csio_hw *hw, struct fw_info *fw_info, + FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c), + FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k), + FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k)); +- ret = EINVAL; ++ ret = -EINVAL; + goto bye; + } + +diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c +index 0526a47e30a3f..db80ab8335dfb 100644 +--- a/drivers/scsi/ibmvscsi/ibmvfc.c ++++ b/drivers/scsi/ibmvscsi/ibmvfc.c +@@ -4790,6 +4790,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id) + if (IS_ERR(vhost->work_thread)) { + dev_err(dev, "Couldn't create kernel thread: %ld\n", + PTR_ERR(vhost->work_thread)); ++ rc = PTR_ERR(vhost->work_thread); + goto free_host_mem; + } + +diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c +index 39285070f3b51..17ec51f9d9880 100644 +--- a/drivers/scsi/mvumi.c ++++ b/drivers/scsi/mvumi.c +@@ -2476,6 +2476,7 @@ static int mvumi_io_attach(struct mvumi_hba *mhba) + if (IS_ERR(mhba->dm_thread)) { + dev_err(&mhba->pdev->dev, + "failed to create device scan thread\n"); ++ ret = PTR_ERR(mhba->dm_thread); + mutex_unlock(&mhba->sas_discovery_mutex); + goto fail_create_thread; + } +diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c +index 3fda5836aac69..f10088a1d38c0 100644 +--- a/drivers/scsi/qla4xxx/ql4_os.c ++++ b/drivers/scsi/qla4xxx/ql4_os.c +@@ -1223,7 +1223,7 @@ static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len) + le64_to_cpu(ql_iscsi_stats->iscsi_sequence_error); + exit_host_stats: + if (ql_iscsi_stats) +- dma_free_coherent(&ha->pdev->dev, host_stats_size, ++ dma_free_coherent(&ha->pdev->dev, stats_size, + ql_iscsi_stats, iscsi_stats_dma); + + ql4_printk(KERN_INFO, ha, "%s: Get host stats done\n", +diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c +index 5997b17311113..cba662c50f919 100644 +--- a/drivers/tty/hvc/hvcs.c ++++ b/drivers/tty/hvc/hvcs.c +@@ -1232,13 +1232,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp) + + tty_wait_until_sent(tty, HVCS_CLOSE_WAIT); + +- /* +- * This line is important because it tells hvcs_open that this +- * device needs to be re-configured the next time hvcs_open is +- * called. +- */ +- tty->driver_data = NULL; +- + free_irq(irq, hvcsd); + return; + } else if (hvcsd->port.count < 0) { +@@ -1254,6 +1247,13 @@ static void hvcs_cleanup(struct tty_struct * tty) + { + struct hvcs_struct *hvcsd = tty->driver_data; + ++ /* ++ * This line is important because it tells hvcs_open that this ++ * device needs to be re-configured the next time hvcs_open is ++ * called. ++ */ ++ tty->driver_data = NULL; ++ + tty_port_put(&hvcsd->port); + } + +diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c +index c0dfb642383b2..dc7f4eb18e0a7 100644 +--- a/drivers/tty/ipwireless/network.c ++++ b/drivers/tty/ipwireless/network.c +@@ -116,7 +116,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel, + skb->len, + notify_packet_sent, + network); +- if (ret == -1) { ++ if (ret < 0) { + skb_pull(skb, 2); + return 0; + } +@@ -133,7 +133,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel, + notify_packet_sent, + network); + kfree(buf); +- if (ret == -1) ++ if (ret < 0) + return 0; + } + kfree_skb(skb); +diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c +index 345cebb07ae79..0b06b1847450f 100644 +--- a/drivers/tty/ipwireless/tty.c ++++ b/drivers/tty/ipwireless/tty.c +@@ -217,7 +217,7 @@ static int ipw_write(struct tty_struct *linux_tty, + ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS, + buf, count, + ipw_write_packet_sent_callback, tty); +- if (ret == -1) { ++ if (ret < 0) { + mutex_unlock(&tty->ipw_tty_mutex); + return 0; + } +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c +index c8a2e5b0eff76..8ee146b14aae8 100644 +--- a/drivers/tty/pty.c ++++ b/drivers/tty/pty.c +@@ -115,10 +115,10 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) + spin_lock_irqsave(&to->port->lock, flags); + /* Stuff the data into the input queue of the other end */ + c = tty_insert_flip_string(to->port, buf, c); ++ spin_unlock_irqrestore(&to->port->lock, flags); + /* And shovel */ + if (c) + tty_flip_buffer_push(to->port); +- spin_unlock_irqrestore(&to->port->lock, flags); + } + return c; + } +diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig +index f38beb28e7ae6..5c3c86d4fe716 100644 +--- a/drivers/tty/serial/Kconfig ++++ b/drivers/tty/serial/Kconfig +@@ -9,6 +9,7 @@ menu "Serial drivers" + + config SERIAL_EARLYCON + bool ++ depends on SERIAL_CORE + help + Support for early consoles with the earlycon parameter. This enables + the console before standard serial driver is probed. The console is +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c +index 515839034dfbc..fb7e56fad41c8 100644 +--- a/drivers/usb/class/cdc-acm.c ++++ b/drivers/usb/class/cdc-acm.c +@@ -1897,6 +1897,17 @@ static const struct usb_device_id acm_ids[] = { + .driver_info = IGNORE_DEVICE, + }, + ++ /* Exclude ETAS ES58x */ ++ { USB_DEVICE(0x108c, 0x0159), /* ES581.4 */ ++ .driver_info = IGNORE_DEVICE, ++ }, ++ { USB_DEVICE(0x108c, 0x0168), /* ES582.1 */ ++ .driver_info = IGNORE_DEVICE, ++ }, ++ { USB_DEVICE(0x108c, 0x0169), /* ES584.1 */ ++ .driver_info = IGNORE_DEVICE, ++ }, ++ + { USB_DEVICE(0x1bc7, 0x0021), /* Telit 3G ACM only composition */ + .driver_info = SEND_ZERO_PACKET, + }, +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c +index 1a1d1cfc3704c..35ee2233ad170 100644 +--- a/drivers/usb/class/cdc-wdm.c ++++ b/drivers/usb/class/cdc-wdm.c +@@ -61,6 +61,9 @@ MODULE_DEVICE_TABLE (usb, wdm_ids); + + #define WDM_MAX 16 + ++/* we cannot wait forever at flush() */ ++#define WDM_FLUSH_TIMEOUT (30 * HZ) ++ + /* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */ + #define WDM_DEFAULT_BUFSIZE 256 + +@@ -151,7 +154,7 @@ static void wdm_out_callback(struct urb *urb) + kfree(desc->outbuf); + desc->outbuf = NULL; + clear_bit(WDM_IN_USE, &desc->flags); +- wake_up(&desc->wait); ++ wake_up_all(&desc->wait); + } + + static void wdm_in_callback(struct urb *urb) +@@ -382,6 +385,9 @@ static ssize_t wdm_write + if (test_bit(WDM_RESETTING, &desc->flags)) + r = -EIO; + ++ if (test_bit(WDM_DISCONNECTING, &desc->flags)) ++ r = -ENODEV; ++ + if (r < 0) { + rv = r; + goto out_free_mem_pm; +@@ -413,6 +419,7 @@ static ssize_t wdm_write + if (rv < 0) { + desc->outbuf = NULL; + clear_bit(WDM_IN_USE, &desc->flags); ++ wake_up_all(&desc->wait); /* for wdm_wait_for_response() */ + dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); + rv = usb_translate_errors(rv); + goto out_free_mem_pm; +@@ -573,28 +580,58 @@ err: + return rv; + } + +-static int wdm_flush(struct file *file, fl_owner_t id) ++static int wdm_wait_for_response(struct file *file, long timeout) + { + struct wdm_device *desc = file->private_data; ++ long rv; /* Use long here because (int) MAX_SCHEDULE_TIMEOUT < 0. */ + +- wait_event(desc->wait, +- /* +- * needs both flags. We cannot do with one +- * because resetting it would cause a race +- * with write() yet we need to signal +- * a disconnect +- */ +- !test_bit(WDM_IN_USE, &desc->flags) || +- test_bit(WDM_DISCONNECTING, &desc->flags)); +- +- /* cannot dereference desc->intf if WDM_DISCONNECTING */ ++ /* ++ * Needs both flags. We cannot do with one because resetting it would ++ * cause a race with write() yet we need to signal a disconnect. ++ */ ++ rv = wait_event_interruptible_timeout(desc->wait, ++ !test_bit(WDM_IN_USE, &desc->flags) || ++ test_bit(WDM_DISCONNECTING, &desc->flags), ++ timeout); ++ ++ /* ++ * To report the correct error. This is best effort. ++ * We are inevitably racing with the hardware. ++ */ + if (test_bit(WDM_DISCONNECTING, &desc->flags)) + return -ENODEV; +- if (desc->werr < 0) +- dev_err(&desc->intf->dev, "Error in flush path: %d\n", +- desc->werr); ++ if (!rv) ++ return -EIO; ++ if (rv < 0) ++ return -EINTR; + +- return usb_translate_errors(desc->werr); ++ spin_lock_irq(&desc->iuspin); ++ rv = desc->werr; ++ desc->werr = 0; ++ spin_unlock_irq(&desc->iuspin); ++ ++ return usb_translate_errors(rv); ++ ++} ++ ++/* ++ * You need to send a signal when you react to malicious or defective hardware. ++ * Also, don't abort when fsync() returned -EINVAL, for older kernels which do ++ * not implement wdm_flush() will return -EINVAL. ++ */ ++static int wdm_fsync(struct file *file, loff_t start, loff_t end, int datasync) ++{ ++ return wdm_wait_for_response(file, MAX_SCHEDULE_TIMEOUT); ++} ++ ++/* ++ * Same with wdm_fsync(), except it uses finite timeout in order to react to ++ * malicious or defective hardware which ceased communication after close() was ++ * implicitly called due to process termination. ++ */ ++static int wdm_flush(struct file *file, fl_owner_t id) ++{ ++ return wdm_wait_for_response(file, WDM_FLUSH_TIMEOUT); + } + + static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait) +@@ -719,6 +756,7 @@ static const struct file_operations wdm_fops = { + .owner = THIS_MODULE, + .read = wdm_read, + .write = wdm_write, ++ .fsync = wdm_fsync, + .open = wdm_open, + .flush = wdm_flush, + .release = wdm_release, +diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c +index c095cde55329c..8c4bfd42f785d 100644 +--- a/drivers/usb/core/urb.c ++++ b/drivers/usb/core/urb.c +@@ -767,11 +767,12 @@ void usb_block_urb(struct urb *urb) + EXPORT_SYMBOL_GPL(usb_block_urb); + + /** +- * usb_kill_anchored_urbs - cancel transfer requests en masse ++ * usb_kill_anchored_urbs - kill all URBs associated with an anchor + * @anchor: anchor the requests are bound to + * +- * this allows all outstanding URBs to be killed starting +- * from the back of the queue ++ * This kills all outstanding URBs starting from the back of the queue, ++ * with guarantee that no completer callbacks will take place from the ++ * anchor after this function returns. + * + * This routine should not be called by a driver after its disconnect + * method has returned. +@@ -779,20 +780,26 @@ EXPORT_SYMBOL_GPL(usb_block_urb); + void usb_kill_anchored_urbs(struct usb_anchor *anchor) + { + struct urb *victim; ++ int surely_empty; + +- spin_lock_irq(&anchor->lock); +- while (!list_empty(&anchor->urb_list)) { +- victim = list_entry(anchor->urb_list.prev, struct urb, +- anchor_list); +- /* we must make sure the URB isn't freed before we kill it*/ +- usb_get_urb(victim); +- spin_unlock_irq(&anchor->lock); +- /* this will unanchor the URB */ +- usb_kill_urb(victim); +- usb_put_urb(victim); ++ do { + spin_lock_irq(&anchor->lock); +- } +- spin_unlock_irq(&anchor->lock); ++ while (!list_empty(&anchor->urb_list)) { ++ victim = list_entry(anchor->urb_list.prev, ++ struct urb, anchor_list); ++ /* make sure the URB isn't freed before we kill it */ ++ usb_get_urb(victim); ++ spin_unlock_irq(&anchor->lock); ++ /* this will unanchor the URB */ ++ usb_kill_urb(victim); ++ usb_put_urb(victim); ++ spin_lock_irq(&anchor->lock); ++ } ++ surely_empty = usb_anchor_check_wakeup(anchor); ++ ++ spin_unlock_irq(&anchor->lock); ++ cpu_relax(); ++ } while (!surely_empty); + } + EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); + +@@ -811,21 +818,27 @@ EXPORT_SYMBOL_GPL(usb_kill_anchored_urbs); + void usb_poison_anchored_urbs(struct usb_anchor *anchor) + { + struct urb *victim; ++ int surely_empty; + +- spin_lock_irq(&anchor->lock); +- anchor->poisoned = 1; +- while (!list_empty(&anchor->urb_list)) { +- victim = list_entry(anchor->urb_list.prev, struct urb, +- anchor_list); +- /* we must make sure the URB isn't freed before we kill it*/ +- usb_get_urb(victim); +- spin_unlock_irq(&anchor->lock); +- /* this will unanchor the URB */ +- usb_poison_urb(victim); +- usb_put_urb(victim); ++ do { + spin_lock_irq(&anchor->lock); +- } +- spin_unlock_irq(&anchor->lock); ++ anchor->poisoned = 1; ++ while (!list_empty(&anchor->urb_list)) { ++ victim = list_entry(anchor->urb_list.prev, ++ struct urb, anchor_list); ++ /* make sure the URB isn't freed before we kill it */ ++ usb_get_urb(victim); ++ spin_unlock_irq(&anchor->lock); ++ /* this will unanchor the URB */ ++ usb_poison_urb(victim); ++ usb_put_urb(victim); ++ spin_lock_irq(&anchor->lock); ++ } ++ surely_empty = usb_anchor_check_wakeup(anchor); ++ ++ spin_unlock_irq(&anchor->lock); ++ cpu_relax(); ++ } while (!surely_empty); + } + EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); + +@@ -965,14 +978,20 @@ void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) + { + struct urb *victim; + unsigned long flags; ++ int surely_empty; ++ ++ do { ++ spin_lock_irqsave(&anchor->lock, flags); ++ while (!list_empty(&anchor->urb_list)) { ++ victim = list_entry(anchor->urb_list.prev, ++ struct urb, anchor_list); ++ __usb_unanchor_urb(victim, anchor); ++ } ++ surely_empty = usb_anchor_check_wakeup(anchor); + +- spin_lock_irqsave(&anchor->lock, flags); +- while (!list_empty(&anchor->urb_list)) { +- victim = list_entry(anchor->urb_list.prev, struct urb, +- anchor_list); +- __usb_unanchor_urb(victim, anchor); +- } +- spin_unlock_irqrestore(&anchor->lock, flags); ++ spin_unlock_irqrestore(&anchor->lock, flags); ++ cpu_relax(); ++ } while (!surely_empty); + } + + EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); +diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c +index 69afc17fca38f..7b21ef09fffc2 100644 +--- a/drivers/usb/gadget/function/f_printer.c ++++ b/drivers/usb/gadget/function/f_printer.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -69,7 +70,7 @@ struct printer_dev { + struct usb_gadget *gadget; + s8 interface; + struct usb_ep *in_ep, *out_ep; +- ++ struct kref kref; + struct list_head rx_reqs; /* List of free RX structs */ + struct list_head rx_reqs_active; /* List of Active RX xfers */ + struct list_head rx_buffers; /* List of completed xfers */ +@@ -223,6 +224,13 @@ static inline struct usb_endpoint_descriptor *ep_desc(struct usb_gadget *gadget, + + /*-------------------------------------------------------------------------*/ + ++static void printer_dev_free(struct kref *kref) ++{ ++ struct printer_dev *dev = container_of(kref, struct printer_dev, kref); ++ ++ kfree(dev); ++} ++ + static struct usb_request * + printer_req_alloc(struct usb_ep *ep, unsigned len, gfp_t gfp_flags) + { +@@ -353,6 +361,7 @@ printer_open(struct inode *inode, struct file *fd) + + spin_unlock_irqrestore(&dev->lock, flags); + ++ kref_get(&dev->kref); + DBG(dev, "printer_open returned %x\n", ret); + return ret; + } +@@ -370,6 +379,7 @@ printer_close(struct inode *inode, struct file *fd) + dev->printer_status &= ~PRINTER_SELECTED; + spin_unlock_irqrestore(&dev->lock, flags); + ++ kref_put(&dev->kref, printer_dev_free); + DBG(dev, "printer_close\n"); + + return 0; +@@ -1316,7 +1326,8 @@ static void gprinter_free(struct usb_function *f) + struct f_printer_opts *opts; + + opts = container_of(f->fi, struct f_printer_opts, func_inst); +- kfree(dev); ++ ++ kref_put(&dev->kref, printer_dev_free); + mutex_lock(&opts->lock); + --opts->refcnt; + mutex_unlock(&opts->lock); +@@ -1385,6 +1396,7 @@ static struct usb_function *gprinter_alloc(struct usb_function_instance *fi) + return ERR_PTR(-ENOMEM); + } + ++ kref_init(&dev->kref); + ++opts->refcnt; + dev->minor = opts->minor; + dev->pnp_string = opts->pnp_string; +diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c +index e69f20b2a3f44..46c50135ef9f7 100644 +--- a/drivers/usb/gadget/function/u_ether.c ++++ b/drivers/usb/gadget/function/u_ether.c +@@ -96,7 +96,7 @@ struct eth_dev { + static inline int qlen(struct usb_gadget *gadget, unsigned qmult) + { + if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH || +- gadget->speed == USB_SPEED_SUPER)) ++ gadget->speed >= USB_SPEED_SUPER)) + return qmult * DEFAULT_QLEN; + else + return DEFAULT_QLEN; +diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c +index 27bd3e49fe8e3..07d76d9d4ce1b 100644 +--- a/drivers/usb/host/ohci-hcd.c ++++ b/drivers/usb/host/ohci-hcd.c +@@ -663,20 +663,24 @@ retry: + + /* handle root hub init quirks ... */ + val = roothub_a (ohci); +- val &= ~(RH_A_PSM | RH_A_OCPM); ++ /* Configure for per-port over-current protection by default */ ++ val &= ~RH_A_NOCP; ++ val |= RH_A_OCPM; + if (ohci->flags & OHCI_QUIRK_SUPERIO) { +- /* NSC 87560 and maybe others */ ++ /* NSC 87560 and maybe others. ++ * Ganged power switching, no over-current protection. ++ */ + val |= RH_A_NOCP; +- val &= ~(RH_A_POTPGT | RH_A_NPS); +- ohci_writel (ohci, val, &ohci->regs->roothub.a); ++ val &= ~(RH_A_POTPGT | RH_A_NPS | RH_A_PSM | RH_A_OCPM); + } else if ((ohci->flags & OHCI_QUIRK_AMD756) || + (ohci->flags & OHCI_QUIRK_HUB_POWER)) { + /* hub power always on; required for AMD-756 and some +- * Mac platforms. ganged overcurrent reporting, if any. ++ * Mac platforms. + */ + val |= RH_A_NPS; +- ohci_writel (ohci, val, &ohci->regs->roothub.a); + } ++ ohci_writel(ohci, val, &ohci->regs->roothub.a); ++ + ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status); + ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM, + &ohci->regs->roothub.b); +diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c +index f7d48661aa944..af4f7ebb45a79 100644 +--- a/drivers/vfio/pci/vfio_pci_intrs.c ++++ b/drivers/vfio/pci/vfio_pci_intrs.c +@@ -364,11 +364,13 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, + vdev->ctx[vector].producer.token = trigger; + vdev->ctx[vector].producer.irq = irq; + ret = irq_bypass_register_producer(&vdev->ctx[vector].producer); +- if (unlikely(ret)) ++ if (unlikely(ret)) { + dev_info(&pdev->dev, + "irq bypass producer (token %p) registration fails: %d\n", + vdev->ctx[vector].producer.token, ret); + ++ vdev->ctx[vector].producer.token = NULL; ++ } + vdev->ctx[vector].trigger = trigger; + + return 0; +diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c +index d414c7a3acf5a..a2f77625b7170 100644 +--- a/drivers/video/backlight/sky81452-backlight.c ++++ b/drivers/video/backlight/sky81452-backlight.c +@@ -207,6 +207,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt( + num_entry); + if (ret < 0) { + dev_err(dev, "led-sources node is invalid.\n"); ++ of_node_put(np); + return ERR_PTR(-EINVAL); + } + +diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c +index dfe3eb769638b..fde27feae5d0c 100644 +--- a/drivers/video/fbdev/sis/init.c ++++ b/drivers/video/fbdev/sis/init.c +@@ -2428,6 +2428,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + + i = 0; + ++ if (SiS_Pr->ChipType == SIS_730) ++ queuedata = &FQBQData730[0]; ++ else ++ queuedata = &FQBQData[0]; ++ + if(ModeNo > 0x13) { + + /* Get VCLK */ +@@ -2445,12 +2450,6 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, + /* Get half colordepth */ + colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; + +- if(SiS_Pr->ChipType == SIS_730) { +- queuedata = &FQBQData730[0]; +- } else { +- queuedata = &FQBQData[0]; +- } +- + do { + templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth; + +diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c +index 1acdb41a8a7c3..06cee2a40a9bf 100644 +--- a/drivers/video/fbdev/vga16fb.c ++++ b/drivers/video/fbdev/vga16fb.c +@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info) + } + + static void vga16fb_clock_chip(struct vga16fb_par *par, +- unsigned int pixclock, ++ unsigned int *pixclock, + const struct fb_info *info, + int mul, int div) + { +@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par, + { 0 /* bad */, 0x00, 0x00}}; + int err; + +- pixclock = (pixclock * mul) / div; ++ *pixclock = (*pixclock * mul) / div; + best = vgaclocks; +- err = pixclock - best->pixclock; ++ err = *pixclock - best->pixclock; + if (err < 0) err = -err; + for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) { + int tmp; + +- tmp = pixclock - ptr->pixclock; ++ tmp = *pixclock - ptr->pixclock; + if (tmp < 0) tmp = -tmp; + if (tmp < err) { + err = tmp; +@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par, + } + par->misc |= best->misc; + par->clkdiv = best->seq_clock_mode; +- pixclock = (best->pixclock * div) / mul; ++ *pixclock = (best->pixclock * div) / mul; + } + + #define FAIL(X) return -EINVAL +@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var, + + if (mode & MODE_8BPP) + /* pixel clock == vga clock / 2 */ +- vga16fb_clock_chip(par, var->pixclock, info, 1, 2); ++ vga16fb_clock_chip(par, &var->pixclock, info, 1, 2); + else + /* pixel clock == vga clock */ +- vga16fb_clock_chip(par, var->pixclock, info, 1, 1); ++ vga16fb_clock_chip(par, &var->pixclock, info, 1, 1); + + var->red.offset = var->green.offset = var->blue.offset = + var->transp.offset = 0; +diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c +index 9f96c7e61387d..0d11b5043db53 100644 +--- a/drivers/virt/fsl_hypervisor.c ++++ b/drivers/virt/fsl_hypervisor.c +@@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) + + unsigned int i; + long ret = 0; +- int num_pinned; /* return value from get_user_pages() */ ++ int num_pinned = 0; /* return value from get_user_pages_fast() */ + phys_addr_t remote_paddr; /* The next address in the remote buffer */ + uint32_t count; /* The number of bytes left to copy */ + +@@ -174,7 +174,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) + return -EINVAL; + + /* +- * The array of pages returned by get_user_pages() covers only ++ * The array of pages returned by get_user_pages_fast() covers only + * page-aligned memory. Since the user buffer is probably not + * page-aligned, we need to handle the discrepancy. + * +@@ -224,7 +224,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) + + /* + * 'pages' is an array of struct page pointers that's initialized by +- * get_user_pages(). ++ * get_user_pages_fast(). + */ + pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL); + if (!pages) { +@@ -241,7 +241,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) + if (!sg_list_unaligned) { + pr_debug("fsl-hv: could not allocate S/G list\n"); + ret = -ENOMEM; +- goto exit; ++ goto free_pages; + } + sg_list = PTR_ALIGN(sg_list_unaligned, sizeof(struct fh_sg_list)); + +@@ -254,7 +254,6 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) + up_read(¤t->mm->mmap_sem); + + if (num_pinned != num_pages) { +- /* get_user_pages() failed */ + pr_debug("fsl-hv: could not lock source buffer\n"); + ret = (num_pinned < 0) ? num_pinned : -EFAULT; + goto exit; +@@ -296,13 +295,13 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) + virt_to_phys(sg_list), num_pages); + + exit: +- if (pages) { +- for (i = 0; i < num_pages; i++) +- if (pages[i]) +- put_page(pages[i]); ++ if (pages && (num_pinned > 0)) { ++ for (i = 0; i < num_pinned; i++) ++ put_page(pages[i]); + } + + kfree(sg_list_unaligned); ++free_pages: + kfree(pages); + + if (!ret) +diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c +index a3b56544c21b9..ae1f2817bd6a6 100644 +--- a/fs/cifs/asn1.c ++++ b/fs/cifs/asn1.c +@@ -541,8 +541,8 @@ decode_negTokenInit(unsigned char *security_blob, int length, + return 0; + } else if ((cls != ASN1_CTX) || (con != ASN1_CON) + || (tag != ASN1_EOC)) { +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 0\n", +- cls, con, tag, end, *end); ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p exit 0\n", ++ cls, con, tag, end); + return 0; + } + +@@ -552,8 +552,8 @@ decode_negTokenInit(unsigned char *security_blob, int length, + return 0; + } else if ((cls != ASN1_UNI) || (con != ASN1_CON) + || (tag != ASN1_SEQ)) { +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 1\n", +- cls, con, tag, end, *end); ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p exit 1\n", ++ cls, con, tag, end); + return 0; + } + +@@ -563,8 +563,8 @@ decode_negTokenInit(unsigned char *security_blob, int length, + return 0; + } else if ((cls != ASN1_CTX) || (con != ASN1_CON) + || (tag != ASN1_EOC)) { +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 0\n", +- cls, con, tag, end, *end); ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p exit 0\n", ++ cls, con, tag, end); + return 0; + } + +@@ -575,8 +575,8 @@ decode_negTokenInit(unsigned char *security_blob, int length, + return 0; + } else if ((cls != ASN1_UNI) || (con != ASN1_CON) + || (tag != ASN1_SEQ)) { +- cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 1\n", +- cls, con, tag, end, *end); ++ cifs_dbg(FYI, "cls = %d con = %d tag = %d sequence_end = %p exit 1\n", ++ cls, con, tag, sequence_end); + return 0; + } + +diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c +index d284f07eda775..38260c07de8b5 100644 +--- a/fs/ntfs/inode.c ++++ b/fs/ntfs/inode.c +@@ -1844,6 +1844,12 @@ int ntfs_read_inode_mount(struct inode *vi) + brelse(bh); + } + ++ if (le32_to_cpu(m->bytes_allocated) != vol->mft_record_size) { ++ ntfs_error(sb, "Incorrect mft record size %u in superblock, should be %u.", ++ le32_to_cpu(m->bytes_allocated), vol->mft_record_size); ++ goto err_out; ++ } ++ + /* Apply the mst fixups. */ + if (post_read_mst_fixup((NTFS_RECORD*)m, vol->mft_record_size)) { + /* FIXME: Try to use the $MFTMirr now. */ +diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c +index 2aa012a68e90e..9891b8fb0432f 100644 +--- a/fs/quota/quota_v2.c ++++ b/fs/quota/quota_v2.c +@@ -266,6 +266,7 @@ static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot) + d->dqb_curspace = cpu_to_le64(m->dqb_curspace); + d->dqb_btime = cpu_to_le64(m->dqb_btime); + d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id)); ++ d->dqb_pad = 0; + if (qtree_entry_unused(info, dp)) + d->dqb_itime = cpu_to_le64(1); + } +diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c +index cfb4691d92741..ccbb15ab029f4 100644 +--- a/fs/reiserfs/inode.c ++++ b/fs/reiserfs/inode.c +@@ -2157,7 +2157,8 @@ out_end_trans: + out_inserted_sd: + clear_nlink(inode); + th->t_trans_id = 0; /* so the caller can't use this handle later */ +- unlock_new_inode(inode); /* OK to do even if we hadn't locked it */ ++ if (inode->i_state & I_NEW) ++ unlock_new_inode(inode); + iput(inode); + return err; + } +diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c +index f9796fd515315..503d8c06e0d93 100644 +--- a/fs/reiserfs/super.c ++++ b/fs/reiserfs/super.c +@@ -1232,6 +1232,10 @@ static int reiserfs_parse_options(struct super_block *s, + "turned on."); + return 0; + } ++ if (qf_names[qtype] != ++ REISERFS_SB(s)->s_qf_names[qtype]) ++ kfree(qf_names[qtype]); ++ qf_names[qtype] = NULL; + if (*arg) { /* Some filename specified? */ + if (REISERFS_SB(s)->s_qf_names[qtype] + && strcmp(REISERFS_SB(s)->s_qf_names[qtype], +@@ -1261,10 +1265,6 @@ static int reiserfs_parse_options(struct super_block *s, + else + *mount_options |= 1 << REISERFS_GRPQUOTA; + } else { +- if (qf_names[qtype] != +- REISERFS_SB(s)->s_qf_names[qtype]) +- kfree(qf_names[qtype]); +- qf_names[qtype] = NULL; + if (qtype == USRQUOTA) + *mount_options &= ~(1 << REISERFS_USRQUOTA); + else +diff --git a/fs/udf/inode.c b/fs/udf/inode.c +index 3876448ec0dcb..2c39c1c81196c 100644 +--- a/fs/udf/inode.c ++++ b/fs/udf/inode.c +@@ -140,21 +140,24 @@ void udf_evict_inode(struct inode *inode) + struct udf_inode_info *iinfo = UDF_I(inode); + int want_delete = 0; + +- if (!inode->i_nlink && !is_bad_inode(inode)) { +- want_delete = 1; +- udf_setsize(inode, 0); +- udf_update_inode(inode, IS_SYNC(inode)); ++ if (!is_bad_inode(inode)) { ++ if (!inode->i_nlink) { ++ want_delete = 1; ++ udf_setsize(inode, 0); ++ udf_update_inode(inode, IS_SYNC(inode)); ++ } ++ if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && ++ inode->i_size != iinfo->i_lenExtents) { ++ udf_warn(inode->i_sb, ++ "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n", ++ inode->i_ino, inode->i_mode, ++ (unsigned long long)inode->i_size, ++ (unsigned long long)iinfo->i_lenExtents); ++ } + } + truncate_inode_pages_final(&inode->i_data); + invalidate_inode_buffers(inode); + clear_inode(inode); +- if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && +- inode->i_size != iinfo->i_lenExtents) { +- udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n", +- inode->i_ino, inode->i_mode, +- (unsigned long long)inode->i_size, +- (unsigned long long)iinfo->i_lenExtents); +- } + kfree(iinfo->i_ext.i_data); + iinfo->i_ext.i_data = NULL; + udf_clear_extent_cache(inode); +diff --git a/fs/udf/super.c b/fs/udf/super.c +index 159977ec8e548..710f1b8fad9bf 100644 +--- a/fs/udf/super.c ++++ b/fs/udf/super.c +@@ -1390,6 +1390,12 @@ static int udf_load_sparable_map(struct super_block *sb, + (int)spm->numSparingTables); + return -EIO; + } ++ if (le32_to_cpu(spm->sizeSparingTable) > sb->s_blocksize) { ++ udf_err(sb, "error loading logical volume descriptor: " ++ "Too big sparing table size (%u)\n", ++ le32_to_cpu(spm->sizeSparingTable)); ++ return -EIO; ++ } + + for (i = 0; i < spm->numSparingTables; i++) { + loc = le32_to_cpu(spm->locSparingTable[i]); +diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c +index 919b6544b61a3..bda5248fc6498 100644 +--- a/fs/xfs/xfs_rtalloc.c ++++ b/fs/xfs/xfs_rtalloc.c +@@ -256,6 +256,9 @@ xfs_rtallocate_extent_block( + end = XFS_BLOCKTOBIT(mp, bbno + 1) - 1; + i <= end; + i++) { ++ /* Make sure we don't scan off the end of the rt volume. */ ++ maxlen = min(mp->m_sb.sb_rextents, i + maxlen) - i; ++ + /* + * See if there's a free extent of maxlen starting at i. + * If it's not so then next will contain the first non-free. +@@ -447,6 +450,14 @@ xfs_rtallocate_extent_near( + */ + if (bno >= mp->m_sb.sb_rextents) + bno = mp->m_sb.sb_rextents - 1; ++ ++ /* Make sure we don't run off the end of the rt volume. */ ++ maxlen = min(mp->m_sb.sb_rextents, bno + maxlen) - bno; ++ if (maxlen < minlen) { ++ *rtblock = NULLRTBLOCK; ++ return 0; ++ } ++ + /* + * Try the exact allocation first. + */ +diff --git a/include/linux/compiler.h b/include/linux/compiler.h +index e5d349d65ae93..7cabe0cc86651 100644 +--- a/include/linux/compiler.h ++++ b/include/linux/compiler.h +@@ -241,23 +241,21 @@ void __read_once_size(const volatile void *p, void *res, int size) + + #ifdef CONFIG_KASAN + /* +- * This function is not 'inline' because __no_sanitize_address confilcts ++ * We can't declare function 'inline' because __no_sanitize_address confilcts + * with inlining. Attempt to inline it may cause a build failure. + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 + * '__maybe_unused' allows us to avoid defined-but-not-used warnings. + */ +-static __no_sanitize_address __maybe_unused +-void __read_once_size_nocheck(const volatile void *p, void *res, int size) +-{ +- __READ_ONCE_SIZE; +-} ++# define __no_kasan_or_inline __no_sanitize_address __maybe_unused + #else +-static __always_inline ++# define __no_kasan_or_inline __always_inline ++#endif ++ ++static __no_kasan_or_inline + void __read_once_size_nocheck(const volatile void *p, void *res, int size) + { + __READ_ONCE_SIZE; + } +-#endif + + static __always_inline void __write_once_size(volatile void *p, void *res, int size) + { +@@ -294,6 +292,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s + * with an explicit memory barrier or atomic instruction that provides the + * required ordering. + */ ++#include + + #define __READ_ONCE(x, check) \ + ({ \ +@@ -312,6 +311,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s + */ + #define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) + ++static __no_kasan_or_inline ++unsigned long read_word_at_a_time(const void *addr) ++{ ++ kasan_check_read(addr, 1); ++ return *(unsigned long *)addr; ++} ++ + #define WRITE_ONCE(x, val) \ + ({ \ + union { typeof(x) __val; char __c[1]; } __u = \ +diff --git a/include/linux/kasan-checks.h b/include/linux/kasan-checks.h +new file mode 100644 +index 0000000000000..b7f8aced78707 +--- /dev/null ++++ b/include/linux/kasan-checks.h +@@ -0,0 +1,12 @@ ++#ifndef _LINUX_KASAN_CHECKS_H ++#define _LINUX_KASAN_CHECKS_H ++ ++#ifdef CONFIG_KASAN ++void kasan_check_read(const void *p, unsigned int size); ++void kasan_check_write(const void *p, unsigned int size); ++#else ++static inline void kasan_check_read(const void *p, unsigned int size) { } ++static inline void kasan_check_write(const void *p, unsigned int size) { } ++#endif ++ ++#endif +diff --git a/include/net/ip.h b/include/net/ip.h +index 6067b7a10ccd2..5c9de851a9191 100644 +--- a/include/net/ip.h ++++ b/include/net/ip.h +@@ -317,12 +317,18 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, + bool forwarding) + { + struct net *net = dev_net(dst->dev); ++ unsigned int mtu; + + if (net->ipv4.sysctl_ip_fwd_use_pmtu || + ip_mtu_locked(dst) || + !forwarding) + return dst_mtu(dst); + ++ /* 'forwarding = true' case should always honour route mtu */ ++ mtu = dst_metric_raw(dst, RTAX_MTU); ++ if (mtu) ++ return mtu; ++ + return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU); + } + +diff --git a/include/scsi/scsi_common.h b/include/scsi/scsi_common.h +index 11571b2a831e3..92ba09200f89b 100644 +--- a/include/scsi/scsi_common.h ++++ b/include/scsi/scsi_common.h +@@ -24,6 +24,13 @@ scsi_command_size(const unsigned char *cmnd) + scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]); + } + ++static inline unsigned char ++scsi_command_control(const unsigned char *cmnd) ++{ ++ return (cmnd[0] == VARIABLE_LENGTH_CMD) ? ++ cmnd[1] : cmnd[COMMAND_SIZE(cmnd[0]) - 1]; ++} ++ + /* Returns a human-readable name for the device */ + extern const char *scsi_device_type(unsigned type); + +diff --git a/include/trace/events/target.h b/include/trace/events/target.h +index 50fea660c0f89..d543e8b87e50a 100644 +--- a/include/trace/events/target.h ++++ b/include/trace/events/target.h +@@ -139,6 +139,7 @@ TRACE_EVENT(target_sequencer_start, + __field( unsigned int, opcode ) + __field( unsigned int, data_length ) + __field( unsigned int, task_attribute ) ++ __field( unsigned char, control ) + __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE ) + __string( initiator, cmd->se_sess->se_node_acl->initiatorname ) + ), +@@ -148,6 +149,7 @@ TRACE_EVENT(target_sequencer_start, + __entry->opcode = cmd->t_task_cdb[0]; + __entry->data_length = cmd->data_length; + __entry->task_attribute = cmd->sam_task_attr; ++ __entry->control = scsi_command_control(cmd->t_task_cdb); + memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE); + __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname); + ), +@@ -157,9 +159,7 @@ TRACE_EVENT(target_sequencer_start, + show_opcode_name(__entry->opcode), + __entry->data_length, __print_hex(__entry->cdb, 16), + show_task_attribute_name(__entry->task_attribute), +- scsi_command_size(__entry->cdb) <= 16 ? +- __entry->cdb[scsi_command_size(__entry->cdb) - 1] : +- __entry->cdb[1] ++ __entry->control + ) + ); + +@@ -174,6 +174,7 @@ TRACE_EVENT(target_cmd_complete, + __field( unsigned int, opcode ) + __field( unsigned int, data_length ) + __field( unsigned int, task_attribute ) ++ __field( unsigned char, control ) + __field( unsigned char, scsi_status ) + __field( unsigned char, sense_length ) + __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE ) +@@ -186,6 +187,7 @@ TRACE_EVENT(target_cmd_complete, + __entry->opcode = cmd->t_task_cdb[0]; + __entry->data_length = cmd->data_length; + __entry->task_attribute = cmd->sam_task_attr; ++ __entry->control = scsi_command_control(cmd->t_task_cdb); + __entry->scsi_status = cmd->scsi_status; + __entry->sense_length = cmd->scsi_status == SAM_STAT_CHECK_CONDITION ? + min(18, ((u8 *) cmd->sense_buffer)[SPC_ADD_SENSE_LEN_OFFSET] + 8) : 0; +@@ -202,9 +204,7 @@ TRACE_EVENT(target_cmd_complete, + show_opcode_name(__entry->opcode), + __entry->data_length, __print_hex(__entry->cdb, 16), + show_task_attribute_name(__entry->task_attribute), +- scsi_command_size(__entry->cdb) <= 16 ? +- __entry->cdb[scsi_command_size(__entry->cdb) - 1] : +- __entry->cdb[1] ++ __entry->control + ) + ); + +diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c +index cc892a9e109d8..ae39b014b7d6c 100644 +--- a/kernel/debug/kdb/kdb_io.c ++++ b/kernel/debug/kdb/kdb_io.c +@@ -683,12 +683,16 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) + size_avail = sizeof(kdb_buffer) - len; + goto kdb_print_out; + } +- if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH) ++ if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH) { + /* + * This was a interactive search (using '/' at more +- * prompt) and it has completed. Clear the flag. ++ * prompt) and it has completed. Replace the \0 with ++ * its original value to ensure multi-line strings ++ * are handled properly, and return to normal mode. + */ ++ *cphold = replaced_byte; + kdb_grepping_flag = 0; ++ } + /* + * at this point the string is a full line and + * should be printed, up to the null. +diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c +index 3124cebaec31e..7d73b30c55ccd 100644 +--- a/kernel/power/hibernate.c ++++ b/kernel/power/hibernate.c +@@ -779,17 +779,6 @@ static int software_resume(void) + + /* Check if the device is there */ + swsusp_resume_device = name_to_dev_t(resume_file); +- +- /* +- * name_to_dev_t is ineffective to verify parition if resume_file is in +- * integer format. (e.g. major:minor) +- */ +- if (isdigit(resume_file[0]) && resume_wait) { +- int partno; +- while (!get_gendisk(swsusp_resume_device, &partno)) +- msleep(10); +- } +- + if (!swsusp_resume_device) { + /* + * Some device discovery might still be in progress; we need +diff --git a/lib/crc32.c b/lib/crc32.c +index 9a907d489d951..eed675bcd6751 100644 +--- a/lib/crc32.c ++++ b/lib/crc32.c +@@ -327,7 +327,7 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p, + return crc; + } + +-#if CRC_LE_BITS == 1 ++#if CRC_BE_BITS == 1 + u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len) + { + return crc32_be_generic(crc, p, len, NULL, CRCPOLY_BE); +diff --git a/lib/string.c b/lib/string.c +index c9983dc01e727..7f4baad6fb193 100644 +--- a/lib/string.c ++++ b/lib/string.c +@@ -202,7 +202,7 @@ ssize_t strscpy(char *dest, const char *src, size_t count) + while (max >= sizeof(unsigned long)) { + unsigned long c, data; + +- c = *(unsigned long *)(src+res); ++ c = read_word_at_a_time(src+res); + if (has_zero(c, &data, &constants)) { + data = prep_zero_mask(c, data, &constants); + data = create_zero_mask(data); +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c +index e562385d9440e..30731ce390ba0 100644 +--- a/net/bluetooth/l2cap_sock.c ++++ b/net/bluetooth/l2cap_sock.c +@@ -1330,8 +1330,6 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err) + + parent = bt_sk(sk)->parent; + +- sock_set_flag(sk, SOCK_ZAPPED); +- + switch (chan->state) { + case BT_OPEN: + case BT_BOUND: +@@ -1358,8 +1356,11 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err) + + break; + } +- + release_sock(sk); ++ ++ /* Only zap after cleanup to avoid use after free race */ ++ sock_set_flag(sk, SOCK_ZAPPED); ++ + } + + static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state, +diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c +index 9a9f49b55abd7..c16c199d9cd99 100644 +--- a/net/ipv4/icmp.c ++++ b/net/ipv4/icmp.c +@@ -246,7 +246,7 @@ static struct { + /** + * icmp_global_allow - Are we allowed to send one more ICMP message ? + * +- * Uses a token bucket to limit our ICMP messages to sysctl_icmp_msgs_per_sec. ++ * Uses a token bucket to limit our ICMP messages to ~sysctl_icmp_msgs_per_sec. + * Returns false if we reached the limit and can not send another packet. + * Note: called with BH disabled + */ +@@ -274,7 +274,10 @@ bool icmp_global_allow(void) + } + credit = min_t(u32, icmp_global.credit + incr, sysctl_icmp_msgs_burst); + if (credit) { +- credit--; ++ /* We want to use a credit of one in average, but need to randomize ++ * it for security reasons. ++ */ ++ credit = max_t(int, credit - prandom_u32_max(3), 0); + rc = true; + } + WRITE_ONCE(icmp_global.credit, credit); +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c +index 9215ee1de4947..0919183b003fc 100644 +--- a/net/ipv4/tcp_input.c ++++ b/net/ipv4/tcp_input.c +@@ -5531,6 +5531,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, + tcp_data_snd_check(sk); + if (!inet_csk_ack_scheduled(sk)) + goto no_ack; ++ } else { ++ tcp_update_wl(tp, TCP_SKB_CB(skb)->seq); + } + + __tcp_ack_snd_check(sk, 0); +diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c +index b176f76dfaa14..c7ee962a547b9 100644 +--- a/net/netfilter/ipvs/ip_vs_ctl.c ++++ b/net/netfilter/ipvs/ip_vs_ctl.c +@@ -2383,6 +2383,10 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) + /* Set timeout values for (tcp tcpfin udp) */ + ret = ip_vs_set_timeout(ipvs, (struct ip_vs_timeout_user *)arg); + goto out_unlock; ++ } else if (!len) { ++ /* No more commands with len == 0 below */ ++ ret = -EINVAL; ++ goto out_unlock; + } + + usvc_compat = (struct ip_vs_service_user *)arg; +@@ -2459,9 +2463,6 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) + break; + case IP_VS_SO_SET_DELDEST: + ret = ip_vs_del_dest(svc, &udest); +- break; +- default: +- ret = -EINVAL; + } + + out_unlock: +diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c +index c9d5e9c621784..639e5cad0442c 100644 +--- a/net/nfc/netlink.c ++++ b/net/nfc/netlink.c +@@ -1190,7 +1190,7 @@ static int nfc_genl_fw_download(struct sk_buff *skb, struct genl_info *info) + u32 idx; + char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1]; + +- if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) ++ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME]) + return -EINVAL; + + idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); +diff --git a/net/tipc/msg.c b/net/tipc/msg.c +index fc1aa8bcb185d..30c3a7985fa4d 100644 +--- a/net/tipc/msg.c ++++ b/net/tipc/msg.c +@@ -138,7 +138,8 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) + if (fragid == FIRST_FRAGMENT) { + if (unlikely(head)) + goto err; +- frag = skb_unshare(frag, GFP_ATOMIC); ++ if (skb_cloned(frag)) ++ frag = skb_copy(frag, GFP_ATOMIC); + if (unlikely(!frag)) + goto err; + head = *headbuf = frag; +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c +index 95366e35ab134..7748d674677c9 100644 +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -1672,7 +1672,10 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, + * case we'll continue with more data in the next round, + * but break unconditionally so unsplit data stops here. + */ +- state->split_start++; ++ if (state->split) ++ state->split_start++; ++ else ++ state->split_start = 0; + break; + case 9: + if (rdev->wiphy.extended_capabilities && +diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c +index 5c87baaefafb6..0c0df76170aef 100644 +--- a/security/integrity/ima/ima_crypto.c ++++ b/security/integrity/ima/ima_crypto.c +@@ -555,6 +555,8 @@ static int __init ima_calc_boot_aggregate_tfm(char *digest, + ima_pcrread(i, pcr_i); + /* now accumulate with current aggregate */ + rc = crypto_shash_update(shash, pcr_i, TPM_DIGEST_SIZE); ++ if (rc != 0) ++ return rc; + } + if (!rc) + crypto_shash_final(shash, digest); +diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c +index 8044775999eda..4d1548b951c41 100644 +--- a/sound/core/seq/oss/seq_oss.c ++++ b/sound/core/seq/oss/seq_oss.c +@@ -186,9 +186,12 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + if (snd_BUG_ON(!dp)) + return -ENXIO; + +- mutex_lock(®ister_mutex); ++ if (cmd != SNDCTL_SEQ_SYNC && ++ mutex_lock_interruptible(®ister_mutex)) ++ return -ERESTARTSYS; + rc = snd_seq_oss_ioctl(dp, cmd, arg); +- mutex_unlock(®ister_mutex); ++ if (cmd != SNDCTL_SEQ_SYNC) ++ mutex_unlock(®ister_mutex); + return rc; + } + +diff --git a/sound/firewire/bebob/bebob_hwdep.c b/sound/firewire/bebob/bebob_hwdep.c +index ce731f4d8b4f5..733ba42e24622 100644 +--- a/sound/firewire/bebob/bebob_hwdep.c ++++ b/sound/firewire/bebob/bebob_hwdep.c +@@ -37,12 +37,11 @@ hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, + } + + memset(&event, 0, sizeof(event)); ++ count = min_t(long, count, sizeof(event.lock_status)); + if (bebob->dev_lock_changed) { + event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; + event.lock_status.status = (bebob->dev_lock_count > 0); + bebob->dev_lock_changed = false; +- +- count = min_t(long, count, sizeof(event.lock_status)); + } + + spin_unlock_irq(&bebob->lock); +diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c +index c8f2d084a8ce3..be5a7c1b36ff3 100644 +--- a/tools/perf/util/intel-pt.c ++++ b/tools/perf/util/intel-pt.c +@@ -794,6 +794,8 @@ static void intel_pt_set_pid_tid_cpu(struct intel_pt *pt, + + if (queue->tid == -1 || pt->have_sched_switch) { + ptq->tid = machine__get_current_tid(pt->machine, ptq->cpu); ++ if (ptq->tid == -1) ++ ptq->pid = -1; + thread__zput(ptq->thread); + } + +@@ -1634,10 +1636,8 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event, + tid = sample->tid; + } + +- if (tid == -1) { +- pr_err("context_switch event has no tid\n"); +- return -EINVAL; +- } ++ if (tid == -1) ++ intel_pt_log("context_switch event has no tid\n"); + + intel_pt_log("context_switch: cpu %d pid %d tid %d time %"PRIu64" tsc %#"PRIx64"\n", + cpu, pid, tid, sample->time, perf_time_to_tsc(sample->time, diff --git a/patch/kernel/rockpis-legacy/patch-4.4.241-242.patch b/patch/kernel/rockpis-legacy/patch-4.4.241-242.patch new file mode 100644 index 000000000..476d862f3 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.241-242.patch @@ -0,0 +1,2641 @@ +diff --git a/Makefile b/Makefile +index f475808037540..0ba3fd9144264 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 241 ++SUBLEVEL = 242 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S +index 5e3f1edf5a292..db1eee5fe5024 100644 +--- a/arch/arc/kernel/entry.S ++++ b/arch/arc/kernel/entry.S +@@ -168,6 +168,7 @@ END(EV_Extension) + tracesys: + ; save EFA in case tracer wants the PC of traced task + ; using ERET won't work since next-PC has already committed ++ lr r12, [efa] + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11 + st r12, [r11, THREAD_FAULT_ADDR] ; thread.fault_address + +@@ -210,9 +211,15 @@ tracesys_exit: + ; Breakpoint TRAP + ; --------------------------------------------- + trap_with_param: +- mov r0, r12 ; EFA in case ptracer/gdb wants stop_pc ++ ++ ; stop_pc info by gdb needs this info ++ lr r0, [efa] + mov r1, sp + ++ ; Now that we have read EFA, it is safe to do "fake" rtie ++ ; and get out of CPU exception mode ++ FAKE_RET_FROM_EXCPN ++ + ; Save callee regs in case gdb wants to have a look + ; SP will grow up by size of CALLEE Reg-File + ; NOTE: clobbers r12 +@@ -239,10 +246,6 @@ ENTRY(EV_Trap) + + EXCEPTION_PROLOGUE + +- lr r12, [efa] +- +- FAKE_RET_FROM_EXCPN +- + ;============ TRAP 1 :breakpoints + ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR) + bmsk.f 0, r9, 7 +@@ -250,6 +253,9 @@ ENTRY(EV_Trap) + + ;============ TRAP (no param): syscall top level + ++ ; First return from Exception to pure K mode (Exception/IRQs renabled) ++ FAKE_RET_FROM_EXCPN ++ + ; If syscall tracing ongoing, invoke pre-post-hooks + GET_CURR_THR_INFO_FLAGS r10 + btst r10, TIF_SYSCALL_TRACE +diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c +index 11b50959f20ed..5401e2bab3da2 100644 +--- a/arch/arc/kernel/stacktrace.c ++++ b/arch/arc/kernel/stacktrace.c +@@ -113,7 +113,7 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, + int (*consumer_fn) (unsigned int, void *), void *arg) + { + #ifdef CONFIG_ARC_DW2_UNWIND +- int ret = 0; ++ int ret = 0, cnt = 0; + unsigned int address; + struct unwind_frame_info frame_info; + +@@ -133,6 +133,11 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, + break; + + frame_info.regs.r63 = frame_info.regs.r31; ++ ++ if (cnt++ > 128) { ++ printk("unwinder looping too long, aborting !\n"); ++ return 0; ++ } + } + + return address; /* return the last address it saw */ +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig +index 45f2a5930379a..7da18cc30d101 100644 +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -676,7 +676,9 @@ config ARCH_S3C24XX + select HAVE_S3C_RTC if RTC_CLASS + select MULTI_IRQ_HANDLER + select NEED_MACH_IO_H ++ select S3C2410_WATCHDOG + select SAMSUNG_ATAGS ++ select WATCHDOG + help + Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443 + and S3C2450 SoCs based systems, such as the Simtec Electronics BAST +diff --git a/arch/arm/boot/dts/s5pv210.dtsi b/arch/arm/boot/dts/s5pv210.dtsi +index b03fe747b98ca..48bcab25720a5 100644 +--- a/arch/arm/boot/dts/s5pv210.dtsi ++++ b/arch/arm/boot/dts/s5pv210.dtsi +@@ -99,19 +99,16 @@ + }; + + clocks: clock-controller@e0100000 { +- compatible = "samsung,s5pv210-clock", "simple-bus"; ++ compatible = "samsung,s5pv210-clock"; + reg = <0xe0100000 0x10000>; + clock-names = "xxti", "xusbxti"; + clocks = <&xxti>, <&xusbxti>; + #clock-cells = <1>; +- #address-cells = <1>; +- #size-cells = <1>; +- ranges; ++ }; + +- pmu_syscon: syscon@e0108000 { +- compatible = "samsung-s5pv210-pmu", "syscon"; +- reg = <0xe0108000 0x8000>; +- }; ++ pmu_syscon: syscon@e0108000 { ++ compatible = "samsung-s5pv210-pmu", "syscon"; ++ reg = <0xe0108000 0x8000>; + }; + + pinctrl0: pinctrl@e0200000 { +@@ -228,43 +225,36 @@ + status = "disabled"; + }; + +- audio-subsystem { +- compatible = "samsung,s5pv210-audss", "simple-bus"; +- #address-cells = <1>; +- #size-cells = <1>; +- ranges; +- +- clk_audss: clock-controller@eee10000 { +- compatible = "samsung,s5pv210-audss-clock"; +- reg = <0xeee10000 0x1000>; +- clock-names = "hclk", "xxti", +- "fout_epll", +- "sclk_audio0"; +- clocks = <&clocks DOUT_HCLKP>, <&xxti>, +- <&clocks FOUT_EPLL>, +- <&clocks SCLK_AUDIO0>; +- #clock-cells = <1>; +- }; ++ clk_audss: clock-controller@eee10000 { ++ compatible = "samsung,s5pv210-audss-clock"; ++ reg = <0xeee10000 0x1000>; ++ clock-names = "hclk", "xxti", ++ "fout_epll", ++ "sclk_audio0"; ++ clocks = <&clocks DOUT_HCLKP>, <&xxti>, ++ <&clocks FOUT_EPLL>, ++ <&clocks SCLK_AUDIO0>; ++ #clock-cells = <1>; ++ }; + +- i2s0: i2s@eee30000 { +- compatible = "samsung,s5pv210-i2s"; +- reg = <0xeee30000 0x1000>; +- interrupt-parent = <&vic2>; +- interrupts = <16>; +- dma-names = "rx", "tx", "tx-sec"; +- dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>; +- clock-names = "iis", +- "i2s_opclk0", +- "i2s_opclk1"; +- clocks = <&clk_audss CLK_I2S>, +- <&clk_audss CLK_I2S>, +- <&clk_audss CLK_DOUT_AUD_BUS>; +- samsung,idma-addr = <0xc0010000>; +- pinctrl-names = "default"; +- pinctrl-0 = <&i2s0_bus>; +- #sound-dai-cells = <0>; +- status = "disabled"; +- }; ++ i2s0: i2s@eee30000 { ++ compatible = "samsung,s5pv210-i2s"; ++ reg = <0xeee30000 0x1000>; ++ interrupt-parent = <&vic2>; ++ interrupts = <16>; ++ dma-names = "rx", "tx", "tx-sec"; ++ dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>; ++ clock-names = "iis", ++ "i2s_opclk0", ++ "i2s_opclk1"; ++ clocks = <&clk_audss CLK_I2S>, ++ <&clk_audss CLK_I2S>, ++ <&clk_audss CLK_DOUT_AUD_BUS>; ++ samsung,idma-addr = <0xc0010000>; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&i2s0_bus>; ++ #sound-dai-cells = <0>; ++ status = "disabled"; + }; + + i2s1: i2s@e2100000 { +diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi +index aa90f319309ba..b8bbc8c187994 100644 +--- a/arch/arm/boot/dts/sun4i-a10.dtsi ++++ b/arch/arm/boot/dts/sun4i-a10.dtsi +@@ -137,7 +137,7 @@ + trips { + cpu_alert0: cpu_alert0 { + /* milliCelsius */ +- temperature = <850000>; ++ temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; +diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig +index b9396dcf836d2..ffdf9f2ca437b 100644 +--- a/arch/arm/plat-samsung/Kconfig ++++ b/arch/arm/plat-samsung/Kconfig +@@ -239,6 +239,7 @@ config SAMSUNG_PM_DEBUG + bool "Samsung PM Suspend debug" + depends on PM && DEBUG_KERNEL + depends on DEBUG_EXYNOS_UART || DEBUG_S3C24XX_UART || DEBUG_S3C2410_UART ++ depends on DEBUG_LL && MMU + help + Say Y here if you want verbose debugging from the PM Suspend and + Resume code. See +diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms +index 5edb50772c11b..5fef6284a0bcb 100644 +--- a/arch/arm64/Kconfig.platforms ++++ b/arch/arm64/Kconfig.platforms +@@ -9,6 +9,7 @@ config ARCH_BERLIN + bool "Marvell Berlin SoC Family" + select ARCH_REQUIRE_GPIOLIB + select DW_APB_ICTL ++ select DW_APB_TIMER_OF + help + This enables support for Marvell Berlin SoC Family + +diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile +index 9edda5466020d..bcd3668f1bb82 100644 +--- a/arch/ia64/kernel/Makefile ++++ b/arch/ia64/kernel/Makefile +@@ -42,7 +42,7 @@ endif + obj-$(CONFIG_INTEL_IOMMU) += pci-dma.o + obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o + +-obj-$(CONFIG_BINFMT_ELF) += elfcore.o ++obj-$(CONFIG_ELF_CORE) += elfcore.o + + # fp_emulate() expects f2-f5,f16-f31 to contain the user-level state. + CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31 +diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c +index e21e2c0af69d2..1a8b6e276a112 100644 +--- a/arch/powerpc/platforms/powernv/opal-dump.c ++++ b/arch/powerpc/platforms/powernv/opal-dump.c +@@ -385,13 +385,12 @@ static irqreturn_t process_dump(int irq, void *data) + { + int rc; + uint32_t dump_id, dump_size, dump_type; +- struct dump_obj *dump; + char name[22]; + struct kobject *kobj; + + rc = dump_read_info(&dump_id, &dump_size, &dump_type); + if (rc != OPAL_SUCCESS) +- return rc; ++ return IRQ_HANDLED; + + sprintf(name, "0x%x-0x%x", dump_type, dump_id); + +@@ -403,12 +402,10 @@ static irqreturn_t process_dump(int irq, void *data) + if (kobj) { + /* Drop reference added by kset_find_obj() */ + kobject_put(kobj); +- return 0; ++ return IRQ_HANDLED; + } + +- dump = create_dump_obj(dump_id, dump_size, dump_type); +- if (!dump) +- return -1; ++ create_dump_obj(dump_id, dump_size, dump_type); + + return IRQ_HANDLED; + } +diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c +index f2344cbd2f464..3595f3cfefa35 100644 +--- a/arch/powerpc/platforms/powernv/opal-elog.c ++++ b/arch/powerpc/platforms/powernv/opal-elog.c +@@ -183,14 +183,14 @@ static ssize_t raw_attr_read(struct file *filep, struct kobject *kobj, + return count; + } + +-static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type) ++static void create_elog_obj(uint64_t id, size_t size, uint64_t type) + { + struct elog_obj *elog; + int rc; + + elog = kzalloc(sizeof(*elog), GFP_KERNEL); + if (!elog) +- return NULL; ++ return; + + elog->kobj.kset = elog_kset; + +@@ -223,18 +223,37 @@ static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type) + rc = kobject_add(&elog->kobj, NULL, "0x%llx", id); + if (rc) { + kobject_put(&elog->kobj); +- return NULL; ++ return; + } + ++ /* ++ * As soon as the sysfs file for this elog is created/activated there is ++ * a chance the opal_errd daemon (or any userspace) might read and ++ * acknowledge the elog before kobject_uevent() is called. If that ++ * happens then there is a potential race between ++ * elog_ack_store->kobject_put() and kobject_uevent() which leads to a ++ * use-after-free of a kernfs object resulting in a kernel crash. ++ * ++ * To avoid that, we need to take a reference on behalf of the bin file, ++ * so that our reference remains valid while we call kobject_uevent(). ++ * We then drop our reference before exiting the function, leaving the ++ * bin file to drop the last reference (if it hasn't already). ++ */ ++ ++ /* Take a reference for the bin file */ ++ kobject_get(&elog->kobj); + rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr); +- if (rc) { ++ if (rc == 0) { ++ kobject_uevent(&elog->kobj, KOBJ_ADD); ++ } else { ++ /* Drop the reference taken for the bin file */ + kobject_put(&elog->kobj); +- return NULL; + } + +- kobject_uevent(&elog->kobj, KOBJ_ADD); ++ /* Drop our reference */ ++ kobject_put(&elog->kobj); + +- return elog; ++ return; + } + + static irqreturn_t elog_event(int irq, void *data) +diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c +index ad7b1a3dbed09..c605c78a80896 100644 +--- a/arch/powerpc/platforms/powernv/smp.c ++++ b/arch/powerpc/platforms/powernv/smp.c +@@ -41,7 +41,7 @@ + #include + #define DBG(fmt...) udbg_printf(fmt) + #else +-#define DBG(fmt...) ++#define DBG(fmt...) do { } while (0) + #endif + + static void pnv_smp_setup_cpu(int cpu) +diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c +index 46866b2097e81..bd27e86ce36db 100644 +--- a/arch/sparc/kernel/smp_64.c ++++ b/arch/sparc/kernel/smp_64.c +@@ -1030,38 +1030,9 @@ void smp_fetch_global_pmu(void) + * are flush_tlb_*() routines, and these run after flush_cache_*() + * which performs the flushw. + * +- * The SMP TLB coherency scheme we use works as follows: +- * +- * 1) mm->cpu_vm_mask is a bit mask of which cpus an address +- * space has (potentially) executed on, this is the heuristic +- * we use to avoid doing cross calls. +- * +- * Also, for flushing from kswapd and also for clones, we +- * use cpu_vm_mask as the list of cpus to make run the TLB. +- * +- * 2) TLB context numbers are shared globally across all processors +- * in the system, this allows us to play several games to avoid +- * cross calls. +- * +- * One invariant is that when a cpu switches to a process, and +- * that processes tsk->active_mm->cpu_vm_mask does not have the +- * current cpu's bit set, that tlb context is flushed locally. +- * +- * If the address space is non-shared (ie. mm->count == 1) we avoid +- * cross calls when we want to flush the currently running process's +- * tlb state. This is done by clearing all cpu bits except the current +- * processor's in current->mm->cpu_vm_mask and performing the +- * flush locally only. This will force any subsequent cpus which run +- * this task to flush the context from the local tlb if the process +- * migrates to another cpu (again). +- * +- * 3) For shared address spaces (threads) and swapping we bite the +- * bullet for most cases and perform the cross call (but only to +- * the cpus listed in cpu_vm_mask). +- * +- * The performance gain from "optimizing" away the cross call for threads is +- * questionable (in theory the big win for threads is the massive sharing of +- * address space state across processors). ++ * mm->cpu_vm_mask is a bit mask of which cpus an address ++ * space has (potentially) executed on, this is the heuristic ++ * we use to limit cross calls. + */ + + /* This currently is only used by the hugetlb arch pre-fault +@@ -1071,18 +1042,13 @@ void smp_fetch_global_pmu(void) + void smp_flush_tlb_mm(struct mm_struct *mm) + { + u32 ctx = CTX_HWBITS(mm->context); +- int cpu = get_cpu(); + +- if (atomic_read(&mm->mm_users) == 1) { +- cpumask_copy(mm_cpumask(mm), cpumask_of(cpu)); +- goto local_flush_and_out; +- } ++ get_cpu(); + + smp_cross_call_masked(&xcall_flush_tlb_mm, + ctx, 0, 0, + mm_cpumask(mm)); + +-local_flush_and_out: + __flush_tlb_mm(ctx, SECONDARY_CONTEXT); + + put_cpu(); +@@ -1105,17 +1071,15 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long + { + u32 ctx = CTX_HWBITS(mm->context); + struct tlb_pending_info info; +- int cpu = get_cpu(); ++ ++ get_cpu(); + + info.ctx = ctx; + info.nr = nr; + info.vaddrs = vaddrs; + +- if (mm == current->mm && atomic_read(&mm->mm_users) == 1) +- cpumask_copy(mm_cpumask(mm), cpumask_of(cpu)); +- else +- smp_call_function_many(mm_cpumask(mm), tlb_pending_func, +- &info, 1); ++ smp_call_function_many(mm_cpumask(mm), tlb_pending_func, ++ &info, 1); + + __flush_tlb_pending(ctx, nr, vaddrs); + +@@ -1125,14 +1089,13 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long + void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr) + { + unsigned long context = CTX_HWBITS(mm->context); +- int cpu = get_cpu(); + +- if (mm == current->mm && atomic_read(&mm->mm_users) == 1) +- cpumask_copy(mm_cpumask(mm), cpumask_of(cpu)); +- else +- smp_cross_call_masked(&xcall_flush_tlb_page, +- context, vaddr, 0, +- mm_cpumask(mm)); ++ get_cpu(); ++ ++ smp_cross_call_masked(&xcall_flush_tlb_page, ++ context, vaddr, 0, ++ mm_cpumask(mm)); ++ + __flush_tlb_page(context, vaddr); + + put_cpu(); +diff --git a/arch/um/kernel/sigio.c b/arch/um/kernel/sigio.c +index b5e0cbb343828..476ded92affac 100644 +--- a/arch/um/kernel/sigio.c ++++ b/arch/um/kernel/sigio.c +@@ -36,14 +36,14 @@ int write_sigio_irq(int fd) + } + + /* These are called from os-Linux/sigio.c to protect its pollfds arrays. */ +-static DEFINE_SPINLOCK(sigio_spinlock); ++static DEFINE_MUTEX(sigio_mutex); + + void sigio_lock(void) + { +- spin_lock(&sigio_spinlock); ++ mutex_lock(&sigio_mutex); + } + + void sigio_unlock(void) + { +- spin_unlock(&sigio_spinlock); ++ mutex_unlock(&sigio_mutex); + } +diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c +index 0bf17576dd2af..299e7fb55f16e 100644 +--- a/arch/x86/kernel/kexec-bzimage64.c ++++ b/arch/x86/kernel/kexec-bzimage64.c +@@ -212,8 +212,7 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params, + params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch; + + /* Copying screen_info will do? */ +- memcpy(¶ms->screen_info, &boot_params.screen_info, +- sizeof(struct screen_info)); ++ memcpy(¶ms->screen_info, &screen_info, sizeof(struct screen_info)); + + /* Fill in memsize later */ + params->screen_info.ext_mem_k = 0; +diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c +index b3842ffc19ba2..46d201fc7ecc7 100644 +--- a/drivers/acpi/acpi_extlog.c ++++ b/drivers/acpi/acpi_extlog.c +@@ -223,9 +223,9 @@ static int __init extlog_init(void) + u64 cap; + int rc; + +- rdmsrl(MSR_IA32_MCG_CAP, cap); +- +- if (!(cap & MCG_ELOG_P) || !extlog_get_l1addr()) ++ if (rdmsrl_safe(MSR_IA32_MCG_CAP, &cap) || ++ !(cap & MCG_ELOG_P) || ++ !extlog_get_l1addr()) + return -ENODEV; + + if (get_edac_report_status() == EDAC_REPORTING_FORCE) { +diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c +index 0936b68eff800..df3df21852fe2 100644 +--- a/drivers/acpi/video_detect.c ++++ b/drivers/acpi/video_detect.c +@@ -251,6 +251,15 @@ static const struct dmi_system_id video_detect_dmi_table[] = { + DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"), + }, + }, ++ /* https://bugs.launchpad.net/bugs/1894667 */ ++ { ++ .callback = video_detect_force_video, ++ .ident = "HP 635 Notebook", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"), ++ }, ++ }, + + /* Non win8 machines which need native backlight nevertheless */ + { +diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c +index 4199f7a39be0b..3adfba441b436 100644 +--- a/drivers/ata/sata_rcar.c ++++ b/drivers/ata/sata_rcar.c +@@ -122,7 +122,7 @@ + /* Descriptor table word 0 bit (when DTA32M = 1) */ + #define SATA_RCAR_DTEND BIT(0) + +-#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFEUL ++#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFFUL + + /* Gen2 Physical Layer Control Registers */ + #define RCAR_GEN2_PHY_CTL1_REG 0x1704 +diff --git a/drivers/base/core.c b/drivers/base/core.c +index ddc9dd971674c..92fa2bfa2925d 100644 +--- a/drivers/base/core.c ++++ b/drivers/base/core.c +@@ -2344,6 +2344,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) + */ + void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) + { ++ struct device *parent = dev->parent; + struct fwnode_handle *fn = dev->fwnode; + + if (fwnode) { +@@ -2355,7 +2356,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) + } else { + if (fwnode_is_primary(fn)) { + dev->fwnode = fn->secondary; +- fn->secondary = NULL; ++ if (!(parent && fn == parent->fwnode)) ++ fn->secondary = ERR_PTR(-ENODEV); + } else { + dev->fwnode = NULL; + } +diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c +index b9bc3b8df659d..4fde9767392e3 100644 +--- a/drivers/clk/ti/clockdomain.c ++++ b/drivers/clk/ti/clockdomain.c +@@ -124,10 +124,12 @@ static void __init of_ti_clockdomain_setup(struct device_node *node) + if (clk_hw_get_flags(clk_hw) & CLK_IS_BASIC) { + pr_warn("can't setup clkdm for basic clk %s\n", + __clk_get_name(clk)); ++ clk_put(clk); + continue; + } + to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name; + omap2_init_clk_clkdm(clk_hw); ++ clk_put(clk); + } + } + +diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c +index c2598381fbc80..9738244a18dda 100644 +--- a/drivers/cpufreq/acpi-cpufreq.c ++++ b/drivers/cpufreq/acpi-cpufreq.c +@@ -713,7 +713,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) + cpumask_copy(policy->cpus, topology_core_cpumask(cpu)); + } + +- if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) { ++ if (check_amd_hwpstate_cpu(cpu) && boot_cpu_data.x86 < 0x19 && ++ !acpi_pstate_strict) { + cpumask_clear(policy->cpus); + cpumask_set_cpu(cpu, policy->cpus); + cpumask_copy(data->freqdomain_cpus, +diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c +index 1d01e3805f9c2..f417fba9bf1c9 100644 +--- a/drivers/dma/dma-jz4780.c ++++ b/drivers/dma/dma-jz4780.c +@@ -563,11 +563,11 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan, + enum dma_status status; + unsigned long flags; + ++ spin_lock_irqsave(&jzchan->vchan.lock, flags); ++ + status = dma_cookie_status(chan, cookie, txstate); + if ((status == DMA_COMPLETE) || (txstate == NULL)) +- return status; +- +- spin_lock_irqsave(&jzchan->vchan.lock, flags); ++ goto out_unlock_irqrestore; + + vdesc = vchan_find_desc(&jzchan->vchan, cookie); + if (vdesc) { +@@ -584,6 +584,7 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan, + && jzchan->desc->status & (JZ_DMA_DCS_AR | JZ_DMA_DCS_HLT)) + status = DMA_ERROR; + ++out_unlock_irqrestore: + spin_unlock_irqrestore(&jzchan->vchan.lock, flags); + return status; + } +diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c +index eef50e91f17cf..e04483254b283 100644 +--- a/drivers/iio/gyro/itg3200_buffer.c ++++ b/drivers/iio/gyro/itg3200_buffer.c +@@ -49,13 +49,20 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p) + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct itg3200 *st = iio_priv(indio_dev); +- __be16 buf[ITG3200_SCAN_ELEMENTS + sizeof(s64)/sizeof(u16)]; +- +- int ret = itg3200_read_all_channels(st->i2c, buf); ++ /* ++ * Ensure correct alignment and padding including for the ++ * timestamp that may be inserted. ++ */ ++ struct { ++ __be16 buf[ITG3200_SCAN_ELEMENTS]; ++ s64 ts __aligned(8); ++ } scan; ++ ++ int ret = itg3200_read_all_channels(st->i2c, scan.buf); + if (ret < 0) + goto error_ret; + +- iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp); ++ iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp); + + iio_trigger_notify_done(indio_dev->trig); + +diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c +index 65605e4ef3cf6..1491a9a5c6b06 100644 +--- a/drivers/input/serio/hil_mlc.c ++++ b/drivers/input/serio/hil_mlc.c +@@ -74,7 +74,7 @@ EXPORT_SYMBOL(hil_mlc_unregister); + static LIST_HEAD(hil_mlcs); + static DEFINE_RWLOCK(hil_mlcs_lock); + static struct timer_list hil_mlcs_kicker; +-static int hil_mlcs_probe; ++static int hil_mlcs_probe, hil_mlc_stop; + + static void hil_mlcs_process(unsigned long unused); + static DECLARE_TASKLET_DISABLED(hil_mlcs_tasklet, hil_mlcs_process, 0); +@@ -704,9 +704,13 @@ static int hilse_donode(hil_mlc *mlc) + if (!mlc->ostarted) { + mlc->ostarted = 1; + mlc->opacket = pack; +- mlc->out(mlc); ++ rc = mlc->out(mlc); + nextidx = HILSEN_DOZE; + write_unlock_irqrestore(&mlc->lock, flags); ++ if (rc) { ++ hil_mlc_stop = 1; ++ return 1; ++ } + break; + } + mlc->ostarted = 0; +@@ -717,8 +721,13 @@ static int hilse_donode(hil_mlc *mlc) + + case HILSE_CTS: + write_lock_irqsave(&mlc->lock, flags); +- nextidx = mlc->cts(mlc) ? node->bad : node->good; ++ rc = mlc->cts(mlc); ++ nextidx = rc ? node->bad : node->good; + write_unlock_irqrestore(&mlc->lock, flags); ++ if (rc) { ++ hil_mlc_stop = 1; ++ return 1; ++ } + break; + + default: +@@ -786,6 +795,12 @@ static void hil_mlcs_process(unsigned long unused) + + static void hil_mlcs_timer(unsigned long data) + { ++ if (hil_mlc_stop) { ++ /* could not send packet - stop immediately. */ ++ pr_warn(PREFIX "HIL seems stuck - Disabling HIL MLC.\n"); ++ return; ++ } ++ + hil_mlcs_probe = 1; + tasklet_schedule(&hil_mlcs_tasklet); + /* Re-insert the periodic task. */ +diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c +index d50f0678bf47a..078cbe6522a2a 100644 +--- a/drivers/input/serio/hp_sdc_mlc.c ++++ b/drivers/input/serio/hp_sdc_mlc.c +@@ -213,7 +213,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc) + priv->tseq[2] = 1; + priv->tseq[3] = 0; + priv->tseq[4] = 0; +- __hp_sdc_enqueue_transaction(&priv->trans); ++ return __hp_sdc_enqueue_transaction(&priv->trans); + busy: + return 1; + done: +@@ -222,7 +222,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc) + return 0; + } + +-static void hp_sdc_mlc_out(hil_mlc *mlc) ++static int hp_sdc_mlc_out(hil_mlc *mlc) + { + struct hp_sdc_mlc_priv_s *priv; + +@@ -237,7 +237,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc) + do_data: + if (priv->emtestmode) { + up(&mlc->osem); +- return; ++ return 0; + } + /* Shouldn't be sending commands when loop may be busy */ + BUG_ON(down_trylock(&mlc->csem)); +@@ -299,7 +299,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc) + BUG_ON(down_trylock(&mlc->csem)); + } + enqueue: +- hp_sdc_enqueue_transaction(&priv->trans); ++ return hp_sdc_enqueue_transaction(&priv->trans); + } + + static int __init hp_sdc_mlc_init(void) +diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c +index c7ea5c6263318..be728106baaef 100644 +--- a/drivers/leds/leds-bcm6328.c ++++ b/drivers/leds/leds-bcm6328.c +@@ -325,7 +325,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, + led->cdev.brightness_set = bcm6328_led_set; + led->cdev.blink_set = bcm6328_blink_set; + +- rc = led_classdev_register(dev, &led->cdev); ++ rc = devm_led_classdev_register(dev, &led->cdev); + if (rc < 0) + return rc; + +diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c +index 82b4ee1bc87e0..dae1fd097941d 100644 +--- a/drivers/leds/leds-bcm6358.c ++++ b/drivers/leds/leds-bcm6358.c +@@ -146,7 +146,7 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, + + led->cdev.brightness_set = bcm6358_led_set; + +- rc = led_classdev_register(dev, &led->cdev); ++ rc = devm_led_classdev_register(dev, &led->cdev); + if (rc < 0) + return rc; + +diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c +index 391090c455cea..65281f168c6fb 100644 +--- a/drivers/md/bitmap.c ++++ b/drivers/md/bitmap.c +@@ -1332,7 +1332,7 @@ __acquires(bitmap->lock) + if (bitmap->bp[page].hijacked || + bitmap->bp[page].map == NULL) + csize = ((sector_t)1) << (bitmap->chunkshift + +- PAGE_COUNTER_SHIFT - 1); ++ PAGE_COUNTER_SHIFT); + else + csize = ((sector_t)1) << bitmap->chunkshift; + *blocks = csize - (offset & (csize - 1)); +diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c +index 99cd843351c2b..24708dcf0bb43 100644 +--- a/drivers/md/raid5.c ++++ b/drivers/md/raid5.c +@@ -2238,8 +2238,6 @@ static int resize_stripes(struct r5conf *conf, int newsize) + } else + err = -ENOMEM; + +- mutex_unlock(&conf->cache_size_mutex); +- + conf->slab_cache = sc; + conf->active_name = 1-conf->active_name; + +@@ -2262,6 +2260,8 @@ static int resize_stripes(struct r5conf *conf, int newsize) + + if (!err) + conf->pool_size = newsize; ++ mutex_unlock(&conf->cache_size_mutex); ++ + return err; + } + +diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c +index 04644e7b42b12..88c32b8dc88a1 100644 +--- a/drivers/memory/emif.c ++++ b/drivers/memory/emif.c +@@ -165,35 +165,12 @@ static const struct file_operations emif_mr4_fops = { + + static int __init_or_module emif_debugfs_init(struct emif_data *emif) + { +- struct dentry *dentry; +- int ret; +- +- dentry = debugfs_create_dir(dev_name(emif->dev), NULL); +- if (!dentry) { +- ret = -ENOMEM; +- goto err0; +- } +- emif->debugfs_root = dentry; +- +- dentry = debugfs_create_file("regcache_dump", S_IRUGO, +- emif->debugfs_root, emif, &emif_regdump_fops); +- if (!dentry) { +- ret = -ENOMEM; +- goto err1; +- } +- +- dentry = debugfs_create_file("mr4", S_IRUGO, +- emif->debugfs_root, emif, &emif_mr4_fops); +- if (!dentry) { +- ret = -ENOMEM; +- goto err1; +- } +- ++ emif->debugfs_root = debugfs_create_dir(dev_name(emif->dev), NULL); ++ debugfs_create_file("regcache_dump", S_IRUGO, emif->debugfs_root, emif, ++ &emif_regdump_fops); ++ debugfs_create_file("mr4", S_IRUGO, emif->debugfs_root, emif, ++ &emif_mr4_fops); + return 0; +-err1: +- debugfs_remove_recursive(emif->debugfs_root); +-err0: +- return ret; + } + + static void __exit emif_debugfs_exit(struct emif_data *emif) +diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c +index e77185e143ab7..32083759b93d0 100644 +--- a/drivers/message/fusion/mptscsih.c ++++ b/drivers/message/fusion/mptscsih.c +@@ -1176,8 +1176,10 @@ mptscsih_remove(struct pci_dev *pdev) + + scsi_remove_host(host); + +- if((hd = shost_priv(host)) == NULL) +- return; ++ if (host == NULL) ++ hd = NULL; ++ else ++ hd = shost_priv(host); + + mptscsih_shutdown(pdev); + +@@ -1193,14 +1195,15 @@ mptscsih_remove(struct pci_dev *pdev) + "Free'd ScsiLookup (%d) memory\n", + ioc->name, sz1)); + +- kfree(hd->info_kbuf); ++ if (hd) ++ kfree(hd->info_kbuf); + + /* NULL the Scsi_Host pointer + */ + ioc->sh = NULL; + +- scsi_host_put(host); +- ++ if (host) ++ scsi_host_put(host); + mpt_detach(pdev); + + } +diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c +index 63fac78b3d46a..b455e9cf95afc 100644 +--- a/drivers/mmc/host/via-sdmmc.c ++++ b/drivers/mmc/host/via-sdmmc.c +@@ -1269,11 +1269,14 @@ static void via_init_sdc_pm(struct via_crdr_mmc_host *host) + static int via_sd_suspend(struct pci_dev *pcidev, pm_message_t state) + { + struct via_crdr_mmc_host *host; ++ unsigned long flags; + + host = pci_get_drvdata(pcidev); + ++ spin_lock_irqsave(&host->lock, flags); + via_save_pcictrlreg(host); + via_save_sdcreg(host); ++ spin_unlock_irqrestore(&host->lock, flags); + + pci_save_state(pcidev); + pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0); +diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c +index f4b3ce2b2bc3c..2ae0bc3d02f96 100644 +--- a/drivers/mtd/ubi/wl.c ++++ b/drivers/mtd/ubi/wl.c +@@ -1460,6 +1460,19 @@ int ubi_thread(void *u) + !ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) { + set_current_state(TASK_INTERRUPTIBLE); + spin_unlock(&ubi->wl_lock); ++ ++ /* ++ * Check kthread_should_stop() after we set the task ++ * state to guarantee that we either see the stop bit ++ * and exit or the task state is reset to runnable such ++ * that it's not scheduled out indefinitely and detects ++ * the stop bit at kthread_should_stop(). ++ */ ++ if (kthread_should_stop()) { ++ set_current_state(TASK_RUNNING); ++ break; ++ } ++ + schedule(); + continue; + } +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c +index 96310e2ee5458..bc00fa5e864f3 100644 +--- a/drivers/net/ethernet/freescale/gianfar.c ++++ b/drivers/net/ethernet/freescale/gianfar.c +@@ -1385,7 +1385,7 @@ static int gfar_probe(struct platform_device *ofdev) + + if (dev->features & NETIF_F_IP_CSUM || + priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) +- dev->needed_headroom = GMAC_FCB_LEN; ++ dev->needed_headroom = GMAC_FCB_LEN + GMAC_TXPAL_LEN; + + /* Initializing some of the rx/tx queue level parameters */ + for (i = 0; i < priv->num_tx_queues; i++) { +@@ -2353,20 +2353,12 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) + fcb_len = GMAC_FCB_LEN + GMAC_TXPAL_LEN; + + /* make space for additional header when fcb is needed */ +- if (fcb_len && unlikely(skb_headroom(skb) < fcb_len)) { +- struct sk_buff *skb_new; +- +- skb_new = skb_realloc_headroom(skb, fcb_len); +- if (!skb_new) { ++ if (fcb_len) { ++ if (unlikely(skb_cow_head(skb, fcb_len))) { + dev->stats.tx_errors++; + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } +- +- if (skb->sk) +- skb_set_owner_w(skb_new, skb->sk); +- dev_consume_skb_any(skb); +- skb = skb_new; + } + + /* total number of fragments in the SKB */ +diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c +index 460b29ac5fd86..c6850287362b8 100644 +--- a/drivers/net/ethernet/renesas/ravb_main.c ++++ b/drivers/net/ethernet/renesas/ravb_main.c +@@ -1572,12 +1572,16 @@ static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) + config.flags = 0; + config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : + HWTSTAMP_TX_OFF; +- if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_V2_L2_EVENT) ++ switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) { ++ case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT: + config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; +- else if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_ALL) ++ break; ++ case RAVB_RXTSTAMP_TYPE_ALL: + config.rx_filter = HWTSTAMP_FILTER_ALL; +- else ++ break; ++ default: + config.rx_filter = HWTSTAMP_FILTER_NONE; ++ } + + return copy_to_user(req->ifr_data, &config, sizeof(config)) ? + -EFAULT : 0; +diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c +index 74d46f7e77eaa..045158fab8fe6 100644 +--- a/drivers/net/wan/hdlc_fr.c ++++ b/drivers/net/wan/hdlc_fr.c +@@ -275,63 +275,69 @@ static inline struct net_device **get_dev_p(struct pvc_device *pvc, + + static int fr_hard_header(struct sk_buff **skb_p, u16 dlci) + { +- u16 head_len; + struct sk_buff *skb = *skb_p; + +- switch (skb->protocol) { +- case cpu_to_be16(NLPID_CCITT_ANSI_LMI): +- head_len = 4; +- skb_push(skb, head_len); +- skb->data[3] = NLPID_CCITT_ANSI_LMI; +- break; +- +- case cpu_to_be16(NLPID_CISCO_LMI): +- head_len = 4; +- skb_push(skb, head_len); +- skb->data[3] = NLPID_CISCO_LMI; +- break; +- +- case cpu_to_be16(ETH_P_IP): +- head_len = 4; +- skb_push(skb, head_len); +- skb->data[3] = NLPID_IP; +- break; +- +- case cpu_to_be16(ETH_P_IPV6): +- head_len = 4; +- skb_push(skb, head_len); +- skb->data[3] = NLPID_IPV6; +- break; +- +- case cpu_to_be16(ETH_P_802_3): +- head_len = 10; +- if (skb_headroom(skb) < head_len) { +- struct sk_buff *skb2 = skb_realloc_headroom(skb, +- head_len); ++ if (!skb->dev) { /* Control packets */ ++ switch (dlci) { ++ case LMI_CCITT_ANSI_DLCI: ++ skb_push(skb, 4); ++ skb->data[3] = NLPID_CCITT_ANSI_LMI; ++ break; ++ ++ case LMI_CISCO_DLCI: ++ skb_push(skb, 4); ++ skb->data[3] = NLPID_CISCO_LMI; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ } else if (skb->dev->type == ARPHRD_DLCI) { ++ switch (skb->protocol) { ++ case htons(ETH_P_IP): ++ skb_push(skb, 4); ++ skb->data[3] = NLPID_IP; ++ break; ++ ++ case htons(ETH_P_IPV6): ++ skb_push(skb, 4); ++ skb->data[3] = NLPID_IPV6; ++ break; ++ ++ default: ++ skb_push(skb, 10); ++ skb->data[3] = FR_PAD; ++ skb->data[4] = NLPID_SNAP; ++ /* OUI 00-00-00 indicates an Ethertype follows */ ++ skb->data[5] = 0x00; ++ skb->data[6] = 0x00; ++ skb->data[7] = 0x00; ++ /* This should be an Ethertype: */ ++ *(__be16 *)(skb->data + 8) = skb->protocol; ++ } ++ ++ } else if (skb->dev->type == ARPHRD_ETHER) { ++ if (skb_headroom(skb) < 10) { ++ struct sk_buff *skb2 = skb_realloc_headroom(skb, 10); + if (!skb2) + return -ENOBUFS; + dev_kfree_skb(skb); + skb = *skb_p = skb2; + } +- skb_push(skb, head_len); ++ skb_push(skb, 10); + skb->data[3] = FR_PAD; + skb->data[4] = NLPID_SNAP; +- skb->data[5] = FR_PAD; ++ /* OUI 00-80-C2 stands for the 802.1 organization */ ++ skb->data[5] = 0x00; + skb->data[6] = 0x80; + skb->data[7] = 0xC2; ++ /* PID 00-07 stands for Ethernet frames without FCS */ + skb->data[8] = 0x00; +- skb->data[9] = 0x07; /* bridged Ethernet frame w/out FCS */ +- break; ++ skb->data[9] = 0x07; + +- default: +- head_len = 10; +- skb_push(skb, head_len); +- skb->data[3] = FR_PAD; +- skb->data[4] = NLPID_SNAP; +- skb->data[5] = FR_PAD; +- skb->data[6] = FR_PAD; +- skb->data[7] = FR_PAD; +- *(__be16*)(skb->data + 8) = skb->protocol; ++ } else { ++ return -EINVAL; + } + + dlci_to_q922(skb->data, dlci); +@@ -427,8 +433,8 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) + skb_put(skb, pad); + memset(skb->data + len, 0, pad); + } +- skb->protocol = cpu_to_be16(ETH_P_802_3); + } ++ skb->dev = dev; + if (!fr_hard_header(&skb, pvc->dlci)) { + dev->stats.tx_bytes += skb->len; + dev->stats.tx_packets++; +@@ -496,10 +502,8 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) + memset(skb->data, 0, len); + skb_reserve(skb, 4); + if (lmi == LMI_CISCO) { +- skb->protocol = cpu_to_be16(NLPID_CISCO_LMI); + fr_hard_header(&skb, LMI_CISCO_DLCI); + } else { +- skb->protocol = cpu_to_be16(NLPID_CCITT_ANSI_LMI); + fr_hard_header(&skb, LMI_CCITT_ANSI_DLCI); + } + data = skb_tail_pointer(skb); +diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c +index 1c6c422dbad64..78079ce1ad5a4 100644 +--- a/drivers/net/wireless/ath/ath10k/htt_rx.c ++++ b/drivers/net/wireless/ath/ath10k/htt_rx.c +@@ -665,6 +665,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar, + u8 preamble = 0; + u8 group_id; + u32 info1, info2, info3; ++ u32 stbc, nsts_su; + + info1 = __le32_to_cpu(rxd->ppdu_start.info1); + info2 = __le32_to_cpu(rxd->ppdu_start.info2); +@@ -708,11 +709,16 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar, + TODO check this */ + bw = info2 & 3; + sgi = info3 & 1; ++ stbc = (info2 >> 3) & 1; + group_id = (info2 >> 4) & 0x3F; + + if (GROUP_ID_IS_SU_MIMO(group_id)) { + mcs = (info3 >> 4) & 0x0F; +- nss = ((info2 >> 10) & 0x07) + 1; ++ nsts_su = ((info2 >> 10) & 0x07); ++ if (stbc) ++ nss = (nsts_su >> 2) + 1; ++ else ++ nss = (nsts_su + 1); + } else { + /* Hardware doesn't decode VHT-SIG-B into Rx descriptor + * so it's impossible to decode MCS. Also since +diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c +index 07dd81586c52b..7ccf077c72a05 100644 +--- a/drivers/of/of_reserved_mem.c ++++ b/drivers/of/of_reserved_mem.c +@@ -218,6 +218,16 @@ static int __init __rmem_cmp(const void *a, const void *b) + if (ra->base > rb->base) + return 1; + ++ /* ++ * Put the dynamic allocations (address == 0, size == 0) before static ++ * allocations at address 0x0 so that overlap detection works ++ * correctly. ++ */ ++ if (ra->size < rb->size) ++ return -1; ++ if (ra->size > rb->size) ++ return 1; ++ + return 0; + } + +@@ -235,8 +245,7 @@ static void __init __rmem_check_for_overlap(void) + + this = &reserved_mem[i]; + next = &reserved_mem[i + 1]; +- if (!(this->base && next->base)) +- continue; ++ + if (this->base + this->size > next->base) { + phys_addr_t this_end, next_end; + +diff --git a/drivers/power/test_power.c b/drivers/power/test_power.c +index 57246cdbd0426..925abec45380f 100644 +--- a/drivers/power/test_power.c ++++ b/drivers/power/test_power.c +@@ -344,6 +344,7 @@ static int param_set_ac_online(const char *key, const struct kernel_param *kp) + static int param_get_ac_online(char *buffer, const struct kernel_param *kp) + { + strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown")); ++ strcat(buffer, "\n"); + return strlen(buffer); + } + +@@ -357,6 +358,7 @@ static int param_set_usb_online(const char *key, const struct kernel_param *kp) + static int param_get_usb_online(char *buffer, const struct kernel_param *kp) + { + strcpy(buffer, map_get_key(map_ac_online, usb_online, "unknown")); ++ strcat(buffer, "\n"); + return strlen(buffer); + } + +@@ -371,6 +373,7 @@ static int param_set_battery_status(const char *key, + static int param_get_battery_status(char *buffer, const struct kernel_param *kp) + { + strcpy(buffer, map_get_key(map_status, battery_status, "unknown")); ++ strcat(buffer, "\n"); + return strlen(buffer); + } + +@@ -385,6 +388,7 @@ static int param_set_battery_health(const char *key, + static int param_get_battery_health(char *buffer, const struct kernel_param *kp) + { + strcpy(buffer, map_get_key(map_health, battery_health, "unknown")); ++ strcat(buffer, "\n"); + return strlen(buffer); + } + +@@ -400,6 +404,7 @@ static int param_get_battery_present(char *buffer, + const struct kernel_param *kp) + { + strcpy(buffer, map_get_key(map_present, battery_present, "unknown")); ++ strcat(buffer, "\n"); + return strlen(buffer); + } + +@@ -417,6 +422,7 @@ static int param_get_battery_technology(char *buffer, + { + strcpy(buffer, + map_get_key(map_technology, battery_technology, "unknown")); ++ strcat(buffer, "\n"); + return strlen(buffer); + } + +diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c +index 3e2288af56bc3..647a057a9b6cc 100644 +--- a/drivers/scsi/scsi_scan.c ++++ b/drivers/scsi/scsi_scan.c +@@ -1710,15 +1710,16 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost) + */ + static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) + { +- struct async_scan_data *data; ++ struct async_scan_data *data = NULL; + unsigned long flags; + + if (strncmp(scsi_scan_type, "sync", 4) == 0) + return NULL; + ++ mutex_lock(&shost->scan_mutex); + if (shost->async_scan) { + shost_printk(KERN_DEBUG, shost, "%s called twice\n", __func__); +- return NULL; ++ goto err; + } + + data = kmalloc(sizeof(*data), GFP_KERNEL); +@@ -1729,7 +1730,6 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) + goto err; + init_completion(&data->prev_finished); + +- mutex_lock(&shost->scan_mutex); + spin_lock_irqsave(shost->host_lock, flags); + shost->async_scan = 1; + spin_unlock_irqrestore(shost->host_lock, flags); +@@ -1744,6 +1744,7 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost) + return data; + + err: ++ mutex_unlock(&shost->scan_mutex); + kfree(data); + return NULL; + } +diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c +index 3cd008acb657a..3ea15bb0e56ef 100644 +--- a/drivers/staging/comedi/drivers/cb_pcidas.c ++++ b/drivers/staging/comedi/drivers/cb_pcidas.c +@@ -1351,6 +1351,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, + if (dev->irq && board->has_ao_fifo) { + dev->write_subdev = s; + s->subdev_flags |= SDF_CMD_WRITE; ++ s->len_chanlist = s->n_chan; + s->do_cmdtest = cb_pcidas_ao_cmdtest; + s->do_cmd = cb_pcidas_ao_cmd; + s->cancel = cb_pcidas_ao_cancel; +diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c +index 470ccf729d598..93334e07dd5f7 100644 +--- a/drivers/tty/serial/8250/8250_mtk.c ++++ b/drivers/tty/serial/8250/8250_mtk.c +@@ -58,7 +58,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios, + */ + baud = tty_termios_baud_rate(termios); + +- serial8250_do_set_termios(port, termios, old); ++ serial8250_do_set_termios(port, termios, NULL); + + tty_termios_encode_baud_rate(termios, baud, baud); + +diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c +index f80312eed4fda..ffb3fb1bda9e7 100644 +--- a/drivers/tty/serial/serial_txx9.c ++++ b/drivers/tty/serial/serial_txx9.c +@@ -1287,6 +1287,9 @@ static int __init serial_txx9_init(void) + + #ifdef ENABLE_SERIAL_TXX9_PCI + ret = pci_register_driver(&serial_txx9_pci_driver); ++ if (ret) { ++ platform_driver_unregister(&serial_txx9_plat_driver); ++ } + #endif + if (ret == 0) + goto out; +diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c +index 96c65fe641414..05941f86df3d8 100644 +--- a/drivers/tty/vt/keyboard.c ++++ b/drivers/tty/vt/keyboard.c +@@ -712,8 +712,13 @@ static void k_fn(struct vc_data *vc, unsigned char value, char up_flag) + return; + + if ((unsigned)value < ARRAY_SIZE(func_table)) { ++ unsigned long flags; ++ ++ spin_lock_irqsave(&func_buf_lock, flags); + if (func_table[value]) + puts_queue(vc, func_table[value]); ++ spin_unlock_irqrestore(&func_buf_lock, flags); ++ + } else + pr_err("k_fn called with value=%d\n", value); + } +@@ -1969,13 +1974,11 @@ out: + #undef s + #undef v + +-/* FIXME: This one needs untangling and locking */ ++/* FIXME: This one needs untangling */ + int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) + { + struct kbsentry *kbs; +- char *p; + u_char *q; +- u_char __user *up; + int sz, fnw_sz; + int delta; + char *first_free, *fj, *fnw; +@@ -2001,23 +2004,19 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) + i = kbs->kb_func; + + switch (cmd) { +- case KDGKBSENT: +- sz = sizeof(kbs->kb_string) - 1; /* sz should have been +- a struct member */ +- up = user_kdgkb->kb_string; +- p = func_table[i]; +- if(p) +- for ( ; *p && sz; p++, sz--) +- if (put_user(*p, up++)) { +- ret = -EFAULT; +- goto reterr; +- } +- if (put_user('\0', up)) { +- ret = -EFAULT; +- goto reterr; +- } +- kfree(kbs); +- return ((p && *p) ? -EOVERFLOW : 0); ++ case KDGKBSENT: { ++ /* size should have been a struct member */ ++ ssize_t len = sizeof(user_kdgkb->kb_string); ++ ++ spin_lock_irqsave(&func_buf_lock, flags); ++ len = strlcpy(kbs->kb_string, func_table[i] ? : "", len); ++ spin_unlock_irqrestore(&func_buf_lock, flags); ++ ++ ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string, ++ len + 1) ? -EFAULT : 0; ++ ++ goto reterr; ++ } + case KDSKBSENT: + if (!perm) { + ret = -EPERM; +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c +index 01aeffcdf9849..7ec5e6dd60e5c 100644 +--- a/drivers/tty/vt/vt.c ++++ b/drivers/tty/vt/vt.c +@@ -4226,27 +4226,6 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op) + return rc; + } + +-static int con_font_copy(struct vc_data *vc, struct console_font_op *op) +-{ +- int con = op->height; +- int rc; +- +- +- console_lock(); +- if (vc->vc_mode != KD_TEXT) +- rc = -EINVAL; +- else if (!vc->vc_sw->con_font_copy) +- rc = -ENOSYS; +- else if (con < 0 || !vc_cons_allocated(con)) +- rc = -ENOTTY; +- else if (con == vc->vc_num) /* nothing to do */ +- rc = 0; +- else +- rc = vc->vc_sw->con_font_copy(vc, con); +- console_unlock(); +- return rc; +-} +- + int con_font_op(struct vc_data *vc, struct console_font_op *op) + { + switch (op->op) { +@@ -4257,7 +4236,8 @@ int con_font_op(struct vc_data *vc, struct console_font_op *op) + case KD_FONT_OP_SET_DEFAULT: + return con_font_default(vc, op); + case KD_FONT_OP_COPY: +- return con_font_copy(vc, op); ++ /* was buggy and never really used */ ++ return -EINVAL; + } + return -ENOSYS; + } +diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c +index b0f0771a57298..b111071d19b53 100644 +--- a/drivers/tty/vt/vt_ioctl.c ++++ b/drivers/tty/vt/vt_ioctl.c +@@ -243,7 +243,7 @@ int vt_waitactive(int n) + + + static inline int +-do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struct console_font_op *op) ++do_fontx_ioctl(struct vc_data *vc, int cmd, struct consolefontdesc __user *user_cfd, int perm, struct console_font_op *op) + { + struct consolefontdesc cfdarg; + int i; +@@ -261,15 +261,16 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc + op->height = cfdarg.charheight; + op->charcount = cfdarg.charcount; + op->data = cfdarg.chardata; +- return con_font_op(vc_cons[fg_console].d, op); +- case GIO_FONTX: { ++ return con_font_op(vc, op); ++ ++ case GIO_FONTX: + op->op = KD_FONT_OP_GET; + op->flags = KD_FONT_FLAG_OLD; + op->width = 8; + op->height = cfdarg.charheight; + op->charcount = cfdarg.charcount; + op->data = cfdarg.chardata; +- i = con_font_op(vc_cons[fg_console].d, op); ++ i = con_font_op(vc, op); + if (i) + return i; + cfdarg.charheight = op->height; +@@ -277,7 +278,6 @@ do_fontx_ioctl(int cmd, struct consolefontdesc __user *user_cfd, int perm, struc + if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc))) + return -EFAULT; + return 0; +- } + } + return -EINVAL; + } +@@ -927,7 +927,7 @@ int vt_ioctl(struct tty_struct *tty, + op.height = 0; + op.charcount = 256; + op.data = up; +- ret = con_font_op(vc_cons[fg_console].d, &op); ++ ret = con_font_op(vc, &op); + break; + } + +@@ -938,7 +938,7 @@ int vt_ioctl(struct tty_struct *tty, + op.height = 32; + op.charcount = 256; + op.data = up; +- ret = con_font_op(vc_cons[fg_console].d, &op); ++ ret = con_font_op(vc, &op); + break; + } + +@@ -955,7 +955,7 @@ int vt_ioctl(struct tty_struct *tty, + + case PIO_FONTX: + case GIO_FONTX: +- ret = do_fontx_ioctl(cmd, up, perm, &op); ++ ret = do_fontx_ioctl(vc, cmd, up, perm, &op); + break; + + case PIO_FONTRESET: +@@ -972,11 +972,11 @@ int vt_ioctl(struct tty_struct *tty, + { + op.op = KD_FONT_OP_SET_DEFAULT; + op.data = NULL; +- ret = con_font_op(vc_cons[fg_console].d, &op); ++ ret = con_font_op(vc, &op); + if (ret) + break; + console_lock(); +- con_set_default_unimap(vc_cons[fg_console].d); ++ con_set_default_unimap(vc); + console_unlock(); + break; + } +@@ -1109,8 +1109,9 @@ struct compat_consolefontdesc { + }; + + static inline int +-compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd, +- int perm, struct console_font_op *op) ++compat_fontx_ioctl(struct vc_data *vc, int cmd, ++ struct compat_consolefontdesc __user *user_cfd, ++ int perm, struct console_font_op *op) + { + struct compat_consolefontdesc cfdarg; + int i; +@@ -1128,7 +1129,8 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd, + op->height = cfdarg.charheight; + op->charcount = cfdarg.charcount; + op->data = compat_ptr(cfdarg.chardata); +- return con_font_op(vc_cons[fg_console].d, op); ++ return con_font_op(vc, op); ++ + case GIO_FONTX: + op->op = KD_FONT_OP_GET; + op->flags = KD_FONT_FLAG_OLD; +@@ -1136,7 +1138,7 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd, + op->height = cfdarg.charheight; + op->charcount = cfdarg.charcount; + op->data = compat_ptr(cfdarg.chardata); +- i = con_font_op(vc_cons[fg_console].d, op); ++ i = con_font_op(vc, op); + if (i) + return i; + cfdarg.charheight = op->height; +@@ -1231,7 +1233,7 @@ long vt_compat_ioctl(struct tty_struct *tty, + */ + case PIO_FONTX: + case GIO_FONTX: +- ret = compat_fontx_ioctl(cmd, up, perm, &op); ++ ret = compat_fontx_ioctl(vc, cmd, up, perm, &op); + break; + + case KDFONTOP: +diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c +index ba5c0a4591ac9..012d97f9c30c7 100644 +--- a/drivers/usb/misc/adutux.c ++++ b/drivers/usb/misc/adutux.c +@@ -210,6 +210,7 @@ static void adu_interrupt_out_callback(struct urb *urb) + + if (status != 0) { + if ((status != -ENOENT) && ++ (status != -ESHUTDOWN) && + (status != -ECONNRESET)) { + dev_dbg(&dev->udev->dev, + "%s :nonzero status received: %d\n", __func__, +diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c +index 8948f375e75d2..5a29ea0d00c58 100644 +--- a/drivers/usb/serial/cyberjack.c ++++ b/drivers/usb/serial/cyberjack.c +@@ -368,11 +368,12 @@ static void cyberjack_write_bulk_callback(struct urb *urb) + struct cyberjack_private *priv = usb_get_serial_port_data(port); + struct device *dev = &port->dev; + int status = urb->status; ++ bool resubmitted = false; + +- set_bit(0, &port->write_urbs_free); + if (status) { + dev_dbg(dev, "%s - nonzero write bulk status received: %d\n", + __func__, status); ++ set_bit(0, &port->write_urbs_free); + return; + } + +@@ -405,6 +406,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb) + goto exit; + } + ++ resubmitted = true; ++ + dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent); + dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled); + +@@ -421,6 +424,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb) + + exit: + spin_unlock(&priv->lock); ++ if (!resubmitted) ++ set_bit(0, &port->write_urbs_free); + usb_serial_port_softint(port); + } + +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c +index 5017d37afe392..34ac1265afe46 100644 +--- a/drivers/usb/serial/option.c ++++ b/drivers/usb/serial/option.c +@@ -1174,6 +1174,8 @@ static const struct usb_device_id option_ids[] = { + .driver_info = NCTRL(0) | RSVD(1) }, + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1054, 0xff), /* Telit FT980-KS */ + .driver_info = NCTRL(2) | RSVD(3) }, ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1055, 0xff), /* Telit FN980 (PCIe) */ ++ .driver_info = NCTRL(0) | RSVD(1) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), + .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), +@@ -1186,6 +1188,8 @@ static const struct usb_device_id option_ids[] = { + .driver_info = NCTRL(0) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1203, 0xff), /* Telit LE910Cx (RNDIS) */ ++ .driver_info = NCTRL(2) | RSVD(3) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4), + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), +@@ -1200,6 +1204,10 @@ static const struct usb_device_id option_ids[] = { + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1213, 0xff) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1214), + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) }, ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1230, 0xff), /* Telit LE910Cx (rmnet) */ ++ .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, ++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1231, 0xff), /* Telit LE910Cx (RNDIS) */ ++ .driver_info = NCTRL(2) | RSVD(3) }, + { USB_DEVICE(TELIT_VENDOR_ID, 0x1260), + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, + { USB_DEVICE(TELIT_VENDOR_ID, 0x1261), +diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c +index 3bb02c60a2f5f..d56736655dec4 100644 +--- a/drivers/vhost/vringh.c ++++ b/drivers/vhost/vringh.c +@@ -272,13 +272,14 @@ __vringh_iov(struct vringh *vrh, u16 i, + desc_max = vrh->vring.num; + up_next = -1; + ++ /* You must want something! */ ++ if (WARN_ON(!riov && !wiov)) ++ return -EINVAL; ++ + if (riov) + riov->i = riov->used = 0; +- else if (wiov) ++ if (wiov) + wiov->i = wiov->used = 0; +- else +- /* You must want something! */ +- BUG(); + + for (;;) { + void *addr; +diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c +index 750a384bf1915..1a015a6b682e7 100644 +--- a/drivers/video/fbdev/pvr2fb.c ++++ b/drivers/video/fbdev/pvr2fb.c +@@ -1029,6 +1029,8 @@ static int __init pvr2fb_setup(char *options) + if (!options || !*options) + return 0; + ++ cable_arg[0] = output_arg[0] = 0; ++ + while ((this_opt = strsep(&options, ","))) { + if (!*this_opt) + continue; +diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c +index dacb5919970c5..d2e9d2f6a7843 100644 +--- a/drivers/w1/masters/mxc_w1.c ++++ b/drivers/w1/masters/mxc_w1.c +@@ -15,7 +15,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +@@ -48,12 +48,12 @@ struct mxc_w1_device { + static u8 mxc_w1_ds2_reset_bus(void *data) + { + struct mxc_w1_device *dev = data; +- unsigned long timeout; ++ ktime_t timeout; + + writeb(MXC_W1_CONTROL_RPP, dev->regs + MXC_W1_CONTROL); + + /* Wait for reset sequence 511+512us, use 1500us for sure */ +- timeout = jiffies + usecs_to_jiffies(1500); ++ timeout = ktime_add_us(ktime_get(), 1500); + + udelay(511 + 512); + +@@ -63,7 +63,7 @@ static u8 mxc_w1_ds2_reset_bus(void *data) + /* PST bit is valid after the RPP bit is self-cleared */ + if (!(ctrl & MXC_W1_CONTROL_RPP)) + return !(ctrl & MXC_W1_CONTROL_PST); +- } while (time_is_after_jiffies(timeout)); ++ } while (ktime_before(ktime_get(), timeout)); + + return 1; + } +@@ -76,12 +76,12 @@ static u8 mxc_w1_ds2_reset_bus(void *data) + static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit) + { + struct mxc_w1_device *dev = data; +- unsigned long timeout; ++ ktime_t timeout; + + writeb(MXC_W1_CONTROL_WR(bit), dev->regs + MXC_W1_CONTROL); + + /* Wait for read/write bit (60us, Max 120us), use 200us for sure */ +- timeout = jiffies + usecs_to_jiffies(200); ++ timeout = ktime_add_us(ktime_get(), 200); + + udelay(60); + +@@ -91,7 +91,7 @@ static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit) + /* RDST bit is valid after the WR1/RD bit is self-cleared */ + if (!(ctrl & MXC_W1_CONTROL_WR(bit))) + return !!(ctrl & MXC_W1_CONTROL_RDST); +- } while (time_is_after_jiffies(timeout)); ++ } while (ktime_before(ktime_get(), timeout)); + + return 0; + } +diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c +index 47a8f1b1087d4..4568af9a165be 100644 +--- a/drivers/watchdog/rdc321x_wdt.c ++++ b/drivers/watchdog/rdc321x_wdt.c +@@ -244,6 +244,8 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) + + rdc321x_wdt_device.sb_pdev = pdata->sb_pdev; + rdc321x_wdt_device.base_reg = r->start; ++ rdc321x_wdt_device.queue = 0; ++ rdc321x_wdt_device.default_ticks = ticks; + + err = misc_register(&rdc321x_wdt_misc); + if (err < 0) { +@@ -258,14 +260,11 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) + rdc321x_wdt_device.base_reg, RDC_WDT_RST); + + init_completion(&rdc321x_wdt_device.stop); +- rdc321x_wdt_device.queue = 0; + + clear_bit(0, &rdc321x_wdt_device.inuse); + + setup_timer(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0); + +- rdc321x_wdt_device.default_ticks = ticks; +- + dev_info(&pdev->dev, "watchdog init success\n"); + + return 0; +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c +index e4dd991e2888b..9a126732d5d9c 100644 +--- a/drivers/xen/events/events_base.c ++++ b/drivers/xen/events/events_base.c +@@ -91,6 +91,8 @@ static bool (*pirq_needs_eoi)(unsigned irq); + /* Xen will never allocate port zero for any purpose. */ + #define VALID_EVTCHN(chn) ((chn) != 0) + ++static struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY]; ++ + static struct irq_chip xen_dynamic_chip; + static struct irq_chip xen_percpu_chip; + static struct irq_chip xen_pirq_chip; +@@ -155,7 +157,18 @@ int get_evtchn_to_irq(unsigned evtchn) + /* Get info for IRQ */ + struct irq_info *info_for_irq(unsigned irq) + { +- return irq_get_chip_data(irq); ++ if (irq < nr_legacy_irqs()) ++ return legacy_info_ptrs[irq]; ++ else ++ return irq_get_chip_data(irq); ++} ++ ++static void set_info_for_irq(unsigned int irq, struct irq_info *info) ++{ ++ if (irq < nr_legacy_irqs()) ++ legacy_info_ptrs[irq] = info; ++ else ++ irq_set_chip_data(irq, info); + } + + /* Constructors for packed IRQ information. */ +@@ -384,7 +397,7 @@ static void xen_irq_init(unsigned irq) + info->type = IRQT_UNBOUND; + info->refcnt = -1; + +- irq_set_chip_data(irq, info); ++ set_info_for_irq(irq, info); + + list_add_tail(&info->list, &xen_irq_list_head); + } +@@ -433,14 +446,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi) + + static void xen_free_irq(unsigned irq) + { +- struct irq_info *info = irq_get_chip_data(irq); ++ struct irq_info *info = info_for_irq(irq); + + if (WARN_ON(!info)) + return; + + list_del(&info->list); + +- irq_set_chip_data(irq, NULL); ++ set_info_for_irq(irq, NULL); + + WARN_ON(info->refcnt > 0); + +@@ -610,7 +623,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); + static void __unbind_from_irq(unsigned int irq) + { + int evtchn = evtchn_from_irq(irq); +- struct irq_info *info = irq_get_chip_data(irq); ++ struct irq_info *info = info_for_irq(irq); + + if (info->refcnt > 0) { + info->refcnt--; +@@ -1114,7 +1127,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi, + + void unbind_from_irqhandler(unsigned int irq, void *dev_id) + { +- struct irq_info *info = irq_get_chip_data(irq); ++ struct irq_info *info = info_for_irq(irq); + + if (WARN_ON(!info)) + return; +@@ -1148,7 +1161,7 @@ int evtchn_make_refcounted(unsigned int evtchn) + if (irq == -1) + return -ENOENT; + +- info = irq_get_chip_data(irq); ++ info = info_for_irq(irq); + + if (!info) + return -ENOENT; +@@ -1176,7 +1189,7 @@ int evtchn_get(unsigned int evtchn) + if (irq == -1) + goto done; + +- info = irq_get_chip_data(irq); ++ info = info_for_irq(irq); + + if (!info) + goto done; +diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c +index 9dbf371471261..b5aa3e005b9e9 100644 +--- a/fs/9p/vfs_file.c ++++ b/fs/9p/vfs_file.c +@@ -624,9 +624,9 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma) + struct writeback_control wbc = { + .nr_to_write = LONG_MAX, + .sync_mode = WB_SYNC_ALL, +- .range_start = vma->vm_pgoff * PAGE_SIZE, ++ .range_start = (loff_t)vma->vm_pgoff * PAGE_SIZE, + /* absolute end, byte at end included */ +- .range_end = vma->vm_pgoff * PAGE_SIZE + ++ .range_end = (loff_t)vma->vm_pgoff * PAGE_SIZE + + (vma->vm_end - vma->vm_start - 1), + }; + +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c +index 8f0f91de436d5..ee26ccd12da80 100644 +--- a/fs/btrfs/tree-log.c ++++ b/fs/btrfs/tree-log.c +@@ -3335,6 +3335,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, + * search and this search we'll not find the key again and can just + * bail. + */ ++search: + ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); + if (ret != 0) + goto done; +@@ -3354,6 +3355,13 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, + + if (min_key.objectid != ino || min_key.type != key_type) + goto done; ++ ++ if (need_resched()) { ++ btrfs_release_path(path); ++ cond_resched(); ++ goto search; ++ } ++ + ret = overwrite_item(trans, log, dst_path, src, i, + &min_key); + if (ret) { +diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c +index 5df898fd0a0aa..9047f0e64bc0a 100644 +--- a/fs/cachefiles/rdwr.c ++++ b/fs/cachefiles/rdwr.c +@@ -125,7 +125,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object, + _debug("reissue read"); + ret = bmapping->a_ops->readpage(NULL, backpage); + if (ret < 0) +- goto unlock_discard; ++ goto discard; + } + + /* but the page may have been read before the monitor was installed, so +@@ -142,6 +142,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object, + + unlock_discard: + unlock_page(backpage); ++discard: + spin_lock_irq(&object->work_lock); + list_del(&monitor->op_link); + spin_unlock_irq(&object->work_lock); +diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c +index 22bae2b434e2c..fbf3830484090 100644 +--- a/fs/ceph/addr.c ++++ b/fs/ceph/addr.c +@@ -1243,7 +1243,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) + struct ceph_inode_info *ci = ceph_inode(inode); + struct ceph_file_info *fi = vma->vm_file->private_data; + struct page *pinned_page = NULL; +- loff_t off = vmf->pgoff << PAGE_CACHE_SHIFT; ++ loff_t off = (loff_t)vmf->pgoff << PAGE_CACHE_SHIFT; + int want, got, ret; + + dout("filemap_fault %p %llx.%llx %llu~%zd trying to get caps\n", +diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c +index abb244b060245..fca235020312d 100644 +--- a/fs/efivarfs/super.c ++++ b/fs/efivarfs/super.c +@@ -147,6 +147,9 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor, + + name[len + EFI_VARIABLE_GUID_LEN+1] = '\0'; + ++ /* replace invalid slashes like kobject_set_name_vargs does for /sys/firmware/efi/vars. */ ++ strreplace(name, '/', '!'); ++ + inode = efivarfs_get_inode(sb, d_inode(root), S_IFREG | 0644, 0, + is_removable); + if (!inode) +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c +index 061b026e464c5..96d77a42ecdea 100644 +--- a/fs/ext4/namei.c ++++ b/fs/ext4/namei.c +@@ -3218,7 +3218,7 @@ static int ext4_link(struct dentry *old_dentry, + return -EMLINK; + if (ext4_encrypted_inode(dir) && + !ext4_is_child_context_consistent_with_parent(dir, inode)) +- return -EPERM; ++ return -EXDEV; + err = dquot_initialize(dir); + if (err) + return err; +@@ -3537,7 +3537,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, + ext4_encrypted_inode(new.dir) && + !ext4_is_child_context_consistent_with_parent(new.dir, + old.inode)) { +- retval = -EPERM; ++ retval = -EXDEV; + goto end_rename; + } + +@@ -3718,7 +3718,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry, + old.inode) || + !ext4_is_child_context_consistent_with_parent(old_dir, + new.inode))) +- return -EPERM; ++ return -EXDEV; + + retval = dquot_initialize(old.dir); + if (retval) +diff --git a/fs/ext4/super.c b/fs/ext4/super.c +index aca086a25b2ef..6350971852e19 100644 +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -5185,6 +5185,11 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, + /* Quotafile not on the same filesystem? */ + if (path->dentry->d_sb != sb) + return -EXDEV; ++ ++ /* Quota already enabled for this file? */ ++ if (IS_NOQUOTA(d_inode(path->dentry))) ++ return -EBUSY; ++ + /* Journaling quota? */ + if (EXT4_SB(sb)->s_qf_names[type]) { + /* Quotafile not in fs root? */ +diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c +index b7b43d00cc6d7..8ed2b1a716376 100644 +--- a/fs/gfs2/ops_fstype.c ++++ b/fs/gfs2/ops_fstype.c +@@ -160,15 +160,19 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent) + return -EINVAL; + } + +- /* If format numbers match exactly, we're done. */ +- +- if (sb->sb_fs_format == GFS2_FORMAT_FS && +- sb->sb_multihost_format == GFS2_FORMAT_MULTI) +- return 0; ++ if (sb->sb_fs_format != GFS2_FORMAT_FS || ++ sb->sb_multihost_format != GFS2_FORMAT_MULTI) { ++ fs_warn(sdp, "Unknown on-disk format, unable to mount\n"); ++ return -EINVAL; ++ } + +- fs_warn(sdp, "Unknown on-disk format, unable to mount\n"); ++ if (sb->sb_bsize < 512 || sb->sb_bsize > PAGE_SIZE || ++ (sb->sb_bsize & (sb->sb_bsize - 1))) { ++ pr_warn("Invalid superblock size\n"); ++ return -EINVAL; ++ } + +- return -EINVAL; ++ return 0; + } + + static void end_bio_io_page(struct bio *bio) +diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c +index c8162c660c440..d29ad4e02d33d 100644 +--- a/fs/nfs/namespace.c ++++ b/fs/nfs/namespace.c +@@ -30,9 +30,9 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; + /* + * nfs_path - reconstruct the path given an arbitrary dentry + * @base - used to return pointer to the end of devname part of path +- * @dentry - pointer to dentry ++ * @dentry_in - pointer to dentry + * @buffer - result buffer +- * @buflen - length of buffer ++ * @buflen_in - length of buffer + * @flags - options (see below) + * + * Helper function for constructing the server pathname +@@ -47,15 +47,19 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; + * the original device (export) name + * (if unset, the original name is returned verbatim) + */ +-char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen, +- unsigned flags) ++char *nfs_path(char **p, struct dentry *dentry_in, char *buffer, ++ ssize_t buflen_in, unsigned flags) + { + char *end; + int namelen; + unsigned seq; + const char *base; ++ struct dentry *dentry; ++ ssize_t buflen; + + rename_retry: ++ buflen = buflen_in; ++ dentry = dentry_in; + end = buffer+buflen; + *--end = '\0'; + buflen--; +diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c +index 595ca0debe117..09134a13a39ce 100644 +--- a/fs/ubifs/debug.c ++++ b/fs/ubifs/debug.c +@@ -1125,6 +1125,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir) + err = PTR_ERR(dent); + if (err == -ENOENT) + break; ++ kfree(pdent); + return err; + } + +diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c +index bda5248fc6498..acadeaf72674e 100644 +--- a/fs/xfs/xfs_rtalloc.c ++++ b/fs/xfs/xfs_rtalloc.c +@@ -1017,10 +1017,13 @@ xfs_growfs_rt( + xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); + /* +- * Update the bitmap inode's size. ++ * Update the bitmap inode's size ondisk and incore. We need ++ * to update the incore size so that inode inactivation won't ++ * punch what it thinks are "posteof" blocks. + */ + mp->m_rbmip->i_d.di_size = + nsbp->sb_rbmblocks * nsbp->sb_blocksize; ++ i_size_write(VFS_I(mp->m_rbmip), mp->m_rbmip->i_d.di_size); + xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); + /* + * Get the summary inode into the transaction. +@@ -1028,9 +1031,12 @@ xfs_growfs_rt( + xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL); + /* +- * Update the summary inode's size. ++ * Update the summary inode's size. We need to update the ++ * incore size so that inode inactivation won't punch what it ++ * thinks are "posteof" blocks. + */ + mp->m_rsumip->i_d.di_size = nmp->m_rsumsize; ++ i_size_write(VFS_I(mp->m_rsumip), mp->m_rsumip->i_d.di_size); + xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE); + /* + * Copy summary data from old to new sizes. +diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h +index 394a8405dd74d..e0521a1d93250 100644 +--- a/include/linux/hil_mlc.h ++++ b/include/linux/hil_mlc.h +@@ -103,7 +103,7 @@ struct hilse_node { + + /* Methods for back-end drivers, e.g. hp_sdc_mlc */ + typedef int (hil_mlc_cts) (hil_mlc *mlc); +-typedef void (hil_mlc_out) (hil_mlc *mlc); ++typedef int (hil_mlc_out) (hil_mlc *mlc); + typedef int (hil_mlc_in) (hil_mlc *mlc, suseconds_t timeout); + + struct hil_mlc_devinfo { +diff --git a/include/linux/mtd/pfow.h b/include/linux/mtd/pfow.h +index 42ff7ff09bf59..09404fb36b345 100644 +--- a/include/linux/mtd/pfow.h ++++ b/include/linux/mtd/pfow.h +@@ -127,7 +127,7 @@ static inline void print_drs_error(unsigned dsr) + + if (!(dsr & DSR_AVAILABLE)) + printk(KERN_NOTICE"DSR.15: (0) Device not Available\n"); +- if (prog_status & 0x03) ++ if ((prog_status & 0x03) == 0x03) + printk(KERN_NOTICE"DSR.9,8: (11) Attempt to program invalid " + "half with 41h command\n"); + else if (prog_status & 0x02) +diff --git a/init/Kconfig b/init/Kconfig +index f9fb621c95623..5d8ada360ca34 100644 +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -823,7 +823,8 @@ config IKCONFIG_PROC + + config LOG_BUF_SHIFT + int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" +- range 12 25 ++ range 12 25 if !H8300 ++ range 12 19 if H8300 + default 17 + depends on PRINTK + help +diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c +index 321ccdbb73649..bc791cec58e63 100644 +--- a/kernel/debug/debug_core.c ++++ b/kernel/debug/debug_core.c +@@ -94,14 +94,6 @@ int dbg_switch_cpu; + /* Use kdb or gdbserver mode */ + int dbg_kdb_mode = 1; + +-static int __init opt_kgdb_con(char *str) +-{ +- kgdb_use_con = 1; +- return 0; +-} +- +-early_param("kgdbcon", opt_kgdb_con); +- + module_param(kgdb_use_con, int, 0644); + module_param(kgdbreboot, int, 0644); + +@@ -811,6 +803,20 @@ static struct console kgdbcons = { + .index = -1, + }; + ++static int __init opt_kgdb_con(char *str) ++{ ++ kgdb_use_con = 1; ++ ++ if (kgdb_io_module_registered && !kgdb_con_registered) { ++ register_console(&kgdbcons); ++ kgdb_con_registered = 1; ++ } ++ ++ return 0; ++} ++ ++early_param("kgdbcon", opt_kgdb_con); ++ + #ifdef CONFIG_MAGIC_SYSRQ + static void sysrq_handle_dbg(int key) + { +diff --git a/kernel/fork.c b/kernel/fork.c +index a6dc6b3f6a015..5d35be1e0913b 100644 +--- a/kernel/fork.c ++++ b/kernel/fork.c +@@ -1539,14 +1539,9 @@ static struct task_struct *copy_process(unsigned long clone_flags, + /* ok, now we should be set up.. */ + p->pid = pid_nr(pid); + if (clone_flags & CLONE_THREAD) { +- p->exit_signal = -1; + p->group_leader = current->group_leader; + p->tgid = current->tgid; + } else { +- if (clone_flags & CLONE_PARENT) +- p->exit_signal = current->group_leader->exit_signal; +- else +- p->exit_signal = (clone_flags & CSIGNAL); + p->group_leader = p; + p->tgid = p->pid; + } +@@ -1591,9 +1586,14 @@ static struct task_struct *copy_process(unsigned long clone_flags, + if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) { + p->real_parent = current->real_parent; + p->parent_exec_id = current->parent_exec_id; ++ if (clone_flags & CLONE_THREAD) ++ p->exit_signal = -1; ++ else ++ p->exit_signal = current->group_leader->exit_signal; + } else { + p->real_parent = current; + p->parent_exec_id = current->self_exec_id; ++ p->exit_signal = (clone_flags & CSIGNAL); + } + + spin_lock(¤t->sighand->siglock); +diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c +index 1cf2402c69228..1c1ecc1d49ad2 100644 +--- a/kernel/trace/ring_buffer.c ++++ b/kernel/trace/ring_buffer.c +@@ -1659,18 +1659,18 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size, + { + struct ring_buffer_per_cpu *cpu_buffer; + unsigned long nr_pages; +- int cpu, err = 0; ++ int cpu, err; + + /* + * Always succeed at resizing a non-existent buffer: + */ + if (!buffer) +- return size; ++ return 0; + + /* Make sure the requested buffer exists */ + if (cpu_id != RING_BUFFER_ALL_CPUS && + !cpumask_test_cpu(cpu_id, buffer->cpumask)) +- return size; ++ return 0; + + nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE); + +@@ -1810,7 +1810,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size, + } + + mutex_unlock(&buffer->mutex); +- return size; ++ return 0; + + out_err: + for_each_buffer_cpu(buffer, cpu) { +diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h +index 12a82a7ad5a68..cd0d8cc7163e1 100644 +--- a/kernel/trace/trace.h ++++ b/kernel/trace/trace.h +@@ -478,6 +478,12 @@ enum { + * can only be modified by current, we can reuse trace_recursion. + */ + TRACE_IRQ_BIT, ++ ++ /* ++ * When transitioning between context, the preempt_count() may ++ * not be correct. Allow for a single recursion to cover this case. ++ */ ++ TRACE_TRANSITION_BIT, + }; + + #define trace_recursion_set(bit) do { (current)->trace_recursion |= (1<<(bit)); } while (0) +@@ -522,14 +528,27 @@ static __always_inline int trace_test_and_set_recursion(int start, int max) + return 0; + + bit = trace_get_context_bit() + start; +- if (unlikely(val & (1 << bit))) +- return -1; ++ if (unlikely(val & (1 << bit))) { ++ /* ++ * It could be that preempt_count has not been updated during ++ * a switch between contexts. Allow for a single recursion. ++ */ ++ bit = TRACE_TRANSITION_BIT; ++ if (trace_recursion_test(bit)) ++ return -1; ++ trace_recursion_set(bit); ++ barrier(); ++ return bit + 1; ++ } ++ ++ /* Normal check passed, clear the transition to allow it again */ ++ trace_recursion_clear(TRACE_TRANSITION_BIT); + + val |= 1 << bit; + current->trace_recursion = val; + barrier(); + +- return bit; ++ return bit + 1; + } + + static __always_inline void trace_clear_recursion(int bit) +@@ -539,6 +558,7 @@ static __always_inline void trace_clear_recursion(int bit) + if (!bit) + return; + ++ bit--; + bit = 1 << bit; + val &= ~bit; + +diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c +index ca70d11b8aa78..f444f57f1338b 100644 +--- a/kernel/trace/trace_selftest.c ++++ b/kernel/trace/trace_selftest.c +@@ -490,8 +490,13 @@ trace_selftest_function_recursion(void) + unregister_ftrace_function(&test_rec_probe); + + ret = -1; +- if (trace_selftest_recursion_cnt != 1) { +- pr_cont("*callback not called once (%d)* ", ++ /* ++ * Recursion allows for transitions between context, ++ * and may call the callback twice. ++ */ ++ if (trace_selftest_recursion_cnt != 1 && ++ trace_selftest_recursion_cnt != 2) { ++ pr_cont("*callback not called once (or twice) (%d)* ", + trace_selftest_recursion_cnt); + goto out; + } +diff --git a/lib/fonts/font_10x18.c b/lib/fonts/font_10x18.c +index 87e904f550c15..0ea39bfdc3cfa 100644 +--- a/lib/fonts/font_10x18.c ++++ b/lib/fonts/font_10x18.c +@@ -7,7 +7,7 @@ + + #define FONTDATAMAX 9216 + +-static struct font_data fontdata_10x18 = { ++static const struct font_data fontdata_10x18 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, 0x00, /* 0000000000 */ +diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c +index 896ffa987c97b..ec243d7d2e0e3 100644 +--- a/lib/fonts/font_6x10.c ++++ b/lib/fonts/font_6x10.c +@@ -2,7 +2,7 @@ + + #define FONTDATAMAX 2560 + +-static struct font_data fontdata_6x10 = { ++static const struct font_data fontdata_6x10 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ +diff --git a/lib/fonts/font_6x11.c b/lib/fonts/font_6x11.c +index eb46a59307d2e..0010e213fbe22 100644 +--- a/lib/fonts/font_6x11.c ++++ b/lib/fonts/font_6x11.c +@@ -8,7 +8,7 @@ + + #define FONTDATAMAX (11*256) + +-static struct font_data fontdata_6x11 = { ++static const struct font_data fontdata_6x11 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ +diff --git a/lib/fonts/font_7x14.c b/lib/fonts/font_7x14.c +index c88b3bba001bd..2900b59325e5f 100644 +--- a/lib/fonts/font_7x14.c ++++ b/lib/fonts/font_7x14.c +@@ -7,7 +7,7 @@ + + #define FONTDATAMAX 3584 + +-static struct font_data fontdata_7x14 = { ++static const struct font_data fontdata_7x14 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 0000000 */ +diff --git a/lib/fonts/font_8x16.c b/lib/fonts/font_8x16.c +index ba53e2643670b..cc3fa17ff94df 100644 +--- a/lib/fonts/font_8x16.c ++++ b/lib/fonts/font_8x16.c +@@ -9,7 +9,7 @@ + + #define FONTDATAMAX 4096 + +-static struct font_data fontdata_8x16 = { ++static const struct font_data fontdata_8x16 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ +diff --git a/lib/fonts/font_8x8.c b/lib/fonts/font_8x8.c +index 4d28b81e8237c..1519b7ce88278 100644 +--- a/lib/fonts/font_8x8.c ++++ b/lib/fonts/font_8x8.c +@@ -8,7 +8,7 @@ + + #define FONTDATAMAX 2048 + +-static struct font_data fontdata_8x8 = { ++static const struct font_data fontdata_8x8 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ +diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c +index 957398b762d38..c6367ed4c5bcf 100644 +--- a/lib/fonts/font_acorn_8x8.c ++++ b/lib/fonts/font_acorn_8x8.c +@@ -4,7 +4,7 @@ + + #define FONTDATAMAX 2048 + +-static struct font_data acorndata_8x8 = { ++static const struct font_data acorndata_8x8 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */ + /* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */ +diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c +index 1449876c6a270..592774a90917b 100644 +--- a/lib/fonts/font_mini_4x6.c ++++ b/lib/fonts/font_mini_4x6.c +@@ -43,7 +43,7 @@ __END__; + + #define FONTDATAMAX 1536 + +-static struct font_data fontdata_mini_4x6 = { ++static const struct font_data fontdata_mini_4x6 = { + { 0, 0, FONTDATAMAX, 0 }, { + /*{*/ + /* Char 0: ' ' */ +diff --git a/lib/fonts/font_pearl_8x8.c b/lib/fonts/font_pearl_8x8.c +index 4649314333bb0..6351b759ae702 100644 +--- a/lib/fonts/font_pearl_8x8.c ++++ b/lib/fonts/font_pearl_8x8.c +@@ -13,7 +13,7 @@ + + #define FONTDATAMAX 2048 + +-static struct font_data fontdata_pearl8x8 = { ++static const struct font_data fontdata_pearl8x8 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, /* 00000000 */ +diff --git a/lib/fonts/font_sun12x22.c b/lib/fonts/font_sun12x22.c +index c6967cdf4207b..057b0bf368a2a 100644 +--- a/lib/fonts/font_sun12x22.c ++++ b/lib/fonts/font_sun12x22.c +@@ -2,7 +2,7 @@ + + #define FONTDATAMAX 11264 + +-static struct font_data fontdata_sun12x22 = { ++static const struct font_data fontdata_sun12x22 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* 0 0x00 '^@' */ + 0x00, 0x00, /* 000000000000 */ +diff --git a/lib/fonts/font_sun8x16.c b/lib/fonts/font_sun8x16.c +index 7d979e5788999..84db7275e0534 100644 +--- a/lib/fonts/font_sun8x16.c ++++ b/lib/fonts/font_sun8x16.c +@@ -2,7 +2,7 @@ + + #define FONTDATAMAX 4096 + +-static struct font_data fontdata_sun8x16 = { ++static const struct font_data fontdata_sun8x16 = { + { 0, 0, FONTDATAMAX, 0 }, { + /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + /* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, +diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c +index eab058f93ec97..6f8e84844bb27 100644 +--- a/net/9p/trans_fd.c ++++ b/net/9p/trans_fd.c +@@ -991,7 +991,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) + + csocket = NULL; + +- if (addr == NULL) ++ if (!addr || !strlen(addr)) + return -EINVAL; + + if (strlen(addr) >= UNIX_PATH_MAX) { +diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c +index 3ed2796d008bb..3fbc312e43cef 100644 +--- a/net/ceph/messenger.c ++++ b/net/ceph/messenger.c +@@ -2976,6 +2976,11 @@ static void con_fault(struct ceph_connection *con) + ceph_msg_put(con->in_msg); + con->in_msg = NULL; + } ++ if (con->out_msg) { ++ BUG_ON(con->out_msg->con != con); ++ ceph_msg_put(con->out_msg); ++ con->out_msg = NULL; ++ } + + /* Requeue anything that hasn't been acked */ + list_splice_init(&con->out_sent, &con->out_queue); +diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c +index f28aeb2cfd328..cc308f7a2c027 100644 +--- a/net/sunrpc/clnt.c ++++ b/net/sunrpc/clnt.c +@@ -1826,6 +1826,14 @@ call_connect_status(struct rpc_task *task) + task->tk_status = 0; + switch (status) { + case -ECONNREFUSED: ++ /* A positive refusal suggests a rebind is needed. */ ++ if (RPC_IS_SOFTCONN(task)) ++ break; ++ if (clnt->cl_autobind) { ++ rpc_force_rebind(clnt); ++ task->tk_action = call_bind; ++ return; ++ } + case -ECONNRESET: + case -ECONNABORTED: + case -ENETUNREACH: +diff --git a/net/tipc/core.c b/net/tipc/core.c +index 1aa16b00f1057..758e59a20a6c5 100644 +--- a/net/tipc/core.c ++++ b/net/tipc/core.c +@@ -88,6 +88,11 @@ out_sk_rht: + static void __net_exit tipc_exit_net(struct net *net) + { + tipc_net_stop(net); ++ ++ /* Make sure the tipc_net_finalize_work stopped ++ * before releasing the resources. ++ */ ++ flush_scheduled_work(); + tipc_bcast_stop(net); + tipc_nametbl_stop(net); + tipc_sk_rht_destroy(net); +diff --git a/net/tipc/msg.c b/net/tipc/msg.c +index 30c3a7985fa4d..f3c7e5d1fc57e 100644 +--- a/net/tipc/msg.c ++++ b/net/tipc/msg.c +@@ -138,12 +138,11 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) + if (fragid == FIRST_FRAGMENT) { + if (unlikely(head)) + goto err; +- if (skb_cloned(frag)) +- frag = skb_copy(frag, GFP_ATOMIC); ++ *buf = NULL; ++ frag = skb_unshare(frag, GFP_ATOMIC); + if (unlikely(!frag)) + goto err; + head = *headbuf = frag; +- *buf = NULL; + TIPC_SKB_CB(head)->tail = NULL; + if (skb_is_nonlinear(head)) { + skb_walk_frags(head, tail) { +diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c +index a645352e366aa..07b1a2775210b 100644 +--- a/net/vmw_vsock/af_vsock.c ++++ b/net/vmw_vsock/af_vsock.c +@@ -633,7 +633,7 @@ struct sock *__vsock_create(struct net *net, + vsk->owner = get_cred(psk->owner); + vsk->connect_timeout = psk->connect_timeout; + } else { +- vsk->trusted = capable(CAP_NET_ADMIN); ++ vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN); + vsk->owner = get_current_cred(); + vsk->connect_timeout = VSOCK_DEFAULT_CONNECT_TIMEOUT; + } +diff --git a/scripts/setlocalversion b/scripts/setlocalversion +index aa28c3f298093..0c8741b795d0c 100755 +--- a/scripts/setlocalversion ++++ b/scripts/setlocalversion +@@ -44,7 +44,7 @@ scm_version() + + # Check for git and a git repo. + if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && +- head=`git rev-parse --verify --short HEAD 2>/dev/null`; then ++ head=$(git rev-parse --verify HEAD 2>/dev/null); then + + # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore + # it, because this version is defined in the top level Makefile. +@@ -58,11 +58,22 @@ scm_version() + fi + # If we are past a tagged commit (like + # "v2.6.30-rc5-302-g72357d5"), we pretty print it. +- if atag="`git describe 2>/dev/null`"; then +- echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' +- +- # If we don't have a tag at all we print -g{commitish}. ++ # ++ # Ensure the abbreviated sha1 has exactly 12 ++ # hex characters, to make the output ++ # independent of git version, local ++ # core.abbrev settings and/or total number of ++ # objects in the current repository - passing ++ # --abbrev=12 ensures a minimum of 12, and the ++ # awk substr() then picks the 'g' and first 12 ++ # hex chars. ++ if atag="$(git describe --abbrev=12 2>/dev/null)"; then ++ echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}' ++ ++ # If we don't have a tag at all we print -g{commitish}, ++ # again using exactly 12 hex chars. + else ++ head="$(echo $head | cut -c1-12)" + printf '%s%s' -g $head + fi + fi +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c +index c97d9a537f763..366813f1a5f80 100644 +--- a/sound/usb/pcm.c ++++ b/sound/usb/pcm.c +@@ -332,6 +332,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, + switch (subs->stream->chip->usb_id) { + case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ + case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */ ++ case USB_ID(0x22f0, 0x0006): /* Allen&Heath Qu-16 */ + ep = 0x81; + iface = usb_ifnum_to_if(dev, 3); + diff --git a/patch/kernel/rockpis-legacy/patch-4.4.242-243.patch b/patch/kernel/rockpis-legacy/patch-4.4.242-243.patch new file mode 100644 index 000000000..dd5374f07 --- /dev/null +++ b/patch/kernel/rockpis-legacy/patch-4.4.242-243.patch @@ -0,0 +1,28 @@ +diff --git a/Makefile b/Makefile +index 0ba3fd9144264..99badda272d74 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 4 +-SUBLEVEL = 242 ++SUBLEVEL = 243 + EXTRAVERSION = + NAME = Blurry Fish Butt + +diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c +index fd12ccc11e262..2313bb93f5c2e 100644 +--- a/drivers/powercap/powercap_sys.c ++++ b/drivers/powercap/powercap_sys.c +@@ -379,9 +379,9 @@ static void create_power_zone_common_attributes( + &dev_attr_max_energy_range_uj.attr; + if (power_zone->ops->get_energy_uj) { + if (power_zone->ops->reset_energy_uj) +- dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO; ++ dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUSR; + else +- dev_attr_energy_uj.attr.mode = S_IRUGO; ++ dev_attr_energy_uj.attr.mode = S_IRUSR; + power_zone->zone_dev_attrs[count++] = + &dev_attr_energy_uj.attr; + } diff --git a/patch/kernel/sunxi-current/patch-5.9.3-4-modified.patch b/patch/kernel/sunxi-current/patch-5.9.3-4-modified.patch deleted file mode 100644 index 74ce81f31..000000000 --- a/patch/kernel/sunxi-current/patch-5.9.3-4-modified.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/Makefile b/Makefile -index 50e927f348532..0c8f0ba8c34f4 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 9 --SUBLEVEL = 3 -+SUBLEVEL = 4 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - diff --git a/patch/kernel/sunxi-current/patch-5.9.4-5.patch b/patch/kernel/sunxi-current/patch-5.9.4-5.patch deleted file mode 100644 index e545ae3eb..000000000 --- a/patch/kernel/sunxi-current/patch-5.9.4-5.patch +++ /dev/null @@ -1,18521 +0,0 @@ -diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt -index ffe864390c5ac..dca917ac21d93 100644 ---- a/Documentation/admin-guide/kernel-parameters.txt -+++ b/Documentation/admin-guide/kernel-parameters.txt -@@ -5828,6 +5828,14 @@ - improve timer resolution at the expense of processing - more timer interrupts. - -+ xen.event_eoi_delay= [XEN] -+ How long to delay EOI handling in case of event -+ storms (jiffies). Default is 10. -+ -+ xen.event_loop_timeout= [XEN] -+ After which time (jiffies) the event handling loop -+ should start to delay EOI handling. Default is 2. -+ - nopv= [X86,XEN,KVM,HYPER_V,VMWARE] - Disables the PV optimizations forcing the guest to run - as generic guest with no PV drivers. Currently support -diff --git a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml -index ae33fc957141f..c3c595e235a86 100644 ---- a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml -+++ b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml -@@ -62,11 +62,6 @@ properties: - $ref: /schemas/types.yaml#/definitions/uint32 - description: TI-SCI device id of the ring accelerator - -- ti,dma-ring-reset-quirk: -- $ref: /schemas/types.yaml#definitions/flag -- description: | -- enable ringacc/udma ring state interoperability issue software w/a -- - required: - - compatible - - reg -@@ -94,7 +89,6 @@ examples: - reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target"; - ti,num-rings = <818>; - ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */ -- ti,dma-ring-reset-quirk; - ti,sci = <&dmsc>; - ti,sci-dev-id = <187>; - msi-parent = <&inta_main_udmass>; -diff --git a/Documentation/userspace-api/media/v4l/colorspaces-defs.rst b/Documentation/userspace-api/media/v4l/colorspaces-defs.rst -index 01404e1f609a7..4089f426258d6 100644 ---- a/Documentation/userspace-api/media/v4l/colorspaces-defs.rst -+++ b/Documentation/userspace-api/media/v4l/colorspaces-defs.rst -@@ -36,8 +36,7 @@ whole range, 0-255, dividing the angular value by 1.41. The enum - :c:type:`v4l2_hsv_encoding` specifies which encoding is used. - - .. note:: The default R'G'B' quantization is full range for all -- colorspaces except for BT.2020 which uses limited range R'G'B' -- quantization. -+ colorspaces. HSV formats are always full range. - - .. tabularcolumns:: |p{6.7cm}|p{10.8cm}| - -@@ -169,8 +168,8 @@ whole range, 0-255, dividing the angular value by 1.41. The enum - - Details - * - ``V4L2_QUANTIZATION_DEFAULT`` - - Use the default quantization encoding as defined by the -- colorspace. This is always full range for R'G'B' (except for the -- BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr. -+ colorspace. This is always full range for R'G'B' and HSV. -+ It is usually limited range for Y'CbCr. - * - ``V4L2_QUANTIZATION_FULL_RANGE`` - - Use the full range quantization encoding. I.e. the range [0…1] is - mapped to [0…255] (with possible clipping to [1…254] to avoid the -@@ -180,4 +179,4 @@ whole range, 0-255, dividing the angular value by 1.41. The enum - * - ``V4L2_QUANTIZATION_LIM_RANGE`` - - Use the limited range quantization encoding. I.e. the range [0…1] - is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to -- [16…240]. -+ [16…240]. Limited Range cannot be used with HSV. -diff --git a/Documentation/userspace-api/media/v4l/colorspaces-details.rst b/Documentation/userspace-api/media/v4l/colorspaces-details.rst -index 300c5d2e7d0f0..cf1b825ec34a7 100644 ---- a/Documentation/userspace-api/media/v4l/colorspaces-details.rst -+++ b/Documentation/userspace-api/media/v4l/colorspaces-details.rst -@@ -377,9 +377,8 @@ Colorspace BT.2020 (V4L2_COLORSPACE_BT2020) - The :ref:`itu2020` standard defines the colorspace used by Ultra-high - definition television (UHDTV). The default transfer function is - ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is --``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited --range (!), and so is the default Y'CbCr quantization. The chromaticities --of the primary colors and the white reference are: -+``V4L2_YCBCR_ENC_BT2020``. The default Y'CbCr quantization is limited range. -+The chromaticities of the primary colors and the white reference are: - - - -diff --git a/Makefile b/Makefile -index 0c8f0ba8c34f4..27d4fe12da24c 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 9 --SUBLEVEL = 4 -+SUBLEVEL = 5 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/Kconfig b/arch/Kconfig -index af14a567b493f..94821e3f94d16 100644 ---- a/arch/Kconfig -+++ b/arch/Kconfig -@@ -414,6 +414,13 @@ config MMU_GATHER_NO_GATHER - bool - depends on MMU_GATHER_TABLE_FREE - -+config ARCH_WANT_IRQS_OFF_ACTIVATE_MM -+ bool -+ help -+ Temporary select until all architectures can be converted to have -+ irqs disabled over activate_mm. Architectures that do IPI based TLB -+ shootdowns should enable this. -+ - config ARCH_HAVE_NMI_SAFE_CMPXCHG - bool - -diff --git a/arch/arc/boot/dts/axc001.dtsi b/arch/arc/boot/dts/axc001.dtsi -index 79ec27c043c1d..2a151607b0805 100644 ---- a/arch/arc/boot/dts/axc001.dtsi -+++ b/arch/arc/boot/dts/axc001.dtsi -@@ -91,7 +91,7 @@ - * avoid duplicating the MB dtsi file given that IRQ from - * this intc to cpu intc are different for axs101 and axs103 - */ -- mb_intc: dw-apb-ictl@e0012000 { -+ mb_intc: interrupt-controller@e0012000 { - #interrupt-cells = <1>; - compatible = "snps,dw-apb-ictl"; - reg = < 0x0 0xe0012000 0x0 0x200 >; -diff --git a/arch/arc/boot/dts/axc003.dtsi b/arch/arc/boot/dts/axc003.dtsi -index ac8e1b463a709..cd1edcf4f95ef 100644 ---- a/arch/arc/boot/dts/axc003.dtsi -+++ b/arch/arc/boot/dts/axc003.dtsi -@@ -129,7 +129,7 @@ - * avoid duplicating the MB dtsi file given that IRQ from - * this intc to cpu intc are different for axs101 and axs103 - */ -- mb_intc: dw-apb-ictl@e0012000 { -+ mb_intc: interrupt-controller@e0012000 { - #interrupt-cells = <1>; - compatible = "snps,dw-apb-ictl"; - reg = < 0x0 0xe0012000 0x0 0x200 >; -diff --git a/arch/arc/boot/dts/axc003_idu.dtsi b/arch/arc/boot/dts/axc003_idu.dtsi -index 9da21e7fd246f..70779386ca796 100644 ---- a/arch/arc/boot/dts/axc003_idu.dtsi -+++ b/arch/arc/boot/dts/axc003_idu.dtsi -@@ -135,7 +135,7 @@ - * avoid duplicating the MB dtsi file given that IRQ from - * this intc to cpu intc are different for axs101 and axs103 - */ -- mb_intc: dw-apb-ictl@e0012000 { -+ mb_intc: interrupt-controller@e0012000 { - #interrupt-cells = <1>; - compatible = "snps,dw-apb-ictl"; - reg = < 0x0 0xe0012000 0x0 0x200 >; -diff --git a/arch/arc/boot/dts/vdk_axc003.dtsi b/arch/arc/boot/dts/vdk_axc003.dtsi -index f8be7ba8dad49..c21d0eb07bf67 100644 ---- a/arch/arc/boot/dts/vdk_axc003.dtsi -+++ b/arch/arc/boot/dts/vdk_axc003.dtsi -@@ -46,7 +46,7 @@ - - }; - -- mb_intc: dw-apb-ictl@e0012000 { -+ mb_intc: interrupt-controller@e0012000 { - #interrupt-cells = <1>; - compatible = "snps,dw-apb-ictl"; - reg = < 0xe0012000 0x200 >; -diff --git a/arch/arc/boot/dts/vdk_axc003_idu.dtsi b/arch/arc/boot/dts/vdk_axc003_idu.dtsi -index 0afa3e53a4e39..4d348853ac7c5 100644 ---- a/arch/arc/boot/dts/vdk_axc003_idu.dtsi -+++ b/arch/arc/boot/dts/vdk_axc003_idu.dtsi -@@ -54,7 +54,7 @@ - - }; - -- mb_intc: dw-apb-ictl@e0012000 { -+ mb_intc: interrupt-controller@e0012000 { - #interrupt-cells = <1>; - compatible = "snps,dw-apb-ictl"; - reg = < 0xe0012000 0x200 >; -diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c -index 79849f37e782c..145722f80c9b7 100644 ---- a/arch/arc/kernel/perf_event.c -+++ b/arch/arc/kernel/perf_event.c -@@ -562,7 +562,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev) - { - struct arc_reg_pct_build pct_bcr; - struct arc_reg_cc_build cc_bcr; -- int i, has_interrupts, irq; -+ int i, has_interrupts, irq = -1; - int counter_size; /* in bits */ - - union cc_name { -@@ -637,19 +637,28 @@ static int arc_pmu_device_probe(struct platform_device *pdev) - .attr_groups = arc_pmu->attr_groups, - }; - -- if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) { -+ if (has_interrupts) { -+ irq = platform_get_irq(pdev, 0); -+ if (irq >= 0) { -+ int ret; - -- arc_pmu->irq = irq; -+ arc_pmu->irq = irq; - -- /* intc map function ensures irq_set_percpu_devid() called */ -- request_percpu_irq(irq, arc_pmu_intr, "ARC perf counters", -- this_cpu_ptr(&arc_pmu_cpu)); -+ /* intc map function ensures irq_set_percpu_devid() called */ -+ ret = request_percpu_irq(irq, arc_pmu_intr, "ARC perf counters", -+ this_cpu_ptr(&arc_pmu_cpu)); -+ -+ if (!ret) -+ on_each_cpu(arc_cpu_pmu_irq_init, &irq, 1); -+ else -+ irq = -1; -+ } - -- on_each_cpu(arc_cpu_pmu_irq_init, &irq, 1); -- } else { -- arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; - } - -+ if (irq == -1) -+ arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; -+ - /* - * perf parser doesn't really like '-' symbol in events name, so let's - * use '_' in arc pct name as it goes to kernel PMU event prefix. -diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig -index e00d94b166587..23e2c0dc85c1e 100644 ---- a/arch/arm/Kconfig -+++ b/arch/arm/Kconfig -@@ -506,8 +506,10 @@ config ARCH_S3C24XX - select HAVE_S3C2410_WATCHDOG if WATCHDOG - select HAVE_S3C_RTC if RTC_CLASS - select NEED_MACH_IO_H -+ select S3C2410_WATCHDOG - select SAMSUNG_ATAGS - select USE_OF -+ select WATCHDOG - help - Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443 - and S3C2450 SoCs based systems, such as the Simtec Electronics BAST -diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi -index 9c91afb2b4042..a93009aa2f040 100644 ---- a/arch/arm/boot/dts/aspeed-g5.dtsi -+++ b/arch/arm/boot/dts/aspeed-g5.dtsi -@@ -425,7 +425,6 @@ - interrupts = <8>; - clocks = <&syscon ASPEED_CLK_APB>; - no-loopback-test; -- aspeed,sirq-polarity-sense = <&syscon 0x70 25>; - status = "disabled"; - }; - -diff --git a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts -index 2b760f90f38c8..5375c6699843f 100644 ---- a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts -+++ b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts -@@ -192,6 +192,7 @@ - fixed-link { - speed = <1000>; - full-duplex; -+ pause; - }; - }; - }; -diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi -index 0282b9de3384f..52e8298275050 100644 ---- a/arch/arm/boot/dts/omap4.dtsi -+++ b/arch/arm/boot/dts/omap4.dtsi -@@ -410,7 +410,7 @@ - status = "disabled"; - }; - -- target-module@56000000 { -+ sgx_module: target-module@56000000 { - compatible = "ti,sysc-omap4", "ti,sysc"; - reg = <0x5600fe00 0x4>, - <0x5600fe10 0x4>; -diff --git a/arch/arm/boot/dts/omap443x.dtsi b/arch/arm/boot/dts/omap443x.dtsi -index 8ed510ab00c52..cb309743de5da 100644 ---- a/arch/arm/boot/dts/omap443x.dtsi -+++ b/arch/arm/boot/dts/omap443x.dtsi -@@ -74,3 +74,13 @@ - }; - - /include/ "omap443x-clocks.dtsi" -+ -+/* -+ * Use dpll_per for sgx at 153.6MHz like droid4 stock v3.0.8 Android kernel -+ */ -+&sgx_module { -+ assigned-clocks = <&l3_gfx_clkctrl OMAP4_GPU_CLKCTRL 24>, -+ <&dpll_per_m7x2_ck>; -+ assigned-clock-rates = <0>, <153600000>; -+ assigned-clock-parents = <&dpll_per_m7x2_ck>; -+}; -diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi b/arch/arm/boot/dts/s5pv210-aries.dtsi -index 822207f63ee0a..bd4450dbdcb61 100644 ---- a/arch/arm/boot/dts/s5pv210-aries.dtsi -+++ b/arch/arm/boot/dts/s5pv210-aries.dtsi -@@ -47,6 +47,18 @@ - }; - }; - -+ pmic_ap_clk: clock-0 { -+ /* Workaround for missing clock on PMIC */ -+ compatible = "fixed-clock"; -+ #clock-cells = <0>; -+ clock-frequency = <32768>; -+ }; -+ -+ bt_codec: bt_sco { -+ compatible = "linux,bt-sco"; -+ #sound-dai-cells = <0>; -+ }; -+ - vibrator_pwr: regulator-fixed-0 { - compatible = "regulator-fixed"; - regulator-name = "vibrator-en"; -@@ -54,7 +66,7 @@ - gpio = <&gpj1 1 GPIO_ACTIVE_HIGH>; - - pinctrl-names = "default"; -- pinctr-0 = <&vibrator_ena>; -+ pinctrl-0 = <&vibrator_ena>; - }; - - touchkey_vdd: regulator-fixed-1 { -@@ -533,7 +545,7 @@ - value = <0x5200>; - }; - -- spi_lcd: spi-gpio-0 { -+ spi_lcd: spi-2 { - compatible = "spi-gpio"; - #address-cells = <1>; - #size-cells = <0>; -@@ -624,6 +636,11 @@ - }; - }; - -+&i2s0 { -+ dmas = <&pdma0 9>, <&pdma0 10>, <&pdma0 11>; -+ status = "okay"; -+}; -+ - &mfc { - memory-region = <&mfc_left>, <&mfc_right>; - }; -@@ -815,6 +832,11 @@ - samsung,pwm-outputs = <1>; - }; - -+&rtc { -+ clocks = <&clocks CLK_RTC>, <&pmic_ap_clk>; -+ clock-names = "rtc", "rtc_src"; -+}; -+ - &sdhci1 { - #address-cells = <1>; - #size-cells = <0>; -diff --git a/arch/arm/boot/dts/s5pv210-fascinate4g.dts b/arch/arm/boot/dts/s5pv210-fascinate4g.dts -index 65eed01cfced1..ca064359dd308 100644 ---- a/arch/arm/boot/dts/s5pv210-fascinate4g.dts -+++ b/arch/arm/boot/dts/s5pv210-fascinate4g.dts -@@ -35,6 +35,80 @@ - linux,code = ; - }; - }; -+ -+ headset_micbias_reg: regulator-fixed-3 { -+ compatible = "regulator-fixed"; -+ regulator-name = "Headset_Micbias"; -+ gpio = <&gpj2 5 GPIO_ACTIVE_HIGH>; -+ enable-active-high; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&headset_micbias_ena>; -+ }; -+ -+ main_micbias_reg: regulator-fixed-4 { -+ compatible = "regulator-fixed"; -+ regulator-name = "Main_Micbias"; -+ gpio = <&gpj4 2 GPIO_ACTIVE_HIGH>; -+ enable-active-high; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&main_micbias_ena>; -+ }; -+ -+ sound { -+ compatible = "samsung,fascinate4g-wm8994"; -+ -+ model = "Fascinate4G"; -+ -+ extcon = <&fsa9480>; -+ -+ main-micbias-supply = <&main_micbias_reg>; -+ headset-micbias-supply = <&headset_micbias_reg>; -+ -+ earpath-sel-gpios = <&gpj2 6 GPIO_ACTIVE_HIGH>; -+ -+ io-channels = <&adc 3>; -+ io-channel-names = "headset-detect"; -+ headset-detect-gpios = <&gph0 6 GPIO_ACTIVE_HIGH>; -+ headset-key-gpios = <&gph3 6 GPIO_ACTIVE_HIGH>; -+ -+ samsung,audio-routing = -+ "HP", "HPOUT1L", -+ "HP", "HPOUT1R", -+ -+ "SPK", "SPKOUTLN", -+ "SPK", "SPKOUTLP", -+ -+ "RCV", "HPOUT2N", -+ "RCV", "HPOUT2P", -+ -+ "LINE", "LINEOUT2N", -+ "LINE", "LINEOUT2P", -+ -+ "IN1LP", "Main Mic", -+ "IN1LN", "Main Mic", -+ -+ "IN1RP", "Headset Mic", -+ "IN1RN", "Headset Mic", -+ -+ "Modem Out", "Modem TX", -+ "Modem RX", "Modem In", -+ -+ "Bluetooth SPK", "TX", -+ "RX", "Bluetooth Mic"; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&headset_det &earpath_sel>; -+ -+ cpu { -+ sound-dai = <&i2s0>, <&bt_codec>; -+ }; -+ -+ codec { -+ sound-dai = <&wm8994>; -+ }; -+ }; - }; - - &fg { -@@ -51,6 +125,12 @@ - pinctrl-names = "default"; - pinctrl-0 = <&sleep_cfg>; - -+ headset_det: headset-det { -+ samsung,pins = "gph0-6", "gph3-6"; -+ samsung,pin-function = ; -+ samsung,pin-pud = ; -+ }; -+ - fg_irq: fg-irq { - samsung,pins = "gph3-3"; - samsung,pin-function = ; -@@ -58,6 +138,24 @@ - samsung,pin-drv = ; - }; - -+ headset_micbias_ena: headset-micbias-ena { -+ samsung,pins = "gpj2-5"; -+ samsung,pin-pud = ; -+ samsung,pin-drv = ; -+ }; -+ -+ earpath_sel: earpath-sel { -+ samsung,pins = "gpj2-6"; -+ samsung,pin-pud = ; -+ samsung,pin-drv = ; -+ }; -+ -+ main_micbias_ena: main-micbias-ena { -+ samsung,pins = "gpj4-2"; -+ samsung,pin-pud = ; -+ samsung,pin-drv = ; -+ }; -+ - /* Based on vendor kernel v2.6.35.7 */ - sleep_cfg: sleep-cfg { - PIN_SLP(gpa0-0, PREV, NONE); -diff --git a/arch/arm/boot/dts/s5pv210-galaxys.dts b/arch/arm/boot/dts/s5pv210-galaxys.dts -index 5d10dd67eacc5..560f830b6f6be 100644 ---- a/arch/arm/boot/dts/s5pv210-galaxys.dts -+++ b/arch/arm/boot/dts/s5pv210-galaxys.dts -@@ -72,6 +72,73 @@ - pinctrl-0 = <&fm_irq &fm_rst>; - }; - }; -+ -+ micbias_reg: regulator-fixed-3 { -+ compatible = "regulator-fixed"; -+ regulator-name = "MICBIAS"; -+ gpio = <&gpj4 2 GPIO_ACTIVE_HIGH>; -+ enable-active-high; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&micbias_reg_ena>; -+ }; -+ -+ sound { -+ compatible = "samsung,aries-wm8994"; -+ -+ model = "Aries"; -+ -+ extcon = <&fsa9480>; -+ -+ main-micbias-supply = <&micbias_reg>; -+ headset-micbias-supply = <&micbias_reg>; -+ -+ earpath-sel-gpios = <&gpj2 6 GPIO_ACTIVE_HIGH>; -+ -+ io-channels = <&adc 3>; -+ io-channel-names = "headset-detect"; -+ headset-detect-gpios = <&gph0 6 GPIO_ACTIVE_LOW>; -+ headset-key-gpios = <&gph3 6 GPIO_ACTIVE_HIGH>; -+ -+ samsung,audio-routing = -+ "HP", "HPOUT1L", -+ "HP", "HPOUT1R", -+ -+ "SPK", "SPKOUTLN", -+ "SPK", "SPKOUTLP", -+ -+ "RCV", "HPOUT2N", -+ "RCV", "HPOUT2P", -+ -+ "LINE", "LINEOUT2N", -+ "LINE", "LINEOUT2P", -+ -+ "IN1LP", "Main Mic", -+ "IN1LN", "Main Mic", -+ -+ "IN1RP", "Headset Mic", -+ "IN1RN", "Headset Mic", -+ -+ "IN2LN", "FM In", -+ "IN2RN", "FM In", -+ -+ "Modem Out", "Modem TX", -+ "Modem RX", "Modem In", -+ -+ "Bluetooth SPK", "TX", -+ "RX", "Bluetooth Mic"; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&headset_det &earpath_sel>; -+ -+ cpu { -+ sound-dai = <&i2s0>, <&bt_codec>; -+ }; -+ -+ codec { -+ sound-dai = <&wm8994>; -+ }; -+ }; - }; - - &aliases { -@@ -88,6 +155,12 @@ - samsung,pin-drv = ; - }; - -+ headset_det: headset-det { -+ samsung,pins = "gph0-6", "gph3-6"; -+ samsung,pin-function = ; -+ samsung,pin-pud = ; -+ }; -+ - fm_irq: fm-irq { - samsung,pins = "gpj2-4"; - samsung,pin-function = ; -@@ -102,6 +175,12 @@ - samsung,pin-drv = ; - }; - -+ earpath_sel: earpath-sel { -+ samsung,pins = "gpj2-6"; -+ samsung,pin-pud = ; -+ samsung,pin-drv = ; -+ }; -+ - massmemory_en: massmemory-en { - samsung,pins = "gpj2-7"; - samsung,pin-function = ; -@@ -109,6 +188,12 @@ - samsung,pin-drv = ; - }; - -+ micbias_reg_ena: micbias-reg-ena { -+ samsung,pins = "gpj4-2"; -+ samsung,pin-pud = ; -+ samsung,pin-drv = ; -+ }; -+ - /* Based on CyanogenMod 3.0.101 kernel */ - sleep_cfg: sleep-cfg { - PIN_SLP(gpa0-0, PREV, NONE); -diff --git a/arch/arm/boot/dts/s5pv210.dtsi b/arch/arm/boot/dts/s5pv210.dtsi -index 1b0ee884e91db..2871351ab9074 100644 ---- a/arch/arm/boot/dts/s5pv210.dtsi -+++ b/arch/arm/boot/dts/s5pv210.dtsi -@@ -52,34 +52,26 @@ - }; - }; - -+ xxti: oscillator-0 { -+ compatible = "fixed-clock"; -+ clock-frequency = <0>; -+ clock-output-names = "xxti"; -+ #clock-cells = <0>; -+ }; -+ -+ xusbxti: oscillator-1 { -+ compatible = "fixed-clock"; -+ clock-frequency = <0>; -+ clock-output-names = "xusbxti"; -+ #clock-cells = <0>; -+ }; -+ - soc { - compatible = "simple-bus"; - #address-cells = <1>; - #size-cells = <1>; - ranges; - -- external-clocks { -- compatible = "simple-bus"; -- #address-cells = <1>; -- #size-cells = <0>; -- -- xxti: oscillator@0 { -- compatible = "fixed-clock"; -- reg = <0>; -- clock-frequency = <0>; -- clock-output-names = "xxti"; -- #clock-cells = <0>; -- }; -- -- xusbxti: oscillator@1 { -- compatible = "fixed-clock"; -- reg = <1>; -- clock-frequency = <0>; -- clock-output-names = "xusbxti"; -- #clock-cells = <0>; -- }; -- }; -- - onenand: onenand@b0600000 { - compatible = "samsung,s5pv210-onenand"; - reg = <0xb0600000 0x2000>, -@@ -100,19 +92,16 @@ - }; - - clocks: clock-controller@e0100000 { -- compatible = "samsung,s5pv210-clock", "simple-bus"; -+ compatible = "samsung,s5pv210-clock"; - reg = <0xe0100000 0x10000>; - clock-names = "xxti", "xusbxti"; - clocks = <&xxti>, <&xusbxti>; - #clock-cells = <1>; -- #address-cells = <1>; -- #size-cells = <1>; -- ranges; -+ }; - -- pmu_syscon: syscon@e0108000 { -- compatible = "samsung-s5pv210-pmu", "syscon"; -- reg = <0xe0108000 0x8000>; -- }; -+ pmu_syscon: syscon@e0108000 { -+ compatible = "samsung-s5pv210-pmu", "syscon"; -+ reg = <0xe0108000 0x8000>; - }; - - pinctrl0: pinctrl@e0200000 { -@@ -128,35 +117,28 @@ - }; - }; - -- amba { -- #address-cells = <1>; -- #size-cells = <1>; -- compatible = "simple-bus"; -- ranges; -- -- pdma0: dma@e0900000 { -- compatible = "arm,pl330", "arm,primecell"; -- reg = <0xe0900000 0x1000>; -- interrupt-parent = <&vic0>; -- interrupts = <19>; -- clocks = <&clocks CLK_PDMA0>; -- clock-names = "apb_pclk"; -- #dma-cells = <1>; -- #dma-channels = <8>; -- #dma-requests = <32>; -- }; -+ pdma0: dma@e0900000 { -+ compatible = "arm,pl330", "arm,primecell"; -+ reg = <0xe0900000 0x1000>; -+ interrupt-parent = <&vic0>; -+ interrupts = <19>; -+ clocks = <&clocks CLK_PDMA0>; -+ clock-names = "apb_pclk"; -+ #dma-cells = <1>; -+ #dma-channels = <8>; -+ #dma-requests = <32>; -+ }; - -- pdma1: dma@e0a00000 { -- compatible = "arm,pl330", "arm,primecell"; -- reg = <0xe0a00000 0x1000>; -- interrupt-parent = <&vic0>; -- interrupts = <20>; -- clocks = <&clocks CLK_PDMA1>; -- clock-names = "apb_pclk"; -- #dma-cells = <1>; -- #dma-channels = <8>; -- #dma-requests = <32>; -- }; -+ pdma1: dma@e0a00000 { -+ compatible = "arm,pl330", "arm,primecell"; -+ reg = <0xe0a00000 0x1000>; -+ interrupt-parent = <&vic0>; -+ interrupts = <20>; -+ clocks = <&clocks CLK_PDMA1>; -+ clock-names = "apb_pclk"; -+ #dma-cells = <1>; -+ #dma-channels = <8>; -+ #dma-requests = <32>; - }; - - adc: adc@e1700000 { -@@ -241,43 +223,36 @@ - status = "disabled"; - }; - -- audio-subsystem { -- compatible = "samsung,s5pv210-audss", "simple-bus"; -- #address-cells = <1>; -- #size-cells = <1>; -- ranges; -- -- clk_audss: clock-controller@eee10000 { -- compatible = "samsung,s5pv210-audss-clock"; -- reg = <0xeee10000 0x1000>; -- clock-names = "hclk", "xxti", -- "fout_epll", -- "sclk_audio0"; -- clocks = <&clocks DOUT_HCLKP>, <&xxti>, -- <&clocks FOUT_EPLL>, -- <&clocks SCLK_AUDIO0>; -- #clock-cells = <1>; -- }; -+ clk_audss: clock-controller@eee10000 { -+ compatible = "samsung,s5pv210-audss-clock"; -+ reg = <0xeee10000 0x1000>; -+ clock-names = "hclk", "xxti", -+ "fout_epll", -+ "sclk_audio0"; -+ clocks = <&clocks DOUT_HCLKP>, <&xxti>, -+ <&clocks FOUT_EPLL>, -+ <&clocks SCLK_AUDIO0>; -+ #clock-cells = <1>; -+ }; - -- i2s0: i2s@eee30000 { -- compatible = "samsung,s5pv210-i2s"; -- reg = <0xeee30000 0x1000>; -- interrupt-parent = <&vic2>; -- interrupts = <16>; -- dma-names = "rx", "tx", "tx-sec"; -- dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>; -- clock-names = "iis", -- "i2s_opclk0", -- "i2s_opclk1"; -- clocks = <&clk_audss CLK_I2S>, -- <&clk_audss CLK_I2S>, -- <&clk_audss CLK_DOUT_AUD_BUS>; -- samsung,idma-addr = <0xc0010000>; -- pinctrl-names = "default"; -- pinctrl-0 = <&i2s0_bus>; -- #sound-dai-cells = <0>; -- status = "disabled"; -- }; -+ i2s0: i2s@eee30000 { -+ compatible = "samsung,s5pv210-i2s"; -+ reg = <0xeee30000 0x1000>; -+ interrupt-parent = <&vic2>; -+ interrupts = <16>; -+ dma-names = "rx", "tx", "tx-sec"; -+ dmas = <&pdma1 9>, <&pdma1 10>, <&pdma1 11>; -+ clock-names = "iis", -+ "i2s_opclk0", -+ "i2s_opclk1"; -+ clocks = <&clk_audss CLK_I2S>, -+ <&clk_audss CLK_I2S>, -+ <&clk_audss CLK_DOUT_AUD_BUS>; -+ samsung,idma-addr = <0xc0010000>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&i2s0_bus>; -+ #sound-dai-cells = <0>; -+ status = "disabled"; - }; - - i2s1: i2s@e2100000 { -diff --git a/arch/arm/configs/aspeed_g4_defconfig b/arch/arm/configs/aspeed_g4_defconfig -index 303f75a3baec9..58d293b635818 100644 ---- a/arch/arm/configs/aspeed_g4_defconfig -+++ b/arch/arm/configs/aspeed_g4_defconfig -@@ -160,7 +160,8 @@ CONFIG_SENSORS_TMP421=y - CONFIG_SENSORS_W83773G=y - CONFIG_WATCHDOG_SYSFS=y - CONFIG_MEDIA_SUPPORT=y --CONFIG_MEDIA_CAMERA_SUPPORT=y -+CONFIG_MEDIA_SUPPORT_FILTER=y -+CONFIG_MEDIA_PLATFORM_SUPPORT=y - CONFIG_V4L_PLATFORM_DRIVERS=y - CONFIG_VIDEO_ASPEED=y - CONFIG_DRM=y -diff --git a/arch/arm/configs/aspeed_g5_defconfig b/arch/arm/configs/aspeed_g5_defconfig -index b0d056d49abe1..cc2449ed6e6d3 100644 ---- a/arch/arm/configs/aspeed_g5_defconfig -+++ b/arch/arm/configs/aspeed_g5_defconfig -@@ -175,7 +175,8 @@ CONFIG_SENSORS_TMP421=y - CONFIG_SENSORS_W83773G=y - CONFIG_WATCHDOG_SYSFS=y - CONFIG_MEDIA_SUPPORT=y --CONFIG_MEDIA_CAMERA_SUPPORT=y -+CONFIG_MEDIA_SUPPORT_FILTER=y -+CONFIG_MEDIA_PLATFORM_SUPPORT=y - CONFIG_V4L_PLATFORM_DRIVERS=y - CONFIG_VIDEO_ASPEED=y - CONFIG_DRM=y -diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c -index 7a4853b1213a8..08660ae9dcbce 100644 ---- a/arch/arm/kernel/hw_breakpoint.c -+++ b/arch/arm/kernel/hw_breakpoint.c -@@ -683,6 +683,40 @@ static void disable_single_step(struct perf_event *bp) - arch_install_hw_breakpoint(bp); - } - -+/* -+ * Arm32 hardware does not always report a watchpoint hit address that matches -+ * one of the watchpoints set. It can also report an address "near" the -+ * watchpoint if a single instruction access both watched and unwatched -+ * addresses. There is no straight-forward way, short of disassembling the -+ * offending instruction, to map that address back to the watchpoint. This -+ * function computes the distance of the memory access from the watchpoint as a -+ * heuristic for the likelyhood that a given access triggered the watchpoint. -+ * -+ * See this same function in the arm64 platform code, which has the same -+ * problem. -+ * -+ * The function returns the distance of the address from the bytes watched by -+ * the watchpoint. In case of an exact match, it returns 0. -+ */ -+static u32 get_distance_from_watchpoint(unsigned long addr, u32 val, -+ struct arch_hw_breakpoint_ctrl *ctrl) -+{ -+ u32 wp_low, wp_high; -+ u32 lens, lene; -+ -+ lens = __ffs(ctrl->len); -+ lene = __fls(ctrl->len); -+ -+ wp_low = val + lens; -+ wp_high = val + lene; -+ if (addr < wp_low) -+ return wp_low - addr; -+ else if (addr > wp_high) -+ return addr - wp_high; -+ else -+ return 0; -+} -+ - static int watchpoint_fault_on_uaccess(struct pt_regs *regs, - struct arch_hw_breakpoint *info) - { -@@ -692,23 +726,25 @@ static int watchpoint_fault_on_uaccess(struct pt_regs *regs, - static void watchpoint_handler(unsigned long addr, unsigned int fsr, - struct pt_regs *regs) - { -- int i, access; -- u32 val, ctrl_reg, alignment_mask; -+ int i, access, closest_match = 0; -+ u32 min_dist = -1, dist; -+ u32 val, ctrl_reg; - struct perf_event *wp, **slots; - struct arch_hw_breakpoint *info; - struct arch_hw_breakpoint_ctrl ctrl; - - slots = this_cpu_ptr(wp_on_reg); - -+ /* -+ * Find all watchpoints that match the reported address. If no exact -+ * match is found. Attribute the hit to the closest watchpoint. -+ */ -+ rcu_read_lock(); - for (i = 0; i < core_num_wrps; ++i) { -- rcu_read_lock(); -- - wp = slots[i]; -- - if (wp == NULL) -- goto unlock; -+ continue; - -- info = counter_arch_bp(wp); - /* - * The DFAR is an unknown value on debug architectures prior - * to 7.1. Since we only allow a single watchpoint on these -@@ -717,33 +753,31 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr, - */ - if (debug_arch < ARM_DEBUG_ARCH_V7_1) { - BUG_ON(i > 0); -+ info = counter_arch_bp(wp); - info->trigger = wp->attr.bp_addr; - } else { -- if (info->ctrl.len == ARM_BREAKPOINT_LEN_8) -- alignment_mask = 0x7; -- else -- alignment_mask = 0x3; -- -- /* Check if the watchpoint value matches. */ -- val = read_wb_reg(ARM_BASE_WVR + i); -- if (val != (addr & ~alignment_mask)) -- goto unlock; -- -- /* Possible match, check the byte address select. */ -- ctrl_reg = read_wb_reg(ARM_BASE_WCR + i); -- decode_ctrl_reg(ctrl_reg, &ctrl); -- if (!((1 << (addr & alignment_mask)) & ctrl.len)) -- goto unlock; -- - /* Check that the access type matches. */ - if (debug_exception_updates_fsr()) { - access = (fsr & ARM_FSR_ACCESS_MASK) ? - HW_BREAKPOINT_W : HW_BREAKPOINT_R; - if (!(access & hw_breakpoint_type(wp))) -- goto unlock; -+ continue; - } - -+ val = read_wb_reg(ARM_BASE_WVR + i); -+ ctrl_reg = read_wb_reg(ARM_BASE_WCR + i); -+ decode_ctrl_reg(ctrl_reg, &ctrl); -+ dist = get_distance_from_watchpoint(addr, val, &ctrl); -+ if (dist < min_dist) { -+ min_dist = dist; -+ closest_match = i; -+ } -+ /* Is this an exact match? */ -+ if (dist != 0) -+ continue; -+ - /* We have a winner. */ -+ info = counter_arch_bp(wp); - info->trigger = addr; - } - -@@ -765,13 +799,23 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr, - * we can single-step over the watchpoint trigger. - */ - if (!is_default_overflow_handler(wp)) -- goto unlock; -- -+ continue; - step: - enable_single_step(wp, instruction_pointer(regs)); --unlock: -- rcu_read_unlock(); - } -+ -+ if (min_dist > 0 && min_dist != -1) { -+ /* No exact match found. */ -+ wp = slots[closest_match]; -+ info = counter_arch_bp(wp); -+ info->trigger = addr; -+ pr_debug("watchpoint fired: address = 0x%x\n", info->trigger); -+ perf_bp_event(wp, regs); -+ if (is_default_overflow_handler(wp)) -+ enable_single_step(wp, instruction_pointer(regs)); -+ } -+ -+ rcu_read_unlock(); - } - - static void watchpoint_single_step_handler(unsigned long pc) -diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig -index 301e572651c0f..790c87ee72716 100644 ---- a/arch/arm/plat-samsung/Kconfig -+++ b/arch/arm/plat-samsung/Kconfig -@@ -241,6 +241,7 @@ config SAMSUNG_PM_DEBUG - depends on PM && DEBUG_KERNEL - depends on PLAT_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 - depends on DEBUG_EXYNOS_UART || DEBUG_S3C24XX_UART || DEBUG_S3C2410_UART -+ depends on DEBUG_LL && MMU - help - Say Y here if you want verbose debugging from the PM Suspend and - Resume code. See -diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms -index cd58f8495c458..5b433a7f975b0 100644 ---- a/arch/arm64/Kconfig.platforms -+++ b/arch/arm64/Kconfig.platforms -@@ -54,6 +54,7 @@ config ARCH_BCM_IPROC - config ARCH_BERLIN - bool "Marvell Berlin SoC Family" - select DW_APB_ICTL -+ select DW_APB_TIMER_OF - select GPIOLIB - select PINCTRL - help -diff --git a/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts b/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts -index 03733fd92732d..215d2f7026233 100644 ---- a/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts -+++ b/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts -@@ -20,17 +20,23 @@ - compatible = "globalscale,espressobin-v7-emmc", "globalscale,espressobin-v7", - "globalscale,espressobin", "marvell,armada3720", - "marvell,armada3710"; -+ -+ aliases { -+ /* ethernet1 is wan port */ -+ ethernet1 = &switch0port3; -+ ethernet3 = &switch0port1; -+ }; - }; - - &switch0 { - ports { -- port@1 { -+ switch0port1: port@1 { - reg = <1>; - label = "lan1"; - phy-handle = <&switch0phy0>; - }; - -- port@3 { -+ switch0port3: port@3 { - reg = <3>; - label = "wan"; - phy-handle = <&switch0phy2>; -diff --git a/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts b/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts -index 8570c5f47d7d8..b6f4af8ebafbb 100644 ---- a/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts -+++ b/arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts -@@ -19,17 +19,23 @@ - model = "Globalscale Marvell ESPRESSOBin Board V7"; - compatible = "globalscale,espressobin-v7", "globalscale,espressobin", - "marvell,armada3720", "marvell,armada3710"; -+ -+ aliases { -+ /* ethernet1 is wan port */ -+ ethernet1 = &switch0port3; -+ ethernet3 = &switch0port1; -+ }; - }; - - &switch0 { - ports { -- port@1 { -+ switch0port1: port@1 { - reg = <1>; - label = "lan1"; - phy-handle = <&switch0phy0>; - }; - -- port@3 { -+ switch0port3: port@3 { - reg = <3>; - label = "wan"; - phy-handle = <&switch0phy2>; -diff --git a/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi b/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi -index b97218c727277..0775c16e0ec80 100644 ---- a/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi -+++ b/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi -@@ -13,6 +13,10 @@ - / { - aliases { - ethernet0 = ð0; -+ /* for dsa slave device */ -+ ethernet1 = &switch0port1; -+ ethernet2 = &switch0port2; -+ ethernet3 = &switch0port3; - serial0 = &uart0; - serial1 = &uart1; - }; -@@ -120,7 +124,7 @@ - #address-cells = <1>; - #size-cells = <0>; - -- port@0 { -+ switch0port0: port@0 { - reg = <0>; - label = "cpu"; - ethernet = <ð0>; -@@ -131,19 +135,19 @@ - }; - }; - -- port@1 { -+ switch0port1: port@1 { - reg = <1>; - label = "wan"; - phy-handle = <&switch0phy0>; - }; - -- port@2 { -+ switch0port2: port@2 { - reg = <2>; - label = "lan0"; - phy-handle = <&switch0phy1>; - }; - -- port@3 { -+ switch0port3: port@3 { - reg = <3>; - label = "lan1"; - phy-handle = <&switch0phy2>; -diff --git a/arch/arm64/boot/dts/qcom/msm8994-sony-xperia-kitakami.dtsi b/arch/arm64/boot/dts/qcom/msm8994-sony-xperia-kitakami.dtsi -index 4032b7478f044..791f254ac3f87 100644 ---- a/arch/arm64/boot/dts/qcom/msm8994-sony-xperia-kitakami.dtsi -+++ b/arch/arm64/boot/dts/qcom/msm8994-sony-xperia-kitakami.dtsi -@@ -221,7 +221,12 @@ - }; - - &sdhc1 { -- status = "okay"; -+ /* There is an issue with the eMMC causing permanent -+ * damage to the card if a quirk isn't addressed. -+ * Until it's fixed, disable the MMC so as not to brick -+ * devices. -+ */ -+ status = "disabled"; - - /* Downstream pushes 2.95V to the sdhci device, - * but upstream driver REALLY wants to make vmmc 1.8v -diff --git a/arch/arm64/boot/dts/renesas/ulcb.dtsi b/arch/arm64/boot/dts/renesas/ulcb.dtsi -index ff88af8e39d3f..a2e085db87c53 100644 ---- a/arch/arm64/boot/dts/renesas/ulcb.dtsi -+++ b/arch/arm64/boot/dts/renesas/ulcb.dtsi -@@ -469,6 +469,7 @@ - mmc-hs200-1_8v; - mmc-hs400-1_8v; - non-removable; -+ full-pwr-cycle-in-suspend; - status = "okay"; - }; - -diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h -index 905c2b87e05ac..34675109921e7 100644 ---- a/arch/arm64/include/asm/kvm_host.h -+++ b/arch/arm64/include/asm/kvm_host.h -@@ -231,6 +231,7 @@ enum vcpu_sysreg { - #define cp14_DBGWCR0 (DBGWCR0_EL1 * 2) - #define cp14_DBGWVR0 (DBGWVR0_EL1 * 2) - #define cp14_DBGDCCINT (MDCCINT_EL1 * 2) -+#define cp14_DBGVCR (DBGVCR32_EL2 * 2) - - #define NR_COPRO_REGS (NR_SYS_REGS * 2) - -diff --git a/arch/arm64/include/asm/numa.h b/arch/arm64/include/asm/numa.h -index 626ad01e83bf0..dd870390d639f 100644 ---- a/arch/arm64/include/asm/numa.h -+++ b/arch/arm64/include/asm/numa.h -@@ -25,6 +25,9 @@ const struct cpumask *cpumask_of_node(int node); - /* Returns a pointer to the cpumask of CPUs on Node 'node'. */ - static inline const struct cpumask *cpumask_of_node(int node) - { -+ if (node == NUMA_NO_NODE) -+ return cpu_all_mask; -+ - return node_to_cpumask_map[node]; - } - #endif -diff --git a/arch/arm64/kernel/efi-header.S b/arch/arm64/kernel/efi-header.S -index df67c0f2a077e..a71844fb923ee 100644 ---- a/arch/arm64/kernel/efi-header.S -+++ b/arch/arm64/kernel/efi-header.S -@@ -147,6 +147,6 @@ efi_debug_entry: - * correctly at this alignment, we must ensure that .text is - * placed at a 4k boundary in the Image to begin with. - */ -- .align 12 -+ .balign SEGMENT_ALIGN - efi_header_end: - .endm -diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c -index 0801a0f3c156a..ff1dd1dbfe641 100644 ---- a/arch/arm64/kernel/topology.c -+++ b/arch/arm64/kernel/topology.c -@@ -36,21 +36,23 @@ void store_cpu_topology(unsigned int cpuid) - if (mpidr & MPIDR_UP_BITMASK) - return; - -- /* Create cpu topology mapping based on MPIDR. */ -- if (mpidr & MPIDR_MT_BITMASK) { -- /* Multiprocessor system : Multi-threads per core */ -- cpuid_topo->thread_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); -- cpuid_topo->core_id = MPIDR_AFFINITY_LEVEL(mpidr, 1); -- cpuid_topo->package_id = MPIDR_AFFINITY_LEVEL(mpidr, 2) | -- MPIDR_AFFINITY_LEVEL(mpidr, 3) << 8; -- } else { -- /* Multiprocessor system : Single-thread per core */ -- cpuid_topo->thread_id = -1; -- cpuid_topo->core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); -- cpuid_topo->package_id = MPIDR_AFFINITY_LEVEL(mpidr, 1) | -- MPIDR_AFFINITY_LEVEL(mpidr, 2) << 8 | -- MPIDR_AFFINITY_LEVEL(mpidr, 3) << 16; -- } -+ /* -+ * This would be the place to create cpu topology based on MPIDR. -+ * -+ * However, it cannot be trusted to depict the actual topology; some -+ * pieces of the architecture enforce an artificial cap on Aff0 values -+ * (e.g. GICv3's ICC_SGI1R_EL1 limits it to 15), leading to an -+ * artificial cycling of Aff1, Aff2 and Aff3 values. IOW, these end up -+ * having absolutely no relationship to the actual underlying system -+ * topology, and cannot be reasonably used as core / package ID. -+ * -+ * If the MT bit is set, Aff0 *could* be used to define a thread ID, but -+ * we still wouldn't be able to obtain a sane core ID. This means we -+ * need to entirely ignore MPIDR for any topology deduction. -+ */ -+ cpuid_topo->thread_id = -1; -+ cpuid_topo->core_id = cpuid; -+ cpuid_topo->package_id = cpu_to_node(cpuid); - - pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n", - cpuid, cpuid_topo->package_id, cpuid_topo->core_id, -diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c -index 077293b5115fa..de5a5a80ae99a 100644 ---- a/arch/arm64/kvm/sys_regs.c -+++ b/arch/arm64/kvm/sys_regs.c -@@ -1881,9 +1881,9 @@ static const struct sys_reg_desc cp14_regs[] = { - { Op1( 0), CRn( 0), CRm( 1), Op2( 0), trap_raz_wi }, - DBG_BCR_BVR_WCR_WVR(1), - /* DBGDCCINT */ -- { Op1( 0), CRn( 0), CRm( 2), Op2( 0), trap_debug32 }, -+ { Op1( 0), CRn( 0), CRm( 2), Op2( 0), trap_debug32, NULL, cp14_DBGDCCINT }, - /* DBGDSCRext */ -- { Op1( 0), CRn( 0), CRm( 2), Op2( 2), trap_debug32 }, -+ { Op1( 0), CRn( 0), CRm( 2), Op2( 2), trap_debug32, NULL, cp14_DBGDSCRext }, - DBG_BCR_BVR_WCR_WVR(2), - /* DBGDTR[RT]Xint */ - { Op1( 0), CRn( 0), CRm( 3), Op2( 0), trap_raz_wi }, -@@ -1898,7 +1898,7 @@ static const struct sys_reg_desc cp14_regs[] = { - { Op1( 0), CRn( 0), CRm( 6), Op2( 2), trap_raz_wi }, - DBG_BCR_BVR_WCR_WVR(6), - /* DBGVCR */ -- { Op1( 0), CRn( 0), CRm( 7), Op2( 0), trap_debug32 }, -+ { Op1( 0), CRn( 0), CRm( 7), Op2( 0), trap_debug32, NULL, cp14_DBGVCR }, - DBG_BCR_BVR_WCR_WVR(7), - DBG_BCR_BVR_WCR_WVR(8), - DBG_BCR_BVR_WCR_WVR(9), -diff --git a/arch/arm64/lib/memcpy.S b/arch/arm64/lib/memcpy.S -index e0bf83d556f23..dc8d2a216a6e6 100644 ---- a/arch/arm64/lib/memcpy.S -+++ b/arch/arm64/lib/memcpy.S -@@ -56,9 +56,8 @@ - stp \reg1, \reg2, [\ptr], \val - .endm - -- .weak memcpy - SYM_FUNC_START_ALIAS(__memcpy) --SYM_FUNC_START_PI(memcpy) -+SYM_FUNC_START_WEAK_PI(memcpy) - #include "copy_template.S" - ret - SYM_FUNC_END_PI(memcpy) -diff --git a/arch/arm64/lib/memmove.S b/arch/arm64/lib/memmove.S -index 02cda2e33bde2..1035dce4bdaf4 100644 ---- a/arch/arm64/lib/memmove.S -+++ b/arch/arm64/lib/memmove.S -@@ -45,9 +45,8 @@ C_h .req x12 - D_l .req x13 - D_h .req x14 - -- .weak memmove - SYM_FUNC_START_ALIAS(__memmove) --SYM_FUNC_START_PI(memmove) -+SYM_FUNC_START_WEAK_PI(memmove) - cmp dstin, src - b.lo __memcpy - add tmp1, src, count -diff --git a/arch/arm64/lib/memset.S b/arch/arm64/lib/memset.S -index 77c3c7ba00842..a9c1c9a01ea90 100644 ---- a/arch/arm64/lib/memset.S -+++ b/arch/arm64/lib/memset.S -@@ -42,9 +42,8 @@ dst .req x8 - tmp3w .req w9 - tmp3 .req x9 - -- .weak memset - SYM_FUNC_START_ALIAS(__memset) --SYM_FUNC_START_PI(memset) -+SYM_FUNC_START_WEAK_PI(memset) - mov dst, dstin /* Preserve return value. */ - and A_lw, val, #255 - orr A_lw, A_lw, A_lw, lsl #8 -diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c -index 73f8b49d485c2..88e51aade0da0 100644 ---- a/arch/arm64/mm/numa.c -+++ b/arch/arm64/mm/numa.c -@@ -46,7 +46,11 @@ EXPORT_SYMBOL(node_to_cpumask_map); - */ - const struct cpumask *cpumask_of_node(int node) - { -- if (WARN_ON(node >= nr_node_ids)) -+ -+ if (node == NUMA_NO_NODE) -+ return cpu_all_mask; -+ -+ if (WARN_ON(node < 0 || node >= nr_node_ids)) - return cpu_none_mask; - - if (WARN_ON(node_to_cpumask_map[node] == NULL)) -diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile -index 1a8df6669eee6..18d6008b151fd 100644 ---- a/arch/ia64/kernel/Makefile -+++ b/arch/ia64/kernel/Makefile -@@ -41,7 +41,7 @@ obj-y += esi_stub.o # must be in kernel proper - endif - obj-$(CONFIG_INTEL_IOMMU) += pci-dma.o - --obj-$(CONFIG_BINFMT_ELF) += elfcore.o -+obj-$(CONFIG_ELF_CORE) += elfcore.o - - # fp_emulate() expects f2-f5,f16-f31 to contain the user-level state. - CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31 -diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c -index 7a7df944d7986..fc1ff8a4d7de6 100644 ---- a/arch/ia64/kernel/kprobes.c -+++ b/arch/ia64/kernel/kprobes.c -@@ -396,83 +396,9 @@ static void kretprobe_trampoline(void) - { - } - --/* -- * At this point the target function has been tricked into -- * returning into our trampoline. Lookup the associated instance -- * and then: -- * - call the handler function -- * - cleanup by marking the instance as unused -- * - long jump back to the original return address -- */ - int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) - { -- struct kretprobe_instance *ri = NULL; -- struct hlist_head *head, empty_rp; -- struct hlist_node *tmp; -- unsigned long flags, orig_ret_address = 0; -- unsigned long trampoline_address = -- ((struct fnptr *)kretprobe_trampoline)->ip; -- -- INIT_HLIST_HEAD(&empty_rp); -- kretprobe_hash_lock(current, &head, &flags); -- -- /* -- * It is possible to have multiple instances associated with a given -- * task either because an multiple functions in the call path -- * have a return probe installed on them, and/or more than one return -- * return probe was registered for a target function. -- * -- * We can handle this because: -- * - instances are always inserted at the head of the list -- * - when multiple return probes are registered for the same -- * function, the first instance's ret_addr will point to the -- * real return address, and all the rest will point to -- * kretprobe_trampoline -- */ -- hlist_for_each_entry_safe(ri, tmp, head, hlist) { -- if (ri->task != current) -- /* another task is sharing our hash bucket */ -- continue; -- -- orig_ret_address = (unsigned long)ri->ret_addr; -- if (orig_ret_address != trampoline_address) -- /* -- * This is the real return address. Any other -- * instances associated with this task are for -- * other calls deeper on the call stack -- */ -- break; -- } -- -- regs->cr_iip = orig_ret_address; -- -- hlist_for_each_entry_safe(ri, tmp, head, hlist) { -- if (ri->task != current) -- /* another task is sharing our hash bucket */ -- continue; -- -- if (ri->rp && ri->rp->handler) -- ri->rp->handler(ri, regs); -- -- orig_ret_address = (unsigned long)ri->ret_addr; -- recycle_rp_inst(ri, &empty_rp); -- -- if (orig_ret_address != trampoline_address) -- /* -- * This is the real return address. Any other -- * instances associated with this task are for -- * other calls deeper on the call stack -- */ -- break; -- } -- kretprobe_assert(ri, orig_ret_address, trampoline_address); -- -- kretprobe_hash_unlock(current, &flags); -- -- hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { -- hlist_del(&ri->hlist); -- kfree(ri); -- } -+ regs->cr_iip = __kretprobe_trampoline_handler(regs, kretprobe_trampoline, NULL); - /* - * By returning a non-zero value, we are telling - * kprobe_handler() that we don't want the post_handler -@@ -485,6 +411,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, - struct pt_regs *regs) - { - ri->ret_addr = (kprobe_opcode_t *)regs->b0; -+ ri->fp = NULL; - - /* Replace the return addr with trampoline addr */ - regs->b0 = ((struct fnptr *)kretprobe_trampoline)->ip; -diff --git a/arch/mips/configs/qi_lb60_defconfig b/arch/mips/configs/qi_lb60_defconfig -index 81bfbee72b0c3..9c2c183085d11 100644 ---- a/arch/mips/configs/qi_lb60_defconfig -+++ b/arch/mips/configs/qi_lb60_defconfig -@@ -8,6 +8,7 @@ CONFIG_EMBEDDED=y - # CONFIG_COMPAT_BRK is not set - CONFIG_SLAB=y - CONFIG_MACH_INGENIC=y -+CONFIG_JZ4740_QI_LB60=y - CONFIG_HZ_100=y - # CONFIG_SECCOMP is not set - CONFIG_MODULES=y -diff --git a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c -index d4e868b828e58..eaad0ed4b523b 100644 ---- a/arch/mips/dec/setup.c -+++ b/arch/mips/dec/setup.c -@@ -6,7 +6,7 @@ - * for more details. - * - * Copyright (C) 1998 Harald Koerfgen -- * Copyright (C) 2000, 2001, 2002, 2003, 2005 Maciej W. Rozycki -+ * Copyright (C) 2000, 2001, 2002, 2003, 2005, 2020 Maciej W. Rozycki - */ - #include - #include -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -22,6 +23,7 @@ - #include - #include - -+#include - #include - #include - #include -@@ -29,7 +31,9 @@ - #include - #include - #include -+#include - #include -+#include - #include - #include - #include -@@ -146,6 +150,9 @@ void __init plat_mem_setup(void) - - ioport_resource.start = ~0UL; - ioport_resource.end = 0UL; -+ -+ /* Stay away from the firmware working memory area for now. */ -+ memblock_reserve(PHYS_OFFSET, __pa_symbol(&_text) - PHYS_OFFSET); - } - - /* -diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig -index 2b15b4870565d..aaf069c72aa1b 100644 ---- a/arch/powerpc/Kconfig -+++ b/arch/powerpc/Kconfig -@@ -148,6 +148,7 @@ config PPC - select ARCH_USE_QUEUED_RWLOCKS if PPC_QUEUED_SPINLOCKS - select ARCH_USE_QUEUED_SPINLOCKS if PPC_QUEUED_SPINLOCKS - select ARCH_WANT_IPC_PARSE_VERSION -+ select ARCH_WANT_IRQS_OFF_ACTIVATE_MM - select ARCH_WEAK_RELEASE_ACQUIRE - select BINFMT_ELF - select BUILDTIME_TABLE_SORT -@@ -1000,6 +1001,19 @@ config PPC_SECVAR_SYSFS - read/write operations on these variables. Say Y if you have - secure boot enabled and want to expose variables to userspace. - -+config PPC_RTAS_FILTER -+ bool "Enable filtering of RTAS syscalls" -+ default y -+ depends on PPC_RTAS -+ help -+ The RTAS syscall API has security issues that could be used to -+ compromise system integrity. This option enforces restrictions on the -+ RTAS calls and arguments passed by userspace programs to mitigate -+ these issues. -+ -+ Say Y unless you know what you are doing and the filter is causing -+ problems for you. -+ - endmenu - - config ISA_DMA_API -diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h -index 030a19d922132..bf2402fed3e03 100644 ---- a/arch/powerpc/include/asm/drmem.h -+++ b/arch/powerpc/include/asm/drmem.h -@@ -20,7 +20,7 @@ struct drmem_lmb { - struct drmem_lmb_info { - struct drmem_lmb *lmbs; - int n_lmbs; -- u32 lmb_size; -+ u64 lmb_size; - }; - - extern struct drmem_lmb_info *drmem_info; -@@ -80,7 +80,7 @@ struct of_drconf_cell_v2 { - #define DRCONF_MEM_RESERVED 0x00000080 - #define DRCONF_MEM_HOTREMOVABLE 0x00000100 - --static inline u32 drmem_lmb_size(void) -+static inline u64 drmem_lmb_size(void) - { - return drmem_info->lmb_size; - } -diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h -index 7f3658a973846..e02aa793420b8 100644 ---- a/arch/powerpc/include/asm/mmu_context.h -+++ b/arch/powerpc/include/asm/mmu_context.h -@@ -244,7 +244,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, - */ - static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) - { -- switch_mm(prev, next, current); -+ switch_mm_irqs_off(prev, next, current); - } - - /* We don't currently use enter_lazy_tlb() for anything */ -diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S -index f3ab94d73936d..a5a612deef66e 100644 ---- a/arch/powerpc/kernel/head_32.S -+++ b/arch/powerpc/kernel/head_32.S -@@ -274,14 +274,8 @@ __secondary_hold_acknowledge: - DO_KVM 0x200 - MachineCheck: - EXCEPTION_PROLOG_0 --#ifdef CONFIG_VMAP_STACK -- li r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ -- mtmsr r11 -- isync --#endif - #ifdef CONFIG_PPC_CHRP - mfspr r11, SPRN_SPRG_THREAD -- tovirt_vmstack r11, r11 - lwz r11, RTAS_SP(r11) - cmpwi cr1, r11, 0 - bne cr1, 7f -@@ -1002,7 +996,7 @@ BEGIN_MMU_FTR_SECTION - END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) - blr - --load_segment_registers: -+_GLOBAL(load_segment_registers) - li r0, NUM_USER_SEGMENTS /* load up user segment register values */ - mtctr r0 /* for context 0 */ - li r3, 0 /* Kp = 0, Ks = 0, VSID = 0 */ -diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h -index 9abec6cd099c6..cc36998c55416 100644 ---- a/arch/powerpc/kernel/head_32.h -+++ b/arch/powerpc/kernel/head_32.h -@@ -40,48 +40,52 @@ - - .macro EXCEPTION_PROLOG_1 for_rtas=0 - #ifdef CONFIG_VMAP_STACK -- .ifeq \for_rtas -- li r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ -- mtmsr r11 -- isync -- .endif -- subi r11, r1, INT_FRAME_SIZE /* use r1 if kernel */ -+ mr r11, r1 -+ subi r1, r1, INT_FRAME_SIZE /* use r1 if kernel */ -+ beq 1f -+ mfspr r1,SPRN_SPRG_THREAD -+ lwz r1,TASK_STACK-THREAD(r1) -+ addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE - #else -- tophys(r11,r1) /* use tophys(r1) if kernel */ -- subi r11, r11, INT_FRAME_SIZE /* alloc exc. frame */ --#endif -+ subi r11, r1, INT_FRAME_SIZE /* use r1 if kernel */ - beq 1f - mfspr r11,SPRN_SPRG_THREAD -- tovirt_vmstack r11, r11 - lwz r11,TASK_STACK-THREAD(r11) - addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE -- tophys_novmstack r11, r11 -+#endif - 1: -+ tophys_novmstack r11, r11 - #ifdef CONFIG_VMAP_STACK -- mtcrf 0x7f, r11 -+ mtcrf 0x7f, r1 - bt 32 - THREAD_ALIGN_SHIFT, stack_overflow - #endif - .endm - - .macro EXCEPTION_PROLOG_2 handle_dar_dsisr=0 --#if defined(CONFIG_VMAP_STACK) && defined(CONFIG_PPC_BOOK3S) --BEGIN_MMU_FTR_SECTION -+#ifdef CONFIG_VMAP_STACK - mtcr r10 --FTR_SECTION_ELSE -- stw r10, _CCR(r11) --ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_HPTE_TABLE) -+ li r10, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */ -+ mtmsr r10 -+ isync - #else - stw r10,_CCR(r11) /* save registers */ - #endif - mfspr r10, SPRN_SPRG_SCRATCH0 -+#ifdef CONFIG_VMAP_STACK -+ stw r11,GPR1(r1) -+ stw r11,0(r1) -+ mr r11, r1 -+#else -+ stw r1,GPR1(r11) -+ stw r1,0(r11) -+ tovirt(r1, r11) /* set new kernel sp */ -+#endif - stw r12,GPR12(r11) - stw r9,GPR9(r11) - stw r10,GPR10(r11) --#if defined(CONFIG_VMAP_STACK) && defined(CONFIG_PPC_BOOK3S) --BEGIN_MMU_FTR_SECTION -+#ifdef CONFIG_VMAP_STACK - mfcr r10 - stw r10, _CCR(r11) --END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) - #endif - mfspr r12,SPRN_SPRG_SCRATCH1 - stw r12,GPR11(r11) -@@ -97,19 +101,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) - stw r10, _DSISR(r11) - .endif - lwz r9, SRR1(r12) --#if defined(CONFIG_VMAP_STACK) && defined(CONFIG_PPC_BOOK3S) --BEGIN_MMU_FTR_SECTION - andi. r10, r9, MSR_PR --END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) --#endif - lwz r12, SRR0(r12) - #else - mfspr r12,SPRN_SRR0 - mfspr r9,SPRN_SRR1 - #endif -- stw r1,GPR1(r11) -- stw r1,0(r11) -- tovirt_novmstack r1, r11 /* set new kernel sp */ - #ifdef CONFIG_40x - rlwinm r9,r9,0,14,12 /* clear MSR_WE (necessary?) */ - #else -@@ -327,20 +324,19 @@ label: - .macro vmap_stack_overflow_exception - #ifdef CONFIG_VMAP_STACK - #ifdef CONFIG_SMP -- mfspr r11, SPRN_SPRG_THREAD -- tovirt(r11, r11) -- lwz r11, TASK_CPU - THREAD(r11) -- slwi r11, r11, 3 -- addis r11, r11, emergency_ctx@ha -+ mfspr r1, SPRN_SPRG_THREAD -+ lwz r1, TASK_CPU - THREAD(r1) -+ slwi r1, r1, 3 -+ addis r1, r1, emergency_ctx@ha - #else -- lis r11, emergency_ctx@ha -+ lis r1, emergency_ctx@ha - #endif -- lwz r11, emergency_ctx@l(r11) -- cmpwi cr1, r11, 0 -+ lwz r1, emergency_ctx@l(r1) -+ cmpwi cr1, r1, 0 - bne cr1, 1f -- lis r11, init_thread_union@ha -- addi r11, r11, init_thread_union@l --1: addi r11, r11, THREAD_SIZE - INT_FRAME_SIZE -+ lis r1, init_thread_union@ha -+ addi r1, r1, init_thread_union@l -+1: addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE - EXCEPTION_PROLOG_2 - SAVE_NVGPRS(r11) - addi r3, r1, STACK_FRAME_OVERHEAD -diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c -index ada59f6c4298f..63702c0badb97 100644 ---- a/arch/powerpc/kernel/mce.c -+++ b/arch/powerpc/kernel/mce.c -@@ -591,12 +591,11 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info); - long notrace machine_check_early(struct pt_regs *regs) - { - long handled = 0; -- bool nested = in_nmi(); - u8 ftrace_enabled = this_cpu_get_ftrace_enabled(); - - this_cpu_set_ftrace_enabled(0); -- -- if (!nested) -+ /* Do not use nmi_enter/exit for pseries hpte guest */ -+ if (radix_enabled() || !firmware_has_feature(FW_FEATURE_LPAR)) - nmi_enter(); - - hv_nmi_check_nonrecoverable(regs); -@@ -607,7 +606,7 @@ long notrace machine_check_early(struct pt_regs *regs) - if (ppc_md.machine_check_early) - handled = ppc_md.machine_check_early(regs); - -- if (!nested) -+ if (radix_enabled() || !firmware_has_feature(FW_FEATURE_LPAR)) - nmi_exit(); - - this_cpu_set_ftrace_enabled(ftrace_enabled); -diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c -index 73a57043ee662..3f2dc0675ea7a 100644 ---- a/arch/powerpc/kernel/process.c -+++ b/arch/powerpc/kernel/process.c -@@ -1256,15 +1256,17 @@ struct task_struct *__switch_to(struct task_struct *prev, - restore_math(current->thread.regs); - - /* -- * The copy-paste buffer can only store into foreign real -- * addresses, so unprivileged processes can not see the -- * data or use it in any way unless they have foreign real -- * mappings. If the new process has the foreign real address -- * mappings, we must issue a cp_abort to clear any state and -- * prevent snooping, corruption or a covert channel. -+ * On POWER9 the copy-paste buffer can only paste into -+ * foreign real addresses, so unprivileged processes can not -+ * see the data or use it in any way unless they have -+ * foreign real mappings. If the new process has the foreign -+ * real address mappings, we must issue a cp_abort to clear -+ * any state and prevent snooping, corruption or a covert -+ * channel. ISA v3.1 supports paste into local memory. - */ - if (current->mm && -- atomic_read(¤t->mm->context.vas_windows)) -+ (cpu_has_feature(CPU_FTR_ARCH_31) || -+ atomic_read(¤t->mm->context.vas_windows))) - asm volatile(PPC_CP_ABORT); - } - #endif /* CONFIG_PPC_BOOK3S_64 */ -diff --git a/arch/powerpc/kernel/ptrace/ptrace-noadv.c b/arch/powerpc/kernel/ptrace/ptrace-noadv.c -index 8bd8d8de5c40b..a570782e954be 100644 ---- a/arch/powerpc/kernel/ptrace/ptrace-noadv.c -+++ b/arch/powerpc/kernel/ptrace/ptrace-noadv.c -@@ -217,7 +217,7 @@ long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_inf - return -EIO; - - brk.address = ALIGN_DOWN(bp_info->addr, HW_BREAKPOINT_SIZE); -- brk.type = HW_BRK_TYPE_TRANSLATE; -+ brk.type = HW_BRK_TYPE_TRANSLATE | HW_BRK_TYPE_PRIV_ALL; - brk.len = DABR_MAX_LEN; - brk.hw_len = DABR_MAX_LEN; - if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_READ) -diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c -index 806d554ce3577..954f41676f692 100644 ---- a/arch/powerpc/kernel/rtas.c -+++ b/arch/powerpc/kernel/rtas.c -@@ -992,6 +992,147 @@ struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, - return NULL; - } - -+#ifdef CONFIG_PPC_RTAS_FILTER -+ -+/* -+ * The sys_rtas syscall, as originally designed, allows root to pass -+ * arbitrary physical addresses to RTAS calls. A number of RTAS calls -+ * can be abused to write to arbitrary memory and do other things that -+ * are potentially harmful to system integrity, and thus should only -+ * be used inside the kernel and not exposed to userspace. -+ * -+ * All known legitimate users of the sys_rtas syscall will only ever -+ * pass addresses that fall within the RMO buffer, and use a known -+ * subset of RTAS calls. -+ * -+ * Accordingly, we filter RTAS requests to check that the call is -+ * permitted, and that provided pointers fall within the RMO buffer. -+ * The rtas_filters list contains an entry for each permitted call, -+ * with the indexes of the parameters which are expected to contain -+ * addresses and sizes of buffers allocated inside the RMO buffer. -+ */ -+struct rtas_filter { -+ const char *name; -+ int token; -+ /* Indexes into the args buffer, -1 if not used */ -+ int buf_idx1; -+ int size_idx1; -+ int buf_idx2; -+ int size_idx2; -+ -+ int fixed_size; -+}; -+ -+static struct rtas_filter rtas_filters[] __ro_after_init = { -+ { "ibm,activate-firmware", -1, -1, -1, -1, -1 }, -+ { "ibm,configure-connector", -1, 0, -1, 1, -1, 4096 }, /* Special cased */ -+ { "display-character", -1, -1, -1, -1, -1 }, -+ { "ibm,display-message", -1, 0, -1, -1, -1 }, -+ { "ibm,errinjct", -1, 2, -1, -1, -1, 1024 }, -+ { "ibm,close-errinjct", -1, -1, -1, -1, -1 }, -+ { "ibm,open-errinct", -1, -1, -1, -1, -1 }, -+ { "ibm,get-config-addr-info2", -1, -1, -1, -1, -1 }, -+ { "ibm,get-dynamic-sensor-state", -1, 1, -1, -1, -1 }, -+ { "ibm,get-indices", -1, 2, 3, -1, -1 }, -+ { "get-power-level", -1, -1, -1, -1, -1 }, -+ { "get-sensor-state", -1, -1, -1, -1, -1 }, -+ { "ibm,get-system-parameter", -1, 1, 2, -1, -1 }, -+ { "get-time-of-day", -1, -1, -1, -1, -1 }, -+ { "ibm,get-vpd", -1, 0, -1, 1, 2 }, -+ { "ibm,lpar-perftools", -1, 2, 3, -1, -1 }, -+ { "ibm,platform-dump", -1, 4, 5, -1, -1 }, -+ { "ibm,read-slot-reset-state", -1, -1, -1, -1, -1 }, -+ { "ibm,scan-log-dump", -1, 0, 1, -1, -1 }, -+ { "ibm,set-dynamic-indicator", -1, 2, -1, -1, -1 }, -+ { "ibm,set-eeh-option", -1, -1, -1, -1, -1 }, -+ { "set-indicator", -1, -1, -1, -1, -1 }, -+ { "set-power-level", -1, -1, -1, -1, -1 }, -+ { "set-time-for-power-on", -1, -1, -1, -1, -1 }, -+ { "ibm,set-system-parameter", -1, 1, -1, -1, -1 }, -+ { "set-time-of-day", -1, -1, -1, -1, -1 }, -+ { "ibm,suspend-me", -1, -1, -1, -1, -1 }, -+ { "ibm,update-nodes", -1, 0, -1, -1, -1, 4096 }, -+ { "ibm,update-properties", -1, 0, -1, -1, -1, 4096 }, -+ { "ibm,physical-attestation", -1, 0, 1, -1, -1 }, -+}; -+ -+static bool in_rmo_buf(u32 base, u32 end) -+{ -+ return base >= rtas_rmo_buf && -+ base < (rtas_rmo_buf + RTAS_RMOBUF_MAX) && -+ base <= end && -+ end >= rtas_rmo_buf && -+ end < (rtas_rmo_buf + RTAS_RMOBUF_MAX); -+} -+ -+static bool block_rtas_call(int token, int nargs, -+ struct rtas_args *args) -+{ -+ int i; -+ -+ for (i = 0; i < ARRAY_SIZE(rtas_filters); i++) { -+ struct rtas_filter *f = &rtas_filters[i]; -+ u32 base, size, end; -+ -+ if (token != f->token) -+ continue; -+ -+ if (f->buf_idx1 != -1) { -+ base = be32_to_cpu(args->args[f->buf_idx1]); -+ if (f->size_idx1 != -1) -+ size = be32_to_cpu(args->args[f->size_idx1]); -+ else if (f->fixed_size) -+ size = f->fixed_size; -+ else -+ size = 1; -+ -+ end = base + size - 1; -+ if (!in_rmo_buf(base, end)) -+ goto err; -+ } -+ -+ if (f->buf_idx2 != -1) { -+ base = be32_to_cpu(args->args[f->buf_idx2]); -+ if (f->size_idx2 != -1) -+ size = be32_to_cpu(args->args[f->size_idx2]); -+ else if (f->fixed_size) -+ size = f->fixed_size; -+ else -+ size = 1; -+ end = base + size - 1; -+ -+ /* -+ * Special case for ibm,configure-connector where the -+ * address can be 0 -+ */ -+ if (!strcmp(f->name, "ibm,configure-connector") && -+ base == 0) -+ return false; -+ -+ if (!in_rmo_buf(base, end)) -+ goto err; -+ } -+ -+ return false; -+ } -+ -+err: -+ pr_err_ratelimited("sys_rtas: RTAS call blocked - exploit attempt?\n"); -+ pr_err_ratelimited("sys_rtas: token=0x%x, nargs=%d (called by %s)\n", -+ token, nargs, current->comm); -+ return true; -+} -+ -+#else -+ -+static bool block_rtas_call(int token, int nargs, -+ struct rtas_args *args) -+{ -+ return false; -+} -+ -+#endif /* CONFIG_PPC_RTAS_FILTER */ -+ - /* We assume to be passed big endian arguments */ - SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs) - { -@@ -1029,6 +1170,9 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs) - args.rets = &args.args[nargs]; - memset(args.rets, 0, nret * sizeof(rtas_arg_t)); - -+ if (block_rtas_call(token, nargs, &args)) -+ return -EINVAL; -+ - /* Need to handle ibm,suspend_me call specially */ - if (token == ibm_suspend_me_token) { - -@@ -1090,6 +1234,9 @@ void __init rtas_initialize(void) - unsigned long rtas_region = RTAS_INSTANTIATE_MAX; - u32 base, size, entry; - int no_base, no_size, no_entry; -+#ifdef CONFIG_PPC_RTAS_FILTER -+ int i; -+#endif - - /* Get RTAS dev node and fill up our "rtas" structure with infos - * about it. -@@ -1129,6 +1276,12 @@ void __init rtas_initialize(void) - #ifdef CONFIG_RTAS_ERROR_LOGGING - rtas_last_error_token = rtas_token("rtas-last-error"); - #endif -+ -+#ifdef CONFIG_PPC_RTAS_FILTER -+ for (i = 0; i < ARRAY_SIZE(rtas_filters); i++) { -+ rtas_filters[i].token = rtas_token(rtas_filters[i].name); -+ } -+#endif - } - - int __init early_init_dt_scan_rtas(unsigned long node, -diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c -index 46b4ebc33db77..5dea98fa2f938 100644 ---- a/arch/powerpc/kernel/sysfs.c -+++ b/arch/powerpc/kernel/sysfs.c -@@ -32,29 +32,27 @@ - - static DEFINE_PER_CPU(struct cpu, cpu_devices); - --/* -- * SMT snooze delay stuff, 64-bit only for now -- */ -- - #ifdef CONFIG_PPC64 - --/* Time in microseconds we delay before sleeping in the idle loop */ --static DEFINE_PER_CPU(long, smt_snooze_delay) = { 100 }; -+/* -+ * Snooze delay has not been hooked up since 3fa8cad82b94 ("powerpc/pseries/cpuidle: -+ * smt-snooze-delay cleanup.") and has been broken even longer. As was foretold in -+ * 2014: -+ * -+ * "ppc64_util currently utilises it. Once we fix ppc64_util, propose to clean -+ * up the kernel code." -+ * -+ * powerpc-utils stopped using it as of 1.3.8. At some point in the future this -+ * code should be removed. -+ */ - - static ssize_t store_smt_snooze_delay(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) - { -- struct cpu *cpu = container_of(dev, struct cpu, dev); -- ssize_t ret; -- long snooze; -- -- ret = sscanf(buf, "%ld", &snooze); -- if (ret != 1) -- return -EINVAL; -- -- per_cpu(smt_snooze_delay, cpu->dev.id) = snooze; -+ pr_warn_once("%s (%d) stored to unsupported smt_snooze_delay, which has no effect.\n", -+ current->comm, current->pid); - return count; - } - -@@ -62,9 +60,9 @@ static ssize_t show_smt_snooze_delay(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- struct cpu *cpu = container_of(dev, struct cpu, dev); -- -- return sprintf(buf, "%ld\n", per_cpu(smt_snooze_delay, cpu->dev.id)); -+ pr_warn_once("%s (%d) read from unsupported smt_snooze_delay\n", -+ current->comm, current->pid); -+ return sprintf(buf, "100\n"); - } - - static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay, -@@ -72,16 +70,10 @@ static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay, - - static int __init setup_smt_snooze_delay(char *str) - { -- unsigned int cpu; -- long snooze; -- - if (!cpu_has_feature(CPU_FTR_SMT)) - return 1; - -- snooze = simple_strtol(str, NULL, 10); -- for_each_possible_cpu(cpu) -- per_cpu(smt_snooze_delay, cpu) = snooze; -- -+ pr_warn("smt-snooze-delay command line option has no effect\n"); - return 1; - } - __setup("smt-snooze-delay=", setup_smt_snooze_delay); -diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c -index d1ebe152f2107..8bcbf632e95a5 100644 ---- a/arch/powerpc/kernel/traps.c -+++ b/arch/powerpc/kernel/traps.c -@@ -889,7 +889,7 @@ static void p9_hmi_special_emu(struct pt_regs *regs) - { - unsigned int ra, rb, t, i, sel, instr, rc; - const void __user *addr; -- u8 vbuf[16], *vdst; -+ u8 vbuf[16] __aligned(16), *vdst; - unsigned long ea, msr, msr_mask; - bool swap; - -diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c -index 4ba06a2a306cf..e2b476d76506a 100644 ---- a/arch/powerpc/kvm/book3s_hv.c -+++ b/arch/powerpc/kvm/book3s_hv.c -@@ -3530,6 +3530,13 @@ static int kvmhv_load_hv_regs_and_go(struct kvm_vcpu *vcpu, u64 time_limit, - */ - asm volatile("eieio; tlbsync; ptesync"); - -+ /* -+ * cp_abort is required if the processor supports local copy-paste -+ * to clear the copy buffer that was under control of the guest. -+ */ -+ if (cpu_has_feature(CPU_FTR_ARCH_31)) -+ asm volatile(PPC_CP_ABORT); -+ - mtspr(SPRN_LPID, vcpu->kvm->arch.host_lpid); /* restore host LPID */ - isync(); - -@@ -5250,6 +5257,12 @@ static long kvm_arch_vm_ioctl_hv(struct file *filp, - case KVM_PPC_ALLOCATE_HTAB: { - u32 htab_order; - -+ /* If we're a nested hypervisor, we currently only support radix */ -+ if (kvmhv_on_pseries()) { -+ r = -EOPNOTSUPP; -+ break; -+ } -+ - r = -EFAULT; - if (get_user(htab_order, (u32 __user *)argp)) - break; -diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S -index 799d6d0f4eade..cd9995ee84419 100644 ---- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S -+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S -@@ -1830,6 +1830,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_P9_RADIX_PREFETCH_BUG) - 2: - #endif /* CONFIG_PPC_RADIX_MMU */ - -+ /* -+ * cp_abort is required if the processor supports local copy-paste -+ * to clear the copy buffer that was under control of the guest. -+ */ -+BEGIN_FTR_SECTION -+ PPC_CP_ABORT -+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_31) -+ - /* - * POWER7/POWER8 guest -> host partition switch code. - * We don't have to lock against tlbies but we do -diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c -index 26292544630fb..e7ae2a2c45450 100644 ---- a/arch/powerpc/mm/hugetlbpage.c -+++ b/arch/powerpc/mm/hugetlbpage.c -@@ -330,10 +330,24 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif - get_hugepd_cache_index(pdshift - shift)); - } - --static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, unsigned long addr) -+static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, -+ unsigned long addr, unsigned long end, -+ unsigned long floor, unsigned long ceiling) - { -+ unsigned long start = addr; - pgtable_t token = pmd_pgtable(*pmd); - -+ start &= PMD_MASK; -+ if (start < floor) -+ return; -+ if (ceiling) { -+ ceiling &= PMD_MASK; -+ if (!ceiling) -+ return; -+ } -+ if (end - 1 > ceiling - 1) -+ return; -+ - pmd_clear(pmd); - pte_free_tlb(tlb, token, addr); - mm_dec_nr_ptes(tlb->mm); -@@ -363,7 +377,7 @@ static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud, - */ - WARN_ON(!IS_ENABLED(CONFIG_PPC_8xx)); - -- hugetlb_free_pte_range(tlb, pmd, addr); -+ hugetlb_free_pte_range(tlb, pmd, addr, end, floor, ceiling); - - continue; - } -diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c -index 8459056cce671..2ae42c2a5cf04 100644 ---- a/arch/powerpc/mm/init_64.c -+++ b/arch/powerpc/mm/init_64.c -@@ -162,16 +162,16 @@ static __meminit struct vmemmap_backing * vmemmap_list_alloc(int node) - return next++; - } - --static __meminit void vmemmap_list_populate(unsigned long phys, -- unsigned long start, -- int node) -+static __meminit int vmemmap_list_populate(unsigned long phys, -+ unsigned long start, -+ int node) - { - struct vmemmap_backing *vmem_back; - - vmem_back = vmemmap_list_alloc(node); - if (unlikely(!vmem_back)) { -- WARN_ON(1); -- return; -+ pr_debug("vmemap list allocation failed\n"); -+ return -ENOMEM; - } - - vmem_back->phys = phys; -@@ -179,6 +179,7 @@ static __meminit void vmemmap_list_populate(unsigned long phys, - vmem_back->list = vmemmap_list; - - vmemmap_list = vmem_back; -+ return 0; - } - - static bool altmap_cross_boundary(struct vmem_altmap *altmap, unsigned long start, -@@ -199,6 +200,7 @@ static bool altmap_cross_boundary(struct vmem_altmap *altmap, unsigned long star - int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, - struct vmem_altmap *altmap) - { -+ bool altmap_alloc; - unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift; - - /* Align to the page size of the linear mapping. */ -@@ -228,13 +230,32 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, - p = vmemmap_alloc_block_buf(page_size, node, altmap); - if (!p) - pr_debug("altmap block allocation failed, falling back to system memory"); -+ else -+ altmap_alloc = true; - } -- if (!p) -+ if (!p) { - p = vmemmap_alloc_block_buf(page_size, node, NULL); -+ altmap_alloc = false; -+ } - if (!p) - return -ENOMEM; - -- vmemmap_list_populate(__pa(p), start, node); -+ if (vmemmap_list_populate(__pa(p), start, node)) { -+ /* -+ * If we don't populate vmemap list, we don't have -+ * the ability to free the allocated vmemmap -+ * pages in section_deactivate. Hence free them -+ * here. -+ */ -+ int nr_pfns = page_size >> PAGE_SHIFT; -+ unsigned long page_order = get_order(page_size); -+ -+ if (altmap_alloc) -+ vmem_altmap_free(altmap, nr_pfns); -+ else -+ free_pages((unsigned long)p, page_order); -+ return -ENOMEM; -+ } - - pr_debug(" * %016lx..%016lx allocated at %p\n", - start, start + page_size, p); -diff --git a/arch/powerpc/platforms/powermac/sleep.S b/arch/powerpc/platforms/powermac/sleep.S -index f9a680fdd9c4b..51bfdfe85058c 100644 ---- a/arch/powerpc/platforms/powermac/sleep.S -+++ b/arch/powerpc/platforms/powermac/sleep.S -@@ -294,14 +294,7 @@ grackle_wake_up: - * we do any r1 memory access as we are not sure they - * are in a sane state above the first 256Mb region - */ -- li r0,16 /* load up segment register values */ -- mtctr r0 /* for context 0 */ -- lis r3,0x2000 /* Ku = 1, VSID = 0 */ -- li r4,0 --3: mtsrin r3,r4 -- addi r3,r3,0x111 /* increment VSID */ -- addis r4,r4,0x1000 /* address of next segment */ -- bdnz 3b -+ bl load_segment_registers - sync - isync - -diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c -index 62ef7ad995da3..5e33b1fc67c2b 100644 ---- a/arch/powerpc/platforms/powernv/opal-elog.c -+++ b/arch/powerpc/platforms/powernv/opal-elog.c -@@ -179,14 +179,14 @@ static ssize_t raw_attr_read(struct file *filep, struct kobject *kobj, - return count; - } - --static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type) -+static void create_elog_obj(uint64_t id, size_t size, uint64_t type) - { - struct elog_obj *elog; - int rc; - - elog = kzalloc(sizeof(*elog), GFP_KERNEL); - if (!elog) -- return NULL; -+ return; - - elog->kobj.kset = elog_kset; - -@@ -219,18 +219,37 @@ static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type) - rc = kobject_add(&elog->kobj, NULL, "0x%llx", id); - if (rc) { - kobject_put(&elog->kobj); -- return NULL; -+ return; - } - -+ /* -+ * As soon as the sysfs file for this elog is created/activated there is -+ * a chance the opal_errd daemon (or any userspace) might read and -+ * acknowledge the elog before kobject_uevent() is called. If that -+ * happens then there is a potential race between -+ * elog_ack_store->kobject_put() and kobject_uevent() which leads to a -+ * use-after-free of a kernfs object resulting in a kernel crash. -+ * -+ * To avoid that, we need to take a reference on behalf of the bin file, -+ * so that our reference remains valid while we call kobject_uevent(). -+ * We then drop our reference before exiting the function, leaving the -+ * bin file to drop the last reference (if it hasn't already). -+ */ -+ -+ /* Take a reference for the bin file */ -+ kobject_get(&elog->kobj); - rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr); -- if (rc) { -+ if (rc == 0) { -+ kobject_uevent(&elog->kobj, KOBJ_ADD); -+ } else { -+ /* Drop the reference taken for the bin file */ - kobject_put(&elog->kobj); -- return NULL; - } - -- kobject_uevent(&elog->kobj, KOBJ_ADD); -+ /* Drop our reference */ -+ kobject_put(&elog->kobj); - -- return elog; -+ return; - } - - static irqreturn_t elog_event(int irq, void *data) -diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c -index b2ba3e95bda73..bbf361f23ae86 100644 ---- a/arch/powerpc/platforms/powernv/smp.c -+++ b/arch/powerpc/platforms/powernv/smp.c -@@ -43,7 +43,7 @@ - #include - #define DBG(fmt...) udbg_printf(fmt) - #else --#define DBG(fmt...) -+#define DBG(fmt...) do { } while (0) - #endif - - static void pnv_smp_setup_cpu(int cpu) -diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c -index 0ea976d1cac47..843db91e39aad 100644 ---- a/arch/powerpc/platforms/pseries/hotplug-memory.c -+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c -@@ -277,7 +277,7 @@ static int dlpar_offline_lmb(struct drmem_lmb *lmb) - return dlpar_change_lmb_state(lmb, false); - } - --static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size) -+static int pseries_remove_memblock(unsigned long base, unsigned long memblock_size) - { - unsigned long block_sz, start_pfn; - int sections_per_block; -@@ -308,10 +308,11 @@ out: - - static int pseries_remove_mem_node(struct device_node *np) - { -- const __be32 *regs; -+ const __be32 *prop; - unsigned long base; -- unsigned int lmb_size; -+ unsigned long lmb_size; - int ret = -EINVAL; -+ int addr_cells, size_cells; - - /* - * Check to see if we are actually removing memory -@@ -322,12 +323,19 @@ static int pseries_remove_mem_node(struct device_node *np) - /* - * Find the base address and size of the memblock - */ -- regs = of_get_property(np, "reg", NULL); -- if (!regs) -+ prop = of_get_property(np, "reg", NULL); -+ if (!prop) - return ret; - -- base = be64_to_cpu(*(unsigned long *)regs); -- lmb_size = be32_to_cpu(regs[3]); -+ addr_cells = of_n_addr_cells(np); -+ size_cells = of_n_size_cells(np); -+ -+ /* -+ * "reg" property represents (addr,size) tuple. -+ */ -+ base = of_read_number(prop, addr_cells); -+ prop += addr_cells; -+ lmb_size = of_read_number(prop, size_cells); - - pseries_remove_memblock(base, lmb_size); - return 0; -@@ -564,7 +572,7 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index) - - #else - static inline int pseries_remove_memblock(unsigned long base, -- unsigned int memblock_size) -+ unsigned long memblock_size) - { - return -EOPNOTSUPP; - } -@@ -886,10 +894,11 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog) - - static int pseries_add_mem_node(struct device_node *np) - { -- const __be32 *regs; -+ const __be32 *prop; - unsigned long base; -- unsigned int lmb_size; -+ unsigned long lmb_size; - int ret = -EINVAL; -+ int addr_cells, size_cells; - - /* - * Check to see if we are actually adding memory -@@ -900,12 +909,18 @@ static int pseries_add_mem_node(struct device_node *np) - /* - * Find the base and size of the memblock - */ -- regs = of_get_property(np, "reg", NULL); -- if (!regs) -+ prop = of_get_property(np, "reg", NULL); -+ if (!prop) - return ret; - -- base = be64_to_cpu(*(unsigned long *)regs); -- lmb_size = be32_to_cpu(regs[3]); -+ addr_cells = of_n_addr_cells(np); -+ size_cells = of_n_size_cells(np); -+ /* -+ * "reg" property represents (addr,size) tuple. -+ */ -+ base = of_read_number(prop, addr_cells); -+ prop += addr_cells; -+ lmb_size = of_read_number(prop, size_cells); - - /* - * Update memory region to represent the memory add -diff --git a/arch/riscv/include/uapi/asm/auxvec.h b/arch/riscv/include/uapi/asm/auxvec.h -index d86cb17bbabe6..22e0ae8884061 100644 ---- a/arch/riscv/include/uapi/asm/auxvec.h -+++ b/arch/riscv/include/uapi/asm/auxvec.h -@@ -10,4 +10,7 @@ - /* vDSO location */ - #define AT_SYSINFO_EHDR 33 - -+/* entries in ARCH_DLINFO */ -+#define AT_VECTOR_SIZE_ARCH 1 -+ - #endif /* _UAPI_ASM_RISCV_AUXVEC_H */ -diff --git a/arch/s390/boot/head.S b/arch/s390/boot/head.S -index dae10961d0724..1a2c2b1ed9649 100644 ---- a/arch/s390/boot/head.S -+++ b/arch/s390/boot/head.S -@@ -360,22 +360,23 @@ ENTRY(startup_kdump) - # the save area and does disabled wait with a faulty address. - # - ENTRY(startup_pgm_check_handler) -- stmg %r0,%r15,__LC_SAVE_AREA_SYNC -- la %r1,4095 -- stctg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r1) -- mvc __LC_GPREGS_SAVE_AREA-4095(128,%r1),__LC_SAVE_AREA_SYNC -- mvc __LC_PSW_SAVE_AREA-4095(16,%r1),__LC_PGM_OLD_PSW -+ stmg %r8,%r15,__LC_SAVE_AREA_SYNC -+ la %r8,4095 -+ stctg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r8) -+ stmg %r0,%r7,__LC_GPREGS_SAVE_AREA-4095(%r8) -+ mvc __LC_GPREGS_SAVE_AREA-4095+64(64,%r8),__LC_SAVE_AREA_SYNC -+ mvc __LC_PSW_SAVE_AREA-4095(16,%r8),__LC_PGM_OLD_PSW - mvc __LC_RETURN_PSW(16),__LC_PGM_OLD_PSW - ni __LC_RETURN_PSW,0xfc # remove IO and EX bits - ni __LC_RETURN_PSW+1,0xfb # remove MCHK bit - oi __LC_RETURN_PSW+1,0x2 # set wait state bit -- larl %r2,.Lold_psw_disabled_wait -- stg %r2,__LC_PGM_NEW_PSW+8 -- l %r15,.Ldump_info_stack-.Lold_psw_disabled_wait(%r2) -+ larl %r9,.Lold_psw_disabled_wait -+ stg %r9,__LC_PGM_NEW_PSW+8 -+ l %r15,.Ldump_info_stack-.Lold_psw_disabled_wait(%r9) - brasl %r14,print_pgm_check_info - .Lold_psw_disabled_wait: -- la %r1,4095 -- lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1) -+ la %r8,4095 -+ lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r8) - lpswe __LC_RETURN_PSW # disabled wait - .Ldump_info_stack: - .long 0x5000 + PAGE_SIZE - STACK_FRAME_OVERHEAD -diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c -index 513e59d08a55c..270f5e9d5a224 100644 ---- a/arch/s390/kernel/time.c -+++ b/arch/s390/kernel/time.c -@@ -345,8 +345,9 @@ static DEFINE_PER_CPU(atomic_t, clock_sync_word); - static DEFINE_MUTEX(clock_sync_mutex); - static unsigned long clock_sync_flags; - --#define CLOCK_SYNC_HAS_STP 0 --#define CLOCK_SYNC_STP 1 -+#define CLOCK_SYNC_HAS_STP 0 -+#define CLOCK_SYNC_STP 1 -+#define CLOCK_SYNC_STPINFO_VALID 2 - - /* - * The get_clock function for the physical clock. It will get the current -@@ -583,6 +584,22 @@ void stp_queue_work(void) - queue_work(time_sync_wq, &stp_work); - } - -+static int __store_stpinfo(void) -+{ -+ int rc = chsc_sstpi(stp_page, &stp_info, sizeof(struct stp_sstpi)); -+ -+ if (rc) -+ clear_bit(CLOCK_SYNC_STPINFO_VALID, &clock_sync_flags); -+ else -+ set_bit(CLOCK_SYNC_STPINFO_VALID, &clock_sync_flags); -+ return rc; -+} -+ -+static int stpinfo_valid(void) -+{ -+ return stp_online && test_bit(CLOCK_SYNC_STPINFO_VALID, &clock_sync_flags); -+} -+ - static int stp_sync_clock(void *data) - { - struct clock_sync_data *sync = data; -@@ -604,8 +621,7 @@ static int stp_sync_clock(void *data) - if (rc == 0) { - sync->clock_delta = clock_delta; - clock_sync_global(clock_delta); -- rc = chsc_sstpi(stp_page, &stp_info, -- sizeof(struct stp_sstpi)); -+ rc = __store_stpinfo(); - if (rc == 0 && stp_info.tmd != 2) - rc = -EAGAIN; - } -@@ -650,7 +666,7 @@ static void stp_work_fn(struct work_struct *work) - if (rc) - goto out_unlock; - -- rc = chsc_sstpi(stp_page, &stp_info, sizeof(struct stp_sstpi)); -+ rc = __store_stpinfo(); - if (rc || stp_info.c == 0) - goto out_unlock; - -@@ -687,10 +703,14 @@ static ssize_t ctn_id_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online) -- return -ENODATA; -- return sprintf(buf, "%016llx\n", -- *(unsigned long long *) stp_info.ctnid); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid()) -+ ret = sprintf(buf, "%016llx\n", -+ *(unsigned long long *) stp_info.ctnid); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(ctn_id); -@@ -699,9 +719,13 @@ static ssize_t ctn_type_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online) -- return -ENODATA; -- return sprintf(buf, "%i\n", stp_info.ctn); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid()) -+ ret = sprintf(buf, "%i\n", stp_info.ctn); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(ctn_type); -@@ -710,9 +734,13 @@ static ssize_t dst_offset_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online || !(stp_info.vbits & 0x2000)) -- return -ENODATA; -- return sprintf(buf, "%i\n", (int)(s16) stp_info.dsto); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid() && (stp_info.vbits & 0x2000)) -+ ret = sprintf(buf, "%i\n", (int)(s16) stp_info.dsto); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(dst_offset); -@@ -721,9 +749,13 @@ static ssize_t leap_seconds_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online || !(stp_info.vbits & 0x8000)) -- return -ENODATA; -- return sprintf(buf, "%i\n", (int)(s16) stp_info.leaps); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid() && (stp_info.vbits & 0x8000)) -+ ret = sprintf(buf, "%i\n", (int)(s16) stp_info.leaps); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(leap_seconds); -@@ -732,9 +764,13 @@ static ssize_t stratum_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online) -- return -ENODATA; -- return sprintf(buf, "%i\n", (int)(s16) stp_info.stratum); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid()) -+ ret = sprintf(buf, "%i\n", (int)(s16) stp_info.stratum); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(stratum); -@@ -743,9 +779,13 @@ static ssize_t time_offset_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online || !(stp_info.vbits & 0x0800)) -- return -ENODATA; -- return sprintf(buf, "%i\n", (int) stp_info.tto); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid() && (stp_info.vbits & 0x0800)) -+ ret = sprintf(buf, "%i\n", (int) stp_info.tto); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(time_offset); -@@ -754,9 +794,13 @@ static ssize_t time_zone_offset_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online || !(stp_info.vbits & 0x4000)) -- return -ENODATA; -- return sprintf(buf, "%i\n", (int)(s16) stp_info.tzo); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid() && (stp_info.vbits & 0x4000)) -+ ret = sprintf(buf, "%i\n", (int)(s16) stp_info.tzo); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(time_zone_offset); -@@ -765,9 +809,13 @@ static ssize_t timing_mode_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online) -- return -ENODATA; -- return sprintf(buf, "%i\n", stp_info.tmd); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid()) -+ ret = sprintf(buf, "%i\n", stp_info.tmd); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(timing_mode); -@@ -776,9 +824,13 @@ static ssize_t timing_state_show(struct device *dev, - struct device_attribute *attr, - char *buf) - { -- if (!stp_online) -- return -ENODATA; -- return sprintf(buf, "%i\n", stp_info.tst); -+ ssize_t ret = -ENODATA; -+ -+ mutex_lock(&stp_work_mutex); -+ if (stpinfo_valid()) -+ ret = sprintf(buf, "%i\n", stp_info.tst); -+ mutex_unlock(&stp_work_mutex); -+ return ret; - } - - static DEVICE_ATTR_RO(timing_state); -diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c -index e286e2badc8a4..e38d8bf454e86 100644 ---- a/arch/sparc/kernel/smp_64.c -+++ b/arch/sparc/kernel/smp_64.c -@@ -1039,38 +1039,9 @@ void smp_fetch_global_pmu(void) - * are flush_tlb_*() routines, and these run after flush_cache_*() - * which performs the flushw. - * -- * The SMP TLB coherency scheme we use works as follows: -- * -- * 1) mm->cpu_vm_mask is a bit mask of which cpus an address -- * space has (potentially) executed on, this is the heuristic -- * we use to avoid doing cross calls. -- * -- * Also, for flushing from kswapd and also for clones, we -- * use cpu_vm_mask as the list of cpus to make run the TLB. -- * -- * 2) TLB context numbers are shared globally across all processors -- * in the system, this allows us to play several games to avoid -- * cross calls. -- * -- * One invariant is that when a cpu switches to a process, and -- * that processes tsk->active_mm->cpu_vm_mask does not have the -- * current cpu's bit set, that tlb context is flushed locally. -- * -- * If the address space is non-shared (ie. mm->count == 1) we avoid -- * cross calls when we want to flush the currently running process's -- * tlb state. This is done by clearing all cpu bits except the current -- * processor's in current->mm->cpu_vm_mask and performing the -- * flush locally only. This will force any subsequent cpus which run -- * this task to flush the context from the local tlb if the process -- * migrates to another cpu (again). -- * -- * 3) For shared address spaces (threads) and swapping we bite the -- * bullet for most cases and perform the cross call (but only to -- * the cpus listed in cpu_vm_mask). -- * -- * The performance gain from "optimizing" away the cross call for threads is -- * questionable (in theory the big win for threads is the massive sharing of -- * address space state across processors). -+ * mm->cpu_vm_mask is a bit mask of which cpus an address -+ * space has (potentially) executed on, this is the heuristic -+ * we use to limit cross calls. - */ - - /* This currently is only used by the hugetlb arch pre-fault -@@ -1080,18 +1051,13 @@ void smp_fetch_global_pmu(void) - void smp_flush_tlb_mm(struct mm_struct *mm) - { - u32 ctx = CTX_HWBITS(mm->context); -- int cpu = get_cpu(); - -- if (atomic_read(&mm->mm_users) == 1) { -- cpumask_copy(mm_cpumask(mm), cpumask_of(cpu)); -- goto local_flush_and_out; -- } -+ get_cpu(); - - smp_cross_call_masked(&xcall_flush_tlb_mm, - ctx, 0, 0, - mm_cpumask(mm)); - --local_flush_and_out: - __flush_tlb_mm(ctx, SECONDARY_CONTEXT); - - put_cpu(); -@@ -1114,17 +1080,15 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long - { - u32 ctx = CTX_HWBITS(mm->context); - struct tlb_pending_info info; -- int cpu = get_cpu(); -+ -+ get_cpu(); - - info.ctx = ctx; - info.nr = nr; - info.vaddrs = vaddrs; - -- if (mm == current->mm && atomic_read(&mm->mm_users) == 1) -- cpumask_copy(mm_cpumask(mm), cpumask_of(cpu)); -- else -- smp_call_function_many(mm_cpumask(mm), tlb_pending_func, -- &info, 1); -+ smp_call_function_many(mm_cpumask(mm), tlb_pending_func, -+ &info, 1); - - __flush_tlb_pending(ctx, nr, vaddrs); - -@@ -1134,14 +1098,13 @@ void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long - void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr) - { - unsigned long context = CTX_HWBITS(mm->context); -- int cpu = get_cpu(); - -- if (mm == current->mm && atomic_read(&mm->mm_users) == 1) -- cpumask_copy(mm_cpumask(mm), cpumask_of(cpu)); -- else -- smp_cross_call_masked(&xcall_flush_tlb_page, -- context, vaddr, 0, -- mm_cpumask(mm)); -+ get_cpu(); -+ -+ smp_cross_call_masked(&xcall_flush_tlb_page, -+ context, vaddr, 0, -+ mm_cpumask(mm)); -+ - __flush_tlb_page(context, vaddr); - - put_cpu(); -diff --git a/arch/um/kernel/sigio.c b/arch/um/kernel/sigio.c -index 10c99e058fcae..d1cffc2a7f212 100644 ---- a/arch/um/kernel/sigio.c -+++ b/arch/um/kernel/sigio.c -@@ -35,14 +35,14 @@ int write_sigio_irq(int fd) - } - - /* These are called from os-Linux/sigio.c to protect its pollfds arrays. */ --static DEFINE_SPINLOCK(sigio_spinlock); -+static DEFINE_MUTEX(sigio_mutex); - - void sigio_lock(void) - { -- spin_lock(&sigio_spinlock); -+ mutex_lock(&sigio_mutex); - } - - void sigio_unlock(void) - { -- spin_unlock(&sigio_spinlock); -+ mutex_unlock(&sigio_mutex); - } -diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c -index dde7cb3724df3..9bd966ef7d19e 100644 ---- a/arch/x86/boot/compressed/kaslr.c -+++ b/arch/x86/boot/compressed/kaslr.c -@@ -87,8 +87,11 @@ static unsigned long get_boot_seed(void) - static bool memmap_too_large; - - --/* Store memory limit specified by "mem=nn[KMG]" or "memmap=nn[KMG]" */ --static unsigned long long mem_limit = ULLONG_MAX; -+/* -+ * Store memory limit: MAXMEM on 64-bit and KERNEL_IMAGE_SIZE on 32-bit. -+ * It may be reduced by "mem=nn[KMG]" or "memmap=nn[KMG]" command line options. -+ */ -+static unsigned long long mem_limit; - - /* Number of immovable memory regions */ - static int num_immovable_mem; -@@ -214,7 +217,7 @@ static void mem_avoid_memmap(enum parse_mode mode, char *str) - - if (start == 0) { - /* Store the specified memory limit if size > 0 */ -- if (size > 0) -+ if (size > 0 && size < mem_limit) - mem_limit = size; - - continue; -@@ -302,7 +305,8 @@ static void handle_mem_options(void) - if (mem_size == 0) - goto out; - -- mem_limit = mem_size; -+ if (mem_size < mem_limit) -+ mem_limit = mem_size; - } else if (!strcmp(param, "efi_fake_mem")) { - mem_avoid_memmap(PARSE_EFI, val); - } -@@ -314,7 +318,9 @@ out: - } - - /* -- * In theory, KASLR can put the kernel anywhere in the range of [16M, 64T). -+ * In theory, KASLR can put the kernel anywhere in the range of [16M, MAXMEM) -+ * on 64-bit, and [16M, KERNEL_IMAGE_SIZE) on 32-bit. -+ * - * The mem_avoid array is used to store the ranges that need to be avoided - * when KASLR searches for an appropriate random address. We must avoid any - * regions that are unsafe to overlap with during decompression, and other -@@ -614,10 +620,6 @@ static void __process_mem_region(struct mem_vector *entry, - unsigned long start_orig, end; - struct mem_vector cur_entry; - -- /* On 32-bit, ignore entries entirely above our maximum. */ -- if (IS_ENABLED(CONFIG_X86_32) && entry->start >= KERNEL_IMAGE_SIZE) -- return; -- - /* Ignore entries entirely below our minimum. */ - if (entry->start + entry->size < minimum) - return; -@@ -650,11 +652,6 @@ static void __process_mem_region(struct mem_vector *entry, - /* Reduce size by any delta from the original address. */ - region.size -= region.start - start_orig; - -- /* On 32-bit, reduce region size to fit within max size. */ -- if (IS_ENABLED(CONFIG_X86_32) && -- region.start + region.size > KERNEL_IMAGE_SIZE) -- region.size = KERNEL_IMAGE_SIZE - region.start; -- - /* Return if region can't contain decompressed kernel */ - if (region.size < image_size) - return; -@@ -839,15 +836,16 @@ static void process_e820_entries(unsigned long minimum, - static unsigned long find_random_phys_addr(unsigned long minimum, - unsigned long image_size) - { -+ /* Bail out early if it's impossible to succeed. */ -+ if (minimum + image_size > mem_limit) -+ return 0; -+ - /* Check if we had too many memmaps. */ - if (memmap_too_large) { - debug_putstr("Aborted memory entries scan (more than 4 memmap= args)!\n"); - return 0; - } - -- /* Make sure minimum is aligned. */ -- minimum = ALIGN(minimum, CONFIG_PHYSICAL_ALIGN); -- - if (process_efi_entries(minimum, image_size)) - return slots_fetch_random(); - -@@ -860,8 +858,6 @@ static unsigned long find_random_virt_addr(unsigned long minimum, - { - unsigned long slots, random_addr; - -- /* Make sure minimum is aligned. */ -- minimum = ALIGN(minimum, CONFIG_PHYSICAL_ALIGN); - /* Align image_size for easy slot calculations. */ - image_size = ALIGN(image_size, CONFIG_PHYSICAL_ALIGN); - -@@ -908,6 +904,11 @@ void choose_random_location(unsigned long input, - /* Prepare to add new identity pagetables on demand. */ - initialize_identity_maps(); - -+ if (IS_ENABLED(CONFIG_X86_32)) -+ mem_limit = KERNEL_IMAGE_SIZE; -+ else -+ mem_limit = MAXMEM; -+ - /* Record the various known unsafe memory ranges. */ - mem_avoid_init(input, input_size, *output); - -@@ -917,6 +918,8 @@ void choose_random_location(unsigned long input, - * location: - */ - min_addr = min(*output, 512UL << 20); -+ /* Make sure minimum is aligned. */ -+ min_addr = ALIGN(min_addr, CONFIG_PHYSICAL_ALIGN); - - /* Walk available memory entries to find a random address. */ - random_addr = find_random_phys_addr(min_addr, output_size); -diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c -index a023cbe21230a..39169885adfa8 100644 ---- a/arch/x86/events/amd/ibs.c -+++ b/arch/x86/events/amd/ibs.c -@@ -335,11 +335,15 @@ static u64 get_ibs_op_count(u64 config) - { - u64 count = 0; - -+ /* -+ * If the internal 27-bit counter rolled over, the count is MaxCnt -+ * and the lower 7 bits of CurCnt are randomized. -+ * Otherwise CurCnt has the full 27-bit current counter value. -+ */ - if (config & IBS_OP_VAL) -- count += (config & IBS_OP_MAX_CNT) << 4; /* cnt rolled over */ -- -- if (ibs_caps & IBS_CAPS_RDWROPCNT) -- count += (config & IBS_OP_CUR_CNT) >> 32; -+ count = (config & IBS_OP_MAX_CNT) << 4; -+ else if (ibs_caps & IBS_CAPS_RDWROPCNT) -+ count = (config & IBS_OP_CUR_CNT) >> 32; - - return count; - } -@@ -632,18 +636,24 @@ fail: - perf_ibs->offset_max, - offset + 1); - } while (offset < offset_max); -+ /* -+ * Read IbsBrTarget, IbsOpData4, and IbsExtdCtl separately -+ * depending on their availability. -+ * Can't add to offset_max as they are staggered -+ */ - if (event->attr.sample_type & PERF_SAMPLE_RAW) { -- /* -- * Read IbsBrTarget and IbsOpData4 separately -- * depending on their availability. -- * Can't add to offset_max as they are staggered -- */ -- if (ibs_caps & IBS_CAPS_BRNTRGT) { -- rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++); -- size++; -+ if (perf_ibs == &perf_ibs_op) { -+ if (ibs_caps & IBS_CAPS_BRNTRGT) { -+ rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++); -+ size++; -+ } -+ if (ibs_caps & IBS_CAPS_OPDATA4) { -+ rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++); -+ size++; -+ } - } -- if (ibs_caps & IBS_CAPS_OPDATA4) { -- rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++); -+ if (perf_ibs == &perf_ibs_fetch && (ibs_caps & IBS_CAPS_FETCHCTLEXTD)) { -+ rdmsrl(MSR_AMD64_ICIBSEXTDCTL, *buf++); - size++; - } - } -diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c -index 76400c052b0eb..e7e61c8b56bd6 100644 ---- a/arch/x86/events/amd/uncore.c -+++ b/arch/x86/events/amd/uncore.c -@@ -181,28 +181,16 @@ static void amd_uncore_del(struct perf_event *event, int flags) - } - - /* -- * Convert logical CPU number to L3 PMC Config ThreadMask format -+ * Return a full thread and slice mask until per-CPU is -+ * properly supported. - */ --static u64 l3_thread_slice_mask(int cpu) -+static u64 l3_thread_slice_mask(void) - { -- u64 thread_mask, core = topology_core_id(cpu); -- unsigned int shift, thread = 0; -+ if (boot_cpu_data.x86 <= 0x18) -+ return AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK; - -- if (topology_smt_supported() && !topology_is_primary_thread(cpu)) -- thread = 1; -- -- if (boot_cpu_data.x86 <= 0x18) { -- shift = AMD64_L3_THREAD_SHIFT + 2 * (core % 4) + thread; -- thread_mask = BIT_ULL(shift); -- -- return AMD64_L3_SLICE_MASK | thread_mask; -- } -- -- core = (core << AMD64_L3_COREID_SHIFT) & AMD64_L3_COREID_MASK; -- shift = AMD64_L3_THREAD_SHIFT + thread; -- thread_mask = BIT_ULL(shift); -- -- return AMD64_L3_EN_ALL_SLICES | core | thread_mask; -+ return AMD64_L3_EN_ALL_SLICES | AMD64_L3_EN_ALL_CORES | -+ AMD64_L3_F19H_THREAD_MASK; - } - - static int amd_uncore_event_init(struct perf_event *event) -@@ -232,7 +220,7 @@ static int amd_uncore_event_init(struct perf_event *event) - * For other events, the two fields do not affect the count. - */ - if (l3_mask && is_llc_event(event)) -- hwc->config |= l3_thread_slice_mask(event->cpu); -+ hwc->config |= l3_thread_slice_mask(); - - uncore = event_to_amd_uncore(event); - if (!uncore) -diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c -index 11bbc6590f904..82bb0b716e49a 100644 ---- a/arch/x86/events/core.c -+++ b/arch/x86/events/core.c -@@ -1286,11 +1286,11 @@ int x86_perf_event_set_period(struct perf_event *event) - wrmsrl(hwc->event_base, (u64)(-left) & x86_pmu.cntval_mask); - - /* -- * Clear the Merge event counter's upper 16 bits since -+ * Sign extend the Merge event counter's upper 16 bits since - * we currently declare a 48-bit counter width - */ - if (is_counter_pair(hwc)) -- wrmsrl(x86_pmu_event_addr(idx + 1), 0); -+ wrmsrl(x86_pmu_event_addr(idx + 1), 0xffff); - - /* - * Due to erratum on certan cpu we need -diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c -index 31e6887d24f1a..34b21ba666378 100644 ---- a/arch/x86/events/intel/core.c -+++ b/arch/x86/events/intel/core.c -@@ -243,7 +243,7 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = { - - static struct event_constraint intel_icl_event_constraints[] = { - FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ -- INTEL_UEVENT_CONSTRAINT(0x1c0, 0), /* INST_RETIRED.PREC_DIST */ -+ FIXED_EVENT_CONSTRAINT(0x01c0, 0), /* INST_RETIRED.PREC_DIST */ - FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ - FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */ - FIXED_EVENT_CONSTRAINT(0x0400, 3), /* SLOTS */ -diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h -index 5a42f92061387..51e2bf27cc9b0 100644 ---- a/arch/x86/include/asm/asm-prototypes.h -+++ b/arch/x86/include/asm/asm-prototypes.h -@@ -5,6 +5,7 @@ - #include - #include - #include -+#include - - #include - -diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h -index 2859ee4f39a83..b08c8a2afc0eb 100644 ---- a/arch/x86/include/asm/msr-index.h -+++ b/arch/x86/include/asm/msr-index.h -@@ -464,6 +464,7 @@ - #define MSR_AMD64_IBSOP_REG_MASK ((1UL<task; -- - if (unwind_done(state)) - return NULL; - - if (state->regs) - return &state->regs->ip; - -- if (task != current && state->sp == task->thread.sp) { -- struct inactive_task_frame *frame = (void *)task->thread.sp; -- return &frame->ret_addr; -- } -- - if (state->sp) - return (unsigned long *)state->sp - 1; - -@@ -662,7 +655,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, - } else { - struct inactive_task_frame *frame = (void *)task->thread.sp; - -- state->sp = task->thread.sp; -+ state->sp = task->thread.sp + sizeof(*frame); - state->bp = READ_ONCE_NOCHECK(frame->bp); - state->ip = READ_ONCE_NOCHECK(frame->ret_addr); - state->signal = (void *)state->ip == ret_from_fork; -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c -index ce856e0ece844..bacfc9e94a62b 100644 ---- a/arch/x86/kvm/x86.c -+++ b/arch/x86/kvm/x86.c -@@ -259,13 +259,13 @@ static int kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr, - - if (ignore_msrs) { - if (report_ignored_msrs) -- vcpu_unimpl(vcpu, "ignored %s: 0x%x data 0x%llx\n", -- op, msr, data); -+ kvm_pr_unimpl("ignored %s: 0x%x data 0x%llx\n", -+ op, msr, data); - /* Mask the error */ - return 0; - } else { -- vcpu_debug_ratelimited(vcpu, "unhandled %s: 0x%x data 0x%llx\n", -- op, msr, data); -+ kvm_debug_ratelimited("unhandled %s: 0x%x data 0x%llx\n", -+ op, msr, data); - return 1; - } - } -diff --git a/block/bio.c b/block/bio.c -index e865ea55b9f9a..58d7654002261 100644 ---- a/block/bio.c -+++ b/block/bio.c -@@ -1046,6 +1046,7 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) - ssize_t size, left; - unsigned len, i; - size_t offset; -+ int ret = 0; - - if (WARN_ON_ONCE(!max_append_sectors)) - return 0; -@@ -1068,15 +1069,17 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) - - len = min_t(size_t, PAGE_SIZE - offset, left); - if (bio_add_hw_page(q, bio, page, len, offset, -- max_append_sectors, &same_page) != len) -- return -EINVAL; -+ max_append_sectors, &same_page) != len) { -+ ret = -EINVAL; -+ break; -+ } - if (same_page) - put_page(page); - offset = 0; - } - -- iov_iter_advance(iter, size); -- return 0; -+ iov_iter_advance(iter, size - left); -+ return ret; - } - - /** -diff --git a/block/blk-mq.c b/block/blk-mq.c -index 94a53d779c12b..ca2fdb58e7af5 100644 ---- a/block/blk-mq.c -+++ b/block/blk-mq.c -@@ -105,7 +105,7 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx, - { - struct mq_inflight *mi = priv; - -- if (rq->part == mi->part) -+ if (rq->part == mi->part && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) - mi->inflight[rq_data_dir(rq)]++; - - return true; -diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c -index 88c8af455ea3f..cf91f49101eac 100644 ---- a/drivers/acpi/acpi_configfs.c -+++ b/drivers/acpi/acpi_configfs.c -@@ -228,6 +228,7 @@ static void acpi_table_drop_item(struct config_group *group, - - ACPI_INFO(("Host-directed Dynamic ACPI Table Unload")); - acpi_unload_table(table->index); -+ config_item_put(cfg); - } - - static struct configfs_group_operations acpi_table_group_ops = { -diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c -index 6041974c76271..fb72903385933 100644 ---- a/drivers/acpi/acpi_dbg.c -+++ b/drivers/acpi/acpi_dbg.c -@@ -749,6 +749,9 @@ static int __init acpi_aml_init(void) - { - int ret; - -+ if (acpi_disabled) -+ return -ENODEV; -+ - /* Initialize AML IO interface */ - mutex_init(&acpi_aml_io.lock); - init_waitqueue_head(&acpi_aml_io.wait); -diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c -index f138e12b7b823..72f1fb77abcd0 100644 ---- a/drivers/acpi/acpi_extlog.c -+++ b/drivers/acpi/acpi_extlog.c -@@ -222,9 +222,9 @@ static int __init extlog_init(void) - u64 cap; - int rc; - -- rdmsrl(MSR_IA32_MCG_CAP, cap); -- -- if (!(cap & MCG_ELOG_P) || !extlog_get_l1addr()) -+ if (rdmsrl_safe(MSR_IA32_MCG_CAP, &cap) || -+ !(cap & MCG_ELOG_P) || -+ !extlog_get_l1addr()) - return -ENODEV; - - rc = -EINVAL; -diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c -index a4eda7fe50d31..da4b125ab4c3e 100644 ---- a/drivers/acpi/button.c -+++ b/drivers/acpi/button.c -@@ -153,6 +153,7 @@ struct acpi_button { - int last_state; - ktime_t last_time; - bool suspended; -+ bool lid_state_initialized; - }; - - static struct acpi_device *lid_device; -@@ -383,6 +384,8 @@ static int acpi_lid_update_state(struct acpi_device *device, - - static void acpi_lid_initialize_state(struct acpi_device *device) - { -+ struct acpi_button *button = acpi_driver_data(device); -+ - switch (lid_init_state) { - case ACPI_BUTTON_LID_INIT_OPEN: - (void)acpi_lid_notify_state(device, 1); -@@ -394,13 +397,14 @@ static void acpi_lid_initialize_state(struct acpi_device *device) - default: - break; - } -+ -+ button->lid_state_initialized = true; - } - - static void acpi_button_notify(struct acpi_device *device, u32 event) - { - struct acpi_button *button = acpi_driver_data(device); - struct input_dev *input; -- int users; - - switch (event) { - case ACPI_FIXED_HARDWARE_EVENT: -@@ -409,10 +413,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event) - case ACPI_BUTTON_NOTIFY_STATUS: - input = button->input; - if (button->type == ACPI_BUTTON_TYPE_LID) { -- mutex_lock(&button->input->mutex); -- users = button->input->users; -- mutex_unlock(&button->input->mutex); -- if (users) -+ if (button->lid_state_initialized) - acpi_lid_update_state(device, true); - } else { - int keycode; -@@ -457,7 +458,7 @@ static int acpi_button_resume(struct device *dev) - struct acpi_button *button = acpi_driver_data(device); - - button->suspended = false; -- if (button->type == ACPI_BUTTON_TYPE_LID && button->input->users) { -+ if (button->type == ACPI_BUTTON_TYPE_LID) { - button->last_state = !!acpi_lid_evaluate_state(device); - button->last_time = ktime_get(); - acpi_lid_initialize_state(device); -diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c -index fcddda3d67128..e0cb1bcfffb29 100644 ---- a/drivers/acpi/ec.c -+++ b/drivers/acpi/ec.c -@@ -2011,20 +2011,16 @@ bool acpi_ec_dispatch_gpe(void) - if (acpi_any_gpe_status_set(first_ec->gpe)) - return true; - -- if (ec_no_wakeup) -- return false; -- - /* - * Dispatch the EC GPE in-band, but do not report wakeup in any case - * to allow the caller to process events properly after that. - */ - ret = acpi_dispatch_gpe(NULL, first_ec->gpe); -- if (ret == ACPI_INTERRUPT_HANDLED) { -+ if (ret == ACPI_INTERRUPT_HANDLED) - pm_pr_dbg("ACPI EC GPE dispatched\n"); - -- /* Flush the event and query workqueues. */ -- acpi_ec_flush_work(); -- } -+ /* Flush the event and query workqueues. */ -+ acpi_ec_flush_work(); - - return false; - } -diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c -index 2c32cfb723701..6a91a55229aee 100644 ---- a/drivers/acpi/numa/hmat.c -+++ b/drivers/acpi/numa/hmat.c -@@ -424,7 +424,8 @@ static int __init hmat_parse_proximity_domain(union acpi_subtable_headers *heade - pr_info("HMAT: Memory Flags:%04x Processor Domain:%u Memory Domain:%u\n", - p->flags, p->processor_PD, p->memory_PD); - -- if (p->flags & ACPI_HMAT_MEMORY_PD_VALID && hmat_revision == 1) { -+ if ((hmat_revision == 1 && p->flags & ACPI_HMAT_MEMORY_PD_VALID) || -+ hmat_revision > 1) { - target = find_mem_target(p->memory_PD); - if (!target) { - pr_debug("HMAT: Memory Domain missing from SRAT\n"); -diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c -index 15bbaab8500b9..1fb486f46ee20 100644 ---- a/drivers/acpi/numa/srat.c -+++ b/drivers/acpi/numa/srat.c -@@ -31,7 +31,7 @@ int acpi_numa __initdata; - - int pxm_to_node(int pxm) - { -- if (pxm < 0) -+ if (pxm < 0 || pxm >= MAX_PXM_DOMAINS || numa_off) - return NUMA_NO_NODE; - return pxm_to_node_map[pxm]; - } -diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c -index 54b36b7ad47d9..e526571e0ebdb 100644 ---- a/drivers/acpi/pci_mcfg.c -+++ b/drivers/acpi/pci_mcfg.c -@@ -142,6 +142,26 @@ static struct mcfg_fixup mcfg_quirks[] = { - XGENE_V2_ECAM_MCFG(4, 0), - XGENE_V2_ECAM_MCFG(4, 1), - XGENE_V2_ECAM_MCFG(4, 2), -+ -+#define ALTRA_ECAM_QUIRK(rev, seg) \ -+ { "Ampere", "Altra ", rev, seg, MCFG_BUS_ANY, &pci_32b_read_ops } -+ -+ ALTRA_ECAM_QUIRK(1, 0), -+ ALTRA_ECAM_QUIRK(1, 1), -+ ALTRA_ECAM_QUIRK(1, 2), -+ ALTRA_ECAM_QUIRK(1, 3), -+ ALTRA_ECAM_QUIRK(1, 4), -+ ALTRA_ECAM_QUIRK(1, 5), -+ ALTRA_ECAM_QUIRK(1, 6), -+ ALTRA_ECAM_QUIRK(1, 7), -+ ALTRA_ECAM_QUIRK(1, 8), -+ ALTRA_ECAM_QUIRK(1, 9), -+ ALTRA_ECAM_QUIRK(1, 10), -+ ALTRA_ECAM_QUIRK(1, 11), -+ ALTRA_ECAM_QUIRK(1, 12), -+ ALTRA_ECAM_QUIRK(1, 13), -+ ALTRA_ECAM_QUIRK(1, 14), -+ ALTRA_ECAM_QUIRK(1, 15), - }; - - static char mcfg_oem_id[ACPI_OEM_ID_SIZE]; -diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c -index 2499d7e3c710e..36b62e9c8b695 100644 ---- a/drivers/acpi/video_detect.c -+++ b/drivers/acpi/video_detect.c -@@ -282,6 +282,15 @@ static const struct dmi_system_id video_detect_dmi_table[] = { - DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"), - }, - }, -+ /* https://bugs.launchpad.net/bugs/1894667 */ -+ { -+ .callback = video_detect_force_video, -+ .ident = "HP 635 Notebook", -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "HP 635 Notebook PC"), -+ }, -+ }, - - /* Non win8 machines which need native backlight nevertheless */ - { -diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c -index eb9dc14e5147a..20190f66ced98 100644 ---- a/drivers/ata/sata_nv.c -+++ b/drivers/ata/sata_nv.c -@@ -2100,7 +2100,7 @@ static int nv_swncq_sdbfis(struct ata_port *ap) - pp->dhfis_bits &= ~done_mask; - pp->dmafis_bits &= ~done_mask; - pp->sdbfis_bits |= done_mask; -- ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask); -+ ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); - - if (!ap->qc_active) { - DPRINTK("over\n"); -diff --git a/drivers/base/core.c b/drivers/base/core.c -index bb5806a2bd4ca..792b92439b77d 100644 ---- a/drivers/base/core.c -+++ b/drivers/base/core.c -@@ -4260,6 +4260,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) - */ - void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) - { -+ struct device *parent = dev->parent; - struct fwnode_handle *fn = dev->fwnode; - - if (fwnode) { -@@ -4274,7 +4275,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) - } else { - if (fwnode_is_primary(fn)) { - dev->fwnode = fn->secondary; -- fn->secondary = NULL; -+ if (!(parent && fn == parent->fwnode)) -+ fn->secondary = ERR_PTR(-ENODEV); - } else { - dev->fwnode = NULL; - } -diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c -index 63b9714a01548..b0ec2721f55de 100644 ---- a/drivers/base/firmware_loader/main.c -+++ b/drivers/base/firmware_loader/main.c -@@ -470,14 +470,12 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, - int i, len; - int rc = -ENOENT; - char *path; -- enum kernel_read_file_id id = READING_FIRMWARE; - size_t msize = INT_MAX; - void *buffer = NULL; - - /* Already populated data member means we're loading into a buffer */ - if (!decompress && fw_priv->data) { - buffer = fw_priv->data; -- id = READING_FIRMWARE_PREALLOC_BUFFER; - msize = fw_priv->allocated_size; - } - -@@ -501,7 +499,8 @@ fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv, - - /* load firmware files from the mount namespace of init */ - rc = kernel_read_file_from_path_initns(path, &buffer, -- &size, msize, id); -+ &size, msize, -+ READING_FIRMWARE); - if (rc) { - if (rc != -ENOENT) - dev_warn(device, "loading %s failed with error %d\n", -diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c -index 8143210a5c547..6f605f7820bb5 100644 ---- a/drivers/base/power/runtime.c -+++ b/drivers/base/power/runtime.c -@@ -291,8 +291,7 @@ static int rpm_get_suppliers(struct device *dev) - device_links_read_lock_held()) { - int retval; - -- if (!(link->flags & DL_FLAG_PM_RUNTIME) || -- READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND) -+ if (!(link->flags & DL_FLAG_PM_RUNTIME)) - continue; - - retval = pm_runtime_get_sync(link->supplier); -@@ -312,8 +311,6 @@ static void rpm_put_suppliers(struct device *dev) - - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, - device_links_read_lock_held()) { -- if (READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND) -- continue; - - while (refcount_dec_not_one(&link->rpm_active)) - pm_runtime_put(link->supplier); -diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c -index edf8b632e3d27..f46e26c9d9b3c 100644 ---- a/drivers/block/nbd.c -+++ b/drivers/block/nbd.c -@@ -801,9 +801,9 @@ static void recv_work(struct work_struct *work) - if (likely(!blk_should_fake_timeout(rq->q))) - blk_mq_complete_request(rq); - } -+ nbd_config_put(nbd); - atomic_dec(&config->recv_threads); - wake_up(&config->recv_wq); -- nbd_config_put(nbd); - kfree(args); - } - -diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h -index daed4a9c34367..206309ecc7e4e 100644 ---- a/drivers/block/null_blk.h -+++ b/drivers/block/null_blk.h -@@ -44,6 +44,7 @@ struct nullb_device { - unsigned int nr_zones; - struct blk_zone *zones; - sector_t zone_size_sects; -+ unsigned long *zone_locks; - - unsigned long size; /* device size in MB */ - unsigned long completion_nsec; /* time in ns to complete a request */ -diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c -index 3d25c9ad23831..495713d6c989b 100644 ---- a/drivers/block/null_blk_zoned.c -+++ b/drivers/block/null_blk_zoned.c -@@ -1,5 +1,6 @@ - // SPDX-License-Identifier: GPL-2.0 - #include -+#include - #include "null_blk.h" - - #define CREATE_TRACE_POINTS -@@ -45,6 +46,12 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) - if (!dev->zones) - return -ENOMEM; - -+ dev->zone_locks = bitmap_zalloc(dev->nr_zones, GFP_KERNEL); -+ if (!dev->zone_locks) { -+ kvfree(dev->zones); -+ return -ENOMEM; -+ } -+ - if (dev->zone_nr_conv >= dev->nr_zones) { - dev->zone_nr_conv = dev->nr_zones - 1; - pr_info("changed the number of conventional zones to %u", -@@ -105,15 +112,26 @@ int null_register_zoned_dev(struct nullb *nullb) - - void null_free_zoned_dev(struct nullb_device *dev) - { -+ bitmap_free(dev->zone_locks); - kvfree(dev->zones); - } - -+static inline void null_lock_zone(struct nullb_device *dev, unsigned int zno) -+{ -+ wait_on_bit_lock_io(dev->zone_locks, zno, TASK_UNINTERRUPTIBLE); -+} -+ -+static inline void null_unlock_zone(struct nullb_device *dev, unsigned int zno) -+{ -+ clear_and_wake_up_bit(zno, dev->zone_locks); -+} -+ - int null_report_zones(struct gendisk *disk, sector_t sector, - unsigned int nr_zones, report_zones_cb cb, void *data) - { - struct nullb *nullb = disk->private_data; - struct nullb_device *dev = nullb->dev; -- unsigned int first_zone, i; -+ unsigned int first_zone, i, zno; - struct blk_zone zone; - int error; - -@@ -124,15 +142,18 @@ int null_report_zones(struct gendisk *disk, sector_t sector, - nr_zones = min(nr_zones, dev->nr_zones - first_zone); - trace_nullb_report_zones(nullb, nr_zones); - -- for (i = 0; i < nr_zones; i++) { -+ zno = first_zone; -+ for (i = 0; i < nr_zones; i++, zno++) { - /* - * Stacked DM target drivers will remap the zone information by - * modifying the zone information passed to the report callback. - * So use a local copy to avoid corruption of the device zone - * array. - */ -- memcpy(&zone, &dev->zones[first_zone + i], -- sizeof(struct blk_zone)); -+ null_lock_zone(dev, zno); -+ memcpy(&zone, &dev->zones[zno], sizeof(struct blk_zone)); -+ null_unlock_zone(dev, zno); -+ - error = cb(&zone, i, data); - if (error) - return error; -@@ -141,6 +162,10 @@ int null_report_zones(struct gendisk *disk, sector_t sector, - return nr_zones; - } - -+/* -+ * This is called in the case of memory backing from null_process_cmd() -+ * with the target zone already locked. -+ */ - size_t null_zone_valid_read_len(struct nullb *nullb, - sector_t sector, unsigned int len) - { -@@ -172,10 +197,13 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector, - if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) - return null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors); - -+ null_lock_zone(dev, zno); -+ - switch (zone->cond) { - case BLK_ZONE_COND_FULL: - /* Cannot write to a full zone */ -- return BLK_STS_IOERR; -+ ret = BLK_STS_IOERR; -+ break; - case BLK_ZONE_COND_EMPTY: - case BLK_ZONE_COND_IMP_OPEN: - case BLK_ZONE_COND_EXP_OPEN: -@@ -193,66 +221,96 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector, - else - cmd->rq->__sector = sector; - } else if (sector != zone->wp) { -- return BLK_STS_IOERR; -+ ret = BLK_STS_IOERR; -+ break; - } - -- if (zone->wp + nr_sectors > zone->start + zone->capacity) -- return BLK_STS_IOERR; -+ if (zone->wp + nr_sectors > zone->start + zone->capacity) { -+ ret = BLK_STS_IOERR; -+ break; -+ } - - if (zone->cond != BLK_ZONE_COND_EXP_OPEN) - zone->cond = BLK_ZONE_COND_IMP_OPEN; - - ret = null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors); - if (ret != BLK_STS_OK) -- return ret; -+ break; - - zone->wp += nr_sectors; - if (zone->wp == zone->start + zone->capacity) - zone->cond = BLK_ZONE_COND_FULL; -- return BLK_STS_OK; -+ ret = BLK_STS_OK; -+ break; - default: - /* Invalid zone condition */ -- return BLK_STS_IOERR; -+ ret = BLK_STS_IOERR; - } -+ -+ null_unlock_zone(dev, zno); -+ -+ return ret; - } - - static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op, - sector_t sector) - { - struct nullb_device *dev = cmd->nq->dev; -- unsigned int zone_no = null_zone_no(dev, sector); -- struct blk_zone *zone = &dev->zones[zone_no]; -+ unsigned int zone_no; -+ struct blk_zone *zone; -+ blk_status_t ret = BLK_STS_OK; - size_t i; - -- switch (op) { -- case REQ_OP_ZONE_RESET_ALL: -- for (i = 0; i < dev->nr_zones; i++) { -- if (zone[i].type == BLK_ZONE_TYPE_CONVENTIONAL) -- continue; -- zone[i].cond = BLK_ZONE_COND_EMPTY; -- zone[i].wp = zone[i].start; -+ if (op == REQ_OP_ZONE_RESET_ALL) { -+ for (i = dev->zone_nr_conv; i < dev->nr_zones; i++) { -+ null_lock_zone(dev, i); -+ zone = &dev->zones[i]; -+ if (zone->cond != BLK_ZONE_COND_EMPTY) { -+ zone->cond = BLK_ZONE_COND_EMPTY; -+ zone->wp = zone->start; -+ trace_nullb_zone_op(cmd, i, zone->cond); -+ } -+ null_unlock_zone(dev, i); - } -- break; -+ return BLK_STS_OK; -+ } -+ -+ zone_no = null_zone_no(dev, sector); -+ zone = &dev->zones[zone_no]; -+ -+ null_lock_zone(dev, zone_no); -+ -+ switch (op) { - case REQ_OP_ZONE_RESET: -- if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) -- return BLK_STS_IOERR; -+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { -+ ret = BLK_STS_IOERR; -+ break; -+ } - - zone->cond = BLK_ZONE_COND_EMPTY; - zone->wp = zone->start; - break; - case REQ_OP_ZONE_OPEN: -- if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) -- return BLK_STS_IOERR; -- if (zone->cond == BLK_ZONE_COND_FULL) -- return BLK_STS_IOERR; -+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { -+ ret = BLK_STS_IOERR; -+ break; -+ } -+ if (zone->cond == BLK_ZONE_COND_FULL) { -+ ret = BLK_STS_IOERR; -+ break; -+ } - - zone->cond = BLK_ZONE_COND_EXP_OPEN; - break; - case REQ_OP_ZONE_CLOSE: -- if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) -- return BLK_STS_IOERR; -- if (zone->cond == BLK_ZONE_COND_FULL) -- return BLK_STS_IOERR; -+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { -+ ret = BLK_STS_IOERR; -+ break; -+ } -+ if (zone->cond == BLK_ZONE_COND_FULL) { -+ ret = BLK_STS_IOERR; -+ break; -+ } - - if (zone->wp == zone->start) - zone->cond = BLK_ZONE_COND_EMPTY; -@@ -260,35 +318,54 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op, - zone->cond = BLK_ZONE_COND_CLOSED; - break; - case REQ_OP_ZONE_FINISH: -- if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) -- return BLK_STS_IOERR; -+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { -+ ret = BLK_STS_IOERR; -+ break; -+ } - - zone->cond = BLK_ZONE_COND_FULL; - zone->wp = zone->start + zone->len; -+ ret = BLK_STS_OK; - break; - default: -- return BLK_STS_NOTSUPP; -+ ret = BLK_STS_NOTSUPP; -+ break; - } - -- trace_nullb_zone_op(cmd, zone_no, zone->cond); -- return BLK_STS_OK; -+ if (ret == BLK_STS_OK) -+ trace_nullb_zone_op(cmd, zone_no, zone->cond); -+ -+ null_unlock_zone(dev, zone_no); -+ -+ return ret; - } - - blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd, enum req_opf op, - sector_t sector, sector_t nr_sectors) - { -+ struct nullb_device *dev = cmd->nq->dev; -+ unsigned int zno = null_zone_no(dev, sector); -+ blk_status_t sts; -+ - switch (op) { - case REQ_OP_WRITE: -- return null_zone_write(cmd, sector, nr_sectors, false); -+ sts = null_zone_write(cmd, sector, nr_sectors, false); -+ break; - case REQ_OP_ZONE_APPEND: -- return null_zone_write(cmd, sector, nr_sectors, true); -+ sts = null_zone_write(cmd, sector, nr_sectors, true); -+ break; - case REQ_OP_ZONE_RESET: - case REQ_OP_ZONE_RESET_ALL: - case REQ_OP_ZONE_OPEN: - case REQ_OP_ZONE_CLOSE: - case REQ_OP_ZONE_FINISH: -- return null_zone_mgmt(cmd, op, sector); -+ sts = null_zone_mgmt(cmd, op, sector); -+ break; - default: -- return null_process_cmd(cmd, op, sector, nr_sectors); -+ null_lock_zone(dev, zno); -+ sts = null_process_cmd(cmd, op, sector, nr_sectors); -+ null_unlock_zone(dev, zno); - } -+ -+ return sts; - } -diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c -index adfc9352351df..501e9dacfff9d 100644 ---- a/drivers/block/xen-blkback/blkback.c -+++ b/drivers/block/xen-blkback/blkback.c -@@ -201,7 +201,7 @@ static inline void shrink_free_pagepool(struct xen_blkif_ring *ring, int num) - - #define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page))) - --static int do_block_io_op(struct xen_blkif_ring *ring); -+static int do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags); - static int dispatch_rw_block_io(struct xen_blkif_ring *ring, - struct blkif_request *req, - struct pending_req *pending_req); -@@ -612,6 +612,8 @@ int xen_blkif_schedule(void *arg) - struct xen_vbd *vbd = &blkif->vbd; - unsigned long timeout; - int ret; -+ bool do_eoi; -+ unsigned int eoi_flags = XEN_EOI_FLAG_SPURIOUS; - - set_freezable(); - while (!kthread_should_stop()) { -@@ -636,16 +638,23 @@ int xen_blkif_schedule(void *arg) - if (timeout == 0) - goto purge_gnt_list; - -+ do_eoi = ring->waiting_reqs; -+ - ring->waiting_reqs = 0; - smp_mb(); /* clear flag *before* checking for work */ - -- ret = do_block_io_op(ring); -+ ret = do_block_io_op(ring, &eoi_flags); - if (ret > 0) - ring->waiting_reqs = 1; - if (ret == -EACCES) - wait_event_interruptible(ring->shutdown_wq, - kthread_should_stop()); - -+ if (do_eoi && !ring->waiting_reqs) { -+ xen_irq_lateeoi(ring->irq, eoi_flags); -+ eoi_flags |= XEN_EOI_FLAG_SPURIOUS; -+ } -+ - purge_gnt_list: - if (blkif->vbd.feature_gnt_persistent && - time_after(jiffies, ring->next_lru)) { -@@ -1121,7 +1130,7 @@ static void end_block_io_op(struct bio *bio) - * and transmute it to the block API to hand it over to the proper block disk. - */ - static int --__do_block_io_op(struct xen_blkif_ring *ring) -+__do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags) - { - union blkif_back_rings *blk_rings = &ring->blk_rings; - struct blkif_request req; -@@ -1144,6 +1153,9 @@ __do_block_io_op(struct xen_blkif_ring *ring) - if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc)) - break; - -+ /* We've seen a request, so clear spurious eoi flag. */ -+ *eoi_flags &= ~XEN_EOI_FLAG_SPURIOUS; -+ - if (kthread_should_stop()) { - more_to_do = 1; - break; -@@ -1202,13 +1214,13 @@ done: - } - - static int --do_block_io_op(struct xen_blkif_ring *ring) -+do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags) - { - union blkif_back_rings *blk_rings = &ring->blk_rings; - int more_to_do; - - do { -- more_to_do = __do_block_io_op(ring); -+ more_to_do = __do_block_io_op(ring, eoi_flags); - if (more_to_do) - break; - -diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c -index b9aa5d1ac10b7..5e7c36d73dc62 100644 ---- a/drivers/block/xen-blkback/xenbus.c -+++ b/drivers/block/xen-blkback/xenbus.c -@@ -246,9 +246,8 @@ static int xen_blkif_map(struct xen_blkif_ring *ring, grant_ref_t *gref, - if (req_prod - rsp_prod > size) - goto fail; - -- err = bind_interdomain_evtchn_to_irqhandler(blkif->domid, evtchn, -- xen_blkif_be_int, 0, -- "blkif-backend", ring); -+ err = bind_interdomain_evtchn_to_irqhandler_lateeoi(blkif->domid, -+ evtchn, xen_blkif_be_int, 0, "blkif-backend", ring); - if (err < 0) - goto fail; - ring->irq = err; -diff --git a/drivers/bus/fsl-mc/mc-io.c b/drivers/bus/fsl-mc/mc-io.c -index a30b53f1d87d8..305015486b91c 100644 ---- a/drivers/bus/fsl-mc/mc-io.c -+++ b/drivers/bus/fsl-mc/mc-io.c -@@ -129,7 +129,12 @@ error_destroy_mc_io: - */ - void fsl_destroy_mc_io(struct fsl_mc_io *mc_io) - { -- struct fsl_mc_device *dpmcp_dev = mc_io->dpmcp_dev; -+ struct fsl_mc_device *dpmcp_dev; -+ -+ if (!mc_io) -+ return; -+ -+ dpmcp_dev = mc_io->dpmcp_dev; - - if (dpmcp_dev) - fsl_mc_io_unset_dpmcp(mc_io); -diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c -index 7960980780832..661d704c8093d 100644 ---- a/drivers/bus/mhi/core/pm.c -+++ b/drivers/bus/mhi/core/pm.c -@@ -686,7 +686,8 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) - return -EIO; - - /* Return busy if there are any pending resources */ -- if (atomic_read(&mhi_cntrl->dev_wake)) -+ if (atomic_read(&mhi_cntrl->dev_wake) || -+ atomic_read(&mhi_cntrl->pending_pkts)) - return -EBUSY; - - /* Take MHI out of M2 state */ -@@ -712,7 +713,8 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) - - write_lock_irq(&mhi_cntrl->pm_lock); - -- if (atomic_read(&mhi_cntrl->dev_wake)) { -+ if (atomic_read(&mhi_cntrl->dev_wake) || -+ atomic_read(&mhi_cntrl->pending_pkts)) { - write_unlock_irq(&mhi_cntrl->pm_lock); - return -EBUSY; - } -diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c -index ee56306f79d5f..700b7f44f6716 100644 ---- a/drivers/clk/ti/clockdomain.c -+++ b/drivers/clk/ti/clockdomain.c -@@ -148,10 +148,12 @@ static void __init of_ti_clockdomain_setup(struct device_node *node) - if (!omap2_clk_is_hw_omap(clk_hw)) { - pr_warn("can't setup clkdm for basic clk %s\n", - __clk_get_name(clk)); -+ clk_put(clk); - continue; - } - to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name; - omap2_init_clk_clkdm(clk_hw); -+ clk_put(clk); - } - } - -diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig -index 2c7171e0b0010..85de313ddec29 100644 ---- a/drivers/cpufreq/Kconfig -+++ b/drivers/cpufreq/Kconfig -@@ -71,6 +71,7 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE - - config CPU_FREQ_DEFAULT_GOV_ONDEMAND - bool "ondemand" -+ depends on !(X86_INTEL_PSTATE && SMP) - select CPU_FREQ_GOV_ONDEMAND - select CPU_FREQ_GOV_PERFORMANCE - help -@@ -83,6 +84,7 @@ config CPU_FREQ_DEFAULT_GOV_ONDEMAND - - config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE - bool "conservative" -+ depends on !(X86_INTEL_PSTATE && SMP) - select CPU_FREQ_GOV_CONSERVATIVE - select CPU_FREQ_GOV_PERFORMANCE - help -diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c -index e4ff681faaaaa..1e4fbb002a31d 100644 ---- a/drivers/cpufreq/acpi-cpufreq.c -+++ b/drivers/cpufreq/acpi-cpufreq.c -@@ -691,7 +691,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) - cpumask_copy(policy->cpus, topology_core_cpumask(cpu)); - } - -- if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) { -+ if (check_amd_hwpstate_cpu(cpu) && boot_cpu_data.x86 < 0x19 && -+ !acpi_pstate_strict) { - cpumask_clear(policy->cpus); - cpumask_set_cpu(cpu, policy->cpus); - cpumask_copy(data->freqdomain_cpus, -diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c -index dade36725b8f1..e97ff004ac6a9 100644 ---- a/drivers/cpufreq/cpufreq.c -+++ b/drivers/cpufreq/cpufreq.c -@@ -1903,6 +1903,18 @@ void cpufreq_resume(void) - } - } - -+/** -+ * cpufreq_driver_test_flags - Test cpufreq driver's flags against given ones. -+ * @flags: Flags to test against the current cpufreq driver's flags. -+ * -+ * Assumes that the driver is there, so callers must ensure that this is the -+ * case. -+ */ -+bool cpufreq_driver_test_flags(u16 flags) -+{ -+ return !!(cpufreq_driver->flags & flags); -+} -+ - /** - * cpufreq_get_current_driver - return current driver's name - * -@@ -2166,7 +2178,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, - * exactly same freq is called again and so we can save on few function - * calls. - */ -- if (target_freq == policy->cur) -+ if (target_freq == policy->cur && -+ !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS)) - return 0; - - /* Save last value to restore later on errors */ -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c -index 9a515c460a008..ef15ec4959c5c 100644 ---- a/drivers/cpufreq/intel_pstate.c -+++ b/drivers/cpufreq/intel_pstate.c -@@ -2550,14 +2550,12 @@ static int intel_cpufreq_update_pstate(struct cpudata *cpu, int target_pstate, - int old_pstate = cpu->pstate.current_pstate; - - target_pstate = intel_pstate_prepare_request(cpu, target_pstate); -- if (target_pstate != old_pstate) { -+ if (hwp_active) { -+ intel_cpufreq_adjust_hwp(cpu, target_pstate, fast_switch); -+ cpu->pstate.current_pstate = target_pstate; -+ } else if (target_pstate != old_pstate) { -+ intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, fast_switch); - cpu->pstate.current_pstate = target_pstate; -- if (hwp_active) -- intel_cpufreq_adjust_hwp(cpu, target_pstate, -- fast_switch); -- else -- intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, -- fast_switch); - } - - intel_cpufreq_trace(cpu, fast_switch ? INTEL_PSTATE_TRACE_FAST_SWITCH : -@@ -3014,6 +3012,7 @@ static int __init intel_pstate_init(void) - hwp_mode_bdw = id->driver_data; - intel_pstate.attr = hwp_cpufreq_attrs; - intel_cpufreq.attr = hwp_cpufreq_attrs; -+ intel_cpufreq.flags |= CPUFREQ_NEED_UPDATE_LIMITS; - if (!default_driver) - default_driver = &intel_pstate; - -diff --git a/drivers/cpufreq/sti-cpufreq.c b/drivers/cpufreq/sti-cpufreq.c -index a5ad96d29adca..4ac6fb23792a0 100644 ---- a/drivers/cpufreq/sti-cpufreq.c -+++ b/drivers/cpufreq/sti-cpufreq.c -@@ -141,7 +141,8 @@ static const struct reg_field sti_stih407_dvfs_regfields[DVFS_MAX_REGFIELDS] = { - static const struct reg_field *sti_cpufreq_match(void) - { - if (of_machine_is_compatible("st,stih407") || -- of_machine_is_compatible("st,stih410")) -+ of_machine_is_compatible("st,stih410") || -+ of_machine_is_compatible("st,stih418")) - return sti_stih407_dvfs_regfields; - - return NULL; -@@ -258,7 +259,8 @@ static int sti_cpufreq_init(void) - int ret; - - if ((!of_machine_is_compatible("st,stih407")) && -- (!of_machine_is_compatible("st,stih410"))) -+ (!of_machine_is_compatible("st,stih410")) && -+ (!of_machine_is_compatible("st,stih418"))) - return -ENODEV; - - ddata.cpu = get_cpu_device(0); -diff --git a/drivers/cpuidle/cpuidle-tegra.c b/drivers/cpuidle/cpuidle-tegra.c -index a12fb141875a7..e8956706a2917 100644 ---- a/drivers/cpuidle/cpuidle-tegra.c -+++ b/drivers/cpuidle/cpuidle-tegra.c -@@ -172,7 +172,7 @@ static int tegra_cpuidle_coupled_barrier(struct cpuidle_device *dev) - static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, - int index, unsigned int cpu) - { -- int ret; -+ int err; - - /* - * CC6 state is the "CPU cluster power-off" state. In order to -@@ -183,9 +183,9 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, - * CPU cores, GIC and L2 cache). - */ - if (index == TEGRA_CC6) { -- ret = tegra_cpuidle_coupled_barrier(dev); -- if (ret) -- return ret; -+ err = tegra_cpuidle_coupled_barrier(dev); -+ if (err) -+ return err; - } - - local_fiq_disable(); -@@ -194,15 +194,15 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, - - switch (index) { - case TEGRA_C7: -- ret = tegra_cpuidle_c7_enter(); -+ err = tegra_cpuidle_c7_enter(); - break; - - case TEGRA_CC6: -- ret = tegra_cpuidle_cc6_enter(cpu); -+ err = tegra_cpuidle_cc6_enter(cpu); - break; - - default: -- ret = -EINVAL; -+ err = -EINVAL; - break; - } - -@@ -210,7 +210,7 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, - tegra_pm_clear_cpu_in_lp2(); - local_fiq_enable(); - -- return ret; -+ return err ?: index; - } - - static int tegra_cpuidle_adjust_state_index(int index, unsigned int cpu) -@@ -236,21 +236,27 @@ static int tegra_cpuidle_enter(struct cpuidle_device *dev, - int index) - { - unsigned int cpu = cpu_logical_map(dev->cpu); -- int err; -+ int ret; - - index = tegra_cpuidle_adjust_state_index(index, cpu); - if (dev->states_usage[index].disable) - return -1; - - if (index == TEGRA_C1) -- err = arm_cpuidle_simple_enter(dev, drv, index); -+ ret = arm_cpuidle_simple_enter(dev, drv, index); - else -- err = tegra_cpuidle_state_enter(dev, index, cpu); -+ ret = tegra_cpuidle_state_enter(dev, index, cpu); - -- if (err && (err != -EINTR || index != TEGRA_CC6)) -- pr_err_once("failed to enter state %d err: %d\n", index, err); -+ if (ret < 0) { -+ if (ret != -EINTR || index != TEGRA_CC6) -+ pr_err_once("failed to enter state %d err: %d\n", -+ index, ret); -+ index = -1; -+ } else { -+ index = ret; -+ } - -- return err ? -1 : index; -+ return index; - } - - static int tegra114_enter_s2idle(struct cpuidle_device *dev, -diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c -index 8beed91428bd6..a608efaa435fb 100644 ---- a/drivers/dma/dma-jz4780.c -+++ b/drivers/dma/dma-jz4780.c -@@ -639,11 +639,11 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan, - unsigned long flags; - unsigned long residue = 0; - -+ spin_lock_irqsave(&jzchan->vchan.lock, flags); -+ - status = dma_cookie_status(chan, cookie, txstate); - if ((status == DMA_COMPLETE) || (txstate == NULL)) -- return status; -- -- spin_lock_irqsave(&jzchan->vchan.lock, flags); -+ goto out_unlock_irqrestore; - - vdesc = vchan_find_desc(&jzchan->vchan, cookie); - if (vdesc) { -@@ -660,6 +660,7 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan, - && jzchan->desc->status & (JZ_DMA_DCS_AR | JZ_DMA_DCS_HLT)) - status = DMA_ERROR; - -+out_unlock_irqrestore: - spin_unlock_irqrestore(&jzchan->vchan.lock, flags); - return status; - } -diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c -index d1c997599390a..5f52527526441 100644 ---- a/drivers/extcon/extcon-ptn5150.c -+++ b/drivers/extcon/extcon-ptn5150.c -@@ -127,7 +127,7 @@ static void ptn5150_irq_work(struct work_struct *work) - case PTN5150_DFP_ATTACHED: - extcon_set_state_sync(info->edev, - EXTCON_USB_HOST, false); -- gpiod_set_value(info->vbus_gpiod, 0); -+ gpiod_set_value_cansleep(info->vbus_gpiod, 0); - extcon_set_state_sync(info->edev, EXTCON_USB, - true); - break; -@@ -138,9 +138,9 @@ static void ptn5150_irq_work(struct work_struct *work) - PTN5150_REG_CC_VBUS_DETECTION_MASK) >> - PTN5150_REG_CC_VBUS_DETECTION_SHIFT); - if (vbus) -- gpiod_set_value(info->vbus_gpiod, 0); -+ gpiod_set_value_cansleep(info->vbus_gpiod, 0); - else -- gpiod_set_value(info->vbus_gpiod, 1); -+ gpiod_set_value_cansleep(info->vbus_gpiod, 1); - - extcon_set_state_sync(info->edev, - EXTCON_USB_HOST, true); -@@ -156,7 +156,7 @@ static void ptn5150_irq_work(struct work_struct *work) - EXTCON_USB_HOST, false); - extcon_set_state_sync(info->edev, - EXTCON_USB, false); -- gpiod_set_value(info->vbus_gpiod, 0); -+ gpiod_set_value_cansleep(info->vbus_gpiod, 0); - } - } - -diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c -index 9853bd3c4d456..017e5d8bd869a 100644 ---- a/drivers/firmware/arm_scmi/base.c -+++ b/drivers/firmware/arm_scmi/base.c -@@ -197,6 +197,8 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, - protocols_imp[tot_num_ret + loop] = *(list + loop); - - tot_num_ret += loop_num_ret; -+ -+ scmi_reset_rx_to_maxsz(handle, t); - } while (loop_num_ret); - - scmi_xfer_put(handle, t); -diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c -index db55c43a2cbda..1377ec76a45db 100644 ---- a/drivers/firmware/arm_scmi/bus.c -+++ b/drivers/firmware/arm_scmi/bus.c -@@ -230,7 +230,7 @@ static void scmi_devices_unregister(void) - bus_for_each_dev(&scmi_bus_type, NULL, NULL, __scmi_devices_unregister); - } - --static int __init scmi_bus_init(void) -+int __init scmi_bus_init(void) - { - int retval; - -@@ -240,12 +240,10 @@ static int __init scmi_bus_init(void) - - return retval; - } --subsys_initcall(scmi_bus_init); - --static void __exit scmi_bus_exit(void) -+void __exit scmi_bus_exit(void) - { - scmi_devices_unregister(); - bus_unregister(&scmi_bus_type); - ida_destroy(&scmi_bus_id); - } --module_exit(scmi_bus_exit); -diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c -index 75e39882746e1..fa3ad3a150c36 100644 ---- a/drivers/firmware/arm_scmi/clock.c -+++ b/drivers/firmware/arm_scmi/clock.c -@@ -192,6 +192,8 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id, - } - - tot_rate_cnt += num_returned; -+ -+ scmi_reset_rx_to_maxsz(handle, t); - /* - * check for both returned and remaining to avoid infinite - * loop due to buggy firmware -diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h -index c113e578cc6ce..124080955c4a0 100644 ---- a/drivers/firmware/arm_scmi/common.h -+++ b/drivers/firmware/arm_scmi/common.h -@@ -147,6 +147,8 @@ int scmi_do_xfer_with_response(const struct scmi_handle *h, - struct scmi_xfer *xfer); - int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id, - size_t tx_size, size_t rx_size, struct scmi_xfer **p); -+void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle, -+ struct scmi_xfer *xfer); - int scmi_handle_put(const struct scmi_handle *handle); - struct scmi_handle *scmi_handle_get(struct device *dev); - void scmi_set_handle(struct scmi_device *scmi_dev); -@@ -156,6 +158,9 @@ void scmi_setup_protocol_implemented(const struct scmi_handle *handle, - - int scmi_base_protocol_init(struct scmi_handle *h); - -+int __init scmi_bus_init(void); -+void __exit scmi_bus_exit(void); -+ - /* SCMI Transport */ - /** - * struct scmi_chan_info - Structure representing a SCMI channel information -diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c -index 03ec74242c141..5c2f4fab40994 100644 ---- a/drivers/firmware/arm_scmi/driver.c -+++ b/drivers/firmware/arm_scmi/driver.c -@@ -402,6 +402,14 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) - return ret; - } - -+void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle, -+ struct scmi_xfer *xfer) -+{ -+ struct scmi_info *info = handle_to_scmi_info(handle); -+ -+ xfer->rx.len = info->desc->max_msg_size; -+} -+ - #define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC) - - /** -@@ -928,7 +936,21 @@ static struct platform_driver scmi_driver = { - .remove = scmi_remove, - }; - --module_platform_driver(scmi_driver); -+static int __init scmi_driver_init(void) -+{ -+ scmi_bus_init(); -+ -+ return platform_driver_register(&scmi_driver); -+} -+module_init(scmi_driver_init); -+ -+static void __exit scmi_driver_exit(void) -+{ -+ scmi_bus_exit(); -+ -+ platform_driver_unregister(&scmi_driver); -+} -+module_exit(scmi_driver_exit); - - MODULE_ALIAS("platform: arm-scmi"); - MODULE_AUTHOR("Sudeep Holla "); -diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c -index 4731daaacd19e..51c5a376fb472 100644 ---- a/drivers/firmware/arm_scmi/notify.c -+++ b/drivers/firmware/arm_scmi/notify.c -@@ -1403,15 +1403,21 @@ static void scmi_protocols_late_init(struct work_struct *work) - "finalized PENDING handler - key:%X\n", - hndl->key); - ret = scmi_event_handler_enable_events(hndl); -+ if (ret) { -+ dev_dbg(ni->handle->dev, -+ "purging INVALID handler - key:%X\n", -+ hndl->key); -+ scmi_put_active_handler(ni, hndl); -+ } - } else { - ret = scmi_valid_pending_handler(ni, hndl); -- } -- if (ret) { -- dev_dbg(ni->handle->dev, -- "purging PENDING handler - key:%X\n", -- hndl->key); -- /* this hndl can be only a pending one */ -- scmi_put_handler_unlocked(ni, hndl); -+ if (ret) { -+ dev_dbg(ni->handle->dev, -+ "purging PENDING handler - key:%X\n", -+ hndl->key); -+ /* this hndl can be only a pending one */ -+ scmi_put_handler_unlocked(ni, hndl); -+ } - } - } - mutex_unlock(&ni->pending_mtx); -@@ -1468,7 +1474,7 @@ int scmi_notification_init(struct scmi_handle *handle) - ni->gid = gid; - ni->handle = handle; - -- ni->notify_wq = alloc_workqueue("scmi_notify", -+ ni->notify_wq = alloc_workqueue(dev_name(handle->dev), - WQ_UNBOUND | WQ_FREEZABLE | WQ_SYSFS, - 0); - if (!ni->notify_wq) -diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c -index 3e1e87012c95b..3e8b548a12b62 100644 ---- a/drivers/firmware/arm_scmi/perf.c -+++ b/drivers/firmware/arm_scmi/perf.c -@@ -304,6 +304,8 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain, - } - - tot_opp_cnt += num_returned; -+ -+ scmi_reset_rx_to_maxsz(handle, t); - /* - * check for both returned and remaining to avoid infinite - * loop due to buggy firmware -diff --git a/drivers/firmware/arm_scmi/reset.c b/drivers/firmware/arm_scmi/reset.c -index 3691bafca0574..86bda46de8eb8 100644 ---- a/drivers/firmware/arm_scmi/reset.c -+++ b/drivers/firmware/arm_scmi/reset.c -@@ -36,9 +36,7 @@ struct scmi_msg_reset_domain_reset { - #define EXPLICIT_RESET_ASSERT BIT(1) - #define ASYNCHRONOUS_RESET BIT(2) - __le32 reset_state; --#define ARCH_RESET_TYPE BIT(31) --#define COLD_RESET_STATE BIT(0) --#define ARCH_COLD_RESET (ARCH_RESET_TYPE | COLD_RESET_STATE) -+#define ARCH_COLD_RESET 0 - }; - - struct scmi_msg_reset_notify { -diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c -index 1af0ad362e823..4beee439b84ba 100644 ---- a/drivers/firmware/arm_scmi/sensors.c -+++ b/drivers/firmware/arm_scmi/sensors.c -@@ -166,6 +166,8 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle, - } - - desc_index += num_returned; -+ -+ scmi_reset_rx_to_maxsz(handle, t); - /* - * check for both returned and remaining to avoid infinite - * loop due to buggy firmware -diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c -index a1537d123e385..22f83af6853a1 100644 ---- a/drivers/firmware/arm_scmi/smc.c -+++ b/drivers/firmware/arm_scmi/smc.c -@@ -149,6 +149,6 @@ static struct scmi_transport_ops scmi_smc_ops = { - const struct scmi_desc scmi_smc_desc = { - .ops = &scmi_smc_ops, - .max_rx_timeout_ms = 30, -- .max_msg = 1, -+ .max_msg = 20, - .max_msg_size = 128, - }; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c -index 8842c55d4490b..fc695126b6e75 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c -@@ -46,7 +46,7 @@ const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = { - static int amdgpu_ctx_priority_permit(struct drm_file *filp, - enum drm_sched_priority priority) - { -- if (priority < 0 || priority >= DRM_SCHED_PRIORITY_MAX) -+ if (priority < 0 || priority >= DRM_SCHED_PRIORITY_COUNT) - return -EINVAL; - - /* NORMAL and below are accessible by everyone */ -@@ -65,7 +65,7 @@ static int amdgpu_ctx_priority_permit(struct drm_file *filp, - static enum gfx_pipe_priority amdgpu_ctx_sched_prio_to_compute_prio(enum drm_sched_priority prio) - { - switch (prio) { -- case DRM_SCHED_PRIORITY_HIGH_HW: -+ case DRM_SCHED_PRIORITY_HIGH: - case DRM_SCHED_PRIORITY_KERNEL: - return AMDGPU_GFX_PIPE_PRIO_HIGH; - default: -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -index d0b8d0d341af5..b4a8da8fc8fd7 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c -@@ -3316,10 +3316,8 @@ fence_driver_init: - flush_delayed_work(&adev->delayed_init_work); - - r = sysfs_create_files(&adev->dev->kobj, amdgpu_dev_attributes); -- if (r) { -+ if (r) - dev_err(adev->dev, "Could not create amdgpu device attr\n"); -- return r; -- } - - if (IS_ENABLED(CONFIG_PERF_EVENTS)) - r = amdgpu_pmu_init(adev); -@@ -4376,7 +4374,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, - retry: /* Rest of adevs pre asic reset from XGMI hive. */ - list_for_each_entry(tmp_adev, device_list_handle, gmc.xgmi.head) { - r = amdgpu_device_pre_asic_reset(tmp_adev, -- NULL, -+ (tmp_adev == adev) ? job : NULL, - &need_full_reset); - /*TODO Should we stop ?*/ - if (r) { -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c -index 7f9e50247413d..fb3fa9b27d53b 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c -@@ -596,6 +596,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, - struct ww_acquire_ctx ticket; - struct list_head list, duplicates; - uint64_t va_flags; -+ uint64_t vm_size; - int r = 0; - - if (args->va_address < AMDGPU_VA_RESERVED_SIZE) { -@@ -616,6 +617,15 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, - - args->va_address &= AMDGPU_GMC_HOLE_MASK; - -+ vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; -+ vm_size -= AMDGPU_VA_RESERVED_SIZE; -+ if (args->va_address + args->map_size > vm_size) { -+ dev_dbg(&dev->pdev->dev, -+ "va_address 0x%llx is in top reserved area 0x%llx\n", -+ args->va_address + args->map_size, vm_size); -+ return -EINVAL; -+ } -+ - if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) { - dev_dbg(&dev->pdev->dev, "invalid flags combination 0x%08X\n", - args->flags); -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c -index 937029ad5271a..dcfe8a3b03ffb 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c -@@ -251,7 +251,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched) - int i; - - /* Signal all jobs not yet scheduled */ -- for (i = DRM_SCHED_PRIORITY_MAX - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { -+ for (i = DRM_SCHED_PRIORITY_COUNT - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { - struct drm_sched_rq *rq = &sched->sched_rq[i]; - - if (!rq) -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c -index 06757681b2cec..f1cae42dcc364 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c -@@ -206,7 +206,8 @@ static int psp_sw_fini(void *handle) - adev->psp.ta_fw = NULL; - } - -- if (adev->asic_type == CHIP_NAVI10) -+ if (adev->asic_type == CHIP_NAVI10 || -+ adev->asic_type == CHIP_SIENNA_CICHLID) - psp_sysfs_fini(adev); - - return 0; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c -index 1bedb416eebd0..b4fb5a473df5a 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c -@@ -367,12 +367,19 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user * - static ssize_t amdgpu_ras_debugfs_eeprom_write(struct file *f, const char __user *buf, - size_t size, loff_t *pos) - { -- struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private; -+ struct amdgpu_device *adev = -+ (struct amdgpu_device *)file_inode(f)->i_private; - int ret; - -- ret = amdgpu_ras_eeprom_reset_table(&adev->psp.ras.ras->eeprom_control); -+ ret = amdgpu_ras_eeprom_reset_table( -+ &(amdgpu_ras_get_context(adev)->eeprom_control)); - -- return ret == 1 ? size : -EIO; -+ if (ret == 1) { -+ amdgpu_ras_get_context(adev)->flags = RAS_DEFAULT_FLAGS; -+ return size; -+ } else { -+ return -EIO; -+ } - } - - static const struct file_operations amdgpu_ras_debugfs_ctrl_ops = { -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c -index 13ea8ebc421c6..6d4fc79bf84aa 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c -@@ -267,7 +267,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, - &ring->sched; - } - -- for (i = 0; i < DRM_SCHED_PRIORITY_MAX; ++i) -+ for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_COUNT; ++i) - atomic_set(&ring->num_jobs[i], 0); - - return 0; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h -index da871d84b7424..7112137689db0 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h -@@ -243,7 +243,7 @@ struct amdgpu_ring { - bool has_compute_vm_bug; - bool no_scheduler; - -- atomic_t num_jobs[DRM_SCHED_PRIORITY_MAX]; -+ atomic_t num_jobs[DRM_SCHED_PRIORITY_COUNT]; - struct mutex priority_mutex; - /* protected by priority_mutex */ - int priority; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c -index c799691dfa848..17661ede94885 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c -@@ -36,14 +36,14 @@ enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority) - { - switch (amdgpu_priority) { - case AMDGPU_CTX_PRIORITY_VERY_HIGH: -- return DRM_SCHED_PRIORITY_HIGH_HW; -+ return DRM_SCHED_PRIORITY_HIGH; - case AMDGPU_CTX_PRIORITY_HIGH: -- return DRM_SCHED_PRIORITY_HIGH_SW; -+ return DRM_SCHED_PRIORITY_HIGH; - case AMDGPU_CTX_PRIORITY_NORMAL: - return DRM_SCHED_PRIORITY_NORMAL; - case AMDGPU_CTX_PRIORITY_LOW: - case AMDGPU_CTX_PRIORITY_VERY_LOW: -- return DRM_SCHED_PRIORITY_LOW; -+ return DRM_SCHED_PRIORITY_MIN; - case AMDGPU_CTX_PRIORITY_UNSET: - return DRM_SCHED_PRIORITY_UNSET; - default: -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c -index 978bae7313980..b7fd0cdffce0e 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c -@@ -2101,7 +2101,7 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable) - ring = adev->mman.buffer_funcs_ring; - sched = &ring->sched; - r = drm_sched_entity_init(&adev->mman.entity, -- DRM_SCHED_PRIORITY_KERNEL, &sched, -+ DRM_SCHED_PRIORITY_KERNEL, &sched, - 1, NULL); - if (r) { - DRM_ERROR("Failed setting up TTM BO move entity (%d)\n", -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c -index 495c3d7bb2b2b..f3b7287e84c43 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c -@@ -68,6 +68,7 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev) - - INIT_DELAYED_WORK(&adev->vcn.idle_work, amdgpu_vcn_idle_work_handler); - mutex_init(&adev->vcn.vcn_pg_lock); -+ mutex_init(&adev->vcn.vcn1_jpeg1_workaround); - atomic_set(&adev->vcn.total_submission_cnt, 0); - for (i = 0; i < adev->vcn.num_vcn_inst; i++) - atomic_set(&adev->vcn.inst[i].dpg_enc_submission_cnt, 0); -@@ -237,6 +238,7 @@ int amdgpu_vcn_sw_fini(struct amdgpu_device *adev) - } - - release_firmware(adev->vcn.fw); -+ mutex_destroy(&adev->vcn.vcn1_jpeg1_workaround); - mutex_destroy(&adev->vcn.vcn_pg_lock); - - return 0; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h -index 7a9b804bc988a..17691158f783e 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h -@@ -220,6 +220,7 @@ struct amdgpu_vcn { - struct amdgpu_vcn_inst inst[AMDGPU_MAX_VCN_INSTANCES]; - struct amdgpu_vcn_reg internal; - struct mutex vcn_pg_lock; -+ struct mutex vcn1_jpeg1_workaround; - atomic_t total_submission_cnt; - - unsigned harvest_config; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h -index 770025a5e5003..5b6788fb540a3 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h -@@ -112,8 +112,8 @@ struct amdgpu_bo_list_entry; - #define AMDGPU_MMHUB_0 1 - #define AMDGPU_MMHUB_1 2 - --/* hardcode that limit for now */ --#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20) -+/* Reserve 2MB at top/bottom of address space for kernel use */ -+#define AMDGPU_VA_RESERVED_SIZE (2ULL << 20) - - /* max vmids dedicated for process */ - #define AMDGPU_VM_MAX_RESERVED_VMID 1 -diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c -index f73ce97212339..b1cbb958d5cd6 100644 ---- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c -@@ -112,6 +112,22 @@ - #define mmCP_HYP_ME_UCODE_DATA 0x5817 - #define mmCP_HYP_ME_UCODE_DATA_BASE_IDX 1 - -+//CC_GC_SA_UNIT_DISABLE -+#define mmCC_GC_SA_UNIT_DISABLE 0x0fe9 -+#define mmCC_GC_SA_UNIT_DISABLE_BASE_IDX 0 -+#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT 0x8 -+#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK 0x0000FF00L -+//GC_USER_SA_UNIT_DISABLE -+#define mmGC_USER_SA_UNIT_DISABLE 0x0fea -+#define mmGC_USER_SA_UNIT_DISABLE_BASE_IDX 0 -+#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT 0x8 -+#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK 0x0000FF00L -+//PA_SC_ENHANCE_3 -+#define mmPA_SC_ENHANCE_3 0x1085 -+#define mmPA_SC_ENHANCE_3_BASE_IDX 0 -+#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO__SHIFT 0x3 -+#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO_MASK 0x00000008L -+ - MODULE_FIRMWARE("amdgpu/navi10_ce.bin"); - MODULE_FIRMWARE("amdgpu/navi10_pfp.bin"); - MODULE_FIRMWARE("amdgpu/navi10_me.bin"); -@@ -3091,6 +3107,7 @@ static const struct soc15_reg_golden golden_settings_gc_10_3[] = - SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_ADDR_MATCH_MASK, 0xffffffff, 0xffffffcf), - SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CM_CTRL1, 0xff8fff0f, 0x580f1008), - SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CTRL3, 0xf7ffffff, 0x10f80988), -+ SOC15_REG_GOLDEN_VALUE(GC, 0, mmLDS_CONFIG, 0x00000020, 0x00000020), - SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_CL_ENHANCE, 0xf17fffff, 0x01200007), - SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_TIMEOUT_COUNTER, 0xffffffff, 0x00000800), - SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0xffffffbf, 0x00000820), -@@ -3188,6 +3205,8 @@ static int gfx_v10_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev); - static void gfx_v10_0_ring_emit_ce_meta(struct amdgpu_ring *ring, bool resume); - static void gfx_v10_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume); - static void gfx_v10_0_ring_emit_frame_cntl(struct amdgpu_ring *ring, bool start, bool secure); -+static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev); -+static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev); - - static void gfx10_kiq_set_resources(struct amdgpu_ring *kiq_ring, uint64_t queue_mask) - { -@@ -4518,12 +4537,17 @@ static void gfx_v10_0_setup_rb(struct amdgpu_device *adev) - int i, j; - u32 data; - u32 active_rbs = 0; -+ u32 bitmap; - u32 rb_bitmap_width_per_sh = adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se; - - mutex_lock(&adev->grbm_idx_mutex); - for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { - for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { -+ bitmap = i * adev->gfx.config.max_sh_per_se + j; -+ if ((adev->asic_type == CHIP_SIENNA_CICHLID) && -+ ((gfx_v10_3_get_disabled_sa(adev) >> bitmap) & 1)) -+ continue; - gfx_v10_0_select_se_sh(adev, i, j, 0xffffffff); - data = gfx_v10_0_get_rb_active_bitmap(adev); - active_rbs |= data << ((i * adev->gfx.config.max_sh_per_se + j) * -@@ -6928,6 +6952,9 @@ static int gfx_v10_0_hw_init(void *handle) - if (r) - return r; - -+ if (adev->asic_type == CHIP_SIENNA_CICHLID) -+ gfx_v10_3_program_pbb_mode(adev); -+ - return r; - } - -@@ -8739,6 +8766,10 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device *adev, - mutex_lock(&adev->grbm_idx_mutex); - for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { - for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { -+ bitmap = i * adev->gfx.config.max_sh_per_se + j; -+ if ((adev->asic_type == CHIP_SIENNA_CICHLID) && -+ ((gfx_v10_3_get_disabled_sa(adev) >> bitmap) & 1)) -+ continue; - mask = 1; - ao_bitmap = 0; - counter = 0; -@@ -8773,6 +8804,47 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device *adev, - return 0; - } - -+static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev) -+{ -+ uint32_t efuse_setting, vbios_setting, disabled_sa, max_sa_mask; -+ -+ efuse_setting = RREG32_SOC15(GC, 0, mmCC_GC_SA_UNIT_DISABLE); -+ efuse_setting &= CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK; -+ efuse_setting >>= CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT; -+ -+ vbios_setting = RREG32_SOC15(GC, 0, mmGC_USER_SA_UNIT_DISABLE); -+ vbios_setting &= GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK; -+ vbios_setting >>= GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT; -+ -+ max_sa_mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_sh_per_se * -+ adev->gfx.config.max_shader_engines); -+ disabled_sa = efuse_setting | vbios_setting; -+ disabled_sa &= max_sa_mask; -+ -+ return disabled_sa; -+} -+ -+static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev) -+{ -+ uint32_t max_sa_per_se, max_sa_per_se_mask, max_shader_engines; -+ uint32_t disabled_sa_mask, se_index, disabled_sa_per_se; -+ -+ disabled_sa_mask = gfx_v10_3_get_disabled_sa(adev); -+ -+ max_sa_per_se = adev->gfx.config.max_sh_per_se; -+ max_sa_per_se_mask = (1 << max_sa_per_se) - 1; -+ max_shader_engines = adev->gfx.config.max_shader_engines; -+ -+ for (se_index = 0; max_shader_engines > se_index; se_index++) { -+ disabled_sa_per_se = disabled_sa_mask >> (se_index * max_sa_per_se); -+ disabled_sa_per_se &= max_sa_per_se_mask; -+ if (disabled_sa_per_se == max_sa_per_se_mask) { -+ WREG32_FIELD15(GC, 0, PA_SC_ENHANCE_3, FORCE_PBB_WORKLOAD_MODE_TO_ZERO, 1); -+ break; -+ } -+ } -+} -+ - const struct amdgpu_ip_block_version gfx_v10_0_ip_block = - { - .type = AMD_IP_BLOCK_TYPE_GFX, -diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c -index bc300283b6abc..c600b61b5f45d 100644 ---- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c -@@ -33,6 +33,7 @@ - - static void jpeg_v1_0_set_dec_ring_funcs(struct amdgpu_device *adev); - static void jpeg_v1_0_set_irq_funcs(struct amdgpu_device *adev); -+static void jpeg_v1_0_ring_begin_use(struct amdgpu_ring *ring); - - static void jpeg_v1_0_decode_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t *ptr, uint32_t reg_offset, uint32_t val) - { -@@ -564,8 +565,8 @@ static const struct amdgpu_ring_funcs jpeg_v1_0_decode_ring_vm_funcs = { - .insert_start = jpeg_v1_0_decode_ring_insert_start, - .insert_end = jpeg_v1_0_decode_ring_insert_end, - .pad_ib = amdgpu_ring_generic_pad_ib, -- .begin_use = vcn_v1_0_ring_begin_use, -- .end_use = amdgpu_vcn_ring_end_use, -+ .begin_use = jpeg_v1_0_ring_begin_use, -+ .end_use = vcn_v1_0_ring_end_use, - .emit_wreg = jpeg_v1_0_decode_ring_emit_wreg, - .emit_reg_wait = jpeg_v1_0_decode_ring_emit_reg_wait, - .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, -@@ -586,3 +587,22 @@ static void jpeg_v1_0_set_irq_funcs(struct amdgpu_device *adev) - { - adev->jpeg.inst->irq.funcs = &jpeg_v1_0_irq_funcs; - } -+ -+static void jpeg_v1_0_ring_begin_use(struct amdgpu_ring *ring) -+{ -+ struct amdgpu_device *adev = ring->adev; -+ bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work); -+ int cnt = 0; -+ -+ mutex_lock(&adev->vcn.vcn1_jpeg1_workaround); -+ -+ if (amdgpu_fence_wait_empty(&adev->vcn.inst->ring_dec)) -+ DRM_ERROR("JPEG dec: vcn dec ring may not be empty\n"); -+ -+ for (cnt = 0; cnt < adev->vcn.num_enc_rings; cnt++) { -+ if (amdgpu_fence_wait_empty(&adev->vcn.inst->ring_enc[cnt])) -+ DRM_ERROR("JPEG dec: vcn enc ring[%d] may not be empty\n", cnt); -+ } -+ -+ vcn_v1_0_set_pg_for_begin_use(ring, set_clocks); -+} -diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c -index 927c330fad21c..ec4ce8746d5ef 100644 ---- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c -@@ -54,6 +54,7 @@ static int vcn_v1_0_pause_dpg_mode(struct amdgpu_device *adev, - int inst_idx, struct dpg_pause_state *new_state); - - static void vcn_v1_0_idle_work_handler(struct work_struct *work); -+static void vcn_v1_0_ring_begin_use(struct amdgpu_ring *ring); - - /** - * vcn_v1_0_early_init - set function pointers -@@ -1804,11 +1805,24 @@ static void vcn_v1_0_idle_work_handler(struct work_struct *work) - } - } - --void vcn_v1_0_ring_begin_use(struct amdgpu_ring *ring) -+static void vcn_v1_0_ring_begin_use(struct amdgpu_ring *ring) - { -- struct amdgpu_device *adev = ring->adev; -+ struct amdgpu_device *adev = ring->adev; - bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work); - -+ mutex_lock(&adev->vcn.vcn1_jpeg1_workaround); -+ -+ if (amdgpu_fence_wait_empty(&ring->adev->jpeg.inst->ring_dec)) -+ DRM_ERROR("VCN dec: jpeg dec ring may not be empty\n"); -+ -+ vcn_v1_0_set_pg_for_begin_use(ring, set_clocks); -+ -+} -+ -+void vcn_v1_0_set_pg_for_begin_use(struct amdgpu_ring *ring, bool set_clocks) -+{ -+ struct amdgpu_device *adev = ring->adev; -+ - if (set_clocks) { - amdgpu_gfx_off_ctrl(adev, false); - if (adev->pm.dpm_enabled) -@@ -1844,6 +1858,12 @@ void vcn_v1_0_ring_begin_use(struct amdgpu_ring *ring) - } - } - -+void vcn_v1_0_ring_end_use(struct amdgpu_ring *ring) -+{ -+ schedule_delayed_work(&ring->adev->vcn.idle_work, VCN_IDLE_TIMEOUT); -+ mutex_unlock(&ring->adev->vcn.vcn1_jpeg1_workaround); -+} -+ - static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { - .name = "vcn_v1_0", - .early_init = vcn_v1_0_early_init, -@@ -1891,7 +1911,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { - .insert_end = vcn_v1_0_dec_ring_insert_end, - .pad_ib = amdgpu_ring_generic_pad_ib, - .begin_use = vcn_v1_0_ring_begin_use, -- .end_use = amdgpu_vcn_ring_end_use, -+ .end_use = vcn_v1_0_ring_end_use, - .emit_wreg = vcn_v1_0_dec_ring_emit_wreg, - .emit_reg_wait = vcn_v1_0_dec_ring_emit_reg_wait, - .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, -@@ -1923,7 +1943,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_enc_ring_vm_funcs = { - .insert_end = vcn_v1_0_enc_ring_insert_end, - .pad_ib = amdgpu_ring_generic_pad_ib, - .begin_use = vcn_v1_0_ring_begin_use, -- .end_use = amdgpu_vcn_ring_end_use, -+ .end_use = vcn_v1_0_ring_end_use, - .emit_wreg = vcn_v1_0_enc_ring_emit_wreg, - .emit_reg_wait = vcn_v1_0_enc_ring_emit_reg_wait, - .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, -diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.h b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.h -index f67d7391fc21c..1f1cc7f0ece70 100644 ---- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.h -+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.h -@@ -24,7 +24,8 @@ - #ifndef __VCN_V1_0_H__ - #define __VCN_V1_0_H__ - --void vcn_v1_0_ring_begin_use(struct amdgpu_ring *ring); -+void vcn_v1_0_ring_end_use(struct amdgpu_ring *ring); -+void vcn_v1_0_set_pg_for_begin_use(struct amdgpu_ring *ring, bool set_clocks); - - extern const struct amdgpu_ip_block_version vcn_v1_0_ip_block; - -diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v10.c -index 72e4d61ac7522..ad05933423337 100644 ---- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v10.c -+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v10.c -@@ -58,8 +58,9 @@ static int update_qpd_v10(struct device_queue_manager *dqm, - /* check if sh_mem_config register already configured */ - if (qpd->sh_mem_config == 0) { - qpd->sh_mem_config = -- SH_MEM_ALIGNMENT_MODE_UNALIGNED << -- SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT; -+ (SH_MEM_ALIGNMENT_MODE_UNALIGNED << -+ SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | -+ (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT); - #if 0 - /* TODO: - * This shouldn't be an issue with Navi10. Verify. -diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -index 5474f7e4c75b1..6beccd5a0941a 100644 ---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -@@ -4882,6 +4882,13 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector) - struct amdgpu_device *adev = connector->dev->dev_private; - struct amdgpu_display_manager *dm = &adev->dm; - -+ /* -+ * Call only if mst_mgr was iniitalized before since it's not done -+ * for all connector types. -+ */ -+ if (aconnector->mst_mgr.dev) -+ drm_dp_mst_topology_mgr_destroy(&aconnector->mst_mgr); -+ - #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) ||\ - defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE) - -diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce112/dce112_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce112/dce112_clk_mgr.c -index d031bd3d30724..807dca8f7d7aa 100644 ---- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dce112/dce112_clk_mgr.c -+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dce112/dce112_clk_mgr.c -@@ -79,8 +79,7 @@ int dce112_set_clock(struct clk_mgr *clk_mgr_base, int requested_clk_khz) - memset(&dce_clk_params, 0, sizeof(dce_clk_params)); - - /* Make sure requested clock isn't lower than minimum threshold*/ -- if (requested_clk_khz > 0) -- requested_clk_khz = max(requested_clk_khz, -+ requested_clk_khz = max(requested_clk_khz, - clk_mgr_dce->base.dentist_vco_freq_khz / 62); - - dce_clk_params.target_clock_frequency = requested_clk_khz; -diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c -index 21a3073c8929e..2f8fee05547ac 100644 ---- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c -+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c -@@ -761,6 +761,7 @@ void rn_clk_mgr_construct( - { - struct dc_debug_options *debug = &ctx->dc->debug; - struct dpm_clocks clock_table = { 0 }; -+ enum pp_smu_status status = 0; - - clk_mgr->base.ctx = ctx; - clk_mgr->base.funcs = &dcn21_funcs; -@@ -817,8 +818,10 @@ void rn_clk_mgr_construct( - clk_mgr->base.bw_params = &rn_bw_params; - - if (pp_smu && pp_smu->rn_funcs.get_dpm_clock_table) { -- pp_smu->rn_funcs.get_dpm_clock_table(&pp_smu->rn_funcs.pp_smu, &clock_table); -- if (ctx->dc_bios && ctx->dc_bios->integrated_info) { -+ status = pp_smu->rn_funcs.get_dpm_clock_table(&pp_smu->rn_funcs.pp_smu, &clock_table); -+ -+ if (status == PP_SMU_RESULT_OK && -+ ctx->dc_bios && ctx->dc_bios->integrated_info) { - rn_clk_mgr_helper_populate_bw_params (clk_mgr->base.bw_params, &clock_table, ctx->dc_bios->integrated_info); - } - } -diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c -index 437d1a7a16fe7..b0f8bfd48d102 100644 ---- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c -+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c -@@ -2441,7 +2441,7 @@ enum dc_status dc_link_validate_mode_timing( - /* A hack to avoid failing any modes for EDID override feature on - * topology change such as lower quality cable for DP or different dongle - */ -- if (link->remote_sinks[0]) -+ if (link->remote_sinks[0] && link->remote_sinks[0]->sink_signal == SIGNAL_TYPE_VIRTUAL) - return DC_OK; - - /* Passive Dongle */ -diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h b/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h -index 99c68ca9c7e00..967d04d75b989 100644 ---- a/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h -+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h -@@ -54,7 +54,7 @@ - SR(BL_PWM_CNTL2), \ - SR(BL_PWM_PERIOD_CNTL), \ - SR(BL_PWM_GRP1_REG_LOCK), \ -- SR(BIOS_SCRATCH_2) -+ NBIO_SR(BIOS_SCRATCH_2) - - #define DCE_PANEL_CNTL_SF(reg_name, field_name, post_fix)\ - .field_name = reg_name ## __ ## field_name ## post_fix -diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c -index 842abb4c475bc..62651d0041fd9 100644 ---- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c -+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c -@@ -896,10 +896,10 @@ void enc1_stream_encoder_dp_blank( - */ - REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_DIS_DEFER, 2); - /* Larger delay to wait until VBLANK - use max retry of -- * 10us*5000=50ms. This covers 41.7ms of minimum 24 Hz mode + -+ * 10us*10200=102ms. This covers 100.0ms of minimum 10 Hz mode + - * a little more because we may not trust delay accuracy. - */ -- max_retries = DP_BLANK_MAX_RETRY * 250; -+ max_retries = DP_BLANK_MAX_RETRY * 501; - - /* disable DP stream */ - REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, 0); -diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c -index f67c18375bfdb..dac427b68fd7b 100644 ---- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c -+++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c -@@ -63,13 +63,13 @@ enum gpio_result dal_gpio_open_ex( - enum gpio_mode mode) - { - if (gpio->pin) { -- ASSERT_CRITICAL(false); -+ BREAK_TO_DEBUGGER(); - return GPIO_RESULT_ALREADY_OPENED; - } - - // No action if allocation failed during gpio construct - if (!gpio->hw_container.ddc) { -- ASSERT_CRITICAL(false); -+ BREAK_TO_DEBUGGER(); - return GPIO_RESULT_NON_SPECIFIC_ERROR; - } - gpio->mode = mode; -diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h -index c3bbfe397e8df..aee98b1d7ebf3 100644 ---- a/drivers/gpu/drm/amd/display/dc/os_types.h -+++ b/drivers/gpu/drm/amd/display/dc/os_types.h -@@ -90,7 +90,7 @@ - * general debug capabilities - * - */ --#if defined(CONFIG_HAVE_KGDB) || defined(CONFIG_KGDB) -+#if defined(CONFIG_DEBUG_KERNEL_DC) && (defined(CONFIG_HAVE_KGDB) || defined(CONFIG_KGDB)) - #define ASSERT_CRITICAL(expr) do { \ - if (WARN_ON(!(expr))) { \ - kgdb_breakpoint(); \ -diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c -index 4a3b64aa21ceb..fc63d9e32e1f8 100644 ---- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c -+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c -@@ -2873,7 +2873,7 @@ static int smu7_vblank_too_short(struct pp_hwmgr *hwmgr, - if (hwmgr->is_kicker) - switch_limit_us = data->is_memory_gddr5 ? 450 : 150; - else -- switch_limit_us = data->is_memory_gddr5 ? 190 : 150; -+ switch_limit_us = data->is_memory_gddr5 ? 200 : 150; - break; - case CHIP_VEGAM: - switch_limit_us = 30; -diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_types.h b/drivers/gpu/drm/amd/powerplay/inc/smu_types.h -index 7b585e205a5a0..3b868f2adc12f 100644 ---- a/drivers/gpu/drm/amd/powerplay/inc/smu_types.h -+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_types.h -@@ -217,6 +217,7 @@ enum smu_clk_type { - __SMU_DUMMY_MAP(DPM_MP0CLK), \ - __SMU_DUMMY_MAP(DPM_LINK), \ - __SMU_DUMMY_MAP(DPM_DCEFCLK), \ -+ __SMU_DUMMY_MAP(DPM_XGMI), \ - __SMU_DUMMY_MAP(DS_GFXCLK), \ - __SMU_DUMMY_MAP(DS_SOCCLK), \ - __SMU_DUMMY_MAP(DS_LCLK), \ -diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c -index b1547a83e7217..e0992cd7914ec 100644 ---- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c -+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c -@@ -2463,37 +2463,11 @@ static const struct i2c_algorithm navi10_i2c_algo = { - .functionality = navi10_i2c_func, - }; - --static int navi10_i2c_control_init(struct smu_context *smu, struct i2c_adapter *control) --{ -- struct amdgpu_device *adev = to_amdgpu_device(control); -- int res; -- -- control->owner = THIS_MODULE; -- control->class = I2C_CLASS_SPD; -- control->dev.parent = &adev->pdev->dev; -- control->algo = &navi10_i2c_algo; -- snprintf(control->name, sizeof(control->name), "AMDGPU SMU"); -- -- res = i2c_add_adapter(control); -- if (res) -- DRM_ERROR("Failed to register hw i2c, err: %d\n", res); -- -- return res; --} -- --static void navi10_i2c_control_fini(struct smu_context *smu, struct i2c_adapter *control) --{ -- i2c_del_adapter(control); --} -- -- - static const struct pptable_funcs navi10_ppt_funcs = { - .get_allowed_feature_mask = navi10_get_allowed_feature_mask, - .set_default_dpm_table = navi10_set_default_dpm_table, - .dpm_set_vcn_enable = navi10_dpm_set_vcn_enable, - .dpm_set_jpeg_enable = navi10_dpm_set_jpeg_enable, -- .i2c_init = navi10_i2c_control_init, -- .i2c_fini = navi10_i2c_control_fini, - .print_clk_levels = navi10_print_clk_levels, - .force_clk_levels = navi10_force_clk_levels, - .populate_umd_state_clk = navi10_populate_umd_state_clk, -diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c -index ace682fde22fb..8f41496630a52 100644 ---- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c -+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c -@@ -150,14 +150,17 @@ static struct cmn2asic_mapping sienna_cichlid_feature_mask_map[SMU_FEATURE_COUNT - FEA_MAP(DPM_GFXCLK), - FEA_MAP(DPM_GFX_GPO), - FEA_MAP(DPM_UCLK), -+ FEA_MAP(DPM_FCLK), - FEA_MAP(DPM_SOCCLK), - FEA_MAP(DPM_MP0CLK), - FEA_MAP(DPM_LINK), - FEA_MAP(DPM_DCEFCLK), -+ FEA_MAP(DPM_XGMI), - FEA_MAP(MEM_VDDCI_SCALING), - FEA_MAP(MEM_MVDD_SCALING), - FEA_MAP(DS_GFXCLK), - FEA_MAP(DS_SOCCLK), -+ FEA_MAP(DS_FCLK), - FEA_MAP(DS_LCLK), - FEA_MAP(DS_DCEFCLK), - FEA_MAP(DS_UCLK), -@@ -447,6 +450,9 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu, - case METRICS_CURR_DCEFCLK: - *value = metrics->CurrClock[PPCLK_DCEFCLK]; - break; -+ case METRICS_CURR_FCLK: -+ *value = metrics->CurrClock[PPCLK_FCLK]; -+ break; - case METRICS_AVERAGE_GFXCLK: - if (metrics->AverageGfxActivity <= SMU_11_0_7_GFX_BUSY_THRESHOLD) - *value = metrics->AverageGfxclkFrequencyPostDs; -diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c -index 0b58f7aee6b01..9d04f2b5225cf 100644 ---- a/drivers/gpu/drm/ast/ast_drv.c -+++ b/drivers/gpu/drm/ast/ast_drv.c -@@ -43,9 +43,33 @@ int ast_modeset = -1; - MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); - module_param_named(modeset, ast_modeset, int, 0400); - --#define PCI_VENDOR_ASPEED 0x1a03 -+/* -+ * DRM driver -+ */ -+ -+DEFINE_DRM_GEM_FOPS(ast_fops); -+ -+static struct drm_driver ast_driver = { -+ .driver_features = DRIVER_ATOMIC | -+ DRIVER_GEM | -+ DRIVER_MODESET, -+ -+ .fops = &ast_fops, -+ .name = DRIVER_NAME, -+ .desc = DRIVER_DESC, -+ .date = DRIVER_DATE, -+ .major = DRIVER_MAJOR, -+ .minor = DRIVER_MINOR, -+ .patchlevel = DRIVER_PATCHLEVEL, - --static struct drm_driver driver; -+ DRM_GEM_VRAM_DRIVER -+}; -+ -+/* -+ * PCI driver -+ */ -+ -+#define PCI_VENDOR_ASPEED 0x1a03 - - #define AST_VGA_DEVICE(id, info) { \ - .class = PCI_BASE_CLASS_DISPLAY << 16, \ -@@ -56,13 +80,13 @@ static struct drm_driver driver; - .subdevice = PCI_ANY_ID, \ - .driver_data = (unsigned long) info } - --static const struct pci_device_id pciidlist[] = { -+static const struct pci_device_id ast_pciidlist[] = { - AST_VGA_DEVICE(PCI_CHIP_AST2000, NULL), - AST_VGA_DEVICE(PCI_CHIP_AST2100, NULL), - {0, 0, 0}, - }; - --MODULE_DEVICE_TABLE(pci, pciidlist); -+MODULE_DEVICE_TABLE(pci, ast_pciidlist); - - static void ast_kick_out_firmware_fb(struct pci_dev *pdev) - { -@@ -94,7 +118,7 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - if (ret) - return ret; - -- dev = drm_dev_alloc(&driver, &pdev->dev); -+ dev = drm_dev_alloc(&ast_driver, &pdev->dev); - if (IS_ERR(dev)) - return PTR_ERR(dev); - -@@ -118,11 +142,9 @@ err_ast_driver_unload: - err_drm_dev_put: - drm_dev_put(dev); - return ret; -- - } - --static void --ast_pci_remove(struct pci_dev *pdev) -+static void ast_pci_remove(struct pci_dev *pdev) - { - struct drm_device *dev = pci_get_drvdata(pdev); - -@@ -217,30 +239,12 @@ static const struct dev_pm_ops ast_pm_ops = { - - static struct pci_driver ast_pci_driver = { - .name = DRIVER_NAME, -- .id_table = pciidlist, -+ .id_table = ast_pciidlist, - .probe = ast_pci_probe, - .remove = ast_pci_remove, - .driver.pm = &ast_pm_ops, - }; - --DEFINE_DRM_GEM_FOPS(ast_fops); -- --static struct drm_driver driver = { -- .driver_features = DRIVER_ATOMIC | -- DRIVER_GEM | -- DRIVER_MODESET, -- -- .fops = &ast_fops, -- .name = DRIVER_NAME, -- .desc = DRIVER_DESC, -- .date = DRIVER_DATE, -- .major = DRIVER_MAJOR, -- .minor = DRIVER_MINOR, -- .patchlevel = DRIVER_PATCHLEVEL, -- -- DRM_GEM_VRAM_DRIVER --}; -- - static int __init ast_init(void) - { - if (vgacon_text_force() && ast_modeset == -1) -@@ -261,4 +265,3 @@ module_exit(ast_exit); - MODULE_AUTHOR(DRIVER_AUTHOR); - MODULE_DESCRIPTION(DRIVER_DESC); - MODULE_LICENSE("GPL and additional rights"); -- -diff --git a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c -index 6200f12a37e69..ab8174831cf40 100644 ---- a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c -+++ b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c -@@ -302,8 +302,12 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client *stdp4028_i2c, - const struct i2c_device_id *id) - { - struct device *dev = &stdp4028_i2c->dev; -+ int ret; -+ -+ ret = ge_b850v3_lvds_init(dev); - -- ge_b850v3_lvds_init(dev); -+ if (ret) -+ return ret; - - ge_b850v3_lvds_ptr->stdp4028_i2c = stdp4028_i2c; - i2c_set_clientdata(stdp4028_i2c, ge_b850v3_lvds_ptr); -@@ -361,8 +365,12 @@ static int stdp2690_ge_b850v3_fw_probe(struct i2c_client *stdp2690_i2c, - const struct i2c_device_id *id) - { - struct device *dev = &stdp2690_i2c->dev; -+ int ret; -+ -+ ret = ge_b850v3_lvds_init(dev); - -- ge_b850v3_lvds_init(dev); -+ if (ret) -+ return ret; - - ge_b850v3_lvds_ptr->stdp2690_i2c = stdp2690_i2c; - i2c_set_clientdata(stdp2690_i2c, ge_b850v3_lvds_ptr); -diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c -index d580b2aa4ce98..979acaa90d002 100644 ---- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c -+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c -@@ -365,7 +365,6 @@ static void dw_mipi_message_config(struct dw_mipi_dsi *dsi, - if (lpm) - val |= CMD_MODE_ALL_LP; - -- dsi_write(dsi, DSI_LPCLK_CTRL, lpm ? 0 : PHY_TXREQUESTCLKHS); - dsi_write(dsi, DSI_CMD_MODE_CFG, val); - } - -@@ -541,16 +540,22 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi) - static void dw_mipi_dsi_set_mode(struct dw_mipi_dsi *dsi, - unsigned long mode_flags) - { -+ u32 val; -+ - dsi_write(dsi, DSI_PWR_UP, RESET); - - if (mode_flags & MIPI_DSI_MODE_VIDEO) { - dsi_write(dsi, DSI_MODE_CFG, ENABLE_VIDEO_MODE); - dw_mipi_dsi_video_mode_config(dsi); -- dsi_write(dsi, DSI_LPCLK_CTRL, PHY_TXREQUESTCLKHS); - } else { - dsi_write(dsi, DSI_MODE_CFG, ENABLE_CMD_MODE); - } - -+ val = PHY_TXREQUESTCLKHS; -+ if (dsi->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS) -+ val |= AUTO_CLKLANE_CTRL; -+ dsi_write(dsi, DSI_LPCLK_CTRL, val); -+ - dsi_write(dsi, DSI_PWR_UP, POWERUP); - } - -diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c -index c6994fe673f31..a58cbde59c34a 100644 ---- a/drivers/gpu/drm/drm_bridge_connector.c -+++ b/drivers/gpu/drm/drm_bridge_connector.c -@@ -187,6 +187,7 @@ drm_bridge_connector_detect(struct drm_connector *connector, bool force) - case DRM_MODE_CONNECTOR_DPI: - case DRM_MODE_CONNECTOR_LVDS: - case DRM_MODE_CONNECTOR_DSI: -+ case DRM_MODE_CONNECTOR_eDP: - status = connector_status_connected; - break; - default: -diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c -index 19d73868490e6..69c2c079d8036 100644 ---- a/drivers/gpu/drm/drm_gem.c -+++ b/drivers/gpu/drm/drm_gem.c -@@ -1085,6 +1085,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, - */ - drm_gem_object_get(obj); - -+ vma->vm_private_data = obj; -+ - if (obj->funcs && obj->funcs->mmap) { - ret = obj->funcs->mmap(obj, vma); - if (ret) { -@@ -1107,8 +1109,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, - vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); - } - -- vma->vm_private_data = obj; -- - return 0; - } - EXPORT_SYMBOL(drm_gem_mmap_obj); -diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c -index 4b7cfbac4daae..22a5d58a7eaa4 100644 ---- a/drivers/gpu/drm/drm_gem_shmem_helper.c -+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c -@@ -594,8 +594,13 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) - /* Remove the fake offset */ - vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node); - -- if (obj->import_attach) -+ if (obj->import_attach) { -+ /* Drop the reference drm_gem_mmap_obj() acquired.*/ -+ drm_gem_object_put(obj); -+ vma->vm_private_data = NULL; -+ - return dma_buf_mmap(obj->dma_buf, vma, 0); -+ } - - shmem = to_drm_gem_shmem_obj(obj); - -diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c -index 03be314271811..967a5cdc120e3 100644 ---- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c -+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c -@@ -395,8 +395,8 @@ static void g2d_userptr_put_dma_addr(struct g2d_data *g2d, - return; - - out: -- dma_unmap_sg(to_dma_dev(g2d->drm_dev), g2d_userptr->sgt->sgl, -- g2d_userptr->sgt->nents, DMA_BIDIRECTIONAL); -+ dma_unmap_sgtable(to_dma_dev(g2d->drm_dev), g2d_userptr->sgt, -+ DMA_BIDIRECTIONAL, 0); - - pages = frame_vector_pages(g2d_userptr->vec); - if (!IS_ERR(pages)) { -@@ -511,10 +511,10 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct g2d_data *g2d, - - g2d_userptr->sgt = sgt; - -- if (!dma_map_sg(to_dma_dev(g2d->drm_dev), sgt->sgl, sgt->nents, -- DMA_BIDIRECTIONAL)) { -+ ret = dma_map_sgtable(to_dma_dev(g2d->drm_dev), sgt, -+ DMA_BIDIRECTIONAL, 0); -+ if (ret) { - DRM_DEV_ERROR(g2d->dev, "failed to map sgt with dma region.\n"); -- ret = -ENOMEM; - goto err_sg_free_table; - } - -diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h -index e4f7f6518945b..37e6f2abab004 100644 ---- a/drivers/gpu/drm/i915/i915_drv.h -+++ b/drivers/gpu/drm/i915/i915_drv.h -@@ -33,6 +33,8 @@ - #include - #include - -+#include -+ - #include - #include - #include -@@ -1716,7 +1718,9 @@ static inline bool intel_vtd_active(void) - if (intel_iommu_gfx_mapped) - return true; - #endif -- return false; -+ -+ /* Running as a guest, we assume the host is enforcing VT'd */ -+ return !hypervisor_is_type(X86_HYPER_NATIVE); - } - - static inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv) -diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c -index 155f2b4b4030a..11223fe348dfe 100644 ---- a/drivers/gpu/drm/lima/lima_gem.c -+++ b/drivers/gpu/drm/lima/lima_gem.c -@@ -69,8 +69,7 @@ int lima_heap_alloc(struct lima_bo *bo, struct lima_vm *vm) - return ret; - - if (bo->base.sgt) { -- dma_unmap_sg(dev, bo->base.sgt->sgl, -- bo->base.sgt->nents, DMA_BIDIRECTIONAL); -+ dma_unmap_sgtable(dev, bo->base.sgt, DMA_BIDIRECTIONAL, 0); - sg_free_table(bo->base.sgt); - } else { - bo->base.sgt = kmalloc(sizeof(*bo->base.sgt), GFP_KERNEL); -@@ -80,7 +79,13 @@ int lima_heap_alloc(struct lima_bo *bo, struct lima_vm *vm) - } - } - -- dma_map_sg(dev, sgt.sgl, sgt.nents, DMA_BIDIRECTIONAL); -+ ret = dma_map_sgtable(dev, &sgt, DMA_BIDIRECTIONAL, 0); -+ if (ret) { -+ sg_free_table(&sgt); -+ kfree(bo->base.sgt); -+ bo->base.sgt = NULL; -+ return ret; -+ } - - *bo->base.sgt = sgt; - -diff --git a/drivers/gpu/drm/lima/lima_vm.c b/drivers/gpu/drm/lima/lima_vm.c -index 5b92fb82674a9..2b2739adc7f53 100644 ---- a/drivers/gpu/drm/lima/lima_vm.c -+++ b/drivers/gpu/drm/lima/lima_vm.c -@@ -124,7 +124,7 @@ int lima_vm_bo_add(struct lima_vm *vm, struct lima_bo *bo, bool create) - if (err) - goto err_out1; - -- for_each_sg_dma_page(bo->base.sgt->sgl, &sg_iter, bo->base.sgt->nents, 0) { -+ for_each_sgtable_dma_page(bo->base.sgt, &sg_iter, 0) { - err = lima_vm_map_page(vm, sg_page_iter_dma_address(&sg_iter), - bo_va->node.start + offset); - if (err) -@@ -298,8 +298,7 @@ int lima_vm_map_bo(struct lima_vm *vm, struct lima_bo *bo, int pageoff) - mutex_lock(&vm->lock); - - base = bo_va->node.start + (pageoff << PAGE_SHIFT); -- for_each_sg_dma_page(bo->base.sgt->sgl, &sg_iter, -- bo->base.sgt->nents, pageoff) { -+ for_each_sgtable_dma_page(bo->base.sgt, &sg_iter, pageoff) { - err = lima_vm_map_page(vm, sg_page_iter_dma_address(&sg_iter), - base + offset); - if (err) -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c -index 33355dd302f11..1a6cea0e0bd74 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.c -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c -@@ -41,8 +41,8 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj) - - for (i = 0; i < n_sgt; i++) { - if (bo->sgts[i].sgl) { -- dma_unmap_sg(pfdev->dev, bo->sgts[i].sgl, -- bo->sgts[i].nents, DMA_BIDIRECTIONAL); -+ dma_unmap_sgtable(pfdev->dev, &bo->sgts[i], -+ DMA_BIDIRECTIONAL, 0); - sg_free_table(&bo->sgts[i]); - } - } -diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c -index e8f7b11352d27..776448c527ea9 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_mmu.c -+++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c -@@ -253,7 +253,7 @@ static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu, - struct io_pgtable_ops *ops = mmu->pgtbl_ops; - u64 start_iova = iova; - -- for_each_sg(sgt->sgl, sgl, sgt->nents, count) { -+ for_each_sgtable_dma_sg(sgt, sgl, count) { - unsigned long paddr = sg_dma_address(sgl); - size_t len = sg_dma_len(sgl); - -@@ -517,10 +517,9 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as, - if (ret) - goto err_pages; - -- if (!dma_map_sg(pfdev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL)) { -- ret = -EINVAL; -+ ret = dma_map_sgtable(pfdev->dev, sgt, DMA_BIDIRECTIONAL, 0); -+ if (ret) - goto err_map; -- } - - mmu_map_sg(pfdev, bomapping->mmu, addr, - IOMMU_WRITE | IOMMU_READ | IOMMU_NOEXEC, sgt); -diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c -index 96f763d888af5..9a0d77a680180 100644 ---- a/drivers/gpu/drm/scheduler/sched_main.c -+++ b/drivers/gpu/drm/scheduler/sched_main.c -@@ -625,7 +625,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched) - return NULL; - - /* Kernel run queue has higher priority than normal run queue*/ -- for (i = DRM_SCHED_PRIORITY_MAX - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { -+ for (i = DRM_SCHED_PRIORITY_COUNT - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { - entity = drm_sched_rq_select_entity(&sched->sched_rq[i]); - if (entity) - break; -@@ -852,7 +852,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, - sched->name = name; - sched->timeout = timeout; - sched->hang_limit = hang_limit; -- for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_MAX; i++) -+ for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_COUNT; i++) - drm_sched_rq_init(sched, &sched->sched_rq[i]); - - init_waitqueue_head(&sched->wake_up_worker); -diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c -index cc6a4e7551e31..760a8c102af3d 100644 ---- a/drivers/gpu/drm/ttm/ttm_bo.c -+++ b/drivers/gpu/drm/ttm/ttm_bo.c -@@ -694,7 +694,7 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, - /* Don't evict this BO if it's outside of the - * requested placement range - */ -- if (place->fpfn >= (bo->mem.start + bo->mem.size) || -+ if (place->fpfn >= (bo->mem.start + bo->mem.num_pages) || - (place->lpfn && place->lpfn <= bo->mem.start)) - return false; - -diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c -index ac85e17428f88..09c012d54d58f 100644 ---- a/drivers/gpu/drm/vkms/vkms_crtc.c -+++ b/drivers/gpu/drm/vkms/vkms_crtc.c -@@ -86,6 +86,11 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, - struct vkms_output *output = &vkmsdev->output; - struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; - -+ if (!READ_ONCE(vblank->enabled)) { -+ *vblank_time = ktime_get(); -+ return true; -+ } -+ - *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires); - - if (WARN_ON(*vblank_time == vblank->time)) -diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c -index 83dfec327c422..1bd0eb71559ca 100644 ---- a/drivers/hid/wacom_wac.c -+++ b/drivers/hid/wacom_wac.c -@@ -2773,7 +2773,9 @@ static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *repo - if (report->type != HID_INPUT_REPORT) - return -1; - -- if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) -+ if (WACOM_PAD_FIELD(field)) -+ return 0; -+ else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) - wacom_wac_pen_report(hdev, report); - else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) - wacom_wac_finger_report(hdev, report); -diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c -index de04dff28945b..34f42589d90dc 100644 ---- a/drivers/hwmon/pmbus/max34440.c -+++ b/drivers/hwmon/pmbus/max34440.c -@@ -31,6 +31,13 @@ enum chips { max34440, max34441, max34446, max34451, max34460, max34461 }; - #define MAX34440_STATUS_OT_FAULT BIT(5) - #define MAX34440_STATUS_OT_WARN BIT(6) - -+/* -+ * The whole max344* family have IOUT_OC_WARN_LIMIT and IOUT_OC_FAULT_LIMIT -+ * swapped from the standard pmbus spec addresses. -+ */ -+#define MAX34440_IOUT_OC_WARN_LIMIT 0x46 -+#define MAX34440_IOUT_OC_FAULT_LIMIT 0x4A -+ - #define MAX34451_MFR_CHANNEL_CONFIG 0xe4 - #define MAX34451_MFR_CHANNEL_CONFIG_SEL_MASK 0x3f - -@@ -49,6 +56,14 @@ static int max34440_read_word_data(struct i2c_client *client, int page, - const struct max34440_data *data = to_max34440_data(info); - - switch (reg) { -+ case PMBUS_IOUT_OC_FAULT_LIMIT: -+ ret = pmbus_read_word_data(client, page, phase, -+ MAX34440_IOUT_OC_FAULT_LIMIT); -+ break; -+ case PMBUS_IOUT_OC_WARN_LIMIT: -+ ret = pmbus_read_word_data(client, page, phase, -+ MAX34440_IOUT_OC_WARN_LIMIT); -+ break; - case PMBUS_VIRT_READ_VOUT_MIN: - ret = pmbus_read_word_data(client, page, phase, - MAX34440_MFR_VOUT_MIN); -@@ -115,6 +130,14 @@ static int max34440_write_word_data(struct i2c_client *client, int page, - int ret; - - switch (reg) { -+ case PMBUS_IOUT_OC_FAULT_LIMIT: -+ ret = pmbus_write_word_data(client, page, MAX34440_IOUT_OC_FAULT_LIMIT, -+ word); -+ break; -+ case PMBUS_IOUT_OC_WARN_LIMIT: -+ ret = pmbus_write_word_data(client, page, MAX34440_IOUT_OC_WARN_LIMIT, -+ word); -+ break; - case PMBUS_VIRT_RESET_POUT_HISTORY: - ret = pmbus_write_word_data(client, page, - MAX34446_MFR_POUT_PEAK, 0); -diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c -index 392757f3a019e..7ff7e7780bbfb 100644 ---- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c -+++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c -@@ -1065,6 +1065,13 @@ static int cti_create_con_sysfs_attr(struct device *dev, - } - eattr->var = con; - con->con_attrs[attr_idx] = &eattr->attr.attr; -+ /* -+ * Initialize the dynamically allocated attribute -+ * to avoid LOCKDEP splat. See include/linux/sysfs.h -+ * for more details. -+ */ -+ sysfs_attr_init(con->con_attrs[attr_idx]); -+ - return 0; - } - -diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h -index f2dc625ea5856..5fe773c4d6cc5 100644 ---- a/drivers/hwtracing/coresight/coresight-priv.h -+++ b/drivers/hwtracing/coresight/coresight-priv.h -@@ -148,7 +148,8 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val, - void coresight_disable_path(struct list_head *path); - int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); - struct coresight_device *coresight_get_sink(struct list_head *path); --struct coresight_device *coresight_get_enabled_sink(bool reset); -+struct coresight_device * -+coresight_get_enabled_sink(struct coresight_device *source); - struct coresight_device *coresight_get_sink_by_id(u32 id); - struct coresight_device * - coresight_find_default_sink(struct coresight_device *csdev); -diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c -index cdcb1917216fd..fd46216669449 100644 ---- a/drivers/hwtracing/coresight/coresight.c -+++ b/drivers/hwtracing/coresight/coresight.c -@@ -540,50 +540,46 @@ struct coresight_device *coresight_get_sink(struct list_head *path) - return csdev; - } - --static int coresight_enabled_sink(struct device *dev, const void *data) -+static struct coresight_device * -+coresight_find_enabled_sink(struct coresight_device *csdev) - { -- const bool *reset = data; -- struct coresight_device *csdev = to_coresight_device(dev); -+ int i; -+ struct coresight_device *sink; - - if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || - csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && -- csdev->activated) { -- /* -- * Now that we have a handle on the sink for this session, -- * disable the sysFS "enable_sink" flag so that possible -- * concurrent perf session that wish to use another sink don't -- * trip on it. Doing so has no ramification for the current -- * session. -- */ -- if (*reset) -- csdev->activated = false; -+ csdev->activated) -+ return csdev; - -- return 1; -+ /* -+ * Recursively explore each port found on this element. -+ */ -+ for (i = 0; i < csdev->pdata->nr_outport; i++) { -+ struct coresight_device *child_dev; -+ -+ child_dev = csdev->pdata->conns[i].child_dev; -+ if (child_dev) -+ sink = coresight_find_enabled_sink(child_dev); -+ if (sink) -+ return sink; - } - -- return 0; -+ return NULL; - } - - /** -- * coresight_get_enabled_sink - returns the first enabled sink found on the bus -- * @deactivate: Whether the 'enable_sink' flag should be reset -- * -- * When operated from perf the deactivate parameter should be set to 'true'. -- * That way the "enabled_sink" flag of the sink that was selected can be reset, -- * allowing for other concurrent perf sessions to choose a different sink. -+ * coresight_get_enabled_sink - returns the first enabled sink using -+ * connection based search starting from the source reference - * -- * When operated from sysFS users have full control and as such the deactivate -- * parameter should be set to 'false', hence mandating users to explicitly -- * clear the flag. -+ * @source: Coresight source device reference - */ --struct coresight_device *coresight_get_enabled_sink(bool deactivate) -+struct coresight_device * -+coresight_get_enabled_sink(struct coresight_device *source) - { -- struct device *dev = NULL; -- -- dev = bus_find_device(&coresight_bustype, NULL, &deactivate, -- coresight_enabled_sink); -+ if (!source) -+ return NULL; - -- return dev ? to_coresight_device(dev) : NULL; -+ return coresight_find_enabled_sink(source); - } - - static int coresight_sink_by_id(struct device *dev, const void *data) -@@ -988,11 +984,7 @@ int coresight_enable(struct coresight_device *csdev) - goto out; - } - -- /* -- * Search for a valid sink for this session but don't reset the -- * "enable_sink" flag in sysFS. Users get to do that explicitly. -- */ -- sink = coresight_get_enabled_sink(false); -+ sink = coresight_get_enabled_sink(csdev); - if (!sink) { - ret = -EINVAL; - goto out; -diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c -index 0ab5381aa0127..7e7257c6f83fa 100644 ---- a/drivers/i2c/busses/i2c-imx.c -+++ b/drivers/i2c/busses/i2c-imx.c -@@ -1171,14 +1171,6 @@ static int i2c_imx_probe(struct platform_device *pdev) - return ret; - } - -- /* Request IRQ */ -- ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, IRQF_SHARED, -- pdev->name, i2c_imx); -- if (ret) { -- dev_err(&pdev->dev, "can't claim irq %d\n", irq); -- goto clk_disable; -- } -- - /* Init queue */ - init_waitqueue_head(&i2c_imx->queue); - -@@ -1197,6 +1189,14 @@ static int i2c_imx_probe(struct platform_device *pdev) - if (ret < 0) - goto rpm_disable; - -+ /* Request IRQ */ -+ ret = request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED, -+ pdev->name, i2c_imx); -+ if (ret) { -+ dev_err(&pdev->dev, "can't claim irq %d\n", irq); -+ goto rpm_disable; -+ } -+ - /* Set up clock divider */ - i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ; - ret = of_property_read_u32(pdev->dev.of_node, -@@ -1239,13 +1239,12 @@ static int i2c_imx_probe(struct platform_device *pdev) - - clk_notifier_unregister: - clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); -+ free_irq(irq, i2c_imx); - rpm_disable: - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); -- --clk_disable: - clk_disable_unprepare(i2c_imx->clk); - return ret; - } -@@ -1253,7 +1252,7 @@ clk_disable: - static int i2c_imx_remove(struct platform_device *pdev) - { - struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev); -- int ret; -+ int irq, ret; - - ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) -@@ -1273,6 +1272,9 @@ static int i2c_imx_remove(struct platform_device *pdev) - imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR); - - clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); -+ irq = platform_get_irq(pdev, 0); -+ if (irq >= 0) -+ free_irq(irq, i2c_imx); - clk_disable_unprepare(i2c_imx->clk); - - pm_runtime_put_noidle(&pdev->dev); -diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c -index 9a810e4a79460..d09b807e1c3a1 100644 ---- a/drivers/idle/intel_idle.c -+++ b/drivers/idle/intel_idle.c -@@ -1212,14 +1212,13 @@ static bool __init intel_idle_acpi_cst_extract(void) - if (!intel_idle_cst_usable()) - continue; - -- if (!acpi_processor_claim_cst_control()) { -- acpi_state_table.count = 0; -- return false; -- } -+ if (!acpi_processor_claim_cst_control()) -+ break; - - return true; - } - -+ acpi_state_table.count = 0; - pr_debug("ACPI _CST not found or not usable\n"); - return false; - } -@@ -1236,7 +1235,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) - struct acpi_processor_cx *cx; - struct cpuidle_state *state; - -- if (intel_idle_max_cstate_reached(cstate)) -+ if (intel_idle_max_cstate_reached(cstate - 1)) - break; - - cx = &acpi_state_table.states[cstate]; -diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c -index 2eafbe7ac7c7b..ab204e9199e99 100644 ---- a/drivers/iio/adc/ad7292.c -+++ b/drivers/iio/adc/ad7292.c -@@ -310,8 +310,10 @@ static int ad7292_probe(struct spi_device *spi) - - for_each_available_child_of_node(spi->dev.of_node, child) { - diff_channels = of_property_read_bool(child, "diff-channels"); -- if (diff_channels) -+ if (diff_channels) { -+ of_node_put(child); - break; -+ } - } - - if (diff_channels) { -diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c -index de9583d6cddd7..f94641193b980 100644 ---- a/drivers/iio/adc/at91-sama5d2_adc.c -+++ b/drivers/iio/adc/at91-sama5d2_adc.c -@@ -884,7 +884,7 @@ static bool at91_adc_current_chan_is_touch(struct iio_dev *indio_dev) - AT91_SAMA5D2_MAX_CHAN_IDX + 1); - } - --static int at91_adc_buffer_preenable(struct iio_dev *indio_dev) -+static int at91_adc_buffer_prepare(struct iio_dev *indio_dev) - { - int ret; - u8 bit; -@@ -901,7 +901,7 @@ static int at91_adc_buffer_preenable(struct iio_dev *indio_dev) - /* we continue with the triggered buffer */ - ret = at91_adc_dma_start(indio_dev); - if (ret) { -- dev_err(&indio_dev->dev, "buffer postenable failed\n"); -+ dev_err(&indio_dev->dev, "buffer prepare failed\n"); - return ret; - } - -@@ -989,7 +989,6 @@ static int at91_adc_buffer_postdisable(struct iio_dev *indio_dev) - } - - static const struct iio_buffer_setup_ops at91_buffer_setup_ops = { -- .preenable = &at91_adc_buffer_preenable, - .postdisable = &at91_adc_buffer_postdisable, - }; - -@@ -1563,6 +1562,7 @@ static void at91_adc_dma_disable(struct platform_device *pdev) - static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) - { - struct at91_adc_state *st = iio_priv(indio_dev); -+ int ret; - - if (val > AT91_HWFIFO_MAX_SIZE) - return -EINVAL; -@@ -1586,7 +1586,15 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) - else if (val > 1) - at91_adc_dma_init(to_platform_device(&indio_dev->dev)); - -- return 0; -+ /* -+ * We can start the DMA only after setting the watermark and -+ * having the DMA initialization completed -+ */ -+ ret = at91_adc_buffer_prepare(indio_dev); -+ if (ret) -+ at91_adc_dma_disable(to_platform_device(&indio_dev->dev)); -+ -+ return ret; - } - - static int at91_adc_update_scan_mode(struct iio_dev *indio_dev, -diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c -index d2c1419e72a01..34fa189e9b5e5 100644 ---- a/drivers/iio/adc/rcar-gyroadc.c -+++ b/drivers/iio/adc/rcar-gyroadc.c -@@ -357,7 +357,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3); - break; - default: -- return -EINVAL; -+ goto err_e_inval; - } - - /* -@@ -374,7 +374,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - dev_err(dev, - "Failed to get child reg property of ADC \"%pOFn\".\n", - child); -- return ret; -+ goto err_of_node_put; - } - - /* Channel number is too high. */ -@@ -382,7 +382,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - dev_err(dev, - "Only %i channels supported with %pOFn, but reg = <%i>.\n", - num_channels, child, reg); -- return -EINVAL; -+ goto err_e_inval; - } - } - -@@ -391,7 +391,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - dev_err(dev, - "Channel %i uses different ADC mode than the rest.\n", - reg); -- return -EINVAL; -+ goto err_e_inval; - } - - /* Channel is valid, grab the regulator. */ -@@ -401,7 +401,8 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - if (IS_ERR(vref)) { - dev_dbg(dev, "Channel %i 'vref' supply not connected.\n", - reg); -- return PTR_ERR(vref); -+ ret = PTR_ERR(vref); -+ goto err_of_node_put; - } - - priv->vref[reg] = vref; -@@ -425,8 +426,10 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - * attached to the GyroADC at a time, so if we found it, - * we can stop parsing here. - */ -- if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) -+ if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) { -+ of_node_put(child); - break; -+ } - } - - if (first) { -@@ -435,6 +438,12 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) - } - - return 0; -+ -+err_e_inval: -+ ret = -EINVAL; -+err_of_node_put: -+ of_node_put(child); -+ return ret; - } - - static void rcar_gyroadc_deinit_supplies(struct iio_dev *indio_dev) -diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c -index c7a085dce1f47..0261b3cfc92b6 100644 ---- a/drivers/iio/adc/ti-adc0832.c -+++ b/drivers/iio/adc/ti-adc0832.c -@@ -29,6 +29,12 @@ struct adc0832 { - struct regulator *reg; - struct mutex lock; - u8 mux_bits; -+ /* -+ * Max size needed: 16x 1 byte ADC data + 8 bytes timestamp -+ * May be shorter if not all channels are enabled subject -+ * to the timestamp remaining 8 byte aligned. -+ */ -+ u8 data[24] __aligned(8); - - u8 tx_buf[2] ____cacheline_aligned; - u8 rx_buf[2]; -@@ -200,7 +206,6 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p) - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct adc0832 *adc = iio_priv(indio_dev); -- u8 data[24] = { }; /* 16x 1 byte ADC data + 8 bytes timestamp */ - int scan_index; - int i = 0; - -@@ -218,10 +223,10 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p) - goto out; - } - -- data[i] = ret; -+ adc->data[i] = ret; - i++; - } -- iio_push_to_buffers_with_timestamp(indio_dev, data, -+ iio_push_to_buffers_with_timestamp(indio_dev, adc->data, - iio_get_time_ns(indio_dev)); - out: - mutex_unlock(&adc->lock); -diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c -index e485719cd2c4c..fcd5d39dd03ea 100644 ---- a/drivers/iio/adc/ti-adc12138.c -+++ b/drivers/iio/adc/ti-adc12138.c -@@ -47,6 +47,12 @@ struct adc12138 { - struct completion complete; - /* The number of cclk periods for the S/H's acquisition time */ - unsigned int acquisition_time; -+ /* -+ * Maximum size needed: 16x 2 bytes ADC data + 8 bytes timestamp. -+ * Less may be need if not all channels are enabled, as long as -+ * the 8 byte alignment of the timestamp is maintained. -+ */ -+ __be16 data[20] __aligned(8); - - u8 tx_buf[2] ____cacheline_aligned; - u8 rx_buf[2]; -@@ -329,7 +335,6 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p) - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct adc12138 *adc = iio_priv(indio_dev); -- __be16 data[20] = { }; /* 16x 2 bytes ADC data + 8 bytes timestamp */ - __be16 trash; - int ret; - int scan_index; -@@ -345,7 +350,7 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p) - reinit_completion(&adc->complete); - - ret = adc12138_start_and_read_conv(adc, scan_chan, -- i ? &data[i - 1] : &trash); -+ i ? &adc->data[i - 1] : &trash); - if (ret) { - dev_warn(&adc->spi->dev, - "failed to start conversion\n"); -@@ -362,7 +367,7 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p) - } - - if (i) { -- ret = adc12138_read_conv_data(adc, &data[i - 1]); -+ ret = adc12138_read_conv_data(adc, &adc->data[i - 1]); - if (ret) { - dev_warn(&adc->spi->dev, - "failed to get conversion data\n"); -@@ -370,7 +375,7 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p) - } - } - -- iio_push_to_buffers_with_timestamp(indio_dev, data, -+ iio_push_to_buffers_with_timestamp(indio_dev, adc->data, - iio_get_time_ns(indio_dev)); - out: - mutex_unlock(&adc->lock); -diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c -index d3fbe9d86467c..1c3c1bd53374a 100644 ---- a/drivers/iio/gyro/itg3200_buffer.c -+++ b/drivers/iio/gyro/itg3200_buffer.c -@@ -46,13 +46,20 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p) - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct itg3200 *st = iio_priv(indio_dev); -- __be16 buf[ITG3200_SCAN_ELEMENTS + sizeof(s64)/sizeof(u16)]; -- -- int ret = itg3200_read_all_channels(st->i2c, buf); -+ /* -+ * Ensure correct alignment and padding including for the -+ * timestamp that may be inserted. -+ */ -+ struct { -+ __be16 buf[ITG3200_SCAN_ELEMENTS]; -+ s64 ts __aligned(8); -+ } scan; -+ -+ int ret = itg3200_read_all_channels(st->i2c, scan.buf); - if (ret < 0) - goto error_ret; - -- iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp); -+ iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp); - - iio_trigger_notify_done(indio_dev->trig); - -diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h -index cd38b3fccc7b2..eb522b38acf3f 100644 ---- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h -+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h -@@ -122,6 +122,13 @@ struct inv_mpu6050_chip_config { - u8 user_ctrl; - }; - -+/* -+ * Maximum of 6 + 6 + 2 + 7 (for MPU9x50) = 21 round up to 24 and plus 8. -+ * May be less if fewer channels are enabled, as long as the timestamp -+ * remains 8 byte aligned -+ */ -+#define INV_MPU6050_OUTPUT_DATA_SIZE 32 -+ - /** - * struct inv_mpu6050_hw - Other important hardware information. - * @whoami: Self identification byte from WHO_AM_I register -@@ -165,6 +172,7 @@ struct inv_mpu6050_hw { - * @magn_raw_to_gauss: coefficient to convert mag raw value to Gauss. - * @magn_orient: magnetometer sensor chip orientation if available. - * @suspended_sensors: sensors mask of sensors turned off for suspend -+ * @data: dma safe buffer used for bulk reads. - */ - struct inv_mpu6050_state { - struct mutex lock; -@@ -190,6 +198,7 @@ struct inv_mpu6050_state { - s32 magn_raw_to_gauss[3]; - struct iio_mount_matrix magn_orient; - unsigned int suspended_sensors; -+ u8 data[INV_MPU6050_OUTPUT_DATA_SIZE] ____cacheline_aligned; - }; - - /*register and associated bit definition*/ -@@ -334,9 +343,6 @@ struct inv_mpu6050_state { - #define INV_ICM20608_TEMP_OFFSET 8170 - #define INV_ICM20608_TEMP_SCALE 3059976 - --/* 6 + 6 + 2 + 7 (for MPU9x50) = 21 round up to 24 and plus 8 */ --#define INV_MPU6050_OUTPUT_DATA_SIZE 32 -- - #define INV_MPU6050_REG_INT_PIN_CFG 0x37 - #define INV_MPU6050_ACTIVE_HIGH 0x00 - #define INV_MPU6050_ACTIVE_LOW 0x80 -diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c -index b533fa2dad0ab..d8e6b88ddffcb 100644 ---- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c -+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c -@@ -13,7 +13,6 @@ - #include - #include - #include --#include - #include "inv_mpu_iio.h" - - /** -@@ -121,7 +120,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) - struct inv_mpu6050_state *st = iio_priv(indio_dev); - size_t bytes_per_datum; - int result; -- u8 data[INV_MPU6050_OUTPUT_DATA_SIZE]; - u16 fifo_count; - s64 timestamp; - int int_status; -@@ -160,11 +158,11 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) - * read fifo_count register to know how many bytes are inside the FIFO - * right now - */ -- result = regmap_bulk_read(st->map, st->reg->fifo_count_h, data, -- INV_MPU6050_FIFO_COUNT_BYTE); -+ result = regmap_bulk_read(st->map, st->reg->fifo_count_h, -+ st->data, INV_MPU6050_FIFO_COUNT_BYTE); - if (result) - goto end_session; -- fifo_count = get_unaligned_be16(&data[0]); -+ fifo_count = be16_to_cpup((__be16 *)&st->data[0]); - - /* - * Handle fifo overflow by resetting fifo. -@@ -182,7 +180,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) - inv_mpu6050_update_period(st, pf->timestamp, nb); - for (i = 0; i < nb; ++i) { - result = regmap_bulk_read(st->map, st->reg->fifo_r_w, -- data, bytes_per_datum); -+ st->data, bytes_per_datum); - if (result) - goto flush_fifo; - /* skip first samples if needed */ -@@ -191,7 +189,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) - continue; - } - timestamp = inv_mpu6050_get_timestamp(st); -- iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); -+ iio_push_to_buffers_with_timestamp(indio_dev, st->data, timestamp); - } - - end_session: -diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h -index d80ba2e688ed0..9275346a9cc1e 100644 ---- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h -+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h -@@ -383,6 +383,7 @@ struct st_lsm6dsx_sensor { - * @iio_devs: Pointers to acc/gyro iio_dev instances. - * @settings: Pointer to the specific sensor settings in use. - * @orientation: sensor chip orientation relative to main hardware. -+ * @scan: Temporary buffers used to align data before iio_push_to_buffers() - */ - struct st_lsm6dsx_hw { - struct device *dev; -@@ -411,6 +412,11 @@ struct st_lsm6dsx_hw { - const struct st_lsm6dsx_settings *settings; - - struct iio_mount_matrix orientation; -+ /* Ensure natural alignment of buffer elements */ -+ struct { -+ __le16 channels[3]; -+ s64 ts __aligned(8); -+ } scan[3]; - }; - - static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = { -diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c -index 7de10bd636ea0..12ed0a2e55e46 100644 ---- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c -+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c -@@ -353,9 +353,6 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) - int err, sip, acc_sip, gyro_sip, ts_sip, ext_sip, read_len, offset; - u16 fifo_len, pattern_len = hw->sip * ST_LSM6DSX_SAMPLE_SIZE; - u16 fifo_diff_mask = hw->settings->fifo_ops.fifo_diff.mask; -- u8 gyro_buff[ST_LSM6DSX_IIO_BUFF_SIZE]; -- u8 acc_buff[ST_LSM6DSX_IIO_BUFF_SIZE]; -- u8 ext_buff[ST_LSM6DSX_IIO_BUFF_SIZE]; - bool reset_ts = false; - __le16 fifo_status; - s64 ts = 0; -@@ -416,19 +413,22 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) - - while (acc_sip > 0 || gyro_sip > 0 || ext_sip > 0) { - if (gyro_sip > 0 && !(sip % gyro_sensor->decimator)) { -- memcpy(gyro_buff, &hw->buff[offset], -- ST_LSM6DSX_SAMPLE_SIZE); -- offset += ST_LSM6DSX_SAMPLE_SIZE; -+ memcpy(hw->scan[ST_LSM6DSX_ID_GYRO].channels, -+ &hw->buff[offset], -+ sizeof(hw->scan[ST_LSM6DSX_ID_GYRO].channels)); -+ offset += sizeof(hw->scan[ST_LSM6DSX_ID_GYRO].channels); - } - if (acc_sip > 0 && !(sip % acc_sensor->decimator)) { -- memcpy(acc_buff, &hw->buff[offset], -- ST_LSM6DSX_SAMPLE_SIZE); -- offset += ST_LSM6DSX_SAMPLE_SIZE; -+ memcpy(hw->scan[ST_LSM6DSX_ID_ACC].channels, -+ &hw->buff[offset], -+ sizeof(hw->scan[ST_LSM6DSX_ID_ACC].channels)); -+ offset += sizeof(hw->scan[ST_LSM6DSX_ID_ACC].channels); - } - if (ext_sip > 0 && !(sip % ext_sensor->decimator)) { -- memcpy(ext_buff, &hw->buff[offset], -- ST_LSM6DSX_SAMPLE_SIZE); -- offset += ST_LSM6DSX_SAMPLE_SIZE; -+ memcpy(hw->scan[ST_LSM6DSX_ID_EXT0].channels, -+ &hw->buff[offset], -+ sizeof(hw->scan[ST_LSM6DSX_ID_EXT0].channels)); -+ offset += sizeof(hw->scan[ST_LSM6DSX_ID_EXT0].channels); - } - - if (ts_sip-- > 0) { -@@ -458,19 +458,22 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) - if (gyro_sip > 0 && !(sip % gyro_sensor->decimator)) { - iio_push_to_buffers_with_timestamp( - hw->iio_devs[ST_LSM6DSX_ID_GYRO], -- gyro_buff, gyro_sensor->ts_ref + ts); -+ &hw->scan[ST_LSM6DSX_ID_GYRO], -+ gyro_sensor->ts_ref + ts); - gyro_sip--; - } - if (acc_sip > 0 && !(sip % acc_sensor->decimator)) { - iio_push_to_buffers_with_timestamp( - hw->iio_devs[ST_LSM6DSX_ID_ACC], -- acc_buff, acc_sensor->ts_ref + ts); -+ &hw->scan[ST_LSM6DSX_ID_ACC], -+ acc_sensor->ts_ref + ts); - acc_sip--; - } - if (ext_sip > 0 && !(sip % ext_sensor->decimator)) { - iio_push_to_buffers_with_timestamp( - hw->iio_devs[ST_LSM6DSX_ID_EXT0], -- ext_buff, ext_sensor->ts_ref + ts); -+ &hw->scan[ST_LSM6DSX_ID_EXT0], -+ ext_sensor->ts_ref + ts); - ext_sip--; - } - sip++; -@@ -555,7 +558,14 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw) - { - u16 pattern_len = hw->sip * ST_LSM6DSX_TAGGED_SAMPLE_SIZE; - u16 fifo_len, fifo_diff_mask; -- u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE], tag; -+ /* -+ * Alignment needed as this can ultimately be passed to a -+ * call to iio_push_to_buffers_with_timestamp() which -+ * must be passed a buffer that is aligned to 8 bytes so -+ * as to allow insertion of a naturally aligned timestamp. -+ */ -+ u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE] __aligned(8); -+ u8 tag; - bool reset_ts = false; - int i, err, read_len; - __le16 fifo_status; -diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c -index ed83471dc7ddf..8c8d8870ca075 100644 ---- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c -+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c -@@ -313,6 +313,8 @@ st_lsm6dsx_shub_read(struct st_lsm6dsx_sensor *sensor, u8 addr, - - err = st_lsm6dsx_shub_read_output(hw, data, - len & ST_LS6DSX_READ_OP_MASK); -+ if (err < 0) -+ return err; - - st_lsm6dsx_shub_master_enable(sensor, false); - -diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c -index 8f5f857c2e7d9..b304801c79163 100644 ---- a/drivers/iio/light/si1145.c -+++ b/drivers/iio/light/si1145.c -@@ -168,6 +168,7 @@ struct si1145_part_info { - * @part_info: Part information - * @trig: Pointer to iio trigger - * @meas_rate: Value of MEAS_RATE register. Only set in HW in auto mode -+ * @buffer: Used to pack data read from sensor. - */ - struct si1145_data { - struct i2c_client *client; -@@ -179,6 +180,14 @@ struct si1145_data { - bool autonomous; - struct iio_trigger *trig; - int meas_rate; -+ /* -+ * Ensure timestamp will be naturally aligned if present. -+ * Maximum buffer size (may be only partly used if not all -+ * channels are enabled): -+ * 6*2 bytes channels data + 4 bytes alignment + -+ * 8 bytes timestamp -+ */ -+ u8 buffer[24] __aligned(8); - }; - - /* -@@ -440,12 +449,6 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private) - struct iio_poll_func *pf = private; - struct iio_dev *indio_dev = pf->indio_dev; - struct si1145_data *data = iio_priv(indio_dev); -- /* -- * Maximum buffer size: -- * 6*2 bytes channels data + 4 bytes alignment + -- * 8 bytes timestamp -- */ -- u8 buffer[24]; - int i, j = 0; - int ret; - u8 irq_status = 0; -@@ -478,7 +481,7 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private) - - ret = i2c_smbus_read_i2c_block_data_or_emulated( - data->client, indio_dev->channels[i].address, -- sizeof(u16) * run, &buffer[j]); -+ sizeof(u16) * run, &data->buffer[j]); - if (ret < 0) - goto done; - j += run * sizeof(u16); -@@ -493,7 +496,7 @@ static irqreturn_t si1145_trigger_handler(int irq, void *private) - goto done; - } - -- iio_push_to_buffers_with_timestamp(indio_dev, buffer, -+ iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns(indio_dev)); - - done: -diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c -index 55ff28a0f1c74..3b5ba26d7d867 100644 ---- a/drivers/iio/temperature/ltc2983.c -+++ b/drivers/iio/temperature/ltc2983.c -@@ -1285,18 +1285,20 @@ static int ltc2983_parse_dt(struct ltc2983_data *st) - ret = of_property_read_u32(child, "reg", &sensor.chan); - if (ret) { - dev_err(dev, "reg property must given for child nodes\n"); -- return ret; -+ goto put_child; - } - - /* check if we have a valid channel */ - if (sensor.chan < LTC2983_MIN_CHANNELS_NR || - sensor.chan > LTC2983_MAX_CHANNELS_NR) { -+ ret = -EINVAL; - dev_err(dev, - "chan:%d must be from 1 to 20\n", sensor.chan); -- return -EINVAL; -+ goto put_child; - } else if (channel_avail_mask & BIT(sensor.chan)) { -+ ret = -EINVAL; - dev_err(dev, "chan:%d already in use\n", sensor.chan); -- return -EINVAL; -+ goto put_child; - } - - ret = of_property_read_u32(child, "adi,sensor-type", -@@ -1304,7 +1306,7 @@ static int ltc2983_parse_dt(struct ltc2983_data *st) - if (ret) { - dev_err(dev, - "adi,sensor-type property must given for child nodes\n"); -- return ret; -+ goto put_child; - } - - dev_dbg(dev, "Create new sensor, type %u, chann %u", -@@ -1334,13 +1336,15 @@ static int ltc2983_parse_dt(struct ltc2983_data *st) - st->sensors[chan] = ltc2983_adc_new(child, st, &sensor); - } else { - dev_err(dev, "Unknown sensor type %d\n", sensor.type); -- return -EINVAL; -+ ret = -EINVAL; -+ goto put_child; - } - - if (IS_ERR(st->sensors[chan])) { - dev_err(dev, "Failed to create sensor %ld", - PTR_ERR(st->sensors[chan])); -- return PTR_ERR(st->sensors[chan]); -+ ret = PTR_ERR(st->sensors[chan]); -+ goto put_child; - } - /* set generic sensor parameters */ - st->sensors[chan]->chan = sensor.chan; -@@ -1351,6 +1355,9 @@ static int ltc2983_parse_dt(struct ltc2983_data *st) - } - - return 0; -+put_child: -+ of_node_put(child); -+ return ret; - } - - static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio) -diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c -index 6d3ed7c6e19eb..3962da54ffbf4 100644 ---- a/drivers/infiniband/core/rdma_core.c -+++ b/drivers/infiniband/core/rdma_core.c -@@ -130,17 +130,6 @@ static int uverbs_destroy_uobject(struct ib_uobject *uobj, - lockdep_assert_held(&ufile->hw_destroy_rwsem); - assert_uverbs_usecnt(uobj, UVERBS_LOOKUP_WRITE); - -- if (reason == RDMA_REMOVE_ABORT_HWOBJ) { -- reason = RDMA_REMOVE_ABORT; -- ret = uobj->uapi_object->type_class->destroy_hw(uobj, reason, -- attrs); -- /* -- * Drivers are not permitted to ignore RDMA_REMOVE_ABORT, see -- * ib_is_destroy_retryable, cleanup_retryable == false here. -- */ -- WARN_ON(ret); -- } -- - if (reason == RDMA_REMOVE_ABORT) { - WARN_ON(!list_empty(&uobj->list)); - WARN_ON(!uobj->context); -@@ -674,11 +663,22 @@ void rdma_alloc_abort_uobject(struct ib_uobject *uobj, - bool hw_obj_valid) - { - struct ib_uverbs_file *ufile = uobj->ufile; -+ int ret; -+ -+ if (hw_obj_valid) { -+ ret = uobj->uapi_object->type_class->destroy_hw( -+ uobj, RDMA_REMOVE_ABORT, attrs); -+ /* -+ * If the driver couldn't destroy the object then go ahead and -+ * commit it. Leaking objects that can't be destroyed is only -+ * done during FD close after the driver has a few more tries to -+ * destroy it. -+ */ -+ if (WARN_ON(ret)) -+ return rdma_alloc_commit_uobject(uobj, attrs); -+ } - -- uverbs_destroy_uobject(uobj, -- hw_obj_valid ? RDMA_REMOVE_ABORT_HWOBJ : -- RDMA_REMOVE_ABORT, -- attrs); -+ uverbs_destroy_uobject(uobj, RDMA_REMOVE_ABORT, attrs); - - /* Matches the down_read in rdma_alloc_begin_uobject */ - up_read(&ufile->hw_destroy_rwsem); -diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c -index b805cc8124657..2a7b5ffb2a2ef 100644 ---- a/drivers/infiniband/hw/mlx5/main.c -+++ b/drivers/infiniband/hw/mlx5/main.c -@@ -3318,7 +3318,8 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num) - int err; - - dev->port[port_num].roce.nb.notifier_call = mlx5_netdev_event; -- err = register_netdevice_notifier(&dev->port[port_num].roce.nb); -+ err = register_netdevice_notifier_net(mlx5_core_net(dev->mdev), -+ &dev->port[port_num].roce.nb); - if (err) { - dev->port[port_num].roce.nb.notifier_call = NULL; - return err; -@@ -3330,7 +3331,8 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num) - static void mlx5_remove_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num) - { - if (dev->port[port_num].roce.nb.notifier_call) { -- unregister_netdevice_notifier(&dev->port[port_num].roce.nb); -+ unregister_netdevice_notifier_net(mlx5_core_net(dev->mdev), -+ &dev->port[port_num].roce.nb); - dev->port[port_num].roce.nb.notifier_call = NULL; - } - } -diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c b/drivers/infiniband/hw/qedr/qedr_iw_cm.c -index c7169d2c69e5b..c4bc58736e489 100644 ---- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c -+++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c -@@ -727,6 +727,7 @@ int qedr_iw_destroy_listen(struct iw_cm_id *cm_id) - listener->qed_handle); - - cm_id->rem_ref(cm_id); -+ kfree(listener); - return rc; - } - -diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c -index 65f4e9d62a67d..d36e89d6fc546 100644 ---- a/drivers/input/serio/hil_mlc.c -+++ b/drivers/input/serio/hil_mlc.c -@@ -74,7 +74,7 @@ EXPORT_SYMBOL(hil_mlc_unregister); - static LIST_HEAD(hil_mlcs); - static DEFINE_RWLOCK(hil_mlcs_lock); - static struct timer_list hil_mlcs_kicker; --static int hil_mlcs_probe; -+static int hil_mlcs_probe, hil_mlc_stop; - - static void hil_mlcs_process(unsigned long unused); - static DECLARE_TASKLET_DISABLED_OLD(hil_mlcs_tasklet, hil_mlcs_process); -@@ -702,9 +702,13 @@ static int hilse_donode(hil_mlc *mlc) - if (!mlc->ostarted) { - mlc->ostarted = 1; - mlc->opacket = pack; -- mlc->out(mlc); -+ rc = mlc->out(mlc); - nextidx = HILSEN_DOZE; - write_unlock_irqrestore(&mlc->lock, flags); -+ if (rc) { -+ hil_mlc_stop = 1; -+ return 1; -+ } - break; - } - mlc->ostarted = 0; -@@ -715,8 +719,13 @@ static int hilse_donode(hil_mlc *mlc) - - case HILSE_CTS: - write_lock_irqsave(&mlc->lock, flags); -- nextidx = mlc->cts(mlc) ? node->bad : node->good; -+ rc = mlc->cts(mlc); -+ nextidx = rc ? node->bad : node->good; - write_unlock_irqrestore(&mlc->lock, flags); -+ if (rc) { -+ hil_mlc_stop = 1; -+ return 1; -+ } - break; - - default: -@@ -780,6 +789,12 @@ static void hil_mlcs_process(unsigned long unused) - - static void hil_mlcs_timer(struct timer_list *unused) - { -+ if (hil_mlc_stop) { -+ /* could not send packet - stop immediately. */ -+ pr_warn(PREFIX "HIL seems stuck - Disabling HIL MLC.\n"); -+ return; -+ } -+ - hil_mlcs_probe = 1; - tasklet_schedule(&hil_mlcs_tasklet); - /* Re-insert the periodic task. */ -diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c -index 232d30c825bd1..3e85e90393746 100644 ---- a/drivers/input/serio/hp_sdc_mlc.c -+++ b/drivers/input/serio/hp_sdc_mlc.c -@@ -210,7 +210,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc) - priv->tseq[2] = 1; - priv->tseq[3] = 0; - priv->tseq[4] = 0; -- __hp_sdc_enqueue_transaction(&priv->trans); -+ return __hp_sdc_enqueue_transaction(&priv->trans); - busy: - return 1; - done: -@@ -219,7 +219,7 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc) - return 0; - } - --static void hp_sdc_mlc_out(hil_mlc *mlc) -+static int hp_sdc_mlc_out(hil_mlc *mlc) - { - struct hp_sdc_mlc_priv_s *priv; - -@@ -234,7 +234,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc) - do_data: - if (priv->emtestmode) { - up(&mlc->osem); -- return; -+ return 0; - } - /* Shouldn't be sending commands when loop may be busy */ - BUG_ON(down_trylock(&mlc->csem)); -@@ -296,7 +296,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc) - BUG_ON(down_trylock(&mlc->csem)); - } - enqueue: -- hp_sdc_enqueue_transaction(&priv->trans); -+ return hp_sdc_enqueue_transaction(&priv->trans); - } - - static int __init hp_sdc_mlc_init(void) -diff --git a/drivers/interconnect/qcom/sdm845.c b/drivers/interconnect/qcom/sdm845.c -index f6c7b969520d0..86f08c0f4c41b 100644 ---- a/drivers/interconnect/qcom/sdm845.c -+++ b/drivers/interconnect/qcom/sdm845.c -@@ -151,7 +151,7 @@ DEFINE_QBCM(bcm_mc0, "MC0", true, &ebi); - DEFINE_QBCM(bcm_sh0, "SH0", true, &qns_llcc); - DEFINE_QBCM(bcm_mm0, "MM0", false, &qns_mem_noc_hf); - DEFINE_QBCM(bcm_sh1, "SH1", false, &qns_apps_io); --DEFINE_QBCM(bcm_mm1, "MM1", false, &qxm_camnoc_hf0_uncomp, &qxm_camnoc_hf1_uncomp, &qxm_camnoc_sf_uncomp, &qxm_camnoc_hf0, &qxm_camnoc_hf1, &qxm_mdp0, &qxm_mdp1); -+DEFINE_QBCM(bcm_mm1, "MM1", true, &qxm_camnoc_hf0_uncomp, &qxm_camnoc_hf1_uncomp, &qxm_camnoc_sf_uncomp, &qxm_camnoc_hf0, &qxm_camnoc_hf1, &qxm_mdp0, &qxm_mdp1); - DEFINE_QBCM(bcm_sh2, "SH2", false, &qns_memnoc_snoc); - DEFINE_QBCM(bcm_mm2, "MM2", false, &qns2_mem_noc); - DEFINE_QBCM(bcm_sh3, "SH3", false, &acm_tcu); -diff --git a/drivers/irqchip/irq-loongson-htvec.c b/drivers/irqchip/irq-loongson-htvec.c -index 13e6016fe4646..6392aafb9a631 100644 ---- a/drivers/irqchip/irq-loongson-htvec.c -+++ b/drivers/irqchip/irq-loongson-htvec.c -@@ -151,7 +151,7 @@ static void htvec_reset(struct htvec *priv) - /* Clear IRQ cause registers, mask all interrupts */ - for (idx = 0; idx < priv->num_parents; idx++) { - writel_relaxed(0x0, priv->base + HTVEC_EN_OFF + 4 * idx); -- writel_relaxed(0xFFFFFFFF, priv->base); -+ writel_relaxed(0xFFFFFFFF, priv->base + 4 * idx); - } - } - -@@ -172,7 +172,7 @@ static int htvec_of_init(struct device_node *node, - goto free_priv; - } - -- /* Interrupt may come from any of the 4 interrupt line */ -+ /* Interrupt may come from any of the 8 interrupt lines */ - for (i = 0; i < HTVEC_MAX_PARENT_IRQ; i++) { - parent_irq[i] = irq_of_parse_and_map(node, i); - if (parent_irq[i] <= 0) -diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c -index bad7efb751120..df385c1d8a22b 100644 ---- a/drivers/leds/leds-bcm6328.c -+++ b/drivers/leds/leds-bcm6328.c -@@ -383,7 +383,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, - led->cdev.brightness_set = bcm6328_led_set; - led->cdev.blink_set = bcm6328_blink_set; - -- rc = led_classdev_register(dev, &led->cdev); -+ rc = devm_led_classdev_register(dev, &led->cdev); - if (rc < 0) - return rc; - -diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c -index 94fefd456ba07..80145f9d7c146 100644 ---- a/drivers/leds/leds-bcm6358.c -+++ b/drivers/leds/leds-bcm6358.c -@@ -137,7 +137,7 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, - - led->cdev.brightness_set = bcm6358_led_set; - -- rc = led_classdev_register(dev, &led->cdev); -+ rc = devm_led_classdev_register(dev, &led->cdev); - if (rc < 0) - return rc; - -diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c -index c61ab86a28b52..d910833feeb4d 100644 ---- a/drivers/md/md-bitmap.c -+++ b/drivers/md/md-bitmap.c -@@ -1367,7 +1367,7 @@ __acquires(bitmap->lock) - if (bitmap->bp[page].hijacked || - bitmap->bp[page].map == NULL) - csize = ((sector_t)1) << (bitmap->chunkshift + -- PAGE_COUNTER_SHIFT - 1); -+ PAGE_COUNTER_SHIFT); - else - csize = ((sector_t)1) << bitmap->chunkshift; - *blocks = csize - (offset & (csize - 1)); -diff --git a/drivers/md/md.c b/drivers/md/md.c -index 6072782070230..cd3c249d8609c 100644 ---- a/drivers/md/md.c -+++ b/drivers/md/md.c -@@ -9545,7 +9545,7 @@ static int __init md_init(void) - goto err_misc_wq; - - md_rdev_misc_wq = alloc_workqueue("md_rdev_misc", 0, 0); -- if (!md_misc_wq) -+ if (!md_rdev_misc_wq) - goto err_rdev_misc_wq; - - if ((ret = register_blkdev(MD_MAJOR, "md")) < 0) -diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c -index 225380efd1e24..4839f41f0ada7 100644 ---- a/drivers/md/raid5.c -+++ b/drivers/md/raid5.c -@@ -2429,8 +2429,6 @@ static int resize_stripes(struct r5conf *conf, int newsize) - } else - err = -ENOMEM; - -- mutex_unlock(&conf->cache_size_mutex); -- - conf->slab_cache = sc; - conf->active_name = 1-conf->active_name; - -@@ -2453,6 +2451,8 @@ static int resize_stripes(struct r5conf *conf, int newsize) - - if (!err) - conf->pool_size = newsize; -+ mutex_unlock(&conf->cache_size_mutex); -+ - return err; - } - -diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c -index 6011cec5e351d..e6aa9f32b6a83 100644 ---- a/drivers/media/i2c/imx274.c -+++ b/drivers/media/i2c/imx274.c -@@ -1235,6 +1235,8 @@ static int imx274_s_frame_interval(struct v4l2_subdev *sd, - ret = imx274_set_frame_interval(imx274, fi->interval); - - if (!ret) { -+ fi->interval = imx274->frame_interval; -+ - /* - * exposure time range is decided by frame interval - * need to update it after frame interval changes -@@ -1730,9 +1732,9 @@ static int imx274_set_frame_interval(struct stimx274 *priv, - __func__, frame_interval.numerator, - frame_interval.denominator); - -- if (frame_interval.numerator == 0) { -- err = -EINVAL; -- goto fail; -+ if (frame_interval.numerator == 0 || frame_interval.denominator == 0) { -+ frame_interval.denominator = IMX274_DEF_FRAME_RATE; -+ frame_interval.numerator = 1; - } - - req_frame_rate = (u32)(frame_interval.denominator -diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c -index ec1e06da7e4fb..a65114e7ca346 100644 ---- a/drivers/media/pci/tw5864/tw5864-video.c -+++ b/drivers/media/pci/tw5864/tw5864-video.c -@@ -767,6 +767,9 @@ static int tw5864_enum_frameintervals(struct file *file, void *priv, - fintv->type = V4L2_FRMIVAL_TYPE_STEPWISE; - - ret = tw5864_frameinterval_get(input, &frameinterval); -+ if (ret) -+ return ret; -+ - fintv->stepwise.step = frameinterval; - fintv->stepwise.min = frameinterval; - fintv->stepwise.max = frameinterval; -@@ -785,6 +788,9 @@ static int tw5864_g_parm(struct file *file, void *priv, - cp->capability = V4L2_CAP_TIMEPERFRAME; - - ret = tw5864_frameinterval_get(input, &cp->timeperframe); -+ if (ret) -+ return ret; -+ - cp->timeperframe.numerator *= input->frame_interval; - cp->capturemode = 0; - cp->readbuffers = 2; -diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c -index 61fed1e35a005..b1ca4e3adae32 100644 ---- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c -+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c -@@ -571,6 +571,13 @@ static int mtk_jpeg_queue_setup(struct vb2_queue *q, - if (!q_data) - return -EINVAL; - -+ if (*num_planes) { -+ for (i = 0; i < *num_planes; i++) -+ if (sizes[i] < q_data->sizeimage[i]) -+ return -EINVAL; -+ return 0; -+ } -+ - *num_planes = q_data->fmt->colplanes; - for (i = 0; i < q_data->fmt->colplanes; i++) { - sizes[i] = q_data->sizeimage[i]; -diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c -index a30a8a731eda8..36abe47997b01 100644 ---- a/drivers/media/usb/uvc/uvc_ctrl.c -+++ b/drivers/media/usb/uvc/uvc_ctrl.c -@@ -1848,30 +1848,35 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain, - { - struct uvc_entity *entity; - struct uvc_control *ctrl; -- unsigned int i, found = 0; -+ unsigned int i; -+ bool found; - u32 reqflags; - u16 size; - u8 *data = NULL; - int ret; - - /* Find the extension unit. */ -+ found = false; - list_for_each_entry(entity, &chain->entities, chain) { - if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT && -- entity->id == xqry->unit) -+ entity->id == xqry->unit) { -+ found = true; - break; -+ } - } - -- if (entity->id != xqry->unit) { -+ if (!found) { - uvc_trace(UVC_TRACE_CONTROL, "Extension unit %u not found.\n", - xqry->unit); - return -ENOENT; - } - - /* Find the control and perform delayed initialization if needed. */ -+ found = false; - for (i = 0; i < entity->ncontrols; ++i) { - ctrl = &entity->controls[i]; - if (ctrl->index == xqry->selector - 1) { -- found = 1; -+ found = true; - break; - } - } -@@ -2028,13 +2033,6 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, - goto done; - } - -- /* -- * Retrieve control flags from the device. Ignore errors and work with -- * default flag values from the uvc_ctrl array when the device doesn't -- * properly implement GET_INFO on standard controls. -- */ -- uvc_ctrl_get_flags(dev, ctrl, &ctrl->info); -- - ctrl->initialized = 1; - - uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s " -@@ -2257,6 +2255,13 @@ static void uvc_ctrl_init_ctrl(struct uvc_device *dev, struct uvc_control *ctrl) - if (uvc_entity_match_guid(ctrl->entity, info->entity) && - ctrl->index == info->index) { - uvc_ctrl_add_info(dev, ctrl, info); -+ /* -+ * Retrieve control flags from the device. Ignore errors -+ * and work with default flag values from the uvc_ctrl -+ * array when the device doesn't properly implement -+ * GET_INFO on standard controls. -+ */ -+ uvc_ctrl_get_flags(dev, ctrl, &ctrl->info); - break; - } - } -diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c -index ddff687c79eaa..dcf50bb8dd690 100644 ---- a/drivers/memory/brcmstb_dpfe.c -+++ b/drivers/memory/brcmstb_dpfe.c -@@ -656,8 +656,10 @@ static int brcmstb_dpfe_download_firmware(struct brcmstb_dpfe_priv *priv) - return (ret == -ENOENT) ? -EPROBE_DEFER : ret; - - ret = __verify_firmware(&init, fw); -- if (ret) -- return -EFAULT; -+ if (ret) { -+ ret = -EFAULT; -+ goto release_fw; -+ } - - __disable_dcpu(priv); - -@@ -676,18 +678,20 @@ static int brcmstb_dpfe_download_firmware(struct brcmstb_dpfe_priv *priv) - - ret = __write_firmware(priv->dmem, dmem, dmem_size, is_big_endian); - if (ret) -- return ret; -+ goto release_fw; - ret = __write_firmware(priv->imem, imem, imem_size, is_big_endian); - if (ret) -- return ret; -+ goto release_fw; - - ret = __verify_fw_checksum(&init, priv, header, init.chksum); - if (ret) -- return ret; -+ goto release_fw; - - __enable_dcpu(priv); - -- return 0; -+release_fw: -+ release_firmware(fw); -+ return ret; - } - - static ssize_t generic_show(unsigned int command, u32 response[], -diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c -index bb6a71d267988..5c4d8319c9cfb 100644 ---- a/drivers/memory/emif.c -+++ b/drivers/memory/emif.c -@@ -163,35 +163,12 @@ static const struct file_operations emif_mr4_fops = { - - static int __init_or_module emif_debugfs_init(struct emif_data *emif) - { -- struct dentry *dentry; -- int ret; -- -- dentry = debugfs_create_dir(dev_name(emif->dev), NULL); -- if (!dentry) { -- ret = -ENOMEM; -- goto err0; -- } -- emif->debugfs_root = dentry; -- -- dentry = debugfs_create_file("regcache_dump", S_IRUGO, -- emif->debugfs_root, emif, &emif_regdump_fops); -- if (!dentry) { -- ret = -ENOMEM; -- goto err1; -- } -- -- dentry = debugfs_create_file("mr4", S_IRUGO, -- emif->debugfs_root, emif, &emif_mr4_fops); -- if (!dentry) { -- ret = -ENOMEM; -- goto err1; -- } -- -+ emif->debugfs_root = debugfs_create_dir(dev_name(emif->dev), NULL); -+ debugfs_create_file("regcache_dump", S_IRUGO, emif->debugfs_root, emif, -+ &emif_regdump_fops); -+ debugfs_create_file("mr4", S_IRUGO, emif->debugfs_root, emif, -+ &emif_mr4_fops); - return 0; --err1: -- debugfs_remove_recursive(emif->debugfs_root); --err0: -- return ret; - } - - static void __exit emif_debugfs_exit(struct emif_data *emif) -diff --git a/drivers/memory/tegra/tegra124.c b/drivers/memory/tegra/tegra124.c -index 493b5dc3a4b38..0cede24479bfa 100644 ---- a/drivers/memory/tegra/tegra124.c -+++ b/drivers/memory/tegra/tegra124.c -@@ -957,7 +957,6 @@ static const struct tegra_smmu_swgroup tegra124_swgroups[] = { - static const unsigned int tegra124_group_drm[] = { - TEGRA_SWGROUP_DC, - TEGRA_SWGROUP_DCB, -- TEGRA_SWGROUP_GPU, - TEGRA_SWGROUP_VIC, - }; - -diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c -index 8543f0324d5a8..0d1b2b0eb8439 100644 ---- a/drivers/message/fusion/mptscsih.c -+++ b/drivers/message/fusion/mptscsih.c -@@ -1176,8 +1176,10 @@ mptscsih_remove(struct pci_dev *pdev) - MPT_SCSI_HOST *hd; - int sz1; - -- if((hd = shost_priv(host)) == NULL) -- return; -+ if (host == NULL) -+ hd = NULL; -+ else -+ hd = shost_priv(host); - - mptscsih_shutdown(pdev); - -@@ -1193,14 +1195,15 @@ mptscsih_remove(struct pci_dev *pdev) - "Free'd ScsiLookup (%d) memory\n", - ioc->name, sz1)); - -- kfree(hd->info_kbuf); -+ if (hd) -+ kfree(hd->info_kbuf); - - /* NULL the Scsi_Host pointer - */ - ioc->sh = NULL; - -- scsi_host_put(host); -- -+ if (host) -+ scsi_host_put(host); - mpt_detach(pdev); - - } -diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c -index 7939c55daceb2..9d68677493163 100644 ---- a/drivers/misc/fastrpc.c -+++ b/drivers/misc/fastrpc.c -@@ -518,7 +518,7 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment, - - table = &a->sgt; - -- if (!dma_map_sg(attachment->dev, table->sgl, table->nents, dir)) -+ if (!dma_map_sgtable(attachment->dev, table, dir, 0)) - return ERR_PTR(-ENOMEM); - - return table; -@@ -528,7 +528,7 @@ static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach, - struct sg_table *table, - enum dma_data_direction dir) - { -- dma_unmap_sg(attach->dev, table->sgl, table->nents, dir); -+ dma_unmap_sgtable(attach->dev, table, dir, 0); - } - - static void fastrpc_release(struct dma_buf *dmabuf) -diff --git a/drivers/misc/habanalabs/gaudi/gaudi_security.c b/drivers/misc/habanalabs/gaudi/gaudi_security.c -index 8d5d6ddee6eda..615b547ad2b7d 100644 ---- a/drivers/misc/habanalabs/gaudi/gaudi_security.c -+++ b/drivers/misc/habanalabs/gaudi/gaudi_security.c -@@ -831,8 +831,7 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmMME0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & - PROT_BITS_OFFS) >> 7) << 2; -- mask = 1 << ((mmMME0_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmMME0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmMME0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmMME0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmMME0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmMME0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -1311,8 +1310,7 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmMME2_QM_ARB_MST_CHOISE_PUSH_OFST_23 & - PROT_BITS_OFFS) >> 7) << 2; -- mask = 1 << ((mmMME2_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmMME2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmMME2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmMME2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmMME2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmMME2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -1790,8 +1788,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA0_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -2186,8 +2183,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA1_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA1_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA1_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA1_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA1_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -2582,8 +2578,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA2_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA2_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -2978,8 +2973,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA3_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA3_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA3_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA3_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA3_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -3374,8 +3368,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA4_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA4_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA4_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA4_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA4_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -3770,8 +3763,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA5_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA5_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA5_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA5_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA5_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -4166,8 +4158,8 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA6_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA6_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ -+ mask = 1 << ((mmDMA6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA6_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA6_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA6_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -4562,8 +4554,7 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev) - word_offset = - ((mmDMA7_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7) - << 2; -- mask = 1 << ((mmDMA7_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmDMA7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmDMA7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmDMA7_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmDMA7_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmDMA7_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -5491,8 +5482,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - - word_offset = ((mmTPC0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC0_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -5947,8 +5937,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - - word_offset = ((mmTPC1_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC1_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC1_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC1_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC1_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -6402,8 +6391,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmTPC2_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC2_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -6857,8 +6845,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmTPC3_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC3_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC3_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC3_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC3_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -7312,8 +7299,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmTPC4_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC4_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC4_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC4_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC4_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -7767,8 +7753,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmTPC5_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC5_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC5_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC5_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC5_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -8223,8 +8208,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - - word_offset = ((mmTPC6_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC6_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC6_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC6_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC6_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -@@ -8681,8 +8665,7 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev) - PROT_BITS_OFFS; - word_offset = ((mmTPC7_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) - >> 7) << 2; -- mask = 1 << ((mmTPC7_QM_ARB_MST_QUIET_PER & 0x7F) >> 2); -- mask |= 1 << ((mmTPC7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); -+ mask = 1 << ((mmTPC7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2); - mask |= 1 << ((mmTPC7_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2); - mask |= 1 << ((mmTPC7_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2); - mask |= 1 << ((mmTPC7_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2); -diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c -index 284cba11e2795..d335a34ad05b3 100644 ---- a/drivers/mmc/host/sdhci-acpi.c -+++ b/drivers/mmc/host/sdhci-acpi.c -@@ -662,6 +662,43 @@ static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev, - (host->mmc->caps & MMC_CAP_1_8V_DDR)) - host->mmc->caps2 = MMC_CAP2_HS400_1_8V; - -+ /* -+ * There are two types of presets out in the wild: -+ * 1) Default/broken presets. -+ * These presets have two sets of problems: -+ * a) The clock divisor for SDR12, SDR25, and SDR50 is too small. -+ * This results in clock frequencies that are 2x higher than -+ * acceptable. i.e., SDR12 = 25 MHz, SDR25 = 50 MHz, SDR50 = -+ * 100 MHz.x -+ * b) The HS200 and HS400 driver strengths don't match. -+ * By default, the SDR104 preset register has a driver strength of -+ * A, but the (internal) HS400 preset register has a driver -+ * strength of B. As part of initializing HS400, HS200 tuning -+ * needs to be performed. Having different driver strengths -+ * between tuning and operation is wrong. It results in different -+ * rise/fall times that lead to incorrect sampling. -+ * 2) Firmware with properly initialized presets. -+ * These presets have proper clock divisors. i.e., SDR12 => 12MHz, -+ * SDR25 => 25 MHz, SDR50 => 50 MHz. Additionally the HS200 and -+ * HS400 preset driver strengths match. -+ * -+ * Enabling presets for HS400 doesn't work for the following reasons: -+ * 1) sdhci_set_ios has a hard coded list of timings that are used -+ * to determine if presets should be enabled. -+ * 2) sdhci_get_preset_value is using a non-standard register to -+ * read out HS400 presets. The AMD controller doesn't support this -+ * non-standard register. In fact, it doesn't expose the HS400 -+ * preset register anywhere in the SDHCI memory map. This results -+ * in reading a garbage value and using the wrong presets. -+ * -+ * Since HS400 and HS200 presets must be identical, we could -+ * instead use the the SDR104 preset register. -+ * -+ * If the above issues are resolved we could remove this quirk for -+ * firmware that that has valid presets (i.e., SDR12 <= 12 MHz). -+ */ -+ host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; -+ - host->mmc_host_ops.select_drive_strength = amd_select_drive_strength; - host->mmc_host_ops.set_ios = amd_set_ios; - host->mmc_host_ops.execute_tuning = amd_sdhci_execute_tuning; -diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h -index a30796e79b1cb..6de02f09c3222 100644 ---- a/drivers/mmc/host/sdhci-esdhc.h -+++ b/drivers/mmc/host/sdhci-esdhc.h -@@ -5,6 +5,7 @@ - * Copyright (c) 2007 Freescale Semiconductor, Inc. - * Copyright (c) 2009 MontaVista Software, Inc. - * Copyright (c) 2010 Pengutronix e.K. -+ * Copyright 2020 NXP - * Author: Wolfram Sang - */ - -@@ -88,6 +89,7 @@ - /* DLL Config 0 Register */ - #define ESDHC_DLLCFG0 0x160 - #define ESDHC_DLL_ENABLE 0x80000000 -+#define ESDHC_DLL_RESET 0x40000000 - #define ESDHC_DLL_FREQ_SEL 0x08000000 - - /* DLL Config 1 Register */ -diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c -index 45881b3099567..156e75302df56 100644 ---- a/drivers/mmc/host/sdhci-of-esdhc.c -+++ b/drivers/mmc/host/sdhci-of-esdhc.c -@@ -4,6 +4,7 @@ - * - * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc. - * Copyright (c) 2009 MontaVista Software, Inc. -+ * Copyright 2020 NXP - * - * Authors: Xiaobo Xie - * Anton Vorontsov -@@ -19,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include "sdhci-pltfm.h" -@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock) - if (host->mmc->actual_clock == MMC_HS200_MAX_DTR) - temp |= ESDHC_DLL_FREQ_SEL; - sdhci_writel(host, temp, ESDHC_DLLCFG0); -+ -+ temp |= ESDHC_DLL_RESET; -+ sdhci_writel(host, temp, ESDHC_DLLCFG0); -+ udelay(1); -+ temp &= ~ESDHC_DLL_RESET; -+ sdhci_writel(host, temp, ESDHC_DLLCFG0); -+ -+ /* Wait max 20 ms */ -+ if (read_poll_timeout(sdhci_readl, temp, -+ temp & ESDHC_DLL_STS_SLV_LOCK, -+ 10, 20000, false, -+ host, ESDHC_DLLSTAT0)) -+ pr_err("%s: timeout for delay chain lock.\n", -+ mmc_hostname(host->mmc)); -+ - temp = sdhci_readl(host, ESDHC_TBCTL); - sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL); - -@@ -1052,6 +1069,17 @@ static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) - - esdhc_tuning_block_enable(host, true); - -+ /* -+ * The eSDHC controller takes the data timeout value into account -+ * during tuning. If the SD card is too slow sending the response, the -+ * timer will expire and a "Buffer Read Ready" interrupt without data -+ * is triggered. This leads to tuning errors. -+ * -+ * Just set the timeout to the maximum value because the core will -+ * already take care of it in sdhci_send_tuning(). -+ */ -+ sdhci_writeb(host, 0xe, SDHCI_TIMEOUT_CONTROL); -+ - hs400_tuning = host->flags & SDHCI_HS400_TUNING; - - do { -diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c -index 914f5184295ff..23da7f7fe093a 100644 ---- a/drivers/mmc/host/sdhci-pci-core.c -+++ b/drivers/mmc/host/sdhci-pci-core.c -@@ -24,6 +24,8 @@ - #include - #include - #include -+#include -+#include - #include - #include - #include -@@ -516,6 +518,8 @@ struct intel_host { - bool rpm_retune_ok; - u32 glk_rx_ctrl1; - u32 glk_tun_val; -+ u32 active_ltr; -+ u32 idle_ltr; - }; - - static const guid_t intel_dsm_guid = -@@ -760,6 +764,108 @@ static int intel_execute_tuning(struct mmc_host *mmc, u32 opcode) - return 0; - } - -+#define INTEL_ACTIVELTR 0x804 -+#define INTEL_IDLELTR 0x808 -+ -+#define INTEL_LTR_REQ BIT(15) -+#define INTEL_LTR_SCALE_MASK GENMASK(11, 10) -+#define INTEL_LTR_SCALE_1US (2 << 10) -+#define INTEL_LTR_SCALE_32US (3 << 10) -+#define INTEL_LTR_VALUE_MASK GENMASK(9, 0) -+ -+static void intel_cache_ltr(struct sdhci_pci_slot *slot) -+{ -+ struct intel_host *intel_host = sdhci_pci_priv(slot); -+ struct sdhci_host *host = slot->host; -+ -+ intel_host->active_ltr = readl(host->ioaddr + INTEL_ACTIVELTR); -+ intel_host->idle_ltr = readl(host->ioaddr + INTEL_IDLELTR); -+} -+ -+static void intel_ltr_set(struct device *dev, s32 val) -+{ -+ struct sdhci_pci_chip *chip = dev_get_drvdata(dev); -+ struct sdhci_pci_slot *slot = chip->slots[0]; -+ struct intel_host *intel_host = sdhci_pci_priv(slot); -+ struct sdhci_host *host = slot->host; -+ u32 ltr; -+ -+ pm_runtime_get_sync(dev); -+ -+ /* -+ * Program latency tolerance (LTR) accordingly what has been asked -+ * by the PM QoS layer or disable it in case we were passed -+ * negative value or PM_QOS_LATENCY_ANY. -+ */ -+ ltr = readl(host->ioaddr + INTEL_ACTIVELTR); -+ -+ if (val == PM_QOS_LATENCY_ANY || val < 0) { -+ ltr &= ~INTEL_LTR_REQ; -+ } else { -+ ltr |= INTEL_LTR_REQ; -+ ltr &= ~INTEL_LTR_SCALE_MASK; -+ ltr &= ~INTEL_LTR_VALUE_MASK; -+ -+ if (val > INTEL_LTR_VALUE_MASK) { -+ val >>= 5; -+ if (val > INTEL_LTR_VALUE_MASK) -+ val = INTEL_LTR_VALUE_MASK; -+ ltr |= INTEL_LTR_SCALE_32US | val; -+ } else { -+ ltr |= INTEL_LTR_SCALE_1US | val; -+ } -+ } -+ -+ if (ltr == intel_host->active_ltr) -+ goto out; -+ -+ writel(ltr, host->ioaddr + INTEL_ACTIVELTR); -+ writel(ltr, host->ioaddr + INTEL_IDLELTR); -+ -+ /* Cache the values into lpss structure */ -+ intel_cache_ltr(slot); -+out: -+ pm_runtime_put_autosuspend(dev); -+} -+ -+static bool intel_use_ltr(struct sdhci_pci_chip *chip) -+{ -+ switch (chip->pdev->device) { -+ case PCI_DEVICE_ID_INTEL_BYT_EMMC: -+ case PCI_DEVICE_ID_INTEL_BYT_EMMC2: -+ case PCI_DEVICE_ID_INTEL_BYT_SDIO: -+ case PCI_DEVICE_ID_INTEL_BYT_SD: -+ case PCI_DEVICE_ID_INTEL_BSW_EMMC: -+ case PCI_DEVICE_ID_INTEL_BSW_SDIO: -+ case PCI_DEVICE_ID_INTEL_BSW_SD: -+ return false; -+ default: -+ return true; -+ } -+} -+ -+static void intel_ltr_expose(struct sdhci_pci_chip *chip) -+{ -+ struct device *dev = &chip->pdev->dev; -+ -+ if (!intel_use_ltr(chip)) -+ return; -+ -+ dev->power.set_latency_tolerance = intel_ltr_set; -+ dev_pm_qos_expose_latency_tolerance(dev); -+} -+ -+static void intel_ltr_hide(struct sdhci_pci_chip *chip) -+{ -+ struct device *dev = &chip->pdev->dev; -+ -+ if (!intel_use_ltr(chip)) -+ return; -+ -+ dev_pm_qos_hide_latency_tolerance(dev); -+ dev->power.set_latency_tolerance = NULL; -+} -+ - static void byt_probe_slot(struct sdhci_pci_slot *slot) - { - struct mmc_host_ops *ops = &slot->host->mmc_host_ops; -@@ -774,6 +880,43 @@ static void byt_probe_slot(struct sdhci_pci_slot *slot) - ops->start_signal_voltage_switch = intel_start_signal_voltage_switch; - - device_property_read_u32(dev, "max-frequency", &mmc->f_max); -+ -+ if (!mmc->slotno) { -+ slot->chip->slots[mmc->slotno] = slot; -+ intel_ltr_expose(slot->chip); -+ } -+} -+ -+static void byt_add_debugfs(struct sdhci_pci_slot *slot) -+{ -+ struct intel_host *intel_host = sdhci_pci_priv(slot); -+ struct mmc_host *mmc = slot->host->mmc; -+ struct dentry *dir = mmc->debugfs_root; -+ -+ if (!intel_use_ltr(slot->chip)) -+ return; -+ -+ debugfs_create_x32("active_ltr", 0444, dir, &intel_host->active_ltr); -+ debugfs_create_x32("idle_ltr", 0444, dir, &intel_host->idle_ltr); -+ -+ intel_cache_ltr(slot); -+} -+ -+static int byt_add_host(struct sdhci_pci_slot *slot) -+{ -+ int ret = sdhci_add_host(slot->host); -+ -+ if (!ret) -+ byt_add_debugfs(slot); -+ return ret; -+} -+ -+static void byt_remove_slot(struct sdhci_pci_slot *slot, int dead) -+{ -+ struct mmc_host *mmc = slot->host->mmc; -+ -+ if (!mmc->slotno) -+ intel_ltr_hide(slot->chip); - } - - static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot) -@@ -855,6 +998,8 @@ static int glk_emmc_add_host(struct sdhci_pci_slot *slot) - if (ret) - goto cleanup; - -+ byt_add_debugfs(slot); -+ - return 0; - - cleanup: -@@ -1032,6 +1177,8 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { - #endif - .allow_runtime_pm = true, - .probe_slot = byt_emmc_probe_slot, -+ .add_host = byt_add_host, -+ .remove_slot = byt_remove_slot, - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | - SDHCI_QUIRK_NO_LED, - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | -@@ -1045,6 +1192,7 @@ static const struct sdhci_pci_fixes sdhci_intel_glk_emmc = { - .allow_runtime_pm = true, - .probe_slot = glk_emmc_probe_slot, - .add_host = glk_emmc_add_host, -+ .remove_slot = byt_remove_slot, - #ifdef CONFIG_PM_SLEEP - .suspend = sdhci_cqhci_suspend, - .resume = sdhci_cqhci_resume, -@@ -1075,6 +1223,8 @@ static const struct sdhci_pci_fixes sdhci_ni_byt_sdio = { - SDHCI_QUIRK2_PRESET_VALUE_BROKEN, - .allow_runtime_pm = true, - .probe_slot = ni_byt_sdio_probe_slot, -+ .add_host = byt_add_host, -+ .remove_slot = byt_remove_slot, - .ops = &sdhci_intel_byt_ops, - .priv_size = sizeof(struct intel_host), - }; -@@ -1092,6 +1242,8 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = { - SDHCI_QUIRK2_PRESET_VALUE_BROKEN, - .allow_runtime_pm = true, - .probe_slot = byt_sdio_probe_slot, -+ .add_host = byt_add_host, -+ .remove_slot = byt_remove_slot, - .ops = &sdhci_intel_byt_ops, - .priv_size = sizeof(struct intel_host), - }; -@@ -1111,6 +1263,8 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_sd = { - .allow_runtime_pm = true, - .own_cd_for_runtime_pm = true, - .probe_slot = byt_sd_probe_slot, -+ .add_host = byt_add_host, -+ .remove_slot = byt_remove_slot, - .ops = &sdhci_intel_byt_ops, - .priv_size = sizeof(struct intel_host), - }; -diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c -index 592a55a34b58e..3561ae8a481a0 100644 ---- a/drivers/mmc/host/sdhci.c -+++ b/drivers/mmc/host/sdhci.c -@@ -1384,9 +1384,11 @@ static inline void sdhci_auto_cmd_select(struct sdhci_host *host, - /* - * In case of Version 4.10 or later, use of 'Auto CMD Auto - * Select' is recommended rather than use of 'Auto CMD12 -- * Enable' or 'Auto CMD23 Enable'. -+ * Enable' or 'Auto CMD23 Enable'. We require Version 4 Mode -+ * here because some controllers (e.g sdhci-of-dwmshc) expect it. - */ -- if (host->version >= SDHCI_SPEC_410 && (use_cmd12 || use_cmd23)) { -+ if (host->version >= SDHCI_SPEC_410 && host->v4_mode && -+ (use_cmd12 || use_cmd23)) { - *mode |= SDHCI_TRNS_AUTO_SEL; - - ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); -diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c -index 49dab9f42b6d6..9b755ea0fa03c 100644 ---- a/drivers/mmc/host/via-sdmmc.c -+++ b/drivers/mmc/host/via-sdmmc.c -@@ -1257,11 +1257,14 @@ static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host) - static int __maybe_unused via_sd_suspend(struct device *dev) - { - struct via_crdr_mmc_host *host; -+ unsigned long flags; - - host = dev_get_drvdata(dev); - -+ spin_lock_irqsave(&host->lock, flags); - via_save_pcictrlreg(host); - via_save_sdcreg(host); -+ spin_unlock_irqrestore(&host->lock, flags); - - device_wakeup_enable(dev); - -diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c -index 42cac572f82dc..7847de75a74ca 100644 ---- a/drivers/mtd/ubi/wl.c -+++ b/drivers/mtd/ubi/wl.c -@@ -1639,6 +1639,19 @@ int ubi_thread(void *u) - !ubi->thread_enabled || ubi_dbg_is_bgt_disabled(ubi)) { - set_current_state(TASK_INTERRUPTIBLE); - spin_unlock(&ubi->wl_lock); -+ -+ /* -+ * Check kthread_should_stop() after we set the task -+ * state to guarantee that we either see the stop bit -+ * and exit or the task state is reset to runnable such -+ * that it's not scheduled out indefinitely and detects -+ * the stop bit at kthread_should_stop(). -+ */ -+ if (kthread_should_stop()) { -+ set_current_state(TASK_RUNNING); -+ break; -+ } -+ - schedule(); - continue; - } -diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c -index 2ac7a667bde35..bc21a82cf3a76 100644 ---- a/drivers/net/can/flexcan.c -+++ b/drivers/net/can/flexcan.c -@@ -1722,8 +1722,6 @@ static int __maybe_unused flexcan_suspend(struct device *device) - err = flexcan_chip_disable(priv); - if (err) - return err; -- -- err = pm_runtime_force_suspend(device); - } - netif_stop_queue(dev); - netif_device_detach(dev); -@@ -1749,10 +1747,6 @@ static int __maybe_unused flexcan_resume(struct device *device) - if (err) - return err; - } else { -- err = pm_runtime_force_resume(device); -- if (err) -- return err; -- - err = flexcan_chip_enable(priv); - } - } -@@ -1783,8 +1777,16 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device) - struct net_device *dev = dev_get_drvdata(device); - struct flexcan_priv *priv = netdev_priv(dev); - -- if (netif_running(dev) && device_may_wakeup(device)) -- flexcan_enable_wakeup_irq(priv, true); -+ if (netif_running(dev)) { -+ int err; -+ -+ if (device_may_wakeup(device)) -+ flexcan_enable_wakeup_irq(priv, true); -+ -+ err = pm_runtime_force_suspend(device); -+ if (err) -+ return err; -+ } - - return 0; - } -@@ -1794,8 +1796,16 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device) - struct net_device *dev = dev_get_drvdata(device); - struct flexcan_priv *priv = netdev_priv(dev); - -- if (netif_running(dev) && device_may_wakeup(device)) -- flexcan_enable_wakeup_irq(priv, false); -+ if (netif_running(dev)) { -+ int err; -+ -+ err = pm_runtime_force_resume(device); -+ if (err) -+ return err; -+ -+ if (device_may_wakeup(device)) -+ flexcan_enable_wakeup_irq(priv, false); -+ } - - return 0; - } -diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c -index 7b5d521924872..b8d534b719d4f 100644 ---- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c -+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c -@@ -8735,6 +8735,11 @@ static void bnxt_report_link(struct bnxt *bp) - u16 fec; - - netif_carrier_on(bp->dev); -+ speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); -+ if (speed == SPEED_UNKNOWN) { -+ netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); -+ return; -+ } - if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) - duplex = "full"; - else -@@ -8747,7 +8752,6 @@ static void bnxt_report_link(struct bnxt *bp) - flow_ctrl = "ON - receive"; - else - flow_ctrl = "none"; -- speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); - netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s duplex, Flow control: %s\n", - speed, duplex, flow_ctrl); - if (bp->flags & BNXT_FLAG_EEE_CAP) -diff --git a/drivers/net/ethernet/marvell/octeontx2/af/npc.h b/drivers/net/ethernet/marvell/octeontx2/af/npc.h -index 3803af9231c68..c0ff5f70aa431 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/af/npc.h -+++ b/drivers/net/ethernet/marvell/octeontx2/af/npc.h -@@ -77,6 +77,8 @@ enum npc_kpu_ld_ltype { - NPC_LT_LD_ICMP, - NPC_LT_LD_SCTP, - NPC_LT_LD_ICMP6, -+ NPC_LT_LD_CUSTOM0, -+ NPC_LT_LD_CUSTOM1, - NPC_LT_LD_IGMP = 8, - NPC_LT_LD_ESP, - NPC_LT_LD_AH, -@@ -85,8 +87,6 @@ enum npc_kpu_ld_ltype { - NPC_LT_LD_NSH, - NPC_LT_LD_TU_MPLS_IN_NSH, - NPC_LT_LD_TU_MPLS_IN_IP, -- NPC_LT_LD_CUSTOM0 = 0xE, -- NPC_LT_LD_CUSTOM1 = 0xF, - }; - - enum npc_kpu_le_ltype { -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h -index d046db7bb047d..3a9fa629503f0 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h -+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h -@@ -90,9 +90,4 @@ int mlx5_create_encryption_key(struct mlx5_core_dev *mdev, - u32 key_type, u32 *p_key_id); - void mlx5_destroy_encryption_key(struct mlx5_core_dev *mdev, u32 key_id); - --static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev) --{ -- return devlink_net(priv_to_devlink(dev)); --} -- - #endif -diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c -index f6aa80fe343f5..05e90ef15871c 100644 ---- a/drivers/net/ethernet/mellanox/mlxsw/core.c -+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c -@@ -607,6 +607,9 @@ static void mlxsw_emad_transmit_retry(struct mlxsw_core *mlxsw_core, - err = mlxsw_emad_transmit(trans->core, trans); - if (err == 0) - return; -+ -+ if (!atomic_dec_and_test(&trans->active)) -+ return; - } else { - err = -EIO; - } -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c -index 26988ad7ec979..8867d4ac871c1 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c -+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c -@@ -1512,7 +1512,6 @@ static void ionic_txrx_deinit(struct ionic_lif *lif) - if (lif->rxqcqs) { - for (i = 0; i < lif->nxqs; i++) { - ionic_lif_qcq_deinit(lif, lif->rxqcqs[i].qcq); -- ionic_rx_flush(&lif->rxqcqs[i].qcq->cq); - ionic_rx_empty(&lif->rxqcqs[i].qcq->q); - } - } -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c -index def65fee27b5a..39e85870c15e9 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c -+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c -@@ -253,19 +253,6 @@ static bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info) - return true; - } - --void ionic_rx_flush(struct ionic_cq *cq) --{ -- struct ionic_dev *idev = &cq->lif->ionic->idev; -- u32 work_done; -- -- work_done = ionic_cq_service(cq, cq->num_descs, -- ionic_rx_service, NULL, NULL); -- -- if (work_done) -- ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index, -- work_done, IONIC_INTR_CRED_RESET_COALESCE); --} -- - static struct page *ionic_rx_page_alloc(struct ionic_queue *q, - dma_addr_t *dma_addr) - { -diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h -index a5883be0413f6..7667b72232b8a 100644 ---- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h -+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h -@@ -4,7 +4,6 @@ - #ifndef _IONIC_TXRX_H_ - #define _IONIC_TXRX_H_ - --void ionic_rx_flush(struct ionic_cq *cq); - void ionic_tx_flush(struct ionic_cq *cq); - - void ionic_rx_fill(struct ionic_queue *q); -diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c -index d6cfd51613ed8..3a44dad87602d 100644 ---- a/drivers/net/wan/hdlc_fr.c -+++ b/drivers/net/wan/hdlc_fr.c -@@ -273,63 +273,69 @@ static inline struct net_device **get_dev_p(struct pvc_device *pvc, - - static int fr_hard_header(struct sk_buff **skb_p, u16 dlci) - { -- u16 head_len; - struct sk_buff *skb = *skb_p; - -- switch (skb->protocol) { -- case cpu_to_be16(NLPID_CCITT_ANSI_LMI): -- head_len = 4; -- skb_push(skb, head_len); -- skb->data[3] = NLPID_CCITT_ANSI_LMI; -- break; -- -- case cpu_to_be16(NLPID_CISCO_LMI): -- head_len = 4; -- skb_push(skb, head_len); -- skb->data[3] = NLPID_CISCO_LMI; -- break; -- -- case cpu_to_be16(ETH_P_IP): -- head_len = 4; -- skb_push(skb, head_len); -- skb->data[3] = NLPID_IP; -- break; -- -- case cpu_to_be16(ETH_P_IPV6): -- head_len = 4; -- skb_push(skb, head_len); -- skb->data[3] = NLPID_IPV6; -- break; -- -- case cpu_to_be16(ETH_P_802_3): -- head_len = 10; -- if (skb_headroom(skb) < head_len) { -- struct sk_buff *skb2 = skb_realloc_headroom(skb, -- head_len); -+ if (!skb->dev) { /* Control packets */ -+ switch (dlci) { -+ case LMI_CCITT_ANSI_DLCI: -+ skb_push(skb, 4); -+ skb->data[3] = NLPID_CCITT_ANSI_LMI; -+ break; -+ -+ case LMI_CISCO_DLCI: -+ skb_push(skb, 4); -+ skb->data[3] = NLPID_CISCO_LMI; -+ break; -+ -+ default: -+ return -EINVAL; -+ } -+ -+ } else if (skb->dev->type == ARPHRD_DLCI) { -+ switch (skb->protocol) { -+ case htons(ETH_P_IP): -+ skb_push(skb, 4); -+ skb->data[3] = NLPID_IP; -+ break; -+ -+ case htons(ETH_P_IPV6): -+ skb_push(skb, 4); -+ skb->data[3] = NLPID_IPV6; -+ break; -+ -+ default: -+ skb_push(skb, 10); -+ skb->data[3] = FR_PAD; -+ skb->data[4] = NLPID_SNAP; -+ /* OUI 00-00-00 indicates an Ethertype follows */ -+ skb->data[5] = 0x00; -+ skb->data[6] = 0x00; -+ skb->data[7] = 0x00; -+ /* This should be an Ethertype: */ -+ *(__be16 *)(skb->data + 8) = skb->protocol; -+ } -+ -+ } else if (skb->dev->type == ARPHRD_ETHER) { -+ if (skb_headroom(skb) < 10) { -+ struct sk_buff *skb2 = skb_realloc_headroom(skb, 10); - if (!skb2) - return -ENOBUFS; - dev_kfree_skb(skb); - skb = *skb_p = skb2; - } -- skb_push(skb, head_len); -+ skb_push(skb, 10); - skb->data[3] = FR_PAD; - skb->data[4] = NLPID_SNAP; -- skb->data[5] = FR_PAD; -+ /* OUI 00-80-C2 stands for the 802.1 organization */ -+ skb->data[5] = 0x00; - skb->data[6] = 0x80; - skb->data[7] = 0xC2; -+ /* PID 00-07 stands for Ethernet frames without FCS */ - skb->data[8] = 0x00; -- skb->data[9] = 0x07; /* bridged Ethernet frame w/out FCS */ -- break; -+ skb->data[9] = 0x07; - -- default: -- head_len = 10; -- skb_push(skb, head_len); -- skb->data[3] = FR_PAD; -- skb->data[4] = NLPID_SNAP; -- skb->data[5] = FR_PAD; -- skb->data[6] = FR_PAD; -- skb->data[7] = FR_PAD; -- *(__be16*)(skb->data + 8) = skb->protocol; -+ } else { -+ return -EINVAL; - } - - dlci_to_q922(skb->data, dlci); -@@ -425,8 +431,8 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) - skb_put(skb, pad); - memset(skb->data + len, 0, pad); - } -- skb->protocol = cpu_to_be16(ETH_P_802_3); - } -+ skb->dev = dev; - if (!fr_hard_header(&skb, pvc->dlci)) { - dev->stats.tx_bytes += skb->len; - dev->stats.tx_packets++; -@@ -494,10 +500,8 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) - memset(skb->data, 0, len); - skb_reserve(skb, 4); - if (lmi == LMI_CISCO) { -- skb->protocol = cpu_to_be16(NLPID_CISCO_LMI); - fr_hard_header(&skb, LMI_CISCO_DLCI); - } else { -- skb->protocol = cpu_to_be16(NLPID_CCITT_ANSI_LMI); - fr_hard_header(&skb, LMI_CCITT_ANSI_DLCI); - } - data = skb_tail_pointer(skb); -diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c -index 215ade6faf328..a00498338b1cc 100644 ---- a/drivers/net/wireless/ath/ath10k/htt_rx.c -+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c -@@ -949,6 +949,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar, - u8 preamble = 0; - u8 group_id; - u32 info1, info2, info3; -+ u32 stbc, nsts_su; - - info1 = __le32_to_cpu(rxd->ppdu_start.info1); - info2 = __le32_to_cpu(rxd->ppdu_start.info2); -@@ -993,11 +994,16 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar, - */ - bw = info2 & 3; - sgi = info3 & 1; -+ stbc = (info2 >> 3) & 1; - group_id = (info2 >> 4) & 0x3F; - - if (GROUP_ID_IS_SU_MIMO(group_id)) { - mcs = (info3 >> 4) & 0x0F; -- nss = ((info2 >> 10) & 0x07) + 1; -+ nsts_su = ((info2 >> 10) & 0x07); -+ if (stbc) -+ nss = (nsts_su >> 2) + 1; -+ else -+ nss = (nsts_su + 1); - } else { - /* Hardware doesn't decode VHT-SIG-B into Rx descriptor - * so it's impossible to decode MCS. Also since -@@ -3583,12 +3589,14 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, - } - - if (ar->htt.disable_tx_comp) { -- arsta->tx_retries += peer_stats->retry_pkts; - arsta->tx_failed += peer_stats->failed_pkts; -- ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx retries %d tx failed %d\n", -- arsta->tx_retries, arsta->tx_failed); -+ ath10k_dbg(ar, ATH10K_DBG_HTT, "tx failed %d\n", -+ arsta->tx_failed); - } - -+ arsta->tx_retries += peer_stats->retry_pkts; -+ ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx retries %d", arsta->tx_retries); -+ - if (ath10k_debug_is_extd_tx_stats_enabled(ar)) - ath10k_accumulate_per_peer_tx_stats(ar, arsta, peer_stats, - rate_idx); -diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c -index 2177e9d92bdff..03c7edf05a1d1 100644 ---- a/drivers/net/wireless/ath/ath10k/mac.c -+++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -8542,12 +8542,13 @@ static void ath10k_sta_statistics(struct ieee80211_hw *hw, - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); - - if (ar->htt.disable_tx_comp) { -- sinfo->tx_retries = arsta->tx_retries; -- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); - sinfo->tx_failed = arsta->tx_failed; - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); - } - -+ sinfo->tx_retries = arsta->tx_retries; -+ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); -+ - ath10k_mac_sta_get_peer_stats_info(ar, sta, sinfo); - } - -diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c -index 63f882c690bff..0841e69b10b1a 100644 ---- a/drivers/net/wireless/ath/ath10k/sdio.c -+++ b/drivers/net/wireless/ath/ath10k/sdio.c -@@ -557,6 +557,10 @@ static int ath10k_sdio_mbox_rx_alloc(struct ath10k *ar, - le16_to_cpu(htc_hdr->len), - ATH10K_HTC_MBOX_MAX_PAYLOAD_LENGTH); - ret = -ENOMEM; -+ -+ queue_work(ar->workqueue, &ar->restart_work); -+ ath10k_warn(ar, "exceeds length, start recovery\n"); -+ - goto err; - } - -diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c -index 791d971784ce0..055c3bb61e4c5 100644 ---- a/drivers/net/wireless/ath/ath11k/dp_rx.c -+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c -@@ -1421,7 +1421,7 @@ struct htt_ppdu_stats_info *ath11k_dp_htt_get_ppdu_desc(struct ath11k *ar, - } - spin_unlock_bh(&ar->data_lock); - -- ppdu_info = kzalloc(sizeof(*ppdu_info), GFP_KERNEL); -+ ppdu_info = kzalloc(sizeof(*ppdu_info), GFP_ATOMIC); - if (!ppdu_info) - return NULL; - -diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c -index 1af76775b1a87..99cff8fb39773 100644 ---- a/drivers/net/wireless/ath/ath11k/dp_tx.c -+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c -@@ -514,6 +514,8 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id) - u32 msdu_id; - u8 mac_id; - -+ spin_lock_bh(&status_ring->lock); -+ - ath11k_hal_srng_access_begin(ab, status_ring); - - while ((ATH11K_TX_COMPL_NEXT(tx_ring->tx_status_head) != -@@ -533,6 +535,8 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id) - - ath11k_hal_srng_access_end(ab, status_ring); - -+ spin_unlock_bh(&status_ring->lock); -+ - while (ATH11K_TX_COMPL_NEXT(tx_ring->tx_status_tail) != tx_ring->tx_status_head) { - struct hal_wbm_release_ring *tx_status; - u32 desc_id; -diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c -index 7c9dc91cc48a9..c79a7c7eb56ee 100644 ---- a/drivers/net/wireless/ath/ath11k/reg.c -+++ b/drivers/net/wireless/ath/ath11k/reg.c -@@ -206,7 +206,7 @@ int ath11k_regd_update(struct ath11k *ar, bool init) - ab = ar->ab; - pdev_id = ar->pdev_idx; - -- spin_lock(&ab->base_lock); -+ spin_lock_bh(&ab->base_lock); - - if (init) { - /* Apply the regd received during init through -@@ -227,7 +227,7 @@ int ath11k_regd_update(struct ath11k *ar, bool init) - - if (!regd) { - ret = -EINVAL; -- spin_unlock(&ab->base_lock); -+ spin_unlock_bh(&ab->base_lock); - goto err; - } - -@@ -238,7 +238,7 @@ int ath11k_regd_update(struct ath11k *ar, bool init) - if (regd_copy) - ath11k_copy_regd(regd, regd_copy); - -- spin_unlock(&ab->base_lock); -+ spin_unlock_bh(&ab->base_lock); - - if (!regd_copy) { - ret = -ENOMEM; -diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c -index a5cced2c89ac6..921b94c4f5f9a 100644 ---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c -+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c -@@ -304,10 +304,12 @@ void brcmf_fweh_detach(struct brcmf_pub *drvr) - { - struct brcmf_fweh_info *fweh = &drvr->fweh; - -- /* cancel the worker */ -- cancel_work_sync(&fweh->event_work); -- WARN_ON(!list_empty(&fweh->event_q)); -- memset(fweh->evt_handler, 0, sizeof(fweh->evt_handler)); -+ /* cancel the worker if initialized */ -+ if (fweh->event_work.func) { -+ cancel_work_sync(&fweh->event_work); -+ WARN_ON(!list_empty(&fweh->event_q)); -+ memset(fweh->evt_handler, 0, sizeof(fweh->evt_handler)); -+ } - } - - /** -diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c -index 3c07d1bbe1c6e..ac3ee93a23780 100644 ---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c -+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c -@@ -4278,6 +4278,7 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err, - brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_MESBUSYCTRL, - CY_43012_MESBUSYCTRL, &err); - break; -+ case SDIO_DEVICE_ID_BROADCOM_4329: - case SDIO_DEVICE_ID_BROADCOM_4339: - brcmf_dbg(INFO, "set F2 watermark to 0x%x*4 bytes for 4339\n", - CY_4339_F2_WATERMARK); -diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h -index ae477f7756af1..8ee24e351bdc2 100644 ---- a/drivers/net/xen-netback/common.h -+++ b/drivers/net/xen-netback/common.h -@@ -140,6 +140,20 @@ struct xenvif_queue { /* Per-queue data for xenvif */ - char name[QUEUE_NAME_SIZE]; /* DEVNAME-qN */ - struct xenvif *vif; /* Parent VIF */ - -+ /* -+ * TX/RX common EOI handling. -+ * When feature-split-event-channels = 0, interrupt handler sets -+ * NETBK_COMMON_EOI, otherwise NETBK_RX_EOI and NETBK_TX_EOI are set -+ * by the RX and TX interrupt handlers. -+ * RX and TX handler threads will issue an EOI when either -+ * NETBK_COMMON_EOI or their specific bits (NETBK_RX_EOI or -+ * NETBK_TX_EOI) are set and they will reset those bits. -+ */ -+ atomic_t eoi_pending; -+#define NETBK_RX_EOI 0x01 -+#define NETBK_TX_EOI 0x02 -+#define NETBK_COMMON_EOI 0x04 -+ - /* Use NAPI for guest TX */ - struct napi_struct napi; - /* When feature-split-event-channels = 0, tx_irq = rx_irq. */ -@@ -378,6 +392,7 @@ int xenvif_dealloc_kthread(void *data); - - irqreturn_t xenvif_ctrl_irq_fn(int irq, void *data); - -+bool xenvif_have_rx_work(struct xenvif_queue *queue, bool test_kthread); - void xenvif_rx_action(struct xenvif_queue *queue); - void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb); - -diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c -index 8af4972856915..acb786d8b1d8f 100644 ---- a/drivers/net/xen-netback/interface.c -+++ b/drivers/net/xen-netback/interface.c -@@ -77,12 +77,28 @@ int xenvif_schedulable(struct xenvif *vif) - !vif->disabled; - } - -+static bool xenvif_handle_tx_interrupt(struct xenvif_queue *queue) -+{ -+ bool rc; -+ -+ rc = RING_HAS_UNCONSUMED_REQUESTS(&queue->tx); -+ if (rc) -+ napi_schedule(&queue->napi); -+ return rc; -+} -+ - static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id) - { - struct xenvif_queue *queue = dev_id; -+ int old; - -- if (RING_HAS_UNCONSUMED_REQUESTS(&queue->tx)) -- napi_schedule(&queue->napi); -+ old = atomic_fetch_or(NETBK_TX_EOI, &queue->eoi_pending); -+ WARN(old & NETBK_TX_EOI, "Interrupt while EOI pending\n"); -+ -+ if (!xenvif_handle_tx_interrupt(queue)) { -+ atomic_andnot(NETBK_TX_EOI, &queue->eoi_pending); -+ xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); -+ } - - return IRQ_HANDLED; - } -@@ -116,19 +132,46 @@ static int xenvif_poll(struct napi_struct *napi, int budget) - return work_done; - } - -+static bool xenvif_handle_rx_interrupt(struct xenvif_queue *queue) -+{ -+ bool rc; -+ -+ rc = xenvif_have_rx_work(queue, false); -+ if (rc) -+ xenvif_kick_thread(queue); -+ return rc; -+} -+ - static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id) - { - struct xenvif_queue *queue = dev_id; -+ int old; - -- xenvif_kick_thread(queue); -+ old = atomic_fetch_or(NETBK_RX_EOI, &queue->eoi_pending); -+ WARN(old & NETBK_RX_EOI, "Interrupt while EOI pending\n"); -+ -+ if (!xenvif_handle_rx_interrupt(queue)) { -+ atomic_andnot(NETBK_RX_EOI, &queue->eoi_pending); -+ xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); -+ } - - return IRQ_HANDLED; - } - - irqreturn_t xenvif_interrupt(int irq, void *dev_id) - { -- xenvif_tx_interrupt(irq, dev_id); -- xenvif_rx_interrupt(irq, dev_id); -+ struct xenvif_queue *queue = dev_id; -+ int old; -+ -+ old = atomic_fetch_or(NETBK_COMMON_EOI, &queue->eoi_pending); -+ WARN(old, "Interrupt while EOI pending\n"); -+ -+ /* Use bitwise or as we need to call both functions. */ -+ if ((!xenvif_handle_tx_interrupt(queue) | -+ !xenvif_handle_rx_interrupt(queue))) { -+ atomic_andnot(NETBK_COMMON_EOI, &queue->eoi_pending); -+ xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); -+ } - - return IRQ_HANDLED; - } -@@ -605,7 +648,7 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_t ring_ref, - if (req_prod - rsp_prod > RING_SIZE(&vif->ctrl)) - goto err_unmap; - -- err = bind_interdomain_evtchn_to_irq(vif->domid, evtchn); -+ err = bind_interdomain_evtchn_to_irq_lateeoi(vif->domid, evtchn); - if (err < 0) - goto err_unmap; - -@@ -709,7 +752,7 @@ int xenvif_connect_data(struct xenvif_queue *queue, - - if (tx_evtchn == rx_evtchn) { - /* feature-split-event-channels == 0 */ -- err = bind_interdomain_evtchn_to_irqhandler( -+ err = bind_interdomain_evtchn_to_irqhandler_lateeoi( - queue->vif->domid, tx_evtchn, xenvif_interrupt, 0, - queue->name, queue); - if (err < 0) -@@ -720,7 +763,7 @@ int xenvif_connect_data(struct xenvif_queue *queue, - /* feature-split-event-channels == 1 */ - snprintf(queue->tx_irq_name, sizeof(queue->tx_irq_name), - "%s-tx", queue->name); -- err = bind_interdomain_evtchn_to_irqhandler( -+ err = bind_interdomain_evtchn_to_irqhandler_lateeoi( - queue->vif->domid, tx_evtchn, xenvif_tx_interrupt, 0, - queue->tx_irq_name, queue); - if (err < 0) -@@ -730,7 +773,7 @@ int xenvif_connect_data(struct xenvif_queue *queue, - - snprintf(queue->rx_irq_name, sizeof(queue->rx_irq_name), - "%s-rx", queue->name); -- err = bind_interdomain_evtchn_to_irqhandler( -+ err = bind_interdomain_evtchn_to_irqhandler_lateeoi( - queue->vif->domid, rx_evtchn, xenvif_rx_interrupt, 0, - queue->rx_irq_name, queue); - if (err < 0) -diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c -index 6dfca72656449..bc3421d145768 100644 ---- a/drivers/net/xen-netback/netback.c -+++ b/drivers/net/xen-netback/netback.c -@@ -169,6 +169,10 @@ void xenvif_napi_schedule_or_enable_events(struct xenvif_queue *queue) - - if (more_to_do) - napi_schedule(&queue->napi); -+ else if (atomic_fetch_andnot(NETBK_TX_EOI | NETBK_COMMON_EOI, -+ &queue->eoi_pending) & -+ (NETBK_TX_EOI | NETBK_COMMON_EOI)) -+ xen_irq_lateeoi(queue->tx_irq, 0); - } - - static void tx_add_credit(struct xenvif_queue *queue) -@@ -1643,9 +1647,14 @@ static bool xenvif_ctrl_work_todo(struct xenvif *vif) - irqreturn_t xenvif_ctrl_irq_fn(int irq, void *data) - { - struct xenvif *vif = data; -+ unsigned int eoi_flag = XEN_EOI_FLAG_SPURIOUS; - -- while (xenvif_ctrl_work_todo(vif)) -+ while (xenvif_ctrl_work_todo(vif)) { - xenvif_ctrl_action(vif); -+ eoi_flag = 0; -+ } -+ -+ xen_irq_lateeoi(irq, eoi_flag); - - return IRQ_HANDLED; - } -diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c -index ac034f69a170b..b8febe1d1bfd3 100644 ---- a/drivers/net/xen-netback/rx.c -+++ b/drivers/net/xen-netback/rx.c -@@ -503,13 +503,13 @@ static bool xenvif_rx_queue_ready(struct xenvif_queue *queue) - return queue->stalled && prod - cons >= 1; - } - --static bool xenvif_have_rx_work(struct xenvif_queue *queue) -+bool xenvif_have_rx_work(struct xenvif_queue *queue, bool test_kthread) - { - return xenvif_rx_ring_slots_available(queue) || - (queue->vif->stall_timeout && - (xenvif_rx_queue_stalled(queue) || - xenvif_rx_queue_ready(queue))) || -- kthread_should_stop() || -+ (test_kthread && kthread_should_stop()) || - queue->vif->disabled; - } - -@@ -540,15 +540,20 @@ static void xenvif_wait_for_rx_work(struct xenvif_queue *queue) - { - DEFINE_WAIT(wait); - -- if (xenvif_have_rx_work(queue)) -+ if (xenvif_have_rx_work(queue, true)) - return; - - for (;;) { - long ret; - - prepare_to_wait(&queue->wq, &wait, TASK_INTERRUPTIBLE); -- if (xenvif_have_rx_work(queue)) -+ if (xenvif_have_rx_work(queue, true)) - break; -+ if (atomic_fetch_andnot(NETBK_RX_EOI | NETBK_COMMON_EOI, -+ &queue->eoi_pending) & -+ (NETBK_RX_EOI | NETBK_COMMON_EOI)) -+ xen_irq_lateeoi(queue->rx_irq, 0); -+ - ret = schedule_timeout(xenvif_rx_queue_timeout(queue)); - if (!ret) - break; -diff --git a/drivers/nfc/s3fwrn5/Kconfig b/drivers/nfc/s3fwrn5/Kconfig -index af9d18690afeb..3f8b6da582803 100644 ---- a/drivers/nfc/s3fwrn5/Kconfig -+++ b/drivers/nfc/s3fwrn5/Kconfig -@@ -2,6 +2,7 @@ - config NFC_S3FWRN5 - tristate - select CRYPTO -+ select CRYPTO_HASH - help - Core driver for Samsung S3FWRN5 NFC chip. Contains core utilities - of chip. It's intended to be used by PHYs to avoid duplicating lots -diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c -index 9e378d0a0c01c..116902b1b2c34 100644 ---- a/drivers/nvme/host/rdma.c -+++ b/drivers/nvme/host/rdma.c -@@ -1926,7 +1926,6 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id, - complete(&queue->cm_done); - return 0; - case RDMA_CM_EVENT_REJECTED: -- nvme_rdma_destroy_queue_ib(queue); - cm_error = nvme_rdma_conn_rejected(queue, ev); - break; - case RDMA_CM_EVENT_ROUTE_ERROR: -diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c -index 3aac77a295ba1..82336bbaf8dca 100644 ---- a/drivers/pci/controller/dwc/pcie-qcom.c -+++ b/drivers/pci/controller/dwc/pcie-qcom.c -@@ -302,6 +302,9 @@ static void qcom_pcie_deinit_2_1_0(struct qcom_pcie *pcie) - reset_control_assert(res->por_reset); - reset_control_assert(res->ext_reset); - reset_control_assert(res->phy_reset); -+ -+ writel(1, pcie->parf + PCIE20_PARF_PHY_CTRL); -+ - regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); - } - -@@ -314,6 +317,16 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) - u32 val; - int ret; - -+ /* reset the PCIe interface as uboot can leave it undefined state */ -+ reset_control_assert(res->pci_reset); -+ reset_control_assert(res->axi_reset); -+ reset_control_assert(res->ahb_reset); -+ reset_control_assert(res->por_reset); -+ reset_control_assert(res->ext_reset); -+ reset_control_assert(res->phy_reset); -+ -+ writel(1, pcie->parf + PCIE20_PARF_PHY_CTRL); -+ - ret = regulator_bulk_enable(ARRAY_SIZE(res->supplies), res->supplies); - if (ret < 0) { - dev_err(dev, "cannot enable regulators\n"); -diff --git a/drivers/pci/ecam.c b/drivers/pci/ecam.c -index 8f065a42fc1a2..b54d32a316693 100644 ---- a/drivers/pci/ecam.c -+++ b/drivers/pci/ecam.c -@@ -168,4 +168,14 @@ const struct pci_ecam_ops pci_32b_ops = { - .write = pci_generic_config_write32, - } - }; -+ -+/* ECAM ops for 32-bit read only (non-compliant) */ -+const struct pci_ecam_ops pci_32b_read_ops = { -+ .bus_shift = 20, -+ .pci_ops = { -+ .map_bus = pci_ecam_map_bus, -+ .read = pci_generic_config_read32, -+ .write = pci_generic_config_write, -+ } -+}; - #endif -diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c -index d5869a03f7483..d9aa551f84236 100644 ---- a/drivers/pci/pci-acpi.c -+++ b/drivers/pci/pci-acpi.c -@@ -944,6 +944,16 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev) - if (!dev->is_hotplug_bridge) - return false; - -+ /* Assume D3 support if the bridge is power-manageable by ACPI. */ -+ adev = ACPI_COMPANION(&dev->dev); -+ if (!adev && !pci_dev_is_added(dev)) { -+ adev = acpi_pci_find_companion(&dev->dev); -+ ACPI_COMPANION_SET(&dev->dev, adev); -+ } -+ -+ if (adev && acpi_device_power_manageable(adev)) -+ return true; -+ - /* - * Look for a special _DSD property for the root port and if it - * is set we know the hierarchy behind it supports D3 just fine. -diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c -index a123f6e21f08a..08b9d025a3e81 100644 ---- a/drivers/power/supply/bq27xxx_battery.c -+++ b/drivers/power/supply/bq27xxx_battery.c -@@ -1772,8 +1772,6 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di, - status = POWER_SUPPLY_STATUS_FULL; - else if (di->cache.flags & BQ27000_FLAG_CHGS) - status = POWER_SUPPLY_STATUS_CHARGING; -- else if (power_supply_am_i_supplied(di->bat) > 0) -- status = POWER_SUPPLY_STATUS_NOT_CHARGING; - else - status = POWER_SUPPLY_STATUS_DISCHARGING; - } else if (di->opts & BQ27Z561_O_BITS) { -@@ -1792,6 +1790,10 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di, - status = POWER_SUPPLY_STATUS_CHARGING; - } - -+ if ((status == POWER_SUPPLY_STATUS_DISCHARGING) && -+ (power_supply_am_i_supplied(di->bat) > 0)) -+ status = POWER_SUPPLY_STATUS_NOT_CHARGING; -+ - val->intval = status; - - return 0; -diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c -index 04acd76bbaa12..4895ee5e63a9a 100644 ---- a/drivers/power/supply/test_power.c -+++ b/drivers/power/supply/test_power.c -@@ -353,6 +353,7 @@ static int param_set_ac_online(const char *key, const struct kernel_param *kp) - static int param_get_ac_online(char *buffer, const struct kernel_param *kp) - { - strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown")); -+ strcat(buffer, "\n"); - return strlen(buffer); - } - -@@ -366,6 +367,7 @@ static int param_set_usb_online(const char *key, const struct kernel_param *kp) - static int param_get_usb_online(char *buffer, const struct kernel_param *kp) - { - strcpy(buffer, map_get_key(map_ac_online, usb_online, "unknown")); -+ strcat(buffer, "\n"); - return strlen(buffer); - } - -@@ -380,6 +382,7 @@ static int param_set_battery_status(const char *key, - static int param_get_battery_status(char *buffer, const struct kernel_param *kp) - { - strcpy(buffer, map_get_key(map_status, battery_status, "unknown")); -+ strcat(buffer, "\n"); - return strlen(buffer); - } - -@@ -394,6 +397,7 @@ static int param_set_battery_health(const char *key, - static int param_get_battery_health(char *buffer, const struct kernel_param *kp) - { - strcpy(buffer, map_get_key(map_health, battery_health, "unknown")); -+ strcat(buffer, "\n"); - return strlen(buffer); - } - -@@ -409,6 +413,7 @@ static int param_get_battery_present(char *buffer, - const struct kernel_param *kp) - { - strcpy(buffer, map_get_key(map_present, battery_present, "unknown")); -+ strcat(buffer, "\n"); - return strlen(buffer); - } - -@@ -426,6 +431,7 @@ static int param_get_battery_technology(char *buffer, - { - strcpy(buffer, - map_get_key(map_technology, battery_technology, "unknown")); -+ strcat(buffer, "\n"); - return strlen(buffer); - } - -diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c -index 2e3b3e22e1d01..7ca823f6aa638 100644 ---- a/drivers/remoteproc/remoteproc_debugfs.c -+++ b/drivers/remoteproc/remoteproc_debugfs.c -@@ -94,7 +94,7 @@ static ssize_t rproc_coredump_write(struct file *filp, - goto out; - } - -- if (!strncmp(buf, "disable", count)) { -+ if (!strncmp(buf, "disabled", count)) { - rproc->dump_conf = RPROC_COREDUMP_DISABLED; - } else if (!strncmp(buf, "inline", count)) { - rproc->dump_conf = RPROC_COREDUMP_INLINE; -diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c -index f40312b16da06..b5570c83a28c6 100644 ---- a/drivers/rpmsg/qcom_glink_native.c -+++ b/drivers/rpmsg/qcom_glink_native.c -@@ -970,7 +970,7 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid) - return -EINVAL; - } - -- complete(&channel->open_ack); -+ complete_all(&channel->open_ack); - - return 0; - } -@@ -1178,7 +1178,7 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev) - __be32 *val = defaults; - int size; - -- if (glink->intentless) -+ if (glink->intentless || !completion_done(&channel->open_ack)) - return 0; - - prop = of_find_property(np, "qcom,intents", NULL); -@@ -1413,7 +1413,7 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid, - channel->rcid = ret; - spin_unlock_irqrestore(&glink->idr_lock, flags); - -- complete(&channel->open_req); -+ complete_all(&channel->open_req); - - if (create_device) { - rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL); -diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c -index fe010151ec8f2..08c93d4924946 100644 ---- a/drivers/rtc/rtc-rx8010.c -+++ b/drivers/rtc/rtc-rx8010.c -@@ -407,16 +407,26 @@ static int rx8010_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) - } - } - --static struct rtc_class_ops rx8010_rtc_ops = { -+static const struct rtc_class_ops rx8010_rtc_ops_default = { - .read_time = rx8010_get_time, - .set_time = rx8010_set_time, - .ioctl = rx8010_ioctl, - }; - -+static const struct rtc_class_ops rx8010_rtc_ops_alarm = { -+ .read_time = rx8010_get_time, -+ .set_time = rx8010_set_time, -+ .ioctl = rx8010_ioctl, -+ .read_alarm = rx8010_read_alarm, -+ .set_alarm = rx8010_set_alarm, -+ .alarm_irq_enable = rx8010_alarm_irq_enable, -+}; -+ - static int rx8010_probe(struct i2c_client *client, - const struct i2c_device_id *id) - { - struct i2c_adapter *adapter = client->adapter; -+ const struct rtc_class_ops *rtc_ops; - struct rx8010_data *rx8010; - int err = 0; - -@@ -447,16 +457,16 @@ static int rx8010_probe(struct i2c_client *client, - - if (err) { - dev_err(&client->dev, "unable to request IRQ\n"); -- client->irq = 0; -- } else { -- rx8010_rtc_ops.read_alarm = rx8010_read_alarm; -- rx8010_rtc_ops.set_alarm = rx8010_set_alarm; -- rx8010_rtc_ops.alarm_irq_enable = rx8010_alarm_irq_enable; -+ return err; - } -+ -+ rtc_ops = &rx8010_rtc_ops_alarm; -+ } else { -+ rtc_ops = &rx8010_rtc_ops_default; - } - - rx8010->rtc = devm_rtc_device_register(&client->dev, client->name, -- &rx8010_rtc_ops, THIS_MODULE); -+ rtc_ops, THIS_MODULE); - - if (IS_ERR(rx8010->rtc)) { - dev_err(&client->dev, "unable to register the class device\n"); -diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h -index 1ea046324e8f6..c4afca0d773c6 100644 ---- a/drivers/s390/crypto/ap_bus.h -+++ b/drivers/s390/crypto/ap_bus.h -@@ -50,6 +50,7 @@ static inline int ap_test_bit(unsigned int *ptr, unsigned int nr) - #define AP_RESPONSE_NO_FIRST_PART 0x13 - #define AP_RESPONSE_MESSAGE_TOO_BIG 0x15 - #define AP_RESPONSE_REQ_FAC_NOT_INST 0x16 -+#define AP_RESPONSE_INVALID_DOMAIN 0x42 - - /* - * Known device types -diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c -index 688ebebbf98cb..99f73bbb1c751 100644 ---- a/drivers/s390/crypto/ap_queue.c -+++ b/drivers/s390/crypto/ap_queue.c -@@ -237,6 +237,9 @@ static enum ap_sm_wait ap_sm_write(struct ap_queue *aq) - case AP_RESPONSE_RESET_IN_PROGRESS: - aq->sm_state = AP_SM_STATE_RESET_WAIT; - return AP_SM_WAIT_TIMEOUT; -+ case AP_RESPONSE_INVALID_DOMAIN: -+ AP_DBF(DBF_WARN, "AP_RESPONSE_INVALID_DOMAIN on NQAP\n"); -+ fallthrough; - case AP_RESPONSE_MESSAGE_TOO_BIG: - case AP_RESPONSE_REQ_FAC_NOT_INST: - list_del_init(&ap_msg->list); -@@ -278,11 +281,6 @@ static enum ap_sm_wait ap_sm_reset(struct ap_queue *aq) - aq->sm_state = AP_SM_STATE_RESET_WAIT; - aq->interrupt = AP_INTR_DISABLED; - return AP_SM_WAIT_TIMEOUT; -- case AP_RESPONSE_BUSY: -- return AP_SM_WAIT_TIMEOUT; -- case AP_RESPONSE_Q_NOT_AVAIL: -- case AP_RESPONSE_DECONFIGURED: -- case AP_RESPONSE_CHECKSTOPPED: - default: - aq->sm_state = AP_SM_STATE_BORKED; - return AP_SM_WAIT_NONE; -diff --git a/drivers/s390/crypto/zcrypt_debug.h b/drivers/s390/crypto/zcrypt_debug.h -index 241dbb5f75bf3..3225489a1c411 100644 ---- a/drivers/s390/crypto/zcrypt_debug.h -+++ b/drivers/s390/crypto/zcrypt_debug.h -@@ -21,6 +21,14 @@ - - #define ZCRYPT_DBF(...) \ - debug_sprintf_event(zcrypt_dbf_info, ##__VA_ARGS__) -+#define ZCRYPT_DBF_ERR(...) \ -+ debug_sprintf_event(zcrypt_dbf_info, DBF_ERR, ##__VA_ARGS__) -+#define ZCRYPT_DBF_WARN(...) \ -+ debug_sprintf_event(zcrypt_dbf_info, DBF_WARN, ##__VA_ARGS__) -+#define ZCRYPT_DBF_INFO(...) \ -+ debug_sprintf_event(zcrypt_dbf_info, DBF_INFO, ##__VA_ARGS__) -+#define ZCRYPT_DBF_DBG(...) \ -+ debug_sprintf_event(zcrypt_dbf_info, DBF_DEBUG, ##__VA_ARGS__) - - extern debug_info_t *zcrypt_dbf_info; - -diff --git a/drivers/s390/crypto/zcrypt_error.h b/drivers/s390/crypto/zcrypt_error.h -index 54a04f8c38ef9..39e626e3a3794 100644 ---- a/drivers/s390/crypto/zcrypt_error.h -+++ b/drivers/s390/crypto/zcrypt_error.h -@@ -52,7 +52,6 @@ struct error_hdr { - #define REP82_ERROR_INVALID_COMMAND 0x30 - #define REP82_ERROR_MALFORMED_MSG 0x40 - #define REP82_ERROR_INVALID_SPECIAL_CMD 0x41 --#define REP82_ERROR_INVALID_DOMAIN_PRECHECK 0x42 - #define REP82_ERROR_RESERVED_FIELDO 0x50 /* old value */ - #define REP82_ERROR_WORD_ALIGNMENT 0x60 - #define REP82_ERROR_MESSAGE_LENGTH 0x80 -@@ -67,7 +66,6 @@ struct error_hdr { - #define REP82_ERROR_ZERO_BUFFER_LEN 0xB0 - - #define REP88_ERROR_MODULE_FAILURE 0x10 -- - #define REP88_ERROR_MESSAGE_TYPE 0x20 - #define REP88_ERROR_MESSAGE_MALFORMD 0x22 - #define REP88_ERROR_MESSAGE_LENGTH 0x23 -@@ -85,78 +83,56 @@ static inline int convert_error(struct zcrypt_queue *zq, - int queue = AP_QID_QUEUE(zq->queue->qid); - - switch (ehdr->reply_code) { -- case REP82_ERROR_OPERAND_INVALID: -- case REP82_ERROR_OPERAND_SIZE: -- case REP82_ERROR_EVEN_MOD_IN_OPND: -- case REP88_ERROR_MESSAGE_MALFORMD: -- case REP82_ERROR_INVALID_DOMAIN_PRECHECK: -- case REP82_ERROR_INVALID_DOMAIN_PENDING: -- case REP82_ERROR_INVALID_SPECIAL_CMD: -- case REP82_ERROR_FILTERED_BY_HYPERVISOR: -- // REP88_ERROR_INVALID_KEY // '82' CEX2A -- // REP88_ERROR_OPERAND // '84' CEX2A -- // REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A -- /* Invalid input data. */ -+ case REP82_ERROR_INVALID_MSG_LEN: /* 0x23 */ -+ case REP82_ERROR_RESERVD_FIELD: /* 0x24 */ -+ case REP82_ERROR_FORMAT_FIELD: /* 0x29 */ -+ case REP82_ERROR_MALFORMED_MSG: /* 0x40 */ -+ case REP82_ERROR_INVALID_SPECIAL_CMD: /* 0x41 */ -+ case REP82_ERROR_MESSAGE_LENGTH: /* 0x80 */ -+ case REP82_ERROR_OPERAND_INVALID: /* 0x82 */ -+ case REP82_ERROR_OPERAND_SIZE: /* 0x84 */ -+ case REP82_ERROR_EVEN_MOD_IN_OPND: /* 0x85 */ -+ case REP82_ERROR_INVALID_DOMAIN_PENDING: /* 0x8A */ -+ case REP82_ERROR_FILTERED_BY_HYPERVISOR: /* 0x8B */ -+ case REP82_ERROR_PACKET_TRUNCATED: /* 0xA0 */ -+ case REP88_ERROR_MESSAGE_MALFORMD: /* 0x22 */ -+ case REP88_ERROR_KEY_TYPE: /* 0x34 */ -+ /* RY indicates malformed request */ - ZCRYPT_DBF(DBF_WARN, -- "device=%02x.%04x reply=0x%02x => rc=EINVAL\n", -+ "dev=%02x.%04x RY=0x%02x => rc=EINVAL\n", - card, queue, ehdr->reply_code); - return -EINVAL; -- case REP82_ERROR_MESSAGE_TYPE: -- // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A -+ case REP82_ERROR_MACHINE_FAILURE: /* 0x10 */ -+ case REP82_ERROR_MESSAGE_TYPE: /* 0x20 */ -+ case REP82_ERROR_TRANSPORT_FAIL: /* 0x90 */ - /* -- * To sent a message of the wrong type is a bug in the -- * device driver. Send error msg, disable the device -- * and then repeat the request. -+ * Msg to wrong type or card/infrastructure failure. -+ * Trigger rescan of the ap bus, trigger retry request. - */ - atomic_set(&zcrypt_rescan_req, 1); -- zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -- card, queue); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n", -- card, queue, ehdr->reply_code); -- return -EAGAIN; -- case REP82_ERROR_TRANSPORT_FAIL: -- /* Card or infrastructure failure, disable card */ -- atomic_set(&zcrypt_rescan_req, 1); -- zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -- card, queue); - /* For type 86 response show the apfs value (failure reason) */ -- if (ehdr->type == TYPE86_RSP_CODE) { -+ if (ehdr->reply_code == REP82_ERROR_TRANSPORT_FAIL && -+ ehdr->type == TYPE86_RSP_CODE) { - struct { - struct type86_hdr hdr; - struct type86_fmt2_ext fmt2; - } __packed * head = reply->msg; - unsigned int apfs = *((u32 *)head->fmt2.apfs); - -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x reply=0x%02x apfs=0x%x => online=0 rc=EAGAIN\n", -- card, queue, apfs, ehdr->reply_code); -+ ZCRYPT_DBF(DBF_WARN, -+ "dev=%02x.%04x RY=0x%02x apfs=0x%x => bus rescan, rc=EAGAIN\n", -+ card, queue, ehdr->reply_code, apfs); - } else -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n", -+ ZCRYPT_DBF(DBF_WARN, -+ "dev=%02x.%04x RY=0x%02x => bus rescan, rc=EAGAIN\n", - card, queue, ehdr->reply_code); - return -EAGAIN; -- case REP82_ERROR_MACHINE_FAILURE: -- // REP88_ERROR_MODULE_FAILURE // '10' CEX2A -- /* If a card fails disable it and repeat the request. */ -- atomic_set(&zcrypt_rescan_req, 1); -- zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -- card, queue); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n", -- card, queue, ehdr->reply_code); -- return -EAGAIN; - default: -- zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -- card, queue); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n", -+ /* Assume request is valid and a retry will be worth it */ -+ ZCRYPT_DBF(DBF_WARN, -+ "dev=%02x.%04x RY=0x%02x => rc=EAGAIN\n", - card, queue, ehdr->reply_code); -- return -EAGAIN; /* repeat the request on a different device. */ -+ return -EAGAIN; - } - } - -diff --git a/drivers/s390/crypto/zcrypt_msgtype50.c b/drivers/s390/crypto/zcrypt_msgtype50.c -index 7aedc338b4459..88916addd513e 100644 ---- a/drivers/s390/crypto/zcrypt_msgtype50.c -+++ b/drivers/s390/crypto/zcrypt_msgtype50.c -@@ -356,15 +356,15 @@ static int convert_type80(struct zcrypt_queue *zq, - if (t80h->len < sizeof(*t80h) + outputdatalength) { - /* The result is too short, the CEXxA card may not do that.. */ - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x code=0x%02x => online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x code=0x%02x => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- t80h->code); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ t80h->code); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x code=0x%02x => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ t80h->code); -+ return -EAGAIN; - } - if (zq->zcard->user_space_type == ZCRYPT_CEX2A) - BUG_ON(t80h->len > CEX2A_MAX_RESPONSE_SIZE); -@@ -376,10 +376,10 @@ static int convert_type80(struct zcrypt_queue *zq, - return 0; - } - --static int convert_response(struct zcrypt_queue *zq, -- struct ap_message *reply, -- char __user *outputdata, -- unsigned int outputdatalength) -+static int convert_response_cex2a(struct zcrypt_queue *zq, -+ struct ap_message *reply, -+ char __user *outputdata, -+ unsigned int outputdatalength) - { - /* Response type byte is the second byte in the response. */ - unsigned char rtype = ((unsigned char *) reply->msg)[1]; -@@ -393,15 +393,15 @@ static int convert_response(struct zcrypt_queue *zq, - outputdata, outputdatalength); - default: /* Unknown response type, this should NEVER EVER happen */ - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (unsigned int) rtype); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) rtype); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) rtype); -+ return -EAGAIN; - } - } - -@@ -476,8 +476,9 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, - if (rc == 0) { - rc = ap_msg.rc; - if (rc == 0) -- rc = convert_response(zq, &ap_msg, mex->outputdata, -- mex->outputdatalength); -+ rc = convert_response_cex2a(zq, &ap_msg, -+ mex->outputdata, -+ mex->outputdatalength); - } else - /* Signal pending. */ - ap_cancel_message(zq->queue, &ap_msg); -@@ -520,8 +521,9 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, - if (rc == 0) { - rc = ap_msg.rc; - if (rc == 0) -- rc = convert_response(zq, &ap_msg, crt->outputdata, -- crt->outputdatalength); -+ rc = convert_response_cex2a(zq, &ap_msg, -+ crt->outputdata, -+ crt->outputdatalength); - } else - /* Signal pending. */ - ap_cancel_message(zq->queue, &ap_msg); -diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c -index d77991c74c252..21ea3b73c8674 100644 ---- a/drivers/s390/crypto/zcrypt_msgtype6.c -+++ b/drivers/s390/crypto/zcrypt_msgtype6.c -@@ -650,23 +650,22 @@ static int convert_type86_ica(struct zcrypt_queue *zq, - (service_rc == 8 && service_rs == 72) || - (service_rc == 8 && service_rs == 770) || - (service_rc == 12 && service_rs == 769)) { -- ZCRYPT_DBF(DBF_DEBUG, -- "device=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (int) service_rc, (int) service_rs); -+ ZCRYPT_DBF_WARN("dev=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) service_rc, (int) service_rs); - return -EINVAL; - } - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x rc/rs=%d/%d online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (int) service_rc, (int) service_rs); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) service_rc, (int) service_rs); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) service_rc, (int) service_rs); -+ return -EAGAIN; - } - data = msg->text; - reply_len = msg->length - 2; -@@ -800,17 +799,18 @@ static int convert_response_ica(struct zcrypt_queue *zq, - return convert_type86_ica(zq, reply, - outputdata, outputdatalength); - fallthrough; /* wrong cprb version is an unknown response */ -- default: /* Unknown response type, this should NEVER EVER happen */ -+ default: -+ /* Unknown response type, this should NEVER EVER happen */ - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (int) msg->hdr.type); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ return -EAGAIN; - } - } - -@@ -836,15 +836,15 @@ static int convert_response_xcrb(struct zcrypt_queue *zq, - default: /* Unknown response type, this should NEVER EVER happen */ - xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (int) msg->hdr.type); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ return -EAGAIN; - } - } - -@@ -865,15 +865,15 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq, - fallthrough; /* wrong cprb version is an unknown resp */ - default: /* Unknown response type, this should NEVER EVER happen */ - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (int) msg->hdr.type); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ return -EAGAIN; - } - } - -@@ -895,15 +895,15 @@ static int convert_response_rng(struct zcrypt_queue *zq, - fallthrough; /* wrong cprb version is an unknown response */ - default: /* Unknown response type, this should NEVER EVER happen */ - zq->online = 0; -- pr_err("Cryptographic device %02x.%04x failed and was set offline\n", -+ pr_err("Crypto dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", - AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid)); -- ZCRYPT_DBF(DBF_ERR, -- "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n", -- AP_QID_CARD(zq->queue->qid), -- AP_QID_QUEUE(zq->queue->qid), -- (int) msg->hdr.type); -- return -EAGAIN; /* repeat the request on a different device. */ -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ ZCRYPT_DBF_ERR("dev=%02x.%04x unknown response type 0x%02x => online=0 rc=EAGAIN\n", -+ AP_QID_CARD(zq->queue->qid), -+ AP_QID_QUEUE(zq->queue->qid), -+ (int) msg->hdr.type); -+ return -EAGAIN; - } - } - -diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c -index 5d93ccc731535..5ab955007a07b 100644 ---- a/drivers/scsi/qla2xxx/qla_attr.c -+++ b/drivers/scsi/qla2xxx/qla_attr.c -@@ -157,6 +157,14 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, - vha->host_no); - } - break; -+ case 10: -+ if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { -+ ql_log(ql_log_info, vha, 0x70e9, -+ "Issuing MPI firmware dump on host#%ld.\n", -+ vha->host_no); -+ ha->isp_ops->mpi_fw_dump(vha, 0); -+ } -+ break; - } - return count; - } -@@ -744,8 +752,6 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, - qla83xx_idc_audit(vha, IDC_AUDIT_TIMESTAMP); - qla83xx_idc_unlock(vha, 0); - break; -- } else if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { -- qla27xx_reset_mpi(vha); - } else { - /* Make sure FC side is not in reset */ - WARN_ON_ONCE(qla2x00_wait_for_hba_online(vha) != -diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h -index 0ced18f3104e5..76711b34643a8 100644 ---- a/drivers/scsi/qla2xxx/qla_gbl.h -+++ b/drivers/scsi/qla2xxx/qla_gbl.h -@@ -938,6 +938,5 @@ extern void qla24xx_process_purex_list(struct purex_list *); - - /* nvme.c */ - void qla_nvme_unregister_remote_port(struct fc_port *fcport); --void qla27xx_reset_mpi(scsi_qla_host_t *vha); - void qla_handle_els_plogi_done(scsi_qla_host_t *vha, struct event_arg *ea); - #endif /* _QLA_GBL_H */ -diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c -index 8d4b651e14422..91f2cfc12aaa2 100644 ---- a/drivers/scsi/qla2xxx/qla_init.c -+++ b/drivers/scsi/qla2xxx/qla_init.c -@@ -3298,6 +3298,8 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) - j, fwdt->dump_size); - dump_size += fwdt->dump_size; - } -+ /* Add space for spare MPI fw dump. */ -+ dump_size += ha->fwdt[1].dump_size; - } else { - req_q_size = req->length * sizeof(request_t); - rsp_q_size = rsp->length * sizeof(response_t); -diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c -index 25e0a16847632..96db78c882009 100644 ---- a/drivers/scsi/qla2xxx/qla_isr.c -+++ b/drivers/scsi/qla2xxx/qla_isr.c -@@ -767,7 +767,7 @@ qla27xx_handle_8200_aen(scsi_qla_host_t *vha, uint16_t *mb) - ql_log(ql_log_warn, vha, 0x02f0, - "MPI Heartbeat stop. MPI reset is%s needed. " - "MB0[%xh] MB1[%xh] MB2[%xh] MB3[%xh]\n", -- mb[0] & BIT_8 ? "" : " not", -+ mb[1] & BIT_8 ? "" : " not", - mb[0], mb[1], mb[2], mb[3]); - - if ((mb[1] & BIT_8) == 0) -diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c -index 2a88e7e79bd50..9028bcddc98c9 100644 ---- a/drivers/scsi/qla2xxx/qla_target.c -+++ b/drivers/scsi/qla2xxx/qla_target.c -@@ -1229,14 +1229,15 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess) - case DSC_DELETE_PEND: - return; - case DSC_DELETED: -- if (tgt && tgt->tgt_stop && (tgt->sess_count == 0)) -- wake_up_all(&tgt->waitQ); -- if (sess->vha->fcport_count == 0) -- wake_up_all(&sess->vha->fcport_waitQ); -- - if (!sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] && -- !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]) -+ !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]) { -+ if (tgt && tgt->tgt_stop && tgt->sess_count == 0) -+ wake_up_all(&tgt->waitQ); -+ -+ if (sess->vha->fcport_count == 0) -+ wake_up_all(&sess->vha->fcport_waitQ); - return; -+ } - break; - case DSC_UPD_FCPORT: - /* -diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c -index 8dc82cfd38b27..2847243f6cfd3 100644 ---- a/drivers/scsi/qla2xxx/qla_tmpl.c -+++ b/drivers/scsi/qla2xxx/qla_tmpl.c -@@ -12,33 +12,6 @@ - #define IOBASE(vha) IOBAR(ISPREG(vha)) - #define INVALID_ENTRY ((struct qla27xx_fwdt_entry *)0xffffffffffffffffUL) - --/* hardware_lock assumed held. */ --static void --qla27xx_write_remote_reg(struct scsi_qla_host *vha, -- u32 addr, u32 data) --{ -- struct device_reg_24xx __iomem *reg = &vha->hw->iobase->isp24; -- -- ql_dbg(ql_dbg_misc, vha, 0xd300, -- "%s: addr/data = %xh/%xh\n", __func__, addr, data); -- -- wrt_reg_dword(®->iobase_addr, 0x40); -- wrt_reg_dword(®->iobase_c4, data); -- wrt_reg_dword(®->iobase_window, addr); --} -- --void --qla27xx_reset_mpi(scsi_qla_host_t *vha) --{ -- ql_dbg(ql_dbg_misc + ql_dbg_verbose, vha, 0xd301, -- "Entered %s.\n", __func__); -- -- qla27xx_write_remote_reg(vha, 0x104050, 0x40004); -- qla27xx_write_remote_reg(vha, 0x10405c, 0x4); -- -- vha->hw->stat.num_mpi_reset++; --} -- - static inline void - qla27xx_insert16(uint16_t value, void *buf, ulong *len) - { -@@ -1028,7 +1001,6 @@ void - qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked) - { - ulong flags = 0; -- bool need_mpi_reset = true; - - #ifndef __CHECKER__ - if (!hardware_locked) -@@ -1036,14 +1008,20 @@ qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked) - #endif - if (!vha->hw->mpi_fw_dump) { - ql_log(ql_log_warn, vha, 0x02f3, "-> mpi_fwdump no buffer\n"); -- } else if (vha->hw->mpi_fw_dumped) { -- ql_log(ql_log_warn, vha, 0x02f4, -- "-> MPI firmware already dumped (%p) -- ignoring request\n", -- vha->hw->mpi_fw_dump); - } else { - struct fwdt *fwdt = &vha->hw->fwdt[1]; - ulong len; - void *buf = vha->hw->mpi_fw_dump; -+ bool walk_template_only = false; -+ -+ if (vha->hw->mpi_fw_dumped) { -+ /* Use the spare area for any further dumps. */ -+ buf += fwdt->dump_size; -+ walk_template_only = true; -+ ql_log(ql_log_warn, vha, 0x02f4, -+ "-> MPI firmware already dumped -- dump saving to temporary buffer %p.\n", -+ buf); -+ } - - ql_log(ql_log_warn, vha, 0x02f5, "-> fwdt1 running...\n"); - if (!fwdt->template) { -@@ -1058,9 +1036,10 @@ qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked) - ql_log(ql_log_warn, vha, 0x02f7, - "-> fwdt1 fwdump residual=%+ld\n", - fwdt->dump_size - len); -- } else { -- need_mpi_reset = false; - } -+ vha->hw->stat.num_mpi_reset++; -+ if (walk_template_only) -+ goto bailout; - - vha->hw->mpi_fw_dump_len = len; - vha->hw->mpi_fw_dumped = 1; -@@ -1072,8 +1051,6 @@ qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked) - } - - bailout: -- if (need_mpi_reset) -- qla27xx_reset_mpi(vha); - #ifndef __CHECKER__ - if (!hardware_locked) - spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); -diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c -index 7affaaf8b98e0..198130b6a9963 100644 ---- a/drivers/scsi/scsi_lib.c -+++ b/drivers/scsi/scsi_lib.c -@@ -530,7 +530,7 @@ static void scsi_uninit_cmd(struct scsi_cmnd *cmd) - } - } - --static void scsi_free_sgtables(struct scsi_cmnd *cmd) -+void scsi_free_sgtables(struct scsi_cmnd *cmd) - { - if (cmd->sdb.table.nents) - sg_free_table_chained(&cmd->sdb.table, -@@ -539,6 +539,7 @@ static void scsi_free_sgtables(struct scsi_cmnd *cmd) - sg_free_table_chained(&cmd->prot_sdb->table, - SCSI_INLINE_PROT_SG_CNT); - } -+EXPORT_SYMBOL_GPL(scsi_free_sgtables); - - static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd) - { -@@ -966,7 +967,7 @@ static inline bool scsi_cmd_needs_dma_drain(struct scsi_device *sdev, - } - - /** -- * scsi_init_io - SCSI I/O initialization function. -+ * scsi_alloc_sgtables - allocate S/G tables for a command - * @cmd: command descriptor we wish to initialize - * - * Returns: -@@ -974,7 +975,7 @@ static inline bool scsi_cmd_needs_dma_drain(struct scsi_device *sdev, - * * BLK_STS_RESOURCE - if the failure is retryable - * * BLK_STS_IOERR - if the failure is fatal - */ --blk_status_t scsi_init_io(struct scsi_cmnd *cmd) -+blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd) - { - struct scsi_device *sdev = cmd->device; - struct request *rq = cmd->request; -@@ -1066,7 +1067,7 @@ out_free_sgtables: - scsi_free_sgtables(cmd); - return ret; - } --EXPORT_SYMBOL(scsi_init_io); -+EXPORT_SYMBOL(scsi_alloc_sgtables); - - /** - * scsi_initialize_rq - initialize struct scsi_cmnd partially -@@ -1154,7 +1155,7 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev, - * submit a request without an attached bio. - */ - if (req->bio) { -- blk_status_t ret = scsi_init_io(cmd); -+ blk_status_t ret = scsi_alloc_sgtables(cmd); - if (unlikely(ret != BLK_STS_OK)) - return ret; - } else { -@@ -1194,7 +1195,6 @@ static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev, - struct request *req) - { - struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); -- blk_status_t ret; - - if (!blk_rq_bytes(req)) - cmd->sc_data_direction = DMA_NONE; -@@ -1204,14 +1204,8 @@ static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev, - cmd->sc_data_direction = DMA_FROM_DEVICE; - - if (blk_rq_is_scsi(req)) -- ret = scsi_setup_scsi_cmnd(sdev, req); -- else -- ret = scsi_setup_fs_cmnd(sdev, req); -- -- if (ret != BLK_STS_OK) -- scsi_free_sgtables(cmd); -- -- return ret; -+ return scsi_setup_scsi_cmnd(sdev, req); -+ return scsi_setup_fs_cmnd(sdev, req); - } - - static blk_status_t -diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c -index 16503e22691ed..e93a9a874004f 100644 ---- a/drivers/scsi/sd.c -+++ b/drivers/scsi/sd.c -@@ -866,7 +866,7 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd) - cmd->transfersize = data_len; - rq->timeout = SD_TIMEOUT; - -- return scsi_init_io(cmd); -+ return scsi_alloc_sgtables(cmd); - } - - static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, -@@ -897,7 +897,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, - cmd->transfersize = data_len; - rq->timeout = unmap ? SD_TIMEOUT : SD_WRITE_SAME_TIMEOUT; - -- return scsi_init_io(cmd); -+ return scsi_alloc_sgtables(cmd); - } - - static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, -@@ -928,7 +928,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, - cmd->transfersize = data_len; - rq->timeout = unmap ? SD_TIMEOUT : SD_WRITE_SAME_TIMEOUT; - -- return scsi_init_io(cmd); -+ return scsi_alloc_sgtables(cmd); - } - - static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) -@@ -1069,7 +1069,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) - * knows how much to actually write. - */ - rq->__data_len = sdp->sector_size; -- ret = scsi_init_io(cmd); -+ ret = scsi_alloc_sgtables(cmd); - rq->__data_len = blk_rq_bytes(rq); - - return ret; -@@ -1187,23 +1187,24 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) - unsigned int dif; - bool dix; - -- ret = scsi_init_io(cmd); -+ ret = scsi_alloc_sgtables(cmd); - if (ret != BLK_STS_OK) - return ret; - -+ ret = BLK_STS_IOERR; - if (!scsi_device_online(sdp) || sdp->changed) { - scmd_printk(KERN_ERR, cmd, "device offline or changed\n"); -- return BLK_STS_IOERR; -+ goto fail; - } - - if (blk_rq_pos(rq) + blk_rq_sectors(rq) > get_capacity(rq->rq_disk)) { - scmd_printk(KERN_ERR, cmd, "access beyond end of device\n"); -- return BLK_STS_IOERR; -+ goto fail; - } - - if ((blk_rq_pos(rq) & mask) || (blk_rq_sectors(rq) & mask)) { - scmd_printk(KERN_ERR, cmd, "request not aligned to the logical block size\n"); -- return BLK_STS_IOERR; -+ goto fail; - } - - /* -@@ -1225,7 +1226,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) - if (req_op(rq) == REQ_OP_ZONE_APPEND) { - ret = sd_zbc_prepare_zone_append(cmd, &lba, nr_blocks); - if (ret) -- return ret; -+ goto fail; - } - - fua = rq->cmd_flags & REQ_FUA ? 0x8 : 0; -@@ -1253,7 +1254,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) - } - - if (unlikely(ret != BLK_STS_OK)) -- return ret; -+ goto fail; - - /* - * We shouldn't disconnect in the middle of a sector, so with a dumb -@@ -1277,10 +1278,12 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) - blk_rq_sectors(rq))); - - /* -- * This indicates that the command is ready from our end to be -- * queued. -+ * This indicates that the command is ready from our end to be queued. - */ - return BLK_STS_OK; -+fail: -+ scsi_free_sgtables(cmd); -+ return ret; - } - - static blk_status_t sd_init_command(struct scsi_cmnd *cmd) -diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c -index 3b3a53c6a0de5..7e8fe55f3b339 100644 ---- a/drivers/scsi/sr.c -+++ b/drivers/scsi/sr.c -@@ -392,15 +392,11 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt) - struct request *rq = SCpnt->request; - blk_status_t ret; - -- ret = scsi_init_io(SCpnt); -+ ret = scsi_alloc_sgtables(SCpnt); - if (ret != BLK_STS_OK) -- goto out; -+ return ret; - cd = scsi_cd(rq->rq_disk); - -- /* from here on until we're complete, any goto out -- * is used for a killable error condition */ -- ret = BLK_STS_IOERR; -- - SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt, - "Doing sr request, block = %d\n", block)); - -@@ -509,12 +505,12 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt) - SCpnt->allowed = MAX_RETRIES; - - /* -- * This indicates that the command is ready from our end to be -- * queued. -+ * This indicates that the command is ready from our end to be queued. - */ -- ret = BLK_STS_OK; -+ return BLK_STS_OK; - out: -- return ret; -+ scsi_free_sgtables(SCpnt); -+ return BLK_STS_IOERR; - } - - static int sr_block_open(struct block_device *bdev, fmode_t mode) -diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h -index ef60e790a750a..344ba687c13be 100644 ---- a/drivers/soc/qcom/rpmh-internal.h -+++ b/drivers/soc/qcom/rpmh-internal.h -@@ -8,6 +8,7 @@ - #define __RPM_INTERNAL_H__ - - #include -+#include - #include - - #define TCS_TYPE_NR 4 -@@ -106,6 +107,8 @@ struct rpmh_ctrlr { - * @lock: Synchronize state of the controller. If RPMH's cache - * lock will also be held, the order is: drv->lock then - * cache_lock. -+ * @tcs_wait: Wait queue used to wait for @tcs_in_use to free up a -+ * slot - * @client: Handle to the DRV's client. - */ - struct rsc_drv { -@@ -118,6 +121,7 @@ struct rsc_drv { - struct tcs_group tcs[TCS_TYPE_NR]; - DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR); - spinlock_t lock; -+ wait_queue_head_t tcs_wait; - struct rpmh_ctrlr client; - }; - -diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c -index ae66757825813..a297911afe571 100644 ---- a/drivers/soc/qcom/rpmh-rsc.c -+++ b/drivers/soc/qcom/rpmh-rsc.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - - #include - #include -@@ -453,6 +454,7 @@ skip: - if (!drv->tcs[ACTIVE_TCS].num_tcs) - enable_tcs_irq(drv, i, false); - spin_unlock(&drv->lock); -+ wake_up(&drv->tcs_wait); - if (req) - rpmh_tx_done(req, err); - } -@@ -571,73 +573,34 @@ static int find_free_tcs(struct tcs_group *tcs) - } - - /** -- * tcs_write() - Store messages into a TCS right now, or return -EBUSY. -+ * claim_tcs_for_req() - Claim a tcs in the given tcs_group; only for active. - * @drv: The controller. -+ * @tcs: The tcs_group used for ACTIVE_ONLY transfers. - * @msg: The data to be sent. - * -- * Grabs a TCS for ACTIVE_ONLY transfers and writes the messages to it. -+ * Claims a tcs in the given tcs_group while making sure that no existing cmd -+ * is in flight that would conflict with the one in @msg. - * -- * If there are no free TCSes for ACTIVE_ONLY transfers or if a command for -- * the same address is already transferring returns -EBUSY which means the -- * client should retry shortly. -+ * Context: Must be called with the drv->lock held since that protects -+ * tcs_in_use. - * -- * Return: 0 on success, -EBUSY if client should retry, or an error. -- * Client should have interrupts enabled for a bit before retrying. -+ * Return: The id of the claimed tcs or -EBUSY if a matching msg is in flight -+ * or the tcs_group is full. - */ --static int tcs_write(struct rsc_drv *drv, const struct tcs_request *msg) -+static int claim_tcs_for_req(struct rsc_drv *drv, struct tcs_group *tcs, -+ const struct tcs_request *msg) - { -- struct tcs_group *tcs; -- int tcs_id; -- unsigned long flags; - int ret; - -- tcs = get_tcs_for_msg(drv, msg); -- if (IS_ERR(tcs)) -- return PTR_ERR(tcs); -- -- spin_lock_irqsave(&drv->lock, flags); - /* - * The h/w does not like if we send a request to the same address, - * when one is already in-flight or being processed. - */ - ret = check_for_req_inflight(drv, tcs, msg); - if (ret) -- goto unlock; -- -- ret = find_free_tcs(tcs); -- if (ret < 0) -- goto unlock; -- tcs_id = ret; -- -- tcs->req[tcs_id - tcs->offset] = msg; -- set_bit(tcs_id, drv->tcs_in_use); -- if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) { -- /* -- * Clear previously programmed WAKE commands in selected -- * repurposed TCS to avoid triggering them. tcs->slots will be -- * cleaned from rpmh_flush() by invoking rpmh_rsc_invalidate() -- */ -- write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, tcs_id, 0); -- write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, tcs_id, 0); -- enable_tcs_irq(drv, tcs_id, true); -- } -- spin_unlock_irqrestore(&drv->lock, flags); -- -- /* -- * These two can be done after the lock is released because: -- * - We marked "tcs_in_use" under lock. -- * - Once "tcs_in_use" has been marked nobody else could be writing -- * to these registers until the interrupt goes off. -- * - The interrupt can't go off until we trigger w/ the last line -- * of __tcs_set_trigger() below. -- */ -- __tcs_buffer_write(drv, tcs_id, 0, msg); -- __tcs_set_trigger(drv, tcs_id, true); -+ return ret; - -- return 0; --unlock: -- spin_unlock_irqrestore(&drv->lock, flags); -- return ret; -+ return find_free_tcs(tcs); - } - - /** -@@ -664,18 +627,47 @@ unlock: - */ - int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) - { -- int ret; -+ struct tcs_group *tcs; -+ int tcs_id; -+ unsigned long flags; - -- do { -- ret = tcs_write(drv, msg); -- if (ret == -EBUSY) { -- pr_info_ratelimited("TCS Busy, retrying RPMH message send: addr=%#x\n", -- msg->cmds[0].addr); -- udelay(10); -- } -- } while (ret == -EBUSY); -+ tcs = get_tcs_for_msg(drv, msg); -+ if (IS_ERR(tcs)) -+ return PTR_ERR(tcs); - -- return ret; -+ spin_lock_irqsave(&drv->lock, flags); -+ -+ /* Wait forever for a free tcs. It better be there eventually! */ -+ wait_event_lock_irq(drv->tcs_wait, -+ (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0, -+ drv->lock); -+ -+ tcs->req[tcs_id - tcs->offset] = msg; -+ set_bit(tcs_id, drv->tcs_in_use); -+ if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) { -+ /* -+ * Clear previously programmed WAKE commands in selected -+ * repurposed TCS to avoid triggering them. tcs->slots will be -+ * cleaned from rpmh_flush() by invoking rpmh_rsc_invalidate() -+ */ -+ write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, tcs_id, 0); -+ write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, tcs_id, 0); -+ enable_tcs_irq(drv, tcs_id, true); -+ } -+ spin_unlock_irqrestore(&drv->lock, flags); -+ -+ /* -+ * These two can be done after the lock is released because: -+ * - We marked "tcs_in_use" under lock. -+ * - Once "tcs_in_use" has been marked nobody else could be writing -+ * to these registers until the interrupt goes off. -+ * - The interrupt can't go off until we trigger w/ the last line -+ * of __tcs_set_trigger() below. -+ */ -+ __tcs_buffer_write(drv, tcs_id, 0, msg); -+ __tcs_set_trigger(drv, tcs_id, true); -+ -+ return 0; - } - - /** -@@ -983,6 +975,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev) - return ret; - - spin_lock_init(&drv->lock); -+ init_waitqueue_head(&drv->tcs_wait); - bitmap_zero(drv->tcs_in_use, MAX_TCS_NR); - - irq = platform_get_irq(pdev, drv->id); -diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c -index 6dcc21dde0cb7..1147dc4c1d596 100644 ---- a/drivers/soc/ti/k3-ringacc.c -+++ b/drivers/soc/ti/k3-ringacc.c -@@ -10,6 +10,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -208,6 +209,15 @@ struct k3_ringacc { - const struct k3_ringacc_ops *ops; - }; - -+/** -+ * struct k3_ringacc - Rings accelerator SoC data -+ * -+ * @dma_ring_reset_quirk: DMA reset w/a enable -+ */ -+struct k3_ringacc_soc_data { -+ unsigned dma_ring_reset_quirk:1; -+}; -+ - static long k3_ringacc_ring_get_fifo_pos(struct k3_ring *ring) - { - return K3_RINGACC_FIFO_WINDOW_SIZE_BYTES - -@@ -1051,9 +1061,6 @@ static int k3_ringacc_probe_dt(struct k3_ringacc *ringacc) - return ret; - } - -- ringacc->dma_ring_reset_quirk = -- of_property_read_bool(node, "ti,dma-ring-reset-quirk"); -- - ringacc->tisci = ti_sci_get_by_phandle(node, "ti,sci"); - if (IS_ERR(ringacc->tisci)) { - ret = PTR_ERR(ringacc->tisci); -@@ -1084,9 +1091,22 @@ static int k3_ringacc_probe_dt(struct k3_ringacc *ringacc) - ringacc->rm_gp_range); - } - -+static const struct k3_ringacc_soc_data k3_ringacc_soc_data_sr1 = { -+ .dma_ring_reset_quirk = 1, -+}; -+ -+static const struct soc_device_attribute k3_ringacc_socinfo[] = { -+ { .family = "AM65X", -+ .revision = "SR1.0", -+ .data = &k3_ringacc_soc_data_sr1 -+ }, -+ {/* sentinel */} -+}; -+ - static int k3_ringacc_init(struct platform_device *pdev, - struct k3_ringacc *ringacc) - { -+ const struct soc_device_attribute *soc; - void __iomem *base_fifo, *base_rt; - struct device *dev = &pdev->dev; - struct resource *res; -@@ -1103,6 +1123,13 @@ static int k3_ringacc_init(struct platform_device *pdev, - if (ret) - return ret; - -+ soc = soc_device_match(k3_ringacc_socinfo); -+ if (soc && soc->data) { -+ const struct k3_ringacc_soc_data *soc_data = soc->data; -+ -+ ringacc->dma_ring_reset_quirk = soc_data->dma_ring_reset_quirk; -+ } -+ - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rt"); - base_rt = devm_ioremap_resource(dev, res); - if (IS_ERR(base_rt)) -diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c -index b08d8e9a8ee98..89531587d9cc0 100644 ---- a/drivers/spi/spi-mtk-nor.c -+++ b/drivers/spi/spi-mtk-nor.c -@@ -89,7 +89,7 @@ - // Buffered page program can do one 128-byte transfer - #define MTK_NOR_PP_SIZE 128 - --#define CLK_TO_US(sp, clkcnt) ((clkcnt) * 1000000 / sp->spi_freq) -+#define CLK_TO_US(sp, clkcnt) DIV_ROUND_UP(clkcnt, sp->spi_freq / 1000000) - - struct mtk_nor { - struct spi_controller *ctlr; -@@ -177,6 +177,10 @@ static int mtk_nor_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) - if ((op->addr.nbytes == 3) || (op->addr.nbytes == 4)) { - if ((op->data.dir == SPI_MEM_DATA_IN) && - mtk_nor_match_read(op)) { -+ // limit size to prevent timeout calculation overflow -+ if (op->data.nbytes > 0x400000) -+ op->data.nbytes = 0x400000; -+ - if ((op->addr.val & MTK_NOR_DMA_ALIGN_MASK) || - (op->data.nbytes < MTK_NOR_DMA_ALIGN)) - op->data.nbytes = 1; -diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c -index 6678f1cbc5660..0443fec3a6ab5 100644 ---- a/drivers/spi/spi-sprd.c -+++ b/drivers/spi/spi-sprd.c -@@ -563,11 +563,11 @@ static int sprd_spi_dma_request(struct sprd_spi *ss) - - ss->dma.dma_chan[SPRD_SPI_TX] = dma_request_chan(ss->dev, "tx_chn"); - if (IS_ERR_OR_NULL(ss->dma.dma_chan[SPRD_SPI_TX])) { -+ dma_release_channel(ss->dma.dma_chan[SPRD_SPI_RX]); - if (PTR_ERR(ss->dma.dma_chan[SPRD_SPI_TX]) == -EPROBE_DEFER) - return PTR_ERR(ss->dma.dma_chan[SPRD_SPI_TX]); - - dev_err(ss->dev, "request TX DMA channel failed!\n"); -- dma_release_channel(ss->dma.dma_chan[SPRD_SPI_RX]); - return PTR_ERR(ss->dma.dma_chan[SPRD_SPI_TX]); - } - -diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c -index 48ec2ee953dc5..d740c47827751 100644 ---- a/drivers/staging/comedi/drivers/cb_pcidas.c -+++ b/drivers/staging/comedi/drivers/cb_pcidas.c -@@ -1342,6 +1342,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, - if (dev->irq && board->has_ao_fifo) { - dev->write_subdev = s; - s->subdev_flags |= SDF_CMD_WRITE; -+ s->len_chanlist = s->n_chan; - s->do_cmdtest = cb_pcidas_ao_cmdtest; - s->do_cmd = cb_pcidas_ao_cmd; - s->cancel = cb_pcidas_ao_cancel; -diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c b/drivers/staging/fieldbus/anybuss/arcx-anybus.c -index 5b8d0bae9ff3d..b5fded15e8a69 100644 ---- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c -+++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c -@@ -293,7 +293,7 @@ static int controller_probe(struct platform_device *pdev) - regulator = devm_regulator_register(dev, &can_power_desc, &config); - if (IS_ERR(regulator)) { - err = PTR_ERR(regulator); -- goto out_reset; -+ goto out_ida; - } - /* make controller info visible to userspace */ - cd->class_dev = kzalloc(sizeof(*cd->class_dev), GFP_KERNEL); -diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c -index cfb673a52b257..0bf545849b119 100644 ---- a/drivers/staging/octeon/ethernet-mdio.c -+++ b/drivers/staging/octeon/ethernet-mdio.c -@@ -147,12 +147,6 @@ int cvm_oct_phy_setup_device(struct net_device *dev) - - phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0); - if (!phy_node && of_phy_is_fixed_link(priv->of_node)) { -- int rc; -- -- rc = of_phy_register_fixed_link(priv->of_node); -- if (rc) -- return rc; -- - phy_node = of_node_get(priv->of_node); - } - if (!phy_node) -diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c -index 2c16230f993cb..9ebd665e5d427 100644 ---- a/drivers/staging/octeon/ethernet-rx.c -+++ b/drivers/staging/octeon/ethernet-rx.c -@@ -69,15 +69,17 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work) - else - port = work->word1.cn38xx.ipprt; - -- if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) { -+ if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) - /* - * Ignore length errors on min size packets. Some - * equipment incorrectly pads packets to 64+4FCS - * instead of 60+4FCS. Note these packets still get - * counted as frame errors. - */ -- } else if (work->word2.snoip.err_code == 5 || -- work->word2.snoip.err_code == 7) { -+ return 0; -+ -+ if (work->word2.snoip.err_code == 5 || -+ work->word2.snoip.err_code == 7) { - /* - * We received a packet with either an alignment error - * or a FCS error. This may be signalling that we are -@@ -108,7 +110,10 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work) - /* Port received 0xd5 preamble */ - work->packet_ptr.s.addr += i + 1; - work->word1.len -= i + 5; -- } else if ((*ptr & 0xf) == 0xd) { -+ return 0; -+ } -+ -+ if ((*ptr & 0xf) == 0xd) { - /* Port received 0xd preamble */ - work->packet_ptr.s.addr += i; - work->word1.len -= i + 4; -@@ -118,21 +123,20 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work) - ((*(ptr + 1) & 0xf) << 4); - ptr++; - } -- } else { -- printk_ratelimited("Port %d unknown preamble, packet dropped\n", -- port); -- cvm_oct_free_work(work); -- return 1; -+ return 0; - } -+ -+ printk_ratelimited("Port %d unknown preamble, packet dropped\n", -+ port); -+ cvm_oct_free_work(work); -+ return 1; - } -- } else { -- printk_ratelimited("Port %d receive error code %d, packet dropped\n", -- port, work->word2.snoip.err_code); -- cvm_oct_free_work(work); -- return 1; - } - -- return 0; -+ printk_ratelimited("Port %d receive error code %d, packet dropped\n", -+ port, work->word2.snoip.err_code); -+ cvm_oct_free_work(work); -+ return 1; - } - - static void copy_segments_to_skb(struct cvmx_wqe *work, struct sk_buff *skb) -diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c -index 204f0b1e27397..5dea6e96ec901 100644 ---- a/drivers/staging/octeon/ethernet.c -+++ b/drivers/staging/octeon/ethernet.c -@@ -13,6 +13,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -892,6 +893,14 @@ static int cvm_oct_probe(struct platform_device *pdev) - break; - } - -+ if (priv->of_node && of_phy_is_fixed_link(priv->of_node)) { -+ if (of_phy_register_fixed_link(priv->of_node)) { -+ netdev_err(dev, "Failed to register fixed link for interface %d, port %d\n", -+ interface, priv->port); -+ dev->netdev_ops = NULL; -+ } -+ } -+ - if (!dev->netdev_ops) { - free_netdev(dev); - } else if (register_netdev(dev) < 0) { -diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c -index 7dace7c17bf5c..536c62001c709 100644 ---- a/drivers/staging/wfx/sta.c -+++ b/drivers/staging/wfx/sta.c -@@ -761,17 +761,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) - return -EOPNOTSUPP; - } - -- for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { -- if (!wdev->vif[i]) { -- wdev->vif[i] = vif; -- wvif->id = i; -- break; -- } -- } -- if (i == ARRAY_SIZE(wdev->vif)) { -- mutex_unlock(&wdev->conf_mutex); -- return -EOPNOTSUPP; -- } - // FIXME: prefer use of container_of() to get vif - wvif->vif = vif; - wvif->wdev = wdev; -@@ -788,12 +777,22 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) - init_completion(&wvif->scan_complete); - INIT_WORK(&wvif->scan_work, wfx_hw_scan_work); - -- mutex_unlock(&wdev->conf_mutex); -+ wfx_tx_queues_init(wvif); -+ wfx_tx_policy_init(wvif); -+ -+ for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { -+ if (!wdev->vif[i]) { -+ wdev->vif[i] = vif; -+ wvif->id = i; -+ break; -+ } -+ } -+ WARN(i == ARRAY_SIZE(wdev->vif), "try to instantiate more vif than supported"); - - hif_set_macaddr(wvif, vif->addr); - -- wfx_tx_queues_init(wvif); -- wfx_tx_policy_init(wvif); -+ mutex_unlock(&wdev->conf_mutex); -+ - wvif = NULL; - while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { - // Combo mode does not support Block Acks. We can re-enable them -@@ -825,6 +824,7 @@ void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) - wvif->vif = NULL; - - mutex_unlock(&wdev->conf_mutex); -+ - wvif = NULL; - while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { - // Combo mode does not support Block Acks. We can re-enable them -diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c -index 64637e09a0953..2f6199ebf7698 100644 ---- a/drivers/tee/tee_core.c -+++ b/drivers/tee/tee_core.c -@@ -200,7 +200,8 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method, - int name_len; - int rc; - -- if (connection_method == TEE_IOCTL_LOGIN_PUBLIC) { -+ if (connection_method == TEE_IOCTL_LOGIN_PUBLIC || -+ connection_method == TEE_IOCTL_LOGIN_REE_KERNEL) { - /* Nil UUID to be passed to TEE environment */ - uuid_copy(uuid, &uuid_null); - return 0; -diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c -index 718e010fcb048..09baef4ccc39a 100644 ---- a/drivers/tty/serial/21285.c -+++ b/drivers/tty/serial/21285.c -@@ -50,25 +50,25 @@ static const char serial21285_name[] = "Footbridge UART"; - - static bool is_enabled(struct uart_port *port, int bit) - { -- unsigned long private_data = (unsigned long)port->private_data; -+ unsigned long *private_data = (unsigned long *)&port->private_data; - -- if (test_bit(bit, &private_data)) -+ if (test_bit(bit, private_data)) - return true; - return false; - } - - static void enable(struct uart_port *port, int bit) - { -- unsigned long private_data = (unsigned long)port->private_data; -+ unsigned long *private_data = (unsigned long *)&port->private_data; - -- set_bit(bit, &private_data); -+ set_bit(bit, private_data); - } - - static void disable(struct uart_port *port, int bit) - { -- unsigned long private_data = (unsigned long)port->private_data; -+ unsigned long *private_data = (unsigned long *)&port->private_data; - -- clear_bit(bit, &private_data); -+ clear_bit(bit, private_data); - } - - #define is_tx_enabled(port) is_enabled(port, tx_enabled_bit) -diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c -index e17465a8a773c..ffa90a1c4c0a4 100644 ---- a/drivers/tty/serial/fsl_lpuart.c -+++ b/drivers/tty/serial/fsl_lpuart.c -@@ -314,9 +314,10 @@ MODULE_DEVICE_TABLE(of, lpuart_dt_ids); - /* Forward declare this for the dma callbacks*/ - static void lpuart_dma_tx_complete(void *arg); - --static inline bool is_ls1028a_lpuart(struct lpuart_port *sport) -+static inline bool is_layerscape_lpuart(struct lpuart_port *sport) - { -- return sport->devtype == LS1028A_LPUART; -+ return (sport->devtype == LS1021A_LPUART || -+ sport->devtype == LS1028A_LPUART); - } - - static inline bool is_imx8qxp_lpuart(struct lpuart_port *sport) -@@ -1644,11 +1645,11 @@ static int lpuart32_startup(struct uart_port *port) - UARTFIFO_FIFOSIZE_MASK); - - /* -- * The LS1028A has a fixed length of 16 words. Although it supports the -- * RX/TXSIZE fields their encoding is different. Eg the reference manual -- * states 0b101 is 16 words. -+ * The LS1021A and LS1028A have a fixed FIFO depth of 16 words. -+ * Although they support the RX/TXSIZE fields, their encoding is -+ * different. Eg the reference manual states 0b101 is 16 words. - */ -- if (is_ls1028a_lpuart(sport)) { -+ if (is_layerscape_lpuart(sport)) { - sport->rxfifo_size = 16; - sport->txfifo_size = 16; - sport->port.fifosize = sport->txfifo_size; -diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c -index 0db53b5b3acf6..78acc270e39ac 100644 ---- a/drivers/tty/vt/keyboard.c -+++ b/drivers/tty/vt/keyboard.c -@@ -743,8 +743,13 @@ static void k_fn(struct vc_data *vc, unsigned char value, char up_flag) - return; - - if ((unsigned)value < ARRAY_SIZE(func_table)) { -+ unsigned long flags; -+ -+ spin_lock_irqsave(&func_buf_lock, flags); - if (func_table[value]) - puts_queue(vc, func_table[value]); -+ spin_unlock_irqrestore(&func_buf_lock, flags); -+ - } else - pr_err("k_fn called with value=%d\n", value); - } -@@ -1991,13 +1996,11 @@ out: - #undef s - #undef v - --/* FIXME: This one needs untangling and locking */ -+/* FIXME: This one needs untangling */ - int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) - { - struct kbsentry *kbs; -- char *p; - u_char *q; -- u_char __user *up; - int sz, fnw_sz; - int delta; - char *first_free, *fj, *fnw; -@@ -2023,23 +2026,19 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) - i = array_index_nospec(kbs->kb_func, MAX_NR_FUNC); - - switch (cmd) { -- case KDGKBSENT: -- sz = sizeof(kbs->kb_string) - 1; /* sz should have been -- a struct member */ -- up = user_kdgkb->kb_string; -- p = func_table[i]; -- if(p) -- for ( ; *p && sz; p++, sz--) -- if (put_user(*p, up++)) { -- ret = -EFAULT; -- goto reterr; -- } -- if (put_user('\0', up)) { -- ret = -EFAULT; -- goto reterr; -- } -- kfree(kbs); -- return ((p && *p) ? -EOVERFLOW : 0); -+ case KDGKBSENT: { -+ /* size should have been a struct member */ -+ ssize_t len = sizeof(user_kdgkb->kb_string); -+ -+ spin_lock_irqsave(&func_buf_lock, flags); -+ len = strlcpy(kbs->kb_string, func_table[i] ? : "", len); -+ spin_unlock_irqrestore(&func_buf_lock, flags); -+ -+ ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string, -+ len + 1) ? -EFAULT : 0; -+ -+ goto reterr; -+ } - case KDSKBSENT: - if (!perm) { - ret = -EPERM; -diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c -index bc33938e2f20e..21bc7dd4ad7ee 100644 ---- a/drivers/tty/vt/vt_ioctl.c -+++ b/drivers/tty/vt/vt_ioctl.c -@@ -485,7 +485,7 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd, - return 0; - } - --static inline int do_fontx_ioctl(int cmd, -+static inline int do_fontx_ioctl(struct vc_data *vc, int cmd, - struct consolefontdesc __user *user_cfd, - struct console_font_op *op) - { -@@ -503,15 +503,16 @@ static inline int do_fontx_ioctl(int cmd, - op->height = cfdarg.charheight; - op->charcount = cfdarg.charcount; - op->data = cfdarg.chardata; -- return con_font_op(vc_cons[fg_console].d, op); -- case GIO_FONTX: { -+ return con_font_op(vc, op); -+ -+ case GIO_FONTX: - op->op = KD_FONT_OP_GET; - op->flags = KD_FONT_FLAG_OLD; - op->width = 8; - op->height = cfdarg.charheight; - op->charcount = cfdarg.charcount; - op->data = cfdarg.chardata; -- i = con_font_op(vc_cons[fg_console].d, op); -+ i = con_font_op(vc, op); - if (i) - return i; - cfdarg.charheight = op->height; -@@ -519,12 +520,11 @@ static inline int do_fontx_ioctl(int cmd, - if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc))) - return -EFAULT; - return 0; -- } - } - return -EINVAL; - } - --static int vt_io_fontreset(struct console_font_op *op) -+static int vt_io_fontreset(struct vc_data *vc, struct console_font_op *op) - { - int ret; - -@@ -538,19 +538,19 @@ static int vt_io_fontreset(struct console_font_op *op) - - op->op = KD_FONT_OP_SET_DEFAULT; - op->data = NULL; -- ret = con_font_op(vc_cons[fg_console].d, op); -+ ret = con_font_op(vc, op); - if (ret) - return ret; - - console_lock(); -- con_set_default_unimap(vc_cons[fg_console].d); -+ con_set_default_unimap(vc); - console_unlock(); - - return 0; - } - - static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, -- struct vc_data *vc) -+ bool perm, struct vc_data *vc) - { - struct unimapdesc tmp; - -@@ -558,9 +558,11 @@ static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, - return -EFAULT; - switch (cmd) { - case PIO_UNIMAP: -+ if (!perm) -+ return -EPERM; - return con_set_unimap(vc, tmp.entry_ct, tmp.entries); - case GIO_UNIMAP: -- if (fg_console != vc->vc_num) -+ if (!perm && fg_console != vc->vc_num) - return -EPERM; - return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), - tmp.entries); -@@ -583,7 +585,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up, - op.height = 0; - op.charcount = 256; - op.data = up; -- return con_font_op(vc_cons[fg_console].d, &op); -+ return con_font_op(vc, &op); - - case GIO_FONT: - op.op = KD_FONT_OP_GET; -@@ -592,7 +594,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up, - op.height = 32; - op.charcount = 256; - op.data = up; -- return con_font_op(vc_cons[fg_console].d, &op); -+ return con_font_op(vc, &op); - - case PIO_CMAP: - if (!perm) -@@ -608,13 +610,13 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up, - - fallthrough; - case GIO_FONTX: -- return do_fontx_ioctl(cmd, up, &op); -+ return do_fontx_ioctl(vc, cmd, up, &op); - - case PIO_FONTRESET: - if (!perm) - return -EPERM; - -- return vt_io_fontreset(&op); -+ return vt_io_fontreset(vc, &op); - - case PIO_SCRNMAP: - if (!perm) -@@ -640,10 +642,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up, - - case PIO_UNIMAP: - case GIO_UNIMAP: -- if (!perm) -- return -EPERM; -- -- return do_unimap_ioctl(cmd, up, vc); -+ return do_unimap_ioctl(cmd, up, perm, vc); - - default: - return -ENOIOCTLCMD; -@@ -1068,8 +1067,9 @@ struct compat_consolefontdesc { - }; - - static inline int --compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd, -- int perm, struct console_font_op *op) -+compat_fontx_ioctl(struct vc_data *vc, int cmd, -+ struct compat_consolefontdesc __user *user_cfd, -+ int perm, struct console_font_op *op) - { - struct compat_consolefontdesc cfdarg; - int i; -@@ -1087,7 +1087,8 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd, - op->height = cfdarg.charheight; - op->charcount = cfdarg.charcount; - op->data = compat_ptr(cfdarg.chardata); -- return con_font_op(vc_cons[fg_console].d, op); -+ return con_font_op(vc, op); -+ - case GIO_FONTX: - op->op = KD_FONT_OP_GET; - op->flags = KD_FONT_FLAG_OLD; -@@ -1095,7 +1096,7 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd, - op->height = cfdarg.charheight; - op->charcount = cfdarg.charcount; - op->data = compat_ptr(cfdarg.chardata); -- i = con_font_op(vc_cons[fg_console].d, op); -+ i = con_font_op(vc, op); - if (i) - return i; - cfdarg.charheight = op->height; -@@ -1185,7 +1186,7 @@ long vt_compat_ioctl(struct tty_struct *tty, - */ - case PIO_FONTX: - case GIO_FONTX: -- return compat_fontx_ioctl(cmd, up, perm, &op); -+ return compat_fontx_ioctl(vc, cmd, up, perm, &op); - - case KDFONTOP: - return compat_kdfontop_ioctl(up, perm, &op, vc); -diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c -index 73efb80815db8..6dca744e39e95 100644 ---- a/drivers/uio/uio.c -+++ b/drivers/uio/uio.c -@@ -1048,8 +1048,6 @@ void uio_unregister_device(struct uio_info *info) - - idev = info->uio_dev; - -- uio_free_minor(idev); -- - mutex_lock(&idev->info_lock); - uio_dev_del_attributes(idev); - -@@ -1064,6 +1062,8 @@ void uio_unregister_device(struct uio_info *info) - - device_unregister(&idev->dev); - -+ uio_free_minor(idev); -+ - return; - } - EXPORT_SYMBOL_GPL(uio_unregister_device); -diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c -index d9779abc65b2b..89b94e45ee15d 100644 ---- a/drivers/usb/cdns3/ep0.c -+++ b/drivers/usb/cdns3/ep0.c -@@ -137,48 +137,36 @@ static int cdns3_req_ep0_set_configuration(struct cdns3_device *priv_dev, - struct usb_ctrlrequest *ctrl_req) - { - enum usb_device_state device_state = priv_dev->gadget.state; -- struct cdns3_endpoint *priv_ep; - u32 config = le16_to_cpu(ctrl_req->wValue); - int result = 0; -- int i; - - switch (device_state) { - case USB_STATE_ADDRESS: -- /* Configure non-control EPs */ -- for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) { -- priv_ep = priv_dev->eps[i]; -- if (!priv_ep) -- continue; -- -- if (priv_ep->flags & EP_CLAIMED) -- cdns3_ep_config(priv_ep); -- } -- - result = cdns3_ep0_delegate_req(priv_dev, ctrl_req); - -- if (result) -- return result; -- -- if (!config) { -- cdns3_hw_reset_eps_config(priv_dev); -- usb_gadget_set_state(&priv_dev->gadget, -- USB_STATE_ADDRESS); -- } -+ if (result || !config) -+ goto reset_config; - - break; - case USB_STATE_CONFIGURED: - result = cdns3_ep0_delegate_req(priv_dev, ctrl_req); -+ if (!config && !result) -+ goto reset_config; - -- if (!config && !result) { -- cdns3_hw_reset_eps_config(priv_dev); -- usb_gadget_set_state(&priv_dev->gadget, -- USB_STATE_ADDRESS); -- } - break; - default: -- result = -EINVAL; -+ return -EINVAL; - } - -+ return 0; -+ -+reset_config: -+ if (result != USB_GADGET_DELAYED_STATUS) -+ cdns3_hw_reset_eps_config(priv_dev); -+ -+ usb_gadget_set_state(&priv_dev->gadget, -+ USB_STATE_ADDRESS); -+ - return result; - } - -@@ -705,6 +693,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, - unsigned long flags; - int ret = 0; - u8 zlp = 0; -+ int i; - - spin_lock_irqsave(&priv_dev->lock, flags); - trace_cdns3_ep0_queue(priv_dev, request); -@@ -718,6 +707,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, - /* send STATUS stage. Should be called only for SET_CONFIGURATION */ - if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) { - cdns3_select_ep(priv_dev, 0x00); -+ -+ /* -+ * Configure all non-control EPs which are not enabled by class driver -+ */ -+ for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) { -+ priv_ep = priv_dev->eps[i]; -+ if (priv_ep && priv_ep->flags & EP_CLAIMED && -+ !(priv_ep->flags & EP_ENABLED)) -+ cdns3_ep_config(priv_ep, 0); -+ } -+ - cdns3_set_hw_configuration(priv_dev); - cdns3_ep0_complete_setup(priv_dev, 0, 1); - request->actual = 0; -@@ -803,6 +803,7 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev) - struct cdns3_usb_regs __iomem *regs; - struct cdns3_endpoint *priv_ep; - u32 max_packet_size = 64; -+ u32 ep_cfg; - - regs = priv_dev->regs; - -@@ -834,8 +835,10 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev) - BIT(0) | BIT(16)); - } - -- writel(EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size), -- ®s->ep_cfg); -+ ep_cfg = EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size); -+ -+ if (!(priv_ep->flags & EP_CONFIGURED)) -+ writel(ep_cfg, ®s->ep_cfg); - - writel(EP_STS_EN_SETUPEN | EP_STS_EN_DESCMISEN | EP_STS_EN_TRBERREN, - ®s->ep_sts_en); -@@ -843,8 +846,10 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev) - /* init ep in */ - cdns3_select_ep(priv_dev, USB_DIR_IN); - -- writel(EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size), -- ®s->ep_cfg); -+ if (!(priv_ep->flags & EP_CONFIGURED)) -+ writel(ep_cfg, ®s->ep_cfg); -+ -+ priv_ep->flags |= EP_CONFIGURED; - - writel(EP_STS_EN_SETUPEN | EP_STS_EN_TRBERREN, ®s->ep_sts_en); - -diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c -index 02a69e20014b1..e0e1cb907ffd8 100644 ---- a/drivers/usb/cdns3/gadget.c -+++ b/drivers/usb/cdns3/gadget.c -@@ -296,6 +296,8 @@ static void cdns3_ep_stall_flush(struct cdns3_endpoint *priv_ep) - */ - void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev) - { -+ int i; -+ - writel(USB_CONF_CFGRST, &priv_dev->regs->usb_conf); - - cdns3_allow_enable_l1(priv_dev, 0); -@@ -304,6 +306,10 @@ void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev) - priv_dev->out_mem_is_allocated = 0; - priv_dev->wait_for_setup = 0; - priv_dev->using_streams = 0; -+ -+ for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) -+ if (priv_dev->eps[i]) -+ priv_dev->eps[i]->flags &= ~EP_CONFIGURED; - } - - /** -@@ -1907,27 +1913,6 @@ static int cdns3_ep_onchip_buffer_reserve(struct cdns3_device *priv_dev, - return 0; - } - --static void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev, -- struct cdns3_endpoint *priv_ep) --{ -- if (!priv_ep->use_streams || priv_dev->gadget.speed < USB_SPEED_SUPER) -- return; -- -- if (priv_dev->dev_ver >= DEV_VER_V3) { -- u32 mask = BIT(priv_ep->num + (priv_ep->dir ? 16 : 0)); -- -- /* -- * Stream capable endpoints are handled by using ep_tdl -- * register. Other endpoints use TDL from TRB feature. -- */ -- cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb, mask); -- } -- -- /* Enable Stream Bit TDL chk and SID chk */ -- cdns3_set_register_bit(&priv_dev->regs->ep_cfg, EP_CFG_STREAM_EN | -- EP_CFG_TDL_CHK | EP_CFG_SID_CHK); --} -- - static void cdns3_configure_dmult(struct cdns3_device *priv_dev, - struct cdns3_endpoint *priv_ep) - { -@@ -1965,8 +1950,9 @@ static void cdns3_configure_dmult(struct cdns3_device *priv_dev, - /** - * cdns3_ep_config Configure hardware endpoint - * @priv_ep: extended endpoint object -+ * @enable: set EP_CFG_ENABLE bit in ep_cfg register. - */ --void cdns3_ep_config(struct cdns3_endpoint *priv_ep) -+int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable) - { - bool is_iso_ep = (priv_ep->type == USB_ENDPOINT_XFER_ISOC); - struct cdns3_device *priv_dev = priv_ep->cdns3_dev; -@@ -2027,7 +2013,7 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep) - break; - default: - /* all other speed are not supported */ -- return; -+ return -EINVAL; - } - - if (max_packet_size == 1024) -@@ -2037,11 +2023,33 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep) - else - priv_ep->trb_burst_size = 16; - -- ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1, -- !!priv_ep->dir); -- if (ret) { -- dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n"); -- return; -+ /* onchip buffer is only allocated before configuration */ -+ if (!priv_dev->hw_configured_flag) { -+ ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1, -+ !!priv_ep->dir); -+ if (ret) { -+ dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n"); -+ return ret; -+ } -+ } -+ -+ if (enable) -+ ep_cfg |= EP_CFG_ENABLE; -+ -+ if (priv_ep->use_streams && priv_dev->gadget.speed >= USB_SPEED_SUPER) { -+ if (priv_dev->dev_ver >= DEV_VER_V3) { -+ u32 mask = BIT(priv_ep->num + (priv_ep->dir ? 16 : 0)); -+ -+ /* -+ * Stream capable endpoints are handled by using ep_tdl -+ * register. Other endpoints use TDL from TRB feature. -+ */ -+ cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb, -+ mask); -+ } -+ -+ /* Enable Stream Bit TDL chk and SID chk */ -+ ep_cfg |= EP_CFG_STREAM_EN | EP_CFG_TDL_CHK | EP_CFG_SID_CHK; - } - - ep_cfg |= EP_CFG_MAXPKTSIZE(max_packet_size) | -@@ -2051,9 +2059,12 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep) - - cdns3_select_ep(priv_dev, bEndpointAddress); - writel(ep_cfg, &priv_dev->regs->ep_cfg); -+ priv_ep->flags |= EP_CONFIGURED; - - dev_dbg(priv_dev->dev, "Configure %s: with val %08x\n", - priv_ep->name, ep_cfg); -+ -+ return 0; - } - - /* Find correct direction for HW endpoint according to description */ -@@ -2194,7 +2205,7 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep, - u32 bEndpointAddress; - unsigned long flags; - int enable = 1; -- int ret; -+ int ret = 0; - int val; - - priv_ep = ep_to_cdns3_ep(ep); -@@ -2233,6 +2244,17 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep, - bEndpointAddress = priv_ep->num | priv_ep->dir; - cdns3_select_ep(priv_dev, bEndpointAddress); - -+ /* -+ * For some versions of controller at some point during ISO OUT traffic -+ * DMA reads Transfer Ring for the EP which has never got doorbell. -+ * This issue was detected only on simulation, but to avoid this issue -+ * driver add protection against it. To fix it driver enable ISO OUT -+ * endpoint before setting DRBL. This special treatment of ISO OUT -+ * endpoints are recommended by controller specification. -+ */ -+ if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && !priv_ep->dir) -+ enable = 0; -+ - if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) { - /* - * Enable stream support (SS mode) related interrupts -@@ -2243,13 +2265,17 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep, - EP_STS_EN_SIDERREN | EP_STS_EN_MD_EXITEN | - EP_STS_EN_STREAMREN; - priv_ep->use_streams = true; -- cdns3_stream_ep_reconfig(priv_dev, priv_ep); -+ ret = cdns3_ep_config(priv_ep, enable); - priv_dev->using_streams |= true; - } -+ } else { -+ ret = cdns3_ep_config(priv_ep, enable); - } - -- ret = cdns3_allocate_trb_pool(priv_ep); -+ if (ret) -+ goto exit; - -+ ret = cdns3_allocate_trb_pool(priv_ep); - if (ret) - goto exit; - -@@ -2279,20 +2305,6 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep, - - writel(reg, &priv_dev->regs->ep_sts_en); - -- /* -- * For some versions of controller at some point during ISO OUT traffic -- * DMA reads Transfer Ring for the EP which has never got doorbell. -- * This issue was detected only on simulation, but to avoid this issue -- * driver add protection against it. To fix it driver enable ISO OUT -- * endpoint before setting DRBL. This special treatment of ISO OUT -- * endpoints are recommended by controller specification. -- */ -- if (priv_ep->type == USB_ENDPOINT_XFER_ISOC && !priv_ep->dir) -- enable = 0; -- -- if (enable) -- cdns3_set_register_bit(&priv_dev->regs->ep_cfg, EP_CFG_ENABLE); -- - ep->desc = desc; - priv_ep->flags &= ~(EP_PENDING_REQUEST | EP_STALLED | EP_STALL_PENDING | - EP_QUIRK_ISO_OUT_EN | EP_QUIRK_EXTRA_BUF_EN); -diff --git a/drivers/usb/cdns3/gadget.h b/drivers/usb/cdns3/gadget.h -index 52765b098b9e1..8212bddf6c8d1 100644 ---- a/drivers/usb/cdns3/gadget.h -+++ b/drivers/usb/cdns3/gadget.h -@@ -1154,6 +1154,7 @@ struct cdns3_endpoint { - #define EP_QUIRK_EXTRA_BUF_DET BIT(12) - #define EP_QUIRK_EXTRA_BUF_EN BIT(13) - #define EP_TDLCHK_EN BIT(15) -+#define EP_CONFIGURED BIT(16) - u32 flags; - - struct cdns3_request *descmis_req; -@@ -1351,7 +1352,7 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep, - int cdns3_init_ep0(struct cdns3_device *priv_dev, - struct cdns3_endpoint *priv_ep); - void cdns3_ep0_config(struct cdns3_device *priv_dev); --void cdns3_ep_config(struct cdns3_endpoint *priv_ep); -+int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable); - void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir); - int __cdns3_gadget_wakeup(struct cdns3_device *priv_dev); - -diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c -index 24d79eec6654e..71664bfcf1bd8 100644 ---- a/drivers/usb/class/cdc-acm.c -+++ b/drivers/usb/class/cdc-acm.c -@@ -507,6 +507,7 @@ static void acm_read_bulk_callback(struct urb *urb) - "%s - cooling babbling device\n", __func__); - usb_mark_last_busy(acm->dev); - set_bit(rb->index, &acm->urbs_in_error_delay); -+ set_bit(ACM_ERROR_DELAY, &acm->flags); - cooldown = true; - break; - default: -@@ -532,7 +533,7 @@ static void acm_read_bulk_callback(struct urb *urb) - - if (stopped || stalled || cooldown) { - if (stalled) -- schedule_work(&acm->work); -+ schedule_delayed_work(&acm->dwork, 0); - else if (cooldown) - schedule_delayed_work(&acm->dwork, HZ / 2); - return; -@@ -562,13 +563,13 @@ static void acm_write_bulk(struct urb *urb) - acm_write_done(acm, wb); - spin_unlock_irqrestore(&acm->write_lock, flags); - set_bit(EVENT_TTY_WAKEUP, &acm->flags); -- schedule_work(&acm->work); -+ schedule_delayed_work(&acm->dwork, 0); - } - - static void acm_softint(struct work_struct *work) - { - int i; -- struct acm *acm = container_of(work, struct acm, work); -+ struct acm *acm = container_of(work, struct acm, dwork.work); - - if (test_bit(EVENT_RX_STALL, &acm->flags)) { - smp_mb(); /* against acm_suspend() */ -@@ -584,7 +585,7 @@ static void acm_softint(struct work_struct *work) - if (test_and_clear_bit(ACM_ERROR_DELAY, &acm->flags)) { - for (i = 0; i < acm->rx_buflimit; i++) - if (test_and_clear_bit(i, &acm->urbs_in_error_delay)) -- acm_submit_read_urb(acm, i, GFP_NOIO); -+ acm_submit_read_urb(acm, i, GFP_KERNEL); - } - - if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags)) -@@ -1364,7 +1365,6 @@ made_compressed_probe: - acm->ctrlsize = ctrlsize; - acm->readsize = readsize; - acm->rx_buflimit = num_rx_buf; -- INIT_WORK(&acm->work, acm_softint); - INIT_DELAYED_WORK(&acm->dwork, acm_softint); - init_waitqueue_head(&acm->wioctl); - spin_lock_init(&acm->write_lock); -@@ -1574,7 +1574,6 @@ static void acm_disconnect(struct usb_interface *intf) - } - - acm_kill_urbs(acm); -- cancel_work_sync(&acm->work); - cancel_delayed_work_sync(&acm->dwork); - - tty_unregister_device(acm_tty_driver, acm->minor); -@@ -1617,7 +1616,6 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message) - return 0; - - acm_kill_urbs(acm); -- cancel_work_sync(&acm->work); - cancel_delayed_work_sync(&acm->dwork); - acm->urbs_in_error_delay = 0; - -diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h -index cd5e9d8ab2375..b95ff769072e7 100644 ---- a/drivers/usb/class/cdc-acm.h -+++ b/drivers/usb/class/cdc-acm.h -@@ -112,8 +112,7 @@ struct acm { - # define ACM_ERROR_DELAY 3 - unsigned long urbs_in_error_delay; /* these need to be restarted after a delay */ - struct usb_cdc_line_coding line; /* bits, stop, parity */ -- struct work_struct work; /* work queue entry for various purposes*/ -- struct delayed_work dwork; /* for cool downs needed in error recovery */ -+ struct delayed_work dwork; /* work queue entry for various purposes */ - unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ - unsigned int ctrlout; /* output control lines (DTR, RTS) */ - struct async_icount iocount; /* counters for control line changes */ -diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c -index b351962279e4d..1b53dc9237579 100644 ---- a/drivers/usb/core/driver.c -+++ b/drivers/usb/core/driver.c -@@ -839,6 +839,22 @@ const struct usb_device_id *usb_device_match_id(struct usb_device *udev, - return NULL; - } - -+bool usb_driver_applicable(struct usb_device *udev, -+ struct usb_device_driver *udrv) -+{ -+ if (udrv->id_table && udrv->match) -+ return usb_device_match_id(udev, udrv->id_table) != NULL && -+ udrv->match(udev); -+ -+ if (udrv->id_table) -+ return usb_device_match_id(udev, udrv->id_table) != NULL; -+ -+ if (udrv->match) -+ return udrv->match(udev); -+ -+ return false; -+} -+ - static int usb_device_match(struct device *dev, struct device_driver *drv) - { - /* devices and interfaces are handled separately */ -@@ -853,17 +869,14 @@ static int usb_device_match(struct device *dev, struct device_driver *drv) - udev = to_usb_device(dev); - udrv = to_usb_device_driver(drv); - -- if (udrv->id_table) -- return usb_device_match_id(udev, udrv->id_table) != NULL; -- -- if (udrv->match) -- return udrv->match(udev); -- - /* If the device driver under consideration does not have a - * id_table or a match function, then let the driver's probe - * function decide. - */ -- return 1; -+ if (!udrv->id_table && !udrv->match) -+ return 1; -+ -+ return usb_driver_applicable(udev, udrv); - - } else if (is_usb_interface(dev)) { - struct usb_interface *intf; -@@ -941,8 +954,7 @@ static int __usb_bus_reprobe_drivers(struct device *dev, void *data) - return 0; - - udev = to_usb_device(dev); -- if (usb_device_match_id(udev, new_udriver->id_table) == NULL && -- (!new_udriver->match || new_udriver->match(udev) == 0)) -+ if (!usb_driver_applicable(udev, new_udriver)) - return 0; - - ret = device_reprobe(dev); -diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c -index 2b2f1ab6e36aa..d87175fc8a98d 100644 ---- a/drivers/usb/core/generic.c -+++ b/drivers/usb/core/generic.c -@@ -205,9 +205,7 @@ static int __check_usb_generic(struct device_driver *drv, void *data) - udrv = to_usb_device_driver(drv); - if (udrv == &usb_generic_driver) - return 0; -- if (usb_device_match_id(udev, udrv->id_table) != NULL) -- return 1; -- return (udrv->match && udrv->match(udev)); -+ return usb_driver_applicable(udev, udrv); - } - - static bool usb_generic_driver_match(struct usb_device *udev) -diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h -index 98e7d1ee63dc3..0ebaf8a784f76 100644 ---- a/drivers/usb/core/usb.h -+++ b/drivers/usb/core/usb.h -@@ -74,6 +74,8 @@ extern int usb_match_device(struct usb_device *dev, - const struct usb_device_id *id); - extern const struct usb_device_id *usb_device_match_id(struct usb_device *udev, - const struct usb_device_id *id); -+extern bool usb_driver_applicable(struct usb_device *udev, -+ struct usb_device_driver *udrv); - extern void usb_forced_unbind_intf(struct usb_interface *intf); - extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev); - -diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c -index 2f9f4ad562d4e..60b5a69409737 100644 ---- a/drivers/usb/dwc3/core.c -+++ b/drivers/usb/dwc3/core.c -@@ -121,9 +121,6 @@ static void __dwc3_set_mode(struct work_struct *work) - int ret; - u32 reg; - -- if (dwc->dr_mode != USB_DR_MODE_OTG) -- return; -- - pm_runtime_get_sync(dwc->dev); - - if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG) -@@ -209,6 +206,9 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) - { - unsigned long flags; - -+ if (dwc->dr_mode != USB_DR_MODE_OTG) -+ return; -+ - spin_lock_irqsave(&dwc->lock, flags); - dwc->desired_dr_role = mode; - spin_unlock_irqrestore(&dwc->lock, flags); -@@ -1564,6 +1564,17 @@ static int dwc3_probe(struct platform_device *pdev) - - err5: - dwc3_event_buffers_cleanup(dwc); -+ -+ usb_phy_shutdown(dwc->usb2_phy); -+ usb_phy_shutdown(dwc->usb3_phy); -+ phy_exit(dwc->usb2_generic_phy); -+ phy_exit(dwc->usb3_generic_phy); -+ -+ usb_phy_set_suspend(dwc->usb2_phy, 1); -+ usb_phy_set_suspend(dwc->usb3_phy, 1); -+ phy_power_off(dwc->usb2_generic_phy); -+ phy_power_off(dwc->usb3_generic_phy); -+ - dwc3_ulpi_exit(dwc); - - err4: -@@ -1599,9 +1610,9 @@ static int dwc3_remove(struct platform_device *pdev) - dwc3_core_exit(dwc); - dwc3_ulpi_exit(dwc); - -- pm_runtime_put_sync(&pdev->dev); -- pm_runtime_allow(&pdev->dev); - pm_runtime_disable(&pdev->dev); -+ pm_runtime_put_noidle(&pdev->dev); -+ pm_runtime_set_suspended(&pdev->dev); - - dwc3_free_event_buffers(dwc); - dwc3_free_scratch_buffers(dwc); -diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h -index ba0f743f35528..6d843e6c29410 100644 ---- a/drivers/usb/dwc3/core.h -+++ b/drivers/usb/dwc3/core.h -@@ -710,6 +710,7 @@ struct dwc3_ep { - #define DWC3_EP_IGNORE_NEXT_NOSTREAM BIT(8) - #define DWC3_EP_FORCE_RESTART_STREAM BIT(9) - #define DWC3_EP_FIRST_STREAM_PRIMED BIT(10) -+#define DWC3_EP_PENDING_CLEAR_STALL BIT(11) - - /* This last one is specific to EP0 */ - #define DWC3_EP0_DIR_IN BIT(31) -diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c -index f5a61f57c74f0..242b6210380a4 100644 ---- a/drivers/usb/dwc3/dwc3-pci.c -+++ b/drivers/usb/dwc3/dwc3-pci.c -@@ -147,7 +147,8 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) - - if (pdev->vendor == PCI_VENDOR_ID_INTEL) { - if (pdev->device == PCI_DEVICE_ID_INTEL_BXT || -- pdev->device == PCI_DEVICE_ID_INTEL_BXT_M) { -+ pdev->device == PCI_DEVICE_ID_INTEL_BXT_M || -+ pdev->device == PCI_DEVICE_ID_INTEL_EHLLP) { - guid_parse(PCI_INTEL_BXT_DSM_GUID, &dwc->guid); - dwc->has_dsm_for_pm = true; - } -diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c -index 59f2e8c31bd1b..cc816142eb95e 100644 ---- a/drivers/usb/dwc3/ep0.c -+++ b/drivers/usb/dwc3/ep0.c -@@ -524,6 +524,11 @@ static int dwc3_ep0_handle_endpoint(struct dwc3 *dwc, - ret = __dwc3_gadget_ep_set_halt(dep, set, true); - if (ret) - return -EINVAL; -+ -+ /* ClearFeature(Halt) may need delayed status */ -+ if (!set && (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) -+ return USB_GADGET_DELAYED_STATUS; -+ - break; - default: - return -EINVAL; -@@ -942,12 +947,16 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, - static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, - struct dwc3_ep *dep, struct dwc3_request *req) - { -+ unsigned int trb_length = 0; - int ret; - - req->direction = !!dep->number; - - if (req->request.length == 0) { -- dwc3_ep0_prepare_one_trb(dep, dwc->ep0_trb_addr, 0, -+ if (!req->direction) -+ trb_length = dep->endpoint.maxpacket; -+ -+ dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr, trb_length, - DWC3_TRBCTL_CONTROL_DATA, false); - ret = dwc3_ep0_start_trans(dep); - } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) -@@ -994,9 +1003,12 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, - - req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1]; - -+ if (!req->direction) -+ trb_length = dep->endpoint.maxpacket; -+ - /* Now prepare one extra TRB to align transfer size */ - dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr, -- 0, DWC3_TRBCTL_CONTROL_DATA, -+ trb_length, DWC3_TRBCTL_CONTROL_DATA, - false); - ret = dwc3_ep0_start_trans(dep); - } else { -@@ -1042,6 +1054,17 @@ static void dwc3_ep0_do_control_status(struct dwc3 *dwc, - __dwc3_ep0_do_control_status(dwc, dep); - } - -+void dwc3_ep0_send_delayed_status(struct dwc3 *dwc) -+{ -+ unsigned int direction = !dwc->ep0_expect_in; -+ -+ if (dwc->ep0state != EP0_STATUS_PHASE) -+ return; -+ -+ dwc->delayed_status = false; -+ __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); -+} -+ - static void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) - { - struct dwc3_gadget_ep_cmd_params params; -diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c -index c2a0f64f8d1e1..e822ba03d3cc3 100644 ---- a/drivers/usb/dwc3/gadget.c -+++ b/drivers/usb/dwc3/gadget.c -@@ -1095,6 +1095,8 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, - struct scatterlist *s; - int i; - unsigned int length = req->request.length; -+ unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); -+ unsigned int rem = length % maxp; - unsigned int remaining = req->request.num_mapped_sgs - - req->num_queued_sgs; - -@@ -1106,8 +1108,6 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, - length -= sg_dma_len(s); - - for_each_sg(sg, s, remaining, i) { -- unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); -- unsigned int rem = length % maxp; - unsigned int trb_length; - unsigned chain = true; - -@@ -1628,8 +1628,13 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) - if (dep->flags & DWC3_EP_WAIT_TRANSFER_COMPLETE) - return 0; - -- /* Start the transfer only after the END_TRANSFER is completed */ -- if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { -+ /* -+ * Start the transfer only after the END_TRANSFER is completed -+ * and endpoint STALL is cleared. -+ */ -+ if ((dep->flags & DWC3_EP_END_TRANSFER_PENDING) || -+ (dep->flags & DWC3_EP_WEDGE) || -+ (dep->flags & DWC3_EP_STALL)) { - dep->flags |= DWC3_EP_DELAY_START; - return 0; - } -@@ -1822,6 +1827,18 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) - return 0; - } - -+ dwc3_stop_active_transfer(dep, true, true); -+ -+ list_for_each_entry_safe(req, tmp, &dep->started_list, list) -+ dwc3_gadget_move_cancelled_request(req); -+ -+ if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { -+ dep->flags |= DWC3_EP_PENDING_CLEAR_STALL; -+ return 0; -+ } -+ -+ dwc3_gadget_ep_cleanup_cancelled_requests(dep); -+ - ret = dwc3_send_clear_stall_ep_cmd(dep); - if (ret) { - dev_err(dwc->dev, "failed to clear STALL on %s\n", -@@ -1831,18 +1848,11 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) - - dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); - -- dwc3_stop_active_transfer(dep, true, true); -- -- list_for_each_entry_safe(req, tmp, &dep->started_list, list) -- dwc3_gadget_move_cancelled_request(req); -- -- list_for_each_entry_safe(req, tmp, &dep->pending_list, list) -- dwc3_gadget_move_cancelled_request(req); -+ if ((dep->flags & DWC3_EP_DELAY_START) && -+ !usb_endpoint_xfer_isoc(dep->endpoint.desc)) -+ __dwc3_gadget_kick_transfer(dep); - -- if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) { -- dep->flags &= ~DWC3_EP_DELAY_START; -- dwc3_gadget_ep_cleanup_cancelled_requests(dep); -- } -+ dep->flags &= ~DWC3_EP_DELAY_START; - } - - return ret; -@@ -2732,6 +2742,11 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, - ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, - status); - -+ req->request.actual = req->request.length - req->remaining; -+ -+ if (!dwc3_gadget_ep_request_completed(req)) -+ goto out; -+ - if (req->needs_extra_trb) { - unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); - -@@ -2747,11 +2762,6 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, - req->needs_extra_trb = false; - } - -- req->request.actual = req->request.length - req->remaining; -- -- if (!dwc3_gadget_ep_request_completed(req)) -- goto out; -- - dwc3_gadget_giveback(dep, req, status); - - out: -@@ -2997,6 +3007,26 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, - dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; - dep->flags &= ~DWC3_EP_TRANSFER_STARTED; - dwc3_gadget_ep_cleanup_cancelled_requests(dep); -+ -+ if (dep->flags & DWC3_EP_PENDING_CLEAR_STALL) { -+ struct dwc3 *dwc = dep->dwc; -+ -+ dep->flags &= ~DWC3_EP_PENDING_CLEAR_STALL; -+ if (dwc3_send_clear_stall_ep_cmd(dep)) { -+ struct usb_ep *ep0 = &dwc->eps[0]->endpoint; -+ -+ dev_err(dwc->dev, "failed to clear STALL on %s\n", -+ dep->name); -+ if (dwc->delayed_status) -+ __dwc3_gadget_ep0_set_halt(ep0, 1); -+ return; -+ } -+ -+ dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); -+ if (dwc->delayed_status) -+ dwc3_ep0_send_delayed_status(dwc); -+ } -+ - if ((dep->flags & DWC3_EP_DELAY_START) && - !usb_endpoint_xfer_isoc(dep->endpoint.desc)) - __dwc3_gadget_kick_transfer(dep); -diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h -index bd85eb7fa9ef8..a7791cb827c49 100644 ---- a/drivers/usb/dwc3/gadget.h -+++ b/drivers/usb/dwc3/gadget.h -@@ -113,6 +113,7 @@ 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 protocol); -+void dwc3_ep0_send_delayed_status(struct dwc3 *dwc); - - /** - * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW -diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c -index e077b2ca53c51..869d9c4de5fcd 100644 ---- a/drivers/usb/host/ehci-tegra.c -+++ b/drivers/usb/host/ehci-tegra.c -@@ -479,8 +479,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) - u_phy->otg->host = hcd_to_bus(hcd); - - irq = platform_get_irq(pdev, 0); -- if (!irq) { -- err = -ENODEV; -+ if (irq < 0) { -+ err = irq; - goto cleanup_phy; - } - -diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c -index ae8f60f6e6a5e..44a7e58a26e3d 100644 ---- a/drivers/usb/host/fsl-mph-dr-of.c -+++ b/drivers/usb/host/fsl-mph-dr-of.c -@@ -94,10 +94,13 @@ static struct platform_device *fsl_usb2_device_register( - - pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; - -- if (!pdev->dev.dma_mask) -+ if (!pdev->dev.dma_mask) { - pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask; -- else -- dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); -+ } else { -+ retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); -+ if (retval) -+ goto error; -+ } - - retval = platform_device_add_data(pdev, pdata, sizeof(*pdata)); - if (retval) -diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c -index 3feaafebfe581..90a1a750c150d 100644 ---- a/drivers/usb/host/xhci-pci.c -+++ b/drivers/usb/host/xhci-pci.c -@@ -22,6 +22,8 @@ - #define SSIC_PORT_CFG2_OFFSET 0x30 - #define PROG_DONE (1 << 30) - #define SSIC_PORT_UNUSED (1 << 31) -+#define SPARSE_DISABLE_BIT 17 -+#define SPARSE_CNTL_ENABLE 0xC12C - - /* Device for a quirk */ - #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 -@@ -160,6 +162,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) - (pdev->device == 0x15e0 || pdev->device == 0x15e1)) - xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND; - -+ if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5) -+ xhci->quirks |= XHCI_DISABLE_SPARSE; -+ - if (pdev->vendor == PCI_VENDOR_ID_AMD) - xhci->quirks |= XHCI_TRUST_TX_LENGTH; - -@@ -490,6 +495,15 @@ static void xhci_pme_quirk(struct usb_hcd *hcd) - readl(reg); - } - -+static void xhci_sparse_control_quirk(struct usb_hcd *hcd) -+{ -+ u32 reg; -+ -+ reg = readl(hcd->regs + SPARSE_CNTL_ENABLE); -+ reg &= ~BIT(SPARSE_DISABLE_BIT); -+ writel(reg, hcd->regs + SPARSE_CNTL_ENABLE); -+} -+ - static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) - { - struct xhci_hcd *xhci = hcd_to_xhci(hcd); -@@ -509,6 +523,9 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) - if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) - xhci_ssic_port_unused_quirk(hcd, true); - -+ if (xhci->quirks & XHCI_DISABLE_SPARSE) -+ xhci_sparse_control_quirk(hcd); -+ - ret = xhci_suspend(xhci, do_wakeup); - if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED)) - xhci_ssic_port_unused_quirk(hcd, false); -diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c -index e534f524b7f87..e88f4f9539955 100644 ---- a/drivers/usb/host/xhci.c -+++ b/drivers/usb/host/xhci.c -@@ -982,12 +982,15 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) - xhci->shared_hcd->state != HC_STATE_SUSPENDED) - return -EINVAL; - -- xhci_dbc_suspend(xhci); -- - /* Clear root port wake on bits if wakeup not allowed. */ - if (!do_wakeup) - xhci_disable_port_wake_on_bits(xhci); - -+ if (!HCD_HW_ACCESSIBLE(hcd)) -+ return 0; -+ -+ xhci_dbc_suspend(xhci); -+ - /* Don't poll the roothubs on bus suspend. */ - xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); -diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h -index ea1754f185a22..564945eae5022 100644 ---- a/drivers/usb/host/xhci.h -+++ b/drivers/usb/host/xhci.h -@@ -1874,6 +1874,7 @@ struct xhci_hcd { - #define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34) - #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) - #define XHCI_RENESAS_FW_QUIRK BIT_ULL(36) -+#define XHCI_DISABLE_SPARSE BIT_ULL(38) - - unsigned int num_active_eps; - unsigned int limit_active_eps; -diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c -index a7eefe11f31aa..45a3879799352 100644 ---- a/drivers/usb/misc/adutux.c -+++ b/drivers/usb/misc/adutux.c -@@ -209,6 +209,7 @@ static void adu_interrupt_out_callback(struct urb *urb) - - if (status != 0) { - if ((status != -ENOENT) && -+ (status != -ESHUTDOWN) && - (status != -ECONNRESET)) { - dev_dbg(&dev->udev->dev, - "%s :nonzero status received: %d\n", __func__, -diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c -index b403094a6b3a5..579d8c84de42c 100644 ---- a/drivers/usb/misc/apple-mfi-fastcharge.c -+++ b/drivers/usb/misc/apple-mfi-fastcharge.c -@@ -163,17 +163,23 @@ static const struct power_supply_desc apple_mfi_fc_desc = { - .property_is_writeable = apple_mfi_fc_property_is_writeable - }; - -+static bool mfi_fc_match(struct usb_device *udev) -+{ -+ int idProduct; -+ -+ idProduct = le16_to_cpu(udev->descriptor.idProduct); -+ /* See comment above mfi_fc_id_table[] */ -+ return (idProduct >= 0x1200 && idProduct <= 0x12ff); -+} -+ - static int mfi_fc_probe(struct usb_device *udev) - { - struct power_supply_config battery_cfg = {}; - struct mfi_device *mfi = NULL; -- int err, idProduct; -+ int err; - -- idProduct = le16_to_cpu(udev->descriptor.idProduct); -- /* See comment above mfi_fc_id_table[] */ -- if (idProduct < 0x1200 || idProduct > 0x12ff) { -+ if (!mfi_fc_match(udev)) - return -ENODEV; -- } - - mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL); - if (!mfi) { -@@ -220,6 +226,7 @@ static struct usb_device_driver mfi_fc_driver = { - .probe = mfi_fc_probe, - .disconnect = mfi_fc_disconnect, - .id_table = mfi_fc_id_table, -+ .match = mfi_fc_match, - .generic_subclass = 1, - }; - -diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c -index a48e3f90d1961..af1b02f3e35f1 100644 ---- a/drivers/usb/typec/tcpm/tcpm.c -+++ b/drivers/usb/typec/tcpm/tcpm.c -@@ -2789,6 +2789,9 @@ static void tcpm_reset_port(struct tcpm_port *port) - - static void tcpm_detach(struct tcpm_port *port) - { -+ if (tcpm_port_is_disconnected(port)) -+ port->hard_reset_count = 0; -+ - if (!port->attached) - return; - -@@ -2797,9 +2800,6 @@ static void tcpm_detach(struct tcpm_port *port) - port->tcpc->set_bist_data(port->tcpc, false); - } - -- if (tcpm_port_is_disconnected(port)) -- port->hard_reset_count = 0; -- - tcpm_reset_port(port); - } - -@@ -3573,7 +3573,7 @@ static void run_state_machine(struct tcpm_port *port) - */ - tcpm_set_pwr_role(port, TYPEC_SOURCE); - tcpm_pd_send_control(port, PD_CTRL_PS_RDY); -- tcpm_set_state(port, SRC_STARTUP, 0); -+ tcpm_set_state(port, SRC_STARTUP, PD_T_SWAP_SRC_START); - break; - - case VCONN_SWAP_ACCEPT: -diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c -index ef1c550f82662..4b6195666c589 100644 ---- a/drivers/vdpa/mlx5/core/mr.c -+++ b/drivers/vdpa/mlx5/core/mr.c -@@ -239,7 +239,6 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr - u64 paend; - struct scatterlist *sg; - struct device *dma = mvdev->mdev->device; -- int ret; - - for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); - map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { -@@ -277,8 +276,8 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr - done: - mr->log_size = log_entity_size; - mr->nsg = nsg; -- ret = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0); -- if (!ret) -+ err = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0); -+ if (!err) - goto err_map; - - err = create_direct_mr(mvdev, mr); -diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c -index 62d6403271450..995a13244d9c6 100644 ---- a/drivers/vdpa/vdpa_sim/vdpa_sim.c -+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c -@@ -60,7 +60,8 @@ struct vdpasim_virtqueue { - - static u64 vdpasim_features = (1ULL << VIRTIO_F_ANY_LAYOUT) | - (1ULL << VIRTIO_F_VERSION_1) | -- (1ULL << VIRTIO_F_ACCESS_PLATFORM); -+ (1ULL << VIRTIO_F_ACCESS_PLATFORM) | -+ (1ULL << VIRTIO_NET_F_MAC); - - /* State of each vdpasim device */ - struct vdpasim { -@@ -361,7 +362,9 @@ static struct vdpasim *vdpasim_create(void) - spin_lock_init(&vdpasim->iommu_lock); - - dev = &vdpasim->vdpa.dev; -- dev->coherent_dma_mask = DMA_BIT_MASK(64); -+ dev->dma_mask = &dev->coherent_dma_mask; -+ if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) -+ goto err_iommu; - set_dma_ops(dev, &vdpasim_dma_ops); - - vdpasim->iommu = vhost_iotlb_alloc(2048, 0); -diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c -index 62a9bb0efc558..676175bd9a679 100644 ---- a/drivers/vhost/vdpa.c -+++ b/drivers/vhost/vdpa.c -@@ -428,12 +428,11 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, - void __user *argp = (void __user *)arg; - u64 __user *featurep = argp; - u64 features; -- long r; -+ long r = 0; - - if (cmd == VHOST_SET_BACKEND_FEATURES) { -- r = copy_from_user(&features, featurep, sizeof(features)); -- if (r) -- return r; -+ if (copy_from_user(&features, featurep, sizeof(features))) -+ return -EFAULT; - if (features & ~VHOST_VDPA_BACKEND_FEATURES) - return -EOPNOTSUPP; - vhost_set_backend_features(&v->vdev, features); -@@ -476,7 +475,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, - break; - case VHOST_GET_BACKEND_FEATURES: - features = VHOST_VDPA_BACKEND_FEATURES; -- r = copy_to_user(featurep, &features, sizeof(features)); -+ if (copy_to_user(featurep, &features, sizeof(features))) -+ r = -EFAULT; - break; - default: - r = vhost_dev_ioctl(&v->vdev, cmd, argp); -@@ -595,19 +595,21 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, - struct vhost_dev *dev = &v->vdev; - struct vhost_iotlb *iotlb = dev->iotlb; - struct page **page_list; -- struct vm_area_struct **vmas; -+ unsigned long list_size = PAGE_SIZE / sizeof(struct page *); - unsigned int gup_flags = FOLL_LONGTERM; -- unsigned long map_pfn, last_pfn = 0; -- unsigned long npages, lock_limit; -- unsigned long i, nmap = 0; -+ unsigned long npages, cur_base, map_pfn, last_pfn = 0; -+ unsigned long locked, lock_limit, pinned, i; - u64 iova = msg->iova; -- long pinned; - int ret = 0; - - if (vhost_iotlb_itree_first(iotlb, msg->iova, - msg->iova + msg->size - 1)) - return -EEXIST; - -+ page_list = (struct page **) __get_free_page(GFP_KERNEL); -+ if (!page_list) -+ return -ENOMEM; -+ - if (msg->perm & VHOST_ACCESS_WO) - gup_flags |= FOLL_WRITE; - -@@ -615,86 +617,61 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, - if (!npages) - return -EINVAL; - -- page_list = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL); -- vmas = kvmalloc_array(npages, sizeof(struct vm_area_struct *), -- GFP_KERNEL); -- if (!page_list || !vmas) { -- ret = -ENOMEM; -- goto free; -- } -- - mmap_read_lock(dev->mm); - -+ locked = atomic64_add_return(npages, &dev->mm->pinned_vm); - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; -- if (npages + atomic64_read(&dev->mm->pinned_vm) > lock_limit) { -- ret = -ENOMEM; -- goto unlock; -- } - -- pinned = pin_user_pages(msg->uaddr & PAGE_MASK, npages, gup_flags, -- page_list, vmas); -- if (npages != pinned) { -- if (pinned < 0) { -- ret = pinned; -- } else { -- unpin_user_pages(page_list, pinned); -- ret = -ENOMEM; -- } -- goto unlock; -+ if (locked > lock_limit) { -+ ret = -ENOMEM; -+ goto out; - } - -+ cur_base = msg->uaddr & PAGE_MASK; - iova &= PAGE_MASK; -- map_pfn = page_to_pfn(page_list[0]); -- -- /* One more iteration to avoid extra vdpa_map() call out of loop. */ -- for (i = 0; i <= npages; i++) { -- unsigned long this_pfn; -- u64 csize; -- -- /* The last chunk may have no valid PFN next to it */ -- this_pfn = i < npages ? page_to_pfn(page_list[i]) : -1UL; -- -- if (last_pfn && (this_pfn == -1UL || -- this_pfn != last_pfn + 1)) { -- /* Pin a contiguous chunk of memory */ -- csize = last_pfn - map_pfn + 1; -- ret = vhost_vdpa_map(v, iova, csize << PAGE_SHIFT, -- map_pfn << PAGE_SHIFT, -- msg->perm); -- if (ret) { -- /* -- * Unpin the rest chunks of memory on the -- * flight with no corresponding vdpa_map() -- * calls having been made yet. On the other -- * hand, vdpa_unmap() in the failure path -- * is in charge of accounting the number of -- * pinned pages for its own. -- * This asymmetrical pattern of accounting -- * is for efficiency to pin all pages at -- * once, while there is no other callsite -- * of vdpa_map() than here above. -- */ -- unpin_user_pages(&page_list[nmap], -- npages - nmap); -- goto out; -+ -+ while (npages) { -+ pinned = min_t(unsigned long, npages, list_size); -+ ret = pin_user_pages(cur_base, pinned, -+ gup_flags, page_list, NULL); -+ if (ret != pinned) -+ goto out; -+ -+ if (!last_pfn) -+ map_pfn = page_to_pfn(page_list[0]); -+ -+ for (i = 0; i < ret; i++) { -+ unsigned long this_pfn = page_to_pfn(page_list[i]); -+ u64 csize; -+ -+ if (last_pfn && (this_pfn != last_pfn + 1)) { -+ /* Pin a contiguous chunk of memory */ -+ csize = (last_pfn - map_pfn + 1) << PAGE_SHIFT; -+ if (vhost_vdpa_map(v, iova, csize, -+ map_pfn << PAGE_SHIFT, -+ msg->perm)) -+ goto out; -+ map_pfn = this_pfn; -+ iova += csize; - } -- atomic64_add(csize, &dev->mm->pinned_vm); -- nmap += csize; -- iova += csize << PAGE_SHIFT; -- map_pfn = this_pfn; -+ -+ last_pfn = this_pfn; - } -- last_pfn = this_pfn; -+ -+ cur_base += ret << PAGE_SHIFT; -+ npages -= ret; - } - -- WARN_ON(nmap != npages); -+ /* Pin the rest chunk */ -+ ret = vhost_vdpa_map(v, iova, (last_pfn - map_pfn + 1) << PAGE_SHIFT, -+ map_pfn << PAGE_SHIFT, msg->perm); - out: -- if (ret) -+ if (ret) { - vhost_vdpa_unmap(v, msg->iova, msg->size); --unlock: -+ atomic64_sub(npages, &dev->mm->pinned_vm); -+ } - mmap_read_unlock(dev->mm); --free: -- kvfree(vmas); -- kvfree(page_list); -+ free_page((unsigned long)page_list); - return ret; - } - -diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c -index e059a9a47cdf1..8bd8b403f0872 100644 ---- a/drivers/vhost/vringh.c -+++ b/drivers/vhost/vringh.c -@@ -284,13 +284,14 @@ __vringh_iov(struct vringh *vrh, u16 i, - desc_max = vrh->vring.num; - up_next = -1; - -+ /* You must want something! */ -+ if (WARN_ON(!riov && !wiov)) -+ return -EINVAL; -+ - if (riov) - riov->i = riov->used = 0; -- else if (wiov) -+ if (wiov) - wiov->i = wiov->used = 0; -- else -- /* You must want something! */ -- BUG(); - - for (;;) { - void *addr; -diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c -index 2d9f69b93392a..f4add36cb5f4d 100644 ---- a/drivers/video/fbdev/pvr2fb.c -+++ b/drivers/video/fbdev/pvr2fb.c -@@ -1028,6 +1028,8 @@ static int __init pvr2fb_setup(char *options) - if (!options || !*options) - return 0; - -+ cable_arg[0] = output_arg[0] = 0; -+ - while ((this_opt = strsep(&options, ","))) { - if (!*this_opt) - continue; -diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c -index 1ca880e014769..090cbbf9e1e22 100644 ---- a/drivers/w1/masters/mxc_w1.c -+++ b/drivers/w1/masters/mxc_w1.c -@@ -7,7 +7,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include -@@ -40,12 +40,12 @@ struct mxc_w1_device { - static u8 mxc_w1_ds2_reset_bus(void *data) - { - struct mxc_w1_device *dev = data; -- unsigned long timeout; -+ ktime_t timeout; - - writeb(MXC_W1_CONTROL_RPP, dev->regs + MXC_W1_CONTROL); - - /* Wait for reset sequence 511+512us, use 1500us for sure */ -- timeout = jiffies + usecs_to_jiffies(1500); -+ timeout = ktime_add_us(ktime_get(), 1500); - - udelay(511 + 512); - -@@ -55,7 +55,7 @@ static u8 mxc_w1_ds2_reset_bus(void *data) - /* PST bit is valid after the RPP bit is self-cleared */ - if (!(ctrl & MXC_W1_CONTROL_RPP)) - return !(ctrl & MXC_W1_CONTROL_PST); -- } while (time_is_after_jiffies(timeout)); -+ } while (ktime_before(ktime_get(), timeout)); - - return 1; - } -@@ -68,12 +68,12 @@ static u8 mxc_w1_ds2_reset_bus(void *data) - static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit) - { - struct mxc_w1_device *dev = data; -- unsigned long timeout; -+ ktime_t timeout; - - writeb(MXC_W1_CONTROL_WR(bit), dev->regs + MXC_W1_CONTROL); - - /* Wait for read/write bit (60us, Max 120us), use 200us for sure */ -- timeout = jiffies + usecs_to_jiffies(200); -+ timeout = ktime_add_us(ktime_get(), 200); - - udelay(60); - -@@ -83,7 +83,7 @@ static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit) - /* RDST bit is valid after the WR1/RD bit is self-cleared */ - if (!(ctrl & MXC_W1_CONTROL_WR(bit))) - return !!(ctrl & MXC_W1_CONTROL_RDST); -- } while (time_is_after_jiffies(timeout)); -+ } while (ktime_before(ktime_get(), timeout)); - - return 0; - } -diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c -index 57187efeb86f1..f0c94ea51c3e4 100644 ---- a/drivers/watchdog/rdc321x_wdt.c -+++ b/drivers/watchdog/rdc321x_wdt.c -@@ -231,6 +231,8 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) - - rdc321x_wdt_device.sb_pdev = pdata->sb_pdev; - rdc321x_wdt_device.base_reg = r->start; -+ rdc321x_wdt_device.queue = 0; -+ rdc321x_wdt_device.default_ticks = ticks; - - err = misc_register(&rdc321x_wdt_misc); - if (err < 0) { -@@ -245,14 +247,11 @@ static int rdc321x_wdt_probe(struct platform_device *pdev) - rdc321x_wdt_device.base_reg, RDC_WDT_RST); - - init_completion(&rdc321x_wdt_device.stop); -- rdc321x_wdt_device.queue = 0; - - clear_bit(0, &rdc321x_wdt_device.inuse); - - timer_setup(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0); - -- rdc321x_wdt_device.default_ticks = ticks; -- - dev_info(&pdev->dev, "watchdog init success\n"); - - return 0; -diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c -index 64df919a2111b..fe5ad0e89cd8a 100644 ---- a/drivers/xen/events/events_2l.c -+++ b/drivers/xen/events/events_2l.c -@@ -91,6 +91,8 @@ static void evtchn_2l_unmask(evtchn_port_t port) - - BUG_ON(!irqs_disabled()); - -+ smp_wmb(); /* All writes before unmask must be visible. */ -+ - if (unlikely((cpu != cpu_from_evtchn(port)))) - do_hypercall = 1; - else { -@@ -159,7 +161,7 @@ static inline xen_ulong_t active_evtchns(unsigned int cpu, - * a bitset of words which contain pending event bits. The second - * level is a bitset of pending events themselves. - */ --static void evtchn_2l_handle_events(unsigned cpu) -+static void evtchn_2l_handle_events(unsigned cpu, struct evtchn_loop_ctrl *ctrl) - { - int irq; - xen_ulong_t pending_words; -@@ -240,10 +242,7 @@ static void evtchn_2l_handle_events(unsigned cpu) - - /* Process port. */ - port = (word_idx * BITS_PER_EVTCHN_WORD) + bit_idx; -- irq = get_evtchn_to_irq(port); -- -- if (irq != -1) -- generic_handle_irq(irq); -+ handle_irq_for_port(port, ctrl); - - bit_idx = (bit_idx + 1) % BITS_PER_EVTCHN_WORD; - -diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c -index 6f02c18fa65c8..cc317739e7860 100644 ---- a/drivers/xen/events/events_base.c -+++ b/drivers/xen/events/events_base.c -@@ -33,6 +33,10 @@ - #include - #include - #include -+#include -+#include -+#include -+#include - - #ifdef CONFIG_X86 - #include -@@ -63,6 +67,15 @@ - - #include "events_internal.h" - -+#undef MODULE_PARAM_PREFIX -+#define MODULE_PARAM_PREFIX "xen." -+ -+static uint __read_mostly event_loop_timeout = 2; -+module_param(event_loop_timeout, uint, 0644); -+ -+static uint __read_mostly event_eoi_delay = 10; -+module_param(event_eoi_delay, uint, 0644); -+ - const struct evtchn_ops *evtchn_ops; - - /* -@@ -71,6 +84,24 @@ const struct evtchn_ops *evtchn_ops; - */ - static DEFINE_MUTEX(irq_mapping_update_lock); - -+/* -+ * Lock protecting event handling loop against removing event channels. -+ * Adding of event channels is no issue as the associated IRQ becomes active -+ * only after everything is setup (before request_[threaded_]irq() the handler -+ * can't be entered for an event, as the event channel will be unmasked only -+ * then). -+ */ -+static DEFINE_RWLOCK(evtchn_rwlock); -+ -+/* -+ * Lock hierarchy: -+ * -+ * irq_mapping_update_lock -+ * evtchn_rwlock -+ * IRQ-desc lock -+ * percpu eoi_list_lock -+ */ -+ - static LIST_HEAD(xen_irq_list_head); - - /* IRQ <-> VIRQ mapping. */ -@@ -95,17 +126,20 @@ static bool (*pirq_needs_eoi)(unsigned irq); - static struct irq_info *legacy_info_ptrs[NR_IRQS_LEGACY]; - - static struct irq_chip xen_dynamic_chip; -+static struct irq_chip xen_lateeoi_chip; - static struct irq_chip xen_percpu_chip; - static struct irq_chip xen_pirq_chip; - static void enable_dynirq(struct irq_data *data); - static void disable_dynirq(struct irq_data *data); - -+static DEFINE_PER_CPU(unsigned int, irq_epoch); -+ - static void clear_evtchn_to_irq_row(unsigned row) - { - unsigned col; - - for (col = 0; col < EVTCHN_PER_ROW; col++) -- evtchn_to_irq[row][col] = -1; -+ WRITE_ONCE(evtchn_to_irq[row][col], -1); - } - - static void clear_evtchn_to_irq_all(void) -@@ -142,7 +176,7 @@ static int set_evtchn_to_irq(evtchn_port_t evtchn, unsigned int irq) - clear_evtchn_to_irq_row(row); - } - -- evtchn_to_irq[row][col] = irq; -+ WRITE_ONCE(evtchn_to_irq[row][col], irq); - return 0; - } - -@@ -152,7 +186,7 @@ int get_evtchn_to_irq(evtchn_port_t evtchn) - return -1; - if (evtchn_to_irq[EVTCHN_ROW(evtchn)] == NULL) - return -1; -- return evtchn_to_irq[EVTCHN_ROW(evtchn)][EVTCHN_COL(evtchn)]; -+ return READ_ONCE(evtchn_to_irq[EVTCHN_ROW(evtchn)][EVTCHN_COL(evtchn)]); - } - - /* Get info for IRQ */ -@@ -261,10 +295,14 @@ static void xen_irq_info_cleanup(struct irq_info *info) - */ - evtchn_port_t evtchn_from_irq(unsigned irq) - { -- if (WARN(irq >= nr_irqs, "Invalid irq %d!\n", irq)) -+ const struct irq_info *info = NULL; -+ -+ if (likely(irq < nr_irqs)) -+ info = info_for_irq(irq); -+ if (!info) - return 0; - -- return info_for_irq(irq)->evtchn; -+ return info->evtchn; - } - - unsigned int irq_from_evtchn(evtchn_port_t evtchn) -@@ -375,9 +413,157 @@ void notify_remote_via_irq(int irq) - } - EXPORT_SYMBOL_GPL(notify_remote_via_irq); - -+struct lateeoi_work { -+ struct delayed_work delayed; -+ spinlock_t eoi_list_lock; -+ struct list_head eoi_list; -+}; -+ -+static DEFINE_PER_CPU(struct lateeoi_work, lateeoi); -+ -+static void lateeoi_list_del(struct irq_info *info) -+{ -+ struct lateeoi_work *eoi = &per_cpu(lateeoi, info->eoi_cpu); -+ unsigned long flags; -+ -+ spin_lock_irqsave(&eoi->eoi_list_lock, flags); -+ list_del_init(&info->eoi_list); -+ spin_unlock_irqrestore(&eoi->eoi_list_lock, flags); -+} -+ -+static void lateeoi_list_add(struct irq_info *info) -+{ -+ struct lateeoi_work *eoi = &per_cpu(lateeoi, info->eoi_cpu); -+ struct irq_info *elem; -+ u64 now = get_jiffies_64(); -+ unsigned long delay; -+ unsigned long flags; -+ -+ if (now < info->eoi_time) -+ delay = info->eoi_time - now; -+ else -+ delay = 1; -+ -+ spin_lock_irqsave(&eoi->eoi_list_lock, flags); -+ -+ if (list_empty(&eoi->eoi_list)) { -+ list_add(&info->eoi_list, &eoi->eoi_list); -+ mod_delayed_work_on(info->eoi_cpu, system_wq, -+ &eoi->delayed, delay); -+ } else { -+ list_for_each_entry_reverse(elem, &eoi->eoi_list, eoi_list) { -+ if (elem->eoi_time <= info->eoi_time) -+ break; -+ } -+ list_add(&info->eoi_list, &elem->eoi_list); -+ } -+ -+ spin_unlock_irqrestore(&eoi->eoi_list_lock, flags); -+} -+ -+static void xen_irq_lateeoi_locked(struct irq_info *info, bool spurious) -+{ -+ evtchn_port_t evtchn; -+ unsigned int cpu; -+ unsigned int delay = 0; -+ -+ evtchn = info->evtchn; -+ if (!VALID_EVTCHN(evtchn) || !list_empty(&info->eoi_list)) -+ return; -+ -+ if (spurious) { -+ if ((1 << info->spurious_cnt) < (HZ << 2)) -+ info->spurious_cnt++; -+ if (info->spurious_cnt > 1) { -+ delay = 1 << (info->spurious_cnt - 2); -+ if (delay > HZ) -+ delay = HZ; -+ if (!info->eoi_time) -+ info->eoi_cpu = smp_processor_id(); -+ info->eoi_time = get_jiffies_64() + delay; -+ } -+ } else { -+ info->spurious_cnt = 0; -+ } -+ -+ cpu = info->eoi_cpu; -+ if (info->eoi_time && -+ (info->irq_epoch == per_cpu(irq_epoch, cpu) || delay)) { -+ lateeoi_list_add(info); -+ return; -+ } -+ -+ info->eoi_time = 0; -+ unmask_evtchn(evtchn); -+} -+ -+static void xen_irq_lateeoi_worker(struct work_struct *work) -+{ -+ struct lateeoi_work *eoi; -+ struct irq_info *info; -+ u64 now = get_jiffies_64(); -+ unsigned long flags; -+ -+ eoi = container_of(to_delayed_work(work), struct lateeoi_work, delayed); -+ -+ read_lock_irqsave(&evtchn_rwlock, flags); -+ -+ while (true) { -+ spin_lock(&eoi->eoi_list_lock); -+ -+ info = list_first_entry_or_null(&eoi->eoi_list, struct irq_info, -+ eoi_list); -+ -+ if (info == NULL || now < info->eoi_time) { -+ spin_unlock(&eoi->eoi_list_lock); -+ break; -+ } -+ -+ list_del_init(&info->eoi_list); -+ -+ spin_unlock(&eoi->eoi_list_lock); -+ -+ info->eoi_time = 0; -+ -+ xen_irq_lateeoi_locked(info, false); -+ } -+ -+ if (info) -+ mod_delayed_work_on(info->eoi_cpu, system_wq, -+ &eoi->delayed, info->eoi_time - now); -+ -+ read_unlock_irqrestore(&evtchn_rwlock, flags); -+} -+ -+static void xen_cpu_init_eoi(unsigned int cpu) -+{ -+ struct lateeoi_work *eoi = &per_cpu(lateeoi, cpu); -+ -+ INIT_DELAYED_WORK(&eoi->delayed, xen_irq_lateeoi_worker); -+ spin_lock_init(&eoi->eoi_list_lock); -+ INIT_LIST_HEAD(&eoi->eoi_list); -+} -+ -+void xen_irq_lateeoi(unsigned int irq, unsigned int eoi_flags) -+{ -+ struct irq_info *info; -+ unsigned long flags; -+ -+ read_lock_irqsave(&evtchn_rwlock, flags); -+ -+ info = info_for_irq(irq); -+ -+ if (info) -+ xen_irq_lateeoi_locked(info, eoi_flags & XEN_EOI_FLAG_SPURIOUS); -+ -+ read_unlock_irqrestore(&evtchn_rwlock, flags); -+} -+EXPORT_SYMBOL_GPL(xen_irq_lateeoi); -+ - static void xen_irq_init(unsigned irq) - { - struct irq_info *info; -+ - #ifdef CONFIG_SMP - /* By default all event channels notify CPU#0. */ - cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(0)); -@@ -392,6 +578,7 @@ static void xen_irq_init(unsigned irq) - - set_info_for_irq(irq, info); - -+ INIT_LIST_HEAD(&info->eoi_list); - list_add_tail(&info->list, &xen_irq_list_head); - } - -@@ -440,16 +627,24 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi) - static void xen_free_irq(unsigned irq) - { - struct irq_info *info = info_for_irq(irq); -+ unsigned long flags; - - if (WARN_ON(!info)) - return; - -+ write_lock_irqsave(&evtchn_rwlock, flags); -+ -+ if (!list_empty(&info->eoi_list)) -+ lateeoi_list_del(info); -+ - list_del(&info->list); - - set_info_for_irq(irq, NULL); - - WARN_ON(info->refcnt > 0); - -+ write_unlock_irqrestore(&evtchn_rwlock, flags); -+ - kfree(info); - - /* Legacy IRQ descriptors are managed by the arch. */ -@@ -841,7 +1036,7 @@ int xen_pirq_from_irq(unsigned irq) - } - EXPORT_SYMBOL_GPL(xen_pirq_from_irq); - --int bind_evtchn_to_irq(evtchn_port_t evtchn) -+static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip) - { - int irq; - int ret; -@@ -858,7 +1053,7 @@ int bind_evtchn_to_irq(evtchn_port_t evtchn) - if (irq < 0) - goto out; - -- irq_set_chip_and_handler_name(irq, &xen_dynamic_chip, -+ irq_set_chip_and_handler_name(irq, chip, - handle_edge_irq, "event"); - - ret = xen_irq_info_evtchn_setup(irq, evtchn); -@@ -879,8 +1074,19 @@ out: - - return irq; - } -+ -+int bind_evtchn_to_irq(evtchn_port_t evtchn) -+{ -+ return bind_evtchn_to_irq_chip(evtchn, &xen_dynamic_chip); -+} - EXPORT_SYMBOL_GPL(bind_evtchn_to_irq); - -+int bind_evtchn_to_irq_lateeoi(evtchn_port_t evtchn) -+{ -+ return bind_evtchn_to_irq_chip(evtchn, &xen_lateeoi_chip); -+} -+EXPORT_SYMBOL_GPL(bind_evtchn_to_irq_lateeoi); -+ - static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) - { - struct evtchn_bind_ipi bind_ipi; -@@ -922,8 +1128,9 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) - return irq; - } - --int bind_interdomain_evtchn_to_irq(unsigned int remote_domain, -- evtchn_port_t remote_port) -+static int bind_interdomain_evtchn_to_irq_chip(unsigned int remote_domain, -+ evtchn_port_t remote_port, -+ struct irq_chip *chip) - { - struct evtchn_bind_interdomain bind_interdomain; - int err; -@@ -934,10 +1141,26 @@ int bind_interdomain_evtchn_to_irq(unsigned int remote_domain, - err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, - &bind_interdomain); - -- return err ? : bind_evtchn_to_irq(bind_interdomain.local_port); -+ return err ? : bind_evtchn_to_irq_chip(bind_interdomain.local_port, -+ chip); -+} -+ -+int bind_interdomain_evtchn_to_irq(unsigned int remote_domain, -+ evtchn_port_t remote_port) -+{ -+ return bind_interdomain_evtchn_to_irq_chip(remote_domain, remote_port, -+ &xen_dynamic_chip); - } - EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irq); - -+int bind_interdomain_evtchn_to_irq_lateeoi(unsigned int remote_domain, -+ evtchn_port_t remote_port) -+{ -+ return bind_interdomain_evtchn_to_irq_chip(remote_domain, remote_port, -+ &xen_lateeoi_chip); -+} -+EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irq_lateeoi); -+ - static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn) - { - struct evtchn_status status; -@@ -1034,14 +1257,15 @@ static void unbind_from_irq(unsigned int irq) - mutex_unlock(&irq_mapping_update_lock); - } - --int bind_evtchn_to_irqhandler(evtchn_port_t evtchn, -- irq_handler_t handler, -- unsigned long irqflags, -- const char *devname, void *dev_id) -+static int bind_evtchn_to_irqhandler_chip(evtchn_port_t evtchn, -+ irq_handler_t handler, -+ unsigned long irqflags, -+ const char *devname, void *dev_id, -+ struct irq_chip *chip) - { - int irq, retval; - -- irq = bind_evtchn_to_irq(evtchn); -+ irq = bind_evtchn_to_irq_chip(evtchn, chip); - if (irq < 0) - return irq; - retval = request_irq(irq, handler, irqflags, devname, dev_id); -@@ -1052,18 +1276,38 @@ int bind_evtchn_to_irqhandler(evtchn_port_t evtchn, - - return irq; - } -+ -+int bind_evtchn_to_irqhandler(evtchn_port_t evtchn, -+ irq_handler_t handler, -+ unsigned long irqflags, -+ const char *devname, void *dev_id) -+{ -+ return bind_evtchn_to_irqhandler_chip(evtchn, handler, irqflags, -+ devname, dev_id, -+ &xen_dynamic_chip); -+} - EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler); - --int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, -- evtchn_port_t remote_port, -- irq_handler_t handler, -- unsigned long irqflags, -- const char *devname, -- void *dev_id) -+int bind_evtchn_to_irqhandler_lateeoi(evtchn_port_t evtchn, -+ irq_handler_t handler, -+ unsigned long irqflags, -+ const char *devname, void *dev_id) -+{ -+ return bind_evtchn_to_irqhandler_chip(evtchn, handler, irqflags, -+ devname, dev_id, -+ &xen_lateeoi_chip); -+} -+EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler_lateeoi); -+ -+static int bind_interdomain_evtchn_to_irqhandler_chip( -+ unsigned int remote_domain, evtchn_port_t remote_port, -+ irq_handler_t handler, unsigned long irqflags, -+ const char *devname, void *dev_id, struct irq_chip *chip) - { - int irq, retval; - -- irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port); -+ irq = bind_interdomain_evtchn_to_irq_chip(remote_domain, remote_port, -+ chip); - if (irq < 0) - return irq; - -@@ -1075,8 +1319,33 @@ int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, - - return irq; - } -+ -+int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, -+ evtchn_port_t remote_port, -+ irq_handler_t handler, -+ unsigned long irqflags, -+ const char *devname, -+ void *dev_id) -+{ -+ return bind_interdomain_evtchn_to_irqhandler_chip(remote_domain, -+ remote_port, handler, irqflags, devname, -+ dev_id, &xen_dynamic_chip); -+} - EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler); - -+int bind_interdomain_evtchn_to_irqhandler_lateeoi(unsigned int remote_domain, -+ evtchn_port_t remote_port, -+ irq_handler_t handler, -+ unsigned long irqflags, -+ const char *devname, -+ void *dev_id) -+{ -+ return bind_interdomain_evtchn_to_irqhandler_chip(remote_domain, -+ remote_port, handler, irqflags, devname, -+ dev_id, &xen_lateeoi_chip); -+} -+EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler_lateeoi); -+ - int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, - irq_handler_t handler, - unsigned long irqflags, const char *devname, void *dev_id) -@@ -1189,7 +1458,7 @@ int evtchn_get(evtchn_port_t evtchn) - goto done; - - err = -EINVAL; -- if (info->refcnt <= 0) -+ if (info->refcnt <= 0 || info->refcnt == SHRT_MAX) - goto done; - - info->refcnt++; -@@ -1228,21 +1497,81 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector) - notify_remote_via_irq(irq); - } - -+struct evtchn_loop_ctrl { -+ ktime_t timeout; -+ unsigned count; -+ bool defer_eoi; -+}; -+ -+void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl) -+{ -+ int irq; -+ struct irq_info *info; -+ -+ irq = get_evtchn_to_irq(port); -+ if (irq == -1) -+ return; -+ -+ /* -+ * Check for timeout every 256 events. -+ * We are setting the timeout value only after the first 256 -+ * events in order to not hurt the common case of few loop -+ * iterations. The 256 is basically an arbitrary value. -+ * -+ * In case we are hitting the timeout we need to defer all further -+ * EOIs in order to ensure to leave the event handling loop rather -+ * sooner than later. -+ */ -+ if (!ctrl->defer_eoi && !(++ctrl->count & 0xff)) { -+ ktime_t kt = ktime_get(); -+ -+ if (!ctrl->timeout) { -+ kt = ktime_add_ms(kt, -+ jiffies_to_msecs(event_loop_timeout)); -+ ctrl->timeout = kt; -+ } else if (kt > ctrl->timeout) { -+ ctrl->defer_eoi = true; -+ } -+ } -+ -+ info = info_for_irq(irq); -+ -+ if (ctrl->defer_eoi) { -+ info->eoi_cpu = smp_processor_id(); -+ info->irq_epoch = __this_cpu_read(irq_epoch); -+ info->eoi_time = get_jiffies_64() + event_eoi_delay; -+ } -+ -+ generic_handle_irq(irq); -+} -+ - static void __xen_evtchn_do_upcall(void) - { - struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu); - int cpu = smp_processor_id(); -+ struct evtchn_loop_ctrl ctrl = { 0 }; -+ -+ read_lock(&evtchn_rwlock); - - do { - vcpu_info->evtchn_upcall_pending = 0; - -- xen_evtchn_handle_events(cpu); -+ xen_evtchn_handle_events(cpu, &ctrl); - - BUG_ON(!irqs_disabled()); - - virt_rmb(); /* Hypervisor can set upcall pending. */ - - } while (vcpu_info->evtchn_upcall_pending); -+ -+ read_unlock(&evtchn_rwlock); -+ -+ /* -+ * Increment irq_epoch only now to defer EOIs only for -+ * xen_irq_lateeoi() invocations occurring from inside the loop -+ * above. -+ */ -+ __this_cpu_inc(irq_epoch); - } - - void xen_evtchn_do_upcall(struct pt_regs *regs) -@@ -1606,6 +1935,21 @@ static struct irq_chip xen_dynamic_chip __read_mostly = { - .irq_retrigger = retrigger_dynirq, - }; - -+static struct irq_chip xen_lateeoi_chip __read_mostly = { -+ /* The chip name needs to contain "xen-dyn" for irqbalance to work. */ -+ .name = "xen-dyn-lateeoi", -+ -+ .irq_disable = disable_dynirq, -+ .irq_mask = disable_dynirq, -+ .irq_unmask = enable_dynirq, -+ -+ .irq_ack = mask_ack_dynirq, -+ .irq_mask_ack = mask_ack_dynirq, -+ -+ .irq_set_affinity = set_affinity_irq, -+ .irq_retrigger = retrigger_dynirq, -+}; -+ - static struct irq_chip xen_pirq_chip __read_mostly = { - .name = "xen-pirq", - -@@ -1676,12 +2020,31 @@ void xen_setup_callback_vector(void) {} - static inline void xen_alloc_callback_vector(void) {} - #endif - --#undef MODULE_PARAM_PREFIX --#define MODULE_PARAM_PREFIX "xen." -- - static bool fifo_events = true; - module_param(fifo_events, bool, 0); - -+static int xen_evtchn_cpu_prepare(unsigned int cpu) -+{ -+ int ret = 0; -+ -+ xen_cpu_init_eoi(cpu); -+ -+ if (evtchn_ops->percpu_init) -+ ret = evtchn_ops->percpu_init(cpu); -+ -+ return ret; -+} -+ -+static int xen_evtchn_cpu_dead(unsigned int cpu) -+{ -+ int ret = 0; -+ -+ if (evtchn_ops->percpu_deinit) -+ ret = evtchn_ops->percpu_deinit(cpu); -+ -+ return ret; -+} -+ - void __init xen_init_IRQ(void) - { - int ret = -EINVAL; -@@ -1692,6 +2055,12 @@ void __init xen_init_IRQ(void) - if (ret < 0) - xen_evtchn_2l_init(); - -+ xen_cpu_init_eoi(smp_processor_id()); -+ -+ cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE, -+ "xen/evtchn:prepare", -+ xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); -+ - evtchn_to_irq = kcalloc(EVTCHN_ROW(xen_evtchn_max_channels()), - sizeof(*evtchn_to_irq), GFP_KERNEL); - BUG_ON(!evtchn_to_irq); -diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c -index c60ee0450173e..6085a808da95c 100644 ---- a/drivers/xen/events/events_fifo.c -+++ b/drivers/xen/events/events_fifo.c -@@ -227,19 +227,25 @@ static bool evtchn_fifo_is_masked(evtchn_port_t port) - return sync_test_bit(EVTCHN_FIFO_BIT(MASKED, word), BM(word)); - } - /* -- * Clear MASKED, spinning if BUSY is set. -+ * Clear MASKED if not PENDING, spinning if BUSY is set. -+ * Return true if mask was cleared. - */ --static void clear_masked(volatile event_word_t *word) -+static bool clear_masked_cond(volatile event_word_t *word) - { - event_word_t new, old, w; - - w = *word; - - do { -+ if (w & (1 << EVTCHN_FIFO_PENDING)) -+ return false; -+ - old = w & ~(1 << EVTCHN_FIFO_BUSY); - new = old & ~(1 << EVTCHN_FIFO_MASKED); - w = sync_cmpxchg(word, old, new); - } while (w != old); -+ -+ return true; - } - - static void evtchn_fifo_unmask(evtchn_port_t port) -@@ -248,8 +254,7 @@ static void evtchn_fifo_unmask(evtchn_port_t port) - - BUG_ON(!irqs_disabled()); - -- clear_masked(word); -- if (evtchn_fifo_is_pending(port)) { -+ if (!clear_masked_cond(word)) { - struct evtchn_unmask unmask = { .port = port }; - (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask); - } -@@ -270,19 +275,9 @@ static uint32_t clear_linked(volatile event_word_t *word) - return w & EVTCHN_FIFO_LINK_MASK; - } - --static void handle_irq_for_port(evtchn_port_t port) --{ -- int irq; -- -- irq = get_evtchn_to_irq(port); -- if (irq != -1) -- generic_handle_irq(irq); --} -- --static void consume_one_event(unsigned cpu, -+static void consume_one_event(unsigned cpu, struct evtchn_loop_ctrl *ctrl, - struct evtchn_fifo_control_block *control_block, -- unsigned priority, unsigned long *ready, -- bool drop) -+ unsigned priority, unsigned long *ready) - { - struct evtchn_fifo_queue *q = &per_cpu(cpu_queue, cpu); - uint32_t head; -@@ -315,16 +310,17 @@ static void consume_one_event(unsigned cpu, - clear_bit(priority, ready); - - if (evtchn_fifo_is_pending(port) && !evtchn_fifo_is_masked(port)) { -- if (unlikely(drop)) -+ if (unlikely(!ctrl)) - pr_warn("Dropping pending event for port %u\n", port); - else -- handle_irq_for_port(port); -+ handle_irq_for_port(port, ctrl); - } - - q->head[priority] = head; - } - --static void __evtchn_fifo_handle_events(unsigned cpu, bool drop) -+static void __evtchn_fifo_handle_events(unsigned cpu, -+ struct evtchn_loop_ctrl *ctrl) - { - struct evtchn_fifo_control_block *control_block; - unsigned long ready; -@@ -336,14 +332,15 @@ static void __evtchn_fifo_handle_events(unsigned cpu, bool drop) - - while (ready) { - q = find_first_bit(&ready, EVTCHN_FIFO_MAX_QUEUES); -- consume_one_event(cpu, control_block, q, &ready, drop); -+ consume_one_event(cpu, ctrl, control_block, q, &ready); - ready |= xchg(&control_block->ready, 0); - } - } - --static void evtchn_fifo_handle_events(unsigned cpu) -+static void evtchn_fifo_handle_events(unsigned cpu, -+ struct evtchn_loop_ctrl *ctrl) - { -- __evtchn_fifo_handle_events(cpu, false); -+ __evtchn_fifo_handle_events(cpu, ctrl); - } - - static void evtchn_fifo_resume(void) -@@ -380,21 +377,6 @@ static void evtchn_fifo_resume(void) - event_array_pages = 0; - } - --static const struct evtchn_ops evtchn_ops_fifo = { -- .max_channels = evtchn_fifo_max_channels, -- .nr_channels = evtchn_fifo_nr_channels, -- .setup = evtchn_fifo_setup, -- .bind_to_cpu = evtchn_fifo_bind_to_cpu, -- .clear_pending = evtchn_fifo_clear_pending, -- .set_pending = evtchn_fifo_set_pending, -- .is_pending = evtchn_fifo_is_pending, -- .test_and_set_mask = evtchn_fifo_test_and_set_mask, -- .mask = evtchn_fifo_mask, -- .unmask = evtchn_fifo_unmask, -- .handle_events = evtchn_fifo_handle_events, -- .resume = evtchn_fifo_resume, --}; -- - static int evtchn_fifo_alloc_control_block(unsigned cpu) - { - void *control_block = NULL; -@@ -417,19 +399,36 @@ static int evtchn_fifo_alloc_control_block(unsigned cpu) - return ret; - } - --static int xen_evtchn_cpu_prepare(unsigned int cpu) -+static int evtchn_fifo_percpu_init(unsigned int cpu) - { - if (!per_cpu(cpu_control_block, cpu)) - return evtchn_fifo_alloc_control_block(cpu); - return 0; - } - --static int xen_evtchn_cpu_dead(unsigned int cpu) -+static int evtchn_fifo_percpu_deinit(unsigned int cpu) - { -- __evtchn_fifo_handle_events(cpu, true); -+ __evtchn_fifo_handle_events(cpu, NULL); - return 0; - } - -+static const struct evtchn_ops evtchn_ops_fifo = { -+ .max_channels = evtchn_fifo_max_channels, -+ .nr_channels = evtchn_fifo_nr_channels, -+ .setup = evtchn_fifo_setup, -+ .bind_to_cpu = evtchn_fifo_bind_to_cpu, -+ .clear_pending = evtchn_fifo_clear_pending, -+ .set_pending = evtchn_fifo_set_pending, -+ .is_pending = evtchn_fifo_is_pending, -+ .test_and_set_mask = evtchn_fifo_test_and_set_mask, -+ .mask = evtchn_fifo_mask, -+ .unmask = evtchn_fifo_unmask, -+ .handle_events = evtchn_fifo_handle_events, -+ .resume = evtchn_fifo_resume, -+ .percpu_init = evtchn_fifo_percpu_init, -+ .percpu_deinit = evtchn_fifo_percpu_deinit, -+}; -+ - int __init xen_evtchn_fifo_init(void) - { - int cpu = smp_processor_id(); -@@ -443,9 +442,5 @@ int __init xen_evtchn_fifo_init(void) - - evtchn_ops = &evtchn_ops_fifo; - -- cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE, -- "xen/evtchn:prepare", -- xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); -- - return ret; - } -diff --git a/drivers/xen/events/events_internal.h b/drivers/xen/events/events_internal.h -index 10684feb094e1..82937d90d7d72 100644 ---- a/drivers/xen/events/events_internal.h -+++ b/drivers/xen/events/events_internal.h -@@ -30,11 +30,16 @@ enum xen_irq_type { - */ - struct irq_info { - struct list_head list; -- int refcnt; -+ struct list_head eoi_list; -+ short refcnt; -+ short spurious_cnt; - enum xen_irq_type type; /* type */ - unsigned irq; - evtchn_port_t evtchn; /* event channel */ - unsigned short cpu; /* cpu bound */ -+ unsigned short eoi_cpu; /* EOI must happen on this cpu */ -+ unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */ -+ u64 eoi_time; /* Time in jiffies when to EOI. */ - - union { - unsigned short virq; -@@ -53,6 +58,8 @@ struct irq_info { - #define PIRQ_SHAREABLE (1 << 1) - #define PIRQ_MSI_GROUP (1 << 2) - -+struct evtchn_loop_ctrl; -+ - struct evtchn_ops { - unsigned (*max_channels)(void); - unsigned (*nr_channels)(void); -@@ -67,14 +74,18 @@ struct evtchn_ops { - void (*mask)(evtchn_port_t port); - void (*unmask)(evtchn_port_t port); - -- void (*handle_events)(unsigned cpu); -+ void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl); - void (*resume)(void); -+ -+ int (*percpu_init)(unsigned int cpu); -+ int (*percpu_deinit)(unsigned int cpu); - }; - - extern const struct evtchn_ops *evtchn_ops; - - extern int **evtchn_to_irq; - int get_evtchn_to_irq(evtchn_port_t evtchn); -+void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl); - - struct irq_info *info_for_irq(unsigned irq); - unsigned cpu_from_irq(unsigned irq); -@@ -132,9 +143,10 @@ static inline void unmask_evtchn(evtchn_port_t port) - return evtchn_ops->unmask(port); - } - --static inline void xen_evtchn_handle_events(unsigned cpu) -+static inline void xen_evtchn_handle_events(unsigned cpu, -+ struct evtchn_loop_ctrl *ctrl) - { -- return evtchn_ops->handle_events(cpu); -+ return evtchn_ops->handle_events(cpu, ctrl); - } - - static inline void xen_evtchn_resume(void) -diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c -index 6e0b1dd5573cb..5dc016d68f833 100644 ---- a/drivers/xen/evtchn.c -+++ b/drivers/xen/evtchn.c -@@ -167,7 +167,6 @@ static irqreturn_t evtchn_interrupt(int irq, void *data) - "Interrupt for port %u, but apparently not enabled; per-user %p\n", - evtchn->port, u); - -- disable_irq_nosync(irq); - evtchn->enabled = false; - - spin_lock(&u->ring_prod_lock); -@@ -293,7 +292,7 @@ static ssize_t evtchn_write(struct file *file, const char __user *buf, - evtchn = find_evtchn(u, port); - if (evtchn && !evtchn->enabled) { - evtchn->enabled = true; -- enable_irq(irq_from_evtchn(port)); -+ xen_irq_lateeoi(irq_from_evtchn(port), 0); - } - } - -@@ -393,8 +392,8 @@ static int evtchn_bind_to_user(struct per_user_data *u, evtchn_port_t port) - if (rc < 0) - goto err; - -- rc = bind_evtchn_to_irqhandler(port, evtchn_interrupt, 0, -- u->name, evtchn); -+ rc = bind_evtchn_to_irqhandler_lateeoi(port, evtchn_interrupt, 0, -+ u->name, evtchn); - if (rc < 0) - goto err; - -diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c -index b1b6eebafd5de..4c13cbc99896a 100644 ---- a/drivers/xen/gntdev-dmabuf.c -+++ b/drivers/xen/gntdev-dmabuf.c -@@ -247,10 +247,9 @@ static void dmabuf_exp_ops_detach(struct dma_buf *dma_buf, - - if (sgt) { - if (gntdev_dmabuf_attach->dir != DMA_NONE) -- dma_unmap_sg_attrs(attach->dev, sgt->sgl, -- sgt->nents, -- gntdev_dmabuf_attach->dir, -- DMA_ATTR_SKIP_CPU_SYNC); -+ dma_unmap_sgtable(attach->dev, sgt, -+ gntdev_dmabuf_attach->dir, -+ DMA_ATTR_SKIP_CPU_SYNC); - sg_free_table(sgt); - } - -@@ -288,8 +287,8 @@ dmabuf_exp_ops_map_dma_buf(struct dma_buf_attachment *attach, - sgt = dmabuf_pages_to_sgt(gntdev_dmabuf->pages, - gntdev_dmabuf->nr_pages); - if (!IS_ERR(sgt)) { -- if (!dma_map_sg_attrs(attach->dev, sgt->sgl, sgt->nents, dir, -- DMA_ATTR_SKIP_CPU_SYNC)) { -+ if (dma_map_sgtable(attach->dev, sgt, dir, -+ DMA_ATTR_SKIP_CPU_SYNC)) { - sg_free_table(sgt); - kfree(sgt); - sgt = ERR_PTR(-ENOMEM); -@@ -633,7 +632,7 @@ dmabuf_imp_to_refs(struct gntdev_dmabuf_priv *priv, struct device *dev, - - /* Now convert sgt to array of pages and check for page validity. */ - i = 0; -- for_each_sg_page(sgt->sgl, &sg_iter, sgt->nents, 0) { -+ for_each_sgtable_page(sgt, &sg_iter, 0) { - struct page *page = sg_page_iter_page(&sg_iter); - /* - * Check if page is valid: this can happen if we are given -diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c -index 9eae1fceec1e5..a7d293fa8d140 100644 ---- a/drivers/xen/pvcalls-back.c -+++ b/drivers/xen/pvcalls-back.c -@@ -66,6 +66,7 @@ struct sock_mapping { - atomic_t write; - atomic_t io; - atomic_t release; -+ atomic_t eoi; - void (*saved_data_ready)(struct sock *sk); - struct pvcalls_ioworker ioworker; - }; -@@ -87,7 +88,7 @@ static int pvcalls_back_release_active(struct xenbus_device *dev, - struct pvcalls_fedata *fedata, - struct sock_mapping *map); - --static void pvcalls_conn_back_read(void *opaque) -+static bool pvcalls_conn_back_read(void *opaque) - { - struct sock_mapping *map = (struct sock_mapping *)opaque; - struct msghdr msg; -@@ -107,17 +108,17 @@ static void pvcalls_conn_back_read(void *opaque) - virt_mb(); - - if (error) -- return; -+ return false; - - size = pvcalls_queued(prod, cons, array_size); - if (size >= array_size) -- return; -+ return false; - spin_lock_irqsave(&map->sock->sk->sk_receive_queue.lock, flags); - if (skb_queue_empty(&map->sock->sk->sk_receive_queue)) { - atomic_set(&map->read, 0); - spin_unlock_irqrestore(&map->sock->sk->sk_receive_queue.lock, - flags); -- return; -+ return true; - } - spin_unlock_irqrestore(&map->sock->sk->sk_receive_queue.lock, flags); - wanted = array_size - size; -@@ -141,7 +142,7 @@ static void pvcalls_conn_back_read(void *opaque) - ret = inet_recvmsg(map->sock, &msg, wanted, MSG_DONTWAIT); - WARN_ON(ret > wanted); - if (ret == -EAGAIN) /* shouldn't happen */ -- return; -+ return true; - if (!ret) - ret = -ENOTCONN; - spin_lock_irqsave(&map->sock->sk->sk_receive_queue.lock, flags); -@@ -160,10 +161,10 @@ static void pvcalls_conn_back_read(void *opaque) - virt_wmb(); - notify_remote_via_irq(map->irq); - -- return; -+ return true; - } - --static void pvcalls_conn_back_write(struct sock_mapping *map) -+static bool pvcalls_conn_back_write(struct sock_mapping *map) - { - struct pvcalls_data_intf *intf = map->ring; - struct pvcalls_data *data = &map->data; -@@ -180,7 +181,7 @@ static void pvcalls_conn_back_write(struct sock_mapping *map) - array_size = XEN_FLEX_RING_SIZE(map->ring_order); - size = pvcalls_queued(prod, cons, array_size); - if (size == 0) -- return; -+ return false; - - memset(&msg, 0, sizeof(msg)); - msg.msg_flags |= MSG_DONTWAIT; -@@ -198,12 +199,11 @@ static void pvcalls_conn_back_write(struct sock_mapping *map) - - atomic_set(&map->write, 0); - ret = inet_sendmsg(map->sock, &msg, size); -- if (ret == -EAGAIN || (ret >= 0 && ret < size)) { -+ if (ret == -EAGAIN) { - atomic_inc(&map->write); - atomic_inc(&map->io); -+ return true; - } -- if (ret == -EAGAIN) -- return; - - /* write the data, then update the indexes */ - virt_wmb(); -@@ -216,9 +216,13 @@ static void pvcalls_conn_back_write(struct sock_mapping *map) - } - /* update the indexes, then notify the other end */ - virt_wmb(); -- if (prod != cons + ret) -+ if (prod != cons + ret) { - atomic_inc(&map->write); -+ atomic_inc(&map->io); -+ } - notify_remote_via_irq(map->irq); -+ -+ return true; - } - - static void pvcalls_back_ioworker(struct work_struct *work) -@@ -227,6 +231,7 @@ static void pvcalls_back_ioworker(struct work_struct *work) - struct pvcalls_ioworker, register_work); - struct sock_mapping *map = container_of(ioworker, struct sock_mapping, - ioworker); -+ unsigned int eoi_flags = XEN_EOI_FLAG_SPURIOUS; - - while (atomic_read(&map->io) > 0) { - if (atomic_read(&map->release) > 0) { -@@ -234,10 +239,18 @@ static void pvcalls_back_ioworker(struct work_struct *work) - return; - } - -- if (atomic_read(&map->read) > 0) -- pvcalls_conn_back_read(map); -- if (atomic_read(&map->write) > 0) -- pvcalls_conn_back_write(map); -+ if (atomic_read(&map->read) > 0 && -+ pvcalls_conn_back_read(map)) -+ eoi_flags = 0; -+ if (atomic_read(&map->write) > 0 && -+ pvcalls_conn_back_write(map)) -+ eoi_flags = 0; -+ -+ if (atomic_read(&map->eoi) > 0 && !atomic_read(&map->write)) { -+ atomic_set(&map->eoi, 0); -+ xen_irq_lateeoi(map->irq, eoi_flags); -+ eoi_flags = XEN_EOI_FLAG_SPURIOUS; -+ } - - atomic_dec(&map->io); - } -@@ -334,12 +347,9 @@ static struct sock_mapping *pvcalls_new_active_socket( - goto out; - map->bytes = page; - -- ret = bind_interdomain_evtchn_to_irqhandler(fedata->dev->otherend_id, -- evtchn, -- pvcalls_back_conn_event, -- 0, -- "pvcalls-backend", -- map); -+ ret = bind_interdomain_evtchn_to_irqhandler_lateeoi( -+ fedata->dev->otherend_id, evtchn, -+ pvcalls_back_conn_event, 0, "pvcalls-backend", map); - if (ret < 0) - goto out; - map->irq = ret; -@@ -873,15 +883,18 @@ static irqreturn_t pvcalls_back_event(int irq, void *dev_id) - { - struct xenbus_device *dev = dev_id; - struct pvcalls_fedata *fedata = NULL; -+ unsigned int eoi_flags = XEN_EOI_FLAG_SPURIOUS; - -- if (dev == NULL) -- return IRQ_HANDLED; -+ if (dev) { -+ fedata = dev_get_drvdata(&dev->dev); -+ if (fedata) { -+ pvcalls_back_work(fedata); -+ eoi_flags = 0; -+ } -+ } - -- fedata = dev_get_drvdata(&dev->dev); -- if (fedata == NULL) -- return IRQ_HANDLED; -+ xen_irq_lateeoi(irq, eoi_flags); - -- pvcalls_back_work(fedata); - return IRQ_HANDLED; - } - -@@ -891,12 +904,15 @@ static irqreturn_t pvcalls_back_conn_event(int irq, void *sock_map) - struct pvcalls_ioworker *iow; - - if (map == NULL || map->sock == NULL || map->sock->sk == NULL || -- map->sock->sk->sk_user_data != map) -+ map->sock->sk->sk_user_data != map) { -+ xen_irq_lateeoi(irq, 0); - return IRQ_HANDLED; -+ } - - iow = &map->ioworker; - - atomic_inc(&map->write); -+ atomic_inc(&map->eoi); - atomic_inc(&map->io); - queue_work(iow->wq, &iow->register_work); - -@@ -932,7 +948,7 @@ static int backend_connect(struct xenbus_device *dev) - goto error; - } - -- err = bind_interdomain_evtchn_to_irq(dev->otherend_id, evtchn); -+ err = bind_interdomain_evtchn_to_irq_lateeoi(dev->otherend_id, evtchn); - if (err < 0) - goto error; - fedata->irq = err; -diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c -index e876c3d6dad1f..cb904ac830064 100644 ---- a/drivers/xen/xen-pciback/pci_stub.c -+++ b/drivers/xen/xen-pciback/pci_stub.c -@@ -734,10 +734,17 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev, - wmb(); - notify_remote_via_irq(pdev->evtchn_irq); - -+ /* Enable IRQ to signal "request done". */ -+ xen_pcibk_lateeoi(pdev, 0); -+ - ret = wait_event_timeout(xen_pcibk_aer_wait_queue, - !(test_bit(_XEN_PCIB_active, (unsigned long *) - &sh_info->flags)), 300*HZ); - -+ /* Enable IRQ for pcifront request if not already active. */ -+ if (!test_bit(_PDEVF_op_active, &pdev->flags)) -+ xen_pcibk_lateeoi(pdev, 0); -+ - if (!ret) { - if (test_bit(_XEN_PCIB_active, - (unsigned long *)&sh_info->flags)) { -@@ -751,12 +758,6 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev, - } - clear_bit(_PCIB_op_pending, (unsigned long *)&pdev->flags); - -- if (test_bit(_XEN_PCIF_active, -- (unsigned long *)&sh_info->flags)) { -- dev_dbg(&psdev->dev->dev, "schedule pci_conf service\n"); -- xen_pcibk_test_and_schedule_op(psdev->pdev); -- } -- - res = (pci_ers_result_t)aer_op->err; - return res; - } -diff --git a/drivers/xen/xen-pciback/pciback.h b/drivers/xen/xen-pciback/pciback.h -index f1ed2dbf685cb..95e28ee48d52b 100644 ---- a/drivers/xen/xen-pciback/pciback.h -+++ b/drivers/xen/xen-pciback/pciback.h -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - - #define DRV_NAME "xen-pciback" -@@ -27,6 +28,8 @@ struct pci_dev_entry { - #define PDEVF_op_active (1<<(_PDEVF_op_active)) - #define _PCIB_op_pending (1) - #define PCIB_op_pending (1<<(_PCIB_op_pending)) -+#define _EOI_pending (2) -+#define EOI_pending (1<<(_EOI_pending)) - - struct xen_pcibk_device { - void *pci_dev_data; -@@ -183,10 +186,15 @@ static inline void xen_pcibk_release_devices(struct xen_pcibk_device *pdev) - irqreturn_t xen_pcibk_handle_event(int irq, void *dev_id); - void xen_pcibk_do_op(struct work_struct *data); - -+static inline void xen_pcibk_lateeoi(struct xen_pcibk_device *pdev, -+ unsigned int eoi_flag) -+{ -+ if (test_and_clear_bit(_EOI_pending, &pdev->flags)) -+ xen_irq_lateeoi(pdev->evtchn_irq, eoi_flag); -+} -+ - int xen_pcibk_xenbus_register(void); - void xen_pcibk_xenbus_unregister(void); -- --void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev); - #endif - - /* Handles shared IRQs that can to device domain and control domain. */ -diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c -index e11a7438e1a25..3fbc21466a934 100644 ---- a/drivers/xen/xen-pciback/pciback_ops.c -+++ b/drivers/xen/xen-pciback/pciback_ops.c -@@ -276,26 +276,41 @@ int xen_pcibk_disable_msix(struct xen_pcibk_device *pdev, - return 0; - } - #endif -+ -+static inline bool xen_pcibk_test_op_pending(struct xen_pcibk_device *pdev) -+{ -+ return test_bit(_XEN_PCIF_active, -+ (unsigned long *)&pdev->sh_info->flags) && -+ !test_and_set_bit(_PDEVF_op_active, &pdev->flags); -+} -+ - /* - * Now the same evtchn is used for both pcifront conf_read_write request - * as well as pcie aer front end ack. We use a new work_queue to schedule - * xen_pcibk conf_read_write service for avoiding confict with aer_core - * do_recovery job which also use the system default work_queue - */ --void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev) -+static void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev) - { -+ bool eoi = true; -+ - /* Check that frontend is requesting an operation and that we are not - * already processing a request */ -- if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags) -- && !test_and_set_bit(_PDEVF_op_active, &pdev->flags)) { -+ if (xen_pcibk_test_op_pending(pdev)) { - schedule_work(&pdev->op_work); -+ eoi = false; - } - /*_XEN_PCIB_active should have been cleared by pcifront. And also make - sure xen_pcibk is waiting for ack by checking _PCIB_op_pending*/ - if (!test_bit(_XEN_PCIB_active, (unsigned long *)&pdev->sh_info->flags) - && test_bit(_PCIB_op_pending, &pdev->flags)) { - wake_up(&xen_pcibk_aer_wait_queue); -+ eoi = false; - } -+ -+ /* EOI if there was nothing to do. */ -+ if (eoi) -+ xen_pcibk_lateeoi(pdev, XEN_EOI_FLAG_SPURIOUS); - } - - /* Performing the configuration space reads/writes must not be done in atomic -@@ -303,10 +318,8 @@ void xen_pcibk_test_and_schedule_op(struct xen_pcibk_device *pdev) - * use of semaphores). This function is intended to be called from a work - * queue in process context taking a struct xen_pcibk_device as a parameter */ - --void xen_pcibk_do_op(struct work_struct *data) -+static void xen_pcibk_do_one_op(struct xen_pcibk_device *pdev) - { -- struct xen_pcibk_device *pdev = -- container_of(data, struct xen_pcibk_device, op_work); - struct pci_dev *dev; - struct xen_pcibk_dev_data *dev_data = NULL; - struct xen_pci_op *op = &pdev->op; -@@ -379,16 +392,31 @@ void xen_pcibk_do_op(struct work_struct *data) - smp_mb__before_atomic(); /* /after/ clearing PCIF_active */ - clear_bit(_PDEVF_op_active, &pdev->flags); - smp_mb__after_atomic(); /* /before/ final check for work */ -+} - -- /* Check to see if the driver domain tried to start another request in -- * between clearing _XEN_PCIF_active and clearing _PDEVF_op_active. -- */ -- xen_pcibk_test_and_schedule_op(pdev); -+void xen_pcibk_do_op(struct work_struct *data) -+{ -+ struct xen_pcibk_device *pdev = -+ container_of(data, struct xen_pcibk_device, op_work); -+ -+ do { -+ xen_pcibk_do_one_op(pdev); -+ } while (xen_pcibk_test_op_pending(pdev)); -+ -+ xen_pcibk_lateeoi(pdev, 0); - } - - irqreturn_t xen_pcibk_handle_event(int irq, void *dev_id) - { - struct xen_pcibk_device *pdev = dev_id; -+ bool eoi; -+ -+ /* IRQs might come in before pdev->evtchn_irq is written. */ -+ if (unlikely(pdev->evtchn_irq != irq)) -+ pdev->evtchn_irq = irq; -+ -+ eoi = test_and_set_bit(_EOI_pending, &pdev->flags); -+ WARN(eoi, "IRQ while EOI pending\n"); - - xen_pcibk_test_and_schedule_op(pdev); - -diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c -index b500466a6c371..4b99ec3dec58a 100644 ---- a/drivers/xen/xen-pciback/xenbus.c -+++ b/drivers/xen/xen-pciback/xenbus.c -@@ -123,7 +123,7 @@ static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref, - - pdev->sh_info = vaddr; - -- err = bind_interdomain_evtchn_to_irqhandler( -+ err = bind_interdomain_evtchn_to_irqhandler_lateeoi( - pdev->xdev->otherend_id, remote_evtchn, xen_pcibk_handle_event, - 0, DRV_NAME, pdev); - if (err < 0) { -diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c -index 1e8cfd80a4e6b..4acc4e899600c 100644 ---- a/drivers/xen/xen-scsiback.c -+++ b/drivers/xen/xen-scsiback.c -@@ -91,7 +91,6 @@ struct vscsibk_info { - unsigned int irq; - - struct vscsiif_back_ring ring; -- int ring_error; - - spinlock_t ring_lock; - atomic_t nr_unreplied_reqs; -@@ -722,7 +721,8 @@ static struct vscsibk_pend *prepare_pending_reqs(struct vscsibk_info *info, - return pending_req; - } - --static int scsiback_do_cmd_fn(struct vscsibk_info *info) -+static int scsiback_do_cmd_fn(struct vscsibk_info *info, -+ unsigned int *eoi_flags) - { - struct vscsiif_back_ring *ring = &info->ring; - struct vscsiif_request ring_req; -@@ -739,11 +739,12 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info) - rc = ring->rsp_prod_pvt; - pr_warn("Dom%d provided bogus ring requests (%#x - %#x = %u). Halting ring processing\n", - info->domid, rp, rc, rp - rc); -- info->ring_error = 1; -- return 0; -+ return -EINVAL; - } - - while ((rc != rp)) { -+ *eoi_flags &= ~XEN_EOI_FLAG_SPURIOUS; -+ - if (RING_REQUEST_CONS_OVERFLOW(ring, rc)) - break; - -@@ -802,13 +803,16 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info) - static irqreturn_t scsiback_irq_fn(int irq, void *dev_id) - { - struct vscsibk_info *info = dev_id; -+ int rc; -+ unsigned int eoi_flags = XEN_EOI_FLAG_SPURIOUS; - -- if (info->ring_error) -- return IRQ_HANDLED; -- -- while (scsiback_do_cmd_fn(info)) -+ while ((rc = scsiback_do_cmd_fn(info, &eoi_flags)) > 0) - cond_resched(); - -+ /* In case of a ring error we keep the event channel masked. */ -+ if (!rc) -+ xen_irq_lateeoi(irq, eoi_flags); -+ - return IRQ_HANDLED; - } - -@@ -829,7 +833,7 @@ static int scsiback_init_sring(struct vscsibk_info *info, grant_ref_t ring_ref, - sring = (struct vscsiif_sring *)area; - BACK_RING_INIT(&info->ring, sring, PAGE_SIZE); - -- err = bind_interdomain_evtchn_to_irq(info->domid, evtchn); -+ err = bind_interdomain_evtchn_to_irq_lateeoi(info->domid, evtchn); - if (err < 0) - goto unmap_page; - -@@ -1253,7 +1257,6 @@ static int scsiback_probe(struct xenbus_device *dev, - - info->domid = dev->otherend_id; - spin_lock_init(&info->ring_lock); -- info->ring_error = 0; - atomic_set(&info->nr_unreplied_reqs, 0); - init_waitqueue_head(&info->waiting_to_free); - info->dev = dev; -diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c -index 3576123d82990..6d97b6b4d34b6 100644 ---- a/fs/9p/vfs_file.c -+++ b/fs/9p/vfs_file.c -@@ -612,9 +612,9 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma) - struct writeback_control wbc = { - .nr_to_write = LONG_MAX, - .sync_mode = WB_SYNC_ALL, -- .range_start = vma->vm_pgoff * PAGE_SIZE, -+ .range_start = (loff_t)vma->vm_pgoff * PAGE_SIZE, - /* absolute end, byte at end included */ -- .range_end = vma->vm_pgoff * PAGE_SIZE + -+ .range_end = (loff_t)vma->vm_pgoff * PAGE_SIZE + - (vma->vm_end - vma->vm_start - 1), - }; - -diff --git a/fs/afs/dir.c b/fs/afs/dir.c -index 1d2e61e0ab047..1bb5b9d7f0a2c 100644 ---- a/fs/afs/dir.c -+++ b/fs/afs/dir.c -@@ -281,8 +281,7 @@ retry: - if (ret < 0) - goto error; - -- set_page_private(req->pages[i], 1); -- SetPagePrivate(req->pages[i]); -+ attach_page_private(req->pages[i], (void *)1); - unlock_page(req->pages[i]); - i++; - } else { -@@ -1975,8 +1974,7 @@ static int afs_dir_releasepage(struct page *page, gfp_t gfp_flags) - - _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, page->index); - -- set_page_private(page, 0); -- ClearPagePrivate(page); -+ detach_page_private(page); - - /* The directory will need reloading. */ - if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) -@@ -2003,8 +2001,6 @@ static void afs_dir_invalidatepage(struct page *page, unsigned int offset, - afs_stat_v(dvnode, n_inval); - - /* we clean up only if the entire page is being invalidated */ -- if (offset == 0 && length == PAGE_SIZE) { -- set_page_private(page, 0); -- ClearPagePrivate(page); -- } -+ if (offset == 0 && length == PAGE_SIZE) -+ detach_page_private(page); - } -diff --git a/fs/afs/dir_edit.c b/fs/afs/dir_edit.c -index b108528bf010d..2ffe09abae7fc 100644 ---- a/fs/afs/dir_edit.c -+++ b/fs/afs/dir_edit.c -@@ -243,10 +243,8 @@ void afs_edit_dir_add(struct afs_vnode *vnode, - index, gfp); - if (!page) - goto error; -- if (!PagePrivate(page)) { -- set_page_private(page, 1); -- SetPagePrivate(page); -- } -+ if (!PagePrivate(page)) -+ attach_page_private(page, (void *)1); - dir_page = kmap(page); - } - -diff --git a/fs/afs/file.c b/fs/afs/file.c -index 371d1488cc549..5015f2b107824 100644 ---- a/fs/afs/file.c -+++ b/fs/afs/file.c -@@ -600,6 +600,63 @@ static int afs_readpages(struct file *file, struct address_space *mapping, - return ret; - } - -+/* -+ * Adjust the dirty region of the page on truncation or full invalidation, -+ * getting rid of the markers altogether if the region is entirely invalidated. -+ */ -+static void afs_invalidate_dirty(struct page *page, unsigned int offset, -+ unsigned int length) -+{ -+ struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); -+ unsigned long priv; -+ unsigned int f, t, end = offset + length; -+ -+ priv = page_private(page); -+ -+ /* we clean up only if the entire page is being invalidated */ -+ if (offset == 0 && length == thp_size(page)) -+ goto full_invalidate; -+ -+ /* If the page was dirtied by page_mkwrite(), the PTE stays writable -+ * and we don't get another notification to tell us to expand it -+ * again. -+ */ -+ if (afs_is_page_dirty_mmapped(priv)) -+ return; -+ -+ /* We may need to shorten the dirty region */ -+ f = afs_page_dirty_from(priv); -+ t = afs_page_dirty_to(priv); -+ -+ if (t <= offset || f >= end) -+ return; /* Doesn't overlap */ -+ -+ if (f < offset && t > end) -+ return; /* Splits the dirty region - just absorb it */ -+ -+ if (f >= offset && t <= end) -+ goto undirty; -+ -+ if (f < offset) -+ t = offset; -+ else -+ f = end; -+ if (f == t) -+ goto undirty; -+ -+ priv = afs_page_dirty(f, t); -+ set_page_private(page, priv); -+ trace_afs_page_dirty(vnode, tracepoint_string("trunc"), page->index, priv); -+ return; -+ -+undirty: -+ trace_afs_page_dirty(vnode, tracepoint_string("undirty"), page->index, priv); -+ clear_page_dirty_for_io(page); -+full_invalidate: -+ priv = (unsigned long)detach_page_private(page); -+ trace_afs_page_dirty(vnode, tracepoint_string("inval"), page->index, priv); -+} -+ - /* - * invalidate part or all of a page - * - release a page and clean up its private data if offset is 0 (indicating -@@ -608,31 +665,23 @@ static int afs_readpages(struct file *file, struct address_space *mapping, - static void afs_invalidatepage(struct page *page, unsigned int offset, - unsigned int length) - { -- struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); -- unsigned long priv; -- - _enter("{%lu},%u,%u", page->index, offset, length); - - BUG_ON(!PageLocked(page)); - -+#ifdef CONFIG_AFS_FSCACHE - /* we clean up only if the entire page is being invalidated */ - if (offset == 0 && length == PAGE_SIZE) { --#ifdef CONFIG_AFS_FSCACHE - if (PageFsCache(page)) { - struct afs_vnode *vnode = AFS_FS_I(page->mapping->host); - fscache_wait_on_page_write(vnode->cache, page); - fscache_uncache_page(vnode->cache, page); - } -+ } - #endif - -- if (PagePrivate(page)) { -- priv = page_private(page); -- trace_afs_page_dirty(vnode, tracepoint_string("inval"), -- page->index, priv); -- set_page_private(page, 0); -- ClearPagePrivate(page); -- } -- } -+ if (PagePrivate(page)) -+ afs_invalidate_dirty(page, offset, length); - - _leave(""); - } -@@ -660,11 +709,9 @@ static int afs_releasepage(struct page *page, gfp_t gfp_flags) - #endif - - if (PagePrivate(page)) { -- priv = page_private(page); -+ priv = (unsigned long)detach_page_private(page); - trace_afs_page_dirty(vnode, tracepoint_string("rel"), - page->index, priv); -- set_page_private(page, 0); -- ClearPagePrivate(page); - } - - /* indicate that the page can be released */ -diff --git a/fs/afs/internal.h b/fs/afs/internal.h -index 06e617ee4cd1e..17336cbb8419f 100644 ---- a/fs/afs/internal.h -+++ b/fs/afs/internal.h -@@ -811,6 +811,7 @@ struct afs_operation { - pgoff_t last; /* last page in mapping to deal with */ - unsigned first_offset; /* offset into mapping[first] */ - unsigned last_to; /* amount of mapping[last] */ -+ bool laundering; /* Laundering page, PG_writeback not set */ - } store; - struct { - struct iattr *attr; -@@ -856,6 +857,62 @@ struct afs_vnode_cache_aux { - u64 data_version; - } __packed; - -+/* -+ * We use page->private to hold the amount of the page that we've written to, -+ * splitting the field into two parts. However, we need to represent a range -+ * 0...PAGE_SIZE, so we reduce the resolution if the size of the page -+ * exceeds what we can encode. -+ */ -+#ifdef CONFIG_64BIT -+#define __AFS_PAGE_PRIV_MASK 0x7fffffffUL -+#define __AFS_PAGE_PRIV_SHIFT 32 -+#define __AFS_PAGE_PRIV_MMAPPED 0x80000000UL -+#else -+#define __AFS_PAGE_PRIV_MASK 0x7fffUL -+#define __AFS_PAGE_PRIV_SHIFT 16 -+#define __AFS_PAGE_PRIV_MMAPPED 0x8000UL -+#endif -+ -+static inline unsigned int afs_page_dirty_resolution(void) -+{ -+ int shift = PAGE_SHIFT - (__AFS_PAGE_PRIV_SHIFT - 1); -+ return (shift > 0) ? shift : 0; -+} -+ -+static inline size_t afs_page_dirty_from(unsigned long priv) -+{ -+ unsigned long x = priv & __AFS_PAGE_PRIV_MASK; -+ -+ /* The lower bound is inclusive */ -+ return x << afs_page_dirty_resolution(); -+} -+ -+static inline size_t afs_page_dirty_to(unsigned long priv) -+{ -+ unsigned long x = (priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK; -+ -+ /* The upper bound is immediately beyond the region */ -+ return (x + 1) << afs_page_dirty_resolution(); -+} -+ -+static inline unsigned long afs_page_dirty(size_t from, size_t to) -+{ -+ unsigned int res = afs_page_dirty_resolution(); -+ from >>= res; -+ to = (to - 1) >> res; -+ return (to << __AFS_PAGE_PRIV_SHIFT) | from; -+} -+ -+static inline unsigned long afs_page_dirty_mmapped(unsigned long priv) -+{ -+ return priv | __AFS_PAGE_PRIV_MMAPPED; -+} -+ -+static inline bool afs_is_page_dirty_mmapped(unsigned long priv) -+{ -+ return priv & __AFS_PAGE_PRIV_MMAPPED; -+} -+ - #include - - /*****************************************************************************/ -diff --git a/fs/afs/server.c b/fs/afs/server.c -index e82e452e26124..684a2b02b9ff7 100644 ---- a/fs/afs/server.c -+++ b/fs/afs/server.c -@@ -550,7 +550,12 @@ void afs_manage_servers(struct work_struct *work) - - _debug("manage %pU %u", &server->uuid, active); - -- ASSERTIFCMP(purging, active, ==, 0); -+ if (purging) { -+ trace_afs_server(server, atomic_read(&server->ref), -+ active, afs_server_trace_purging); -+ if (active != 0) -+ pr_notice("Can't purge s=%08x\n", server->debug_id); -+ } - - if (active == 0) { - time64_t expire_at = server->unuse_time; -diff --git a/fs/afs/write.c b/fs/afs/write.c -index da12abd6db213..50371207f3273 100644 ---- a/fs/afs/write.c -+++ b/fs/afs/write.c -@@ -76,7 +76,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key, - */ - int afs_write_begin(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned flags, -- struct page **pagep, void **fsdata) -+ struct page **_page, void **fsdata) - { - struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); - struct page *page; -@@ -90,11 +90,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping, - _enter("{%llx:%llu},{%lx},%u,%u", - vnode->fid.vid, vnode->fid.vnode, index, from, to); - -- /* We want to store information about how much of a page is altered in -- * page->private. -- */ -- BUILD_BUG_ON(PAGE_SIZE > 32768 && sizeof(page->private) < 8); -- - page = grab_cache_page_write_begin(mapping, index, flags); - if (!page) - return -ENOMEM; -@@ -110,9 +105,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping, - SetPageUptodate(page); - } - -- /* page won't leak in error case: it eventually gets cleaned off LRU */ -- *pagep = page; -- - try_again: - /* See if this page is already partially written in a way that we can - * merge the new write with. -@@ -120,8 +112,8 @@ try_again: - t = f = 0; - if (PagePrivate(page)) { - priv = page_private(page); -- f = priv & AFS_PRIV_MAX; -- t = priv >> AFS_PRIV_SHIFT; -+ f = afs_page_dirty_from(priv); -+ t = afs_page_dirty_to(priv); - ASSERTCMP(f, <=, t); - } - -@@ -138,21 +130,9 @@ try_again: - if (!test_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags) && - (to < f || from > t)) - goto flush_conflicting_write; -- if (from < f) -- f = from; -- if (to > t) -- t = to; -- } else { -- f = from; -- t = to; - } - -- priv = (unsigned long)t << AFS_PRIV_SHIFT; -- priv |= f; -- trace_afs_page_dirty(vnode, tracepoint_string("begin"), -- page->index, priv); -- SetPagePrivate(page); -- set_page_private(page, priv); -+ *_page = page; - _leave(" = 0"); - return 0; - -@@ -162,17 +142,18 @@ try_again: - flush_conflicting_write: - _debug("flush conflict"); - ret = write_one_page(page); -- if (ret < 0) { -- _leave(" = %d", ret); -- return ret; -- } -+ if (ret < 0) -+ goto error; - - ret = lock_page_killable(page); -- if (ret < 0) { -- _leave(" = %d", ret); -- return ret; -- } -+ if (ret < 0) -+ goto error; - goto try_again; -+ -+error: -+ put_page(page); -+ _leave(" = %d", ret); -+ return ret; - } - - /* -@@ -184,6 +165,9 @@ int afs_write_end(struct file *file, struct address_space *mapping, - { - struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); - struct key *key = afs_file_key(file); -+ unsigned long priv; -+ unsigned int f, from = pos & (PAGE_SIZE - 1); -+ unsigned int t, to = from + copied; - loff_t i_size, maybe_i_size; - int ret; - -@@ -215,6 +199,25 @@ int afs_write_end(struct file *file, struct address_space *mapping, - SetPageUptodate(page); - } - -+ if (PagePrivate(page)) { -+ priv = page_private(page); -+ f = afs_page_dirty_from(priv); -+ t = afs_page_dirty_to(priv); -+ if (from < f) -+ f = from; -+ if (to > t) -+ t = to; -+ priv = afs_page_dirty(f, t); -+ set_page_private(page, priv); -+ trace_afs_page_dirty(vnode, tracepoint_string("dirty+"), -+ page->index, priv); -+ } else { -+ priv = afs_page_dirty(from, to); -+ attach_page_private(page, (void *)priv); -+ trace_afs_page_dirty(vnode, tracepoint_string("dirty"), -+ page->index, priv); -+ } -+ - set_page_dirty(page); - if (PageDirty(page)) - _debug("dirtied"); -@@ -334,10 +337,9 @@ static void afs_pages_written_back(struct afs_vnode *vnode, - ASSERTCMP(pv.nr, ==, count); - - for (loop = 0; loop < count; loop++) { -- priv = page_private(pv.pages[loop]); -+ priv = (unsigned long)detach_page_private(pv.pages[loop]); - trace_afs_page_dirty(vnode, tracepoint_string("clear"), - pv.pages[loop]->index, priv); -- set_page_private(pv.pages[loop], 0); - end_page_writeback(pv.pages[loop]); - } - first += count; -@@ -396,7 +398,8 @@ static void afs_store_data_success(struct afs_operation *op) - op->ctime = op->file[0].scb.status.mtime_client; - afs_vnode_commit_status(op, &op->file[0]); - if (op->error == 0) { -- afs_pages_written_back(vnode, op->store.first, op->store.last); -+ if (!op->store.laundering) -+ afs_pages_written_back(vnode, op->store.first, op->store.last); - afs_stat_v(vnode, n_stores); - atomic_long_add((op->store.last * PAGE_SIZE + op->store.last_to) - - (op->store.first * PAGE_SIZE + op->store.first_offset), -@@ -415,7 +418,7 @@ static const struct afs_operation_ops afs_store_data_operation = { - */ - static int afs_store_data(struct address_space *mapping, - pgoff_t first, pgoff_t last, -- unsigned offset, unsigned to) -+ unsigned offset, unsigned to, bool laundering) - { - struct afs_vnode *vnode = AFS_FS_I(mapping->host); - struct afs_operation *op; -@@ -448,6 +451,7 @@ static int afs_store_data(struct address_space *mapping, - op->store.last = last; - op->store.first_offset = offset; - op->store.last_to = to; -+ op->store.laundering = laundering; - op->mtime = vnode->vfs_inode.i_mtime; - op->flags |= AFS_OPERATION_UNINTR; - op->ops = &afs_store_data_operation; -@@ -509,8 +513,8 @@ static int afs_write_back_from_locked_page(struct address_space *mapping, - */ - start = primary_page->index; - priv = page_private(primary_page); -- offset = priv & AFS_PRIV_MAX; -- to = priv >> AFS_PRIV_SHIFT; -+ offset = afs_page_dirty_from(priv); -+ to = afs_page_dirty_to(priv); - trace_afs_page_dirty(vnode, tracepoint_string("store"), - primary_page->index, priv); - -@@ -555,8 +559,8 @@ static int afs_write_back_from_locked_page(struct address_space *mapping, - } - - priv = page_private(page); -- f = priv & AFS_PRIV_MAX; -- t = priv >> AFS_PRIV_SHIFT; -+ f = afs_page_dirty_from(priv); -+ t = afs_page_dirty_to(priv); - if (f != 0 && - !test_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags)) { - unlock_page(page); -@@ -601,7 +605,7 @@ no_more: - if (end > i_size) - to = i_size & ~PAGE_MASK; - -- ret = afs_store_data(mapping, first, last, offset, to); -+ ret = afs_store_data(mapping, first, last, offset, to, false); - switch (ret) { - case 0: - ret = count; -@@ -857,12 +861,14 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) - */ - wait_on_page_writeback(vmf->page); - -- priv = (unsigned long)PAGE_SIZE << AFS_PRIV_SHIFT; /* To */ -- priv |= 0; /* From */ -+ priv = afs_page_dirty(0, PAGE_SIZE); -+ priv = afs_page_dirty_mmapped(priv); - trace_afs_page_dirty(vnode, tracepoint_string("mkwrite"), - vmf->page->index, priv); -- SetPagePrivate(vmf->page); -- set_page_private(vmf->page, priv); -+ if (PagePrivate(vmf->page)) -+ set_page_private(vmf->page, priv); -+ else -+ attach_page_private(vmf->page, (void *)priv); - file_update_time(file); - - sb_end_pagefault(inode->i_sb); -@@ -915,19 +921,18 @@ int afs_launder_page(struct page *page) - f = 0; - t = PAGE_SIZE; - if (PagePrivate(page)) { -- f = priv & AFS_PRIV_MAX; -- t = priv >> AFS_PRIV_SHIFT; -+ f = afs_page_dirty_from(priv); -+ t = afs_page_dirty_to(priv); - } - - trace_afs_page_dirty(vnode, tracepoint_string("launder"), - page->index, priv); -- ret = afs_store_data(mapping, page->index, page->index, t, f); -+ ret = afs_store_data(mapping, page->index, page->index, t, f, true); - } - -+ priv = (unsigned long)detach_page_private(page); - trace_afs_page_dirty(vnode, tracepoint_string("laundered"), - page->index, priv); -- set_page_private(page, 0); -- ClearPagePrivate(page); - - #ifdef CONFIG_AFS_FSCACHE - if (PageFsCache(page)) { -diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c -index 84f3c4f575318..38884d6c57cdc 100644 ---- a/fs/afs/xattr.c -+++ b/fs/afs/xattr.c -@@ -85,7 +85,7 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler, - if (acl->size <= size) - memcpy(buffer, acl->data, acl->size); - else -- op->error = -ERANGE; -+ ret = -ERANGE; - } - } - -diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c -index ea8aaf36647ee..a5347d8dcd76b 100644 ---- a/fs/btrfs/block-group.c -+++ b/fs/btrfs/block-group.c -@@ -2034,6 +2034,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) - key.offset = 0; - btrfs_release_path(path); - } -+ btrfs_release_path(path); - - rcu_read_lock(); - list_for_each_entry_rcu(space_info, &info->space_info, list) { -diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c -index cd392da69b819..376827b04b0a3 100644 ---- a/fs/btrfs/ctree.c -+++ b/fs/btrfs/ctree.c -@@ -1061,6 +1061,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, - - ret = update_ref_for_cow(trans, root, buf, cow, &last_ref); - if (ret) { -+ btrfs_tree_unlock(cow); -+ free_extent_buffer(cow); - btrfs_abort_transaction(trans, ret); - return ret; - } -@@ -1068,6 +1070,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, - if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) { - ret = btrfs_reloc_cow_block(trans, root, buf, cow); - if (ret) { -+ btrfs_tree_unlock(cow); -+ free_extent_buffer(cow); - btrfs_abort_transaction(trans, ret); - return ret; - } -@@ -1100,6 +1104,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, - if (last_ref) { - ret = tree_mod_log_free_eb(buf); - if (ret) { -+ btrfs_tree_unlock(cow); -+ free_extent_buffer(cow); - btrfs_abort_transaction(trans, ret); - return ret; - } -diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h -index 9a72896bed2ee..2f5ab8c47f506 100644 ---- a/fs/btrfs/ctree.h -+++ b/fs/btrfs/ctree.h -@@ -2619,7 +2619,7 @@ enum btrfs_flush_state { - int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, - struct btrfs_block_rsv *rsv, - int nitems, bool use_global_rsv); --void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info, -+void btrfs_subvolume_release_metadata(struct btrfs_root *root, - struct btrfs_block_rsv *rsv); - void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes); - -@@ -3517,6 +3517,8 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root, - int btrfs_reada_wait(void *handle); - void btrfs_reada_detach(void *handle); - int btree_readahead_hook(struct extent_buffer *eb, int err); -+void btrfs_reada_remove_dev(struct btrfs_device *dev); -+void btrfs_reada_undo_remove_dev(struct btrfs_device *dev); - - static inline int is_fstree(u64 rootid) - { -diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c -index bf1595a42a988..0727b10a9a897 100644 ---- a/fs/btrfs/delayed-inode.c -+++ b/fs/btrfs/delayed-inode.c -@@ -627,8 +627,7 @@ static int btrfs_delayed_inode_reserve_metadata( - */ - if (!src_rsv || (!trans->bytes_reserved && - src_rsv->type != BTRFS_BLOCK_RSV_DELALLOC)) { -- ret = btrfs_qgroup_reserve_meta_prealloc(root, -- fs_info->nodesize, true); -+ ret = btrfs_qgroup_reserve_meta_prealloc(root, num_bytes, true); - if (ret < 0) - return ret; - ret = btrfs_block_rsv_add(root, dst_rsv, num_bytes, -diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c -index e4a1c6afe35dc..b58b33051a89d 100644 ---- a/fs/btrfs/dev-replace.c -+++ b/fs/btrfs/dev-replace.c -@@ -230,7 +230,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, - int ret = 0; - - *device_out = NULL; -- if (fs_info->fs_devices->seeding) { -+ if (srcdev->fs_devices->seeding) { - btrfs_err(fs_info, "the filesystem is a seed filesystem!"); - return -EINVAL; - } -@@ -668,6 +668,9 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, - } - btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); - -+ if (!scrub_ret) -+ btrfs_reada_remove_dev(src_device); -+ - /* - * We have to use this loop approach because at this point src_device - * has to be available for transaction commit to complete, yet new -@@ -676,6 +679,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, - while (1) { - trans = btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) { -+ btrfs_reada_undo_remove_dev(src_device); - mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); - return PTR_ERR(trans); - } -@@ -726,6 +730,7 @@ error: - up_write(&dev_replace->rwsem); - mutex_unlock(&fs_info->chunk_mutex); - mutex_unlock(&fs_info->fs_devices->device_list_mutex); -+ btrfs_reada_undo_remove_dev(src_device); - btrfs_rm_dev_replace_blocked(fs_info); - if (tgt_device) - btrfs_destroy_dev_replace_tgtdev(tgt_device); -diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c -index 9f72b092bc228..7882c07645014 100644 ---- a/fs/btrfs/disk-io.c -+++ b/fs/btrfs/disk-io.c -@@ -3482,8 +3482,12 @@ struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev, - return ERR_CAST(page); - - super = page_address(page); -- if (btrfs_super_bytenr(super) != bytenr || -- btrfs_super_magic(super) != BTRFS_MAGIC) { -+ if (btrfs_super_magic(super) != BTRFS_MAGIC) { -+ btrfs_release_disk_super(super); -+ return ERR_PTR(-ENODATA); -+ } -+ -+ if (btrfs_super_bytenr(super) != bytenr) { - btrfs_release_disk_super(super); - return ERR_PTR(-EINVAL); - } -diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c -index 780b9c9a98fe3..dbff61d36cab4 100644 ---- a/fs/btrfs/extent-tree.c -+++ b/fs/btrfs/extent-tree.c -@@ -3918,11 +3918,12 @@ static int prepare_allocation(struct btrfs_fs_info *fs_info, - * |- Push harder to find free extents - * |- If not found, re-iterate all block groups - */ --static noinline int find_free_extent(struct btrfs_fs_info *fs_info, -+static noinline int find_free_extent(struct btrfs_root *root, - u64 ram_bytes, u64 num_bytes, u64 empty_size, - u64 hint_byte_orig, struct btrfs_key *ins, - u64 flags, int delalloc) - { -+ struct btrfs_fs_info *fs_info = root->fs_info; - int ret = 0; - int cache_block_group_error = 0; - struct btrfs_block_group *block_group = NULL; -@@ -3954,7 +3955,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, - ins->objectid = 0; - ins->offset = 0; - -- trace_find_free_extent(fs_info, num_bytes, empty_size, flags); -+ trace_find_free_extent(root, num_bytes, empty_size, flags); - - space_info = btrfs_find_space_info(fs_info, flags); - if (!space_info) { -@@ -4203,7 +4204,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, - flags = get_alloc_profile_by_root(root, is_data); - again: - WARN_ON(num_bytes < fs_info->sectorsize); -- ret = find_free_extent(fs_info, ram_bytes, num_bytes, empty_size, -+ ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, - hint_byte, ins, flags, delalloc); - if (!ret && !is_data) { - btrfs_dec_block_group_reservations(fs_info, ins->objectid); -diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c -index 9570458aa8471..11d132bc2679c 100644 ---- a/fs/btrfs/inode.c -+++ b/fs/btrfs/inode.c -@@ -4051,7 +4051,7 @@ out_end_trans: - err = ret; - inode->i_flags |= S_DEAD; - out_release: -- btrfs_subvolume_release_metadata(fs_info, &block_rsv); -+ btrfs_subvolume_release_metadata(root, &block_rsv); - out_up_write: - up_write(&fs_info->subvol_sem); - if (err) { -diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c -index 2d9109d9e98f9..2a5dc42f07505 100644 ---- a/fs/btrfs/ioctl.c -+++ b/fs/btrfs/ioctl.c -@@ -618,7 +618,7 @@ static noinline int create_subvol(struct inode *dir, - trans = btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) { - ret = PTR_ERR(trans); -- btrfs_subvolume_release_metadata(fs_info, &block_rsv); -+ btrfs_subvolume_release_metadata(root, &block_rsv); - goto fail_free; - } - trans->block_rsv = &block_rsv; -@@ -742,7 +742,7 @@ fail: - kfree(root_item); - trans->block_rsv = NULL; - trans->bytes_reserved = 0; -- btrfs_subvolume_release_metadata(fs_info, &block_rsv); -+ btrfs_subvolume_release_metadata(root, &block_rsv); - - err = btrfs_commit_transaction(trans); - if (err && !ret) -@@ -856,7 +856,7 @@ fail: - if (ret && pending_snapshot->snap) - pending_snapshot->snap->anon_dev = 0; - btrfs_put_root(pending_snapshot->snap); -- btrfs_subvolume_release_metadata(fs_info, &pending_snapshot->block_rsv); -+ btrfs_subvolume_release_metadata(root, &pending_snapshot->block_rsv); - free_pending: - if (pending_snapshot->anon_dev) - free_anon_bdev(pending_snapshot->anon_dev); -diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c -index 243a2e44526ef..49ff7162d3d0a 100644 ---- a/fs/btrfs/reada.c -+++ b/fs/btrfs/reada.c -@@ -421,6 +421,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, - if (!dev->bdev) - continue; - -+ if (test_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state)) -+ continue; -+ - if (dev_replace_is_ongoing && - dev == fs_info->dev_replace.tgtdev) { - /* -@@ -445,6 +448,8 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, - } - have_zone = 1; - } -+ if (!have_zone) -+ radix_tree_delete(&fs_info->reada_tree, index); - spin_unlock(&fs_info->reada_lock); - up_read(&fs_info->dev_replace.rwsem); - -@@ -1012,3 +1017,45 @@ void btrfs_reada_detach(void *handle) - - kref_put(&rc->refcnt, reada_control_release); - } -+ -+/* -+ * Before removing a device (device replace or device remove ioctls), call this -+ * function to wait for all existing readahead requests on the device and to -+ * make sure no one queues more readahead requests for the device. -+ * -+ * Must be called without holding neither the device list mutex nor the device -+ * replace semaphore, otherwise it will deadlock. -+ */ -+void btrfs_reada_remove_dev(struct btrfs_device *dev) -+{ -+ struct btrfs_fs_info *fs_info = dev->fs_info; -+ -+ /* Serialize with readahead extent creation at reada_find_extent(). */ -+ spin_lock(&fs_info->reada_lock); -+ set_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state); -+ spin_unlock(&fs_info->reada_lock); -+ -+ /* -+ * There might be readahead requests added to the radix trees which -+ * were not yet added to the readahead work queue. We need to start -+ * them and wait for their completion, otherwise we can end up with -+ * use-after-free problems when dropping the last reference on the -+ * readahead extents and their zones, as they need to access the -+ * device structure. -+ */ -+ reada_start_machine(fs_info); -+ btrfs_flush_workqueue(fs_info->readahead_workers); -+} -+ -+/* -+ * If when removing a device (device replace or device remove ioctls) an error -+ * happens after calling btrfs_reada_remove_dev(), call this to undo what that -+ * function did. This is safe to call even if btrfs_reada_remove_dev() was not -+ * called before. -+ */ -+void btrfs_reada_undo_remove_dev(struct btrfs_device *dev) -+{ -+ spin_lock(&dev->fs_info->reada_lock); -+ clear_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state); -+ spin_unlock(&dev->fs_info->reada_lock); -+} -diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c -index 5cd02514cf4d4..bcb785d1867cf 100644 ---- a/fs/btrfs/reflink.c -+++ b/fs/btrfs/reflink.c -@@ -520,6 +520,8 @@ process_slot: - ret = -EINTR; - goto out; - } -+ -+ cond_resched(); - } - ret = 0; - -diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c -index c89697486366a..702dc5441f039 100644 ---- a/fs/btrfs/root-tree.c -+++ b/fs/btrfs/root-tree.c -@@ -512,11 +512,20 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, - if (ret && qgroup_num_bytes) - btrfs_qgroup_free_meta_prealloc(root, qgroup_num_bytes); - -+ if (!ret) { -+ spin_lock(&rsv->lock); -+ rsv->qgroup_rsv_reserved += qgroup_num_bytes; -+ spin_unlock(&rsv->lock); -+ } - return ret; - } - --void btrfs_subvolume_release_metadata(struct btrfs_fs_info *fs_info, -+void btrfs_subvolume_release_metadata(struct btrfs_root *root, - struct btrfs_block_rsv *rsv) - { -- btrfs_block_rsv_release(fs_info, rsv, (u64)-1, NULL); -+ struct btrfs_fs_info *fs_info = root->fs_info; -+ u64 qgroup_to_release; -+ -+ btrfs_block_rsv_release(fs_info, rsv, (u64)-1, &qgroup_to_release); -+ btrfs_qgroup_convert_reserved_meta(root, qgroup_to_release); - } -diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c -index d9813a5b075ac..e357f23fb54ad 100644 ---- a/fs/btrfs/send.c -+++ b/fs/btrfs/send.c -@@ -3812,6 +3812,72 @@ static int update_ref_path(struct send_ctx *sctx, struct recorded_ref *ref) - return 0; - } - -+/* -+ * When processing the new references for an inode we may orphanize an existing -+ * directory inode because its old name conflicts with one of the new references -+ * of the current inode. Later, when processing another new reference of our -+ * inode, we might need to orphanize another inode, but the path we have in the -+ * reference reflects the pre-orphanization name of the directory we previously -+ * orphanized. For example: -+ * -+ * parent snapshot looks like: -+ * -+ * . (ino 256) -+ * |----- f1 (ino 257) -+ * |----- f2 (ino 258) -+ * |----- d1/ (ino 259) -+ * |----- d2/ (ino 260) -+ * -+ * send snapshot looks like: -+ * -+ * . (ino 256) -+ * |----- d1 (ino 258) -+ * |----- f2/ (ino 259) -+ * |----- f2_link/ (ino 260) -+ * | |----- f1 (ino 257) -+ * | -+ * |----- d2 (ino 258) -+ * -+ * When processing inode 257 we compute the name for inode 259 as "d1", and we -+ * cache it in the name cache. Later when we start processing inode 258, when -+ * collecting all its new references we set a full path of "d1/d2" for its new -+ * reference with name "d2". When we start processing the new references we -+ * start by processing the new reference with name "d1", and this results in -+ * orphanizing inode 259, since its old reference causes a conflict. Then we -+ * move on the next new reference, with name "d2", and we find out we must -+ * orphanize inode 260, as its old reference conflicts with ours - but for the -+ * orphanization we use a source path corresponding to the path we stored in the -+ * new reference, which is "d1/d2" and not "o259-6-0/d2" - this makes the -+ * receiver fail since the path component "d1/" no longer exists, it was renamed -+ * to "o259-6-0/" when processing the previous new reference. So in this case we -+ * must recompute the path in the new reference and use it for the new -+ * orphanization operation. -+ */ -+static int refresh_ref_path(struct send_ctx *sctx, struct recorded_ref *ref) -+{ -+ char *name; -+ int ret; -+ -+ name = kmemdup(ref->name, ref->name_len, GFP_KERNEL); -+ if (!name) -+ return -ENOMEM; -+ -+ fs_path_reset(ref->full_path); -+ ret = get_cur_path(sctx, ref->dir, ref->dir_gen, ref->full_path); -+ if (ret < 0) -+ goto out; -+ -+ ret = fs_path_add(ref->full_path, name, ref->name_len); -+ if (ret < 0) -+ goto out; -+ -+ /* Update the reference's base name pointer. */ -+ set_ref_path(ref, ref->full_path); -+out: -+ kfree(name); -+ return ret; -+} -+ - /* - * This does all the move/link/unlink/rmdir magic. - */ -@@ -3880,52 +3946,56 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) - goto out; - } - -+ /* -+ * Before doing any rename and link operations, do a first pass on the -+ * new references to orphanize any unprocessed inodes that may have a -+ * reference that conflicts with one of the new references of the current -+ * inode. This needs to happen first because a new reference may conflict -+ * with the old reference of a parent directory, so we must make sure -+ * that the path used for link and rename commands don't use an -+ * orphanized name when an ancestor was not yet orphanized. -+ * -+ * Example: -+ * -+ * Parent snapshot: -+ * -+ * . (ino 256) -+ * |----- testdir/ (ino 259) -+ * | |----- a (ino 257) -+ * | -+ * |----- b (ino 258) -+ * -+ * Send snapshot: -+ * -+ * . (ino 256) -+ * |----- testdir_2/ (ino 259) -+ * | |----- a (ino 260) -+ * | -+ * |----- testdir (ino 257) -+ * |----- b (ino 257) -+ * |----- b2 (ino 258) -+ * -+ * Processing the new reference for inode 257 with name "b" may happen -+ * before processing the new reference with name "testdir". If so, we -+ * must make sure that by the time we send a link command to create the -+ * hard link "b", inode 259 was already orphanized, since the generated -+ * path in "valid_path" already contains the orphanized name for 259. -+ * We are processing inode 257, so only later when processing 259 we do -+ * the rename operation to change its temporary (orphanized) name to -+ * "testdir_2". -+ */ - list_for_each_entry(cur, &sctx->new_refs, list) { -- /* -- * We may have refs where the parent directory does not exist -- * yet. This happens if the parent directories inum is higher -- * than the current inum. To handle this case, we create the -- * parent directory out of order. But we need to check if this -- * did already happen before due to other refs in the same dir. -- */ - ret = get_cur_inode_state(sctx, cur->dir, cur->dir_gen); - if (ret < 0) - goto out; -- if (ret == inode_state_will_create) { -- ret = 0; -- /* -- * First check if any of the current inodes refs did -- * already create the dir. -- */ -- list_for_each_entry(cur2, &sctx->new_refs, list) { -- if (cur == cur2) -- break; -- if (cur2->dir == cur->dir) { -- ret = 1; -- break; -- } -- } -- -- /* -- * If that did not happen, check if a previous inode -- * did already create the dir. -- */ -- if (!ret) -- ret = did_create_dir(sctx, cur->dir); -- if (ret < 0) -- goto out; -- if (!ret) { -- ret = send_create_inode(sctx, cur->dir); -- if (ret < 0) -- goto out; -- } -- } -+ if (ret == inode_state_will_create) -+ continue; - - /* -- * Check if this new ref would overwrite the first ref of -- * another unprocessed inode. If yes, orphanize the -- * overwritten inode. If we find an overwritten ref that is -- * not the first ref, simply unlink it. -+ * Check if this new ref would overwrite the first ref of another -+ * unprocessed inode. If yes, orphanize the overwritten inode. -+ * If we find an overwritten ref that is not the first ref, -+ * simply unlink it. - */ - ret = will_overwrite_ref(sctx, cur->dir, cur->dir_gen, - cur->name, cur->name_len, -@@ -3942,6 +4012,12 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) - struct name_cache_entry *nce; - struct waiting_dir_move *wdm; - -+ if (orphanized_dir) { -+ ret = refresh_ref_path(sctx, cur); -+ if (ret < 0) -+ goto out; -+ } -+ - ret = orphanize_inode(sctx, ow_inode, ow_gen, - cur->full_path); - if (ret < 0) -@@ -4004,6 +4080,49 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) - } - } - -+ } -+ -+ list_for_each_entry(cur, &sctx->new_refs, list) { -+ /* -+ * We may have refs where the parent directory does not exist -+ * yet. This happens if the parent directories inum is higher -+ * than the current inum. To handle this case, we create the -+ * parent directory out of order. But we need to check if this -+ * did already happen before due to other refs in the same dir. -+ */ -+ ret = get_cur_inode_state(sctx, cur->dir, cur->dir_gen); -+ if (ret < 0) -+ goto out; -+ if (ret == inode_state_will_create) { -+ ret = 0; -+ /* -+ * First check if any of the current inodes refs did -+ * already create the dir. -+ */ -+ list_for_each_entry(cur2, &sctx->new_refs, list) { -+ if (cur == cur2) -+ break; -+ if (cur2->dir == cur->dir) { -+ ret = 1; -+ break; -+ } -+ } -+ -+ /* -+ * If that did not happen, check if a previous inode -+ * did already create the dir. -+ */ -+ if (!ret) -+ ret = did_create_dir(sctx, cur->dir); -+ if (ret < 0) -+ goto out; -+ if (!ret) { -+ ret = send_create_inode(sctx, cur->dir); -+ if (ret < 0) -+ goto out; -+ } -+ } -+ - if (S_ISDIR(sctx->cur_inode_mode) && sctx->parent_root) { - ret = wait_for_dest_dir_move(sctx, cur, is_orphan); - if (ret < 0) -@@ -7181,7 +7300,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg) - - alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1); - -- sctx->clone_roots = kzalloc(alloc_size, GFP_KERNEL); -+ sctx->clone_roots = kvzalloc(alloc_size, GFP_KERNEL); - if (!sctx->clone_roots) { - ret = -ENOMEM; - goto out; -diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c -index 7b1fee630f978..8784b74f5232e 100644 ---- a/fs/btrfs/tree-checker.c -+++ b/fs/btrfs/tree-checker.c -@@ -760,18 +760,36 @@ int btrfs_check_chunk_valid(struct extent_buffer *leaf, - u64 type; - u64 features; - bool mixed = false; -+ int raid_index; -+ int nparity; -+ int ncopies; - - length = btrfs_chunk_length(leaf, chunk); - stripe_len = btrfs_chunk_stripe_len(leaf, chunk); - num_stripes = btrfs_chunk_num_stripes(leaf, chunk); - sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk); - type = btrfs_chunk_type(leaf, chunk); -+ raid_index = btrfs_bg_flags_to_raid_index(type); -+ ncopies = btrfs_raid_array[raid_index].ncopies; -+ nparity = btrfs_raid_array[raid_index].nparity; - - if (!num_stripes) { - chunk_err(leaf, chunk, logical, - "invalid chunk num_stripes, have %u", num_stripes); - return -EUCLEAN; - } -+ if (num_stripes < ncopies) { -+ chunk_err(leaf, chunk, logical, -+ "invalid chunk num_stripes < ncopies, have %u < %d", -+ num_stripes, ncopies); -+ return -EUCLEAN; -+ } -+ if (nparity && num_stripes == nparity) { -+ chunk_err(leaf, chunk, logical, -+ "invalid chunk num_stripes == nparity, have %u == %d", -+ num_stripes, nparity); -+ return -EUCLEAN; -+ } - if (!IS_ALIGNED(logical, fs_info->sectorsize)) { - chunk_err(leaf, chunk, logical, - "invalid chunk logical, have %llu should aligned to %u", -@@ -1035,7 +1053,7 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key, - int slot) - { - struct btrfs_fs_info *fs_info = leaf->fs_info; -- struct btrfs_root_item ri; -+ struct btrfs_root_item ri = { 0 }; - const u64 valid_root_flags = BTRFS_ROOT_SUBVOL_RDONLY | - BTRFS_ROOT_SUBVOL_DEAD; - int ret; -@@ -1044,14 +1062,21 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key, - if (ret < 0) - return ret; - -- if (btrfs_item_size_nr(leaf, slot) != sizeof(ri)) { -+ if (btrfs_item_size_nr(leaf, slot) != sizeof(ri) && -+ btrfs_item_size_nr(leaf, slot) != btrfs_legacy_root_item_size()) { - generic_err(leaf, slot, -- "invalid root item size, have %u expect %zu", -- btrfs_item_size_nr(leaf, slot), sizeof(ri)); -+ "invalid root item size, have %u expect %zu or %u", -+ btrfs_item_size_nr(leaf, slot), sizeof(ri), -+ btrfs_legacy_root_item_size()); - } - -+ /* -+ * For legacy root item, the members starting at generation_v2 will be -+ * all filled with 0. -+ * And since we allow geneartion_v2 as 0, it will still pass the check. -+ */ - read_extent_buffer(leaf, &ri, btrfs_item_ptr_offset(leaf, slot), -- sizeof(ri)); -+ btrfs_item_size_nr(leaf, slot)); - - /* Generation related */ - if (btrfs_root_generation(&ri) > -diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c -index 39da9db352786..a6f061fcd3001 100644 ---- a/fs/btrfs/tree-log.c -+++ b/fs/btrfs/tree-log.c -@@ -3615,6 +3615,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, - * search and this search we'll not find the key again and can just - * bail. - */ -+search: - ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); - if (ret != 0) - goto done; -@@ -3634,6 +3635,13 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, - - if (min_key.objectid != ino || min_key.type != key_type) - goto done; -+ -+ if (need_resched()) { -+ btrfs_release_path(path); -+ cond_resched(); -+ goto search; -+ } -+ - ret = overwrite_item(trans, log, dst_path, src, i, - &min_key); - if (ret) { -diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c -index e61c298ce2b42..309734fdd1580 100644 ---- a/fs/btrfs/volumes.c -+++ b/fs/btrfs/volumes.c -@@ -942,16 +942,18 @@ static noinline struct btrfs_device *device_list_add(const char *path, - bdput(path_bdev); - mutex_unlock(&fs_devices->device_list_mutex); - btrfs_warn_in_rcu(device->fs_info, -- "duplicate device fsid:devid for %pU:%llu old:%s new:%s", -- disk_super->fsid, devid, -- rcu_str_deref(device->name), path); -+ "duplicate device %s devid %llu generation %llu scanned by %s (%d)", -+ path, devid, found_transid, -+ current->comm, -+ task_pid_nr(current)); - return ERR_PTR(-EEXIST); - } - bdput(path_bdev); - btrfs_info_in_rcu(device->fs_info, -- "device fsid %pU devid %llu moved old:%s new:%s", -- disk_super->fsid, devid, -- rcu_str_deref(device->name), path); -+ "devid %llu device path %s changed to %s scanned by %s (%d)", -+ devid, rcu_str_deref(device->name), -+ path, current->comm, -+ task_pid_nr(current)); - } - - name = rcu_string_strdup(path, GFP_NOFS); -@@ -1198,17 +1200,23 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, - { - struct btrfs_device *device; - struct btrfs_device *latest_dev = NULL; -+ struct btrfs_device *tmp_device; - - flags |= FMODE_EXCL; - -- list_for_each_entry(device, &fs_devices->devices, dev_list) { -- /* Just open everything we can; ignore failures here */ -- if (btrfs_open_one_device(fs_devices, device, flags, holder)) -- continue; -+ list_for_each_entry_safe(device, tmp_device, &fs_devices->devices, -+ dev_list) { -+ int ret; - -- if (!latest_dev || -- device->generation > latest_dev->generation) -+ ret = btrfs_open_one_device(fs_devices, device, flags, holder); -+ if (ret == 0 && -+ (!latest_dev || device->generation > latest_dev->generation)) { - latest_dev = device; -+ } else if (ret == -ENODATA) { -+ fs_devices->num_devices--; -+ list_del(&device->dev_list); -+ btrfs_free_device(device); -+ } - } - if (fs_devices->open_devices == 0) - return -EINVAL; -@@ -2096,6 +2104,8 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, - - mutex_unlock(&uuid_mutex); - ret = btrfs_shrink_device(device, 0); -+ if (!ret) -+ btrfs_reada_remove_dev(device); - mutex_lock(&uuid_mutex); - if (ret) - goto error_undo; -@@ -2183,6 +2193,7 @@ out: - return ret; - - error_undo: -+ btrfs_reada_undo_remove_dev(device); - if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { - mutex_lock(&fs_info->chunk_mutex); - list_add(&device->dev_alloc_list, -@@ -2611,9 +2622,6 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path - btrfs_set_super_num_devices(fs_info->super_copy, - orig_super_num_devices + 1); - -- /* add sysfs device entry */ -- btrfs_sysfs_add_devices_dir(fs_devices, device); -- - /* - * we've got more storage, clear any full flags on the space - * infos -@@ -2621,6 +2629,10 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path - btrfs_clear_space_info_full(fs_info); - - mutex_unlock(&fs_info->chunk_mutex); -+ -+ /* Add sysfs device entry */ -+ btrfs_sysfs_add_devices_dir(fs_devices, device); -+ - mutex_unlock(&fs_devices->device_list_mutex); - - if (seeding_dev) { -diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h -index 302c9234f7d08..2a33a6af289b9 100644 ---- a/fs/btrfs/volumes.h -+++ b/fs/btrfs/volumes.h -@@ -50,6 +50,7 @@ struct btrfs_io_geometry { - #define BTRFS_DEV_STATE_MISSING (2) - #define BTRFS_DEV_STATE_REPLACE_TGT (3) - #define BTRFS_DEV_STATE_FLUSH_SENT (4) -+#define BTRFS_DEV_STATE_NO_READA (5) - - struct btrfs_device { - struct list_head dev_list; /* device_list_mutex */ -diff --git a/fs/buffer.c b/fs/buffer.c -index 50bbc99e3d960..5a28a6aa7f16b 100644 ---- a/fs/buffer.c -+++ b/fs/buffer.c -@@ -2771,16 +2771,6 @@ int nobh_writepage(struct page *page, get_block_t *get_block, - /* Is the page fully outside i_size? (truncate in progress) */ - offset = i_size & (PAGE_SIZE-1); - if (page->index >= end_index+1 || !offset) { -- /* -- * The page may have dirty, unmapped buffers. For example, -- * they may have been added in ext3_writepage(). Make them -- * freeable here, so the page does not leak. -- */ --#if 0 -- /* Not really sure about this - do we need this ? */ -- if (page->mapping->a_ops->invalidatepage) -- page->mapping->a_ops->invalidatepage(page, offset); --#endif - unlock_page(page); - return 0; /* don't care */ - } -@@ -2975,12 +2965,6 @@ int block_write_full_page(struct page *page, get_block_t *get_block, - /* Is the page fully outside i_size? (truncate in progress) */ - offset = i_size & (PAGE_SIZE-1); - if (page->index >= end_index+1 || !offset) { -- /* -- * The page may have dirty, unmapped buffers. For example, -- * they may have been added in ext3_writepage(). Make them -- * freeable here, so the page does not leak. -- */ -- do_invalidatepage(page, 0, PAGE_SIZE); - unlock_page(page); - return 0; /* don't care */ - } -diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c -index 3080cda9e8245..8bda092e60c5a 100644 ---- a/fs/cachefiles/rdwr.c -+++ b/fs/cachefiles/rdwr.c -@@ -121,7 +121,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object, - _debug("reissue read"); - ret = bmapping->a_ops->readpage(NULL, backpage); - if (ret < 0) -- goto unlock_discard; -+ goto discard; - } - - /* but the page may have been read before the monitor was installed, so -@@ -138,6 +138,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object, - - unlock_discard: - unlock_page(backpage); -+discard: - spin_lock_irq(&object->work_lock); - list_del(&monitor->op_link); - spin_unlock_irq(&object->work_lock); -diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c -index 6ea761c84494f..970e5a0940350 100644 ---- a/fs/ceph/addr.c -+++ b/fs/ceph/addr.c -@@ -1522,7 +1522,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) - struct ceph_inode_info *ci = ceph_inode(inode); - struct ceph_file_info *fi = vma->vm_file->private_data; - struct page *pinned_page = NULL; -- loff_t off = vmf->pgoff << PAGE_SHIFT; -+ loff_t off = (loff_t)vmf->pgoff << PAGE_SHIFT; - int want, got, err; - sigset_t oldset; - vm_fault_t ret = VM_FAULT_SIGBUS; -diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c -index 4a26862d7667e..76d8d9495d1d4 100644 ---- a/fs/ceph/mds_client.c -+++ b/fs/ceph/mds_client.c -@@ -3612,6 +3612,39 @@ fail_msg: - return err; - } - -+static struct dentry* d_find_primary(struct inode *inode) -+{ -+ struct dentry *alias, *dn = NULL; -+ -+ if (hlist_empty(&inode->i_dentry)) -+ return NULL; -+ -+ spin_lock(&inode->i_lock); -+ if (hlist_empty(&inode->i_dentry)) -+ goto out_unlock; -+ -+ if (S_ISDIR(inode->i_mode)) { -+ alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias); -+ if (!IS_ROOT(alias)) -+ dn = dget(alias); -+ goto out_unlock; -+ } -+ -+ hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { -+ spin_lock(&alias->d_lock); -+ if (!d_unhashed(alias) && -+ (ceph_dentry(alias)->flags & CEPH_DENTRY_PRIMARY_LINK)) { -+ dn = dget_dlock(alias); -+ } -+ spin_unlock(&alias->d_lock); -+ if (dn) -+ break; -+ } -+out_unlock: -+ spin_unlock(&inode->i_lock); -+ return dn; -+} -+ - /* - * Encode information about a cap for a reconnect with the MDS. - */ -@@ -3625,13 +3658,32 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap, - struct ceph_inode_info *ci = cap->ci; - struct ceph_reconnect_state *recon_state = arg; - struct ceph_pagelist *pagelist = recon_state->pagelist; -- int err; -+ struct dentry *dentry; -+ char *path; -+ int pathlen, err; -+ u64 pathbase; - u64 snap_follows; - - dout(" adding %p ino %llx.%llx cap %p %lld %s\n", - inode, ceph_vinop(inode), cap, cap->cap_id, - ceph_cap_string(cap->issued)); - -+ dentry = d_find_primary(inode); -+ if (dentry) { -+ /* set pathbase to parent dir when msg_version >= 2 */ -+ path = ceph_mdsc_build_path(dentry, &pathlen, &pathbase, -+ recon_state->msg_version >= 2); -+ dput(dentry); -+ if (IS_ERR(path)) { -+ err = PTR_ERR(path); -+ goto out_err; -+ } -+ } else { -+ path = NULL; -+ pathlen = 0; -+ pathbase = 0; -+ } -+ - spin_lock(&ci->i_ceph_lock); - cap->seq = 0; /* reset cap seq */ - cap->issue_seq = 0; /* and issue_seq */ -@@ -3652,7 +3704,7 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap, - rec.v2.wanted = cpu_to_le32(__ceph_caps_wanted(ci)); - rec.v2.issued = cpu_to_le32(cap->issued); - rec.v2.snaprealm = cpu_to_le64(ci->i_snap_realm->ino); -- rec.v2.pathbase = 0; -+ rec.v2.pathbase = cpu_to_le64(pathbase); - rec.v2.flock_len = (__force __le32) - ((ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) ? 0 : 1); - } else { -@@ -3663,7 +3715,7 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap, - ceph_encode_timespec64(&rec.v1.mtime, &inode->i_mtime); - ceph_encode_timespec64(&rec.v1.atime, &inode->i_atime); - rec.v1.snaprealm = cpu_to_le64(ci->i_snap_realm->ino); -- rec.v1.pathbase = 0; -+ rec.v1.pathbase = cpu_to_le64(pathbase); - } - - if (list_empty(&ci->i_cap_snaps)) { -@@ -3725,7 +3777,7 @@ encode_again: - sizeof(struct ceph_filelock); - rec.v2.flock_len = cpu_to_le32(struct_len); - -- struct_len += sizeof(u32) + sizeof(rec.v2); -+ struct_len += sizeof(u32) + pathlen + sizeof(rec.v2); - - if (struct_v >= 2) - struct_len += sizeof(u64); /* snap_follows */ -@@ -3749,7 +3801,7 @@ encode_again: - ceph_pagelist_encode_8(pagelist, 1); - ceph_pagelist_encode_32(pagelist, struct_len); - } -- ceph_pagelist_encode_string(pagelist, NULL, 0); -+ ceph_pagelist_encode_string(pagelist, path, pathlen); - ceph_pagelist_append(pagelist, &rec, sizeof(rec.v2)); - ceph_locks_to_pagelist(flocks, pagelist, - num_fcntl_locks, num_flock_locks); -@@ -3758,39 +3810,20 @@ encode_again: - out_freeflocks: - kfree(flocks); - } else { -- u64 pathbase = 0; -- int pathlen = 0; -- char *path = NULL; -- struct dentry *dentry; -- -- dentry = d_find_alias(inode); -- if (dentry) { -- path = ceph_mdsc_build_path(dentry, -- &pathlen, &pathbase, 0); -- dput(dentry); -- if (IS_ERR(path)) { -- err = PTR_ERR(path); -- goto out_err; -- } -- rec.v1.pathbase = cpu_to_le64(pathbase); -- } -- - err = ceph_pagelist_reserve(pagelist, - sizeof(u64) + sizeof(u32) + - pathlen + sizeof(rec.v1)); -- if (err) { -- goto out_freepath; -- } -+ if (err) -+ goto out_err; - - ceph_pagelist_encode_64(pagelist, ceph_ino(inode)); - ceph_pagelist_encode_string(pagelist, path, pathlen); - ceph_pagelist_append(pagelist, &rec, sizeof(rec.v1)); --out_freepath: -- ceph_mdsc_free_path(path, pathlen); - } - - out_err: -- if (err >= 0) -+ ceph_mdsc_free_path(path, pathlen); -+ if (!err) - recon_state->nr_caps++; - return err; - } -diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h -index b565d83ba89ed..5a491afafacc7 100644 ---- a/fs/cifs/cifsglob.h -+++ b/fs/cifs/cifsglob.h -@@ -510,6 +510,8 @@ struct smb_version_operations { - struct fiemap_extent_info *, u64, u64); - /* version specific llseek implementation */ - loff_t (*llseek)(struct file *, struct cifs_tcon *, loff_t, int); -+ /* Check for STATUS_IO_TIMEOUT */ -+ bool (*is_status_io_timeout)(char *buf); - }; - - struct smb_version_values { -diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c -index 9817a31a39db6..b8780a79a42a2 100644 ---- a/fs/cifs/connect.c -+++ b/fs/cifs/connect.c -@@ -69,6 +69,9 @@ extern bool disable_legacy_dialects; - #define TLINK_ERROR_EXPIRE (1 * HZ) - #define TLINK_IDLE_EXPIRE (600 * HZ) - -+/* Drop the connection to not overload the server */ -+#define NUM_STATUS_IO_TIMEOUT 5 -+ - enum { - /* Mount options that take no arguments */ - Opt_user_xattr, Opt_nouser_xattr, -@@ -1117,7 +1120,7 @@ cifs_demultiplex_thread(void *p) - struct task_struct *task_to_wake = NULL; - struct mid_q_entry *mids[MAX_COMPOUND]; - char *bufs[MAX_COMPOUND]; -- unsigned int noreclaim_flag; -+ unsigned int noreclaim_flag, num_io_timeout = 0; - - noreclaim_flag = memalloc_noreclaim_save(); - cifs_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current)); -@@ -1213,6 +1216,16 @@ next_pdu: - continue; - } - -+ if (server->ops->is_status_io_timeout && -+ server->ops->is_status_io_timeout(buf)) { -+ num_io_timeout++; -+ if (num_io_timeout > NUM_STATUS_IO_TIMEOUT) { -+ cifs_reconnect(server); -+ num_io_timeout = 0; -+ continue; -+ } -+ } -+ - server->lstrp = jiffies; - - for (i = 0; i < num_mids; i++) { -diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c -index 1f75b25e559a7..daec31be85718 100644 ---- a/fs/cifs/inode.c -+++ b/fs/cifs/inode.c -@@ -2883,13 +2883,18 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs) - { - struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); - struct cifs_tcon *pTcon = cifs_sb_master_tcon(cifs_sb); -+ int rc, retries = 0; - -- if (pTcon->unix_ext) -- return cifs_setattr_unix(direntry, attrs); -- -- return cifs_setattr_nounix(direntry, attrs); -+ do { -+ if (pTcon->unix_ext) -+ rc = cifs_setattr_unix(direntry, attrs); -+ else -+ rc = cifs_setattr_nounix(direntry, attrs); -+ retries++; -+ } while (is_retryable_error(rc) && retries < 2); - - /* BB: add cifs_setattr_legacy for really old servers */ -+ return rc; - } - - #if 0 -diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c -index 7fde3775cb574..b004cf87692a7 100644 ---- a/fs/cifs/smb2maperror.c -+++ b/fs/cifs/smb2maperror.c -@@ -488,7 +488,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = { - {STATUS_PIPE_CONNECTED, -EIO, "STATUS_PIPE_CONNECTED"}, - {STATUS_PIPE_LISTENING, -EIO, "STATUS_PIPE_LISTENING"}, - {STATUS_INVALID_READ_MODE, -EIO, "STATUS_INVALID_READ_MODE"}, -- {STATUS_IO_TIMEOUT, -ETIMEDOUT, "STATUS_IO_TIMEOUT"}, -+ {STATUS_IO_TIMEOUT, -EAGAIN, "STATUS_IO_TIMEOUT"}, - {STATUS_FILE_FORCED_CLOSED, -EIO, "STATUS_FILE_FORCED_CLOSED"}, - {STATUS_PROFILING_NOT_STARTED, -EIO, "STATUS_PROFILING_NOT_STARTED"}, - {STATUS_PROFILING_NOT_STOPPED, -EIO, "STATUS_PROFILING_NOT_STOPPED"}, -diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c -index 09e1cd320ee56..e2e53652193e6 100644 ---- a/fs/cifs/smb2ops.c -+++ b/fs/cifs/smb2ops.c -@@ -2346,6 +2346,17 @@ smb2_is_session_expired(char *buf) - return true; - } - -+static bool -+smb2_is_status_io_timeout(char *buf) -+{ -+ struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; -+ -+ if (shdr->Status == STATUS_IO_TIMEOUT) -+ return true; -+ else -+ return false; -+} -+ - static int - smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid, - struct cifsInodeInfo *cinode) -@@ -4816,6 +4827,7 @@ struct smb_version_operations smb20_operations = { - .make_node = smb2_make_node, - .fiemap = smb3_fiemap, - .llseek = smb3_llseek, -+ .is_status_io_timeout = smb2_is_status_io_timeout, - }; - - struct smb_version_operations smb21_operations = { -@@ -4916,6 +4928,7 @@ struct smb_version_operations smb21_operations = { - .make_node = smb2_make_node, - .fiemap = smb3_fiemap, - .llseek = smb3_llseek, -+ .is_status_io_timeout = smb2_is_status_io_timeout, - }; - - struct smb_version_operations smb30_operations = { -@@ -5026,6 +5039,7 @@ struct smb_version_operations smb30_operations = { - .make_node = smb2_make_node, - .fiemap = smb3_fiemap, - .llseek = smb3_llseek, -+ .is_status_io_timeout = smb2_is_status_io_timeout, - }; - - struct smb_version_operations smb311_operations = { -@@ -5137,6 +5151,7 @@ struct smb_version_operations smb311_operations = { - .make_node = smb2_make_node, - .fiemap = smb3_fiemap, - .llseek = smb3_llseek, -+ .is_status_io_timeout = smb2_is_status_io_timeout, - }; - - struct smb_version_values smb20_values = { -diff --git a/fs/exec.c b/fs/exec.c -index 07910f5032e74..529c3bcefb650 100644 ---- a/fs/exec.c -+++ b/fs/exec.c -@@ -955,6 +955,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, - { - loff_t i_size, pos; - ssize_t bytes = 0; -+ void *allocated = NULL; - int ret; - - if (!S_ISREG(file_inode(file)->i_mode) || max_size < 0) -@@ -978,8 +979,8 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, - goto out; - } - -- if (id != READING_FIRMWARE_PREALLOC_BUFFER) -- *buf = vmalloc(i_size); -+ if (!*buf) -+ *buf = allocated = vmalloc(i_size); - if (!*buf) { - ret = -ENOMEM; - goto out; -@@ -1008,7 +1009,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, - - out_free: - if (ret < 0) { -- if (id != READING_FIRMWARE_PREALLOC_BUFFER) { -+ if (allocated) { - vfree(*buf); - *buf = NULL; - } -@@ -1131,11 +1132,24 @@ static int exec_mmap(struct mm_struct *mm) - } - - task_lock(tsk); -- active_mm = tsk->active_mm; - membarrier_exec_mmap(mm); -- tsk->mm = mm; -+ -+ local_irq_disable(); -+ active_mm = tsk->active_mm; - tsk->active_mm = mm; -+ tsk->mm = mm; -+ /* -+ * This prevents preemption while active_mm is being loaded and -+ * it and mm are being updated, which could cause problems for -+ * lazy tlb mm refcounting when these are updated by context -+ * switches. Not all architectures can handle irqs off over -+ * activate_mm yet. -+ */ -+ if (!IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM)) -+ local_irq_enable(); - activate_mm(active_mm, mm); -+ if (IS_ENABLED(CONFIG_ARCH_WANT_IRQS_OFF_ACTIVATE_MM)) -+ local_irq_enable(); - tsk->mm->vmacache_seqnum = 0; - vmacache_flush(tsk); - task_unlock(tsk); -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index 48c3df47748db..8e7e9715cde9c 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -494,6 +494,7 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group, - * submit the buffer_head for reading - */ - set_buffer_new(bh); -+ clear_buffer_verified(bh); - trace_ext4_read_block_bitmap_load(sb, block_group, ignore_locked); - bh->b_end_io = ext4_end_bitmap_read; - get_bh(bh); -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index a0481582187a3..9e506129ea367 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -501,6 +501,7 @@ __read_extent_tree_block(const char *function, unsigned int line, - - if (!bh_uptodate_or_lock(bh)) { - trace_ext4_ext_load_extent(inode, pblk, _RET_IP_); -+ clear_buffer_verified(bh); - err = bh_submit_read(bh); - if (err < 0) - goto errout; -@@ -1471,16 +1472,16 @@ static int ext4_ext_search_left(struct inode *inode, - } - - /* -- * search the closest allocated block to the right for *logical -- * and returns it at @logical + it's physical address at @phys -- * if *logical is the largest allocated block, the function -- * returns 0 at @phys -- * return value contains 0 (success) or error code -+ * Search the closest allocated block to the right for *logical -+ * and returns it at @logical + it's physical address at @phys. -+ * If not exists, return 0 and @phys is set to 0. We will return -+ * 1 which means we found an allocated block and ret_ex is valid. -+ * Or return a (< 0) error code. - */ - static int ext4_ext_search_right(struct inode *inode, - struct ext4_ext_path *path, - ext4_lblk_t *logical, ext4_fsblk_t *phys, -- struct ext4_extent **ret_ex) -+ struct ext4_extent *ret_ex) - { - struct buffer_head *bh = NULL; - struct ext4_extent_header *eh; -@@ -1574,10 +1575,11 @@ got_index: - found_extent: - *logical = le32_to_cpu(ex->ee_block); - *phys = ext4_ext_pblock(ex); -- *ret_ex = ex; -+ if (ret_ex) -+ *ret_ex = *ex; - if (bh) - put_bh(bh); -- return 0; -+ return 1; - } - - /* -@@ -2868,8 +2870,8 @@ again: - */ - lblk = ex_end + 1; - err = ext4_ext_search_right(inode, path, &lblk, &pblk, -- &ex); -- if (err) -+ NULL); -+ if (err < 0) - goto out; - if (pblk) { - partial.pclu = EXT4_B2C(sbi, pblk); -@@ -4037,7 +4039,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, int flags) - { - struct ext4_ext_path *path = NULL; -- struct ext4_extent newex, *ex, *ex2; -+ struct ext4_extent newex, *ex, ex2; - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); - ext4_fsblk_t newblock = 0, pblk; - int err = 0, depth, ret; -@@ -4173,15 +4175,14 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - if (err) - goto out; - ar.lright = map->m_lblk; -- ex2 = NULL; - err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); -- if (err) -+ if (err < 0) - goto out; - - /* Check if the extent after searching to the right implies a - * cluster we can use. */ -- if ((sbi->s_cluster_ratio > 1) && ex2 && -- get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) { -+ if ((sbi->s_cluster_ratio > 1) && err && -+ get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) { - ar.len = allocated = map->m_len; - newblock = map->m_pblk; - goto got_allocated_blocks; -@@ -4769,7 +4770,7 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode, - - int ext4_convert_unwritten_io_end_vec(handle_t *handle, ext4_io_end_t *io_end) - { -- int ret, err = 0; -+ int ret = 0, err = 0; - struct ext4_io_end_vec *io_end_vec; - - /* -diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c -index df25d38d65393..20cda952c6219 100644 ---- a/fs/ext4/ialloc.c -+++ b/fs/ext4/ialloc.c -@@ -188,6 +188,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) - /* - * submit the buffer_head for reading - */ -+ clear_buffer_verified(bh); - trace_ext4_load_inode_bitmap(sb, block_group); - bh->b_end_io = ext4_end_bitmap_read; - get_bh(bh); -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index bf596467c234c..16a8c29256cd9 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -884,6 +884,7 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode, - return bh; - if (!bh || ext4_buffer_uptodate(bh)) - return bh; -+ clear_buffer_verified(bh); - ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh); - wait_on_buffer(bh); - if (buffer_uptodate(bh)) -@@ -909,9 +910,11 @@ int ext4_bread_batch(struct inode *inode, ext4_lblk_t block, int bh_count, - - for (i = 0; i < bh_count; i++) - /* Note that NULL bhs[i] is valid because of holes. */ -- if (bhs[i] && !ext4_buffer_uptodate(bhs[i])) -+ if (bhs[i] && !ext4_buffer_uptodate(bhs[i])) { -+ clear_buffer_verified(bhs[i]); - ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, - &bhs[i]); -+ } - - if (!wait) - return 0; -@@ -2254,7 +2257,7 @@ static int mpage_process_page(struct mpage_da_data *mpd, struct page *page, - err = PTR_ERR(io_end_vec); - goto out; - } -- io_end_vec->offset = mpd->map.m_lblk << blkbits; -+ io_end_vec->offset = (loff_t)mpd->map.m_lblk << blkbits; - } - *map_bh = true; - goto out; -@@ -3601,6 +3604,13 @@ static int ext4_set_page_dirty(struct page *page) - return __set_page_dirty_buffers(page); - } - -+static int ext4_iomap_swap_activate(struct swap_info_struct *sis, -+ struct file *file, sector_t *span) -+{ -+ return iomap_swapfile_activate(sis, file, span, -+ &ext4_iomap_report_ops); -+} -+ - static const struct address_space_operations ext4_aops = { - .readpage = ext4_readpage, - .readahead = ext4_readahead, -@@ -3616,6 +3626,7 @@ static const struct address_space_operations ext4_aops = { - .migratepage = buffer_migrate_page, - .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, -+ .swap_activate = ext4_iomap_swap_activate, - }; - - static const struct address_space_operations ext4_journalled_aops = { -@@ -3632,6 +3643,7 @@ static const struct address_space_operations ext4_journalled_aops = { - .direct_IO = noop_direct_IO, - .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, -+ .swap_activate = ext4_iomap_swap_activate, - }; - - static const struct address_space_operations ext4_da_aops = { -@@ -3649,6 +3661,7 @@ static const struct address_space_operations ext4_da_aops = { - .migratepage = buffer_migrate_page, - .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, -+ .swap_activate = ext4_iomap_swap_activate, - }; - - static const struct address_space_operations ext4_dax_aops = { -@@ -3657,6 +3670,7 @@ static const struct address_space_operations ext4_dax_aops = { - .set_page_dirty = noop_set_page_dirty, - .bmap = ext4_bmap, - .invalidatepage = noop_invalidatepage, -+ .swap_activate = ext4_iomap_swap_activate, - }; - - void ext4_set_aops(struct inode *inode) -@@ -4971,6 +4985,12 @@ static int ext4_do_update_inode(handle_t *handle, - if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) - memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); - -+ err = ext4_inode_blocks_set(handle, raw_inode, ei); -+ if (err) { -+ spin_unlock(&ei->i_raw_lock); -+ goto out_brelse; -+ } -+ - raw_inode->i_mode = cpu_to_le16(inode->i_mode); - i_uid = i_uid_read(inode); - i_gid = i_gid_read(inode); -@@ -5004,11 +5024,6 @@ static int ext4_do_update_inode(handle_t *handle, - EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode); - EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode); - -- err = ext4_inode_blocks_set(handle, raw_inode, ei); -- if (err) { -- spin_unlock(&ei->i_raw_lock); -- goto out_brelse; -- } - raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); - raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF); - if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) -diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c -index a50b51270ea9a..71bf600e5b42c 100644 ---- a/fs/ext4/resize.c -+++ b/fs/ext4/resize.c -@@ -843,8 +843,10 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, - - BUFFER_TRACE(dind, "get_write_access"); - err = ext4_journal_get_write_access(handle, dind); -- if (unlikely(err)) -+ if (unlikely(err)) { - ext4_std_error(sb, err); -+ goto errout; -+ } - - /* ext4_reserve_inode_write() gets a reference on the iloc */ - err = ext4_reserve_inode_write(handle, inode, &iloc); -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index ea425b49b3456..20378050df09c 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -156,6 +156,7 @@ ext4_sb_bread(struct super_block *sb, sector_t block, int op_flags) - return ERR_PTR(-ENOMEM); - if (ext4_buffer_uptodate(bh)) - return bh; -+ clear_buffer_verified(bh); - ll_rw_block(REQ_OP_READ, REQ_META | op_flags, 1, &bh); - wait_on_buffer(bh); - if (buffer_uptodate(bh)) -@@ -4814,9 +4815,8 @@ no_journal: - * used to detect the metadata async write error. - */ - spin_lock_init(&sbi->s_bdev_wb_lock); -- if (!sb_rdonly(sb)) -- errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, -- &sbi->s_bdev_wb_err); -+ errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, -+ &sbi->s_bdev_wb_err); - sb->s_bdev->bd_super = sb; - EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS; - ext4_orphan_cleanup(sb, es); -@@ -4872,6 +4872,7 @@ cantfind_ext4: - - failed_mount8: - ext4_unregister_sysfs(sb); -+ kobject_put(&sbi->s_kobj); - failed_mount7: - ext4_unregister_li_request(sb); - failed_mount6: -@@ -5707,14 +5708,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) - goto restore_opts; - } - -- /* -- * Update the original bdev mapping's wb_err value -- * which could be used to detect the metadata async -- * write error. -- */ -- errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, -- &sbi->s_bdev_wb_err); -- - /* - * Mounting a RDONLY partition read-write, so reread - * and store the current valid flag. (It may have -@@ -6042,6 +6035,11 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, - /* Quotafile not on the same filesystem? */ - if (path->dentry->d_sb != sb) - return -EXDEV; -+ -+ /* Quota already enabled for this file? */ -+ if (IS_NOQUOTA(d_inode(path->dentry))) -+ return -EBUSY; -+ - /* Journaling quota? */ - if (EXT4_SB(sb)->s_qf_names[type]) { - /* Quotafile not in fs root? */ -diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c -index ff807e14c8911..4a97fe4ddf789 100644 ---- a/fs/f2fs/checkpoint.c -+++ b/fs/f2fs/checkpoint.c -@@ -107,7 +107,7 @@ struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index) - return __get_meta_page(sbi, index, true); - } - --struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index) -+struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index) - { - struct page *page; - int count = 0; -@@ -243,6 +243,8 @@ int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages, - blkno * NAT_ENTRY_PER_BLOCK); - break; - case META_SIT: -+ if (unlikely(blkno >= TOTAL_SEGS(sbi))) -+ goto out; - /* get sit block addr */ - fio.new_blkaddr = current_sit_addr(sbi, - blkno * SIT_ENTRY_PER_BLOCK); -@@ -1047,8 +1049,12 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type) - get_pages(sbi, is_dir ? - F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA)); - retry: -- if (unlikely(f2fs_cp_error(sbi))) -+ if (unlikely(f2fs_cp_error(sbi))) { -+ trace_f2fs_sync_dirty_inodes_exit(sbi->sb, is_dir, -+ get_pages(sbi, is_dir ? -+ F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA)); - return -EIO; -+ } - - spin_lock(&sbi->inode_lock[type]); - -diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c -index 1dfb126a0cb20..1cd4b3f9c9f8c 100644 ---- a/fs/f2fs/compress.c -+++ b/fs/f2fs/compress.c -@@ -382,16 +382,17 @@ static int zstd_init_decompress_ctx(struct decompress_io_ctx *dic) - ZSTD_DStream *stream; - void *workspace; - unsigned int workspace_size; -+ unsigned int max_window_size = -+ MAX_COMPRESS_WINDOW_SIZE(dic->log_cluster_size); - -- workspace_size = ZSTD_DStreamWorkspaceBound(MAX_COMPRESS_WINDOW_SIZE); -+ workspace_size = ZSTD_DStreamWorkspaceBound(max_window_size); - - workspace = f2fs_kvmalloc(F2FS_I_SB(dic->inode), - workspace_size, GFP_NOFS); - if (!workspace) - return -ENOMEM; - -- stream = ZSTD_initDStream(MAX_COMPRESS_WINDOW_SIZE, -- workspace, workspace_size); -+ stream = ZSTD_initDStream(max_window_size, workspace, workspace_size); - if (!stream) { - printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_initDStream failed\n", - KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id, -diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c -index 069f498af1e38..ceb4431b56690 100644 ---- a/fs/f2fs/dir.c -+++ b/fs/f2fs/dir.c -@@ -357,16 +357,15 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, - unsigned int max_depth; - unsigned int level; - -+ *res_page = NULL; -+ - if (f2fs_has_inline_dentry(dir)) { -- *res_page = NULL; - de = f2fs_find_in_inline_dir(dir, fname, res_page); - goto out; - } - -- if (npages == 0) { -- *res_page = NULL; -+ if (npages == 0) - goto out; -- } - - max_depth = F2FS_I(dir)->i_current_depth; - if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) { -@@ -377,7 +376,6 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, - } - - for (level = 0; level < max_depth; level++) { -- *res_page = NULL; - de = find_in_level(dir, level, fname, res_page); - if (de || IS_ERR(*res_page)) - break; -diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h -index d9e52a7f3702f..d44c6c36de678 100644 ---- a/fs/f2fs/f2fs.h -+++ b/fs/f2fs/f2fs.h -@@ -1394,7 +1394,7 @@ struct decompress_io_ctx { - #define NULL_CLUSTER ((unsigned int)(~0)) - #define MIN_COMPRESS_LOG_SIZE 2 - #define MAX_COMPRESS_LOG_SIZE 8 --#define MAX_COMPRESS_WINDOW_SIZE ((PAGE_SIZE) << MAX_COMPRESS_LOG_SIZE) -+#define MAX_COMPRESS_WINDOW_SIZE(log_size) ((PAGE_SIZE) << (log_size)) - - struct f2fs_sb_info { - struct super_block *sb; /* pointer to VFS super block */ -@@ -3385,7 +3385,7 @@ enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, - void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io); - struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); - struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); --struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index); -+struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index); - struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index); - bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, - block_t blkaddr, int type); -diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c -index 8a422400e824d..4ec10256dc67f 100644 ---- a/fs/f2fs/file.c -+++ b/fs/f2fs/file.c -@@ -1836,6 +1836,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) - if (iflags & F2FS_COMPR_FL) { - if (!f2fs_may_compress(inode)) - return -EINVAL; -+ if (S_ISREG(inode->i_mode) && inode->i_size) -+ return -EINVAL; - - set_compress_context(inode); - } -diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c -index 5195e083fc1e6..12c7fa1631935 100644 ---- a/fs/f2fs/inode.c -+++ b/fs/f2fs/inode.c -@@ -299,6 +299,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) - F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, - i_log_cluster_size)) { - if (ri->i_compress_algorithm >= COMPRESS_MAX) { -+ set_sbi_flag(sbi, SBI_NEED_FSCK); - f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported " - "compress algorithm: %u, run fsck to fix", - __func__, inode->i_ino, -@@ -307,6 +308,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) - } - if (le64_to_cpu(ri->i_compr_blocks) > - SECTOR_TO_BLOCK(inode->i_blocks)) { -+ set_sbi_flag(sbi, SBI_NEED_FSCK); - f2fs_warn(sbi, "%s: inode (ino=%lx) has inconsistent " - "i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix", - __func__, inode->i_ino, -@@ -316,6 +318,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) - } - if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE || - ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) { -+ set_sbi_flag(sbi, SBI_NEED_FSCK); - f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported " - "log cluster size: %u, run fsck to fix", - __func__, inode->i_ino, -diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c -index cb1b5b61a1dab..cc4700f6240db 100644 ---- a/fs/f2fs/node.c -+++ b/fs/f2fs/node.c -@@ -109,7 +109,7 @@ static void clear_node_page_dirty(struct page *page) - - static struct page *get_current_nat_page(struct f2fs_sb_info *sbi, nid_t nid) - { -- return f2fs_get_meta_page_nofail(sbi, current_nat_addr(sbi, nid)); -+ return f2fs_get_meta_page(sbi, current_nat_addr(sbi, nid)); - } - - static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid) -diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c -index e247a5ef3713f..2628406f43f64 100644 ---- a/fs/f2fs/segment.c -+++ b/fs/f2fs/segment.c -@@ -2344,7 +2344,9 @@ int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra) - */ - struct page *f2fs_get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno) - { -- return f2fs_get_meta_page_nofail(sbi, GET_SUM_BLOCK(sbi, segno)); -+ if (unlikely(f2fs_cp_error(sbi))) -+ return ERR_PTR(-EIO); -+ return f2fs_get_meta_page_retry(sbi, GET_SUM_BLOCK(sbi, segno)); - } - - void f2fs_update_meta_page(struct f2fs_sb_info *sbi, -@@ -2616,7 +2618,11 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type) - __next_free_blkoff(sbi, curseg, 0); - - sum_page = f2fs_get_sum_page(sbi, new_segno); -- f2fs_bug_on(sbi, IS_ERR(sum_page)); -+ if (IS_ERR(sum_page)) { -+ /* GC won't be able to use stale summary pages by cp_error */ -+ memset(curseg->sum_blk, 0, SUM_ENTRY_SIZE); -+ return; -+ } - sum_node = (struct f2fs_summary_block *)page_address(sum_page); - memcpy(curseg->sum_blk, sum_node, SUM_ENTRY_SIZE); - f2fs_put_page(sum_page, 1); -@@ -3781,7 +3787,7 @@ int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type, - static struct page *get_current_sit_page(struct f2fs_sb_info *sbi, - unsigned int segno) - { -- return f2fs_get_meta_page_nofail(sbi, current_sit_addr(sbi, segno)); -+ return f2fs_get_meta_page(sbi, current_sit_addr(sbi, segno)); - } - - static struct page *get_next_sit_page(struct f2fs_sb_info *sbi, -diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c -index dfa072fa80815..be5050292caa5 100644 ---- a/fs/f2fs/super.c -+++ b/fs/f2fs/super.c -@@ -2832,6 +2832,12 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, - segment_count, dev_seg_count); - return -EFSCORRUPTED; - } -+ } else { -+ if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_BLKZONED) && -+ !bdev_is_zoned(sbi->sb->s_bdev)) { -+ f2fs_info(sbi, "Zoned block device path is missing"); -+ return -EFSCORRUPTED; -+ } - } - - if (secs_per_zone > total_sections || !secs_per_zone) { -diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c -index f13b136654cae..1192fcd8ee41c 100644 ---- a/fs/gfs2/glock.c -+++ b/fs/gfs2/glock.c -@@ -270,7 +270,12 @@ static void __gfs2_glock_put(struct gfs2_glock *gl) - gfs2_glock_remove_from_lru(gl); - spin_unlock(&gl->gl_lockref.lock); - GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders)); -- GLOCK_BUG_ON(gl, mapping && mapping->nrpages && !gfs2_withdrawn(sdp)); -+ if (mapping) { -+ truncate_inode_pages_final(mapping); -+ if (!gfs2_withdrawn(sdp)) -+ GLOCK_BUG_ON(gl, mapping->nrpages || -+ mapping->nrexceptional); -+ } - trace_gfs2_glock_put(gl); - sdp->sd_lockstruct.ls_ops->lm_put_lock(gl); - } -@@ -1049,7 +1054,8 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, - gl->gl_object = NULL; - gl->gl_hold_time = GL_GLOCK_DFT_HOLD; - INIT_DELAYED_WORK(&gl->gl_work, glock_work_func); -- INIT_DELAYED_WORK(&gl->gl_delete, delete_work_func); -+ if (gl->gl_name.ln_type == LM_TYPE_IOPEN) -+ INIT_DELAYED_WORK(&gl->gl_delete, delete_work_func); - - mapping = gfs2_glock2aspace(gl); - if (mapping) { -@@ -1901,9 +1907,11 @@ bool gfs2_delete_work_queued(const struct gfs2_glock *gl) - - static void flush_delete_work(struct gfs2_glock *gl) - { -- if (cancel_delayed_work(&gl->gl_delete)) { -- queue_delayed_work(gfs2_delete_workqueue, -- &gl->gl_delete, 0); -+ if (gl->gl_name.ln_type == LM_TYPE_IOPEN) { -+ if (cancel_delayed_work(&gl->gl_delete)) { -+ queue_delayed_work(gfs2_delete_workqueue, -+ &gl->gl_delete, 0); -+ } - } - gfs2_glock_queue_work(gl, 0); - } -diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c -index de1d5f1d9ff85..c2c90747d79b5 100644 ---- a/fs/gfs2/glops.c -+++ b/fs/gfs2/glops.c -@@ -227,6 +227,15 @@ static void rgrp_go_inval(struct gfs2_glock *gl, int flags) - rgd->rd_flags &= ~GFS2_RDF_UPTODATE; - } - -+static void gfs2_rgrp_go_dump(struct seq_file *seq, struct gfs2_glock *gl, -+ const char *fs_id_buf) -+{ -+ struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl); -+ -+ if (rgd) -+ gfs2_rgrp_dump(seq, rgd, fs_id_buf); -+} -+ - static struct gfs2_inode *gfs2_glock2inode(struct gfs2_glock *gl) - { - struct gfs2_inode *ip; -@@ -712,7 +721,7 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = { - .go_sync = rgrp_go_sync, - .go_inval = rgrp_go_inval, - .go_lock = gfs2_rgrp_go_lock, -- .go_dump = gfs2_rgrp_dump, -+ .go_dump = gfs2_rgrp_go_dump, - .go_type = LM_TYPE_RGRP, - .go_flags = GLOF_LVB, - }; -diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h -index ca2ec02436ec7..387e99d6eda9e 100644 ---- a/fs/gfs2/incore.h -+++ b/fs/gfs2/incore.h -@@ -705,6 +705,7 @@ struct gfs2_sbd { - struct super_block *sd_vfs; - struct gfs2_pcpu_lkstats __percpu *sd_lkstats; - struct kobject sd_kobj; -+ struct completion sd_kobj_unregister; - unsigned long sd_flags; /* SDF_... */ - struct gfs2_sb_host sd_sb; - -diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c -index 3763c9ff1406b..93032feb51599 100644 ---- a/fs/gfs2/log.c -+++ b/fs/gfs2/log.c -@@ -954,10 +954,8 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) - goto out; - - /* Log might have been flushed while we waited for the flush lock */ -- if (gl && !test_bit(GLF_LFLUSH, &gl->gl_flags)) { -- up_write(&sdp->sd_log_flush_lock); -- return; -- } -+ if (gl && !test_bit(GLF_LFLUSH, &gl->gl_flags)) -+ goto out; - trace_gfs2_log_flush(sdp, 1, flags); - - if (flags & GFS2_LOG_HEAD_FLUSH_SHUTDOWN) -@@ -971,25 +969,25 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) - if (unlikely (state == SFS_FROZEN)) - if (gfs2_assert_withdraw_delayed(sdp, - !tr->tr_num_buf_new && !tr->tr_num_databuf_new)) -- goto out; -+ goto out_withdraw; - } - - if (unlikely(state == SFS_FROZEN)) - if (gfs2_assert_withdraw_delayed(sdp, !sdp->sd_log_num_revoke)) -- goto out; -+ goto out_withdraw; - if (gfs2_assert_withdraw_delayed(sdp, - sdp->sd_log_num_revoke == sdp->sd_log_committed_revoke)) -- goto out; -+ goto out_withdraw; - - gfs2_ordered_write(sdp); - if (gfs2_withdrawn(sdp)) -- goto out; -+ goto out_withdraw; - lops_before_commit(sdp, tr); - if (gfs2_withdrawn(sdp)) -- goto out; -+ goto out_withdraw; - gfs2_log_submit_bio(&sdp->sd_log_bio, REQ_OP_WRITE); - if (gfs2_withdrawn(sdp)) -- goto out; -+ goto out_withdraw; - - if (sdp->sd_log_head != sdp->sd_log_flush_head) { - log_flush_wait(sdp); -@@ -1000,7 +998,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) - log_write_header(sdp, flags); - } - if (gfs2_withdrawn(sdp)) -- goto out; -+ goto out_withdraw; - lops_after_commit(sdp, tr); - - gfs2_log_lock(sdp); -@@ -1020,7 +1018,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) - if (!sdp->sd_log_idle) { - empty_ail1_list(sdp); - if (gfs2_withdrawn(sdp)) -- goto out; -+ goto out_withdraw; - atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */ - trace_gfs2_log_blocks(sdp, -1); - log_write_header(sdp, flags); -@@ -1033,27 +1031,30 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) - atomic_set(&sdp->sd_freeze_state, SFS_FROZEN); - } - --out: -- if (gfs2_withdrawn(sdp)) { -- trans_drain(tr); -- /** -- * If the tr_list is empty, we're withdrawing during a log -- * flush that targets a transaction, but the transaction was -- * never queued onto any of the ail lists. Here we add it to -- * ail1 just so that ail_drain() will find and free it. -- */ -- spin_lock(&sdp->sd_ail_lock); -- if (tr && list_empty(&tr->tr_list)) -- list_add(&tr->tr_list, &sdp->sd_ail1_list); -- spin_unlock(&sdp->sd_ail_lock); -- ail_drain(sdp); /* frees all transactions */ -- tr = NULL; -- } -- -+out_end: - trace_gfs2_log_flush(sdp, 0, flags); -+out: - up_write(&sdp->sd_log_flush_lock); -- - gfs2_trans_free(sdp, tr); -+ if (gfs2_withdrawing(sdp)) -+ gfs2_withdraw(sdp); -+ return; -+ -+out_withdraw: -+ trans_drain(tr); -+ /** -+ * If the tr_list is empty, we're withdrawing during a log -+ * flush that targets a transaction, but the transaction was -+ * never queued onto any of the ail lists. Here we add it to -+ * ail1 just so that ail_drain() will find and free it. -+ */ -+ spin_lock(&sdp->sd_ail_lock); -+ if (tr && list_empty(&tr->tr_list)) -+ list_add(&tr->tr_list, &sdp->sd_ail1_list); -+ spin_unlock(&sdp->sd_ail_lock); -+ ail_drain(sdp); /* frees all transactions */ -+ tr = NULL; -+ goto out_end; - } - - /** -diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c -index 6d18d2c91add2..03c33fc03c055 100644 ---- a/fs/gfs2/ops_fstype.c -+++ b/fs/gfs2/ops_fstype.c -@@ -169,15 +169,19 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent) - return -EINVAL; - } - -- /* If format numbers match exactly, we're done. */ -- -- if (sb->sb_fs_format == GFS2_FORMAT_FS && -- sb->sb_multihost_format == GFS2_FORMAT_MULTI) -- return 0; -+ if (sb->sb_fs_format != GFS2_FORMAT_FS || -+ sb->sb_multihost_format != GFS2_FORMAT_MULTI) { -+ fs_warn(sdp, "Unknown on-disk format, unable to mount\n"); -+ return -EINVAL; -+ } - -- fs_warn(sdp, "Unknown on-disk format, unable to mount\n"); -+ if (sb->sb_bsize < 512 || sb->sb_bsize > PAGE_SIZE || -+ (sb->sb_bsize & (sb->sb_bsize - 1))) { -+ pr_warn("Invalid superblock size\n"); -+ return -EINVAL; -+ } - -- return -EINVAL; -+ return 0; - } - - static void end_bio_io_page(struct bio *bio) -@@ -1062,26 +1066,14 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc) - } - - error = init_names(sdp, silent); -- if (error) { -- /* In this case, we haven't initialized sysfs, so we have to -- manually free the sdp. */ -- free_sbd(sdp); -- sb->s_fs_info = NULL; -- return error; -- } -+ if (error) -+ goto fail_free; - - snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s", sdp->sd_table_name); - - error = gfs2_sys_fs_add(sdp); -- /* -- * If we hit an error here, gfs2_sys_fs_add will have called function -- * kobject_put which causes the sysfs usage count to go to zero, which -- * causes sysfs to call function gfs2_sbd_release, which frees sdp. -- * Subsequent error paths here will call gfs2_sys_fs_del, which also -- * kobject_put to free sdp. -- */ - if (error) -- return error; -+ goto fail_free; - - gfs2_create_debugfs_file(sdp); - -@@ -1179,9 +1171,9 @@ fail_lm: - gfs2_lm_unmount(sdp); - fail_debug: - gfs2_delete_debugfs_file(sdp); -- /* gfs2_sys_fs_del must be the last thing we do, since it causes -- * sysfs to call function gfs2_sbd_release, which frees sdp. */ - gfs2_sys_fs_del(sdp); -+fail_free: -+ free_sbd(sdp); - sb->s_fs_info = NULL; - return error; - } -diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c -index 074f228ea8390..1bba5a9d45fa3 100644 ---- a/fs/gfs2/rgrp.c -+++ b/fs/gfs2/rgrp.c -@@ -2209,20 +2209,17 @@ static void rgblk_free(struct gfs2_sbd *sdp, struct gfs2_rgrpd *rgd, - /** - * gfs2_rgrp_dump - print out an rgrp - * @seq: The iterator -- * @gl: The glock in question -+ * @rgd: The rgrp in question - * @fs_id_buf: pointer to file system id (if requested) - * - */ - --void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl, -+void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_rgrpd *rgd, - const char *fs_id_buf) - { -- struct gfs2_rgrpd *rgd = gl->gl_object; - struct gfs2_blkreserv *trs; - const struct rb_node *n; - -- if (rgd == NULL) -- return; - gfs2_print_dbg(seq, "%s R: n:%llu f:%02x b:%u/%u i:%u r:%u e:%u\n", - fs_id_buf, - (unsigned long long)rgd->rd_addr, rgd->rd_flags, -@@ -2253,7 +2250,7 @@ static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd) - (unsigned long long)rgd->rd_addr); - fs_warn(sdp, "umount on all nodes and run fsck.gfs2 to fix the error\n"); - sprintf(fs_id_buf, "fsid=%s: ", sdp->sd_fsname); -- gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf); -+ gfs2_rgrp_dump(NULL, rgd, fs_id_buf); - rgd->rd_flags |= GFS2_RDF_ERROR; - } - -diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h -index a1d7e14fc55b9..9a587ada51eda 100644 ---- a/fs/gfs2/rgrp.h -+++ b/fs/gfs2/rgrp.h -@@ -67,7 +67,7 @@ extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist, - extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist); - extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); - extern u64 gfs2_ri_total(struct gfs2_sbd *sdp); --extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl, -+extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_rgrpd *rgd, - const char *fs_id_buf); - extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset, - struct buffer_head *bh, -diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c -index 9f4d9e7be8397..32ae1a7cdaed8 100644 ---- a/fs/gfs2/super.c -+++ b/fs/gfs2/super.c -@@ -702,6 +702,8 @@ restart: - if (error) - gfs2_io_error(sdp); - } -+ WARN_ON(gfs2_withdrawing(sdp)); -+ - /* At this point, we're through modifying the disk */ - - /* Release stuff */ -@@ -736,6 +738,7 @@ restart: - - /* At this point, we're through participating in the lockspace */ - gfs2_sys_fs_del(sdp); -+ free_sbd(sdp); - } - - /** -diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c -index d28c41bd69b05..c3e72dba7418a 100644 ---- a/fs/gfs2/sys.c -+++ b/fs/gfs2/sys.c -@@ -303,7 +303,7 @@ static void gfs2_sbd_release(struct kobject *kobj) - { - struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); - -- free_sbd(sdp); -+ complete(&sdp->sd_kobj_unregister); - } - - static struct kobj_type gfs2_ktype = { -@@ -655,6 +655,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) - sprintf(ro, "RDONLY=%d", sb_rdonly(sb)); - sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0); - -+ init_completion(&sdp->sd_kobj_unregister); - sdp->sd_kobj.kset = gfs2_kset; - error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, - "%s", sdp->sd_table_name); -@@ -685,6 +686,7 @@ fail_tune: - fail_reg: - fs_err(sdp, "error %d adding sysfs files\n", error); - kobject_put(&sdp->sd_kobj); -+ wait_for_completion(&sdp->sd_kobj_unregister); - sb->s_fs_info = NULL; - return error; - } -@@ -695,6 +697,7 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp) - sysfs_remove_group(&sdp->sd_kobj, &tune_group); - sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); - kobject_put(&sdp->sd_kobj); -+ wait_for_completion(&sdp->sd_kobj_unregister); - } - - static int gfs2_uevent(struct kset *kset, struct kobject *kobj, -diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c -index 1cd0328cae20a..0fba3bf641890 100644 ---- a/fs/gfs2/util.c -+++ b/fs/gfs2/util.c -@@ -419,7 +419,7 @@ void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, - char fs_id_buf[sizeof(sdp->sd_fsname) + 7]; - - sprintf(fs_id_buf, "fsid=%s: ", sdp->sd_fsname); -- gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf); -+ gfs2_rgrp_dump(NULL, rgd, fs_id_buf); - gfs2_lm(sdp, - "fatal: filesystem consistency error\n" - " RG = %llu\n" -diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h -index 6d9157efe16c3..d7562981b3a09 100644 ---- a/fs/gfs2/util.h -+++ b/fs/gfs2/util.h -@@ -205,6 +205,16 @@ static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp) - test_bit(SDF_WITHDRAWING, &sdp->sd_flags); - } - -+/** -+ * gfs2_withdrawing - check if a withdraw is pending -+ * @sdp: the superblock -+ */ -+static inline bool gfs2_withdrawing(struct gfs2_sbd *sdp) -+{ -+ return test_bit(SDF_WITHDRAWING, &sdp->sd_flags) && -+ !test_bit(SDF_WITHDRAWN, &sdp->sd_flags); -+} -+ - #define gfs2_tune_get(sdp, field) \ - gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field) - -diff --git a/fs/io-wq.c b/fs/io-wq.c -index 19db17e99cf96..5ad65b3059367 100644 ---- a/fs/io-wq.c -+++ b/fs/io-wq.c -@@ -654,6 +654,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index) - kfree(worker); - return false; - } -+ kthread_bind_mask(worker->task, cpumask_of_node(wqe->node)); - - raw_spin_lock_irq(&wqe->lock); - hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->free_list); -diff --git a/fs/io_uring.c b/fs/io_uring.c -index 59ab8c5c2aaaa..64f214a3dc9dd 100644 ---- a/fs/io_uring.c -+++ b/fs/io_uring.c -@@ -1650,6 +1650,7 @@ static bool io_link_cancel_timeout(struct io_kiocb *req) - - ret = hrtimer_try_to_cancel(&req->io->timeout.timer); - if (ret != -1) { -+ req->flags |= REQ_F_COMP_LOCKED; - io_cqring_fill_event(req, -ECANCELED); - io_commit_cqring(ctx); - req->flags &= ~REQ_F_LINK_HEAD; -@@ -1672,7 +1673,6 @@ static bool __io_kill_linked_timeout(struct io_kiocb *req) - return false; - - list_del_init(&link->link_list); -- link->flags |= REQ_F_COMP_LOCKED; - wake_ev = io_link_cancel_timeout(link); - req->flags &= ~REQ_F_LINK_TIMEOUT; - return wake_ev; -@@ -4786,8 +4786,10 @@ static int io_poll_double_wake(struct wait_queue_entry *wait, unsigned mode, - /* make sure double remove sees this as being gone */ - wait->private = NULL; - spin_unlock(&poll->head->lock); -- if (!done) -- __io_async_wake(req, poll, mask, io_poll_task_func); -+ if (!done) { -+ /* use wait func handler, so it matches the rq type */ -+ poll->wait.func(&poll->wait, mode, sync, key); -+ } - } - refcount_dec(&req->refs); - return 1; -diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c -index faa97d748474d..fb134c7a12c89 100644 ---- a/fs/jbd2/recovery.c -+++ b/fs/jbd2/recovery.c -@@ -428,6 +428,8 @@ static int do_one_pass(journal_t *journal, - __u32 crc32_sum = ~0; /* Transactional Checksums */ - int descr_csum_size = 0; - int block_error = 0; -+ bool need_check_commit_time = false; -+ __u64 last_trans_commit_time = 0, commit_time; - - /* - * First thing is to establish what we expect to find in the log -@@ -520,12 +522,21 @@ static int do_one_pass(journal_t *journal, - if (descr_csum_size > 0 && - !jbd2_descriptor_block_csum_verify(journal, - bh->b_data)) { -- printk(KERN_ERR "JBD2: Invalid checksum " -- "recovering block %lu in log\n", -- next_log_block); -- err = -EFSBADCRC; -- brelse(bh); -- goto failed; -+ /* -+ * PASS_SCAN can see stale blocks due to lazy -+ * journal init. Don't error out on those yet. -+ */ -+ if (pass != PASS_SCAN) { -+ pr_err("JBD2: Invalid checksum recovering block %lu in log\n", -+ next_log_block); -+ err = -EFSBADCRC; -+ brelse(bh); -+ goto failed; -+ } -+ need_check_commit_time = true; -+ jbd_debug(1, -+ "invalid descriptor block found in %lu\n", -+ next_log_block); - } - - /* If it is a valid descriptor block, replay it -@@ -535,6 +546,7 @@ static int do_one_pass(journal_t *journal, - if (pass != PASS_REPLAY) { - if (pass == PASS_SCAN && - jbd2_has_feature_checksum(journal) && -+ !need_check_commit_time && - !info->end_transaction) { - if (calc_chksums(journal, bh, - &next_log_block, -@@ -683,11 +695,41 @@ static int do_one_pass(journal_t *journal, - * mentioned conditions. Hence assume - * "Interrupted Commit".) - */ -+ commit_time = be64_to_cpu( -+ ((struct commit_header *)bh->b_data)->h_commit_sec); -+ /* -+ * If need_check_commit_time is set, it means we are in -+ * PASS_SCAN and csum verify failed before. If -+ * commit_time is increasing, it's the same journal, -+ * otherwise it is stale journal block, just end this -+ * recovery. -+ */ -+ if (need_check_commit_time) { -+ if (commit_time >= last_trans_commit_time) { -+ pr_err("JBD2: Invalid checksum found in transaction %u\n", -+ next_commit_ID); -+ err = -EFSBADCRC; -+ brelse(bh); -+ goto failed; -+ } -+ ignore_crc_mismatch: -+ /* -+ * It likely does not belong to same journal, -+ * just end this recovery with success. -+ */ -+ jbd_debug(1, "JBD2: Invalid checksum ignored in transaction %u, likely stale data\n", -+ next_commit_ID); -+ err = 0; -+ brelse(bh); -+ goto done; -+ } - -- /* Found an expected commit block: if checksums -- * are present verify them in PASS_SCAN; else not -+ /* -+ * Found an expected commit block: if checksums -+ * are present, verify them in PASS_SCAN; else not - * much to do other than move on to the next sequence -- * number. */ -+ * number. -+ */ - if (pass == PASS_SCAN && - jbd2_has_feature_checksum(journal)) { - struct commit_header *cbh = -@@ -719,6 +761,8 @@ static int do_one_pass(journal_t *journal, - !jbd2_commit_block_csum_verify(journal, - bh->b_data)) { - chksum_error: -+ if (commit_time < last_trans_commit_time) -+ goto ignore_crc_mismatch; - info->end_transaction = next_commit_ID; - - if (!jbd2_has_feature_async_commit(journal)) { -@@ -728,11 +772,24 @@ static int do_one_pass(journal_t *journal, - break; - } - } -+ if (pass == PASS_SCAN) -+ last_trans_commit_time = commit_time; - brelse(bh); - next_commit_ID++; - continue; - - case JBD2_REVOKE_BLOCK: -+ /* -+ * Check revoke block crc in pass_scan, if csum verify -+ * failed, check commit block time later. -+ */ -+ if (pass == PASS_SCAN && -+ !jbd2_descriptor_block_csum_verify(journal, -+ bh->b_data)) { -+ jbd_debug(1, "JBD2: invalid revoke block found in %lu\n", -+ next_log_block); -+ need_check_commit_time = true; -+ } - /* If we aren't in the REVOKE pass, then we can - * just skip over this block. */ - if (pass != PASS_REVOKE) { -@@ -800,9 +857,6 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, - offset = sizeof(jbd2_journal_revoke_header_t); - rcount = be32_to_cpu(header->r_count); - -- if (!jbd2_descriptor_block_csum_verify(journal, header)) -- return -EFSBADCRC; -- - if (jbd2_journal_has_csum_v2or3(journal)) - csum_size = sizeof(struct jbd2_journal_block_tail); - if (rcount > journal->j_blocksize - csum_size) -diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c -index 6b063227e34e9..2bcbe38afe2e7 100644 ---- a/fs/nfs/namespace.c -+++ b/fs/nfs/namespace.c -@@ -32,9 +32,9 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; - /* - * nfs_path - reconstruct the path given an arbitrary dentry - * @base - used to return pointer to the end of devname part of path -- * @dentry - pointer to dentry -+ * @dentry_in - pointer to dentry - * @buffer - result buffer -- * @buflen - length of buffer -+ * @buflen_in - length of buffer - * @flags - options (see below) - * - * Helper function for constructing the server pathname -@@ -49,15 +49,19 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ; - * the original device (export) name - * (if unset, the original name is returned verbatim) - */ --char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen, -- unsigned flags) -+char *nfs_path(char **p, struct dentry *dentry_in, char *buffer, -+ ssize_t buflen_in, unsigned flags) - { - char *end; - int namelen; - unsigned seq; - const char *base; -+ struct dentry *dentry; -+ ssize_t buflen; - - rename_retry: -+ buflen = buflen_in; -+ dentry = dentry_in; - end = buffer+buflen; - *--end = '\0'; - buflen--; -diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h -index 0c9505dc852cd..065cb04222a1b 100644 ---- a/fs/nfs/nfs4_fs.h -+++ b/fs/nfs/nfs4_fs.h -@@ -599,6 +599,14 @@ static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stat - return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0; - } - -+static inline bool nfs4_stateid_is_next(const nfs4_stateid *s1, const nfs4_stateid *s2) -+{ -+ u32 seq1 = be32_to_cpu(s1->seqid); -+ u32 seq2 = be32_to_cpu(s2->seqid); -+ -+ return seq2 == seq1 + 1U || (seq2 == 1U && seq1 == 0xffffffffU); -+} -+ - static inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src) - { - return nfs4_stateid_match_other(dst, src) && -diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c -index 984938024011b..9d354de613dae 100644 ---- a/fs/nfs/nfs4file.c -+++ b/fs/nfs/nfs4file.c -@@ -146,7 +146,8 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, - /* Only offload copy if superblock is the same */ - if (file_in->f_op != &nfs4_file_operations) - return -EXDEV; -- if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY)) -+ if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY) || -+ !nfs_server_capable(file_inode(file_in), NFS_CAP_COPY)) - return -EOPNOTSUPP; - if (file_inode(file_in) == file_inode(file_out)) - return -EOPNOTSUPP; -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c -index 6e95c85fe395a..3375f0a096390 100644 ---- a/fs/nfs/nfs4proc.c -+++ b/fs/nfs/nfs4proc.c -@@ -1547,19 +1547,6 @@ static void nfs_state_log_update_open_stateid(struct nfs4_state *state) - wake_up_all(&state->waitq); - } - --static void nfs_state_log_out_of_order_open_stateid(struct nfs4_state *state, -- const nfs4_stateid *stateid) --{ -- u32 state_seqid = be32_to_cpu(state->open_stateid.seqid); -- u32 stateid_seqid = be32_to_cpu(stateid->seqid); -- -- if (stateid_seqid == state_seqid + 1U || -- (stateid_seqid == 1U && state_seqid == 0xffffffffU)) -- nfs_state_log_update_open_stateid(state); -- else -- set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); --} -- - static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state) - { - struct nfs_client *clp = state->owner->so_server->nfs_client; -@@ -1585,21 +1572,19 @@ static void nfs_test_and_clear_all_open_stateid(struct nfs4_state *state) - * i.e. The stateid seqids have to be initialised to 1, and - * are then incremented on every state transition. - */ --static bool nfs_need_update_open_stateid(struct nfs4_state *state, -+static bool nfs_stateid_is_sequential(struct nfs4_state *state, - const nfs4_stateid *stateid) - { -- if (test_bit(NFS_OPEN_STATE, &state->flags) == 0 || -- !nfs4_stateid_match_other(stateid, &state->open_stateid)) { -+ if (test_bit(NFS_OPEN_STATE, &state->flags)) { -+ /* The common case - we're updating to a new sequence number */ -+ if (nfs4_stateid_match_other(stateid, &state->open_stateid) && -+ nfs4_stateid_is_next(&state->open_stateid, stateid)) { -+ return true; -+ } -+ } else { -+ /* This is the first OPEN in this generation */ - if (stateid->seqid == cpu_to_be32(1)) -- nfs_state_log_update_open_stateid(state); -- else -- set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); -- return true; -- } -- -- if (nfs4_stateid_is_newer(stateid, &state->open_stateid)) { -- nfs_state_log_out_of_order_open_stateid(state, stateid); -- return true; -+ return true; - } - return false; - } -@@ -1673,16 +1658,16 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, - int status = 0; - for (;;) { - -- if (!nfs_need_update_open_stateid(state, stateid)) -- return; -- if (!test_bit(NFS_STATE_CHANGE_WAIT, &state->flags)) -+ if (nfs_stateid_is_sequential(state, stateid)) - break; -+ - if (status) - break; - /* Rely on seqids for serialisation with NFSv4.0 */ - if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client)) - break; - -+ set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); - prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); - /* - * Ensure we process the state changes in the same order -@@ -1693,6 +1678,7 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, - spin_unlock(&state->owner->so_lock); - rcu_read_unlock(); - trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0); -+ - if (!signal_pending(current)) { - if (schedule_timeout(5*HZ) == 0) - status = -EAGAIN; -@@ -3435,7 +3421,8 @@ static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst, - __be32 seqid_open; - u32 dst_seqid; - bool ret; -- int seq; -+ int seq, status = -EAGAIN; -+ DEFINE_WAIT(wait); - - for (;;) { - ret = false; -@@ -3447,15 +3434,41 @@ static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst, - continue; - break; - } -+ -+ write_seqlock(&state->seqlock); - seqid_open = state->open_stateid.seqid; -- if (read_seqretry(&state->seqlock, seq)) -- continue; - - dst_seqid = be32_to_cpu(dst->seqid); -- if ((s32)(dst_seqid - be32_to_cpu(seqid_open)) >= 0) -- dst->seqid = cpu_to_be32(dst_seqid + 1); -- else -+ -+ /* Did another OPEN bump the state's seqid? try again: */ -+ if ((s32)(be32_to_cpu(seqid_open) - dst_seqid) > 0) { - dst->seqid = seqid_open; -+ write_sequnlock(&state->seqlock); -+ ret = true; -+ break; -+ } -+ -+ /* server says we're behind but we haven't seen the update yet */ -+ set_bit(NFS_STATE_CHANGE_WAIT, &state->flags); -+ prepare_to_wait(&state->waitq, &wait, TASK_KILLABLE); -+ write_sequnlock(&state->seqlock); -+ trace_nfs4_close_stateid_update_wait(state->inode, dst, 0); -+ -+ if (signal_pending(current)) -+ status = -EINTR; -+ else -+ if (schedule_timeout(5*HZ) != 0) -+ status = 0; -+ -+ finish_wait(&state->waitq, &wait); -+ -+ if (!status) -+ continue; -+ if (status == -EINTR) -+ break; -+ -+ /* we slept the whole 5 seconds, we must have lost a seqid */ -+ dst->seqid = cpu_to_be32(dst_seqid + 1); - ret = true; - break; - } -@@ -8039,9 +8052,11 @@ int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, - * both PNFS and NON_PNFS flags set, and not having one of NON_PNFS, PNFS, or - * DS flags set. - */ --static int nfs4_check_cl_exchange_flags(u32 flags) -+static int nfs4_check_cl_exchange_flags(u32 flags, u32 version) - { -- if (flags & ~EXCHGID4_FLAG_MASK_R) -+ if (version >= 2 && (flags & ~EXCHGID4_2_FLAG_MASK_R)) -+ goto out_inval; -+ else if (version < 2 && (flags & ~EXCHGID4_FLAG_MASK_R)) - goto out_inval; - if ((flags & EXCHGID4_FLAG_USE_PNFS_MDS) && - (flags & EXCHGID4_FLAG_USE_NON_PNFS)) -@@ -8454,7 +8469,8 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cre - if (status != 0) - goto out; - -- status = nfs4_check_cl_exchange_flags(resp->flags); -+ status = nfs4_check_cl_exchange_flags(resp->flags, -+ clp->cl_mvops->minor_version); - if (status != 0) - goto out; - -diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h -index b4f852d4d0994..484c1da96dea2 100644 ---- a/fs/nfs/nfs4trace.h -+++ b/fs/nfs/nfs4trace.h -@@ -1511,6 +1511,7 @@ DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr); - DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn); - DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update); - DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait); -+DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_close_stateid_update_wait); - - DECLARE_EVENT_CLASS(nfs4_getattr_event, - TP_PROTO( -diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c -index c09a2a4281ec9..1f646a27481fb 100644 ---- a/fs/nfsd/nfs4state.c -+++ b/fs/nfsd/nfs4state.c -@@ -4954,7 +4954,6 @@ static int nfsd4_check_conflicting_opens(struct nfs4_client *clp, - writes--; - if (fp->fi_fds[O_RDWR]) - writes--; -- WARN_ON_ONCE(writes < 0); - if (writes > 0) - return -EAGAIN; - spin_lock(&fp->fi_lock); -@@ -5126,7 +5125,7 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, - - memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid)); - -- trace_nfsd_deleg_open(&dp->dl_stid.sc_stateid); -+ trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); - open->op_delegate_type = NFS4_OPEN_DELEGATE_READ; - nfs4_put_stid(&dp->dl_stid); - return; -@@ -5243,7 +5242,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf - nfs4_open_delegation(current_fh, open, stp); - nodeleg: - status = nfs_ok; -- trace_nfsd_deleg_none(&stp->st_stid.sc_stateid); -+ trace_nfsd_open(&stp->st_stid.sc_stateid); - out: - /* 4.1 client trying to upgrade/downgrade delegation? */ - if (open->op_delegate_type == NFS4_OPEN_DELEGATE_NONE && dp && -diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c -index 6e0b066480c50..6d1b3af40a4f5 100644 ---- a/fs/nfsd/nfsproc.c -+++ b/fs/nfsd/nfsproc.c -@@ -118,6 +118,13 @@ done: - return nfsd_return_attrs(nfserr, resp); - } - -+/* Obsolete, replaced by MNTPROC_MNT. */ -+static __be32 -+nfsd_proc_root(struct svc_rqst *rqstp) -+{ -+ return nfs_ok; -+} -+ - /* - * Look up a path name component - * Note: the dentry in the resp->fh may be negative if the file -@@ -203,6 +210,13 @@ nfsd_proc_read(struct svc_rqst *rqstp) - return fh_getattr(&resp->fh, &resp->stat); - } - -+/* Reserved */ -+static __be32 -+nfsd_proc_writecache(struct svc_rqst *rqstp) -+{ -+ return nfs_ok; -+} -+ - /* - * Write data to a file - * N.B. After this call resp->fh needs an fh_put -@@ -617,6 +631,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { - .pc_xdrressize = ST+AT, - }, - [NFSPROC_ROOT] = { -+ .pc_func = nfsd_proc_root, - .pc_decode = nfssvc_decode_void, - .pc_encode = nfssvc_encode_void, - .pc_argsize = sizeof(struct nfsd_void), -@@ -654,6 +669,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { - .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4, - }, - [NFSPROC_WRITECACHE] = { -+ .pc_func = nfsd_proc_writecache, - .pc_decode = nfssvc_decode_void, - .pc_encode = nfssvc_encode_void, - .pc_argsize = sizeof(struct nfsd_void), -diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h -index 1861db1bdc670..99bf07800cd09 100644 ---- a/fs/nfsd/trace.h -+++ b/fs/nfsd/trace.h -@@ -289,8 +289,8 @@ DEFINE_STATEID_EVENT(layout_recall_done); - DEFINE_STATEID_EVENT(layout_recall_fail); - DEFINE_STATEID_EVENT(layout_recall_release); - --DEFINE_STATEID_EVENT(deleg_open); --DEFINE_STATEID_EVENT(deleg_none); -+DEFINE_STATEID_EVENT(open); -+DEFINE_STATEID_EVENT(deleg_read); - DEFINE_STATEID_EVENT(deleg_break); - DEFINE_STATEID_EVENT(deleg_recall); - -diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c -index 31288d8fa2ce9..ebff43f8009c2 100644 ---- a/fs/ubifs/debug.c -+++ b/fs/ubifs/debug.c -@@ -1123,6 +1123,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir) - err = PTR_ERR(dent); - if (err == -ENOENT) - break; -+ kfree(pdent); - return err; - } - -diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c -index 4a5b06f8d8129..9a3b6e92270db 100644 ---- a/fs/ubifs/journal.c -+++ b/fs/ubifs/journal.c -@@ -894,6 +894,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) - if (err == -ENOENT) - break; - -+ kfree(pxent); - goto out_release; - } - -@@ -906,6 +907,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) - ubifs_err(c, "dead directory entry '%s', error %d", - xent->name, err); - ubifs_ro_mode(c, err); -+ kfree(pxent); - kfree(xent); - goto out_release; - } -@@ -936,8 +938,6 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) - inode->i_ino); - release_head(c, BASEHD); - -- ubifs_add_auth_dirt(c, lnum); -- - if (last_reference) { - err = ubifs_tnc_remove_ino(c, inode->i_ino); - if (err) -@@ -947,6 +947,8 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode) - } else { - union ubifs_key key; - -+ ubifs_add_auth_dirt(c, lnum); -+ - ino_key_init(c, &key, inode->i_ino); - err = ubifs_tnc_add(c, &key, lnum, offs, ilen, hash); - } -diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c -index 2c294085ffedc..0fb61956146da 100644 ---- a/fs/ubifs/orphan.c -+++ b/fs/ubifs/orphan.c -@@ -173,6 +173,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum) - err = PTR_ERR(xent); - if (err == -ENOENT) - break; -+ kfree(pxent); - return err; - } - -@@ -182,6 +183,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum) - - xattr_orphan = orphan_add(c, xattr_inum, orphan); - if (IS_ERR(xattr_orphan)) { -+ kfree(pxent); - kfree(xent); - return PTR_ERR(xattr_orphan); - } -diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c -index a2420c900275a..732218ef66567 100644 ---- a/fs/ubifs/super.c -+++ b/fs/ubifs/super.c -@@ -1110,14 +1110,20 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options, - break; - } - case Opt_auth_key: -- c->auth_key_name = kstrdup(args[0].from, GFP_KERNEL); -- if (!c->auth_key_name) -- return -ENOMEM; -+ if (!is_remount) { -+ c->auth_key_name = kstrdup(args[0].from, -+ GFP_KERNEL); -+ if (!c->auth_key_name) -+ return -ENOMEM; -+ } - break; - case Opt_auth_hash_name: -- c->auth_hash_name = kstrdup(args[0].from, GFP_KERNEL); -- if (!c->auth_hash_name) -- return -ENOMEM; -+ if (!is_remount) { -+ c->auth_hash_name = kstrdup(args[0].from, -+ GFP_KERNEL); -+ if (!c->auth_hash_name) -+ return -ENOMEM; -+ } - break; - case Opt_ignore: - break; -@@ -1141,6 +1147,18 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options, - return 0; - } - -+/* -+ * ubifs_release_options - release mount parameters which have been dumped. -+ * @c: UBIFS file-system description object -+ */ -+static void ubifs_release_options(struct ubifs_info *c) -+{ -+ kfree(c->auth_key_name); -+ c->auth_key_name = NULL; -+ kfree(c->auth_hash_name); -+ c->auth_hash_name = NULL; -+} -+ - /** - * destroy_journal - destroy journal data structures. - * @c: UBIFS file-system description object -@@ -1313,7 +1331,7 @@ static int mount_ubifs(struct ubifs_info *c) - - err = ubifs_read_superblock(c); - if (err) -- goto out_free; -+ goto out_auth; - - c->probing = 0; - -@@ -1325,18 +1343,18 @@ static int mount_ubifs(struct ubifs_info *c) - ubifs_err(c, "'compressor \"%s\" is not compiled in", - ubifs_compr_name(c, c->default_compr)); - err = -ENOTSUPP; -- goto out_free; -+ goto out_auth; - } - - err = init_constants_sb(c); - if (err) -- goto out_free; -+ goto out_auth; - - sz = ALIGN(c->max_idx_node_sz, c->min_io_size) * 2; - c->cbuf = kmalloc(sz, GFP_NOFS); - if (!c->cbuf) { - err = -ENOMEM; -- goto out_free; -+ goto out_auth; - } - - err = alloc_wbufs(c); -@@ -1611,6 +1629,8 @@ out_wbufs: - free_wbufs(c); - out_cbuf: - kfree(c->cbuf); -+out_auth: -+ ubifs_exit_authentication(c); - out_free: - kfree(c->write_reserve_buf); - kfree(c->bu.buf); -@@ -1650,8 +1670,7 @@ static void ubifs_umount(struct ubifs_info *c) - ubifs_lpt_free(c, 0); - ubifs_exit_authentication(c); - -- kfree(c->auth_key_name); -- kfree(c->auth_hash_name); -+ ubifs_release_options(c); - kfree(c->cbuf); - kfree(c->rcvrd_mst_node); - kfree(c->mst_node); -@@ -2219,6 +2238,7 @@ out_umount: - out_unlock: - mutex_unlock(&c->umount_mutex); - out_close: -+ ubifs_release_options(c); - ubi_close_volume(c->ubi); - out: - return err; -diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c -index f609f6cdde700..b120a00773f81 100644 ---- a/fs/ubifs/tnc.c -+++ b/fs/ubifs/tnc.c -@@ -2885,6 +2885,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum) - err = PTR_ERR(xent); - if (err == -ENOENT) - break; -+ kfree(pxent); - return err; - } - -@@ -2898,6 +2899,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum) - fname_len(&nm) = le16_to_cpu(xent->nlen); - err = ubifs_tnc_remove_nm(c, &key1, &nm); - if (err) { -+ kfree(pxent); - kfree(xent); - return err; - } -@@ -2906,6 +2908,7 @@ int ubifs_tnc_remove_ino(struct ubifs_info *c, ino_t inum) - highest_ino_key(c, &key2, xattr_inum); - err = ubifs_tnc_remove_range(c, &key1, &key2); - if (err) { -+ kfree(pxent); - kfree(xent); - return err; - } -diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c -index 9aefbb60074ff..a0b9b349efe65 100644 ---- a/fs/ubifs/xattr.c -+++ b/fs/ubifs/xattr.c -@@ -522,6 +522,7 @@ int ubifs_purge_xattrs(struct inode *host) - xent->name, err); - ubifs_ro_mode(c, err); - kfree(pxent); -+ kfree(xent); - return err; - } - -@@ -531,6 +532,7 @@ int ubifs_purge_xattrs(struct inode *host) - err = remove_xattr(c, host, xino, &nm); - if (err) { - kfree(pxent); -+ kfree(xent); - iput(xino); - ubifs_err(c, "cannot remove xattr, error %d", err); - return err; -diff --git a/fs/udf/super.c b/fs/udf/super.c -index a03b8ce5ef0fd..fca3f5b590782 100644 ---- a/fs/udf/super.c -+++ b/fs/udf/super.c -@@ -1704,7 +1704,8 @@ static noinline int udf_process_sequence( - "Pointers (max %u supported)\n", - UDF_MAX_TD_NESTING); - brelse(bh); -- return -EIO; -+ ret = -EIO; -+ goto out; - } - - vdp = (struct volDescPtr *)bh->b_data; -@@ -1724,7 +1725,8 @@ static noinline int udf_process_sequence( - curr = get_volume_descriptor_record(ident, bh, &data); - if (IS_ERR(curr)) { - brelse(bh); -- return PTR_ERR(curr); -+ ret = PTR_ERR(curr); -+ goto out; - } - /* Descriptor we don't care about? */ - if (!curr) -@@ -1746,28 +1748,31 @@ static noinline int udf_process_sequence( - */ - if (!data.vds[VDS_POS_PRIMARY_VOL_DESC].block) { - udf_err(sb, "Primary Volume Descriptor not found!\n"); -- return -EAGAIN; -+ ret = -EAGAIN; -+ goto out; - } - ret = udf_load_pvoldesc(sb, data.vds[VDS_POS_PRIMARY_VOL_DESC].block); - if (ret < 0) -- return ret; -+ goto out; - - if (data.vds[VDS_POS_LOGICAL_VOL_DESC].block) { - ret = udf_load_logicalvol(sb, - data.vds[VDS_POS_LOGICAL_VOL_DESC].block, - fileset); - if (ret < 0) -- return ret; -+ goto out; - } - - /* Now handle prevailing Partition Descriptors */ - for (i = 0; i < data.num_part_descs; i++) { - ret = udf_load_partdesc(sb, data.part_descs_loc[i].rec.block); - if (ret < 0) -- return ret; -+ goto out; - } -- -- return 0; -+ ret = 0; -+out: -+ kfree(data.part_descs_loc); -+ return ret; - } - - /* -diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c -index 1b0a01b06a05d..d9a692484eaed 100644 ---- a/fs/xfs/libxfs/xfs_bmap.c -+++ b/fs/xfs/libxfs/xfs_bmap.c -@@ -5046,20 +5046,25 @@ xfs_bmap_del_extent_real( - - flags = XFS_ILOG_CORE; - if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { -- xfs_fsblock_t bno; - xfs_filblks_t len; - xfs_extlen_t mod; - -- bno = div_u64_rem(del->br_startblock, mp->m_sb.sb_rextsize, -- &mod); -- ASSERT(mod == 0); - len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize, - &mod); - ASSERT(mod == 0); - -- error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); -- if (error) -- goto done; -+ if (!(bflags & XFS_BMAPI_REMAP)) { -+ xfs_fsblock_t bno; -+ -+ bno = div_u64_rem(del->br_startblock, -+ mp->m_sb.sb_rextsize, &mod); -+ ASSERT(mod == 0); -+ -+ error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); -+ if (error) -+ goto done; -+ } -+ - do_fx = 0; - nblks = len * mp->m_sb.sb_rextsize; - qfield = XFS_TRANS_DQ_RTBCOUNT; -diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c -index d8f586256add7..4959d8a32b606 100644 ---- a/fs/xfs/libxfs/xfs_defer.c -+++ b/fs/xfs/libxfs/xfs_defer.c -@@ -186,8 +186,9 @@ xfs_defer_create_intent( - { - const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; - -- dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, -- dfp->dfp_count, sort); -+ if (!dfp->dfp_intent) -+ dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, -+ dfp->dfp_count, sort); - } - - /* -@@ -390,6 +391,7 @@ xfs_defer_finish_one( - list_add(li, &dfp->dfp_work); - dfp->dfp_count++; - dfp->dfp_done = NULL; -+ dfp->dfp_intent = NULL; - xfs_defer_create_intent(tp, dfp, false); - } - -@@ -428,8 +430,17 @@ xfs_defer_finish_noroll( - - /* Until we run out of pending work to finish... */ - while (!list_empty(&dop_pending) || !list_empty(&(*tp)->t_dfops)) { -+ /* -+ * Deferred items that are created in the process of finishing -+ * other deferred work items should be queued at the head of -+ * the pending list, which puts them ahead of the deferred work -+ * that was created by the caller. This keeps the number of -+ * pending work items to a minimum, which decreases the amount -+ * of time that any one intent item can stick around in memory, -+ * pinning the log tail. -+ */ - xfs_defer_create_intents(*tp); -- list_splice_tail_init(&(*tp)->t_dfops, &dop_pending); -+ list_splice_init(&(*tp)->t_dfops, &dop_pending); - - error = xfs_defer_trans_roll(tp); - if (error) -@@ -552,3 +563,23 @@ xfs_defer_move( - - xfs_defer_reset(stp); - } -+ -+/* -+ * Prepare a chain of fresh deferred ops work items to be completed later. Log -+ * recovery requires the ability to put off until later the actual finishing -+ * work so that it can process unfinished items recovered from the log in -+ * correct order. -+ * -+ * Create and log intent items for all the work that we're capturing so that we -+ * can be assured that the items will get replayed if the system goes down -+ * before log recovery gets a chance to finish the work it put off. Then we -+ * move the chain from stp to dtp. -+ */ -+void -+xfs_defer_capture( -+ struct xfs_trans *dtp, -+ struct xfs_trans *stp) -+{ -+ xfs_defer_create_intents(stp); -+ xfs_defer_move(dtp, stp); -+} -diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h -index 6b2ca580f2b06..3164199162b61 100644 ---- a/fs/xfs/libxfs/xfs_defer.h -+++ b/fs/xfs/libxfs/xfs_defer.h -@@ -63,4 +63,10 @@ extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; - extern const struct xfs_defer_op_type xfs_extent_free_defer_type; - extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; - -+/* -+ * Functions to capture a chain of deferred operations and continue them later. -+ * This doesn't normally happen except log recovery. -+ */ -+void xfs_defer_capture(struct xfs_trans *dtp, struct xfs_trans *stp); -+ - #endif /* __XFS_DEFER_H__ */ -diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c -index ec3691372e7c0..815a0563288f4 100644 ---- a/fs/xfs/xfs_bmap_item.c -+++ b/fs/xfs/xfs_bmap_item.c -@@ -534,7 +534,7 @@ xfs_bui_item_recover( - xfs_bmap_unmap_extent(tp, ip, &irec); - } - -- xfs_defer_move(parent_tp, tp); -+ xfs_defer_capture(parent_tp, tp); - error = xfs_trans_commit(tp); - xfs_iunlock(ip, XFS_ILOCK_EXCL); - xfs_irele(ip); -diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c -index e2ec91b2d0f46..9ceb67d0f2565 100644 ---- a/fs/xfs/xfs_log_recover.c -+++ b/fs/xfs/xfs_log_recover.c -@@ -2904,7 +2904,8 @@ STATIC int - xlog_valid_rec_header( - struct xlog *log, - struct xlog_rec_header *rhead, -- xfs_daddr_t blkno) -+ xfs_daddr_t blkno, -+ int bufsize) - { - int hlen; - -@@ -2920,10 +2921,14 @@ xlog_valid_rec_header( - return -EFSCORRUPTED; - } - -- /* LR body must have data or it wouldn't have been written */ -+ /* -+ * LR body must have data (or it wouldn't have been written) -+ * and h_len must not be greater than LR buffer size. -+ */ - hlen = be32_to_cpu(rhead->h_len); -- if (XFS_IS_CORRUPT(log->l_mp, hlen <= 0 || hlen > INT_MAX)) -+ if (XFS_IS_CORRUPT(log->l_mp, hlen <= 0 || hlen > bufsize)) - return -EFSCORRUPTED; -+ - if (XFS_IS_CORRUPT(log->l_mp, - blkno > log->l_logBBsize || blkno > INT_MAX)) - return -EFSCORRUPTED; -@@ -2984,9 +2989,6 @@ xlog_do_recovery_pass( - goto bread_err1; - - rhead = (xlog_rec_header_t *)offset; -- error = xlog_valid_rec_header(log, rhead, tail_blk); -- if (error) -- goto bread_err1; - - /* - * xfsprogs has a bug where record length is based on lsunit but -@@ -3001,21 +3003,18 @@ xlog_do_recovery_pass( - */ - h_size = be32_to_cpu(rhead->h_size); - h_len = be32_to_cpu(rhead->h_len); -- if (h_len > h_size) { -- if (h_len <= log->l_mp->m_logbsize && -- be32_to_cpu(rhead->h_num_logops) == 1) { -- xfs_warn(log->l_mp, -+ if (h_len > h_size && h_len <= log->l_mp->m_logbsize && -+ rhead->h_num_logops == cpu_to_be32(1)) { -+ xfs_warn(log->l_mp, - "invalid iclog size (%d bytes), using lsunit (%d bytes)", -- h_size, log->l_mp->m_logbsize); -- h_size = log->l_mp->m_logbsize; -- } else { -- XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, -- log->l_mp); -- error = -EFSCORRUPTED; -- goto bread_err1; -- } -+ h_size, log->l_mp->m_logbsize); -+ h_size = log->l_mp->m_logbsize; - } - -+ error = xlog_valid_rec_header(log, rhead, tail_blk, h_size); -+ if (error) -+ goto bread_err1; -+ - if ((be32_to_cpu(rhead->h_version) & XLOG_VERSION_2) && - (h_size > XLOG_HEADER_CYCLE_SIZE)) { - hblks = h_size / XLOG_HEADER_CYCLE_SIZE; -@@ -3096,7 +3095,7 @@ xlog_do_recovery_pass( - } - rhead = (xlog_rec_header_t *)offset; - error = xlog_valid_rec_header(log, rhead, -- split_hblks ? blk_no : 0); -+ split_hblks ? blk_no : 0, h_size); - if (error) - goto bread_err2; - -@@ -3177,7 +3176,7 @@ xlog_do_recovery_pass( - goto bread_err2; - - rhead = (xlog_rec_header_t *)offset; -- error = xlog_valid_rec_header(log, rhead, blk_no); -+ error = xlog_valid_rec_header(log, rhead, blk_no, h_size); - if (error) - goto bread_err2; - -diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c -index ca93b64883774..492d80a0b4060 100644 ---- a/fs/xfs/xfs_refcount_item.c -+++ b/fs/xfs/xfs_refcount_item.c -@@ -555,7 +555,7 @@ xfs_cui_item_recover( - } - - xfs_refcount_finish_one_cleanup(tp, rcur, error); -- xfs_defer_move(parent_tp, tp); -+ xfs_defer_capture(parent_tp, tp); - error = xfs_trans_commit(tp); - return error; - -diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c -index 86994d7f7cba3..be01bfbc3ad93 100644 ---- a/fs/xfs/xfs_rtalloc.c -+++ b/fs/xfs/xfs_rtalloc.c -@@ -778,8 +778,14 @@ xfs_growfs_rt_alloc( - struct xfs_bmbt_irec map; /* block map output */ - int nmap; /* number of block maps */ - int resblks; /* space reservation */ -+ enum xfs_blft buf_type; - struct xfs_trans *tp; - -+ if (ip == mp->m_rsumip) -+ buf_type = XFS_BLFT_RTSUMMARY_BUF; -+ else -+ buf_type = XFS_BLFT_RTBITMAP_BUF; -+ - /* - * Allocate space to the file, as necessary. - */ -@@ -841,6 +847,9 @@ xfs_growfs_rt_alloc( - mp->m_bsize, 0, &bp); - if (error) - goto out_trans_cancel; -+ -+ xfs_trans_buf_set_type(tp, bp, buf_type); -+ bp->b_ops = &xfs_rtbuf_ops; - memset(bp->b_addr, 0, mp->m_sb.sb_blocksize); - xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); - /* -@@ -1018,10 +1027,13 @@ xfs_growfs_rt( - xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); - /* -- * Update the bitmap inode's size. -+ * Update the bitmap inode's size ondisk and incore. We need -+ * to update the incore size so that inode inactivation won't -+ * punch what it thinks are "posteof" blocks. - */ - mp->m_rbmip->i_d.di_size = - nsbp->sb_rbmblocks * nsbp->sb_blocksize; -+ i_size_write(VFS_I(mp->m_rbmip), mp->m_rbmip->i_d.di_size); - xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); - /* - * Get the summary inode into the transaction. -@@ -1029,9 +1041,12 @@ xfs_growfs_rt( - xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL); - /* -- * Update the summary inode's size. -+ * Update the summary inode's size. We need to update the -+ * incore size so that inode inactivation won't punch what it -+ * thinks are "posteof" blocks. - */ - mp->m_rsumip->i_d.di_size = nmp->m_rsumsize; -+ i_size_write(VFS_I(mp->m_rsumip), mp->m_rsumip->i_d.di_size); - xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE); - /* - * Copy summary data from old to new sizes. -diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h -index 7636bc71c71f9..2b34e6de3e8a2 100644 ---- a/include/asm-generic/vmlinux.lds.h -+++ b/include/asm-generic/vmlinux.lds.h -@@ -581,7 +581,10 @@ - */ - #define TEXT_TEXT \ - ALIGN_FUNCTION(); \ -- *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \ -+ *(.text.hot .text.hot.*) \ -+ *(TEXT_MAIN .text.fixup) \ -+ *(.text.unlikely .text.unlikely.*) \ -+ *(.text.unknown .text.unknown.*) \ - NOINSTR_TEXT \ - *(.text..refcount) \ - *(.ref.text) \ -diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h -index b9780ae9dd26c..72dc3a95fbaad 100644 ---- a/include/drm/gpu_scheduler.h -+++ b/include/drm/gpu_scheduler.h -@@ -33,14 +33,16 @@ - struct drm_gpu_scheduler; - struct drm_sched_rq; - -+/* These are often used as an (initial) index -+ * to an array, and as such should start at 0. -+ */ - enum drm_sched_priority { - DRM_SCHED_PRIORITY_MIN, -- DRM_SCHED_PRIORITY_LOW = DRM_SCHED_PRIORITY_MIN, - DRM_SCHED_PRIORITY_NORMAL, -- DRM_SCHED_PRIORITY_HIGH_SW, -- DRM_SCHED_PRIORITY_HIGH_HW, -+ DRM_SCHED_PRIORITY_HIGH, - DRM_SCHED_PRIORITY_KERNEL, -- DRM_SCHED_PRIORITY_MAX, -+ -+ DRM_SCHED_PRIORITY_COUNT, - DRM_SCHED_PRIORITY_INVALID = -1, - DRM_SCHED_PRIORITY_UNSET = -2 - }; -@@ -274,7 +276,7 @@ struct drm_gpu_scheduler { - uint32_t hw_submission_limit; - long timeout; - const char *name; -- struct drm_sched_rq sched_rq[DRM_SCHED_PRIORITY_MAX]; -+ struct drm_sched_rq sched_rq[DRM_SCHED_PRIORITY_COUNT]; - wait_queue_head_t wake_up_worker; - wait_queue_head_t job_scheduled; - atomic_t hw_rq_count; -diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h -index a911e5d068454..2e900fd461f2e 100644 ---- a/include/linux/cpufreq.h -+++ b/include/linux/cpufreq.h -@@ -293,7 +293,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name) - - struct cpufreq_driver { - char name[CPUFREQ_NAME_LEN]; -- u8 flags; -+ u16 flags; - void *driver_data; - - /* needed by all drivers */ -@@ -417,9 +417,18 @@ struct cpufreq_driver { - */ - #define CPUFREQ_IS_COOLING_DEV BIT(7) - -+/* -+ * Set by drivers that need to update internale upper and lower boundaries along -+ * with the target frequency and so the core and governors should also invoke -+ * the diver if the target frequency does not change, but the policy min or max -+ * may have changed. -+ */ -+#define CPUFREQ_NEED_UPDATE_LIMITS BIT(8) -+ - int cpufreq_register_driver(struct cpufreq_driver *driver_data); - int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); - -+bool cpufreq_driver_test_flags(u16 flags); - const char *cpufreq_get_current_driver(void); - void *cpufreq_get_driver_data(void); - -diff --git a/include/linux/fs.h b/include/linux/fs.h -index 7d4d04c9d3e64..dbbeb52ce5f31 100644 ---- a/include/linux/fs.h -+++ b/include/linux/fs.h -@@ -2861,7 +2861,6 @@ extern int do_pipe_flags(int *, int); - #define __kernel_read_file_id(id) \ - id(UNKNOWN, unknown) \ - id(FIRMWARE, firmware) \ -- id(FIRMWARE_PREALLOC_BUFFER, firmware) \ - id(MODULE, kernel-module) \ - id(KEXEC_IMAGE, kexec-image) \ - id(KEXEC_INITRAMFS, kexec-initramfs) \ -diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h -index 774f7d3b8f6af..369221fd55187 100644 ---- a/include/linux/hil_mlc.h -+++ b/include/linux/hil_mlc.h -@@ -103,7 +103,7 @@ struct hilse_node { - - /* Methods for back-end drivers, e.g. hp_sdc_mlc */ - typedef int (hil_mlc_cts) (hil_mlc *mlc); --typedef void (hil_mlc_out) (hil_mlc *mlc); -+typedef int (hil_mlc_out) (hil_mlc *mlc); - typedef int (hil_mlc_in) (hil_mlc *mlc, suseconds_t timeout); - - struct hil_mlc_devinfo { -diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h -index 372100c755e7f..e30be3dd5be0e 100644 ---- a/include/linux/mlx5/driver.h -+++ b/include/linux/mlx5/driver.h -@@ -1212,4 +1212,22 @@ static inline bool mlx5_is_roce_enabled(struct mlx5_core_dev *dev) - return val.vbool; - } - -+/** -+ * mlx5_core_net - Provide net namespace of the mlx5_core_dev -+ * @dev: mlx5 core device -+ * -+ * mlx5_core_net() returns the net namespace of mlx5 core device. -+ * This can be called only in below described limited context. -+ * (a) When a devlink instance for mlx5_core is registered and -+ * when devlink reload operation is disabled. -+ * or -+ * (b) during devlink reload reload_down() and reload_up callbacks -+ * where it is ensured that devlink instance's net namespace is -+ * stable. -+ */ -+static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev) -+{ -+ return devlink_net(priv_to_devlink(dev)); -+} -+ - #endif /* MLX5_DRIVER_H */ -diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h -index 1af5cb02ef7f9..033ce74f02e81 100644 ---- a/include/linux/pci-ecam.h -+++ b/include/linux/pci-ecam.h -@@ -51,6 +51,7 @@ extern const struct pci_ecam_ops pci_generic_ecam_ops; - - #if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS) - extern const struct pci_ecam_ops pci_32b_ops; /* 32-bit accesses only */ -+extern const struct pci_ecam_ops pci_32b_read_ops; /* 32-bit read only */ - extern const struct pci_ecam_ops hisi_pcie_ops; /* HiSilicon */ - extern const struct pci_ecam_ops thunder_pem_ecam_ops; /* Cavium ThunderX 1.x & 2.x */ - extern const struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */ -diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h -index d9015aac78c63..a6a6a3acab5a8 100644 ---- a/include/linux/rcupdate_trace.h -+++ b/include/linux/rcupdate_trace.h -@@ -50,6 +50,7 @@ static inline void rcu_read_lock_trace(void) - struct task_struct *t = current; - - WRITE_ONCE(t->trc_reader_nesting, READ_ONCE(t->trc_reader_nesting) + 1); -+ barrier(); - if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB) && - t->trc_reader_special.b.need_mb) - smp_mb(); // Pairs with update-side barriers -@@ -72,6 +73,9 @@ static inline void rcu_read_unlock_trace(void) - - rcu_lock_release(&rcu_trace_lock_map); - nesting = READ_ONCE(t->trc_reader_nesting) - 1; -+ barrier(); // Critical section before disabling. -+ // Disable IPI-based setting of .need_qs. -+ WRITE_ONCE(t->trc_reader_nesting, INT_MIN); - if (likely(!READ_ONCE(t->trc_reader_special.s)) || nesting) { - WRITE_ONCE(t->trc_reader_nesting, nesting); - return; // We assume shallow reader nesting. -diff --git a/include/linux/time64.h b/include/linux/time64.h -index c9dcb3e5781f8..5117cb5b56561 100644 ---- a/include/linux/time64.h -+++ b/include/linux/time64.h -@@ -124,6 +124,10 @@ static inline bool timespec64_valid_settod(const struct timespec64 *ts) - */ - static inline s64 timespec64_to_ns(const struct timespec64 *ts) - { -+ /* Prevent multiplication overflow */ -+ if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX) -+ return KTIME_MAX; -+ - return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec; - } - -diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h -index b6c233e79bd45..1df895e4680b2 100644 ---- a/include/linux/usb/pd.h -+++ b/include/linux/usb/pd.h -@@ -473,6 +473,7 @@ static inline unsigned int rdo_max_power(u32 rdo) - #define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */ - #define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ - #define PD_T_NEWSRC 250 /* Maximum of 275ms */ -+#define PD_T_SWAP_SRC_START 20 /* Minimum of 20ms */ - - #define PD_T_DRP_TRY 100 /* 75 - 150 ms */ - #define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */ -diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h -index 5b4f0efc4241f..ef7b786b8675c 100644 ---- a/include/rdma/ib_verbs.h -+++ b/include/rdma/ib_verbs.h -@@ -1463,11 +1463,6 @@ enum rdma_remove_reason { - RDMA_REMOVE_DRIVER_REMOVE, - /* uobj is being cleaned-up before being committed */ - RDMA_REMOVE_ABORT, -- /* -- * uobj has been fully created, with the uobj->object set, but is being -- * cleaned up before being comitted -- */ -- RDMA_REMOVE_ABORT_HWOBJ, - }; - - struct ib_rdmacg_object { -diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h -index e76bac4d14c51..69ade4fb71aab 100644 ---- a/include/scsi/scsi_cmnd.h -+++ b/include/scsi/scsi_cmnd.h -@@ -165,7 +165,8 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, - size_t *offset, size_t *len); - extern void scsi_kunmap_atomic_sg(void *virt); - --extern blk_status_t scsi_init_io(struct scsi_cmnd *cmd); -+blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd); -+void scsi_free_sgtables(struct scsi_cmnd *cmd); - - #ifdef CONFIG_SCSI_DMA - extern int scsi_dma_map(struct scsi_cmnd *cmd); -diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h -index 5f0c1cf1ea130..342b35fc33c59 100644 ---- a/include/trace/events/afs.h -+++ b/include/trace/events/afs.h -@@ -40,6 +40,7 @@ enum afs_server_trace { - afs_server_trace_get_new_cbi, - afs_server_trace_get_probe, - afs_server_trace_give_up_cb, -+ afs_server_trace_purging, - afs_server_trace_put_call, - afs_server_trace_put_cbi, - afs_server_trace_put_find_rsq, -@@ -270,6 +271,7 @@ enum afs_cb_break_reason { - EM(afs_server_trace_get_new_cbi, "GET cbi ") \ - EM(afs_server_trace_get_probe, "GET probe") \ - EM(afs_server_trace_give_up_cb, "giveup-cb") \ -+ EM(afs_server_trace_purging, "PURGE ") \ - EM(afs_server_trace_put_call, "PUT call ") \ - EM(afs_server_trace_put_cbi, "PUT cbi ") \ - EM(afs_server_trace_put_find_rsq, "PUT f-rsq") \ -@@ -884,19 +886,6 @@ TRACE_EVENT(afs_dir_check_failed, - __entry->vnode, __entry->off, __entry->i_size) - ); - --/* -- * We use page->private to hold the amount of the page that we've written to, -- * splitting the field into two parts. However, we need to represent a range -- * 0...PAGE_SIZE inclusive, so we can't support 64K pages on a 32-bit system. -- */ --#if PAGE_SIZE > 32768 --#define AFS_PRIV_MAX 0xffffffff --#define AFS_PRIV_SHIFT 32 --#else --#define AFS_PRIV_MAX 0xffff --#define AFS_PRIV_SHIFT 16 --#endif -- - TRACE_EVENT(afs_page_dirty, - TP_PROTO(struct afs_vnode *vnode, const char *where, - pgoff_t page, unsigned long priv), -@@ -917,10 +906,11 @@ TRACE_EVENT(afs_page_dirty, - __entry->priv = priv; - ), - -- TP_printk("vn=%p %lx %s %lu-%lu", -+ TP_printk("vn=%p %lx %s %zx-%zx%s", - __entry->vnode, __entry->page, __entry->where, -- __entry->priv & AFS_PRIV_MAX, -- __entry->priv >> AFS_PRIV_SHIFT) -+ afs_page_dirty_from(__entry->priv), -+ afs_page_dirty_to(__entry->priv), -+ afs_is_page_dirty_mmapped(__entry->priv) ? " M" : "") - ); - - TRACE_EVENT(afs_call_state, -diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h -index 863335ecb7e8a..b9241836d4f73 100644 ---- a/include/trace/events/btrfs.h -+++ b/include/trace/events/btrfs.h -@@ -1176,25 +1176,27 @@ DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, - - TRACE_EVENT(find_free_extent, - -- TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, -+ TP_PROTO(const struct btrfs_root *root, u64 num_bytes, - u64 empty_size, u64 data), - -- TP_ARGS(fs_info, num_bytes, empty_size, data), -+ TP_ARGS(root, num_bytes, empty_size, data), - - TP_STRUCT__entry_btrfs( -+ __field( u64, root_objectid ) - __field( u64, num_bytes ) - __field( u64, empty_size ) - __field( u64, data ) - ), - -- TP_fast_assign_btrfs(fs_info, -+ TP_fast_assign_btrfs(root->fs_info, -+ __entry->root_objectid = root->root_key.objectid; - __entry->num_bytes = num_bytes; - __entry->empty_size = empty_size; - __entry->data = data; - ), - - TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)", -- show_root_type(BTRFS_EXTENT_TREE_OBJECTID), -+ show_root_type(__entry->root_objectid), - __entry->num_bytes, __entry->empty_size, __entry->data, - __print_flags((unsigned long)__entry->data, "|", - BTRFS_GROUP_FLAGS)) -diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h -index 9ba64ca6b4ac9..6b885982ece68 100644 ---- a/include/uapi/linux/btrfs_tree.h -+++ b/include/uapi/linux/btrfs_tree.h -@@ -4,6 +4,11 @@ - - #include - #include -+#ifdef __KERNEL__ -+#include -+#else -+#include -+#endif - - /* - * This header contains the structure definitions and constants used -@@ -644,6 +649,15 @@ struct btrfs_root_item { - __le64 reserved[8]; /* for future */ - } __attribute__ ((__packed__)); - -+/* -+ * Btrfs root item used to be smaller than current size. The old format ends -+ * at where member generation_v2 is. -+ */ -+static inline __u32 btrfs_legacy_root_item_size(void) -+{ -+ return offsetof(struct btrfs_root_item, generation_v2); -+} -+ - /* - * this is used for both forward and backward root refs - */ -diff --git a/include/uapi/linux/nfs4.h b/include/uapi/linux/nfs4.h -index bf197e99b98fc..ed5415e0f1c19 100644 ---- a/include/uapi/linux/nfs4.h -+++ b/include/uapi/linux/nfs4.h -@@ -139,6 +139,8 @@ - - #define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000 - #define EXCHGID4_FLAG_CONFIRMED_R 0x80000000 -+ -+#define EXCHGID4_FLAG_SUPP_FENCE_OPS 0x00000004 - /* - * Since the validity of these bits depends on whether - * they're set in the argument or response, have separate -@@ -146,6 +148,7 @@ - */ - #define EXCHGID4_FLAG_MASK_A 0x40070103 - #define EXCHGID4_FLAG_MASK_R 0x80070103 -+#define EXCHGID4_2_FLAG_MASK_R 0x80070107 - - #define SEQ4_STATUS_CB_PATH_DOWN 0x00000001 - #define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002 -diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h -index 235db7754606d..f717826d5d7c0 100644 ---- a/include/uapi/linux/videodev2.h -+++ b/include/uapi/linux/videodev2.h -@@ -373,9 +373,9 @@ enum v4l2_hsv_encoding { - - enum v4l2_quantization { - /* -- * The default for R'G'B' quantization is always full range, except -- * for the BT2020 colorspace. For Y'CbCr the quantization is always -- * limited range, except for COLORSPACE_JPEG: this is full range. -+ * The default for R'G'B' quantization is always full range. -+ * For Y'CbCr the quantization is always limited range, except -+ * for COLORSPACE_JPEG: this is full range. - */ - V4L2_QUANTIZATION_DEFAULT = 0, - V4L2_QUANTIZATION_FULL_RANGE = 1, -@@ -384,14 +384,13 @@ enum v4l2_quantization { - - /* - * Determine how QUANTIZATION_DEFAULT should map to a proper quantization. -- * This depends on whether the image is RGB or not, the colorspace and the -- * Y'CbCr encoding. -+ * This depends on whether the image is RGB or not, the colorspace. -+ * The Y'CbCr encoding is not used anymore, but is still there for backwards -+ * compatibility. - */ - #define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \ -- (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \ -- V4L2_QUANTIZATION_LIM_RANGE : \ -- (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ -- V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) -+ (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ -+ V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE) - - /* - * Deprecated names for opRGB colorspace (IEC 61966-2-5) -diff --git a/include/xen/events.h b/include/xen/events.h -index df1e6391f63ff..3b8155c2ea034 100644 ---- a/include/xen/events.h -+++ b/include/xen/events.h -@@ -15,10 +15,15 @@ - unsigned xen_evtchn_nr_channels(void); - - int bind_evtchn_to_irq(evtchn_port_t evtchn); -+int bind_evtchn_to_irq_lateeoi(evtchn_port_t evtchn); - int bind_evtchn_to_irqhandler(evtchn_port_t evtchn, - irq_handler_t handler, - unsigned long irqflags, const char *devname, - void *dev_id); -+int bind_evtchn_to_irqhandler_lateeoi(evtchn_port_t evtchn, -+ irq_handler_t handler, -+ unsigned long irqflags, const char *devname, -+ void *dev_id); - int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu); - int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, - irq_handler_t handler, -@@ -32,12 +37,20 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi, - void *dev_id); - int bind_interdomain_evtchn_to_irq(unsigned int remote_domain, - evtchn_port_t remote_port); -+int bind_interdomain_evtchn_to_irq_lateeoi(unsigned int remote_domain, -+ evtchn_port_t remote_port); - int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, - evtchn_port_t remote_port, - irq_handler_t handler, - unsigned long irqflags, - const char *devname, - void *dev_id); -+int bind_interdomain_evtchn_to_irqhandler_lateeoi(unsigned int remote_domain, -+ evtchn_port_t remote_port, -+ irq_handler_t handler, -+ unsigned long irqflags, -+ const char *devname, -+ void *dev_id); - - /* - * Common unbind function for all event sources. Takes IRQ to unbind from. -@@ -46,6 +59,14 @@ int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, - */ - void unbind_from_irqhandler(unsigned int irq, void *dev_id); - -+/* -+ * Send late EOI for an IRQ bound to an event channel via one of the *_lateeoi -+ * functions above. -+ */ -+void xen_irq_lateeoi(unsigned int irq, unsigned int eoi_flags); -+/* Signal an event was spurious, i.e. there was no action resulting from it. */ -+#define XEN_EOI_FLAG_SPURIOUS 0x00000001 -+ - #define XEN_IRQ_PRIORITY_MAX EVTCHN_FIFO_PRIORITY_MAX - #define XEN_IRQ_PRIORITY_DEFAULT EVTCHN_FIFO_PRIORITY_DEFAULT - #define XEN_IRQ_PRIORITY_MIN EVTCHN_FIFO_PRIORITY_MIN -diff --git a/init/Kconfig b/init/Kconfig -index d6a0b31b13dc9..2a5df1cf838c6 100644 ---- a/init/Kconfig -+++ b/init/Kconfig -@@ -682,7 +682,8 @@ config IKHEADERS - - config LOG_BUF_SHIFT - int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" -- range 12 25 -+ range 12 25 if !H8300 -+ range 12 19 if H8300 - default 17 - depends on PRINTK - help -diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c -index 43cd175c66a55..718bbdc8b3c66 100644 ---- a/kernel/bpf/verifier.c -+++ b/kernel/bpf/verifier.c -@@ -5246,6 +5246,10 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, - dst, reg_type_str[ptr_reg->type]); - return -EACCES; - case CONST_PTR_TO_MAP: -+ /* smin_val represents the known value */ -+ if (known && smin_val == 0 && opcode == BPF_ADD) -+ break; -+ /* fall-through */ - case PTR_TO_PACKET_END: - case PTR_TO_SOCKET: - case PTR_TO_SOCKET_OR_NULL: -diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c -index b16dbc1bf0567..404d6d47a11da 100644 ---- a/kernel/debug/debug_core.c -+++ b/kernel/debug/debug_core.c -@@ -94,14 +94,6 @@ int dbg_switch_cpu; - /* Use kdb or gdbserver mode */ - int dbg_kdb_mode = 1; - --static int __init opt_kgdb_con(char *str) --{ -- kgdb_use_con = 1; -- return 0; --} -- --early_param("kgdbcon", opt_kgdb_con); -- - module_param(kgdb_use_con, int, 0644); - module_param(kgdbreboot, int, 0644); - -@@ -920,6 +912,20 @@ static struct console kgdbcons = { - .index = -1, - }; - -+static int __init opt_kgdb_con(char *str) -+{ -+ kgdb_use_con = 1; -+ -+ if (kgdb_io_module_registered && !kgdb_con_registered) { -+ register_console(&kgdbcons); -+ kgdb_con_registered = 1; -+ } -+ -+ return 0; -+} -+ -+early_param("kgdbcon", opt_kgdb_con); -+ - #ifdef CONFIG_MAGIC_SYSRQ - static void sysrq_handle_dbg(int key) - { -diff --git a/kernel/futex.c b/kernel/futex.c -index a5876694a60eb..044c1a4fbece0 100644 ---- a/kernel/futex.c -+++ b/kernel/futex.c -@@ -39,6 +39,7 @@ - #include - #include - #include -+#include - - #include - -@@ -1502,8 +1503,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ - */ - newval = FUTEX_WAITERS | task_pid_vnr(new_owner); - -- if (unlikely(should_fail_futex(true))) -+ if (unlikely(should_fail_futex(true))) { - ret = -EFAULT; -+ goto out_unlock; -+ } - - ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval); - if (!ret && (curval != uval)) { -@@ -3797,6 +3800,8 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, - t = timespec64_to_ktime(ts); - if (cmd == FUTEX_WAIT) - t = ktime_add_safe(ktime_get(), t); -+ else if (!(op & FUTEX_CLOCK_REALTIME)) -+ t = timens_ktime_to_host(CLOCK_MONOTONIC, t); - tp = &t; - } - /* -@@ -3989,6 +3994,8 @@ SYSCALL_DEFINE6(futex_time32, u32 __user *, uaddr, int, op, u32, val, - t = timespec64_to_ktime(ts); - if (cmd == FUTEX_WAIT) - t = ktime_add_safe(ktime_get(), t); -+ else if (!(op & FUTEX_CLOCK_REALTIME)) -+ t = timens_ktime_to_host(CLOCK_MONOTONIC, t); - tp = &t; - } - if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || -diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c -index 85d15f0362dc5..3eb35ad1b5241 100644 ---- a/kernel/locking/lockdep.c -+++ b/kernel/locking/lockdep.c -@@ -3681,7 +3681,7 @@ void lockdep_hardirqs_on_prepare(unsigned long ip) - if (unlikely(in_nmi())) - return; - -- if (unlikely(__this_cpu_read(lockdep_recursion))) -+ if (unlikely(this_cpu_read(lockdep_recursion))) - return; - - if (unlikely(lockdep_hardirqs_enabled())) { -@@ -3750,7 +3750,7 @@ void noinstr lockdep_hardirqs_on(unsigned long ip) - goto skip_checks; - } - -- if (unlikely(__this_cpu_read(lockdep_recursion))) -+ if (unlikely(this_cpu_read(lockdep_recursion))) - return; - - if (lockdep_hardirqs_enabled()) { -diff --git a/kernel/module.c b/kernel/module.c -index 8486123ffd7af..cc9281398f698 100644 ---- a/kernel/module.c -+++ b/kernel/module.c -@@ -4028,7 +4028,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) - { - struct load_info info = { }; - loff_t size; -- void *hdr; -+ void *hdr = NULL; - int err; - - err = may_init_module(); -diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h -index 05d3e1375e4ca..a443b25e12ed5 100644 ---- a/kernel/rcu/tasks.h -+++ b/kernel/rcu/tasks.h -@@ -821,6 +821,12 @@ static void trc_read_check_handler(void *t_in) - WRITE_ONCE(t->trc_reader_checked, true); - goto reset_ipi; - } -+ // If we are racing with an rcu_read_unlock_trace(), try again later. -+ if (unlikely(t->trc_reader_nesting < 0)) { -+ if (WARN_ON_ONCE(atomic_dec_and_test(&trc_n_readers_need_end))) -+ wake_up(&trc_wait); -+ goto reset_ipi; -+ } - WRITE_ONCE(t->trc_reader_checked, true); - - // Get here if the task is in a read-side critical section. Set -@@ -1072,15 +1078,17 @@ static void rcu_tasks_trace_postgp(struct rcu_tasks *rtp) - if (ret) - break; // Count reached zero. - // Stall warning time, so make a list of the offenders. -+ rcu_read_lock(); - for_each_process_thread(g, t) - if (READ_ONCE(t->trc_reader_special.b.need_qs)) - trc_add_holdout(t, &holdouts); -+ rcu_read_unlock(); - firstreport = true; -- list_for_each_entry_safe(t, g, &holdouts, trc_holdout_list) -- if (READ_ONCE(t->trc_reader_special.b.need_qs)) { -+ list_for_each_entry_safe(t, g, &holdouts, trc_holdout_list) { -+ if (READ_ONCE(t->trc_reader_special.b.need_qs)) - show_stalled_task_trace(t, &firstreport); -- trc_del_holdout(t); -- } -+ trc_del_holdout(t); // Release task_struct reference. -+ } - if (firstreport) - pr_err("INFO: rcu_tasks_trace detected stalls? (Counter/taskslist mismatch?)\n"); - show_stalled_ipi_trace(); -diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c -index 388a2ad292bf4..c8f62e2d02761 100644 ---- a/kernel/rcu/tree.c -+++ b/kernel/rcu/tree.c -@@ -416,7 +416,7 @@ bool rcu_eqs_special_set(int cpu) - * - * The caller must have disabled interrupts and must not be idle. - */ --void rcu_momentary_dyntick_idle(void) -+notrace void rcu_momentary_dyntick_idle(void) - { - int special; - -diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c -index e39008242cf4d..59d511e326730 100644 ---- a/kernel/sched/cpufreq_schedutil.c -+++ b/kernel/sched/cpufreq_schedutil.c -@@ -102,7 +102,8 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) - static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time, - unsigned int next_freq) - { -- if (sg_policy->next_freq == next_freq) -+ if (sg_policy->next_freq == next_freq && -+ !cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS)) - return false; - - sg_policy->next_freq = next_freq; -@@ -175,7 +176,8 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, - - freq = map_util_freq(util, freq, max); - -- if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) -+ if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update && -+ !cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS)) - return sg_policy->next_freq; - - sg_policy->need_freq_update = false; -diff --git a/kernel/seccomp.c b/kernel/seccomp.c -index 676d4af621038..c359ef4380ad8 100644 ---- a/kernel/seccomp.c -+++ b/kernel/seccomp.c -@@ -1472,13 +1472,7 @@ static const struct file_operations seccomp_notify_ops = { - - static struct file *init_listener(struct seccomp_filter *filter) - { -- struct file *ret = ERR_PTR(-EBUSY); -- struct seccomp_filter *cur; -- -- for (cur = current->seccomp.filter; cur; cur = cur->prev) { -- if (cur->notif) -- goto out; -- } -+ struct file *ret; - - ret = ERR_PTR(-ENOMEM); - filter->notif = kzalloc(sizeof(*(filter->notif)), GFP_KERNEL); -@@ -1504,6 +1498,31 @@ out: - return ret; - } - -+/* -+ * Does @new_child have a listener while an ancestor also has a listener? -+ * If so, we'll want to reject this filter. -+ * This only has to be tested for the current process, even in the TSYNC case, -+ * because TSYNC installs @child with the same parent on all threads. -+ * Note that @new_child is not hooked up to its parent at this point yet, so -+ * we use current->seccomp.filter. -+ */ -+static bool has_duplicate_listener(struct seccomp_filter *new_child) -+{ -+ struct seccomp_filter *cur; -+ -+ /* must be protected against concurrent TSYNC */ -+ lockdep_assert_held(¤t->sighand->siglock); -+ -+ if (!new_child->notif) -+ return false; -+ for (cur = current->seccomp.filter; cur; cur = cur->prev) { -+ if (cur->notif) -+ return true; -+ } -+ -+ return false; -+} -+ - /** - * seccomp_set_mode_filter: internal function for setting seccomp filter - * @flags: flags to change filter behavior -@@ -1575,6 +1594,11 @@ static long seccomp_set_mode_filter(unsigned int flags, - if (!seccomp_may_assign_mode(seccomp_mode)) - goto out; - -+ if (has_duplicate_listener(prepared)) { -+ ret = -EBUSY; -+ goto out; -+ } -+ - ret = seccomp_attach_filter(flags, prepared); - if (ret) - goto out; -diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c -index 865bb0228ab66..890b79cf0e7c3 100644 ---- a/kernel/stop_machine.c -+++ b/kernel/stop_machine.c -@@ -178,7 +178,7 @@ static void ack_state(struct multi_stop_data *msdata) - set_state(msdata, msdata->state + 1); - } - --void __weak stop_machine_yield(const struct cpumask *cpumask) -+notrace void __weak stop_machine_yield(const struct cpumask *cpumask) - { - cpu_relax(); - } -diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c -index ca4e6d57d68b9..00629e658ca19 100644 ---- a/kernel/time/itimer.c -+++ b/kernel/time/itimer.c -@@ -172,10 +172,6 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, - u64 oval, nval, ointerval, ninterval; - struct cpu_itimer *it = &tsk->signal->it[clock_id]; - -- /* -- * Use the to_ktime conversion because that clamps the maximum -- * value to KTIME_MAX and avoid multiplication overflows. -- */ - nval = timespec64_to_ns(&value->it_value); - ninterval = timespec64_to_ns(&value->it_interval); - -diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c -index 1c03eec6ca9b9..4b7bdd7a5f27c 100644 ---- a/kernel/time/sched_clock.c -+++ b/kernel/time/sched_clock.c -@@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift) - return (cyc * mult) >> shift; - } - --struct clock_read_data *sched_clock_read_begin(unsigned int *seq) -+notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq) - { - *seq = raw_read_seqcount_latch(&cd.seq); - return cd.read_data + (*seq & 1); - } - --int sched_clock_read_retry(unsigned int seq) -+notrace int sched_clock_read_retry(unsigned int seq) - { - return read_seqcount_retry(&cd.seq, seq); - } -diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c -index 93ef0ab6ea201..5c6a9c6a058fa 100644 ---- a/kernel/trace/ring_buffer.c -+++ b/kernel/trace/ring_buffer.c -@@ -1952,18 +1952,18 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, - { - struct ring_buffer_per_cpu *cpu_buffer; - unsigned long nr_pages; -- int cpu, err = 0; -+ int cpu, err; - - /* - * Always succeed at resizing a non-existent buffer: - */ - if (!buffer) -- return size; -+ return 0; - - /* Make sure the requested buffer exists */ - if (cpu_id != RING_BUFFER_ALL_CPUS && - !cpumask_test_cpu(cpu_id, buffer->cpumask)) -- return size; -+ return 0; - - nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE); - -@@ -2119,7 +2119,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, - } - - mutex_unlock(&buffer->mutex); -- return size; -+ return 0; - - out_err: - for_each_buffer_cpu(buffer, cpu) { -@@ -4866,6 +4866,9 @@ void ring_buffer_reset_cpu(struct trace_buffer *buffer, int cpu) - if (!cpumask_test_cpu(cpu, buffer->cpumask)) - return; - -+ /* prevent another thread from changing buffer sizes */ -+ mutex_lock(&buffer->mutex); -+ - atomic_inc(&cpu_buffer->resize_disabled); - atomic_inc(&cpu_buffer->record_disabled); - -@@ -4876,6 +4879,8 @@ void ring_buffer_reset_cpu(struct trace_buffer *buffer, int cpu) - - atomic_dec(&cpu_buffer->record_disabled); - atomic_dec(&cpu_buffer->resize_disabled); -+ -+ mutex_unlock(&buffer->mutex); - } - EXPORT_SYMBOL_GPL(ring_buffer_reset_cpu); - -@@ -4889,6 +4894,9 @@ void ring_buffer_reset_online_cpus(struct trace_buffer *buffer) - struct ring_buffer_per_cpu *cpu_buffer; - int cpu; - -+ /* prevent another thread from changing buffer sizes */ -+ mutex_lock(&buffer->mutex); -+ - for_each_online_buffer_cpu(buffer, cpu) { - cpu_buffer = buffer->buffers[cpu]; - -@@ -4907,6 +4915,8 @@ void ring_buffer_reset_online_cpus(struct trace_buffer *buffer) - atomic_dec(&cpu_buffer->record_disabled); - atomic_dec(&cpu_buffer->resize_disabled); - } -+ -+ mutex_unlock(&buffer->mutex); - } - - /** -diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c -index c8892156db341..65e8c27141c02 100644 ---- a/kernel/trace/trace_events_synth.c -+++ b/kernel/trace/trace_events_synth.c -@@ -465,6 +465,7 @@ static struct synth_field *parse_synth_field(int argc, const char **argv, - struct synth_field *field; - const char *prefix = NULL, *field_type = argv[0], *field_name, *array; - int len, ret = 0; -+ struct seq_buf s; - ssize_t size; - - if (field_type[0] == ';') -@@ -503,13 +504,9 @@ static struct synth_field *parse_synth_field(int argc, const char **argv, - field_type++; - len = strlen(field_type) + 1; - -- if (array) { -- int l = strlen(array); -+ if (array) -+ len += strlen(array); - -- if (l && array[l - 1] == ';') -- l--; -- len += l; -- } - if (prefix) - len += strlen(prefix); - -@@ -518,14 +515,18 @@ static struct synth_field *parse_synth_field(int argc, const char **argv, - ret = -ENOMEM; - goto free; - } -+ seq_buf_init(&s, field->type, len); - if (prefix) -- strcat(field->type, prefix); -- strcat(field->type, field_type); -+ seq_buf_puts(&s, prefix); -+ seq_buf_puts(&s, field_type); - if (array) { -- strcat(field->type, array); -- if (field->type[len - 1] == ';') -- field->type[len - 1] = '\0'; -+ seq_buf_puts(&s, array); -+ if (s.buffer[s.len - 1] == ';') -+ s.len--; - } -+ if (WARN_ON_ONCE(!seq_buf_buffer_left(&s))) -+ goto free; -+ s.buffer[s.len] = '\0'; - - size = synth_field_size(field->type); - if (size <= 0) { -diff --git a/lib/scatterlist.c b/lib/scatterlist.c -index 5d63a8857f361..c448642e0f786 100644 ---- a/lib/scatterlist.c -+++ b/lib/scatterlist.c -@@ -514,7 +514,7 @@ struct scatterlist *sgl_alloc_order(unsigned long long length, - elem_len = min_t(u64, length, PAGE_SIZE << order); - page = alloc_pages(gfp, order); - if (!page) { -- sgl_free(sgl); -+ sgl_free_order(sgl, order); - return NULL; - } - -diff --git a/mm/slab.c b/mm/slab.c -index f658e86ec8cee..5c70600d8b1cc 100644 ---- a/mm/slab.c -+++ b/mm/slab.c -@@ -3440,7 +3440,7 @@ void ___cache_free(struct kmem_cache *cachep, void *objp, - memset(objp, 0, cachep->object_size); - kmemleak_free_recursive(objp, cachep->flags); - objp = cache_free_debugcheck(cachep, objp, caller); -- memcg_slab_free_hook(cachep, virt_to_head_page(objp), objp); -+ memcg_slab_free_hook(cachep, &objp, 1); - - /* - * Skip calling cache_free_alien() when the platform is not numa. -diff --git a/mm/slab.h b/mm/slab.h -index 6cc323f1313af..6dd4b702888a7 100644 ---- a/mm/slab.h -+++ b/mm/slab.h -@@ -345,30 +345,42 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, - obj_cgroup_put(objcg); - } - --static inline void memcg_slab_free_hook(struct kmem_cache *s, struct page *page, -- void *p) -+static inline void memcg_slab_free_hook(struct kmem_cache *s_orig, -+ void **p, int objects) - { -+ struct kmem_cache *s; - struct obj_cgroup *objcg; -+ struct page *page; - unsigned int off; -+ int i; - - if (!memcg_kmem_enabled()) - return; - -- if (!page_has_obj_cgroups(page)) -- return; -+ for (i = 0; i < objects; i++) { -+ if (unlikely(!p[i])) -+ continue; - -- off = obj_to_index(s, page, p); -- objcg = page_obj_cgroups(page)[off]; -- page_obj_cgroups(page)[off] = NULL; -+ page = virt_to_head_page(p[i]); -+ if (!page_has_obj_cgroups(page)) -+ continue; - -- if (!objcg) -- return; -+ if (!s_orig) -+ s = page->slab_cache; -+ else -+ s = s_orig; - -- obj_cgroup_uncharge(objcg, obj_full_size(s)); -- mod_objcg_state(objcg, page_pgdat(page), cache_vmstat_idx(s), -- -obj_full_size(s)); -+ off = obj_to_index(s, page, p[i]); -+ objcg = page_obj_cgroups(page)[off]; -+ if (!objcg) -+ continue; - -- obj_cgroup_put(objcg); -+ page_obj_cgroups(page)[off] = NULL; -+ obj_cgroup_uncharge(objcg, obj_full_size(s)); -+ mod_objcg_state(objcg, page_pgdat(page), cache_vmstat_idx(s), -+ -obj_full_size(s)); -+ obj_cgroup_put(objcg); -+ } - } - - #else /* CONFIG_MEMCG_KMEM */ -@@ -406,8 +418,8 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, - { - } - --static inline void memcg_slab_free_hook(struct kmem_cache *s, struct page *page, -- void *p) -+static inline void memcg_slab_free_hook(struct kmem_cache *s, -+ void **p, int objects) - { - } - #endif /* CONFIG_MEMCG_KMEM */ -diff --git a/mm/slub.c b/mm/slub.c -index 6d3574013b2f8..0cbe67f13946e 100644 ---- a/mm/slub.c -+++ b/mm/slub.c -@@ -3091,7 +3091,7 @@ static __always_inline void do_slab_free(struct kmem_cache *s, - struct kmem_cache_cpu *c; - unsigned long tid; - -- memcg_slab_free_hook(s, page, head); -+ memcg_slab_free_hook(s, &head, 1); - redo: - /* - * Determine the currently cpus per cpu slab. -@@ -3253,6 +3253,7 @@ void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p) - if (WARN_ON(!size)) - return; - -+ memcg_slab_free_hook(s, p, size); - do { - struct detached_freelist df; - -diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c -index c0762a302162c..8f528e783a6c5 100644 ---- a/net/9p/trans_fd.c -+++ b/net/9p/trans_fd.c -@@ -1023,7 +1023,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) - - csocket = NULL; - -- if (addr == NULL) -+ if (!addr || !strlen(addr)) - return -EINVAL; - - if (strlen(addr) >= UNIX_PATH_MAX) { -diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c -index d4d7a0e524910..9d4a21b819c19 100644 ---- a/net/ceph/messenger.c -+++ b/net/ceph/messenger.c -@@ -2998,6 +2998,11 @@ static void con_fault(struct ceph_connection *con) - ceph_msg_put(con->in_msg); - con->in_msg = NULL; - } -+ if (con->out_msg) { -+ BUG_ON(con->out_msg->con != con); -+ ceph_msg_put(con->out_msg); -+ con->out_msg = NULL; -+ } - - /* Requeue anything that hasn't been acked */ - list_splice_init(&con->out_sent, &con->out_queue); -diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c -index dca01d7e6e3e0..282b0bc201eeb 100644 ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -4209,6 +4209,12 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata, - if (is_zero_ether_addr(ra)) - goto out_free; - -+ if (local->ops->wake_tx_queue) { -+ u16 queue = __ieee80211_select_queue(sdata, sta, skb); -+ skb_set_queue_mapping(skb, queue); -+ skb_get_hash(skb); -+ } -+ - multicast = is_multicast_ether_addr(ra); - - if (sta) -diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c -index 999eee1ed61c9..e81a28f30f1d2 100644 ---- a/net/sunrpc/sysctl.c -+++ b/net/sunrpc/sysctl.c -@@ -70,7 +70,13 @@ static int proc_do_xprt(struct ctl_table *table, int write, - return 0; - } - len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); -- return memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); -+ *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); -+ -+ if (*lenp < 0) { -+ *lenp = 0; -+ return -EINVAL; -+ } -+ return 0; - } - - static int -diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c -index 5a8e47bbfb9f4..13fbc2dd4196a 100644 ---- a/net/sunrpc/xprt.c -+++ b/net/sunrpc/xprt.c -@@ -1520,10 +1520,13 @@ xprt_transmit(struct rpc_task *task) - { - struct rpc_rqst *next, *req = task->tk_rqstp; - struct rpc_xprt *xprt = req->rq_xprt; -- int status; -+ int counter, status; - - spin_lock(&xprt->queue_lock); -+ counter = 0; - while (!list_empty(&xprt->xmit_queue)) { -+ if (++counter == 20) -+ break; - next = list_first_entry(&xprt->xmit_queue, - struct rpc_rqst, rq_xmit); - xprt_pin_rqst(next); -@@ -1531,7 +1534,6 @@ xprt_transmit(struct rpc_task *task) - status = xprt_request_transmit(next, task); - if (status == -EBADMSG && next != req) - status = 0; -- cond_resched(); - spin_lock(&xprt->queue_lock); - xprt_unpin_rqst(next); - if (status == 0) { -diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c -index c821e98671393..63a9a2a39da7b 100644 ---- a/samples/bpf/xdpsock_user.c -+++ b/samples/bpf/xdpsock_user.c -@@ -1111,6 +1111,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds) - while (ret != rcvd) { - if (ret < 0) - exit_with_error(-ret); -+ complete_tx_l2fwd(xsk, fds); - if (xsk_ring_prod__needs_wakeup(&xsk->tx)) - kick_tx(xsk); - ret = xsk_ring_prod__reserve(&xsk->tx, rcvd, &idx_tx); -diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c -index e9cbadade74bd..ac02b7632353e 100644 ---- a/security/integrity/digsig.c -+++ b/security/integrity/digsig.c -@@ -169,7 +169,7 @@ int __init integrity_add_key(const unsigned int id, const void *data, - - int __init integrity_load_x509(const unsigned int id, const char *path) - { -- void *data; -+ void *data = NULL; - loff_t size; - int rc; - key_perm_t perm; -diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c -index e3fcad871861a..15a44c5022f77 100644 ---- a/security/integrity/ima/ima_fs.c -+++ b/security/integrity/ima/ima_fs.c -@@ -272,7 +272,7 @@ static const struct file_operations ima_ascii_measurements_ops = { - - static ssize_t ima_read_policy(char *path) - { -- void *data; -+ void *data = NULL; - char *datap; - loff_t size; - int rc, pathlen = strlen(path); -diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c -index 4c86cd4eece0c..e22caa833b7d9 100644 ---- a/security/integrity/ima/ima_main.c -+++ b/security/integrity/ima/ima_main.c -@@ -621,19 +621,17 @@ void ima_post_path_mknod(struct dentry *dentry) - int ima_read_file(struct file *file, enum kernel_read_file_id read_id) - { - /* -- * READING_FIRMWARE_PREALLOC_BUFFER -- * - * Do devices using pre-allocated memory run the risk of the - * firmware being accessible to the device prior to the completion - * of IMA's signature verification any more than when using two -- * buffers? -+ * buffers? It may be desirable to include the buffer address -+ * in this API and walk all the dma_map_single() mappings to check. - */ - return 0; - } - - const int read_idmap[READING_MAX_ID] = { - [READING_FIRMWARE] = FIRMWARE_CHECK, -- [READING_FIRMWARE_PREALLOC_BUFFER] = FIRMWARE_CHECK, - [READING_MODULE] = MODULE_CHECK, - [READING_KEXEC_IMAGE] = KEXEC_KERNEL_CHECK, - [READING_KEXEC_INITRAMFS] = KEXEC_INITRAMFS_CHECK, -diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h -index b0e02cfe3ce14..8a432f646967e 100644 ---- a/security/selinux/include/security.h -+++ b/security/selinux/include/security.h -@@ -177,49 +177,49 @@ static inline bool selinux_policycap_netpeer(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_NETPEER]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_NETPEER]); - } - - static inline bool selinux_policycap_openperm(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_OPENPERM]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_OPENPERM]); - } - - static inline bool selinux_policycap_extsockclass(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_EXTSOCKCLASS]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_EXTSOCKCLASS]); - } - - static inline bool selinux_policycap_alwaysnetwork(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_ALWAYSNETWORK]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_ALWAYSNETWORK]); - } - - static inline bool selinux_policycap_cgroupseclabel(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_CGROUPSECLABEL]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_CGROUPSECLABEL]); - } - - static inline bool selinux_policycap_nnp_nosuid_transition(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_NNP_NOSUID_TRANSITION]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_NNP_NOSUID_TRANSITION]); - } - - static inline bool selinux_policycap_genfs_seclabel_symlinks(void) - { - struct selinux_state *state = &selinux_state; - -- return state->policycap[POLICYDB_CAPABILITY_GENFS_SECLABEL_SYMLINKS]; -+ return READ_ONCE(state->policycap[POLICYDB_CAPABILITY_GENFS_SECLABEL_SYMLINKS]); - } - - int security_mls_enabled(struct selinux_state *state); -diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c -index 1caf4e6033096..c55b3063753ab 100644 ---- a/security/selinux/ss/services.c -+++ b/security/selinux/ss/services.c -@@ -2103,7 +2103,8 @@ static void security_load_policycaps(struct selinux_state *state) - struct ebitmap_node *node; - - for (i = 0; i < ARRAY_SIZE(state->policycap); i++) -- state->policycap[i] = ebitmap_get_bit(&p->policycaps, i); -+ WRITE_ONCE(state->policycap[i], -+ ebitmap_get_bit(&p->policycaps, i)); - - for (i = 0; i < ARRAY_SIZE(selinux_policycap_names); i++) - pr_info("SELinux: policy capability %s=%d\n", -diff --git a/sound/soc/amd/acp3x-rt5682-max9836.c b/sound/soc/amd/acp3x-rt5682-max9836.c -index 406526e79af34..1a4e8ca0f99c2 100644 ---- a/sound/soc/amd/acp3x-rt5682-max9836.c -+++ b/sound/soc/amd/acp3x-rt5682-max9836.c -@@ -472,12 +472,17 @@ static int acp3x_probe(struct platform_device *pdev) - - ret = devm_snd_soc_register_card(&pdev->dev, card); - if (ret) { -- dev_err(&pdev->dev, -+ if (ret != -EPROBE_DEFER) -+ dev_err(&pdev->dev, - "devm_snd_soc_register_card(%s) failed: %d\n", - card->name, ret); -- return ret; -+ else -+ dev_dbg(&pdev->dev, -+ "devm_snd_soc_register_card(%s) probe deferred: %d\n", -+ card->name, ret); - } -- return 0; -+ -+ return ret; - } - - static const struct acpi_device_id acp3x_audio_acpi_match[] = { -diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c -index 2c5c451fa19d7..c475955c6eeba 100644 ---- a/sound/soc/sof/intel/hda-codec.c -+++ b/sound/soc/sof/intel/hda-codec.c -@@ -151,7 +151,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, - if (!hdev->bus->audio_component) { - dev_dbg(sdev->dev, - "iDisp hw present but no driver\n"); -- return -ENOENT; -+ goto error; - } - hda_priv->need_display_power = true; - } -@@ -174,7 +174,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, - * other return codes without modification - */ - if (ret == 0) -- ret = -ENOENT; -+ goto error; - } - - return ret; -diff --git a/tools/perf/pmu-events/arch/x86/amdzen1/cache.json b/tools/perf/pmu-events/arch/x86/amdzen1/cache.json -index 404d4c569c01e..695ed3ffa3a6d 100644 ---- a/tools/perf/pmu-events/arch/x86/amdzen1/cache.json -+++ b/tools/perf/pmu-events/arch/x86/amdzen1/cache.json -@@ -249,6 +249,24 @@ - "BriefDescription": "Cycles with fill pending from L2. Total cycles spent with one or more fill requests in flight from L2.", - "UMask": "0x1" - }, -+ { -+ "EventName": "l2_pf_hit_l2", -+ "EventCode": "0x70", -+ "BriefDescription": "L2 prefetch hit in L2.", -+ "UMask": "0xff" -+ }, -+ { -+ "EventName": "l2_pf_miss_l2_hit_l3", -+ "EventCode": "0x71", -+ "BriefDescription": "L2 prefetcher hits in L3. Counts all L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit the L3.", -+ "UMask": "0xff" -+ }, -+ { -+ "EventName": "l2_pf_miss_l2_l3", -+ "EventCode": "0x72", -+ "BriefDescription": "L2 prefetcher misses in L3. All L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches.", -+ "UMask": "0xff" -+ }, - { - "EventName": "l3_request_g1.caching_l3_cache_accesses", - "EventCode": "0x01", -diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c -index 599a1543871de..13fdc51c61d96 100644 ---- a/tools/perf/util/print_binary.c -+++ b/tools/perf/util/print_binary.c -@@ -50,7 +50,7 @@ int is_printable_array(char *p, unsigned int len) - - len--; - -- for (i = 0; i < len; i++) { -+ for (i = 0; i < len && p[i]; i++) { - if (!isprint(p[i]) && !isspace(p[i])) - return 0; - } -diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c -index 50525235380e8..5489823c83fc2 100644 ---- a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c -+++ b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c -@@ -19,11 +19,11 @@ - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - #endif - -+const char tcp_mem_name[] = "net/ipv4/tcp_mem"; - static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx) - { -- char tcp_mem_name[] = "net/ipv4/tcp_mem"; - unsigned char i; -- char name[64]; -+ char name[sizeof(tcp_mem_name)]; - int ret; - - memset(name, 0, sizeof(name)); -diff --git a/tools/testing/selftests/powerpc/utils.c b/tools/testing/selftests/powerpc/utils.c -index 18b6a773d5c73..638ffacc90aa1 100644 ---- a/tools/testing/selftests/powerpc/utils.c -+++ b/tools/testing/selftests/powerpc/utils.c -@@ -318,7 +318,9 @@ int using_hash_mmu(bool *using_hash) - - rc = 0; - while (fgets(line, sizeof(line), f) != NULL) { -- if (strcmp(line, "MMU : Hash\n") == 0) { -+ if (!strcmp(line, "MMU : Hash\n") || -+ !strcmp(line, "platform : Cell\n") || -+ !strcmp(line, "platform : PowerMac\n")) { - *using_hash = true; - goto out; - } -diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c -index 9983195535237..7161cfc2e60b4 100644 ---- a/tools/testing/selftests/x86/fsgsbase.c -+++ b/tools/testing/selftests/x86/fsgsbase.c -@@ -443,6 +443,68 @@ static void test_unexpected_base(void) - - #define USER_REGS_OFFSET(r) offsetof(struct user_regs_struct, r) - -+static void test_ptrace_write_gs_read_base(void) -+{ -+ int status; -+ pid_t child = fork(); -+ -+ if (child < 0) -+ err(1, "fork"); -+ -+ if (child == 0) { -+ printf("[RUN]\tPTRACE_POKE GS, read GSBASE back\n"); -+ -+ printf("[RUN]\tARCH_SET_GS to 1\n"); -+ if (syscall(SYS_arch_prctl, ARCH_SET_GS, 1) != 0) -+ err(1, "ARCH_SET_GS"); -+ -+ if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) != 0) -+ err(1, "PTRACE_TRACEME"); -+ -+ raise(SIGTRAP); -+ _exit(0); -+ } -+ -+ wait(&status); -+ -+ if (WSTOPSIG(status) == SIGTRAP) { -+ unsigned long base; -+ unsigned long gs_offset = USER_REGS_OFFSET(gs); -+ unsigned long base_offset = USER_REGS_OFFSET(gs_base); -+ -+ /* Read the initial base. It should be 1. */ -+ base = ptrace(PTRACE_PEEKUSER, child, base_offset, NULL); -+ if (base == 1) { -+ printf("[OK]\tGSBASE started at 1\n"); -+ } else { -+ nerrs++; -+ printf("[FAIL]\tGSBASE started at 0x%lx\n", base); -+ } -+ -+ printf("[RUN]\tSet GS = 0x7, read GSBASE\n"); -+ -+ /* Poke an LDT selector into GS. */ -+ if (ptrace(PTRACE_POKEUSER, child, gs_offset, 0x7) != 0) -+ err(1, "PTRACE_POKEUSER"); -+ -+ /* And read the base. */ -+ base = ptrace(PTRACE_PEEKUSER, child, base_offset, NULL); -+ -+ if (base == 0 || base == 1) { -+ printf("[OK]\tGSBASE reads as 0x%lx with invalid GS\n", base); -+ } else { -+ nerrs++; -+ printf("[FAIL]\tGSBASE=0x%lx (should be 0 or 1)\n", base); -+ } -+ } -+ -+ ptrace(PTRACE_CONT, child, NULL, NULL); -+ -+ wait(&status); -+ if (!WIFEXITED(status)) -+ printf("[WARN]\tChild didn't exit cleanly.\n"); -+} -+ - static void test_ptrace_write_gsbase(void) - { - int status; -@@ -517,6 +579,9 @@ static void test_ptrace_write_gsbase(void) - - END: - ptrace(PTRACE_CONT, child, NULL, NULL); -+ wait(&status); -+ if (!WIFEXITED(status)) -+ printf("[WARN]\tChild didn't exit cleanly.\n"); - } - - int main() -@@ -526,6 +591,9 @@ int main() - shared_scratch = mmap(NULL, 4096, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_SHARED, -1, 0); - -+ /* Do these tests before we have an LDT. */ -+ test_ptrace_write_gs_read_base(); -+ - /* Probe FSGSBASE */ - sethandler(SIGILL, sigill, 0); - if (sigsetjmp(jmpbuf, 1) == 0) { diff --git a/patch/misc/general-packaging-4.4.y-rk3399.patch b/patch/misc/general-packaging-4.4.y-rk3399.patch index 7477281e6..0f61efa4d 100644 --- a/patch/misc/general-packaging-4.4.y-rk3399.patch +++ b/patch/misc/general-packaging-4.4.y-rk3399.patch @@ -141,7 +141,7 @@ index 6c3b038e..f4166fbe 100755 + +for file in /dev/* ; do + CURRENT_DEVICE=\$(printf "%d:%d" \$(stat --printf="0x%t 0x%T" \$file)) -+ if [[ "\$CURRENT_DEVICE" = "\$boot_device" ]]; then ++ if [ "\$CURRENT_DEVICE" = "\$boot_device" ]; then + boot_partition=\$file + break; + fi diff --git a/patch/u-boot/u-boot-rockchip64/add_fdtfile_dt_overlays.patch b/patch/u-boot/u-boot-rockchip64/add_fdtfile_dt_overlays.patch index 1770c52e1..3cb7ab101 100644 --- a/patch/u-boot/u-boot-rockchip64/add_fdtfile_dt_overlays.patch +++ b/patch/u-boot/u-boot-rockchip64/add_fdtfile_dt_overlays.patch @@ -12,20 +12,21 @@ index 84462f3..3291f9f select ENABLE_ARM_SOC_BOOT0_HOOK imply CMD_FASTBOOT diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h -index 513237e..a1bcebd +index 6be9ad7..f553425 100644 --- a/include/configs/rk3328_common.h +++ b/include/configs/rk3328_common.h -@@ -73,12 +73,13 @@ - "fdt_addr_r=0x01f00000\0" \ - "kernel_addr_r=0x02000000\0" \ - "ramdisk_addr_r=0x04000000\0" +@@ -57,6 +57,7 @@ + "fdt_addr_r=0x08300000\0" \ + "kernel_addr_r=0x00280000\0" \ + "ramdisk_addr_r=0x0a200000\0" +#define FDTFILE "rockchip/" CONFIG_DEFAULT_DEVICE_TREE ".dtb" #include #define CONFIG_EXTRA_ENV_SETTINGS \ - ENV_MEM_LAYOUT_SETTINGS \ -- "fdtfile=" FDTFILE \ +@@ -64,6 +65,7 @@ + RKIMG_DET_BOOTDEV \ "partitions=" PARTS_DEFAULT \ + ROCKCHIP_DEVICE_SETTINGS \ + "fdtfile=" FDTFILE "\0" \ BOOTENV