summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--1005_linux-5.7.6.patch20870
-rw-r--r--1005_linux-5.8.6.patch11789
2 files changed, 11789 insertions, 20870 deletions
diff --git a/1005_linux-5.7.6.patch b/1005_linux-5.7.6.patch
deleted file mode 100644
index 9939e08b..00000000
--- a/1005_linux-5.7.6.patch
+++ /dev/null
@@ -1,20870 +0,0 @@
-diff --git a/Makefile b/Makefile
-index c48d489f82bc..f928cd1dfdc1 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1,7 +1,7 @@
- # SPDX-License-Identifier: GPL-2.0
- VERSION = 5
- PATCHLEVEL = 7
--SUBLEVEL = 5
-+SUBLEVEL = 6
- EXTRAVERSION =
- NAME = Kleptomaniac Octopus
-
-diff --git a/arch/arm/boot/dts/aspeed-bmc-facebook-tiogapass.dts b/arch/arm/boot/dts/aspeed-bmc-facebook-tiogapass.dts
-index 5d7cbd9164d4..669980c690f9 100644
---- a/arch/arm/boot/dts/aspeed-bmc-facebook-tiogapass.dts
-+++ b/arch/arm/boot/dts/aspeed-bmc-facebook-tiogapass.dts
-@@ -112,13 +112,13 @@
- &kcs2 {
- // BMC KCS channel 2
- status = "okay";
-- kcs_addr = <0xca8>;
-+ aspeed,lpc-io-reg = <0xca8>;
- };
-
- &kcs3 {
- // BMC KCS channel 3
- status = "okay";
-- kcs_addr = <0xca2>;
-+ aspeed,lpc-io-reg = <0xca2>;
- };
-
- &mac0 {
-diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi
-index f12ec04d3cbc..bc92d3db7b78 100644
---- a/arch/arm/boot/dts/aspeed-g5.dtsi
-+++ b/arch/arm/boot/dts/aspeed-g5.dtsi
-@@ -426,22 +426,22 @@
- #size-cells = <1>;
- ranges = <0x0 0x0 0x80>;
-
-- kcs1: kcs1@0 {
-- compatible = "aspeed,ast2500-kcs-bmc";
-+ kcs1: kcs@24 {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x24 0x1>, <0x30 0x1>, <0x3c 0x1>;
- interrupts = <8>;
-- kcs_chan = <1>;
- status = "disabled";
- };
-- kcs2: kcs2@0 {
-- compatible = "aspeed,ast2500-kcs-bmc";
-+ kcs2: kcs@28 {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x28 0x1>, <0x34 0x1>, <0x40 0x1>;
- interrupts = <8>;
-- kcs_chan = <2>;
- status = "disabled";
- };
-- kcs3: kcs3@0 {
-- compatible = "aspeed,ast2500-kcs-bmc";
-+ kcs3: kcs@2c {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x2c 0x1>, <0x38 0x1>, <0x44 0x1>;
- interrupts = <8>;
-- kcs_chan = <3>;
- status = "disabled";
- };
- };
-@@ -455,10 +455,10 @@
- #size-cells = <1>;
- ranges = <0x0 0x80 0x1e0>;
-
-- kcs4: kcs4@0 {
-- compatible = "aspeed,ast2500-kcs-bmc";
-+ kcs4: kcs@94 {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x94 0x1>, <0x98 0x1>, <0x9c 0x1>;
- interrupts = <8>;
-- kcs_chan = <4>;
- status = "disabled";
- };
-
-diff --git a/arch/arm/boot/dts/aspeed-g6.dtsi b/arch/arm/boot/dts/aspeed-g6.dtsi
-index 0a29b3b57a9d..a2d2ac720a51 100644
---- a/arch/arm/boot/dts/aspeed-g6.dtsi
-+++ b/arch/arm/boot/dts/aspeed-g6.dtsi
-@@ -65,6 +65,7 @@
- <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
- clocks = <&syscon ASPEED_CLK_HPLL>;
- arm,cpu-registers-not-fw-configured;
-+ always-on;
- };
-
- ahb {
-@@ -368,6 +369,7 @@
- <&gic GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
- clocks = <&syscon ASPEED_CLK_APB1>;
- clock-names = "PCLK";
-+ status = "disabled";
- };
-
- uart1: serial@1e783000 {
-@@ -433,22 +435,23 @@
- #size-cells = <1>;
- ranges = <0x0 0x0 0x80>;
-
-- kcs1: kcs1@0 {
-- compatible = "aspeed,ast2600-kcs-bmc";
-+ kcs1: kcs@24 {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x24 0x1>, <0x30 0x1>, <0x3c 0x1>;
- interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>;
- kcs_chan = <1>;
- status = "disabled";
- };
-- kcs2: kcs2@0 {
-- compatible = "aspeed,ast2600-kcs-bmc";
-+ kcs2: kcs@28 {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x28 0x1>, <0x34 0x1>, <0x40 0x1>;
- interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
-- kcs_chan = <2>;
- status = "disabled";
- };
-- kcs3: kcs3@0 {
-- compatible = "aspeed,ast2600-kcs-bmc";
-+ kcs3: kcs@2c {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x2c 0x1>, <0x38 0x1>, <0x44 0x1>;
- interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
-- kcs_chan = <3>;
- status = "disabled";
- };
- };
-@@ -462,10 +465,10 @@
- #size-cells = <1>;
- ranges = <0x0 0x80 0x1e0>;
-
-- kcs4: kcs4@0 {
-- compatible = "aspeed,ast2600-kcs-bmc";
-+ kcs4: kcs@94 {
-+ compatible = "aspeed,ast2500-kcs-bmc-v2";
-+ reg = <0x94 0x1>, <0x98 0x1>, <0x9c 0x1>;
- interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>;
-- kcs_chan = <4>;
- status = "disabled";
- };
-
-diff --git a/arch/arm/boot/dts/bcm2835-common.dtsi b/arch/arm/boot/dts/bcm2835-common.dtsi
-index 2b1d9d4c0cde..4119271c979d 100644
---- a/arch/arm/boot/dts/bcm2835-common.dtsi
-+++ b/arch/arm/boot/dts/bcm2835-common.dtsi
-@@ -130,7 +130,6 @@
- compatible = "brcm,bcm2835-v3d";
- reg = <0x7ec00000 0x1000>;
- interrupts = <1 10>;
-- power-domains = <&pm BCM2835_POWER_DOMAIN_GRAFX_V3D>;
- };
-
- vc4: gpu {
-diff --git a/arch/arm/boot/dts/bcm2835-rpi-common.dtsi b/arch/arm/boot/dts/bcm2835-rpi-common.dtsi
-new file mode 100644
-index 000000000000..8a55b6cded59
---- /dev/null
-+++ b/arch/arm/boot/dts/bcm2835-rpi-common.dtsi
-@@ -0,0 +1,12 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * This include file covers the common peripherals and configuration between
-+ * bcm2835, bcm2836 and bcm2837 implementations that interact with RPi's
-+ * firmware interface.
-+ */
-+
-+#include <dt-bindings/power/raspberrypi-power.h>
-+
-+&v3d {
-+ power-domains = <&power RPI_POWER_DOMAIN_V3D>;
-+};
-diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi
-index 53bf4579cc22..0549686134ea 100644
---- a/arch/arm/boot/dts/bcm2835.dtsi
-+++ b/arch/arm/boot/dts/bcm2835.dtsi
-@@ -1,6 +1,7 @@
- // SPDX-License-Identifier: GPL-2.0
- #include "bcm283x.dtsi"
- #include "bcm2835-common.dtsi"
-+#include "bcm2835-rpi-common.dtsi"
-
- / {
- compatible = "brcm,bcm2835";
-diff --git a/arch/arm/boot/dts/bcm2836.dtsi b/arch/arm/boot/dts/bcm2836.dtsi
-index 82d6c4662ae4..b390006aef79 100644
---- a/arch/arm/boot/dts/bcm2836.dtsi
-+++ b/arch/arm/boot/dts/bcm2836.dtsi
-@@ -1,6 +1,7 @@
- // SPDX-License-Identifier: GPL-2.0
- #include "bcm283x.dtsi"
- #include "bcm2835-common.dtsi"
-+#include "bcm2835-rpi-common.dtsi"
-
- / {
- compatible = "brcm,bcm2836";
-diff --git a/arch/arm/boot/dts/bcm2837.dtsi b/arch/arm/boot/dts/bcm2837.dtsi
-index 9e95fee78e19..0199ec98cd61 100644
---- a/arch/arm/boot/dts/bcm2837.dtsi
-+++ b/arch/arm/boot/dts/bcm2837.dtsi
-@@ -1,5 +1,6 @@
- #include "bcm283x.dtsi"
- #include "bcm2835-common.dtsi"
-+#include "bcm2835-rpi-common.dtsi"
-
- / {
- compatible = "brcm,bcm2837";
-diff --git a/arch/arm/boot/dts/r8a7743.dtsi b/arch/arm/boot/dts/r8a7743.dtsi
-index e8b340bb99bc..fff123753b85 100644
---- a/arch/arm/boot/dts/r8a7743.dtsi
-+++ b/arch/arm/boot/dts/r8a7743.dtsi
-@@ -338,7 +338,7 @@
- #thermal-sensor-cells = <0>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7743",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -348,7 +348,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7743",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -357,7 +357,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7743",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -367,7 +367,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7743",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -376,7 +376,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7743",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -386,7 +386,7 @@
- status = "disabled";
- };
-
-- ipmmu_gp: mmu@e62a0000 {
-+ ipmmu_gp: iommu@e62a0000 {
- compatible = "renesas,ipmmu-r8a7743",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe62a0000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/r8a7744.dtsi b/arch/arm/boot/dts/r8a7744.dtsi
-index def840b8b2d3..5050ac19041d 100644
---- a/arch/arm/boot/dts/r8a7744.dtsi
-+++ b/arch/arm/boot/dts/r8a7744.dtsi
-@@ -338,7 +338,7 @@
- #thermal-sensor-cells = <0>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7744",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -348,7 +348,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7744",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -357,7 +357,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7744",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -367,7 +367,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7744",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -376,7 +376,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7744",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -386,7 +386,7 @@
- status = "disabled";
- };
-
-- ipmmu_gp: mmu@e62a0000 {
-+ ipmmu_gp: iommu@e62a0000 {
- compatible = "renesas,ipmmu-r8a7744",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe62a0000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/r8a7745.dtsi b/arch/arm/boot/dts/r8a7745.dtsi
-index 7ab58d8bb740..b0d1fc24e97e 100644
---- a/arch/arm/boot/dts/r8a7745.dtsi
-+++ b/arch/arm/boot/dts/r8a7745.dtsi
-@@ -302,7 +302,7 @@
- resets = <&cpg 407>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7745",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -312,7 +312,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7745",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -321,7 +321,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7745",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -331,7 +331,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7745",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -340,7 +340,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7745",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -350,7 +350,7 @@
- status = "disabled";
- };
-
-- ipmmu_gp: mmu@e62a0000 {
-+ ipmmu_gp: iommu@e62a0000 {
- compatible = "renesas,ipmmu-r8a7745",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe62a0000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
-index e5ef9fd4284a..166d5566229d 100644
---- a/arch/arm/boot/dts/r8a7790.dtsi
-+++ b/arch/arm/boot/dts/r8a7790.dtsi
-@@ -427,7 +427,7 @@
- #thermal-sensor-cells = <0>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7790",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -437,7 +437,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7790",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -446,7 +446,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7790",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -456,7 +456,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7790",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -465,7 +465,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7790",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -475,7 +475,7 @@
- status = "disabled";
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a7790",
- "renesas,ipmmu-vmsa";
- reg = <0 0xffc80000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
-index 6e5bd86731cd..09e47cc17765 100644
---- a/arch/arm/boot/dts/r8a7791.dtsi
-+++ b/arch/arm/boot/dts/r8a7791.dtsi
-@@ -350,7 +350,7 @@
- #thermal-sensor-cells = <0>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -360,7 +360,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -369,7 +369,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -379,7 +379,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -388,7 +388,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -398,7 +398,7 @@
- status = "disabled";
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xffc80000 0 0x1000>;
-@@ -407,7 +407,7 @@
- status = "disabled";
- };
-
-- ipmmu_gp: mmu@e62a0000 {
-+ ipmmu_gp: iommu@e62a0000 {
- compatible = "renesas,ipmmu-r8a7791",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe62a0000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/r8a7793.dtsi b/arch/arm/boot/dts/r8a7793.dtsi
-index dadbda16161b..1b62a7e06b42 100644
---- a/arch/arm/boot/dts/r8a7793.dtsi
-+++ b/arch/arm/boot/dts/r8a7793.dtsi
-@@ -336,7 +336,7 @@
- #thermal-sensor-cells = <0>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -346,7 +346,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -355,7 +355,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -365,7 +365,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -374,7 +374,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -384,7 +384,7 @@
- status = "disabled";
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xffc80000 0 0x1000>;
-@@ -393,7 +393,7 @@
- status = "disabled";
- };
-
-- ipmmu_gp: mmu@e62a0000 {
-+ ipmmu_gp: iommu@e62a0000 {
- compatible = "renesas,ipmmu-r8a7793",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe62a0000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/r8a7794.dtsi b/arch/arm/boot/dts/r8a7794.dtsi
-index 2c9e7a1ebfec..8d7f8798628a 100644
---- a/arch/arm/boot/dts/r8a7794.dtsi
-+++ b/arch/arm/boot/dts/r8a7794.dtsi
-@@ -290,7 +290,7 @@
- resets = <&cpg 407>;
- };
-
-- ipmmu_sy0: mmu@e6280000 {
-+ ipmmu_sy0: iommu@e6280000 {
- compatible = "renesas,ipmmu-r8a7794",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6280000 0 0x1000>;
-@@ -300,7 +300,7 @@
- status = "disabled";
- };
-
-- ipmmu_sy1: mmu@e6290000 {
-+ ipmmu_sy1: iommu@e6290000 {
- compatible = "renesas,ipmmu-r8a7794",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6290000 0 0x1000>;
-@@ -309,7 +309,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds: mmu@e6740000 {
-+ ipmmu_ds: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7794",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe6740000 0 0x1000>;
-@@ -319,7 +319,7 @@
- status = "disabled";
- };
-
-- ipmmu_mp: mmu@ec680000 {
-+ ipmmu_mp: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7794",
- "renesas,ipmmu-vmsa";
- reg = <0 0xec680000 0 0x1000>;
-@@ -328,7 +328,7 @@
- status = "disabled";
- };
-
-- ipmmu_mx: mmu@fe951000 {
-+ ipmmu_mx: iommu@fe951000 {
- compatible = "renesas,ipmmu-r8a7794",
- "renesas,ipmmu-vmsa";
- reg = <0 0xfe951000 0 0x1000>;
-@@ -338,7 +338,7 @@
- status = "disabled";
- };
-
-- ipmmu_gp: mmu@e62a0000 {
-+ ipmmu_gp: iommu@e62a0000 {
- compatible = "renesas,ipmmu-r8a7794",
- "renesas,ipmmu-vmsa";
- reg = <0 0xe62a0000 0 0x1000>;
-diff --git a/arch/arm/boot/dts/stm32mp157a-avenger96.dts b/arch/arm/boot/dts/stm32mp157a-avenger96.dts
-index 425175f7d83c..081037b510bc 100644
---- a/arch/arm/boot/dts/stm32mp157a-avenger96.dts
-+++ b/arch/arm/boot/dts/stm32mp157a-avenger96.dts
-@@ -92,6 +92,9 @@
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "snps,dwmac-mdio";
-+ reset-gpios = <&gpioz 2 GPIO_ACTIVE_LOW>;
-+ reset-delay-us = <1000>;
-+
- phy0: ethernet-phy@7 {
- reg = <7>;
- };
-diff --git a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
-index d277d043031b..4c6704e4c57e 100644
---- a/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
-+++ b/arch/arm/boot/dts/sun8i-h2-plus-bananapi-m2-zero.dts
-@@ -31,7 +31,7 @@
-
- pwr_led {
- label = "bananapi-m2-zero:red:pwr";
-- gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
-+ gpios = <&r_pio 0 10 GPIO_ACTIVE_LOW>; /* PL10 */
- default-state = "on";
- };
- };
-diff --git a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
-index 5c183483ec3b..8010cdcdb37a 100644
---- a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
-+++ b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
-@@ -31,7 +31,7 @@
- #interrupt-cells = <1>;
- ranges;
-
-- nor_flash: flash@0,00000000 {
-+ nor_flash: flash@0 {
- compatible = "arm,vexpress-flash", "cfi-flash";
- reg = <0 0x00000000 0x04000000>,
- <4 0x00000000 0x04000000>;
-@@ -41,13 +41,13 @@
- };
- };
-
-- psram@1,00000000 {
-+ psram@100000000 {
- compatible = "arm,vexpress-psram", "mtd-ram";
- reg = <1 0x00000000 0x02000000>;
- bank-width = <4>;
- };
-
-- ethernet@2,02000000 {
-+ ethernet@202000000 {
- compatible = "smsc,lan9118", "smsc,lan9115";
- reg = <2 0x02000000 0x10000>;
- interrupts = <15>;
-@@ -59,14 +59,14 @@
- vddvario-supply = <&v2m_fixed_3v3>;
- };
-
-- usb@2,03000000 {
-+ usb@203000000 {
- compatible = "nxp,usb-isp1761";
- reg = <2 0x03000000 0x20000>;
- interrupts = <16>;
- port1-otg;
- };
-
-- iofpga@3,00000000 {
-+ iofpga@300000000 {
- compatible = "simple-bus";
- #address-cells = <1>;
- #size-cells = <1>;
-diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
-index 3461d12bbfc0..a5d3708fedf6 100644
---- a/arch/arm/mach-davinci/board-dm644x-evm.c
-+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
-@@ -655,19 +655,6 @@ static struct i2c_board_info __initdata i2c_info[] = {
- },
- };
-
--/* Fixed regulator support */
--static struct regulator_consumer_supply fixed_supplies_3_3v[] = {
-- /* Baseboard 3.3V: 5V -> TPS54310PWP -> 3.3V */
-- REGULATOR_SUPPLY("AVDD", "1-001b"),
-- REGULATOR_SUPPLY("DRVDD", "1-001b"),
--};
--
--static struct regulator_consumer_supply fixed_supplies_1_8v[] = {
-- /* Baseboard 1.8V: 5V -> TPS54310PWP -> 1.8V */
-- REGULATOR_SUPPLY("IOVDD", "1-001b"),
-- REGULATOR_SUPPLY("DVDD", "1-001b"),
--};
--
- #define DM644X_I2C_SDA_PIN GPIO_TO_PIN(2, 12)
- #define DM644X_I2C_SCL_PIN GPIO_TO_PIN(2, 11)
-
-@@ -700,6 +687,19 @@ static void __init evm_init_i2c(void)
- }
- #endif
-
-+/* Fixed regulator support */
-+static struct regulator_consumer_supply fixed_supplies_3_3v[] = {
-+ /* Baseboard 3.3V: 5V -> TPS54310PWP -> 3.3V */
-+ REGULATOR_SUPPLY("AVDD", "1-001b"),
-+ REGULATOR_SUPPLY("DRVDD", "1-001b"),
-+};
-+
-+static struct regulator_consumer_supply fixed_supplies_1_8v[] = {
-+ /* Baseboard 1.8V: 5V -> TPS54310PWP -> 1.8V */
-+ REGULATOR_SUPPLY("IOVDD", "1-001b"),
-+ REGULATOR_SUPPLY("DVDD", "1-001b"),
-+};
-+
- #define VENC_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
-
- /* venc standard timings */
-diff --git a/arch/arm/mach-integrator/Kconfig b/arch/arm/mach-integrator/Kconfig
-index 982eabc36163..2406cab73835 100644
---- a/arch/arm/mach-integrator/Kconfig
-+++ b/arch/arm/mach-integrator/Kconfig
-@@ -4,6 +4,8 @@ menuconfig ARCH_INTEGRATOR
- depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 || ARCH_MULTI_V6
- select ARM_AMBA
- select COMMON_CLK_VERSATILE
-+ select CMA
-+ select DMA_CMA
- select HAVE_TCM
- select ICST
- select MFD_SYSCON
-@@ -35,14 +37,13 @@ config INTEGRATOR_IMPD1
- select ARM_VIC
- select GPIO_PL061
- select GPIOLIB
-+ select REGULATOR
-+ select REGULATOR_FIXED_VOLTAGE
- help
- The IM-PD1 is an add-on logic module for the Integrator which
- allows ARM(R) Ltd PrimeCells to be developed and evaluated.
- The IM-PD1 can be found on the Integrator/PP2 platform.
-
-- To compile this driver as a module, choose M here: the
-- module will be called impd1.
--
- config INTEGRATOR_CM7TDMI
- bool "Integrator/CM7TDMI core module"
- depends on ARCH_INTEGRATOR_AP
-diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
-index 55d70cfe0f9e..3c7e310fd8bf 100644
---- a/arch/arm64/Kconfig.platforms
-+++ b/arch/arm64/Kconfig.platforms
-@@ -248,7 +248,7 @@ config ARCH_TEGRA
- This enables support for the NVIDIA Tegra SoC family.
-
- config ARCH_SPRD
-- tristate "Spreadtrum SoC platform"
-+ bool "Spreadtrum SoC platform"
- help
- Support for Spreadtrum ARM based SoCs
-
-diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
-index aace3d32a3df..8e6281c685fa 100644
---- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
-+++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
-@@ -1735,18 +1735,18 @@
- };
-
- sram: sram@fffc0000 {
-- compatible = "amlogic,meson-axg-sram", "mmio-sram";
-+ compatible = "mmio-sram";
- reg = <0x0 0xfffc0000 0x0 0x20000>;
- #address-cells = <1>;
- #size-cells = <1>;
- ranges = <0 0x0 0xfffc0000 0x20000>;
-
-- cpu_scp_lpri: scp-shmem@13000 {
-+ cpu_scp_lpri: scp-sram@13000 {
- compatible = "amlogic,meson-axg-scp-shmem";
- reg = <0x13000 0x400>;
- };
-
-- cpu_scp_hpri: scp-shmem@13400 {
-+ cpu_scp_hpri: scp-sram@13400 {
- compatible = "amlogic,meson-axg-scp-shmem";
- reg = <0x13400 0x400>;
- };
-diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-ugoos-am6.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-ugoos-am6.dts
-index 06c5430eb92d..fdaacfd96b97 100644
---- a/arch/arm64/boot/dts/amlogic/meson-g12b-ugoos-am6.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-g12b-ugoos-am6.dts
-@@ -14,7 +14,7 @@
- #include <dt-bindings/sound/meson-g12a-tohdmitx.h>
-
- / {
-- compatible = "ugoos,am6", "amlogic,g12b";
-+ compatible = "ugoos,am6", "amlogic,s922x", "amlogic,g12b";
- model = "Ugoos AM6";
-
- aliases {
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gx-libretech-pc.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-libretech-pc.dtsi
-index 248b018c83d5..b1da36fdeac6 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gx-libretech-pc.dtsi
-+++ b/arch/arm64/boot/dts/amlogic/meson-gx-libretech-pc.dtsi
-@@ -96,14 +96,14 @@
- leds {
- compatible = "gpio-leds";
-
-- green {
-+ led-green {
- color = <LED_COLOR_ID_GREEN>;
- function = LED_FUNCTION_DISK_ACTIVITY;
- gpios = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>;
- linux,default-trigger = "disk-activity";
- };
-
-- blue {
-+ led-blue {
- color = <LED_COLOR_ID_BLUE>;
- function = LED_FUNCTION_STATUS;
- gpios = <&gpio GPIODV_28 GPIO_ACTIVE_HIGH>;
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
-index 03f79fe045b7..e2bb68ec8502 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
-+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
-@@ -398,20 +398,20 @@
- };
-
- sram: sram@c8000000 {
-- compatible = "amlogic,meson-gx-sram", "amlogic,meson-gxbb-sram", "mmio-sram";
-+ compatible = "mmio-sram";
- reg = <0x0 0xc8000000 0x0 0x14000>;
-
- #address-cells = <1>;
- #size-cells = <1>;
- ranges = <0 0x0 0xc8000000 0x14000>;
-
-- cpu_scp_lpri: scp-shmem@0 {
-- compatible = "amlogic,meson-gx-scp-shmem", "amlogic,meson-gxbb-scp-shmem";
-+ cpu_scp_lpri: scp-sram@0 {
-+ compatible = "amlogic,meson-gxbb-scp-shmem";
- reg = <0x13000 0x400>;
- };
-
-- cpu_scp_hpri: scp-shmem@200 {
-- compatible = "amlogic,meson-gx-scp-shmem", "amlogic,meson-gxbb-scp-shmem";
-+ cpu_scp_hpri: scp-sram@200 {
-+ compatible = "amlogic,meson-gxbb-scp-shmem";
- reg = <0x13400 0x400>;
- };
- };
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-kii-pro.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-kii-pro.dts
-index 6c9cc45fb417..e8394a8269ee 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-kii-pro.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-kii-pro.dts
-@@ -11,7 +11,7 @@
- #include <dt-bindings/input/input.h>
- #include <dt-bindings/leds/common.h>
- / {
-- compatible = "videostrong,kii-pro", "amlogic,p201", "amlogic,s905", "amlogic,meson-gxbb";
-+ compatible = "videostrong,kii-pro", "amlogic,meson-gxbb";
- model = "Videostrong KII Pro";
-
- leds {
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
-index d6ca684e0e61..7be3e354093b 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nanopi-k2.dts
-@@ -29,7 +29,7 @@
- leds {
- compatible = "gpio-leds";
-
-- stat {
-+ led-stat {
- label = "nanopi-k2:blue:stat";
- gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_HIGH>;
- default-state = "on";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
-index 65ec7dea828c..67d901ed2fa3 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-nexbox-a95x.dts
-@@ -31,7 +31,7 @@
-
- leds {
- compatible = "gpio-leds";
-- blue {
-+ led-blue {
- label = "a95x:system-status";
- gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_LOW>;
- linux,default-trigger = "heartbeat";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
-index b46ef985bb44..70fcfb7b0683 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
-@@ -49,7 +49,7 @@
-
- leds {
- compatible = "gpio-leds";
-- blue {
-+ led-blue {
- label = "c2:blue:alive";
- gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_LOW>;
- linux,default-trigger = "heartbeat";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi
-index 45cb83625951..222ee8069cfa 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi
-@@ -20,7 +20,7 @@
- leds {
- compatible = "gpio-leds";
-
-- blue {
-+ led-blue {
- label = "vega-s95:blue:on";
- gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_HIGH>;
- default-state = "on";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dts
-index 1d32d1f6d032..2ab8a3d10079 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dts
-@@ -14,13 +14,13 @@
- model = "WeTek Play 2";
-
- leds {
-- wifi {
-+ led-wifi {
- label = "wetek-play:wifi-status";
- gpios = <&gpio GPIODV_26 GPIO_ACTIVE_HIGH>;
- default-state = "off";
- };
-
-- ethernet {
-+ led-ethernet {
- label = "wetek-play:ethernet-status";
- gpios = <&gpio GPIODV_27 GPIO_ACTIVE_HIGH>;
- default-state = "off";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek.dtsi
-index dee51cf95223..d6133af09d64 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek.dtsi
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek.dtsi
-@@ -25,7 +25,7 @@
- leds {
- compatible = "gpio-leds";
-
-- system {
-+ led-system {
- label = "wetek-play:system-status";
- gpios = <&gpio_ao GPIOAO_13 GPIO_ACTIVE_HIGH>;
- default-state = "on";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
-index e8348b2728db..a4a71c13891b 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
-@@ -54,14 +54,14 @@
- leds {
- compatible = "gpio-leds";
-
-- system {
-+ led-system {
- label = "librecomputer:system-status";
- gpios = <&gpio GPIODV_24 GPIO_ACTIVE_HIGH>;
- default-state = "on";
- panic-indicator;
- };
-
-- blue {
-+ led-blue {
- label = "librecomputer:blue";
- gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
- linux,default-trigger = "heartbeat";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-rbox-pro.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-rbox-pro.dts
-index 420a88e9a195..c89c9f846fb1 100644
---- a/arch/arm64/boot/dts/amlogic/meson-gxm-rbox-pro.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-rbox-pro.dts
-@@ -36,13 +36,13 @@
- leds {
- compatible = "gpio-leds";
-
-- blue {
-+ led-blue {
- label = "rbox-pro:blue:on";
- gpios = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>;
- default-state = "on";
- };
-
-- red {
-+ led-red {
- label = "rbox-pro:red:standby";
- gpios = <&gpio GPIODV_28 GPIO_ACTIVE_HIGH>;
- default-state = "off";
-diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
-index 094ecf2222bb..1ef1e3672b96 100644
---- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
-+++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
-@@ -39,13 +39,13 @@
- leds {
- compatible = "gpio-leds";
-
-- white {
-+ led-white {
- label = "vim3:white:sys";
- gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_LOW>;
- linux,default-trigger = "heartbeat";
- };
-
-- red {
-+ led-red {
- label = "vim3:red";
- gpios = <&gpio_expander 5 GPIO_ACTIVE_LOW>;
- };
-diff --git a/arch/arm64/boot/dts/amlogic/meson-sm1-sei610.dts b/arch/arm64/boot/dts/amlogic/meson-sm1-sei610.dts
-index dfb2438851c0..5ab139a34c01 100644
---- a/arch/arm64/boot/dts/amlogic/meson-sm1-sei610.dts
-+++ b/arch/arm64/boot/dts/amlogic/meson-sm1-sei610.dts
-@@ -104,7 +104,7 @@
- leds {
- compatible = "gpio-leds";
-
-- bluetooth {
-+ led-bluetooth {
- label = "sei610:blue:bt";
- gpios = <&gpio GPIOC_7 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
- default-state = "off";
-diff --git a/arch/arm64/boot/dts/arm/foundation-v8-gicv2.dtsi b/arch/arm64/boot/dts/arm/foundation-v8-gicv2.dtsi
-index 15fe81738e94..dfb23dfc0b0f 100644
---- a/arch/arm64/boot/dts/arm/foundation-v8-gicv2.dtsi
-+++ b/arch/arm64/boot/dts/arm/foundation-v8-gicv2.dtsi
-@@ -8,7 +8,7 @@
- gic: interrupt-controller@2c001000 {
- compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
- #interrupt-cells = <3>;
-- #address-cells = <2>;
-+ #address-cells = <1>;
- interrupt-controller;
- reg = <0x0 0x2c001000 0 0x1000>,
- <0x0 0x2c002000 0 0x2000>,
-diff --git a/arch/arm64/boot/dts/arm/foundation-v8-gicv3.dtsi b/arch/arm64/boot/dts/arm/foundation-v8-gicv3.dtsi
-index f2c75c756039..906f51935b36 100644
---- a/arch/arm64/boot/dts/arm/foundation-v8-gicv3.dtsi
-+++ b/arch/arm64/boot/dts/arm/foundation-v8-gicv3.dtsi
-@@ -8,9 +8,9 @@
- gic: interrupt-controller@2f000000 {
- compatible = "arm,gic-v3";
- #interrupt-cells = <3>;
-- #address-cells = <2>;
-- #size-cells = <2>;
-- ranges;
-+ #address-cells = <1>;
-+ #size-cells = <1>;
-+ ranges = <0x0 0x0 0x2f000000 0x100000>;
- interrupt-controller;
- reg = <0x0 0x2f000000 0x0 0x10000>,
- <0x0 0x2f100000 0x0 0x200000>,
-@@ -22,7 +22,7 @@
- its: its@2f020000 {
- compatible = "arm,gic-v3-its";
- msi-controller;
-- reg = <0x0 0x2f020000 0x0 0x20000>;
-+ reg = <0x20000 0x20000>;
- };
- };
- };
-diff --git a/arch/arm64/boot/dts/arm/foundation-v8.dtsi b/arch/arm64/boot/dts/arm/foundation-v8.dtsi
-index 12f039fa3dad..e2da63f78298 100644
---- a/arch/arm64/boot/dts/arm/foundation-v8.dtsi
-+++ b/arch/arm64/boot/dts/arm/foundation-v8.dtsi
-@@ -107,51 +107,51 @@
-
- #interrupt-cells = <1>;
- interrupt-map-mask = <0 0 63>;
-- interrupt-map = <0 0 0 &gic 0 0 GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 1 &gic 0 0 GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 2 &gic 0 0 GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 3 &gic 0 0 GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 4 &gic 0 0 GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 5 &gic 0 0 GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 6 &gic 0 0 GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 7 &gic 0 0 GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 8 &gic 0 0 GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 9 &gic 0 0 GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 10 &gic 0 0 GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 11 &gic 0 0 GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 12 &gic 0 0 GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 13 &gic 0 0 GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 14 &gic 0 0 GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 15 &gic 0 0 GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 16 &gic 0 0 GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 17 &gic 0 0 GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 18 &gic 0 0 GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 19 &gic 0 0 GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 20 &gic 0 0 GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 21 &gic 0 0 GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 22 &gic 0 0 GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 23 &gic 0 0 GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 24 &gic 0 0 GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 25 &gic 0 0 GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 26 &gic 0 0 GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 27 &gic 0 0 GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 28 &gic 0 0 GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 29 &gic 0 0 GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 30 &gic 0 0 GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 31 &gic 0 0 GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 32 &gic 0 0 GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 33 &gic 0 0 GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 34 &gic 0 0 GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 35 &gic 0 0 GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 36 &gic 0 0 GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 37 &gic 0 0 GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 38 &gic 0 0 GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 39 &gic 0 0 GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 40 &gic 0 0 GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 41 &gic 0 0 GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 42 &gic 0 0 GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
--
-- ethernet@2,02000000 {
-+ interrupt-map = <0 0 0 &gic 0 GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 1 &gic 0 GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 2 &gic 0 GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 3 &gic 0 GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 4 &gic 0 GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 5 &gic 0 GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 6 &gic 0 GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 7 &gic 0 GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 8 &gic 0 GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 9 &gic 0 GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 10 &gic 0 GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 11 &gic 0 GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 12 &gic 0 GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 13 &gic 0 GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 14 &gic 0 GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 15 &gic 0 GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 16 &gic 0 GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 17 &gic 0 GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 18 &gic 0 GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 19 &gic 0 GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 20 &gic 0 GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 21 &gic 0 GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 22 &gic 0 GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 23 &gic 0 GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 24 &gic 0 GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 25 &gic 0 GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 26 &gic 0 GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 27 &gic 0 GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 28 &gic 0 GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 29 &gic 0 GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 30 &gic 0 GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 31 &gic 0 GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 32 &gic 0 GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 33 &gic 0 GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 34 &gic 0 GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 35 &gic 0 GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 36 &gic 0 GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 37 &gic 0 GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 38 &gic 0 GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 39 &gic 0 GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 40 &gic 0 GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 41 &gic 0 GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 42 &gic 0 GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
-+
-+ ethernet@202000000 {
- compatible = "smsc,lan91c111";
- reg = <2 0x02000000 0x10000>;
- interrupts = <15>;
-@@ -178,7 +178,7 @@
- clock-output-names = "v2m:refclk32khz";
- };
-
-- iofpga@3,00000000 {
-+ iofpga@300000000 {
- compatible = "simple-bus";
- #address-cells = <1>;
- #size-cells = <1>;
-diff --git a/arch/arm64/boot/dts/arm/juno-base.dtsi b/arch/arm64/boot/dts/arm/juno-base.dtsi
-index f5889281545f..59b6ac0b828a 100644
---- a/arch/arm64/boot/dts/arm/juno-base.dtsi
-+++ b/arch/arm64/boot/dts/arm/juno-base.dtsi
-@@ -74,35 +74,35 @@
- <0x0 0x2c02f000 0 0x2000>,
- <0x0 0x2c04f000 0 0x2000>,
- <0x0 0x2c06f000 0 0x2000>;
-- #address-cells = <2>;
-+ #address-cells = <1>;
- #interrupt-cells = <3>;
-- #size-cells = <2>;
-+ #size-cells = <1>;
- interrupt-controller;
- interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_HIGH)>;
-- ranges = <0 0 0 0x2c1c0000 0 0x40000>;
-+ ranges = <0 0 0x2c1c0000 0x40000>;
-
- v2m_0: v2m@0 {
- compatible = "arm,gic-v2m-frame";
- msi-controller;
-- reg = <0 0 0 0x10000>;
-+ reg = <0 0x10000>;
- };
-
- v2m@10000 {
- compatible = "arm,gic-v2m-frame";
- msi-controller;
-- reg = <0 0x10000 0 0x10000>;
-+ reg = <0x10000 0x10000>;
- };
-
- v2m@20000 {
- compatible = "arm,gic-v2m-frame";
- msi-controller;
-- reg = <0 0x20000 0 0x10000>;
-+ reg = <0x20000 0x10000>;
- };
-
- v2m@30000 {
- compatible = "arm,gic-v2m-frame";
- msi-controller;
-- reg = <0 0x30000 0 0x10000>;
-+ reg = <0x30000 0x10000>;
- };
- };
-
-@@ -546,10 +546,10 @@
- <0x42000000 0x40 0x00000000 0x40 0x00000000 0x1 0x00000000>;
- #interrupt-cells = <1>;
- interrupt-map-mask = <0 0 0 7>;
-- interrupt-map = <0 0 0 1 &gic 0 0 GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 0 2 &gic 0 0 GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 0 3 &gic 0 0 GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 0 4 &gic 0 0 GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
-+ interrupt-map = <0 0 0 1 &gic 0 GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 0 2 &gic 0 GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 0 3 &gic 0 GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 0 4 &gic 0 GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
- msi-parent = <&v2m_0>;
- status = "disabled";
- iommu-map-mask = <0x0>; /* RC has no means to output PCI RID */
-@@ -813,19 +813,19 @@
-
- #interrupt-cells = <1>;
- interrupt-map-mask = <0 0 15>;
-- interrupt-map = <0 0 0 &gic 0 0 GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 1 &gic 0 0 GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 2 &gic 0 0 GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 3 &gic 0 0 GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 4 &gic 0 0 GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 5 &gic 0 0 GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 6 &gic 0 0 GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 7 &gic 0 0 GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 8 &gic 0 0 GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 9 &gic 0 0 GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 10 &gic 0 0 GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 11 &gic 0 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
-- <0 0 12 &gic 0 0 GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
-+ interrupt-map = <0 0 0 &gic 0 GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 1 &gic 0 GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 2 &gic 0 GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 3 &gic 0 GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 4 &gic 0 GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 5 &gic 0 GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 6 &gic 0 GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 7 &gic 0 GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 8 &gic 0 GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 9 &gic 0 GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 10 &gic 0 GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 11 &gic 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
-+ <0 0 12 &gic 0 GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
- };
-
- site2: tlx@60000000 {
-@@ -835,6 +835,6 @@
- ranges = <0 0 0x60000000 0x10000000>;
- #interrupt-cells = <1>;
- interrupt-map-mask = <0 0>;
-- interrupt-map = <0 0 &gic 0 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
-+ interrupt-map = <0 0 &gic 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
- };
- };
-diff --git a/arch/arm64/boot/dts/arm/juno-motherboard.dtsi b/arch/arm64/boot/dts/arm/juno-motherboard.dtsi
-index e3983ded3c3c..d5cefddde08c 100644
---- a/arch/arm64/boot/dts/arm/juno-motherboard.dtsi
-+++ b/arch/arm64/boot/dts/arm/juno-motherboard.dtsi
-@@ -103,7 +103,7 @@
- };
- };
-
-- flash@0,00000000 {
-+ flash@0 {
- /* 2 * 32MiB NOR Flash memory mounted on CS0 */
- compatible = "arm,vexpress-flash", "cfi-flash";
- reg = <0 0x00000000 0x04000000>;
-@@ -120,7 +120,7 @@
- };
- };
-
-- ethernet@2,00000000 {
-+ ethernet@200000000 {
- compatible = "smsc,lan9118", "smsc,lan9115";
- reg = <2 0x00000000 0x10000>;
- interrupts = <3>;
-@@ -133,7 +133,7 @@
- vddvario-supply = <&mb_fixed_3v3>;
- };
-
-- iofpga@3,00000000 {
-+ iofpga@300000000 {
- compatible = "simple-bus";
- #address-cells = <1>;
- #size-cells = <1>;
-diff --git a/arch/arm64/boot/dts/arm/rtsm_ve-motherboard-rs2.dtsi b/arch/arm64/boot/dts/arm/rtsm_ve-motherboard-rs2.dtsi
-index 60703b5763c6..350cbf17e8b4 100644
---- a/arch/arm64/boot/dts/arm/rtsm_ve-motherboard-rs2.dtsi
-+++ b/arch/arm64/boot/dts/arm/rtsm_ve-motherboard-rs2.dtsi
-@@ -9,7 +9,7 @@
- motherboard {
- arm,v2m-memory-map = "rs2";
-
-- iofpga@3,00000000 {
-+ iofpga@300000000 {
- virtio-p9@140000 {
- compatible = "virtio,mmio";
- reg = <0x140000 0x200>;
-diff --git a/arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi b/arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi
-index e333c8d2d0e4..d1bfa62ca073 100644
---- a/arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi
-+++ b/arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi
-@@ -17,14 +17,14 @@
- #interrupt-cells = <1>;
- ranges;
-
-- flash@0,00000000 {
-+ flash@0 {
- compatible = "arm,vexpress-flash", "cfi-flash";
- reg = <0 0x00000000 0x04000000>,
- <4 0x00000000 0x04000000>;
- bank-width = <4>;
- };
-
-- ethernet@2,02000000 {
-+ ethernet@202000000 {
- compatible = "smsc,lan91c111";
- reg = <2 0x02000000 0x10000>;
- interrupts = <15>;
-@@ -51,7 +51,7 @@
- clock-output-names = "v2m:refclk32khz";
- };
-
-- iofpga@3,00000000 {
-+ iofpga@300000000 {
- compatible = "simple-bus";
- #address-cells = <1>;
- #size-cells = <1>;
-diff --git a/arch/arm64/boot/dts/marvell/armada-3720-db.dts b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
-index f2cc00594d64..3e5789f37206 100644
---- a/arch/arm64/boot/dts/marvell/armada-3720-db.dts
-+++ b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
-@@ -128,6 +128,9 @@
-
- /* CON15(V2.0)/CON17(V1.4) : PCIe / CON15(V2.0)/CON12(V1.4) :mini-PCIe */
- &pcie0 {
-+ pinctrl-names = "default";
-+ pinctrl-0 = <&pcie_reset_pins &pcie_clkreq_pins>;
-+ reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>;
- status = "okay";
- };
-
-diff --git a/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi b/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi
-index 42e992f9c8a5..c92ad664cb0e 100644
---- a/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi
-+++ b/arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi
-@@ -47,6 +47,7 @@
- phys = <&comphy1 0>;
- pinctrl-names = "default";
- pinctrl-0 = <&pcie_reset_pins &pcie_clkreq_pins>;
-+ reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>;
- };
-
- /* J6 */
-diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
-index bb42d1e6a4e9..1452c821f8c0 100644
---- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
-+++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
-@@ -95,7 +95,7 @@
- };
-
- sfp: sfp {
-- compatible = "sff,sfp+";
-+ compatible = "sff,sfp";
- i2c-bus = <&i2c0>;
- los-gpio = <&moxtet_sfp 0 GPIO_ACTIVE_HIGH>;
- tx-fault-gpio = <&moxtet_sfp 1 GPIO_ACTIVE_HIGH>;
-@@ -128,10 +128,6 @@
- };
- };
-
--&pcie_reset_pins {
-- function = "gpio";
--};
--
- &pcie0 {
- pinctrl-names = "default";
- pinctrl-0 = <&pcie_reset_pins &pcie_clkreq_pins>;
-@@ -179,6 +175,8 @@
- marvell,pad-type = "sd";
- vqmmc-supply = <&vsdio_reg>;
- mmc-pwrseq = <&sdhci1_pwrseq>;
-+ /* forbid SDR104 for FCC purposes */
-+ sdhci-caps-mask = <0x2 0x0>;
- status = "okay";
- };
-
-diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
-index 000c135e39b7..7909c146eabf 100644
---- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
-+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
-@@ -317,7 +317,7 @@
-
- pcie_reset_pins: pcie-reset-pins {
- groups = "pcie1";
-- function = "pcie";
-+ function = "gpio";
- };
-
- pcie_clkreq_pins: pcie-clkreq-pins {
-diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
-index d819e44d94a8..6ad1053afd27 100644
---- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
-+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
-@@ -242,21 +242,21 @@
- cpu_on = <0x84000003>;
- };
-
-- clk26m: oscillator@0 {
-+ clk26m: oscillator0 {
- compatible = "fixed-clock";
- #clock-cells = <0>;
- clock-frequency = <26000000>;
- clock-output-names = "clk26m";
- };
-
-- clk32k: oscillator@1 {
-+ clk32k: oscillator1 {
- compatible = "fixed-clock";
- #clock-cells = <0>;
- clock-frequency = <32000>;
- clock-output-names = "clk32k";
- };
-
-- cpum_ck: oscillator@2 {
-+ cpum_ck: oscillator2 {
- compatible = "fixed-clock";
- #clock-cells = <0>;
- clock-frequency = <0>;
-@@ -272,19 +272,19 @@
- sustainable-power = <1500>; /* milliwatts */
-
- trips {
-- threshold: trip-point@0 {
-+ threshold: trip-point0 {
- temperature = <68000>;
- hysteresis = <2000>;
- type = "passive";
- };
-
-- target: trip-point@1 {
-+ target: trip-point1 {
- temperature = <85000>;
- hysteresis = <2000>;
- type = "passive";
- };
-
-- cpu_crit: cpu_crit@0 {
-+ cpu_crit: cpu_crit0 {
- temperature = <115000>;
- hysteresis = <2000>;
- type = "critical";
-@@ -292,13 +292,13 @@
- };
-
- cooling-maps {
-- map@0 {
-+ map0 {
- trip = <&target>;
- cooling-device = <&cpu0 0 0>,
- <&cpu1 0 0>;
- contribution = <3072>;
- };
-- map@1 {
-+ map1 {
- trip = <&target>;
- cooling-device = <&cpu2 0 0>,
- <&cpu3 0 0>;
-@@ -312,7 +312,7 @@
- #address-cells = <2>;
- #size-cells = <2>;
- ranges;
-- vpu_dma_reserved: vpu_dma_mem_region {
-+ vpu_dma_reserved: vpu_dma_mem_region@b7000000 {
- compatible = "shared-dma-pool";
- reg = <0 0xb7000000 0 0x500000>;
- alignment = <0x1000>;
-@@ -365,7 +365,7 @@
- reg = <0 0x10005000 0 0x1000>;
- };
-
-- pio: pinctrl@10005000 {
-+ pio: pinctrl@1000b000 {
- compatible = "mediatek,mt8173-pinctrl";
- reg = <0 0x1000b000 0 0x1000>;
- mediatek,pctl-regmap = <&syscfg_pctl_a>;
-@@ -572,7 +572,7 @@
- status = "disabled";
- };
-
-- gic: interrupt-controller@10220000 {
-+ gic: interrupt-controller@10221000 {
- compatible = "arm,gic-400";
- #interrupt-cells = <3>;
- interrupt-parent = <&gic>;
-diff --git a/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi b/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi
-index 623f7d7d216b..8e3136dfdd62 100644
---- a/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi
-+++ b/arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi
-@@ -33,7 +33,7 @@
-
- phy-reset-gpios = <&gpio TEGRA194_MAIN_GPIO(G, 5) GPIO_ACTIVE_LOW>;
- phy-handle = <&phy>;
-- phy-mode = "rgmii";
-+ phy-mode = "rgmii-id";
-
- mdio {
- #address-cells = <1>;
-diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
-index f4ede86e32b4..3c928360f4ed 100644
---- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
-+++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
-@@ -1387,7 +1387,7 @@
-
- bus-range = <0x0 0xff>;
- ranges = <0x81000000 0x0 0x30100000 0x0 0x30100000 0x0 0x00100000 /* downstream I/O (1MB) */
-- 0xc2000000 0x12 0x00000000 0x12 0x00000000 0x0 0x30000000 /* prefetchable memory (768MB) */
-+ 0xc3000000 0x12 0x00000000 0x12 0x00000000 0x0 0x30000000 /* prefetchable memory (768MB) */
- 0x82000000 0x0 0x40000000 0x12 0x30000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */
- };
-
-@@ -1432,7 +1432,7 @@
-
- bus-range = <0x0 0xff>;
- ranges = <0x81000000 0x0 0x32100000 0x0 0x32100000 0x0 0x00100000 /* downstream I/O (1MB) */
-- 0xc2000000 0x12 0x40000000 0x12 0x40000000 0x0 0x30000000 /* prefetchable memory (768MB) */
-+ 0xc3000000 0x12 0x40000000 0x12 0x40000000 0x0 0x30000000 /* prefetchable memory (768MB) */
- 0x82000000 0x0 0x40000000 0x12 0x70000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */
- };
-
-@@ -1477,7 +1477,7 @@
-
- bus-range = <0x0 0xff>;
- ranges = <0x81000000 0x0 0x34100000 0x0 0x34100000 0x0 0x00100000 /* downstream I/O (1MB) */
-- 0xc2000000 0x12 0x80000000 0x12 0x80000000 0x0 0x30000000 /* prefetchable memory (768MB) */
-+ 0xc3000000 0x12 0x80000000 0x12 0x80000000 0x0 0x30000000 /* prefetchable memory (768MB) */
- 0x82000000 0x0 0x40000000 0x12 0xb0000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */
- };
-
-@@ -1522,7 +1522,7 @@
-
- bus-range = <0x0 0xff>;
- ranges = <0x81000000 0x0 0x36100000 0x0 0x36100000 0x0 0x00100000 /* downstream I/O (1MB) */
-- 0xc2000000 0x14 0x00000000 0x14 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */
-+ 0xc3000000 0x14 0x00000000 0x14 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */
- 0x82000000 0x0 0x40000000 0x17 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */
- };
-
-@@ -1567,7 +1567,7 @@
-
- bus-range = <0x0 0xff>;
- ranges = <0x81000000 0x0 0x38100000 0x0 0x38100000 0x0 0x00100000 /* downstream I/O (1MB) */
-- 0xc2000000 0x18 0x00000000 0x18 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */
-+ 0xc3000000 0x18 0x00000000 0x18 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */
- 0x82000000 0x0 0x40000000 0x1b 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */
- };
-
-@@ -1616,7 +1616,7 @@
-
- bus-range = <0x0 0xff>;
- ranges = <0x81000000 0x0 0x3a100000 0x0 0x3a100000 0x0 0x00100000 /* downstream I/O (1MB) */
-- 0xc2000000 0x1c 0x00000000 0x1c 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */
-+ 0xc3000000 0x1c 0x00000000 0x1c 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */
- 0x82000000 0x0 0x40000000 0x1f 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */
- };
-
-diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
-index c4abbccf2bed..eaa1eb70b455 100644
---- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
-+++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
-@@ -117,16 +117,6 @@
- regulator-max-microvolt = <3700000>;
- };
-
-- vreg_s8a_l3a_input: vreg-s8a-l3a-input {
-- compatible = "regulator-fixed";
-- regulator-name = "vreg_s8a_l3a_input";
-- regulator-always-on;
-- regulator-boot-on;
--
-- regulator-min-microvolt = <0>;
-- regulator-max-microvolt = <0>;
-- };
--
- wlan_en: wlan-en-1-8v {
- pinctrl-names = "default";
- pinctrl-0 = <&wlan_en_gpios>;
-@@ -705,14 +695,14 @@
- vdd_s11-supply = <&vph_pwr>;
- vdd_s12-supply = <&vph_pwr>;
- vdd_l2_l26_l28-supply = <&vreg_s3a_1p3>;
-- vdd_l3_l11-supply = <&vreg_s8a_l3a_input>;
-+ vdd_l3_l11-supply = <&vreg_s3a_1p3>;
- vdd_l4_l27_l31-supply = <&vreg_s3a_1p3>;
- vdd_l5_l7-supply = <&vreg_s5a_2p15>;
- vdd_l6_l12_l32-supply = <&vreg_s5a_2p15>;
- vdd_l8_l16_l30-supply = <&vph_pwr>;
- vdd_l14_l15-supply = <&vreg_s5a_2p15>;
- vdd_l25-supply = <&vreg_s3a_1p3>;
-- vdd_lvs1_2-supply = <&vreg_s4a_1p8>;
-+ vdd_lvs1_lvs2-supply = <&vreg_s4a_1p8>;
-
- vreg_s3a_1p3: s3 {
- regulator-name = "vreg_s3a_1p3";
-diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
-index a88a15f2352b..5548d7b5096c 100644
---- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
-+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
-@@ -261,7 +261,7 @@
- thermal-sensors = <&tsens 4>;
-
- trips {
-- cpu2_3_alert0: trip-point@0 {
-+ cpu2_3_alert0: trip-point0 {
- temperature = <75000>;
- hysteresis = <2000>;
- type = "passive";
-@@ -291,7 +291,7 @@
- thermal-sensors = <&tsens 2>;
-
- trips {
-- gpu_alert0: trip-point@0 {
-+ gpu_alert0: trip-point0 {
- temperature = <75000>;
- hysteresis = <2000>;
- type = "passive";
-@@ -311,7 +311,7 @@
- thermal-sensors = <&tsens 1>;
-
- trips {
-- cam_alert0: trip-point@0 {
-+ cam_alert0: trip-point0 {
- temperature = <75000>;
- hysteresis = <2000>;
- type = "hot";
-@@ -326,7 +326,7 @@
- thermal-sensors = <&tsens 0>;
-
- trips {
-- modem_alert0: trip-point@0 {
-+ modem_alert0: trip-point0 {
- temperature = <85000>;
- hysteresis = <2000>;
- type = "hot";
-diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
-index 98634d5c4440..d22c364b520a 100644
---- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
-+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
-@@ -989,16 +989,16 @@
- "csi_clk_mux",
- "vfe0",
- "vfe1";
-- interrupts = <GIC_SPI 78 0>,
-- <GIC_SPI 79 0>,
-- <GIC_SPI 80 0>,
-- <GIC_SPI 296 0>,
-- <GIC_SPI 297 0>,
-- <GIC_SPI 298 0>,
-- <GIC_SPI 299 0>,
-- <GIC_SPI 309 0>,
-- <GIC_SPI 314 0>,
-- <GIC_SPI 315 0>;
-+ interrupts = <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 80 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 296 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 297 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 298 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 299 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 309 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 314 IRQ_TYPE_EDGE_RISING>,
-+ <GIC_SPI 315 IRQ_TYPE_EDGE_RISING>;
- interrupt-names = "csiphy0",
- "csiphy1",
- "csiphy2",
-diff --git a/arch/arm64/boot/dts/qcom/pm8150.dtsi b/arch/arm64/boot/dts/qcom/pm8150.dtsi
-index b6e304748a57..c0b197458665 100644
---- a/arch/arm64/boot/dts/qcom/pm8150.dtsi
-+++ b/arch/arm64/boot/dts/qcom/pm8150.dtsi
-@@ -73,18 +73,8 @@
- reg = <0xc000>;
- gpio-controller;
- #gpio-cells = <2>;
-- interrupts = <0x0 0xc0 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc1 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc2 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc3 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc4 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc5 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc6 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc7 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc8 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xc9 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xca 0x0 IRQ_TYPE_NONE>,
-- <0x0 0xcb 0x0 IRQ_TYPE_NONE>;
-+ interrupt-controller;
-+ #interrupt-cells = <2>;
- };
- };
-
-diff --git a/arch/arm64/boot/dts/qcom/pm8150b.dtsi b/arch/arm64/boot/dts/qcom/pm8150b.dtsi
-index 322379d5c31f..40b5d75a4a1d 100644
---- a/arch/arm64/boot/dts/qcom/pm8150b.dtsi
-+++ b/arch/arm64/boot/dts/qcom/pm8150b.dtsi
-@@ -62,18 +62,8 @@
- reg = <0xc000>;
- gpio-controller;
- #gpio-cells = <2>;
-- interrupts = <0x2 0xc0 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc1 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc2 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc3 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc4 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc5 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc6 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc7 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc8 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xc9 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xca 0x0 IRQ_TYPE_NONE>,
-- <0x2 0xcb 0x0 IRQ_TYPE_NONE>;
-+ interrupt-controller;
-+ #interrupt-cells = <2>;
- };
- };
-
-diff --git a/arch/arm64/boot/dts/qcom/pm8150l.dtsi b/arch/arm64/boot/dts/qcom/pm8150l.dtsi
-index eb0e9a090e42..cf05e0685d10 100644
---- a/arch/arm64/boot/dts/qcom/pm8150l.dtsi
-+++ b/arch/arm64/boot/dts/qcom/pm8150l.dtsi
-@@ -56,18 +56,8 @@
- reg = <0xc000>;
- gpio-controller;
- #gpio-cells = <2>;
-- interrupts = <0x4 0xc0 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc1 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc2 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc3 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc4 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc5 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc6 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc7 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc8 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xc9 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xca 0x0 IRQ_TYPE_NONE>,
-- <0x4 0xcb 0x0 IRQ_TYPE_NONE>;
-+ interrupt-controller;
-+ #interrupt-cells = <2>;
- };
- };
-
-diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi b/arch/arm64/boot/dts/qcom/sc7180.dtsi
-index 998f101ad623..eea92b314fc6 100644
---- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
-+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
-@@ -1657,8 +1657,7 @@
- pdc: interrupt-controller@b220000 {
- compatible = "qcom,sc7180-pdc", "qcom,pdc";
- reg = <0 0x0b220000 0 0x30000>;
-- qcom,pdc-ranges = <0 480 15>, <17 497 98>,
-- <119 634 4>, <124 639 1>;
-+ qcom,pdc-ranges = <0 480 94>, <94 609 31>, <125 63 1>;
- #interrupt-cells = <2>;
- interrupt-parent = <&intc>;
- interrupt-controller;
-diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
-index 51a670ad15b2..4b9860a2c8eb 100644
---- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
-+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
-@@ -577,3 +577,14 @@
- };
- };
- };
-+
-+&wifi {
-+ status = "okay";
-+
-+ vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>;
-+ vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
-+ vdd-1.3-rfa-supply = <&vreg_l17a_1p3>;
-+ vdd-3.3-ch0-supply = <&vreg_l25a_3p3>;
-+
-+ qcom,snoc-host-cap-8bit-quirk;
-+};
-diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi
-index 891d83b2afea..2a7eaefd221d 100644
---- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
-+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
-@@ -314,8 +314,8 @@
- };
-
- pdc: interrupt-controller@b220000 {
-- compatible = "qcom,sm8250-pdc";
-- reg = <0x0b220000 0x30000>, <0x17c000f0 0x60>;
-+ compatible = "qcom,sm8250-pdc", "qcom,pdc";
-+ reg = <0 0x0b220000 0 0x30000>, <0 0x17c000f0 0 0x60>;
- qcom,pdc-ranges = <0 480 94>, <94 609 31>,
- <125 63 1>, <126 716 12>;
- #interrupt-cells = <2>;
-diff --git a/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts b/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts
-index b2dd583146b4..b2e44c6c2d22 100644
---- a/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts
-+++ b/arch/arm64/boot/dts/realtek/rtd1293-ds418j.dts
-@@ -1,6 +1,6 @@
- // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
- /*
-- * Copyright (c) 2017 Andreas Färber
-+ * Copyright (c) 2017-2019 Andreas Färber
- */
-
- /dts-v1/;
-@@ -11,9 +11,9 @@
- compatible = "synology,ds418j", "realtek,rtd1293";
- model = "Synology DiskStation DS418j";
-
-- memory@0 {
-+ memory@1f000 {
- device_type = "memory";
-- reg = <0x0 0x40000000>;
-+ reg = <0x1f000 0x3ffe1000>; /* boot ROM to 1 GiB */
- };
-
- aliases {
-diff --git a/arch/arm64/boot/dts/realtek/rtd1293.dtsi b/arch/arm64/boot/dts/realtek/rtd1293.dtsi
-index bd4e22723f7b..2d92b56ac94d 100644
---- a/arch/arm64/boot/dts/realtek/rtd1293.dtsi
-+++ b/arch/arm64/boot/dts/realtek/rtd1293.dtsi
-@@ -36,16 +36,20 @@
- timer {
- compatible = "arm,armv8-timer";
- interrupts = <GIC_PPI 13
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 14
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 11
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 10
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>;
-+ (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
- };
- };
-
- &arm_pmu {
- interrupt-affinity = <&cpu0>, <&cpu1>;
- };
-+
-+&gic {
-+ interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
-+};
-diff --git a/arch/arm64/boot/dts/realtek/rtd1295-mele-v9.dts b/arch/arm64/boot/dts/realtek/rtd1295-mele-v9.dts
-index bd584e99fff9..cf4a57c012a8 100644
---- a/arch/arm64/boot/dts/realtek/rtd1295-mele-v9.dts
-+++ b/arch/arm64/boot/dts/realtek/rtd1295-mele-v9.dts
-@@ -1,5 +1,5 @@
- /*
-- * Copyright (c) 2017 Andreas Färber
-+ * Copyright (c) 2017-2019 Andreas Färber
- *
- * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
- */
-@@ -12,9 +12,9 @@
- compatible = "mele,v9", "realtek,rtd1295";
- model = "MeLE V9";
-
-- memory@0 {
-+ memory@1f000 {
- device_type = "memory";
-- reg = <0x0 0x80000000>;
-+ reg = <0x1f000 0x7ffe1000>; /* boot ROM to 2 GiB */
- };
-
- aliases {
-diff --git a/arch/arm64/boot/dts/realtek/rtd1295-probox2-ava.dts b/arch/arm64/boot/dts/realtek/rtd1295-probox2-ava.dts
-index 8e2b0e75298a..14161c3f304d 100644
---- a/arch/arm64/boot/dts/realtek/rtd1295-probox2-ava.dts
-+++ b/arch/arm64/boot/dts/realtek/rtd1295-probox2-ava.dts
-@@ -1,5 +1,5 @@
- /*
-- * Copyright (c) 2017 Andreas Färber
-+ * Copyright (c) 2017-2019 Andreas Färber
- *
- * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
- */
-@@ -12,9 +12,9 @@
- compatible = "probox2,ava", "realtek,rtd1295";
- model = "PROBOX2 AVA";
-
-- memory@0 {
-+ memory@1f000 {
- device_type = "memory";
-- reg = <0x0 0x80000000>;
-+ reg = <0x1f000 0x7ffe1000>; /* boot ROM to 2 GiB */
- };
-
- aliases {
-diff --git a/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts b/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts
-index e98e508b9514..4beb37bb9522 100644
---- a/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts
-+++ b/arch/arm64/boot/dts/realtek/rtd1295-zidoo-x9s.dts
-@@ -11,9 +11,9 @@
- compatible = "zidoo,x9s", "realtek,rtd1295";
- model = "Zidoo X9S";
-
-- memory@0 {
-+ memory@1f000 {
- device_type = "memory";
-- reg = <0x0 0x80000000>;
-+ reg = <0x1f000 0x7ffe1000>; /* boot ROM to 2 GiB */
- };
-
- aliases {
-diff --git a/arch/arm64/boot/dts/realtek/rtd1295.dtsi b/arch/arm64/boot/dts/realtek/rtd1295.dtsi
-index 93f0e1d97721..1402abe80ea1 100644
---- a/arch/arm64/boot/dts/realtek/rtd1295.dtsi
-+++ b/arch/arm64/boot/dts/realtek/rtd1295.dtsi
-@@ -2,7 +2,7 @@
- /*
- * Realtek RTD1295 SoC
- *
-- * Copyright (c) 2016-2017 Andreas Färber
-+ * Copyright (c) 2016-2019 Andreas Färber
- */
-
- #include "rtd129x.dtsi"
-@@ -47,27 +47,16 @@
- };
- };
-
-- reserved-memory {
-- #address-cells = <1>;
-- #size-cells = <1>;
-- ranges;
--
-- tee@10100000 {
-- reg = <0x10100000 0xf00000>;
-- no-map;
-- };
-- };
--
- timer {
- compatible = "arm,armv8-timer";
- interrupts = <GIC_PPI 13
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 14
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 11
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 10
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>;
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
- };
- };
-
-diff --git a/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts b/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts
-index 5a051a52bf88..cc706d13da8b 100644
---- a/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts
-+++ b/arch/arm64/boot/dts/realtek/rtd1296-ds418.dts
-@@ -11,9 +11,9 @@
- compatible = "synology,ds418", "realtek,rtd1296";
- model = "Synology DiskStation DS418";
-
-- memory@0 {
-+ memory@1f000 {
- device_type = "memory";
-- reg = <0x0 0x80000000>;
-+ reg = <0x1f000 0x7ffe1000>; /* boot ROM to 2 GiB */
- };
-
- aliases {
-diff --git a/arch/arm64/boot/dts/realtek/rtd1296.dtsi b/arch/arm64/boot/dts/realtek/rtd1296.dtsi
-index 0f9e59cac086..fb864a139c97 100644
---- a/arch/arm64/boot/dts/realtek/rtd1296.dtsi
-+++ b/arch/arm64/boot/dts/realtek/rtd1296.dtsi
-@@ -50,13 +50,13 @@
- timer {
- compatible = "arm,armv8-timer";
- interrupts = <GIC_PPI 13
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 14
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 11
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>,
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
- <GIC_PPI 10
-- (GIC_CPU_MASK_RAW(0xf) | IRQ_TYPE_LEVEL_LOW)>;
-+ (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
- };
- };
-
-diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
-index 4433114476f5..b63d0c03597a 100644
---- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi
-+++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
-@@ -2,14 +2,12 @@
- /*
- * Realtek RTD1293/RTD1295/RTD1296 SoC
- *
-- * Copyright (c) 2016-2017 Andreas Färber
-+ * Copyright (c) 2016-2019 Andreas Färber
- */
-
--/memreserve/ 0x0000000000000000 0x0000000000030000;
--/memreserve/ 0x000000000001f000 0x0000000000001000;
--/memreserve/ 0x0000000000030000 0x00000000000d0000;
-+/memreserve/ 0x0000000000000000 0x000000000001f000;
-+/memreserve/ 0x000000000001f000 0x00000000000e1000;
- /memreserve/ 0x0000000001b00000 0x00000000004be000;
--/memreserve/ 0x0000000001ffe000 0x0000000000004000;
-
- #include <dt-bindings/interrupt-controller/arm-gic.h>
- #include <dt-bindings/reset/realtek,rtd1295.h>
-@@ -19,6 +17,25 @@
- #address-cells = <1>;
- #size-cells = <1>;
-
-+ reserved-memory {
-+ #address-cells = <1>;
-+ #size-cells = <1>;
-+ ranges;
-+
-+ rpc_comm: rpc@1f000 {
-+ reg = <0x1f000 0x1000>;
-+ };
-+
-+ rpc_ringbuf: rpc@1ffe000 {
-+ reg = <0x1ffe000 0x4000>;
-+ };
-+
-+ tee: tee@10100000 {
-+ reg = <0x10100000 0xf00000>;
-+ no-map;
-+ };
-+ };
-+
- arm_pmu: arm-pmu {
- compatible = "arm,cortex-a53-pmu";
- interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
-@@ -35,8 +52,9 @@
- compatible = "simple-bus";
- #address-cells = <1>;
- #size-cells = <1>;
-- /* Exclude up to 2 GiB of RAM */
-- ranges = <0x80000000 0x80000000 0x80000000>;
-+ ranges = <0x00000000 0x00000000 0x0001f000>, /* boot ROM */
-+ /* Exclude up to 2 GiB of RAM */
-+ <0x80000000 0x80000000 0x80000000>;
-
- reset1: reset-controller@98000000 {
- compatible = "snps,dw-low-reset";
-diff --git a/arch/arm64/boot/dts/renesas/r8a774a1.dtsi b/arch/arm64/boot/dts/renesas/r8a774a1.dtsi
-index 79023433a740..a603d947970e 100644
---- a/arch/arm64/boot/dts/renesas/r8a774a1.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a774a1.dtsi
-@@ -1000,7 +1000,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -1008,7 +1008,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -1016,7 +1016,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -1024,7 +1024,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -1033,7 +1033,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -1041,7 +1041,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 5>;
-@@ -1049,7 +1049,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv1: mmu@fd950000 {
-+ ipmmu_pv1: iommu@fd950000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xfd950000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -1057,7 +1057,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 8>;
-@@ -1065,7 +1065,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a774a1";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 9>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a774b1.dtsi b/arch/arm64/boot/dts/renesas/r8a774b1.dtsi
-index 3137f735974b..1e51855c7cd3 100644
---- a/arch/arm64/boot/dts/renesas/r8a774b1.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a774b1.dtsi
-@@ -874,7 +874,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -882,7 +882,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -890,7 +890,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -898,7 +898,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -907,7 +907,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -915,7 +915,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -923,7 +923,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -931,7 +931,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -939,7 +939,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp0: mmu@fe990000 {
-+ ipmmu_vp0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a774b1";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 16>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a774c0.dtsi b/arch/arm64/boot/dts/renesas/r8a774c0.dtsi
-index 22785cbddff5..5c72a7efbb03 100644
---- a/arch/arm64/boot/dts/renesas/r8a774c0.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a774c0.dtsi
-@@ -847,7 +847,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -855,7 +855,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -863,7 +863,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -871,7 +871,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -880,7 +880,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -888,7 +888,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -896,7 +896,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -904,7 +904,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -912,7 +912,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp0: mmu@fe990000 {
-+ ipmmu_vp0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a774c0";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 16>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77950.dtsi b/arch/arm64/boot/dts/renesas/r8a77950.dtsi
-index 3975eecd50c4..d716c4386ae9 100644
---- a/arch/arm64/boot/dts/renesas/r8a77950.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77950.dtsi
-@@ -77,7 +77,7 @@
- /delete-node/ dma-controller@e6460000;
- /delete-node/ dma-controller@e6470000;
-
-- ipmmu_mp1: mmu@ec680000 {
-+ ipmmu_mp1: iommu@ec680000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xec680000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 5>;
-@@ -85,7 +85,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_sy: mmu@e7730000 {
-+ ipmmu_sy: iommu@e7730000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xe7730000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 8>;
-@@ -93,11 +93,11 @@
- #iommu-cells = <1>;
- };
-
-- /delete-node/ mmu@fd950000;
-- /delete-node/ mmu@fd960000;
-- /delete-node/ mmu@fd970000;
-- /delete-node/ mmu@febe0000;
-- /delete-node/ mmu@fe980000;
-+ /delete-node/ iommu@fd950000;
-+ /delete-node/ iommu@fd960000;
-+ /delete-node/ iommu@fd970000;
-+ /delete-node/ iommu@febe0000;
-+ /delete-node/ iommu@fe980000;
-
- xhci1: usb@ee040000 {
- compatible = "renesas,xhci-r8a7795", "renesas,rcar-gen3-xhci";
-diff --git a/arch/arm64/boot/dts/renesas/r8a77951.dtsi b/arch/arm64/boot/dts/renesas/r8a77951.dtsi
-index 52229546454c..61d67d9714ab 100644
---- a/arch/arm64/boot/dts/renesas/r8a77951.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77951.dtsi
-@@ -1073,7 +1073,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -1081,7 +1081,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -1089,7 +1089,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -1097,7 +1097,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ir: mmu@ff8b0000 {
-+ ipmmu_ir: iommu@ff8b0000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xff8b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 3>;
-@@ -1105,7 +1105,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -1114,7 +1114,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp0: mmu@ec670000 {
-+ ipmmu_mp0: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -1122,7 +1122,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -1130,7 +1130,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv1: mmu@fd950000 {
-+ ipmmu_pv1: iommu@fd950000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfd950000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 7>;
-@@ -1138,7 +1138,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv2: mmu@fd960000 {
-+ ipmmu_pv2: iommu@fd960000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfd960000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 8>;
-@@ -1146,7 +1146,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv3: mmu@fd970000 {
-+ ipmmu_pv3: iommu@fd970000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfd970000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 9>;
-@@ -1154,7 +1154,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 10>;
-@@ -1162,7 +1162,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -1170,7 +1170,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc1: mmu@fe6f0000 {
-+ ipmmu_vc1: iommu@fe6f0000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfe6f0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 13>;
-@@ -1178,7 +1178,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -1186,7 +1186,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi1: mmu@febe0000 {
-+ ipmmu_vi1: iommu@febe0000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfebe0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 15>;
-@@ -1194,7 +1194,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp0: mmu@fe990000 {
-+ ipmmu_vp0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 16>;
-@@ -1202,7 +1202,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp1: mmu@fe980000 {
-+ ipmmu_vp1: iommu@fe980000 {
- compatible = "renesas,ipmmu-r8a7795";
- reg = <0 0xfe980000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 17>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77960.dtsi b/arch/arm64/boot/dts/renesas/r8a77960.dtsi
-index 31282367d3ac..33bf62acffbb 100644
---- a/arch/arm64/boot/dts/renesas/r8a77960.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77960.dtsi
-@@ -997,7 +997,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -1005,7 +1005,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -1013,7 +1013,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -1021,7 +1021,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ir: mmu@ff8b0000 {
-+ ipmmu_ir: iommu@ff8b0000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xff8b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 3>;
-@@ -1029,7 +1029,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -1038,7 +1038,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -1046,7 +1046,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 5>;
-@@ -1054,7 +1054,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv1: mmu@fd950000 {
-+ ipmmu_pv1: iommu@fd950000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xfd950000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -1062,7 +1062,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 7>;
-@@ -1070,7 +1070,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 8>;
-@@ -1078,7 +1078,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a7796";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 9>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
-index d82dd4e67b62..6f7ab39fd282 100644
---- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
-@@ -867,7 +867,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -875,7 +875,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -883,7 +883,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -891,7 +891,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -900,7 +900,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -908,7 +908,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -916,7 +916,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 10>;
-@@ -924,7 +924,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -932,7 +932,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -940,7 +940,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp0: mmu@fe990000 {
-+ ipmmu_vp0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a77965";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 16>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77970.dtsi b/arch/arm64/boot/dts/renesas/r8a77970.dtsi
-index a009c0ebc8b4..bd95ecb1b40d 100644
---- a/arch/arm64/boot/dts/renesas/r8a77970.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77970.dtsi
-@@ -985,7 +985,7 @@
- <&ipmmu_ds1 22>, <&ipmmu_ds1 23>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a77970";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -993,7 +993,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ir: mmu@ff8b0000 {
-+ ipmmu_ir: iommu@ff8b0000 {
- compatible = "renesas,ipmmu-r8a77970";
- reg = <0 0xff8b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 3>;
-@@ -1001,7 +1001,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a77970";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -1010,7 +1010,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a77970";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 7>;
-@@ -1018,7 +1018,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a77970";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 9>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77980.dtsi b/arch/arm64/boot/dts/renesas/r8a77980.dtsi
-index d672b320bc14..387e6d99f2f3 100644
---- a/arch/arm64/boot/dts/renesas/r8a77980.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77980.dtsi
-@@ -1266,7 +1266,7 @@
- status = "disabled";
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -1274,7 +1274,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ir: mmu@ff8b0000 {
-+ ipmmu_ir: iommu@ff8b0000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xff8b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 3>;
-@@ -1282,7 +1282,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -1291,7 +1291,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 10>;
-@@ -1299,7 +1299,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe990000 {
-+ ipmmu_vc0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -1307,7 +1307,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -1315,7 +1315,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vip0: mmu@e7b00000 {
-+ ipmmu_vip0: iommu@e7b00000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xe7b00000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -1323,7 +1323,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vip1: mmu@e7960000 {
-+ ipmmu_vip1: iommu@e7960000 {
- compatible = "renesas,ipmmu-r8a77980";
- reg = <0 0xe7960000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 11>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77990.dtsi b/arch/arm64/boot/dts/renesas/r8a77990.dtsi
-index 1543f18e834f..cd11f24744d4 100644
---- a/arch/arm64/boot/dts/renesas/r8a77990.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77990.dtsi
-@@ -817,7 +817,7 @@
- <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -825,7 +825,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -833,7 +833,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -841,7 +841,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -850,7 +850,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -858,7 +858,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -866,7 +866,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 10>;
-@@ -874,7 +874,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -882,7 +882,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -890,7 +890,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp0: mmu@fe990000 {
-+ ipmmu_vp0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a77990";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 16>;
-diff --git a/arch/arm64/boot/dts/renesas/r8a77995.dtsi b/arch/arm64/boot/dts/renesas/r8a77995.dtsi
-index e8d2290fe79d..e5617ec0f49c 100644
---- a/arch/arm64/boot/dts/renesas/r8a77995.dtsi
-+++ b/arch/arm64/boot/dts/renesas/r8a77995.dtsi
-@@ -507,7 +507,7 @@
- <&ipmmu_ds1 22>, <&ipmmu_ds1 23>;
- };
-
-- ipmmu_ds0: mmu@e6740000 {
-+ ipmmu_ds0: iommu@e6740000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xe6740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 0>;
-@@ -515,7 +515,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_ds1: mmu@e7740000 {
-+ ipmmu_ds1: iommu@e7740000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xe7740000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 1>;
-@@ -523,7 +523,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_hc: mmu@e6570000 {
-+ ipmmu_hc: iommu@e6570000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xe6570000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 2>;
-@@ -531,7 +531,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mm: mmu@e67b0000 {
-+ ipmmu_mm: iommu@e67b0000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xe67b0000 0 0x1000>;
- interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-@@ -540,7 +540,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_mp: mmu@ec670000 {
-+ ipmmu_mp: iommu@ec670000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xec670000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 4>;
-@@ -548,7 +548,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_pv0: mmu@fd800000 {
-+ ipmmu_pv0: iommu@fd800000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xfd800000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 6>;
-@@ -556,7 +556,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_rt: mmu@ffc80000 {
-+ ipmmu_rt: iommu@ffc80000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xffc80000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 10>;
-@@ -564,7 +564,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vc0: mmu@fe6b0000 {
-+ ipmmu_vc0: iommu@fe6b0000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xfe6b0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 12>;
-@@ -572,7 +572,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vi0: mmu@febd0000 {
-+ ipmmu_vi0: iommu@febd0000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xfebd0000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 14>;
-@@ -580,7 +580,7 @@
- #iommu-cells = <1>;
- };
-
-- ipmmu_vp0: mmu@fe990000 {
-+ ipmmu_vp0: iommu@fe990000 {
- compatible = "renesas,ipmmu-r8a77995";
- reg = <0 0xfe990000 0 0x1000>;
- renesas,ipmmu-main = <&ipmmu_mm 16>;
-diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
-index 8618faa82e6d..86a5cf9bc19a 100644
---- a/arch/arm64/kernel/ftrace.c
-+++ b/arch/arm64/kernel/ftrace.c
-@@ -69,7 +69,8 @@ static struct plt_entry *get_ftrace_plt(struct module *mod, unsigned long addr)
-
- if (addr == FTRACE_ADDR)
- return &plt[FTRACE_PLT_IDX];
-- if (addr == FTRACE_REGS_ADDR && IS_ENABLED(CONFIG_FTRACE_WITH_REGS))
-+ if (addr == FTRACE_REGS_ADDR &&
-+ IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
- return &plt[FTRACE_REGS_PLT_IDX];
- #endif
- return NULL;
-diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
-index 0b727edf4104..af234a1e08b7 100644
---- a/arch/arm64/kernel/hw_breakpoint.c
-+++ b/arch/arm64/kernel/hw_breakpoint.c
-@@ -730,6 +730,27 @@ static u64 get_distance_from_watchpoint(unsigned long addr, u64 val,
- return 0;
- }
-
-+static int watchpoint_report(struct perf_event *wp, unsigned long addr,
-+ struct pt_regs *regs)
-+{
-+ int step = is_default_overflow_handler(wp);
-+ struct arch_hw_breakpoint *info = counter_arch_bp(wp);
-+
-+ info->trigger = addr;
-+
-+ /*
-+ * 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 (!user_mode(regs) && info->ctrl.privilege == AARCH64_BREAKPOINT_EL0)
-+ step = 1;
-+ else
-+ perf_bp_event(wp, regs);
-+
-+ return step;
-+}
-+
- static int watchpoint_handler(unsigned long addr, unsigned int esr,
- struct pt_regs *regs)
- {
-@@ -739,7 +760,6 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr,
- u64 val;
- struct perf_event *wp, **slots;
- struct debug_info *debug_info;
-- struct arch_hw_breakpoint *info;
- struct arch_hw_breakpoint_ctrl ctrl;
-
- slots = this_cpu_ptr(wp_on_reg);
-@@ -777,25 +797,13 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr,
- if (dist != 0)
- continue;
-
-- info = counter_arch_bp(wp);
-- info->trigger = addr;
-- perf_bp_event(wp, regs);
--
-- /* Do we need to handle the stepping? */
-- if (is_default_overflow_handler(wp))
-- step = 1;
-+ step = watchpoint_report(wp, addr, regs);
- }
-- if (min_dist > 0 && min_dist != -1) {
-- /* No exact match found. */
-- wp = slots[closest_match];
-- info = counter_arch_bp(wp);
-- info->trigger = addr;
-- perf_bp_event(wp, regs);
-
-- /* Do we need to handle the stepping? */
-- if (is_default_overflow_handler(wp))
-- step = 1;
-- }
-+ /* No exact match found? */
-+ if (min_dist > 0 && min_dist != -1)
-+ step = watchpoint_report(slots[closest_match], addr, regs);
-+
- rcu_read_unlock();
-
- if (!step)
-diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
-index e42727e3568e..3f9010167468 100644
---- a/arch/arm64/mm/init.c
-+++ b/arch/arm64/mm/init.c
-@@ -458,11 +458,6 @@ void __init arm64_memblock_init(void)
- high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
-
- dma_contiguous_reserve(arm64_dma32_phys_limit);
--
--#ifdef CONFIG_ARM64_4K_PAGES
-- hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT);
--#endif
--
- }
-
- void __init bootmem_init(void)
-@@ -478,6 +473,16 @@ void __init bootmem_init(void)
- min_low_pfn = min;
-
- arm64_numa_init();
-+
-+ /*
-+ * must be done after arm64_numa_init() which calls numa_init() to
-+ * initialize node_online_map that gets used in hugetlb_cma_reserve()
-+ * while allocating required CMA size across online nodes.
-+ */
-+#ifdef CONFIG_ARM64_4K_PAGES
-+ hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT);
-+#endif
-+
- /*
- * Sparsemem tries to allocate bootmem in memory_present(), so must be
- * done after the fixed reservations.
-diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
-index 62b0eb6cf69a..84eab0f5e00a 100644
---- a/arch/m68k/coldfire/pci.c
-+++ b/arch/m68k/coldfire/pci.c
-@@ -216,8 +216,10 @@ static int __init mcf_pci_init(void)
-
- /* Keep a virtual mapping to IO/config space active */
- iospace = (unsigned long) ioremap(PCI_IO_PA, PCI_IO_SIZE);
-- if (iospace == 0)
-+ if (iospace == 0) {
-+ pci_free_host_bridge(bridge);
- return -ENODEV;
-+ }
- pr_info("Coldfire: PCI IO/config window mapped to 0x%x\n",
- (u32) iospace);
-
-diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
-index e4a78571f883..c6481cfc5220 100644
---- a/arch/openrisc/kernel/entry.S
-+++ b/arch/openrisc/kernel/entry.S
-@@ -1166,13 +1166,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.jal _sys_rt_sigreturn
-diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
-index 62aca9efbbbe..310957b988e3 100644
---- a/arch/powerpc/Kconfig
-+++ b/arch/powerpc/Kconfig
-@@ -773,6 +773,7 @@ config THREAD_SHIFT
- range 13 15
- default "15" if PPC_256K_PAGES
- default "14" if PPC64
-+ default "14" if KASAN
- default "13"
- help
- Used to define the stack size. The default is almost always what you
-diff --git a/arch/powerpc/configs/adder875_defconfig b/arch/powerpc/configs/adder875_defconfig
-index f55e23cb176c..5326bc739279 100644
---- a/arch/powerpc/configs/adder875_defconfig
-+++ b/arch/powerpc/configs/adder875_defconfig
-@@ -10,7 +10,6 @@ CONFIG_EXPERT=y
- # CONFIG_BLK_DEV_BSG is not set
- CONFIG_PARTITION_ADVANCED=y
- CONFIG_PPC_ADDER875=y
--CONFIG_8xx_COPYBACK=y
- CONFIG_GEN_RTC=y
- CONFIG_HZ_1000=y
- # CONFIG_SECCOMP is not set
-diff --git a/arch/powerpc/configs/ep88xc_defconfig b/arch/powerpc/configs/ep88xc_defconfig
-index 0e2e5e81a359..f5c3e72da719 100644
---- a/arch/powerpc/configs/ep88xc_defconfig
-+++ b/arch/powerpc/configs/ep88xc_defconfig
-@@ -12,7 +12,6 @@ CONFIG_EXPERT=y
- # CONFIG_BLK_DEV_BSG is not set
- CONFIG_PARTITION_ADVANCED=y
- CONFIG_PPC_EP88XC=y
--CONFIG_8xx_COPYBACK=y
- CONFIG_GEN_RTC=y
- CONFIG_HZ_100=y
- # CONFIG_SECCOMP is not set
-diff --git a/arch/powerpc/configs/mpc866_ads_defconfig b/arch/powerpc/configs/mpc866_ads_defconfig
-index 5320735395e7..5c56d36cdfc5 100644
---- a/arch/powerpc/configs/mpc866_ads_defconfig
-+++ b/arch/powerpc/configs/mpc866_ads_defconfig
-@@ -12,7 +12,6 @@ CONFIG_EXPERT=y
- # CONFIG_BLK_DEV_BSG is not set
- CONFIG_PARTITION_ADVANCED=y
- CONFIG_MPC86XADS=y
--CONFIG_8xx_COPYBACK=y
- CONFIG_GEN_RTC=y
- CONFIG_HZ_1000=y
- CONFIG_MATH_EMULATION=y
-diff --git a/arch/powerpc/configs/mpc885_ads_defconfig b/arch/powerpc/configs/mpc885_ads_defconfig
-index 82a008c04eae..949ff9ccda5e 100644
---- a/arch/powerpc/configs/mpc885_ads_defconfig
-+++ b/arch/powerpc/configs/mpc885_ads_defconfig
-@@ -11,7 +11,6 @@ CONFIG_EXPERT=y
- # CONFIG_VM_EVENT_COUNTERS is not set
- # CONFIG_BLK_DEV_BSG is not set
- CONFIG_PARTITION_ADVANCED=y
--CONFIG_8xx_COPYBACK=y
- CONFIG_GEN_RTC=y
- CONFIG_HZ_100=y
- # CONFIG_SECCOMP is not set
-diff --git a/arch/powerpc/configs/tqm8xx_defconfig b/arch/powerpc/configs/tqm8xx_defconfig
-index eda8bfb2d0a3..77857d513022 100644
---- a/arch/powerpc/configs/tqm8xx_defconfig
-+++ b/arch/powerpc/configs/tqm8xx_defconfig
-@@ -15,7 +15,6 @@ CONFIG_MODULE_SRCVERSION_ALL=y
- # CONFIG_BLK_DEV_BSG is not set
- CONFIG_PARTITION_ADVANCED=y
- CONFIG_TQM8XX=y
--CONFIG_8xx_COPYBACK=y
- # CONFIG_8xx_CPU15 is not set
- CONFIG_GEN_RTC=y
- CONFIG_HZ_100=y
-diff --git a/arch/powerpc/include/asm/book3s/64/kup-radix.h b/arch/powerpc/include/asm/book3s/64/kup-radix.h
-index 3bcef989a35d..101d60f16d46 100644
---- a/arch/powerpc/include/asm/book3s/64/kup-radix.h
-+++ b/arch/powerpc/include/asm/book3s/64/kup-radix.h
-@@ -16,7 +16,9 @@
- #ifdef CONFIG_PPC_KUAP
- BEGIN_MMU_FTR_SECTION_NESTED(67)
- ld \gpr, STACK_REGS_KUAP(r1)
-+ isync
- mtspr SPRN_AMR, \gpr
-+ /* No isync required, see kuap_restore_amr() */
- END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
- #endif
- .endm
-@@ -62,8 +64,15 @@
-
- static inline void kuap_restore_amr(struct pt_regs *regs)
- {
-- if (mmu_has_feature(MMU_FTR_RADIX_KUAP))
-+ if (mmu_has_feature(MMU_FTR_RADIX_KUAP)) {
-+ isync();
- mtspr(SPRN_AMR, regs->kuap);
-+ /*
-+ * No isync required here because we are about to RFI back to
-+ * previous context before any user accesses would be made,
-+ * which is a CSI.
-+ */
-+ }
- }
-
- static inline void kuap_check_amr(void)
-diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
-index 368b136517e0..2838b98bc6df 100644
---- a/arch/powerpc/include/asm/book3s/64/pgtable.h
-+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
-@@ -998,10 +998,25 @@ extern struct page *pgd_page(pgd_t pgd);
- #define pud_page_vaddr(pud) __va(pud_val(pud) & ~PUD_MASKED_BITS)
- #define pgd_page_vaddr(pgd) __va(pgd_val(pgd) & ~PGD_MASKED_BITS)
-
--#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
--#define pud_index(address) (((address) >> (PUD_SHIFT)) & (PTRS_PER_PUD - 1))
--#define pmd_index(address) (((address) >> (PMD_SHIFT)) & (PTRS_PER_PMD - 1))
--#define pte_index(address) (((address) >> (PAGE_SHIFT)) & (PTRS_PER_PTE - 1))
-+static inline unsigned long pgd_index(unsigned long address)
-+{
-+ return (address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1);
-+}
-+
-+static inline unsigned long pud_index(unsigned long address)
-+{
-+ return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
-+}
-+
-+static inline unsigned long pmd_index(unsigned long address)
-+{
-+ return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
-+}
-+
-+static inline unsigned long pte_index(unsigned long address)
-+{
-+ return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
-+}
-
- /*
- * Find an entry in a page-table-directory. We combine the address region
-diff --git a/arch/powerpc/include/asm/nohash/32/mmu-8xx.h b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h
-index 76af5b0cb16e..26b7cee34dfe 100644
---- a/arch/powerpc/include/asm/nohash/32/mmu-8xx.h
-+++ b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h
-@@ -19,7 +19,6 @@
- #define MI_RSV4I 0x08000000 /* Reserve 4 TLB entries */
- #define MI_PPCS 0x02000000 /* Use MI_RPN prob/priv state */
- #define MI_IDXMASK 0x00001f00 /* TLB index to be loaded */
--#define MI_RESETVAL 0x00000000 /* Value of register at reset */
-
- /* These are the Ks and Kp from the PowerPC books. For proper operation,
- * Ks = 0, Kp = 1.
-@@ -95,7 +94,6 @@
- #define MD_TWAM 0x04000000 /* Use 4K page hardware assist */
- #define MD_PPCS 0x02000000 /* Use MI_RPN prob/priv state */
- #define MD_IDXMASK 0x00001f00 /* TLB index to be loaded */
--#define MD_RESETVAL 0x04000000 /* Value of register at reset */
-
- #define SPRN_M_CASID 793 /* Address space ID (context) to match */
- #define MC_ASIDMASK 0x0000000f /* Bits used for ASID value */
-diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
-index eedcbfb9a6ff..c220cb9eccad 100644
---- a/arch/powerpc/include/asm/processor.h
-+++ b/arch/powerpc/include/asm/processor.h
-@@ -301,7 +301,6 @@ struct thread_struct {
- #else
- #define INIT_THREAD { \
- .ksp = INIT_SP, \
-- .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
- .addr_limit = KERNEL_DS, \
- .fpexc_mode = 0, \
- .fscr = FSCR_TAR | FSCR_EBB \
-diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
-index ebeebab74b56..d9ddce40bed8 100644
---- a/arch/powerpc/kernel/exceptions-64s.S
-+++ b/arch/powerpc/kernel/exceptions-64s.S
-@@ -270,7 +270,7 @@ BEGIN_FTR_SECTION
- END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
- .endif
-
-- ld r10,PACA_EXGEN+EX_CTR(r13)
-+ ld r10,IAREA+EX_CTR(r13)
- mtctr r10
- BEGIN_FTR_SECTION
- ld r10,IAREA+EX_PPR(r13)
-@@ -298,7 +298,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
-
- .if IKVM_SKIP
- 89: mtocrf 0x80,r9
-- ld r10,PACA_EXGEN+EX_CTR(r13)
-+ ld r10,IAREA+EX_CTR(r13)
- mtctr r10
- ld r9,IAREA+EX_R9(r13)
- ld r10,IAREA+EX_R10(r13)
-@@ -1117,11 +1117,30 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
- li r10,MSR_RI
- mtmsrd r10,1
-
-+ /*
-+ * Set IRQS_ALL_DISABLED and save PACAIRQHAPPENED (see
-+ * system_reset_common)
-+ */
-+ li r10,IRQS_ALL_DISABLED
-+ stb r10,PACAIRQSOFTMASK(r13)
-+ lbz r10,PACAIRQHAPPENED(r13)
-+ std r10,RESULT(r1)
-+ ori r10,r10,PACA_IRQ_HARD_DIS
-+ stb r10,PACAIRQHAPPENED(r13)
-+
- addi r3,r1,STACK_FRAME_OVERHEAD
- bl machine_check_early
- std r3,RESULT(r1) /* Save result */
- ld r12,_MSR(r1)
-
-+ /*
-+ * Restore soft mask settings.
-+ */
-+ ld r10,RESULT(r1)
-+ stb r10,PACAIRQHAPPENED(r13)
-+ ld r10,SOFTE(r1)
-+ stb r10,PACAIRQSOFTMASK(r13)
-+
- #ifdef CONFIG_PPC_P7_NAP
- /*
- * Check if thread was in power saving mode. We come here when any
-@@ -1225,17 +1244,19 @@ EXC_COMMON_BEGIN(machine_check_idle_common)
- bl machine_check_queue_event
-
- /*
-- * We have not used any non-volatile GPRs here, and as a rule
-- * most exception code including machine check does not.
-- * Therefore PACA_NAPSTATELOST does not need to be set. Idle
-- * wakeup will restore volatile registers.
-+ * GPR-loss wakeups are relatively straightforward, because the
-+ * idle sleep code has saved all non-volatile registers on its
-+ * own stack, and r1 in PACAR1.
- *
-- * Load the original SRR1 into r3 for pnv_powersave_wakeup_mce.
-+ * For no-loss wakeups the r1 and lr registers used by the
-+ * early machine check handler have to be restored first. r2 is
-+ * the kernel TOC, so no need to restore it.
- *
- * Then decrement MCE nesting after finishing with the stack.
- */
- ld r3,_MSR(r1)
- ld r4,_LINK(r1)
-+ ld r1,GPR1(r1)
-
- lhz r11,PACA_IN_MCE(r13)
- subi r11,r11,1
-@@ -1244,7 +1265,7 @@ EXC_COMMON_BEGIN(machine_check_idle_common)
- mtlr r4
- rlwinm r10,r3,47-31,30,31
- cmpwi cr1,r10,2
-- bltlr cr1 /* no state loss, return to idle caller */
-+ bltlr cr1 /* no state loss, return to idle caller with r3=SRR1 */
- b idle_return_gpr_loss
- #endif
-
-diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
-index ddfbd02140d9..0e05a9a47a4b 100644
---- a/arch/powerpc/kernel/head_64.S
-+++ b/arch/powerpc/kernel/head_64.S
-@@ -947,15 +947,8 @@ start_here_multiplatform:
- std r0,0(r4)
- #endif
-
-- /* The following gets the stack set up with the regs */
-- /* pointing to the real addr of the kernel stack. This is */
-- /* all done to support the C function call below which sets */
-- /* up the htab. This is done because we have relocated the */
-- /* kernel but are still running in real mode. */
--
-- LOAD_REG_ADDR(r3,init_thread_union)
--
- /* set up a stack pointer */
-+ LOAD_REG_ADDR(r3,init_thread_union)
- LOAD_REG_IMMEDIATE(r1,THREAD_SIZE)
- add r1,r3,r1
- li r0,0
-diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
-index 073a651787df..905205c79a25 100644
---- a/arch/powerpc/kernel/head_8xx.S
-+++ b/arch/powerpc/kernel/head_8xx.S
-@@ -779,10 +779,7 @@ start_here:
- initial_mmu:
- li r8, 0
- mtspr SPRN_MI_CTR, r8 /* remove PINNED ITLB entries */
-- lis r10, MD_RESETVAL@h
--#ifndef CONFIG_8xx_COPYBACK
-- oris r10, r10, MD_WTDEF@h
--#endif
-+ lis r10, MD_TWAM@h
- mtspr SPRN_MD_CTR, r10 /* remove PINNED DTLB entries */
-
- tlbia /* Invalidate all TLB entries */
-@@ -857,17 +854,7 @@ initial_mmu:
- mtspr SPRN_DC_CST, r8
- lis r8, IDC_ENABLE@h
- mtspr SPRN_IC_CST, r8
--#ifdef CONFIG_8xx_COPYBACK
-- mtspr SPRN_DC_CST, r8
--#else
-- /* For a debug option, I left this here to easily enable
-- * the write through cache mode
-- */
-- lis r8, DC_SFWT@h
- mtspr SPRN_DC_CST, r8
-- lis r8, IDC_ENABLE@h
-- mtspr SPRN_DC_CST, r8
--#endif
- /* Disable debug mode entry on breakpoints */
- mfspr r8, SPRN_DER
- #ifdef CONFIG_PERF_EVENTS
-diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
-index 9c21288f8645..774476be591b 100644
---- a/arch/powerpc/kernel/process.c
-+++ b/arch/powerpc/kernel/process.c
-@@ -1241,29 +1241,31 @@ struct task_struct *__switch_to(struct task_struct *prev,
- static void show_instructions(struct pt_regs *regs)
- {
- int i;
-+ unsigned long nip = regs->nip;
- unsigned long pc = regs->nip - (NR_INSN_TO_PRINT * 3 / 4 * sizeof(int));
-
- printk("Instruction dump:");
-
-+ /*
-+ * If we were executing with the MMU off for instructions, adjust pc
-+ * rather than printing XXXXXXXX.
-+ */
-+ if (!IS_ENABLED(CONFIG_BOOKE) && !(regs->msr & MSR_IR)) {
-+ pc = (unsigned long)phys_to_virt(pc);
-+ nip = (unsigned long)phys_to_virt(regs->nip);
-+ }
-+
- for (i = 0; i < NR_INSN_TO_PRINT; i++) {
- int instr;
-
- if (!(i % 8))
- pr_cont("\n");
-
--#if !defined(CONFIG_BOOKE)
-- /* If executing with the IMMU off, adjust pc rather
-- * than print XXXXXXXX.
-- */
-- if (!(regs->msr & MSR_IR))
-- pc = (unsigned long)phys_to_virt(pc);
--#endif
--
- if (!__kernel_text_address(pc) ||
- probe_kernel_address((const void *)pc, instr)) {
- pr_cont("XXXXXXXX ");
- } else {
-- if (regs->nip == pc)
-+ if (nip == pc)
- pr_cont("<%08x> ", instr);
- else
- pr_cont("%08x ", instr);
-diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c
-index 078fe3d76feb..56da5eb2b923 100644
---- a/arch/powerpc/kexec/core.c
-+++ b/arch/powerpc/kexec/core.c
-@@ -115,11 +115,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;
-@@ -178,6 +179,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);
- }
-@@ -186,7 +188,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/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
-index aa12cd4078b3..bc6c1aa3d0e9 100644
---- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
-+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
-@@ -353,7 +353,13 @@ static struct kmem_cache *kvm_pmd_cache;
-
- static pte_t *kvmppc_pte_alloc(void)
- {
-- return kmem_cache_alloc(kvm_pte_cache, GFP_KERNEL);
-+ pte_t *pte;
-+
-+ pte = kmem_cache_alloc(kvm_pte_cache, GFP_KERNEL);
-+ /* pmd_populate() will only reference _pa(pte). */
-+ kmemleak_ignore(pte);
-+
-+ return pte;
- }
-
- static void kvmppc_pte_free(pte_t *ptep)
-@@ -363,7 +369,13 @@ static void kvmppc_pte_free(pte_t *ptep)
-
- static pmd_t *kvmppc_pmd_alloc(void)
- {
-- return kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL);
-+ pmd_t *pmd;
-+
-+ pmd = kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL);
-+ /* pud_populate() will only reference _pa(pmd). */
-+ kmemleak_ignore(pmd);
-+
-+ return pmd;
- }
-
- static void kvmppc_pmd_free(pmd_t *pmdp)
-diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
-index 50555ad1db93..1a529df0ab44 100644
---- a/arch/powerpc/kvm/book3s_64_vio.c
-+++ b/arch/powerpc/kvm/book3s_64_vio.c
-@@ -73,6 +73,7 @@ extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm,
- struct kvmppc_spapr_tce_iommu_table *stit, *tmp;
- struct iommu_table_group *table_group = NULL;
-
-+ rcu_read_lock();
- list_for_each_entry_rcu(stt, &kvm->arch.spapr_tce_tables, list) {
-
- table_group = iommu_group_get_iommudata(grp);
-@@ -87,7 +88,9 @@ extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm,
- kref_put(&stit->kref, kvm_spapr_tce_liobn_put);
- }
- }
-+ cond_resched_rcu();
- }
-+ rcu_read_unlock();
- }
-
- extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
-@@ -105,12 +108,14 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
- if (!f.file)
- return -EBADF;
-
-+ rcu_read_lock();
- list_for_each_entry_rcu(stt, &kvm->arch.spapr_tce_tables, list) {
- if (stt == f.file->private_data) {
- found = true;
- break;
- }
- }
-+ rcu_read_unlock();
-
- fdput(f);
-
-@@ -143,6 +148,7 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
- if (!tbl)
- return -EINVAL;
-
-+ rcu_read_lock();
- list_for_each_entry_rcu(stit, &stt->iommu_tables, next) {
- if (tbl != stit->tbl)
- continue;
-@@ -150,14 +156,17 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
- if (!kref_get_unless_zero(&stit->kref)) {
- /* stit is being destroyed */
- iommu_tce_table_put(tbl);
-+ rcu_read_unlock();
- return -ENOTTY;
- }
- /*
- * The table is already known to this KVM, we just increased
- * its KVM reference counter and can return.
- */
-+ rcu_read_unlock();
- return 0;
- }
-+ rcu_read_unlock();
-
- stit = kzalloc(sizeof(*stit), GFP_KERNEL);
- if (!stit) {
-@@ -365,18 +374,19 @@ static long kvmppc_tce_validate(struct kvmppc_spapr_tce_table *stt,
- if (kvmppc_tce_to_ua(stt->kvm, tce, &ua))
- return H_TOO_HARD;
-
-+ rcu_read_lock();
- list_for_each_entry_rcu(stit, &stt->iommu_tables, next) {
- unsigned long hpa = 0;
- struct mm_iommu_table_group_mem_t *mem;
- long shift = stit->tbl->it_page_shift;
-
- mem = mm_iommu_lookup(stt->kvm->mm, ua, 1ULL << shift);
-- if (!mem)
-- return H_TOO_HARD;
--
-- if (mm_iommu_ua_to_hpa(mem, ua, shift, &hpa))
-+ if (!mem || mm_iommu_ua_to_hpa(mem, ua, shift, &hpa)) {
-+ rcu_read_unlock();
- return H_TOO_HARD;
-+ }
- }
-+ rcu_read_unlock();
-
- return H_SUCCESS;
- }
-diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
-index 93493f0cbfe8..ee581cde4878 100644
---- a/arch/powerpc/kvm/book3s_hv.c
-+++ b/arch/powerpc/kvm/book3s_hv.c
-@@ -1099,9 +1099,14 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
- ret = kvmppc_h_svm_init_done(vcpu->kvm);
- break;
- case H_SVM_INIT_ABORT:
-- ret = H_UNSUPPORTED;
-- if (kvmppc_get_srr1(vcpu) & MSR_S)
-- ret = kvmppc_h_svm_init_abort(vcpu->kvm);
-+ /*
-+ * Even if that call is made by the Ultravisor, the SSR1 value
-+ * is the guest context one, with the secure bit clear as it has
-+ * not yet been secured. So we can't check it here.
-+ * Instead the kvm->arch.secure_guest flag is checked inside
-+ * kvmppc_h_svm_init_abort().
-+ */
-+ ret = kvmppc_h_svm_init_abort(vcpu->kvm);
- break;
-
- default:
-diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c
-index 39ba53ca5bb5..a9b2cbc74797 100644
---- a/arch/powerpc/mm/book3s32/mmu.c
-+++ b/arch/powerpc/mm/book3s32/mmu.c
-@@ -187,6 +187,7 @@ void mmu_mark_initmem_nx(void)
- int i;
- unsigned long base = (unsigned long)_stext - PAGE_OFFSET;
- unsigned long top = (unsigned long)_etext - PAGE_OFFSET;
-+ unsigned long border = (unsigned long)__init_begin - PAGE_OFFSET;
- unsigned long size;
-
- if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
-@@ -201,9 +202,10 @@ void mmu_mark_initmem_nx(void)
- size = block_size(base, top);
- size = max(size, 128UL << 10);
- if ((top - base) > size) {
-- if (strict_kernel_rwx_enabled())
-- pr_warn("Kernel _etext not properly aligned\n");
- size <<= 1;
-+ if (strict_kernel_rwx_enabled() && base + size > border)
-+ pr_warn("Some RW data is getting mapped X. "
-+ "Adjust CONFIG_DATA_SHIFT to avoid that.\n");
- }
- setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_TEXT);
- base += size;
-diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
-index 758ade2c2b6e..b5cc9b23cf02 100644
---- a/arch/powerpc/mm/book3s64/radix_tlb.c
-+++ b/arch/powerpc/mm/book3s64/radix_tlb.c
-@@ -884,9 +884,7 @@ is_local:
- if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
- hstart = (start + PMD_SIZE - 1) & PMD_MASK;
- hend = end & PMD_MASK;
-- if (hstart == hend)
-- hflush = false;
-- else
-+ if (hstart < hend)
- hflush = true;
- }
-
-diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
-index 59e49c0e8154..b7c287adfd59 100644
---- a/arch/powerpc/mm/kasan/kasan_init_32.c
-+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
-@@ -76,15 +76,14 @@ static int __init kasan_init_region(void *start, size_t size)
- return ret;
-
- block = memblock_alloc(k_end - k_start, PAGE_SIZE);
-+ if (!block)
-+ return -ENOMEM;
-
- for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
- pmd_t *pmd = pmd_ptr_k(k_cur);
- void *va = block + k_cur - k_start;
- pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL);
-
-- if (!va)
-- return -ENOMEM;
--
- __set_pte_at(&init_mm, k_cur, pte_offset_kernel(pmd, k_cur), pte, 0);
- }
- flush_tlb_kernel_range(k_start, k_end);
-diff --git a/arch/powerpc/mm/ptdump/shared.c b/arch/powerpc/mm/ptdump/shared.c
-index f7ed2f187cb0..784f8df17f73 100644
---- a/arch/powerpc/mm/ptdump/shared.c
-+++ b/arch/powerpc/mm/ptdump/shared.c
-@@ -30,6 +30,11 @@ static const struct flag_info flag_array[] = {
- .val = _PAGE_PRESENT,
- .set = "present",
- .clear = " ",
-+ }, {
-+ .mask = _PAGE_COHERENT,
-+ .val = _PAGE_COHERENT,
-+ .set = "coherent",
-+ .clear = " ",
- }, {
- .mask = _PAGE_GUARDED,
- .val = _PAGE_GUARDED,
-diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
-index 573e0b309c0c..48e8f4b17b91 100644
---- a/arch/powerpc/perf/hv-24x7.c
-+++ b/arch/powerpc/perf/hv-24x7.c
-@@ -1400,16 +1400,6 @@ static void h_24x7_event_read(struct perf_event *event)
- h24x7hw = &get_cpu_var(hv_24x7_hw);
- h24x7hw->events[i] = event;
- put_cpu_var(h24x7hw);
-- /*
-- * Clear the event count so we can compute the _change_
-- * in the 24x7 raw counter value at the end of the txn.
-- *
-- * Note that we could alternatively read the 24x7 value
-- * now and save its value in event->hw.prev_count. But
-- * that would require issuing a hcall, which would then
-- * defeat the purpose of using the txn interface.
-- */
-- local64_set(&event->count, 0);
- }
-
- put_cpu_var(hv_24x7_reqb);
-diff --git a/arch/powerpc/platforms/4xx/pci.c b/arch/powerpc/platforms/4xx/pci.c
-index e6e2adcc7b64..c13d64c3b019 100644
---- a/arch/powerpc/platforms/4xx/pci.c
-+++ b/arch/powerpc/platforms/4xx/pci.c
-@@ -1242,7 +1242,7 @@ static void __init ppc460sx_pciex_check_link(struct ppc4xx_pciex_port *port)
- if (mbase == NULL) {
- printk(KERN_ERR "%pOF: Can't map internal config space !",
- port->node);
-- goto done;
-+ return;
- }
-
- while (attempt && (0 == (in_le32(mbase + PECFG_460SX_DLLSTA)
-@@ -1252,9 +1252,7 @@ static void __init ppc460sx_pciex_check_link(struct ppc4xx_pciex_port *port)
- }
- if (attempt)
- port->link = 1;
--done:
- iounmap(mbase);
--
- }
-
- static struct ppc4xx_pciex_hwops ppc460sx_pcie_hwops __initdata = {
-diff --git a/arch/powerpc/platforms/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig
-index e0fe670f06f6..b37de62d7e7f 100644
---- a/arch/powerpc/platforms/8xx/Kconfig
-+++ b/arch/powerpc/platforms/8xx/Kconfig
-@@ -98,15 +98,6 @@ menu "MPC8xx CPM Options"
- # 8xx specific questions.
- comment "Generic MPC8xx Options"
-
--config 8xx_COPYBACK
-- bool "Copy-Back Data Cache (else Writethrough)"
-- help
-- Saying Y here will cause the cache on an MPC8xx processor to be used
-- in Copy-Back mode. If you say N here, it is used in Writethrough
-- mode.
--
-- If in doubt, say Y here.
--
- config 8xx_GPIO
- bool "GPIO API Support"
- select GPIOLIB
-diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
-index 2b3dfd0b6cdd..d95954ad4c0a 100644
---- a/arch/powerpc/platforms/powernv/opal.c
-+++ b/arch/powerpc/platforms/powernv/opal.c
-@@ -811,6 +811,10 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
- goto out;
-
- attr = kzalloc(sizeof(*attr), GFP_KERNEL);
-+ if (!attr) {
-+ rc = -ENOMEM;
-+ goto out;
-+ }
- name = kstrdup(export_name, GFP_KERNEL);
- if (!name) {
- rc = -ENOMEM;
-diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
-index 423be34f0f5f..f42fe4e86ce5 100644
---- a/arch/powerpc/platforms/ps3/mm.c
-+++ b/arch/powerpc/platforms/ps3/mm.c
-@@ -200,13 +200,14 @@ void ps3_mm_vas_destroy(void)
- {
- int result;
-
-- DBG("%s:%d: map.vas_id = %llu\n", __func__, __LINE__, map.vas_id);
--
- if (map.vas_id) {
- result = lv1_select_virtual_address_space(0);
-- BUG_ON(result);
-- result = lv1_destruct_virtual_address_space(map.vas_id);
-- BUG_ON(result);
-+ result += lv1_destruct_virtual_address_space(map.vas_id);
-+
-+ if (result) {
-+ lv1_panic(0);
-+ }
-+
- map.vas_id = 0;
- }
- }
-@@ -304,19 +305,20 @@ static void ps3_mm_region_destroy(struct mem_region *r)
- int result;
-
- if (!r->destroy) {
-- pr_info("%s:%d: Not destroying high region: %llxh %llxh\n",
-- __func__, __LINE__, r->base, r->size);
- return;
- }
-
-- DBG("%s:%d: r->base = %llxh\n", __func__, __LINE__, r->base);
--
- if (r->base) {
- result = lv1_release_memory(r->base);
-- BUG_ON(result);
-+
-+ if (result) {
-+ lv1_panic(0);
-+ }
-+
- r->size = r->base = r->offset = 0;
- map.total = map.rm.size;
- }
-+
- ps3_mm_set_repository_highmem(NULL);
- }
-
-diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
-index 1d1da639b8b7..16ba5c542e55 100644
---- a/arch/powerpc/platforms/pseries/ras.c
-+++ b/arch/powerpc/platforms/pseries/ras.c
-@@ -395,10 +395,11 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
- /*
- * Some versions of FWNMI place the buffer inside the 4kB page starting at
- * 0x7000. Other versions place it inside the rtas buffer. We check both.
-+ * Minimum size of the buffer is 16 bytes.
- */
- #define VALID_FWNMI_BUFFER(A) \
-- ((((A) >= 0x7000) && ((A) < 0x7ff0)) || \
-- (((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16))))
-+ ((((A) >= 0x7000) && ((A) <= 0x8000 - 16)) || \
-+ (((A) >= rtas.base) && ((A) <= (rtas.base + rtas.size - 16))))
-
- static inline struct rtas_error_log *fwnmi_get_errlog(void)
- {
-diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
-index 2167bce993ff..ae01be202204 100644
---- a/arch/s390/Kconfig
-+++ b/arch/s390/Kconfig
-@@ -462,6 +462,7 @@ config NUMA
-
- config NODES_SHIFT
- int
-+ depends on NEED_MULTIPLE_NODES
- default "1"
-
- config SCHED_SMT
-diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
-index f073292e9fdb..d9d5de0f67ff 100644
---- a/arch/s390/include/asm/syscall.h
-+++ b/arch/s390/include/asm/syscall.h
-@@ -33,7 +33,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/sh/include/asm/io.h b/arch/sh/include/asm/io.h
-index 39c9ead489e5..b42228906eaf 100644
---- a/arch/sh/include/asm/io.h
-+++ b/arch/sh/include/asm/io.h
-@@ -328,7 +328,7 @@ __ioremap_mode(phys_addr_t offset, unsigned long size, pgprot_t prot)
- #else
- #define __ioremap(offset, size, prot) ((void __iomem *)(offset))
- #define __ioremap_mode(offset, size, prot) ((void __iomem *)(offset))
--#define iounmap(addr) do { } while (0)
-+static inline void iounmap(void __iomem *addr) {}
- #endif /* CONFIG_MMU */
-
- static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)
-diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
-index a8c2f2615fc6..ecc9e8786d57 100644
---- a/arch/sparc/mm/srmmu.c
-+++ b/arch/sparc/mm/srmmu.c
-@@ -383,7 +383,6 @@ pgtable_t pte_alloc_one(struct mm_struct *mm)
- return NULL;
- page = pfn_to_page(__nocache_pa(pte) >> PAGE_SHIFT);
- if (!pgtable_pte_page_ctor(page)) {
-- __free_page(page);
- return NULL;
- }
- return page;
-diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile
-index a290821e355c..2a249f619467 100644
---- a/arch/um/drivers/Makefile
-+++ b/arch/um/drivers/Makefile
-@@ -18,9 +18,9 @@ ubd-objs := ubd_kern.o ubd_user.o
- port-objs := port_kern.o port_user.o
- harddog-objs := harddog_kern.o harddog_user.o
-
--LDFLAGS_pcap.o := -r $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a)
-+LDFLAGS_pcap.o = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a)
-
--LDFLAGS_vde.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libvdeplug.a)
-+LDFLAGS_vde.o = $(shell $(CC) $(CFLAGS) -print-file-name=libvdeplug.a)
-
- targets := pcap_kern.o pcap_user.o vde_kern.o vde_user.o
-
-diff --git a/arch/unicore32/lib/Makefile b/arch/unicore32/lib/Makefile
-index 098981a01841..5af06645b8f0 100644
---- a/arch/unicore32/lib/Makefile
-+++ b/arch/unicore32/lib/Makefile
-@@ -10,12 +10,12 @@ lib-y += strncpy_from_user.o strnlen_user.o
- lib-y += clear_user.o copy_page.o
- lib-y += copy_from_user.o copy_to_user.o
-
--GNU_LIBC_A := $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libc.a)
-+GNU_LIBC_A = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libc.a)
- GNU_LIBC_A_OBJS := memchr.o memcpy.o memmove.o memset.o
- GNU_LIBC_A_OBJS += strchr.o strrchr.o
- GNU_LIBC_A_OBJS += rawmemchr.o # needed by strrchr.o
-
--GNU_LIBGCC_A := $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libgcc.a)
-+GNU_LIBGCC_A = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libgcc.a)
- GNU_LIBGCC_A_OBJS := _ashldi3.o _ashrdi3.o _lshrdi3.o
- GNU_LIBGCC_A_OBJS += _divsi3.o _modsi3.o _ucmpdi2.o _umodsi3.o _udivsi3.o
-
-diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
-index e53dda210cd7..21d2f1de1057 100644
---- a/arch/x86/kernel/apic/apic.c
-+++ b/arch/x86/kernel/apic/apic.c
-@@ -2093,7 +2093,7 @@ void __init init_apic_mappings(void)
- unsigned int new_apicid;
-
- if (apic_validate_deadline_timer())
-- pr_debug("TSC deadline timer available\n");
-+ pr_info("TSC deadline timer available\n");
-
- if (x2apic_mode) {
- boot_cpu_physical_apicid = read_apic_id();
-diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c
-index d089567a9ce8..bcb379b2fd42 100644
---- a/arch/x86/kernel/cpu/mce/dev-mcelog.c
-+++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c
-@@ -343,7 +343,7 @@ static __init int dev_mcelog_init_device(void)
- if (!mcelog)
- return -ENOMEM;
-
-- strncpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature));
-+ memcpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature));
- mcelog->len = mce_log_len;
- mcelog->recordlen = sizeof(struct mce);
-
-diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
-index 87ef69a72c52..7bb4c3cbf4dc 100644
---- a/arch/x86/kernel/idt.c
-+++ b/arch/x86/kernel/idt.c
-@@ -318,7 +318,11 @@ void __init idt_setup_apic_and_irq_gates(void)
-
- #ifdef CONFIG_X86_LOCAL_APIC
- for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
-- set_bit(i, system_vectors);
-+ /*
-+ * Don't set the non assigned system vectors in the
-+ * system_vectors bitmap. Otherwise they show up in
-+ * /proc/interrupts.
-+ */
- entry = spurious_entries_start + 8 * (i - FIRST_SYSTEM_VECTOR);
- set_intr_gate(i, entry);
- }
-diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
-index 4d7022a740ab..a12adbe1559d 100644
---- a/arch/x86/kernel/kprobes/core.c
-+++ b/arch/x86/kernel/kprobes/core.c
-@@ -753,16 +753,11 @@ asm(
- NOKPROBE_SYMBOL(kretprobe_trampoline);
- STACK_FRAME_NON_STANDARD(kretprobe_trampoline);
-
--static struct kprobe kretprobe_kprobe = {
-- .addr = (void *)kretprobe_trampoline,
--};
--
- /*
- * Called from kretprobe_trampoline
- */
- __used __visible void *trampoline_handler(struct pt_regs *regs)
- {
-- struct kprobe_ctlblk *kcb;
- struct kretprobe_instance *ri = NULL;
- struct hlist_head *head, empty_rp;
- struct hlist_node *tmp;
-@@ -772,16 +767,12 @@ __used __visible void *trampoline_handler(struct pt_regs *regs)
- void *frame_pointer;
- bool skipped = false;
-
-- preempt_disable();
--
- /*
- * Set a dummy kprobe for avoiding kretprobe recursion.
- * Since kretprobe never run in kprobe handler, kprobe must not
- * be running at this point.
- */
-- kcb = get_kprobe_ctlblk();
-- __this_cpu_write(current_kprobe, &kretprobe_kprobe);
-- kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-+ kprobe_busy_begin();
-
- INIT_HLIST_HEAD(&empty_rp);
- kretprobe_hash_lock(current, &head, &flags);
-@@ -857,7 +848,7 @@ __used __visible void *trampoline_handler(struct pt_regs *regs)
- __this_cpu_write(current_kprobe, &ri->rp->kp);
- ri->ret_addr = correct_ret_addr;
- ri->rp->handler(ri, regs);
-- __this_cpu_write(current_kprobe, &kretprobe_kprobe);
-+ __this_cpu_write(current_kprobe, &kprobe_busy);
- }
-
- recycle_rp_inst(ri, &empty_rp);
-@@ -873,8 +864,7 @@ __used __visible void *trampoline_handler(struct pt_regs *regs)
-
- kretprobe_hash_unlock(current, &flags);
-
-- __this_cpu_write(current_kprobe, NULL);
-- preempt_enable();
-+ kprobe_busy_end();
-
- hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
- hlist_del(&ri->hlist);
-diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
-index fb4ee5444379..9733d1cc791d 100644
---- a/arch/x86/purgatory/Makefile
-+++ b/arch/x86/purgatory/Makefile
-@@ -17,7 +17,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS
- LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
- targets += purgatory.ro
-
-+# Sanitizer, etc. runtimes are unavailable and cannot be linked here.
-+GCOV_PROFILE := n
- KASAN_SANITIZE := n
-+UBSAN_SANITIZE := n
- KCOV_INSTRUMENT := n
-
- # These are adjustments to the compiler flags used for objects that
-@@ -25,7 +28,7 @@ KCOV_INSTRUMENT := n
-
- PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
- PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss
--PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN)
-+PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
-
- # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
- # in turn leaves some undefined symbols like __fentry__ in purgatory and not
-diff --git a/crypto/algboss.c b/crypto/algboss.c
-index 535f1f87e6c1..5ebccbd6b74e 100644
---- a/crypto/algboss.c
-+++ b/crypto/algboss.c
-@@ -178,8 +178,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/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
-index e2c8ab408bed..4c3bdffe0c3a 100644
---- a/crypto/algif_skcipher.c
-+++ b/crypto/algif_skcipher.c
-@@ -74,14 +74,10 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
- return PTR_ERR(areq);
-
- /* convert iovecs of output buffers into RX SGL */
-- err = af_alg_get_rsgl(sk, msg, flags, areq, -1, &len);
-+ err = af_alg_get_rsgl(sk, msg, flags, areq, ctx->used, &len);
- if (err)
- goto free;
-
-- /* Process only as much RX buffers for which we have TX data */
-- if (len > ctx->used)
-- len = ctx->used;
--
- /*
- * If more buffers are to be expected to be processed, process only
- * full block size buffers.
-diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
-index beca5f91bb4c..e74c8fe2a5fd 100644
---- a/drivers/ata/libata-core.c
-+++ b/drivers/ata/libata-core.c
-@@ -42,7 +42,6 @@
- #include <linux/workqueue.h>
- #include <linux/scatterlist.h>
- #include <linux/io.h>
--#include <linux/async.h>
- #include <linux/log2.h>
- #include <linux/slab.h>
- #include <linux/glob.h>
-@@ -5778,7 +5777,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;
-@@ -5920,11 +5919,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 b27d0f6c18c9..f5d485166fd3 100644
---- a/drivers/base/platform.c
-+++ b/drivers/base/platform.c
-@@ -851,6 +851,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 c5c6487a19d5..7b55811c2a81 100644
---- a/drivers/block/ps3disk.c
-+++ b/drivers/block/ps3disk.c
-@@ -454,7 +454,6 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
- queue->queuedata = dev;
-
- 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/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
-index 97e06cc586e4..8be3d0fb0614 100644
---- a/drivers/bus/mhi/core/main.c
-+++ b/drivers/bus/mhi/core/main.c
-@@ -513,7 +513,10 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
- mhi_cntrl->unmap_single(mhi_cntrl, buf_info);
-
- result.buf_addr = buf_info->cb_buf;
-- result.bytes_xferd = xfer_len;
-+
-+ /* truncate to buf len if xfer_len is larger */
-+ result.bytes_xferd =
-+ min_t(u16, xfer_len, buf_info->len);
- mhi_del_ring_element(mhi_cntrl, buf_ring);
- mhi_del_ring_element(mhi_cntrl, tre_ring);
- local_rp = tre_ring->rp;
-@@ -597,7 +600,9 @@ static int parse_rsc_event(struct mhi_controller *mhi_cntrl,
-
- result.transaction_status = (ev_code == MHI_EV_CC_OVERFLOW) ?
- -EOVERFLOW : 0;
-- result.bytes_xferd = xfer_len;
-+
-+ /* truncate to buf len if xfer_len is larger */
-+ result.bytes_xferd = min_t(u16, xfer_len, buf_info->len);
- result.buf_addr = buf_info->cb_buf;
- result.dir = mhi_chan->dir;
-
-diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
-index c48d8f086382..9afd220cd824 100644
---- a/drivers/char/ipmi/ipmi_msghandler.c
-+++ b/drivers/char/ipmi/ipmi_msghandler.c
-@@ -33,6 +33,7 @@
- #include <linux/workqueue.h>
- #include <linux/uuid.h>
- #include <linux/nospec.h>
-+#include <linux/vmalloc.h>
-
- #define IPMI_DRIVER_VERSION "39.2"
-
-@@ -1153,7 +1154,7 @@ static void free_user_work(struct work_struct *work)
- remove_work);
-
- cleanup_srcu_struct(&user->release_barrier);
-- kfree(user);
-+ vfree(user);
- }
-
- int ipmi_create_user(unsigned int if_num,
-@@ -1185,7 +1186,7 @@ int ipmi_create_user(unsigned int if_num,
- if (rv)
- return rv;
-
-- new_user = kmalloc(sizeof(*new_user), GFP_KERNEL);
-+ new_user = vzalloc(sizeof(*new_user));
- if (!new_user)
- return -ENOMEM;
-
-@@ -1232,7 +1233,7 @@ int ipmi_create_user(unsigned int if_num,
-
- out_kfree:
- srcu_read_unlock(&ipmi_interfaces_srcu, index);
-- kfree(new_user);
-+ vfree(new_user);
- return rv;
- }
- EXPORT_SYMBOL(ipmi_create_user);
-diff --git a/drivers/char/mem.c b/drivers/char/mem.c
-index 43dd0891ca1e..31cae88a730b 100644
---- a/drivers/char/mem.c
-+++ b/drivers/char/mem.c
-@@ -31,11 +31,15 @@
- #include <linux/uio.h>
- #include <linux/uaccess.h>
- #include <linux/security.h>
-+#include <linux/pseudo_fs.h>
-+#include <uapi/linux/magic.h>
-+#include <linux/mount.h>
-
- #ifdef CONFIG_IA64
- # include <linux/efi.h>
- #endif
-
-+#define DEVMEM_MINOR 1
- #define DEVPORT_MINOR 4
-
- static inline unsigned long size_inside_page(unsigned long start,
-@@ -805,12 +809,64 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
- return ret;
- }
-
-+static struct inode *devmem_inode;
-+
-+#ifdef CONFIG_IO_STRICT_DEVMEM
-+void revoke_devmem(struct resource *res)
-+{
-+ struct inode *inode = READ_ONCE(devmem_inode);
-+
-+ /*
-+ * Check that the initialization has completed. Losing the race
-+ * is ok because it means drivers are claiming resources before
-+ * the fs_initcall level of init and prevent /dev/mem from
-+ * establishing mappings.
-+ */
-+ if (!inode)
-+ return;
-+
-+ /*
-+ * The expectation is that the driver has successfully marked
-+ * the resource busy by this point, so devmem_is_allowed()
-+ * should start returning false, however for performance this
-+ * does not iterate the entire resource range.
-+ */
-+ if (devmem_is_allowed(PHYS_PFN(res->start)) &&
-+ devmem_is_allowed(PHYS_PFN(res->end))) {
-+ /*
-+ * *cringe* iomem=relaxed says "go ahead, what's the
-+ * worst that can happen?"
-+ */
-+ return;
-+ }
-+
-+ unmap_mapping_range(inode->i_mapping, res->start, resource_size(res), 1);
-+}
-+#endif
-+
- static int open_port(struct inode *inode, struct file *filp)
- {
-+ int rc;
-+
- if (!capable(CAP_SYS_RAWIO))
- return -EPERM;
-
-- return security_locked_down(LOCKDOWN_DEV_MEM);
-+ rc = security_locked_down(LOCKDOWN_DEV_MEM);
-+ if (rc)
-+ return rc;
-+
-+ if (iminor(inode) != DEVMEM_MINOR)
-+ return 0;
-+
-+ /*
-+ * Use a unified address space to have a single point to manage
-+ * revocations when drivers want to take over a /dev/mem mapped
-+ * range.
-+ */
-+ inode->i_mapping = devmem_inode->i_mapping;
-+ filp->f_mapping = inode->i_mapping;
-+
-+ return 0;
- }
-
- #define zero_lseek null_lseek
-@@ -885,7 +941,7 @@ static const struct memdev {
- fmode_t fmode;
- } devlist[] = {
- #ifdef CONFIG_DEVMEM
-- [1] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET },
-+ [DEVMEM_MINOR] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET },
- #endif
- #ifdef CONFIG_DEVKMEM
- [2] = { "kmem", 0, &kmem_fops, FMODE_UNSIGNED_OFFSET },
-@@ -939,6 +995,45 @@ static char *mem_devnode(struct device *dev, umode_t *mode)
-
- static struct class *mem_class;
-
-+static int devmem_fs_init_fs_context(struct fs_context *fc)
-+{
-+ return init_pseudo(fc, DEVMEM_MAGIC) ? 0 : -ENOMEM;
-+}
-+
-+static struct file_system_type devmem_fs_type = {
-+ .name = "devmem",
-+ .owner = THIS_MODULE,
-+ .init_fs_context = devmem_fs_init_fs_context,
-+ .kill_sb = kill_anon_super,
-+};
-+
-+static int devmem_init_inode(void)
-+{
-+ static struct vfsmount *devmem_vfs_mount;
-+ static int devmem_fs_cnt;
-+ struct inode *inode;
-+ int rc;
-+
-+ rc = simple_pin_fs(&devmem_fs_type, &devmem_vfs_mount, &devmem_fs_cnt);
-+ if (rc < 0) {
-+ pr_err("Cannot mount /dev/mem pseudo filesystem: %d\n", rc);
-+ return rc;
-+ }
-+
-+ inode = alloc_anon_inode(devmem_vfs_mount->mnt_sb);
-+ if (IS_ERR(inode)) {
-+ rc = PTR_ERR(inode);
-+ pr_err("Cannot allocate inode for /dev/mem: %d\n", rc);
-+ simple_release_fs(&devmem_vfs_mount, &devmem_fs_cnt);
-+ return rc;
-+ }
-+
-+ /* publish /dev/mem initialized */
-+ WRITE_ONCE(devmem_inode, inode);
-+
-+ return 0;
-+}
-+
- static int __init chr_dev_init(void)
- {
- int minor;
-@@ -960,6 +1055,8 @@ static int __init chr_dev_init(void)
- */
- if ((minor == DEVPORT_MINOR) && !arch_has_dev_port())
- continue;
-+ if ((minor == DEVMEM_MINOR) && devmem_init_inode() != 0)
-+ continue;
-
- device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
- NULL, devlist[minor].name);
-diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
-index f4169cc2fd31..60e811d3f226 100644
---- a/drivers/clk/Makefile
-+++ b/drivers/clk/Makefile
-@@ -105,7 +105,7 @@ obj-$(CONFIG_CLK_SIFIVE) += sifive/
- obj-$(CONFIG_ARCH_SIRF) += sirf/
- obj-$(CONFIG_ARCH_SOCFPGA) += socfpga/
- obj-$(CONFIG_PLAT_SPEAR) += spear/
--obj-$(CONFIG_ARCH_SPRD) += sprd/
-+obj-y += sprd/
- obj-$(CONFIG_ARCH_STI) += st/
- obj-$(CONFIG_ARCH_STRATIX10) += socfpga/
- obj-$(CONFIG_ARCH_SUNXI) += sunxi/
-diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
-index ded13ccf768e..7c845c293af0 100644
---- a/drivers/clk/bcm/clk-bcm2835.c
-+++ b/drivers/clk/bcm/clk-bcm2835.c
-@@ -1448,13 +1448,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
- return &clock->hw;
- }
-
--static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
-+static struct clk_hw *bcm2835_register_gate(struct bcm2835_cprman *cprman,
- const struct bcm2835_gate_data *data)
- {
-- return clk_register_gate(cprman->dev, data->name, data->parent,
-- CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
-- cprman->regs + data->ctl_reg,
-- CM_GATE_BIT, 0, &cprman->regs_lock);
-+ return clk_hw_register_gate(cprman->dev, data->name, data->parent,
-+ CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
-+ cprman->regs + data->ctl_reg,
-+ CM_GATE_BIT, 0, &cprman->regs_lock);
- }
-
- typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
-diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c
-index 392d01705b97..99afc949925f 100644
---- a/drivers/clk/clk-ast2600.c
-+++ b/drivers/clk/clk-ast2600.c
-@@ -642,14 +642,22 @@ static const u32 ast2600_a0_axi_ahb_div_table[] = {
- 2, 2, 3, 5,
- };
-
--static const u32 ast2600_a1_axi_ahb_div_table[] = {
-- 4, 6, 2, 4,
-+static const u32 ast2600_a1_axi_ahb_div0_tbl[] = {
-+ 3, 2, 3, 4,
-+};
-+
-+static const u32 ast2600_a1_axi_ahb_div1_tbl[] = {
-+ 3, 4, 6, 8,
-+};
-+
-+static const u32 ast2600_a1_axi_ahb200_tbl[] = {
-+ 3, 4, 3, 4, 2, 2, 2, 2,
- };
-
- static void __init aspeed_g6_cc(struct regmap *map)
- {
- struct clk_hw *hw;
-- u32 val, div, chip_id, axi_div, ahb_div;
-+ u32 val, div, divbits, chip_id, axi_div, ahb_div;
-
- clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, 25000000);
-
-@@ -679,11 +687,22 @@ static void __init aspeed_g6_cc(struct regmap *map)
- else
- axi_div = 2;
-
-+ divbits = (val >> 11) & 0x3;
- regmap_read(map, ASPEED_G6_SILICON_REV, &chip_id);
-- if (chip_id & BIT(16))
-- ahb_div = ast2600_a1_axi_ahb_div_table[(val >> 11) & 0x3];
-- else
-+ if (chip_id & BIT(16)) {
-+ if (!divbits) {
-+ ahb_div = ast2600_a1_axi_ahb200_tbl[(val >> 8) & 0x3];
-+ if (val & BIT(16))
-+ ahb_div *= 2;
-+ } else {
-+ if (val & BIT(16))
-+ ahb_div = ast2600_a1_axi_ahb_div1_tbl[divbits];
-+ else
-+ ahb_div = ast2600_a1_axi_ahb_div0_tbl[divbits];
-+ }
-+ } else {
- ahb_div = ast2600_a0_axi_ahb_div_table[(val >> 11) & 0x3];
-+ }
-
- hw = clk_hw_register_fixed_factor(NULL, "ahb", "hpll", 0, 1, axi_div * ahb_div);
- aspeed_g6_clk_data->hws[ASPEED_CLK_AHB] = hw;
-diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
-index 34a70c4b4899..11f6b868cf2b 100644
---- a/drivers/clk/meson/meson8b.c
-+++ b/drivers/clk/meson/meson8b.c
-@@ -1077,7 +1077,7 @@ static struct clk_regmap meson8b_vid_pll_in_sel = {
- * Meson8m2: vid2_pll
- */
- .parent_hws = (const struct clk_hw *[]) {
-- &meson8b_hdmi_pll_dco.hw
-+ &meson8b_hdmi_pll_lvds_out.hw
- },
- .num_parents = 1,
- .flags = CLK_SET_RATE_PARENT,
-@@ -1213,7 +1213,7 @@ static struct clk_regmap meson8b_vclk_in_en = {
-
- static struct clk_regmap meson8b_vclk_div1_gate = {
- .data = &(struct clk_regmap_gate_data){
-- .offset = HHI_VID_CLK_DIV,
-+ .offset = HHI_VID_CLK_CNTL,
- .bit_idx = 0,
- },
- .hw.init = &(struct clk_init_data){
-@@ -1243,7 +1243,7 @@ static struct clk_fixed_factor meson8b_vclk_div2_div = {
-
- static struct clk_regmap meson8b_vclk_div2_div_gate = {
- .data = &(struct clk_regmap_gate_data){
-- .offset = HHI_VID_CLK_DIV,
-+ .offset = HHI_VID_CLK_CNTL,
- .bit_idx = 1,
- },
- .hw.init = &(struct clk_init_data){
-@@ -1273,7 +1273,7 @@ static struct clk_fixed_factor meson8b_vclk_div4_div = {
-
- static struct clk_regmap meson8b_vclk_div4_div_gate = {
- .data = &(struct clk_regmap_gate_data){
-- .offset = HHI_VID_CLK_DIV,
-+ .offset = HHI_VID_CLK_CNTL,
- .bit_idx = 2,
- },
- .hw.init = &(struct clk_init_data){
-@@ -1303,7 +1303,7 @@ static struct clk_fixed_factor meson8b_vclk_div6_div = {
-
- static struct clk_regmap meson8b_vclk_div6_div_gate = {
- .data = &(struct clk_regmap_gate_data){
-- .offset = HHI_VID_CLK_DIV,
-+ .offset = HHI_VID_CLK_CNTL,
- .bit_idx = 3,
- },
- .hw.init = &(struct clk_init_data){
-@@ -1333,7 +1333,7 @@ static struct clk_fixed_factor meson8b_vclk_div12_div = {
-
- static struct clk_regmap meson8b_vclk_div12_div_gate = {
- .data = &(struct clk_regmap_gate_data){
-- .offset = HHI_VID_CLK_DIV,
-+ .offset = HHI_VID_CLK_CNTL,
- .bit_idx = 4,
- },
- .hw.init = &(struct clk_init_data){
-@@ -1918,6 +1918,13 @@ static struct clk_regmap meson8b_mali = {
- },
- };
-
-+static const struct reg_sequence meson8m2_gp_pll_init_regs[] = {
-+ { .reg = HHI_GP_PLL_CNTL2, .def = 0x59c88000 },
-+ { .reg = HHI_GP_PLL_CNTL3, .def = 0xca463823 },
-+ { .reg = HHI_GP_PLL_CNTL4, .def = 0x0286a027 },
-+ { .reg = HHI_GP_PLL_CNTL5, .def = 0x00003000 },
-+};
-+
- static const struct pll_params_table meson8m2_gp_pll_params_table[] = {
- PLL_PARAMS(182, 3),
- { /* sentinel */ },
-@@ -1951,6 +1958,8 @@ static struct clk_regmap meson8m2_gp_pll_dco = {
- .width = 1,
- },
- .table = meson8m2_gp_pll_params_table,
-+ .init_regs = meson8m2_gp_pll_init_regs,
-+ .init_count = ARRAY_SIZE(meson8m2_gp_pll_init_regs),
- },
- .hw.init = &(struct clk_init_data){
- .name = "gp_pll_dco",
-@@ -3506,54 +3515,87 @@ static struct clk_regmap *const meson8b_clk_regmaps[] = {
- static const struct meson8b_clk_reset_line {
- u32 reg;
- u8 bit_idx;
-+ bool active_low;
- } meson8b_clk_reset_bits[] = {
- [CLKC_RESET_L2_CACHE_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 30
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 30,
-+ .active_low = false,
- },
- [CLKC_RESET_AXI_64_TO_128_BRIDGE_A5_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 29
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 29,
-+ .active_low = false,
- },
- [CLKC_RESET_SCU_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 28
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 28,
-+ .active_low = false,
- },
- [CLKC_RESET_CPU3_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 27
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 27,
-+ .active_low = false,
- },
- [CLKC_RESET_CPU2_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 26
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 26,
-+ .active_low = false,
- },
- [CLKC_RESET_CPU1_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 25
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 25,
-+ .active_low = false,
- },
- [CLKC_RESET_CPU0_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 24
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 24,
-+ .active_low = false,
- },
- [CLKC_RESET_A5_GLOBAL_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 18
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 18,
-+ .active_low = false,
- },
- [CLKC_RESET_A5_AXI_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 17
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 17,
-+ .active_low = false,
- },
- [CLKC_RESET_A5_ABP_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL0, .bit_idx = 16
-+ .reg = HHI_SYS_CPU_CLK_CNTL0,
-+ .bit_idx = 16,
-+ .active_low = false,
- },
- [CLKC_RESET_AXI_64_TO_128_BRIDGE_MMC_SOFT_RESET] = {
-- .reg = HHI_SYS_CPU_CLK_CNTL1, .bit_idx = 30
-+ .reg = HHI_SYS_CPU_CLK_CNTL1,
-+ .bit_idx = 30,
-+ .active_low = false,
- },
- [CLKC_RESET_VID_CLK_CNTL_SOFT_RESET] = {
-- .reg = HHI_VID_CLK_CNTL, .bit_idx = 15
-+ .reg = HHI_VID_CLK_CNTL,
-+ .bit_idx = 15,
-+ .active_low = false,
- },
- [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_POST] = {
-- .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 7
-+ .reg = HHI_VID_DIVIDER_CNTL,
-+ .bit_idx = 7,
-+ .active_low = false,
- },
- [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_PRE] = {
-- .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 3
-+ .reg = HHI_VID_DIVIDER_CNTL,
-+ .bit_idx = 3,
-+ .active_low = false,
- },
- [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_POST] = {
-- .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 1
-+ .reg = HHI_VID_DIVIDER_CNTL,
-+ .bit_idx = 1,
-+ .active_low = true,
- },
- [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_PRE] = {
-- .reg = HHI_VID_DIVIDER_CNTL, .bit_idx = 0
-+ .reg = HHI_VID_DIVIDER_CNTL,
-+ .bit_idx = 0,
-+ .active_low = true,
- },
- };
-
-@@ -3562,22 +3604,22 @@ static int meson8b_clk_reset_update(struct reset_controller_dev *rcdev,
- {
- struct meson8b_clk_reset *meson8b_clk_reset =
- container_of(rcdev, struct meson8b_clk_reset, reset);
-- unsigned long flags;
- const struct meson8b_clk_reset_line *reset;
-+ unsigned int value = 0;
-+ unsigned long flags;
-
- if (id >= ARRAY_SIZE(meson8b_clk_reset_bits))
- return -EINVAL;
-
- reset = &meson8b_clk_reset_bits[id];
-
-+ if (assert != reset->active_low)
-+ value = BIT(reset->bit_idx);
-+
- spin_lock_irqsave(&meson_clk_lock, flags);
-
-- if (assert)
-- regmap_update_bits(meson8b_clk_reset->regmap, reset->reg,
-- BIT(reset->bit_idx), BIT(reset->bit_idx));
-- else
-- regmap_update_bits(meson8b_clk_reset->regmap, reset->reg,
-- BIT(reset->bit_idx), 0);
-+ regmap_update_bits(meson8b_clk_reset->regmap, reset->reg,
-+ BIT(reset->bit_idx), value);
-
- spin_unlock_irqrestore(&meson_clk_lock, flags);
-
-diff --git a/drivers/clk/meson/meson8b.h b/drivers/clk/meson/meson8b.h
-index c889fbeec30f..c91fb07fcb65 100644
---- a/drivers/clk/meson/meson8b.h
-+++ b/drivers/clk/meson/meson8b.h
-@@ -20,6 +20,10 @@
- * [0] http://dn.odroid.com/S805/Datasheet/S805_Datasheet%20V0.8%2020150126.pdf
- */
- #define HHI_GP_PLL_CNTL 0x40 /* 0x10 offset in data sheet */
-+#define HHI_GP_PLL_CNTL2 0x44 /* 0x11 offset in data sheet */
-+#define HHI_GP_PLL_CNTL3 0x48 /* 0x12 offset in data sheet */
-+#define HHI_GP_PLL_CNTL4 0x4C /* 0x13 offset in data sheet */
-+#define HHI_GP_PLL_CNTL5 0x50 /* 0x14 offset in data sheet */
- #define HHI_VIID_CLK_DIV 0x128 /* 0x4a offset in data sheet */
- #define HHI_VIID_CLK_CNTL 0x12c /* 0x4b offset in data sheet */
- #define HHI_GCLK_MPEG0 0x140 /* 0x50 offset in data sheet */
-diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c
-index 4e329a7baf2b..17e4a5a2a9fd 100644
---- a/drivers/clk/qcom/gcc-msm8916.c
-+++ b/drivers/clk/qcom/gcc-msm8916.c
-@@ -260,7 +260,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,
-@@ -287,7 +287,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,
-@@ -314,7 +314,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,
-@@ -341,7 +341,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/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
-index a2663fbbd7a5..d6a53c99b114 100644
---- a/drivers/clk/renesas/renesas-cpg-mssr.c
-+++ b/drivers/clk/renesas/renesas-cpg-mssr.c
-@@ -812,7 +812,8 @@ static int cpg_mssr_suspend_noirq(struct device *dev)
- /* Save module registers with bits under our control */
- for (reg = 0; reg < ARRAY_SIZE(priv->smstpcr_saved); reg++) {
- if (priv->smstpcr_saved[reg].mask)
-- priv->smstpcr_saved[reg].val =
-+ priv->smstpcr_saved[reg].val = priv->stbyctrl ?
-+ readb(priv->base + STBCR(reg)) :
- readl(priv->base + SMSTPCR(reg));
- }
-
-@@ -872,8 +873,9 @@ static int cpg_mssr_resume_noirq(struct device *dev)
- }
-
- if (!i)
-- dev_warn(dev, "Failed to enable SMSTP %p[0x%x]\n",
-- priv->base + SMSTPCR(reg), oldval & mask);
-+ dev_warn(dev, "Failed to enable %s%u[0x%x]\n",
-+ priv->stbyctrl ? "STB" : "SMSTP", reg,
-+ oldval & mask);
- }
-
- return 0;
-diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
-index c9e5a1fb6653..edb2363c735a 100644
---- a/drivers/clk/samsung/clk-exynos5420.c
-+++ b/drivers/clk/samsung/clk-exynos5420.c
-@@ -540,7 +540,7 @@ static const struct samsung_div_clock exynos5800_div_clks[] __initconst = {
-
- static const struct samsung_gate_clock exynos5800_gate_clks[] __initconst = {
- GATE(CLK_ACLK550_CAM, "aclk550_cam", "mout_user_aclk550_cam",
-- GATE_BUS_TOP, 24, 0, 0),
-+ GATE_BUS_TOP, 24, CLK_IS_CRITICAL, 0),
- GATE(CLK_ACLK432_SCALER, "aclk432_scaler", "mout_user_aclk432_scaler",
- GATE_BUS_TOP, 27, CLK_IS_CRITICAL, 0),
- };
-@@ -943,25 +943,25 @@ static const struct samsung_gate_clock exynos5x_gate_clks[] __initconst = {
- GATE(0, "aclk300_jpeg", "mout_user_aclk300_jpeg",
- GATE_BUS_TOP, 4, CLK_IGNORE_UNUSED, 0),
- GATE(0, "aclk333_432_isp0", "mout_user_aclk333_432_isp0",
-- GATE_BUS_TOP, 5, 0, 0),
-+ GATE_BUS_TOP, 5, CLK_IS_CRITICAL, 0),
- GATE(0, "aclk300_gscl", "mout_user_aclk300_gscl",
- GATE_BUS_TOP, 6, CLK_IS_CRITICAL, 0),
- GATE(0, "aclk333_432_gscl", "mout_user_aclk333_432_gscl",
- GATE_BUS_TOP, 7, CLK_IGNORE_UNUSED, 0),
- GATE(0, "aclk333_432_isp", "mout_user_aclk333_432_isp",
-- GATE_BUS_TOP, 8, 0, 0),
-+ GATE_BUS_TOP, 8, CLK_IS_CRITICAL, 0),
- GATE(CLK_PCLK66_GPIO, "pclk66_gpio", "mout_user_pclk66_gpio",
- GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0),
- GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen",
- GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0),
- GATE(0, "aclk266_isp", "mout_user_aclk266_isp",
-- GATE_BUS_TOP, 13, 0, 0),
-+ GATE_BUS_TOP, 13, CLK_IS_CRITICAL, 0),
- GATE(0, "aclk166", "mout_user_aclk166",
- GATE_BUS_TOP, 14, CLK_IGNORE_UNUSED, 0),
- GATE(CLK_ACLK333, "aclk333", "mout_user_aclk333",
- GATE_BUS_TOP, 15, CLK_IS_CRITICAL, 0),
- GATE(0, "aclk400_isp", "mout_user_aclk400_isp",
-- GATE_BUS_TOP, 16, 0, 0),
-+ GATE_BUS_TOP, 16, CLK_IS_CRITICAL, 0),
- GATE(0, "aclk400_mscl", "mout_user_aclk400_mscl",
- GATE_BUS_TOP, 17, CLK_IS_CRITICAL, 0),
- GATE(0, "aclk200_disp1", "mout_user_aclk200_disp1",
-@@ -1161,8 +1161,10 @@ static const struct samsung_gate_clock exynos5x_gate_clks[] __initconst = {
- GATE_IP_GSCL1, 3, 0, 0),
- GATE(CLK_SMMU_FIMCL1, "smmu_fimcl1", "dout_gscl_blk_333",
- GATE_IP_GSCL1, 4, 0, 0),
-- GATE(CLK_GSCL_WA, "gscl_wa", "sclk_gscl_wa", GATE_IP_GSCL1, 12, 0, 0),
-- GATE(CLK_GSCL_WB, "gscl_wb", "sclk_gscl_wb", GATE_IP_GSCL1, 13, 0, 0),
-+ GATE(CLK_GSCL_WA, "gscl_wa", "sclk_gscl_wa", GATE_IP_GSCL1, 12,
-+ CLK_IS_CRITICAL, 0),
-+ GATE(CLK_GSCL_WB, "gscl_wb", "sclk_gscl_wb", GATE_IP_GSCL1, 13,
-+ CLK_IS_CRITICAL, 0),
- GATE(CLK_SMMU_FIMCL3, "smmu_fimcl3,", "dout_gscl_blk_333",
- GATE_IP_GSCL1, 16, 0, 0),
- GATE(CLK_FIMC_LITE3, "fimc_lite3", "aclk333_432_gscl",
-diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c
-index 4b1aa9382ad2..6f29ecd0442e 100644
---- a/drivers/clk/samsung/clk-exynos5433.c
-+++ b/drivers/clk/samsung/clk-exynos5433.c
-@@ -1706,7 +1706,8 @@ static const struct samsung_gate_clock peric_gate_clks[] __initconst = {
- 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/sprd/pll.c b/drivers/clk/sprd/pll.c
-index 15791484388f..13a322b2535a 100644
---- a/drivers/clk/sprd/pll.c
-+++ b/drivers/clk/sprd/pll.c
-@@ -106,7 +106,7 @@ static unsigned long _sprd_pll_recalc_rate(const struct sprd_pll *pll,
-
- cfg = kcalloc(regs_num, sizeof(*cfg), GFP_KERNEL);
- if (!cfg)
-- return -ENOMEM;
-+ return parent_rate;
-
- for (i = 0; i < regs_num; i++)
- cfg[i] = sprd_pll_read(pll, i);
-diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
-index 4413b6e04a8e..55873d4b7603 100644
---- a/drivers/clk/st/clk-flexgen.c
-+++ b/drivers/clk/st/clk-flexgen.c
-@@ -375,6 +375,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
- break;
- }
-
-+ flex_flags &= ~CLK_IS_CRITICAL;
- of_clk_detect_critical(np, i, &flex_flags);
-
- /*
-diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
-index 27201fd26e44..e1aa1fbac48a 100644
---- a/drivers/clk/sunxi/clk-sunxi.c
-+++ b/drivers/clk/sunxi/clk-sunxi.c
-@@ -90,7 +90,7 @@ static void sun6i_a31_get_pll1_factors(struct factors_request *req)
- * 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 6a89936ba03a..eaa43575cfa5 100644
---- a/drivers/clk/ti/composite.c
-+++ b/drivers/clk/ti/composite.c
-@@ -196,6 +196,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/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
-index 10e89f23880b..b66c3a62233a 100644
---- a/drivers/clk/zynqmp/clkc.c
-+++ b/drivers/clk/zynqmp/clkc.c
-@@ -558,7 +558,7 @@ static struct clk_hw *zynqmp_register_clk_topology(int clk_id, char *clk_name,
- {
- int j;
- u32 num_nodes, clk_dev_id;
-- char *clk_out = NULL;
-+ char *clk_out[MAX_NODES];
- struct clock_topology *nodes;
- struct clk_hw *hw = NULL;
-
-@@ -572,16 +572,16 @@ static struct clk_hw *zynqmp_register_clk_topology(int clk_id, char *clk_name,
- * Intermediate clock names are postfixed with type of clock.
- */
- if (j != (num_nodes - 1)) {
-- clk_out = kasprintf(GFP_KERNEL, "%s%s", clk_name,
-+ clk_out[j] = kasprintf(GFP_KERNEL, "%s%s", clk_name,
- clk_type_postfix[nodes[j].type]);
- } else {
-- clk_out = kasprintf(GFP_KERNEL, "%s", clk_name);
-+ clk_out[j] = kasprintf(GFP_KERNEL, "%s", clk_name);
- }
-
- if (!clk_topology[nodes[j].type])
- continue;
-
-- hw = (*clk_topology[nodes[j].type])(clk_out, clk_dev_id,
-+ hw = (*clk_topology[nodes[j].type])(clk_out[j], clk_dev_id,
- parent_names,
- num_parents,
- &nodes[j]);
-@@ -590,9 +590,12 @@ static struct clk_hw *zynqmp_register_clk_topology(int clk_id, char *clk_name,
- __func__, clk_dev_id, clk_name,
- PTR_ERR(hw));
-
-- parent_names[0] = clk_out;
-+ parent_names[0] = clk_out[j];
- }
-- kfree(clk_out);
-+
-+ for (j = 0; j < num_nodes; j++)
-+ kfree(clk_out[j]);
-+
- return hw;
- }
-
-diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c
-index 4be2cc76aa2e..9bc4f9409aea 100644
---- a/drivers/clk/zynqmp/divider.c
-+++ b/drivers/clk/zynqmp/divider.c
-@@ -111,23 +111,30 @@ static unsigned long zynqmp_clk_divider_recalc_rate(struct clk_hw *hw,
-
- static void zynqmp_get_divider2_val(struct clk_hw *hw,
- unsigned long rate,
-- unsigned long parent_rate,
- struct zynqmp_clk_divider *divider,
- int *bestdiv)
- {
- int div1;
- int div2;
- long error = LONG_MAX;
-- struct clk_hw *parent_hw = clk_hw_get_parent(hw);
-- struct zynqmp_clk_divider *pdivider = to_zynqmp_clk_divider(parent_hw);
-+ unsigned long div1_prate;
-+ struct clk_hw *div1_parent_hw;
-+ struct clk_hw *div2_parent_hw = clk_hw_get_parent(hw);
-+ struct zynqmp_clk_divider *pdivider =
-+ to_zynqmp_clk_divider(div2_parent_hw);
-
- if (!pdivider)
- return;
-
-+ div1_parent_hw = clk_hw_get_parent(div2_parent_hw);
-+ if (!div1_parent_hw)
-+ return;
-+
-+ div1_prate = clk_hw_get_rate(div1_parent_hw);
- *bestdiv = 1;
- for (div1 = 1; div1 <= pdivider->max_div;) {
- for (div2 = 1; div2 <= divider->max_div;) {
-- long new_error = ((parent_rate / div1) / div2) - rate;
-+ long new_error = ((div1_prate / div1) / div2) - rate;
-
- if (abs(new_error) < abs(error)) {
- *bestdiv = div2;
-@@ -192,7 +199,7 @@ static long zynqmp_clk_divider_round_rate(struct clk_hw *hw,
- */
- if (div_type == TYPE_DIV2 &&
- (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
-- zynqmp_get_divider2_val(hw, rate, *prate, divider, &bestdiv);
-+ zynqmp_get_divider2_val(hw, rate, divider, &bestdiv);
- }
-
- if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && divider->is_frac)
-diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c
-index 0e8c7e324fb4..725a739800b0 100644
---- a/drivers/crypto/hisilicon/sgl.c
-+++ b/drivers/crypto/hisilicon/sgl.c
-@@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
-
- sgl_size = sizeof(struct acc_hw_sge) * sge_nr +
- sizeof(struct hisi_acc_hw_sgl);
-- block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1));
-+ block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ?
-+ PAGE_SHIFT + MAX_ORDER - 1 : 31);
- sgl_num_per_block = block_size / sgl_size;
- block_num = count / sgl_num_per_block;
- remain_sgl = count % sgl_num_per_block;
-diff --git a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
-index 06202bcffb33..a370c99ecf4c 100644
---- a/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
-+++ b/drivers/crypto/marvell/octeontx/otx_cptvf_algs.c
-@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
- struct otx_cpt_req_info *cpt_req;
- struct pci_dev *pdev;
-
-+ if (!cpt_info)
-+ goto complete;
-+
- cpt_req = cpt_info->req;
- if (!status) {
- /*
-@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
- !cpt_req->is_enc)
- status = validate_hmac_cipher_null(cpt_req);
- }
-- if (cpt_info) {
-- pdev = cpt_info->pdev;
-- do_request_cleanup(pdev, cpt_info);
-- }
-+ pdev = cpt_info->pdev;
-+ do_request_cleanup(pdev, cpt_info);
-+
-+complete:
- if (areq)
- areq->complete(areq, status);
- }
-diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
-index e4072cd38585..a82a3596dca3 100644
---- a/drivers/crypto/omap-sham.c
-+++ b/drivers/crypto/omap-sham.c
-@@ -169,8 +169,6 @@ struct omap_sham_hmac_ctx {
- };
-
- struct omap_sham_ctx {
-- struct omap_sham_dev *dd;
--
- unsigned long flags;
-
- /* fallback stuff */
-@@ -751,8 +749,15 @@ static int omap_sham_align_sgs(struct scatterlist *sg,
- int offset = rctx->offset;
- int bufcnt = rctx->bufcnt;
-
-- if (!sg || !sg->length || !nbytes)
-+ if (!sg || !sg->length || !nbytes) {
-+ if (bufcnt) {
-+ sg_init_table(rctx->sgl, 1);
-+ sg_set_buf(rctx->sgl, rctx->dd->xmit_buf, bufcnt);
-+ rctx->sg = rctx->sgl;
-+ }
-+
- return 0;
-+ }
-
- new_len = nbytes;
-
-@@ -896,7 +901,7 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update)
- if (hash_later < 0)
- hash_later = 0;
-
-- if (hash_later) {
-+ if (hash_later && hash_later <= rctx->buflen) {
- scatterwalk_map_and_copy(rctx->buffer,
- req->src,
- req->nbytes - hash_later,
-@@ -926,27 +931,35 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)
- return 0;
- }
-
-+struct omap_sham_dev *omap_sham_find_dev(struct omap_sham_reqctx *ctx)
-+{
-+ struct omap_sham_dev *dd;
-+
-+ if (ctx->dd)
-+ return ctx->dd;
-+
-+ spin_lock_bh(&sham.lock);
-+ dd = list_first_entry(&sham.dev_list, struct omap_sham_dev, list);
-+ list_move_tail(&dd->list, &sham.dev_list);
-+ ctx->dd = dd;
-+ spin_unlock_bh(&sham.lock);
-+
-+ return dd;
-+}
-+
- static int omap_sham_init(struct ahash_request *req)
- {
- struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
- struct omap_sham_ctx *tctx = crypto_ahash_ctx(tfm);
- struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
-- struct omap_sham_dev *dd = NULL, *tmp;
-+ struct omap_sham_dev *dd;
- int bs = 0;
-
-- spin_lock_bh(&sham.lock);
-- if (!tctx->dd) {
-- list_for_each_entry(tmp, &sham.dev_list, list) {
-- dd = tmp;
-- break;
-- }
-- tctx->dd = dd;
-- } else {
-- dd = tctx->dd;
-- }
-- spin_unlock_bh(&sham.lock);
-+ ctx->dd = NULL;
-
-- ctx->dd = dd;
-+ dd = omap_sham_find_dev(ctx);
-+ if (!dd)
-+ return -ENODEV;
-
- ctx->flags = 0;
-
-@@ -1216,8 +1229,7 @@ err1:
- static int omap_sham_enqueue(struct ahash_request *req, unsigned int op)
- {
- struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
-- struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
-- struct omap_sham_dev *dd = tctx->dd;
-+ struct omap_sham_dev *dd = ctx->dd;
-
- ctx->op = op;
-
-@@ -1227,7 +1239,7 @@ static int omap_sham_enqueue(struct ahash_request *req, unsigned int op)
- static int omap_sham_update(struct ahash_request *req)
- {
- struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
-- struct omap_sham_dev *dd = ctx->dd;
-+ struct omap_sham_dev *dd = omap_sham_find_dev(ctx);
-
- if (!req->nbytes)
- return 0;
-@@ -1331,21 +1343,8 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,
- struct omap_sham_hmac_ctx *bctx = tctx->base;
- int bs = crypto_shash_blocksize(bctx->shash);
- int ds = crypto_shash_digestsize(bctx->shash);
-- struct omap_sham_dev *dd = NULL, *tmp;
- int err, i;
-
-- spin_lock_bh(&sham.lock);
-- if (!tctx->dd) {
-- list_for_each_entry(tmp, &sham.dev_list, list) {
-- dd = tmp;
-- break;
-- }
-- tctx->dd = dd;
-- } else {
-- dd = tctx->dd;
-- }
-- spin_unlock_bh(&sham.lock);
--
- err = crypto_shash_setkey(tctx->fallback, key, keylen);
- if (err)
- return err;
-@@ -1363,7 +1362,7 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,
-
- memset(bctx->ipad + keylen, 0, bs - keylen);
-
-- if (!test_bit(FLAGS_AUTO_XOR, &dd->flags)) {
-+ if (!test_bit(FLAGS_AUTO_XOR, &sham.flags)) {
- memcpy(bctx->opad, bctx->ipad, bs);
-
- for (i = 0; i < bs; i++) {
-@@ -2167,6 +2166,7 @@ static int omap_sham_probe(struct platform_device *pdev)
- }
-
- dd->flags |= dd->pdata->flags;
-+ sham.flags |= dd->pdata->flags;
-
- pm_runtime_use_autosuspend(dev);
- pm_runtime_set_autosuspend_delay(dev, DEFAULT_AUTOSUSPEND_DELAY);
-@@ -2194,6 +2194,9 @@ static int omap_sham_probe(struct platform_device *pdev)
- spin_unlock(&sham.lock);
-
- for (i = 0; i < dd->pdata->algs_info_size; i++) {
-+ if (dd->pdata->algs_info[i].registered)
-+ break;
-+
- for (j = 0; j < dd->pdata->algs_info[i].size; j++) {
- struct ahash_alg *alg;
-
-@@ -2245,9 +2248,11 @@ static int omap_sham_remove(struct platform_device *pdev)
- list_del(&dd->list);
- spin_unlock(&sham.lock);
- for (i = dd->pdata->algs_info_size - 1; i >= 0; i--)
-- for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
-+ for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) {
- crypto_unregister_ahash(
- &dd->pdata->algs_info[i].algs_list[j]);
-+ dd->pdata->algs_info[i].registered--;
-+ }
- tasklet_kill(&dd->done_task);
- pm_runtime_disable(&pdev->dev);
-
-diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
-index ad02dc6747a4..0317b614b680 100644
---- a/drivers/extcon/extcon-adc-jack.c
-+++ b/drivers/extcon/extcon-adc-jack.c
-@@ -124,7 +124,7 @@ static int adc_jack_probe(struct platform_device *pdev)
- for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++);
- data->num_conditions = i;
-
-- data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
-+ data->chan = devm_iio_channel_get(&pdev->dev, pdata->consumer_channel);
- if (IS_ERR(data->chan))
- return PTR_ERR(data->chan);
-
-@@ -164,7 +164,6 @@ static int adc_jack_remove(struct platform_device *pdev)
-
- free_irq(data->irq, data);
- cancel_work_sync(&data->handler.work);
-- iio_channel_release(data->chan);
-
- return 0;
- }
-diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c
-index b3da2e193ad2..176ddd151375 100644
---- a/drivers/firmware/imx/imx-scu.c
-+++ b/drivers/firmware/imx/imx-scu.c
-@@ -314,6 +314,7 @@ static int imx_scu_probe(struct platform_device *pdev)
- if (ret != -EPROBE_DEFER)
- dev_err(dev, "Failed to request mbox chan %s ret %d\n",
- chan_name, ret);
-+ kfree(chan_name);
- return ret;
- }
-
-diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
-index 059bb0fbae9e..4701487573f7 100644
---- a/drivers/firmware/qcom_scm.c
-+++ b/drivers/firmware/qcom_scm.c
-@@ -6,7 +6,6 @@
- #include <linux/init.h>
- #include <linux/cpumask.h>
- #include <linux/export.h>
--#include <linux/dma-direct.h>
- #include <linux/dma-mapping.h>
- #include <linux/module.h>
- #include <linux/types.h>
-@@ -806,8 +805,7 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
- struct qcom_scm_mem_map_info *mem_to_map;
- phys_addr_t mem_to_map_phys;
- phys_addr_t dest_phys;
-- phys_addr_t ptr_phys;
-- dma_addr_t ptr_dma;
-+ dma_addr_t ptr_phys;
- size_t mem_to_map_sz;
- size_t dest_sz;
- size_t src_sz;
-@@ -824,10 +822,9 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
- ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) +
- ALIGN(dest_sz, SZ_64);
-
-- ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_dma, GFP_KERNEL);
-+ ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL);
- if (!ptr)
- return -ENOMEM;
-- ptr_phys = dma_to_phys(__scm->dev, ptr_dma);
-
- /* Fill source vmid detail */
- src = ptr;
-@@ -855,7 +852,7 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
-
- ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz,
- ptr_phys, src_sz, dest_phys, dest_sz);
-- dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_dma);
-+ dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys);
- if (ret) {
- dev_err(__scm->dev,
- "Assign memory protection call failed %d\n", ret);
-diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
-index 62f924489db5..5942343a5d6e 100644
---- a/drivers/fpga/dfl-afu-dma-region.c
-+++ b/drivers/fpga/dfl-afu-dma-region.c
-@@ -61,10 +61,10 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
- region->pages);
- if (pinned < 0) {
- ret = pinned;
-- goto put_pages;
-+ goto free_pages;
- } else if (pinned != npages) {
- ret = -EFAULT;
-- goto free_pages;
-+ goto put_pages;
- }
-
- dev_dbg(dev, "%d pages pinned\n", pinned);
-diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
-index 92e127e74813..ed6061b5cca1 100644
---- a/drivers/gpio/gpio-dwapb.c
-+++ b/drivers/gpio/gpio-dwapb.c
-@@ -49,7 +49,9 @@
- #define GPIO_EXT_PORTC 0x58
- #define GPIO_EXT_PORTD 0x5c
-
-+#define DWAPB_DRIVER_NAME "gpio-dwapb"
- #define DWAPB_MAX_PORTS 4
-+
- #define GPIO_EXT_PORT_STRIDE 0x04 /* register stride 32 bits */
- #define GPIO_SWPORT_DR_STRIDE 0x0c /* register stride 3*32 bits */
- #define GPIO_SWPORT_DDR_STRIDE 0x0c /* register stride 3*32 bits */
-@@ -398,7 +400,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio,
- return;
-
- err = irq_alloc_domain_generic_chips(gpio->domain, ngpio, 2,
-- "gpio-dwapb", handle_level_irq,
-+ DWAPB_DRIVER_NAME, handle_level_irq,
- IRQ_NOREQUEST, 0,
- IRQ_GC_INIT_NESTED_LOCK);
- if (err) {
-@@ -455,7 +457,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio,
- */
- err = devm_request_irq(gpio->dev, pp->irq[0],
- dwapb_irq_handler_mfd,
-- IRQF_SHARED, "gpio-dwapb-mfd", gpio);
-+ IRQF_SHARED, DWAPB_DRIVER_NAME, gpio);
- if (err) {
- dev_err(gpio->dev, "error requesting IRQ\n");
- irq_domain_remove(gpio->domain);
-@@ -533,26 +535,33 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
- dwapb_configure_irqs(gpio, port, pp);
-
- err = gpiochip_add_data(&port->gc, port);
-- if (err)
-+ if (err) {
- dev_err(gpio->dev, "failed to register gpiochip for port%d\n",
- port->idx);
-- else
-- port->is_registered = true;
-+ return err;
-+ }
-
- /* Add GPIO-signaled ACPI event support */
-- if (pp->has_irq)
-- acpi_gpiochip_request_interrupts(&port->gc);
-+ acpi_gpiochip_request_interrupts(&port->gc);
-
-- return err;
-+ port->is_registered = true;
-+
-+ return 0;
- }
-
- static void dwapb_gpio_unregister(struct dwapb_gpio *gpio)
- {
- unsigned int m;
-
-- for (m = 0; m < gpio->nr_ports; ++m)
-- if (gpio->ports[m].is_registered)
-- gpiochip_remove(&gpio->ports[m].gc);
-+ for (m = 0; m < gpio->nr_ports; ++m) {
-+ struct dwapb_gpio_port *port = &gpio->ports[m];
-+
-+ if (!port->is_registered)
-+ continue;
-+
-+ acpi_gpiochip_free_interrupts(&port->gc);
-+ gpiochip_remove(&port->gc);
-+ }
- }
-
- static struct dwapb_platform_data *
-@@ -836,7 +845,7 @@ static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend,
-
- static struct platform_driver dwapb_gpio_driver = {
- .driver = {
-- .name = "gpio-dwapb",
-+ .name = DWAPB_DRIVER_NAME,
- .pm = &dwapb_gpio_pm_ops,
- .of_match_table = of_match_ptr(dwapb_of_match),
- .acpi_match_table = ACPI_PTR(dwapb_acpi_match),
-@@ -850,3 +859,4 @@ module_platform_driver(dwapb_gpio_driver);
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("Jamie Iles");
- MODULE_DESCRIPTION("Synopsys DesignWare APB GPIO driver");
-+MODULE_ALIAS("platform:" DWAPB_DRIVER_NAME);
-diff --git a/drivers/gpio/gpio-mlxbf2.c b/drivers/gpio/gpio-mlxbf2.c
-index da570e63589d..cc0dd8593a4b 100644
---- a/drivers/gpio/gpio-mlxbf2.c
-+++ b/drivers/gpio/gpio-mlxbf2.c
-@@ -110,8 +110,8 @@ static int mlxbf2_gpio_get_lock_res(struct platform_device *pdev)
- }
-
- yu_arm_gpio_lock_param.io = devm_ioremap(dev, res->start, size);
-- if (IS_ERR(yu_arm_gpio_lock_param.io))
-- ret = PTR_ERR(yu_arm_gpio_lock_param.io);
-+ if (!yu_arm_gpio_lock_param.io)
-+ ret = -ENOMEM;
-
- exit:
- mutex_unlock(yu_arm_gpio_lock_param.lock);
-diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
-index 4269ea9a817e..01011a780688 100644
---- a/drivers/gpio/gpio-pca953x.c
-+++ b/drivers/gpio/gpio-pca953x.c
-@@ -307,8 +307,22 @@ static const struct regmap_config pca953x_i2c_regmap = {
- .volatile_reg = pca953x_volatile_register,
-
- .cache_type = REGCACHE_RBTREE,
-- /* REVISIT: should be 0x7f but some 24 bit chips use REG_ADDR_AI */
-- .max_register = 0xff,
-+ .max_register = 0x7f,
-+};
-+
-+static const struct regmap_config pca953x_ai_i2c_regmap = {
-+ .reg_bits = 8,
-+ .val_bits = 8,
-+
-+ .read_flag_mask = REG_ADDR_AI,
-+ .write_flag_mask = REG_ADDR_AI,
-+
-+ .readable_reg = pca953x_readable_register,
-+ .writeable_reg = pca953x_writeable_register,
-+ .volatile_reg = pca953x_volatile_register,
-+
-+ .cache_type = REGCACHE_RBTREE,
-+ .max_register = 0x7f,
- };
-
- static u8 pca953x_recalc_addr(struct pca953x_chip *chip, int reg, int off,
-@@ -319,18 +333,6 @@ static u8 pca953x_recalc_addr(struct pca953x_chip *chip, int reg, int off,
- int pinctrl = (reg & PCAL_PINCTRL_MASK) << 1;
- u8 regaddr = pinctrl | addr | (off / BANK_SZ);
-
-- /* Single byte read doesn't need AI bit set. */
-- if (!addrinc)
-- return regaddr;
--
-- /* Chips with 24 and more GPIOs always support Auto Increment */
-- if (write && NBANK(chip) > 2)
-- regaddr |= REG_ADDR_AI;
--
-- /* PCA9575 needs address-increment on multi-byte writes */
-- if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE)
-- regaddr |= REG_ADDR_AI;
--
- return regaddr;
- }
-
-@@ -863,6 +865,7 @@ static int pca953x_probe(struct i2c_client *client,
- int ret;
- u32 invert = 0;
- struct regulator *reg;
-+ const struct regmap_config *regmap_config;
-
- chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
- if (chip == NULL)
-@@ -925,7 +928,17 @@ static int pca953x_probe(struct i2c_client *client,
-
- i2c_set_clientdata(client, chip);
-
-- chip->regmap = devm_regmap_init_i2c(client, &pca953x_i2c_regmap);
-+ pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
-+
-+ if (NBANK(chip) > 2 || PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) {
-+ dev_info(&client->dev, "using AI\n");
-+ regmap_config = &pca953x_ai_i2c_regmap;
-+ } else {
-+ dev_info(&client->dev, "using no AI\n");
-+ regmap_config = &pca953x_i2c_regmap;
-+ }
-+
-+ chip->regmap = devm_regmap_init_i2c(client, regmap_config);
- if (IS_ERR(chip->regmap)) {
- ret = PTR_ERR(chip->regmap);
- goto err_exit;
-@@ -956,7 +969,6 @@ static int pca953x_probe(struct i2c_client *client,
- /* initialize cached registers from their original values.
- * we can't share this chip with another i2c master.
- */
-- pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
-
- if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) {
- chip->regs = &pca953x_regs;
-diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
-index c24cad3c64ed..f7cfb8180b71 100644
---- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
-+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
-@@ -40,6 +40,7 @@
- #include <drm/drm_file.h>
- #include <drm/drm_drv.h>
- #include <drm/drm_device.h>
-+#include <drm/drm_ioctl.h>
- #include <kgd_kfd_interface.h>
- #include <linux/swap.h>
-
-@@ -1053,7 +1054,7 @@ static inline int kfd_devcgroup_check_permission(struct kfd_dev *kfd)
- #if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF)
- struct drm_device *ddev = kfd->ddev;
-
-- return devcgroup_check_permission(DEVCG_DEV_CHAR, ddev->driver->major,
-+ return devcgroup_check_permission(DEVCG_DEV_CHAR, DRM_MAJOR,
- ddev->render->index,
- DEVCG_ACC_WRITE | DEVCG_ACC_READ);
- #else
-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 7fc15b82fe48..f9f02e08054b 100644
---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
-+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
-@@ -1334,7 +1334,7 @@ static int dm_late_init(void *handle)
- unsigned int linear_lut[16];
- int i;
- struct dmcu *dmcu = adev->dm.dc->res_pool->dmcu;
-- bool ret = false;
-+ bool ret;
-
- for (i = 0; i < 16; i++)
- linear_lut[i] = 0xFFFF * i / 15;
-@@ -1350,13 +1350,10 @@ static int dm_late_init(void *handle)
- */
- params.min_abm_backlight = 0x28F;
-
-- /* todo will enable for navi10 */
-- if (adev->asic_type <= CHIP_RAVEN) {
-- ret = dmcu_load_iram(dmcu, params);
-+ ret = dmcu_load_iram(dmcu, params);
-
-- if (!ret)
-- return -EINVAL;
-- }
-+ if (!ret)
-+ return -EINVAL;
-
- return detect_mst_link_for_all_connectors(adev->ddev);
- }
-diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
-index 47431ca6986d..4acaf4be8a81 100644
---- a/drivers/gpu/drm/amd/display/dc/core/dc.c
-+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
-@@ -1011,9 +1011,17 @@ static void program_timing_sync(
- }
- }
-
-- /* set first pipe with plane as master */
-+ /* set first unblanked pipe as master */
- for (j = 0; j < group_size; j++) {
-- if (pipe_set[j]->plane_state) {
-+ bool is_blanked;
-+
-+ if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked)
-+ is_blanked =
-+ pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp);
-+ else
-+ is_blanked =
-+ pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg);
-+ if (!is_blanked) {
- if (j == 0)
- break;
-
-@@ -1034,9 +1042,17 @@ static void program_timing_sync(
- status->timing_sync_info.master = false;
-
- }
-- /* remove any other pipes with plane as they have already been synced */
-+ /* remove any other unblanked pipes as they have already been synced */
- for (j = j + 1; j < group_size; j++) {
-- if (pipe_set[j]->plane_state) {
-+ bool is_blanked;
-+
-+ if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked)
-+ is_blanked =
-+ pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp);
-+ else
-+ is_blanked =
-+ pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg);
-+ if (!is_blanked) {
- group_size--;
- pipe_set[j] = pipe_set[group_size];
- j--;
-@@ -2517,6 +2533,12 @@ void dc_commit_updates_for_stream(struct dc *dc,
-
- copy_stream_update_to_stream(dc, context, stream, stream_update);
-
-+ if (!dc->res_pool->funcs->validate_bandwidth(dc, context, false)) {
-+ DC_ERROR("Mode validation failed for stream update!\n");
-+ dc_release_state(context);
-+ return;
-+ }
-+
- commit_planes_for_stream(
- dc,
- srf_updates,
-diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
-index cac09d500fda..e89694eb90b4 100644
---- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
-+++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
-@@ -843,7 +843,7 @@ static bool build_regamma(struct pwl_float_data_ex *rgb_regamma,
- pow_buffer_ptr = -1; // reset back to no optimize
- ret = true;
- release:
-- kfree(coeff);
-+ kvfree(coeff);
- return ret;
- }
-
-diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
-index 868e2d5f6e62..7c3e903230ca 100644
---- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
-+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
-@@ -239,7 +239,7 @@ static void ci_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
-
- switch (dev_id) {
- case 0x67BA:
-- case 0x66B1:
-+ case 0x67B1:
- smu_data->power_tune_defaults = &defaults_hawaii_pro;
- break;
- case 0x67B8:
-diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
-index 7a9f20a2fd30..e7ba0b6f46d8 100644
---- a/drivers/gpu/drm/ast/ast_mode.c
-+++ b/drivers/gpu/drm/ast/ast_mode.c
-@@ -226,6 +226,7 @@ static void ast_set_vbios_color_reg(struct ast_private *ast,
- case 3:
- case 4:
- color_index = TrueCModeIndex;
-+ break;
- default:
- return;
- }
-@@ -801,6 +802,9 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
- return -EINVAL;
- }
-
-+ if (!state->enable)
-+ return 0; /* no mode checks if CRTC is being disabled */
-+
- ast_state = to_ast_crtc_state(state);
-
- format = ast_state->format;
-diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
-index 644f0ad10671..ac9fd96c4c66 100644
---- a/drivers/gpu/drm/drm_connector.c
-+++ b/drivers/gpu/drm/drm_connector.c
-@@ -27,6 +27,7 @@
- #include <drm/drm_print.h>
- #include <drm/drm_drv.h>
- #include <drm/drm_file.h>
-+#include <drm/drm_sysfs.h>
-
- #include <linux/uaccess.h>
-
-@@ -523,6 +524,10 @@ int drm_connector_register(struct drm_connector *connector)
- drm_mode_object_register(connector->dev, &connector->base);
-
- connector->registration_state = DRM_CONNECTOR_REGISTERED;
-+
-+ /* Let userspace know we have a new connector */
-+ drm_sysfs_hotplug_event(connector->dev);
-+
- goto unlock;
-
- err_debugfs:
-diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
-index 9d89ebf3a749..abb1f358ec6d 100644
---- a/drivers/gpu/drm/drm_dp_mst_topology.c
-+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
-@@ -27,6 +27,7 @@
- #include <linux/kernel.h>
- #include <linux/sched.h>
- #include <linux/seq_file.h>
-+#include <linux/iopoll.h>
-
- #if IS_ENABLED(CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS)
- #include <linux/stacktrace.h>
-@@ -4448,6 +4449,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.
-@@ -4457,33 +4469,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 cf804389f5ec..d50a7884e69e 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/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
-index 939f0032aab1..f0336c804639 100644
---- a/drivers/gpu/drm/drm_sysfs.c
-+++ b/drivers/gpu/drm/drm_sysfs.c
-@@ -291,9 +291,6 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
- return PTR_ERR(connector->kdev);
- }
-
-- /* Let userspace know we have a new connector */
-- drm_sysfs_hotplug_event(dev);
--
- if (connector->ddc)
- return sysfs_create_link(&connector->kdev->kobj,
- &connector->ddc->dev.kobj, "ddc");
-diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
-index 52db7852827b..647412da733e 100644
---- a/drivers/gpu/drm/i915/display/intel_ddi.c
-+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
-@@ -2866,7 +2866,7 @@ icl_program_mg_dp_mode(struct intel_digital_port *intel_dig_port,
- ln1 = intel_de_read(dev_priv, MG_DP_MODE(1, tc_port));
- }
-
-- ln0 &= ~(MG_DP_MODE_CFG_DP_X1_MODE | MG_DP_MODE_CFG_DP_X1_MODE);
-+ ln0 &= ~(MG_DP_MODE_CFG_DP_X1_MODE | MG_DP_MODE_CFG_DP_X2_MODE);
- ln1 &= ~(MG_DP_MODE_CFG_DP_X1_MODE | MG_DP_MODE_CFG_DP_X2_MODE);
-
- /* DPPATC */
-diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
-index a2fafd4499f2..5e228d202e4d 100644
---- a/drivers/gpu/drm/i915/display/intel_dp.c
-+++ b/drivers/gpu/drm/i915/display/intel_dp.c
-@@ -1343,8 +1343,7 @@ intel_dp_aux_xfer(struct intel_dp *intel_dp,
- bool is_tc_port = intel_phy_is_tc(i915, phy);
- i915_reg_t ch_ctl, ch_data[5];
- u32 aux_clock_divider;
-- enum intel_display_power_domain aux_domain =
-- intel_aux_power_domain(intel_dig_port);
-+ enum intel_display_power_domain aux_domain;
- intel_wakeref_t aux_wakeref;
- intel_wakeref_t pps_wakeref;
- int i, ret, recv_bytes;
-@@ -1359,6 +1358,8 @@ intel_dp_aux_xfer(struct intel_dp *intel_dp,
- if (is_tc_port)
- intel_tc_port_lock(intel_dig_port);
-
-+ aux_domain = intel_aux_power_domain(intel_dig_port);
-+
- aux_wakeref = intel_display_power_get(i915, aux_domain);
- pps_wakeref = pps_lock(intel_dp);
-
-diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
-index 5d5d7eef3f43..7aff3514d97a 100644
---- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
-+++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
-@@ -39,7 +39,6 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
- unsigned long last_pfn = 0; /* suppress gcc warning */
- unsigned int max_segment = i915_sg_segment_size();
- unsigned int sg_page_sizes;
-- struct pagevec pvec;
- gfp_t noreclaim;
- int ret;
-
-@@ -192,13 +191,17 @@ err_sg:
- sg_mark_end(sg);
- err_pages:
- mapping_clear_unevictable(mapping);
-- pagevec_init(&pvec);
-- for_each_sgt_page(page, sgt_iter, st) {
-- if (!pagevec_add(&pvec, page))
-+ if (sg != st->sgl) {
-+ struct pagevec pvec;
-+
-+ pagevec_init(&pvec);
-+ for_each_sgt_page(page, sgt_iter, st) {
-+ if (!pagevec_add(&pvec, page))
-+ check_release_pagevec(&pvec);
-+ }
-+ if (pagevec_count(&pvec))
- check_release_pagevec(&pvec);
- }
-- if (pagevec_count(&pvec))
-- check_release_pagevec(&pvec);
- sg_free_table(st);
- kfree(st);
-
-diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
-index 883a9b7fe88d..55b9165e7533 100644
---- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
-+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
-@@ -639,7 +639,7 @@ static int engine_setup_common(struct intel_engine_cs *engine)
- struct measure_breadcrumb {
- struct i915_request rq;
- struct intel_ring ring;
-- u32 cs[1024];
-+ u32 cs[2048];
- };
-
- static int measure_breadcrumb_dw(struct intel_context *ce)
-@@ -661,6 +661,8 @@ static int measure_breadcrumb_dw(struct intel_context *ce)
-
- frame->ring.vaddr = frame->cs;
- frame->ring.size = sizeof(frame->cs);
-+ frame->ring.wrap =
-+ BITS_PER_TYPE(frame->ring.size) - ilog2(frame->ring.size);
- frame->ring.effective_size = frame->ring.size;
- intel_ring_update_space(&frame->ring);
- frame->rq.ring = &frame->ring;
-diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
-index 2dfaddb8811e..ba82193b4e31 100644
---- a/drivers/gpu/drm/i915/gt/intel_lrc.c
-+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
-@@ -972,6 +972,13 @@ __unwind_incomplete_requests(struct intel_engine_cs *engine)
- list_move(&rq->sched.link, pl);
- set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags);
-
-+ /* Check in case we rollback so far we wrap [size/2] */
-+ if (intel_ring_direction(rq->ring,
-+ intel_ring_wrap(rq->ring,
-+ rq->tail),
-+ rq->ring->tail) > 0)
-+ rq->context->lrc.desc |= CTX_DESC_FORCE_RESTORE;
-+
- active = rq;
- } else {
- struct intel_engine_cs *owner = rq->context->engine;
-@@ -1383,8 +1390,9 @@ static u64 execlists_update_context(struct i915_request *rq)
- * HW has a tendency to ignore us rewinding the TAIL to the end of
- * an earlier request.
- */
-+ GEM_BUG_ON(ce->lrc_reg_state[CTX_RING_TAIL] != rq->ring->tail);
-+ prev = rq->ring->tail;
- tail = intel_ring_set_tail(rq->ring, rq->tail);
-- prev = ce->lrc_reg_state[CTX_RING_TAIL];
- if (unlikely(intel_ring_direction(rq->ring, tail, prev) <= 0))
- desc |= CTX_DESC_FORCE_RESTORE;
- ce->lrc_reg_state[CTX_RING_TAIL] = tail;
-@@ -4213,6 +4221,14 @@ static int gen12_emit_flush_render(struct i915_request *request,
- return 0;
- }
-
-+static void assert_request_valid(struct i915_request *rq)
-+{
-+ struct intel_ring *ring __maybe_unused = rq->ring;
-+
-+ /* Can we unwind this request without appearing to go forwards? */
-+ GEM_BUG_ON(intel_ring_direction(ring, rq->wa_tail, rq->head) <= 0);
-+}
-+
- /*
- * Reserve space for 2 NOOPs at the end of each request to be
- * used as a workaround for not being allowed to do lite
-@@ -4225,6 +4241,9 @@ static u32 *gen8_emit_wa_tail(struct i915_request *request, u32 *cs)
- *cs++ = MI_NOOP;
- request->wa_tail = intel_ring_offset(request, cs);
-
-+ /* Check that entire request is less than half the ring */
-+ assert_request_valid(request);
-+
- return cs;
- }
-
-diff --git a/drivers/gpu/drm/i915/gt/intel_ring.c b/drivers/gpu/drm/i915/gt/intel_ring.c
-index 8cda1b7e17ba..bdb324167ef3 100644
---- a/drivers/gpu/drm/i915/gt/intel_ring.c
-+++ b/drivers/gpu/drm/i915/gt/intel_ring.c
-@@ -315,3 +315,7 @@ int intel_ring_cacheline_align(struct i915_request *rq)
- GEM_BUG_ON(rq->ring->emit & (CACHELINE_BYTES - 1));
- return 0;
- }
-+
-+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
-+#include "selftest_ring.c"
-+#endif
-diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
-index 5176ad1a3976..bb100872cd07 100644
---- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
-+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
-@@ -178,6 +178,12 @@ wa_write_or(struct i915_wa_list *wal, i915_reg_t reg, u32 set)
- wa_write_masked_or(wal, reg, set, set);
- }
-
-+static void
-+wa_write_clr(struct i915_wa_list *wal, i915_reg_t reg, u32 clr)
-+{
-+ wa_write_masked_or(wal, reg, clr, 0);
-+}
-+
- static void
- wa_masked_en(struct i915_wa_list *wal, i915_reg_t reg, u32 val)
- {
-@@ -697,6 +703,227 @@ int intel_engine_emit_ctx_wa(struct i915_request *rq)
- return 0;
- }
-
-+static void
-+gen4_gt_workarounds_init(struct drm_i915_private *i915,
-+ struct i915_wa_list *wal)
-+{
-+ /* WaDisable_RenderCache_OperationalFlush:gen4,ilk */
-+ wa_masked_dis(wal, CACHE_MODE_0, RC_OP_FLUSH_ENABLE);
-+}
-+
-+static void
-+g4x_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
-+{
-+ gen4_gt_workarounds_init(i915, wal);
-+
-+ /* WaDisableRenderCachePipelinedFlush:g4x,ilk */
-+ wa_masked_en(wal, CACHE_MODE_0, CM0_PIPELINED_RENDER_FLUSH_DISABLE);
-+}
-+
-+static void
-+ilk_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
-+{
-+ g4x_gt_workarounds_init(i915, wal);
-+
-+ wa_masked_en(wal, _3D_CHICKEN2, _3D_CHICKEN2_WM_READ_PIPELINED);
-+}
-+
-+static void
-+snb_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
-+{
-+ /* WaDisableHiZPlanesWhenMSAAEnabled:snb */
-+ wa_masked_en(wal,
-+ _3D_CHICKEN,
-+ _3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB);
-+
-+ /* WaDisable_RenderCache_OperationalFlush:snb */
-+ wa_masked_dis(wal, CACHE_MODE_0, RC_OP_FLUSH_ENABLE);
-+
-+ /*
-+ * BSpec recommends 8x4 when MSAA is used,
-+ * however in practice 16x4 seems fastest.
-+ *
-+ * Note that PS/WM thread counts depend on the WIZ hashing
-+ * disable bit, which we don't touch here, but it's good
-+ * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-+ */
-+ wa_add(wal,
-+ GEN6_GT_MODE, 0,
-+ _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4),
-+ GEN6_WIZ_HASHING_16x4);
-+
-+ wa_masked_dis(wal, CACHE_MODE_0, CM0_STC_EVICT_DISABLE_LRA_SNB);
-+
-+ wa_masked_en(wal,
-+ _3D_CHICKEN3,
-+ /* WaStripsFansDisableFastClipPerformanceFix:snb */
-+ _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL |
-+ /*
-+ * Bspec says:
-+ * "This bit must be set if 3DSTATE_CLIP clip mode is set
-+ * to normal and 3DSTATE_SF number of SF output attributes
-+ * is more than 16."
-+ */
-+ _3D_CHICKEN3_SF_DISABLE_PIPELINED_ATTR_FETCH);
-+}
-+
-+static void
-+ivb_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
-+{
-+ /* WaDisableEarlyCull:ivb */
-+ wa_masked_en(wal, _3D_CHICKEN3, _3D_CHICKEN_SF_DISABLE_OBJEND_CULL);
-+
-+ /* WaDisablePSDDualDispatchEnable:ivb */
-+ if (IS_IVB_GT1(i915))
-+ wa_masked_en(wal,
-+ GEN7_HALF_SLICE_CHICKEN1,
-+ GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE);
-+
-+ /* WaDisable_RenderCache_OperationalFlush:ivb */
-+ wa_masked_dis(wal, CACHE_MODE_0_GEN7, RC_OP_FLUSH_ENABLE);
-+
-+ /* Apply the WaDisableRHWOOptimizationForRenderHang:ivb workaround. */
-+ wa_masked_dis(wal,
-+ GEN7_COMMON_SLICE_CHICKEN1,
-+ GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
-+
-+ /* WaApplyL3ControlAndL3ChickenMode:ivb */
-+ wa_write(wal, GEN7_L3CNTLREG1, GEN7_WA_FOR_GEN7_L3_CONTROL);
-+ wa_write(wal, GEN7_L3_CHICKEN_MODE_REGISTER, GEN7_WA_L3_CHICKEN_MODE);
-+
-+ /* WaForceL3Serialization:ivb */
-+ wa_write_clr(wal, GEN7_L3SQCREG4, L3SQ_URB_READ_CAM_MATCH_DISABLE);
-+
-+ /*
-+ * WaVSThreadDispatchOverride:ivb,vlv
-+ *
-+ * This actually overrides the dispatch
-+ * mode for all thread types.
-+ */
-+ wa_write_masked_or(wal, GEN7_FF_THREAD_MODE,
-+ GEN7_FF_SCHED_MASK,
-+ GEN7_FF_TS_SCHED_HW |
-+ GEN7_FF_VS_SCHED_HW |
-+ GEN7_FF_DS_SCHED_HW);
-+
-+ if (0) { /* causes HiZ corruption on ivb:gt1 */
-+ /* enable HiZ Raw Stall Optimization */
-+ wa_masked_dis(wal, CACHE_MODE_0_GEN7, HIZ_RAW_STALL_OPT_DISABLE);
-+ }
-+
-+ /* WaDisable4x2SubspanOptimization:ivb */
-+ wa_masked_en(wal, CACHE_MODE_1, PIXEL_SUBSPAN_COLLECT_OPT_DISABLE);
-+
-+ /*
-+ * BSpec recommends 8x4 when MSAA is used,
-+ * however in practice 16x4 seems fastest.
-+ *
-+ * Note that PS/WM thread counts depend on the WIZ hashing
-+ * disable bit, which we don't touch here, but it's good
-+ * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-+ */
-+ wa_add(wal, GEN7_GT_MODE, 0,
-+ _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4),
-+ GEN6_WIZ_HASHING_16x4);
-+}
-+
-+static void
-+vlv_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
-+{
-+ /* WaDisableEarlyCull:vlv */
-+ wa_masked_en(wal, _3D_CHICKEN3, _3D_CHICKEN_SF_DISABLE_OBJEND_CULL);
-+
-+ /* WaPsdDispatchEnable:vlv */
-+ /* WaDisablePSDDualDispatchEnable:vlv */
-+ wa_masked_en(wal,
-+ GEN7_HALF_SLICE_CHICKEN1,
-+ GEN7_MAX_PS_THREAD_DEP |
-+ GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE);
-+
-+ /* WaDisable_RenderCache_OperationalFlush:vlv */
-+ wa_masked_dis(wal, CACHE_MODE_0_GEN7, RC_OP_FLUSH_ENABLE);
-+
-+ /* WaForceL3Serialization:vlv */
-+ wa_write_clr(wal, GEN7_L3SQCREG4, L3SQ_URB_READ_CAM_MATCH_DISABLE);
-+
-+ /*
-+ * WaVSThreadDispatchOverride:ivb,vlv
-+ *
-+ * This actually overrides the dispatch
-+ * mode for all thread types.
-+ */
-+ wa_write_masked_or(wal,
-+ GEN7_FF_THREAD_MODE,
-+ GEN7_FF_SCHED_MASK,
-+ GEN7_FF_TS_SCHED_HW |
-+ GEN7_FF_VS_SCHED_HW |
-+ GEN7_FF_DS_SCHED_HW);
-+
-+ /*
-+ * BSpec says this must be set, even though
-+ * WaDisable4x2SubspanOptimization isn't listed for VLV.
-+ */
-+ wa_masked_en(wal, CACHE_MODE_1, PIXEL_SUBSPAN_COLLECT_OPT_DISABLE);
-+
-+ /*
-+ * BSpec recommends 8x4 when MSAA is used,
-+ * however in practice 16x4 seems fastest.
-+ *
-+ * Note that PS/WM thread counts depend on the WIZ hashing
-+ * disable bit, which we don't touch here, but it's good
-+ * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-+ */
-+ wa_add(wal, GEN7_GT_MODE, 0,
-+ _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4),
-+ GEN6_WIZ_HASHING_16x4);
-+
-+ /*
-+ * WaIncreaseL3CreditsForVLVB0:vlv
-+ * This is the hardware default actually.
-+ */
-+ wa_write(wal, GEN7_L3SQCREG1, VLV_B0_WA_L3SQCREG1_VALUE);
-+}
-+
-+static void
-+hsw_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
-+{
-+ /* L3 caching of data atomics doesn't work -- disable it. */
-+ wa_write(wal, HSW_SCRATCH1, HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE);
-+
-+ wa_add(wal,
-+ HSW_ROW_CHICKEN3, 0,
-+ _MASKED_BIT_ENABLE(HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE),
-+ 0 /* XXX does this reg exist? */);
-+
-+ /* WaVSRefCountFullforceMissDisable:hsw */
-+ wa_write_clr(wal, GEN7_FF_THREAD_MODE, GEN7_FF_VS_REF_CNT_FFME);
-+
-+ wa_masked_dis(wal,
-+ CACHE_MODE_0_GEN7,
-+ /* WaDisable_RenderCache_OperationalFlush:hsw */
-+ RC_OP_FLUSH_ENABLE |
-+ /* enable HiZ Raw Stall Optimization */
-+ HIZ_RAW_STALL_OPT_DISABLE);
-+
-+ /* WaDisable4x2SubspanOptimization:hsw */
-+ wa_masked_en(wal, CACHE_MODE_1, PIXEL_SUBSPAN_COLLECT_OPT_DISABLE);
-+
-+ /*
-+ * BSpec recommends 8x4 when MSAA is used,
-+ * however in practice 16x4 seems fastest.
-+ *
-+ * Note that PS/WM thread counts depend on the WIZ hashing
-+ * disable bit, which we don't touch here, but it's good
-+ * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-+ */
-+ wa_add(wal, GEN7_GT_MODE, 0,
-+ _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4),
-+ GEN6_WIZ_HASHING_16x4);
-+
-+ /* WaSampleCChickenBitEnable:hsw */
-+ wa_masked_en(wal, HALF_SLICE_CHICKEN3, HSW_SAMPLE_C_PERFORMANCE);
-+}
-+
- static void
- gen9_gt_workarounds_init(struct drm_i915_private *i915, struct i915_wa_list *wal)
- {
-@@ -974,6 +1201,20 @@ gt_init_workarounds(struct drm_i915_private *i915, struct i915_wa_list *wal)
- bxt_gt_workarounds_init(i915, wal);
- else if (IS_SKYLAKE(i915))
- skl_gt_workarounds_init(i915, wal);
-+ else if (IS_HASWELL(i915))
-+ hsw_gt_workarounds_init(i915, wal);
-+ else if (IS_VALLEYVIEW(i915))
-+ vlv_gt_workarounds_init(i915, wal);
-+ else if (IS_IVYBRIDGE(i915))
-+ ivb_gt_workarounds_init(i915, wal);
-+ else if (IS_GEN(i915, 6))
-+ snb_gt_workarounds_init(i915, wal);
-+ else if (IS_GEN(i915, 5))
-+ ilk_gt_workarounds_init(i915, wal);
-+ else if (IS_G4X(i915))
-+ g4x_gt_workarounds_init(i915, wal);
-+ else if (IS_GEN(i915, 4))
-+ gen4_gt_workarounds_init(i915, wal);
- else if (INTEL_GEN(i915) <= 8)
- return;
- else
-@@ -1379,12 +1620,6 @@ rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
- GEN7_FF_THREAD_MODE,
- GEN12_FF_TESSELATION_DOP_GATE_DISABLE);
-
-- /*
-- * Wa_1409085225:tgl
-- * Wa_14010229206:tgl
-- */
-- wa_masked_en(wal, GEN9_ROW_CHICKEN4, GEN12_DISABLE_TDL_PUSH);
--
- /* Wa_1408615072:tgl */
- wa_write_or(wal, UNSLICE_UNIT_LEVEL_CLKGATE2,
- VSUNIT_CLKGATE_DIS_TGL);
-@@ -1402,6 +1637,12 @@ rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
- wa_masked_en(wal,
- GEN9_CS_DEBUG_MODE1,
- FF_DOP_CLOCK_GATE_DISABLE);
-+
-+ /*
-+ * Wa_1409085225:tgl
-+ * Wa_14010229206:tgl
-+ */
-+ wa_masked_en(wal, GEN9_ROW_CHICKEN4, GEN12_DISABLE_TDL_PUSH);
- }
-
- if (IS_GEN(i915, 11)) {
-diff --git a/drivers/gpu/drm/i915/gt/selftest_mocs.c b/drivers/gpu/drm/i915/gt/selftest_mocs.c
-index 8831ffee2061..63f87d8608c3 100644
---- a/drivers/gpu/drm/i915/gt/selftest_mocs.c
-+++ b/drivers/gpu/drm/i915/gt/selftest_mocs.c
-@@ -18,6 +18,20 @@ struct live_mocs {
- void *vaddr;
- };
-
-+static struct intel_context *mocs_context_create(struct intel_engine_cs *engine)
-+{
-+ struct intel_context *ce;
-+
-+ ce = intel_context_create(engine);
-+ if (IS_ERR(ce))
-+ return ce;
-+
-+ /* We build large requests to read the registers from the ring */
-+ ce->ring = __intel_context_ring_size(SZ_16K);
-+
-+ return ce;
-+}
-+
- static int request_add_sync(struct i915_request *rq, int err)
- {
- i915_request_get(rq);
-@@ -301,7 +315,7 @@ static int live_mocs_clean(void *arg)
- for_each_engine(engine, gt, id) {
- struct intel_context *ce;
-
-- ce = intel_context_create(engine);
-+ ce = mocs_context_create(engine);
- if (IS_ERR(ce)) {
- err = PTR_ERR(ce);
- break;
-@@ -395,7 +409,7 @@ static int live_mocs_reset(void *arg)
- for_each_engine(engine, gt, id) {
- struct intel_context *ce;
-
-- ce = intel_context_create(engine);
-+ ce = mocs_context_create(engine);
- if (IS_ERR(ce)) {
- err = PTR_ERR(ce);
- break;
-diff --git a/drivers/gpu/drm/i915/gt/selftest_ring.c b/drivers/gpu/drm/i915/gt/selftest_ring.c
-new file mode 100644
-index 000000000000..2a8c534dc125
---- /dev/null
-+++ b/drivers/gpu/drm/i915/gt/selftest_ring.c
-@@ -0,0 +1,110 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Copyright © 2020 Intel Corporation
-+ */
-+
-+static struct intel_ring *mock_ring(unsigned long sz)
-+{
-+ struct intel_ring *ring;
-+
-+ ring = kzalloc(sizeof(*ring) + sz, GFP_KERNEL);
-+ if (!ring)
-+ return NULL;
-+
-+ kref_init(&ring->ref);
-+ ring->size = sz;
-+ ring->wrap = BITS_PER_TYPE(ring->size) - ilog2(sz);
-+ ring->effective_size = sz;
-+ ring->vaddr = (void *)(ring + 1);
-+ atomic_set(&ring->pin_count, 1);
-+
-+ intel_ring_update_space(ring);
-+
-+ return ring;
-+}
-+
-+static void mock_ring_free(struct intel_ring *ring)
-+{
-+ kfree(ring);
-+}
-+
-+static int check_ring_direction(struct intel_ring *ring,
-+ u32 next, u32 prev,
-+ int expected)
-+{
-+ int result;
-+
-+ result = intel_ring_direction(ring, next, prev);
-+ if (result < 0)
-+ result = -1;
-+ else if (result > 0)
-+ result = 1;
-+
-+ if (result != expected) {
-+ pr_err("intel_ring_direction(%u, %u):%d != %d\n",
-+ next, prev, result, expected);
-+ return -EINVAL;
-+ }
-+
-+ return 0;
-+}
-+
-+static int check_ring_step(struct intel_ring *ring, u32 x, u32 step)
-+{
-+ u32 prev = x, next = intel_ring_wrap(ring, x + step);
-+ int err = 0;
-+
-+ err |= check_ring_direction(ring, next, next, 0);
-+ err |= check_ring_direction(ring, prev, prev, 0);
-+ err |= check_ring_direction(ring, next, prev, 1);
-+ err |= check_ring_direction(ring, prev, next, -1);
-+
-+ return err;
-+}
-+
-+static int check_ring_offset(struct intel_ring *ring, u32 x, u32 step)
-+{
-+ int err = 0;
-+
-+ err |= check_ring_step(ring, x, step);
-+ err |= check_ring_step(ring, intel_ring_wrap(ring, x + 1), step);
-+ err |= check_ring_step(ring, intel_ring_wrap(ring, x - 1), step);
-+
-+ return err;
-+}
-+
-+static int igt_ring_direction(void *dummy)
-+{
-+ struct intel_ring *ring;
-+ unsigned int half = 2048;
-+ int step, err = 0;
-+
-+ ring = mock_ring(2 * half);
-+ if (!ring)
-+ return -ENOMEM;
-+
-+ GEM_BUG_ON(ring->size != 2 * half);
-+
-+ /* Precision of wrap detection is limited to ring->size / 2 */
-+ for (step = 1; step < half; step <<= 1) {
-+ err |= check_ring_offset(ring, 0, step);
-+ err |= check_ring_offset(ring, half, step);
-+ }
-+ err |= check_ring_step(ring, 0, half - 64);
-+
-+ /* And check unwrapped handling for good measure */
-+ err |= check_ring_offset(ring, 0, 2 * half + 64);
-+ err |= check_ring_offset(ring, 3 * half, 1);
-+
-+ mock_ring_free(ring);
-+ return err;
-+}
-+
-+int intel_ring_mock_selftests(void)
-+{
-+ static const struct i915_subtest tests[] = {
-+ SUBTEST(igt_ring_direction),
-+ };
-+
-+ return i915_subtests(tests, NULL);
-+}
-diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
-index 189b573d02be..372354d33f55 100644
---- a/drivers/gpu/drm/i915/i915_cmd_parser.c
-+++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
-@@ -572,6 +572,9 @@ struct drm_i915_reg_descriptor {
- #define REG32(_reg, ...) \
- { .addr = (_reg), __VA_ARGS__ }
-
-+#define REG32_IDX(_reg, idx) \
-+ { .addr = _reg(idx) }
-+
- /*
- * Convenience macro for adding 64-bit registers.
- *
-@@ -669,6 +672,7 @@ static const struct drm_i915_reg_descriptor gen9_blt_regs[] = {
- REG64_IDX(RING_TIMESTAMP, BSD_RING_BASE),
- REG32(BCS_SWCTRL),
- REG64_IDX(RING_TIMESTAMP, BLT_RING_BASE),
-+ REG32_IDX(RING_CTX_TIMESTAMP, BLT_RING_BASE),
- REG64_IDX(BCS_GPR, 0),
- REG64_IDX(BCS_GPR, 1),
- REG64_IDX(BCS_GPR, 2),
-diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
-index 8a2b83807ffc..bd042725a678 100644
---- a/drivers/gpu/drm/i915/i915_irq.c
-+++ b/drivers/gpu/drm/i915/i915_irq.c
-@@ -3092,6 +3092,7 @@ static void gen11_hpd_irq_setup(struct drm_i915_private *dev_priv)
-
- val = I915_READ(GEN11_DE_HPD_IMR);
- val &= ~hotplug_irqs;
-+ val |= ~enabled_irqs & hotplug_irqs;
- I915_WRITE(GEN11_DE_HPD_IMR, val);
- POSTING_READ(GEN11_DE_HPD_IMR);
-
-diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
-index 6e12000c4b6b..a41be9357d15 100644
---- a/drivers/gpu/drm/i915/i915_reg.h
-+++ b/drivers/gpu/drm/i915/i915_reg.h
-@@ -7819,7 +7819,7 @@ enum {
-
- /* GEN7 chicken */
- #define GEN7_COMMON_SLICE_CHICKEN1 _MMIO(0x7010)
-- #define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC ((1 << 10) | (1 << 26))
-+ #define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC (1 << 10)
- #define GEN9_RHWO_OPTIMIZATION_DISABLE (1 << 14)
-
- #define COMMON_SLICE_CHICKEN2 _MMIO(0x7014)
-diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
-index a52986a9e7a6..20c1683fda24 100644
---- a/drivers/gpu/drm/i915/intel_pm.c
-+++ b/drivers/gpu/drm/i915/intel_pm.c
-@@ -6593,16 +6593,6 @@ static void ilk_init_clock_gating(struct drm_i915_private *dev_priv)
- I915_WRITE(ILK_DISPLAY_CHICKEN2,
- I915_READ(ILK_DISPLAY_CHICKEN2) |
- ILK_ELPIN_409_SELECT);
-- I915_WRITE(_3D_CHICKEN2,
-- _3D_CHICKEN2_WM_READ_PIPELINED << 16 |
-- _3D_CHICKEN2_WM_READ_PIPELINED);
--
-- /* WaDisableRenderCachePipelinedFlush:ilk */
-- I915_WRITE(CACHE_MODE_0,
-- _MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE));
--
-- /* WaDisable_RenderCache_OperationalFlush:ilk */
-- I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
-
- g4x_disable_trickle_feed(dev_priv);
-
-@@ -6665,27 +6655,6 @@ static void gen6_init_clock_gating(struct drm_i915_private *dev_priv)
- I915_READ(ILK_DISPLAY_CHICKEN2) |
- ILK_ELPIN_409_SELECT);
-
-- /* WaDisableHiZPlanesWhenMSAAEnabled:snb */
-- I915_WRITE(_3D_CHICKEN,
-- _MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB));
--
-- /* WaDisable_RenderCache_OperationalFlush:snb */
-- I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
--
-- /*
-- * BSpec recoomends 8x4 when MSAA is used,
-- * however in practice 16x4 seems fastest.
-- *
-- * Note that PS/WM thread counts depend on the WIZ hashing
-- * disable bit, which we don't touch here, but it's good
-- * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-- */
-- I915_WRITE(GEN6_GT_MODE,
-- _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
--
-- I915_WRITE(CACHE_MODE_0,
-- _MASKED_BIT_DISABLE(CM0_STC_EVICT_DISABLE_LRA_SNB));
--
- I915_WRITE(GEN6_UCGCTL1,
- I915_READ(GEN6_UCGCTL1) |
- GEN6_BLBUNIT_CLOCK_GATE_DISABLE |
-@@ -6708,18 +6677,6 @@ static void gen6_init_clock_gating(struct drm_i915_private *dev_priv)
- GEN6_RCPBUNIT_CLOCK_GATE_DISABLE |
- GEN6_RCCUNIT_CLOCK_GATE_DISABLE);
-
-- /* WaStripsFansDisableFastClipPerformanceFix:snb */
-- I915_WRITE(_3D_CHICKEN3,
-- _MASKED_BIT_ENABLE(_3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL));
--
-- /*
-- * Bspec says:
-- * "This bit must be set if 3DSTATE_CLIP clip mode is set to normal and
-- * 3DSTATE_SF number of SF output attributes is more than 16."
-- */
-- I915_WRITE(_3D_CHICKEN3,
-- _MASKED_BIT_ENABLE(_3D_CHICKEN3_SF_DISABLE_PIPELINED_ATTR_FETCH));
--
- /*
- * According to the spec the following bits should be
- * set in order to enable memory self-refresh and fbc:
-@@ -6749,24 +6706,6 @@ static void gen6_init_clock_gating(struct drm_i915_private *dev_priv)
- gen6_check_mch_setup(dev_priv);
- }
-
--static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
--{
-- u32 reg = I915_READ(GEN7_FF_THREAD_MODE);
--
-- /*
-- * WaVSThreadDispatchOverride:ivb,vlv
-- *
-- * This actually overrides the dispatch
-- * mode for all thread types.
-- */
-- reg &= ~GEN7_FF_SCHED_MASK;
-- reg |= GEN7_FF_TS_SCHED_HW;
-- reg |= GEN7_FF_VS_SCHED_HW;
-- reg |= GEN7_FF_DS_SCHED_HW;
--
-- I915_WRITE(GEN7_FF_THREAD_MODE, reg);
--}
--
- static void lpt_init_clock_gating(struct drm_i915_private *dev_priv)
- {
- /*
-@@ -6992,45 +6931,10 @@ static void bdw_init_clock_gating(struct drm_i915_private *dev_priv)
-
- static void hsw_init_clock_gating(struct drm_i915_private *dev_priv)
- {
-- /* L3 caching of data atomics doesn't work -- disable it. */
-- I915_WRITE(HSW_SCRATCH1, HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE);
-- I915_WRITE(HSW_ROW_CHICKEN3,
-- _MASKED_BIT_ENABLE(HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE));
--
- /* This is required by WaCatErrorRejectionIssue:hsw */
- I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG,
-- I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
-- GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
--
-- /* WaVSRefCountFullforceMissDisable:hsw */
-- I915_WRITE(GEN7_FF_THREAD_MODE,
-- I915_READ(GEN7_FF_THREAD_MODE) & ~GEN7_FF_VS_REF_CNT_FFME);
--
-- /* WaDisable_RenderCache_OperationalFlush:hsw */
-- I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
--
-- /* enable HiZ Raw Stall Optimization */
-- I915_WRITE(CACHE_MODE_0_GEN7,
-- _MASKED_BIT_DISABLE(HIZ_RAW_STALL_OPT_DISABLE));
--
-- /* WaDisable4x2SubspanOptimization:hsw */
-- I915_WRITE(CACHE_MODE_1,
-- _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
--
-- /*
-- * BSpec recommends 8x4 when MSAA is used,
-- * however in practice 16x4 seems fastest.
-- *
-- * Note that PS/WM thread counts depend on the WIZ hashing
-- * disable bit, which we don't touch here, but it's good
-- * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-- */
-- I915_WRITE(GEN7_GT_MODE,
-- _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
--
-- /* WaSampleCChickenBitEnable:hsw */
-- I915_WRITE(HALF_SLICE_CHICKEN3,
-- _MASKED_BIT_ENABLE(HSW_SAMPLE_C_PERFORMANCE));
-+ I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
-+ GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
-
- /* WaSwitchSolVfFArbitrationPriority:hsw */
- I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | HSW_ECOCHK_ARB_PRIO_SOL);
-@@ -7044,32 +6948,11 @@ static void ivb_init_clock_gating(struct drm_i915_private *dev_priv)
-
- I915_WRITE(ILK_DSPCLK_GATE_D, ILK_VRHUNIT_CLOCK_GATE_DISABLE);
-
-- /* WaDisableEarlyCull:ivb */
-- I915_WRITE(_3D_CHICKEN3,
-- _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL));
--
- /* WaDisableBackToBackFlipFix:ivb */
- I915_WRITE(IVB_CHICKEN3,
- CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
- CHICKEN3_DGMG_DONE_FIX_DISABLE);
-
-- /* WaDisablePSDDualDispatchEnable:ivb */
-- if (IS_IVB_GT1(dev_priv))
-- I915_WRITE(GEN7_HALF_SLICE_CHICKEN1,
-- _MASKED_BIT_ENABLE(GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
--
-- /* WaDisable_RenderCache_OperationalFlush:ivb */
-- I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
--
-- /* Apply the WaDisableRHWOOptimizationForRenderHang:ivb workaround. */
-- I915_WRITE(GEN7_COMMON_SLICE_CHICKEN1,
-- GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC);
--
-- /* WaApplyL3ControlAndL3ChickenMode:ivb */
-- I915_WRITE(GEN7_L3CNTLREG1,
-- GEN7_WA_FOR_GEN7_L3_CONTROL);
-- I915_WRITE(GEN7_L3_CHICKEN_MODE_REGISTER,
-- GEN7_WA_L3_CHICKEN_MODE);
- if (IS_IVB_GT1(dev_priv))
- I915_WRITE(GEN7_ROW_CHICKEN2,
- _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
-@@ -7081,10 +6964,6 @@ static void ivb_init_clock_gating(struct drm_i915_private *dev_priv)
- _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
- }
-
-- /* WaForceL3Serialization:ivb */
-- I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) &
-- ~L3SQ_URB_READ_CAM_MATCH_DISABLE);
--
- /*
- * According to the spec, bit 13 (RCZUNIT) must be set on IVB.
- * This implements the WaDisableRCZUnitClockGating:ivb workaround.
-@@ -7099,29 +6978,6 @@ static void ivb_init_clock_gating(struct drm_i915_private *dev_priv)
-
- g4x_disable_trickle_feed(dev_priv);
-
-- gen7_setup_fixed_func_scheduler(dev_priv);
--
-- if (0) { /* causes HiZ corruption on ivb:gt1 */
-- /* enable HiZ Raw Stall Optimization */
-- I915_WRITE(CACHE_MODE_0_GEN7,
-- _MASKED_BIT_DISABLE(HIZ_RAW_STALL_OPT_DISABLE));
-- }
--
-- /* WaDisable4x2SubspanOptimization:ivb */
-- I915_WRITE(CACHE_MODE_1,
-- _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
--
-- /*
-- * BSpec recommends 8x4 when MSAA is used,
-- * however in practice 16x4 seems fastest.
-- *
-- * Note that PS/WM thread counts depend on the WIZ hashing
-- * disable bit, which we don't touch here, but it's good
-- * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-- */
-- I915_WRITE(GEN7_GT_MODE,
-- _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
--
- snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
- snpcr &= ~GEN6_MBC_SNPCR_MASK;
- snpcr |= GEN6_MBC_SNPCR_MED;
-@@ -7135,28 +6991,11 @@ static void ivb_init_clock_gating(struct drm_i915_private *dev_priv)
-
- static void vlv_init_clock_gating(struct drm_i915_private *dev_priv)
- {
-- /* WaDisableEarlyCull:vlv */
-- I915_WRITE(_3D_CHICKEN3,
-- _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_DISABLE_OBJEND_CULL));
--
- /* WaDisableBackToBackFlipFix:vlv */
- I915_WRITE(IVB_CHICKEN3,
- CHICKEN3_DGMG_REQ_OUT_FIX_DISABLE |
- CHICKEN3_DGMG_DONE_FIX_DISABLE);
-
-- /* WaPsdDispatchEnable:vlv */
-- /* WaDisablePSDDualDispatchEnable:vlv */
-- I915_WRITE(GEN7_HALF_SLICE_CHICKEN1,
-- _MASKED_BIT_ENABLE(GEN7_MAX_PS_THREAD_DEP |
-- GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE));
--
-- /* WaDisable_RenderCache_OperationalFlush:vlv */
-- I915_WRITE(CACHE_MODE_0_GEN7, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
--
-- /* WaForceL3Serialization:vlv */
-- I915_WRITE(GEN7_L3SQCREG4, I915_READ(GEN7_L3SQCREG4) &
-- ~L3SQ_URB_READ_CAM_MATCH_DISABLE);
--
- /* WaDisableDopClockGating:vlv */
- I915_WRITE(GEN7_ROW_CHICKEN2,
- _MASKED_BIT_ENABLE(DOP_CLOCK_GATING_DISABLE));
-@@ -7166,8 +7005,6 @@ static void vlv_init_clock_gating(struct drm_i915_private *dev_priv)
- I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
- GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB);
-
-- gen7_setup_fixed_func_scheduler(dev_priv);
--
- /*
- * According to the spec, bit 13 (RCZUNIT) must be set on IVB.
- * This implements the WaDisableRCZUnitClockGating:vlv workaround.
-@@ -7181,30 +7018,6 @@ static void vlv_init_clock_gating(struct drm_i915_private *dev_priv)
- I915_WRITE(GEN7_UCGCTL4,
- I915_READ(GEN7_UCGCTL4) | GEN7_L3BANK2X_CLOCK_GATE_DISABLE);
-
-- /*
-- * BSpec says this must be set, even though
-- * WaDisable4x2SubspanOptimization isn't listed for VLV.
-- */
-- I915_WRITE(CACHE_MODE_1,
-- _MASKED_BIT_ENABLE(PIXEL_SUBSPAN_COLLECT_OPT_DISABLE));
--
-- /*
-- * BSpec recommends 8x4 when MSAA is used,
-- * however in practice 16x4 seems fastest.
-- *
-- * Note that PS/WM thread counts depend on the WIZ hashing
-- * disable bit, which we don't touch here, but it's good
-- * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM).
-- */
-- I915_WRITE(GEN7_GT_MODE,
-- _MASKED_FIELD(GEN6_WIZ_HASHING_MASK, GEN6_WIZ_HASHING_16x4));
--
-- /*
-- * WaIncreaseL3CreditsForVLVB0:vlv
-- * This is the hardware default actually.
-- */
-- I915_WRITE(GEN7_L3SQCREG1, VLV_B0_WA_L3SQCREG1_VALUE);
--
- /*
- * WaDisableVLVClockGating_VBIIssue:vlv
- * Disable clock gating on th GCFG unit to prevent a delay
-@@ -7257,13 +7070,6 @@ static void g4x_init_clock_gating(struct drm_i915_private *dev_priv)
- dspclk_gate |= DSSUNIT_CLOCK_GATE_DISABLE;
- I915_WRITE(DSPCLK_GATE_D, dspclk_gate);
-
-- /* WaDisableRenderCachePipelinedFlush */
-- I915_WRITE(CACHE_MODE_0,
-- _MASKED_BIT_ENABLE(CM0_PIPELINED_RENDER_FLUSH_DISABLE));
--
-- /* WaDisable_RenderCache_OperationalFlush:g4x */
-- I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
--
- g4x_disable_trickle_feed(dev_priv);
- }
-
-@@ -7279,11 +7085,6 @@ static void i965gm_init_clock_gating(struct drm_i915_private *dev_priv)
- intel_uncore_write(uncore,
- MI_ARB_STATE,
- _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
--
-- /* WaDisable_RenderCache_OperationalFlush:gen4 */
-- intel_uncore_write(uncore,
-- CACHE_MODE_0,
-- _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
- }
-
- static void i965g_init_clock_gating(struct drm_i915_private *dev_priv)
-@@ -7296,9 +7097,6 @@ static void i965g_init_clock_gating(struct drm_i915_private *dev_priv)
- I915_WRITE(RENCLK_GATE_D2, 0);
- I915_WRITE(MI_ARB_STATE,
- _MASKED_BIT_ENABLE(MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE));
--
-- /* WaDisable_RenderCache_OperationalFlush:gen4 */
-- I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
- }
-
- static void gen3_init_clock_gating(struct drm_i915_private *dev_priv)
-diff --git a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
-index 5b39bab4da1d..86baed226b53 100644
---- a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
-+++ b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h
-@@ -20,6 +20,7 @@ selftest(fence, i915_sw_fence_mock_selftests)
- selftest(scatterlist, scatterlist_mock_selftests)
- selftest(syncmap, i915_syncmap_mock_selftests)
- selftest(uncore, intel_uncore_mock_selftests)
-+selftest(ring, intel_ring_mock_selftests)
- selftest(engine, intel_engine_cs_mock_selftests)
- selftest(timelines, intel_timeline_mock_selftests)
- selftest(requests, i915_request_mock_selftests)
-diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
-index 724024a2243a..662d02289533 100644
---- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
-+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
-@@ -1404,6 +1404,10 @@ static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu)
- {
- u64 busy_cycles, busy_time;
-
-+ /* Only read the gpu busy if the hardware is already active */
-+ if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
-+ return 0;
-+
- busy_cycles = gpu_read64(gpu, REG_A5XX_RBBM_PERFCTR_RBBM_0_LO,
- REG_A5XX_RBBM_PERFCTR_RBBM_0_HI);
-
-@@ -1412,6 +1416,8 @@ static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu)
-
- gpu->devfreq.busy_cycles = busy_cycles;
-
-+ pm_runtime_put(&gpu->pdev->dev);
-+
- if (WARN_ON(busy_time > ~0LU))
- return ~0LU;
-
-diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
-index c4e71abbdd53..34607a98cc7c 100644
---- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
-+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
-@@ -108,6 +108,13 @@ static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
- struct msm_gpu *gpu = &adreno_gpu->base;
- int ret;
-
-+ /*
-+ * This can get called from devfreq while the hardware is idle. Don't
-+ * bring up the power if it isn't already active
-+ */
-+ if (pm_runtime_get_if_in_use(gmu->dev) == 0)
-+ return;
-+
- gmu_write(gmu, REG_A6XX_GMU_DCVS_ACK_OPTION, 0);
-
- gmu_write(gmu, REG_A6XX_GMU_DCVS_PERF_SETTING,
-@@ -134,6 +141,7 @@ static void __a6xx_gmu_set_freq(struct a6xx_gmu *gmu, int index)
- * for now leave it at max so that the performance is nominal.
- */
- icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
-+ pm_runtime_put(gmu->dev);
- }
-
- void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq)
-diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
-index 68af24150de5..2c09d2c21773 100644
---- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
-+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
-@@ -810,6 +810,11 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)
- struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
- u64 busy_cycles, busy_time;
-
-+
-+ /* Only read the gpu busy if the hardware is already active */
-+ if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
-+ return 0;
-+
- busy_cycles = gmu_read64(&a6xx_gpu->gmu,
- REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
- REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
-@@ -819,6 +824,8 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)
-
- gpu->devfreq.busy_cycles = busy_cycles;
-
-+ pm_runtime_put(a6xx_gpu->gmu.dev);
-+
- if (WARN_ON(busy_time > ~0LU))
- return ~0LU;
-
-diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
-index 47b989834af1..c23a2fa13fb9 100644
---- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
-+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
-@@ -943,7 +943,8 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
-
- return 0;
- fail:
-- mdp5_destroy(pdev);
-+ if (mdp5_kms)
-+ mdp5_destroy(pdev);
- return ret;
- }
-
-diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c
-index 732f65df5c4f..fea30e7aa9e8 100644
---- a/drivers/gpu/drm/msm/msm_rd.c
-+++ b/drivers/gpu/drm/msm/msm_rd.c
-@@ -29,8 +29,6 @@
- * or shader programs (if not emitted inline in cmdstream).
- */
-
--#ifdef CONFIG_DEBUG_FS
--
- #include <linux/circ_buf.h>
- #include <linux/debugfs.h>
- #include <linux/kfifo.h>
-@@ -47,6 +45,8 @@ bool rd_full = false;
- MODULE_PARM_DESC(rd_full, "If true, $debugfs/.../rd will snapshot all buffer contents");
- module_param_named(rd_full, rd_full, bool, 0600);
-
-+#ifdef CONFIG_DEBUG_FS
-+
- enum rd_sect_type {
- RD_NONE,
- RD_TEST, /* ascii text */
-diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
-index 6be9df1820c5..2625ed84fc44 100644
---- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
-+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
-@@ -482,15 +482,16 @@ nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe)
- * audio component binding for ELD notification
- */
- static void
--nv50_audio_component_eld_notify(struct drm_audio_component *acomp, int port)
-+nv50_audio_component_eld_notify(struct drm_audio_component *acomp, int port,
-+ int dev_id)
- {
- if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
- acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
-- port, -1);
-+ port, dev_id);
- }
-
- static int
--nv50_audio_component_get_eld(struct device *kdev, int port, int pipe,
-+nv50_audio_component_get_eld(struct device *kdev, int port, int dev_id,
- bool *enabled, unsigned char *buf, int max_bytes)
- {
- struct drm_device *drm_dev = dev_get_drvdata(kdev);
-@@ -506,7 +507,8 @@ nv50_audio_component_get_eld(struct device *kdev, int port, int pipe,
- nv_encoder = nouveau_encoder(encoder);
- nv_connector = nouveau_encoder_connector_get(nv_encoder);
- nv_crtc = nouveau_crtc(encoder->crtc);
-- if (!nv_connector || !nv_crtc || nv_crtc->index != port)
-+ if (!nv_connector || !nv_crtc || nv_encoder->or != port ||
-+ nv_crtc->index != dev_id)
- continue;
- *enabled = drm_detect_monitor_audio(nv_connector->edid);
- if (*enabled) {
-@@ -600,7 +602,8 @@ nv50_audio_disable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc)
-
- nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
-
-- nv50_audio_component_eld_notify(drm->audio.component, nv_crtc->index);
-+ nv50_audio_component_eld_notify(drm->audio.component, nv_encoder->or,
-+ nv_crtc->index);
- }
-
- static void
-@@ -634,7 +637,8 @@ nv50_audio_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
- nvif_mthd(&disp->disp->object, 0, &args,
- sizeof(args.base) + drm_eld_size(args.data));
-
-- nv50_audio_component_eld_notify(drm->audio.component, nv_crtc->index);
-+ nv50_audio_component_eld_notify(drm->audio.component, nv_encoder->or,
-+ nv_crtc->index);
- }
-
- /******************************************************************************
-diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigm200.c
-index 9b16a08eb4d9..bf6d41fb0c9f 100644
---- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigm200.c
-+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigm200.c
-@@ -27,10 +27,10 @@ void
- gm200_hdmi_scdc(struct nvkm_ior *ior, int head, u8 scdc)
- {
- struct nvkm_device *device = ior->disp->engine.subdev.device;
-- const u32 hoff = head * 0x800;
-+ const u32 soff = nv50_ior_base(ior);
- const u32 ctrl = scdc & 0x3;
-
-- nvkm_mask(device, 0x61c5bc + hoff, 0x00000003, ctrl);
-+ nvkm_mask(device, 0x61c5bc + soff, 0x00000003, ctrl);
-
- ior->tmds.high_speed = !!(scdc & 0x2);
- }
-diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
-index 4209b24a46d7..bf6b65257852 100644
---- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
-+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
-@@ -341,7 +341,7 @@ gk20a_gr_load(struct gf100_gr *gr, int ver, const struct gf100_gr_fwif *fwif)
-
- static const struct gf100_gr_fwif
- gk20a_gr_fwif[] = {
-- { -1, gk20a_gr_load, &gk20a_gr },
-+ { 0, gk20a_gr_load, &gk20a_gr },
- {}
- };
-
-diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
-index 70b20ee4741a..41ef6a9ca8cc 100644
---- a/drivers/gpu/drm/qxl/qxl_kms.c
-+++ b/drivers/gpu/drm/qxl/qxl_kms.c
-@@ -218,7 +218,7 @@ 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/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
-index 7ad3f06c127e..00ca35f07ba5 100644
---- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h
-+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
-@@ -148,7 +148,7 @@
- #define SUN4I_HDMI_DDC_CMD_IMPLICIT_WRITE 3
-
- #define SUN4I_HDMI_DDC_CLK_REG 0x528
--#define SUN4I_HDMI_DDC_CLK_M(m) (((m) & 0x7) << 3)
-+#define SUN4I_HDMI_DDC_CLK_M(m) (((m) & 0xf) << 3)
- #define SUN4I_HDMI_DDC_CLK_N(n) ((n) & 0x7)
-
- #define SUN4I_HDMI_DDC_LINE_CTRL_REG 0x540
-diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c
-index 2ff780114106..12430b9d4e93 100644
---- a/drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c
-+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c
-@@ -33,7 +33,7 @@ static unsigned long sun4i_ddc_calc_divider(unsigned long rate,
- unsigned long best_rate = 0;
- u8 best_m = 0, best_n = 0, _m, _n;
-
-- for (_m = 0; _m < 8; _m++) {
-+ for (_m = 0; _m < 16; _m++) {
- for (_n = 0; _n < 8; _n++) {
- unsigned long tmp_rate;
-
-diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
-index 1c71a1aa76b2..f03f1cc913ce 100644
---- a/drivers/hid/hid-ids.h
-+++ b/drivers/hid/hid-ids.h
-@@ -1157,6 +1157,9 @@
- #define USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN_8882 0x8882
- #define USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN_8883 0x8883
-
-+#define USB_VENDOR_ID_TRUST 0x145f
-+#define USB_DEVICE_ID_TRUST_PANORA_TABLET 0x0212
-+
- #define USB_VENDOR_ID_TURBOX 0x062a
- #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
- #define USB_DEVICE_ID_ASUS_MD_5110 0x5110
-diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
-index e4cb543de0cd..ca8b5c261c7c 100644
---- a/drivers/hid/hid-quirks.c
-+++ b/drivers/hid/hid-quirks.c
-@@ -168,6 +168,7 @@ static const struct hid_device_id hid_quirks[] = {
- { HID_USB_DEVICE(USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS), HID_QUIRK_MULTI_INPUT },
- { HID_USB_DEVICE(USB_VENDOR_ID_TPV, USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN_8882), HID_QUIRK_NOGET },
- { HID_USB_DEVICE(USB_VENDOR_ID_TPV, USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN_8883), HID_QUIRK_NOGET },
-+ { HID_USB_DEVICE(USB_VENDOR_ID_TRUST, USB_DEVICE_ID_TRUST_PANORA_TABLET), HID_QUIRK_MULTI_INPUT | HID_QUIRK_HIDINPUT_FORCE },
- { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD), HID_QUIRK_NOGET },
- { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_KNA5), HID_QUIRK_MULTI_INPUT },
- { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWA60), HID_QUIRK_MULTI_INPUT },
-diff --git a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
-index aa2dbed30fc3..6cf59fd26ad7 100644
---- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
-+++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
-@@ -480,6 +480,7 @@ static int ish_query_loader_prop(struct ishtp_cl_data *client_data,
- sizeof(ldr_xfer_query_resp));
- if (rv < 0) {
- client_data->flag_retry = true;
-+ *fw_info = (struct shim_fw_info){};
- return rv;
- }
-
-@@ -489,6 +490,7 @@ static int ish_query_loader_prop(struct ishtp_cl_data *client_data,
- "data size %d is not equal to size of loader_xfer_query_response %zu\n",
- rv, sizeof(struct loader_xfer_query_response));
- client_data->flag_retry = true;
-+ *fw_info = (struct shim_fw_info){};
- return -EMSGSIZE;
- }
-
-diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
-index a90d757f7043..a6d6c7a3abcb 100644
---- a/drivers/hwtracing/coresight/coresight-etm4x.c
-+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
-@@ -1527,6 +1527,7 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
- return 0;
-
- err_arch_supported:
-+ etmdrvdata[drvdata->cpu] = NULL;
- if (--etm4_count == 0) {
- etm4_cpu_pm_unregister();
-
-diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
-index 43418a2126ff..471f34e40c74 100644
---- a/drivers/hwtracing/coresight/coresight-platform.c
-+++ b/drivers/hwtracing/coresight/coresight-platform.c
-@@ -87,6 +87,7 @@ static void of_coresight_get_ports_legacy(const struct device_node *node,
- int *nr_inport, int *nr_outport)
- {
- struct device_node *ep = NULL;
-+ struct of_endpoint endpoint;
- int in = 0, out = 0;
-
- do {
-@@ -94,10 +95,16 @@ static void of_coresight_get_ports_legacy(const struct device_node *node,
- if (!ep)
- break;
-
-- if (of_coresight_legacy_ep_is_input(ep))
-- in++;
-- else
-- out++;
-+ if (of_graph_parse_endpoint(ep, &endpoint))
-+ continue;
-+
-+ if (of_coresight_legacy_ep_is_input(ep)) {
-+ in = (endpoint.port + 1 > in) ?
-+ endpoint.port + 1 : in;
-+ } else {
-+ out = (endpoint.port + 1) > out ?
-+ endpoint.port + 1 : out;
-+ }
-
- } while (ep);
-
-@@ -137,9 +144,16 @@ of_coresight_count_ports(struct device_node *port_parent)
- {
- int i = 0;
- struct device_node *ep = NULL;
-+ struct of_endpoint endpoint;
-+
-+ while ((ep = of_graph_get_next_endpoint(port_parent, ep))) {
-+ /* Defer error handling to parsing */
-+ if (of_graph_parse_endpoint(ep, &endpoint))
-+ continue;
-+ if (endpoint.port + 1 > i)
-+ i = endpoint.port + 1;
-+ }
-
-- while ((ep = of_graph_get_next_endpoint(port_parent, ep)))
-- i++;
- return i;
- }
-
-@@ -191,14 +205,12 @@ static int of_coresight_get_cpu(struct device *dev)
- * Parses the local port, remote device name and the remote port.
- *
- * Returns :
-- * 1 - If the parsing is successful and a connection record
-- * was created for an output connection.
- * 0 - If the parsing completed without any fatal errors.
- * -Errno - Fatal error, abort the scanning.
- */
- static int of_coresight_parse_endpoint(struct device *dev,
- struct device_node *ep,
-- struct coresight_connection *conn)
-+ struct coresight_platform_data *pdata)
- {
- int ret = 0;
- struct of_endpoint endpoint, rendpoint;
-@@ -206,6 +218,7 @@ static int of_coresight_parse_endpoint(struct device *dev,
- struct device_node *rep = NULL;
- struct device *rdev = NULL;
- struct fwnode_handle *rdev_fwnode;
-+ struct coresight_connection *conn;
-
- do {
- /* Parse the local port details */
-@@ -232,6 +245,13 @@ static int of_coresight_parse_endpoint(struct device *dev,
- break;
- }
-
-+ conn = &pdata->conns[endpoint.port];
-+ if (conn->child_fwnode) {
-+ dev_warn(dev, "Duplicate output port %d\n",
-+ endpoint.port);
-+ ret = -EINVAL;
-+ break;
-+ }
- conn->outport = endpoint.port;
- /*
- * Hold the refcount to the target device. This could be
-@@ -244,7 +264,6 @@ static int of_coresight_parse_endpoint(struct device *dev,
- conn->child_fwnode = fwnode_handle_get(rdev_fwnode);
- conn->child_port = rendpoint.port;
- /* Connection record updated */
-- ret = 1;
- } while (0);
-
- of_node_put(rparent);
-@@ -258,7 +277,6 @@ static int of_get_coresight_platform_data(struct device *dev,
- struct coresight_platform_data *pdata)
- {
- int ret = 0;
-- struct coresight_connection *conn;
- struct device_node *ep = NULL;
- const struct device_node *parent = NULL;
- bool legacy_binding = false;
-@@ -287,8 +305,6 @@ static int of_get_coresight_platform_data(struct device *dev,
- dev_warn_once(dev, "Uses obsolete Coresight DT bindings\n");
- }
-
-- conn = pdata->conns;
--
- /* Iterate through each output port to discover topology */
- while ((ep = of_graph_get_next_endpoint(parent, ep))) {
- /*
-@@ -300,15 +316,9 @@ static int of_get_coresight_platform_data(struct device *dev,
- if (legacy_binding && of_coresight_legacy_ep_is_input(ep))
- continue;
-
-- ret = of_coresight_parse_endpoint(dev, ep, conn);
-- switch (ret) {
-- case 1:
-- conn++; /* Fall through */
-- case 0:
-- break;
-- default:
-+ ret = of_coresight_parse_endpoint(dev, ep, pdata);
-+ if (ret)
- return ret;
-- }
- }
-
- return 0;
-@@ -647,6 +657,16 @@ static int acpi_coresight_parse_link(struct acpi_device *adev,
- * coresight_remove_match().
- */
- conn->child_fwnode = fwnode_handle_get(&r_adev->fwnode);
-+ } else if (dir == ACPI_CORESIGHT_LINK_SLAVE) {
-+ /*
-+ * We are only interested in the port number
-+ * for the input ports at this component.
-+ * Store the port number in child_port.
-+ */
-+ conn->child_port = fields[0].integer.value;
-+ } else {
-+ /* Invalid direction */
-+ return -EINVAL;
- }
-
- return dir;
-@@ -692,10 +712,20 @@ static int acpi_coresight_parse_graph(struct acpi_device *adev,
- return dir;
-
- if (dir == ACPI_CORESIGHT_LINK_MASTER) {
-- pdata->nr_outport++;
-+ if (ptr->outport > pdata->nr_outport)
-+ pdata->nr_outport = ptr->outport;
- ptr++;
- } else {
-- pdata->nr_inport++;
-+ WARN_ON(pdata->nr_inport == ptr->child_port);
-+ /*
-+ * We do not track input port connections for a device.
-+ * However we need the highest port number described,
-+ * which can be recorded now and reuse this connection
-+ * record for an output connection. Hence, do not move
-+ * the ptr for input connections
-+ */
-+ if (ptr->child_port > pdata->nr_inport)
-+ pdata->nr_inport = ptr->child_port;
- }
- }
-
-@@ -704,8 +734,13 @@ static int acpi_coresight_parse_graph(struct acpi_device *adev,
- return rc;
-
- /* Copy the connection information to the final location */
-- for (i = 0; i < pdata->nr_outport; i++)
-- pdata->conns[i] = conns[i];
-+ for (i = 0; conns + i < ptr; i++) {
-+ int port = conns[i].outport;
-+
-+ /* Duplicate output port */
-+ WARN_ON(pdata->conns[port].child_fwnode);
-+ pdata->conns[port] = conns[i];
-+ }
-
- devm_kfree(&adev->dev, conns);
- return 0;
-diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
-index d0cc3985b72a..36cce2bfb744 100644
---- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
-+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
-@@ -596,13 +596,6 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata)
- goto out;
- }
-
-- /* There is no point in reading a TMC in HW FIFO mode */
-- mode = readl_relaxed(drvdata->base + TMC_MODE);
-- if (mode != TMC_MODE_CIRCULAR_BUFFER) {
-- ret = -EINVAL;
-- goto out;
-- }
--
- /* Don't interfere if operated from Perf */
- if (drvdata->mode == CS_MODE_PERF) {
- ret = -EINVAL;
-@@ -616,8 +609,15 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata)
- }
-
- /* Disable the TMC if need be */
-- if (drvdata->mode == CS_MODE_SYSFS)
-+ if (drvdata->mode == CS_MODE_SYSFS) {
-+ /* There is no point in reading a TMC in HW FIFO mode */
-+ mode = readl_relaxed(drvdata->base + TMC_MODE);
-+ if (mode != TMC_MODE_CIRCULAR_BUFFER) {
-+ ret = -EINVAL;
-+ goto out;
-+ }
- __tmc_etb_disable_hw(drvdata);
-+ }
-
- drvdata->reading = true;
- out:
-diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
-index c71553c09f8e..8f5e62f02444 100644
---- a/drivers/hwtracing/coresight/coresight.c
-+++ b/drivers/hwtracing/coresight/coresight.c
-@@ -1053,6 +1053,9 @@ static int coresight_orphan_match(struct device *dev, void *data)
- for (i = 0; i < i_csdev->pdata->nr_outport; i++) {
- conn = &i_csdev->pdata->conns[i];
-
-+ /* Skip the port if FW doesn't describe it */
-+ if (!conn->child_fwnode)
-+ continue;
- /* We have found at least one orphan connection */
- if (conn->child_dev == NULL) {
- /* Does it match this newly added device? */
-@@ -1091,6 +1094,8 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev)
- for (i = 0; i < csdev->pdata->nr_outport; i++) {
- struct coresight_connection *conn = &csdev->pdata->conns[i];
-
-+ if (!conn->child_fwnode)
-+ continue;
- conn->child_dev =
- coresight_find_csdev_by_fwnode(conn->child_fwnode);
- if (!conn->child_dev)
-@@ -1118,7 +1123,7 @@ static int coresight_remove_match(struct device *dev, void *data)
- for (i = 0; i < iterator->pdata->nr_outport; i++) {
- conn = &iterator->pdata->conns[i];
-
-- if (conn->child_dev == NULL)
-+ if (conn->child_dev == NULL || conn->child_fwnode == NULL)
- continue;
-
- if (csdev->dev.fwnode == conn->child_fwnode) {
-diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c
-index 271470f4d8a9..66c9923fc766 100644
---- a/drivers/i2c/busses/i2c-icy.c
-+++ b/drivers/i2c/busses/i2c-icy.c
-@@ -43,6 +43,7 @@
- #include <linux/i2c.h>
- #include <linux/i2c-algo-pcf.h>
-
-+#include <asm/amigahw.h>
- #include <asm/amigaints.h>
- #include <linux/zorro.h>
-
-diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
-index 30ded6422e7b..69740a4ff1db 100644
---- a/drivers/i2c/busses/i2c-piix4.c
-+++ b/drivers/i2c/busses/i2c-piix4.c
-@@ -977,7 +977,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 466e4f681d7a..f537a37ac1d5 100644
---- a/drivers/i2c/busses/i2c-pxa.c
-+++ b/drivers/i2c/busses/i2c-pxa.c
-@@ -311,11 +311,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 */
-@@ -747,11 +746,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/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
-index b129693af0fd..94da3b1ca3a2 100644
---- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
-+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
-@@ -134,7 +134,7 @@ static ssize_t iio_dmaengine_buffer_get_length_align(struct device *dev,
- struct dmaengine_buffer *dmaengine_buffer =
- iio_buffer_to_dmaengine_buffer(indio_dev->buffer);
-
-- return sprintf(buf, "%u\n", dmaengine_buffer->align);
-+ return sprintf(buf, "%zu\n", dmaengine_buffer->align);
- }
-
- static IIO_DEVICE_ATTR(length_align_bytes, 0444,
-diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
-index b7ef16b28280..7a2679bdc987 100644
---- a/drivers/iio/light/gp2ap002.c
-+++ b/drivers/iio/light/gp2ap002.c
-@@ -158,6 +158,9 @@ static irqreturn_t gp2ap002_prox_irq(int irq, void *d)
- int val;
- int ret;
-
-+ if (!gp2ap002->enabled)
-+ goto err_retrig;
-+
- ret = regmap_read(gp2ap002->map, GP2AP002_PROX, &val);
- if (ret) {
- dev_err(gp2ap002->dev, "error reading proximity\n");
-@@ -247,6 +250,8 @@ static int gp2ap002_read_raw(struct iio_dev *indio_dev,
- struct gp2ap002 *gp2ap002 = iio_priv(indio_dev);
- int ret;
-
-+ pm_runtime_get_sync(gp2ap002->dev);
-+
- switch (mask) {
- case IIO_CHAN_INFO_RAW:
- switch (chan->type) {
-@@ -255,13 +260,21 @@ static int gp2ap002_read_raw(struct iio_dev *indio_dev,
- if (ret < 0)
- return ret;
- *val = ret;
-- return IIO_VAL_INT;
-+ ret = IIO_VAL_INT;
-+ goto out;
- default:
-- return -EINVAL;
-+ ret = -EINVAL;
-+ goto out;
- }
- default:
-- return -EINVAL;
-+ ret = -EINVAL;
- }
-+
-+out:
-+ pm_runtime_mark_last_busy(gp2ap002->dev);
-+ pm_runtime_put_autosuspend(gp2ap002->dev);
-+
-+ return ret;
- }
-
- static int gp2ap002_init(struct gp2ap002 *gp2ap002)
-diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
-index 29c209cc1108..973264a088f9 100644
---- a/drivers/iio/pressure/bmp280-core.c
-+++ b/drivers/iio/pressure/bmp280-core.c
-@@ -271,6 +271,8 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data,
- + (s32)2097152) * calib->H2 + 8192) >> 14);
- var -= ((((var >> 15) * (var >> 15)) >> 7) * (s32)calib->H1) >> 4;
-
-+ var = clamp_val(var, 0, 419430400);
-+
- return var >> 12;
- };
-
-@@ -713,7 +715,7 @@ static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas)
- unsigned int ctrl;
-
- if (data->use_eoc)
-- init_completion(&data->done);
-+ reinit_completion(&data->done);
-
- ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas);
- if (ret)
-@@ -969,6 +971,9 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
- "trying to enforce it\n");
- irq_trig = IRQF_TRIGGER_RISING;
- }
-+
-+ init_completion(&data->done);
-+
- ret = devm_request_threaded_irq(dev,
- irq,
- bmp085_eoc_irq,
-diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
-index 17f14e0eafe4..1c2bf18cda9f 100644
---- a/drivers/infiniband/core/cm.c
-+++ b/drivers/infiniband/core/cm.c
-@@ -1076,7 +1076,9 @@ retest:
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
-- /* Fall through */
-+ cm_send_rej_locked(cm_id_priv, IB_CM_REJ_CONSUMER_DEFINED, NULL,
-+ 0, NULL, 0);
-+ goto retest;
- case IB_CM_MRA_REQ_SENT:
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
-diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
-index c672a4978bfd..3c1e2ca564fe 100644
---- a/drivers/infiniband/core/cma_configfs.c
-+++ b/drivers/infiniband/core/cma_configfs.c
-@@ -322,8 +322,21 @@ fail:
- return ERR_PTR(err);
- }
-
-+static void drop_cma_dev(struct config_group *cgroup, struct config_item *item)
-+{
-+ struct config_group *group =
-+ container_of(item, struct config_group, cg_item);
-+ struct cma_dev_group *cma_dev_group =
-+ container_of(group, struct cma_dev_group, device_group);
-+
-+ configfs_remove_default_groups(&cma_dev_group->ports_group);
-+ configfs_remove_default_groups(&cma_dev_group->device_group);
-+ config_item_put(item);
-+}
-+
- static struct configfs_group_operations cma_subsys_group_ops = {
- .make_group = make_cma_dev,
-+ .drop_item = drop_cma_dev,
- };
-
- static const struct config_item_type cma_subsys_type = {
-diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
-index 087682e6969e..defe9cd4c5ee 100644
---- a/drivers/infiniband/core/sysfs.c
-+++ b/drivers/infiniband/core/sysfs.c
-@@ -1058,8 +1058,7 @@ static int add_port(struct ib_core_device *coredev, int port_num)
- coredev->ports_kobj,
- "%d", port_num);
- if (ret) {
-- kfree(p);
-- return ret;
-+ goto err_put;
- }
-
- p->gid_attr_group = kzalloc(sizeof(*p->gid_attr_group), GFP_KERNEL);
-@@ -1072,8 +1071,7 @@ static int add_port(struct ib_core_device *coredev, int port_num)
- ret = kobject_init_and_add(&p->gid_attr_group->kobj, &gid_attr_type,
- &p->kobj, "gid_attrs");
- if (ret) {
-- kfree(p->gid_attr_group);
-- goto err_put;
-+ goto err_put_gid_attrs;
- }
-
- if (device->ops.process_mad && is_full_dev) {
-@@ -1404,8 +1402,10 @@ int ib_port_register_module_stat(struct ib_device *device, u8 port_num,
-
- ret = kobject_init_and_add(kobj, ktype, &port->kobj, "%s",
- name);
-- if (ret)
-+ if (ret) {
-+ kobject_put(kobj);
- return ret;
-+ }
- }
-
- return 0;
-diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
-index 060b4ebbd2ba..d6e9cc94dd90 100644
---- a/drivers/infiniband/core/uverbs_cmd.c
-+++ b/drivers/infiniband/core/uverbs_cmd.c
-@@ -2959,6 +2959,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
- wq_init_attr.event_handler = ib_uverbs_wq_event_handler;
- wq_init_attr.create_flags = cmd.create_flags;
- INIT_LIST_HEAD(&obj->uevent.event_list);
-+ obj->uevent.uobject.user_handle = cmd.user_handle;
-
- wq = pd->device->ops.create_wq(pd, &wq_init_attr, &attrs->driver_udata);
- if (IS_ERR(wq)) {
-@@ -2976,8 +2977,6 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
- atomic_set(&wq->usecnt, 0);
- atomic_inc(&pd->usecnt);
- atomic_inc(&cq->usecnt);
-- wq->uobject = obj;
-- obj->uevent.uobject.object = wq;
-
- memset(&resp, 0, sizeof(resp));
- resp.wq_handle = obj->uevent.uobject.id;
-diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
-index 599340c1f0b8..541dbcf22d0e 100644
---- a/drivers/infiniband/hw/cxgb4/device.c
-+++ b/drivers/infiniband/hw/cxgb4/device.c
-@@ -953,6 +953,7 @@ void c4iw_dealloc(struct uld_ctx *ctx)
- static void c4iw_remove(struct uld_ctx *ctx)
- {
- pr_debug("c4iw_dev %p\n", ctx->dev);
-+ debugfs_remove_recursive(ctx->dev->debugfs_root);
- c4iw_unregister_device(ctx->dev);
- c4iw_dealloc(ctx);
- }
-diff --git a/drivers/infiniband/hw/efa/efa_com_cmd.c b/drivers/infiniband/hw/efa/efa_com_cmd.c
-index eea5574a62e8..69f842c92ff6 100644
---- a/drivers/infiniband/hw/efa/efa_com_cmd.c
-+++ b/drivers/infiniband/hw/efa/efa_com_cmd.c
-@@ -388,7 +388,7 @@ static int efa_com_get_feature_ex(struct efa_com_dev *edev,
-
- if (control_buff_size)
- EFA_SET(&get_cmd.aq_common_descriptor.flags,
-- EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT, 1);
-+ EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA, 1);
-
- efa_com_set_dma_addr(control_buf_dma_addr,
- &get_cmd.control_buffer.address.mem_addr_high,
-@@ -540,7 +540,7 @@ static int efa_com_set_feature_ex(struct efa_com_dev *edev,
- if (control_buff_size) {
- set_cmd->aq_common_descriptor.flags = 0;
- EFA_SET(&set_cmd->aq_common_descriptor.flags,
-- EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT, 1);
-+ EFA_ADMIN_AQ_COMMON_DESC_CTRL_DATA, 1);
- efa_com_set_dma_addr(control_buf_dma_addr,
- &set_cmd->control_buffer.address.mem_addr_high,
- &set_cmd->control_buffer.address.mem_addr_low);
-diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
-index c3316672b70e..f9fa80ae5560 100644
---- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
-+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
-@@ -1349,34 +1349,26 @@ static int hns_roce_query_pf_resource(struct hns_roce_dev *hr_dev)
- static int hns_roce_query_pf_timer_resource(struct hns_roce_dev *hr_dev)
- {
- struct hns_roce_pf_timer_res_a *req_a;
-- struct hns_roce_cmq_desc desc[2];
-- int ret, i;
-+ struct hns_roce_cmq_desc desc;
-+ int ret;
-
-- for (i = 0; i < 2; i++) {
-- hns_roce_cmq_setup_basic_desc(&desc[i],
-- HNS_ROCE_OPC_QUERY_PF_TIMER_RES,
-- true);
-+ hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_QUERY_PF_TIMER_RES,
-+ true);
-
-- if (i == 0)
-- desc[i].flag |= cpu_to_le16(HNS_ROCE_CMD_FLAG_NEXT);
-- else
-- desc[i].flag &= ~cpu_to_le16(HNS_ROCE_CMD_FLAG_NEXT);
-- }
--
-- ret = hns_roce_cmq_send(hr_dev, desc, 2);
-+ ret = hns_roce_cmq_send(hr_dev, &desc, 1);
- if (ret)
- return ret;
-
-- req_a = (struct hns_roce_pf_timer_res_a *)desc[0].data;
-+ req_a = (struct hns_roce_pf_timer_res_a *)desc.data;
-
- hr_dev->caps.qpc_timer_bt_num =
-- roce_get_field(req_a->qpc_timer_bt_idx_num,
-- PF_RES_DATA_1_PF_QPC_TIMER_BT_NUM_M,
-- PF_RES_DATA_1_PF_QPC_TIMER_BT_NUM_S);
-+ roce_get_field(req_a->qpc_timer_bt_idx_num,
-+ PF_RES_DATA_1_PF_QPC_TIMER_BT_NUM_M,
-+ PF_RES_DATA_1_PF_QPC_TIMER_BT_NUM_S);
- hr_dev->caps.cqc_timer_bt_num =
-- roce_get_field(req_a->cqc_timer_bt_idx_num,
-- PF_RES_DATA_2_PF_CQC_TIMER_BT_NUM_M,
-- PF_RES_DATA_2_PF_CQC_TIMER_BT_NUM_S);
-+ roce_get_field(req_a->cqc_timer_bt_idx_num,
-+ PF_RES_DATA_2_PF_CQC_TIMER_BT_NUM_M,
-+ PF_RES_DATA_2_PF_CQC_TIMER_BT_NUM_S);
-
- return 0;
- }
-@@ -4639,7 +4631,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
- qp_attr->path_mig_state = IB_MIG_ARMED;
- qp_attr->ah_attr.type = RDMA_AH_ATTR_TYPE_ROCE;
- if (hr_qp->ibqp.qp_type == IB_QPT_UD)
-- qp_attr->qkey = V2_QKEY_VAL;
-+ qp_attr->qkey = le32_to_cpu(context.qkey_xrcd);
-
- qp_attr->rq_psn = roce_get_field(context.byte_108_rx_reqepsn,
- V2_QPC_BYTE_108_RX_REQ_EPSN_M,
-diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
-index 46e1ab771f10..ed10e2f32aab 100644
---- a/drivers/infiniband/hw/mlx5/devx.c
-+++ b/drivers/infiniband/hw/mlx5/devx.c
-@@ -494,6 +494,10 @@ static u64 devx_get_obj_id(const void *in)
- obj_id = get_enc_obj_id(MLX5_CMD_OP_CREATE_QP,
- MLX5_GET(rst2init_qp_in, in, qpn));
- break;
-+ case MLX5_CMD_OP_INIT2INIT_QP:
-+ obj_id = get_enc_obj_id(MLX5_CMD_OP_CREATE_QP,
-+ MLX5_GET(init2init_qp_in, in, qpn));
-+ break;
- case MLX5_CMD_OP_INIT2RTR_QP:
- obj_id = get_enc_obj_id(MLX5_CMD_OP_CREATE_QP,
- MLX5_GET(init2rtr_qp_in, in, qpn));
-@@ -819,6 +823,7 @@ static bool devx_is_obj_modify_cmd(const void *in)
- case MLX5_CMD_OP_SET_L2_TABLE_ENTRY:
- case MLX5_CMD_OP_RST2INIT_QP:
- case MLX5_CMD_OP_INIT2RTR_QP:
-+ case MLX5_CMD_OP_INIT2INIT_QP:
- case MLX5_CMD_OP_RTR2RTS_QP:
- case MLX5_CMD_OP_RTS2RTS_QP:
- case MLX5_CMD_OP_SQERR2RTS_QP:
-diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c
-index b1a8a9175040..6d1ff13d2283 100644
---- a/drivers/infiniband/hw/mlx5/srq.c
-+++ b/drivers/infiniband/hw/mlx5/srq.c
-@@ -310,12 +310,18 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq,
- srq->msrq.event = mlx5_ib_srq_event;
- srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn;
-
-- if (udata)
-- if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) {
-+ if (udata) {
-+ struct mlx5_ib_create_srq_resp resp = {
-+ .srqn = srq->msrq.srqn,
-+ };
-+
-+ if (ib_copy_to_udata(udata, &resp, min(udata->outlen,
-+ sizeof(resp)))) {
- mlx5_ib_dbg(dev, "copy to user failed\n");
- err = -EFAULT;
- goto err_core;
- }
-+ }
-
- init_attr->attr.max_wr = srq->msrq.max - 1;
-
-diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
-index 98552749d71c..fcf982c60db6 100644
---- a/drivers/infiniband/ulp/srpt/ib_srpt.c
-+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
-@@ -610,6 +610,11 @@ static int srpt_refresh_port(struct srpt_port *sport)
- dev_name(&sport->sdev->device->dev), sport->port,
- PTR_ERR(sport->mad_agent));
- sport->mad_agent = NULL;
-+ memset(&port_modify, 0, sizeof(port_modify));
-+ port_modify.clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP;
-+ ib_modify_port(sport->sdev->device, sport->port, 0,
-+ &port_modify);
-+
- }
- }
-
-@@ -633,9 +638,8 @@ static void srpt_unregister_mad_agent(struct srpt_device *sdev)
- for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
- sport = &sdev->port[i - 1];
- WARN_ON(sport->port != i);
-- if (ib_modify_port(sdev->device, i, 0, &port_modify) < 0)
-- pr_err("disabling MAD processing failed.\n");
- if (sport->mad_agent) {
-+ ib_modify_port(sdev->device, i, 0, &port_modify);
- ib_unregister_mad_agent(sport->mad_agent);
- sport->mad_agent = NULL;
- }
-diff --git a/drivers/input/serio/i8042-ppcio.h b/drivers/input/serio/i8042-ppcio.h
-deleted file mode 100644
-index 391f94d9e47d..000000000000
---- a/drivers/input/serio/i8042-ppcio.h
-+++ /dev/null
-@@ -1,57 +0,0 @@
--/* SPDX-License-Identifier: GPL-2.0-only */
--#ifndef _I8042_PPCIO_H
--#define _I8042_PPCIO_H
--
--
--#if defined(CONFIG_WALNUT)
--
--#define I8042_KBD_IRQ 25
--#define I8042_AUX_IRQ 26
--
--#define I8042_KBD_PHYS_DESC "walnutps2/serio0"
--#define I8042_AUX_PHYS_DESC "walnutps2/serio1"
--#define I8042_MUX_PHYS_DESC "walnutps2/serio%d"
--
--extern void *kb_cs;
--extern void *kb_data;
--
--#define I8042_COMMAND_REG (*(int *)kb_cs)
--#define I8042_DATA_REG (*(int *)kb_data)
--
--static inline int i8042_read_data(void)
--{
-- return readb(kb_data);
--}
--
--static inline int i8042_read_status(void)
--{
-- return readb(kb_cs);
--}
--
--static inline void i8042_write_data(int val)
--{
-- writeb(val, kb_data);
--}
--
--static inline void i8042_write_command(int val)
--{
-- writeb(val, kb_cs);
--}
--
--static inline int i8042_platform_init(void)
--{
-- i8042_reset = I8042_RESET_ALWAYS;
-- return 0;
--}
--
--static inline void i8042_platform_exit(void)
--{
--}
--
--#else
--
--#include "i8042-io.h"
--
--#endif
--
--#endif /* _I8042_PPCIO_H */
-diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
-index 38dc27ad3c18..eb376700dfff 100644
---- a/drivers/input/serio/i8042.h
-+++ b/drivers/input/serio/i8042.h
-@@ -17,8 +17,6 @@
- #include "i8042-ip22io.h"
- #elif defined(CONFIG_SNI_RM)
- #include "i8042-snirm.h"
--#elif defined(CONFIG_PPC)
--#include "i8042-ppcio.h"
- #elif defined(CONFIG_SPARC)
- #include "i8042-sparcio.h"
- #elif defined(CONFIG_X86) || defined(CONFIG_IA64)
-diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
-index d2587724c52a..9b8450794a8a 100644
---- a/drivers/input/touchscreen/edt-ft5x06.c
-+++ b/drivers/input/touchscreen/edt-ft5x06.c
-@@ -938,19 +938,25 @@ static void edt_ft5x06_ts_get_defaults(struct device *dev,
-
- error = device_property_read_u32(dev, "offset", &val);
- if (!error) {
-- edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, val);
-+ if (reg_addr->reg_offset != NO_REGISTER)
-+ edt_ft5x06_register_write(tsdata,
-+ reg_addr->reg_offset, val);
- tsdata->offset = val;
- }
-
- error = device_property_read_u32(dev, "offset-x", &val);
- if (!error) {
-- edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x, val);
-+ if (reg_addr->reg_offset_x != NO_REGISTER)
-+ edt_ft5x06_register_write(tsdata,
-+ reg_addr->reg_offset_x, val);
- tsdata->offset_x = val;
- }
-
- error = device_property_read_u32(dev, "offset-y", &val);
- if (!error) {
-- edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y, val);
-+ if (reg_addr->reg_offset_y != NO_REGISTER)
-+ edt_ft5x06_register_write(tsdata,
-+ reg_addr->reg_offset_y, val);
- tsdata->offset_y = val;
- }
- }
-diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
-index 82508730feb7..af21d24a09e8 100644
---- a/drivers/iommu/arm-smmu-v3.c
-+++ b/drivers/iommu/arm-smmu-v3.c
-@@ -171,6 +171,8 @@
- #define ARM_SMMU_PRIQ_IRQ_CFG1 0xd8
- #define ARM_SMMU_PRIQ_IRQ_CFG2 0xdc
-
-+#define ARM_SMMU_REG_SZ 0xe00
-+
- /* Common MSI config fields */
- #define MSI_CFG0_ADDR_MASK GENMASK_ULL(51, 2)
- #define MSI_CFG2_SH GENMASK(5, 4)
-@@ -628,6 +630,7 @@ struct arm_smmu_strtab_cfg {
- struct arm_smmu_device {
- struct device *dev;
- void __iomem *base;
-+ void __iomem *page1;
-
- #define ARM_SMMU_FEAT_2_LVL_STRTAB (1 << 0)
- #define ARM_SMMU_FEAT_2_LVL_CDTAB (1 << 1)
-@@ -733,9 +736,8 @@ static struct arm_smmu_option_prop arm_smmu_options[] = {
- static inline void __iomem *arm_smmu_page1_fixup(unsigned long offset,
- struct arm_smmu_device *smmu)
- {
-- if ((offset > SZ_64K) &&
-- (smmu->options & ARM_SMMU_OPT_PAGE0_REGS_ONLY))
-- offset -= SZ_64K;
-+ if (offset > SZ_64K)
-+ return smmu->page1 + offset - SZ_64K;
-
- return smmu->base + offset;
- }
-@@ -4021,6 +4023,18 @@ err_reset_pci_ops: __maybe_unused;
- return err;
- }
-
-+static void __iomem *arm_smmu_ioremap(struct device *dev, resource_size_t start,
-+ resource_size_t size)
-+{
-+ struct resource res = {
-+ .flags = IORESOURCE_MEM,
-+ .start = start,
-+ .end = start + size - 1,
-+ };
-+
-+ return devm_ioremap_resource(dev, &res);
-+}
-+
- static int arm_smmu_device_probe(struct platform_device *pdev)
- {
- int irq, ret;
-@@ -4056,10 +4070,23 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
- }
- ioaddr = res->start;
-
-- smmu->base = devm_ioremap_resource(dev, res);
-+ /*
-+ * Don't map the IMPLEMENTATION DEFINED regions, since they may contain
-+ * the PMCG registers which are reserved by the PMU driver.
-+ */
-+ smmu->base = arm_smmu_ioremap(dev, ioaddr, ARM_SMMU_REG_SZ);
- if (IS_ERR(smmu->base))
- return PTR_ERR(smmu->base);
-
-+ if (arm_smmu_resource_size(smmu) > SZ_64K) {
-+ smmu->page1 = arm_smmu_ioremap(dev, ioaddr + SZ_64K,
-+ ARM_SMMU_REG_SZ);
-+ if (IS_ERR(smmu->page1))
-+ return PTR_ERR(smmu->page1);
-+ } else {
-+ smmu->page1 = smmu->base;
-+ }
-+
- /* Interrupt lines */
-
- irq = platform_get_irq_byname_optional(pdev, "combined");
-diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
-index 11ed871dd255..fde7aba49b74 100644
---- a/drivers/iommu/intel-iommu.c
-+++ b/drivers/iommu/intel-iommu.c
-@@ -2518,9 +2518,6 @@ struct dmar_domain *find_domain(struct device *dev)
- if (unlikely(attach_deferred(dev) || iommu_dummy(dev)))
- return NULL;
-
-- if (dev_is_pci(dev))
-- dev = &pci_real_dma_dev(to_pci_dev(dev))->dev;
--
- /* No lock here, assumes no domain exit in normal case */
- info = dev->archdata.iommu;
- if (likely(info))
-diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
-index 7906624a731c..478308fb82cc 100644
---- a/drivers/mailbox/imx-mailbox.c
-+++ b/drivers/mailbox/imx-mailbox.c
-@@ -66,6 +66,8 @@ struct imx_mu_priv {
- struct clk *clk;
- int irq;
-
-+ u32 xcr;
-+
- bool side_b;
- };
-
-@@ -374,7 +376,7 @@ static struct mbox_chan *imx_mu_scu_xlate(struct mbox_controller *mbox,
- break;
- default:
- dev_err(mbox->dev, "Invalid chan type: %d\n", type);
-- return NULL;
-+ return ERR_PTR(-EINVAL);
- }
-
- if (chan >= mbox->num_chans) {
-@@ -558,12 +560,45 @@ static const struct of_device_id imx_mu_dt_ids[] = {
- };
- MODULE_DEVICE_TABLE(of, imx_mu_dt_ids);
-
-+static int imx_mu_suspend_noirq(struct device *dev)
-+{
-+ struct imx_mu_priv *priv = dev_get_drvdata(dev);
-+
-+ priv->xcr = imx_mu_read(priv, priv->dcfg->xCR);
-+
-+ return 0;
-+}
-+
-+static int imx_mu_resume_noirq(struct device *dev)
-+{
-+ struct imx_mu_priv *priv = dev_get_drvdata(dev);
-+
-+ /*
-+ * ONLY restore MU when context lost, the TIE could
-+ * be set during noirq resume as there is MU data
-+ * communication going on, and restore the saved
-+ * value will overwrite the TIE and cause MU data
-+ * send failed, may lead to system freeze. This issue
-+ * is observed by testing freeze mode suspend.
-+ */
-+ if (!imx_mu_read(priv, priv->dcfg->xCR))
-+ imx_mu_write(priv, priv->xcr, priv->dcfg->xCR);
-+
-+ return 0;
-+}
-+
-+static const struct dev_pm_ops imx_mu_pm_ops = {
-+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_mu_suspend_noirq,
-+ imx_mu_resume_noirq)
-+};
-+
- static struct platform_driver imx_mu_driver = {
- .probe = imx_mu_probe,
- .remove = imx_mu_remove,
- .driver = {
- .name = "imx_mu",
- .of_match_table = imx_mu_dt_ids,
-+ .pm = &imx_mu_pm_ops,
- },
- };
- module_platform_driver(imx_mu_driver);
-diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
-index 86887c9a349a..f9cc674ba9b7 100644
---- a/drivers/mailbox/zynqmp-ipi-mailbox.c
-+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
-@@ -504,10 +504,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox,
- mchan->req_buf_size = resource_size(&res);
- mchan->req_buf = devm_ioremap(mdev, res.start,
- mchan->req_buf_size);
-- if (IS_ERR(mchan->req_buf)) {
-+ if (!mchan->req_buf) {
- dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-- ret = PTR_ERR(mchan->req_buf);
-- return ret;
-+ return -ENOMEM;
- }
- } else if (ret != -ENODEV) {
- dev_err(mdev, "Unmatched resource %s, %d.\n", name, ret);
-@@ -520,10 +519,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox,
- mchan->resp_buf_size = resource_size(&res);
- mchan->resp_buf = devm_ioremap(mdev, res.start,
- mchan->resp_buf_size);
-- if (IS_ERR(mchan->resp_buf)) {
-+ if (!mchan->resp_buf) {
- dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-- ret = PTR_ERR(mchan->resp_buf);
-- return ret;
-+ return -ENOMEM;
- }
- } else if (ret != -ENODEV) {
- dev_err(mdev, "Unmatched resource %s.\n", name);
-@@ -543,10 +541,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox,
- mchan->req_buf_size = resource_size(&res);
- mchan->req_buf = devm_ioremap(mdev, res.start,
- mchan->req_buf_size);
-- if (IS_ERR(mchan->req_buf)) {
-+ if (!mchan->req_buf) {
- dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-- ret = PTR_ERR(mchan->req_buf);
-- return ret;
-+ return -ENOMEM;
- }
- } else if (ret != -ENODEV) {
- dev_err(mdev, "Unmatched resource %s.\n", name);
-@@ -559,10 +556,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox,
- mchan->resp_buf_size = resource_size(&res);
- mchan->resp_buf = devm_ioremap(mdev, res.start,
- mchan->resp_buf_size);
-- if (IS_ERR(mchan->resp_buf)) {
-+ if (!mchan->resp_buf) {
- dev_err(mdev, "Unable to map IPI buffer I/O memory\n");
-- ret = PTR_ERR(mchan->resp_buf);
-- return ret;
-+ return -ENOMEM;
- }
- } else if (ret != -ENODEV) {
- dev_err(mdev, "Unmatched resource %s.\n", name);
-diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
-index 72856e5f23a3..fd1f288fd801 100644
---- a/drivers/md/bcache/btree.c
-+++ b/drivers/md/bcache/btree.c
-@@ -1389,7 +1389,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 */
-@@ -1418,7 +1418,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);
-@@ -1464,6 +1464,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);
-
-diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
-index 3e500098132f..e0c800cf87a9 100644
---- a/drivers/md/dm-mpath.c
-+++ b/drivers/md/dm-mpath.c
-@@ -1918,7 +1918,7 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
- int r;
-
- current_pgpath = READ_ONCE(m->current_pgpath);
-- if (!current_pgpath)
-+ if (!current_pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
- current_pgpath = choose_pgpath(m, 0);
-
- if (current_pgpath) {
-diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
-index 369de15c4e80..61b7d7b7e5a6 100644
---- a/drivers/md/dm-zoned-metadata.c
-+++ b/drivers/md/dm-zoned-metadata.c
-@@ -1554,7 +1554,7 @@ static struct dm_zone *dmz_get_rnd_zone_for_reclaim(struct dmz_metadata *zmd)
- return dzone;
- }
-
-- return ERR_PTR(-EBUSY);
-+ return NULL;
- }
-
- /*
-@@ -1574,7 +1574,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd)
- return zone;
- }
-
-- return ERR_PTR(-EBUSY);
-+ return NULL;
- }
-
- /*
-diff --git a/drivers/md/dm-zoned-reclaim.c b/drivers/md/dm-zoned-reclaim.c
-index e7ace908a9b7..d50817320e8e 100644
---- a/drivers/md/dm-zoned-reclaim.c
-+++ b/drivers/md/dm-zoned-reclaim.c
-@@ -349,8 +349,8 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)
-
- /* Get a data zone */
- dzone = dmz_get_zone_for_reclaim(zmd);
-- if (IS_ERR(dzone))
-- return PTR_ERR(dzone);
-+ if (!dzone)
-+ return -EBUSY;
-
- start = jiffies;
-
-diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
-index 5c2a23b953a4..eba2b9f040df 100644
---- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
-+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
-@@ -1089,6 +1089,10 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
- child->coherent_dma_mask = dev->coherent_dma_mask;
- child->dma_mask = dev->dma_mask;
- child->release = s5p_mfc_memdev_release;
-+ child->dma_parms = devm_kzalloc(dev, sizeof(*child->dma_parms),
-+ GFP_KERNEL);
-+ if (!child->dma_parms)
-+ goto err;
-
- /*
- * The memdevs are not proper OF platform devices, so in order for them
-@@ -1104,7 +1108,7 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
- return child;
- device_del(child);
- }
--
-+err:
- put_device(child);
- return NULL;
- }
-diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
-index 452edd06d67d..99fd377f9b81 100644
---- a/drivers/media/v4l2-core/v4l2-ctrls.c
-+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
-@@ -1825,7 +1825,7 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
- sizeof(p_hevc_pps->row_height_minus1));
-
- p_hevc_pps->flags &=
-- ~V4L2_HEVC_PPS_FLAG_PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED;
-+ ~V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED;
- }
-
- if (p_hevc_pps->flags &
-diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
-index 857991cb3cbb..711979afd90a 100644
---- a/drivers/mfd/stmfx.c
-+++ b/drivers/mfd/stmfx.c
-@@ -287,14 +287,21 @@ static int stmfx_irq_init(struct i2c_client *client)
-
- ret = regmap_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN, irqoutpin);
- if (ret)
-- return ret;
-+ goto irq_exit;
-
- ret = devm_request_threaded_irq(stmfx->dev, client->irq,
- NULL, stmfx_irq_handler,
- irqtrigger | IRQF_ONESHOT,
- "stmfx", stmfx);
- if (ret)
-- stmfx_irq_exit(client);
-+ goto irq_exit;
-+
-+ stmfx->irq = client->irq;
-+
-+ return 0;
-+
-+irq_exit:
-+ stmfx_irq_exit(client);
-
- return ret;
- }
-@@ -481,6 +488,8 @@ static int stmfx_suspend(struct device *dev)
- if (ret)
- return ret;
-
-+ disable_irq(stmfx->irq);
-+
- if (stmfx->vdd)
- return regulator_disable(stmfx->vdd);
-
-@@ -501,6 +510,13 @@ static int stmfx_resume(struct device *dev)
- }
- }
-
-+ /* Reset STMFX - supply has been stopped during suspend */
-+ ret = stmfx_chip_reset(stmfx);
-+ if (ret) {
-+ dev_err(stmfx->dev, "Failed to reset chip: %d\n", ret);
-+ return ret;
-+ }
-+
- ret = regmap_raw_write(stmfx->map, STMFX_REG_SYS_CTRL,
- &stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
- if (ret)
-@@ -517,6 +533,8 @@ static int stmfx_resume(struct device *dev)
- if (ret)
- return ret;
-
-+ enable_irq(stmfx->irq);
-+
- return 0;
- }
- #endif
-diff --git a/drivers/mfd/wcd934x.c b/drivers/mfd/wcd934x.c
-index 90341f3c6810..da910302d51a 100644
---- a/drivers/mfd/wcd934x.c
-+++ b/drivers/mfd/wcd934x.c
-@@ -280,7 +280,6 @@ static void wcd934x_slim_remove(struct slim_device *sdev)
-
- regulator_bulk_disable(WCD934X_MAX_SUPPLY, ddata->supplies);
- mfd_remove_devices(&sdev->dev);
-- kfree(ddata);
- }
-
- static const struct slim_device_id wcd934x_slim_id[] = {
-diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
-index 1e9fe7d92597..737dede4a95c 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 <broonie@opensource.wolfsonmicro.com>");
-+MODULE_SOFTDEP("pre: wm8994_regulator");
-diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
-index e3e085e33d46..7939c55daceb 100644
---- a/drivers/misc/fastrpc.c
-+++ b/drivers/misc/fastrpc.c
-@@ -904,6 +904,7 @@ static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
- struct fastrpc_channel_ctx *cctx;
- struct fastrpc_user *fl = ctx->fl;
- struct fastrpc_msg *msg = &ctx->msg;
-+ int ret;
-
- cctx = fl->cctx;
- msg->pid = fl->tgid;
-@@ -919,7 +920,13 @@ static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
- msg->size = roundup(ctx->msg_sz, PAGE_SIZE);
- fastrpc_context_get(ctx);
-
-- return rpmsg_send(cctx->rpdev->ept, (void *)msg, sizeof(*msg));
-+ ret = rpmsg_send(cctx->rpdev->ept, (void *)msg, sizeof(*msg));
-+
-+ if (ret)
-+ fastrpc_context_put(ctx);
-+
-+ return ret;
-+
- }
-
- static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
-@@ -1613,8 +1620,10 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
- domains[domain_id]);
- data->miscdev.fops = &fastrpc_fops;
- err = misc_register(&data->miscdev);
-- if (err)
-+ if (err) {
-+ kfree(data);
- return err;
-+ }
-
- kref_init(&data->refcount);
-
-diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c
-index aef4de36b7aa..6d9c298e02c7 100644
---- a/drivers/misc/habanalabs/device.c
-+++ b/drivers/misc/habanalabs/device.c
-@@ -718,7 +718,7 @@ disable_device:
- return rc;
- }
-
--static void device_kill_open_processes(struct hl_device *hdev)
-+static int device_kill_open_processes(struct hl_device *hdev)
- {
- u16 pending_total, pending_cnt;
- struct hl_fpriv *hpriv;
-@@ -771,9 +771,7 @@ static void device_kill_open_processes(struct hl_device *hdev)
- ssleep(1);
- }
-
-- if (!list_empty(&hdev->fpriv_list))
-- dev_crit(hdev->dev,
-- "Going to hard reset with open user contexts\n");
-+ return list_empty(&hdev->fpriv_list) ? 0 : -EBUSY;
- }
-
- static void device_hard_reset_pending(struct work_struct *work)
-@@ -894,7 +892,12 @@ again:
- * process can't really exit until all its CSs are done, which
- * is what we do in cs rollback
- */
-- device_kill_open_processes(hdev);
-+ rc = device_kill_open_processes(hdev);
-+ if (rc) {
-+ dev_crit(hdev->dev,
-+ "Failed to kill all open processes, stopping hard reset\n");
-+ goto out_err;
-+ }
-
- /* Flush the Event queue workers to make sure no other thread is
- * reading or writing to registers during the reset
-@@ -1375,7 +1378,9 @@ void hl_device_fini(struct hl_device *hdev)
- * can't really exit until all its CSs are done, which is what we
- * do in cs rollback
- */
-- device_kill_open_processes(hdev);
-+ rc = device_kill_open_processes(hdev);
-+ if (rc)
-+ dev_crit(hdev->dev, "Failed to kill all open processes\n");
-
- hl_cb_pool_fini(hdev);
-
-diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h
-index 31ebcf9458fe..a6dd8e6ca594 100644
---- a/drivers/misc/habanalabs/habanalabs.h
-+++ b/drivers/misc/habanalabs/habanalabs.h
-@@ -23,7 +23,7 @@
-
- #define HL_MMAP_CB_MASK (0x8000000000000000ull >> PAGE_SHIFT)
-
--#define HL_PENDING_RESET_PER_SEC 5
-+#define HL_PENDING_RESET_PER_SEC 30
-
- #define HL_DEVICE_TIMEOUT_USEC 1000000 /* 1 s */
-
-diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
-index 71bbaa56bdb5..e2766aad9e14 100644
---- a/drivers/misc/xilinx_sdfec.c
-+++ b/drivers/misc/xilinx_sdfec.c
-@@ -602,10 +602,10 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset,
- const u32 depth)
- {
- u32 reg = 0;
-- u32 res;
-- u32 n, i;
-+ int res, i, nr_pages;
-+ u32 n;
- u32 *addr = NULL;
-- struct page *page[MAX_NUM_PAGES];
-+ struct page *pages[MAX_NUM_PAGES];
-
- /*
- * Writes that go beyond the length of
-@@ -622,15 +622,22 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset,
- if ((len * XSDFEC_REG_WIDTH_JUMP) % PAGE_SIZE)
- n += 1;
-
-- res = get_user_pages_fast((unsigned long)src_ptr, n, 0, page);
-- if (res < n) {
-- for (i = 0; i < res; i++)
-- put_page(page[i]);
-+ if (WARN_ON_ONCE(n > INT_MAX))
-+ return -EINVAL;
-+
-+ nr_pages = n;
-+
-+ res = get_user_pages_fast((unsigned long)src_ptr, nr_pages, 0, pages);
-+ if (res < nr_pages) {
-+ if (res > 0) {
-+ for (i = 0; i < res; i++)
-+ put_page(pages[i]);
-+ }
- return -EINVAL;
- }
-
-- for (i = 0; i < n; i++) {
-- addr = kmap(page[i]);
-+ for (i = 0; i < nr_pages; i++) {
-+ addr = kmap(pages[i]);
- do {
- xsdfec_regwrite(xsdfec,
- base_addr + ((offset + reg) *
-@@ -639,7 +646,7 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset,
- reg++;
- } while ((reg < len) &&
- ((reg * XSDFEC_REG_WIDTH_JUMP) % PAGE_SIZE));
-- put_page(page[i]);
-+ put_page(pages[i]);
- }
- return reg;
- }
-diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
-index efd1a1d1f35e..5d3c691a1c66 100644
---- a/drivers/net/bareudp.c
-+++ b/drivers/net/bareudp.c
-@@ -552,6 +552,8 @@ static int bareudp_validate(struct nlattr *tb[], struct nlattr *data[],
- static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
- struct netlink_ext_ack *extack)
- {
-+ memset(conf, 0, sizeof(*conf));
-+
- if (!data[IFLA_BAREUDP_PORT]) {
- NL_SET_ERR_MSG(extack, "port not specified");
- return -EINVAL;
-diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
-index cf6fa8fede33..521ebc072903 100644
---- a/drivers/net/dsa/lantiq_gswip.c
-+++ b/drivers/net/dsa/lantiq_gswip.c
-@@ -1452,7 +1452,8 @@ static void gswip_phylink_validate(struct dsa_switch *ds, int port,
-
- unsupported:
- bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
-- dev_err(ds->dev, "Unsupported interface: %d\n", state->interface);
-+ dev_err(ds->dev, "Unsupported interface '%s' for port %d\n",
-+ phy_modes(state->interface), port);
- return;
- }
-
-diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
-index bc0e47c1dbb9..177134596458 100644
---- a/drivers/net/dsa/sja1105/sja1105_ptp.c
-+++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
-@@ -891,16 +891,16 @@ void sja1105_ptp_txtstamp_skb(struct dsa_switch *ds, int port,
-
- mutex_lock(&ptp_data->lock);
-
-- rc = sja1105_ptpclkval_read(priv, &ticks, NULL);
-+ rc = sja1105_ptpegr_ts_poll(ds, port, &ts);
- if (rc < 0) {
-- dev_err(ds->dev, "Failed to read PTP clock: %d\n", rc);
-+ dev_err(ds->dev, "timed out polling for tstamp\n");
- kfree_skb(skb);
- goto out;
- }
-
-- rc = sja1105_ptpegr_ts_poll(ds, port, &ts);
-+ rc = sja1105_ptpclkval_read(priv, &ticks, NULL);
- if (rc < 0) {
-- dev_err(ds->dev, "timed out polling for tstamp\n");
-+ dev_err(ds->dev, "Failed to read PTP clock: %d\n", rc);
- kfree_skb(skb);
- goto out;
- }
-diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
-index 58e0d9a781e9..19c4a0a5727a 100644
---- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
-+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
-@@ -10014,7 +10014,7 @@ static void bnxt_timer(struct timer_list *t)
- struct bnxt *bp = from_timer(bp, t, timer);
- struct net_device *dev = bp->dev;
-
-- if (!netif_running(dev))
-+ if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state))
- return;
-
- if (atomic_read(&bp->intr_sem) != 0)
-@@ -12097,19 +12097,9 @@ static int bnxt_resume(struct device *device)
- goto resume_exit;
- }
-
-- if (bnxt_hwrm_queue_qportcfg(bp)) {
-- rc = -ENODEV;
-+ rc = bnxt_hwrm_func_qcaps(bp);
-+ if (rc)
- goto resume_exit;
-- }
--
-- if (bp->hwrm_spec_code >= 0x10803) {
-- if (bnxt_alloc_ctx_mem(bp)) {
-- rc = -ENODEV;
-- goto resume_exit;
-- }
-- }
-- if (BNXT_NEW_RM(bp))
-- bnxt_hwrm_func_resc_qcaps(bp, false);
-
- if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) {
- rc = -ENODEV;
-@@ -12125,6 +12115,8 @@ static int bnxt_resume(struct device *device)
-
- resume_exit:
- bnxt_ulp_start(bp, rc);
-+ if (!rc)
-+ bnxt_reenable_sriov(bp);
- rtnl_unlock();
- return rc;
- }
-@@ -12168,6 +12160,9 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
- bnxt_close(netdev);
-
- pci_disable_device(pdev);
-+ bnxt_free_ctx_mem(bp);
-+ kfree(bp->ctx);
-+ bp->ctx = NULL;
- rtnl_unlock();
-
- /* Request a slot slot reset. */
-@@ -12201,12 +12196,16 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
- pci_set_master(pdev);
-
- err = bnxt_hwrm_func_reset(bp);
-- if (!err && netif_running(netdev))
-- err = bnxt_open(netdev);
--
-- if (!err)
-- result = PCI_ERS_RESULT_RECOVERED;
-+ if (!err) {
-+ err = bnxt_hwrm_func_qcaps(bp);
-+ if (!err && netif_running(netdev))
-+ err = bnxt_open(netdev);
-+ }
- bnxt_ulp_start(bp, err);
-+ if (!err) {
-+ bnxt_reenable_sriov(bp);
-+ result = PCI_ERS_RESULT_RECOVERED;
-+ }
- }
-
- if (result != PCI_ERS_RESULT_RECOVERED) {
-diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
-index 9d868403d86c..cbaa1924afbe 100644
---- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
-+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
-@@ -234,6 +234,11 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
-
- /* Put it in the ring. */
- p->rx_ring[p->rx_next_fill] = re.d64;
-+ /* Make sure there is no reorder of filling the ring and ringing
-+ * the bell
-+ */
-+ wmb();
-+
- dma_sync_single_for_device(p->dev, p->rx_ring_handle,
- ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
- DMA_BIDIRECTIONAL);
-diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
-index 197dc5b2c090..1b4d04e4474b 100644
---- a/drivers/net/ethernet/ibm/ibmvnic.c
-+++ b/drivers/net/ethernet/ibm/ibmvnic.c
-@@ -5184,6 +5184,9 @@ static int ibmvnic_remove(struct vio_dev *dev)
- adapter->state = VNIC_REMOVING;
- spin_unlock_irqrestore(&adapter->state_lock, flags);
-
-+ flush_work(&adapter->ibmvnic_reset);
-+ flush_delayed_work(&adapter->ibmvnic_delayed_reset);
-+
- rtnl_lock();
- unregister_netdevice(netdev);
-
-diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
-index df3d50e759de..5e388d4a97a1 100644
---- a/drivers/net/ethernet/intel/e1000e/netdev.c
-+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
-@@ -6518,11 +6518,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;
-@@ -6579,7 +6585,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
- if (adapter->hw.phy.type == e1000_phy_igp_3) {
- e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
- } else if (hw->mac.type >= e1000_pch_lpt) {
-- 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/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
-index bcd11b4b29df..2d4ce6fdba1a 100644
---- a/drivers/net/ethernet/intel/iavf/iavf.h
-+++ b/drivers/net/ethernet/intel/iavf/iavf.h
-@@ -87,6 +87,10 @@ struct iavf_vsi {
- #define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)
- #define IAVF_MBPS_DIVISOR 125000 /* divisor to convert to Mbps */
-
-+#define IAVF_VIRTCHNL_VF_RESOURCE_SIZE (sizeof(struct virtchnl_vf_resource) + \
-+ (IAVF_MAX_VF_VSI * \
-+ sizeof(struct virtchnl_vsi_resource)))
-+
- /* MAX_MSIX_Q_VECTORS of these are allocated,
- * but we only use one per queue-specific vector.
- */
-@@ -306,6 +310,14 @@ struct iavf_adapter {
- bool netdev_registered;
- bool link_up;
- enum virtchnl_link_speed link_speed;
-+ /* This is only populated if the VIRTCHNL_VF_CAP_ADV_LINK_SPEED is set
-+ * in vf_res->vf_cap_flags. Use ADV_LINK_SUPPORT macro to determine if
-+ * this field is valid. This field should be used going forward and the
-+ * enum virtchnl_link_speed above should be considered the legacy way of
-+ * storing/communicating link speeds.
-+ */
-+ u32 link_speed_mbps;
-+
- enum virtchnl_ops current_op;
- #define CLIENT_ALLOWED(_a) ((_a)->vf_res ? \
- (_a)->vf_res->vf_cap_flags & \
-@@ -322,6 +334,8 @@ struct iavf_adapter {
- VIRTCHNL_VF_OFFLOAD_RSS_PF)))
- #define VLAN_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
- VIRTCHNL_VF_OFFLOAD_VLAN)
-+#define ADV_LINK_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
-+ VIRTCHNL_VF_CAP_ADV_LINK_SPEED)
- struct virtchnl_vf_resource *vf_res; /* incl. all VSIs */
- struct virtchnl_vsi_resource *vsi_res; /* our LAN VSI */
- struct virtchnl_version_info pf_version;
-diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
-index 2c39d46b6138..40a3fc7c5ea5 100644
---- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
-+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
-@@ -278,7 +278,18 @@ static int iavf_get_link_ksettings(struct net_device *netdev,
- ethtool_link_ksettings_zero_link_mode(cmd, supported);
- cmd->base.autoneg = AUTONEG_DISABLE;
- cmd->base.port = PORT_NONE;
-- /* Set speed and duplex */
-+ cmd->base.duplex = DUPLEX_FULL;
-+
-+ if (ADV_LINK_SUPPORT(adapter)) {
-+ if (adapter->link_speed_mbps &&
-+ adapter->link_speed_mbps < U32_MAX)
-+ cmd->base.speed = adapter->link_speed_mbps;
-+ else
-+ cmd->base.speed = SPEED_UNKNOWN;
-+
-+ return 0;
-+ }
-+
- switch (adapter->link_speed) {
- case IAVF_LINK_SPEED_40GB:
- cmd->base.speed = SPEED_40000;
-@@ -306,7 +317,6 @@ static int iavf_get_link_ksettings(struct net_device *netdev,
- default:
- break;
- }
-- cmd->base.duplex = DUPLEX_FULL;
-
- return 0;
- }
-diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
-index 2050649848ba..a21ae74bcd1b 100644
---- a/drivers/net/ethernet/intel/iavf/iavf_main.c
-+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
-@@ -1756,17 +1756,17 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- struct iavf_hw *hw = &adapter->hw;
-- int err = 0, bufsz;
-+ int err;
-
- WARN_ON(adapter->state != __IAVF_INIT_GET_RESOURCES);
- /* aq msg sent, awaiting reply */
- if (!adapter->vf_res) {
-- bufsz = sizeof(struct virtchnl_vf_resource) +
-- (IAVF_MAX_VF_VSI *
-- sizeof(struct virtchnl_vsi_resource));
-- adapter->vf_res = kzalloc(bufsz, GFP_KERNEL);
-- if (!adapter->vf_res)
-+ adapter->vf_res = kzalloc(IAVF_VIRTCHNL_VF_RESOURCE_SIZE,
-+ GFP_KERNEL);
-+ if (!adapter->vf_res) {
-+ err = -ENOMEM;
- goto err;
-+ }
- }
- err = iavf_get_vf_config(adapter);
- if (err == IAVF_ERR_ADMIN_QUEUE_NO_WORK) {
-@@ -2036,7 +2036,7 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
- iavf_reset_interrupt_capability(adapter);
- iavf_free_queues(adapter);
- iavf_free_q_vectors(adapter);
-- kfree(adapter->vf_res);
-+ memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);
- iavf_shutdown_adminq(&adapter->hw);
- adapter->netdev->flags &= ~IFF_UP;
- clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section);
-@@ -2487,6 +2487,16 @@ static int iavf_validate_tx_bandwidth(struct iavf_adapter *adapter,
- {
- int speed = 0, ret = 0;
-
-+ if (ADV_LINK_SUPPORT(adapter)) {
-+ if (adapter->link_speed_mbps < U32_MAX) {
-+ speed = adapter->link_speed_mbps;
-+ goto validate_bw;
-+ } else {
-+ dev_err(&adapter->pdev->dev, "Unknown link speed\n");
-+ return -EINVAL;
-+ }
-+ }
-+
- switch (adapter->link_speed) {
- case IAVF_LINK_SPEED_40GB:
- speed = 40000;
-@@ -2510,6 +2520,7 @@ static int iavf_validate_tx_bandwidth(struct iavf_adapter *adapter,
- break;
- }
-
-+validate_bw:
- if (max_tx_rate > speed) {
- dev_err(&adapter->pdev->dev,
- "Invalid tx rate specified\n");
-diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
-index d58374c2c33d..ca79bec4ebd9 100644
---- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
-+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
-@@ -139,7 +139,8 @@ int iavf_send_vf_config_msg(struct iavf_adapter *adapter)
- VIRTCHNL_VF_OFFLOAD_ENCAP |
- VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
- VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
-- VIRTCHNL_VF_OFFLOAD_ADQ;
-+ VIRTCHNL_VF_OFFLOAD_ADQ |
-+ VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
-
- adapter->current_op = VIRTCHNL_OP_GET_VF_RESOURCES;
- adapter->aq_required &= ~IAVF_FLAG_AQ_GET_CONFIG;
-@@ -891,6 +892,8 @@ void iavf_disable_vlan_stripping(struct iavf_adapter *adapter)
- iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, NULL, 0);
- }
-
-+#define IAVF_MAX_SPEED_STRLEN 13
-+
- /**
- * iavf_print_link_message - print link up or down
- * @adapter: adapter structure
-@@ -900,37 +903,99 @@ void iavf_disable_vlan_stripping(struct iavf_adapter *adapter)
- static void iavf_print_link_message(struct iavf_adapter *adapter)
- {
- struct net_device *netdev = adapter->netdev;
-- char *speed = "Unknown ";
-+ int link_speed_mbps;
-+ char *speed;
-
- if (!adapter->link_up) {
- netdev_info(netdev, "NIC Link is Down\n");
- return;
- }
-
-+ speed = kcalloc(1, IAVF_MAX_SPEED_STRLEN, GFP_KERNEL);
-+ if (!speed)
-+ return;
-+
-+ if (ADV_LINK_SUPPORT(adapter)) {
-+ link_speed_mbps = adapter->link_speed_mbps;
-+ goto print_link_msg;
-+ }
-+
- switch (adapter->link_speed) {
- case IAVF_LINK_SPEED_40GB:
-- speed = "40 G";
-+ link_speed_mbps = SPEED_40000;
- break;
- case IAVF_LINK_SPEED_25GB:
-- speed = "25 G";
-+ link_speed_mbps = SPEED_25000;
- break;
- case IAVF_LINK_SPEED_20GB:
-- speed = "20 G";
-+ link_speed_mbps = SPEED_20000;
- break;
- case IAVF_LINK_SPEED_10GB:
-- speed = "10 G";
-+ link_speed_mbps = SPEED_10000;
- break;
- case IAVF_LINK_SPEED_1GB:
-- speed = "1000 M";
-+ link_speed_mbps = SPEED_1000;
- break;
- case IAVF_LINK_SPEED_100MB:
-- speed = "100 M";
-+ link_speed_mbps = SPEED_100;
- break;
- default:
-+ link_speed_mbps = SPEED_UNKNOWN;
- break;
- }
-
-- netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
-+print_link_msg:
-+ if (link_speed_mbps > SPEED_1000) {
-+ if (link_speed_mbps == SPEED_2500)
-+ snprintf(speed, IAVF_MAX_SPEED_STRLEN, "2.5 Gbps");
-+ else
-+ /* convert to Gbps inline */
-+ snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
-+ link_speed_mbps / 1000, "Gbps");
-+ } else if (link_speed_mbps == SPEED_UNKNOWN) {
-+ snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%s", "Unknown Mbps");
-+ } else {
-+ snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%u %s",
-+ link_speed_mbps, "Mbps");
-+ }
-+
-+ netdev_info(netdev, "NIC Link is Up Speed is %s Full Duplex\n", speed);
-+ kfree(speed);
-+}
-+
-+/**
-+ * iavf_get_vpe_link_status
-+ * @adapter: adapter structure
-+ * @vpe: virtchnl_pf_event structure
-+ *
-+ * Helper function for determining the link status
-+ **/
-+static bool
-+iavf_get_vpe_link_status(struct iavf_adapter *adapter,
-+ struct virtchnl_pf_event *vpe)
-+{
-+ if (ADV_LINK_SUPPORT(adapter))
-+ return vpe->event_data.link_event_adv.link_status;
-+ else
-+ return vpe->event_data.link_event.link_status;
-+}
-+
-+/**
-+ * iavf_set_adapter_link_speed_from_vpe
-+ * @adapter: adapter structure for which we are setting the link speed
-+ * @vpe: virtchnl_pf_event structure that contains the link speed we are setting
-+ *
-+ * Helper function for setting iavf_adapter link speed
-+ **/
-+static void
-+iavf_set_adapter_link_speed_from_vpe(struct iavf_adapter *adapter,
-+ struct virtchnl_pf_event *vpe)
-+{
-+ if (ADV_LINK_SUPPORT(adapter))
-+ adapter->link_speed_mbps =
-+ vpe->event_data.link_event_adv.link_speed;
-+ else
-+ adapter->link_speed = vpe->event_data.link_event.link_speed;
- }
-
- /**
-@@ -1160,12 +1225,11 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
- if (v_opcode == VIRTCHNL_OP_EVENT) {
- struct virtchnl_pf_event *vpe =
- (struct virtchnl_pf_event *)msg;
-- bool link_up = vpe->event_data.link_event.link_status;
-+ bool link_up = iavf_get_vpe_link_status(adapter, vpe);
-
- switch (vpe->event) {
- case VIRTCHNL_EVENT_LINK_CHANGE:
-- adapter->link_speed =
-- vpe->event_data.link_event.link_speed;
-+ iavf_set_adapter_link_speed_from_vpe(adapter, vpe);
-
- /* we've already got the right link status, bail */
- if (adapter->link_up == link_up)
-diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
-index 2b5dad2ec650..b7b553602ea9 100644
---- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
-+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
-@@ -5983,8 +5983,8 @@ static int mvpp2_remove(struct platform_device *pdev)
- {
- struct mvpp2 *priv = platform_get_drvdata(pdev);
- struct fwnode_handle *fwnode = pdev->dev.fwnode;
-+ int i = 0, poolnum = MVPP2_BM_POOLS_NUM;
- struct fwnode_handle *port_fwnode;
-- int i = 0;
-
- mvpp2_dbgfs_cleanup(priv);
-
-@@ -5998,7 +5998,10 @@ static int mvpp2_remove(struct platform_device *pdev)
-
- destroy_workqueue(priv->stats_queue);
-
-- for (i = 0; i < MVPP2_BM_POOLS_NUM; i++) {
-+ if (priv->percpu_pools)
-+ poolnum = mvpp2_get_nrxqs(priv) * 2;
-+
-+ for (i = 0; i < poolnum; i++) {
- struct mvpp2_bm_pool *bm_pool = &priv->bm_pools[i];
-
- mvpp2_bm_pool_destroy(&pdev->dev, priv, bm_pool);
-diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
-index 18719acb7e54..eff8bb64899d 100644
---- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
-+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
-@@ -181,7 +181,7 @@ static struct mlx5dr_qp *dr_create_rc_qp(struct mlx5_core_dev *mdev,
- in, pas));
-
- err = mlx5_core_create_qp(mdev, &dr_qp->mqp, in, inlen);
-- kfree(in);
-+ kvfree(in);
-
- if (err) {
- mlx5_core_warn(mdev, " Can't create QP\n");
-diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
-index 6b39978acd07..3e4199246a18 100644
---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
-+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
-@@ -990,8 +990,10 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu,
-
- lossy = !(pfc || pause_en);
- thres_cells = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu);
-+ mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, &thres_cells);
- delay_cells = mlxsw_sp_pg_buf_delay_get(mlxsw_sp, mtu, delay,
- pfc, pause_en);
-+ mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, &delay_cells);
- total_cells = thres_cells + delay_cells;
-
- taken_headroom_cells += total_cells;
-diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
-index ca56e72cb4b7..e28ecb84b816 100644
---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
-+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
-@@ -395,6 +395,19 @@ mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port,
- return NULL;
- }
-
-+static inline void
-+mlxsw_sp_port_headroom_8x_adjust(const struct mlxsw_sp_port *mlxsw_sp_port,
-+ u16 *p_size)
-+{
-+ /* Ports with eight lanes use two headroom buffers between which the
-+ * configured headroom size is split. Therefore, multiply the calculated
-+ * headroom size by two.
-+ */
-+ if (mlxsw_sp_port->mapping.width != 8)
-+ return;
-+ *p_size *= 2;
-+}
-+
- enum mlxsw_sp_flood_type {
- MLXSW_SP_FLOOD_TYPE_UC,
- MLXSW_SP_FLOOD_TYPE_BC,
-diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
-index 968f0902e4fe..19bf0768ed78 100644
---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
-+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
-@@ -312,6 +312,7 @@ static int mlxsw_sp_port_pb_init(struct mlxsw_sp_port *mlxsw_sp_port)
-
- if (i == MLXSW_SP_PB_UNUSED)
- continue;
-+ mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, &size);
- mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl, i, size);
- }
- mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl,
-diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
-index 9fb2e9d93929..7c5032f9c8ff 100644
---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
-+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
-@@ -776,6 +776,7 @@ mlxsw_sp_span_port_buffsize_update(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu)
- speed = 0;
-
- buffsize = mlxsw_sp_span_buffsize_get(mlxsw_sp, speed, mtu);
-+ mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, (u16 *) &buffsize);
- mlxsw_reg_sbib_pack(sbib_pl, mlxsw_sp_port->local_port, buffsize);
- return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sbib), sbib_pl);
- }
-diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
-index 6b461be1820b..75266580b586 100644
---- a/drivers/net/geneve.c
-+++ b/drivers/net/geneve.c
-@@ -987,9 +987,10 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
- if (geneve->collect_md) {
- info = skb_tunnel_info(skb);
- if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX))) {
-- err = -EINVAL;
- netdev_dbg(dev, "no tunnel metadata\n");
-- goto tx_error;
-+ dev_kfree_skb(skb);
-+ dev->stats.tx_dropped++;
-+ return NETDEV_TX_OK;
- }
- } else {
- info = &geneve->info;
-@@ -1006,7 +1007,7 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
-
- if (likely(!err))
- return NETDEV_TX_OK;
--tx_error:
-+
- dev_kfree_skb(skb);
-
- if (err == -ELOOP)
-diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
-index 71cdef9fb56b..5ab53e9942f3 100644
---- a/drivers/net/hamradio/yam.c
-+++ b/drivers/net/hamradio/yam.c
-@@ -1133,6 +1133,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/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
-index a21534f1462f..1d823ac0f6d6 100644
---- a/drivers/net/ipa/ipa_endpoint.c
-+++ b/drivers/net/ipa/ipa_endpoint.c
-@@ -669,10 +669,12 @@ static void ipa_endpoint_init_seq(struct ipa_endpoint *endpoint)
- u32 seq_type = endpoint->seq_type;
- u32 val = 0;
-
-+ /* Sequencer type is made up of four nibbles */
- val |= u32_encode_bits(seq_type & 0xf, HPS_SEQ_TYPE_FMASK);
- val |= u32_encode_bits((seq_type >> 4) & 0xf, DPS_SEQ_TYPE_FMASK);
-- /* HPS_REP_SEQ_TYPE is 0 */
-- /* DPS_REP_SEQ_TYPE is 0 */
-+ /* The second two apply to replicated packets */
-+ val |= u32_encode_bits((seq_type >> 8) & 0xf, HPS_REP_SEQ_TYPE_FMASK);
-+ val |= u32_encode_bits((seq_type >> 12) & 0xf, DPS_REP_SEQ_TYPE_FMASK);
-
- iowrite32(val, endpoint->ipa->reg_virt + offset);
- }
-diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h
-index 3b8106aa277a..0a688d8c1d7c 100644
---- a/drivers/net/ipa/ipa_reg.h
-+++ b/drivers/net/ipa/ipa_reg.h
-@@ -455,6 +455,8 @@ enum ipa_mode {
- * second packet processing pass + no decipher + microcontroller
- * @IPA_SEQ_DMA_DEC: DMA + cipher/decipher
- * @IPA_SEQ_DMA_COMP_DECOMP: DMA + compression/decompression
-+ * @IPA_SEQ_PKT_PROCESS_NO_DEC_NO_UCP_DMAP:
-+ * packet processing + no decipher + no uCP + HPS REP DMA parser
- * @IPA_SEQ_INVALID: invalid sequencer type
- *
- * The values defined here are broken into 4-bit nibbles that are written
-diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
-index b55e3c0403ed..ddac79960ea7 100644
---- a/drivers/net/phy/dp83867.c
-+++ b/drivers/net/phy/dp83867.c
-@@ -488,7 +488,7 @@ static int dp83867_verify_rgmii_cfg(struct phy_device *phydev)
- return 0;
- }
-
--#ifdef CONFIG_OF_MDIO
-+#if IS_ENABLED(CONFIG_OF_MDIO)
- static int dp83867_of_init(struct phy_device *phydev)
- {
- struct dp83867_private *dp83867 = phydev->priv;
-diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
-index 7fc8e10c5f33..a435f7352cfb 100644
---- a/drivers/net/phy/marvell.c
-+++ b/drivers/net/phy/marvell.c
-@@ -337,7 +337,7 @@ static int m88e1101_config_aneg(struct phy_device *phydev)
- return marvell_config_aneg(phydev);
- }
-
--#ifdef CONFIG_OF_MDIO
-+#if IS_ENABLED(CONFIG_OF_MDIO)
- /* Set and/or override some configuration registers based on the
- * marvell,reg-init property stored in the of_node for the phydev.
- *
-diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
-index 7a4eb3f2cb74..a1a4dee2a033 100644
---- a/drivers/net/phy/mdio_bus.c
-+++ b/drivers/net/phy/mdio_bus.c
-@@ -757,6 +757,7 @@ EXPORT_SYMBOL(mdiobus_scan);
-
- static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
- {
-+ preempt_disable();
- u64_stats_update_begin(&stats->syncp);
-
- u64_stats_inc(&stats->transfers);
-@@ -771,6 +772,7 @@ static void mdiobus_stats_acct(struct mdio_bus_stats *stats, bool op, int ret)
- u64_stats_inc(&stats->writes);
- out:
- u64_stats_update_end(&stats->syncp);
-+ preempt_enable();
- }
-
- /**
-diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
-index 414e3b31bb1f..132f9bf49198 100644
---- a/drivers/net/phy/mscc/mscc.h
-+++ b/drivers/net/phy/mscc/mscc.h
-@@ -375,7 +375,7 @@ struct vsc8531_private {
- #endif
- };
-
--#ifdef CONFIG_OF_MDIO
-+#if IS_ENABLED(CONFIG_OF_MDIO)
- struct vsc8531_edge_rate_table {
- u32 vddmac;
- u32 slowdown[8];
-diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
-index c8aa6d905d8e..485a4f8a6a9a 100644
---- a/drivers/net/phy/mscc/mscc_main.c
-+++ b/drivers/net/phy/mscc/mscc_main.c
-@@ -98,7 +98,7 @@ static const struct vsc85xx_hw_stat vsc8584_hw_stats[] = {
- },
- };
-
--#ifdef CONFIG_OF_MDIO
-+#if IS_ENABLED(CONFIG_OF_MDIO)
- static const struct vsc8531_edge_rate_table edge_table[] = {
- {MSCC_VDDMAC_3300, { 0, 2, 4, 7, 10, 17, 29, 53} },
- {MSCC_VDDMAC_2500, { 0, 3, 6, 10, 14, 23, 37, 63} },
-@@ -382,7 +382,7 @@ out_unlock:
- mutex_unlock(&phydev->lock);
- }
-
--#ifdef CONFIG_OF_MDIO
-+#if IS_ENABLED(CONFIG_OF_MDIO)
- static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
- {
- u32 vdd, sd;
-diff --git a/drivers/ntb/core.c b/drivers/ntb/core.c
-index 2581ab724c34..f8f75a504a58 100644
---- a/drivers/ntb/core.c
-+++ b/drivers/ntb/core.c
-@@ -214,10 +214,8 @@ int ntb_default_port_number(struct ntb_dev *ntb)
- case NTB_TOPO_B2B_DSD:
- return NTB_PORT_SEC_DSD;
- default:
-- break;
-+ return 0;
- }
--
-- return -EINVAL;
- }
- EXPORT_SYMBOL(ntb_default_port_number);
-
-@@ -240,10 +238,8 @@ int ntb_default_peer_port_number(struct ntb_dev *ntb, int pidx)
- case NTB_TOPO_B2B_DSD:
- return NTB_PORT_PRI_USD;
- default:
-- break;
-+ return 0;
- }
--
-- return -EINVAL;
- }
- EXPORT_SYMBOL(ntb_default_peer_port_number);
-
-@@ -315,4 +311,3 @@ static void __exit ntb_driver_exit(void)
- bus_unregister(&ntb_bus);
- }
- module_exit(ntb_driver_exit);
--
-diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
-index 972f6d984f6d..528751803419 100644
---- a/drivers/ntb/test/ntb_perf.c
-+++ b/drivers/ntb/test/ntb_perf.c
-@@ -159,6 +159,8 @@ struct perf_peer {
- /* NTB connection setup service */
- struct work_struct service;
- unsigned long sts;
-+
-+ struct completion init_comp;
- };
- #define to_peer_service(__work) \
- container_of(__work, struct perf_peer, service)
-@@ -547,6 +549,7 @@ static int perf_setup_outbuf(struct perf_peer *peer)
-
- /* Initialization is finally done */
- set_bit(PERF_STS_DONE, &peer->sts);
-+ complete_all(&peer->init_comp);
-
- return 0;
- }
-@@ -557,7 +560,7 @@ static void perf_free_inbuf(struct perf_peer *peer)
- return;
-
- (void)ntb_mw_clear_trans(peer->perf->ntb, peer->pidx, peer->gidx);
-- dma_free_coherent(&peer->perf->ntb->dev, peer->inbuf_size,
-+ dma_free_coherent(&peer->perf->ntb->pdev->dev, peer->inbuf_size,
- peer->inbuf, peer->inbuf_xlat);
- peer->inbuf = NULL;
- }
-@@ -586,8 +589,9 @@ static int perf_setup_inbuf(struct perf_peer *peer)
-
- perf_free_inbuf(peer);
-
-- peer->inbuf = dma_alloc_coherent(&perf->ntb->dev, peer->inbuf_size,
-- &peer->inbuf_xlat, GFP_KERNEL);
-+ peer->inbuf = dma_alloc_coherent(&perf->ntb->pdev->dev,
-+ peer->inbuf_size, &peer->inbuf_xlat,
-+ GFP_KERNEL);
- if (!peer->inbuf) {
- dev_err(&perf->ntb->dev, "Failed to alloc inbuf of %pa\n",
- &peer->inbuf_size);
-@@ -637,6 +641,7 @@ static void perf_service_work(struct work_struct *work)
- perf_setup_outbuf(peer);
-
- if (test_and_clear_bit(PERF_CMD_CLEAR, &peer->sts)) {
-+ init_completion(&peer->init_comp);
- clear_bit(PERF_STS_DONE, &peer->sts);
- if (test_bit(0, &peer->perf->busy_flag) &&
- peer == peer->perf->test_peer) {
-@@ -653,7 +658,7 @@ static int perf_init_service(struct perf_ctx *perf)
- {
- u64 mask;
-
-- if (ntb_peer_mw_count(perf->ntb) < perf->pcnt + 1) {
-+ if (ntb_peer_mw_count(perf->ntb) < perf->pcnt) {
- dev_err(&perf->ntb->dev, "Not enough memory windows\n");
- return -EINVAL;
- }
-@@ -1083,8 +1088,9 @@ static int perf_submit_test(struct perf_peer *peer)
- struct perf_thread *pthr;
- int tidx, ret;
-
-- if (!test_bit(PERF_STS_DONE, &peer->sts))
-- return -ENOLINK;
-+ ret = wait_for_completion_interruptible(&peer->init_comp);
-+ if (ret < 0)
-+ return ret;
-
- if (test_and_set_bit_lock(0, &perf->busy_flag))
- return -EBUSY;
-@@ -1455,10 +1461,21 @@ static int perf_init_peers(struct perf_ctx *perf)
- peer->gidx = pidx;
- }
- INIT_WORK(&peer->service, perf_service_work);
-+ init_completion(&peer->init_comp);
- }
- if (perf->gidx == -1)
- perf->gidx = pidx;
-
-+ /*
-+ * Hardware with only two ports may not have unique port
-+ * numbers. In this case, the gidxs should all be zero.
-+ */
-+ if (perf->pcnt == 1 && ntb_port_number(perf->ntb) == 0 &&
-+ ntb_peer_port_number(perf->ntb, 0) == 0) {
-+ perf->gidx = 0;
-+ perf->peers[0].gidx = 0;
-+ }
-+
- for (pidx = 0; pidx < perf->pcnt; pidx++) {
- ret = perf_setup_peer_mw(&perf->peers[pidx]);
- if (ret)
-@@ -1554,4 +1571,3 @@ static void __exit perf_exit(void)
- destroy_workqueue(perf_wq);
- }
- module_exit(perf_exit);
--
-diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c
-index 04dd46647db3..2164e8492772 100644
---- a/drivers/ntb/test/ntb_pingpong.c
-+++ b/drivers/ntb/test/ntb_pingpong.c
-@@ -121,15 +121,14 @@ static int pp_find_next_peer(struct pp_ctx *pp)
- link = ntb_link_is_up(pp->ntb, NULL, NULL);
-
- /* Find next available peer */
-- if (link & pp->nmask) {
-+ if (link & pp->nmask)
- pidx = __ffs64(link & pp->nmask);
-- out_db = BIT_ULL(pidx + 1);
-- } else if (link & pp->pmask) {
-+ else if (link & pp->pmask)
- pidx = __ffs64(link & pp->pmask);
-- out_db = BIT_ULL(pidx);
-- } else {
-+ else
- return -ENODEV;
-- }
-+
-+ out_db = BIT_ULL(ntb_peer_port_number(pp->ntb, pidx));
-
- spin_lock(&pp->lock);
- pp->out_pidx = pidx;
-@@ -303,7 +302,7 @@ static void pp_init_flds(struct pp_ctx *pp)
- break;
- }
-
-- pp->in_db = BIT_ULL(pidx);
-+ pp->in_db = BIT_ULL(lport);
- pp->pmask = GENMASK_ULL(pidx, 0) >> 1;
- pp->nmask = GENMASK_ULL(pcnt - 1, pidx);
-
-@@ -432,4 +431,3 @@ static void __exit pp_exit(void)
- debugfs_remove_recursive(pp_dbgfs_topdir);
- }
- module_exit(pp_exit);
--
-diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
-index 69da758fe64c..b7bf3f863d79 100644
---- a/drivers/ntb/test/ntb_tool.c
-+++ b/drivers/ntb/test/ntb_tool.c
-@@ -504,7 +504,7 @@ static ssize_t tool_peer_link_read(struct file *filep, char __user *ubuf,
- buf[1] = '\n';
- buf[2] = '\0';
-
-- return simple_read_from_buffer(ubuf, size, offp, buf, 3);
-+ return simple_read_from_buffer(ubuf, size, offp, buf, 2);
- }
-
- static TOOL_FOPS_RDWR(tool_peer_link_fops,
-@@ -590,7 +590,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,
- inmw->size = min_t(resource_size_t, req_size, size);
- inmw->size = round_up(inmw->size, addr_align);
- inmw->size = round_up(inmw->size, size_align);
-- inmw->mm_base = dma_alloc_coherent(&tc->ntb->dev, inmw->size,
-+ inmw->mm_base = dma_alloc_coherent(&tc->ntb->pdev->dev, inmw->size,
- &inmw->dma_base, GFP_KERNEL);
- if (!inmw->mm_base)
- return -ENOMEM;
-@@ -612,7 +612,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,
- return 0;
-
- err_free_dma:
-- dma_free_coherent(&tc->ntb->dev, inmw->size, inmw->mm_base,
-+ dma_free_coherent(&tc->ntb->pdev->dev, inmw->size, inmw->mm_base,
- inmw->dma_base);
- inmw->mm_base = NULL;
- inmw->dma_base = 0;
-@@ -629,7 +629,7 @@ static void tool_free_mw(struct tool_ctx *tc, int pidx, int widx)
-
- if (inmw->mm_base != NULL) {
- ntb_mw_clear_trans(tc->ntb, pidx, widx);
-- dma_free_coherent(&tc->ntb->dev, inmw->size,
-+ dma_free_coherent(&tc->ntb->pdev->dev, inmw->size,
- inmw->mm_base, inmw->dma_base);
- }
-
-@@ -1690,4 +1690,3 @@ static void __exit tool_exit(void)
- debugfs_remove_recursive(tool_dbgfs_topdir);
- }
- module_exit(tool_exit);
--
-diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
-index 5ef4a84c442a..564e3f220ac7 100644
---- a/drivers/nvme/host/fc.c
-+++ b/drivers/nvme/host/fc.c
-@@ -2300,10 +2300,11 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
- opstate = atomic_xchg(&op->state, FCPOP_STATE_COMPLETE);
- __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
-
-- if (!(op->flags & FCOP_FLAGS_AEN))
-+ if (!(op->flags & FCOP_FLAGS_AEN)) {
- nvme_fc_unmap_data(ctrl, op->rq, op);
-+ nvme_cleanup_cmd(op->rq);
-+ }
-
-- nvme_cleanup_cmd(op->rq);
- nvme_fc_ctrl_put(ctrl);
-
- if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE &&
-diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
-index 076bdd90c922..4ad629eb3bc6 100644
---- a/drivers/nvme/host/pci.c
-+++ b/drivers/nvme/host/pci.c
-@@ -2958,9 +2958,15 @@ static int nvme_suspend(struct device *dev)
- * the PCI bus layer to put it into D3 in order to take the PCIe link
- * down, so as to allow the platform to achieve its minimum low-power
- * state (which may not be possible if the link is up).
-+ *
-+ * If a host memory buffer is enabled, shut down the device as the NVMe
-+ * specification allows the device to access the host memory buffer in
-+ * host DRAM from all power states, but hosts will fail access to DRAM
-+ * during S3.
- */
- if (pm_suspend_via_firmware() || !ctrl->npss ||
- !pcie_aspm_enabled(pdev) ||
-+ ndev->nr_host_mem_descs ||
- (ndev->ctrl.quirks & NVME_QUIRK_SIMPLE_SUSPEND))
- return nvme_disable_prepare_reset(ndev, true);
-
-diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
-index 05c6ae4b0b97..a8300202a7fb 100644
---- a/drivers/nvmem/core.c
-+++ b/drivers/nvmem/core.c
-@@ -66,6 +66,30 @@ static LIST_HEAD(nvmem_lookup_list);
-
- static BLOCKING_NOTIFIER_HEAD(nvmem_notifier);
-
-+static int nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
-+ void *val, size_t bytes)
-+{
-+ if (nvmem->reg_read)
-+ return nvmem->reg_read(nvmem->priv, offset, val, bytes);
-+
-+ return -EINVAL;
-+}
-+
-+static int nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset,
-+ void *val, size_t bytes)
-+{
-+ int ret;
-+
-+ if (nvmem->reg_write) {
-+ gpiod_set_value_cansleep(nvmem->wp_gpio, 0);
-+ ret = nvmem->reg_write(nvmem->priv, offset, val, bytes);
-+ gpiod_set_value_cansleep(nvmem->wp_gpio, 1);
-+ return ret;
-+ }
-+
-+ return -EINVAL;
-+}
-+
- #ifdef CONFIG_NVMEM_SYSFS
- static const char * const nvmem_type_str[] = {
- [NVMEM_TYPE_UNKNOWN] = "Unknown",
-@@ -122,7 +146,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
- if (!nvmem->reg_read)
- return -EPERM;
-
-- rc = nvmem->reg_read(nvmem->priv, pos, buf, count);
-+ rc = nvmem_reg_read(nvmem, pos, buf, count);
-
- if (rc)
- return rc;
-@@ -159,7 +183,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
- if (!nvmem->reg_write)
- return -EPERM;
-
-- rc = nvmem->reg_write(nvmem->priv, pos, buf, count);
-+ rc = nvmem_reg_write(nvmem, pos, buf, count);
-
- if (rc)
- return rc;
-@@ -311,30 +335,6 @@ static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem,
-
- #endif /* CONFIG_NVMEM_SYSFS */
-
--static int nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
-- void *val, size_t bytes)
--{
-- if (nvmem->reg_read)
-- return nvmem->reg_read(nvmem->priv, offset, val, bytes);
--
-- return -EINVAL;
--}
--
--static int nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset,
-- void *val, size_t bytes)
--{
-- int ret;
--
-- if (nvmem->reg_write) {
-- gpiod_set_value_cansleep(nvmem->wp_gpio, 0);
-- ret = nvmem->reg_write(nvmem->priv, offset, val, bytes);
-- gpiod_set_value_cansleep(nvmem->wp_gpio, 1);
-- return ret;
-- }
--
-- return -EINVAL;
--}
--
- static void nvmem_release(struct device *dev)
- {
- struct nvmem_device *nvmem = to_nvmem_device(dev);
-diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c
-index c72eef988041..a32e60b024b8 100644
---- a/drivers/of/kobj.c
-+++ b/drivers/of/kobj.c
-@@ -134,8 +134,6 @@ int __of_attach_node_sysfs(struct device_node *np)
- if (!name)
- return -ENOMEM;
-
-- of_node_get(np);
--
- rc = kobject_add(&np->kobj, parent, "%s", name);
- kfree(name);
- if (rc)
-@@ -144,6 +142,7 @@ int __of_attach_node_sysfs(struct device_node *np)
- for_each_property_of_node(np, pp)
- __of_add_property_sysfs(np, pp);
-
-+ of_node_get(np);
- return 0;
- }
-
-diff --git a/drivers/of/property.c b/drivers/of/property.c
-index b4916dcc9e72..6dc542af5a70 100644
---- a/drivers/of/property.c
-+++ b/drivers/of/property.c
-@@ -1045,8 +1045,20 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np,
- * Find the device node that contains the supplier phandle. It may be
- * @sup_np or it may be an ancestor of @sup_np.
- */
-- while (sup_np && !of_find_property(sup_np, "compatible", NULL))
-+ while (sup_np) {
-+
-+ /* Don't allow linking to a disabled supplier */
-+ if (!of_device_is_available(sup_np)) {
-+ of_node_put(sup_np);
-+ sup_np = NULL;
-+ }
-+
-+ if (of_find_property(sup_np, "compatible", NULL))
-+ break;
-+
- sup_np = of_get_next_parent(sup_np);
-+ }
-+
- if (!sup_np) {
- dev_dbg(dev, "Not linking to %pOFP - No device\n", tmp_np);
- return -ENODEV;
-@@ -1296,7 +1308,7 @@ static int of_link_to_suppliers(struct device *dev,
- if (of_link_property(dev, con_np, p->name))
- ret = -ENODEV;
-
-- for_each_child_of_node(con_np, child)
-+ for_each_available_child_of_node(con_np, child)
- if (of_link_to_suppliers(dev, child) && !ret)
- ret = -EAGAIN;
-
-diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
-index 3b0e58f2de58..6184ebc9392d 100644
---- a/drivers/pci/controller/dwc/pci-dra7xx.c
-+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
-@@ -840,7 +840,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
- struct phy **phy;
- struct device_link **link;
- void __iomem *base;
-- struct resource *res;
- struct dw_pcie *pci;
- struct dra7xx_pcie *dra7xx;
- struct device *dev = &pdev->dev;
-@@ -877,10 +876,9 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
- return irq;
- }
-
-- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf");
-- base = devm_ioremap(dev, res->start, resource_size(res));
-- if (!base)
-- return -ENOMEM;
-+ base = devm_platform_ioremap_resource_byname(pdev, "ti_conf");
-+ if (IS_ERR(base))
-+ return PTR_ERR(base);
-
- phy_count = of_property_count_strings(np, "phy-names");
- if (phy_count < 0) {
-diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
-index 3715dceca1bf..ca59ba9e0ecd 100644
---- a/drivers/pci/controller/dwc/pci-meson.c
-+++ b/drivers/pci/controller/dwc/pci-meson.c
-@@ -289,11 +289,11 @@ static void meson_pcie_init_dw(struct meson_pcie *mp)
- meson_cfg_writel(mp, val, PCIE_CFG0);
-
- val = meson_elb_readl(mp, PCIE_PORT_LINK_CTRL_OFF);
-- val &= ~LINK_CAPABLE_MASK;
-+ val &= ~(LINK_CAPABLE_MASK | FAST_LINK_MODE);
- meson_elb_writel(mp, val, PCIE_PORT_LINK_CTRL_OFF);
-
- val = meson_elb_readl(mp, PCIE_PORT_LINK_CTRL_OFF);
-- val |= LINK_CAPABLE_X1 | FAST_LINK_MODE;
-+ val |= LINK_CAPABLE_X1;
- meson_elb_writel(mp, val, PCIE_PORT_LINK_CTRL_OFF);
-
- val = meson_elb_readl(mp, PCIE_GEN2_CTRL_OFF);
-diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
-index 395feb8ca051..3c43311bb95c 100644
---- a/drivers/pci/controller/dwc/pcie-designware-host.c
-+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
-@@ -264,6 +264,8 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)
- return -ENOMEM;
- }
-
-+ irq_domain_update_bus_token(pp->irq_domain, DOMAIN_BUS_NEXUS);
-+
- pp->msi_domain = pci_msi_create_irq_domain(fwnode,
- &dw_pcie_msi_domain_info,
- pp->irq_domain);
-diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
-index 2a20b649f40c..2ecc79c03ade 100644
---- a/drivers/pci/controller/pci-aardvark.c
-+++ b/drivers/pci/controller/pci-aardvark.c
-@@ -9,6 +9,7 @@
- */
-
- #include <linux/delay.h>
-+#include <linux/gpio.h>
- #include <linux/interrupt.h>
- #include <linux/irq.h>
- #include <linux/irqdomain.h>
-@@ -18,6 +19,7 @@
- #include <linux/platform_device.h>
- #include <linux/msi.h>
- #include <linux/of_address.h>
-+#include <linux/of_gpio.h>
- #include <linux/of_pci.h>
-
- #include "../pci.h"
-@@ -40,6 +42,7 @@
- #define PCIE_CORE_LINK_CTRL_STAT_REG 0xd0
- #define PCIE_CORE_LINK_L0S_ENTRY BIT(0)
- #define PCIE_CORE_LINK_TRAINING BIT(5)
-+#define PCIE_CORE_LINK_SPEED_SHIFT 16
- #define PCIE_CORE_LINK_WIDTH_SHIFT 20
- #define PCIE_CORE_ERR_CAPCTL_REG 0x118
- #define PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX BIT(5)
-@@ -201,7 +204,9 @@ struct advk_pcie {
- struct mutex msi_used_lock;
- u16 msi_msg;
- int root_bus_nr;
-+ int link_gen;
- struct pci_bridge_emul bridge;
-+ struct gpio_desc *reset_gpio;
- };
-
- static inline void advk_writel(struct advk_pcie *pcie, u32 val, u64 reg)
-@@ -225,20 +230,16 @@ static int advk_pcie_link_up(struct advk_pcie *pcie)
-
- static int advk_pcie_wait_for_link(struct advk_pcie *pcie)
- {
-- struct device *dev = &pcie->pdev->dev;
- int retries;
-
- /* check if the link is up or not */
- for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) {
-- if (advk_pcie_link_up(pcie)) {
-- dev_info(dev, "link up\n");
-+ if (advk_pcie_link_up(pcie))
- return 0;
-- }
-
- usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX);
- }
-
-- dev_err(dev, "link never came up\n");
- return -ETIMEDOUT;
- }
-
-@@ -253,10 +254,110 @@ static void advk_pcie_wait_for_retrain(struct advk_pcie *pcie)
- }
- }
-
-+static int advk_pcie_train_at_gen(struct advk_pcie *pcie, int gen)
-+{
-+ int ret, neg_gen;
-+ u32 reg;
-+
-+ /* Setup link speed */
-+ reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
-+ reg &= ~PCIE_GEN_SEL_MSK;
-+ if (gen == 3)
-+ reg |= SPEED_GEN_3;
-+ else if (gen == 2)
-+ reg |= SPEED_GEN_2;
-+ else
-+ reg |= SPEED_GEN_1;
-+ advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
-+
-+ /*
-+ * Enable link training. This is not needed in every call to this
-+ * function, just once suffices, but it does not break anything either.
-+ */
-+ reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
-+ reg |= LINK_TRAINING_EN;
-+ advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
-+
-+ /*
-+ * Start link training immediately after enabling it.
-+ * This solves problems for some buggy cards.
-+ */
-+ reg = advk_readl(pcie, PCIE_CORE_LINK_CTRL_STAT_REG);
-+ reg |= PCIE_CORE_LINK_TRAINING;
-+ advk_writel(pcie, reg, PCIE_CORE_LINK_CTRL_STAT_REG);
-+
-+ ret = advk_pcie_wait_for_link(pcie);
-+ if (ret)
-+ return ret;
-+
-+ reg = advk_readl(pcie, PCIE_CORE_LINK_CTRL_STAT_REG);
-+ neg_gen = (reg >> PCIE_CORE_LINK_SPEED_SHIFT) & 0xf;
-+
-+ return neg_gen;
-+}
-+
-+static void advk_pcie_train_link(struct advk_pcie *pcie)
-+{
-+ struct device *dev = &pcie->pdev->dev;
-+ int neg_gen = -1, gen;
-+
-+ /*
-+ * Try link training at link gen specified by device tree property
-+ * 'max-link-speed'. If this fails, iteratively train at lower gen.
-+ */
-+ for (gen = pcie->link_gen; gen > 0; --gen) {
-+ neg_gen = advk_pcie_train_at_gen(pcie, gen);
-+ if (neg_gen > 0)
-+ break;
-+ }
-+
-+ if (neg_gen < 0)
-+ goto err;
-+
-+ /*
-+ * After successful training if negotiated gen is lower than requested,
-+ * train again on negotiated gen. This solves some stability issues for
-+ * some buggy gen1 cards.
-+ */
-+ if (neg_gen < gen) {
-+ gen = neg_gen;
-+ neg_gen = advk_pcie_train_at_gen(pcie, gen);
-+ }
-+
-+ if (neg_gen == gen) {
-+ dev_info(dev, "link up at gen %i\n", gen);
-+ return;
-+ }
-+
-+err:
-+ dev_err(dev, "link never came up\n");
-+}
-+
-+static void advk_pcie_issue_perst(struct advk_pcie *pcie)
-+{
-+ u32 reg;
-+
-+ if (!pcie->reset_gpio)
-+ return;
-+
-+ /* PERST does not work for some cards when link training is enabled */
-+ reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
-+ reg &= ~LINK_TRAINING_EN;
-+ advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
-+
-+ /* 10ms delay is needed for some cards */
-+ dev_info(&pcie->pdev->dev, "issuing PERST via reset GPIO for 10ms\n");
-+ gpiod_set_value_cansleep(pcie->reset_gpio, 1);
-+ usleep_range(10000, 11000);
-+ gpiod_set_value_cansleep(pcie->reset_gpio, 0);
-+}
-+
- static void advk_pcie_setup_hw(struct advk_pcie *pcie)
- {
- u32 reg;
-
-+ advk_pcie_issue_perst(pcie);
-+
- /* Set to Direct mode */
- reg = advk_readl(pcie, CTRL_CONFIG_REG);
- reg &= ~(CTRL_MODE_MASK << CTRL_MODE_SHIFT);
-@@ -288,23 +389,12 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
- PCIE_CORE_CTRL2_TD_ENABLE;
- advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG);
-
-- /* Set GEN2 */
-- reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
-- reg &= ~PCIE_GEN_SEL_MSK;
-- reg |= SPEED_GEN_2;
-- advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
--
- /* Set lane X1 */
- reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
- reg &= ~LANE_CNT_MSK;
- reg |= LANE_COUNT_1;
- advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
-
-- /* Enable link training */
-- reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
-- reg |= LINK_TRAINING_EN;
-- advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
--
- /* Enable MSI */
- reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
- reg |= PCIE_CORE_CTRL2_MSI_ENABLE;
-@@ -340,22 +430,14 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
-
- /*
- * PERST# signal could have been asserted by pinctrl subsystem before
-- * probe() callback has been called, making the endpoint going into
-+ * probe() callback has been called or issued explicitly by reset gpio
-+ * function advk_pcie_issue_perst(), making the endpoint going into
- * fundamental reset. As required by PCI Express spec a delay for at
- * least 100ms after such a reset before link training is needed.
- */
- msleep(PCI_PM_D3COLD_WAIT);
-
-- /* Start link training */
-- reg = advk_readl(pcie, PCIE_CORE_LINK_CTRL_STAT_REG);
-- reg |= PCIE_CORE_LINK_TRAINING;
-- advk_writel(pcie, reg, PCIE_CORE_LINK_CTRL_STAT_REG);
--
-- advk_pcie_wait_for_link(pcie);
--
-- reg = PCIE_CORE_LINK_L0S_ENTRY |
-- (1 << PCIE_CORE_LINK_WIDTH_SHIFT);
-- advk_writel(pcie, reg, PCIE_CORE_LINK_CTRL_STAT_REG);
-+ advk_pcie_train_link(pcie);
-
- reg = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
- reg |= PCIE_CORE_CMD_MEM_ACCESS_EN |
-@@ -989,6 +1071,28 @@ static int advk_pcie_probe(struct platform_device *pdev)
- }
- pcie->root_bus_nr = bus->start;
-
-+ pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
-+ "reset-gpios", 0,
-+ GPIOD_OUT_LOW,
-+ "pcie1-reset");
-+ ret = PTR_ERR_OR_ZERO(pcie->reset_gpio);
-+ if (ret) {
-+ if (ret == -ENOENT) {
-+ pcie->reset_gpio = NULL;
-+ } else {
-+ if (ret != -EPROBE_DEFER)
-+ dev_err(dev, "Failed to get reset-gpio: %i\n",
-+ ret);
-+ return ret;
-+ }
-+ }
-+
-+ ret = of_pci_get_max_link_speed(dev->of_node);
-+ if (ret <= 0 || ret > 3)
-+ pcie->link_gen = 3;
-+ else
-+ pcie->link_gen = ret;
-+
- advk_pcie_setup_hw(pcie);
-
- advk_sw_pci_bridge_init(pcie);
-diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c
-index bd05221f5a22..ddcb4571a79b 100644
---- a/drivers/pci/controller/pci-v3-semi.c
-+++ b/drivers/pci/controller/pci-v3-semi.c
-@@ -720,7 +720,7 @@ static int v3_pci_probe(struct platform_device *pdev)
- int irq;
- int ret;
-
-- host = pci_alloc_host_bridge(sizeof(*v3));
-+ host = devm_pci_alloc_host_bridge(dev, sizeof(*v3));
- if (!host)
- return -ENOMEM;
-
-diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
-index 6d79d14527a6..2297910bf6e4 100644
---- a/drivers/pci/controller/pcie-brcmstb.c
-+++ b/drivers/pci/controller/pcie-brcmstb.c
-@@ -54,11 +54,11 @@
-
- #define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO 0x400c
- #define PCIE_MEM_WIN0_LO(win) \
-- PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 4)
-+ PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 8)
-
- #define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI 0x4010
- #define PCIE_MEM_WIN0_HI(win) \
-- PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 4)
-+ PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 8)
-
- #define PCIE_MISC_RC_BAR1_CONFIG_LO 0x402c
- #define PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK 0x1f
-@@ -697,6 +697,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
-
- /* Reset the bridge */
- brcm_pcie_bridge_sw_init_set(pcie, 1);
-+ brcm_pcie_perst_set(pcie, 1);
-
- usleep_range(100, 200);
-
-diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
-index 759c6542c5c8..1bae6a4abaae 100644
---- a/drivers/pci/controller/pcie-rcar.c
-+++ b/drivers/pci/controller/pcie-rcar.c
-@@ -333,11 +333,12 @@ static struct pci_ops rcar_pcie_ops = {
- };
-
- static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
-- struct resource *res)
-+ struct resource_entry *window)
- {
- /* Setup PCIe address space mappings for each resource */
- resource_size_t size;
- resource_size_t res_start;
-+ struct resource *res = window->res;
- u32 mask;
-
- rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
-@@ -351,9 +352,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
- rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
-
- if (res->flags & IORESOURCE_IO)
-- res_start = pci_pio_to_address(res->start);
-+ res_start = pci_pio_to_address(res->start) - window->offset;
- else
-- res_start = res->start;
-+ res_start = res->start - window->offset;
-
- rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
- rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
-@@ -382,7 +383,7 @@ static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci)
- switch (resource_type(res)) {
- case IORESOURCE_IO:
- case IORESOURCE_MEM:
-- rcar_pcie_setup_window(i, pci, res);
-+ rcar_pcie_setup_window(i, pci, win);
- i++;
- break;
- case IORESOURCE_BUS:
-diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
-index dac91d60701d..e386d4eac407 100644
---- a/drivers/pci/controller/vmd.c
-+++ b/drivers/pci/controller/vmd.c
-@@ -445,9 +445,11 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
- if (!membar2)
- return -ENOMEM;
- offset[0] = vmd->dev->resource[VMD_MEMBAR1].start -
-- readq(membar2 + MB2_SHADOW_OFFSET);
-+ (readq(membar2 + MB2_SHADOW_OFFSET) &
-+ PCI_BASE_ADDRESS_MEM_MASK);
- offset[1] = vmd->dev->resource[VMD_MEMBAR2].start -
-- readq(membar2 + MB2_SHADOW_OFFSET + 8);
-+ (readq(membar2 + MB2_SHADOW_OFFSET + 8) &
-+ PCI_BASE_ADDRESS_MEM_MASK);
- pci_iounmap(vmd->dev, membar2);
- }
- }
-diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
-index 60330f3e3751..c89a9561439f 100644
---- a/drivers/pci/endpoint/functions/pci-epf-test.c
-+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
-@@ -187,6 +187,9 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test)
- */
- static void pci_epf_test_clean_dma_chan(struct pci_epf_test *epf_test)
- {
-+ if (!epf_test->dma_supported)
-+ return;
-+
- dma_release_channel(epf_test->dma_chan);
- epf_test->dma_chan = NULL;
- }
-diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c
-index 4f4f54bc732e..faa414655f33 100644
---- a/drivers/pci/pci-bridge-emul.c
-+++ b/drivers/pci/pci-bridge-emul.c
-@@ -185,8 +185,8 @@ static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = {
- * RO, the rest is reserved
- */
- .w1c = GENMASK(19, 16),
-- .ro = GENMASK(20, 19),
-- .rsvd = GENMASK(31, 21),
-+ .ro = GENMASK(21, 20),
-+ .rsvd = GENMASK(31, 22),
- },
-
- [PCI_EXP_LNKCAP / 4] = {
-@@ -226,7 +226,7 @@ static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = {
- PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC) << 16,
- .ro = (PCI_EXP_SLTSTA_MRLSS | PCI_EXP_SLTSTA_PDS |
- PCI_EXP_SLTSTA_EIS) << 16,
-- .rsvd = GENMASK(15, 12) | (GENMASK(15, 9) << 16),
-+ .rsvd = GENMASK(15, 13) | (GENMASK(15, 9) << 16),
- },
-
- [PCI_EXP_RTCTL / 4] = {
-diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
-index 6d3234f75692..809f2584e338 100644
---- a/drivers/pci/pci.c
-+++ b/drivers/pci/pci.c
-@@ -4660,7 +4660,8 @@ static int pci_pm_reset(struct pci_dev *dev, int probe)
- * pcie_wait_for_link_delay - Wait until link is active or inactive
- * @pdev: Bridge device
- * @active: waiting for active or inactive?
-- * @delay: Delay to wait after link has become active (in ms)
-+ * @delay: Delay to wait after link has become active (in ms). Specify %0
-+ * for no delay.
- *
- * Use this to wait till link becomes active or inactive.
- */
-@@ -4701,7 +4702,7 @@ static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active,
- msleep(10);
- timeout -= 10;
- }
-- if (active && ret)
-+ if (active && ret && delay)
- msleep(delay);
- else if (ret != active)
- pci_info(pdev, "Data Link Layer Link Active not %s in 1000 msec\n",
-@@ -4822,17 +4823,28 @@ void pci_bridge_wait_for_secondary_bus(struct pci_dev *dev)
- if (!pcie_downstream_port(dev))
- return;
-
-- if (pcie_get_speed_cap(dev) <= PCIE_SPEED_5_0GT) {
-- pci_dbg(dev, "waiting %d ms for downstream link\n", delay);
-- msleep(delay);
-- } else {
-- pci_dbg(dev, "waiting %d ms for downstream link, after activation\n",
-- delay);
-- if (!pcie_wait_for_link_delay(dev, true, delay)) {
-+ /*
-+ * Per PCIe r5.0, sec 6.6.1, for downstream ports that support
-+ * speeds > 5 GT/s, we must wait for link training to complete
-+ * before the mandatory delay.
-+ *
-+ * We can only tell when link training completes via DLL Link
-+ * Active, which is required for downstream ports that support
-+ * speeds > 5 GT/s (sec 7.5.3.6). Unfortunately some common
-+ * devices do not implement Link Active reporting even when it's
-+ * required, so we'll check for that directly instead of checking
-+ * the supported link speed. We assume devices without Link Active
-+ * reporting can train in 100 ms regardless of speed.
-+ */
-+ if (dev->link_active_reporting) {
-+ pci_dbg(dev, "waiting for link to train\n");
-+ if (!pcie_wait_for_link_delay(dev, true, 0)) {
- /* Did not train, no need to wait any further */
- return;
- }
- }
-+ pci_dbg(child, "waiting %d ms to become accessible\n", delay);
-+ msleep(delay);
-
- if (!pci_device_is_present(child)) {
- pci_dbg(child, "waiting additional %d ms to become accessible\n", delay);
-diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
-index 2378ed692534..b17e5ffd31b1 100644
---- a/drivers/pci/pcie/aspm.c
-+++ b/drivers/pci/pcie/aspm.c
-@@ -628,16 +628,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/pcie/ptm.c b/drivers/pci/pcie/ptm.c
-index 9361f3aa26ab..357a454cafa0 100644
---- a/drivers/pci/pcie/ptm.c
-+++ b/drivers/pci/pcie/ptm.c
-@@ -39,10 +39,6 @@ void pci_ptm_init(struct pci_dev *dev)
- if (!pci_is_pcie(dev))
- return;
-
-- pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM);
-- if (!pos)
-- return;
--
- /*
- * Enable PTM only on interior devices (root ports, switch ports,
- * etc.) on the assumption that it causes no link traffic until an
-@@ -52,6 +48,23 @@ void pci_ptm_init(struct pci_dev *dev)
- pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END))
- return;
-
-+ /*
-+ * Switch Downstream Ports are not permitted to have a PTM
-+ * capability; their PTM behavior is controlled by the Upstream
-+ * Port (PCIe r5.0, sec 7.9.16).
-+ */
-+ ups = pci_upstream_bridge(dev);
-+ if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM &&
-+ ups && ups->ptm_enabled) {
-+ dev->ptm_granularity = ups->ptm_granularity;
-+ dev->ptm_enabled = 1;
-+ return;
-+ }
-+
-+ pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM);
-+ if (!pos)
-+ return;
-+
- pci_read_config_dword(dev, pos + PCI_PTM_CAP, &cap);
- local_clock = (cap & PCI_PTM_GRANULARITY_MASK) >> 8;
-
-@@ -61,7 +74,6 @@ void pci_ptm_init(struct pci_dev *dev)
- * the spec recommendation (PCIe r3.1, sec 7.32.3), select the
- * furthest upstream Time Source as the PTM Root.
- */
-- ups = pci_upstream_bridge(dev);
- if (ups && ups->ptm_enabled) {
- ctrl = PCI_PTM_CTRL_ENABLE;
- if (ups->ptm_granularity == 0)
-diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
-index c7e3a8267521..b59a4b0f5f16 100644
---- a/drivers/pci/probe.c
-+++ b/drivers/pci/probe.c
-@@ -909,9 +909,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
- goto free;
-
- err = device_register(&bridge->dev);
-- if (err)
-+ if (err) {
- put_device(&bridge->dev);
--
-+ goto free;
-+ }
- bus->bridge = get_device(&bridge->dev);
- device_enable_async_suspend(bus->bridge);
- pci_set_bus_of_node(bus);
-diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
-index d8ca40a97693..d21fa04fa44d 100644
---- a/drivers/pci/setup-res.c
-+++ b/drivers/pci/setup-res.c
-@@ -439,10 +439,11 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size)
- res->end = res->start + pci_rebar_size_to_bytes(size) - 1;
-
- /* Check if the new config works by trying to assign everything. */
-- ret = pci_reassign_bridge_resources(dev->bus->self, res->flags);
-- if (ret)
-- goto error_resize;
--
-+ if (dev->bus->self) {
-+ ret = pci_reassign_bridge_resources(dev->bus->self, res->flags);
-+ if (ret)
-+ goto error_resize;
-+ }
- return 0;
-
- error_resize:
-diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
-index 1151e99b241c..479de4be99eb 100644
---- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
-+++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
-@@ -35,7 +35,7 @@
- /* L3C has 8-counters */
- #define L3C_NR_COUNTERS 0x8
-
--#define L3C_PERF_CTRL_EN 0x20000
-+#define L3C_PERF_CTRL_EN 0x10000
- #define L3C_EVTYPE_NONE 0xff
-
- /*
-diff --git a/drivers/phy/broadcom/phy-bcm-sr-usb.c b/drivers/phy/broadcom/phy-bcm-sr-usb.c
-index fe6c58910e4c..7c7862b4f41f 100644
---- a/drivers/phy/broadcom/phy-bcm-sr-usb.c
-+++ b/drivers/phy/broadcom/phy-bcm-sr-usb.c
-@@ -16,8 +16,6 @@ enum bcm_usb_phy_version {
- };
-
- enum bcm_usb_phy_reg {
-- PLL_NDIV_FRAC,
-- PLL_NDIV_INT,
- PLL_CTRL,
- PHY_CTRL,
- PHY_PLL_CTRL,
-@@ -31,18 +29,11 @@ static const u8 bcm_usb_combo_phy_ss[] = {
- };
-
- static const u8 bcm_usb_combo_phy_hs[] = {
-- [PLL_NDIV_FRAC] = 0x04,
-- [PLL_NDIV_INT] = 0x08,
- [PLL_CTRL] = 0x0c,
- [PHY_CTRL] = 0x10,
- };
-
--#define HSPLL_NDIV_INT_VAL 0x13
--#define HSPLL_NDIV_FRAC_VAL 0x1005
--
- static const u8 bcm_usb_hs_phy[] = {
-- [PLL_NDIV_FRAC] = 0x0,
-- [PLL_NDIV_INT] = 0x4,
- [PLL_CTRL] = 0x8,
- [PHY_CTRL] = 0xc,
- };
-@@ -52,7 +43,6 @@ enum pll_ctrl_bits {
- SSPLL_SUSPEND_EN,
- PLL_SEQ_START,
- PLL_LOCK,
-- PLL_PDIV,
- };
-
- static const u8 u3pll_ctrl[] = {
-@@ -66,29 +56,17 @@ static const u8 u3pll_ctrl[] = {
- #define HSPLL_PDIV_VAL 0x1
-
- static const u8 u2pll_ctrl[] = {
-- [PLL_PDIV] = 1,
- [PLL_RESETB] = 5,
- [PLL_LOCK] = 6,
- };
-
- enum bcm_usb_phy_ctrl_bits {
- CORERDY,
-- AFE_LDO_PWRDWNB,
-- AFE_PLL_PWRDWNB,
-- AFE_BG_PWRDWNB,
-- PHY_ISO,
- PHY_RESETB,
- PHY_PCTL,
- };
-
- #define PHY_PCTL_MASK 0xffff
--/*
-- * 0x0806 of PCTL_VAL has below bits set
-- * BIT-8 : refclk divider 1
-- * BIT-3:2: device mode; mode is not effect
-- * BIT-1: soft reset active low
-- */
--#define HSPHY_PCTL_VAL 0x0806
- #define SSPHY_PCTL_VAL 0x0006
-
- static const u8 u3phy_ctrl[] = {
-@@ -98,10 +76,6 @@ static const u8 u3phy_ctrl[] = {
-
- static const u8 u2phy_ctrl[] = {
- [CORERDY] = 0,
-- [AFE_LDO_PWRDWNB] = 1,
-- [AFE_PLL_PWRDWNB] = 2,
-- [AFE_BG_PWRDWNB] = 3,
-- [PHY_ISO] = 4,
- [PHY_RESETB] = 5,
- [PHY_PCTL] = 6,
- };
-@@ -186,38 +160,13 @@ static int bcm_usb_hs_phy_init(struct bcm_usb_phy_cfg *phy_cfg)
- int ret = 0;
- void __iomem *regs = phy_cfg->regs;
- const u8 *offset;
-- u32 rd_data;
-
- offset = phy_cfg->offset;
-
-- writel(HSPLL_NDIV_INT_VAL, regs + offset[PLL_NDIV_INT]);
-- writel(HSPLL_NDIV_FRAC_VAL, regs + offset[PLL_NDIV_FRAC]);
--
-- rd_data = readl(regs + offset[PLL_CTRL]);
-- rd_data &= ~(HSPLL_PDIV_MASK << u2pll_ctrl[PLL_PDIV]);
-- rd_data |= (HSPLL_PDIV_VAL << u2pll_ctrl[PLL_PDIV]);
-- writel(rd_data, regs + offset[PLL_CTRL]);
--
-- /* Set Core Ready high */
-- bcm_usb_reg32_setbits(regs + offset[PHY_CTRL],
-- BIT(u2phy_ctrl[CORERDY]));
--
-- /* Maximum timeout for Core Ready done */
-- msleep(30);
--
-+ bcm_usb_reg32_clrbits(regs + offset[PLL_CTRL],
-+ BIT(u2pll_ctrl[PLL_RESETB]));
- bcm_usb_reg32_setbits(regs + offset[PLL_CTRL],
- BIT(u2pll_ctrl[PLL_RESETB]));
-- bcm_usb_reg32_setbits(regs + offset[PHY_CTRL],
-- BIT(u2phy_ctrl[PHY_RESETB]));
--
--
-- rd_data = readl(regs + offset[PHY_CTRL]);
-- rd_data &= ~(PHY_PCTL_MASK << u2phy_ctrl[PHY_PCTL]);
-- rd_data |= (HSPHY_PCTL_VAL << u2phy_ctrl[PHY_PCTL]);
-- writel(rd_data, regs + offset[PHY_CTRL]);
--
-- /* Maximum timeout for PLL reset done */
-- msleep(30);
-
- ret = bcm_usb_pll_lock_check(regs + offset[PLL_CTRL],
- BIT(u2pll_ctrl[PLL_LOCK]));
-diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
-index a5c08e5bd2bf..faed652b73f7 100644
---- a/drivers/phy/cadence/phy-cadence-sierra.c
-+++ b/drivers/phy/cadence/phy-cadence-sierra.c
-@@ -685,10 +685,10 @@ static struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
- static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
- {0xFE0A, SIERRA_DET_STANDEC_A_PREG},
- {0x000F, SIERRA_DET_STANDEC_B_PREG},
-- {0x00A5, SIERRA_DET_STANDEC_C_PREG},
-+ {0x55A5, SIERRA_DET_STANDEC_C_PREG},
- {0x69ad, SIERRA_DET_STANDEC_D_PREG},
- {0x0241, SIERRA_DET_STANDEC_E_PREG},
-- {0x0010, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
-+ {0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
- {0x0014, SIERRA_PSM_A0IN_TMR_PREG},
- {0xCF00, SIERRA_PSM_DIAG_PREG},
- {0x001F, SIERRA_PSC_TX_A0_PREG},
-@@ -696,7 +696,7 @@ static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
- {0x0003, SIERRA_PSC_TX_A2_PREG},
- {0x0003, SIERRA_PSC_TX_A3_PREG},
- {0x0FFF, SIERRA_PSC_RX_A0_PREG},
-- {0x0619, SIERRA_PSC_RX_A1_PREG},
-+ {0x0003, SIERRA_PSC_RX_A1_PREG},
- {0x0003, SIERRA_PSC_RX_A2_PREG},
- {0x0001, SIERRA_PSC_RX_A3_PREG},
- {0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
-@@ -705,19 +705,19 @@ static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
- {0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
- {0x2512, SIERRA_DFE_BIASTRIM_PREG},
- {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
-- {0x873E, SIERRA_CLKPATHCTRL_TMR_PREG},
-- {0x03CF, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
-- {0x01CE, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
-+ {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
-+ {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
-+ {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
- {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
-- {0x033F, SIERRA_RX_CTLE_MAINTENANCE_PREG},
-+ {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
- {0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
- {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
-- {0x8000, SIERRA_CREQ_SPARE_PREG},
-+ {0x0000, SIERRA_CREQ_SPARE_PREG},
- {0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
-- {0x8453, SIERRA_CTLELUT_CTRL_PREG},
-- {0x4110, SIERRA_DFE_ECMP_RATESEL_PREG},
-- {0x4110, SIERRA_DFE_SMP_RATESEL_PREG},
-- {0x0002, SIERRA_DEQ_PHALIGN_CTRL},
-+ {0x8452, SIERRA_CTLELUT_CTRL_PREG},
-+ {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
-+ {0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
-+ {0x0003, SIERRA_DEQ_PHALIGN_CTRL},
- {0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
- {0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
- {0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
-@@ -725,7 +725,7 @@ static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
- {0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
- {0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
- {0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
-- {0x9A8A, SIERRA_DEQ_VGATUNE_CTRL_PREG},
-+ {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
- {0x0014, SIERRA_DEQ_GLUT0},
- {0x0014, SIERRA_DEQ_GLUT1},
- {0x0014, SIERRA_DEQ_GLUT2},
-@@ -772,6 +772,7 @@ static struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
- {0x000F, SIERRA_LFPSFILT_NS_PREG},
- {0x0009, SIERRA_LFPSFILT_RD_PREG},
- {0x0001, SIERRA_LFPSFILT_MP_PREG},
-+ {0x6013, SIERRA_SIGDET_SUPPORT_PREG},
- {0x8013, SIERRA_SDFILT_H2L_A_PREG},
- {0x8009, SIERRA_SDFILT_L2H_PREG},
- {0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
-diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c
-index 7b51045df783..c8e4ff341cef 100644
---- a/drivers/phy/ti/phy-j721e-wiz.c
-+++ b/drivers/phy/ti/phy-j721e-wiz.c
-@@ -794,8 +794,10 @@ static int wiz_probe(struct platform_device *pdev)
- }
-
- base = devm_ioremap(dev, res.start, resource_size(&res));
-- if (!base)
-+ if (!base) {
-+ ret = -ENOMEM;
- goto err_addr_to_resource;
-+ }
-
- regmap = devm_regmap_init_mmio(dev, base, &wiz_regmap_config);
- if (IS_ERR(regmap)) {
-@@ -812,6 +814,7 @@ static int wiz_probe(struct platform_device *pdev)
-
- if (num_lanes > WIZ_MAX_LANES) {
- dev_err(dev, "Cannot support %d lanes\n", num_lanes);
-+ ret = -ENODEV;
- goto err_addr_to_resource;
- }
-
-@@ -897,6 +900,7 @@ static int wiz_probe(struct platform_device *pdev)
- serdes_pdev = of_platform_device_create(child_node, NULL, dev);
- if (!serdes_pdev) {
- dev_WARN(dev, "Unable to create SERDES platform device\n");
-+ ret = -ENOMEM;
- goto err_pdev_create;
- }
- wiz->serdes_pdev = serdes_pdev;
-diff --git a/drivers/pinctrl/bcm/pinctrl-bcm281xx.c b/drivers/pinctrl/bcm/pinctrl-bcm281xx.c
-index f690fc5cd688..71e666178300 100644
---- a/drivers/pinctrl/bcm/pinctrl-bcm281xx.c
-+++ b/drivers/pinctrl/bcm/pinctrl-bcm281xx.c
-@@ -1406,7 +1406,7 @@ static int __init bcm281xx_pinctrl_probe(struct platform_device *pdev)
- pdata->reg_base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(pdata->reg_base)) {
- dev_err(&pdev->dev, "Failed to ioremap MEM resource\n");
-- return -ENODEV;
-+ return PTR_ERR(pdata->reg_base);
- }
-
- /* Initialize the dynamic part of pinctrl_desc */
-diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
-index 9f42036c5fbb..1f81569c7ae3 100644
---- a/drivers/pinctrl/freescale/pinctrl-imx.c
-+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
-@@ -774,16 +774,6 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
- return 0;
- }
-
--/*
-- * imx_free_resources() - free memory used by this driver
-- * @info: info driver instance
-- */
--static void imx_free_resources(struct imx_pinctrl *ipctl)
--{
-- if (ipctl->pctl)
-- pinctrl_unregister(ipctl->pctl);
--}
--
- int imx_pinctrl_probe(struct platform_device *pdev,
- const struct imx_pinctrl_soc_info *info)
- {
-@@ -874,23 +864,18 @@ int imx_pinctrl_probe(struct platform_device *pdev,
- &ipctl->pctl);
- if (ret) {
- dev_err(&pdev->dev, "could not register IMX pinctrl driver\n");
-- goto free;
-+ return ret;
- }
-
- ret = imx_pinctrl_probe_dt(pdev, ipctl);
- if (ret) {
- dev_err(&pdev->dev, "fail to probe dt properties\n");
-- goto free;
-+ return ret;
- }
-
- dev_info(&pdev->dev, "initialized IMX pinctrl driver\n");
-
- return pinctrl_enable(ipctl->pctl);
--
--free:
-- imx_free_resources(ipctl);
--
-- return ret;
- }
-
- static int __maybe_unused imx_pinctrl_suspend(struct device *dev)
-diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
-index c00d0022d311..421f7d1886e5 100644
---- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
-+++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
-@@ -638,7 +638,6 @@ int imx1_pinctrl_core_probe(struct platform_device *pdev,
-
- ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
- if (ret) {
-- pinctrl_unregister(ipctl->pctl);
- dev_err(&pdev->dev, "Failed to populate subdevices\n");
- return ret;
- }
-diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
-index 694912409fd9..54222ccddfb1 100644
---- a/drivers/pinctrl/pinctrl-at91-pio4.c
-+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
-@@ -1019,7 +1019,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
-
- atmel_pioctrl->reg_base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(atmel_pioctrl->reg_base))
-- return -EINVAL;
-+ return PTR_ERR(atmel_pioctrl->reg_base);
-
- atmel_pioctrl->clk = devm_clk_get(dev, NULL);
- if (IS_ERR(atmel_pioctrl->clk)) {
-diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
-index ed8eac6c1494..b1bf46ec207f 100644
---- a/drivers/pinctrl/pinctrl-ocelot.c
-+++ b/drivers/pinctrl/pinctrl-ocelot.c
-@@ -714,11 +714,12 @@ static void ocelot_irq_handler(struct irq_desc *desc)
- struct irq_chip *parent_chip = irq_desc_get_chip(desc);
- struct gpio_chip *chip = irq_desc_get_handler_data(desc);
- struct ocelot_pinctrl *info = gpiochip_get_data(chip);
-+ unsigned int id_reg = OCELOT_GPIO_INTR_IDENT * info->stride;
- unsigned int reg = 0, irq, i;
- unsigned long irqs;
-
- for (i = 0; i < info->stride; i++) {
-- regmap_read(info->map, OCELOT_GPIO_INTR_IDENT + 4 * i, &reg);
-+ regmap_read(info->map, id_reg + 4 * i, &reg);
- if (!reg)
- continue;
-
-@@ -751,21 +752,21 @@ static int ocelot_gpiochip_register(struct platform_device *pdev,
- gc->of_node = info->dev->of_node;
- gc->label = "ocelot-gpio";
-
-- irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
-- if (irq <= 0)
-- return irq;
--
-- girq = &gc->irq;
-- girq->chip = &ocelot_irqchip;
-- girq->parent_handler = ocelot_irq_handler;
-- girq->num_parents = 1;
-- girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents),
-- GFP_KERNEL);
-- if (!girq->parents)
-- return -ENOMEM;
-- girq->parents[0] = irq;
-- girq->default_type = IRQ_TYPE_NONE;
-- girq->handler = handle_edge_irq;
-+ irq = irq_of_parse_and_map(gc->of_node, 0);
-+ if (irq) {
-+ girq = &gc->irq;
-+ girq->chip = &ocelot_irqchip;
-+ girq->parent_handler = ocelot_irq_handler;
-+ girq->num_parents = 1;
-+ girq->parents = devm_kcalloc(&pdev->dev, 1,
-+ sizeof(*girq->parents),
-+ GFP_KERNEL);
-+ if (!girq->parents)
-+ return -ENOMEM;
-+ girq->parents[0] = irq;
-+ girq->default_type = IRQ_TYPE_NONE;
-+ girq->handler = handle_edge_irq;
-+ }
-
- ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
- if (ret)
-diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
-index 098951346339..d7869b636889 100644
---- a/drivers/pinctrl/pinctrl-rockchip.c
-+++ b/drivers/pinctrl/pinctrl-rockchip.c
-@@ -508,8 +508,8 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
- }
-
- map_num += grp->npins;
-- new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
-- GFP_KERNEL);
-+
-+ new_map = kcalloc(map_num, sizeof(*new_map), GFP_KERNEL);
- if (!new_map)
- return -ENOMEM;
-
-@@ -519,7 +519,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
- /* create mux map */
- parent = of_get_parent(np);
- if (!parent) {
-- devm_kfree(pctldev->dev, new_map);
-+ kfree(new_map);
- return -EINVAL;
- }
- new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
-@@ -546,6 +546,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
- static void rockchip_dt_free_map(struct pinctrl_dev *pctldev,
- struct pinctrl_map *map, unsigned num_maps)
- {
-+ kfree(map);
- }
-
- static const struct pinctrl_ops rockchip_pctrl_ops = {
-diff --git a/drivers/pinctrl/pinctrl-rza1.c b/drivers/pinctrl/pinctrl-rza1.c
-index da2d8365c690..ff4a7fb518bb 100644
---- a/drivers/pinctrl/pinctrl-rza1.c
-+++ b/drivers/pinctrl/pinctrl-rza1.c
-@@ -418,7 +418,7 @@ static const struct rza1_bidir_entry rza1l_bidir_entries[RZA1_NPORTS] = {
- };
-
- static const struct rza1_swio_entry rza1l_swio_entries[] = {
-- [0] = { ARRAY_SIZE(rza1h_swio_pins), rza1h_swio_pins },
-+ [0] = { ARRAY_SIZE(rza1l_swio_pins), rza1l_swio_pins },
- };
-
- /* RZ/A1L (r7s72102x) pinmux flags table */
-diff --git a/drivers/pinctrl/qcom/pinctrl-ipq6018.c b/drivers/pinctrl/qcom/pinctrl-ipq6018.c
-index 38c33a778cb8..ec50a3b4bd16 100644
---- a/drivers/pinctrl/qcom/pinctrl-ipq6018.c
-+++ b/drivers/pinctrl/qcom/pinctrl-ipq6018.c
-@@ -367,7 +367,8 @@ static const char * const wci20_groups[] = {
-
- static const char * const qpic_pad_groups[] = {
- "gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio9", "gpio10",
-- "gpio11", "gpio17",
-+ "gpio11", "gpio17", "gpio15", "gpio12", "gpio13", "gpio14", "gpio5",
-+ "gpio6", "gpio7", "gpio8",
- };
-
- static const char * const burn0_groups[] = {
-diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c
-index 1ebcb957c654..63a287d5795f 100644
---- a/drivers/pinctrl/sirf/pinctrl-sirf.c
-+++ b/drivers/pinctrl/sirf/pinctrl-sirf.c
-@@ -794,13 +794,17 @@ static int sirfsoc_gpio_probe(struct device_node *np)
- return -ENODEV;
-
- sgpio = devm_kzalloc(&pdev->dev, sizeof(*sgpio), GFP_KERNEL);
-- if (!sgpio)
-- return -ENOMEM;
-+ if (!sgpio) {
-+ err = -ENOMEM;
-+ goto out_put_device;
-+ }
- spin_lock_init(&sgpio->lock);
-
- regs = of_iomap(np, 0);
-- if (!regs)
-- return -ENOMEM;
-+ if (!regs) {
-+ err = -ENOMEM;
-+ goto out_put_device;
-+ }
-
- sgpio->chip.gc.request = sirfsoc_gpio_request;
- sgpio->chip.gc.free = sirfsoc_gpio_free;
-@@ -824,8 +828,10 @@ static int sirfsoc_gpio_probe(struct device_node *np)
- girq->parents = devm_kcalloc(&pdev->dev, SIRFSOC_GPIO_NO_OF_BANKS,
- sizeof(*girq->parents),
- GFP_KERNEL);
-- if (!girq->parents)
-- return -ENOMEM;
-+ if (!girq->parents) {
-+ err = -ENOMEM;
-+ goto out_put_device;
-+ }
- for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) {
- bank = &sgpio->sgpio_bank[i];
- spin_lock_init(&bank->lock);
-@@ -868,6 +874,8 @@ out_no_range:
- gpiochip_remove(&sgpio->chip.gc);
- out:
- iounmap(regs);
-+out_put_device:
-+ put_device(&pdev->dev);
- return err;
- }
-
-diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
-index f3424fdce341..d37ec0d03237 100644
---- a/drivers/power/supply/Kconfig
-+++ b/drivers/power/supply/Kconfig
-@@ -577,7 +577,7 @@ config CHARGER_BQ24257
- tristate "TI BQ24250/24251/24257 battery charger driver"
- depends on I2C
- depends on GPIOLIB || COMPILE_TEST
-- depends on REGMAP_I2C
-+ select REGMAP_I2C
- help
- Say Y to enable support for the TI BQ24250, BQ24251, and BQ24257 battery
- chargers.
-diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
-index 84a206f42a8e..e7931ffb7151 100644
---- a/drivers/power/supply/lp8788-charger.c
-+++ b/drivers/power/supply/lp8788-charger.c
-@@ -572,27 +572,14 @@ static void lp8788_setup_adc_channel(struct device *dev,
- return;
-
- /* ADC channel for battery voltage */
-- chan = iio_channel_get(dev, pdata->adc_vbatt);
-+ chan = devm_iio_channel_get(dev, pdata->adc_vbatt);
- pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan;
-
- /* ADC channel for battery temperature */
-- chan = iio_channel_get(dev, pdata->adc_batt_temp);
-+ chan = devm_iio_channel_get(dev, pdata->adc_batt_temp);
- pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan;
- }
-
--static void lp8788_release_adc_channel(struct lp8788_charger *pchg)
--{
-- int i;
--
-- for (i = 0; i < LP8788_NUM_CHG_ADC; i++) {
-- if (!pchg->chan[i])
-- continue;
--
-- iio_channel_release(pchg->chan[i]);
-- pchg->chan[i] = NULL;
-- }
--}
--
- static ssize_t lp8788_show_charger_status(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
-@@ -735,7 +722,6 @@ static int lp8788_charger_remove(struct platform_device *pdev)
- flush_work(&pchg->charger_work);
- lp8788_irq_unregister(pdev, pchg);
- lp8788_psy_unregister(pchg);
-- lp8788_release_adc_channel(pchg);
-
- return 0;
- }
-diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c
-index c1d124b8be0c..d102921b3ab2 100644
---- a/drivers/power/supply/smb347-charger.c
-+++ b/drivers/power/supply/smb347-charger.c
-@@ -1138,6 +1138,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/pwm/core.c b/drivers/pwm/core.c
-index 9973c442b455..6b3cbc0490c6 100644
---- a/drivers/pwm/core.c
-+++ b/drivers/pwm/core.c
-@@ -121,7 +121,7 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
- pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
- trace_pwm_get(pwm, &pwm->state);
-
-- if (IS_ENABLED(PWM_DEBUG))
-+ if (IS_ENABLED(CONFIG_PWM_DEBUG))
- pwm->last = pwm->state;
- }
-
-diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
-index c9e57bd109fb..599a0f66a384 100644
---- a/drivers/pwm/pwm-img.c
-+++ b/drivers/pwm/pwm-img.c
-@@ -129,8 +129,10 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
- duty = DIV_ROUND_UP(timebase * duty_ns, period_ns);
-
- ret = pm_runtime_get_sync(chip->dev);
-- if (ret < 0)
-+ if (ret < 0) {
-+ pm_runtime_put_autosuspend(chip->dev);
- return ret;
-+ }
-
- val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);
- val &= ~(PWM_CTRL_CFG_DIV_MASK << PWM_CTRL_CFG_DIV_SHIFT(pwm->hwpwm));
-@@ -331,8 +333,10 @@ static int img_pwm_remove(struct platform_device *pdev)
- int ret;
-
- ret = pm_runtime_get_sync(&pdev->dev);
-- if (ret < 0)
-+ if (ret < 0) {
-+ pm_runtime_put(&pdev->dev);
- return ret;
-+ }
-
- for (i = 0; i < pwm_chip->chip.npwm; i++) {
- val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);
-diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c
-index a6e40d4c485f..732a6f3701e8 100644
---- a/drivers/pwm/pwm-imx27.c
-+++ b/drivers/pwm/pwm-imx27.c
-@@ -150,13 +150,12 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
-
- prescaler = MX3_PWMCR_PRESCALER_GET(val);
- pwm_clk = clk_get_rate(imx->clk_per);
-- pwm_clk = DIV_ROUND_CLOSEST_ULL(pwm_clk, prescaler);
- val = readl(imx->mmio_base + MX3_PWMPR);
- period = val >= MX3_PWMPR_MAX ? MX3_PWMPR_MAX : val;
-
- /* PWMOUT (Hz) = PWMCLK / (PWMPR + 2) */
-- tmp = NSEC_PER_SEC * (u64)(period + 2);
-- state->period = DIV_ROUND_CLOSEST_ULL(tmp, pwm_clk);
-+ tmp = NSEC_PER_SEC * (u64)(period + 2) * prescaler;
-+ state->period = DIV_ROUND_UP_ULL(tmp, pwm_clk);
-
- /*
- * PWMSAR can be read only if PWM is enabled. If the PWM is disabled,
-@@ -167,8 +166,8 @@ static void pwm_imx27_get_state(struct pwm_chip *chip,
- else
- val = imx->duty_cycle;
-
-- tmp = NSEC_PER_SEC * (u64)(val);
-- state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, pwm_clk);
-+ tmp = NSEC_PER_SEC * (u64)(val) * prescaler;
-+ state->duty_cycle = DIV_ROUND_UP_ULL(tmp, pwm_clk);
-
- pwm_imx27_clk_disable_unprepare(imx);
- }
-@@ -220,22 +219,23 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
- struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
- struct pwm_state cstate;
- unsigned long long c;
-+ unsigned long long clkrate;
- int ret;
- u32 cr;
-
- pwm_get_state(pwm, &cstate);
-
-- c = clk_get_rate(imx->clk_per);
-- c *= state->period;
-+ clkrate = clk_get_rate(imx->clk_per);
-+ c = clkrate * state->period;
-
-- do_div(c, 1000000000);
-+ do_div(c, NSEC_PER_SEC);
- period_cycles = c;
-
- prescale = period_cycles / 0x10000 + 1;
-
- period_cycles /= prescale;
-- c = (unsigned long long)period_cycles * state->duty_cycle;
-- do_div(c, state->period);
-+ c = clkrate * state->duty_cycle;
-+ do_div(c, NSEC_PER_SEC * prescale);
- duty_cycles = c;
-
- /*
-diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
-index 2bead57c9cf9..ac13e7b046a6 100644
---- a/drivers/remoteproc/mtk_scp.c
-+++ b/drivers/remoteproc/mtk_scp.c
-@@ -132,8 +132,8 @@ static int scp_ipi_init(struct mtk_scp *scp)
- (struct mtk_share_obj __iomem *)(scp->sram_base + recv_offset);
- scp->send_buf =
- (struct mtk_share_obj __iomem *)(scp->sram_base + send_offset);
-- memset_io(scp->recv_buf, 0, sizeof(scp->recv_buf));
-- memset_io(scp->send_buf, 0, sizeof(scp->send_buf));
-+ memset_io(scp->recv_buf, 0, sizeof(*scp->recv_buf));
-+ memset_io(scp->send_buf, 0, sizeof(*scp->send_buf));
-
- return 0;
- }
-diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
-index 5475d4f808a8..629abcee2c1d 100644
---- a/drivers/remoteproc/qcom_q6v5_mss.c
-+++ b/drivers/remoteproc/qcom_q6v5_mss.c
-@@ -69,13 +69,9 @@
- #define AXI_HALTREQ_REG 0x0
- #define AXI_HALTACK_REG 0x4
- #define AXI_IDLE_REG 0x8
--#define NAV_AXI_HALTREQ_BIT BIT(0)
--#define NAV_AXI_HALTACK_BIT BIT(1)
--#define NAV_AXI_IDLE_BIT BIT(2)
- #define AXI_GATING_VALID_OVERRIDE BIT(0)
-
- #define HALT_ACK_TIMEOUT_US 100000
--#define NAV_HALT_ACK_TIMEOUT_US 200
-
- /* QDSP6SS_RESET */
- #define Q6SS_STOP_CORE BIT(0)
-@@ -143,7 +139,7 @@ struct rproc_hexagon_res {
- int version;
- bool need_mem_protection;
- bool has_alt_reset;
-- bool has_halt_nav;
-+ bool has_spare_reg;
- };
-
- struct q6v5 {
-@@ -154,13 +150,11 @@ struct q6v5 {
- void __iomem *rmb_base;
-
- struct regmap *halt_map;
-- struct regmap *halt_nav_map;
- struct regmap *conn_map;
-
- u32 halt_q6;
- u32 halt_modem;
- u32 halt_nc;
-- u32 halt_nav;
- u32 conn_box;
-
- struct reset_control *mss_restart;
-@@ -206,7 +200,7 @@ struct q6v5 {
- struct qcom_sysmon *sysmon;
- bool need_mem_protection;
- bool has_alt_reset;
-- bool has_halt_nav;
-+ bool has_spare_reg;
- int mpss_perm;
- int mba_perm;
- const char *hexagon_mdt_image;
-@@ -427,21 +421,19 @@ static int q6v5_reset_assert(struct q6v5 *qproc)
- reset_control_assert(qproc->pdc_reset);
- ret = reset_control_reset(qproc->mss_restart);
- reset_control_deassert(qproc->pdc_reset);
-- } else if (qproc->has_halt_nav) {
-+ } else if (qproc->has_spare_reg) {
- /*
- * When the AXI pipeline is being reset with the Q6 modem partly
- * operational there is possibility of AXI valid signal to
- * glitch, leading to spurious transactions and Q6 hangs. A work
- * around is employed by asserting the AXI_GATING_VALID_OVERRIDE
-- * BIT before triggering Q6 MSS reset. Both the HALTREQ and
-- * AXI_GATING_VALID_OVERRIDE are withdrawn post MSS assert
-- * followed by a MSS deassert, while holding the PDC reset.
-+ * BIT before triggering Q6 MSS reset. AXI_GATING_VALID_OVERRIDE
-+ * is withdrawn post MSS assert followed by a MSS deassert,
-+ * while holding the PDC reset.
- */
- reset_control_assert(qproc->pdc_reset);
- regmap_update_bits(qproc->conn_map, qproc->conn_box,
- AXI_GATING_VALID_OVERRIDE, 1);
-- regmap_update_bits(qproc->halt_nav_map, qproc->halt_nav,
-- NAV_AXI_HALTREQ_BIT, 0);
- reset_control_assert(qproc->mss_restart);
- reset_control_deassert(qproc->pdc_reset);
- regmap_update_bits(qproc->conn_map, qproc->conn_box,
-@@ -464,7 +456,7 @@ static int q6v5_reset_deassert(struct q6v5 *qproc)
- ret = reset_control_reset(qproc->mss_restart);
- writel(0, qproc->rmb_base + RMB_MBA_ALT_RESET);
- reset_control_deassert(qproc->pdc_reset);
-- } else if (qproc->has_halt_nav) {
-+ } else if (qproc->has_spare_reg) {
- ret = reset_control_reset(qproc->mss_restart);
- } else {
- ret = reset_control_deassert(qproc->mss_restart);
-@@ -761,32 +753,6 @@ static void q6v5proc_halt_axi_port(struct q6v5 *qproc,
- regmap_write(halt_map, offset + AXI_HALTREQ_REG, 0);
- }
-
--static void q6v5proc_halt_nav_axi_port(struct q6v5 *qproc,
-- struct regmap *halt_map,
-- u32 offset)
--{
-- unsigned int val;
-- int ret;
--
-- /* Check if we're already idle */
-- ret = regmap_read(halt_map, offset, &val);
-- if (!ret && (val & NAV_AXI_IDLE_BIT))
-- return;
--
-- /* Assert halt request */
-- regmap_update_bits(halt_map, offset, NAV_AXI_HALTREQ_BIT,
-- NAV_AXI_HALTREQ_BIT);
--
-- /* Wait for halt ack*/
-- regmap_read_poll_timeout(halt_map, offset, val,
-- (val & NAV_AXI_HALTACK_BIT),
-- 5, NAV_HALT_ACK_TIMEOUT_US);
--
-- ret = regmap_read(halt_map, offset, &val);
-- if (ret || !(val & NAV_AXI_IDLE_BIT))
-- dev_err(qproc->dev, "port failed halt\n");
--}
--
- static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw)
- {
- unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS;
-@@ -951,9 +917,6 @@ static int q6v5_mba_load(struct q6v5 *qproc)
- halt_axi_ports:
- q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6);
- q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem);
-- if (qproc->has_halt_nav)
-- q6v5proc_halt_nav_axi_port(qproc, qproc->halt_nav_map,
-- qproc->halt_nav);
- q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc);
-
- reclaim_mba:
-@@ -1001,9 +964,6 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc)
-
- q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6);
- q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem);
-- if (qproc->has_halt_nav)
-- q6v5proc_halt_nav_axi_port(qproc, qproc->halt_nav_map,
-- qproc->halt_nav);
- q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc);
- if (qproc->version == MSS_MSM8996) {
- /*
-@@ -1156,7 +1116,13 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
- goto release_firmware;
- }
-
-- ptr = qproc->mpss_region + offset;
-+ ptr = ioremap_wc(qproc->mpss_phys + offset, phdr->p_memsz);
-+ if (!ptr) {
-+ dev_err(qproc->dev,
-+ "unable to map memory region: %pa+%zx-%x\n",
-+ &qproc->mpss_phys, offset, phdr->p_memsz);
-+ goto release_firmware;
-+ }
-
- if (phdr->p_filesz && phdr->p_offset < fw->size) {
- /* Firmware is large enough to be non-split */
-@@ -1165,6 +1131,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
- "failed to load segment %d from truncated file %s\n",
- i, fw_name);
- ret = -EINVAL;
-+ iounmap(ptr);
- goto release_firmware;
- }
-
-@@ -1175,6 +1142,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
- ret = request_firmware(&seg_fw, fw_name, qproc->dev);
- if (ret) {
- dev_err(qproc->dev, "failed to load %s\n", fw_name);
-+ iounmap(ptr);
- goto release_firmware;
- }
-
-@@ -1187,6 +1155,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
- memset(ptr + phdr->p_filesz, 0,
- phdr->p_memsz - phdr->p_filesz);
- }
-+ iounmap(ptr);
- size += phdr->p_memsz;
-
- code_length = readl(qproc->rmb_base + RMB_PMI_CODE_LENGTH_REG);
-@@ -1236,7 +1205,8 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc,
- int ret = 0;
- struct q6v5 *qproc = rproc->priv;
- unsigned long mask = BIT((unsigned long)segment->priv);
-- void *ptr = rproc_da_to_va(rproc, segment->da, segment->size);
-+ int offset = segment->da - qproc->mpss_reloc;
-+ void *ptr = NULL;
-
- /* Unlock mba before copying segments */
- if (!qproc->dump_mba_loaded) {
-@@ -1250,10 +1220,15 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc,
- }
- }
-
-- if (!ptr || ret)
-- memset(dest, 0xff, segment->size);
-- else
-+ if (!ret)
-+ ptr = ioremap_wc(qproc->mpss_phys + offset, segment->size);
-+
-+ if (ptr) {
- memcpy(dest, ptr, segment->size);
-+ iounmap(ptr);
-+ } else {
-+ memset(dest, 0xff, segment->size);
-+ }
-
- qproc->dump_segment_mask |= mask;
-
-@@ -1432,36 +1407,12 @@ static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev)
- qproc->halt_modem = args.args[1];
- qproc->halt_nc = args.args[2];
-
-- if (qproc->has_halt_nav) {
-- struct platform_device *nav_pdev;
--
-+ if (qproc->has_spare_reg) {
- ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
-- "qcom,halt-nav-regs",
-+ "qcom,spare-regs",
- 1, 0, &args);
- if (ret < 0) {
-- dev_err(&pdev->dev, "failed to parse halt-nav-regs\n");
-- return -EINVAL;
-- }
--
-- nav_pdev = of_find_device_by_node(args.np);
-- of_node_put(args.np);
-- if (!nav_pdev) {
-- dev_err(&pdev->dev, "failed to get mss clock device\n");
-- return -EPROBE_DEFER;
-- }
--
-- qproc->halt_nav_map = dev_get_regmap(&nav_pdev->dev, NULL);
-- if (!qproc->halt_nav_map) {
-- dev_err(&pdev->dev, "failed to get map from device\n");
-- return -EINVAL;
-- }
-- qproc->halt_nav = args.args[0];
--
-- ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
-- "qcom,halt-nav-regs",
-- 1, 1, &args);
-- if (ret < 0) {
-- dev_err(&pdev->dev, "failed to parse halt-nav-regs\n");
-+ dev_err(&pdev->dev, "failed to parse spare-regs\n");
- return -EINVAL;
- }
-
-@@ -1547,7 +1498,7 @@ static int q6v5_init_reset(struct q6v5 *qproc)
- return PTR_ERR(qproc->mss_restart);
- }
-
-- if (qproc->has_alt_reset || qproc->has_halt_nav) {
-+ if (qproc->has_alt_reset || qproc->has_spare_reg) {
- qproc->pdc_reset = devm_reset_control_get_exclusive(qproc->dev,
- "pdc_reset");
- if (IS_ERR(qproc->pdc_reset)) {
-@@ -1595,12 +1546,6 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc)
-
- qproc->mpss_phys = qproc->mpss_reloc = r.start;
- qproc->mpss_size = resource_size(&r);
-- qproc->mpss_region = devm_ioremap_wc(qproc->dev, qproc->mpss_phys, qproc->mpss_size);
-- if (!qproc->mpss_region) {
-- dev_err(qproc->dev, "unable to map memory region: %pa+%zx\n",
-- &r.start, qproc->mpss_size);
-- return -EBUSY;
-- }
-
- return 0;
- }
-@@ -1679,7 +1624,7 @@ static int q6v5_probe(struct platform_device *pdev)
-
- platform_set_drvdata(pdev, qproc);
-
-- qproc->has_halt_nav = desc->has_halt_nav;
-+ qproc->has_spare_reg = desc->has_spare_reg;
- ret = q6v5_init_mem(qproc, pdev);
- if (ret)
- goto free_rproc;
-@@ -1828,8 +1773,6 @@ static const struct rproc_hexagon_res sc7180_mss = {
- .active_clk_names = (char*[]){
- "mnoc_axi",
- "nav",
-- "mss_nav",
-- "mss_crypto",
- NULL
- },
- .active_pd_names = (char*[]){
-@@ -1844,7 +1787,7 @@ static const struct rproc_hexagon_res sc7180_mss = {
- },
- .need_mem_protection = true,
- .has_alt_reset = false,
-- .has_halt_nav = true,
-+ .has_spare_reg = true,
- .version = MSS_SC7180,
- };
-
-@@ -1879,7 +1822,7 @@ static const struct rproc_hexagon_res sdm845_mss = {
- },
- .need_mem_protection = true,
- .has_alt_reset = true,
-- .has_halt_nav = false,
-+ .has_spare_reg = false,
- .version = MSS_SDM845,
- };
-
-@@ -1906,7 +1849,7 @@ static const struct rproc_hexagon_res msm8998_mss = {
- },
- .need_mem_protection = true,
- .has_alt_reset = false,
-- .has_halt_nav = false,
-+ .has_spare_reg = false,
- .version = MSS_MSM8998,
- };
-
-@@ -1936,7 +1879,7 @@ static const struct rproc_hexagon_res msm8996_mss = {
- },
- .need_mem_protection = true,
- .has_alt_reset = false,
-- .has_halt_nav = false,
-+ .has_spare_reg = false,
- .version = MSS_MSM8996,
- };
-
-@@ -1969,7 +1912,7 @@ static const struct rproc_hexagon_res msm8916_mss = {
- },
- .need_mem_protection = false,
- .has_alt_reset = false,
-- .has_halt_nav = false,
-+ .has_spare_reg = false,
- .version = MSS_MSM8916,
- };
-
-@@ -2010,7 +1953,7 @@ static const struct rproc_hexagon_res msm8974_mss = {
- },
- .need_mem_protection = false,
- .has_alt_reset = false,
-- .has_halt_nav = false,
-+ .has_spare_reg = false,
- .version = MSS_MSM8974,
- };
-
-diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
-index be15aace9b3c..8f79cfd2e467 100644
---- a/drivers/remoteproc/remoteproc_core.c
-+++ b/drivers/remoteproc/remoteproc_core.c
-@@ -2053,6 +2053,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
- rproc->dev.type = &rproc_type;
- rproc->dev.class = &rproc_class;
- rproc->dev.driver_data = rproc;
-+ idr_init(&rproc->notifyids);
-
- /* Assign a unique device index and name */
- rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
-@@ -2078,8 +2079,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
-
- mutex_init(&rproc->lock);
-
-- idr_init(&rproc->notifyids);
--
- INIT_LIST_HEAD(&rproc->carveouts);
- INIT_LIST_HEAD(&rproc->mappings);
- INIT_LIST_HEAD(&rproc->traces);
-diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
-index afce2c0b4bd6..d6802e6191cb 100644
---- a/drivers/rtc/rtc-mc13xxx.c
-+++ b/drivers/rtc/rtc-mc13xxx.c
-@@ -308,8 +308,10 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
- mc13xxx_unlock(mc13xxx);
-
- ret = rtc_register_device(priv->rtc);
-- if (ret)
-+ if (ret) {
-+ mc13xxx_lock(mc13xxx);
- goto err_irq_request;
-+ }
-
- return 0;
-
-diff --git a/drivers/rtc/rtc-rc5t619.c b/drivers/rtc/rtc-rc5t619.c
-index 24e386ecbc7e..dd1a20977478 100644
---- a/drivers/rtc/rtc-rc5t619.c
-+++ b/drivers/rtc/rtc-rc5t619.c
-@@ -356,10 +356,8 @@ static int rc5t619_rtc_probe(struct platform_device *pdev)
- int err;
-
- rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
-- if (IS_ERR(rtc)) {
-- err = PTR_ERR(rtc);
-+ if (!rtc)
- return -ENOMEM;
-- }
-
- rtc->rn5t618 = rn5t618;
-
-diff --git a/drivers/rtc/rtc-rv3028.c b/drivers/rtc/rtc-rv3028.c
-index a0ddc86c975a..ec84db0b3d7a 100644
---- a/drivers/rtc/rtc-rv3028.c
-+++ b/drivers/rtc/rtc-rv3028.c
-@@ -755,6 +755,8 @@ static int rv3028_probe(struct i2c_client *client)
- return -ENOMEM;
-
- rv3028->regmap = devm_regmap_init_i2c(client, &regmap_config);
-+ if (IS_ERR(rv3028->regmap))
-+ return PTR_ERR(rv3028->regmap);
-
- i2c_set_clientdata(client, rv3028);
-
-diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
-index b8453b594679..a2afd7bc100b 100644
---- a/drivers/s390/cio/qdio.h
-+++ b/drivers/s390/cio/qdio.h
-@@ -364,7 +364,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_device(struct qdio_irq *irq_ptr);
-@@ -389,6 +388,7 @@ int qdio_setup_get_ssqd(struct qdio_irq *irq_ptr,
- struct subchannel_id *schid,
- struct qdio_ssqd_desc *data);
- int qdio_setup_irq(struct qdio_irq *irq_ptr, struct qdio_initialize *init_data);
-+void qdio_shutdown_irq(struct qdio_irq *irq);
- void qdio_print_subchannel_info(struct qdio_irq *irq_ptr);
- void qdio_release_memory(struct qdio_irq *irq_ptr);
- int qdio_setup_init(void);
-diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
-index bcc3ab14e72d..80cc811bd2e0 100644
---- a/drivers/s390/cio/qdio_main.c
-+++ b/drivers/s390/cio/qdio_main.c
-@@ -1154,35 +1154,27 @@ int qdio_shutdown(struct ccw_device *cdev, int how)
-
- /* cleanup subchannel */
- spin_lock_irq(get_ccwdev_lock(cdev));
--
-+ qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
- if (how & QDIO_FLAG_CLEANUP_USING_CLEAR)
- rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
- else
- /* default behaviour is halt */
- rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
-+ spin_unlock_irq(get_ccwdev_lock(cdev));
- if (rc) {
- DBF_ERROR("%4x SHUTD ERR", irq_ptr->schid.sch_no);
- DBF_ERROR("rc:%4d", rc);
- goto no_cleanup;
- }
-
-- qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
-- spin_unlock_irq(get_ccwdev_lock(cdev));
- wait_event_interruptible_timeout(cdev->private->wait_q,
- irq_ptr->state == QDIO_IRQ_STATE_INACTIVE ||
- irq_ptr->state == QDIO_IRQ_STATE_ERR,
- 10 * HZ);
-- spin_lock_irq(get_ccwdev_lock(cdev));
-
- no_cleanup:
- qdio_shutdown_thinint(irq_ptr);
--
-- /* restore interrupt handler */
-- if ((void *)cdev->handler == (void *)qdio_int_handler) {
-- cdev->handler = irq_ptr->orig_handler;
-- cdev->private->intparm = 0;
-- }
-- spin_unlock_irq(get_ccwdev_lock(cdev));
-+ qdio_shutdown_irq(irq_ptr);
-
- qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
- mutex_unlock(&irq_ptr->setup_mutex);
-@@ -1352,8 +1344,8 @@ int qdio_establish(struct ccw_device *cdev,
-
- rc = qdio_establish_thinint(irq_ptr);
- if (rc) {
-+ qdio_shutdown_irq(irq_ptr);
- mutex_unlock(&irq_ptr->setup_mutex);
-- qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
- return rc;
- }
-
-@@ -1371,8 +1363,9 @@ int qdio_establish(struct ccw_device *cdev,
- if (rc) {
- DBF_ERROR("%4x est IO ERR", irq_ptr->schid.sch_no);
- DBF_ERROR("rc:%4x", rc);
-+ qdio_shutdown_thinint(irq_ptr);
-+ qdio_shutdown_irq(irq_ptr);
- mutex_unlock(&irq_ptr->setup_mutex);
-- qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
- return rc;
- }
-
-diff --git a/drivers/s390/cio/qdio_setup.c b/drivers/s390/cio/qdio_setup.c
-index 3083edd61f0c..8edfa0982221 100644
---- a/drivers/s390/cio/qdio_setup.c
-+++ b/drivers/s390/cio/qdio_setup.c
-@@ -480,7 +480,6 @@ int qdio_setup_irq(struct qdio_irq *irq_ptr, struct qdio_initialize *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,
-@@ -491,6 +490,12 @@ int qdio_setup_irq(struct qdio_irq *irq_ptr, struct qdio_initialize *init_data)
-
- /* qdr, qib, sls, slsbs, slibs, sbales are filled now */
-
-+ /* set our IRQ handler */
-+ spin_lock_irq(get_ccwdev_lock(cdev));
-+ irq_ptr->orig_handler = cdev->handler;
-+ cdev->handler = qdio_int_handler;
-+ spin_unlock_irq(get_ccwdev_lock(cdev));
-+
- /* get qdio commands */
- ciw = ccw_device_get_ciw(cdev, CIW_TYPE_EQUEUE);
- if (!ciw) {
-@@ -506,12 +511,18 @@ int qdio_setup_irq(struct qdio_irq *irq_ptr, struct qdio_initialize *init_data)
- }
- irq_ptr->aqueue = *ciw;
-
-- /* set new interrupt handler */
-+ return 0;
-+}
-+
-+void qdio_shutdown_irq(struct qdio_irq *irq)
-+{
-+ struct ccw_device *cdev = irq->cdev;
-+
-+ /* restore IRQ handler */
- spin_lock_irq(get_ccwdev_lock(cdev));
-- irq_ptr->orig_handler = cdev->handler;
-- cdev->handler = qdio_int_handler;
-+ cdev->handler = irq->orig_handler;
-+ cdev->private->intparm = 0;
- spin_unlock_irq(get_ccwdev_lock(cdev));
-- return 0;
- }
-
- void qdio_print_subchannel_info(struct qdio_irq *irq_ptr)
-diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
-index ae50373617cd..0faa0ad21732 100644
---- a/drivers/s390/cio/qdio_thinint.c
-+++ b/drivers/s390/cio/qdio_thinint.c
-@@ -227,17 +227,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 ddb52e7ba622..9a912fd0f70b 100644
---- a/drivers/scsi/arm/acornscsi.c
-+++ b/drivers/scsi/arm/acornscsi.c
-@@ -2911,8 +2911,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/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
-index 524cdbcd29aa..ec7d01f6e2d5 100644
---- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
-+++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
-@@ -959,6 +959,7 @@ static int init_act_open(struct cxgbi_sock *csk)
- struct net_device *ndev = cdev->ports[csk->port_id];
- struct cxgbi_hba *chba = cdev->hbas[csk->port_id];
- struct sk_buff *skb = NULL;
-+ int ret;
-
- log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
- "csk 0x%p,%u,0x%lx.\n", csk, csk->state, csk->flags);
-@@ -979,16 +980,16 @@ static int init_act_open(struct cxgbi_sock *csk)
- csk->atid = cxgb3_alloc_atid(t3dev, &t3_client, csk);
- if (csk->atid < 0) {
- pr_err("NO atid available.\n");
-- return -EINVAL;
-+ ret = -EINVAL;
-+ goto put_sock;
- }
- cxgbi_sock_set_flag(csk, CTPF_HAS_ATID);
- cxgbi_sock_get(csk);
-
- skb = alloc_wr(sizeof(struct cpl_act_open_req), 0, GFP_KERNEL);
- if (!skb) {
-- cxgb3_free_atid(t3dev, csk->atid);
-- cxgbi_sock_put(csk);
-- return -ENOMEM;
-+ ret = -ENOMEM;
-+ goto free_atid;
- }
- skb->sk = (struct sock *)csk;
- set_arp_failure_handler(skb, act_open_arp_failure);
-@@ -1010,6 +1011,15 @@ static int init_act_open(struct cxgbi_sock *csk)
- cxgbi_sock_set_state(csk, CTP_ACTIVE_OPEN);
- send_act_open_req(csk, skb, csk->l2t);
- return 0;
-+
-+free_atid:
-+ cxgb3_free_atid(t3dev, csk->atid);
-+put_sock:
-+ cxgbi_sock_put(csk);
-+ l2t_release(t3dev, csk->l2t);
-+ csk->l2t = NULL;
-+
-+ return ret;
- }
-
- cxgb3_cpl_handler_func cxgb3i_cpl_handlers[NUM_CPL_CMDS] = {
-diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
-index 9a6deb21fe4d..11caa4b0d797 100644
---- a/drivers/scsi/hisi_sas/hisi_sas_main.c
-+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
-@@ -898,8 +898,11 @@ void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no)
- struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
- struct device *dev = hisi_hba->dev;
-
-+ dev_dbg(dev, "phy%d OOB ready\n", phy_no);
-+ if (phy->phy_attached)
-+ return;
-+
- if (!timer_pending(&phy->timer)) {
-- dev_dbg(dev, "phy%d OOB ready\n", phy_no);
- phy->timer.expires = jiffies + HISI_SAS_WAIT_PHYUP_TIMEOUT * HZ;
- add_timer(&phy->timer);
- }
-diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
-index 59f0f1030c54..c5711c659b51 100644
---- a/drivers/scsi/ibmvscsi/ibmvscsi.c
-+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
-@@ -415,6 +415,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 e4857b728033..a64abe38db2d 100644
---- a/drivers/scsi/iscsi_boot_sysfs.c
-+++ b/drivers/scsi/iscsi_boot_sysfs.c
-@@ -352,7 +352,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 80d1e661b0d4..35fbcb4d52eb 100644
---- a/drivers/scsi/lpfc/lpfc_els.c
-+++ b/drivers/scsi/lpfc/lpfc_els.c
-@@ -8514,6 +8514,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 663782bb790d..39d233262039 100644
---- a/drivers/scsi/mpt3sas/mpt3sas_base.c
-+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
-@@ -4915,7 +4915,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
- }
-
- 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->scsiio_depth; i++) {
- for (j = ioc->chains_per_prp_buffer;
-diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
-index f3f399fe10c8..0da4e16fb23a 100644
---- a/drivers/scsi/qedf/qedf.h
-+++ b/drivers/scsi/qedf/qedf.h
-@@ -355,6 +355,7 @@ struct qedf_ctx {
- #define QEDF_GRCDUMP_CAPTURE 4
- #define QEDF_IN_RECOVERY 5
- #define QEDF_DBG_STOP_IO 6
-+#define QEDF_PROBING 8
- unsigned long flags; /* Miscellaneous state flags */
- int fipvlan_retries;
- u8 num_queues;
-diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
-index 5b19f5175c5c..3a7d03472922 100644
---- a/drivers/scsi/qedf/qedf_main.c
-+++ b/drivers/scsi/qedf/qedf_main.c
-@@ -3153,7 +3153,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
- {
- int rc = -EINVAL;
- struct fc_lport *lport;
-- struct qedf_ctx *qedf;
-+ struct qedf_ctx *qedf = NULL;
- struct Scsi_Host *host;
- bool is_vf = false;
- struct qed_ll2_params params;
-@@ -3183,6 +3183,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
-
- /* Initialize qedf_ctx */
- qedf = lport_priv(lport);
-+ set_bit(QEDF_PROBING, &qedf->flags);
- qedf->lport = lport;
- qedf->ctlr.lp = lport;
- qedf->pdev = pdev;
-@@ -3206,9 +3207,12 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
- } else {
- /* Init pointers during recovery */
- qedf = pci_get_drvdata(pdev);
-+ set_bit(QEDF_PROBING, &qedf->flags);
- lport = qedf->lport;
- }
-
-+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC, "Probe started.\n");
-+
- host = lport->host;
-
- /* Allocate mempool for qedf_io_work structs */
-@@ -3513,6 +3517,10 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
- else
- fc_fabric_login(lport);
-
-+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC, "Probe done.\n");
-+
-+ clear_bit(QEDF_PROBING, &qedf->flags);
-+
- /* All good */
- return 0;
-
-@@ -3538,6 +3546,11 @@ err2:
- err1:
- scsi_host_put(lport->host);
- err0:
-+ if (qedf) {
-+ QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC, "Probe done.\n");
-+
-+ clear_bit(QEDF_PROBING, &qedf->flags);
-+ }
- return rc;
- }
-
-@@ -3687,11 +3700,25 @@ void qedf_get_protocol_tlv_data(void *dev, void *data)
- {
- struct qedf_ctx *qedf = dev;
- struct qed_mfw_tlv_fcoe *fcoe = data;
-- struct fc_lport *lport = qedf->lport;
-- struct Scsi_Host *host = lport->host;
-- struct fc_host_attrs *fc_host = shost_to_fc_host(host);
-+ struct fc_lport *lport;
-+ struct Scsi_Host *host;
-+ struct fc_host_attrs *fc_host;
- struct fc_host_statistics *hst;
-
-+ if (!qedf) {
-+ QEDF_ERR(NULL, "qedf is null.\n");
-+ return;
-+ }
-+
-+ if (test_bit(QEDF_PROBING, &qedf->flags)) {
-+ QEDF_ERR(&qedf->dbg_ctx, "Function is still probing.\n");
-+ return;
-+ }
-+
-+ lport = qedf->lport;
-+ host = lport->host;
-+ fc_host = shost_to_fc_host(host);
-+
- /* Force a refresh of the fc_host stats including offload stats */
- hst = qedf_fc_get_host_stats(host);
-
-diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
-index 1f4a5fb00a05..366c65b295a5 100644
---- a/drivers/scsi/qedi/qedi_iscsi.c
-+++ b/drivers/scsi/qedi/qedi_iscsi.c
-@@ -1001,7 +1001,8 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep)
- if (qedi_ep->state == EP_STATE_OFLDCONN_START)
- goto ep_exit_recover;
-
-- flush_work(&qedi_ep->offload_work);
-+ if (qedi_ep->state != EP_STATE_OFLDCONN_NONE)
-+ flush_work(&qedi_ep->offload_work);
-
- if (qedi_ep->conn) {
- qedi_conn = qedi_ep->conn;
-@@ -1218,6 +1219,10 @@ static int qedi_set_path(struct Scsi_Host *shost, struct iscsi_path *path_data)
- }
-
- iscsi_cid = (u32)path_data->handle;
-+ if (iscsi_cid >= qedi->max_active_conns) {
-+ ret = -EINVAL;
-+ goto set_path_exit;
-+ }
- qedi_ep = qedi->ep_tbl[iscsi_cid];
- QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
- "iscsi_cid=0x%x, qedi_ep=%p\n", iscsi_cid, qedi_ep);
-diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
-index 1d9a4866f9a7..9179bb4caed8 100644
---- a/drivers/scsi/qla2xxx/qla_os.c
-+++ b/drivers/scsi/qla2xxx/qla_os.c
-@@ -6871,6 +6871,7 @@ qla2x00_do_dpc(void *data)
-
- if (do_reset && !(test_and_set_bit(ABORT_ISP_ACTIVE,
- &base_vha->dpc_flags))) {
-+ base_vha->flags.online = 1;
- ql_dbg(ql_dbg_dpc, base_vha, 0x4007,
- "ISP abort scheduled.\n");
- if (ha->isp_ops->abort_isp(base_vha)) {
-diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
-index 1f0a185b2a95..bf00ae16b487 100644
---- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
-+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
-@@ -949,6 +949,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;
-@@ -1111,6 +1112,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_error.c b/drivers/scsi/scsi_error.c
-index 978be1602f71..927b1e641842 100644
---- a/drivers/scsi/scsi_error.c
-+++ b/drivers/scsi/scsi_error.c
-@@ -1412,6 +1412,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
- sdev_printk(KERN_INFO, sdev,
- "%s: skip START_UNIT, past eh deadline\n",
- current->comm));
-+ scsi_device_put(sdev);
- break;
- }
- stu_scmd = NULL;
-@@ -1478,6 +1479,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
- sdev_printk(KERN_INFO, sdev,
- "%s: skip BDR, past eh deadline\n",
- current->comm));
-+ scsi_device_put(sdev);
- break;
- }
- bdr_scmd = NULL;
-diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
-index 06c260f6cdae..b8b4366f1200 100644
---- a/drivers/scsi/scsi_lib.c
-+++ b/drivers/scsi/scsi_lib.c
-@@ -548,7 +548,7 @@ static void scsi_uninit_cmd(struct scsi_cmnd *cmd)
- }
- }
-
--static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
-+static void scsi_free_sgtables(struct scsi_cmnd *cmd)
- {
- if (cmd->sdb.table.nents)
- sg_free_table_chained(&cmd->sdb.table,
-@@ -560,7 +560,7 @@ static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
-
- static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
- {
-- scsi_mq_free_sgtables(cmd);
-+ scsi_free_sgtables(cmd);
- scsi_uninit_cmd(cmd);
- }
-
-@@ -1059,7 +1059,7 @@ blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
-
- return BLK_STS_OK;
- out_free_sgtables:
-- scsi_mq_free_sgtables(cmd);
-+ scsi_free_sgtables(cmd);
- return ret;
- }
- EXPORT_SYMBOL(scsi_init_io);
-@@ -1190,6 +1190,7 @@ 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;
-@@ -1199,9 +1200,14 @@ static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev,
- cmd->sc_data_direction = DMA_FROM_DEVICE;
-
- if (blk_rq_is_scsi(req))
-- return scsi_setup_scsi_cmnd(sdev, req);
-+ ret = scsi_setup_scsi_cmnd(sdev, req);
- else
-- return scsi_setup_fs_cmnd(sdev, req);
-+ ret = scsi_setup_fs_cmnd(sdev, req);
-+
-+ if (ret != BLK_STS_OK)
-+ scsi_free_sgtables(cmd);
-+
-+ return ret;
- }
-
- static blk_status_t
-@@ -2859,8 +2865,10 @@ scsi_host_unblock(struct Scsi_Host *shost, int new_state)
-
- shost_for_each_device(sdev, shost) {
- ret = scsi_internal_device_unblock(sdev, new_state);
-- if (ret)
-+ if (ret) {
-+ scsi_device_put(sdev);
- break;
-+ }
- }
- return ret;
- }
-diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
-index b2a803c51288..ea6d498fa923 100644
---- a/drivers/scsi/scsi_transport_iscsi.c
-+++ b/drivers/scsi/scsi_transport_iscsi.c
-@@ -1616,6 +1616,12 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
- static struct sock *nls;
- static DEFINE_MUTEX(rx_queue_mutex);
-
-+/*
-+ * conn_mutex protects the {start,bind,stop,destroy}_conn from racing
-+ * against the kernel stop_connection recovery mechanism
-+ */
-+static DEFINE_MUTEX(conn_mutex);
-+
- static LIST_HEAD(sesslist);
- static LIST_HEAD(sessdestroylist);
- static DEFINE_SPINLOCK(sesslock);
-@@ -2445,6 +2451,32 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
- }
- EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
-
-+/*
-+ * This can be called without the rx_queue_mutex, if invoked by the kernel
-+ * stop work. But, in that case, it is guaranteed not to race with
-+ * iscsi_destroy by conn_mutex.
-+ */
-+static void iscsi_if_stop_conn(struct iscsi_cls_conn *conn, int flag)
-+{
-+ /*
-+ * It is important that this path doesn't rely on
-+ * rx_queue_mutex, otherwise, a thread doing allocation on a
-+ * start_session/start_connection could sleep waiting on a
-+ * writeback to a failed iscsi device, that cannot be recovered
-+ * because the lock is held. If we don't hold it here, the
-+ * kernel stop_conn_work_fn has a chance to stop the broken
-+ * session and resolve the allocation.
-+ *
-+ * Still, the user invoked .stop_conn() needs to be serialized
-+ * with stop_conn_work_fn by a private mutex. Not pretty, but
-+ * it works.
-+ */
-+ mutex_lock(&conn_mutex);
-+ conn->transport->stop_conn(conn, flag);
-+ mutex_unlock(&conn_mutex);
-+
-+}
-+
- static void stop_conn_work_fn(struct work_struct *work)
- {
- struct iscsi_cls_conn *conn, *tmp;
-@@ -2463,30 +2495,17 @@ static void stop_conn_work_fn(struct work_struct *work)
- uint32_t sid = iscsi_conn_get_sid(conn);
- struct iscsi_cls_session *session;
-
-- mutex_lock(&rx_queue_mutex);
--
- session = iscsi_session_lookup(sid);
- if (session) {
- if (system_state != SYSTEM_RUNNING) {
- session->recovery_tmo = 0;
-- conn->transport->stop_conn(conn,
-- STOP_CONN_TERM);
-+ iscsi_if_stop_conn(conn, STOP_CONN_TERM);
- } else {
-- conn->transport->stop_conn(conn,
-- STOP_CONN_RECOVER);
-+ iscsi_if_stop_conn(conn, STOP_CONN_RECOVER);
- }
- }
-
- list_del_init(&conn->conn_list_err);
--
-- mutex_unlock(&rx_queue_mutex);
--
-- /* we don't want to hold rx_queue_mutex for too long,
-- * for instance if many conns failed at the same time,
-- * since this stall other iscsi maintenance operations.
-- * Give other users a chance to proceed.
-- */
-- cond_resched();
- }
- }
-
-@@ -2846,8 +2865,11 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev
- spin_unlock_irqrestore(&connlock, flags);
-
- ISCSI_DBG_TRANS_CONN(conn, "Destroying transport conn\n");
-+
-+ mutex_lock(&conn_mutex);
- if (transport->destroy_conn)
- transport->destroy_conn(conn);
-+ mutex_unlock(&conn_mutex);
-
- return 0;
- }
-@@ -3689,9 +3711,12 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
- break;
- }
-
-+ mutex_lock(&conn_mutex);
- ev->r.retcode = transport->bind_conn(session, conn,
- ev->u.b_conn.transport_eph,
- ev->u.b_conn.is_leading);
-+ mutex_unlock(&conn_mutex);
-+
- if (ev->r.retcode || !transport->ep_connect)
- break;
-
-@@ -3713,9 +3738,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
- case ISCSI_UEVENT_START_CONN:
- conn = iscsi_conn_lookup(ev->u.start_conn.sid, ev->u.start_conn.cid);
- if (conn) {
-+ mutex_lock(&conn_mutex);
- ev->r.retcode = transport->start_conn(conn);
- if (!ev->r.retcode)
- conn->state = ISCSI_CONN_UP;
-+ mutex_unlock(&conn_mutex);
- }
- else
- err = -EINVAL;
-@@ -3723,17 +3750,20 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
- case ISCSI_UEVENT_STOP_CONN:
- conn = iscsi_conn_lookup(ev->u.stop_conn.sid, ev->u.stop_conn.cid);
- if (conn)
-- transport->stop_conn(conn, ev->u.stop_conn.flag);
-+ iscsi_if_stop_conn(conn, ev->u.stop_conn.flag);
- else
- err = -EINVAL;
- break;
- case ISCSI_UEVENT_SEND_PDU:
- conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid);
-- if (conn)
-+ if (conn) {
-+ mutex_lock(&conn_mutex);
- ev->r.retcode = transport->send_pdu(conn,
- (struct iscsi_hdr*)((char*)ev + sizeof(*ev)),
- (char*)ev + sizeof(*ev) + ev->u.send_pdu.hdr_size,
- ev->u.send_pdu.data_size);
-+ mutex_unlock(&conn_mutex);
-+ }
- else
- err = -EINVAL;
- break;
-diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
-index d2fe3fa470f9..1e13c6a0f0ca 100644
---- a/drivers/scsi/sr.c
-+++ b/drivers/scsi/sr.c
-@@ -797,7 +797,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
-@@ -815,8 +815,13 @@ 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);
-+ mutex_destroy(&cd->lock);
- fail_free:
- kfree(cd);
- fail:
-diff --git a/drivers/scsi/ufs/ti-j721e-ufs.c b/drivers/scsi/ufs/ti-j721e-ufs.c
-index 5216d228cdd9..46bb905b4d6a 100644
---- a/drivers/scsi/ufs/ti-j721e-ufs.c
-+++ b/drivers/scsi/ufs/ti-j721e-ufs.c
-@@ -32,14 +32,14 @@ static int ti_j721e_ufs_probe(struct platform_device *pdev)
- ret = pm_runtime_get_sync(dev);
- if (ret < 0) {
- pm_runtime_put_noidle(dev);
-- return ret;
-+ goto disable_pm;
- }
-
- /* Select MPHY refclk frequency */
- clk = devm_clk_get(dev, NULL);
- if (IS_ERR(clk)) {
- dev_err(dev, "Cannot claim MPHY clock.\n");
-- return PTR_ERR(clk);
-+ goto clk_err;
- }
- clk_rate = clk_get_rate(clk);
- if (clk_rate == 26000000)
-@@ -54,16 +54,23 @@ static int ti_j721e_ufs_probe(struct platform_device *pdev)
- dev);
- if (ret) {
- dev_err(dev, "failed to populate child nodes %d\n", ret);
-- pm_runtime_put_sync(dev);
-+ goto clk_err;
- }
-
- return ret;
-+
-+clk_err:
-+ pm_runtime_put_sync(dev);
-+disable_pm:
-+ pm_runtime_disable(dev);
-+ return ret;
- }
-
- static int ti_j721e_ufs_remove(struct platform_device *pdev)
- {
- of_platform_depopulate(&pdev->dev);
- pm_runtime_put_sync(&pdev->dev);
-+ pm_runtime_disable(&pdev->dev);
-
- return 0;
- }
-diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
-index 19aa5c44e0da..f938867301a0 100644
---- a/drivers/scsi/ufs/ufs-qcom.c
-+++ b/drivers/scsi/ufs/ufs-qcom.c
-@@ -1658,11 +1658,11 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
-
- /* sleep a bit intermittently as we are dumping too much data */
- ufs_qcom_print_hw_debug_reg_all(hba, NULL, ufs_qcom_dump_regs_wrapper);
-- usleep_range(1000, 1100);
-+ udelay(1000);
- ufs_qcom_testbus_read(hba);
-- usleep_range(1000, 1100);
-+ udelay(1000);
- ufs_qcom_print_unipro_testbus(hba);
-- usleep_range(1000, 1100);
-+ udelay(1000);
- }
-
- /**
-diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
-index 53dd87628cbe..516a7f573942 100644
---- a/drivers/scsi/ufs/ufs_bsg.c
-+++ b/drivers/scsi/ufs/ufs_bsg.c
-@@ -106,8 +106,10 @@ static int ufs_bsg_request(struct bsg_job *job)
- desc_op = bsg_request->upiu_req.qr.opcode;
- ret = ufs_bsg_alloc_desc_buffer(hba, job, &desc_buff,
- &desc_len, desc_op);
-- if (ret)
-+ if (ret) {
-+ pm_runtime_put_sync(hba->dev);
- goto out;
-+ }
-
- /* fall through */
- case UPIU_TRANSACTION_NOP_OUT:
-diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
-index 698e8d20b4ba..52740b60d786 100644
---- a/drivers/scsi/ufs/ufshcd.c
-+++ b/drivers/scsi/ufs/ufshcd.c
-@@ -5098,7 +5098,6 @@ static int ufshcd_bkops_ctrl(struct ufs_hba *hba,
- err = ufshcd_enable_auto_bkops(hba);
- else
- err = ufshcd_disable_auto_bkops(hba);
-- hba->urgent_bkops_lvl = curr_status;
- out:
- return err;
- }
-diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
-index fc2575fef51b..7426b5884218 100644
---- a/drivers/slimbus/qcom-ngd-ctrl.c
-+++ b/drivers/slimbus/qcom-ngd-ctrl.c
-@@ -1361,7 +1361,6 @@ static int of_qcom_slim_ngd_register(struct device *parent,
- ngd->pdev->driver_override = QCOM_SLIM_NGD_DRV_NAME;
- ngd->pdev->dev.of_node = node;
- ctrl->ngd = ngd;
-- platform_set_drvdata(ngd->pdev, ctrl);
-
- platform_device_add(ngd->pdev);
- ngd->base = ctrl->base + ngd->id * data->offset +
-@@ -1376,12 +1375,13 @@ static int of_qcom_slim_ngd_register(struct device *parent,
-
- static int qcom_slim_ngd_probe(struct platform_device *pdev)
- {
-- struct qcom_slim_ngd_ctrl *ctrl = platform_get_drvdata(pdev);
- struct device *dev = &pdev->dev;
-+ struct qcom_slim_ngd_ctrl *ctrl = dev_get_drvdata(dev->parent);
- int ret;
-
- ctrl->ctrl.dev = dev;
-
-+ platform_set_drvdata(pdev, ctrl);
- pm_runtime_use_autosuspend(dev);
- pm_runtime_set_autosuspend_delay(dev, QCOM_SLIM_NGD_AUTOSUSPEND);
- pm_runtime_set_suspended(dev);
-diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
-index aace57fae7f8..4bacdb187eab 100644
---- a/drivers/soundwire/slave.c
-+++ b/drivers/soundwire/slave.c
-@@ -68,6 +68,8 @@ static int sdw_slave_add(struct sdw_bus *bus,
- list_del(&slave->node);
- mutex_unlock(&bus->bus_lock);
- put_device(&slave->dev);
-+
-+ return ret;
- }
- sdw_slave_debugfs_init(slave);
-
-diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
-index 5f0e089573a2..af26bc9f184a 100644
---- a/drivers/staging/gasket/gasket_sysfs.c
-+++ b/drivers/staging/gasket/gasket_sysfs.c
-@@ -339,6 +339,7 @@ void gasket_sysfs_put_attr(struct device *device,
-
- dev_err(device, "Unable to put unknown attribute: %s\n",
- attr->attr.attr.name);
-+ put_mapping(mapping);
- }
- EXPORT_SYMBOL(gasket_sysfs_put_attr);
-
-@@ -372,6 +373,7 @@ ssize_t gasket_sysfs_register_store(struct device *device,
- gasket_dev = mapping->gasket_dev;
- if (!gasket_dev) {
- dev_err(device, "Device driver may have been removed\n");
-+ put_mapping(mapping);
- return 0;
- }
-
-diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
-index d6ba25f21d80..d2672b65c3f4 100644
---- a/drivers/staging/greybus/light.c
-+++ b/drivers/staging/greybus/light.c
-@@ -1026,7 +1026,8 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
-
- light->channels_count = conf.channel_count;
- light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
--
-+ if (!light->name)
-+ return -ENOMEM;
- light->channels = kcalloc(light->channels_count,
- sizeof(struct gb_channel), GFP_KERNEL);
- if (!light->channels)
-diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi
-index 9e5cf68731bb..82aa93634eda 100644
---- a/drivers/staging/mt7621-dts/mt7621.dtsi
-+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
-@@ -523,11 +523,10 @@
- 0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */
- >;
-
-- #interrupt-cells = <1>;
-- interrupt-map-mask = <0xF0000 0 0 1>;
-- interrupt-map = <0x10000 0 0 1 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>,
-- <0x20000 0 0 1 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>,
-- <0x30000 0 0 1 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
-+ interrupt-parent = <&gic>;
-+ interrupts = <GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH
-+ GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH
-+ GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
-
- status = "disabled";
-
-diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c
-index b9d460a9c041..36207243a71b 100644
---- a/drivers/staging/mt7621-pci/pci-mt7621.c
-+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
-@@ -97,6 +97,7 @@
- * @pcie_rst: pointer to port reset control
- * @gpio_rst: gpio reset
- * @slot: port slot
-+ * @irq: GIC irq
- * @enabled: indicates if port is enabled
- */
- struct mt7621_pcie_port {
-@@ -107,6 +108,7 @@ struct mt7621_pcie_port {
- struct reset_control *pcie_rst;
- struct gpio_desc *gpio_rst;
- u32 slot;
-+ int irq;
- bool enabled;
- };
-
-@@ -120,6 +122,7 @@ struct mt7621_pcie_port {
- * @dev: Pointer to PCIe device
- * @io_map_base: virtual memory base address for io
- * @ports: pointer to PCIe port information
-+ * @irq_map: irq mapping info according pcie link status
- * @resets_inverted: depends on chip revision
- * reset lines are inverted.
- */
-@@ -135,6 +138,7 @@ struct mt7621_pcie {
- } offset;
- unsigned long io_map_base;
- struct list_head ports;
-+ int irq_map[PCIE_P2P_MAX];
- bool resets_inverted;
- };
-
-@@ -279,6 +283,16 @@ static void setup_cm_memory_region(struct mt7621_pcie *pcie)
- }
- }
-
-+static int mt7621_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
-+{
-+ struct mt7621_pcie *pcie = pdev->bus->sysdata;
-+ struct device *dev = pcie->dev;
-+ int irq = pcie->irq_map[slot];
-+
-+ dev_info(dev, "bus=%d slot=%d irq=%d\n", pdev->bus->number, slot, irq);
-+ return irq;
-+}
-+
- static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie)
- {
- struct device *dev = pcie->dev;
-@@ -330,6 +344,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
- {
- struct mt7621_pcie_port *port;
- struct device *dev = pcie->dev;
-+ struct platform_device *pdev = to_platform_device(dev);
- struct device_node *pnode = dev->of_node;
- struct resource regs;
- char name[10];
-@@ -371,6 +386,12 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
- port->slot = slot;
- port->pcie = pcie;
-
-+ port->irq = platform_get_irq(pdev, slot);
-+ if (port->irq < 0) {
-+ dev_err(dev, "Failed to get IRQ for PCIe%d\n", slot);
-+ return -ENXIO;
-+ }
-+
- INIT_LIST_HEAD(&port->list);
- list_add_tail(&port->list, &pcie->ports);
-
-@@ -585,13 +606,15 @@ static int mt7621_pcie_init_virtual_bridges(struct mt7621_pcie *pcie)
- {
- u32 pcie_link_status = 0;
- u32 n;
-- int i;
-+ int i = 0;
- u32 p2p_br_devnum[PCIE_P2P_MAX];
-+ int irqs[PCIE_P2P_MAX];
- struct mt7621_pcie_port *port;
-
- list_for_each_entry(port, &pcie->ports, list) {
- u32 slot = port->slot;
-
-+ irqs[i++] = port->irq;
- if (port->enabled)
- pcie_link_status |= BIT(slot);
- }
-@@ -614,6 +637,15 @@ static int mt7621_pcie_init_virtual_bridges(struct mt7621_pcie *pcie)
- (p2p_br_devnum[1] << PCIE_P2P_BR_DEVNUM1_SHIFT) |
- (p2p_br_devnum[2] << PCIE_P2P_BR_DEVNUM2_SHIFT));
-
-+ /* Assign IRQs */
-+ n = 0;
-+ for (i = 0; i < PCIE_P2P_MAX; i++)
-+ if (pcie_link_status & BIT(i))
-+ pcie->irq_map[n++] = irqs[i];
-+
-+ for (i = n; i < PCIE_P2P_MAX; i++)
-+ pcie->irq_map[i] = -1;
-+
- return 0;
- }
-
-@@ -638,7 +670,7 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host,
- host->busnr = pcie->busn.start;
- host->dev.parent = pcie->dev;
- host->ops = &mt7621_pci_ops;
-- host->map_irq = of_irq_parse_and_map_pci;
-+ host->map_irq = mt7621_map_irq;
- host->swizzle_irq = pci_common_swizzle;
- host->sysdata = pcie;
-
-diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
-index 59568d18ce23..5b72aa81d94c 100644
---- a/drivers/staging/sm750fb/sm750.c
-+++ b/drivers/staging/sm750fb/sm750.c
-@@ -898,6 +898,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/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c
-index dedc3ff58d3e..c2e4bd1e3b0a 100644
---- a/drivers/staging/wfx/bus_sdio.c
-+++ b/drivers/staging/wfx/bus_sdio.c
-@@ -156,7 +156,13 @@ static const struct hwbus_ops wfx_sdio_hwbus_ops = {
- .align_size = wfx_sdio_align_size,
- };
-
--static const struct of_device_id wfx_sdio_of_match[];
-+static const struct of_device_id wfx_sdio_of_match[] = {
-+ { .compatible = "silabs,wfx-sdio" },
-+ { .compatible = "silabs,wf200" },
-+ { },
-+};
-+MODULE_DEVICE_TABLE(of, wfx_sdio_of_match);
-+
- static int wfx_sdio_probe(struct sdio_func *func,
- const struct sdio_device_id *id)
- {
-@@ -248,15 +254,6 @@ static const struct sdio_device_id wfx_sdio_ids[] = {
- };
- MODULE_DEVICE_TABLE(sdio, wfx_sdio_ids);
-
--#ifdef CONFIG_OF
--static const struct of_device_id wfx_sdio_of_match[] = {
-- { .compatible = "silabs,wfx-sdio" },
-- { .compatible = "silabs,wf200" },
-- { },
--};
--MODULE_DEVICE_TABLE(of, wfx_sdio_of_match);
--#endif
--
- struct sdio_driver wfx_sdio_driver = {
- .name = "wfx-sdio",
- .id_table = wfx_sdio_ids,
-@@ -264,6 +261,6 @@ struct sdio_driver wfx_sdio_driver = {
- .remove = wfx_sdio_remove,
- .drv = {
- .owner = THIS_MODULE,
-- .of_match_table = of_match_ptr(wfx_sdio_of_match),
-+ .of_match_table = wfx_sdio_of_match,
- }
- };
-diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c
-index 1164aba118a1..a73b5bbb578e 100644
---- a/drivers/staging/wfx/debug.c
-+++ b/drivers/staging/wfx/debug.c
-@@ -142,7 +142,7 @@ static int wfx_rx_stats_show(struct seq_file *seq, void *v)
- mutex_lock(&wdev->rx_stats_lock);
- seq_printf(seq, "Timestamp: %dus\n", st->date);
- seq_printf(seq, "Low power clock: frequency %uHz, external %s\n",
-- st->pwr_clk_freq,
-+ le32_to_cpu(st->pwr_clk_freq),
- st->is_ext_pwr_clk ? "yes" : "no");
- seq_printf(seq,
- "Num. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n",
-@@ -152,9 +152,12 @@ static int wfx_rx_stats_show(struct seq_file *seq, void *v)
- for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
- if (channel_names[i])
- seq_printf(seq, "%5s %8d %8d %8d %8d %8d\n",
-- channel_names[i], st->nb_rx_by_rate[i],
-- st->per[i], st->rssi[i] / 100,
-- st->snr[i] / 100, st->cfo[i]);
-+ channel_names[i],
-+ le32_to_cpu(st->nb_rx_by_rate[i]),
-+ le16_to_cpu(st->per[i]),
-+ (s16)le16_to_cpu(st->rssi[i]) / 100,
-+ (s16)le16_to_cpu(st->snr[i]) / 100,
-+ (s16)le16_to_cpu(st->cfo[i]));
- }
- mutex_unlock(&wdev->rx_stats_lock);
-
-diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c
-index 77bca43aca42..20b3045d7667 100644
---- a/drivers/staging/wfx/hif_tx.c
-+++ b/drivers/staging/wfx/hif_tx.c
-@@ -268,7 +268,7 @@ int hif_scan(struct wfx_vif *wvif, struct cfg80211_scan_request *req,
- tmo_chan_bg = le32_to_cpu(body->max_channel_time) * USEC_PER_TU;
- tmo_chan_fg = 512 * USEC_PER_TU + body->probe_delay;
- tmo_chan_fg *= body->num_of_probe_requests;
-- tmo = chan_num * max(tmo_chan_bg, tmo_chan_fg);
-+ tmo = chan_num * max(tmo_chan_bg, tmo_chan_fg) + 512 * USEC_PER_TU;
-
- wfx_fill_header(hif, wvif->id, HIF_REQ_ID_START_SCAN, buf_len);
- ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false);
-diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
-index 39d9127ce4b9..8ae23681e29b 100644
---- a/drivers/staging/wfx/queue.c
-+++ b/drivers/staging/wfx/queue.c
-@@ -35,6 +35,7 @@ void wfx_tx_flush(struct wfx_dev *wdev)
- if (wdev->chip_frozen)
- return;
-
-+ wfx_tx_lock(wdev);
- mutex_lock(&wdev->hif_cmd.lock);
- ret = wait_event_timeout(wdev->hif.tx_buffers_empty,
- !wdev->hif.tx_buffers_used,
-@@ -47,6 +48,7 @@ void wfx_tx_flush(struct wfx_dev *wdev)
- wdev->chip_frozen = 1;
- }
- mutex_unlock(&wdev->hif_cmd.lock);
-+ wfx_tx_unlock(wdev);
- }
-
- void wfx_tx_lock_flush(struct wfx_dev *wdev)
-diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
-index 9d430346a58b..b4cd7cb1ce56 100644
---- a/drivers/staging/wfx/sta.c
-+++ b/drivers/staging/wfx/sta.c
-@@ -520,7 +520,9 @@ static void wfx_do_join(struct wfx_vif *wvif)
- ssidie = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
- if (ssidie) {
- ssidlen = ssidie[1];
-- memcpy(ssid, &ssidie[2], ssidie[1]);
-+ if (ssidlen > IEEE80211_MAX_SSID_LEN)
-+ ssidlen = IEEE80211_MAX_SSID_LEN;
-+ memcpy(ssid, &ssidie[2], ssidlen);
- }
- rcu_read_unlock();
-
-@@ -1047,7 +1049,6 @@ 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);
-
-- INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work);
- mutex_unlock(&wdev->conf_mutex);
-
- hif_set_macaddr(wvif, vif->addr);
-diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
-index cf99a8a74a81..ace845f9ed14 100644
---- a/drivers/staging/wfx/sta.h
-+++ b/drivers/staging/wfx/sta.h
-@@ -37,7 +37,7 @@ struct wfx_grp_addr_table {
- struct wfx_sta_priv {
- int link_id;
- int vif_id;
-- u8 buffered[IEEE80211_NUM_TIDS];
-+ int buffered[IEEE80211_NUM_TIDS];
- // Ensure atomicity of "buffered" and calls to ieee80211_sta_set_buffered()
- spinlock_t lock;
- };
-diff --git a/drivers/staging/wilc1000/hif.c b/drivers/staging/wilc1000/hif.c
-index 6c7de2f8d3f2..d025a3093015 100644
---- a/drivers/staging/wilc1000/hif.c
-+++ b/drivers/staging/wilc1000/hif.c
-@@ -11,6 +11,8 @@
-
- #define WILC_FALSE_FRMWR_CHANNEL 100
-
-+#define WILC_SCAN_WID_LIST_SIZE 6
-+
- struct wilc_rcvd_mac_info {
- u8 status;
- };
-@@ -151,7 +153,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
- void *user_arg, struct cfg80211_scan_request *request)
- {
- int result = 0;
-- struct wid wid_list[5];
-+ struct wid wid_list[WILC_SCAN_WID_LIST_SIZE];
- u32 index = 0;
- u32 i, scan_timeout;
- u8 *buffer;
-diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
-index 3305b47fdf53..16d5a4e117a2 100644
---- a/drivers/target/loopback/tcm_loop.c
-+++ b/drivers/target/loopback/tcm_loop.c
-@@ -545,32 +545,15 @@ static int tcm_loop_write_pending(struct se_cmd *se_cmd)
- return 0;
- }
-
--static int tcm_loop_queue_data_in(struct se_cmd *se_cmd)
-+static int tcm_loop_queue_data_or_status(const char *func,
-+ struct se_cmd *se_cmd, u8 scsi_status)
- {
- struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
- struct tcm_loop_cmd, tl_se_cmd);
- struct scsi_cmnd *sc = tl_cmd->sc;
-
- pr_debug("%s() called for scsi_cmnd: %p cdb: 0x%02x\n",
-- __func__, sc, sc->cmnd[0]);
--
-- sc->result = SAM_STAT_GOOD;
-- set_host_byte(sc, DID_OK);
-- if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
-- (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT))
-- scsi_set_resid(sc, se_cmd->residual_count);
-- sc->scsi_done(sc);
-- return 0;
--}
--
--static int tcm_loop_queue_status(struct se_cmd *se_cmd)
--{
-- struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
-- struct tcm_loop_cmd, tl_se_cmd);
-- struct scsi_cmnd *sc = tl_cmd->sc;
--
-- pr_debug("%s() called for scsi_cmnd: %p cdb: 0x%02x\n",
-- __func__, sc, sc->cmnd[0]);
-+ func, sc, sc->cmnd[0]);
-
- if (se_cmd->sense_buffer &&
- ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
-@@ -581,7 +564,7 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)
- sc->result = SAM_STAT_CHECK_CONDITION;
- set_driver_byte(sc, DRIVER_SENSE);
- } else
-- sc->result = se_cmd->scsi_status;
-+ sc->result = scsi_status;
-
- set_host_byte(sc, DID_OK);
- if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
-@@ -591,6 +574,17 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)
- return 0;
- }
-
-+static int tcm_loop_queue_data_in(struct se_cmd *se_cmd)
-+{
-+ return tcm_loop_queue_data_or_status(__func__, se_cmd, SAM_STAT_GOOD);
-+}
-+
-+static int tcm_loop_queue_status(struct se_cmd *se_cmd)
-+{
-+ return tcm_loop_queue_data_or_status(__func__,
-+ se_cmd, se_cmd->scsi_status);
-+}
-+
- static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
- {
- struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
-diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
-index f769bb1e3735..b63a1e0c4aa6 100644
---- a/drivers/target/target_core_user.c
-+++ b/drivers/target/target_core_user.c
-@@ -882,41 +882,24 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd *tcmu_cmd,
- return command_size;
- }
-
--static int tcmu_setup_cmd_timer(struct tcmu_cmd *tcmu_cmd, unsigned int tmo,
-- struct timer_list *timer)
-+static void tcmu_setup_cmd_timer(struct tcmu_cmd *tcmu_cmd, unsigned int tmo,
-+ struct timer_list *timer)
- {
-- struct tcmu_dev *udev = tcmu_cmd->tcmu_dev;
-- int cmd_id;
--
-- if (tcmu_cmd->cmd_id)
-- goto setup_timer;
--
-- cmd_id = idr_alloc(&udev->commands, tcmu_cmd, 1, USHRT_MAX, GFP_NOWAIT);
-- if (cmd_id < 0) {
-- pr_err("tcmu: Could not allocate cmd id.\n");
-- return cmd_id;
-- }
-- tcmu_cmd->cmd_id = cmd_id;
--
-- pr_debug("allocated cmd %u for dev %s tmo %lu\n", tcmu_cmd->cmd_id,
-- udev->name, tmo / MSEC_PER_SEC);
--
--setup_timer:
- if (!tmo)
-- return 0;
-+ return;
-
- tcmu_cmd->deadline = round_jiffies_up(jiffies + msecs_to_jiffies(tmo));
- if (!timer_pending(timer))
- mod_timer(timer, tcmu_cmd->deadline);
-
-- return 0;
-+ pr_debug("Timeout set up for cmd %p, dev = %s, tmo = %lu\n", tcmu_cmd,
-+ tcmu_cmd->tcmu_dev->name, tmo / MSEC_PER_SEC);
- }
-
- static int add_to_qfull_queue(struct tcmu_cmd *tcmu_cmd)
- {
- struct tcmu_dev *udev = tcmu_cmd->tcmu_dev;
- unsigned int tmo;
-- int ret;
-
- /*
- * For backwards compat if qfull_time_out is not set use
-@@ -931,13 +914,11 @@ static int add_to_qfull_queue(struct tcmu_cmd *tcmu_cmd)
- else
- tmo = TCMU_TIME_OUT;
-
-- ret = tcmu_setup_cmd_timer(tcmu_cmd, tmo, &udev->qfull_timer);
-- if (ret)
-- return ret;
-+ tcmu_setup_cmd_timer(tcmu_cmd, tmo, &udev->qfull_timer);
-
- list_add_tail(&tcmu_cmd->queue_entry, &udev->qfull_queue);
-- pr_debug("adding cmd %u on dev %s to ring space wait queue\n",
-- tcmu_cmd->cmd_id, udev->name);
-+ pr_debug("adding cmd %p on dev %s to ring space wait queue\n",
-+ tcmu_cmd, udev->name);
- return 0;
- }
-
-@@ -959,7 +940,7 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
- struct tcmu_mailbox *mb;
- struct tcmu_cmd_entry *entry;
- struct iovec *iov;
-- int iov_cnt, ret;
-+ int iov_cnt, cmd_id;
- uint32_t cmd_head;
- uint64_t cdb_off;
- bool copy_to_data_area;
-@@ -1060,14 +1041,21 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
- }
- entry->req.iov_bidi_cnt = iov_cnt;
-
-- ret = tcmu_setup_cmd_timer(tcmu_cmd, udev->cmd_time_out,
-- &udev->cmd_timer);
-- if (ret) {
-- tcmu_cmd_free_data(tcmu_cmd, tcmu_cmd->dbi_cnt);
-+ cmd_id = idr_alloc(&udev->commands, tcmu_cmd, 1, USHRT_MAX, GFP_NOWAIT);
-+ if (cmd_id < 0) {
-+ pr_err("tcmu: Could not allocate cmd id.\n");
-
-+ tcmu_cmd_free_data(tcmu_cmd, tcmu_cmd->dbi_cnt);
- *scsi_err = TCM_OUT_OF_RESOURCES;
- return -1;
- }
-+ tcmu_cmd->cmd_id = cmd_id;
-+
-+ pr_debug("allocated cmd id %u for cmd %p dev %s\n", tcmu_cmd->cmd_id,
-+ tcmu_cmd, udev->name);
-+
-+ tcmu_setup_cmd_timer(tcmu_cmd, udev->cmd_time_out, &udev->cmd_timer);
-+
- entry->hdr.cmd_id = tcmu_cmd->cmd_id;
-
- /*
-@@ -1279,50 +1267,39 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev *udev)
- return handled;
- }
-
--static int tcmu_check_expired_cmd(int id, void *p, void *data)
-+static void tcmu_check_expired_ring_cmd(struct tcmu_cmd *cmd)
- {
-- struct tcmu_cmd *cmd = p;
-- struct tcmu_dev *udev = cmd->tcmu_dev;
-- u8 scsi_status;
- struct se_cmd *se_cmd;
-- bool is_running;
--
-- if (test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags))
-- return 0;
-
- if (!time_after(jiffies, cmd->deadline))
-- return 0;
-+ return;
-
-- is_running = test_bit(TCMU_CMD_BIT_INFLIGHT, &cmd->flags);
-+ set_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags);
-+ list_del_init(&cmd->queue_entry);
- se_cmd = cmd->se_cmd;
-+ cmd->se_cmd = NULL;
-
-- if (is_running) {
-- /*
-- * If cmd_time_out is disabled but qfull is set deadline
-- * will only reflect the qfull timeout. Ignore it.
-- */
-- if (!udev->cmd_time_out)
-- return 0;
-+ pr_debug("Timing out inflight cmd %u on dev %s.\n",
-+ cmd->cmd_id, cmd->tcmu_dev->name);
-
-- set_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags);
-- /*
-- * target_complete_cmd will translate this to LUN COMM FAILURE
-- */
-- scsi_status = SAM_STAT_CHECK_CONDITION;
-- list_del_init(&cmd->queue_entry);
-- cmd->se_cmd = NULL;
-- } else {
-- list_del_init(&cmd->queue_entry);
-- idr_remove(&udev->commands, id);
-- tcmu_free_cmd(cmd);
-- scsi_status = SAM_STAT_TASK_SET_FULL;
-- }
-+ target_complete_cmd(se_cmd, SAM_STAT_CHECK_CONDITION);
-+}
-
-- pr_debug("Timing out cmd %u on dev %s that is %s.\n",
-- id, udev->name, is_running ? "inflight" : "queued");
-+static void tcmu_check_expired_queue_cmd(struct tcmu_cmd *cmd)
-+{
-+ struct se_cmd *se_cmd;
-
-- target_complete_cmd(se_cmd, scsi_status);
-- return 0;
-+ if (!time_after(jiffies, cmd->deadline))
-+ return;
-+
-+ pr_debug("Timing out queued cmd %p on dev %s.\n",
-+ cmd, cmd->tcmu_dev->name);
-+
-+ list_del_init(&cmd->queue_entry);
-+ se_cmd = cmd->se_cmd;
-+ tcmu_free_cmd(cmd);
-+
-+ target_complete_cmd(se_cmd, SAM_STAT_TASK_SET_FULL);
- }
-
- static void tcmu_device_timedout(struct tcmu_dev *udev)
-@@ -1407,16 +1384,15 @@ static struct se_device *tcmu_alloc_device(struct se_hba *hba, const char *name)
- return &udev->se_dev;
- }
-
--static bool run_qfull_queue(struct tcmu_dev *udev, bool fail)
-+static void run_qfull_queue(struct tcmu_dev *udev, bool fail)
- {
- struct tcmu_cmd *tcmu_cmd, *tmp_cmd;
- LIST_HEAD(cmds);
-- bool drained = true;
- sense_reason_t scsi_ret;
- int ret;
-
- if (list_empty(&udev->qfull_queue))
-- return true;
-+ return;
-
- pr_debug("running %s's cmdr queue forcefail %d\n", udev->name, fail);
-
-@@ -1425,11 +1401,10 @@ static bool run_qfull_queue(struct tcmu_dev *udev, bool fail)
- list_for_each_entry_safe(tcmu_cmd, tmp_cmd, &cmds, queue_entry) {
- list_del_init(&tcmu_cmd->queue_entry);
-
-- pr_debug("removing cmd %u on dev %s from queue\n",
-- tcmu_cmd->cmd_id, udev->name);
-+ pr_debug("removing cmd %p on dev %s from queue\n",
-+ tcmu_cmd, udev->name);
-
- if (fail) {
-- idr_remove(&udev->commands, tcmu_cmd->cmd_id);
- /*
- * We were not able to even start the command, so
- * fail with busy to allow a retry in case runner
-@@ -1444,10 +1419,8 @@ static bool run_qfull_queue(struct tcmu_dev *udev, bool fail)
-
- ret = queue_cmd_ring(tcmu_cmd, &scsi_ret);
- if (ret < 0) {
-- pr_debug("cmd %u on dev %s failed with %u\n",
-- tcmu_cmd->cmd_id, udev->name, scsi_ret);
--
-- idr_remove(&udev->commands, tcmu_cmd->cmd_id);
-+ pr_debug("cmd %p on dev %s failed with %u\n",
-+ tcmu_cmd, udev->name, scsi_ret);
- /*
- * Ignore scsi_ret for now. target_complete_cmd
- * drops it.
-@@ -1462,13 +1435,11 @@ static bool run_qfull_queue(struct tcmu_dev *udev, bool fail)
- * the queue
- */
- list_splice_tail(&cmds, &udev->qfull_queue);
-- drained = false;
- break;
- }
- }
-
- tcmu_set_next_deadline(&udev->qfull_queue, &udev->qfull_timer);
-- return drained;
- }
-
- static int tcmu_irqcontrol(struct uio_info *info, s32 irq_on)
-@@ -1652,6 +1623,8 @@ static void tcmu_dev_kref_release(struct kref *kref)
- if (tcmu_check_and_free_pending_cmd(cmd) != 0)
- all_expired = false;
- }
-+ if (!list_empty(&udev->qfull_queue))
-+ all_expired = false;
- idr_destroy(&udev->commands);
- WARN_ON(!all_expired);
-
-@@ -2037,9 +2010,6 @@ static void tcmu_reset_ring(struct tcmu_dev *udev, u8 err_level)
- mutex_lock(&udev->cmdr_lock);
-
- idr_for_each_entry(&udev->commands, cmd, i) {
-- if (!test_bit(TCMU_CMD_BIT_INFLIGHT, &cmd->flags))
-- continue;
--
- pr_debug("removing cmd %u on dev %s from ring (is expired %d)\n",
- cmd->cmd_id, udev->name,
- test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags));
-@@ -2077,6 +2047,8 @@ static void tcmu_reset_ring(struct tcmu_dev *udev, u8 err_level)
-
- del_timer(&udev->cmd_timer);
-
-+ run_qfull_queue(udev, false);
-+
- mutex_unlock(&udev->cmdr_lock);
- }
-
-@@ -2698,6 +2670,7 @@ static void find_free_blocks(void)
- static void check_timedout_devices(void)
- {
- struct tcmu_dev *udev, *tmp_dev;
-+ struct tcmu_cmd *cmd, *tmp_cmd;
- LIST_HEAD(devs);
-
- spin_lock_bh(&timed_out_udevs_lock);
-@@ -2708,9 +2681,24 @@ static void check_timedout_devices(void)
- spin_unlock_bh(&timed_out_udevs_lock);
-
- mutex_lock(&udev->cmdr_lock);
-- idr_for_each(&udev->commands, tcmu_check_expired_cmd, NULL);
-
-- tcmu_set_next_deadline(&udev->inflight_queue, &udev->cmd_timer);
-+ /*
-+ * If cmd_time_out is disabled but qfull is set deadline
-+ * will only reflect the qfull timeout. Ignore it.
-+ */
-+ if (udev->cmd_time_out) {
-+ list_for_each_entry_safe(cmd, tmp_cmd,
-+ &udev->inflight_queue,
-+ queue_entry) {
-+ tcmu_check_expired_ring_cmd(cmd);
-+ }
-+ tcmu_set_next_deadline(&udev->inflight_queue,
-+ &udev->cmd_timer);
-+ }
-+ list_for_each_entry_safe(cmd, tmp_cmd, &udev->qfull_queue,
-+ queue_entry) {
-+ tcmu_check_expired_queue_cmd(cmd);
-+ }
- tcmu_set_next_deadline(&udev->qfull_queue, &udev->qfull_timer);
-
- mutex_unlock(&udev->cmdr_lock);
-diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
-index d3e959d01606..85776db4bf34 100644
---- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
-+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
-@@ -169,7 +169,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
-
- data = ti_bandgap_get_sensor_data(bgp, id);
-
-- if (!data || IS_ERR(data))
-+ if (!IS_ERR_OR_NULL(data))
- data = ti_thermal_build_data(bgp, id);
-
- if (!data)
-@@ -196,7 +196,7 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id)
-
- data = ti_bandgap_get_sensor_data(bgp, id);
-
-- if (data && data->ti_thermal) {
-+ if (!IS_ERR_OR_NULL(data) && data->ti_thermal) {
- if (data->our_zone)
- thermal_zone_device_unregister(data->ti_thermal);
- }
-@@ -262,7 +262,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id)
-
- data = ti_bandgap_get_sensor_data(bgp, id);
-
-- if (data) {
-+ if (!IS_ERR_OR_NULL(data)) {
- cpufreq_cooling_unregister(data->cool_dev);
- if (data->policy)
- cpufreq_cpu_put(data->policy);
-diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
-index cdcc64ea2554..f8e43a6faea9 100644
---- a/drivers/tty/hvc/hvc_console.c
-+++ b/drivers/tty/hvc/hvc_console.c
-@@ -75,6 +75,8 @@ static LIST_HEAD(hvc_structs);
- */
- static DEFINE_MUTEX(hvc_structs_mutex);
-
-+/* 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
-@@ -346,16 +348,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);
-
-@@ -383,6 +393,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 d77ed82a4840..f189579db7c4 100644
---- a/drivers/tty/n_gsm.c
-+++ b/drivers/tty/n_gsm.c
-@@ -673,11 +673,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)
-@@ -699,18 +698,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);
-+ }
- }
- }
-
-@@ -762,7 +766,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);
- }
-
- /**
-@@ -1223,7 +1227,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:
-@@ -2545,7 +2549,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/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
-index f77bf820b7a3..4d83c85a7389 100644
---- a/drivers/tty/serial/8250/8250_port.c
-+++ b/drivers/tty/serial/8250/8250_port.c
-@@ -2615,6 +2615,8 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
- struct ktermios *termios,
- struct ktermios *old)
- {
-+ unsigned int tolerance = port->uartclk / 100;
-+
- /*
- * Ask the core to calculate the divisor for us.
- * Allow 1% tolerance at the upper limit so uart clks marginally
-@@ -2623,7 +2625,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
- */
- return uart_get_baud_rate(port, termios, old,
- port->uartclk / 16 / UART_DIV_MAX,
-- port->uartclk);
-+ (port->uartclk + tolerance) / 16);
- }
-
- void
-diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c
-index 5685ba11480b..e701ab56b0a7 100644
---- a/drivers/usb/cdns3/cdns3-ti.c
-+++ b/drivers/usb/cdns3/cdns3-ti.c
-@@ -138,7 +138,7 @@ static int cdns_ti_probe(struct platform_device *pdev)
- error = pm_runtime_get_sync(dev);
- if (error < 0) {
- dev_err(dev, "pm_runtime_get_sync failed: %d\n", error);
-- goto err_get;
-+ goto err;
- }
-
- /* assert RESET */
-@@ -185,7 +185,6 @@ static int cdns_ti_probe(struct platform_device *pdev)
-
- err:
- pm_runtime_put_sync(data->dev);
--err_get:
- pm_runtime_disable(data->dev);
-
- return error;
-diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
-index 0d8e3f3804a3..084c48c5848f 100644
---- a/drivers/usb/class/usblp.c
-+++ b/drivers/usb/class/usblp.c
-@@ -468,7 +468,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;
- }
-@@ -1375,9 +1376,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/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
-index 876ff31261d5..55f1d14fc414 100644
---- a/drivers/usb/dwc2/core_intr.c
-+++ b/drivers/usb/dwc2/core_intr.c
-@@ -416,10 +416,13 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
- if (ret && (ret != -ENOTSUPP))
- dev_err(hsotg->dev, "exit power_down failed\n");
-
-+ /* Change to L0 state */
-+ hsotg->lx_state = DWC2_L0;
- call_gadget(hsotg, resume);
-+ } else {
-+ /* Change to L0 state */
-+ hsotg->lx_state = DWC2_L0;
- }
-- /* Change to L0 state */
-- hsotg->lx_state = DWC2_L0;
- } else {
- if (hsotg->params.power_down)
- return;
-diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
-index b81d085bc534..eabb3bb6fcaa 100644
---- a/drivers/usb/dwc3/dwc3-meson-g12a.c
-+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
-@@ -505,7 +505,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
- if (IS_ERR(priv->reset)) {
- ret = PTR_ERR(priv->reset);
- dev_err(dev, "failed to get device reset, err=%d\n", ret);
-- return ret;
-+ goto err_disable_clks;
- }
-
- ret = reset_control_reset(priv->reset);
-@@ -525,7 +525,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
- /* Get dr_mode */
- priv->otg_mode = usb_get_dr_mode(dev);
-
-- dwc3_meson_g12a_usb_init(priv);
-+ ret = dwc3_meson_g12a_usb_init(priv);
-+ if (ret)
-+ goto err_disable_clks;
-
- /* Init PHYs */
- for (i = 0 ; i < PHY_COUNT ; ++i) {
-diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
-index 585cb3deea7a..de3b92680935 100644
---- a/drivers/usb/dwc3/gadget.c
-+++ b/drivers/usb/dwc3/gadget.c
-@@ -1220,6 +1220,8 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep)
- }
- }
-
-+static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep);
-+
- static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
- {
- struct dwc3_gadget_ep_cmd_params params;
-@@ -1259,14 +1261,20 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
-
- ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params);
- if (ret < 0) {
-- /*
-- * FIXME we need to iterate over the list of requests
-- * here and stop, unmap, free and del each of the linked
-- * requests instead of what we do now.
-- */
-- if (req->trb)
-- memset(req->trb, 0, sizeof(struct dwc3_trb));
-- dwc3_gadget_del_and_unmap_request(dep, req, ret);
-+ struct dwc3_request *tmp;
-+
-+ if (ret == -EAGAIN)
-+ return ret;
-+
-+ 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 ep isn't started, then there's no end transfer pending */
-+ if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
-+ dwc3_gadget_ep_cleanup_cancelled_requests(dep);
-+
- return ret;
- }
-
-@@ -1508,6 +1516,10 @@ static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *r
- {
- int i;
-
-+ /* If req->trb is not set, then the request has not started */
-+ if (!req->trb)
-+ return;
-+
- /*
- * If request was already started, this means we had to
- * stop the transfer. With that we also need to ignore
-@@ -1598,6 +1610,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
- {
- struct dwc3_gadget_ep_cmd_params params;
- struct dwc3 *dwc = dep->dwc;
-+ struct dwc3_request *req;
-+ struct dwc3_request *tmp;
- int ret;
-
- if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
-@@ -1634,13 +1648,37 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
- else
- dep->flags |= DWC3_EP_STALL;
- } else {
-+ /*
-+ * Don't issue CLEAR_STALL command to control endpoints. The
-+ * controller automatically clears the STALL when it receives
-+ * the SETUP token.
-+ */
-+ if (dep->number <= 1) {
-+ dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE);
-+ return 0;
-+ }
-
- ret = dwc3_send_clear_stall_ep_cmd(dep);
-- if (ret)
-+ if (ret) {
- dev_err(dwc->dev, "failed to clear STALL on %s\n",
- dep->name);
-- else
-- dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE);
-+ return ret;
-+ }
-+
-+ 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_END_TRANSFER_PENDING)) {
-+ dep->flags &= ~DWC3_EP_DELAY_START;
-+ dwc3_gadget_ep_cleanup_cancelled_requests(dep);
-+ }
- }
-
- return ret;
-diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
-index cb4950cf1cdc..5c1eb96a5c57 100644
---- a/drivers/usb/gadget/composite.c
-+++ b/drivers/usb/gadget/composite.c
-@@ -96,40 +96,43 @@ function_descriptors(struct usb_function *f,
- }
-
- /**
-- * next_ep_desc() - advance to the next EP descriptor
-+ * next_desc() - advance to the next desc_type descriptor
- * @t: currect pointer within descriptor array
-+ * @desc_type: descriptor type
- *
-- * Return: next EP descriptor or NULL
-+ * Return: next desc_type descriptor or NULL
- *
-- * Iterate over @t until either EP descriptor found or
-+ * Iterate over @t until either desc_type descriptor found or
- * NULL (that indicates end of list) encountered
- */
- static struct usb_descriptor_header**
--next_ep_desc(struct usb_descriptor_header **t)
-+next_desc(struct usb_descriptor_header **t, u8 desc_type)
- {
- for (; *t; t++) {
-- if ((*t)->bDescriptorType == USB_DT_ENDPOINT)
-+ if ((*t)->bDescriptorType == desc_type)
- return t;
- }
- return NULL;
- }
-
- /*
-- * for_each_ep_desc()- iterate over endpoint descriptors in the
-- * descriptors list
-- * @start: pointer within descriptor array.
-- * @ep_desc: endpoint descriptor to use as the loop cursor
-+ * for_each_desc() - iterate over desc_type descriptors in the
-+ * descriptors list
-+ * @start: pointer within descriptor array.
-+ * @iter_desc: desc_type descriptor to use as the loop cursor
-+ * @desc_type: wanted descriptr type
- */
--#define for_each_ep_desc(start, ep_desc) \
-- for (ep_desc = next_ep_desc(start); \
-- ep_desc; ep_desc = next_ep_desc(ep_desc+1))
-+#define for_each_desc(start, iter_desc, desc_type) \
-+ for (iter_desc = next_desc(start, desc_type); \
-+ iter_desc; iter_desc = next_desc(iter_desc + 1, desc_type))
-
- /**
-- * config_ep_by_speed() - configures the given endpoint
-+ * config_ep_by_speed_and_alt() - configures the given endpoint
- * according to gadget speed.
- * @g: pointer to the gadget
- * @f: usb function
- * @_ep: the endpoint to configure
-+ * @alt: alternate setting number
- *
- * Return: error code, 0 on success
- *
-@@ -142,11 +145,13 @@ next_ep_desc(struct usb_descriptor_header **t)
- * Note: the supplied function should hold all the descriptors
- * for supported speeds
- */
--int config_ep_by_speed(struct usb_gadget *g,
-- struct usb_function *f,
-- struct usb_ep *_ep)
-+int config_ep_by_speed_and_alt(struct usb_gadget *g,
-+ struct usb_function *f,
-+ struct usb_ep *_ep,
-+ u8 alt)
- {
- struct usb_endpoint_descriptor *chosen_desc = NULL;
-+ struct usb_interface_descriptor *int_desc = NULL;
- struct usb_descriptor_header **speed_desc = NULL;
-
- struct usb_ss_ep_comp_descriptor *comp_desc = NULL;
-@@ -182,8 +187,21 @@ int config_ep_by_speed(struct usb_gadget *g,
- default:
- speed_desc = f->fs_descriptors;
- }
-+
-+ /* find correct alternate setting descriptor */
-+ for_each_desc(speed_desc, d_spd, USB_DT_INTERFACE) {
-+ int_desc = (struct usb_interface_descriptor *)*d_spd;
-+
-+ if (int_desc->bAlternateSetting == alt) {
-+ speed_desc = d_spd;
-+ goto intf_found;
-+ }
-+ }
-+ return -EIO;
-+
-+intf_found:
- /* find descriptors */
-- for_each_ep_desc(speed_desc, d_spd) {
-+ for_each_desc(speed_desc, d_spd, USB_DT_ENDPOINT) {
- chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
- if (chosen_desc->bEndpointAddress == _ep->address)
- goto ep_found;
-@@ -237,6 +255,32 @@ ep_found:
- }
- return 0;
- }
-+EXPORT_SYMBOL_GPL(config_ep_by_speed_and_alt);
-+
-+/**
-+ * config_ep_by_speed() - configures the given endpoint
-+ * according to gadget speed.
-+ * @g: pointer to the gadget
-+ * @f: usb function
-+ * @_ep: the endpoint to configure
-+ *
-+ * Return: error code, 0 on success
-+ *
-+ * This function chooses the right descriptors for a given
-+ * endpoint according to gadget speed and saves it in the
-+ * endpoint desc field. If the endpoint already has a descriptor
-+ * assigned to it - overwrites it with currently corresponding
-+ * descriptor. The endpoint maxpacket field is updated according
-+ * to the chosen descriptor.
-+ * Note: the supplied function should hold all the descriptors
-+ * for supported speeds
-+ */
-+int config_ep_by_speed(struct usb_gadget *g,
-+ struct usb_function *f,
-+ struct usb_ep *_ep)
-+{
-+ return config_ep_by_speed_and_alt(g, f, _ep, 0);
-+}
- EXPORT_SYMBOL_GPL(config_ep_by_speed);
-
- /**
-diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
-index 9b11046480fe..2e28dde8376f 100644
---- a/drivers/usb/gadget/udc/core.c
-+++ b/drivers/usb/gadget/udc/core.c
-@@ -1297,6 +1297,8 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
- kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
-
- usb_gadget_disconnect(udc->gadget);
-+ if (udc->gadget->irq)
-+ synchronize_irq(udc->gadget->irq);
- udc->driver->unbind(udc->gadget);
- usb_gadget_udc_stop(udc);
-
-diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
-index cb997b82c008..465d0b7c6522 100644
---- a/drivers/usb/gadget/udc/lpc32xx_udc.c
-+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
-@@ -1614,17 +1614,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");
-@@ -1872,7 +1872,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))
-@@ -1882,6 +1882,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 75d16a8902e6..931e6362a13d 100644
---- a/drivers/usb/gadget/udc/m66592-udc.c
-+++ b/drivers/usb/gadget/udc/m66592-udc.c
-@@ -1667,7 +1667,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/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
-index 0507a2ca0f55..80002d97b59d 100644
---- a/drivers/usb/gadget/udc/s3c2410_udc.c
-+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
-@@ -251,10 +251,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-mxc.c b/drivers/usb/host/ehci-mxc.c
-index c9f91e6c72b6..7f65c86047dd 100644
---- a/drivers/usb/host/ehci-mxc.c
-+++ b/drivers/usb/host/ehci-mxc.c
-@@ -50,6 +50,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-platform.c b/drivers/usb/host/ehci-platform.c
-index e4fc3f66d43b..e9a49007cce4 100644
---- a/drivers/usb/host/ehci-platform.c
-+++ b/drivers/usb/host/ehci-platform.c
-@@ -455,6 +455,10 @@ 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);
-+
- if (priv->quirk_poll)
- quirk_poll_init(priv);
-
-diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
-index 7addfc2cbadc..4a8456f12a73 100644
---- a/drivers/usb/host/ohci-platform.c
-+++ b/drivers/usb/host/ohci-platform.c
-@@ -299,6 +299,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 c158cda9e4b9..cff965240327 100644
---- a/drivers/usb/host/ohci-sm501.c
-+++ b/drivers/usb/host/ohci-sm501.c
-@@ -157,9 +157,10 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
- * the call to usb_hcd_setup_local_mem() below does just that.
- */
-
-- if (usb_hcd_setup_local_mem(hcd, mem->start,
-- mem->start - mem->parent->start,
-- resource_size(mem)) < 0)
-+ retval = usb_hcd_setup_local_mem(hcd, mem->start,
-+ mem->start - mem->parent->start,
-+ resource_size(mem));
-+ if (retval < 0)
- goto err5;
- retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
- if (retval)
-diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
-index ea460b9682d5..ca82e2c61ddc 100644
---- a/drivers/usb/host/xhci-plat.c
-+++ b/drivers/usb/host/xhci-plat.c
-@@ -409,7 +409,15 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
- if (ret)
- return ret;
-
-- return xhci_resume(xhci, 0);
-+ ret = xhci_resume(xhci, 0);
-+ if (ret)
-+ return ret;
-+
-+ pm_runtime_disable(dev);
-+ pm_runtime_set_active(dev);
-+ pm_runtime_enable(dev);
-+
-+ return 0;
- }
-
- static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
-diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
-index 5b17709821df..27d92af29635 100644
---- a/drivers/usb/roles/class.c
-+++ b/drivers/usb/roles/class.c
-@@ -49,8 +49,10 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)
- mutex_lock(&sw->lock);
-
- ret = sw->set(sw, role);
-- if (!ret)
-+ if (!ret) {
- sw->role = role;
-+ kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE);
-+ }
-
- mutex_unlock(&sw->lock);
-
-diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
-index 8ad14e5c02bf..917fd84c1c6f 100644
---- a/drivers/vfio/mdev/mdev_sysfs.c
-+++ b/drivers/vfio/mdev/mdev_sysfs.c
-@@ -110,7 +110,7 @@ static struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
- "%s-%s", dev_driver_string(parent->dev),
- group->name);
- if (ret) {
-- kfree(type);
-+ kobject_put(&type->kobj);
- return ERR_PTR(ret);
- }
-
-diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
-index 90c0b80f8acf..814bcbe0dd4e 100644
---- a/drivers/vfio/pci/vfio_pci_config.c
-+++ b/drivers/vfio/pci/vfio_pci_config.c
-@@ -1462,7 +1462,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);
-@@ -1728,8 +1733,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/vhost/scsi.c b/drivers/vhost/scsi.c
-index c39952243fd3..8b104f76f324 100644
---- a/drivers/vhost/scsi.c
-+++ b/drivers/vhost/scsi.c
-@@ -2280,6 +2280,7 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
- static const struct target_core_fabric_ops vhost_scsi_ops = {
- .module = THIS_MODULE,
- .fabric_name = "vhost",
-+ .max_data_sg_nents = VHOST_SCSI_PREALLOC_SGLS,
- .tpg_get_wwn = vhost_scsi_get_fabric_wwn,
- .tpg_get_tag = vhost_scsi_get_tpgt,
- .tpg_check_demo_mode = vhost_scsi_check_true,
-diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
-index f68920131a4a..e94932c69f54 100644
---- a/drivers/video/backlight/lp855x_bl.c
-+++ b/drivers/video/backlight/lp855x_bl.c
-@@ -456,7 +456,7 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
- ret = regulator_enable(lp->enable);
- if (ret < 0) {
- dev_err(lp->dev, "failed to enable vddio: %d\n", ret);
-- return ret;
-+ goto disable_supply;
- }
-
- /*
-@@ -471,24 +471,34 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
- ret = lp855x_configure(lp);
- if (ret) {
- dev_err(lp->dev, "device config err: %d", ret);
-- return ret;
-+ goto disable_vddio;
- }
-
- ret = lp855x_backlight_register(lp);
- if (ret) {
- dev_err(lp->dev,
- "failed to register backlight. err: %d\n", ret);
-- return ret;
-+ goto disable_vddio;
- }
-
- ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
- if (ret) {
- dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret);
-- return ret;
-+ goto disable_vddio;
- }
-
- backlight_update_status(lp->bl);
-+
- return 0;
-+
-+disable_vddio:
-+ if (lp->enable)
-+ regulator_disable(lp->enable);
-+disable_supply:
-+ if (lp->supply)
-+ regulator_disable(lp->supply);
-+
-+ return ret;
- }
-
- static int lp855x_remove(struct i2c_client *cl)
-@@ -497,6 +507,8 @@ static int lp855x_remove(struct i2c_client *cl)
-
- lp->bl->props.brightness = 0;
- backlight_update_status(lp->bl);
-+ if (lp->enable)
-+ regulator_disable(lp->enable);
- if (lp->supply)
- regulator_disable(lp->supply);
- sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
-diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c
-index 0ad15d55071c..18dec438d518 100644
---- a/drivers/watchdog/da9062_wdt.c
-+++ b/drivers/watchdog/da9062_wdt.c
-@@ -58,11 +58,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;
-
- regmap_update_bits(chip->regmap,
- DA9062AA_CONTROL_D,
-diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
-index ec975decb5de..b96b11e2b571 100644
---- a/drivers/xen/cpu_hotplug.c
-+++ b/drivers/xen/cpu_hotplug.c
-@@ -93,10 +93,8 @@ static int setup_cpu_watcher(struct notifier_block *notifier,
- (void)register_xenbus_watch(&cpu_watch);
-
- for_each_possible_cpu(cpu) {
-- if (vcpu_online(cpu) == 0) {
-- device_offline(get_cpu_device(cpu));
-- set_cpu_present(cpu, false);
-- }
-+ if (vcpu_online(cpu) == 0)
-+ disable_hotplug_cpu(cpu);
- }
-
- return NOTIFY_DONE;
-@@ -119,5 +117,5 @@ static int __init setup_vcpu_hotplug_event(void)
- return 0;
- }
-
--arch_initcall(setup_vcpu_hotplug_event);
-+late_initcall(setup_vcpu_hotplug_event);
-
-diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
-index 380ad5ace7cf..3a9b8b1f5f2b 100644
---- a/fs/afs/cmservice.c
-+++ b/fs/afs/cmservice.c
-@@ -305,8 +305,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("FID count: %u", call->count);
- if (call->count > AFSCBMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_cb_fid_count);
-+ return afs_protocol_error(call, afs_eproto_cb_fid_count);
-
- call->buffer = kmalloc(array3_size(call->count, 3, 4),
- GFP_KERNEL);
-@@ -351,8 +350,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
- call->count2 = ntohl(call->tmp);
- _debug("CB count: %u", call->count2);
- if (call->count2 != call->count && call->count2 != 0)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_cb_count);
-+ return afs_protocol_error(call, afs_eproto_cb_count);
- call->iter = &call->def_iter;
- iov_iter_discard(&call->def_iter, READ, call->count2 * 3 * 4);
- call->unmarshall++;
-@@ -672,8 +670,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("FID count: %u", call->count);
- if (call->count > YFSCBMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_cb_fid_count);
-+ return afs_protocol_error(call, afs_eproto_cb_fid_count);
-
- size = array_size(call->count, sizeof(struct yfs_xdr_YFSFid));
- call->buffer = kmalloc(size, GFP_KERNEL);
-diff --git a/fs/afs/dir.c b/fs/afs/dir.c
-index d1e1caa23c8b..3c486340b220 100644
---- a/fs/afs/dir.c
-+++ b/fs/afs/dir.c
-@@ -658,7 +658,8 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
-
- cookie->ctx.actor = afs_lookup_filldir;
- cookie->name = dentry->d_name;
-- cookie->nr_fids = 1; /* slot 0 is saved for the fid we actually want */
-+ cookie->nr_fids = 2; /* slot 0 is saved for the fid we actually want
-+ * and slot 1 for the directory */
-
- read_seqlock_excl(&dvnode->cb_lock);
- dcbi = rcu_dereference_protected(dvnode->cb_interest,
-@@ -709,7 +710,11 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
- if (!cookie->inodes)
- goto out_s;
-
-- for (i = 1; i < cookie->nr_fids; i++) {
-+ cookie->fids[1] = dvnode->fid;
-+ cookie->statuses[1].cb_break = afs_calc_vnode_cb_break(dvnode);
-+ cookie->inodes[1] = igrab(&dvnode->vfs_inode);
-+
-+ for (i = 2; i < cookie->nr_fids; i++) {
- scb = &cookie->statuses[i];
-
- /* Find any inodes that already exist and get their
-diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
-index d2b3798c1932..7bca0c13d0c4 100644
---- a/fs/afs/fsclient.c
-+++ b/fs/afs/fsclient.c
-@@ -56,16 +56,15 @@ static void xdr_dump_bad(const __be32 *bp)
- /*
- * decode an AFSFetchStatus block
- */
--static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
-- struct afs_call *call,
-- struct afs_status_cb *scb)
-+static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
-+ struct afs_call *call,
-+ struct afs_status_cb *scb)
- {
- const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
- struct afs_file_status *status = &scb->status;
- bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
- u64 data_version, size;
- u32 type, abort_code;
-- int ret;
-
- abort_code = ntohl(xdr->abort_code);
-
-@@ -79,7 +78,7 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
- */
- status->abort_code = abort_code;
- scb->have_error = true;
-- goto good;
-+ goto advance;
- }
-
- pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
-@@ -89,7 +88,7 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
- if (abort_code != 0 && inline_error) {
- status->abort_code = abort_code;
- scb->have_error = true;
-- goto good;
-+ goto advance;
- }
-
- type = ntohl(xdr->type);
-@@ -125,15 +124,13 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
- data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
- status->data_version = data_version;
- scb->have_status = true;
--good:
-- ret = 0;
- advance:
- *_bp = (const void *)*_bp + sizeof(*xdr);
-- return ret;
-+ return;
-
- bad:
- xdr_dump_bad(*_bp);
-- ret = afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
-+ afs_protocol_error(call, afs_eproto_bad_status);
- goto advance;
- }
-
-@@ -254,9 +251,7 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSCallBack(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
-@@ -419,9 +414,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSCallBack(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
-@@ -577,12 +570,8 @@ static int afs_deliver_fs_create_vnode(struct afs_call *call)
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
- xdr_decode_AFSFid(&bp, call->out_fid);
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_AFSCallBack(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
-@@ -691,9 +680,7 @@ static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -784,12 +771,8 @@ static int afs_deliver_fs_link(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -878,12 +861,8 @@ static int afs_deliver_fs_symlink(struct afs_call *call)
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
- xdr_decode_AFSFid(&bp, call->out_fid);
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -986,16 +965,12 @@ static int afs_deliver_fs_rename(struct afs_call *call)
- if (ret < 0)
- return ret;
-
-+ bp = call->buffer;
- /* If the two dirs are the same, we have two copies of the same status
- * report, so we just decode it twice.
- */
-- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -1103,9 +1078,7 @@ static int afs_deliver_fs_store_data(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -1283,9 +1256,7 @@ static int afs_deliver_fs_store_status(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -1499,8 +1470,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("volname length: %u", call->count);
- if (call->count >= AFSNAMEMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_volname_len);
-+ return afs_protocol_error(call, afs_eproto_volname_len);
- size = (call->count + 3) & ~3; /* It's padded */
- afs_extract_to_buf(call, size);
- call->unmarshall++;
-@@ -1529,8 +1499,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("offline msg length: %u", call->count);
- if (call->count >= AFSNAMEMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_offline_msg_len);
-+ return afs_protocol_error(call, afs_eproto_offline_msg_len);
- size = (call->count + 3) & ~3; /* It's padded */
- afs_extract_to_buf(call, size);
- call->unmarshall++;
-@@ -1560,8 +1529,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("motd length: %u", call->count);
- if (call->count >= AFSNAMEMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_motd_len);
-+ return afs_protocol_error(call, afs_eproto_motd_len);
- size = (call->count + 3) & ~3; /* It's padded */
- afs_extract_to_buf(call, size);
- call->unmarshall++;
-@@ -1954,9 +1922,7 @@ static int afs_deliver_fs_fetch_status(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSCallBack(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
-@@ -2045,8 +2011,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
- tmp = ntohl(call->tmp);
- _debug("status count: %u/%u", tmp, call->count2);
- if (tmp != call->count2)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_ibulkst_count);
-+ return afs_protocol_error(call, afs_eproto_ibulkst_count);
-
- call->count = 0;
- call->unmarshall++;
-@@ -2062,10 +2027,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
-
- bp = call->buffer;
- scb = &call->out_scb[call->count];
-- ret = xdr_decode_AFSFetchStatus(&bp, call, scb);
-- if (ret < 0)
-- return ret;
--
-+ xdr_decode_AFSFetchStatus(&bp, call, scb);
- call->count++;
- if (call->count < call->count2)
- goto more_counts;
-@@ -2085,8 +2047,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
- tmp = ntohl(call->tmp);
- _debug("CB count: %u", tmp);
- if (tmp != call->count2)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_ibulkst_cb_count);
-+ return afs_protocol_error(call, afs_eproto_ibulkst_cb_count);
- call->count = 0;
- call->unmarshall++;
- more_cbs:
-@@ -2243,9 +2204,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- call->unmarshall++;
-@@ -2326,9 +2285,7 @@ static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_AFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-diff --git a/fs/afs/inode.c b/fs/afs/inode.c
-index 281470fe1183..d7b65fad6679 100644
---- a/fs/afs/inode.c
-+++ b/fs/afs/inode.c
-@@ -130,7 +130,7 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
- default:
- dump_vnode(vnode, parent_vnode);
- write_sequnlock(&vnode->cb_lock);
-- return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type);
-+ return afs_protocol_error(NULL, afs_eproto_file_type);
- }
-
- afs_set_i_size(vnode, status->size);
-@@ -170,6 +170,7 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
- struct timespec64 t;
- umode_t mode;
- bool data_changed = false;
-+ bool change_size = false;
-
- BUG_ON(test_bit(AFS_VNODE_UNSET, &vnode->flags));
-
-@@ -179,7 +180,7 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
- vnode->fid.vnode,
- vnode->fid.unique,
- status->type, vnode->status.type);
-- afs_protocol_error(NULL, -EBADMSG, afs_eproto_bad_status);
-+ afs_protocol_error(NULL, afs_eproto_bad_status);
- return;
- }
-
-@@ -225,6 +226,7 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
- } else {
- set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags);
- }
-+ change_size = true;
- } else if (vnode->status.type == AFS_FTYPE_DIR) {
- /* Expected directory change is handled elsewhere so
- * that we can locally edit the directory and save on a
-@@ -232,11 +234,19 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
- */
- if (test_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
- data_changed = false;
-+ change_size = true;
- }
-
- if (data_changed) {
- inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
-- afs_set_i_size(vnode, status->size);
-+
-+ /* Only update the size if the data version jumped. If the
-+ * file is being modified locally, then we might have our own
-+ * idea of what the size should be that's not the same as
-+ * what's on the server.
-+ */
-+ if (change_size)
-+ afs_set_i_size(vnode, status->size);
- }
- }
-
-diff --git a/fs/afs/internal.h b/fs/afs/internal.h
-index 80255513e230..98e0cebd5e5e 100644
---- a/fs/afs/internal.h
-+++ b/fs/afs/internal.h
-@@ -161,6 +161,7 @@ struct afs_call {
- bool upgrade; /* T to request service upgrade */
- bool have_reply_time; /* T if have got reply_time */
- bool intr; /* T if interruptible */
-+ bool unmarshalling_error; /* T if an unmarshalling error occurred */
- u16 service_id; /* Actual service ID (after upgrade) */
- unsigned int debug_id; /* Trace ID */
- u32 operation_ID; /* operation ID for an incoming call */
-@@ -1128,7 +1129,7 @@ extern void afs_flat_call_destructor(struct afs_call *);
- extern void afs_send_empty_reply(struct afs_call *);
- extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
- extern int afs_extract_data(struct afs_call *, bool);
--extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause);
-+extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);
-
- static inline void afs_set_fc_call(struct afs_call *call, struct afs_fs_cursor *fc)
- {
-diff --git a/fs/afs/misc.c b/fs/afs/misc.c
-index 52b19e9c1535..5334f1bd2bca 100644
---- a/fs/afs/misc.c
-+++ b/fs/afs/misc.c
-@@ -83,6 +83,7 @@ int afs_abort_to_error(u32 abort_code)
- case UAENOLCK: return -ENOLCK;
- case UAENOTEMPTY: return -ENOTEMPTY;
- case UAELOOP: return -ELOOP;
-+ case UAEOVERFLOW: return -EOVERFLOW;
- case UAENOMEDIUM: return -ENOMEDIUM;
- case UAEDQUOT: return -EDQUOT;
-
-diff --git a/fs/afs/proc.c b/fs/afs/proc.c
-index 468e1713bce1..6f34c84a0fd0 100644
---- a/fs/afs/proc.c
-+++ b/fs/afs/proc.c
-@@ -563,6 +563,7 @@ void afs_put_sysnames(struct afs_sysnames *sysnames)
- if (sysnames->subs[i] != afs_init_sysname &&
- sysnames->subs[i] != sysnames->blank)
- kfree(sysnames->subs[i]);
-+ kfree(sysnames);
- }
- }
-
-diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
-index 1ecc67da6c1a..e3c2655616dc 100644
---- a/fs/afs/rxrpc.c
-+++ b/fs/afs/rxrpc.c
-@@ -540,6 +540,8 @@ static void afs_deliver_to_call(struct afs_call *call)
-
- ret = call->type->deliver(call);
- state = READ_ONCE(call->state);
-+ if (ret == 0 && call->unmarshalling_error)
-+ ret = -EBADMSG;
- switch (ret) {
- case 0:
- afs_queue_call_work(call);
-@@ -959,9 +961,11 @@ int afs_extract_data(struct afs_call *call, bool want_more)
- /*
- * Log protocol error production.
- */
--noinline int afs_protocol_error(struct afs_call *call, int error,
-+noinline int afs_protocol_error(struct afs_call *call,
- enum afs_eproto_cause cause)
- {
-- trace_afs_protocol_error(call, error, cause);
-- return error;
-+ trace_afs_protocol_error(call, cause);
-+ if (call)
-+ call->unmarshalling_error = true;
-+ return -EBADMSG;
- }
-diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c
-index 516e9a3bb5b4..e64b002c3bb3 100644
---- a/fs/afs/vlclient.c
-+++ b/fs/afs/vlclient.c
-@@ -447,8 +447,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
- call->count2 = ntohl(*bp); /* Type or next count */
-
- if (call->count > YFS_MAXENDPOINTS)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_fsendpt_num);
-+ return afs_protocol_error(call, afs_eproto_yvl_fsendpt_num);
-
- alist = afs_alloc_addrlist(call->count, FS_SERVICE, AFS_FS_PORT);
- if (!alist)
-@@ -468,8 +467,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
- size = sizeof(__be32) * (1 + 4 + 1);
- break;
- default:
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_fsendpt_type);
-+ return afs_protocol_error(call, afs_eproto_yvl_fsendpt_type);
- }
-
- size += sizeof(__be32);
-@@ -487,21 +485,20 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
- switch (call->count2) {
- case YFS_ENDPOINT_IPV4:
- if (ntohl(bp[0]) != sizeof(__be32) * 2)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_fsendpt4_len);
-+ return afs_protocol_error(
-+ call, afs_eproto_yvl_fsendpt4_len);
- afs_merge_fs_addr4(alist, bp[1], ntohl(bp[2]));
- bp += 3;
- break;
- case YFS_ENDPOINT_IPV6:
- if (ntohl(bp[0]) != sizeof(__be32) * 5)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_fsendpt6_len);
-+ return afs_protocol_error(
-+ call, afs_eproto_yvl_fsendpt6_len);
- afs_merge_fs_addr6(alist, bp + 1, ntohl(bp[5]));
- bp += 6;
- break;
- default:
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_fsendpt_type);
-+ return afs_protocol_error(call, afs_eproto_yvl_fsendpt_type);
- }
-
- /* Got either the type of the next entry or the count of
-@@ -519,8 +516,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
- if (!call->count)
- goto end;
- if (call->count > YFS_MAXENDPOINTS)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_vlendpt_type);
-+ return afs_protocol_error(call, afs_eproto_yvl_vlendpt_type);
-
- afs_extract_to_buf(call, 1 * sizeof(__be32));
- call->unmarshall = 3;
-@@ -547,8 +543,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
- size = sizeof(__be32) * (1 + 4 + 1);
- break;
- default:
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_vlendpt_type);
-+ return afs_protocol_error(call, afs_eproto_yvl_vlendpt_type);
- }
-
- if (call->count > 1)
-@@ -566,19 +561,18 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
- switch (call->count2) {
- case YFS_ENDPOINT_IPV4:
- if (ntohl(bp[0]) != sizeof(__be32) * 2)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_vlendpt4_len);
-+ return afs_protocol_error(
-+ call, afs_eproto_yvl_vlendpt4_len);
- bp += 3;
- break;
- case YFS_ENDPOINT_IPV6:
- if (ntohl(bp[0]) != sizeof(__be32) * 5)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_vlendpt6_len);
-+ return afs_protocol_error(
-+ call, afs_eproto_yvl_vlendpt6_len);
- bp += 6;
- break;
- default:
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_yvl_vlendpt_type);
-+ return afs_protocol_error(call, afs_eproto_yvl_vlendpt_type);
- }
-
- /* Got either the type of the next entry or the count of
-diff --git a/fs/afs/write.c b/fs/afs/write.c
-index cb76566763db..96b042af6248 100644
---- a/fs/afs/write.c
-+++ b/fs/afs/write.c
-@@ -194,11 +194,11 @@ int afs_write_end(struct file *file, struct address_space *mapping,
-
- i_size = i_size_read(&vnode->vfs_inode);
- if (maybe_i_size > i_size) {
-- spin_lock(&vnode->wb_lock);
-+ write_seqlock(&vnode->cb_lock);
- i_size = i_size_read(&vnode->vfs_inode);
- if (maybe_i_size > i_size)
- i_size_write(&vnode->vfs_inode, maybe_i_size);
-- spin_unlock(&vnode->wb_lock);
-+ write_sequnlock(&vnode->cb_lock);
- }
-
- if (!PageUptodate(page)) {
-@@ -811,6 +811,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
- vmf->page->index, priv);
- SetPagePrivate(vmf->page);
- set_page_private(vmf->page, priv);
-+ file_update_time(file);
-
- sb_end_pagefault(inode->i_sb);
- return VM_FAULT_LOCKED;
-diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c
-index fe413e7a5cf4..bf74c679c02b 100644
---- a/fs/afs/yfsclient.c
-+++ b/fs/afs/yfsclient.c
-@@ -179,21 +179,20 @@ static void xdr_dump_bad(const __be32 *bp)
- /*
- * Decode a YFSFetchStatus block
- */
--static int xdr_decode_YFSFetchStatus(const __be32 **_bp,
-- struct afs_call *call,
-- struct afs_status_cb *scb)
-+static void xdr_decode_YFSFetchStatus(const __be32 **_bp,
-+ struct afs_call *call,
-+ struct afs_status_cb *scb)
- {
- const struct yfs_xdr_YFSFetchStatus *xdr = (const void *)*_bp;
- struct afs_file_status *status = &scb->status;
- u32 type;
-- int ret;
-
- status->abort_code = ntohl(xdr->abort_code);
- if (status->abort_code != 0) {
- if (status->abort_code == VNOVNODE)
- status->nlink = 0;
- scb->have_error = true;
-- goto good;
-+ goto advance;
- }
-
- type = ntohl(xdr->type);
-@@ -221,15 +220,13 @@ static int xdr_decode_YFSFetchStatus(const __be32 **_bp,
- status->size = xdr_to_u64(xdr->size);
- status->data_version = xdr_to_u64(xdr->data_version);
- scb->have_status = true;
--good:
-- ret = 0;
- advance:
- *_bp += xdr_size(xdr);
-- return ret;
-+ return;
-
- bad:
- xdr_dump_bad(*_bp);
-- ret = afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
-+ afs_protocol_error(call, afs_eproto_bad_status);
- goto advance;
- }
-
-@@ -348,9 +345,7 @@ static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call)
-
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_YFSCallBack(&bp, call, call->out_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-
-@@ -372,9 +367,7 @@ static int yfs_deliver_status_and_volsync(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -534,9 +527,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_YFSCallBack(&bp, call, call->out_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-
-@@ -644,12 +635,8 @@ static int yfs_deliver_fs_create_vnode(struct afs_call *call)
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
- xdr_decode_YFSFid(&bp, call->out_fid);
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_YFSCallBack(&bp, call, call->out_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-
-@@ -802,14 +789,9 @@ static int yfs_deliver_fs_remove_file2(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
--
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_YFSFid(&bp, &fid);
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
- /* Was deleted if vnode->status.abort_code == VNOVNODE. */
-
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-@@ -889,10 +871,7 @@ static int yfs_deliver_fs_remove(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
--
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
- return 0;
- }
-@@ -974,12 +953,8 @@ static int yfs_deliver_fs_link(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
- _leave(" = 0 [done]");
- return 0;
-@@ -1061,12 +1036,8 @@ static int yfs_deliver_fs_symlink(struct afs_call *call)
- /* unmarshall the reply once we've received all of it */
- bp = call->buffer;
- xdr_decode_YFSFid(&bp, call->out_fid);
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-
- _leave(" = 0 [done]");
-@@ -1154,13 +1125,11 @@ static int yfs_deliver_fs_rename(struct afs_call *call)
- return ret;
-
- bp = call->buffer;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-- if (ret < 0)
-- return ret;
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
--
-+ /* If the two dirs are the same, we have two copies of the same status
-+ * report, so we just decode it twice.
-+ */
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
- _leave(" = 0 [done]");
- return 0;
-@@ -1457,8 +1426,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("volname length: %u", call->count);
- if (call->count >= AFSNAMEMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_volname_len);
-+ return afs_protocol_error(call, afs_eproto_volname_len);
- size = (call->count + 3) & ~3; /* It's padded */
- afs_extract_to_buf(call, size);
- call->unmarshall++;
-@@ -1487,8 +1455,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("offline msg length: %u", call->count);
- if (call->count >= AFSNAMEMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_offline_msg_len);
-+ return afs_protocol_error(call, afs_eproto_offline_msg_len);
- size = (call->count + 3) & ~3; /* It's padded */
- afs_extract_to_buf(call, size);
- call->unmarshall++;
-@@ -1518,8 +1485,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
- call->count = ntohl(call->tmp);
- _debug("motd length: %u", call->count);
- if (call->count >= AFSNAMEMAX)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_motd_len);
-+ return afs_protocol_error(call, afs_eproto_motd_len);
- size = (call->count + 3) & ~3; /* It's padded */
- afs_extract_to_buf(call, size);
- call->unmarshall++;
-@@ -1828,8 +1794,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
- tmp = ntohl(call->tmp);
- _debug("status count: %u/%u", tmp, call->count2);
- if (tmp != call->count2)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_ibulkst_count);
-+ return afs_protocol_error(call, afs_eproto_ibulkst_count);
-
- call->count = 0;
- call->unmarshall++;
-@@ -1845,9 +1810,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
-
- bp = call->buffer;
- scb = &call->out_scb[call->count];
-- ret = xdr_decode_YFSFetchStatus(&bp, call, scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, scb);
-
- call->count++;
- if (call->count < call->count2)
-@@ -1868,8 +1831,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
- tmp = ntohl(call->tmp);
- _debug("CB count: %u", tmp);
- if (tmp != call->count2)
-- return afs_protocol_error(call, -EBADMSG,
-- afs_eproto_ibulkst_cb_count);
-+ return afs_protocol_error(call, afs_eproto_ibulkst_cb_count);
- call->count = 0;
- call->unmarshall++;
- more_cbs:
-@@ -2067,9 +2029,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
- bp = call->buffer;
- yacl->inherit_flag = ntohl(*bp++);
- yacl->num_cleaned = ntohl(*bp++);
-- ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
-- if (ret < 0)
-- return ret;
-+ xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
- xdr_decode_YFSVolSync(&bp, call->out_volsync);
-
- call->unmarshall++;
-diff --git a/fs/block_dev.c b/fs/block_dev.c
-index 93672c3f1c78..313aae95818e 100644
---- a/fs/block_dev.c
-+++ b/fs/block_dev.c
-@@ -1583,10 +1583,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:
-@@ -1655,8 +1653,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) ||
-@@ -1706,7 +1706,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
- disk_unblock_events(disk);
- put_disk_and_module(disk);
- out:
-- bdput(bdev);
-
- return ret;
- }
-@@ -1773,6 +1772,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/ceph/export.c b/fs/ceph/export.c
-index 79dc06881e78..e088843a7734 100644
---- a/fs/ceph/export.c
-+++ b/fs/ceph/export.c
-@@ -172,9 +172,16 @@ struct inode *ceph_lookup_inode(struct super_block *sb, u64 ino)
- static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
- {
- struct inode *inode = __lookup_inode(sb, ino);
-+ int err;
-+
- if (IS_ERR(inode))
- return ERR_CAST(inode);
-- if (inode->i_nlink == 0) {
-+ /* We need LINK caps to reliably check i_nlink */
-+ err = ceph_do_getattr(inode, CEPH_CAP_LINK_SHARED, false);
-+ if (err)
-+ return ERR_PTR(err);
-+ /* -ESTALE if inode as been unlinked and no file is open */
-+ if ((inode->i_nlink == 0) && (atomic_read(&inode->i_count) == 1)) {
- iput(inode);
- return ERR_PTR(-ESTALE);
- }
-diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
-index 28268ed461b8..47b9fbb70bf5 100644
---- a/fs/cifs/connect.c
-+++ b/fs/cifs/connect.c
-@@ -572,26 +572,26 @@ cifs_reconnect(struct TCP_Server_Info *server)
- try_to_freeze();
-
- mutex_lock(&server->srv_mutex);
-+#ifdef CONFIG_CIFS_DFS_UPCALL
- /*
- * Set up next DFS target server (if any) for reconnect. If DFS
- * feature is disabled, then we will retry last server we
- * connected to before.
- */
-+ reconn_inval_dfs_target(server, cifs_sb, &tgt_list, &tgt_it);
-+#endif
-+ rc = reconn_set_ipaddr(server);
-+ if (rc) {
-+ cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n",
-+ __func__, rc);
-+ }
-+
- if (cifs_rdma_enabled(server))
- rc = smbd_reconnect(server);
- else
- rc = generic_ip_connect(server);
- if (rc) {
- cifs_dbg(FYI, "reconnect error %d\n", rc);
--#ifdef CONFIG_CIFS_DFS_UPCALL
-- reconn_inval_dfs_target(server, cifs_sb, &tgt_list,
-- &tgt_it);
--#endif
-- rc = reconn_set_ipaddr(server);
-- if (rc) {
-- cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n",
-- __func__, rc);
-- }
- mutex_unlock(&server->srv_mutex);
- msleep(3000);
- } else {
-diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
-index 416d9de35679..4311d01b02a8 100644
---- a/fs/dlm/dlm_internal.h
-+++ b/fs/dlm/dlm_internal.h
-@@ -97,7 +97,6 @@ do { \
- __LINE__, __FILE__, #x, jiffies); \
- {do} \
- printk("\n"); \
-- BUG(); \
- panic("DLM: Record message above and reboot.\n"); \
- } \
- }
-diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
-index 8c7bbf3e566d..470be69f19aa 100644
---- a/fs/ext4/acl.c
-+++ b/fs/ext4/acl.c
-@@ -256,7 +256,7 @@ retry:
- if (!error && update_mode) {
- inode->i_mode = mode;
- inode->i_ctime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ error = ext4_mark_inode_dirty(handle, inode);
- }
- out_stop:
- ext4_journal_stop(handle);
-diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
-index c654205f648d..1d82336b1cd4 100644
---- a/fs/ext4/dir.c
-+++ b/fs/ext4/dir.c
-@@ -675,6 +675,7 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
- struct qstr qstr = {.name = str, .len = len };
- const struct dentry *parent = READ_ONCE(dentry->d_parent);
- const struct inode *inode = READ_ONCE(parent->d_inode);
-+ char strbuf[DNAME_INLINE_LEN];
-
- if (!inode || !IS_CASEFOLDED(inode) ||
- !EXT4_SB(inode->i_sb)->s_encoding) {
-@@ -683,6 +684,21 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
- return memcmp(str, name->name, len);
- }
-
-+ /*
-+ * If the dentry name is stored in-line, then it may be concurrently
-+ * modified by a rename. If this happens, the VFS will eventually retry
-+ * the lookup, so it doesn't matter what ->d_compare() returns.
-+ * However, it's unsafe to call utf8_strncasecmp() with an unstable
-+ * string. Therefore, we have to copy the name into a temporary buffer.
-+ */
-+ if (len <= DNAME_INLINE_LEN - 1) {
-+ memcpy(strbuf, str, len);
-+ strbuf[len] = 0;
-+ qstr.name = strbuf;
-+ /* prevent compiler from optimizing out the temporary buffer */
-+ barrier();
-+ }
-+
- return ext4_ci_compare(inode, name, &qstr, false);
- }
-
-diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
-index ad2dbf6e4924..51a85b50033a 100644
---- a/fs/ext4/ext4.h
-+++ b/fs/ext4/ext4.h
-@@ -3354,7 +3354,7 @@ struct ext4_extent;
- */
- #define EXT_MAX_BLOCKS 0xffffffff
-
--extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
-+extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode);
- extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents);
- extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
- struct ext4_map_blocks *map, int flags);
-diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
-index 4b9002f0e84c..3bacf76d2609 100644
---- a/fs/ext4/ext4_jbd2.h
-+++ b/fs/ext4/ext4_jbd2.h
-@@ -222,7 +222,10 @@ ext4_mark_iloc_dirty(handle_t *handle,
- int ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
- struct ext4_iloc *iloc);
-
--int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
-+#define ext4_mark_inode_dirty(__h, __i) \
-+ __ext4_mark_inode_dirty((__h), (__i), __func__, __LINE__)
-+int __ext4_mark_inode_dirty(handle_t *handle, struct inode *inode,
-+ const char *func, unsigned int line);
-
- int ext4_expand_extra_isize(struct inode *inode,
- unsigned int new_extra_isize,
-diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
-index 2b4b94542e34..d5453072eb63 100644
---- a/fs/ext4/extents.c
-+++ b/fs/ext4/extents.c
-@@ -816,7 +816,7 @@ ext4_ext_binsearch(struct inode *inode,
-
- }
-
--int ext4_ext_tree_init(handle_t *handle, struct inode *inode)
-+void ext4_ext_tree_init(handle_t *handle, struct inode *inode)
- {
- struct ext4_extent_header *eh;
-
-@@ -826,7 +826,6 @@ int ext4_ext_tree_init(handle_t *handle, struct inode *inode)
- eh->eh_magic = EXT4_EXT_MAGIC;
- eh->eh_max = cpu_to_le16(ext4_ext_space_root(inode, 0));
- ext4_mark_inode_dirty(handle, inode);
-- return 0;
- }
-
- struct ext4_ext_path *
-@@ -1319,7 +1318,7 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
- ext4_idx_pblock(EXT_FIRST_INDEX(neh)));
-
- le16_add_cpu(&neh->eh_depth, 1);
-- ext4_mark_inode_dirty(handle, inode);
-+ err = ext4_mark_inode_dirty(handle, inode);
- out:
- brelse(bh);
-
-@@ -2828,7 +2827,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.pclu = EXT4_B2C(sbi, pblk);
- partial.state = nofree;
- }
-@@ -4363,7 +4362,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
- struct inode *inode = file_inode(file);
- handle_t *handle;
- int ret = 0;
-- int ret2 = 0;
-+ int ret2 = 0, ret3 = 0;
- int retries = 0;
- int depth = 0;
- struct ext4_map_blocks map;
-@@ -4423,10 +4422,11 @@ retry:
- if (ext4_update_inode_size(inode, epos) & 0x1)
- inode->i_mtime = inode->i_ctime;
- }
-- ext4_mark_inode_dirty(handle, inode);
-+ ret2 = ext4_mark_inode_dirty(handle, inode);
- ext4_update_inode_fsync_trans(handle, inode, 1);
-- ret2 = ext4_journal_stop(handle);
-- if (ret2)
-+ ret3 = ext4_journal_stop(handle);
-+ ret2 = ret3 ? ret3 : ret2;
-+ if (unlikely(ret2))
- break;
- }
- if (ret == -ENOSPC &&
-@@ -4577,7 +4577,9 @@ static long ext4_zero_range(struct file *file, loff_t offset,
- inode->i_mtime = inode->i_ctime = current_time(inode);
- if (new_size)
- ext4_update_inode_size(inode, new_size);
-- ext4_mark_inode_dirty(handle, inode);
-+ ret = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(ret))
-+ goto out_handle;
-
- /* Zero out partial block at the edges of the range */
- ret = ext4_zero_partial_blocks(handle, inode, offset, len);
-@@ -4587,6 +4589,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
- if (file->f_flags & O_SYNC)
- ext4_handle_sync(handle);
-
-+out_handle:
- ext4_journal_stop(handle);
- out_mutex:
- inode_unlock(inode);
-@@ -4700,8 +4703,7 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
- loff_t offset, ssize_t len)
- {
- unsigned int max_blocks;
-- int ret = 0;
-- int ret2 = 0;
-+ int ret = 0, ret2 = 0, ret3 = 0;
- struct ext4_map_blocks map;
- unsigned int blkbits = inode->i_blkbits;
- unsigned int credits = 0;
-@@ -4734,9 +4736,13 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
- "ext4_ext_map_blocks returned %d",
- inode->i_ino, map.m_lblk,
- map.m_len, ret);
-- ext4_mark_inode_dirty(handle, inode);
-- if (credits)
-- ret2 = ext4_journal_stop(handle);
-+ ret2 = ext4_mark_inode_dirty(handle, inode);
-+ if (credits) {
-+ ret3 = ext4_journal_stop(handle);
-+ if (unlikely(ret3))
-+ ret2 = ret3;
-+ }
-+
- if (ret <= 0 || ret2)
- break;
- }
-@@ -5304,7 +5310,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
- if (IS_SYNC(inode))
- ext4_handle_sync(handle);
- inode->i_mtime = inode->i_ctime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ ret = ext4_mark_inode_dirty(handle, inode);
- ext4_update_inode_fsync_trans(handle, inode, 1);
-
- out_stop:
-diff --git a/fs/ext4/file.c b/fs/ext4/file.c
-index 0d624250a62b..2a01e31a032c 100644
---- a/fs/ext4/file.c
-+++ b/fs/ext4/file.c
-@@ -287,6 +287,7 @@ static ssize_t ext4_handle_inode_extension(struct inode *inode, loff_t offset,
- bool truncate = false;
- u8 blkbits = inode->i_blkbits;
- ext4_lblk_t written_blk, end_blk;
-+ int ret;
-
- /*
- * Note that EXT4_I(inode)->i_disksize can get extended up to
-@@ -327,8 +328,14 @@ static ssize_t ext4_handle_inode_extension(struct inode *inode, loff_t offset,
- goto truncate;
- }
-
-- if (ext4_update_inode_size(inode, offset + written))
-- ext4_mark_inode_dirty(handle, inode);
-+ if (ext4_update_inode_size(inode, offset + written)) {
-+ ret = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(ret)) {
-+ written = ret;
-+ ext4_journal_stop(handle);
-+ goto truncate;
-+ }
-+ }
-
- /*
- * We may need to truncate allocated but not written blocks beyond EOF.
-@@ -495,6 +502,12 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
- if (ret <= 0)
- return ret;
-
-+ /* if we're going to block and IOCB_NOWAIT is set, return -EAGAIN */
-+ if ((iocb->ki_flags & IOCB_NOWAIT) && (unaligned_io || extend)) {
-+ ret = -EAGAIN;
-+ goto out;
-+ }
-+
- offset = iocb->ki_pos;
- count = ret;
-
-diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
-index 107f0043f67f..be2b66eb65f7 100644
---- a/fs/ext4/indirect.c
-+++ b/fs/ext4/indirect.c
-@@ -467,7 +467,9 @@ static int ext4_splice_branch(handle_t *handle,
- /*
- * OK, we spliced it into the inode itself on a direct block.
- */
-- ext4_mark_inode_dirty(handle, ar->inode);
-+ err = ext4_mark_inode_dirty(handle, ar->inode);
-+ if (unlikely(err))
-+ goto err_out;
- jbd_debug(5, "splicing direct\n");
- }
- return err;
-diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
-index f35e289e17aa..c3a1ad2db122 100644
---- a/fs/ext4/inline.c
-+++ b/fs/ext4/inline.c
-@@ -1260,7 +1260,7 @@ out:
- int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
- struct inode *dir, struct inode *inode)
- {
-- int ret, inline_size, no_expand;
-+ int ret, ret2, inline_size, no_expand;
- void *inline_start;
- struct ext4_iloc iloc;
-
-@@ -1314,7 +1314,9 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
-
- out:
- ext4_write_unlock_xattr(dir, &no_expand);
-- ext4_mark_inode_dirty(handle, dir);
-+ ret2 = ext4_mark_inode_dirty(handle, dir);
-+ if (unlikely(ret2 && !ret))
-+ ret = ret2;
- brelse(iloc.bh);
- return ret;
- }
-diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
-index 2a4aae6acdcb..87430d276bcc 100644
---- a/fs/ext4/inode.c
-+++ b/fs/ext4/inode.c
-@@ -1296,7 +1296,7 @@ static int ext4_write_end(struct file *file,
- * filesystems.
- */
- if (i_size_changed || inline_data)
-- ext4_mark_inode_dirty(handle, inode);
-+ ret = ext4_mark_inode_dirty(handle, inode);
-
- if (pos + len > inode->i_size && !verity && ext4_can_truncate(inode))
- /* if we have allocated more blocks and copied
-@@ -3077,7 +3077,7 @@ static int ext4_da_write_end(struct file *file,
- * new_i_size is less that inode->i_size
- * bu greater than i_disksize.(hint delalloc)
- */
-- ext4_mark_inode_dirty(handle, inode);
-+ ret = ext4_mark_inode_dirty(handle, inode);
- }
- }
-
-@@ -3094,7 +3094,7 @@ static int ext4_da_write_end(struct file *file,
- if (ret2 < 0)
- ret = ret2;
- ret2 = ext4_journal_stop(handle);
-- if (!ret)
-+ if (unlikely(ret2 && !ret))
- ret = ret2;
-
- return ret ? ret : copied;
-@@ -3886,6 +3886,8 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
- loff_t len)
- {
- handle_t *handle;
-+ int ret;
-+
- loff_t size = i_size_read(inode);
-
- WARN_ON(!inode_is_locked(inode));
-@@ -3899,10 +3901,10 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- ext4_update_i_disksize(inode, size);
-- ext4_mark_inode_dirty(handle, inode);
-+ ret = ext4_mark_inode_dirty(handle, inode);
- ext4_journal_stop(handle);
-
-- return 0;
-+ return ret;
- }
-
- static void ext4_wait_dax_page(struct ext4_inode_info *ei)
-@@ -3954,7 +3956,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
- loff_t first_block_offset, last_block_offset;
- handle_t *handle;
- unsigned int credits;
-- int ret = 0;
-+ int ret = 0, ret2 = 0;
-
- trace_ext4_punch_hole(inode, offset, length, 0);
-
-@@ -4077,7 +4079,9 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
- ext4_handle_sync(handle);
-
- inode->i_mtime = inode->i_ctime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ ret2 = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(ret2))
-+ ret = ret2;
- if (ret >= 0)
- ext4_update_inode_fsync_trans(handle, inode, 1);
- out_stop:
-@@ -4146,7 +4150,7 @@ int ext4_truncate(struct inode *inode)
- {
- struct ext4_inode_info *ei = EXT4_I(inode);
- unsigned int credits;
-- int err = 0;
-+ int err = 0, err2;
- handle_t *handle;
- struct address_space *mapping = inode->i_mapping;
-
-@@ -4234,7 +4238,9 @@ out_stop:
- ext4_orphan_del(handle, inode);
-
- inode->i_mtime = inode->i_ctime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ err2 = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(err2 && !err))
-+ err = err2;
- ext4_journal_stop(handle);
-
- trace_ext4_truncate_exit(inode);
-@@ -5292,6 +5298,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
- inode->i_gid = attr->ia_gid;
- error = ext4_mark_inode_dirty(handle, inode);
- ext4_journal_stop(handle);
-+ if (unlikely(error))
-+ return error;
- }
-
- if (attr->ia_valid & ATTR_SIZE) {
-@@ -5777,7 +5785,8 @@ out_unlock:
- * Whenever the user wants stuff synced (sys_sync, sys_msync, sys_fsync)
- * we start and wait on commits.
- */
--int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
-+int __ext4_mark_inode_dirty(handle_t *handle, struct inode *inode,
-+ const char *func, unsigned int line)
- {
- struct ext4_iloc iloc;
- struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-@@ -5787,13 +5796,18 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
- trace_ext4_mark_inode_dirty(inode, _RET_IP_);
- err = ext4_reserve_inode_write(handle, inode, &iloc);
- if (err)
-- return err;
-+ goto out;
-
- if (EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize)
- ext4_try_to_expand_extra_isize(inode, sbi->s_want_extra_isize,
- iloc, handle);
-
-- return ext4_mark_iloc_dirty(handle, inode, &iloc);
-+ err = ext4_mark_iloc_dirty(handle, inode, &iloc);
-+out:
-+ if (unlikely(err))
-+ ext4_error_inode_err(inode, func, line, 0, err,
-+ "mark_inode_dirty error");
-+ return err;
- }
-
- /*
-diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
-index fb6520f37135..c5e3fc998211 100644
---- a/fs/ext4/migrate.c
-+++ b/fs/ext4/migrate.c
-@@ -287,7 +287,7 @@ static int free_ind_block(handle_t *handle, struct inode *inode, __le32 *i_data)
- static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode,
- struct inode *tmp_inode)
- {
-- int retval;
-+ int retval, retval2 = 0;
- __le32 i_data[3];
- struct ext4_inode_info *ei = EXT4_I(inode);
- struct ext4_inode_info *tmp_ei = EXT4_I(tmp_inode);
-@@ -342,7 +342,9 @@ static int ext4_ext_swap_inode_data(handle_t *handle, struct inode *inode,
- * i_blocks when freeing the indirect meta-data blocks
- */
- retval = free_ind_block(handle, inode, i_data);
-- ext4_mark_inode_dirty(handle, inode);
-+ retval2 = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(retval2 && !retval))
-+ retval = retval2;
-
- err_out:
- return retval;
-@@ -601,7 +603,7 @@ int ext4_ind_migrate(struct inode *inode)
- ext4_lblk_t start, end;
- ext4_fsblk_t blk;
- handle_t *handle;
-- int ret;
-+ int ret, ret2 = 0;
-
- if (!ext4_has_feature_extents(inode->i_sb) ||
- (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
-@@ -655,7 +657,9 @@ int ext4_ind_migrate(struct inode *inode)
- memset(ei->i_data, 0, sizeof(ei->i_data));
- for (i = start; i <= end; i++)
- ei->i_data[i] = cpu_to_le32(blk++);
-- ext4_mark_inode_dirty(handle, inode);
-+ ret2 = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(ret2 && !ret))
-+ ret = ret2;
- errout:
- ext4_journal_stop(handle);
- up_write(&EXT4_I(inode)->i_data_sem);
-diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
-index a8aca4772aaa..56738b538ddf 100644
---- a/fs/ext4/namei.c
-+++ b/fs/ext4/namei.c
-@@ -1993,7 +1993,7 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
- {
- unsigned int blocksize = dir->i_sb->s_blocksize;
- int csum_size = 0;
-- int err;
-+ int err, err2;
-
- if (ext4_has_metadata_csum(inode->i_sb))
- csum_size = sizeof(struct ext4_dir_entry_tail);
-@@ -2028,12 +2028,12 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
- dir->i_mtime = dir->i_ctime = current_time(dir);
- ext4_update_dx_flag(dir);
- inode_inc_iversion(dir);
-- ext4_mark_inode_dirty(handle, dir);
-+ err2 = ext4_mark_inode_dirty(handle, dir);
- BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata");
- err = ext4_handle_dirty_dirblock(handle, dir, bh);
- if (err)
- ext4_std_error(dir->i_sb, err);
-- return 0;
-+ return err ? err : err2;
- }
-
- /*
-@@ -2223,7 +2223,9 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
- }
- ext4_clear_inode_flag(dir, EXT4_INODE_INDEX);
- dx_fallback++;
-- ext4_mark_inode_dirty(handle, dir);
-+ retval = ext4_mark_inode_dirty(handle, dir);
-+ if (unlikely(retval))
-+ goto out;
- }
- blocks = dir->i_size >> sb->s_blocksize_bits;
- for (block = 0; block < blocks; block++) {
-@@ -2576,12 +2578,12 @@ static int ext4_add_nondir(handle_t *handle,
- struct inode *inode = *inodep;
- int err = ext4_add_entry(handle, dentry, inode);
- if (!err) {
-- ext4_mark_inode_dirty(handle, inode);
-+ err = ext4_mark_inode_dirty(handle, inode);
- if (IS_DIRSYNC(dir))
- ext4_handle_sync(handle);
- d_instantiate_new(dentry, inode);
- *inodep = NULL;
-- return 0;
-+ return err;
- }
- drop_nlink(inode);
- ext4_orphan_add(handle, inode);
-@@ -2775,7 +2777,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
- {
- handle_t *handle;
- struct inode *inode;
-- int err, credits, retries = 0;
-+ int err, err2 = 0, credits, retries = 0;
-
- if (EXT4_DIR_LINK_MAX(dir))
- return -EMLINK;
-@@ -2808,7 +2810,9 @@ out_clear_inode:
- clear_nlink(inode);
- ext4_orphan_add(handle, inode);
- unlock_new_inode(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ err2 = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(err2))
-+ err = err2;
- ext4_journal_stop(handle);
- iput(inode);
- goto out_retry;
-@@ -3148,10 +3152,12 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
- inode->i_size = 0;
- ext4_orphan_add(handle, inode);
- inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ retval = ext4_mark_inode_dirty(handle, inode);
-+ if (retval)
-+ goto end_rmdir;
- ext4_dec_count(handle, dir);
- ext4_update_dx_flag(dir);
-- ext4_mark_inode_dirty(handle, dir);
-+ retval = ext4_mark_inode_dirty(handle, dir);
-
- #ifdef CONFIG_UNICODE
- /* VFS negative dentries are incompatible with Encoding and
-@@ -3221,7 +3227,9 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
- goto end_unlink;
- dir->i_ctime = dir->i_mtime = current_time(dir);
- ext4_update_dx_flag(dir);
-- ext4_mark_inode_dirty(handle, dir);
-+ retval = ext4_mark_inode_dirty(handle, dir);
-+ if (retval)
-+ goto end_unlink;
- if (inode->i_nlink == 0)
- ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
- dentry->d_name.len, dentry->d_name.name);
-@@ -3230,7 +3238,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
- if (!inode->i_nlink)
- ext4_orphan_add(handle, inode);
- inode->i_ctime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ retval = ext4_mark_inode_dirty(handle, inode);
-
- #ifdef CONFIG_UNICODE
- /* VFS negative dentries are incompatible with Encoding and
-@@ -3419,7 +3427,7 @@ retry:
-
- err = ext4_add_entry(handle, dentry, inode);
- if (!err) {
-- ext4_mark_inode_dirty(handle, inode);
-+ err = ext4_mark_inode_dirty(handle, inode);
- /* this can happen only for tmpfile being
- * linked the first time
- */
-@@ -3531,7 +3539,7 @@ static int ext4_rename_dir_finish(handle_t *handle, struct ext4_renament *ent,
- static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
- unsigned ino, unsigned file_type)
- {
-- int retval;
-+ int retval, retval2;
-
- BUFFER_TRACE(ent->bh, "get write access");
- retval = ext4_journal_get_write_access(handle, ent->bh);
-@@ -3543,19 +3551,19 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
- inode_inc_iversion(ent->dir);
- ent->dir->i_ctime = ent->dir->i_mtime =
- current_time(ent->dir);
-- ext4_mark_inode_dirty(handle, ent->dir);
-+ retval = ext4_mark_inode_dirty(handle, ent->dir);
- BUFFER_TRACE(ent->bh, "call ext4_handle_dirty_metadata");
- if (!ent->inlined) {
-- retval = ext4_handle_dirty_dirblock(handle, ent->dir, ent->bh);
-- if (unlikely(retval)) {
-- ext4_std_error(ent->dir->i_sb, retval);
-- return retval;
-+ retval2 = ext4_handle_dirty_dirblock(handle, ent->dir, ent->bh);
-+ if (unlikely(retval2)) {
-+ ext4_std_error(ent->dir->i_sb, retval2);
-+ return retval2;
- }
- }
- brelse(ent->bh);
- ent->bh = NULL;
-
-- return 0;
-+ return retval;
- }
-
- static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
-@@ -3790,7 +3798,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
- EXT4_FT_CHRDEV);
- if (retval)
- goto end_rename;
-- ext4_mark_inode_dirty(handle, whiteout);
-+ retval = ext4_mark_inode_dirty(handle, whiteout);
-+ if (unlikely(retval))
-+ goto end_rename;
- }
- if (!new.bh) {
- retval = ext4_add_entry(handle, new.dentry, old.inode);
-@@ -3811,7 +3821,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
- * rename.
- */
- old.inode->i_ctime = current_time(old.inode);
-- ext4_mark_inode_dirty(handle, old.inode);
-+ retval = ext4_mark_inode_dirty(handle, old.inode);
-+ if (unlikely(retval))
-+ goto end_rename;
-
- if (!whiteout) {
- /*
-@@ -3840,12 +3852,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
- } else {
- ext4_inc_count(handle, new.dir);
- ext4_update_dx_flag(new.dir);
-- ext4_mark_inode_dirty(handle, new.dir);
-+ retval = ext4_mark_inode_dirty(handle, new.dir);
-+ if (unlikely(retval))
-+ goto end_rename;
- }
- }
-- ext4_mark_inode_dirty(handle, old.dir);
-+ retval = ext4_mark_inode_dirty(handle, old.dir);
-+ if (unlikely(retval))
-+ goto end_rename;
- if (new.inode) {
-- ext4_mark_inode_dirty(handle, new.inode);
-+ retval = ext4_mark_inode_dirty(handle, new.inode);
-+ if (unlikely(retval))
-+ goto end_rename;
- if (!new.inode->i_nlink)
- ext4_orphan_add(handle, new.inode);
- }
-@@ -3979,8 +3997,12 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
- ctime = current_time(old.inode);
- old.inode->i_ctime = ctime;
- new.inode->i_ctime = ctime;
-- ext4_mark_inode_dirty(handle, old.inode);
-- ext4_mark_inode_dirty(handle, new.inode);
-+ retval = ext4_mark_inode_dirty(handle, old.inode);
-+ if (unlikely(retval))
-+ goto end_rename;
-+ retval = ext4_mark_inode_dirty(handle, new.inode);
-+ if (unlikely(retval))
-+ goto end_rename;
-
- if (old.dir_bh) {
- retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino);
-diff --git a/fs/ext4/super.c b/fs/ext4/super.c
-index bf5fcb477f66..7318ca71b69e 100644
---- a/fs/ext4/super.c
-+++ b/fs/ext4/super.c
-@@ -522,9 +522,6 @@ static void ext4_handle_error(struct super_block *sb)
- smp_wmb();
- sb->s_flags |= SB_RDONLY;
- } else if (test_opt(sb, ERRORS_PANIC)) {
-- if (EXT4_SB(sb)->s_journal &&
-- !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR))
-- return;
- panic("EXT4-fs (device %s): panic forced after error\n",
- sb->s_id);
- }
-@@ -725,23 +722,20 @@ void __ext4_abort(struct super_block *sb, const char *function,
- va_end(args);
-
- if (sb_rdonly(sb) == 0) {
-- ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
- EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED;
-+ if (EXT4_SB(sb)->s_journal)
-+ jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
-+
-+ ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
- /*
- * Make sure updated value of ->s_mount_flags will be visible
- * before ->s_flags update
- */
- smp_wmb();
- sb->s_flags |= SB_RDONLY;
-- if (EXT4_SB(sb)->s_journal)
-- jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
- }
-- if (test_opt(sb, ERRORS_PANIC) && !system_going_down()) {
-- if (EXT4_SB(sb)->s_journal &&
-- !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR))
-- return;
-+ if (test_opt(sb, ERRORS_PANIC) && !system_going_down())
- panic("EXT4-fs panic from previous error\n");
-- }
- }
-
- void __ext4_msg(struct super_block *sb,
-@@ -2086,6 +2080,16 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
- #endif
- } else if (token == Opt_dax) {
- #ifdef CONFIG_FS_DAX
-+ if (is_remount && test_opt(sb, DAX)) {
-+ ext4_msg(sb, KERN_ERR, "can't mount with "
-+ "both data=journal and dax");
-+ return -1;
-+ }
-+ if (is_remount && !(sbi->s_mount_opt & EXT4_MOUNT_DAX)) {
-+ ext4_msg(sb, KERN_ERR, "can't change "
-+ "dax mount option while remounting");
-+ return -1;
-+ }
- ext4_msg(sb, KERN_WARNING,
- "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
- sbi->s_mount_opt |= m->mount_opt;
-@@ -2344,6 +2348,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
- ext4_msg(sb, KERN_ERR, "revision level too high, "
- "forcing read-only mode");
- err = -EROFS;
-+ goto done;
- }
- if (read_only)
- goto done;
-@@ -5412,12 +5417,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
- err = -EINVAL;
- goto restore_opts;
- }
-- if (test_opt(sb, DAX)) {
-- ext4_msg(sb, KERN_ERR, "can't mount with "
-- "both data=journal and dax");
-- err = -EINVAL;
-- goto restore_opts;
-- }
- } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) {
- if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
- ext4_msg(sb, KERN_ERR, "can't mount with "
-@@ -5433,12 +5432,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
- goto restore_opts;
- }
-
-- if ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT4_MOUNT_DAX) {
-- ext4_msg(sb, KERN_WARNING, "warning: refusing change of "
-- "dax flag with busy inodes while remounting");
-- sbi->s_mount_opt ^= EXT4_MOUNT_DAX;
-- }
--
- if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
- ext4_abort(sb, EXT4_ERR_ESHUTDOWN, "Abort forced by user");
-
-@@ -5885,7 +5878,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
- EXT4_I(inode)->i_flags |= EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL;
- inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
- S_NOATIME | S_IMMUTABLE);
-- ext4_mark_inode_dirty(handle, inode);
-+ err = ext4_mark_inode_dirty(handle, inode);
- ext4_journal_stop(handle);
- unlock_inode:
- inode_unlock(inode);
-@@ -5987,12 +5980,14 @@ static int ext4_quota_off(struct super_block *sb, int type)
- * this is not a hard failure and quotas are already disabled.
- */
- handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
-- if (IS_ERR(handle))
-+ if (IS_ERR(handle)) {
-+ err = PTR_ERR(handle);
- goto out_unlock;
-+ }
- EXT4_I(inode)->i_flags &= ~(EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL);
- inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
- inode->i_mtime = inode->i_ctime = current_time(inode);
-- ext4_mark_inode_dirty(handle, inode);
-+ err = ext4_mark_inode_dirty(handle, inode);
- ext4_journal_stop(handle);
- out_unlock:
- inode_unlock(inode);
-@@ -6050,7 +6045,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
- {
- struct inode *inode = sb_dqopt(sb)->files[type];
- ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
-- int err, offset = off & (sb->s_blocksize - 1);
-+ int err = 0, err2 = 0, offset = off & (sb->s_blocksize - 1);
- int retries = 0;
- struct buffer_head *bh;
- handle_t *handle = journal_current_handle();
-@@ -6098,9 +6093,11 @@ out:
- if (inode->i_size < off + len) {
- i_size_write(inode, off + len);
- EXT4_I(inode)->i_disksize = inode->i_size;
-- ext4_mark_inode_dirty(handle, inode);
-+ err2 = ext4_mark_inode_dirty(handle, inode);
-+ if (unlikely(err2 && !err))
-+ err = err2;
- }
-- return len;
-+ return err ? err : len;
- }
- #endif
-
-diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
-index 01ba66373e97..9b29a40738ac 100644
---- a/fs/ext4/xattr.c
-+++ b/fs/ext4/xattr.c
-@@ -1327,7 +1327,7 @@ static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
- int blocksize = ea_inode->i_sb->s_blocksize;
- int max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits;
- int csize, wsize = 0;
-- int ret = 0;
-+ int ret = 0, ret2 = 0;
- int retries = 0;
-
- retry:
-@@ -1385,7 +1385,9 @@ retry:
- ext4_update_i_disksize(ea_inode, wsize);
- inode_unlock(ea_inode);
-
-- ext4_mark_inode_dirty(handle, ea_inode);
-+ ret2 = ext4_mark_inode_dirty(handle, ea_inode);
-+ if (unlikely(ret2 && !ret))
-+ ret = ret2;
-
- out:
- brelse(bh);
-diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
-index 852890b72d6a..448b3dc6f925 100644
---- a/fs/f2fs/checkpoint.c
-+++ b/fs/f2fs/checkpoint.c
-@@ -889,8 +889,8 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)
- int i;
- int err;
-
-- sbi->ckpt = f2fs_kzalloc(sbi, array_size(blk_size, cp_blks),
-- GFP_KERNEL);
-+ sbi->ckpt = f2fs_kvzalloc(sbi, array_size(blk_size, cp_blks),
-+ GFP_KERNEL);
- if (!sbi->ckpt)
- return -ENOMEM;
- /*
-diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
-index df7b2d15eacd..a5b2e72174bb 100644
---- a/fs/f2fs/compress.c
-+++ b/fs/f2fs/compress.c
-@@ -236,7 +236,12 @@ static int lz4_init_compress_ctx(struct compress_ctx *cc)
- if (!cc->private)
- return -ENOMEM;
-
-- cc->clen = LZ4_compressBound(PAGE_SIZE << cc->log_cluster_size);
-+ /*
-+ * we do not change cc->clen to LZ4_compressBound(inputsize) to
-+ * adapt worst compress case, because lz4 compressor can handle
-+ * output budget properly.
-+ */
-+ cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE;
- return 0;
- }
-
-@@ -252,11 +257,9 @@ static int lz4_compress_pages(struct compress_ctx *cc)
-
- len = LZ4_compress_default(cc->rbuf, cc->cbuf->cdata, cc->rlen,
- cc->clen, cc->private);
-- if (!len) {
-- printk_ratelimited("%sF2FS-fs (%s): lz4 compress failed\n",
-- KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id);
-- return -EIO;
-- }
-+ if (!len)
-+ return -EAGAIN;
-+
- cc->clen = len;
- return 0;
- }
-@@ -366,6 +369,13 @@ static int zstd_compress_pages(struct compress_ctx *cc)
- return -EIO;
- }
-
-+ /*
-+ * there is compressed data remained in intermediate buffer due to
-+ * no more space in cbuf.cdata
-+ */
-+ if (ret)
-+ return -EAGAIN;
-+
- cc->clen = outbuf.pos;
- return 0;
- }
-diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
-index cdf2f626bea7..10491ae1cb85 100644
---- a/fs/f2fs/data.c
-+++ b/fs/f2fs/data.c
-@@ -2130,16 +2130,16 @@ submit_and_realloc:
- page->index, for_write);
- if (IS_ERR(bio)) {
- ret = PTR_ERR(bio);
-- bio = NULL;
- dic->failed = true;
- if (refcount_sub_and_test(dic->nr_cpages - i,
-- &dic->ref))
-+ &dic->ref)) {
- f2fs_decompress_end_io(dic->rpages,
- cc->cluster_size, true,
- false);
-- f2fs_free_dic(dic);
-+ f2fs_free_dic(dic);
-+ }
- f2fs_put_dnode(&dn);
-- *bio_ret = bio;
-+ *bio_ret = NULL;
- return ret;
- }
- }
-diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
-index 44bfc464df78..54e90dbb09e7 100644
---- a/fs/f2fs/dir.c
-+++ b/fs/f2fs/dir.c
-@@ -107,36 +107,28 @@ static struct f2fs_dir_entry *find_in_block(struct inode *dir,
- /*
- * Test whether a case-insensitive directory entry matches the filename
- * being searched for.
-- *
-- * Returns: 0 if the directory entry matches, more than 0 if it
-- * doesn't match or less than zero on error.
- */
--int f2fs_ci_compare(const struct inode *parent, const struct qstr *name,
-- const struct qstr *entry, bool quick)
-+static bool f2fs_match_ci_name(const struct inode *dir, const struct qstr *name,
-+ const struct qstr *entry, bool quick)
- {
-- const struct f2fs_sb_info *sbi = F2FS_SB(parent->i_sb);
-+ const struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
- const struct unicode_map *um = sbi->s_encoding;
-- int ret;
-+ int res;
-
- if (quick)
-- ret = utf8_strncasecmp_folded(um, name, entry);
-+ res = utf8_strncasecmp_folded(um, name, entry);
- else
-- ret = utf8_strncasecmp(um, name, entry);
--
-- if (ret < 0) {
-- /* Handle invalid character sequence as either an error
-- * or as an opaque byte sequence.
-+ res = utf8_strncasecmp(um, name, entry);
-+ if (res < 0) {
-+ /*
-+ * In strict mode, ignore invalid names. In non-strict mode,
-+ * fall back to treating them as opaque byte sequences.
- */
-- if (f2fs_has_strict_mode(sbi))
-- return -EINVAL;
--
-- if (name->len != entry->len)
-- return 1;
--
-- return !!memcmp(name->name, entry->name, name->len);
-+ if (f2fs_has_strict_mode(sbi) || name->len != entry->len)
-+ return false;
-+ return !memcmp(name->name, entry->name, name->len);
- }
--
-- return ret;
-+ return res == 0;
- }
-
- static void f2fs_fname_setup_ci_filename(struct inode *dir,
-@@ -188,10 +180,10 @@ static inline bool f2fs_match_name(struct f2fs_dentry_ptr *d,
- if (cf_str->name) {
- struct qstr cf = {.name = cf_str->name,
- .len = cf_str->len};
-- return !f2fs_ci_compare(parent, &cf, &entry, true);
-+ return f2fs_match_ci_name(parent, &cf, &entry, true);
- }
-- return !f2fs_ci_compare(parent, fname->usr_fname, &entry,
-- false);
-+ return f2fs_match_ci_name(parent, fname->usr_fname, &entry,
-+ false);
- }
- #endif
- if (fscrypt_match_name(fname, d->filename[bit_pos],
-@@ -1080,17 +1072,41 @@ const struct file_operations f2fs_dir_operations = {
- static int f2fs_d_compare(const struct dentry *dentry, unsigned int len,
- const char *str, const struct qstr *name)
- {
-- struct qstr qstr = {.name = str, .len = len };
- const struct dentry *parent = READ_ONCE(dentry->d_parent);
-- const struct inode *inode = READ_ONCE(parent->d_inode);
-+ const struct inode *dir = READ_ONCE(parent->d_inode);
-+ const struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
-+ struct qstr entry = QSTR_INIT(str, len);
-+ char strbuf[DNAME_INLINE_LEN];
-+ int res;
-+
-+ if (!dir || !IS_CASEFOLDED(dir))
-+ goto fallback;
-
-- if (!inode || !IS_CASEFOLDED(inode)) {
-- if (len != name->len)
-- return -1;
-- return memcmp(str, name->name, len);
-+ /*
-+ * If the dentry name is stored in-line, then it may be concurrently
-+ * modified by a rename. If this happens, the VFS will eventually retry
-+ * the lookup, so it doesn't matter what ->d_compare() returns.
-+ * However, it's unsafe to call utf8_strncasecmp() with an unstable
-+ * string. Therefore, we have to copy the name into a temporary buffer.
-+ */
-+ if (len <= DNAME_INLINE_LEN - 1) {
-+ memcpy(strbuf, str, len);
-+ strbuf[len] = 0;
-+ entry.name = strbuf;
-+ /* prevent compiler from optimizing out the temporary buffer */
-+ barrier();
- }
-
-- return f2fs_ci_compare(inode, name, &qstr, false);
-+ res = utf8_strncasecmp(sbi->s_encoding, name, &entry);
-+ if (res >= 0)
-+ return res;
-+
-+ if (f2fs_has_strict_mode(sbi))
-+ return -EINVAL;
-+fallback:
-+ if (len != name->len)
-+ return 1;
-+ return !!memcmp(str, name->name, len);
- }
-
- static int f2fs_d_hash(const struct dentry *dentry, struct qstr *str)
-diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
-index 7c5dd7f666a0..5a0f95dfbac2 100644
---- a/fs/f2fs/f2fs.h
-+++ b/fs/f2fs/f2fs.h
-@@ -2936,18 +2936,12 @@ static inline bool f2fs_may_extent_tree(struct inode *inode)
- static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
- size_t size, gfp_t flags)
- {
-- void *ret;
--
- if (time_to_inject(sbi, FAULT_KMALLOC)) {
- f2fs_show_injection_info(sbi, FAULT_KMALLOC);
- return NULL;
- }
-
-- ret = kmalloc(size, flags);
-- if (ret)
-- return ret;
--
-- return kvmalloc(size, flags);
-+ return kmalloc(size, flags);
- }
-
- static inline void *f2fs_kzalloc(struct f2fs_sb_info *sbi,
-@@ -3107,11 +3101,6 @@ int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
- bool hot, bool set);
- struct dentry *f2fs_get_parent(struct dentry *child);
-
--extern int f2fs_ci_compare(const struct inode *parent,
-- const struct qstr *name,
-- const struct qstr *entry,
-- bool quick);
--
- /*
- * dir.c
- */
-@@ -3656,7 +3645,7 @@ static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
- static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
- static inline void __init f2fs_create_root_stats(void) { }
- static inline void f2fs_destroy_root_stats(void) { }
--static inline void update_sit_info(struct f2fs_sb_info *sbi) {}
-+static inline void f2fs_update_sit_info(struct f2fs_sb_info *sbi) {}
- #endif
-
- extern const struct file_operations f2fs_dir_operations;
-diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
-index 6ab8f621a3c5..30b35915fa3a 100644
---- a/fs/f2fs/file.c
-+++ b/fs/f2fs/file.c
-@@ -2219,8 +2219,15 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
-
- if (in != F2FS_GOING_DOWN_FULLSYNC) {
- ret = mnt_want_write_file(filp);
-- if (ret)
-+ if (ret) {
-+ if (ret == -EROFS) {
-+ ret = 0;
-+ f2fs_stop_checkpoint(sbi, false);
-+ set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
-+ trace_f2fs_shutdown(sbi, in, ret);
-+ }
- return ret;
-+ }
- }
-
- switch (in) {
-diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
-index ecbd6bd14a49..daf531e69b67 100644
---- a/fs/f2fs/node.c
-+++ b/fs/f2fs/node.c
-@@ -2928,7 +2928,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
- return 0;
-
- nm_i->nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8);
-- nm_i->nat_bits = f2fs_kzalloc(sbi,
-+ nm_i->nat_bits = f2fs_kvzalloc(sbi,
- nm_i->nat_bits_blocks << F2FS_BLKSIZE_BITS, GFP_KERNEL);
- if (!nm_i->nat_bits)
- return -ENOMEM;
-@@ -3061,9 +3061,9 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi)
- int i;
-
- nm_i->free_nid_bitmap =
-- f2fs_kzalloc(sbi, array_size(sizeof(unsigned char *),
-- nm_i->nat_blocks),
-- GFP_KERNEL);
-+ f2fs_kvzalloc(sbi, array_size(sizeof(unsigned char *),
-+ nm_i->nat_blocks),
-+ GFP_KERNEL);
- if (!nm_i->free_nid_bitmap)
- return -ENOMEM;
-
-diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
-index 56ccb8323e21..4696c9cb47a5 100644
---- a/fs/f2fs/super.c
-+++ b/fs/f2fs/super.c
-@@ -1303,7 +1303,8 @@ static int f2fs_statfs_project(struct super_block *sb,
- limit >>= sb->s_blocksize_bits;
-
- if (limit && buf->f_blocks > limit) {
-- curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
-+ curblock = (dquot->dq_dqb.dqb_curspace +
-+ dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits;
- buf->f_blocks = limit;
- buf->f_bfree = buf->f_bavail =
- (buf->f_blocks > curblock) ?
-@@ -3038,7 +3039,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
- if (nr_sectors & (bdev_zone_sectors(bdev) - 1))
- FDEV(devi).nr_blkz++;
-
-- FDEV(devi).blkz_seq = f2fs_kzalloc(sbi,
-+ FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,
- BITS_TO_LONGS(FDEV(devi).nr_blkz)
- * sizeof(unsigned long),
- GFP_KERNEL);
-diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
-index 97eec7522bf2..5c155437a455 100644
---- a/fs/fuse/dev.c
-+++ b/fs/fuse/dev.c
-@@ -1977,8 +1977,9 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
- struct pipe_buffer *ibuf;
- struct pipe_buffer *obuf;
-
-- BUG_ON(nbuf >= pipe->ring_size);
-- BUG_ON(tail == head);
-+ if (WARN_ON(nbuf >= count || tail == head))
-+ goto out_free;
-+
- ibuf = &pipe->bufs[tail & mask];
- obuf = &bufs[nbuf];
-
-diff --git a/fs/fuse/file.c b/fs/fuse/file.c
-index 9d67b830fb7a..e3afceecaa6b 100644
---- a/fs/fuse/file.c
-+++ b/fs/fuse/file.c
-@@ -712,6 +712,7 @@ static ssize_t fuse_async_req_send(struct fuse_conn *fc,
- spin_unlock(&io->lock);
-
- ia->ap.args.end = fuse_aio_complete_req;
-+ ia->ap.args.may_block = io->should_dirty;
- err = fuse_simple_background(fc, &ia->ap.args, GFP_KERNEL);
- if (err)
- fuse_aio_complete_req(fc, &ia->ap.args, err);
-@@ -3279,13 +3280,11 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
- if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb)
- return -EXDEV;
-
-- if (fc->writeback_cache) {
-- inode_lock(inode_in);
-- err = fuse_writeback_range(inode_in, pos_in, pos_in + len);
-- inode_unlock(inode_in);
-- if (err)
-- return err;
-- }
-+ inode_lock(inode_in);
-+ err = fuse_writeback_range(inode_in, pos_in, pos_in + len - 1);
-+ inode_unlock(inode_in);
-+ if (err)
-+ return err;
-
- inode_lock(inode_out);
-
-@@ -3293,11 +3292,27 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
- if (err)
- goto out;
-
-- if (fc->writeback_cache) {
-- err = fuse_writeback_range(inode_out, pos_out, pos_out + len);
-- if (err)
-- goto out;
-- }
-+ /*
-+ * Write out dirty pages in the destination file before sending the COPY
-+ * request to userspace. After the request is completed, truncate off
-+ * pages (including partial ones) from the cache that have been copied,
-+ * since these contain stale data at that point.
-+ *
-+ * This should be mostly correct, but if the COPY writes to partial
-+ * pages (at the start or end) and the parts not covered by the COPY are
-+ * written through a memory map after calling fuse_writeback_range(),
-+ * then these partial page modifications will be lost on truncation.
-+ *
-+ * It is unlikely that someone would rely on such mixed style
-+ * modifications. Yet this does give less guarantees than if the
-+ * copying was performed with write(2).
-+ *
-+ * To fix this a i_mmap_sem style lock could be used to prevent new
-+ * faults while the copy is ongoing.
-+ */
-+ err = fuse_writeback_range(inode_out, pos_out, pos_out + len - 1);
-+ if (err)
-+ goto out;
-
- if (is_unstable)
- set_bit(FUSE_I_SIZE_UNSTABLE, &fi_out->state);
-@@ -3318,6 +3333,10 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
- if (err)
- goto out;
-
-+ truncate_inode_pages_range(inode_out->i_mapping,
-+ ALIGN_DOWN(pos_out, PAGE_SIZE),
-+ ALIGN(pos_out + outarg.size, PAGE_SIZE) - 1);
-+
- if (fc->writeback_cache) {
- fuse_write_update_size(inode_out, pos_out + outarg.size);
- file_update_time(file_out);
-diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
-index ca344bf71404..d7cde216fc87 100644
---- a/fs/fuse/fuse_i.h
-+++ b/fs/fuse/fuse_i.h
-@@ -249,6 +249,7 @@ struct fuse_args {
- bool out_argvar:1;
- bool page_zeroing:1;
- bool page_replace:1;
-+ bool may_block:1;
- struct fuse_in_arg in_args[3];
- struct fuse_arg out_args[2];
- void (*end)(struct fuse_conn *fc, struct fuse_args *args, int error);
-diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
-index bade74768903..0c6ef5d3c6ab 100644
---- a/fs/fuse/virtio_fs.c
-+++ b/fs/fuse/virtio_fs.c
-@@ -60,6 +60,12 @@ struct virtio_fs_forget {
- struct virtio_fs_forget_req req;
- };
-
-+struct virtio_fs_req_work {
-+ struct fuse_req *req;
-+ struct virtio_fs_vq *fsvq;
-+ struct work_struct done_work;
-+};
-+
- static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
- struct fuse_req *req, bool in_flight);
-
-@@ -485,19 +491,67 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)
- }
-
- /* Work function for request completion */
-+static void virtio_fs_request_complete(struct fuse_req *req,
-+ struct virtio_fs_vq *fsvq)
-+{
-+ struct fuse_pqueue *fpq = &fsvq->fud->pq;
-+ struct fuse_conn *fc = fsvq->fud->fc;
-+ struct fuse_args *args;
-+ struct fuse_args_pages *ap;
-+ unsigned int len, i, thislen;
-+ struct page *page;
-+
-+ /*
-+ * TODO verify that server properly follows FUSE protocol
-+ * (oh.uniq, oh.len)
-+ */
-+ args = req->args;
-+ copy_args_from_argbuf(args, req);
-+
-+ if (args->out_pages && args->page_zeroing) {
-+ len = args->out_args[args->out_numargs - 1].size;
-+ ap = container_of(args, typeof(*ap), args);
-+ for (i = 0; i < ap->num_pages; i++) {
-+ thislen = ap->descs[i].length;
-+ if (len < thislen) {
-+ WARN_ON(ap->descs[i].offset);
-+ page = ap->pages[i];
-+ zero_user_segment(page, len, thislen);
-+ len = 0;
-+ } else {
-+ len -= thislen;
-+ }
-+ }
-+ }
-+
-+ spin_lock(&fpq->lock);
-+ clear_bit(FR_SENT, &req->flags);
-+ spin_unlock(&fpq->lock);
-+
-+ fuse_request_end(fc, req);
-+ spin_lock(&fsvq->lock);
-+ dec_in_flight_req(fsvq);
-+ spin_unlock(&fsvq->lock);
-+}
-+
-+static void virtio_fs_complete_req_work(struct work_struct *work)
-+{
-+ struct virtio_fs_req_work *w =
-+ container_of(work, typeof(*w), done_work);
-+
-+ virtio_fs_request_complete(w->req, w->fsvq);
-+ kfree(w);
-+}
-+
- static void virtio_fs_requests_done_work(struct work_struct *work)
- {
- struct virtio_fs_vq *fsvq = container_of(work, struct virtio_fs_vq,
- done_work);
- struct fuse_pqueue *fpq = &fsvq->fud->pq;
-- struct fuse_conn *fc = fsvq->fud->fc;
- struct virtqueue *vq = fsvq->vq;
- struct fuse_req *req;
-- struct fuse_args_pages *ap;
- struct fuse_req *next;
-- struct fuse_args *args;
-- unsigned int len, i, thislen;
-- struct page *page;
-+ unsigned int len;
- LIST_HEAD(reqs);
-
- /* Collect completed requests off the virtqueue */
-@@ -515,38 +569,20 @@ static void virtio_fs_requests_done_work(struct work_struct *work)
-
- /* End requests */
- list_for_each_entry_safe(req, next, &reqs, list) {
-- /*
-- * TODO verify that server properly follows FUSE protocol
-- * (oh.uniq, oh.len)
-- */
-- args = req->args;
-- copy_args_from_argbuf(args, req);
--
-- if (args->out_pages && args->page_zeroing) {
-- len = args->out_args[args->out_numargs - 1].size;
-- ap = container_of(args, typeof(*ap), args);
-- for (i = 0; i < ap->num_pages; i++) {
-- thislen = ap->descs[i].length;
-- if (len < thislen) {
-- WARN_ON(ap->descs[i].offset);
-- page = ap->pages[i];
-- zero_user_segment(page, len, thislen);
-- len = 0;
-- } else {
-- len -= thislen;
-- }
-- }
-- }
--
-- spin_lock(&fpq->lock);
-- clear_bit(FR_SENT, &req->flags);
- list_del_init(&req->list);
-- spin_unlock(&fpq->lock);
-
-- fuse_request_end(fc, req);
-- spin_lock(&fsvq->lock);
-- dec_in_flight_req(fsvq);
-- spin_unlock(&fsvq->lock);
-+ /* blocking async request completes in a worker context */
-+ if (req->args->may_block) {
-+ struct virtio_fs_req_work *w;
-+
-+ w = kzalloc(sizeof(*w), GFP_NOFS | __GFP_NOFAIL);
-+ INIT_WORK(&w->done_work, virtio_fs_complete_req_work);
-+ w->fsvq = fsvq;
-+ w->req = req;
-+ schedule_work(&w->done_work);
-+ } else {
-+ virtio_fs_request_complete(req, fsvq);
-+ }
- }
- }
-
-diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
-index 0644e58c6191..b7a5221bea7d 100644
---- a/fs/gfs2/log.c
-+++ b/fs/gfs2/log.c
-@@ -1003,8 +1003,10 @@ out:
- * @new: New transaction to be merged
- */
-
--static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
-+static void gfs2_merge_trans(struct gfs2_sbd *sdp, struct gfs2_trans *new)
- {
-+ struct gfs2_trans *old = sdp->sd_log_tr;
-+
- WARN_ON_ONCE(!test_bit(TR_ATTACHED, &old->tr_flags));
-
- old->tr_num_buf_new += new->tr_num_buf_new;
-@@ -1016,6 +1018,11 @@ static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
-
- list_splice_tail_init(&new->tr_databuf, &old->tr_databuf);
- list_splice_tail_init(&new->tr_buf, &old->tr_buf);
-+
-+ spin_lock(&sdp->sd_ail_lock);
-+ list_splice_tail_init(&new->tr_ail1_list, &old->tr_ail1_list);
-+ list_splice_tail_init(&new->tr_ail2_list, &old->tr_ail2_list);
-+ spin_unlock(&sdp->sd_ail_lock);
- }
-
- static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
-@@ -1027,7 +1034,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
- gfs2_log_lock(sdp);
-
- if (sdp->sd_log_tr) {
-- gfs2_merge_trans(sdp->sd_log_tr, tr);
-+ gfs2_merge_trans(sdp, tr);
- } else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) {
- gfs2_assert_withdraw(sdp, test_bit(TR_ALLOCED, &tr->tr_flags));
- sdp->sd_log_tr = tr;
-diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
-index e2b69ffcc6a8..094f5fe7c009 100644
---- a/fs/gfs2/ops_fstype.c
-+++ b/fs/gfs2/ops_fstype.c
-@@ -880,7 +880,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/io_uring.c b/fs/io_uring.c
-index 2698e9b08490..1829be7f63a3 100644
---- a/fs/io_uring.c
-+++ b/fs/io_uring.c
-@@ -513,7 +513,6 @@ enum {
- REQ_F_INFLIGHT_BIT,
- REQ_F_CUR_POS_BIT,
- REQ_F_NOWAIT_BIT,
-- REQ_F_IOPOLL_COMPLETED_BIT,
- REQ_F_LINK_TIMEOUT_BIT,
- REQ_F_TIMEOUT_BIT,
- REQ_F_ISREG_BIT,
-@@ -556,8 +555,6 @@ enum {
- REQ_F_CUR_POS = BIT(REQ_F_CUR_POS_BIT),
- /* must not punt to workers */
- REQ_F_NOWAIT = BIT(REQ_F_NOWAIT_BIT),
-- /* polled IO has completed */
-- REQ_F_IOPOLL_COMPLETED = BIT(REQ_F_IOPOLL_COMPLETED_BIT),
- /* has linked timeout */
- REQ_F_LINK_TIMEOUT = BIT(REQ_F_LINK_TIMEOUT_BIT),
- /* timeout request */
-@@ -618,6 +615,8 @@ struct io_kiocb {
- int cflags;
- bool needs_fixed_file;
- u8 opcode;
-+ /* polled IO has completed */
-+ u8 iopoll_completed;
-
- u16 buf_index;
-
-@@ -1691,6 +1690,18 @@ static int io_put_kbuf(struct io_kiocb *req)
- return cflags;
- }
-
-+static void io_iopoll_queue(struct list_head *again)
-+{
-+ struct io_kiocb *req;
-+
-+ do {
-+ req = list_first_entry(again, struct io_kiocb, list);
-+ list_del(&req->list);
-+ refcount_inc(&req->refs);
-+ io_queue_async_work(req);
-+ } while (!list_empty(again));
-+}
-+
- /*
- * Find and free completed poll iocbs
- */
-@@ -1699,12 +1710,21 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
- {
- struct req_batch rb;
- struct io_kiocb *req;
-+ LIST_HEAD(again);
-+
-+ /* order with ->result store in io_complete_rw_iopoll() */
-+ smp_rmb();
-
- rb.to_free = rb.need_iter = 0;
- while (!list_empty(done)) {
- int cflags = 0;
-
- req = list_first_entry(done, struct io_kiocb, list);
-+ if (READ_ONCE(req->result) == -EAGAIN) {
-+ req->iopoll_completed = 0;
-+ list_move_tail(&req->list, &again);
-+ continue;
-+ }
- list_del(&req->list);
-
- if (req->flags & REQ_F_BUFFER_SELECTED)
-@@ -1722,18 +1742,9 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
- if (ctx->flags & IORING_SETUP_SQPOLL)
- io_cqring_ev_posted(ctx);
- io_free_req_many(ctx, &rb);
--}
-
--static void io_iopoll_queue(struct list_head *again)
--{
-- struct io_kiocb *req;
--
-- do {
-- req = list_first_entry(again, struct io_kiocb, list);
-- list_del(&req->list);
-- refcount_inc(&req->refs);
-- io_queue_async_work(req);
-- } while (!list_empty(again));
-+ if (!list_empty(&again))
-+ io_iopoll_queue(&again);
- }
-
- static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,
-@@ -1741,7 +1752,6 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,
- {
- struct io_kiocb *req, *tmp;
- LIST_HEAD(done);
-- LIST_HEAD(again);
- bool spin;
- int ret;
-
-@@ -1760,20 +1770,13 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,
- * If we find a request that requires polling, break out
- * and complete those lists first, if we have entries there.
- */
-- if (req->flags & REQ_F_IOPOLL_COMPLETED) {
-+ if (READ_ONCE(req->iopoll_completed)) {
- list_move_tail(&req->list, &done);
- continue;
- }
- if (!list_empty(&done))
- break;
-
-- if (req->result == -EAGAIN) {
-- list_move_tail(&req->list, &again);
-- continue;
-- }
-- if (!list_empty(&again))
-- break;
--
- ret = kiocb->ki_filp->f_op->iopoll(kiocb, spin);
- if (ret < 0)
- break;
-@@ -1786,9 +1789,6 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,
- if (!list_empty(&done))
- io_iopoll_complete(ctx, nr_events, &done);
-
-- if (!list_empty(&again))
-- io_iopoll_queue(&again);
--
- return ret;
- }
-
-@@ -1937,11 +1937,15 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)
- if (kiocb->ki_flags & IOCB_WRITE)
- kiocb_end_write(req);
-
-- if (res != req->result)
-+ if (res != -EAGAIN && res != req->result)
- req_set_fail_links(req);
-- req->result = res;
-- if (res != -EAGAIN)
-- req->flags |= REQ_F_IOPOLL_COMPLETED;
-+
-+ WRITE_ONCE(req->result, res);
-+ /* order with io_poll_complete() checking ->result */
-+ if (res != -EAGAIN) {
-+ smp_wmb();
-+ WRITE_ONCE(req->iopoll_completed, 1);
-+ }
- }
-
- /*
-@@ -1974,7 +1978,7 @@ static void io_iopoll_req_issued(struct io_kiocb *req)
- * For fast devices, IO may have already completed. If it has, add
- * it to the front so we find it first.
- */
-- if (req->flags & REQ_F_IOPOLL_COMPLETED)
-+ if (READ_ONCE(req->iopoll_completed))
- list_add(&req->list, &ctx->poll_list);
- else
- list_add_tail(&req->list, &ctx->poll_list);
-@@ -2098,6 +2102,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
- kiocb->ki_flags |= IOCB_HIPRI;
- kiocb->ki_complete = io_complete_rw_iopoll;
- req->result = 0;
-+ req->iopoll_completed = 0;
- } else {
- if (kiocb->ki_flags & IOCB_HIPRI)
- return -EINVAL;
-@@ -2609,8 +2614,8 @@ copy_iov:
- }
- }
- out_free:
-- kfree(iovec);
-- req->flags &= ~REQ_F_NEED_CLEANUP;
-+ if (!(req->flags & REQ_F_NEED_CLEANUP))
-+ kfree(iovec);
- return ret;
- }
-
-@@ -2732,8 +2737,8 @@ copy_iov:
- }
- }
- out_free:
-- req->flags &= ~REQ_F_NEED_CLEANUP;
-- kfree(iovec);
-+ if (!(req->flags & REQ_F_NEED_CLEANUP))
-+ kfree(iovec);
- return ret;
- }
-
-@@ -4297,6 +4302,28 @@ static void io_async_queue_proc(struct file *file, struct wait_queue_head *head,
- __io_queue_proc(&pt->req->apoll->poll, pt, head);
- }
-
-+static void io_sq_thread_drop_mm(struct io_ring_ctx *ctx)
-+{
-+ struct mm_struct *mm = current->mm;
-+
-+ if (mm) {
-+ unuse_mm(mm);
-+ mmput(mm);
-+ }
-+}
-+
-+static int io_sq_thread_acquire_mm(struct io_ring_ctx *ctx,
-+ struct io_kiocb *req)
-+{
-+ if (io_op_defs[req->opcode].needs_mm && !current->mm) {
-+ if (unlikely(!mmget_not_zero(ctx->sqo_mm)))
-+ return -EFAULT;
-+ use_mm(ctx->sqo_mm);
-+ }
-+
-+ return 0;
-+}
-+
- static void io_async_task_func(struct callback_head *cb)
- {
- struct io_kiocb *req = container_of(cb, struct io_kiocb, task_work);
-@@ -4328,12 +4355,17 @@ static void io_async_task_func(struct callback_head *cb)
- if (canceled) {
- kfree(apoll);
- io_cqring_ev_posted(ctx);
-+end_req:
- req_set_fail_links(req);
- io_double_put_req(req);
- return;
- }
-
- __set_current_state(TASK_RUNNING);
-+ if (io_sq_thread_acquire_mm(ctx, req)) {
-+ io_cqring_add_event(req, -EFAULT);
-+ goto end_req;
-+ }
- mutex_lock(&ctx->uring_lock);
- __io_queue_sqe(req, NULL);
- mutex_unlock(&ctx->uring_lock);
-@@ -5892,11 +5924,8 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
- if (unlikely(req->opcode >= IORING_OP_LAST))
- return -EINVAL;
-
-- if (io_op_defs[req->opcode].needs_mm && !current->mm) {
-- if (unlikely(!mmget_not_zero(ctx->sqo_mm)))
-- return -EFAULT;
-- use_mm(ctx->sqo_mm);
-- }
-+ if (unlikely(io_sq_thread_acquire_mm(ctx, req)))
-+ return -EFAULT;
-
- sqe_flags = READ_ONCE(sqe->flags);
- /* enforce forwards compatibility on users */
-@@ -6006,16 +6035,6 @@ fail_req:
- return submitted;
- }
-
--static inline void io_sq_thread_drop_mm(struct io_ring_ctx *ctx)
--{
-- struct mm_struct *mm = current->mm;
--
-- if (mm) {
-- unuse_mm(mm);
-- mmput(mm);
-- }
--}
--
- static int io_sq_thread(void *data)
- {
- struct io_ring_ctx *ctx = data;
-@@ -7385,7 +7404,17 @@ static void io_ring_exit_work(struct work_struct *work)
- if (ctx->rings)
- io_cqring_overflow_flush(ctx, true);
-
-- wait_for_completion(&ctx->completions[0]);
-+ /*
-+ * If we're doing polled IO and end up having requests being
-+ * submitted async (out-of-line), then completions can come in while
-+ * we're waiting for refs to drop. We need to reap these manually,
-+ * as nobody else will be looking for them.
-+ */
-+ while (!wait_for_completion_timeout(&ctx->completions[0], HZ/20)) {
-+ io_iopoll_reap_events(ctx);
-+ if (ctx->rings)
-+ io_cqring_overflow_flush(ctx, true);
-+ }
- io_ring_ctx_free(ctx);
- }
-
-diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
-index a49d0e670ddf..e4944436e733 100644
---- a/fs/jbd2/journal.c
-+++ b/fs/jbd2/journal.c
-@@ -1140,6 +1140,7 @@ static journal_t *journal_init_common(struct block_device *bdev,
- init_waitqueue_head(&journal->j_wait_commit);
- init_waitqueue_head(&journal->j_wait_updates);
- init_waitqueue_head(&journal->j_wait_reserved);
-+ mutex_init(&journal->j_abort_mutex);
- mutex_init(&journal->j_barrier);
- mutex_init(&journal->j_checkpoint_mutex);
- spin_lock_init(&journal->j_revoke_lock);
-@@ -1402,7 +1403,8 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags)
- printk(KERN_ERR "JBD2: Error %d detected when updating "
- "journal superblock for %s.\n", ret,
- journal->j_devname);
-- jbd2_journal_abort(journal, ret);
-+ if (!is_journal_aborted(journal))
-+ jbd2_journal_abort(journal, ret);
- }
-
- return ret;
-@@ -2153,6 +2155,13 @@ void jbd2_journal_abort(journal_t *journal, int errno)
- {
- transaction_t *transaction;
-
-+ /*
-+ * Lock the aborting procedure until everything is done, this avoid
-+ * races between filesystem's error handling flow (e.g. ext4_abort()),
-+ * ensure panic after the error info is written into journal's
-+ * superblock.
-+ */
-+ mutex_lock(&journal->j_abort_mutex);
- /*
- * ESHUTDOWN always takes precedence because a file system check
- * caused by any other journal abort error is not required after
-@@ -2167,6 +2176,7 @@ void jbd2_journal_abort(journal_t *journal, int errno)
- journal->j_errno = errno;
- jbd2_journal_update_sb_errno(journal);
- }
-+ mutex_unlock(&journal->j_abort_mutex);
- return;
- }
-
-@@ -2188,10 +2198,7 @@ void jbd2_journal_abort(journal_t *journal, int errno)
- * layer could realise that a filesystem check is needed.
- */
- jbd2_journal_update_sb_errno(journal);
--
-- write_lock(&journal->j_state_lock);
-- journal->j_flags |= JBD2_REC_ERR;
-- write_unlock(&journal->j_state_lock);
-+ mutex_unlock(&journal->j_abort_mutex);
- }
-
- /**
-diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
-index a57e7c72c7f4..d49b1d197908 100644
---- a/fs/nfs/direct.c
-+++ b/fs/nfs/direct.c
-@@ -731,6 +731,8 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
- nfs_list_remove_request(req);
- if (request_commit) {
- kref_get(&req->wb_kref);
-+ memcpy(&req->wb_verf, &hdr->verf.verifier,
-+ sizeof(req->wb_verf));
- nfs_mark_request_commit(req, hdr->lseg, &cinfo,
- hdr->ds_commit_idx);
- }
-diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
-index b9d0921cb4fe..0bf1f835de01 100644
---- a/fs/nfs/inode.c
-+++ b/fs/nfs/inode.c
-@@ -833,6 +833,8 @@ int nfs_getattr(const struct path *path, struct kstat *stat,
- do_update |= cache_validity & NFS_INO_INVALID_ATIME;
- if (request_mask & (STATX_CTIME|STATX_MTIME))
- do_update |= cache_validity & NFS_INO_REVAL_PAGECACHE;
-+ if (request_mask & STATX_BLOCKS)
-+ do_update |= cache_validity & NFS_INO_INVALID_BLOCKS;
- if (do_update) {
- /* Update the attribute cache */
- if (!(server->flags & NFS_MOUNT_NOAC))
-@@ -1764,7 +1766,8 @@ out_noforce:
- status = nfs_post_op_update_inode_locked(inode, fattr,
- NFS_INO_INVALID_CHANGE
- | NFS_INO_INVALID_CTIME
-- | NFS_INO_INVALID_MTIME);
-+ | NFS_INO_INVALID_MTIME
-+ | NFS_INO_INVALID_BLOCKS);
- return status;
- }
-
-@@ -1871,7 +1874,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
- nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR
- | NFS_INO_INVALID_ATIME
- | NFS_INO_REVAL_FORCED
-- | NFS_INO_REVAL_PAGECACHE);
-+ | NFS_INO_REVAL_PAGECACHE
-+ | NFS_INO_INVALID_BLOCKS);
-
- /* Do atomic weak cache consistency updates */
- nfs_wcc_update_inode(inode, fattr);
-@@ -2033,8 +2037,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
- inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
- } else if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
- inode->i_blocks = fattr->du.nfs2.blocks;
-- else
-+ else {
-+ nfsi->cache_validity |= save_cache_validity &
-+ (NFS_INO_INVALID_BLOCKS
-+ | NFS_INO_REVAL_FORCED);
- cache_revalidated = false;
-+ }
-
- /* Update attrtimeo value if we're out of the unstable period */
- if (attr_changed) {
-diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
-index 9056f3dd380e..e32717fd1169 100644
---- a/fs/nfs/nfs4proc.c
-+++ b/fs/nfs/nfs4proc.c
-@@ -7909,7 +7909,7 @@ nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata)
- }
-
- static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = {
-- .rpc_call_done = &nfs4_bind_one_conn_to_session_done,
-+ .rpc_call_done = nfs4_bind_one_conn_to_session_done,
- };
-
- /*
-diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h
-index 10ec5ecdf117..65c331f75e9c 100644
---- a/fs/nfsd/cache.h
-+++ b/fs/nfsd/cache.h
-@@ -78,6 +78,8 @@ enum {
- /* Checksum this amount of the request */
- #define RC_CSUMLEN (256U)
-
-+int nfsd_drc_slab_create(void);
-+void nfsd_drc_slab_free(void);
- int nfsd_reply_cache_init(struct nfsd_net *);
- void nfsd_reply_cache_shutdown(struct nfsd_net *);
- int nfsd_cache_lookup(struct svc_rqst *);
-diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
-index 09aa545825bd..9217cb64bf0e 100644
---- a/fs/nfsd/netns.h
-+++ b/fs/nfsd/netns.h
-@@ -139,7 +139,6 @@ struct nfsd_net {
- * Duplicate reply cache
- */
- struct nfsd_drc_bucket *drc_hashtbl;
-- struct kmem_cache *drc_slab;
-
- /* max number of entries allowed in the cache */
- unsigned int max_drc_entries;
-diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
-index 5cf91322de0f..07e0c6f6322f 100644
---- a/fs/nfsd/nfs4callback.c
-+++ b/fs/nfsd/nfs4callback.c
-@@ -1301,6 +1301,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/nfsd/nfscache.c b/fs/nfsd/nfscache.c
-index 96352ab7bd81..4a258065188e 100644
---- a/fs/nfsd/nfscache.c
-+++ b/fs/nfsd/nfscache.c
-@@ -36,6 +36,8 @@ struct nfsd_drc_bucket {
- spinlock_t cache_lock;
- };
-
-+static struct kmem_cache *drc_slab;
-+
- static int nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *vec);
- static unsigned long nfsd_reply_cache_count(struct shrinker *shrink,
- struct shrink_control *sc);
-@@ -95,7 +97,7 @@ nfsd_reply_cache_alloc(struct svc_rqst *rqstp, __wsum csum,
- {
- struct svc_cacherep *rp;
-
-- rp = kmem_cache_alloc(nn->drc_slab, GFP_KERNEL);
-+ rp = kmem_cache_alloc(drc_slab, GFP_KERNEL);
- if (rp) {
- rp->c_state = RC_UNUSED;
- rp->c_type = RC_NOCACHE;
-@@ -129,7 +131,7 @@ nfsd_reply_cache_free_locked(struct nfsd_drc_bucket *b, struct svc_cacherep *rp,
- atomic_dec(&nn->num_drc_entries);
- nn->drc_mem_usage -= sizeof(*rp);
- }
-- kmem_cache_free(nn->drc_slab, rp);
-+ kmem_cache_free(drc_slab, rp);
- }
-
- static void
-@@ -141,6 +143,18 @@ nfsd_reply_cache_free(struct nfsd_drc_bucket *b, struct svc_cacherep *rp,
- spin_unlock(&b->cache_lock);
- }
-
-+int nfsd_drc_slab_create(void)
-+{
-+ drc_slab = kmem_cache_create("nfsd_drc",
-+ sizeof(struct svc_cacherep), 0, 0, NULL);
-+ return drc_slab ? 0: -ENOMEM;
-+}
-+
-+void nfsd_drc_slab_free(void)
-+{
-+ kmem_cache_destroy(drc_slab);
-+}
-+
- int nfsd_reply_cache_init(struct nfsd_net *nn)
- {
- unsigned int hashsize;
-@@ -159,18 +173,13 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)
- if (status)
- goto out_nomem;
-
-- nn->drc_slab = kmem_cache_create("nfsd_drc",
-- sizeof(struct svc_cacherep), 0, 0, NULL);
-- if (!nn->drc_slab)
-- goto out_shrinker;
--
- nn->drc_hashtbl = kcalloc(hashsize,
- sizeof(*nn->drc_hashtbl), GFP_KERNEL);
- if (!nn->drc_hashtbl) {
- nn->drc_hashtbl = vzalloc(array_size(hashsize,
- sizeof(*nn->drc_hashtbl)));
- if (!nn->drc_hashtbl)
-- goto out_slab;
-+ goto out_shrinker;
- }
-
- for (i = 0; i < hashsize; i++) {
-@@ -180,8 +189,6 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)
- nn->drc_hashsize = hashsize;
-
- return 0;
--out_slab:
-- kmem_cache_destroy(nn->drc_slab);
- out_shrinker:
- unregister_shrinker(&nn->nfsd_reply_cache_shrinker);
- out_nomem:
-@@ -209,8 +216,6 @@ void nfsd_reply_cache_shutdown(struct nfsd_net *nn)
- nn->drc_hashtbl = NULL;
- nn->drc_hashsize = 0;
-
-- kmem_cache_destroy(nn->drc_slab);
-- nn->drc_slab = NULL;
- }
-
- /*
-@@ -464,8 +469,7 @@ found_entry:
- rtn = RC_REPLY;
- break;
- default:
-- printk(KERN_WARNING "nfsd: bad repcache type %d\n", rp->c_type);
-- nfsd_reply_cache_free_locked(b, rp, nn);
-+ WARN_ONCE(1, "nfsd: bad repcache type %d\n", rp->c_type);
- }
-
- goto out;
-diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
-index 3bb2db947d29..71687d99b090 100644
---- a/fs/nfsd/nfsctl.c
-+++ b/fs/nfsd/nfsctl.c
-@@ -1533,6 +1533,9 @@ static int __init init_nfsd(void)
- goto out_free_slabs;
- nfsd_fault_inject_init(); /* nfsd fault injection controls */
- nfsd_stat_init(); /* Statistics */
-+ retval = nfsd_drc_slab_create();
-+ if (retval)
-+ goto out_free_stat;
- nfsd_lockd_init(); /* lockd->nfsd callbacks */
- retval = create_proc_exports_entry();
- if (retval)
-@@ -1546,6 +1549,8 @@ out_free_all:
- remove_proc_entry("fs/nfs", NULL);
- out_free_lockd:
- nfsd_lockd_shutdown();
-+ nfsd_drc_slab_free();
-+out_free_stat:
- nfsd_stat_shutdown();
- nfsd_fault_inject_cleanup();
- nfsd4_exit_pnfs();
-@@ -1560,6 +1565,7 @@ out_unregister_pernet:
-
- static void __exit exit_nfsd(void)
- {
-+ nfsd_drc_slab_free();
- remove_proc_entry("fs/nfs/exports", NULL);
- remove_proc_entry("fs/nfs", NULL);
- nfsd_stat_shutdown();
-diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c
-index 9955d75c0585..ad31ec4ad627 100644
---- a/fs/proc/bootconfig.c
-+++ b/fs/proc/bootconfig.c
-@@ -26,8 +26,9 @@ static int boot_config_proc_show(struct seq_file *m, void *v)
- static int __init copy_xbc_key_value_list(char *dst, size_t size)
- {
- struct xbc_node *leaf, *vnode;
-- const char *val;
- char *key, *end = dst + size;
-+ const char *val;
-+ char q;
- int ret = 0;
-
- key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL);
-@@ -41,16 +42,20 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
- break;
- dst += ret;
- vnode = xbc_node_get_child(leaf);
-- if (vnode && xbc_node_is_array(vnode)) {
-+ if (vnode) {
- xbc_array_for_each_value(vnode, val) {
-- ret = snprintf(dst, rest(dst, end), "\"%s\"%s",
-- val, vnode->next ? ", " : "\n");
-+ if (strchr(val, '"'))
-+ q = '\'';
-+ else
-+ q = '"';
-+ ret = snprintf(dst, rest(dst, end), "%c%s%c%s",
-+ q, val, q, vnode->next ? ", " : "\n");
- if (ret < 0)
- goto out;
- dst += ret;
- }
- } else {
-- ret = snprintf(dst, rest(dst, end), "\"%s\"\n", val);
-+ ret = snprintf(dst, rest(dst, end), "\"\"\n");
- if (ret < 0)
- break;
- dst += ret;
-diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
-index d1772786af29..8845faa8161a 100644
---- a/fs/xfs/xfs_inode.c
-+++ b/fs/xfs/xfs_inode.c
-@@ -2639,8 +2639,10 @@ xfs_ifree_cluster(
- error = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
- mp->m_bsize * igeo->blocks_per_cluster,
- XBF_UNMAPPED, &bp);
-- if (error)
-+ if (error) {
-+ xfs_perag_put(pag);
- return error;
-+ }
-
- /*
- * This buffer may not have been correctly initialised as we
-diff --git a/include/linux/bitops.h b/include/linux/bitops.h
-index 9acf654f0b19..99f2ac30b1d9 100644
---- a/include/linux/bitops.h
-+++ b/include/linux/bitops.h
-@@ -72,7 +72,7 @@ static inline int get_bitmask_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/coresight.h b/include/linux/coresight.h
-index 193cc9dbf448..09f0565a5de3 100644
---- a/include/linux/coresight.h
-+++ b/include/linux/coresight.h
-@@ -100,10 +100,12 @@ union coresight_dev_subtype {
- };
-
- /**
-- * struct coresight_platform_data - data harvested from the DT specification
-- * @nr_inport: number of input ports for this component.
-- * @nr_outport: number of output ports for this component.
-- * @conns: Array of nr_outport connections from this component
-+ * struct coresight_platform_data - data harvested from the firmware
-+ * specification.
-+ *
-+ * @nr_inport: Number of elements for the input connections.
-+ * @nr_outport: Number of elements for the output connections.
-+ * @conns: Sparse array of nr_outport connections from this component.
- */
- struct coresight_platform_data {
- int nr_inport;
-diff --git a/include/linux/ioport.h b/include/linux/ioport.h
-index a9b9170b5dd2..6c3eca90cbc4 100644
---- a/include/linux/ioport.h
-+++ b/include/linux/ioport.h
-@@ -301,5 +301,11 @@ struct resource *devm_request_free_mem_region(struct device *dev,
- struct resource *request_free_mem_region(struct resource *base,
- unsigned long size, const char *name);
-
-+#ifdef CONFIG_IO_STRICT_DEVMEM
-+void revoke_devmem(struct resource *res);
-+#else
-+static inline void revoke_devmem(struct resource *res) { };
-+#endif
-+
- #endif /* __ASSEMBLY__ */
- #endif /* _LINUX_IOPORT_H */
-diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
-index f613d8529863..d56128df2aff 100644
---- a/include/linux/jbd2.h
-+++ b/include/linux/jbd2.h
-@@ -765,6 +765,11 @@ struct journal_s
- */
- int j_errno;
-
-+ /**
-+ * @j_abort_mutex: Lock the whole aborting procedure.
-+ */
-+ struct mutex j_abort_mutex;
-+
- /**
- * @j_sb_buffer: The first part of the superblock buffer.
- */
-@@ -1247,7 +1252,6 @@ JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
- #define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file
- * data write error in ordered
- * mode */
--#define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */
-
- /*
- * Function declarations for the journaling transaction and buffer
-diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
-index 04bdaf01112c..645fd401c856 100644
---- a/include/linux/kprobes.h
-+++ b/include/linux/kprobes.h
-@@ -350,6 +350,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);
-+
- kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset);
- int register_kprobe(struct kprobe *p);
- void unregister_kprobe(struct kprobe *p);
-diff --git a/include/linux/libata.h b/include/linux/libata.h
-index cffa4714bfa8..ae6dfc107ea8 100644
---- a/include/linux/libata.h
-+++ b/include/linux/libata.h
-@@ -22,6 +22,7 @@
- #include <linux/acpi.h>
- #include <linux/cdrom.h>
- #include <linux/sched.h>
-+#include <linux/async.h>
-
- /*
- * 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/mfd/stmfx.h b/include/linux/mfd/stmfx.h
-index 3c67983678ec..744dce63946e 100644
---- a/include/linux/mfd/stmfx.h
-+++ b/include/linux/mfd/stmfx.h
-@@ -109,6 +109,7 @@ struct stmfx {
- struct device *dev;
- struct regmap *map;
- struct regulator *vdd;
-+ int irq;
- struct irq_domain *irq_domain;
- struct mutex lock; /* IRQ bus lock */
- u8 irq_src;
-diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
-index 73eda45f1cfd..6ee9119acc5d 100644
---- a/include/linux/nfs_fs.h
-+++ b/include/linux/nfs_fs.h
-@@ -230,6 +230,7 @@ struct nfs4_copy_state {
- #define NFS_INO_INVALID_OTHER BIT(12) /* other attrs are invalid */
- #define NFS_INO_DATA_INVAL_DEFER \
- BIT(13) /* Deferred cache invalidation */
-+#define NFS_INO_INVALID_BLOCKS BIT(14) /* cached blocks are invalid */
-
- #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \
- | NFS_INO_INVALID_CTIME \
-diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
-index 8675e145ea8b..2040696d75b6 100644
---- a/include/linux/usb/composite.h
-+++ b/include/linux/usb/composite.h
-@@ -249,6 +249,9 @@ int usb_function_activate(struct usb_function *);
-
- int usb_interface_id(struct usb_configuration *, struct usb_function *);
-
-+int config_ep_by_speed_and_alt(struct usb_gadget *g, struct usb_function *f,
-+ struct usb_ep *_ep, u8 alt);
-+
- int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f,
- struct usb_ep *_ep);
-
-diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
-index 9411c08a5c7e..73a6113322c6 100644
---- a/include/linux/usb/gadget.h
-+++ b/include/linux/usb/gadget.h
-@@ -373,6 +373,7 @@ struct usb_gadget_ops {
- * @connected: True if gadget is connected.
- * @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag
- * indicates that it supports LPM as per the LPM ECN & errata.
-+ * @irq: the interrupt number for device controller.
- *
- * Gadgets have a mostly-portable "gadget driver" implementing device
- * functions, handling all usb configurations and interfaces. Gadget
-@@ -427,6 +428,7 @@ struct usb_gadget {
- unsigned deactivated:1;
- unsigned connected:1;
- unsigned lpm_capable:1;
-+ int irq;
- };
- #define work_to_gadget(w) (container_of((w), struct usb_gadget, work))
-
-diff --git a/include/sound/soc.h b/include/sound/soc.h
-index 946f88a6c63d..8e480efeda2a 100644
---- a/include/sound/soc.h
-+++ b/include/sound/soc.h
-@@ -790,9 +790,6 @@ struct snd_soc_dai_link {
- const struct snd_soc_pcm_stream *params;
- unsigned int num_params;
-
-- struct snd_soc_dapm_widget *playback_widget;
-- struct snd_soc_dapm_widget *capture_widget;
--
- unsigned int dai_fmt; /* format to set on init */
-
- enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
-@@ -1156,6 +1153,9 @@ struct snd_soc_pcm_runtime {
- struct snd_soc_dai **cpu_dais;
- unsigned int num_cpus;
-
-+ struct snd_soc_dapm_widget *playback_widget;
-+ struct snd_soc_dapm_widget *capture_widget;
-+
- struct delayed_work delayed_work;
- void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd);
- #ifdef CONFIG_DEBUG_FS
-@@ -1177,7 +1177,7 @@ struct snd_soc_pcm_runtime {
- #define asoc_rtd_to_codec(rtd, n) (rtd)->dais[n + (rtd)->num_cpus]
-
- #define for_each_rtd_components(rtd, i, component) \
-- for ((i) = 0; \
-+ for ((i) = 0, component = NULL; \
- ((i) < rtd->num_components) && ((component) = rtd->components[i]);\
- (i)++)
- #define for_each_rtd_cpu_dais(rtd, i, dai) \
-diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h
-index c612cabbc378..93eddd32bd74 100644
---- a/include/trace/events/afs.h
-+++ b/include/trace/events/afs.h
-@@ -988,24 +988,22 @@ TRACE_EVENT(afs_edit_dir,
- );
-
- TRACE_EVENT(afs_protocol_error,
-- TP_PROTO(struct afs_call *call, int error, enum afs_eproto_cause cause),
-+ TP_PROTO(struct afs_call *call, enum afs_eproto_cause cause),
-
-- TP_ARGS(call, error, cause),
-+ TP_ARGS(call, cause),
-
- TP_STRUCT__entry(
- __field(unsigned int, call )
-- __field(int, error )
- __field(enum afs_eproto_cause, cause )
- ),
-
- TP_fast_assign(
- __entry->call = call ? call->debug_id : 0;
-- __entry->error = error;
- __entry->cause = cause;
- ),
-
-- TP_printk("c=%08x r=%d %s",
-- __entry->call, __entry->error,
-+ TP_printk("c=%08x %s",
-+ __entry->call,
- __print_symbolic(__entry->cause, afs_eproto_causes))
- );
-
-diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h
-index d78064007b17..f3956fc11de6 100644
---- a/include/uapi/linux/magic.h
-+++ b/include/uapi/linux/magic.h
-@@ -94,6 +94,7 @@
- #define BALLOON_KVM_MAGIC 0x13661366
- #define ZSMALLOC_MAGIC 0x58295829
- #define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */
-+#define DEVMEM_MAGIC 0x454d444d /* "DMEM" */
- #define Z3FOLD_MAGIC 0x33
- #define PPC_CMM_MAGIC 0xc7571590
-
-diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
-index 5e52765161f9..c8acc8f37583 100644
---- a/kernel/bpf/syscall.c
-+++ b/kernel/bpf/syscall.c
-@@ -2924,6 +2924,7 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
- struct bpf_insn *insns;
- u32 off, type;
- u64 imm;
-+ u8 code;
- int i;
-
- insns = kmemdup(prog->insnsi, bpf_prog_insn_size(prog),
-@@ -2932,21 +2933,27 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
- return insns;
-
- for (i = 0; i < prog->len; i++) {
-- if (insns[i].code == (BPF_JMP | BPF_TAIL_CALL)) {
-+ code = insns[i].code;
-+
-+ if (code == (BPF_JMP | BPF_TAIL_CALL)) {
- insns[i].code = BPF_JMP | BPF_CALL;
- insns[i].imm = BPF_FUNC_tail_call;
- /* fall-through */
- }
-- if (insns[i].code == (BPF_JMP | BPF_CALL) ||
-- insns[i].code == (BPF_JMP | BPF_CALL_ARGS)) {
-- if (insns[i].code == (BPF_JMP | BPF_CALL_ARGS))
-+ if (code == (BPF_JMP | BPF_CALL) ||
-+ code == (BPF_JMP | BPF_CALL_ARGS)) {
-+ if (code == (BPF_JMP | BPF_CALL_ARGS))
- insns[i].code = BPF_JMP | BPF_CALL;
- if (!bpf_dump_raw_ok())
- insns[i].imm = 0;
- continue;
- }
-+ if (BPF_CLASS(code) == BPF_LDX && BPF_MODE(code) == BPF_PROBE_MEM) {
-+ insns[i].code = BPF_LDX | BPF_SIZE(code) | BPF_MEM;
-+ continue;
-+ }
-
-- if (insns[i].code != (BPF_LD | BPF_IMM | BPF_DW))
-+ if (code != (BPF_LD | BPF_IMM | BPF_DW))
- continue;
-
- imm = ((u64)insns[i + 1].imm << 32) | (u32)insns[i].imm;
-diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
-index efe14cf24bc6..739d9ba3ba6b 100644
---- a/kernel/bpf/verifier.c
-+++ b/kernel/bpf/verifier.c
-@@ -7366,7 +7366,7 @@ static int check_btf_func(struct bpf_verifier_env *env,
- const struct btf *btf;
- void __user *urecord;
- u32 prev_offset = 0;
-- int ret = 0;
-+ int ret = -ENOMEM;
-
- nfuncs = attr->func_info_cnt;
- if (!nfuncs)
-diff --git a/kernel/kprobes.c b/kernel/kprobes.c
-index 2625c241ac00..195ecb955fcc 100644
---- a/kernel/kprobes.c
-+++ b/kernel/kprobes.c
-@@ -586,11 +586,12 @@ static void kprobe_optimizer(struct work_struct *work)
- mutex_unlock(&module_mutex);
- mutex_unlock(&text_mutex);
- cpus_read_unlock();
-- 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 */
-@@ -1236,6 +1237,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
-@@ -1253,6 +1274,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];
-@@ -1266,6 +1289,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/resource.c b/kernel/resource.c
-index 76036a41143b..841737bbda9e 100644
---- a/kernel/resource.c
-+++ b/kernel/resource.c
-@@ -1126,6 +1126,7 @@ struct resource * __request_region(struct resource *parent,
- {
- DECLARE_WAITQUEUE(wait, current);
- struct resource *res = alloc_resource(GFP_KERNEL);
-+ struct resource *orig_parent = parent;
-
- if (!res)
- return NULL;
-@@ -1176,6 +1177,10 @@ struct resource * __request_region(struct resource *parent,
- break;
- }
- write_unlock(&resource_lock);
-+
-+ if (res && orig_parent == &iomem_resource)
-+ revoke_devmem(res);
-+
- return res;
- }
- EXPORT_SYMBOL(__request_region);
-diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
-index ca39dc3230cb..35610a4be4a9 100644
---- a/kernel/trace/blktrace.c
-+++ b/kernel/trace/blktrace.c
-@@ -995,8 +995,10 @@ static void blk_add_trace_split(void *ignore,
-
- __blk_add_trace(bt, bio->bi_iter.bi_sector,
- bio->bi_iter.bi_size, bio_op(bio), bio->bi_opf,
-- BLK_TA_SPLIT, bio->bi_status, sizeof(rpdu),
-- &rpdu, blk_trace_bio_get_cgid(q, bio));
-+ BLK_TA_SPLIT,
-+ blk_status_to_errno(bio->bi_status),
-+ sizeof(rpdu), &rpdu,
-+ blk_trace_bio_get_cgid(q, bio));
- }
- rcu_read_unlock();
- }
-@@ -1033,7 +1035,8 @@ static void blk_add_trace_bio_remap(void *ignore,
- r.sector_from = cpu_to_be64(from);
-
- __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
-- bio_op(bio), bio->bi_opf, BLK_TA_REMAP, bio->bi_status,
-+ bio_op(bio), bio->bi_opf, BLK_TA_REMAP,
-+ blk_status_to_errno(bio->bi_status),
- sizeof(r), &r, blk_trace_bio_get_cgid(q, bio));
- rcu_read_unlock();
- }
-@@ -1253,21 +1256,10 @@ static inline __u16 t_error(const struct trace_entry *ent)
-
- static __u64 get_pdu_int(const struct trace_entry *ent, bool has_cg)
- {
-- const __u64 *val = pdu_start(ent, has_cg);
-+ const __be64 *val = pdu_start(ent, has_cg);
- return be64_to_cpu(*val);
- }
-
--static void get_pdu_remap(const struct trace_entry *ent,
-- struct blk_io_trace_remap *r, bool has_cg)
--{
-- const struct blk_io_trace_remap *__r = pdu_start(ent, has_cg);
-- __u64 sector_from = __r->sector_from;
--
-- r->device_from = be32_to_cpu(__r->device_from);
-- r->device_to = be32_to_cpu(__r->device_to);
-- r->sector_from = be64_to_cpu(sector_from);
--}
--
- typedef void (blk_log_action_t) (struct trace_iterator *iter, const char *act,
- bool has_cg);
-
-@@ -1407,13 +1399,13 @@ static void blk_log_with_error(struct trace_seq *s,
-
- static void blk_log_remap(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
- {
-- struct blk_io_trace_remap r = { .device_from = 0, };
-+ const struct blk_io_trace_remap *__r = pdu_start(ent, has_cg);
-
-- get_pdu_remap(ent, &r, has_cg);
- trace_seq_printf(s, "%llu + %u <- (%d,%d) %llu\n",
- t_sector(ent), t_sec(ent),
-- MAJOR(r.device_from), MINOR(r.device_from),
-- (unsigned long long)r.sector_from);
-+ MAJOR(be32_to_cpu(__r->device_from)),
-+ MINOR(be32_to_cpu(__r->device_from)),
-+ be64_to_cpu(__r->sector_from));
- }
-
- static void blk_log_plug(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
-diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
-index 4eb1d004d5f2..7fb2f4c1bc49 100644
---- a/kernel/trace/trace.h
-+++ b/kernel/trace/trace.h
-@@ -61,6 +61,9 @@ enum trace_type {
- #undef __field_desc
- #define __field_desc(type, container, item)
-
-+#undef __field_packed
-+#define __field_packed(type, container, item)
-+
- #undef __array
- #define __array(type, item, size) type item[size];
-
-diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h
-index a523da0dae0a..18c4a58aff79 100644
---- a/kernel/trace/trace_entries.h
-+++ b/kernel/trace/trace_entries.h
-@@ -78,8 +78,8 @@ FTRACE_ENTRY_PACKED(funcgraph_entry, ftrace_graph_ent_entry,
-
- F_STRUCT(
- __field_struct( struct ftrace_graph_ent, graph_ent )
-- __field_desc( unsigned long, graph_ent, func )
-- __field_desc( int, graph_ent, depth )
-+ __field_packed( unsigned long, graph_ent, func )
-+ __field_packed( int, graph_ent, depth )
- ),
-
- F_printk("--> %ps (%d)", (void *)__entry->func, __entry->depth)
-@@ -92,11 +92,11 @@ FTRACE_ENTRY_PACKED(funcgraph_exit, ftrace_graph_ret_entry,
-
- F_STRUCT(
- __field_struct( struct ftrace_graph_ret, ret )
-- __field_desc( unsigned long, ret, func )
-- __field_desc( unsigned long, ret, overrun )
-- __field_desc( unsigned long long, ret, calltime)
-- __field_desc( unsigned long long, ret, rettime )
-- __field_desc( int, ret, depth )
-+ __field_packed( unsigned long, ret, func )
-+ __field_packed( unsigned long, ret, overrun )
-+ __field_packed( unsigned long long, ret, calltime)
-+ __field_packed( unsigned long long, ret, rettime )
-+ __field_packed( int, ret, depth )
- ),
-
- F_printk("<-- %ps (%d) (start: %llx end: %llx) over: %d",
-diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
-index 77ce5a3b6773..70d3d0a09053 100644
---- a/kernel/trace/trace_export.c
-+++ b/kernel/trace/trace_export.c
-@@ -45,6 +45,9 @@ static int ftrace_event_register(struct trace_event_call *call,
- #undef __field_desc
- #define __field_desc(type, container, item) type item;
-
-+#undef __field_packed
-+#define __field_packed(type, container, item) type item;
-+
- #undef __array
- #define __array(type, item, size) type item[size];
-
-@@ -85,6 +88,13 @@ static void __always_unused ____ftrace_check_##name(void) \
- .size = sizeof(_type), .align = __alignof__(_type), \
- is_signed_type(_type), .filter_type = _filter_type },
-
-+
-+#undef __field_ext_packed
-+#define __field_ext_packed(_type, _item, _filter_type) { \
-+ .type = #_type, .name = #_item, \
-+ .size = sizeof(_type), .align = 1, \
-+ is_signed_type(_type), .filter_type = _filter_type },
-+
- #undef __field
- #define __field(_type, _item) __field_ext(_type, _item, FILTER_OTHER)
-
-@@ -94,6 +104,9 @@ static void __always_unused ____ftrace_check_##name(void) \
- #undef __field_desc
- #define __field_desc(_type, _container, _item) __field_ext(_type, _item, FILTER_OTHER)
-
-+#undef __field_packed
-+#define __field_packed(_type, _container, _item) __field_ext_packed(_type, _item, FILTER_OTHER)
-+
- #undef __array
- #define __array(_type, _item, _len) { \
- .type = #_type"["__stringify(_len)"]", .name = #_item, \
-@@ -129,6 +142,9 @@ static struct trace_event_fields ftrace_event_fields_##name[] = { \
- #undef __field_desc
- #define __field_desc(type, container, item)
-
-+#undef __field_packed
-+#define __field_packed(type, container, item)
-+
- #undef __array
- #define __array(type, item, len)
-
-diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
-index 35989383ae11..8eeb95e04bf5 100644
---- a/kernel/trace/trace_kprobe.c
-+++ b/kernel/trace/trace_kprobe.c
-@@ -1629,7 +1629,7 @@ int bpf_get_kprobe_info(const struct perf_event *event, u32 *fd_type,
- if (perf_type_tracepoint)
- tk = find_trace_kprobe(pevent, group);
- else
-- tk = event->tp_event->data;
-+ tk = trace_kprobe_primary_from_call(event->tp_event);
- if (!tk)
- return -EINVAL;
-
-diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
-index ab8b6436d53f..f98d6d94cbbf 100644
---- a/kernel/trace/trace_probe.c
-+++ b/kernel/trace/trace_probe.c
-@@ -639,8 +639,8 @@ static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size,
- ret = -EINVAL;
- goto fail;
- }
-- if ((code->op == FETCH_OP_IMM || code->op == FETCH_OP_COMM) ||
-- parg->count) {
-+ if ((code->op == FETCH_OP_IMM || code->op == FETCH_OP_COMM ||
-+ code->op == FETCH_OP_DATA) || parg->count) {
- /*
- * IMM, DATA and COMM is pointing actual address, those
- * must be kept, and if parg->count != 0, this is an
-diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
-index 2a8e8e9c1c75..fdd47f99b18f 100644
---- a/kernel/trace/trace_uprobe.c
-+++ b/kernel/trace/trace_uprobe.c
-@@ -1412,7 +1412,7 @@ int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
- if (perf_type_tracepoint)
- tu = find_probe_event(pevent, group);
- else
-- tu = event->tp_event->data;
-+ tu = trace_uprobe_primary_from_call(event->tp_event);
- if (!tu)
- return -EINVAL;
-
-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/net/core/dev.c b/net/core/dev.c
-index 2d8aceee4284..93a279ab4e97 100644
---- a/net/core/dev.c
-+++ b/net/core/dev.c
-@@ -79,6 +79,7 @@
- #include <linux/sched.h>
- #include <linux/sched/mm.h>
- #include <linux/mutex.h>
-+#include <linux/rwsem.h>
- #include <linux/string.h>
- #include <linux/mm.h>
- #include <linux/socket.h>
-@@ -194,7 +195,7 @@ static DEFINE_SPINLOCK(napi_hash_lock);
- static unsigned int napi_gen_id = NR_CPUS;
- static DEFINE_READ_MOSTLY_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)
- {
-@@ -930,33 +931,28 @@ EXPORT_SYMBOL(dev_get_by_napi_id);
- * @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_PREEMPTION 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;
- }
-
- /**
-@@ -1228,10 +1224,10 @@ int dev_change_name(struct net_device *dev, const char *newname)
- likely(!(dev->priv_flags & IFF_LIVE_RENAME_OK)))
- 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;
- }
-
-@@ -1239,7 +1235,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;
- }
-
-@@ -1254,11 +1250,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);
-
-@@ -1279,7 +1275,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;
-diff --git a/net/core/filter.c b/net/core/filter.c
-index 11b97c31bca5..9512a9772d69 100644
---- a/net/core/filter.c
-+++ b/net/core/filter.c
-@@ -1766,25 +1766,27 @@ BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb,
- u32, offset, void *, to, u32, len, u32, start_header)
- {
- u8 *end = skb_tail_pointer(skb);
-- u8 *net = skb_network_header(skb);
-- u8 *mac = skb_mac_header(skb);
-- u8 *ptr;
-+ u8 *start, *ptr;
-
-- if (unlikely(offset > 0xffff || len > (end - mac)))
-+ if (unlikely(offset > 0xffff))
- goto err_clear;
-
- switch (start_header) {
- case BPF_HDR_START_MAC:
-- ptr = mac + offset;
-+ if (unlikely(!skb_mac_header_was_set(skb)))
-+ goto err_clear;
-+ start = skb_mac_header(skb);
- break;
- case BPF_HDR_START_NET:
-- ptr = net + offset;
-+ start = skb_network_header(skb);
- break;
- default:
- goto err_clear;
- }
-
-- if (likely(ptr >= mac && ptr + len <= end)) {
-+ ptr = start + offset;
-+
-+ if (likely(ptr + len <= end)) {
- memcpy(to, ptr, len);
- return 0;
- }
-diff --git a/net/core/sock_map.c b/net/core/sock_map.c
-index b08dfae10f88..591457fcbd02 100644
---- a/net/core/sock_map.c
-+++ b/net/core/sock_map.c
-@@ -417,10 +417,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)
- return 0;
- }
-
--static bool sock_map_redirect_allowed(const struct sock *sk)
--{
-- return sk->sk_state != TCP_LISTEN;
--}
-+static bool sock_map_redirect_allowed(const struct sock *sk);
-
- static int sock_map_update_common(struct bpf_map *map, u32 idx,
- struct sock *sk, u64 flags)
-@@ -501,6 +498,11 @@ static bool sk_is_udp(const struct sock *sk)
- sk->sk_protocol == IPPROTO_UDP;
- }
-
-+static bool sock_map_redirect_allowed(const struct sock *sk)
-+{
-+ return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN;
-+}
-+
- static bool sock_map_sk_is_suitable(const struct sock *sk)
- {
- return sk_is_tcp(sk) || sk_is_udp(sk);
-@@ -982,11 +984,15 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr)
- err = -EINVAL;
- goto free_htab;
- }
-+ err = bpf_map_charge_init(&htab->map.memory, cost);
-+ if (err)
-+ goto free_htab;
-
- htab->buckets = bpf_map_area_alloc(htab->buckets_num *
- sizeof(struct bpf_htab_bucket),
- htab->map.numa_node);
- if (!htab->buckets) {
-+ bpf_map_charge_finish(&htab->map.memory);
- err = -ENOMEM;
- goto free_htab;
- }
-@@ -1006,6 +1012,7 @@ static void sock_hash_free(struct bpf_map *map)
- {
- struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
- struct bpf_htab_bucket *bucket;
-+ struct hlist_head unlink_list;
- struct bpf_htab_elem *elem;
- struct hlist_node *node;
- int i;
-@@ -1017,13 +1024,32 @@ static void sock_hash_free(struct bpf_map *map)
- synchronize_rcu();
- for (i = 0; i < htab->buckets_num; i++) {
- bucket = sock_hash_select_bucket(htab, i);
-- hlist_for_each_entry_safe(elem, node, &bucket->head, node) {
-- hlist_del_rcu(&elem->node);
-+
-+ /* We are racing with sock_hash_delete_from_link to
-+ * enter the spin-lock critical section. Every socket on
-+ * the list is still linked to sockhash. Since link
-+ * exists, psock exists and holds a ref to socket. That
-+ * lets us to grab a socket ref too.
-+ */
-+ raw_spin_lock_bh(&bucket->lock);
-+ hlist_for_each_entry(elem, &bucket->head, node)
-+ sock_hold(elem->sk);
-+ hlist_move_list(&bucket->head, &unlink_list);
-+ raw_spin_unlock_bh(&bucket->lock);
-+
-+ /* Process removed entries out of atomic context to
-+ * block for socket lock before deleting the psock's
-+ * link to sockhash.
-+ */
-+ hlist_for_each_entry_safe(elem, node, &unlink_list, node) {
-+ hlist_del(&elem->node);
- lock_sock(elem->sk);
- rcu_read_lock();
- sock_map_unref(elem->sk, elem);
- rcu_read_unlock();
- release_sock(elem->sk);
-+ sock_put(elem->sk);
-+ sock_hash_free_elem(htab, elem);
- }
- }
-
-diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
-index 629aaa9a1eb9..7aa68f4aae6c 100644
---- a/net/ipv4/tcp_bpf.c
-+++ b/net/ipv4/tcp_bpf.c
-@@ -64,6 +64,9 @@ int __tcp_bpf_recvmsg(struct sock *sk, struct sk_psock *psock,
- } while (i != msg_rx->sg.end);
-
- if (unlikely(peek)) {
-+ if (msg_rx == list_last_entry(&psock->ingress_msg,
-+ struct sk_msg, list))
-+ break;
- msg_rx = list_next_entry(msg_rx, list);
- continue;
- }
-@@ -242,6 +245,9 @@ static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock,
- DEFINE_WAIT_FUNC(wait, woken_wake_function);
- int ret = 0;
-
-+ if (sk->sk_shutdown & RCV_SHUTDOWN)
-+ return 1;
-+
- if (!timeo)
- return ret;
-
-diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
-index 8b5acc6910fd..8c04388296b0 100644
---- a/net/netfilter/nft_set_pipapo.c
-+++ b/net/netfilter/nft_set_pipapo.c
-@@ -1242,7 +1242,9 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
- end += NFT_PIPAPO_GROUPS_PADDED_SIZE(f);
- }
-
-- if (!*this_cpu_ptr(m->scratch) || bsize_max > m->bsize_max) {
-+ if (!*get_cpu_ptr(m->scratch) || bsize_max > m->bsize_max) {
-+ put_cpu_ptr(m->scratch);
-+
- err = pipapo_realloc_scratch(m, bsize_max);
- if (err)
- return err;
-@@ -1250,6 +1252,8 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
- this_cpu_write(nft_pipapo_scratch_index, false);
-
- m->bsize_max = bsize_max;
-+ } else {
-+ put_cpu_ptr(m->scratch);
- }
-
- *ext2 = &e->ext;
-diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
-index 62f416bc0579..b6aad3fc46c3 100644
---- a/net/netfilter/nft_set_rbtree.c
-+++ b/net/netfilter/nft_set_rbtree.c
-@@ -271,12 +271,14 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
-
- if (nft_rbtree_interval_start(new)) {
- if (nft_rbtree_interval_end(rbe) &&
-- nft_set_elem_active(&rbe->ext, genmask))
-+ nft_set_elem_active(&rbe->ext, genmask) &&
-+ !nft_set_elem_expired(&rbe->ext))
- overlap = false;
- } else {
- overlap = nft_rbtree_interval_end(rbe) &&
- nft_set_elem_active(&rbe->ext,
-- genmask);
-+ genmask) &&
-+ !nft_set_elem_expired(&rbe->ext);
- }
- } else if (d > 0) {
- p = &parent->rb_right;
-@@ -284,9 +286,11 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
- if (nft_rbtree_interval_end(new)) {
- overlap = nft_rbtree_interval_end(rbe) &&
- nft_set_elem_active(&rbe->ext,
-- genmask);
-+ genmask) &&
-+ !nft_set_elem_expired(&rbe->ext);
- } else if (nft_rbtree_interval_end(rbe) &&
-- nft_set_elem_active(&rbe->ext, genmask)) {
-+ nft_set_elem_active(&rbe->ext, genmask) &&
-+ !nft_set_elem_expired(&rbe->ext)) {
- overlap = true;
- }
- } else {
-@@ -294,15 +298,18 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
- nft_rbtree_interval_start(new)) {
- p = &parent->rb_left;
-
-- if (nft_set_elem_active(&rbe->ext, genmask))
-+ if (nft_set_elem_active(&rbe->ext, genmask) &&
-+ !nft_set_elem_expired(&rbe->ext))
- overlap = false;
- } else if (nft_rbtree_interval_start(rbe) &&
- nft_rbtree_interval_end(new)) {
- p = &parent->rb_right;
-
-- if (nft_set_elem_active(&rbe->ext, genmask))
-+ if (nft_set_elem_active(&rbe->ext, genmask) &&
-+ !nft_set_elem_expired(&rbe->ext))
- overlap = false;
-- } else if (nft_set_elem_active(&rbe->ext, genmask)) {
-+ } else if (nft_set_elem_active(&rbe->ext, genmask) &&
-+ !nft_set_elem_expired(&rbe->ext)) {
- *ext = &rbe->ext;
- return -EEXIST;
- } else {
-diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c
-index 8b179e3c802a..543afd9bd664 100644
---- a/net/rxrpc/proc.c
-+++ b/net/rxrpc/proc.c
-@@ -68,7 +68,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
- "Proto Local "
- " Remote "
- " SvID ConnID CallID End Use State Abort "
-- " UserID TxSeq TW RxSeq RW RxSerial RxTimo\n");
-+ " DebugId TxSeq TW RxSeq RW RxSerial RxTimo\n");
- return 0;
- }
-
-@@ -100,7 +100,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
- rx_hard_ack = READ_ONCE(call->rx_hard_ack);
- seq_printf(seq,
- "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u"
-- " %-8.8s %08x %lx %08x %02x %08x %02x %08x %06lx\n",
-+ " %-8.8s %08x %08x %08x %02x %08x %02x %08x %06lx\n",
- lbuff,
- rbuff,
- call->service_id,
-@@ -110,7 +110,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
- atomic_read(&call->usage),
- rxrpc_call_states[call->state],
- call->abort_code,
-- call->user_call_ID,
-+ call->debug_id,
- tx_hard_ack, READ_ONCE(call->tx_top) - tx_hard_ack,
- rx_hard_ack, READ_ONCE(call->rx_top) - rx_hard_ack,
- call->rx_serial,
-diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c
-index 8b4d72b1a066..010dcb876f9d 100644
---- a/net/sunrpc/addr.c
-+++ b/net/sunrpc/addr.c
-@@ -82,11 +82,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/xdp/xsk.c b/net/xdp/xsk.c
-index c350108aa38d..a4676107fad0 100644
---- a/net/xdp/xsk.c
-+++ b/net/xdp/xsk.c
-@@ -397,10 +397,8 @@ static int xsk_generic_xmit(struct sock *sk)
-
- len = desc.len;
- skb = sock_alloc_send_skb(sk, len, 1, &err);
-- if (unlikely(!skb)) {
-- err = -EAGAIN;
-+ if (unlikely(!skb))
- goto out;
-- }
-
- skb_put(skb, len);
- addr = desc.addr;
-diff --git a/samples/ftrace/sample-trace-array.c b/samples/ftrace/sample-trace-array.c
-index d523450d73eb..6aba02a31c96 100644
---- a/samples/ftrace/sample-trace-array.c
-+++ b/samples/ftrace/sample-trace-array.c
-@@ -6,6 +6,7 @@
- #include <linux/timer.h>
- #include <linux/err.h>
- #include <linux/jiffies.h>
-+#include <linux/workqueue.h>
-
- /*
- * Any file that uses trace points, must include the header.
-@@ -20,6 +21,16 @@ struct trace_array *tr;
- static void mytimer_handler(struct timer_list *unused);
- static struct task_struct *simple_tsk;
-
-+static void trace_work_fn(struct work_struct *work)
-+{
-+ /*
-+ * Disable tracing for event "sample_event".
-+ */
-+ trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
-+ false);
-+}
-+static DECLARE_WORK(trace_work, trace_work_fn);
-+
- /*
- * mytimer: Timer setup to disable tracing for event "sample_event". This
- * timer is only for the purposes of the sample module to demonstrate access of
-@@ -29,11 +40,7 @@ static DEFINE_TIMER(mytimer, mytimer_handler);
-
- static void mytimer_handler(struct timer_list *unused)
- {
-- /*
-- * Disable tracing for event "sample_event".
-- */
-- trace_array_set_clr_event(tr, "sample-subsystem", "sample_event",
-- false);
-+ schedule_work(&trace_work);
- }
-
- static void simple_thread_func(int count)
-@@ -76,6 +83,7 @@ static int simple_thread(void *arg)
- simple_thread_func(count++);
-
- del_timer(&mytimer);
-+ cancel_work_sync(&trace_work);
-
- /*
- * trace_array_put() decrements the reference counter associated with
-@@ -107,8 +115,12 @@ static int __init sample_trace_array_init(void)
- trace_printk_init_buffers();
-
- simple_tsk = kthread_run(simple_thread, NULL, "sample-instance");
-- if (IS_ERR(simple_tsk))
-+ if (IS_ERR(simple_tsk)) {
-+ trace_array_put(tr);
-+ trace_array_destroy(tr);
- return -1;
-+ }
-+
- return 0;
- }
-
-diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
-index 957eed6a17a5..33aaa572f686 100644
---- a/scripts/Makefile.modpost
-+++ b/scripts/Makefile.modpost
-@@ -66,7 +66,7 @@ __modpost:
-
- else
-
--MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
-+MODPOST += -s -T - \
- $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
-
- ifeq ($(KBUILD_EXTMOD),)
-@@ -82,6 +82,11 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
- $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
- endif
-
-+# 'make -i -k' ignores compile errors, and builds as many modules as possible.
-+ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
-+MODPOST += -n
-+endif
-+
- # find all modules listed in modules.order
- modules := $(sort $(shell cat $(MODORDER)))
-
-diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
-index a07668a5c36b..94a833597a88 100755
---- a/scripts/headers_install.sh
-+++ b/scripts/headers_install.sh
-@@ -64,7 +64,7 @@ configs=$(sed -e '
- d
- ' $OUTFILE)
-
--# The entries in the following list are not warned.
-+# The entries in the following list do not result in an error.
- # Please do not add a new entry. This list is only for existing ones.
- # The list will be reduced gradually, and deleted eventually. (hopefully)
- #
-@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
-
- for c in $configs
- do
-- warn=1
-+ leak_error=1
-
- for ignore in $config_leak_ignores
- do
- if echo "$INFILE:$c" | grep -q "$ignore$"; then
-- warn=
-+ leak_error=
- break
- fi
- done
-
-- if [ "$warn" = 1 ]; then
-- echo "warning: $INFILE: leak $c to user-space" >&2
-+ if [ "$leak_error" = 1 ]; then
-+ echo "error: $INFILE: leak $c to user-space" >&2
-+ exit 1
- fi
- done
-
-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/apparmor/domain.c b/security/apparmor/domain.c
-index a84ef030fbd7..4cfa58c07778 100644
---- a/security/apparmor/domain.c
-+++ b/security/apparmor/domain.c
-@@ -929,7 +929,8 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm)
- * aways results in a further reduction of permissions.
- */
- if ((bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS) &&
-- !unconfined(label) && !aa_label_is_subset(new, ctx->nnp)) {
-+ !unconfined(label) &&
-+ !aa_label_is_unconfined_subset(new, ctx->nnp)) {
- error = -EPERM;
- info = "no new privs";
- goto audit;
-@@ -1207,7 +1208,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, int flags)
- * reduce restrictions.
- */
- if (task_no_new_privs(current) && !unconfined(label) &&
-- !aa_label_is_subset(new, ctx->nnp)) {
-+ !aa_label_is_unconfined_subset(new, ctx->nnp)) {
- /* not an apparmor denial per se, so don't log it */
- AA_DEBUG("no_new_privs - change_hat denied");
- error = -EPERM;
-@@ -1228,7 +1229,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, int flags)
- * reduce restrictions.
- */
- if (task_no_new_privs(current) && !unconfined(label) &&
-- !aa_label_is_subset(previous, ctx->nnp)) {
-+ !aa_label_is_unconfined_subset(previous, ctx->nnp)) {
- /* not an apparmor denial per se, so don't log it */
- AA_DEBUG("no_new_privs - change_hat denied");
- error = -EPERM;
-@@ -1423,7 +1424,7 @@ check:
- * reduce restrictions.
- */
- if (task_no_new_privs(current) && !unconfined(label) &&
-- !aa_label_is_subset(new, ctx->nnp)) {
-+ !aa_label_is_unconfined_subset(new, ctx->nnp)) {
- /* not an apparmor denial per se, so don't log it */
- AA_DEBUG("no_new_privs - change_hat denied");
- error = -EPERM;
-diff --git a/security/apparmor/include/label.h b/security/apparmor/include/label.h
-index 47942c4ba7ca..255764ab06e2 100644
---- a/security/apparmor/include/label.h
-+++ b/security/apparmor/include/label.h
-@@ -281,6 +281,7 @@ bool aa_label_init(struct aa_label *label, int size, gfp_t gfp);
- struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp);
-
- bool aa_label_is_subset(struct aa_label *set, struct aa_label *sub);
-+bool aa_label_is_unconfined_subset(struct aa_label *set, struct aa_label *sub);
- struct aa_profile *__aa_label_next_not_in_set(struct label_it *I,
- struct aa_label *set,
- struct aa_label *sub);
-diff --git a/security/apparmor/label.c b/security/apparmor/label.c
-index 470693239e64..5f324d63ceaa 100644
---- a/security/apparmor/label.c
-+++ b/security/apparmor/label.c
-@@ -550,6 +550,39 @@ bool aa_label_is_subset(struct aa_label *set, struct aa_label *sub)
- return __aa_label_next_not_in_set(&i, set, sub) == NULL;
- }
-
-+/**
-+ * aa_label_is_unconfined_subset - test if @sub is a subset of @set
-+ * @set: label to test against
-+ * @sub: label to test if is subset of @set
-+ *
-+ * This checks for subset but taking into account unconfined. IF
-+ * @sub contains an unconfined profile that does not have a matching
-+ * unconfined in @set then this will not cause the test to fail.
-+ * Conversely we don't care about an unconfined in @set that is not in
-+ * @sub
-+ *
-+ * Returns: true if @sub is special_subset of @set
-+ * else false
-+ */
-+bool aa_label_is_unconfined_subset(struct aa_label *set, struct aa_label *sub)
-+{
-+ struct label_it i = { };
-+ struct aa_profile *p;
-+
-+ AA_BUG(!set);
-+ AA_BUG(!sub);
-+
-+ if (sub == set)
-+ return true;
-+
-+ do {
-+ p = __aa_label_next_not_in_set(&i, set, sub);
-+ if (p && !profile_unconfined(p))
-+ break;
-+ } while (p);
-+
-+ return p == NULL;
-+}
-
-
- /**
-@@ -1531,13 +1564,13 @@ static const char *label_modename(struct aa_ns *ns, struct aa_label *label,
-
- label_for_each(i, label, profile) {
- if (aa_ns_visible(ns, profile->ns, flags & FLAG_VIEW_SUBNS)) {
-- if (profile->mode == APPARMOR_UNCONFINED)
-+ count++;
-+ if (profile == profile->ns->unconfined)
- /* special case unconfined so stacks with
- * unconfined don't report as mixed. ie.
- * profile_foo//&:ns1:unconfined (mixed)
- */
- continue;
-- count++;
- if (mode == -1)
- mode = profile->mode;
- else if (mode != profile->mode)
-diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
-index b621ad74f54a..66a8504c8bea 100644
---- a/security/apparmor/lsm.c
-+++ b/security/apparmor/lsm.c
-@@ -804,7 +804,12 @@ static void apparmor_sk_clone_security(const struct sock *sk,
- struct aa_sk_ctx *ctx = SK_CTX(sk);
- struct aa_sk_ctx *new = SK_CTX(newsk);
-
-+ if (new->label)
-+ aa_put_label(new->label);
- new->label = aa_get_label(ctx->label);
-+
-+ if (new->peer)
-+ aa_put_label(new->peer);
- new->peer = aa_get_label(ctx->peer);
- }
-
-diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
-index da94a1b4bfda..0cc7cdd58465 100644
---- a/security/selinux/ss/conditional.c
-+++ b/security/selinux/ss/conditional.c
-@@ -27,6 +27,9 @@ static int cond_evaluate_expr(struct policydb *p, struct cond_expr *expr)
- int s[COND_EXPR_MAXDEPTH];
- int sp = -1;
-
-+ if (expr->len == 0)
-+ return -1;
-+
- for (i = 0; i < expr->len; i++) {
- struct cond_expr_node *node = &expr->nodes[i];
-
-@@ -392,27 +395,19 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
-
- rc = next_entry(buf, fp, sizeof(u32) * 2);
- if (rc)
-- goto err;
-+ return rc;
-
- expr->expr_type = le32_to_cpu(buf[0]);
- expr->bool = le32_to_cpu(buf[1]);
-
-- if (!expr_node_isvalid(p, expr)) {
-- rc = -EINVAL;
-- goto err;
-- }
-+ if (!expr_node_isvalid(p, expr))
-+ return -EINVAL;
- }
-
- rc = cond_read_av_list(p, fp, &node->true_list, NULL);
- if (rc)
-- goto err;
-- rc = cond_read_av_list(p, fp, &node->false_list, &node->true_list);
-- if (rc)
-- goto err;
-- return 0;
--err:
-- cond_node_destroy(node);
-- return rc;
-+ return rc;
-+ return cond_read_av_list(p, fp, &node->false_list, &node->true_list);
- }
-
- int cond_read_list(struct policydb *p, void *fp)
-diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
-index 8ad34fd031d1..77e591fce919 100644
---- a/security/selinux/ss/services.c
-+++ b/security/selinux/ss/services.c
-@@ -2923,8 +2923,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/firewire/amdtp-am824.c b/sound/firewire/amdtp-am824.c
-index 67d735e9a6a4..fea92e148790 100644
---- a/sound/firewire/amdtp-am824.c
-+++ b/sound/firewire/amdtp-am824.c
-@@ -82,7 +82,8 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
- if (err < 0)
- return err;
-
-- s->ctx_data.rx.fdf = AMDTP_FDF_AM824 | s->sfc;
-+ if (s->direction == AMDTP_OUT_STREAM)
-+ s->ctx_data.rx.fdf = AMDTP_FDF_AM824 | s->sfc;
-
- p->pcm_channels = pcm_channels;
- p->midi_ports = midi_ports;
-diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
-index c5b1d5900eed..d6420d224d09 100644
---- a/sound/isa/wavefront/wavefront_synth.c
-+++ b/sound/isa/wavefront/wavefront_synth.c
-@@ -1171,7 +1171,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),
-@@ -1202,6 +1205,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/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
-index 2c4575909441..e057ecb5a904 100644
---- a/sound/pci/hda/patch_realtek.c
-+++ b/sound/pci/hda/patch_realtek.c
-@@ -81,6 +81,7 @@ struct alc_spec {
-
- /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
- int mute_led_polarity;
-+ int micmute_led_polarity;
- hda_nid_t mute_led_nid;
- hda_nid_t cap_mute_led_nid;
-
-@@ -4080,11 +4081,9 @@ static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
-
- /* update LED status via GPIO */
- static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
-- bool enabled)
-+ int polarity, bool enabled)
- {
-- struct alc_spec *spec = codec->spec;
--
-- if (spec->mute_led_polarity)
-+ if (polarity)
- enabled = !enabled;
- alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
- }
-@@ -4095,7 +4094,8 @@ static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
- struct hda_codec *codec = private_data;
- struct alc_spec *spec = codec->spec;
-
-- alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
-+ alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
-+ spec->mute_led_polarity, enabled);
- }
-
- /* turn on/off mic-mute LED via GPIO per capture hook */
-@@ -4104,6 +4104,7 @@ static void alc_gpio_micmute_update(struct hda_codec *codec)
- struct alc_spec *spec = codec->spec;
-
- alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
-+ spec->micmute_led_polarity,
- spec->gen.micmute_led.led_value);
- }
-
-@@ -5808,7 +5809,8 @@ static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
-
- snd_hda_gen_hp_automute(codec, jack);
- /* mute_led_polarity is set to 0, so we pass inverted value here */
-- alc_update_gpio_led(codec, 0x10, !spec->gen.hp_jack_present);
-+ alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
-+ !spec->gen.hp_jack_present);
- }
-
- /* Manage GPIOs for HP EliteBook Folio 9480m.
-diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
-index e60e0b6a689c..8a66f23a7b05 100644
---- a/sound/soc/codecs/Kconfig
-+++ b/sound/soc/codecs/Kconfig
-@@ -1136,10 +1136,13 @@ config SND_SOC_RT5677_SPI
- config SND_SOC_RT5682
- tristate
- depends on I2C || SOUNDWIRE
-+ depends on SOUNDWIRE || !SOUNDWIRE
-+ depends on I2C || !I2C
-
- config SND_SOC_RT5682_SDW
- tristate "Realtek RT5682 Codec - SDW"
- depends on SOUNDWIRE
-+ depends on I2C || !I2C
- select SND_SOC_RT5682
- select REGMAP_SOUNDWIRE
-
-@@ -1620,19 +1623,19 @@ config SND_SOC_WM9090
-
- config SND_SOC_WM9705
- tristate
-- depends on SND_SOC_AC97_BUS
-+ depends on SND_SOC_AC97_BUS || AC97_BUS_NEW
- select REGMAP_AC97
- select AC97_BUS_COMPAT if AC97_BUS_NEW
-
- config SND_SOC_WM9712
- tristate
-- depends on SND_SOC_AC97_BUS
-+ depends on SND_SOC_AC97_BUS || AC97_BUS_NEW
- select REGMAP_AC97
- select AC97_BUS_COMPAT if AC97_BUS_NEW
-
- config SND_SOC_WM9713
- tristate
-- depends on SND_SOC_AC97_BUS
-+ depends on SND_SOC_AC97_BUS || AC97_BUS_NEW
- select REGMAP_AC97
- select AC97_BUS_COMPAT if AC97_BUS_NEW
-
-diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c
-index cae1def8902d..96718e3a1ad0 100644
---- a/sound/soc/codecs/max98373.c
-+++ b/sound/soc/codecs/max98373.c
-@@ -850,8 +850,8 @@ static int max98373_resume(struct device *dev)
- {
- struct max98373_priv *max98373 = dev_get_drvdata(dev);
-
-- max98373_reset(max98373, dev);
- regcache_cache_only(max98373->regmap, false);
-+ max98373_reset(max98373, dev);
- regcache_sync(max98373->regmap);
- return 0;
- }
-diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c
-index a5a7e46de246..a7f45191364d 100644
---- a/sound/soc/codecs/rt1308-sdw.c
-+++ b/sound/soc/codecs/rt1308-sdw.c
-@@ -482,6 +482,9 @@ static int rt1308_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
- {
- struct sdw_stream_data *stream;
-
-+ if (!sdw_stream)
-+ return 0;
-+
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
-index 6ba1849a77b0..e2e1d5b03b38 100644
---- a/sound/soc/codecs/rt5645.c
-+++ b/sound/soc/codecs/rt5645.c
-@@ -3625,6 +3625,12 @@ static const struct rt5645_platform_data asus_t100ha_platform_data = {
- .inv_jd1_1 = true,
- };
-
-+static const struct rt5645_platform_data asus_t101ha_platform_data = {
-+ .dmic1_data_pin = RT5645_DMIC_DATA_IN2N,
-+ .dmic2_data_pin = RT5645_DMIC2_DISABLE,
-+ .jd_mode = 3,
-+};
-+
- static const struct rt5645_platform_data lenovo_ideapad_miix_310_pdata = {
- .jd_mode = 3,
- .in2_diff = true,
-@@ -3708,6 +3714,14 @@ static const struct dmi_system_id dmi_platform_data[] = {
- },
- .driver_data = (void *)&asus_t100ha_platform_data,
- },
-+ {
-+ .ident = "ASUS T101HA",
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "T101HA"),
-+ },
-+ .driver_data = (void *)&asus_t101ha_platform_data,
-+ },
- {
- .ident = "MINIX Z83-4",
- .matches = {
-diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
-index d36f560ad7a8..c4892af14850 100644
---- a/sound/soc/codecs/rt5682.c
-+++ b/sound/soc/codecs/rt5682.c
-@@ -2958,6 +2958,9 @@ static int rt5682_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
- {
- struct sdw_stream_data *stream;
-
-+ if (!sdw_stream)
-+ return 0;
-+
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c
-index ff68f0e4f629..687ac2153666 100644
---- a/sound/soc/codecs/rt700.c
-+++ b/sound/soc/codecs/rt700.c
-@@ -860,6 +860,9 @@ static int rt700_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
- {
- struct sdw_stream_data *stream;
-
-+ if (!sdw_stream)
-+ return 0;
-+
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c
-index 2daed7692a3b..65b59dbfb43c 100644
---- a/sound/soc/codecs/rt711.c
-+++ b/sound/soc/codecs/rt711.c
-@@ -906,6 +906,9 @@ static int rt711_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
- {
- struct sdw_stream_data *stream;
-
-+ if (!sdw_stream)
-+ return 0;
-+
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c
-index 2cbc57b16b13..099c8bd20006 100644
---- a/sound/soc/codecs/rt715.c
-+++ b/sound/soc/codecs/rt715.c
-@@ -530,6 +530,9 @@ static int rt715_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
-
- struct sdw_stream_data *stream;
-
-+ if (!sdw_stream)
-+ return 0;
-+
- stream = kzalloc(sizeof(*stream), GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
-index e7178817d7a7..1ee10eafe3e6 100644
---- a/sound/soc/fsl/fsl_asrc_dma.c
-+++ b/sound/soc/fsl/fsl_asrc_dma.c
-@@ -252,6 +252,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
- 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/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
-index c7a49d03463a..84290be778f0 100644
---- a/sound/soc/fsl/fsl_esai.c
-+++ b/sound/soc/fsl/fsl_esai.c
-@@ -87,6 +87,10 @@ static irqreturn_t esai_isr(int irq, void *devid)
- if ((saisr & (ESAI_SAISR_TUE | ESAI_SAISR_ROE)) &&
- esai_priv->reset_at_xrun) {
- dev_dbg(&pdev->dev, "reset module for xrun\n");
-+ regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR,
-+ ESAI_xCR_xEIE_MASK, 0);
-+ regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR,
-+ ESAI_xCR_xEIE_MASK, 0);
- tasklet_schedule(&esai_priv->task);
- }
-
-diff --git a/sound/soc/img/img-i2s-in.c b/sound/soc/img/img-i2s-in.c
-index a495d1050d49..e30b66b94bf6 100644
---- a/sound/soc/img/img-i2s-in.c
-+++ b/sound/soc/img/img-i2s-in.c
-@@ -482,6 +482,7 @@ static int img_i2s_in_probe(struct platform_device *pdev)
- if (IS_ERR(rst)) {
- if (PTR_ERR(rst) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
-+ pm_runtime_put(&pdev->dev);
- goto err_suspend;
- }
-
-diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
-index 08f4ae964b02..5c1a5e2aff6f 100644
---- a/sound/soc/intel/boards/bytcr_rt5640.c
-+++ b/sound/soc/intel/boards/bytcr_rt5640.c
-@@ -742,6 +742,30 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
- BYT_RT5640_SSP0_AIF1 |
- BYT_RT5640_MCLK_EN),
- },
-+ { /* Toshiba Encore WT8-A */
-+ .matches = {
-+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
-+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT8-A"),
-+ },
-+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
-+ BYT_RT5640_JD_SRC_JD2_IN4N |
-+ BYT_RT5640_OVCD_TH_2000UA |
-+ BYT_RT5640_OVCD_SF_0P75 |
-+ BYT_RT5640_JD_NOT_INV |
-+ BYT_RT5640_MCLK_EN),
-+ },
-+ { /* Toshiba Encore WT10-A */
-+ .matches = {
-+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
-+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT10-A-103"),
-+ },
-+ .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
-+ BYT_RT5640_JD_SRC_JD1_IN4P |
-+ BYT_RT5640_OVCD_TH_2000UA |
-+ BYT_RT5640_OVCD_SF_0P75 |
-+ BYT_RT5640_SSP0_AIF2 |
-+ BYT_RT5640_MCLK_EN),
-+ },
- { /* Catch-all for generic Insyde tablets, must be last */
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
-diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
-index 2e9b56b29d31..b2e867113226 100644
---- a/sound/soc/meson/axg-fifo.c
-+++ b/sound/soc/meson/axg-fifo.c
-@@ -249,7 +249,7 @@ int axg_fifo_pcm_open(struct snd_soc_component *component,
- /* Enable pclk to access registers and clock the fifo ip */
- ret = clk_prepare_enable(fifo->pclk);
- if (ret)
-- return ret;
-+ goto free_irq;
-
- /* Setup status2 so it reports the memory pointer */
- regmap_update_bits(fifo->map, FIFO_CTRL1,
-@@ -269,8 +269,14 @@ int axg_fifo_pcm_open(struct snd_soc_component *component,
- /* Take memory arbitror out of reset */
- ret = reset_control_deassert(fifo->arb);
- if (ret)
-- clk_disable_unprepare(fifo->pclk);
-+ goto free_clk;
-+
-+ return 0;
-
-+free_clk:
-+ clk_disable_unprepare(fifo->pclk);
-+free_irq:
-+ free_irq(fifo->irq, ss);
- return ret;
- }
- EXPORT_SYMBOL_GPL(axg_fifo_pcm_open);
-diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
-index 2ca8c98e204f..5a4a91c88734 100644
---- a/sound/soc/meson/meson-card-utils.c
-+++ b/sound/soc/meson/meson-card-utils.c
-@@ -49,19 +49,26 @@ int meson_card_reallocate_links(struct snd_soc_card *card,
- links = krealloc(priv->card.dai_link,
- num_links * sizeof(*priv->card.dai_link),
- GFP_KERNEL | __GFP_ZERO);
-+ if (!links)
-+ goto err_links;
-+
- ldata = krealloc(priv->link_data,
- num_links * sizeof(*priv->link_data),
- GFP_KERNEL | __GFP_ZERO);
--
-- if (!links || !ldata) {
-- dev_err(priv->card.dev, "failed to allocate links\n");
-- return -ENOMEM;
-- }
-+ if (!ldata)
-+ goto err_ldata;
-
- priv->card.dai_link = links;
- priv->link_data = ldata;
- priv->card.num_links = num_links;
- return 0;
-+
-+err_ldata:
-+ kfree(links);
-+err_links:
-+ dev_err(priv->card.dev, "failed to allocate links\n");
-+ return -ENOMEM;
-+
- }
- EXPORT_SYMBOL_GPL(meson_card_reallocate_links);
-
-diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
-index 125af00bba53..4640804aab7f 100644
---- a/sound/soc/qcom/qdsp6/q6asm-dai.c
-+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
-@@ -176,7 +176,7 @@ static const struct snd_compr_codec_caps q6asm_compr_caps = {
- };
-
- static void event_handler(uint32_t opcode, uint32_t token,
-- uint32_t *payload, void *priv)
-+ void *payload, void *priv)
- {
- struct q6asm_dai_rtd *prtd = priv;
- struct snd_pcm_substream *substream = prtd->substream;
-@@ -490,7 +490,7 @@ static int q6asm_dai_hw_params(struct snd_soc_component *component,
- }
-
- static void compress_event_handler(uint32_t opcode, uint32_t token,
-- uint32_t *payload, void *priv)
-+ void *payload, void *priv)
- {
- struct q6asm_dai_rtd *prtd = priv;
- struct snd_compr_stream *substream = prtd->cstream;
-diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
-index af19010b9d88..8bd49c8a9517 100644
---- a/sound/soc/sh/rcar/gen.c
-+++ b/sound/soc/sh/rcar/gen.c
-@@ -224,6 +224,14 @@ static int rsnd_gen2_probe(struct rsnd_priv *priv)
- RSND_GEN_S_REG(SSI_SYS_STATUS5, 0x884),
- RSND_GEN_S_REG(SSI_SYS_STATUS6, 0x888),
- RSND_GEN_S_REG(SSI_SYS_STATUS7, 0x88c),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE0, 0x850),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE1, 0x854),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE2, 0x858),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE3, 0x85c),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE4, 0x890),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE5, 0x894),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE6, 0x898),
-+ RSND_GEN_S_REG(SSI_SYS_INT_ENABLE7, 0x89c),
- RSND_GEN_S_REG(HDMI0_SEL, 0x9e0),
- RSND_GEN_S_REG(HDMI1_SEL, 0x9e4),
-
-diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
-index ea6cbaa9743e..d47608ff5fac 100644
---- a/sound/soc/sh/rcar/rsnd.h
-+++ b/sound/soc/sh/rcar/rsnd.h
-@@ -189,6 +189,14 @@ enum rsnd_reg {
- SSI_SYS_STATUS5,
- SSI_SYS_STATUS6,
- SSI_SYS_STATUS7,
-+ SSI_SYS_INT_ENABLE0,
-+ SSI_SYS_INT_ENABLE1,
-+ SSI_SYS_INT_ENABLE2,
-+ SSI_SYS_INT_ENABLE3,
-+ SSI_SYS_INT_ENABLE4,
-+ SSI_SYS_INT_ENABLE5,
-+ SSI_SYS_INT_ENABLE6,
-+ SSI_SYS_INT_ENABLE7,
- HDMI0_SEL,
- HDMI1_SEL,
- SSI9_BUSIF0_MODE,
-@@ -237,6 +245,7 @@ enum rsnd_reg {
- #define SSI9_BUSIF_ADINR(i) (SSI9_BUSIF0_ADINR + (i))
- #define SSI9_BUSIF_DALIGN(i) (SSI9_BUSIF0_DALIGN + (i))
- #define SSI_SYS_STATUS(i) (SSI_SYS_STATUS0 + (i))
-+#define SSI_SYS_INT_ENABLE(i) (SSI_SYS_INT_ENABLE0 + (i))
-
-
- struct rsnd_priv;
-diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
-index 4a7d3413917f..47d5ddb526f2 100644
---- a/sound/soc/sh/rcar/ssi.c
-+++ b/sound/soc/sh/rcar/ssi.c
-@@ -372,6 +372,9 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod,
- u32 wsr = ssi->wsr;
- int width;
- int is_tdm, is_tdm_split;
-+ int id = rsnd_mod_id(mod);
-+ int i;
-+ u32 sys_int_enable = 0;
-
- is_tdm = rsnd_runtime_is_tdm(io);
- is_tdm_split = rsnd_runtime_is_tdm_split(io);
-@@ -447,6 +450,38 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod,
- cr_mode = DIEN; /* PIO : enable Data interrupt */
- }
-
-+ /* enable busif buffer over/under run interrupt. */
-+ if (is_tdm || is_tdm_split) {
-+ switch (id) {
-+ case 0:
-+ case 1:
-+ case 2:
-+ case 3:
-+ case 4:
-+ for (i = 0; i < 4; i++) {
-+ sys_int_enable = rsnd_mod_read(mod,
-+ SSI_SYS_INT_ENABLE(i * 2));
-+ sys_int_enable |= 0xf << (id * 4);
-+ rsnd_mod_write(mod,
-+ SSI_SYS_INT_ENABLE(i * 2),
-+ sys_int_enable);
-+ }
-+
-+ break;
-+ case 9:
-+ for (i = 0; i < 4; i++) {
-+ sys_int_enable = rsnd_mod_read(mod,
-+ SSI_SYS_INT_ENABLE((i * 2) + 1));
-+ sys_int_enable |= 0xf << 4;
-+ rsnd_mod_write(mod,
-+ SSI_SYS_INT_ENABLE((i * 2) + 1),
-+ sys_int_enable);
-+ }
-+
-+ break;
-+ }
-+ }
-+
- init_end:
- ssi->cr_own = cr_own;
- ssi->cr_mode = cr_mode;
-@@ -496,6 +531,13 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
- {
- struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
- struct device *dev = rsnd_priv_to_dev(priv);
-+ int is_tdm, is_tdm_split;
-+ int id = rsnd_mod_id(mod);
-+ int i;
-+ u32 sys_int_enable = 0;
-+
-+ is_tdm = rsnd_runtime_is_tdm(io);
-+ is_tdm_split = rsnd_runtime_is_tdm_split(io);
-
- if (!rsnd_ssi_is_run_mods(mod, io))
- return 0;
-@@ -517,6 +559,38 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
- ssi->wsr = 0;
- }
-
-+ /* disable busif buffer over/under run interrupt. */
-+ if (is_tdm || is_tdm_split) {
-+ switch (id) {
-+ case 0:
-+ case 1:
-+ case 2:
-+ case 3:
-+ case 4:
-+ for (i = 0; i < 4; i++) {
-+ sys_int_enable = rsnd_mod_read(mod,
-+ SSI_SYS_INT_ENABLE(i * 2));
-+ sys_int_enable &= ~(0xf << (id * 4));
-+ rsnd_mod_write(mod,
-+ SSI_SYS_INT_ENABLE(i * 2),
-+ sys_int_enable);
-+ }
-+
-+ break;
-+ case 9:
-+ for (i = 0; i < 4; i++) {
-+ sys_int_enable = rsnd_mod_read(mod,
-+ SSI_SYS_INT_ENABLE((i * 2) + 1));
-+ sys_int_enable &= ~(0xf << 4);
-+ rsnd_mod_write(mod,
-+ SSI_SYS_INT_ENABLE((i * 2) + 1),
-+ sys_int_enable);
-+ }
-+
-+ break;
-+ }
-+ }
-+
- return 0;
- }
-
-@@ -622,6 +696,11 @@ static int rsnd_ssi_irq(struct rsnd_mod *mod,
- int enable)
- {
- u32 val = 0;
-+ int is_tdm, is_tdm_split;
-+ int id = rsnd_mod_id(mod);
-+
-+ is_tdm = rsnd_runtime_is_tdm(io);
-+ is_tdm_split = rsnd_runtime_is_tdm_split(io);
-
- if (rsnd_is_gen1(priv))
- return 0;
-@@ -635,6 +714,19 @@ static int rsnd_ssi_irq(struct rsnd_mod *mod,
- if (enable)
- val = rsnd_ssi_is_dma_mode(mod) ? 0x0e000000 : 0x0f000000;
-
-+ if (is_tdm || is_tdm_split) {
-+ switch (id) {
-+ case 0:
-+ case 1:
-+ case 2:
-+ case 3:
-+ case 4:
-+ case 9:
-+ val |= 0x0000ff00;
-+ break;
-+ }
-+ }
-+
- rsnd_mod_write(mod, SSI_INT_ENABLE, val);
-
- return 0;
-@@ -651,6 +743,12 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
- u32 status;
- bool elapsed = false;
- bool stop = false;
-+ int id = rsnd_mod_id(mod);
-+ int i;
-+ int is_tdm, is_tdm_split;
-+
-+ is_tdm = rsnd_runtime_is_tdm(io);
-+ is_tdm_split = rsnd_runtime_is_tdm_split(io);
-
- spin_lock(&priv->lock);
-
-@@ -672,6 +770,53 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
- stop = true;
- }
-
-+ status = 0;
-+
-+ if (is_tdm || is_tdm_split) {
-+ switch (id) {
-+ case 0:
-+ case 1:
-+ case 2:
-+ case 3:
-+ case 4:
-+ for (i = 0; i < 4; i++) {
-+ status = rsnd_mod_read(mod,
-+ SSI_SYS_STATUS(i * 2));
-+ status &= 0xf << (id * 4);
-+
-+ if (status) {
-+ rsnd_dbg_irq_status(dev,
-+ "%s err status : 0x%08x\n",
-+ rsnd_mod_name(mod), status);
-+ rsnd_mod_write(mod,
-+ SSI_SYS_STATUS(i * 2),
-+ 0xf << (id * 4));
-+ stop = true;
-+ break;
-+ }
-+ }
-+ break;
-+ case 9:
-+ for (i = 0; i < 4; i++) {
-+ status = rsnd_mod_read(mod,
-+ SSI_SYS_STATUS((i * 2) + 1));
-+ status &= 0xf << 4;
-+
-+ if (status) {
-+ rsnd_dbg_irq_status(dev,
-+ "%s err status : 0x%08x\n",
-+ rsnd_mod_name(mod), status);
-+ rsnd_mod_write(mod,
-+ SSI_SYS_STATUS((i * 2) + 1),
-+ 0xf << 4);
-+ stop = true;
-+ break;
-+ }
-+ }
-+ break;
-+ }
-+ }
-+
- rsnd_ssi_status_clear(mod);
- rsnd_ssi_interrupt_out:
- spin_unlock(&priv->lock);
-diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
-index 843b8b1c89d4..e5433e8fcf19 100644
---- a/sound/soc/soc-core.c
-+++ b/sound/soc/soc-core.c
-@@ -1720,9 +1720,25 @@ match:
- dai_link->platforms->name = component->name;
-
- /* convert non BE into BE */
-- dai_link->no_pcm = 1;
-- dai_link->dpcm_playback = 1;
-- dai_link->dpcm_capture = 1;
-+ if (!dai_link->no_pcm) {
-+ dai_link->no_pcm = 1;
-+
-+ if (dai_link->dpcm_playback)
-+ dev_warn(card->dev,
-+ "invalid configuration, dailink %s has flags no_pcm=0 and dpcm_playback=1\n",
-+ dai_link->name);
-+ if (dai_link->dpcm_capture)
-+ dev_warn(card->dev,
-+ "invalid configuration, dailink %s has flags no_pcm=0 and dpcm_capture=1\n",
-+ dai_link->name);
-+
-+ /* convert normal link into DPCM one */
-+ if (!(dai_link->dpcm_playback ||
-+ dai_link->dpcm_capture)) {
-+ dai_link->dpcm_playback = !dai_link->capture_only;
-+ dai_link->dpcm_capture = !dai_link->playback_only;
-+ }
-+ }
-
- /* override any BE fixups */
- dai_link->be_hw_params_fixup =
-diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
-index e2632841b321..c0aa64ff8e32 100644
---- a/sound/soc/soc-dapm.c
-+++ b/sound/soc/soc-dapm.c
-@@ -4340,16 +4340,16 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card,
- codec = codec_dai->playback_widget;
-
- if (playback_cpu && codec) {
-- if (dai_link->params && !dai_link->playback_widget) {
-+ if (dai_link->params && !rtd->playback_widget) {
- substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
- dai = snd_soc_dapm_new_dai(card, substream, "playback");
- if (IS_ERR(dai))
- goto capture;
-- dai_link->playback_widget = dai;
-+ rtd->playback_widget = dai;
- }
-
- dapm_connect_dai_routes(&card->dapm, cpu_dai, playback_cpu,
-- dai_link->playback_widget,
-+ rtd->playback_widget,
- codec_dai, codec);
- }
-
-@@ -4358,16 +4358,16 @@ capture:
- codec = codec_dai->capture_widget;
-
- if (codec && capture_cpu) {
-- if (dai_link->params && !dai_link->capture_widget) {
-+ if (dai_link->params && !rtd->capture_widget) {
- substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream;
- dai = snd_soc_dapm_new_dai(card, substream, "capture");
- if (IS_ERR(dai))
- return;
-- dai_link->capture_widget = dai;
-+ rtd->capture_widget = dai;
- }
-
- dapm_connect_dai_routes(&card->dapm, codec_dai, codec,
-- dai_link->capture_widget,
-+ rtd->capture_widget,
- cpu_dai, capture_cpu);
- }
- }
-diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
-index 1f302de44052..39ce61c5b874 100644
---- a/sound/soc/soc-pcm.c
-+++ b/sound/soc/soc-pcm.c
-@@ -2908,20 +2908,44 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
- struct snd_pcm *pcm;
- char new_name[64];
- int ret = 0, playback = 0, capture = 0;
-+ int stream;
- int i;
-
-+ if (rtd->dai_link->dynamic && rtd->num_cpus > 1) {
-+ dev_err(rtd->dev,
-+ "DPCM doesn't support Multi CPU for Front-Ends yet\n");
-+ return -EINVAL;
-+ }
-+
- if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) {
-- cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-- if (rtd->num_cpus > 1) {
-- dev_err(rtd->dev,
-- "DPCM doesn't support Multi CPU yet\n");
-- return -EINVAL;
-+ if (rtd->dai_link->dpcm_playback) {
-+ stream = SNDRV_PCM_STREAM_PLAYBACK;
-+
-+ for_each_rtd_cpu_dais(rtd, i, cpu_dai)
-+ if (!snd_soc_dai_stream_valid(cpu_dai,
-+ stream)) {
-+ dev_err(rtd->card->dev,
-+ "CPU DAI %s for rtd %s does not support playback\n",
-+ cpu_dai->name,
-+ rtd->dai_link->stream_name);
-+ return -EINVAL;
-+ }
-+ playback = 1;
-+ }
-+ if (rtd->dai_link->dpcm_capture) {
-+ stream = SNDRV_PCM_STREAM_CAPTURE;
-+
-+ for_each_rtd_cpu_dais(rtd, i, cpu_dai)
-+ if (!snd_soc_dai_stream_valid(cpu_dai,
-+ stream)) {
-+ dev_err(rtd->card->dev,
-+ "CPU DAI %s for rtd %s does not support capture\n",
-+ cpu_dai->name,
-+ rtd->dai_link->stream_name);
-+ return -EINVAL;
-+ }
-+ capture = 1;
- }
--
-- playback = rtd->dai_link->dpcm_playback &&
-- snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK);
-- capture = rtd->dai_link->dpcm_capture &&
-- snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE);
- } else {
- /* Adapt stream for codec2codec links */
- int cpu_capture = rtd->dai_link->params ?
-diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
-index dfc412e2d956..6d63768d42aa 100644
---- a/sound/soc/sof/control.c
-+++ b/sound/soc/sof/control.c
-@@ -19,8 +19,8 @@ static void update_mute_led(struct snd_sof_control *scontrol,
- struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
-- unsigned int temp = 0;
-- unsigned int mask;
-+ int temp = 0;
-+ int mask;
- int i;
-
- mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
-diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
-index 91acfae7935c..74b438216216 100644
---- a/sound/soc/sof/core.c
-+++ b/sound/soc/sof/core.c
-@@ -176,6 +176,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
- /* init the IPC */
- sdev->ipc = snd_sof_ipc_init(sdev);
- if (!sdev->ipc) {
-+ ret = -ENOMEM;
- dev_err(sdev->dev, "error: failed to init DSP IPC %d\n", ret);
- goto ipc_err;
- }
-diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
-index bae4f7bf5f75..812749064ca8 100644
---- a/sound/soc/sof/imx/Kconfig
-+++ b/sound/soc/sof/imx/Kconfig
-@@ -14,7 +14,7 @@ if SND_SOC_SOF_IMX_TOPLEVEL
- config SND_SOC_SOF_IMX8_SUPPORT
- bool "SOF support for i.MX8"
- depends on IMX_SCU
-- depends on IMX_DSP
-+ select IMX_DSP
- help
- This adds support for Sound Open Firmware for NXP i.MX8 platforms
- Say Y if you have such a device.
-diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c
-index 3041fbbb010a..ea021db697b8 100644
---- a/sound/soc/sof/intel/hda-codec.c
-+++ b/sound/soc/sof/intel/hda-codec.c
-@@ -24,19 +24,44 @@
- #define IDISP_VID_INTEL 0x80860000
-
- /* load the legacy HDA codec driver */
--static int hda_codec_load_module(struct hda_codec *codec)
-+static int request_codec_module(struct hda_codec *codec)
- {
- #ifdef MODULE
- char alias[MODULE_NAME_LEN];
-- const char *module = alias;
-+ const char *mod = NULL;
-
-- snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias));
-- dev_dbg(&codec->core.dev, "loading codec module: %s\n", module);
-- request_module(module);
-+ switch (codec->probe_id) {
-+ case HDA_CODEC_ID_GENERIC:
-+#if IS_MODULE(CONFIG_SND_HDA_GENERIC)
-+ mod = "snd-hda-codec-generic";
- #endif
-+ break;
-+ default:
-+ snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias));
-+ mod = alias;
-+ break;
-+ }
-+
-+ if (mod) {
-+ dev_dbg(&codec->core.dev, "loading codec module: %s\n", mod);
-+ request_module(mod);
-+ }
-+#endif /* MODULE */
- return device_attach(hda_codec_dev(codec));
- }
-
-+static int hda_codec_load_module(struct hda_codec *codec)
-+{
-+ int ret = request_codec_module(codec);
-+
-+ if (ret <= 0) {
-+ codec->probe_id = HDA_CODEC_ID_GENERIC;
-+ ret = request_codec_module(codec);
-+ }
-+
-+ return ret;
-+}
-+
- /* enable controller wake up event for all codecs with jack connectors */
- void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev)
- {
-@@ -78,6 +103,13 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev) {}
- EXPORT_SYMBOL_NS(hda_codec_jack_wake_enable, SND_SOC_SOF_HDA_AUDIO_CODEC);
- EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC);
-
-+#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
-+#define is_generic_config(bus) \
-+ ((bus)->modelname && !strcmp((bus)->modelname, "generic"))
-+#else
-+#define is_generic_config(x) 0
-+#endif
-+
- /* probe individual codec */
- static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
- bool hda_codec_use_common_hdmi)
-@@ -87,6 +119,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
- #endif
- struct hda_bus *hbus = sof_to_hbus(sdev);
- struct hdac_device *hdev;
-+ struct hda_codec *codec;
- u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
- (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
- u32 resp = -1;
-@@ -108,6 +141,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
-
- hda_priv->codec.bus = hbus;
- hdev = &hda_priv->codec.core;
-+ codec = &hda_priv->codec;
-
- ret = snd_hdac_ext_bus_device_init(&hbus->core, address, hdev);
- if (ret < 0)
-@@ -122,6 +156,11 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
- hda_priv->need_display_power = true;
- }
-
-+ if (is_generic_config(hbus))
-+ codec->probe_id = HDA_CODEC_ID_GENERIC;
-+ else
-+ codec->probe_id = 0;
-+
- /*
- * if common HDMI codec driver is not used, codec load
- * is skipped here and hdac_hdmi is used instead
-@@ -129,7 +168,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
- if (hda_codec_use_common_hdmi ||
- (resp & 0xFFFF0000) != IDISP_VID_INTEL) {
- hdev->type = HDA_DEV_LEGACY;
-- ret = hda_codec_load_module(&hda_priv->codec);
-+ ret = hda_codec_load_module(codec);
- /*
- * handle ret==0 (no driver bound) as an error, but pass
- * other return codes without modification
-diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c
-index 2233146386cc..71cf5f9db79d 100644
---- a/sound/soc/sof/nocodec.c
-+++ b/sound/soc/sof/nocodec.c
-@@ -52,8 +52,10 @@ static int sof_nocodec_bes_setup(struct device *dev,
- links[i].platforms->name = dev_name(dev);
- links[i].codecs->dai_name = "snd-soc-dummy-dai";
- links[i].codecs->name = "snd-soc-dummy";
-- links[i].dpcm_playback = 1;
-- links[i].dpcm_capture = 1;
-+ if (ops->drv[i].playback.channels_min)
-+ links[i].dpcm_playback = 1;
-+ if (ops->drv[i].capture.channels_min)
-+ links[i].dpcm_capture = 1;
- }
-
- card->dai_link = links;
-diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c
-index c410822d9920..01d83ddc16ba 100644
---- a/sound/soc/sof/pm.c
-+++ b/sound/soc/sof/pm.c
-@@ -90,7 +90,10 @@ static int sof_resume(struct device *dev, bool runtime_resume)
- int ret;
-
- /* do nothing if dsp resume callbacks are not set */
-- if (!sof_ops(sdev)->resume || !sof_ops(sdev)->runtime_resume)
-+ if (!runtime_resume && !sof_ops(sdev)->resume)
-+ return 0;
-+
-+ if (runtime_resume && !sof_ops(sdev)->runtime_resume)
- return 0;
-
- /* DSP was never successfully started, nothing to resume */
-@@ -175,7 +178,10 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
- int ret;
-
- /* do nothing if dsp suspend callback is not set */
-- if (!sof_ops(sdev)->suspend)
-+ if (!runtime_suspend && !sof_ops(sdev)->suspend)
-+ return 0;
-+
-+ if (runtime_suspend && !sof_ops(sdev)->runtime_suspend)
- return 0;
-
- if (sdev->fw_state != SOF_FW_BOOT_COMPLETE)
-diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
-index bf65f31af858..875a5fc13297 100644
---- a/sound/soc/sof/sof-audio.h
-+++ b/sound/soc/sof/sof-audio.h
-@@ -56,7 +56,7 @@ struct snd_sof_pcm {
- struct snd_sof_led_control {
- unsigned int use_led;
- unsigned int direction;
-- unsigned int led_value;
-+ int led_value;
- };
-
- /* ALSA SOF Kcontrol device */
-diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
-index fe8ba3e05e08..ab2b69de1d4d 100644
---- a/sound/soc/sof/topology.c
-+++ b/sound/soc/sof/topology.c
-@@ -1203,6 +1203,8 @@ static int sof_control_load(struct snd_soc_component *scomp, int index,
- return ret;
- }
-
-+ scontrol->led_ctl.led_value = -1;
-+
- dobj->private = scontrol;
- list_add(&scontrol->list, &sdev->kcontrol_list);
- return ret;
-diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
-index 9b5651502f12..3aca354f9e08 100644
---- a/sound/soc/tegra/tegra_wm8903.c
-+++ b/sound/soc/tegra/tegra_wm8903.c
-@@ -177,6 +177,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
- struct snd_soc_component *component = codec_dai->component;
- struct snd_soc_card *card = rtd->card;
- struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
-+ int shrt = 0;
-
- if (gpio_is_valid(machine->gpio_hp_det)) {
- tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det;
-@@ -189,12 +190,15 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
- &tegra_wm8903_hp_jack_gpio);
- }
-
-+ if (of_property_read_bool(card->dev->of_node, "nvidia,headset"))
-+ shrt = SND_JACK_MICROPHONE;
-+
- snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
- &tegra_wm8903_mic_jack,
- tegra_wm8903_mic_jack_pins,
- ARRAY_SIZE(tegra_wm8903_mic_jack_pins));
- wm8903_mic_detect(component, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
-- 0);
-+ shrt);
-
- snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS");
-
-diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
-index 734ffe925c4d..7a7db743dc5b 100644
---- a/sound/soc/ti/davinci-mcasp.c
-+++ b/sound/soc/ti/davinci-mcasp.c
-@@ -1896,8 +1896,10 @@ static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp)
- PTR_ERR(chan));
- return PTR_ERR(chan);
- }
-- if (WARN_ON(!chan->device || !chan->device->dev))
-+ if (WARN_ON(!chan->device || !chan->device->dev)) {
-+ dma_release_channel(chan);
- return -EINVAL;
-+ }
-
- if (chan->device->dev->of_node)
- ret = of_property_read_string(chan->device->dev->of_node,
-diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
-index 3d41ca2238d4..4f33ddb7b441 100644
---- a/sound/soc/ti/omap-mcbsp.c
-+++ b/sound/soc/ti/omap-mcbsp.c
-@@ -686,7 +686,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
- mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp,
- SNDRV_PCM_STREAM_CAPTURE);
-
-- mcbsp->fclk = clk_get(&pdev->dev, "fck");
-+ mcbsp->fclk = devm_clk_get(&pdev->dev, "fck");
- if (IS_ERR(mcbsp->fclk)) {
- ret = PTR_ERR(mcbsp->fclk);
- dev_err(mcbsp->dev, "unable to get fck: %d\n", ret);
-@@ -711,7 +711,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
- if (ret) {
- dev_err(mcbsp->dev,
- "Unable to create additional controls\n");
-- goto err_thres;
-+ return ret;
- }
- }
-
-@@ -724,8 +724,6 @@ static int omap_mcbsp_init(struct platform_device *pdev)
- err_st:
- if (mcbsp->pdata->buffer_size)
- sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
--err_thres:
-- clk_put(mcbsp->fclk);
- return ret;
- }
-
-@@ -1442,8 +1440,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev)
-
- omap_mcbsp_st_cleanup(pdev);
-
-- clk_put(mcbsp->fclk);
--
- return 0;
- }
-
-diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
-index 2873e8e6f02b..cdae1190b930 100644
---- a/sound/soc/ux500/mop500.c
-+++ b/sound/soc/ux500/mop500.c
-@@ -63,10 +63,11 @@ static void mop500_of_node_put(void)
- {
- int i;
-
-- for (i = 0; i < 2; i++) {
-+ for (i = 0; i < 2; i++)
- of_node_put(mop500_dai_links[i].cpus->of_node);
-- of_node_put(mop500_dai_links[i].codecs->of_node);
-- }
-+
-+ /* Both links use the same codec, which is refcounted only once */
-+ of_node_put(mop500_dai_links[0].codecs->of_node);
- }
-
- static int mop500_of_probe(struct platform_device *pdev,
-@@ -81,7 +82,9 @@ static int mop500_of_probe(struct platform_device *pdev,
-
- if (!(msp_np[0] && msp_np[1] && codec_np)) {
- dev_err(&pdev->dev, "Phandle missing or invalid\n");
-- mop500_of_node_put();
-+ for (i = 0; i < 2; i++)
-+ of_node_put(msp_np[i]);
-+ of_node_put(codec_np);
- return -EINVAL;
- }
-
-diff --git a/sound/usb/card.h b/sound/usb/card.h
-index 395403a2d33f..d6219fba9699 100644
---- a/sound/usb/card.h
-+++ b/sound/usb/card.h
-@@ -84,6 +84,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 */
-@@ -104,6 +108,7 @@ struct snd_usb_endpoint {
- int iface, altsetting;
- int skip_packets; /* quirks for devices to ignore the first n packets
- in a stream */
-+ bool is_implicit_feedback; /* This endpoint is used as implicit feedback */
-
- spinlock_t lock;
- struct list_head list;
-diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
-index 4a9a2f6ef5a4..9bea7d3f99f8 100644
---- a/sound/usb/endpoint.c
-+++ b/sound/usb/endpoint.c
-@@ -124,12 +124,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;
-@@ -146,6 +146,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)
- {
-@@ -190,6 +213,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);
-
-@@ -321,17 +346,17 @@ static void queue_pending_output_urbs(struct snd_usb_endpoint *ep)
- ep->next_packet_read_pos %= MAX_URBS;
-
- /* take URB out of FIFO */
-- if (!list_empty(&ep->ready_playback_urbs))
-+ if (!list_empty(&ep->ready_playback_urbs)) {
- ctx = list_first_entry(&ep->ready_playback_urbs,
- struct snd_urb_ctx, ready_list);
-+ list_del_init(&ctx->ready_list);
-+ }
- }
- spin_unlock_irqrestore(&ep->lock, flags);
-
- if (ctx == NULL)
- return;
-
-- list_del_init(&ctx->ready_list);
--
- /* copy over the length information */
- for (i = 0; i < packet->packets; i++)
- ctx->packet_size[i] = packet->packet_size[i];
-@@ -497,6 +522,8 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
-
- list_add_tail(&ep->list, &chip->ep_list);
-
-+ ep->is_implicit_feedback = 0;
-+
- __exit_unlock:
- mutex_unlock(&chip->mutex);
-
-@@ -596,6 +623,178 @@ static void release_urbs(struct snd_usb_endpoint *ep, int force)
- ep->nurbs = 0;
- }
-
-+/*
-+ * Check data endpoint for format differences
-+ */
-+static bool check_ep_params(struct snd_usb_endpoint *ep,
-+ snd_pcm_format_t pcm_format,
-+ unsigned int channels,
-+ unsigned int period_bytes,
-+ unsigned int frames_per_period,
-+ unsigned int periods_per_buffer,
-+ struct audioformat *fmt,
-+ struct snd_usb_endpoint *sync_ep)
-+{
-+ unsigned int maxsize, minsize, packs_per_ms, max_packs_per_urb;
-+ unsigned int max_packs_per_period, urbs_per_period, urb_packs;
-+ unsigned int max_urbs;
-+ int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels;
-+ int tx_length_quirk = (ep->chip->tx_length_quirk &&
-+ usb_pipeout(ep->pipe));
-+ bool ret = 1;
-+
-+ if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) {
-+ /*
-+ * When operating in DSD DOP mode, the size of a sample frame
-+ * in hardware differs from the actual physical format width
-+ * because we need to make room for the DOP markers.
-+ */
-+ frame_bits += channels << 3;
-+ }
-+
-+ ret = ret && (ep->datainterval == fmt->datainterval);
-+ ret = ret && (ep->stride == frame_bits >> 3);
-+
-+ switch (pcm_format) {
-+ case SNDRV_PCM_FORMAT_U8:
-+ ret = ret && (ep->silence_value == 0x80);
-+ break;
-+ case SNDRV_PCM_FORMAT_DSD_U8:
-+ case SNDRV_PCM_FORMAT_DSD_U16_LE:
-+ case SNDRV_PCM_FORMAT_DSD_U32_LE:
-+ case SNDRV_PCM_FORMAT_DSD_U16_BE:
-+ case SNDRV_PCM_FORMAT_DSD_U32_BE:
-+ ret = ret && (ep->silence_value == 0x69);
-+ break;
-+ default:
-+ ret = ret && (ep->silence_value == 0);
-+ }
-+
-+ /* assume max. frequency is 50% higher than nominal */
-+ ret = ret && (ep->freqmax == ep->freqn + (ep->freqn >> 1));
-+ /* Round up freqmax to nearest integer in order to calculate maximum
-+ * packet size, which must represent a whole number of frames.
-+ * This is accomplished by adding 0x0.ffff before converting the
-+ * Q16.16 format into integer.
-+ * In order to accurately calculate the maximum packet size when
-+ * the data interval is more than 1 (i.e. ep->datainterval > 0),
-+ * multiply by the data interval prior to rounding. For instance,
-+ * a freqmax of 41 kHz will result in a max packet size of 6 (5.125)
-+ * frames with a data interval of 1, but 11 (10.25) frames with a
-+ * data interval of 2.
-+ * (ep->freqmax << ep->datainterval overflows at 8.192 MHz for the
-+ * maximum datainterval value of 3, at USB full speed, higher for
-+ * USB high speed, noting that ep->freqmax is in units of
-+ * frames per packet in Q16.16 format.)
-+ */
-+ maxsize = (((ep->freqmax << ep->datainterval) + 0xffff) >> 16) *
-+ (frame_bits >> 3);
-+ if (tx_length_quirk)
-+ maxsize += sizeof(__le32); /* Space for length descriptor */
-+ /* but wMaxPacketSize might reduce this */
-+ if (ep->maxpacksize && ep->maxpacksize < maxsize) {
-+ /* whatever fits into a max. size packet */
-+ unsigned int data_maxsize = maxsize = ep->maxpacksize;
-+
-+ if (tx_length_quirk)
-+ /* Need to remove the length descriptor to calc freq */
-+ data_maxsize -= sizeof(__le32);
-+ ret = ret && (ep->freqmax == (data_maxsize / (frame_bits >> 3))
-+ << (16 - ep->datainterval));
-+ }
-+
-+ if (ep->fill_max)
-+ ret = ret && (ep->curpacksize == ep->maxpacksize);
-+ else
-+ ret = ret && (ep->curpacksize == maxsize);
-+
-+ if (snd_usb_get_speed(ep->chip->dev) != USB_SPEED_FULL) {
-+ packs_per_ms = 8 >> ep->datainterval;
-+ max_packs_per_urb = MAX_PACKS_HS;
-+ } else {
-+ packs_per_ms = 1;
-+ max_packs_per_urb = MAX_PACKS;
-+ }
-+ if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep))
-+ max_packs_per_urb = min(max_packs_per_urb,
-+ 1U << sync_ep->syncinterval);
-+ max_packs_per_urb = max(1u, max_packs_per_urb >> ep->datainterval);
-+
-+ /*
-+ * Capture endpoints need to use small URBs because there's no way
-+ * to tell in advance where the next period will end, and we don't
-+ * want the next URB to complete much after the period ends.
-+ *
-+ * Playback endpoints with implicit sync much use the same parameters
-+ * as their corresponding capture endpoint.
-+ */
-+ if (usb_pipein(ep->pipe) ||
-+ snd_usb_endpoint_implicit_feedback_sink(ep)) {
-+
-+ urb_packs = packs_per_ms;
-+ /*
-+ * Wireless devices can poll at a max rate of once per 4ms.
-+ * For dataintervals less than 5, increase the packet count to
-+ * allow the host controller to use bursting to fill in the
-+ * gaps.
-+ */
-+ if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_WIRELESS) {
-+ int interval = ep->datainterval;
-+
-+ while (interval < 5) {
-+ urb_packs <<= 1;
-+ ++interval;
-+ }
-+ }
-+ /* make capture URBs <= 1 ms and smaller than a period */
-+ urb_packs = min(max_packs_per_urb, urb_packs);
-+ while (urb_packs > 1 && urb_packs * maxsize >= period_bytes)
-+ urb_packs >>= 1;
-+ ret = ret && (ep->nurbs == MAX_URBS);
-+
-+ /*
-+ * Playback endpoints without implicit sync are adjusted so that
-+ * a period fits as evenly as possible in the smallest number of
-+ * URBs. The total number of URBs is adjusted to the size of the
-+ * ALSA buffer, subject to the MAX_URBS and MAX_QUEUE limits.
-+ */
-+ } else {
-+ /* determine how small a packet can be */
-+ minsize = (ep->freqn >> (16 - ep->datainterval)) *
-+ (frame_bits >> 3);
-+ /* with sync from device, assume it can be 12% lower */
-+ if (sync_ep)
-+ minsize -= minsize >> 3;
-+ minsize = max(minsize, 1u);
-+
-+ /* how many packets will contain an entire ALSA period? */
-+ max_packs_per_period = DIV_ROUND_UP(period_bytes, minsize);
-+
-+ /* how many URBs will contain a period? */
-+ urbs_per_period = DIV_ROUND_UP(max_packs_per_period,
-+ max_packs_per_urb);
-+ /* how many packets are needed in each URB? */
-+ urb_packs = DIV_ROUND_UP(max_packs_per_period, urbs_per_period);
-+
-+ /* limit the number of frames in a single URB */
-+ ret = ret && (ep->max_urb_frames ==
-+ DIV_ROUND_UP(frames_per_period, urbs_per_period));
-+
-+ /* try to use enough URBs to contain an entire ALSA buffer */
-+ max_urbs = min((unsigned) MAX_URBS,
-+ MAX_QUEUE * packs_per_ms / urb_packs);
-+ ret = ret && (ep->nurbs == min(max_urbs,
-+ urbs_per_period * periods_per_buffer));
-+ }
-+
-+ ret = ret && (ep->datainterval == fmt->datainterval);
-+ ret = ret && (ep->maxpacksize == fmt->maxpacksize);
-+ ret = ret &&
-+ (ep->fill_max == !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX));
-+
-+ return ret;
-+}
-+
- /*
- * configure a data endpoint
- */
-@@ -861,10 +1060,23 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
- int err;
-
- if (ep->use_count != 0) {
-- usb_audio_warn(ep->chip,
-- "Unable to change format on ep #%x: already in use\n",
-- ep->ep_num);
-- return -EBUSY;
-+ bool check = ep->is_implicit_feedback &&
-+ check_ep_params(ep, pcm_format,
-+ channels, period_bytes,
-+ period_frames, buffer_periods,
-+ fmt, sync_ep);
-+
-+ if (!check) {
-+ usb_audio_warn(ep->chip,
-+ "Unable to change format on ep #%x: already in use\n",
-+ ep->ep_num);
-+ return -EBUSY;
-+ }
-+
-+ usb_audio_dbg(ep->chip,
-+ "Ep #%x already in use as implicit feedback but format not changed\n",
-+ ep->ep_num);
-+ return 0;
- }
-
- /* release old buffers, if any */
-@@ -874,10 +1086,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;
-@@ -936,6 +1155,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 63a39d4fa8d8..d23fa0a8c11b 100644
---- a/sound/usb/endpoint.h
-+++ b/sound/usb/endpoint.h
-@@ -28,6 +28,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_quirks.c b/sound/usb/mixer_quirks.c
-index a5f65a9a0254..aad2683ff793 100644
---- a/sound/usb/mixer_quirks.c
-+++ b/sound/usb/mixer_quirks.c
-@@ -2185,6 +2185,421 @@ static int snd_rme_controls_create(struct usb_mixer_interface *mixer)
- return 0;
- }
-
-+/*
-+ * RME Babyface Pro (FS)
-+ *
-+ * These devices exposes a couple of DSP functions via request to EP0.
-+ * Switches are available via control registers, while routing is controlled
-+ * by controlling the volume on each possible crossing point.
-+ * Volume control is linear, from -inf (dec. 0) to +6dB (dec. 65536) with
-+ * 0dB being at dec. 32768.
-+ */
-+enum {
-+ SND_BBFPRO_CTL_REG1 = 0,
-+ SND_BBFPRO_CTL_REG2
-+};
-+
-+#define SND_BBFPRO_CTL_REG_MASK 1
-+#define SND_BBFPRO_CTL_IDX_MASK 0xff
-+#define SND_BBFPRO_CTL_IDX_SHIFT 1
-+#define SND_BBFPRO_CTL_VAL_MASK 1
-+#define SND_BBFPRO_CTL_VAL_SHIFT 9
-+#define SND_BBFPRO_CTL_REG1_CLK_MASTER 0
-+#define SND_BBFPRO_CTL_REG1_CLK_OPTICAL 1
-+#define SND_BBFPRO_CTL_REG1_SPDIF_PRO 7
-+#define SND_BBFPRO_CTL_REG1_SPDIF_EMPH 8
-+#define SND_BBFPRO_CTL_REG1_SPDIF_OPTICAL 10
-+#define SND_BBFPRO_CTL_REG2_48V_AN1 0
-+#define SND_BBFPRO_CTL_REG2_48V_AN2 1
-+#define SND_BBFPRO_CTL_REG2_SENS_IN3 2
-+#define SND_BBFPRO_CTL_REG2_SENS_IN4 3
-+#define SND_BBFPRO_CTL_REG2_PAD_AN1 4
-+#define SND_BBFPRO_CTL_REG2_PAD_AN2 5
-+
-+#define SND_BBFPRO_MIXER_IDX_MASK 0x1ff
-+#define SND_BBFPRO_MIXER_VAL_MASK 0x3ffff
-+#define SND_BBFPRO_MIXER_VAL_SHIFT 9
-+#define SND_BBFPRO_MIXER_VAL_MIN 0 // -inf
-+#define SND_BBFPRO_MIXER_VAL_MAX 65536 // +6dB
-+
-+#define SND_BBFPRO_USBREQ_CTL_REG1 0x10
-+#define SND_BBFPRO_USBREQ_CTL_REG2 0x17
-+#define SND_BBFPRO_USBREQ_MIXER 0x12
-+
-+static int snd_bbfpro_ctl_update(struct usb_mixer_interface *mixer, u8 reg,
-+ u8 index, u8 value)
-+{
-+ int err;
-+ u16 usb_req, usb_idx, usb_val;
-+ struct snd_usb_audio *chip = mixer->chip;
-+
-+ err = snd_usb_lock_shutdown(chip);
-+ if (err < 0)
-+ return err;
-+
-+ if (reg == SND_BBFPRO_CTL_REG1) {
-+ usb_req = SND_BBFPRO_USBREQ_CTL_REG1;
-+ if (index == SND_BBFPRO_CTL_REG1_CLK_OPTICAL) {
-+ usb_idx = 3;
-+ usb_val = value ? 3 : 0;
-+ } else {
-+ usb_idx = 1 << index;
-+ usb_val = value ? usb_idx : 0;
-+ }
-+ } else {
-+ usb_req = SND_BBFPRO_USBREQ_CTL_REG2;
-+ usb_idx = 1 << index;
-+ usb_val = value ? usb_idx : 0;
-+ }
-+
-+ err = snd_usb_ctl_msg(chip->dev,
-+ usb_sndctrlpipe(chip->dev, 0), usb_req,
-+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-+ usb_val, usb_idx, 0, 0);
-+
-+ snd_usb_unlock_shutdown(chip);
-+ return err;
-+}
-+
-+static int snd_bbfpro_ctl_get(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ u8 reg, idx, val;
-+ int pv;
-+
-+ pv = kcontrol->private_value;
-+ reg = pv & SND_BBFPRO_CTL_REG_MASK;
-+ idx = (pv >> SND_BBFPRO_CTL_IDX_SHIFT) & SND_BBFPRO_CTL_IDX_MASK;
-+ val = kcontrol->private_value >> SND_BBFPRO_CTL_VAL_SHIFT;
-+
-+ if ((reg == SND_BBFPRO_CTL_REG1 &&
-+ idx == SND_BBFPRO_CTL_REG1_CLK_OPTICAL) ||
-+ (reg == SND_BBFPRO_CTL_REG2 &&
-+ (idx == SND_BBFPRO_CTL_REG2_SENS_IN3 ||
-+ idx == SND_BBFPRO_CTL_REG2_SENS_IN4))) {
-+ ucontrol->value.enumerated.item[0] = val;
-+ } else {
-+ ucontrol->value.integer.value[0] = val;
-+ }
-+ return 0;
-+}
-+
-+static int snd_bbfpro_ctl_info(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_info *uinfo)
-+{
-+ u8 reg, idx;
-+ int pv;
-+
-+ pv = kcontrol->private_value;
-+ reg = pv & SND_BBFPRO_CTL_REG_MASK;
-+ idx = (pv >> SND_BBFPRO_CTL_IDX_SHIFT) & SND_BBFPRO_CTL_IDX_MASK;
-+
-+ if (reg == SND_BBFPRO_CTL_REG1 &&
-+ idx == SND_BBFPRO_CTL_REG1_CLK_OPTICAL) {
-+ static const char * const texts[2] = {
-+ "AutoSync",
-+ "Internal"
-+ };
-+ return snd_ctl_enum_info(uinfo, 1, 2, texts);
-+ } else if (reg == SND_BBFPRO_CTL_REG2 &&
-+ (idx == SND_BBFPRO_CTL_REG2_SENS_IN3 ||
-+ idx == SND_BBFPRO_CTL_REG2_SENS_IN4)) {
-+ static const char * const texts[2] = {
-+ "-10dBV",
-+ "+4dBu"
-+ };
-+ return snd_ctl_enum_info(uinfo, 1, 2, texts);
-+ }
-+
-+ uinfo->count = 1;
-+ uinfo->value.integer.min = 0;
-+ uinfo->value.integer.max = 1;
-+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-+ return 0;
-+}
-+
-+static int snd_bbfpro_ctl_put(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ int err;
-+ u8 reg, idx;
-+ int old_value, pv, val;
-+
-+ struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
-+ struct usb_mixer_interface *mixer = list->mixer;
-+
-+ pv = kcontrol->private_value;
-+ reg = pv & SND_BBFPRO_CTL_REG_MASK;
-+ idx = (pv >> SND_BBFPRO_CTL_IDX_SHIFT) & SND_BBFPRO_CTL_IDX_MASK;
-+ old_value = (pv >> SND_BBFPRO_CTL_VAL_SHIFT) & SND_BBFPRO_CTL_VAL_MASK;
-+
-+ if ((reg == SND_BBFPRO_CTL_REG1 &&
-+ idx == SND_BBFPRO_CTL_REG1_CLK_OPTICAL) ||
-+ (reg == SND_BBFPRO_CTL_REG2 &&
-+ (idx == SND_BBFPRO_CTL_REG2_SENS_IN3 ||
-+ idx == SND_BBFPRO_CTL_REG2_SENS_IN4))) {
-+ val = ucontrol->value.enumerated.item[0];
-+ } else {
-+ val = ucontrol->value.integer.value[0];
-+ }
-+
-+ if (val > 1)
-+ return -EINVAL;
-+
-+ if (val == old_value)
-+ return 0;
-+
-+ kcontrol->private_value = reg
-+ | ((idx & SND_BBFPRO_CTL_IDX_MASK) << SND_BBFPRO_CTL_IDX_SHIFT)
-+ | ((val & SND_BBFPRO_CTL_VAL_MASK) << SND_BBFPRO_CTL_VAL_SHIFT);
-+
-+ err = snd_bbfpro_ctl_update(mixer, reg, idx, val);
-+ return err < 0 ? err : 1;
-+}
-+
-+static int snd_bbfpro_ctl_resume(struct usb_mixer_elem_list *list)
-+{
-+ u8 reg, idx;
-+ int value, pv;
-+
-+ pv = list->kctl->private_value;
-+ reg = pv & SND_BBFPRO_CTL_REG_MASK;
-+ idx = (pv >> SND_BBFPRO_CTL_IDX_SHIFT) & SND_BBFPRO_CTL_IDX_MASK;
-+ value = (pv >> SND_BBFPRO_CTL_VAL_SHIFT) & SND_BBFPRO_CTL_VAL_MASK;
-+
-+ return snd_bbfpro_ctl_update(list->mixer, reg, idx, value);
-+}
-+
-+static int snd_bbfpro_vol_update(struct usb_mixer_interface *mixer, u16 index,
-+ u32 value)
-+{
-+ struct snd_usb_audio *chip = mixer->chip;
-+ int err;
-+ u16 idx;
-+ u16 usb_idx, usb_val;
-+ u32 v;
-+
-+ err = snd_usb_lock_shutdown(chip);
-+ if (err < 0)
-+ return err;
-+
-+ idx = index & SND_BBFPRO_MIXER_IDX_MASK;
-+ // 18 bit linear volume, split so 2 bits end up in index.
-+ v = value & SND_BBFPRO_MIXER_VAL_MASK;
-+ usb_idx = idx | (v & 0x3) << 14;
-+ usb_val = (v >> 2) & 0xffff;
-+
-+ err = snd_usb_ctl_msg(chip->dev,
-+ usb_sndctrlpipe(chip->dev, 0),
-+ SND_BBFPRO_USBREQ_MIXER,
-+ USB_DIR_OUT | USB_TYPE_VENDOR |
-+ USB_RECIP_DEVICE,
-+ usb_val, usb_idx, 0, 0);
-+
-+ snd_usb_unlock_shutdown(chip);
-+ return err;
-+}
-+
-+static int snd_bbfpro_vol_get(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ ucontrol->value.integer.value[0] =
-+ kcontrol->private_value >> SND_BBFPRO_MIXER_VAL_SHIFT;
-+ return 0;
-+}
-+
-+static int snd_bbfpro_vol_info(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_info *uinfo)
-+{
-+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-+ uinfo->count = 1;
-+ uinfo->value.integer.min = SND_BBFPRO_MIXER_VAL_MIN;
-+ uinfo->value.integer.max = SND_BBFPRO_MIXER_VAL_MAX;
-+ return 0;
-+}
-+
-+static int snd_bbfpro_vol_put(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ int err;
-+ u16 idx;
-+ u32 new_val, old_value, uvalue;
-+ struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
-+ struct usb_mixer_interface *mixer = list->mixer;
-+
-+ uvalue = ucontrol->value.integer.value[0];
-+ idx = kcontrol->private_value & SND_BBFPRO_MIXER_IDX_MASK;
-+ old_value = kcontrol->private_value >> SND_BBFPRO_MIXER_VAL_SHIFT;
-+
-+ if (uvalue > SND_BBFPRO_MIXER_VAL_MAX)
-+ return -EINVAL;
-+
-+ if (uvalue == old_value)
-+ return 0;
-+
-+ new_val = uvalue & SND_BBFPRO_MIXER_VAL_MASK;
-+
-+ kcontrol->private_value = idx
-+ | (new_val << SND_BBFPRO_MIXER_VAL_SHIFT);
-+
-+ err = snd_bbfpro_vol_update(mixer, idx, new_val);
-+ return err < 0 ? err : 1;
-+}
-+
-+static int snd_bbfpro_vol_resume(struct usb_mixer_elem_list *list)
-+{
-+ int pv = list->kctl->private_value;
-+ u16 idx = pv & SND_BBFPRO_MIXER_IDX_MASK;
-+ u32 val = (pv >> SND_BBFPRO_MIXER_VAL_SHIFT)
-+ & SND_BBFPRO_MIXER_VAL_MASK;
-+ return snd_bbfpro_vol_update(list->mixer, idx, val);
-+}
-+
-+// Predfine elements
-+static const struct snd_kcontrol_new snd_bbfpro_ctl_control = {
-+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-+ .index = 0,
-+ .info = snd_bbfpro_ctl_info,
-+ .get = snd_bbfpro_ctl_get,
-+ .put = snd_bbfpro_ctl_put
-+};
-+
-+static const struct snd_kcontrol_new snd_bbfpro_vol_control = {
-+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
-+ .index = 0,
-+ .info = snd_bbfpro_vol_info,
-+ .get = snd_bbfpro_vol_get,
-+ .put = snd_bbfpro_vol_put
-+};
-+
-+static int snd_bbfpro_ctl_add(struct usb_mixer_interface *mixer, u8 reg,
-+ u8 index, char *name)
-+{
-+ struct snd_kcontrol_new knew = snd_bbfpro_ctl_control;
-+
-+ knew.name = name;
-+ knew.private_value = (reg & SND_BBFPRO_CTL_REG_MASK)
-+ | ((index & SND_BBFPRO_CTL_IDX_MASK)
-+ << SND_BBFPRO_CTL_IDX_SHIFT);
-+
-+ return add_single_ctl_with_resume(mixer, 0, snd_bbfpro_ctl_resume,
-+ &knew, NULL);
-+}
-+
-+static int snd_bbfpro_vol_add(struct usb_mixer_interface *mixer, u16 index,
-+ char *name)
-+{
-+ struct snd_kcontrol_new knew = snd_bbfpro_vol_control;
-+
-+ knew.name = name;
-+ knew.private_value = index & SND_BBFPRO_MIXER_IDX_MASK;
-+
-+ return add_single_ctl_with_resume(mixer, 0, snd_bbfpro_vol_resume,
-+ &knew, NULL);
-+}
-+
-+static int snd_bbfpro_controls_create(struct usb_mixer_interface *mixer)
-+{
-+ int err, i, o;
-+ char name[48];
-+
-+ static const char * const input[] = {
-+ "AN1", "AN2", "IN3", "IN4", "AS1", "AS2", "ADAT3",
-+ "ADAT4", "ADAT5", "ADAT6", "ADAT7", "ADAT8"};
-+
-+ static const char * const output[] = {
-+ "AN1", "AN2", "PH3", "PH4", "AS1", "AS2", "ADAT3", "ADAT4",
-+ "ADAT5", "ADAT6", "ADAT7", "ADAT8"};
-+
-+ for (o = 0 ; o < 12 ; ++o) {
-+ for (i = 0 ; i < 12 ; ++i) {
-+ // Line routing
-+ snprintf(name, sizeof(name),
-+ "%s-%s-%s Playback Volume",
-+ (i < 2 ? "Mic" : "Line"),
-+ input[i], output[o]);
-+ err = snd_bbfpro_vol_add(mixer, (26 * o + i), name);
-+ if (err < 0)
-+ return err;
-+
-+ // PCM routing... yes, it is output remapping
-+ snprintf(name, sizeof(name),
-+ "PCM-%s-%s Playback Volume",
-+ output[i], output[o]);
-+ err = snd_bbfpro_vol_add(mixer, (26 * o + 12 + i),
-+ name);
-+ if (err < 0)
-+ return err;
-+ }
-+ }
-+
-+ // Control Reg 1
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG1,
-+ SND_BBFPRO_CTL_REG1_CLK_OPTICAL,
-+ "Sample Clock Source");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG1,
-+ SND_BBFPRO_CTL_REG1_SPDIF_PRO,
-+ "IEC958 Pro Mask");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG1,
-+ SND_BBFPRO_CTL_REG1_SPDIF_EMPH,
-+ "IEC958 Emphasis");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG1,
-+ SND_BBFPRO_CTL_REG1_SPDIF_OPTICAL,
-+ "IEC958 Switch");
-+ if (err < 0)
-+ return err;
-+
-+ // Control Reg 2
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG2,
-+ SND_BBFPRO_CTL_REG2_48V_AN1,
-+ "Mic-AN1 48V");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG2,
-+ SND_BBFPRO_CTL_REG2_48V_AN2,
-+ "Mic-AN2 48V");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG2,
-+ SND_BBFPRO_CTL_REG2_SENS_IN3,
-+ "Line-IN3 Sens.");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG2,
-+ SND_BBFPRO_CTL_REG2_SENS_IN4,
-+ "Line-IN4 Sens.");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG2,
-+ SND_BBFPRO_CTL_REG2_PAD_AN1,
-+ "Mic-AN1 PAD");
-+ if (err < 0)
-+ return err;
-+
-+ err = snd_bbfpro_ctl_add(mixer, SND_BBFPRO_CTL_REG2,
-+ SND_BBFPRO_CTL_REG2_PAD_AN2,
-+ "Mic-AN2 PAD");
-+ if (err < 0)
-+ return err;
-+
-+ return 0;
-+}
-+
- int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
- {
- int err = 0;
-@@ -2286,6 +2701,9 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
- case USB_ID(0x0194f, 0x010c): /* Presonus Studio 1810c */
- err = snd_sc1810_init_mixer(mixer);
- break;
-+ case USB_ID(0x2a39, 0x3fb0): /* RME Babyface Pro FS */
-+ err = snd_bbfpro_controls_create(mixer);
-+ break;
- }
-
- return err;
-diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
-index a4e4064f9aee..d61c2f1095b5 100644
---- a/sound/usb/pcm.c
-+++ b/sound/usb/pcm.c
-@@ -404,6 +404,8 @@ add_sync_ep:
- if (!subs->sync_endpoint)
- return -EINVAL;
-
-+ subs->sync_endpoint->is_implicit_feedback = 1;
-+
- subs->data_endpoint->sync_master = subs->sync_endpoint;
-
- return 1;
-@@ -502,12 +504,15 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
- implicit_fb ?
- SND_USB_ENDPOINT_TYPE_DATA :
- SND_USB_ENDPOINT_TYPE_SYNC);
-+
- if (!subs->sync_endpoint) {
- if (is_playback && attr == USB_ENDPOINT_SYNC_NONE)
- return 0;
- return -EINVAL;
- }
-
-+ subs->sync_endpoint->is_implicit_feedback = implicit_fb;
-+
- subs->data_endpoint->sync_master = subs->sync_endpoint;
-
- return 0;
-@@ -1579,6 +1584,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/tools/bootconfig/main.c b/tools/bootconfig/main.c
-index 0efaf45f7367..e0878f5f74b1 100644
---- a/tools/bootconfig/main.c
-+++ b/tools/bootconfig/main.c
-@@ -14,13 +14,18 @@
- #include <linux/kernel.h>
- #include <linux/bootconfig.h>
-
--static int xbc_show_array(struct xbc_node *node)
-+static int xbc_show_value(struct xbc_node *node)
- {
- const char *val;
-+ char q;
- int i = 0;
-
- xbc_array_for_each_value(node, val) {
-- printf("\"%s\"%s", val, node->next ? ", " : ";\n");
-+ if (strchr(val, '"'))
-+ q = '\'';
-+ else
-+ q = '"';
-+ printf("%c%s%c%s", q, val, q, node->next ? ", " : ";\n");
- i++;
- }
- return i;
-@@ -48,10 +53,7 @@ static void xbc_show_compact_tree(void)
- continue;
- } else if (cnode && xbc_node_is_value(cnode)) {
- printf("%s = ", xbc_node_get_data(node));
-- if (cnode->next)
-- xbc_show_array(cnode);
-- else
-- printf("\"%s\";\n", xbc_node_get_data(cnode));
-+ xbc_show_value(cnode);
- } else {
- printf("%s;\n", xbc_node_get_data(node));
- }
-@@ -205,11 +207,13 @@ int show_xbc(const char *path)
- }
-
- ret = load_xbc_from_initrd(fd, &buf);
-- if (ret < 0)
-+ if (ret < 0) {
- pr_err("Failed to load a boot config from initrd: %d\n", ret);
-- else
-- xbc_show_compact_tree();
--
-+ goto out;
-+ }
-+ xbc_show_compact_tree();
-+ ret = 0;
-+out:
- close(fd);
- free(buf);
-
-diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
-index f8113b3646f5..f5960b48c861 100644
---- a/tools/bpf/bpftool/gen.c
-+++ b/tools/bpf/bpftool/gen.c
-@@ -225,6 +225,7 @@ static int codegen(const char *template, ...)
- } else {
- p_err("unrecognized character at pos %td in template '%s'",
- src - template - 1, template);
-+ free(s);
- return -EINVAL;
- }
- }
-@@ -235,6 +236,7 @@ static int codegen(const char *template, ...)
- if (*src != '\t') {
- p_err("not enough tabs at pos %td in template '%s'",
- src - template - 1, template);
-+ free(s);
- return -EINVAL;
- }
- }
-diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
-index 0c28ee82834b..653dbbe2e366 100644
---- a/tools/lib/bpf/btf_dump.c
-+++ b/tools/lib/bpf/btf_dump.c
-@@ -1137,6 +1137,20 @@ static void btf_dump_emit_mods(struct btf_dump *d, struct id_stack *decl_stack)
- }
- }
-
-+static void btf_dump_drop_mods(struct btf_dump *d, struct id_stack *decl_stack)
-+{
-+ const struct btf_type *t;
-+ __u32 id;
-+
-+ while (decl_stack->cnt) {
-+ id = decl_stack->ids[decl_stack->cnt - 1];
-+ t = btf__type_by_id(d->btf, id);
-+ if (!btf_is_mod(t))
-+ return;
-+ decl_stack->cnt--;
-+ }
-+}
-+
- static void btf_dump_emit_name(const struct btf_dump *d,
- const char *name, bool last_was_ptr)
- {
-@@ -1235,14 +1249,7 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
- * a const/volatile modifier for array, so we are
- * going to silently skip them here.
- */
-- while (decls->cnt) {
-- next_id = decls->ids[decls->cnt - 1];
-- next_t = btf__type_by_id(d->btf, next_id);
-- if (btf_is_mod(next_t))
-- decls->cnt--;
-- else
-- break;
-- }
-+ btf_dump_drop_mods(d, decls);
-
- if (decls->cnt == 0) {
- btf_dump_emit_name(d, fname, last_was_ptr);
-@@ -1270,7 +1277,15 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
- __u16 vlen = btf_vlen(t);
- int i;
-
-- btf_dump_emit_mods(d, decls);
-+ /*
-+ * GCC emits extra volatile qualifier for
-+ * __attribute__((noreturn)) function pointers. Clang
-+ * doesn't do it. It's a GCC quirk for backwards
-+ * compatibility with code written for GCC <2.5. So,
-+ * similarly to extra qualifiers for array, just drop
-+ * them, instead of handling them.
-+ */
-+ btf_dump_drop_mods(d, decls);
- if (decls->cnt) {
- btf_dump_printf(d, " (");
- btf_dump_emit_type_chain(d, decls, fname, lvl);
-diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
-index 0c5b4fb553fb..c417cff2cdaf 100644
---- a/tools/lib/bpf/libbpf.c
-+++ b/tools/lib/bpf/libbpf.c
-@@ -3455,10 +3455,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map)
- char *cp, errmsg[STRERR_BUFSIZE];
- int err, zero = 0;
-
-- /* kernel already zero-initializes .bss map. */
-- if (map_type == LIBBPF_MAP_BSS)
-- return 0;
--
- err = bpf_map_update_elem(map->fd, &zero, map->mmaped, 0);
- if (err) {
- err = -errno;
-diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
-index 26d8fc27e427..fc7855262162 100644
---- a/tools/perf/builtin-report.c
-+++ b/tools/perf/builtin-report.c
-@@ -476,8 +476,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
- if (rep->time_str)
- ret += fprintf(fp, " (time slices: %s)", rep->time_str);
-
-- 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/perf/util/parse-events.y b/tools/perf/util/parse-events.y
-index 94f8bcd83582..9a41247c602b 100644
---- a/tools/perf/util/parse-events.y
-+++ b/tools/perf/util/parse-events.y
-@@ -348,7 +348,7 @@ PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
- struct list_head *list;
- char pmu_name[128];
-
-- snprintf(&pmu_name, 128, "%s-%s", $1, $3);
-+ snprintf(pmu_name, sizeof(pmu_name), "%s-%s", $1, $3);
- free($1);
- free($3);
- if (parse_events_multi_pmu_add(_parse_state, pmu_name, &list) < 0)
-diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
-index a08f373d3305..df713a5d1e26 100644
---- a/tools/perf/util/probe-event.c
-+++ b/tools/perf/util/probe-event.c
-@@ -1575,7 +1575,7 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg)
- }
-
- tmp = strchr(str, '@');
-- if (tmp && tmp != str && strcmp(tmp + 1, "user")) { /* user attr */
-+ if (tmp && tmp != str && !strcmp(tmp + 1, "user")) { /* user attr */
- if (!user_access_is_supported()) {
- semantic_error("ftrace does not support user access\n");
- return -EINVAL;
-@@ -1995,7 +1995,10 @@ static int __synthesize_probe_trace_arg_ref(struct probe_trace_arg_ref *ref,
- if (depth < 0)
- return depth;
- }
-- err = strbuf_addf(buf, "%+ld(", ref->offset);
-+ if (ref->user_access)
-+ err = strbuf_addf(buf, "%s%ld(", "+u", ref->offset);
-+ else
-+ err = strbuf_addf(buf, "%+ld(", ref->offset);
- return (err < 0) ? err : depth;
- }
-
-diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
-index 8c852948513e..064b63a6a3f3 100644
---- a/tools/perf/util/probe-file.c
-+++ b/tools/perf/util/probe-file.c
-@@ -1044,7 +1044,7 @@ static struct {
- DEFINE_TYPE(FTRACE_README_PROBE_TYPE_X, "*type: * x8/16/32/64,*"),
- DEFINE_TYPE(FTRACE_README_KRETPROBE_OFFSET, "*place (kretprobe): *"),
- DEFINE_TYPE(FTRACE_README_UPROBE_REF_CTR, "*ref_ctr_offset*"),
-- DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*[u]<offset>*"),
-+ DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*u]<offset>*"),
- DEFINE_TYPE(FTRACE_README_MULTIPROBE_EVENT, "*Create/append/*"),
- DEFINE_TYPE(FTRACE_README_IMMEDIATE_VALUE, "*\\imm-value,*"),
- };
-diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
-index 9e757d18d713..cf393c3eea23 100644
---- a/tools/perf/util/stat-display.c
-+++ b/tools/perf/util/stat-display.c
-@@ -671,7 +671,7 @@ static void print_aggr(struct perf_stat_config *config,
- int s;
- bool first;
-
-- if (!(config->aggr_map || config->aggr_get_id))
-+ if (!config->aggr_map || !config->aggr_get_id)
- return;
-
- aggr_update_shadow(config, evlist);
-@@ -1172,7 +1172,7 @@ static void print_percore(struct perf_stat_config *config,
- int s;
- bool first = true;
-
-- if (!(config->aggr_map || config->aggr_get_id))
-+ if (!config->aggr_map || !config->aggr_get_id)
- return;
-
- if (config->percore_show_thread)
-diff --git a/tools/testing/selftests/bpf/prog_tests/skeleton.c b/tools/testing/selftests/bpf/prog_tests/skeleton.c
-index 9264a2736018..fa153cf67b1b 100644
---- a/tools/testing/selftests/bpf/prog_tests/skeleton.c
-+++ b/tools/testing/selftests/bpf/prog_tests/skeleton.c
-@@ -15,6 +15,8 @@ void test_skeleton(void)
- int duration = 0, err;
- struct test_skeleton* skel;
- struct test_skeleton__bss *bss;
-+ struct test_skeleton__data *data;
-+ struct test_skeleton__rodata *rodata;
- struct test_skeleton__kconfig *kcfg;
-
- skel = test_skeleton__open();
-@@ -24,13 +26,45 @@ void test_skeleton(void)
- if (CHECK(skel->kconfig, "skel_kconfig", "kconfig is mmaped()!\n"))
- goto cleanup;
-
-+ bss = skel->bss;
-+ data = skel->data;
-+ rodata = skel->rodata;
-+
-+ /* validate values are pre-initialized correctly */
-+ CHECK(data->in1 != -1, "in1", "got %d != exp %d\n", data->in1, -1);
-+ CHECK(data->out1 != -1, "out1", "got %d != exp %d\n", data->out1, -1);
-+ CHECK(data->in2 != -1, "in2", "got %lld != exp %lld\n", data->in2, -1LL);
-+ CHECK(data->out2 != -1, "out2", "got %lld != exp %lld\n", data->out2, -1LL);
-+
-+ CHECK(bss->in3 != 0, "in3", "got %d != exp %d\n", bss->in3, 0);
-+ CHECK(bss->out3 != 0, "out3", "got %d != exp %d\n", bss->out3, 0);
-+ CHECK(bss->in4 != 0, "in4", "got %lld != exp %lld\n", bss->in4, 0LL);
-+ CHECK(bss->out4 != 0, "out4", "got %lld != exp %lld\n", bss->out4, 0LL);
-+
-+ CHECK(rodata->in6 != 0, "in6", "got %d != exp %d\n", rodata->in6, 0);
-+ CHECK(bss->out6 != 0, "out6", "got %d != exp %d\n", bss->out6, 0);
-+
-+ /* validate we can pre-setup global variables, even in .bss */
-+ data->in1 = 10;
-+ data->in2 = 11;
-+ bss->in3 = 12;
-+ bss->in4 = 13;
-+ rodata->in6 = 14;
-+
- err = test_skeleton__load(skel);
- if (CHECK(err, "skel_load", "failed to load skeleton: %d\n", err))
- goto cleanup;
-
-- bss = skel->bss;
-- bss->in1 = 1;
-- bss->in2 = 2;
-+ /* validate pre-setup values are still there */
-+ CHECK(data->in1 != 10, "in1", "got %d != exp %d\n", data->in1, 10);
-+ CHECK(data->in2 != 11, "in2", "got %lld != exp %lld\n", data->in2, 11LL);
-+ CHECK(bss->in3 != 12, "in3", "got %d != exp %d\n", bss->in3, 12);
-+ CHECK(bss->in4 != 13, "in4", "got %lld != exp %lld\n", bss->in4, 13LL);
-+ CHECK(rodata->in6 != 14, "in6", "got %d != exp %d\n", rodata->in6, 14);
-+
-+ /* now set new values and attach to get them into outX variables */
-+ data->in1 = 1;
-+ data->in2 = 2;
- bss->in3 = 3;
- bss->in4 = 4;
- bss->in5.a = 5;
-@@ -44,14 +78,15 @@ void test_skeleton(void)
- /* trigger tracepoint */
- usleep(1);
-
-- CHECK(bss->out1 != 1, "res1", "got %d != exp %d\n", bss->out1, 1);
-- CHECK(bss->out2 != 2, "res2", "got %lld != exp %d\n", bss->out2, 2);
-+ CHECK(data->out1 != 1, "res1", "got %d != exp %d\n", data->out1, 1);
-+ CHECK(data->out2 != 2, "res2", "got %lld != exp %d\n", data->out2, 2);
- CHECK(bss->out3 != 3, "res3", "got %d != exp %d\n", (int)bss->out3, 3);
- CHECK(bss->out4 != 4, "res4", "got %lld != exp %d\n", bss->out4, 4);
- CHECK(bss->handler_out5.a != 5, "res5", "got %d != exp %d\n",
- bss->handler_out5.a, 5);
- CHECK(bss->handler_out5.b != 6, "res6", "got %lld != exp %d\n",
- bss->handler_out5.b, 6);
-+ CHECK(bss->out6 != 14, "res7", "got %d != exp %d\n", bss->out6, 14);
-
- CHECK(bss->bpf_syscall != kcfg->CONFIG_BPF_SYSCALL, "ext1",
- "got %d != exp %d\n", bss->bpf_syscall, kcfg->CONFIG_BPF_SYSCALL);
-diff --git a/tools/testing/selftests/bpf/progs/test_skeleton.c b/tools/testing/selftests/bpf/progs/test_skeleton.c
-index de03a90f78ca..77ae86f44db5 100644
---- a/tools/testing/selftests/bpf/progs/test_skeleton.c
-+++ b/tools/testing/selftests/bpf/progs/test_skeleton.c
-@@ -10,16 +10,26 @@ struct s {
- long long b;
- } __attribute__((packed));
-
--int in1 = 0;
--long long in2 = 0;
-+/* .data section */
-+int in1 = -1;
-+long long in2 = -1;
-+
-+/* .bss section */
- char in3 = '\0';
- long long in4 __attribute__((aligned(64))) = 0;
- struct s in5 = {};
-
--long long out2 = 0;
-+/* .rodata section */
-+const volatile int in6 = 0;
-+
-+/* .data section */
-+int out1 = -1;
-+long long out2 = -1;
-+
-+/* .bss section */
- char out3 = 0;
- long long out4 = 0;
--int out1 = 0;
-+int out6 = 0;
-
- extern bool CONFIG_BPF_SYSCALL __kconfig;
- extern int LINUX_KERNEL_VERSION __kconfig;
-@@ -36,6 +46,7 @@ int handler(const void *ctx)
- out3 = in3;
- out4 = in4;
- out5 = in5;
-+ out6 = in6;
-
- bpf_syscall = CONFIG_BPF_SYSCALL;
- kern_ver = LINUX_KERNEL_VERSION;
-diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
-index 42f4f49f2a48..2c85b9dd86f5 100644
---- a/tools/testing/selftests/kvm/Makefile
-+++ b/tools/testing/selftests/kvm/Makefile
-@@ -80,7 +80,11 @@ LIBKVM += $(LIBKVM_$(UNAME_M))
- INSTALL_HDR_PATH = $(top_srcdir)/usr
- LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
- LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
-+ifeq ($(ARCH),x86_64)
-+LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
-+else
- LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
-+endif
- CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
- -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
- -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
-diff --git a/tools/testing/selftests/net/timestamping.c b/tools/testing/selftests/net/timestamping.c
-index aca3491174a1..f4bb4fef0f39 100644
---- a/tools/testing/selftests/net/timestamping.c
-+++ b/tools/testing/selftests/net/timestamping.c
-@@ -313,10 +313,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"))
-@@ -350,12 +356,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/tools/testing/selftests/ntb/ntb_test.sh b/tools/testing/selftests/ntb/ntb_test.sh
-index 9c60337317c6..020137b61407 100755
---- a/tools/testing/selftests/ntb/ntb_test.sh
-+++ b/tools/testing/selftests/ntb/ntb_test.sh
-@@ -241,7 +241,7 @@ function get_files_count()
- split_remote $LOC
-
- if [[ "$REMOTE" == "" ]]; then
-- echo $(ls -1 "$LOC"/${NAME}* 2>/dev/null | wc -l)
-+ echo $(ls -1 "$VPATH"/${NAME}* 2>/dev/null | wc -l)
- else
- echo $(ssh "$REMOTE" "ls -1 \"$VPATH\"/${NAME}* | \
- wc -l" 2> /dev/null)
-diff --git a/tools/testing/selftests/timens/clock_nanosleep.c b/tools/testing/selftests/timens/clock_nanosleep.c
-index 8e7b7c72ef65..72d41b955fb2 100644
---- a/tools/testing/selftests/timens/clock_nanosleep.c
-+++ b/tools/testing/selftests/timens/clock_nanosleep.c
-@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
-
- ksft_set_plan(4);
-
-- check_config_posix_timers();
-+ check_supported_timers();
-
- if (unshare_timens())
- return 1;
-diff --git a/tools/testing/selftests/timens/timens.c b/tools/testing/selftests/timens/timens.c
-index 098be7c83be3..52b6a1185f52 100644
---- a/tools/testing/selftests/timens/timens.c
-+++ b/tools/testing/selftests/timens/timens.c
-@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
-
- nscheck();
-
-- check_config_posix_timers();
-+ check_supported_timers();
-
- ksft_set_plan(ARRAY_SIZE(clocks) * 2);
-
-diff --git a/tools/testing/selftests/timens/timens.h b/tools/testing/selftests/timens/timens.h
-index e09e7e39bc52..d4fc52d47146 100644
---- a/tools/testing/selftests/timens/timens.h
-+++ b/tools/testing/selftests/timens/timens.h
-@@ -14,15 +14,26 @@
- #endif
-
- static int config_posix_timers = true;
-+static int config_alarm_timers = true;
-
--static inline void check_config_posix_timers(void)
-+static inline void check_supported_timers(void)
- {
-+ struct timespec ts;
-+
- if (timer_create(-1, 0, 0) == -1 && errno == ENOSYS)
- config_posix_timers = false;
-+
-+ if (clock_gettime(CLOCK_BOOTTIME_ALARM, &ts) == -1 && errno == EINVAL)
-+ config_alarm_timers = false;
- }
-
- static inline bool check_skip(int clockid)
- {
-+ if (!config_alarm_timers && clockid == CLOCK_BOOTTIME_ALARM) {
-+ ksft_test_result_skip("CLOCK_BOOTTIME_ALARM isn't supported\n");
-+ return true;
-+ }
-+
- if (config_posix_timers)
- return false;
-
-diff --git a/tools/testing/selftests/timens/timer.c b/tools/testing/selftests/timens/timer.c
-index 96dba11ebe44..5e7f0051bd7b 100644
---- a/tools/testing/selftests/timens/timer.c
-+++ b/tools/testing/selftests/timens/timer.c
-@@ -22,6 +22,9 @@ int run_test(int clockid, struct timespec now)
- timer_t fd;
- int i;
-
-+ if (check_skip(clockid))
-+ return 0;
-+
- for (i = 0; i < 2; i++) {
- struct sigevent sevp = {.sigev_notify = SIGEV_NONE};
- int flags = 0;
-@@ -74,6 +77,8 @@ int main(int argc, char *argv[])
-
- nscheck();
-
-+ check_supported_timers();
-+
- ksft_set_plan(3);
-
- clock_gettime(CLOCK_MONOTONIC, &mtime_now);
-diff --git a/tools/testing/selftests/timens/timerfd.c b/tools/testing/selftests/timens/timerfd.c
-index eff1ec5ff215..9edd43d6b2c1 100644
---- a/tools/testing/selftests/timens/timerfd.c
-+++ b/tools/testing/selftests/timens/timerfd.c
-@@ -28,6 +28,9 @@ int run_test(int clockid, struct timespec now)
- long long elapsed;
- int fd, i;
-
-+ if (check_skip(clockid))
-+ return 0;
-+
- if (tclock_gettime(clockid, &now))
- return pr_perror("clock_gettime(%d)", clockid);
-
-@@ -81,6 +84,8 @@ int main(int argc, char *argv[])
-
- nscheck();
-
-+ check_supported_timers();
-+
- ksft_set_plan(3);
-
- clock_gettime(CLOCK_MONOTONIC, &mtime_now);
-diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
-index 480995bceefa..47191af46617 100644
---- a/tools/testing/selftests/x86/protection_keys.c
-+++ b/tools/testing/selftests/x86/protection_keys.c
-@@ -24,6 +24,7 @@
- #define _GNU_SOURCE
- #include <errno.h>
- #include <linux/futex.h>
-+#include <time.h>
- #include <sys/time.h>
- #include <sys/syscall.h>
- #include <string.h>
-@@ -612,10 +613,10 @@ int alloc_random_pkey(void)
- int nr_alloced = 0;
- int random_index;
- memset(alloced_pkeys, 0, sizeof(alloced_pkeys));
-+ srand((unsigned int)time(NULL));
-
- /* allocate every possible key and make a note of which ones we got */
- max_nr_pkey_allocs = NR_PKEYS;
-- max_nr_pkey_allocs = 1;
- for (i = 0; i < max_nr_pkey_allocs; i++) {
- int new_pkey = alloc_pkey();
- if (new_pkey < 0)
diff --git a/1005_linux-5.8.6.patch b/1005_linux-5.8.6.patch
new file mode 100644
index 00000000..842f070e
--- /dev/null
+++ b/1005_linux-5.8.6.patch
@@ -0,0 +1,11789 @@
+diff --git a/Documentation/admin-guide/ext4.rst b/Documentation/admin-guide/ext4.rst
+index 9443fcef18760..f37d0743fd668 100644
+--- a/Documentation/admin-guide/ext4.rst
++++ b/Documentation/admin-guide/ext4.rst
+@@ -482,6 +482,9 @@ Files in /sys/fs/ext4/<devname>:
+ multiple of this tuning parameter if the stripe size is not set in the
+ ext4 superblock
+
++ mb_max_inode_prealloc
++ The maximum length of per-inode ext4_prealloc_space list.
++
+ mb_max_to_scan
+ The maximum number of extents the multiblock allocator will search to
+ find the best extent.
+diff --git a/Makefile b/Makefile
+index f47073a3b4740..5cf35650373b1 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0
+ VERSION = 5
+ PATCHLEVEL = 8
+-SUBLEVEL = 5
++SUBLEVEL = 6
+ EXTRAVERSION =
+ NAME = Kleptomaniac Octopus
+
+diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
+index 760a68c163c83..b2ff27af090ec 100644
+--- a/arch/arm/boot/dts/ls1021a.dtsi
++++ b/arch/arm/boot/dts/ls1021a.dtsi
+@@ -772,7 +772,7 @@
+ fsl,tmr-prsc = <2>;
+ fsl,tmr-add = <0xaaaaaaab>;
+ fsl,tmr-fiper1 = <999999995>;
+- fsl,tmr-fiper2 = <99990>;
++ fsl,tmr-fiper2 = <999999995>;
+ fsl,max-adj = <499999999>;
+ fsl,extts-fifo;
+ };
+diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
+index 91e377770a6b8..d5fe7c9e0be1d 100644
+--- a/arch/arm64/Makefile
++++ b/arch/arm64/Makefile
+@@ -158,7 +158,8 @@ zinstall install:
+ PHONY += vdso_install
+ vdso_install:
+ $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
+- $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@
++ $(if $(CONFIG_COMPAT_VDSO), \
++ $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@)
+
+ # We use MRPROPER_FILES and CLEAN_FILES now
+ archclean:
+diff --git a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
+index 5785bf0a807ce..591f48a575353 100644
+--- a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
++++ b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
+@@ -569,7 +569,7 @@
+ pins = "gpio63", "gpio64", "gpio65", "gpio66",
+ "gpio67", "gpio68";
+ drive-strength = <2>;
+- bias-disable;
++ bias-pull-down;
+ };
+ };
+ };
+diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
+index 51c1d99189992..1da8e3dc44555 100644
+--- a/arch/arm64/include/asm/kvm_arm.h
++++ b/arch/arm64/include/asm/kvm_arm.h
+@@ -71,11 +71,12 @@
+ * IMO: Override CPSR.I and enable signaling with VI
+ * FMO: Override CPSR.F and enable signaling with VF
+ * SWIO: Turn set/way invalidates into set/way clean+invalidate
++ * PTW: Take a stage2 fault if a stage1 walk steps in device memory
+ */
+ #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
+ HCR_BSU_IS | HCR_FB | HCR_TAC | \
+ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \
+- HCR_FMO | HCR_IMO)
++ HCR_FMO | HCR_IMO | HCR_PTW )
+ #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF)
+ #define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK)
+ #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
+diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
+index a0c8a0b652593..0eadbf933e359 100644
+--- a/arch/arm64/include/asm/smp.h
++++ b/arch/arm64/include/asm/smp.h
+@@ -46,7 +46,12 @@ DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
+ * Logical CPU mapping.
+ */
+ extern u64 __cpu_logical_map[NR_CPUS];
+-#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
++extern u64 cpu_logical_map(int cpu);
++
++static inline void set_cpu_logical_map(int cpu, u64 hwid)
++{
++ __cpu_logical_map[cpu] = hwid;
++}
+
+ struct seq_file;
+
+diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
+index 79728bfb5351f..2c0b82db825ba 100644
+--- a/arch/arm64/kernel/cpu_errata.c
++++ b/arch/arm64/kernel/cpu_errata.c
+@@ -910,6 +910,8 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
+ .desc = "ARM erratum 1418040",
+ .capability = ARM64_WORKAROUND_1418040,
+ ERRATA_MIDR_RANGE_LIST(erratum_1418040_list),
++ .type = (ARM64_CPUCAP_SCOPE_LOCAL_CPU |
++ ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU),
+ },
+ #endif
+ #ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT
+diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
+index 35de8ba60e3d5..44445d471442d 100644
+--- a/arch/arm64/kernel/entry.S
++++ b/arch/arm64/kernel/entry.S
+@@ -169,19 +169,6 @@ alternative_cb_end
+ stp x28, x29, [sp, #16 * 14]
+
+ .if \el == 0
+- .if \regsize == 32
+- /*
+- * If we're returning from a 32-bit task on a system affected by
+- * 1418040 then re-enable userspace access to the virtual counter.
+- */
+-#ifdef CONFIG_ARM64_ERRATUM_1418040
+-alternative_if ARM64_WORKAROUND_1418040
+- mrs x0, cntkctl_el1
+- orr x0, x0, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
+- msr cntkctl_el1, x0
+-alternative_else_nop_endif
+-#endif
+- .endif
+ clear_gp_regs
+ mrs x21, sp_el0
+ ldr_this_cpu tsk, __entry_task, x20
+@@ -337,14 +324,6 @@ alternative_else_nop_endif
+ tst x22, #PSR_MODE32_BIT // native task?
+ b.eq 3f
+
+-#ifdef CONFIG_ARM64_ERRATUM_1418040
+-alternative_if ARM64_WORKAROUND_1418040
+- mrs x0, cntkctl_el1
+- bic x0, x0, #2 // ARCH_TIMER_USR_VCT_ACCESS_EN
+- msr cntkctl_el1, x0
+-alternative_else_nop_endif
+-#endif
+-
+ #ifdef CONFIG_ARM64_ERRATUM_845719
+ alternative_if ARM64_WORKAROUND_845719
+ #ifdef CONFIG_PID_IN_CONTEXTIDR
+diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
+index 6089638c7d43f..d8a10cf28f827 100644
+--- a/arch/arm64/kernel/process.c
++++ b/arch/arm64/kernel/process.c
+@@ -515,6 +515,39 @@ static void entry_task_switch(struct task_struct *next)
+ __this_cpu_write(__entry_task, next);
+ }
+
++/*
++ * ARM erratum 1418040 handling, affecting the 32bit view of CNTVCT.
++ * Assuming the virtual counter is enabled at the beginning of times:
++ *
++ * - disable access when switching from a 64bit task to a 32bit task
++ * - enable access when switching from a 32bit task to a 64bit task
++ */
++static void erratum_1418040_thread_switch(struct task_struct *prev,
++ struct task_struct *next)
++{
++ bool prev32, next32;
++ u64 val;
++
++ if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
++ cpus_have_const_cap(ARM64_WORKAROUND_1418040)))
++ return;
++
++ prev32 = is_compat_thread(task_thread_info(prev));
++ next32 = is_compat_thread(task_thread_info(next));
++
++ if (prev32 == next32)
++ return;
++
++ val = read_sysreg(cntkctl_el1);
++
++ if (!next32)
++ val |= ARCH_TIMER_USR_VCT_ACCESS_EN;
++ else
++ val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN;
++
++ write_sysreg(val, cntkctl_el1);
++}
++
+ /*
+ * Thread switching.
+ */
+@@ -530,6 +563,7 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
+ entry_task_switch(next);
+ uao_thread_switch(next);
+ ssbs_thread_switch(next);
++ erratum_1418040_thread_switch(prev, next);
+
+ /*
+ * Complete any pending TLB or cache maintenance on this CPU in case
+diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
+index 93b3844cf4421..07b7940951e28 100644
+--- a/arch/arm64/kernel/setup.c
++++ b/arch/arm64/kernel/setup.c
+@@ -85,7 +85,7 @@ u64 __cacheline_aligned boot_args[4];
+ void __init smp_setup_processor_id(void)
+ {
+ u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
+- cpu_logical_map(0) = mpidr;
++ set_cpu_logical_map(0, mpidr);
+
+ /*
+ * clear __my_cpu_offset on boot CPU to avoid hang caused by
+@@ -276,6 +276,12 @@ arch_initcall(reserve_memblock_reserved_regions);
+
+ u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
+
++u64 cpu_logical_map(int cpu)
++{
++ return __cpu_logical_map[cpu];
++}
++EXPORT_SYMBOL_GPL(cpu_logical_map);
++
+ void __init setup_arch(char **cmdline_p)
+ {
+ init_mm.start_code = (unsigned long) _text;
+diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
+index e43a8ff19f0f6..8cd6316a0d833 100644
+--- a/arch/arm64/kernel/smp.c
++++ b/arch/arm64/kernel/smp.c
+@@ -567,7 +567,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
+ return;
+
+ /* map the logical cpu id to cpu MPIDR */
+- cpu_logical_map(cpu_count) = hwid;
++ set_cpu_logical_map(cpu_count, hwid);
+
+ cpu_madt_gicc[cpu_count] = *processor;
+
+@@ -681,7 +681,7 @@ static void __init of_parse_and_init_cpus(void)
+ goto next;
+
+ pr_debug("cpu logical map 0x%llx\n", hwid);
+- cpu_logical_map(cpu_count) = hwid;
++ set_cpu_logical_map(cpu_count, hwid);
+
+ early_map_cpu_to_node(cpu_count, of_node_to_nid(dn));
+ next:
+@@ -722,7 +722,7 @@ void __init smp_init_cpus(void)
+ for (i = 1; i < nr_cpu_ids; i++) {
+ if (cpu_logical_map(i) != INVALID_HWID) {
+ if (smp_cpu_setup(i))
+- cpu_logical_map(i) = INVALID_HWID;
++ set_cpu_logical_map(i, INVALID_HWID);
+ }
+ }
+ }
+diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
+index db1c4487d95d1..9270b14157b55 100644
+--- a/arch/arm64/kvm/hyp/switch.c
++++ b/arch/arm64/kvm/hyp/switch.c
+@@ -897,7 +897,7 @@ static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par,
+ * making sure it is a kernel address and not a PC-relative
+ * reference.
+ */
+- asm volatile("ldr %0, =__hyp_panic_string" : "=r" (str_va));
++ asm volatile("ldr %0, =%1" : "=r" (str_va) : "S" (__hyp_panic_string));
+
+ __hyp_do_panic(str_va,
+ spsr, elr,
+diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
+index a7e40bb1e5bc6..c43ad3b3cea4b 100644
+--- a/arch/mips/Kconfig
++++ b/arch/mips/Kconfig
+@@ -2203,6 +2203,7 @@ endchoice
+
+ config KVM_GUEST
+ bool "KVM Guest Kernel"
++ depends on CPU_MIPS32_R2
+ depends on BROKEN_ON_SMP
+ help
+ Select this option if building a guest kernel for KVM (Trap & Emulate)
+diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig
+index 2bf02d849a3a8..032b3fca6cbba 100644
+--- a/arch/mips/kvm/Kconfig
++++ b/arch/mips/kvm/Kconfig
+@@ -37,10 +37,11 @@ choice
+
+ config KVM_MIPS_TE
+ bool "Trap & Emulate"
++ depends on CPU_MIPS32_R2
+ help
+ Use trap and emulate to virtualize 32-bit guests in user mode. This
+ does not require any special hardware Virtualization support beyond
+- standard MIPS32/64 r2 or later, but it does require the guest kernel
++ standard MIPS32 r2 or later, but it does require the guest kernel
+ to be configured with CONFIG_KVM_GUEST=y so that it resides in the
+ user address segment.
+
+diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
+index be57b832bbe0a..ccba50ec8a40e 100644
+--- a/arch/mips/vdso/genvdso.c
++++ b/arch/mips/vdso/genvdso.c
+@@ -122,6 +122,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;
+ }
+
+@@ -130,6 +131,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;
+ }
+
+@@ -139,6 +141,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;
+ }
+
+@@ -150,6 +153,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;
+ }
+
+@@ -161,6 +165,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;
+ }
+
+@@ -168,15 +173,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;
+ }
+
+@@ -293,10 +301,12 @@ int main(int argc, char **argv)
+ /* Calculate and write symbol offsets to <output file> */
+ 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/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
+index 01d70280d2872..c6f9d75283813 100644
+--- a/arch/powerpc/perf/core-book3s.c
++++ b/arch/powerpc/perf/core-book3s.c
+@@ -1517,9 +1517,16 @@ nocheck:
+ ret = 0;
+ out:
+ if (has_branch_stack(event)) {
+- power_pmu_bhrb_enable(event);
+- cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
+- event->attr.branch_sample_type);
++ u64 bhrb_filter = -1;
++
++ if (ppmu->bhrb_filter_map)
++ bhrb_filter = ppmu->bhrb_filter_map(
++ event->attr.branch_sample_type);
++
++ if (bhrb_filter != -1) {
++ cpuhw->bhrb_filter = bhrb_filter;
++ power_pmu_bhrb_enable(event);
++ }
+ }
+
+ perf_pmu_enable(event->pmu);
+@@ -1841,7 +1848,6 @@ static int power_pmu_event_init(struct perf_event *event)
+ int n;
+ int err;
+ struct cpu_hw_events *cpuhw;
+- u64 bhrb_filter;
+
+ if (!ppmu)
+ return -ENOENT;
+@@ -1947,7 +1953,10 @@ static int power_pmu_event_init(struct perf_event *event)
+ err = power_check_constraints(cpuhw, events, cflags, n + 1);
+
+ if (has_branch_stack(event)) {
+- bhrb_filter = ppmu->bhrb_filter_map(
++ u64 bhrb_filter = -1;
++
++ if (ppmu->bhrb_filter_map)
++ bhrb_filter = ppmu->bhrb_filter_map(
+ event->attr.branch_sample_type);
+
+ if (bhrb_filter == -1) {
+@@ -2101,6 +2110,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
+
+ if (perf_event_overflow(event, &data, regs))
+ power_pmu_stop(event, 0);
++ } else if (period) {
++ /* Account for interrupt in case of invalid SIAR */
++ if (perf_event_account_interrupt(event))
++ power_pmu_stop(event, 0);
+ }
+ }
+
+diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
+index 87737ec86d39a..1dc9d3c818726 100644
+--- a/arch/powerpc/platforms/Kconfig.cputype
++++ b/arch/powerpc/platforms/Kconfig.cputype
+@@ -36,7 +36,7 @@ config PPC_BOOK3S_6xx
+ select PPC_HAVE_PMU_SUPPORT
+ select PPC_HAVE_KUEP
+ select PPC_HAVE_KUAP
+- select HAVE_ARCH_VMAP_STACK
++ select HAVE_ARCH_VMAP_STACK if !ADB_PMU
+
+ config PPC_BOOK3S_601
+ bool "PowerPC 601"
+diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
+index 0f7c8241912b9..f2ff359041eec 100644
+--- a/arch/powerpc/platforms/cell/Kconfig
++++ b/arch/powerpc/platforms/cell/Kconfig
+@@ -44,6 +44,7 @@ config SPU_FS
+ tristate "SPU file system"
+ default m
+ depends on PPC_CELL
++ depends on COREDUMP
+ select SPU_BASE
+ help
+ The SPU file system is used to access Synergistic Processing
+diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
+index 71b881e554fcb..cb58ec7ce77ac 100644
+--- a/arch/powerpc/sysdev/xive/native.c
++++ b/arch/powerpc/sysdev/xive/native.c
+@@ -18,6 +18,7 @@
+ #include <linux/delay.h>
+ #include <linux/cpumask.h>
+ #include <linux/mm.h>
++#include <linux/kmemleak.h>
+
+ #include <asm/machdep.h>
+ #include <asm/prom.h>
+@@ -647,6 +648,7 @@ static bool xive_native_provision_pages(void)
+ pr_err("Failed to allocate provisioning page\n");
+ return false;
+ }
++ kmemleak_ignore(p);
+ opal_xive_donate_page(chip, __pa(p));
+ }
+ return true;
+diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
+index dae32d948bf25..f8a56b5dc29fe 100644
+--- a/arch/x86/kernel/apic/vector.c
++++ b/arch/x86/kernel/apic/vector.c
+@@ -161,6 +161,7 @@ static void apic_update_vector(struct irq_data *irqd, unsigned int newvec,
+ apicd->move_in_progress = true;
+ apicd->prev_vector = apicd->vector;
+ apicd->prev_cpu = apicd->cpu;
++ WARN_ON_ONCE(apicd->cpu == newcpu);
+ } else {
+ irq_matrix_free(vector_matrix, apicd->cpu, apicd->vector,
+ managed);
+@@ -910,7 +911,7 @@ void send_cleanup_vector(struct irq_cfg *cfg)
+ __send_cleanup_vector(apicd);
+ }
+
+-static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector)
++void irq_complete_move(struct irq_cfg *cfg)
+ {
+ struct apic_chip_data *apicd;
+
+@@ -918,15 +919,16 @@ static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector)
+ if (likely(!apicd->move_in_progress))
+ return;
+
+- if (vector == apicd->vector && apicd->cpu == smp_processor_id())
++ /*
++ * If the interrupt arrived on the new target CPU, cleanup the
++ * vector on the old target CPU. A vector check is not required
++ * because an interrupt can never move from one vector to another
++ * on the same CPU.
++ */
++ if (apicd->cpu == smp_processor_id())
+ __send_cleanup_vector(apicd);
+ }
+
+-void irq_complete_move(struct irq_cfg *cfg)
+-{
+- __irq_complete_move(cfg, ~get_irq_regs()->orig_ax);
+-}
+-
+ /*
+ * Called from fixup_irqs() with @desc->lock held and interrupts disabled.
+ */
+diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
+index 518ac6bf752e0..9fb6a8655ddf3 100644
+--- a/arch/x86/kernel/smpboot.c
++++ b/arch/x86/kernel/smpboot.c
+@@ -1604,14 +1604,28 @@ int native_cpu_disable(void)
+ if (ret)
+ return ret;
+
+- /*
+- * Disable the local APIC. Otherwise IPI broadcasts will reach
+- * it. It still responds normally to INIT, NMI, SMI, and SIPI
+- * messages.
+- */
+- apic_soft_disable();
+ cpu_disable_common();
+
++ /*
++ * Disable the local APIC. Otherwise IPI broadcasts will reach
++ * it. It still responds normally to INIT, NMI, SMI, and SIPI
++ * messages.
++ *
++ * Disabling the APIC must happen after cpu_disable_common()
++ * which invokes fixup_irqs().
++ *
++ * Disabling the APIC preserves already set bits in IRR, but
++ * an interrupt arriving after disabling the local APIC does not
++ * set the corresponding IRR bit.
++ *
++ * fixup_irqs() scans IRR for set bits so it can raise a not
++ * yet handled interrupt on the new destination CPU via an IPI
++ * but obviously it can't do so for IRR bits which are not set.
++ * IOW, interrupts arriving after disabling the local APIC will
++ * be lost.
++ */
++ apic_soft_disable();
++
+ return 0;
+ }
+
+diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
+index 68882b9b8f11f..b791e2041e49b 100644
+--- a/block/bfq-cgroup.c
++++ b/block/bfq-cgroup.c
+@@ -332,7 +332,7 @@ static void bfqg_put(struct bfq_group *bfqg)
+ kfree(bfqg);
+ }
+
+-void bfqg_and_blkg_get(struct bfq_group *bfqg)
++static void bfqg_and_blkg_get(struct bfq_group *bfqg)
+ {
+ /* see comments in bfq_bic_update_cgroup for why refcounting bfqg */
+ bfqg_get(bfqg);
+diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
+index cd224aaf9f52a..703895224562c 100644
+--- a/block/bfq-iosched.h
++++ b/block/bfq-iosched.h
+@@ -986,7 +986,6 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
+ struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg);
+ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
+ struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node);
+-void bfqg_and_blkg_get(struct bfq_group *bfqg);
+ void bfqg_and_blkg_put(struct bfq_group *bfqg);
+
+ #ifdef CONFIG_BFQ_GROUP_IOSCHED
+diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
+index eb0e2a6daabe6..26776bdbdf360 100644
+--- a/block/bfq-wf2q.c
++++ b/block/bfq-wf2q.c
+@@ -533,9 +533,7 @@ static void bfq_get_entity(struct bfq_entity *entity)
+ bfqq->ref++;
+ bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d",
+ bfqq, bfqq->ref);
+- } else
+- bfqg_and_blkg_get(container_of(entity, struct bfq_group,
+- entity));
++ }
+ }
+
+ /**
+@@ -649,14 +647,8 @@ static void bfq_forget_entity(struct bfq_service_tree *st,
+
+ entity->on_st_or_in_serv = false;
+ st->wsum -= entity->weight;
+- if (is_in_service)
+- return;
+-
+- if (bfqq)
++ if (bfqq && !is_in_service)
+ bfq_put_queue(bfqq);
+- else
+- bfqg_and_blkg_put(container_of(entity, struct bfq_group,
+- entity));
+ }
+
+ /**
+diff --git a/block/bio.c b/block/bio.c
+index a7366c02c9b57..b1883adc8f154 100644
+--- a/block/bio.c
++++ b/block/bio.c
+@@ -738,8 +738,8 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
+ struct page *page, unsigned int len, unsigned int off,
+ bool *same_page)
+ {
+- phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) +
+- bv->bv_offset + bv->bv_len - 1;
++ size_t bv_end = bv->bv_offset + bv->bv_len;
++ phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) + bv_end - 1;
+ phys_addr_t page_addr = page_to_phys(page);
+
+ if (vec_end_addr + 1 != page_addr + off)
+@@ -748,9 +748,9 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
+ return false;
+
+ *same_page = ((vec_end_addr & PAGE_MASK) == page_addr);
+- if (!*same_page && pfn_to_page(PFN_DOWN(vec_end_addr)) + 1 != page)
+- return false;
+- return true;
++ if (*same_page)
++ return true;
++ return (bv->bv_page + bv_end / PAGE_SIZE) == (page + off / PAGE_SIZE);
+ }
+
+ /*
+diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
+index 0ecc897b225c9..6e8f5e60b0982 100644
+--- a/block/blk-cgroup.c
++++ b/block/blk-cgroup.c
+@@ -1056,13 +1056,15 @@ int blkcg_init_queue(struct request_queue *q)
+ if (preloaded)
+ radix_tree_preload_end();
+
+- ret = blk_iolatency_init(q);
++ ret = blk_throtl_init(q);
+ if (ret)
+ goto err_destroy_all;
+
+- ret = blk_throtl_init(q);
+- if (ret)
++ ret = blk_iolatency_init(q);
++ if (ret) {
++ blk_throtl_exit(q);
+ goto err_destroy_all;
++ }
+ return 0;
+
+ err_destroy_all:
+diff --git a/block/blk-merge.c b/block/blk-merge.c
+index f0b0bae075a0c..75abba4d4591c 100644
+--- a/block/blk-merge.c
++++ b/block/blk-merge.c
+@@ -154,7 +154,7 @@ static inline unsigned get_max_io_size(struct request_queue *q,
+ if (max_sectors > start_offset)
+ return max_sectors - start_offset;
+
+- return sectors & (lbs - 1);
++ return sectors & ~(lbs - 1);
+ }
+
+ static inline unsigned get_max_segment_size(const struct request_queue *q,
+@@ -534,10 +534,17 @@ int __blk_rq_map_sg(struct request_queue *q, struct request *rq,
+ }
+ EXPORT_SYMBOL(__blk_rq_map_sg);
+
++static inline unsigned int blk_rq_get_max_segments(struct request *rq)
++{
++ if (req_op(rq) == REQ_OP_DISCARD)
++ return queue_max_discard_segments(rq->q);
++ return queue_max_segments(rq->q);
++}
++
+ static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
+ unsigned int nr_phys_segs)
+ {
+- if (req->nr_phys_segments + nr_phys_segs > queue_max_segments(req->q))
++ if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
+ goto no_merge;
+
+ if (blk_integrity_merge_bio(req->q, req, bio) == false)
+@@ -625,7 +632,7 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
+ return 0;
+
+ total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
+- if (total_phys_segments > queue_max_segments(q))
++ if (total_phys_segments > blk_rq_get_max_segments(req))
+ return 0;
+
+ if (blk_integrity_merge_rq(q, req, next) == false)
+diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
+index fdcc2c1dd1788..fd850d9e68a1a 100644
+--- a/block/blk-mq-sched.c
++++ b/block/blk-mq-sched.c
+@@ -77,6 +77,15 @@ void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx)
+ return;
+ clear_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
+
++ /*
++ * Order clearing SCHED_RESTART and list_empty_careful(&hctx->dispatch)
++ * in blk_mq_run_hw_queue(). Its pair is the barrier in
++ * blk_mq_dispatch_rq_list(). So dispatch code won't see SCHED_RESTART,
++ * meantime new request added to hctx->dispatch is missed to check in
++ * blk_mq_run_hw_queue().
++ */
++ smp_mb();
++
+ blk_mq_run_hw_queue(hctx, true);
+ }
+
+diff --git a/block/blk-mq.c b/block/blk-mq.c
+index 4e0d173beaa35..a366726094a89 100644
+--- a/block/blk-mq.c
++++ b/block/blk-mq.c
+@@ -1323,6 +1323,15 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
+ list_splice_tail_init(list, &hctx->dispatch);
+ spin_unlock(&hctx->lock);
+
++ /*
++ * Order adding requests to hctx->dispatch and checking
++ * SCHED_RESTART flag. The pair of this smp_mb() is the one
++ * in blk_mq_sched_restart(). Avoid restart code path to
++ * miss the new added requests to hctx->dispatch, meantime
++ * SCHED_RESTART is observed here.
++ */
++ smp_mb();
++
+ /*
+ * If SCHED_RESTART was set by the caller of this function and
+ * it is no longer set that means that it was cleared by another
+@@ -1909,7 +1918,8 @@ insert:
+ if (bypass_insert)
+ return BLK_STS_RESOURCE;
+
+- blk_mq_request_bypass_insert(rq, false, run_queue);
++ blk_mq_sched_insert_request(rq, false, run_queue, false);
++
+ return BLK_STS_OK;
+ }
+
+diff --git a/crypto/af_alg.c b/crypto/af_alg.c
+index 5882ed46f1adb..e31cf43df2e09 100644
+--- a/crypto/af_alg.c
++++ b/crypto/af_alg.c
+@@ -16,6 +16,7 @@
+ #include <linux/module.h>
+ #include <linux/net.h>
+ #include <linux/rwsem.h>
++#include <linux/sched.h>
+ #include <linux/sched/signal.h>
+ #include <linux/security.h>
+
+@@ -847,9 +848,15 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
+ }
+
+ lock_sock(sk);
+- if (ctx->init && (init || !ctx->more)) {
+- err = -EINVAL;
+- goto unlock;
++ if (ctx->init && !ctx->more) {
++ if (ctx->used) {
++ err = -EINVAL;
++ goto unlock;
++ }
++
++ pr_info_once(
++ "%s sent an empty control message without MSG_MORE.\n",
++ current->comm);
+ }
+ ctx->init = true;
+
+diff --git a/drivers/base/core.c b/drivers/base/core.c
+index 05d414e9e8a40..0799e1445f654 100644
+--- a/drivers/base/core.c
++++ b/drivers/base/core.c
+@@ -3988,9 +3988,9 @@ 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;
+
+@@ -4000,8 +4000,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
+ }
+ 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 9dd85bea40260..205a06752ca90 100644
+--- a/drivers/base/power/main.c
++++ b/drivers/base/power/main.c
+@@ -1606,13 +1606,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/block/loop.c b/drivers/block/loop.c
+index 776083963ee6c..84433922aed16 100644
+--- a/drivers/block/loop.c
++++ b/drivers/block/loop.c
+@@ -877,6 +877,7 @@ static void loop_config_discard(struct loop_device *lo)
+ struct file *file = lo->lo_backing_file;
+ struct inode *inode = file->f_mapping->host;
+ struct request_queue *q = lo->lo_queue;
++ u32 granularity, max_discard_sectors;
+
+ /*
+ * If the backing device is a block device, mirror its zeroing
+@@ -889,11 +890,10 @@ static void loop_config_discard(struct loop_device *lo)
+ struct request_queue *backingq;
+
+ backingq = bdev_get_queue(inode->i_bdev);
+- blk_queue_max_discard_sectors(q,
+- backingq->limits.max_write_zeroes_sectors);
+
+- blk_queue_max_write_zeroes_sectors(q,
+- backingq->limits.max_write_zeroes_sectors);
++ max_discard_sectors = backingq->limits.max_write_zeroes_sectors;
++ granularity = backingq->limits.discard_granularity ?:
++ queue_physical_block_size(backingq);
+
+ /*
+ * We use punch hole to reclaim the free space used by the
+@@ -902,23 +902,26 @@ static void loop_config_discard(struct loop_device *lo)
+ * useful information.
+ */
+ } else if (!file->f_op->fallocate || lo->lo_encrypt_key_size) {
+- q->limits.discard_granularity = 0;
+- q->limits.discard_alignment = 0;
+- blk_queue_max_discard_sectors(q, 0);
+- blk_queue_max_write_zeroes_sectors(q, 0);
++ max_discard_sectors = 0;
++ granularity = 0;
+
+ } else {
+- q->limits.discard_granularity = inode->i_sb->s_blocksize;
+- q->limits.discard_alignment = 0;
+-
+- blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
+- blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> 9);
++ max_discard_sectors = UINT_MAX >> 9;
++ granularity = inode->i_sb->s_blocksize;
+ }
+
+- if (q->limits.max_write_zeroes_sectors)
++ if (max_discard_sectors) {
++ q->limits.discard_granularity = granularity;
++ blk_queue_max_discard_sectors(q, max_discard_sectors);
++ blk_queue_max_write_zeroes_sectors(q, max_discard_sectors);
+ blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
+- else
++ } else {
++ q->limits.discard_granularity = 0;
++ blk_queue_max_discard_sectors(q, 0);
++ blk_queue_max_write_zeroes_sectors(q, 0);
+ blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q);
++ }
++ q->limits.discard_alignment = 0;
+ }
+
+ static void loop_unprepare_queue(struct loop_device *lo)
+diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
+index 87b31f9ca362e..8cf13ea11cd2c 100644
+--- a/drivers/block/null_blk_main.c
++++ b/drivers/block/null_blk_main.c
+@@ -1139,7 +1139,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
+ len = bvec.bv_len;
+ err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset,
+ op_is_write(req_op(rq)), sector,
+- req_op(rq) & REQ_FUA);
++ rq->cmd_flags & REQ_FUA);
+ if (err) {
+ spin_unlock_irq(&nullb->lock);
+ return err;
+diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
+index 980df853ee497..99991b6a6f0ed 100644
+--- a/drivers/block/virtio_blk.c
++++ b/drivers/block/virtio_blk.c
+@@ -126,16 +126,31 @@ static int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap)
+ if (!range)
+ return -ENOMEM;
+
+- __rq_for_each_bio(bio, req) {
+- u64 sector = bio->bi_iter.bi_sector;
+- u32 num_sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT;
+-
+- range[n].flags = cpu_to_le32(flags);
+- range[n].num_sectors = cpu_to_le32(num_sectors);
+- range[n].sector = cpu_to_le64(sector);
+- n++;
++ /*
++ * Single max discard segment means multi-range discard isn't
++ * supported, and block layer only runs contiguity merge like
++ * normal RW request. So we can't reply on bio for retrieving
++ * each range info.
++ */
++ if (queue_max_discard_segments(req->q) == 1) {
++ range[0].flags = cpu_to_le32(flags);
++ range[0].num_sectors = cpu_to_le32(blk_rq_sectors(req));
++ range[0].sector = cpu_to_le64(blk_rq_pos(req));
++ n = 1;
++ } else {
++ __rq_for_each_bio(bio, req) {
++ u64 sector = bio->bi_iter.bi_sector;
++ u32 num_sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT;
++
++ range[n].flags = cpu_to_le32(flags);
++ range[n].num_sectors = cpu_to_le32(num_sectors);
++ range[n].sector = cpu_to_le64(sector);
++ n++;
++ }
+ }
+
++ WARN_ON_ONCE(n != segments);
++
+ req->special_vec.bv_page = virt_to_page(range);
+ req->special_vec.bv_offset = offset_in_page(range);
+ req->special_vec.bv_len = sizeof(*range) * segments;
+diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
+index c7540ad28995b..8c730a47e0537 100644
+--- a/drivers/cpufreq/intel_pstate.c
++++ b/drivers/cpufreq/intel_pstate.c
+@@ -649,11 +649,12 @@ static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data,
+ mutex_lock(&intel_pstate_limits_lock);
+
+ if (boot_cpu_has(X86_FEATURE_HWP_EPP)) {
+- u64 value;
+-
+- ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, &value);
+- if (ret)
+- goto return_pref;
++ /*
++ * Use the cached HWP Request MSR value, because the register
++ * itself may be updated by intel_pstate_hwp_boost_up() or
++ * intel_pstate_hwp_boost_down() at any time.
++ */
++ u64 value = READ_ONCE(cpu_data->hwp_req_cached);
+
+ value &= ~GENMASK_ULL(31, 24);
+
+@@ -661,13 +662,18 @@ static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data,
+ epp = epp_values[pref_index - 1];
+
+ value |= (u64)epp << 24;
++ /*
++ * The only other updater of hwp_req_cached in the active mode,
++ * intel_pstate_hwp_set(), is called under the same lock as this
++ * function, so it cannot run in parallel with the update below.
++ */
++ WRITE_ONCE(cpu_data->hwp_req_cached, value);
+ ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value);
+ } else {
+ if (epp == -EINVAL)
+ epp = (pref_index - 1) << 2;
+ ret = intel_pstate_set_epb(cpu_data->cpu, epp);
+ }
+-return_pref:
+ mutex_unlock(&intel_pstate_limits_lock);
+
+ return ret;
+diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
+index 46c84dce6544a..5f8d94e812c8f 100644
+--- a/drivers/devfreq/devfreq.c
++++ b/drivers/devfreq/devfreq.c
+@@ -1690,9 +1690,9 @@ static int devfreq_summary_show(struct seq_file *s, void *data)
+ #endif
+
+ mutex_lock(&devfreq->lock);
+- cur_freq = devfreq->previous_freq,
++ cur_freq = devfreq->previous_freq;
+ get_freq_range(devfreq, &min_freq, &max_freq);
+- polling_ms = devfreq->profile->polling_ms,
++ polling_ms = devfreq->profile->polling_ms;
+ mutex_unlock(&devfreq->lock);
+
+ seq_printf(s,
+diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
+index de41d7928bff2..984354ca877de 100644
+--- a/drivers/dma/Kconfig
++++ b/drivers/dma/Kconfig
+@@ -285,6 +285,7 @@ config INTEL_IDMA64
+ config INTEL_IDXD
+ tristate "Intel Data Accelerators support"
+ depends on PCI && X86_64
++ depends on PCI_MSI
+ select DMA_ENGINE
+ select SBITMAP
+ help
+diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
+index 5813e931f2f00..01ff71f7b6456 100644
+--- a/drivers/edac/edac_mc.c
++++ b/drivers/edac/edac_mc.c
+@@ -950,6 +950,8 @@ static void edac_ue_error(struct edac_raw_error_desc *e)
+ e->other_detail);
+ }
+
++ edac_inc_ue_error(e);
++
+ if (edac_mc_get_panic_on_ue()) {
+ panic("UE %s%son %s (%s page:0x%lx offset:0x%lx grain:%ld%s%s)\n",
+ e->msg,
+@@ -959,8 +961,6 @@ static void edac_ue_error(struct edac_raw_error_desc *e)
+ *e->other_detail ? " - " : "",
+ e->other_detail);
+ }
+-
+- edac_inc_ue_error(e);
+ }
+
+ static void edac_inc_csrow(struct edac_raw_error_desc *e, int row, int chan)
+diff --git a/drivers/edac/ie31200_edac.c b/drivers/edac/ie31200_edac.c
+index d68346a8e141a..ebe50996cc423 100644
+--- a/drivers/edac/ie31200_edac.c
++++ b/drivers/edac/ie31200_edac.c
+@@ -170,6 +170,8 @@
+ (n << (28 + (2 * skl) - PAGE_SHIFT))
+
+ static int nr_channels;
++static struct pci_dev *mci_pdev;
++static int ie31200_registered = 1;
+
+ struct ie31200_priv {
+ void __iomem *window;
+@@ -538,12 +540,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)
+@@ -552,6 +558,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;
+@@ -593,17 +601,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_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
+index c7fd0c47b2545..1102de76d8767 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
+@@ -195,19 +195,32 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
+ unsigned int engine_id,
+ unsigned int queue_id)
+ {
+- uint32_t sdma_engine_reg_base[2] = {
+- SOC15_REG_OFFSET(SDMA0, 0,
+- mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL,
+- SOC15_REG_OFFSET(SDMA1, 0,
+- mmSDMA1_RLC0_RB_CNTL) - mmSDMA1_RLC0_RB_CNTL
+- };
+- uint32_t retval = sdma_engine_reg_base[engine_id]
++ uint32_t sdma_engine_reg_base = 0;
++ uint32_t sdma_rlc_reg_offset;
++
++ switch (engine_id) {
++ default:
++ dev_warn(adev->dev,
++ "Invalid sdma engine id (%d), using engine id 0\n",
++ engine_id);
++ fallthrough;
++ case 0:
++ sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0,
++ mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;
++ break;
++ case 1:
++ sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA1, 0,
++ mmSDMA1_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;
++ break;
++ }
++
++ sdma_rlc_reg_offset = sdma_engine_reg_base
+ + queue_id * (mmSDMA0_RLC1_RB_CNTL - mmSDMA0_RLC0_RB_CNTL);
+
+ pr_debug("RLC register offset for SDMA%d RLC%d: 0x%x\n", engine_id,
+- queue_id, retval);
++ queue_id, sdma_rlc_reg_offset);
+
+- return retval;
++ return sdma_rlc_reg_offset;
+ }
+
+ static inline struct v9_mqd *get_mqd(void *mqd)
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+index f355d9a752d29..a1aec205435de 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+@@ -716,8 +716,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) {
+@@ -854,8 +856,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);
+@@ -977,8 +981,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)) {
+@@ -1328,8 +1334,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 f7143d927b6d8..5e51f0acf744f 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+@@ -282,7 +282,7 @@ int amdgpu_display_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, ctx);
+
+@@ -297,7 +297,7 @@ int amdgpu_display_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 */
+@@ -306,6 +306,7 @@ int amdgpu_display_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 126e74758a342..d73924e35a57e 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+@@ -1373,11 +1373,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_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+index 3414e119f0cbf..f5a6ee7c2eaa3 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+@@ -754,8 +754,10 @@ static int amdgpu_debugfs_gpu_recover(struct seq_file *m, void *data)
+ int r;
+
+ r = pm_runtime_get_sync(dev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(dev->dev);
+ return 0;
++ }
+
+ seq_printf(m, "gpu recover\n");
+ amdgpu_device_gpu_recover(adev, NULL);
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+index 21292098bc023..0a3b7d9df8a56 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+@@ -663,8 +663,12 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
+ * in the bitfields */
+ if (se_num == AMDGPU_INFO_MMR_SE_INDEX_MASK)
+ se_num = 0xffffffff;
++ else if (se_num >= AMDGPU_GFX_MAX_SE)
++ return -EINVAL;
+ if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
+ sh_num = 0xffffffff;
++ else if (sh_num >= AMDGPU_GFX_MAX_SH_PER_SE)
++ return -EINVAL;
+
+ if (info->read_mmr_reg.count > 128)
+ return -EINVAL;
+@@ -992,7 +996,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)) {
+@@ -1043,6 +1047,7 @@ error_pasid:
+
+ out_suspend:
+ pm_runtime_mark_last_busy(dev->dev);
++pm_put:
+ pm_runtime_put_autosuspend(dev->dev);
+
+ return r;
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+index 02e6f8c4dde08..459b81fc5aef4 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+@@ -167,8 +167,10 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ if (adev->smu.ppt_funcs->get_current_power_state)
+@@ -212,8 +214,10 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,
+ return -EINVAL;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ mutex_lock(&adev->pm.mutex);
+@@ -307,8 +311,10 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ level = smu_get_performance_level(&adev->smu);
+@@ -369,8 +375,10 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,
+ }
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ current_level = smu_get_performance_level(&adev->smu);
+@@ -449,8 +457,10 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ ret = smu_get_power_num_states(&adev->smu, &data);
+@@ -491,8 +501,10 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ pm = smu_get_current_power_state(smu);
+@@ -567,8 +579,10 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,
+ state = data.states[idx];
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ /* only set user selected power states */
+ if (state != POWER_STATE_TYPE_INTERNAL_BOOT &&
+@@ -608,8 +622,10 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ size = smu_sys_get_pp_table(&adev->smu, (void **)&table);
+@@ -650,8 +666,10 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ ret = smu_sys_set_pp_table(&adev->smu, (void *)buf, count);
+@@ -790,8 +808,10 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
+ }
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ ret = smu_od_edit_dpm_table(&adev->smu, type,
+@@ -847,8 +867,10 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ size = smu_print_clk_levels(&adev->smu, SMU_OD_SCLK, buf);
+@@ -905,8 +927,10 @@ static ssize_t amdgpu_set_pp_features(struct device *dev,
+ pr_debug("featuremask = 0x%llx\n", featuremask);
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ ret = smu_sys_set_pp_feature_mask(&adev->smu, featuremask);
+@@ -942,8 +966,10 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_sys_get_pp_feature_mask(&adev->smu, buf);
+@@ -1001,8 +1027,10 @@ static ssize_t amdgpu_get_pp_dpm_sclk(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_print_clk_levels(&adev->smu, SMU_SCLK, buf);
+@@ -1071,8 +1099,10 @@ static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
+ return ret;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_force_clk_levels(&adev->smu, SMU_SCLK, mask, true);
+@@ -1101,8 +1131,10 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_print_clk_levels(&adev->smu, SMU_MCLK, buf);
+@@ -1135,8 +1167,10 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
+ return ret;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_force_clk_levels(&adev->smu, SMU_MCLK, mask, true);
+@@ -1165,8 +1199,10 @@ static ssize_t amdgpu_get_pp_dpm_socclk(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_print_clk_levels(&adev->smu, SMU_SOCCLK, buf);
+@@ -1199,8 +1235,10 @@ static ssize_t amdgpu_set_pp_dpm_socclk(struct device *dev,
+ return ret;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_force_clk_levels(&adev->smu, SMU_SOCCLK, mask, true);
+@@ -1231,8 +1269,10 @@ static ssize_t amdgpu_get_pp_dpm_fclk(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_print_clk_levels(&adev->smu, SMU_FCLK, buf);
+@@ -1265,8 +1305,10 @@ static ssize_t amdgpu_set_pp_dpm_fclk(struct device *dev,
+ return ret;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_force_clk_levels(&adev->smu, SMU_FCLK, mask, true);
+@@ -1297,8 +1339,10 @@ static ssize_t amdgpu_get_pp_dpm_dcefclk(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_print_clk_levels(&adev->smu, SMU_DCEFCLK, buf);
+@@ -1331,8 +1375,10 @@ static ssize_t amdgpu_set_pp_dpm_dcefclk(struct device *dev,
+ return ret;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_force_clk_levels(&adev->smu, SMU_DCEFCLK, mask, true);
+@@ -1363,8 +1409,10 @@ static ssize_t amdgpu_get_pp_dpm_pcie(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_print_clk_levels(&adev->smu, SMU_PCIE, buf);
+@@ -1397,8 +1445,10 @@ static ssize_t amdgpu_set_pp_dpm_pcie(struct device *dev,
+ return ret;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_force_clk_levels(&adev->smu, SMU_PCIE, mask, true);
+@@ -1429,8 +1479,10 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ value = smu_get_od_percentage(&(adev->smu), SMU_OD_SCLK);
+@@ -1462,8 +1514,10 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev,
+ return -EINVAL;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ value = smu_set_od_percentage(&(adev->smu), SMU_OD_SCLK, (uint32_t)value);
+@@ -1498,8 +1552,10 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ value = smu_get_od_percentage(&(adev->smu), SMU_OD_MCLK);
+@@ -1531,8 +1587,10 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev,
+ return -EINVAL;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ value = smu_set_od_percentage(&(adev->smu), SMU_OD_MCLK, (uint32_t)value);
+@@ -1587,8 +1645,10 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ size = smu_get_power_profile_mode(&adev->smu, buf);
+@@ -1650,8 +1710,10 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,
+ parameter[parameter_size] = profile_mode;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev))
+ ret = smu_set_power_profile_mode(&adev->smu, parameter, parameter_size, true);
+@@ -1687,8 +1749,10 @@ static ssize_t amdgpu_get_gpu_busy_percent(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return r;
++ }
+
+ /* read the IP busy sensor */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_LOAD,
+@@ -1723,8 +1787,10 @@ static ssize_t amdgpu_get_mem_busy_percent(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return r;
++ }
+
+ /* read the IP busy sensor */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MEM_LOAD,
+@@ -1770,8 +1836,10 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,
+ return -ENODATA;
+
+ ret = pm_runtime_get_sync(ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(ddev->dev);
+ return ret;
++ }
+
+ amdgpu_asic_get_pcie_usage(adev, &count0, &count1);
+
+@@ -2003,8 +2071,10 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
+ return -EINVAL;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ switch (channel) {
+ case PP_TEMP_JUNCTION:
+@@ -2134,8 +2204,10 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(adev->ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ pwm_mode = smu_get_fan_control_mode(&adev->smu);
+@@ -2172,8 +2244,10 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,
+ return err;
+
+ ret = pm_runtime_get_sync(adev->ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ smu_set_fan_control_mode(&adev->smu, value);
+@@ -2220,8 +2294,10 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,
+ return -EPERM;
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev))
+ pwm_mode = smu_get_fan_control_mode(&adev->smu);
+@@ -2272,8 +2348,10 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,
+ return -EPERM;
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev))
+ err = smu_get_fan_speed_percent(&adev->smu, &speed);
+@@ -2305,8 +2383,10 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
+ return -EPERM;
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev))
+ err = smu_get_fan_speed_rpm(&adev->smu, &speed);
+@@ -2337,8 +2417,10 @@ static ssize_t amdgpu_hwmon_get_fan1_min(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MIN_FAN_RPM,
+ (void *)&min_rpm, &size);
+@@ -2365,8 +2447,10 @@ static ssize_t amdgpu_hwmon_get_fan1_max(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MAX_FAN_RPM,
+ (void *)&max_rpm, &size);
+@@ -2392,8 +2476,10 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,
+ return -EPERM;
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev))
+ err = smu_get_fan_speed_rpm(&adev->smu, &rpm);
+@@ -2424,8 +2510,10 @@ static ssize_t amdgpu_hwmon_set_fan1_target(struct device *dev,
+ return -EPERM;
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev))
+ pwm_mode = smu_get_fan_control_mode(&adev->smu);
+@@ -2473,8 +2561,10 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,
+ return -EPERM;
+
+ ret = pm_runtime_get_sync(adev->ddev->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return ret;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ pwm_mode = smu_get_fan_control_mode(&adev->smu);
+@@ -2519,8 +2609,10 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
+ return -EINVAL;
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ smu_set_fan_control_mode(&adev->smu, pwm_mode);
+@@ -2551,8 +2643,10 @@ static ssize_t amdgpu_hwmon_show_vddgfx(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ /* get the voltage */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_VDDGFX,
+@@ -2590,8 +2684,10 @@ static ssize_t amdgpu_hwmon_show_vddnb(struct device *dev,
+ return -EINVAL;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ /* get the voltage */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_VDDNB,
+@@ -2626,8 +2722,10 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ /* get the voltage */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_POWER,
+@@ -2665,8 +2763,10 @@ static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ smu_get_power_limit(&adev->smu, &limit, true, true);
+@@ -2697,8 +2797,10 @@ static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ if (is_support_sw_smu(adev)) {
+ smu_get_power_limit(&adev->smu, &limit, false, true);
+@@ -2740,8 +2842,10 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,
+
+
+ err = pm_runtime_get_sync(adev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return err;
++ }
+
+ if (is_support_sw_smu(adev))
+ err = smu_set_power_limit(&adev->smu, value);
+@@ -2771,8 +2875,10 @@ static ssize_t amdgpu_hwmon_show_sclk(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ /* get the sclk */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GFX_SCLK,
+@@ -2806,8 +2912,10 @@ static ssize_t amdgpu_hwmon_show_mclk(struct device *dev,
+ return -EPERM;
+
+ r = pm_runtime_get_sync(adev->ddev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(adev->ddev->dev);
+ return r;
++ }
+
+ /* get the sclk */
+ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GFX_MCLK,
+@@ -3669,8 +3777,10 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
+ return -EPERM;
+
+ r = pm_runtime_get_sync(dev->dev);
+- if (r < 0)
++ if (r < 0) {
++ pm_runtime_put_autosuspend(dev->dev);
+ return r;
++ }
+
+ amdgpu_device_ip_get_clockgating_state(adev, &flags);
+ seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags);
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+index 50fe08bf2f727..3f47f35eedff1 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+@@ -1240,7 +1240,6 @@ void amdgpu_ras_debugfs_remove(struct amdgpu_device *adev,
+ if (!obj || !obj->ent)
+ return;
+
+- debugfs_remove(obj->ent);
+ obj->ent = NULL;
+ put_obj(obj);
+ }
+@@ -1254,7 +1253,6 @@ static void amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)
+ amdgpu_ras_debugfs_remove(adev, &obj->head);
+ }
+
+- debugfs_remove_recursive(con->dir);
+ con->dir = NULL;
+ }
+ /* debugfs end */
+@@ -1914,9 +1912,8 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
+ amdgpu_ras_check_supported(adev, &con->hw_supported,
+ &con->supported);
+ if (!con->hw_supported) {
+- amdgpu_ras_set_context(adev, NULL);
+- kfree(con);
+- return 0;
++ r = 0;
++ goto err_out;
+ }
+
+ con->features = 0;
+@@ -1927,29 +1924,31 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
+ if (adev->nbio.funcs->init_ras_controller_interrupt) {
+ r = adev->nbio.funcs->init_ras_controller_interrupt(adev);
+ if (r)
+- return r;
++ goto err_out;
+ }
+
+ if (adev->nbio.funcs->init_ras_err_event_athub_interrupt) {
+ r = adev->nbio.funcs->init_ras_err_event_athub_interrupt(adev);
+ if (r)
+- return r;
++ goto err_out;
+ }
+
+ amdgpu_ras_mask &= AMDGPU_RAS_BLOCK_MASK;
+
+- if (amdgpu_ras_fs_init(adev))
+- goto fs_out;
++ if (amdgpu_ras_fs_init(adev)) {
++ r = -EINVAL;
++ goto err_out;
++ }
+
+ dev_info(adev->dev, "RAS INFO: ras initialized successfully, "
+ "hardware ability[%x] ras_mask[%x]\n",
+ con->hw_supported, con->supported);
+ return 0;
+-fs_out:
++err_out:
+ amdgpu_ras_set_context(adev, NULL);
+ kfree(con);
+
+- return -EINVAL;
++ return r;
+ }
+
+ /* helper function to handle common stuff in ip late init phase */
+diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+index fac77a86c04b2..2c7e6efeea2ff 100644
+--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+@@ -6854,10 +6854,8 @@ static void gfx_v10_0_update_medium_grain_clock_gating(struct amdgpu_device *ade
+ def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
+ data &= ~(RLC_CGTT_MGCG_OVERRIDE__GRBM_CGTT_SCLK_OVERRIDE_MASK |
+ RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK |
+- RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK);
+-
+- /* only for Vega10 & Raven1 */
+- data |= RLC_CGTT_MGCG_OVERRIDE__RLC_CGTT_SCLK_OVERRIDE_MASK;
++ RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK |
++ RLC_CGTT_MGCG_OVERRIDE__ENABLE_CGTS_LEGACY_MASK);
+
+ if (def != data)
+ WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+index 0e0c42e9f6a31..6520a920cad4a 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+@@ -1003,8 +1003,10 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
+ */
+ if (!pdd->runtime_inuse) {
+ err = pm_runtime_get_sync(dev->ddev->dev);
+- if (err < 0)
++ if (err < 0) {
++ pm_runtime_put_autosuspend(dev->ddev->dev);
+ return ERR_PTR(err);
++ }
+ }
+
+ err = kfd_iommu_bind_process_to_device(pdd);
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+index bb77f7af2b6d9..dc3c4149f8600 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+@@ -632,8 +632,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)
+@@ -680,8 +682,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;
+@@ -699,8 +703,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;
+@@ -718,8 +724,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;
+@@ -798,8 +806,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/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+index 0a39a8558b294..666ebe04837af 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+@@ -2882,51 +2882,50 @@ static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)
+ return rc ? 0 : 1;
+ }
+
+-static u32 convert_brightness(const struct amdgpu_dm_backlight_caps *caps,
+- const uint32_t user_brightness)
++static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
++ unsigned *min, unsigned *max)
+ {
+- u32 min, max, conversion_pace;
+- u32 brightness = user_brightness;
+-
+ if (!caps)
+- goto out;
++ return 0;
+
+- if (!caps->aux_support) {
+- max = caps->max_input_signal;
+- min = caps->min_input_signal;
+- /*
+- * The brightness input is in the range 0-255
+- * It needs to be rescaled to be between the
+- * requested min and max input signal
+- * It also needs to be scaled up by 0x101 to
+- * match the DC interface which has a range of
+- * 0 to 0xffff
+- */
+- conversion_pace = 0x101;
+- brightness =
+- user_brightness
+- * conversion_pace
+- * (max - min)
+- / AMDGPU_MAX_BL_LEVEL
+- + min * conversion_pace;
++ if (caps->aux_support) {
++ // Firmware limits are in nits, DC API wants millinits.
++ *max = 1000 * caps->aux_max_input_signal;
++ *min = 1000 * caps->aux_min_input_signal;
+ } else {
+- /* TODO
+- * We are doing a linear interpolation here, which is OK but
+- * does not provide the optimal result. We probably want
+- * something close to the Perceptual Quantizer (PQ) curve.
+- */
+- max = caps->aux_max_input_signal;
+- min = caps->aux_min_input_signal;
+-
+- brightness = (AMDGPU_MAX_BL_LEVEL - user_brightness) * min
+- + user_brightness * max;
+- // Multiple the value by 1000 since we use millinits
+- brightness *= 1000;
+- brightness = DIV_ROUND_CLOSEST(brightness, AMDGPU_MAX_BL_LEVEL);
++ // Firmware limits are 8-bit, PWM control is 16-bit.
++ *max = 0x101 * caps->max_input_signal;
++ *min = 0x101 * caps->min_input_signal;
+ }
++ return 1;
++}
++
++static u32 convert_brightness_from_user(const struct amdgpu_dm_backlight_caps *caps,
++ uint32_t brightness)
++{
++ unsigned min, max;
+
+-out:
+- return brightness;
++ if (!get_brightness_range(caps, &min, &max))
++ return brightness;
++
++ // Rescale 0..255 to min..max
++ return min + DIV_ROUND_CLOSEST((max - min) * brightness,
++ AMDGPU_MAX_BL_LEVEL);
++}
++
++static u32 convert_brightness_to_user(const struct amdgpu_dm_backlight_caps *caps,
++ uint32_t brightness)
++{
++ unsigned min, max;
++
++ if (!get_brightness_range(caps, &min, &max))
++ return brightness;
++
++ if (brightness < min)
++ return 0;
++ // Rescale min..max to 0..255
++ return DIV_ROUND_CLOSEST(AMDGPU_MAX_BL_LEVEL * (brightness - min),
++ max - min);
+ }
+
+ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
+@@ -2942,7 +2941,7 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
+
+ link = (struct dc_link *)dm->backlight_link;
+
+- brightness = convert_brightness(&caps, bd->props.brightness);
++ brightness = convert_brightness_from_user(&caps, bd->props.brightness);
+ // Change brightness based on AUX property
+ if (caps.aux_support)
+ return set_backlight_via_aux(link, brightness);
+@@ -2959,7 +2958,7 @@ static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
+
+ if (ret == DC_ERROR_UNEXPECTED)
+ return bd->props.brightness;
+- return ret;
++ return convert_brightness_to_user(&dm->backlight_caps, ret);
+ }
+
+ static const struct backlight_ops amdgpu_dm_backlight_ops = {
+diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+index 4dfb6b55bb2ed..b321ff654df42 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+@@ -195,10 +195,13 @@ static int __set_legacy_tf(struct dc_transfer_func *func,
+ bool has_rom)
+ {
+ struct dc_gamma *gamma = NULL;
++ struct calculate_buffer cal_buffer = {0};
+ bool res;
+
+ ASSERT(lut && lut_size == MAX_COLOR_LEGACY_LUT_ENTRIES);
+
++ cal_buffer.buffer_index = -1;
++
+ gamma = dc_create_gamma();
+ if (!gamma)
+ return -ENOMEM;
+@@ -208,7 +211,7 @@ static int __set_legacy_tf(struct dc_transfer_func *func,
+ __drm_lut_to_dc_gamma(lut, gamma, true);
+
+ res = mod_color_calculate_regamma_params(func, gamma, true, has_rom,
+- NULL);
++ NULL, &cal_buffer);
+
+ dc_gamma_release(&gamma);
+
+@@ -221,10 +224,13 @@ static int __set_output_tf(struct dc_transfer_func *func,
+ bool has_rom)
+ {
+ struct dc_gamma *gamma = NULL;
++ struct calculate_buffer cal_buffer = {0};
+ bool res;
+
+ ASSERT(lut && lut_size == MAX_COLOR_LUT_ENTRIES);
+
++ cal_buffer.buffer_index = -1;
++
+ gamma = dc_create_gamma();
+ if (!gamma)
+ return -ENOMEM;
+@@ -248,7 +254,7 @@ static int __set_output_tf(struct dc_transfer_func *func,
+ */
+ gamma->type = GAMMA_CS_TFM_1D;
+ res = mod_color_calculate_regamma_params(func, gamma, false,
+- has_rom, NULL);
++ has_rom, NULL, &cal_buffer);
+ }
+
+ dc_gamma_release(&gamma);
+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 07b2f9399671d..842abb4c475bc 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
+@@ -121,35 +121,35 @@ void enc1_update_generic_info_packet(
+ switch (packet_index) {
+ case 0:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC0_FRAME_UPDATE, 1);
++ AFMT_GENERIC0_IMMEDIATE_UPDATE, 1);
+ break;
+ case 1:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC1_FRAME_UPDATE, 1);
++ AFMT_GENERIC1_IMMEDIATE_UPDATE, 1);
+ break;
+ case 2:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC2_FRAME_UPDATE, 1);
++ AFMT_GENERIC2_IMMEDIATE_UPDATE, 1);
+ break;
+ case 3:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC3_FRAME_UPDATE, 1);
++ AFMT_GENERIC3_IMMEDIATE_UPDATE, 1);
+ break;
+ case 4:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC4_FRAME_UPDATE, 1);
++ AFMT_GENERIC4_IMMEDIATE_UPDATE, 1);
+ break;
+ case 5:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC5_FRAME_UPDATE, 1);
++ AFMT_GENERIC5_IMMEDIATE_UPDATE, 1);
+ break;
+ case 6:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC6_FRAME_UPDATE, 1);
++ AFMT_GENERIC6_IMMEDIATE_UPDATE, 1);
+ break;
+ case 7:
+ REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
+- AFMT_GENERIC7_FRAME_UPDATE, 1);
++ AFMT_GENERIC7_IMMEDIATE_UPDATE, 1);
+ break;
+ default:
+ break;
+diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
+index f9b9e221c698b..7507000a99ac4 100644
+--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
++++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
+@@ -273,7 +273,14 @@ struct dcn10_stream_enc_registers {
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC2_FRAME_UPDATE, mask_sh),\
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC3_FRAME_UPDATE, mask_sh),\
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC4_FRAME_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC0_IMMEDIATE_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC1_IMMEDIATE_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC2_IMMEDIATE_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC3_IMMEDIATE_UPDATE, mask_sh),\
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC4_IMMEDIATE_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC5_IMMEDIATE_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC6_IMMEDIATE_UPDATE, mask_sh),\
++ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_IMMEDIATE_UPDATE, mask_sh),\
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC5_FRAME_UPDATE, mask_sh),\
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC6_FRAME_UPDATE, mask_sh),\
+ SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_FRAME_UPDATE, mask_sh),\
+@@ -337,7 +344,14 @@ struct dcn10_stream_enc_registers {
+ type AFMT_GENERIC2_FRAME_UPDATE;\
+ type AFMT_GENERIC3_FRAME_UPDATE;\
+ type AFMT_GENERIC4_FRAME_UPDATE;\
++ type AFMT_GENERIC0_IMMEDIATE_UPDATE;\
++ type AFMT_GENERIC1_IMMEDIATE_UPDATE;\
++ type AFMT_GENERIC2_IMMEDIATE_UPDATE;\
++ type AFMT_GENERIC3_IMMEDIATE_UPDATE;\
+ type AFMT_GENERIC4_IMMEDIATE_UPDATE;\
++ type AFMT_GENERIC5_IMMEDIATE_UPDATE;\
++ type AFMT_GENERIC6_IMMEDIATE_UPDATE;\
++ type AFMT_GENERIC7_IMMEDIATE_UPDATE;\
+ type AFMT_GENERIC5_FRAME_UPDATE;\
+ type AFMT_GENERIC6_FRAME_UPDATE;\
+ type AFMT_GENERIC7_FRAME_UPDATE;\
+diff --git a/drivers/gpu/drm/amd/display/modules/color/Makefile b/drivers/gpu/drm/amd/display/modules/color/Makefile
+index 65c33a76951a4..e66c19a840c29 100644
+--- a/drivers/gpu/drm/amd/display/modules/color/Makefile
++++ b/drivers/gpu/drm/amd/display/modules/color/Makefile
+@@ -23,7 +23,7 @@
+ # Makefile for the color sub-module of DAL.
+ #
+
+-MOD_COLOR = color_gamma.o
++MOD_COLOR = color_gamma.o color_table.o
+
+ AMD_DAL_MOD_COLOR = $(addprefix $(AMDDALPATH)/modules/color/,$(MOD_COLOR))
+ #$(info ************ DAL COLOR MODULE MAKEFILE ************)
+diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
+index bcfe34ef8c28d..b8695660b480e 100644
+--- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
++++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
+@@ -30,20 +30,10 @@
+ #include "opp.h"
+ #include "color_gamma.h"
+
+-#define NUM_PTS_IN_REGION 16
+-#define NUM_REGIONS 32
+-#define MAX_HW_POINTS (NUM_PTS_IN_REGION*NUM_REGIONS)
+-
+ static struct hw_x_point coordinates_x[MAX_HW_POINTS + 2];
+
+-static struct fixed31_32 pq_table[MAX_HW_POINTS + 2];
+-static struct fixed31_32 de_pq_table[MAX_HW_POINTS + 2];
+-
+ // these are helpers for calculations to reduce stack usage
+ // do not depend on these being preserved across calls
+-static struct fixed31_32 scratch_1;
+-static struct fixed31_32 scratch_2;
+-static struct translate_from_linear_space_args scratch_gamma_args;
+
+ /* Helper to optimize gamma calculation, only use in translate_from_linear, in
+ * particular the dc_fixpt_pow function which is very expensive
+@@ -56,9 +46,6 @@ static struct translate_from_linear_space_args scratch_gamma_args;
+ * just multiply with 2^gamma which can be computed once, and save the result so we
+ * recursively compute all the values.
+ */
+-static struct fixed31_32 pow_buffer[NUM_PTS_IN_REGION];
+-static struct fixed31_32 gamma_of_2; // 2^gamma
+-int pow_buffer_ptr = -1;
+ /*sRGB 709 2.2 2.4 P3*/
+ static const int32_t gamma_numerator01[] = { 31308, 180000, 0, 0, 0};
+ static const int32_t gamma_numerator02[] = { 12920, 4500, 0, 0, 0};
+@@ -66,9 +53,6 @@ static const int32_t gamma_numerator03[] = { 55, 99, 0, 0, 0};
+ static const int32_t gamma_numerator04[] = { 55, 99, 0, 0, 0};
+ static const int32_t gamma_numerator05[] = { 2400, 2200, 2200, 2400, 2600};
+
+-static bool pq_initialized; /* = false; */
+-static bool de_pq_initialized; /* = false; */
+-
+ /* one-time setup of X points */
+ void setup_x_points_distribution(void)
+ {
+@@ -250,6 +234,8 @@ void precompute_pq(void)
+ struct fixed31_32 scaling_factor =
+ dc_fixpt_from_fraction(80, 10000);
+
++ struct fixed31_32 *pq_table = mod_color_get_table(type_pq_table);
++
+ /* pow function has problems with arguments too small */
+ for (i = 0; i < 32; i++)
+ pq_table[i] = dc_fixpt_zero;
+@@ -269,7 +255,7 @@ void precompute_de_pq(void)
+ uint32_t begin_index, end_index;
+
+ struct fixed31_32 scaling_factor = dc_fixpt_from_int(125);
+-
++ struct fixed31_32 *de_pq_table = mod_color_get_table(type_de_pq_table);
+ /* X points is 2^-25 to 2^7
+ * De-gamma X is 2^-12 to 2^0 – we are skipping first -12-(-25) = 13 regions
+ */
+@@ -339,6 +325,9 @@ static struct fixed31_32 translate_from_linear_space(
+ {
+ const struct fixed31_32 one = dc_fixpt_from_int(1);
+
++ struct fixed31_32 scratch_1, scratch_2;
++ struct calculate_buffer *cal_buffer = args->cal_buffer;
++
+ if (dc_fixpt_le(one, args->arg))
+ return one;
+
+@@ -352,21 +341,21 @@ static struct fixed31_32 translate_from_linear_space(
+
+ return scratch_1;
+ } else if (dc_fixpt_le(args->a0, args->arg)) {
+- if (pow_buffer_ptr == 0) {
+- gamma_of_2 = dc_fixpt_pow(dc_fixpt_from_int(2),
++ if (cal_buffer->buffer_index == 0) {
++ cal_buffer->gamma_of_2 = dc_fixpt_pow(dc_fixpt_from_int(2),
+ dc_fixpt_recip(args->gamma));
+ }
+ scratch_1 = dc_fixpt_add(one, args->a3);
+- if (pow_buffer_ptr < 16)
++ if (cal_buffer->buffer_index < 16)
+ scratch_2 = dc_fixpt_pow(args->arg,
+ dc_fixpt_recip(args->gamma));
+ else
+- scratch_2 = dc_fixpt_mul(gamma_of_2,
+- pow_buffer[pow_buffer_ptr%16]);
++ scratch_2 = dc_fixpt_mul(cal_buffer->gamma_of_2,
++ cal_buffer->buffer[cal_buffer->buffer_index%16]);
+
+- if (pow_buffer_ptr != -1) {
+- pow_buffer[pow_buffer_ptr%16] = scratch_2;
+- pow_buffer_ptr++;
++ if (cal_buffer->buffer_index != -1) {
++ cal_buffer->buffer[cal_buffer->buffer_index%16] = scratch_2;
++ cal_buffer->buffer_index++;
+ }
+
+ scratch_1 = dc_fixpt_mul(scratch_1, scratch_2);
+@@ -413,15 +402,17 @@ static struct fixed31_32 translate_from_linear_space_long(
+ args->a1);
+ }
+
+-static struct fixed31_32 calculate_gamma22(struct fixed31_32 arg, bool use_eetf)
++static struct fixed31_32 calculate_gamma22(struct fixed31_32 arg, bool use_eetf, struct calculate_buffer *cal_buffer)
+ {
+ struct fixed31_32 gamma = dc_fixpt_from_fraction(22, 10);
++ struct translate_from_linear_space_args scratch_gamma_args;
+
+ scratch_gamma_args.arg = arg;
+ scratch_gamma_args.a0 = dc_fixpt_zero;
+ scratch_gamma_args.a1 = dc_fixpt_zero;
+ scratch_gamma_args.a2 = dc_fixpt_zero;
+ scratch_gamma_args.a3 = dc_fixpt_zero;
++ scratch_gamma_args.cal_buffer = cal_buffer;
+ scratch_gamma_args.gamma = gamma;
+
+ if (use_eetf)
+@@ -467,14 +458,18 @@ static struct fixed31_32 translate_to_linear_space(
+ static struct fixed31_32 translate_from_linear_space_ex(
+ struct fixed31_32 arg,
+ struct gamma_coefficients *coeff,
+- uint32_t color_index)
++ uint32_t color_index,
++ struct calculate_buffer *cal_buffer)
+ {
++ struct translate_from_linear_space_args scratch_gamma_args;
++
+ scratch_gamma_args.arg = arg;
+ scratch_gamma_args.a0 = coeff->a0[color_index];
+ scratch_gamma_args.a1 = coeff->a1[color_index];
+ scratch_gamma_args.a2 = coeff->a2[color_index];
+ scratch_gamma_args.a3 = coeff->a3[color_index];
+ scratch_gamma_args.gamma = coeff->user_gamma[color_index];
++ scratch_gamma_args.cal_buffer = cal_buffer;
+
+ return translate_from_linear_space(&scratch_gamma_args);
+ }
+@@ -742,10 +737,11 @@ static void build_pq(struct pwl_float_data_ex *rgb_regamma,
+ struct fixed31_32 output;
+ struct fixed31_32 scaling_factor =
+ dc_fixpt_from_fraction(sdr_white_level, 10000);
++ struct fixed31_32 *pq_table = mod_color_get_table(type_pq_table);
+
+- if (!pq_initialized && sdr_white_level == 80) {
++ if (!mod_color_is_table_init(type_pq_table) && sdr_white_level == 80) {
+ precompute_pq();
+- pq_initialized = true;
++ mod_color_set_table_init_state(type_pq_table, true);
+ }
+
+ /* TODO: start index is from segment 2^-24, skipping first segment
+@@ -787,12 +783,12 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq,
+ {
+ uint32_t i;
+ struct fixed31_32 output;
+-
++ struct fixed31_32 *de_pq_table = mod_color_get_table(type_de_pq_table);
+ struct fixed31_32 scaling_factor = dc_fixpt_from_int(125);
+
+- if (!de_pq_initialized) {
++ if (!mod_color_is_table_init(type_de_pq_table)) {
+ precompute_de_pq();
+- de_pq_initialized = true;
++ mod_color_set_table_init_state(type_de_pq_table, true);
+ }
+
+
+@@ -811,7 +807,9 @@ static void build_de_pq(struct pwl_float_data_ex *de_pq,
+
+ static bool build_regamma(struct pwl_float_data_ex *rgb_regamma,
+ uint32_t hw_points_num,
+- const struct hw_x_point *coordinate_x, enum dc_transfer_func_predefined type)
++ const struct hw_x_point *coordinate_x,
++ enum dc_transfer_func_predefined type,
++ struct calculate_buffer *cal_buffer)
+ {
+ uint32_t i;
+ bool ret = false;
+@@ -827,20 +825,21 @@ static bool build_regamma(struct pwl_float_data_ex *rgb_regamma,
+ if (!build_coefficients(coeff, type))
+ goto release;
+
+- memset(pow_buffer, 0, NUM_PTS_IN_REGION * sizeof(struct fixed31_32));
+- pow_buffer_ptr = 0; // see variable definition for more info
++ memset(cal_buffer->buffer, 0, NUM_PTS_IN_REGION * sizeof(struct fixed31_32));
++ cal_buffer->buffer_index = 0; // see variable definition for more info
++
+ i = 0;
+ while (i <= hw_points_num) {
+ /*TODO use y vs r,g,b*/
+ rgb->r = translate_from_linear_space_ex(
+- coord_x->x, coeff, 0);
++ coord_x->x, coeff, 0, cal_buffer);
+ rgb->g = rgb->r;
+ rgb->b = rgb->r;
+ ++coord_x;
+ ++rgb;
+ ++i;
+ }
+- pow_buffer_ptr = -1; // reset back to no optimize
++ cal_buffer->buffer_index = -1;
+ ret = true;
+ release:
+ kvfree(coeff);
+@@ -932,7 +931,8 @@ static void hermite_spline_eetf(struct fixed31_32 input_x,
+ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
+ uint32_t hw_points_num,
+ const struct hw_x_point *coordinate_x,
+- const struct freesync_hdr_tf_params *fs_params)
++ const struct freesync_hdr_tf_params *fs_params,
++ struct calculate_buffer *cal_buffer)
+ {
+ uint32_t i;
+ struct pwl_float_data_ex *rgb = rgb_regamma;
+@@ -969,7 +969,7 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
+ max_content = max_display;
+
+ if (!use_eetf)
+- pow_buffer_ptr = 0; // see var definition for more info
++ cal_buffer->buffer_index = 0; // see var definition for more info
+ rgb += 32; // first 32 points have problems with fixed point, too small
+ coord_x += 32;
+ for (i = 32; i <= hw_points_num; i++) {
+@@ -988,7 +988,7 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
+ if (dc_fixpt_lt(scaledX, dc_fixpt_zero))
+ output = dc_fixpt_zero;
+ else
+- output = calculate_gamma22(scaledX, use_eetf);
++ output = calculate_gamma22(scaledX, use_eetf, cal_buffer);
+
+ rgb->r = output;
+ rgb->g = output;
+@@ -1008,7 +1008,7 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
+ ++coord_x;
+ ++rgb;
+ }
+- pow_buffer_ptr = -1;
++ cal_buffer->buffer_index = -1;
+
+ return true;
+ }
+@@ -1606,7 +1606,7 @@ static void build_new_custom_resulted_curve(
+ }
+
+ static void apply_degamma_for_user_regamma(struct pwl_float_data_ex *rgb_regamma,
+- uint32_t hw_points_num)
++ uint32_t hw_points_num, struct calculate_buffer *cal_buffer)
+ {
+ uint32_t i;
+
+@@ -1619,7 +1619,7 @@ static void apply_degamma_for_user_regamma(struct pwl_float_data_ex *rgb_regamma
+ i = 0;
+ while (i != hw_points_num + 1) {
+ rgb->r = translate_from_linear_space_ex(
+- coord_x->x, &coeff, 0);
++ coord_x->x, &coeff, 0, cal_buffer);
+ rgb->g = rgb->r;
+ rgb->b = rgb->r;
+ ++coord_x;
+@@ -1674,7 +1674,8 @@ static bool map_regamma_hw_to_x_user(
+ #define _EXTRA_POINTS 3
+
+ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
+- const struct regamma_lut *regamma)
++ const struct regamma_lut *regamma,
++ struct calculate_buffer *cal_buffer)
+ {
+ struct gamma_coefficients coeff;
+ const struct hw_x_point *coord_x = coordinates_x;
+@@ -1706,11 +1707,11 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
+ }
+ while (i != MAX_HW_POINTS + 1) {
+ output_tf->tf_pts.red[i] = translate_from_linear_space_ex(
+- coord_x->x, &coeff, 0);
++ coord_x->x, &coeff, 0, cal_buffer);
+ output_tf->tf_pts.green[i] = translate_from_linear_space_ex(
+- coord_x->x, &coeff, 1);
++ coord_x->x, &coeff, 1, cal_buffer);
+ output_tf->tf_pts.blue[i] = translate_from_linear_space_ex(
+- coord_x->x, &coeff, 2);
++ coord_x->x, &coeff, 2, cal_buffer);
+ ++coord_x;
+ ++i;
+ }
+@@ -1723,7 +1724,8 @@ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
+ }
+
+ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
+- const struct regamma_lut *regamma)
++ const struct regamma_lut *regamma,
++ struct calculate_buffer *cal_buffer)
+ {
+ struct dc_transfer_func_distributed_points *tf_pts = &output_tf->tf_pts;
+ struct dividers dividers;
+@@ -1756,7 +1758,7 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
+ scale_user_regamma_ramp(rgb_user, &regamma->ramp, dividers);
+
+ if (regamma->flags.bits.applyDegamma == 1) {
+- apply_degamma_for_user_regamma(rgb_regamma, MAX_HW_POINTS);
++ apply_degamma_for_user_regamma(rgb_regamma, MAX_HW_POINTS, cal_buffer);
+ copy_rgb_regamma_to_coordinates_x(coordinates_x,
+ MAX_HW_POINTS, rgb_regamma);
+ }
+@@ -1943,7 +1945,8 @@ static bool calculate_curve(enum dc_transfer_func_predefined trans,
+ struct dc_transfer_func_distributed_points *points,
+ struct pwl_float_data_ex *rgb_regamma,
+ const struct freesync_hdr_tf_params *fs_params,
+- uint32_t sdr_ref_white_level)
++ uint32_t sdr_ref_white_level,
++ struct calculate_buffer *cal_buffer)
+ {
+ uint32_t i;
+ bool ret = false;
+@@ -1979,7 +1982,8 @@ static bool calculate_curve(enum dc_transfer_func_predefined trans,
+ build_freesync_hdr(rgb_regamma,
+ MAX_HW_POINTS,
+ coordinates_x,
+- fs_params);
++ fs_params,
++ cal_buffer);
+
+ ret = true;
+ } else if (trans == TRANSFER_FUNCTION_HLG) {
+@@ -2008,7 +2012,8 @@ static bool calculate_curve(enum dc_transfer_func_predefined trans,
+ build_regamma(rgb_regamma,
+ MAX_HW_POINTS,
+ coordinates_x,
+- trans);
++ trans,
++ cal_buffer);
+
+ ret = true;
+ }
+@@ -2018,7 +2023,8 @@ static bool calculate_curve(enum dc_transfer_func_predefined trans,
+
+ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
+ const struct dc_gamma *ramp, bool mapUserRamp, bool canRomBeUsed,
+- const struct freesync_hdr_tf_params *fs_params)
++ const struct freesync_hdr_tf_params *fs_params,
++ struct calculate_buffer *cal_buffer)
+ {
+ struct dc_transfer_func_distributed_points *tf_pts = &output_tf->tf_pts;
+ struct dividers dividers;
+@@ -2090,7 +2096,8 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
+ tf_pts,
+ rgb_regamma,
+ fs_params,
+- output_tf->sdr_ref_white_level);
++ output_tf->sdr_ref_white_level,
++ cal_buffer);
+
+ if (ret) {
+ map_regamma_hw_to_x_user(ramp, coeff, rgb_user,
+diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.h b/drivers/gpu/drm/amd/display/modules/color/color_gamma.h
+index 7f56226ba77a9..37ffbef6602b0 100644
+--- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.h
++++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.h
+@@ -26,6 +26,8 @@
+ #ifndef COLOR_MOD_COLOR_GAMMA_H_
+ #define COLOR_MOD_COLOR_GAMMA_H_
+
++#include "color_table.h"
++
+ struct dc_transfer_func;
+ struct dc_gamma;
+ struct dc_transfer_func_distributed_points;
+@@ -83,6 +85,12 @@ struct freesync_hdr_tf_params {
+ unsigned int skip_tm; // skip tm
+ };
+
++struct calculate_buffer {
++ int buffer_index;
++ struct fixed31_32 buffer[NUM_PTS_IN_REGION];
++ struct fixed31_32 gamma_of_2;
++};
++
+ struct translate_from_linear_space_args {
+ struct fixed31_32 arg;
+ struct fixed31_32 a0;
+@@ -90,6 +98,7 @@ struct translate_from_linear_space_args {
+ struct fixed31_32 a2;
+ struct fixed31_32 a3;
+ struct fixed31_32 gamma;
++ struct calculate_buffer *cal_buffer;
+ };
+
+ void setup_x_points_distribution(void);
+@@ -99,7 +108,8 @@ void precompute_de_pq(void);
+
+ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
+ const struct dc_gamma *ramp, bool mapUserRamp, bool canRomBeUsed,
+- const struct freesync_hdr_tf_params *fs_params);
++ const struct freesync_hdr_tf_params *fs_params,
++ struct calculate_buffer *cal_buffer);
+
+ bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps,
+ struct dc_transfer_func *output_tf,
+@@ -109,10 +119,12 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
+ struct dc_transfer_func_distributed_points *points);
+
+ bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
+- const struct regamma_lut *regamma);
++ const struct regamma_lut *regamma,
++ struct calculate_buffer *cal_buffer);
+
+ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
+- const struct regamma_lut *regamma);
++ const struct regamma_lut *regamma,
++ struct calculate_buffer *cal_buffer);
+
+
+ #endif /* COLOR_MOD_COLOR_GAMMA_H_ */
+diff --git a/drivers/gpu/drm/amd/display/modules/color/color_table.c b/drivers/gpu/drm/amd/display/modules/color/color_table.c
+new file mode 100644
+index 0000000000000..692e536e7d057
+--- /dev/null
++++ b/drivers/gpu/drm/amd/display/modules/color/color_table.c
+@@ -0,0 +1,48 @@
++/*
++ * Copyright (c) 2019 Advanced Micro Devices, Inc. (unpublished)
++ *
++ * All rights reserved. This notice is intended as a precaution against
++ * inadvertent publication and does not imply publication or any waiver
++ * of confidentiality. The year included in the foregoing notice is the
++ * year of creation of the work.
++ */
++
++#include "color_table.h"
++
++static struct fixed31_32 pq_table[MAX_HW_POINTS + 2];
++static struct fixed31_32 de_pq_table[MAX_HW_POINTS + 2];
++static bool pq_initialized;
++static bool de_pg_initialized;
++
++bool mod_color_is_table_init(enum table_type type)
++{
++ bool ret = false;
++
++ if (type == type_pq_table)
++ ret = pq_initialized;
++ if (type == type_de_pq_table)
++ ret = de_pg_initialized;
++
++ return ret;
++}
++
++struct fixed31_32 *mod_color_get_table(enum table_type type)
++{
++ struct fixed31_32 *table = NULL;
++
++ if (type == type_pq_table)
++ table = pq_table;
++ if (type == type_de_pq_table)
++ table = de_pq_table;
++
++ return table;
++}
++
++void mod_color_set_table_init_state(enum table_type type, bool state)
++{
++ if (type == type_pq_table)
++ pq_initialized = state;
++ if (type == type_de_pq_table)
++ de_pg_initialized = state;
++}
++
+diff --git a/drivers/gpu/drm/amd/display/modules/color/color_table.h b/drivers/gpu/drm/amd/display/modules/color/color_table.h
+new file mode 100644
+index 0000000000000..2621dd6194027
+--- /dev/null
++++ b/drivers/gpu/drm/amd/display/modules/color/color_table.h
+@@ -0,0 +1,47 @@
++/*
++ * Copyright 2016 Advanced Micro Devices, Inc.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
++ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
++ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
++ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ *
++ * Authors: AMD
++ *
++ */
++
++
++#ifndef COLOR_MOD_COLOR_TABLE_H_
++#define COLOR_MOD_COLOR_TABLE_H_
++
++#include "dc_types.h"
++
++#define NUM_PTS_IN_REGION 16
++#define NUM_REGIONS 32
++#define MAX_HW_POINTS (NUM_PTS_IN_REGION*NUM_REGIONS)
++
++enum table_type {
++ type_pq_table,
++ type_de_pq_table
++};
++
++bool mod_color_is_table_init(enum table_type type);
++
++struct fixed31_32 *mod_color_get_table(enum table_type type);
++
++void mod_color_set_table_init_state(enum table_type type, bool state);
++
++#endif /* COLOR_MOD_COLOR_TABLE_H_ */
+diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+index eb7421e83b865..23a7fa8447e24 100644
+--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
++++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+@@ -324,22 +324,44 @@ static void apply_below_the_range(struct core_freesync *core_freesync,
+
+ /* Choose number of frames to insert based on how close it
+ * can get to the mid point of the variable range.
++ * - Delta for CEIL: delta_from_mid_point_in_us_1
++ * - Delta for FLOOR: delta_from_mid_point_in_us_2
+ */
+- if ((frame_time_in_us / mid_point_frames_ceil) > in_out_vrr->min_duration_in_us &&
+- (delta_from_mid_point_in_us_1 < delta_from_mid_point_in_us_2 ||
+- mid_point_frames_floor < 2)) {
++ if ((last_render_time_in_us / mid_point_frames_ceil) < in_out_vrr->min_duration_in_us) {
++ /* Check for out of range.
++ * If using CEIL produces a value that is out of range,
++ * then we are forced to use FLOOR.
++ */
++ frames_to_insert = mid_point_frames_floor;
++ } else if (mid_point_frames_floor < 2) {
++ /* Check if FLOOR would result in non-LFC. In this case
++ * choose to use CEIL
++ */
++ frames_to_insert = mid_point_frames_ceil;
++ } else if (delta_from_mid_point_in_us_1 < delta_from_mid_point_in_us_2) {
++ /* If choosing CEIL results in a frame duration that is
++ * closer to the mid point of the range.
++ * Choose CEIL
++ */
+ frames_to_insert = mid_point_frames_ceil;
+- delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_2 -
+- delta_from_mid_point_in_us_1;
+ } else {
++ /* If choosing FLOOR results in a frame duration that is
++ * closer to the mid point of the range.
++ * Choose FLOOR
++ */
+ frames_to_insert = mid_point_frames_floor;
+- delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_1 -
+- delta_from_mid_point_in_us_2;
+ }
+
+ /* Prefer current frame multiplier when BTR is enabled unless it drifts
+ * too far from the midpoint
+ */
++ if (delta_from_mid_point_in_us_1 < delta_from_mid_point_in_us_2) {
++ delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_2 -
++ delta_from_mid_point_in_us_1;
++ } else {
++ delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_1 -
++ delta_from_mid_point_in_us_2;
++ }
+ if (in_out_vrr->btr.frames_to_insert != 0 &&
+ delta_from_mid_point_delta_in_us < BTR_DRIFT_MARGIN) {
+ if (((last_render_time_in_us / in_out_vrr->btr.frames_to_insert) <
+diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
+index c9cfe90a29471..9ee8cf8267c88 100644
+--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
+@@ -204,8 +204,7 @@ static int smu10_set_min_deep_sleep_dcefclk(struct pp_hwmgr *hwmgr, uint32_t clo
+ {
+ struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
+
+- if (smu10_data->need_min_deep_sleep_dcefclk &&
+- smu10_data->deep_sleep_dcefclk != clock) {
++ if (clock && smu10_data->deep_sleep_dcefclk != clock) {
+ smu10_data->deep_sleep_dcefclk = clock;
+ smum_send_msg_to_smc_with_parameter(hwmgr,
+ PPSMC_MSG_SetMinDeepSleepDcefclk,
+@@ -219,8 +218,7 @@ static int smu10_set_hard_min_dcefclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t c
+ {
+ struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
+
+- if (smu10_data->dcf_actual_hard_min_freq &&
+- smu10_data->dcf_actual_hard_min_freq != clock) {
++ if (clock && smu10_data->dcf_actual_hard_min_freq != clock) {
+ smu10_data->dcf_actual_hard_min_freq = clock;
+ smum_send_msg_to_smc_with_parameter(hwmgr,
+ PPSMC_MSG_SetHardMinDcefclkByFreq,
+@@ -234,8 +232,7 @@ static int smu10_set_hard_min_fclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t cloc
+ {
+ struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
+
+- if (smu10_data->f_actual_hard_min_freq &&
+- smu10_data->f_actual_hard_min_freq != clock) {
++ if (clock && smu10_data->f_actual_hard_min_freq != clock) {
+ smu10_data->f_actual_hard_min_freq = clock;
+ smum_send_msg_to_smc_with_parameter(hwmgr,
+ PPSMC_MSG_SetHardMinFclkByFreq,
+diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
+index 7783c7fd7ccb0..eff87c8968380 100644
+--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
+@@ -363,17 +363,19 @@ int vega10_thermal_get_temperature(struct pp_hwmgr *hwmgr)
+ static int vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
+ struct PP_TemperatureRange *range)
+ {
++ struct phm_ppt_v2_information *pp_table_info =
++ (struct phm_ppt_v2_information *)(hwmgr->pptable);
++ struct phm_tdp_table *tdp_table = pp_table_info->tdp_table;
+ struct amdgpu_device *adev = hwmgr->adev;
+- int low = VEGA10_THERMAL_MINIMUM_ALERT_TEMP *
+- PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+- int high = VEGA10_THERMAL_MAXIMUM_ALERT_TEMP *
+- PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
++ int low = VEGA10_THERMAL_MINIMUM_ALERT_TEMP;
++ int high = VEGA10_THERMAL_MAXIMUM_ALERT_TEMP;
+ uint32_t val;
+
+- if (low < range->min)
+- low = range->min;
+- if (high > range->max)
+- high = range->max;
++ /* compare them in unit celsius degree */
++ if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
++ low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
++ if (high > tdp_table->usSoftwareShutdownTemp)
++ high = tdp_table->usSoftwareShutdownTemp;
+
+ if (low > high)
+ return -EINVAL;
+@@ -382,8 +384,8 @@ static int vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
+
+ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
+ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
+- val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
+- val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
++ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
++ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
+ val &= (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK) &
+ (~THM_THERMAL_INT_CTRL__THERM_INTH_MASK_MASK) &
+ (~THM_THERMAL_INT_CTRL__THERM_INTL_MASK_MASK);
+diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_thermal.c
+index c85806a6f62e3..650623106ceba 100644
+--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_thermal.c
++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_thermal.c
+@@ -170,17 +170,18 @@ int vega12_thermal_get_temperature(struct pp_hwmgr *hwmgr)
+ static int vega12_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
+ struct PP_TemperatureRange *range)
+ {
++ struct phm_ppt_v3_information *pptable_information =
++ (struct phm_ppt_v3_information *)hwmgr->pptable;
+ struct amdgpu_device *adev = hwmgr->adev;
+- int low = VEGA12_THERMAL_MINIMUM_ALERT_TEMP *
+- PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+- int high = VEGA12_THERMAL_MAXIMUM_ALERT_TEMP *
+- PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
++ int low = VEGA12_THERMAL_MINIMUM_ALERT_TEMP;
++ int high = VEGA12_THERMAL_MAXIMUM_ALERT_TEMP;
+ uint32_t val;
+
+- if (low < range->min)
+- low = range->min;
+- if (high > range->max)
+- high = range->max;
++ /* compare them in unit celsius degree */
++ if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
++ low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
++ if (high > pptable_information->us_software_shutdown_temp)
++ high = pptable_information->us_software_shutdown_temp;
+
+ if (low > high)
+ return -EINVAL;
+@@ -189,8 +190,8 @@ static int vega12_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
+
+ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
+ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
+- val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
+- val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
++ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
++ val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
+ val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
+
+ WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL, val);
+diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+index 9ff470f1b826c..9bd2874a122b4 100644
+--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+@@ -979,10 +979,7 @@ static int vega20_disable_all_smu_features(struct pp_hwmgr *hwmgr)
+ {
+ struct vega20_hwmgr *data =
+ (struct vega20_hwmgr *)(hwmgr->backend);
+- uint64_t features_enabled;
+- int i;
+- bool enabled;
+- int ret = 0;
++ int i, ret = 0;
+
+ PP_ASSERT_WITH_CODE((ret = smum_send_msg_to_smc(hwmgr,
+ PPSMC_MSG_DisableAllSmuFeatures,
+@@ -990,17 +987,8 @@ static int vega20_disable_all_smu_features(struct pp_hwmgr *hwmgr)
+ "[DisableAllSMUFeatures] Failed to disable all smu features!",
+ return ret);
+
+- ret = vega20_get_enabled_smc_features(hwmgr, &features_enabled);
+- PP_ASSERT_WITH_CODE(!ret,
+- "[DisableAllSMUFeatures] Failed to get enabled smc features!",
+- return ret);
+-
+- for (i = 0; i < GNLD_FEATURES_MAX; i++) {
+- enabled = (features_enabled & data->smu_features[i].smu_feature_bitmap) ?
+- true : false;
+- data->smu_features[i].enabled = enabled;
+- data->smu_features[i].supported = enabled;
+- }
++ for (i = 0; i < GNLD_FEATURES_MAX; i++)
++ data->smu_features[i].enabled = 0;
+
+ return 0;
+ }
+@@ -1652,12 +1640,6 @@ static void vega20_init_powergate_state(struct pp_hwmgr *hwmgr)
+
+ data->uvd_power_gated = true;
+ data->vce_power_gated = true;
+-
+- if (data->smu_features[GNLD_DPM_UVD].enabled)
+- data->uvd_power_gated = false;
+-
+- if (data->smu_features[GNLD_DPM_VCE].enabled)
+- data->vce_power_gated = false;
+ }
+
+ static int vega20_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
+@@ -3230,10 +3212,11 @@ static int vega20_get_ppfeature_status(struct pp_hwmgr *hwmgr, char *buf)
+
+ static int vega20_set_ppfeature_status(struct pp_hwmgr *hwmgr, uint64_t new_ppfeature_masks)
+ {
+- uint64_t features_enabled;
+- uint64_t features_to_enable;
+- uint64_t features_to_disable;
+- int ret = 0;
++ struct vega20_hwmgr *data =
++ (struct vega20_hwmgr *)(hwmgr->backend);
++ uint64_t features_enabled, features_to_enable, features_to_disable;
++ int i, ret = 0;
++ bool enabled;
+
+ if (new_ppfeature_masks >= (1ULL << GNLD_FEATURES_MAX))
+ return -EINVAL;
+@@ -3262,6 +3245,17 @@ static int vega20_set_ppfeature_status(struct pp_hwmgr *hwmgr, uint64_t new_ppfe
+ return ret;
+ }
+
++ /* Update the cached feature enablement state */
++ ret = vega20_get_enabled_smc_features(hwmgr, &features_enabled);
++ if (ret)
++ return ret;
++
++ for (i = 0; i < GNLD_FEATURES_MAX; i++) {
++ enabled = (features_enabled & data->smu_features[i].smu_feature_bitmap) ?
++ true : false;
++ data->smu_features[i].enabled = enabled;
++ }
++
+ return 0;
+ }
+
+diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c
+index 7add2f60f49c4..364162ddaa9c6 100644
+--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c
++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c
+@@ -240,17 +240,18 @@ int vega20_thermal_get_temperature(struct pp_hwmgr *hwmgr)
+ static int vega20_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
+ struct PP_TemperatureRange *range)
+ {
++ struct phm_ppt_v3_information *pptable_information =
++ (struct phm_ppt_v3_information *)hwmgr->pptable;
+ struct amdgpu_device *adev = hwmgr->adev;
+- int low = VEGA20_THERMAL_MINIMUM_ALERT_TEMP *
+- PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+- int high = VEGA20_THERMAL_MAXIMUM_ALERT_TEMP *
+- PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
++ int low = VEGA20_THERMAL_MINIMUM_ALERT_TEMP;
++ int high = VEGA20_THERMAL_MAXIMUM_ALERT_TEMP;
+ uint32_t val;
+
+- if (low < range->min)
+- low = range->min;
+- if (high > range->max)
+- high = range->max;
++ /* compare them in unit celsius degree */
++ if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
++ low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
++ if (high > pptable_information->us_software_shutdown_temp)
++ high = pptable_information->us_software_shutdown_temp;
+
+ if (low > high)
+ return -EINVAL;
+@@ -259,8 +260,8 @@ static int vega20_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
+
+ val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
+ val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
+- val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
+- val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
++ val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
++ val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
+ val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
+
+ WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL, val);
+diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+index 56bd938961eee..f33418d6e1a08 100644
+--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
++++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+@@ -492,10 +492,8 @@ static void komeda_crtc_reset(struct drm_crtc *crtc)
+ crtc->state = NULL;
+
+ state = kzalloc(sizeof(*state), GFP_KERNEL);
+- if (state) {
+- crtc->state = &state->base;
+- crtc->state->crtc = crtc;
+- }
++ if (state)
++ __drm_atomic_helper_crtc_reset(crtc, &state->base);
+ }
+
+ static struct drm_crtc_state *
+@@ -616,7 +614,6 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms,
+ return err;
+
+ drm_crtc_helper_add(crtc, &komeda_crtc_helper_funcs);
+- drm_crtc_vblank_reset(crtc);
+
+ crtc->port = kcrtc->master->of_output_port;
+
+diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
+index def8c9ffafcaf..a2a10bfbccac4 100644
+--- a/drivers/gpu/drm/arm/malidp_drv.c
++++ b/drivers/gpu/drm/arm/malidp_drv.c
+@@ -870,7 +870,6 @@ static int malidp_bind(struct device *dev)
+ drm->irq_enabled = true;
+
+ ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
+- drm_crtc_vblank_reset(&malidp->crtc);
+ if (ret < 0) {
+ DRM_ERROR("failed to initialise vblank\n");
+ goto vblank_fail;
+diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+index 10985134ce0ba..ce246b96330b7 100644
+--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
++++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+@@ -411,10 +411,8 @@ static void atmel_hlcdc_crtc_reset(struct drm_crtc *crtc)
+ }
+
+ state = kzalloc(sizeof(*state), GFP_KERNEL);
+- if (state) {
+- crtc->state = &state->base;
+- crtc->state->crtc = crtc;
+- }
++ if (state)
++ __drm_atomic_helper_crtc_reset(crtc, &state->base);
+ }
+
+ static struct drm_crtc_state *
+@@ -528,7 +526,6 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)
+ }
+
+ drm_crtc_helper_add(&crtc->base, &lcdc_crtc_helper_funcs);
+- drm_crtc_vblank_reset(&crtc->base);
+
+ drm_mode_crtc_set_gamma_size(&crtc->base, ATMEL_HLCDC_CLUT_SIZE);
+ drm_crtc_enable_color_mgmt(&crtc->base, 0, false,
+diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
+index 85d163f16801f..b78e142a5620c 100644
+--- a/drivers/gpu/drm/drm_atomic_helper.c
++++ b/drivers/gpu/drm/drm_atomic_helper.c
+@@ -34,6 +34,7 @@
+ #include <drm/drm_bridge.h>
+ #include <drm/drm_damage_helper.h>
+ #include <drm/drm_device.h>
++#include <drm/drm_drv.h>
+ #include <drm/drm_plane_helper.h>
+ #include <drm/drm_print.h>
+ #include <drm/drm_self_refresh_helper.h>
+@@ -3105,7 +3106,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)
+ if (ret)
+ DRM_ERROR("Disabling all crtc's during unload failed with %i\n", ret);
+
+- DRM_MODESET_LOCK_ALL_END(ctx, ret);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
+ }
+ EXPORT_SYMBOL(drm_atomic_helper_shutdown);
+
+@@ -3245,7 +3246,7 @@ struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
+ }
+
+ unlock:
+- DRM_MODESET_LOCK_ALL_END(ctx, err);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
+ if (err)
+ return ERR_PTR(err);
+
+@@ -3326,7 +3327,7 @@ int drm_atomic_helper_resume(struct drm_device *dev,
+
+ err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
+
+- DRM_MODESET_LOCK_ALL_END(ctx, err);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
+ drm_atomic_state_put(state);
+
+ return err;
+diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
+index 8fce6a115dfe3..9ad74045158ec 100644
+--- a/drivers/gpu/drm/drm_atomic_state_helper.c
++++ b/drivers/gpu/drm/drm_atomic_state_helper.c
+@@ -32,6 +32,7 @@
+ #include <drm/drm_device.h>
+ #include <drm/drm_plane.h>
+ #include <drm/drm_print.h>
++#include <drm/drm_vblank.h>
+ #include <drm/drm_writeback.h>
+
+ #include <linux/slab.h>
+@@ -93,6 +94,9 @@ __drm_atomic_helper_crtc_reset(struct drm_crtc *crtc,
+ if (crtc_state)
+ __drm_atomic_helper_crtc_state_reset(crtc_state, crtc);
+
++ if (drm_dev_has_vblank(crtc->dev))
++ drm_crtc_vblank_reset(crtc);
++
+ crtc->state = crtc_state;
+ }
+ EXPORT_SYMBOL(__drm_atomic_helper_crtc_reset);
+diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
+index c93123ff7c218..138ff34b31db5 100644
+--- a/drivers/gpu/drm/drm_color_mgmt.c
++++ b/drivers/gpu/drm/drm_color_mgmt.c
+@@ -294,7 +294,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
+ crtc->gamma_size, &ctx);
+
+ out:
+- DRM_MODESET_LOCK_ALL_END(ctx, ret);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
+ return ret;
+
+ }
+diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
+index 4936e1080e417..eb1c33e5d0f49 100644
+--- a/drivers/gpu/drm/drm_crtc.c
++++ b/drivers/gpu/drm/drm_crtc.c
+@@ -561,7 +561,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
+ if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
+ return -EACCES;
+
+- mutex_lock(&crtc->dev->mode_config.mutex);
+ DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx,
+ DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret);
+
+@@ -728,8 +727,7 @@ out:
+ fb = NULL;
+ mode = NULL;
+
+- DRM_MODESET_LOCK_ALL_END(ctx, ret);
+- mutex_unlock(&crtc->dev->mode_config.mutex);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
+
+ return ret;
+ }
+diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
+index ffbd754a53825..954cd69117826 100644
+--- a/drivers/gpu/drm/drm_dp_mst_topology.c
++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
+@@ -4993,8 +4993,8 @@ int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm
+
+ crtc = conn_state->crtc;
+
+- if (WARN_ON(!crtc))
+- return -EINVAL;
++ if (!crtc)
++ continue;
+
+ if (!drm_dp_mst_dsc_aux_for_port(pos->port))
+ continue;
+diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
+index 901b078abf40c..db05f386a709e 100644
+--- a/drivers/gpu/drm/drm_mode_object.c
++++ b/drivers/gpu/drm/drm_mode_object.c
+@@ -428,7 +428,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
+ out_unref:
+ drm_mode_object_put(obj);
+ out:
+- DRM_MODESET_LOCK_ALL_END(ctx, ret);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
+ return ret;
+ }
+
+@@ -470,7 +470,7 @@ static int set_property_legacy(struct drm_mode_object *obj,
+ break;
+ }
+ drm_property_change_valid_put(prop, ref);
+- DRM_MODESET_LOCK_ALL_END(ctx, ret);
++ DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
+
+ return ret;
+ }
+diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
+index 4af173ced3277..fdbafc2b81998 100644
+--- a/drivers/gpu/drm/drm_plane.c
++++ b/drivers/gpu/drm/drm_plane.c
+@@ -791,7 +791,7 @@ static int setplane_internal(struct drm_plane *plane,
+ crtc_x, crtc_y, crtc_w, crtc_h,
+ src_x, src_y, src_w, src_h, &ctx);
+
+- DRM_MODESET_LOCK_ALL_END(ctx, ret);
++ DRM_MODESET_LOCK_ALL_END(plane->dev, ctx, ret);
+
+ return ret;
+ }
+diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+index 4a512b062df8f..bb9a37d3fcff6 100644
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -337,9 +337,16 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
+
+ gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL);
+ gpu->identity.revision = gpu_read(gpu, VIVS_HI_CHIP_REV);
+- gpu->identity.product_id = gpu_read(gpu, VIVS_HI_CHIP_PRODUCT_ID);
+ gpu->identity.customer_id = gpu_read(gpu, VIVS_HI_CHIP_CUSTOMER_ID);
+- gpu->identity.eco_id = gpu_read(gpu, VIVS_HI_CHIP_ECO_ID);
++
++ /*
++ * Reading these two registers on GC600 rev 0x19 result in a
++ * unhandled fault: external abort on non-linefetch
++ */
++ if (!etnaviv_is_model_rev(gpu, GC600, 0x19)) {
++ gpu->identity.product_id = gpu_read(gpu, VIVS_HI_CHIP_PRODUCT_ID);
++ gpu->identity.eco_id = gpu_read(gpu, VIVS_HI_CHIP_ECO_ID);
++ }
+
+ /*
+ * !!!! HACK ALERT !!!!
+diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+index 4e3e95dce6d87..cd46c882269cc 100644
+--- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+@@ -89,12 +89,15 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
+ u32 dma_addr;
+ int change;
+
++ /* block scheduler */
++ drm_sched_stop(&gpu->sched, sched_job);
++
+ /*
+ * If the GPU managed to complete this jobs fence, the timout is
+ * spurious. Bail out.
+ */
+ if (dma_fence_is_signaled(submit->out_fence))
+- return;
++ goto out_no_timeout;
+
+ /*
+ * If the GPU is still making forward progress on the front-end (which
+@@ -105,12 +108,9 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
+ change = dma_addr - gpu->hangcheck_dma_addr;
+ if (change < 0 || change > 16) {
+ gpu->hangcheck_dma_addr = dma_addr;
+- return;
++ goto out_no_timeout;
+ }
+
+- /* block scheduler */
+- drm_sched_stop(&gpu->sched, sched_job);
+-
+ if(sched_job)
+ drm_sched_increase_karma(sched_job);
+
+@@ -120,6 +120,7 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
+
+ drm_sched_resubmit_jobs(&gpu->sched);
+
++out_no_timeout:
+ /* restart scheduler after GPU is usable again */
+ drm_sched_start(&gpu->sched, true);
+ }
+diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
+index 372354d33f552..5ac4a999f05a6 100644
+--- a/drivers/gpu/drm/i915/i915_cmd_parser.c
++++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
+@@ -1204,6 +1204,12 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj,
+ return dst;
+ }
+
++static inline bool cmd_desc_is(const struct drm_i915_cmd_descriptor * const desc,
++ const u32 cmd)
++{
++ return desc->cmd.value == (cmd & desc->cmd.mask);
++}
++
+ static bool check_cmd(const struct intel_engine_cs *engine,
+ const struct drm_i915_cmd_descriptor *desc,
+ const u32 *cmd, u32 length)
+@@ -1242,19 +1248,19 @@ static bool check_cmd(const struct intel_engine_cs *engine,
+ * allowed mask/value pair given in the whitelist entry.
+ */
+ if (reg->mask) {
+- if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
++ if (cmd_desc_is(desc, MI_LOAD_REGISTER_MEM)) {
+ DRM_DEBUG("CMD: Rejected LRM to masked register 0x%08X\n",
+ reg_addr);
+ return false;
+ }
+
+- if (desc->cmd.value == MI_LOAD_REGISTER_REG) {
++ if (cmd_desc_is(desc, MI_LOAD_REGISTER_REG)) {
+ DRM_DEBUG("CMD: Rejected LRR to masked register 0x%08X\n",
+ reg_addr);
+ return false;
+ }
+
+- if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1) &&
++ if (cmd_desc_is(desc, MI_LOAD_REGISTER_IMM(1)) &&
+ (offset + 2 > length ||
+ (cmd[offset + 1] & reg->mask) != reg->value)) {
+ DRM_DEBUG("CMD: Rejected LRI to masked register 0x%08X\n",
+@@ -1478,7 +1484,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
+ break;
+ }
+
+- if (desc->cmd.value == MI_BATCH_BUFFER_START) {
++ if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) {
+ ret = check_bbstart(cmd, offset, length, batch_length,
+ batch_addr, shadow_addr,
+ jump_whitelist);
+diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+index 5db06b5909438..e7b39f3ca33dc 100644
+--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
++++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+@@ -396,7 +396,7 @@ int adreno_hw_init(struct msm_gpu *gpu)
+ ring->next = ring->start;
+
+ /* reset completed fence seqno: */
+- ring->memptrs->fence = ring->seqno;
++ ring->memptrs->fence = ring->fctx->completed_fence;
+ ring->memptrs->rptr = 0;
+ }
+
+diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+index b5fed67c4651f..0c54b7bc19010 100644
+--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
++++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+@@ -1117,8 +1117,6 @@ static void mdp5_crtc_reset(struct drm_crtc *crtc)
+ mdp5_crtc_destroy_state(crtc, crtc->state);
+
+ __drm_atomic_helper_crtc_reset(crtc, &mdp5_cstate->base);
+-
+- drm_crtc_vblank_reset(crtc);
+ }
+
+ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
+diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
+index 800b7757252e3..d2c2d102e7329 100644
+--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
++++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
+@@ -2160,8 +2160,10 @@ nv50_disp_atomic_commit(struct drm_device *dev,
+ int ret, i;
+
+ 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;
++ }
+
+ ret = drm_atomic_helper_setup_commit(state, nonblock);
+ if (ret)
+diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
+index 1b383ae0248f3..ef8ddbe445812 100644
+--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
++++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
+@@ -572,8 +572,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 d5c23d1c20d88..44e515bbbb444 100644
+--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+@@ -189,8 +189,10 @@ nouveau_fbcon_open(struct fb_info *info, int user)
+ struct nouveau_fbdev *fbcon = info->par;
+ struct nouveau_drm *drm = nouveau_drm(fbcon->helper.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/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
+index fce7e944a280b..6d40914675dad 100644
+--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
++++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
+@@ -697,14 +697,16 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
+
+ static void omap_crtc_reset(struct drm_crtc *crtc)
+ {
++ struct omap_crtc_state *state;
++
+ if (crtc->state)
+ __drm_atomic_helper_crtc_destroy_state(crtc->state);
+
+ kfree(crtc->state);
+- crtc->state = kzalloc(sizeof(struct omap_crtc_state), GFP_KERNEL);
+
+- if (crtc->state)
+- crtc->state->crtc = crtc;
++ state = kzalloc(sizeof(*state), GFP_KERNEL);
++ if (state)
++ __drm_atomic_helper_crtc_reset(crtc, &state->base);
+ }
+
+ static struct drm_crtc_state *
+diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
+index cdafd7ef1c320..cc4d754ff8c02 100644
+--- a/drivers/gpu/drm/omapdrm/omap_drv.c
++++ b/drivers/gpu/drm/omapdrm/omap_drv.c
+@@ -595,7 +595,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
+ {
+ const struct soc_device_attribute *soc;
+ struct drm_device *ddev;
+- unsigned int i;
+ int ret;
+
+ DBG("%s", dev_name(dev));
+@@ -642,9 +641,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
+ goto err_cleanup_modeset;
+ }
+
+- for (i = 0; i < priv->num_pipes; i++)
+- drm_crtc_vblank_off(priv->pipes[i].crtc);
+-
+ omap_fbdev_init(ddev);
+
+ drm_kms_helper_poll_init(ddev);
+diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
+index fe12d9d91d7a5..e308344344425 100644
+--- a/drivers/gpu/drm/radeon/radeon_connectors.c
++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
+@@ -879,8 +879,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) {
+@@ -1025,8 +1027,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);
+@@ -1163,8 +1167,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);
+@@ -1247,8 +1253,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) {
+@@ -1657,8 +1665,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/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+index d73e88ddecd0f..fe86a3e677571 100644
+--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
++++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+@@ -975,8 +975,7 @@ static void rcar_du_crtc_reset(struct drm_crtc *crtc)
+ state->crc.source = VSP1_DU_CRC_NONE;
+ state->crc.index = 0;
+
+- crtc->state = &state->state;
+- crtc->state->crtc = crtc;
++ __drm_atomic_helper_crtc_reset(crtc, &state->state);
+ }
+
+ static int rcar_du_crtc_enable_vblank(struct drm_crtc *crtc)
+@@ -1271,9 +1270,6 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
+
+ drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+- /* Start with vertical blanking interrupt reporting disabled. */
+- drm_crtc_vblank_off(crtc);
+-
+ /* Register the interrupt handler. */
+ if (rcar_du_has(rcdu, RCAR_DU_FEATURE_CRTC_IRQ_CLOCK)) {
+ /* The IRQ's are associated with the CRTC (sw)index. */
+diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
+index 04d6848d19fcf..da8b9983b7de0 100644
+--- a/drivers/gpu/drm/tegra/dc.c
++++ b/drivers/gpu/drm/tegra/dc.c
+@@ -1169,7 +1169,6 @@ static void tegra_crtc_reset(struct drm_crtc *crtc)
+ tegra_crtc_atomic_destroy_state(crtc, crtc->state);
+
+ __drm_atomic_helper_crtc_reset(crtc, &state->base);
+- drm_crtc_vblank_reset(crtc);
+ }
+
+ static struct drm_crtc_state *
+diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c b/drivers/gpu/drm/tidss/tidss_crtc.c
+index 89a226912de85..4d01c4af61cd0 100644
+--- a/drivers/gpu/drm/tidss/tidss_crtc.c
++++ b/drivers/gpu/drm/tidss/tidss_crtc.c
+@@ -352,8 +352,7 @@ static void tidss_crtc_reset(struct drm_crtc *crtc)
+ return;
+ }
+
+- crtc->state = &tcrtc->base;
+- crtc->state->crtc = crtc;
++ __drm_atomic_helper_crtc_reset(crtc, &tcrtc->base);
+ }
+
+ static struct drm_crtc_state *tidss_crtc_duplicate_state(struct drm_crtc *crtc)
+diff --git a/drivers/gpu/drm/tidss/tidss_kms.c b/drivers/gpu/drm/tidss/tidss_kms.c
+index c0240f7e0b198..eec359f61a06d 100644
+--- a/drivers/gpu/drm/tidss/tidss_kms.c
++++ b/drivers/gpu/drm/tidss/tidss_kms.c
+@@ -253,7 +253,6 @@ static int tidss_dispc_modeset_init(struct tidss_device *tidss)
+ int tidss_modeset_init(struct tidss_device *tidss)
+ {
+ struct drm_device *ddev = &tidss->ddev;
+- unsigned int i;
+ int ret;
+
+ dev_dbg(tidss->dev, "%s\n", __func__);
+@@ -278,10 +277,6 @@ int tidss_modeset_init(struct tidss_device *tidss)
+ if (ret)
+ return ret;
+
+- /* Start with vertical blanking interrupt reporting disabled. */
+- for (i = 0; i < tidss->num_crtcs; ++i)
+- drm_crtc_vblank_reset(tidss->crtcs[i]);
+-
+ drm_mode_config_reset(ddev);
+
+ dev_dbg(tidss->dev, "%s done\n", __func__);
+diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
+index 6ccbd01cd888c..703b5cd517519 100644
+--- a/drivers/gpu/drm/virtio/virtgpu_object.c
++++ b/drivers/gpu/drm/virtio/virtgpu_object.c
+@@ -79,6 +79,7 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo)
+ }
+
+ sg_free_table(shmem->pages);
++ kfree(shmem->pages);
+ shmem->pages = NULL;
+ drm_gem_shmem_unpin(&bo->base.base);
+ }
+diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+index 009f1742bed51..c4017c7a24db6 100644
+--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+@@ -387,8 +387,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
+ ldu->base.is_implicit = true;
+
+ /* Initialize primary plane */
+- vmw_du_plane_reset(primary);
+-
+ ret = drm_universal_plane_init(dev, &ldu->base.primary,
+ 0, &vmw_ldu_plane_funcs,
+ vmw_primary_plane_formats,
+@@ -402,8 +400,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
+ drm_plane_helper_add(primary, &vmw_ldu_primary_plane_helper_funcs);
+
+ /* Initialize cursor plane */
+- vmw_du_plane_reset(cursor);
+-
+ ret = drm_universal_plane_init(dev, &ldu->base.cursor,
+ 0, &vmw_ldu_cursor_funcs,
+ vmw_cursor_plane_formats,
+@@ -417,7 +413,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
+
+ drm_plane_helper_add(cursor, &vmw_ldu_cursor_plane_helper_funcs);
+
+- vmw_du_connector_reset(connector);
+ ret = drm_connector_init(dev, connector, &vmw_legacy_connector_funcs,
+ DRM_MODE_CONNECTOR_VIRTUAL);
+ if (ret) {
+@@ -445,7 +440,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
+ goto err_free_encoder;
+ }
+
+- vmw_du_crtc_reset(crtc);
+ ret = drm_crtc_init_with_planes(dev, crtc, &ldu->base.primary,
+ &ldu->base.cursor,
+ &vmw_legacy_crtc_funcs, NULL);
+@@ -520,6 +514,8 @@ int vmw_kms_ldu_init_display(struct vmw_private *dev_priv)
+
+ dev_priv->active_display_unit = vmw_du_legacy;
+
++ drm_mode_config_reset(dev);
++
+ DRM_INFO("Legacy Display Unit initialized\n");
+
+ return 0;
+diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+index 32a22e4eddb1a..4bf0f5ec4fc2d 100644
+--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+@@ -859,8 +859,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
+ sou->base.is_implicit = false;
+
+ /* Initialize primary plane */
+- vmw_du_plane_reset(primary);
+-
+ ret = drm_universal_plane_init(dev, &sou->base.primary,
+ 0, &vmw_sou_plane_funcs,
+ vmw_primary_plane_formats,
+@@ -875,8 +873,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
+ drm_plane_enable_fb_damage_clips(primary);
+
+ /* Initialize cursor plane */
+- vmw_du_plane_reset(cursor);
+-
+ ret = drm_universal_plane_init(dev, &sou->base.cursor,
+ 0, &vmw_sou_cursor_funcs,
+ vmw_cursor_plane_formats,
+@@ -890,7 +886,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
+
+ drm_plane_helper_add(cursor, &vmw_sou_cursor_plane_helper_funcs);
+
+- vmw_du_connector_reset(connector);
+ ret = drm_connector_init(dev, connector, &vmw_sou_connector_funcs,
+ DRM_MODE_CONNECTOR_VIRTUAL);
+ if (ret) {
+@@ -918,8 +913,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
+ goto err_free_encoder;
+ }
+
+-
+- vmw_du_crtc_reset(crtc);
+ ret = drm_crtc_init_with_planes(dev, crtc, &sou->base.primary,
+ &sou->base.cursor,
+ &vmw_screen_object_crtc_funcs, NULL);
+@@ -973,6 +966,8 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv)
+
+ dev_priv->active_display_unit = vmw_du_screen_object;
+
++ drm_mode_config_reset(dev);
++
+ DRM_INFO("Screen Objects Display Unit initialized\n");
+
+ return 0;
+diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+index 16b3856296889..cf3aafd00837c 100644
+--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+@@ -1738,8 +1738,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
+ stdu->base.is_implicit = false;
+
+ /* Initialize primary plane */
+- vmw_du_plane_reset(primary);
+-
+ ret = drm_universal_plane_init(dev, primary,
+ 0, &vmw_stdu_plane_funcs,
+ vmw_primary_plane_formats,
+@@ -1754,8 +1752,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
+ drm_plane_enable_fb_damage_clips(primary);
+
+ /* Initialize cursor plane */
+- vmw_du_plane_reset(cursor);
+-
+ ret = drm_universal_plane_init(dev, cursor,
+ 0, &vmw_stdu_cursor_funcs,
+ vmw_cursor_plane_formats,
+@@ -1769,8 +1765,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
+
+ drm_plane_helper_add(cursor, &vmw_stdu_cursor_plane_helper_funcs);
+
+- vmw_du_connector_reset(connector);
+-
+ ret = drm_connector_init(dev, connector, &vmw_stdu_connector_funcs,
+ DRM_MODE_CONNECTOR_VIRTUAL);
+ if (ret) {
+@@ -1798,7 +1792,6 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
+ goto err_free_encoder;
+ }
+
+- vmw_du_crtc_reset(crtc);
+ ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary,
+ &stdu->base.cursor,
+ &vmw_stdu_crtc_funcs, NULL);
+@@ -1894,6 +1887,8 @@ int vmw_kms_stdu_init_display(struct vmw_private *dev_priv)
+ }
+ }
+
++ drm_mode_config_reset(dev);
++
+ DRM_INFO("Screen Target Display device initialized\n");
+
+ return 0;
+diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
+index a10643aa89aa5..2ac5a99406d98 100644
+--- a/drivers/gpu/host1x/job.c
++++ b/drivers/gpu/host1x/job.c
+@@ -102,6 +102,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ {
+ struct host1x_client *client = job->client;
+ struct device *dev = client->dev;
++ struct host1x_job_gather *g;
+ struct iommu_domain *domain;
+ unsigned int i;
+ int err;
+@@ -184,7 +185,6 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ }
+
+ for (i = 0; i < job->num_gathers; i++) {
+- struct host1x_job_gather *g = &job->gathers[i];
+ size_t gather_size = 0;
+ struct scatterlist *sg;
+ struct sg_table *sgt;
+@@ -194,6 +194,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ dma_addr_t *phys;
+ unsigned int j;
+
++ g = &job->gathers[i];
+ g->bo = host1x_bo_get(g->bo);
+ if (!g->bo) {
+ err = -EINVAL;
+@@ -213,7 +214,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ sgt = host1x_bo_pin(host->dev, g->bo, phys);
+ if (IS_ERR(sgt)) {
+ err = PTR_ERR(sgt);
+- goto unpin;
++ goto put;
+ }
+
+ if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) {
+@@ -226,7 +227,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ host->iova_end >> shift, true);
+ if (!alloc) {
+ err = -ENOMEM;
+- goto unpin;
++ goto put;
+ }
+
+ err = iommu_map_sg(host->domain,
+@@ -235,7 +236,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ if (err == 0) {
+ __free_iova(&host->iova, alloc);
+ err = -EINVAL;
+- goto unpin;
++ goto put;
+ }
+
+ job->unpins[job->num_unpins].size = gather_size;
+@@ -245,7 +246,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+ DMA_TO_DEVICE);
+ if (!err) {
+ err = -ENOMEM;
+- goto unpin;
++ goto put;
+ }
+
+ job->unpins[job->num_unpins].dir = DMA_TO_DEVICE;
+@@ -263,6 +264,8 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
+
+ return 0;
+
++put:
++ host1x_bo_put(g->bo);
+ unpin:
+ host1x_job_unpin(job);
+ return err;
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
+index 6f370e020feb3..7cfa9785bfbb0 100644
+--- a/drivers/hid/hid-ids.h
++++ b/drivers/hid/hid-ids.h
+@@ -773,6 +773,7 @@
+ #define USB_DEVICE_ID_LOGITECH_G27_WHEEL 0xc29b
+ #define USB_DEVICE_ID_LOGITECH_WII_WHEEL 0xc29c
+ #define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a
++#define USB_DEVICE_ID_LOGITECH_GROUP_AUDIO 0x0882
+ #define USB_DEVICE_ID_S510_RECEIVER 0xc50c
+ #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
+ #define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
+diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
+index 934fc0a798d4d..c242150d35a3a 100644
+--- a/drivers/hid/hid-quirks.c
++++ b/drivers/hid/hid-quirks.c
+@@ -179,6 +179,7 @@ static const struct hid_device_id hid_quirks[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD2, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS), HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD), HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE), HID_QUIRK_MULTI_INPUT },
++ { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_GROUP_AUDIO), HID_QUIRK_NOGET },
+
+ { 0 }
+ };
+diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
+index 294c84e136d72..dbd04492825d4 100644
+--- a/drivers/hid/i2c-hid/i2c-hid-core.c
++++ b/drivers/hid/i2c-hid/i2c-hid-core.c
+@@ -420,6 +420,19 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
+ dev_err(&client->dev, "failed to change power setting.\n");
+
+ set_pwr_exit:
++
++ /*
++ * The HID over I2C specification states that if a DEVICE needs time
++ * after the PWR_ON request, it should utilise CLOCK stretching.
++ * However, it has been observered that the Windows driver provides a
++ * 1ms sleep between the PWR_ON and RESET requests.
++ * According to Goodix Windows even waits 60 ms after (other?)
++ * PWR_ON requests. Testing has confirmed that several devices
++ * will not work properly without a delay after a PWR_ON request.
++ */
++ if (!ret && power_state == I2C_HID_PWR_ON)
++ msleep(60);
++
+ return ret;
+ }
+
+@@ -441,15 +454,6 @@ static int i2c_hid_hwreset(struct i2c_client *client)
+ if (ret)
+ goto out_unlock;
+
+- /*
+- * The HID over I2C specification states that if a DEVICE needs time
+- * after the PWR_ON request, it should utilise CLOCK stretching.
+- * However, it has been observered that the Windows driver provides a
+- * 1ms sleep between the PWR_ON and RESET requests and that some devices
+- * rely on this.
+- */
+- usleep_range(1000, 5000);
+-
+ i2c_hid_dbg(ihid, "resetting...\n");
+
+ ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
+diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
+index 4140dea693e90..4f97e6c120595 100644
+--- a/drivers/hid/usbhid/hiddev.c
++++ b/drivers/hid/usbhid/hiddev.c
+@@ -519,12 +519,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/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
+index 2137bc65829d3..35337922aa1bd 100644
+--- a/drivers/hwmon/gsc-hwmon.c
++++ b/drivers/hwmon/gsc-hwmon.c
+@@ -172,6 +172,7 @@ gsc_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
+ case mode_temperature:
+ if (tmp > 0x8000)
+ tmp -= 0xffff;
++ tmp *= 100; /* convert to millidegrees celsius */
+ break;
+ case mode_voltage_raw:
+ tmp = clamp_val(tmp, 0, BIT(GSC_HWMON_RESOLUTION));
+diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
+index b0425694f7022..242ff8bee78dd 100644
+--- a/drivers/hwmon/nct7904.c
++++ b/drivers/hwmon/nct7904.c
+@@ -231,7 +231,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
+ if (ret < 0)
+ return ret;
+ cnt = ((ret & 0xff00) >> 3) | (ret & 0x1f);
+- if (cnt == 0x1fff)
++ if (cnt == 0 || cnt == 0x1fff)
+ rpm = 0;
+ else
+ rpm = 1350000 / cnt;
+@@ -243,7 +243,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
+ if (ret < 0)
+ return ret;
+ cnt = ((ret & 0xff00) >> 3) | (ret & 0x1f);
+- if (cnt == 0x1fff)
++ if (cnt == 0 || cnt == 0x1fff)
+ rpm = 0;
+ else
+ rpm = 1350000 / cnt;
+diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
+index fea644921a768..f206e28af5831 100644
+--- a/drivers/i2c/busses/i2c-i801.c
++++ b/drivers/i2c/busses/i2c-i801.c
+@@ -67,6 +67,7 @@
+ * Comet Lake-H (PCH) 0x06a3 32 hard yes yes yes
+ * Elkhart Lake (PCH) 0x4b23 32 hard yes yes yes
+ * Tiger Lake-LP (PCH) 0xa0a3 32 hard yes yes yes
++ * Tiger Lake-H (PCH) 0x43a3 32 hard yes yes yes
+ * Jasper Lake (SOC) 0x4da3 32 hard yes yes yes
+ * Comet Lake-V (PCH) 0xa3a3 32 hard yes yes yes
+ *
+@@ -221,6 +222,7 @@
+ #define PCI_DEVICE_ID_INTEL_GEMINILAKE_SMBUS 0x31d4
+ #define PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS 0x34a3
+ #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30
++#define PCI_DEVICE_ID_INTEL_TIGERLAKE_H_SMBUS 0x43a3
+ #define PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS 0x4b23
+ #define PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS 0x4da3
+ #define PCI_DEVICE_ID_INTEL_BROXTON_SMBUS 0x5ad4
+@@ -1074,6 +1076,7 @@ static const struct pci_device_id i801_ids[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_V_SMBUS) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS) },
++ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TIGERLAKE_H_SMBUS) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS) },
+ { 0, }
+ };
+@@ -1748,6 +1751,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
+ case PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS:
+ case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS:
+ case PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS:
++ case PCI_DEVICE_ID_INTEL_TIGERLAKE_H_SMBUS:
+ case PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS:
+ priv->features |= FEATURE_BLOCK_PROC;
+ priv->features |= FEATURE_I2C_BLOCK_READ;
+diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
+index 9e883474db8ce..c7c543483b08c 100644
+--- a/drivers/i2c/busses/i2c-rcar.c
++++ b/drivers/i2c/busses/i2c-rcar.c
+@@ -590,6 +590,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/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
+index 26f03a14a4781..4f09d4c318287 100644
+--- a/drivers/i2c/i2c-core-base.c
++++ b/drivers/i2c/i2c-core-base.c
+@@ -354,7 +354,7 @@ static int i2c_device_probe(struct device *dev)
+ * or ACPI ID table is supplied for the probing device.
+ */
+ if (!driver->id_table &&
+- !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
++ !acpi_driver_match_device(dev, dev->driver) &&
+ !i2c_of_match_device(dev->driver->of_match_table, client)) {
+ status = -ENODEV;
+ goto put_sync_adapter;
+diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
+index 4959f5df21bd0..5141d49a046ba 100644
+--- a/drivers/iommu/dma-iommu.c
++++ b/drivers/iommu/dma-iommu.c
+@@ -1035,8 +1035,8 @@ static void *iommu_dma_alloc(struct device *dev, size_t size,
+
+ if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
+ !gfpflags_allow_blocking(gfp) && !coherent)
+- cpu_addr = dma_alloc_from_pool(dev, PAGE_ALIGN(size), &page,
+- gfp);
++ page = dma_alloc_from_pool(dev, PAGE_ALIGN(size), &cpu_addr,
++ gfp, NULL);
+ else
+ cpu_addr = iommu_dma_alloc_pages(dev, size, &page, gfp, attrs);
+ if (!cpu_addr)
+diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
+index 49fc01f2a28d4..45a251da54537 100644
+--- a/drivers/iommu/iova.c
++++ b/drivers/iommu/iova.c
+@@ -811,7 +811,9 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
+ for (i = 0 ; i < mag->size; ++i) {
+ struct iova *iova = private_find_iova(iovad, mag->pfns[i]);
+
+- BUG_ON(!iova);
++ if (WARN_ON(!iova))
++ continue;
++
+ private_free_iova(iovad, iova);
+ }
+
+diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
+index faa8482c8246d..4dd8a5532f893 100644
+--- a/drivers/irqchip/irq-stm32-exti.c
++++ b/drivers/irqchip/irq-stm32-exti.c
+@@ -431,6 +431,16 @@ static void stm32_irq_ack(struct irq_data *d)
+ irq_gc_unlock(gc);
+ }
+
++/* directly set the target bit without reading first. */
++static inline void stm32_exti_write_bit(struct irq_data *d, u32 reg)
++{
++ struct stm32_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
++ void __iomem *base = chip_data->host_data->base;
++ u32 val = BIT(d->hwirq % IRQS_PER_BANK);
++
++ writel_relaxed(val, base + reg);
++}
++
+ static inline u32 stm32_exti_set_bit(struct irq_data *d, u32 reg)
+ {
+ struct stm32_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
+@@ -464,9 +474,9 @@ static void stm32_exti_h_eoi(struct irq_data *d)
+
+ raw_spin_lock(&chip_data->rlock);
+
+- stm32_exti_set_bit(d, stm32_bank->rpr_ofst);
++ stm32_exti_write_bit(d, stm32_bank->rpr_ofst);
+ if (stm32_bank->fpr_ofst != UNDEF_REG)
+- stm32_exti_set_bit(d, stm32_bank->fpr_ofst);
++ stm32_exti_write_bit(d, stm32_bank->fpr_ofst);
+
+ raw_spin_unlock(&chip_data->rlock);
+
+diff --git a/drivers/media/cec/core/cec-api.c b/drivers/media/cec/core/cec-api.c
+index 17d1cb2e5f976..f922a2196b2b7 100644
+--- a/drivers/media/cec/core/cec-api.c
++++ b/drivers/media/cec/core/cec-api.c
+@@ -147,7 +147,13 @@ static long cec_adap_g_log_addrs(struct cec_adapter *adap,
+ struct cec_log_addrs log_addrs;
+
+ mutex_lock(&adap->lock);
+- log_addrs = adap->log_addrs;
++ /*
++ * We use memcpy here instead of assignment since there is a
++ * hole at the end of struct cec_log_addrs that an assignment
++ * might ignore. So when we do copy_to_user() we could leak
++ * one byte of memory.
++ */
++ memcpy(&log_addrs, &adap->log_addrs, sizeof(log_addrs));
+ if (!adap->is_configured)
+ memset(log_addrs.log_addr, CEC_LOG_ADDR_INVALID,
+ sizeof(log_addrs.log_addr));
+diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
+index f7678e5a5d879..157a0ed0a8856 100644
+--- a/drivers/media/i2c/imx290.c
++++ b/drivers/media/i2c/imx290.c
+@@ -628,7 +628,7 @@ static int imx290_power_on(struct device *dev)
+ }
+
+ usleep_range(1, 2);
+- gpiod_set_value_cansleep(imx290->rst_gpio, 1);
++ gpiod_set_value_cansleep(imx290->rst_gpio, 0);
+ usleep_range(30000, 31000);
+
+ return 0;
+@@ -641,7 +641,7 @@ static int imx290_power_off(struct device *dev)
+ struct imx290 *imx290 = to_imx290(sd);
+
+ clk_disable_unprepare(imx290->xclk);
+- gpiod_set_value_cansleep(imx290->rst_gpio, 0);
++ gpiod_set_value_cansleep(imx290->rst_gpio, 1);
+ regulator_bulk_disable(IMX290_NUM_SUPPLIES, imx290->supplies);
+
+ return 0;
+@@ -760,7 +760,8 @@ static int imx290_probe(struct i2c_client *client)
+ goto free_err;
+ }
+
+- imx290->rst_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS);
++ imx290->rst_gpio = devm_gpiod_get_optional(dev, "reset",
++ GPIOD_OUT_HIGH);
+ if (IS_ERR(imx290->rst_gpio)) {
+ dev_err(dev, "Cannot get reset gpio\n");
+ ret = PTR_ERR(imx290->rst_gpio);
+diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
+index d0cdee1c6eb0b..bf36b1e22b635 100644
+--- a/drivers/media/pci/ttpci/av7110.c
++++ b/drivers/media/pci/ttpci/av7110.c
+@@ -406,14 +406,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 d9ec439faefa6..72a0e94e2e21a 100644
+--- a/drivers/media/platform/davinci/vpif_capture.c
++++ b/drivers/media/platform/davinci/vpif_capture.c
+@@ -1482,8 +1482,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/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
+index 046222684b8b2..9a58032f818ae 100644
+--- a/drivers/mfd/intel-lpss-pci.c
++++ b/drivers/mfd/intel-lpss-pci.c
+@@ -201,6 +201,9 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
+ { PCI_VDEVICE(INTEL, 0x1ac4), (kernel_ulong_t)&bxt_info },
+ { PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info },
+ { PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info },
++ /* EBG */
++ { PCI_VDEVICE(INTEL, 0x1bad), (kernel_ulong_t)&bxt_uart_info },
++ { PCI_VDEVICE(INTEL, 0x1bae), (kernel_ulong_t)&bxt_uart_info },
+ /* GLK */
+ { PCI_VDEVICE(INTEL, 0x31ac), (kernel_ulong_t)&glk_i2c_info },
+ { PCI_VDEVICE(INTEL, 0x31ae), (kernel_ulong_t)&glk_i2c_info },
+@@ -230,6 +233,22 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
+ { PCI_VDEVICE(INTEL, 0x34ea), (kernel_ulong_t)&bxt_i2c_info },
+ { PCI_VDEVICE(INTEL, 0x34eb), (kernel_ulong_t)&bxt_i2c_info },
+ { PCI_VDEVICE(INTEL, 0x34fb), (kernel_ulong_t)&spt_info },
++ /* TGL-H */
++ { PCI_VDEVICE(INTEL, 0x43a7), (kernel_ulong_t)&bxt_uart_info },
++ { PCI_VDEVICE(INTEL, 0x43a8), (kernel_ulong_t)&bxt_uart_info },
++ { PCI_VDEVICE(INTEL, 0x43a9), (kernel_ulong_t)&bxt_uart_info },
++ { PCI_VDEVICE(INTEL, 0x43aa), (kernel_ulong_t)&bxt_info },
++ { PCI_VDEVICE(INTEL, 0x43ab), (kernel_ulong_t)&bxt_info },
++ { PCI_VDEVICE(INTEL, 0x43ad), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43ae), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43d8), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43da), (kernel_ulong_t)&bxt_uart_info },
++ { PCI_VDEVICE(INTEL, 0x43e8), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43e9), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43ea), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43eb), (kernel_ulong_t)&bxt_i2c_info },
++ { PCI_VDEVICE(INTEL, 0x43fb), (kernel_ulong_t)&bxt_info },
++ { PCI_VDEVICE(INTEL, 0x43fd), (kernel_ulong_t)&bxt_info },
+ /* EHL */
+ { PCI_VDEVICE(INTEL, 0x4b28), (kernel_ulong_t)&bxt_uart_info },
+ { PCI_VDEVICE(INTEL, 0x4b29), (kernel_ulong_t)&bxt_uart_info },
+diff --git a/drivers/misc/habanalabs/debugfs.c b/drivers/misc/habanalabs/debugfs.c
+index 0bc036e01ee8d..6c2b9cf45e831 100644
+--- a/drivers/misc/habanalabs/debugfs.c
++++ b/drivers/misc/habanalabs/debugfs.c
+@@ -19,7 +19,7 @@
+ static struct dentry *hl_debug_root;
+
+ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
+- u8 i2c_reg, u32 *val)
++ u8 i2c_reg, long *val)
+ {
+ struct armcp_packet pkt;
+ int rc;
+@@ -36,7 +36,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
+ pkt.i2c_reg = i2c_reg;
+
+ rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
+- 0, (long *) val);
++ 0, val);
+
+ if (rc)
+ dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
+@@ -827,7 +827,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
+ struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+ struct hl_device *hdev = entry->hdev;
+ char tmp_buf[32];
+- u32 val;
++ long val;
+ ssize_t rc;
+
+ if (*ppos)
+@@ -842,7 +842,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
+ return rc;
+ }
+
+- sprintf(tmp_buf, "0x%02x\n", val);
++ sprintf(tmp_buf, "0x%02lx\n", val);
+ rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
+ strlen(tmp_buf));
+
+diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
+index fb26e743e1fd4..d0a80bfb953b0 100644
+--- a/drivers/mmc/host/sdhci-of-arasan.c
++++ b/drivers/mmc/host/sdhci-of-arasan.c
+@@ -1025,7 +1025,6 @@ static void arasan_dt_read_clk_phase(struct device *dev,
+ static void arasan_dt_parse_clk_phases(struct device *dev,
+ struct sdhci_arasan_clk_data *clk_data)
+ {
+- int *iclk_phase, *oclk_phase;
+ u32 mio_bank = 0;
+ int i;
+
+@@ -1037,28 +1036,32 @@ static void arasan_dt_parse_clk_phases(struct device *dev,
+ clk_data->set_clk_delays = sdhci_arasan_set_clk_delays;
+
+ if (of_device_is_compatible(dev->of_node, "xlnx,zynqmp-8.9a")) {
+- iclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) ZYNQMP_ICLK_PHASE;
+- oclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) ZYNQMP_OCLK_PHASE;
++ u32 zynqmp_iclk_phase[MMC_TIMING_MMC_HS400 + 1] =
++ ZYNQMP_ICLK_PHASE;
++ u32 zynqmp_oclk_phase[MMC_TIMING_MMC_HS400 + 1] =
++ ZYNQMP_OCLK_PHASE;
+
+ of_property_read_u32(dev->of_node, "xlnx,mio-bank", &mio_bank);
+ if (mio_bank == 2) {
+- oclk_phase[MMC_TIMING_UHS_SDR104] = 90;
+- oclk_phase[MMC_TIMING_MMC_HS200] = 90;
++ zynqmp_oclk_phase[MMC_TIMING_UHS_SDR104] = 90;
++ zynqmp_oclk_phase[MMC_TIMING_MMC_HS200] = 90;
+ }
+
+ for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
+- clk_data->clk_phase_in[i] = iclk_phase[i];
+- clk_data->clk_phase_out[i] = oclk_phase[i];
++ clk_data->clk_phase_in[i] = zynqmp_iclk_phase[i];
++ clk_data->clk_phase_out[i] = zynqmp_oclk_phase[i];
+ }
+ }
+
+ if (of_device_is_compatible(dev->of_node, "xlnx,versal-8.9a")) {
+- iclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) VERSAL_ICLK_PHASE;
+- oclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) VERSAL_OCLK_PHASE;
++ u32 versal_iclk_phase[MMC_TIMING_MMC_HS400 + 1] =
++ VERSAL_ICLK_PHASE;
++ u32 versal_oclk_phase[MMC_TIMING_MMC_HS400 + 1] =
++ VERSAL_OCLK_PHASE;
+
+ for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
+- clk_data->clk_phase_in[i] = iclk_phase[i];
+- clk_data->clk_phase_out[i] = oclk_phase[i];
++ clk_data->clk_phase_in[i] = versal_iclk_phase[i];
++ clk_data->clk_phase_out[i] = versal_oclk_phase[i];
+ }
+ }
+
+diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
+index b513b8c5c3b5e..41dd3d0f34524 100644
+--- a/drivers/net/ethernet/freescale/gianfar.c
++++ b/drivers/net/ethernet/freescale/gianfar.c
+@@ -750,8 +750,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/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
+index ec7a11d13fdc0..9e70b9a674409 100644
+--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
+@@ -192,7 +192,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
+ }
+
+ /* alloc the udl from per cpu ddp pool */
+- ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_KERNEL, &ddp->udp);
++ ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_ATOMIC, &ddp->udp);
+ if (!ddp->udl) {
+ e_err(drv, "failed allocated ddp context\n");
+ goto out_noddp_unmap;
+diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
+index 4942f6112e51f..5da04e9979894 100644
+--- a/drivers/net/macvlan.c
++++ b/drivers/net/macvlan.c
+@@ -1269,6 +1269,9 @@ static void macvlan_port_destroy(struct net_device *dev)
+ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[],
+ struct netlink_ext_ack *extack)
+ {
++ struct nlattr *nla, *head;
++ int rem, len;
++
+ if (tb[IFLA_ADDRESS]) {
+ if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
+ return -EINVAL;
+@@ -1316,6 +1319,20 @@ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[],
+ return -EADDRNOTAVAIL;
+ }
+
++ if (data[IFLA_MACVLAN_MACADDR_DATA]) {
++ head = nla_data(data[IFLA_MACVLAN_MACADDR_DATA]);
++ len = nla_len(data[IFLA_MACVLAN_MACADDR_DATA]);
++
++ nla_for_each_attr(nla, head, len, rem) {
++ if (nla_type(nla) != IFLA_MACVLAN_MACADDR ||
++ nla_len(nla) != ETH_ALEN)
++ return -EINVAL;
++
++ if (!is_valid_ether_addr(nla_data(nla)))
++ return -EADDRNOTAVAIL;
++ }
++ }
++
+ if (data[IFLA_MACVLAN_MACADDR_COUNT])
+ return -EINVAL;
+
+@@ -1372,10 +1389,6 @@ static int macvlan_changelink_sources(struct macvlan_dev *vlan, u32 mode,
+ len = nla_len(data[IFLA_MACVLAN_MACADDR_DATA]);
+
+ nla_for_each_attr(nla, head, len, rem) {
+- if (nla_type(nla) != IFLA_MACVLAN_MACADDR ||
+- nla_len(nla) != ETH_ALEN)
+- continue;
+-
+ addr = nla_data(nla);
+ ret = macvlan_hash_add_source(vlan, addr);
+ if (ret)
+diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c
+index dfc16770458d8..386ed2aa31fd9 100644
+--- a/drivers/net/wan/hdlc.c
++++ b/drivers/net/wan/hdlc.c
+@@ -230,6 +230,7 @@ static void hdlc_setup_dev(struct net_device *dev)
+ dev->max_mtu = HDLC_MAX_MTU;
+ dev->type = ARPHRD_RAWHDLC;
+ dev->hard_header_len = 16;
++ dev->needed_headroom = 0;
+ dev->addr_len = 0;
+ dev->header_ops = &hdlc_null_ops;
+ }
+diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
+index f70336bb6f524..f52b9fed05931 100644
+--- a/drivers/net/wan/hdlc_x25.c
++++ b/drivers/net/wan/hdlc_x25.c
+@@ -107,8 +107,14 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
+ {
+ int result;
+
++ /* 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) {
++ kfree_skb(skb);
++ return NETDEV_TX_OK;
++ }
+
+- /* X.25 to LAPB */
+ switch (skb->data[0]) {
+ case X25_IFACE_DATA: /* Data to be transmitted */
+ skb_pull(skb, 1);
+@@ -294,6 +300,15 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
+ return result;
+
+ memcpy(&state(hdlc)->settings, &new_settings, size);
++
++ /* There's no header_ops so hard_header_len should be 0. */
++ dev->hard_header_len = 0;
++ /* When transmitting data:
++ * first we'll remove a pseudo header of 1 byte,
++ * then we'll prepend an LAPB header of at most 3 bytes.
++ */
++ dev->needed_headroom = 3 - 1;
++
+ dev->type = ARPHRD_X25;
+ call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
+ netif_dormant_off(dev);
+diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+index a757abd7a5999..f4db818cccae7 100644
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -84,6 +84,8 @@
+
+ #define BRCMF_ND_INFO_TIMEOUT msecs_to_jiffies(2000)
+
++#define BRCMF_PS_MAX_TIMEOUT_MS 2000
++
+ #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \
+ (sizeof(struct brcmf_assoc_params_le) - sizeof(u16))
+
+@@ -2941,6 +2943,12 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev,
+ else
+ bphy_err(drvr, "error (%d)\n", err);
+ }
++
++ err = brcmf_fil_iovar_int_set(ifp, "pm2_sleep_ret",
++ min_t(u32, timeout, BRCMF_PS_MAX_TIMEOUT_MS));
++ if (err)
++ bphy_err(drvr, "Unable to set pm timeout, (%d)\n", err);
++
+ done:
+ brcmf_dbg(TRACE, "Exit\n");
+ return err;
+diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
+index c66c6dc003783..bad06939a247c 100644
+--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
++++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
+@@ -718,8 +718,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/nvme/host/fc.c b/drivers/nvme/host/fc.c
+index 549f5b0fb0b4b..1a2b6910509ca 100644
+--- a/drivers/nvme/host/fc.c
++++ b/drivers/nvme/host/fc.c
+@@ -2076,7 +2076,7 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
+ if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) {
+ dev_err(ctrl->dev,
+ "FCP Op failed - cmdiu dma mapping failed.\n");
+- ret = EFAULT;
++ ret = -EFAULT;
+ goto out_on_error;
+ }
+
+@@ -2086,7 +2086,7 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
+ if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) {
+ dev_err(ctrl->dev,
+ "FCP Op failed - rspiu dma mapping failed.\n");
+- ret = EFAULT;
++ ret = -EFAULT;
+ }
+
+ atomic_set(&op->state, FCPOP_STATE_IDLE);
+diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
+index 2672953233434..041a755f936a6 100644
+--- a/drivers/nvme/host/multipath.c
++++ b/drivers/nvme/host/multipath.c
+@@ -255,12 +255,17 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
+ fallback = ns;
+ }
+
+- /* No optimized path found, re-check the current path */
++ /*
++ * The loop above skips the current path for round-robin semantics.
++ * Fall back to the current path if either:
++ * - no other optimized path found and current is optimized,
++ * - no other usable path found and current is usable.
++ */
+ if (!nvme_path_is_disabled(old) &&
+- old->ana_state == NVME_ANA_OPTIMIZED) {
+- found = old;
+- goto out;
+- }
++ (old->ana_state == NVME_ANA_OPTIMIZED ||
++ (!fallback && old->ana_state == NVME_ANA_NONOPTIMIZED)))
++ return old;
++
+ if (!fallback)
+ return NULL;
+ found = fallback;
+diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
+index 419e0d4ce79b1..d84b935704a3d 100644
+--- a/drivers/nvme/target/configfs.c
++++ b/drivers/nvme/target/configfs.c
+@@ -1035,6 +1035,7 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
+ up_write(&nvmet_config_sem);
+
+ kfree_rcu(new_model, rcuhead);
++ kfree(new_model_number);
+
+ return count;
+ }
+diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
+index 5dd1740855770..f38e710de4789 100644
+--- a/drivers/pci/controller/dwc/pcie-qcom.c
++++ b/drivers/pci/controller/dwc/pcie-qcom.c
+@@ -106,11 +106,14 @@ struct qcom_pcie_resources_2_1_0 {
+ struct clk *iface_clk;
+ struct clk *core_clk;
+ struct clk *phy_clk;
++ struct clk *aux_clk;
++ struct clk *ref_clk;
+ struct reset_control *pci_reset;
+ struct reset_control *axi_reset;
+ struct reset_control *ahb_reset;
+ struct reset_control *por_reset;
+ struct reset_control *phy_reset;
++ struct reset_control *ext_reset;
+ struct regulator_bulk_data supplies[QCOM_PCIE_2_1_0_MAX_SUPPLY];
+ };
+
+@@ -264,6 +267,14 @@ static int qcom_pcie_get_resources_2_1_0(struct qcom_pcie *pcie)
+ if (IS_ERR(res->phy_clk))
+ return PTR_ERR(res->phy_clk);
+
++ res->aux_clk = devm_clk_get_optional(dev, "aux");
++ if (IS_ERR(res->aux_clk))
++ return PTR_ERR(res->aux_clk);
++
++ res->ref_clk = devm_clk_get_optional(dev, "ref");
++ if (IS_ERR(res->ref_clk))
++ return PTR_ERR(res->ref_clk);
++
+ res->pci_reset = devm_reset_control_get_exclusive(dev, "pci");
+ if (IS_ERR(res->pci_reset))
+ return PTR_ERR(res->pci_reset);
+@@ -280,6 +291,10 @@ static int qcom_pcie_get_resources_2_1_0(struct qcom_pcie *pcie)
+ if (IS_ERR(res->por_reset))
+ return PTR_ERR(res->por_reset);
+
++ res->ext_reset = devm_reset_control_get_optional_exclusive(dev, "ext");
++ if (IS_ERR(res->ext_reset))
++ return PTR_ERR(res->ext_reset);
++
+ res->phy_reset = devm_reset_control_get_exclusive(dev, "phy");
+ return PTR_ERR_OR_ZERO(res->phy_reset);
+ }
+@@ -288,14 +303,17 @@ static void qcom_pcie_deinit_2_1_0(struct qcom_pcie *pcie)
+ {
+ struct qcom_pcie_resources_2_1_0 *res = &pcie->res.v2_1_0;
+
++ clk_disable_unprepare(res->phy_clk);
+ 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->pci_reset);
++ reset_control_assert(res->ext_reset);
++ reset_control_assert(res->phy_reset);
+ clk_disable_unprepare(res->iface_clk);
+ clk_disable_unprepare(res->core_clk);
+- clk_disable_unprepare(res->phy_clk);
++ clk_disable_unprepare(res->aux_clk);
++ clk_disable_unprepare(res->ref_clk);
+ regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies);
+ }
+
+@@ -326,24 +344,36 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie)
+ goto err_assert_ahb;
+ }
+
+- ret = clk_prepare_enable(res->phy_clk);
+- if (ret) {
+- dev_err(dev, "cannot prepare/enable phy clock\n");
+- goto err_clk_phy;
+- }
+-
+ ret = clk_prepare_enable(res->core_clk);
+ if (ret) {
+ dev_err(dev, "cannot prepare/enable core clock\n");
+ goto err_clk_core;
+ }
+
++ ret = clk_prepare_enable(res->aux_clk);
++ if (ret) {
++ dev_err(dev, "cannot prepare/enable aux clock\n");
++ goto err_clk_aux;
++ }
++
++ ret = clk_prepare_enable(res->ref_clk);
++ if (ret) {
++ dev_err(dev, "cannot prepare/enable ref clock\n");
++ goto err_clk_ref;
++ }
++
+ ret = reset_control_deassert(res->ahb_reset);
+ if (ret) {
+ dev_err(dev, "cannot deassert ahb reset\n");
+ goto err_deassert_ahb;
+ }
+
++ ret = reset_control_deassert(res->ext_reset);
++ if (ret) {
++ dev_err(dev, "cannot deassert ext reset\n");
++ goto err_deassert_ahb;
++ }
++
+ /* enable PCIe clocks and resets */
+ val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL);
+ val &= ~BIT(0);
+@@ -398,6 +428,12 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie)
+ return ret;
+ }
+
++ ret = clk_prepare_enable(res->phy_clk);
++ if (ret) {
++ dev_err(dev, "cannot prepare/enable phy clock\n");
++ goto err_deassert_ahb;
++ }
++
+ /* wait for clock acquisition */
+ usleep_range(1000, 1500);
+
+@@ -411,10 +447,12 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie)
+ return 0;
+
+ err_deassert_ahb:
++ clk_disable_unprepare(res->ref_clk);
++err_clk_ref:
++ clk_disable_unprepare(res->aux_clk);
++err_clk_aux:
+ clk_disable_unprepare(res->core_clk);
+ err_clk_core:
+- clk_disable_unprepare(res->phy_clk);
+-err_clk_phy:
+ clk_disable_unprepare(res->iface_clk);
+ err_assert_ahb:
+ regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies);
+diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
+index cc386ef2fa122..3861505741e6d 100644
+--- a/drivers/pci/slot.c
++++ b/drivers/pci/slot.c
+@@ -268,13 +268,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);
+@@ -293,7 +296,6 @@ out:
+ mutex_unlock(&pci_slot_mutex);
+ return slot;
+ err:
+- kfree(slot);
+ slot = ERR_PTR(err);
+ goto out;
+ }
+diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+index b77b18fe5adcf..2f3dfb56c3fa4 100644
+--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
++++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+@@ -243,6 +243,29 @@ static int mtk_xt_find_eint_num(struct mtk_pinctrl *hw, unsigned long eint_n)
+ return EINT_NA;
+ }
+
++/*
++ * Virtual GPIO only used inside SOC and not being exported to outside SOC.
++ * Some modules use virtual GPIO as eint (e.g. pmif or usb).
++ * In MTK platform, external interrupt (EINT) and GPIO is 1-1 mapping
++ * and we can set GPIO as eint.
++ * But some modules use specific eint which doesn't have real GPIO pin.
++ * So we use virtual GPIO to map it.
++ */
++
++bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n)
++{
++ const struct mtk_pin_desc *desc;
++ bool virt_gpio = false;
++
++ desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n];
++
++ if (desc->funcs && !desc->funcs[desc->eint.eint_m].name)
++ virt_gpio = true;
++
++ return virt_gpio;
++}
++EXPORT_SYMBOL_GPL(mtk_is_virt_gpio);
++
+ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n,
+ unsigned int *gpio_n,
+ struct gpio_chip **gpio_chip)
+@@ -295,6 +318,9 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n)
+ if (err)
+ return err;
+
++ if (mtk_is_virt_gpio(hw, gpio_n))
++ return 0;
++
+ desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n];
+
+ err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
+diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+index 27df087363960..bd079f4fb1d6f 100644
+--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
++++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+@@ -315,4 +315,5 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
+ int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val);
+
++bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
+ #endif /* __PINCTRL_MTK_COMMON_V2_H */
+diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
+index 90a432bf9fedc..a23c18251965e 100644
+--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
++++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
+@@ -769,6 +769,13 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
+ if (gpio >= hw->soc->npins)
+ return -EINVAL;
+
++ /*
++ * "Virtual" GPIOs are always and only used for interrupts
++ * Since they are only used for interrupts, they are always inputs
++ */
++ if (mtk_is_virt_gpio(hw, gpio))
++ return 1;
++
+ desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
+
+ err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &value);
+diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+index 24e48d96ed766..b1c641c72f515 100644
+--- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
++++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+@@ -419,9 +419,7 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
+ * Disable filtering since we might add more jitter
+ * if b is in a random point in time.
+ */
+- new_timestamp = fifo_timestamp -
+- fifo_info->timestamp * 1000 +
+- in->timestamp * 1000;
++ new_timestamp = c - b * 1000 + a * 1000;
+ /*
+ * The timestamp can be stale if we had to use the fifo
+ * info timestamp.
+diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
+index 94edbb33d0d1f..aca022239b333 100644
+--- a/drivers/s390/cio/css.c
++++ b/drivers/s390/cio/css.c
+@@ -677,6 +677,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 1791a393795da..07a0dadc75bf5 100644
+--- a/drivers/scsi/fcoe/fcoe_ctlr.c
++++ b/drivers/scsi/fcoe/fcoe_ctlr.c
+@@ -255,9 +255,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 b766463579800..d0296f7cf45fc 100644
+--- a/drivers/scsi/lpfc/lpfc_vport.c
++++ b/drivers/scsi/lpfc/lpfc_vport.c
+@@ -642,27 +642,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);
+@@ -809,8 +798,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/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
+index df670fba2ab8a..de9fd7f688d01 100644
+--- a/drivers/scsi/qla2xxx/qla_gs.c
++++ b/drivers/scsi/qla2xxx/qla_gs.c
+@@ -1505,11 +1505,11 @@ qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t cmd,
+ static uint
+ qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
+ {
++ uint speeds = 0;
++
+ if (IS_CNA_CAPABLE(ha))
+ return FDMI_PORT_SPEED_10GB;
+ if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) {
+- uint speeds = 0;
+-
+ if (ha->max_supported_speed == 2) {
+ if (ha->min_supported_speed <= 6)
+ speeds |= FDMI_PORT_SPEED_64GB;
+@@ -1536,9 +1536,16 @@ qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
+ }
+ return speeds;
+ }
+- if (IS_QLA2031(ha))
+- return FDMI_PORT_SPEED_16GB|FDMI_PORT_SPEED_8GB|
+- FDMI_PORT_SPEED_4GB;
++ if (IS_QLA2031(ha)) {
++ if ((ha->pdev->subsystem_vendor == 0x103C) &&
++ (ha->pdev->subsystem_device == 0x8002)) {
++ speeds = FDMI_PORT_SPEED_16GB;
++ } else {
++ speeds = FDMI_PORT_SPEED_16GB|FDMI_PORT_SPEED_8GB|
++ FDMI_PORT_SPEED_4GB;
++ }
++ return speeds;
++ }
+ if (IS_QLA25XX(ha))
+ return FDMI_PORT_SPEED_8GB|FDMI_PORT_SPEED_4GB|
+ FDMI_PORT_SPEED_2GB|FDMI_PORT_SPEED_1GB;
+@@ -3436,7 +3443,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp)
+ list_for_each_entry(fcport, &vha->vp_fcports, list) {
+ if ((fcport->flags & FCF_FABRIC_DEVICE) != 0) {
+ fcport->scan_state = QLA_FCPORT_SCAN;
+- fcport->logout_on_delete = 0;
+ }
+ }
+ goto login_logout;
+@@ -3532,10 +3538,22 @@ login_logout:
+ }
+
+ if (fcport->scan_state != QLA_FCPORT_FOUND) {
++ bool do_delete = false;
++
++ if (fcport->scan_needed &&
++ fcport->disc_state == DSC_LOGIN_PEND) {
++ /* Cable got disconnected after we sent
++ * a login. Do delete to prevent timeout.
++ */
++ fcport->logout_on_delete = 1;
++ do_delete = true;
++ }
++
+ fcport->scan_needed = 0;
+- if ((qla_dual_mode_enabled(vha) ||
+- qla_ini_mode_enabled(vha)) &&
+- atomic_read(&fcport->state) == FCS_ONLINE) {
++ if (((qla_dual_mode_enabled(vha) ||
++ qla_ini_mode_enabled(vha)) &&
++ atomic_read(&fcport->state) == FCS_ONLINE) ||
++ do_delete) {
+ if (fcport->loop_id != FC_NO_LOOP_ID) {
+ if (fcport->flags & FCF_FCP2_DEVICE)
+ fcport->logout_on_delete = 0;
+@@ -3736,6 +3754,18 @@ static void qla2x00_async_gpnft_gnnft_sp_done(srb_t *sp, int res)
+ unsigned long flags;
+ const char *name = sp->name;
+
++ if (res == QLA_OS_TIMER_EXPIRED) {
++ /* switch is ignoring all commands.
++ * This might be a zone disable behavior.
++ * This means we hit 64s timeout.
++ * 22s GPNFT + 44s Abort = 64s
++ */
++ ql_dbg(ql_dbg_disc, vha, 0xffff,
++ "%s: Switch Zone check please .\n",
++ name);
++ qla2x00_mark_all_devices_lost(vha);
++ }
++
+ /*
+ * We are in an Interrupt context, queue up this
+ * sp for GNNFT_DONE work. This will allow all
+diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
+index df31ee0d59b20..fdb2ce7acb912 100644
+--- a/drivers/scsi/qla2xxx/qla_mbx.c
++++ b/drivers/scsi/qla2xxx/qla_mbx.c
+@@ -333,14 +333,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
+ if (time_after(jiffies, wait_time))
+ break;
+
+- /*
+- * Check if it's UNLOADING, cause we cannot poll in
+- * this case, or else a NULL pointer dereference
+- * is triggered.
+- */
+- if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)))
+- return QLA_FUNCTION_TIMEOUT;
+-
+ /* Check for pending interrupts. */
+ qla2x00_poll(ha->rsp_q_map[0]);
+
+diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
+index fa695a4007f86..262dfd7635a48 100644
+--- a/drivers/scsi/qla2xxx/qla_nvme.c
++++ b/drivers/scsi/qla2xxx/qla_nvme.c
+@@ -536,6 +536,11 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
+ struct nvme_private *priv = fd->private;
+ struct qla_nvme_rport *qla_rport = rport->private;
+
++ if (!priv) {
++ /* nvme association has been torn down */
++ return rval;
++ }
++
+ fcport = qla_rport->fcport;
+
+ if (!qpair || !fcport || (qpair && !qpair->fw_started) ||
+diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
+index 5c7c22d0fab4b..8b6803f4f2dc1 100644
+--- a/drivers/scsi/qla2xxx/qla_os.c
++++ b/drivers/scsi/qla2xxx/qla_os.c
+@@ -2017,6 +2017,11 @@ skip_pio:
+ /* Determine queue resources */
+ ha->max_req_queues = ha->max_rsp_queues = 1;
+ ha->msix_count = QLA_BASE_VECTORS;
++
++ /* Check if FW supports MQ or not */
++ if (!(ha->fw_attributes & BIT_6))
++ goto mqiobase_exit;
++
+ if (!ql2xmqsupport || !ql2xnvmeenable ||
+ (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
+ goto mqiobase_exit;
+diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
+index fbb80a043b4fe..90289162dbd4c 100644
+--- a/drivers/scsi/qla2xxx/qla_target.c
++++ b/drivers/scsi/qla2xxx/qla_target.c
+@@ -1270,7 +1270,7 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess)
+
+ qla24xx_chk_fcp_state(sess);
+
+- ql_dbg(ql_dbg_tgt, sess->vha, 0xe001,
++ ql_dbg(ql_dbg_disc, sess->vha, 0xe001,
+ "Scheduling sess %p for deletion %8phC\n",
+ sess, sess->port_name);
+
+diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
+index b0d93bf79978f..25faad7f8e617 100644
+--- a/drivers/scsi/scsi_debug.c
++++ b/drivers/scsi/scsi_debug.c
+@@ -5486,9 +5486,11 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
+ u64 d = ktime_get_boottime_ns() - ns_from_boot;
+
+ if (kt <= d) { /* elapsed duration >= kt */
++ spin_lock_irqsave(&sqp->qc_lock, iflags);
+ sqcp->a_cmnd = NULL;
+ atomic_dec(&devip->num_in_q);
+ clear_bit(k, sqp->in_use_bm);
++ spin_unlock_irqrestore(&sqp->qc_lock, iflags);
+ if (new_sd_dp)
+ kfree(sd_dp);
+ /* call scsi_done() from this thread */
+diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
+index 7ae5024e78243..df07ecd94793a 100644
+--- a/drivers/scsi/scsi_transport_iscsi.c
++++ b/drivers/scsi/scsi_transport_iscsi.c
+@@ -3291,7 +3291,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 136b863bc1d45..8bc8e4e62c045 100644
+--- a/drivers/scsi/ufs/ufshcd.c
++++ b/drivers/scsi/ufs/ufshcd.c
+@@ -1566,6 +1566,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))
+@@ -1597,7 +1598,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;
+ }
+@@ -5988,7 +5991,7 @@ static irqreturn_t ufshcd_sl_intr(struct ufs_hba *hba, u32 intr_status)
+ */
+ static irqreturn_t ufshcd_intr(int irq, void *__hba)
+ {
+- u32 intr_status, enabled_intr_status;
++ u32 intr_status, enabled_intr_status = 0;
+ irqreturn_t retval = IRQ_NONE;
+ struct ufs_hba *hba = __hba;
+ int retries = hba->nutrs;
+@@ -6002,7 +6005,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
+ * read, make sure we handle them by checking the interrupt status
+ * again in a loop until we process all of the reqs before returning.
+ */
+- do {
++ while (intr_status && retries--) {
+ enabled_intr_status =
+ intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+ if (intr_status)
+@@ -6011,7 +6014,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
+ retval |= ufshcd_sl_intr(hba, enabled_intr_status);
+
+ intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
+- } while (intr_status && --retries);
++ }
+
+ if (enabled_intr_status && retval == IRQ_NONE) {
+ dev_err(hba->dev, "%s: Unhandled interrupt 0x%08x\n",
+@@ -6538,7 +6541,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
+ /* command completed already */
+ dev_err(hba->dev, "%s: cmd at tag %d successfully cleared from DB.\n",
+ __func__, tag);
+- goto out;
++ goto cleanup;
+ } else {
+ dev_err(hba->dev,
+ "%s: no response from device. tag = %d, err %d\n",
+@@ -6572,6 +6575,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
+ goto out;
+ }
+
++cleanup:
+ scsi_dma_unmap(cmd);
+
+ spin_lock_irqsave(host->host_lock, flags);
+diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
+index 9672cda2f8031..d4b33b358a31e 100644
+--- a/drivers/spi/spi-stm32.c
++++ b/drivers/spi/spi-stm32.c
+@@ -442,7 +442,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
+ {
+ u32 div, mbrdiv;
+
+- div = DIV_ROUND_UP(spi->clk_rate, speed_hz);
++ /* Ensure spi->clk_rate is even */
++ div = DIV_ROUND_UP(spi->clk_rate & ~0x1, speed_hz);
+
+ /*
+ * SPI framework set xfer->speed_hz to master->max_speed_hz if
+@@ -468,20 +469,27 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
+ /**
+ * stm32h7_spi_prepare_fthlv - Determine FIFO threshold level
+ * @spi: pointer to the spi controller data structure
++ * @xfer_len: length of the message to be transferred
+ */
+-static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
++static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi, u32 xfer_len)
+ {
+- u32 fthlv, half_fifo;
++ u32 fthlv, half_fifo, packet;
+
+ /* data packet should not exceed 1/2 of fifo space */
+ half_fifo = (spi->fifo_size / 2);
+
++ /* data_packet should not exceed transfer length */
++ if (half_fifo > xfer_len)
++ packet = xfer_len;
++ else
++ packet = half_fifo;
++
+ if (spi->cur_bpw <= 8)
+- fthlv = half_fifo;
++ fthlv = packet;
+ else if (spi->cur_bpw <= 16)
+- fthlv = half_fifo / 2;
++ fthlv = packet / 2;
+ else
+- fthlv = half_fifo / 4;
++ fthlv = packet / 4;
+
+ /* align packet size with data registers access */
+ if (spi->cur_bpw > 8)
+@@ -489,6 +497,9 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
+ else
+ fthlv -= (fthlv % 4); /* multiple of 4 */
+
++ if (!fthlv)
++ fthlv = 1;
++
+ return fthlv;
+ }
+
+@@ -967,13 +978,13 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
+ if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
+ stm32h7_spi_read_rxfifo(spi, false);
+
+- writel_relaxed(mask, spi->base + STM32H7_SPI_IFCR);
++ writel_relaxed(sr & mask, spi->base + STM32H7_SPI_IFCR);
+
+ spin_unlock_irqrestore(&spi->lock, flags);
+
+ if (end) {
+- spi_finalize_current_transfer(master);
+ stm32h7_spi_disable(spi);
++ spi_finalize_current_transfer(master);
+ }
+
+ return IRQ_HANDLED;
+@@ -1394,7 +1405,7 @@ static void stm32h7_spi_set_bpw(struct stm32_spi *spi)
+ cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) &
+ STM32H7_SPI_CFG1_DSIZE;
+
+- spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi);
++ spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi, spi->cur_xferlen);
+ fthlv = spi->cur_fthlv - 1;
+
+ cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV;
+@@ -1586,39 +1597,33 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
+ unsigned long flags;
+ unsigned int comm_type;
+ int nb_words, ret = 0;
++ int mbr;
+
+ spin_lock_irqsave(&spi->lock, flags);
+
+- if (spi->cur_bpw != transfer->bits_per_word) {
+- spi->cur_bpw = transfer->bits_per_word;
+- spi->cfg->set_bpw(spi);
+- }
++ spi->cur_xferlen = transfer->len;
+
+- if (spi->cur_speed != transfer->speed_hz) {
+- int mbr;
++ spi->cur_bpw = transfer->bits_per_word;
++ spi->cfg->set_bpw(spi);
+
+- /* Update spi->cur_speed with real clock speed */
+- mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
+- spi->cfg->baud_rate_div_min,
+- spi->cfg->baud_rate_div_max);
+- if (mbr < 0) {
+- ret = mbr;
+- goto out;
+- }
+-
+- transfer->speed_hz = spi->cur_speed;
+- stm32_spi_set_mbr(spi, mbr);
++ /* Update spi->cur_speed with real clock speed */
++ mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
++ spi->cfg->baud_rate_div_min,
++ spi->cfg->baud_rate_div_max);
++ if (mbr < 0) {
++ ret = mbr;
++ goto out;
+ }
+
+- comm_type = stm32_spi_communication_type(spi_dev, transfer);
+- if (spi->cur_comm != comm_type) {
+- ret = spi->cfg->set_mode(spi, comm_type);
++ transfer->speed_hz = spi->cur_speed;
++ stm32_spi_set_mbr(spi, mbr);
+
+- if (ret < 0)
+- goto out;
++ comm_type = stm32_spi_communication_type(spi_dev, transfer);
++ ret = spi->cfg->set_mode(spi, comm_type);
++ if (ret < 0)
++ goto out;
+
+- spi->cur_comm = comm_type;
+- }
++ spi->cur_comm = comm_type;
+
+ if (spi->cfg->set_data_idleness)
+ spi->cfg->set_data_idleness(spi, transfer->len);
+@@ -1636,8 +1641,6 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
+ goto out;
+ }
+
+- spi->cur_xferlen = transfer->len;
+-
+ dev_dbg(spi->dev, "transfer communication mode set to %d\n",
+ spi->cur_comm);
+ dev_dbg(spi->dev,
+diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
+index be0053c795b7a..937f4e732a75c 100644
+--- a/drivers/staging/rts5208/rtsx.c
++++ b/drivers/staging/rts5208/rtsx.c
+@@ -972,6 +972,7 @@ ioremap_fail:
+ kfree(dev->chip);
+ chip_alloc_fail:
+ dev_err(&pci->dev, "%s failed\n", __func__);
++ scsi_host_put(host);
+ scsi_host_alloc_fail:
+ pci_release_regions(pci);
+ return err;
+diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
+index 8533444159635..e7b3c6e5d5744 100644
+--- a/drivers/target/target_core_internal.h
++++ b/drivers/target/target_core_internal.h
+@@ -138,6 +138,7 @@ int init_se_kmem_caches(void);
+ void release_se_kmem_caches(void);
+ u32 scsi_get_new_index(scsi_index_t);
+ void transport_subsystem_check_init(void);
++void transport_uninit_session(struct se_session *);
+ unsigned char *transport_dump_cmd_direction(struct se_cmd *);
+ void transport_dump_dev_state(struct se_device *, char *, int *);
+ void transport_dump_dev_info(struct se_device *, struct se_lun *,
+diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
+index 90ecdd706a017..e6e1fa68de542 100644
+--- a/drivers/target/target_core_transport.c
++++ b/drivers/target/target_core_transport.c
+@@ -236,6 +236,11 @@ int transport_init_session(struct se_session *se_sess)
+ }
+ EXPORT_SYMBOL(transport_init_session);
+
++void transport_uninit_session(struct se_session *se_sess)
++{
++ percpu_ref_exit(&se_sess->cmd_count);
++}
++
+ /**
+ * transport_alloc_session - allocate a session object and initialize it
+ * @sup_prot_ops: bitmask that defines which T10-PI modes are supported.
+@@ -579,7 +584,7 @@ void transport_free_session(struct se_session *se_sess)
+ sbitmap_queue_free(&se_sess->sess_tag_pool);
+ kvfree(se_sess->sess_cmd_map);
+ }
+- percpu_ref_exit(&se_sess->cmd_count);
++ transport_uninit_session(se_sess);
+ kmem_cache_free(se_sess_cache, se_sess);
+ }
+ EXPORT_SYMBOL(transport_free_session);
+diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
+index 63cca0e1e9123..9ab960cc39b6f 100644
+--- a/drivers/target/target_core_user.c
++++ b/drivers/target/target_core_user.c
+@@ -1220,7 +1220,14 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev *udev)
+
+ struct tcmu_cmd_entry *entry = (void *) mb + CMDR_OFF + udev->cmdr_last_cleaned;
+
+- 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/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
+index 0d00ccbeb0503..44e15d7fb2f09 100644
+--- a/drivers/target/target_core_xcopy.c
++++ b/drivers/target/target_core_xcopy.c
+@@ -474,7 +474,7 @@ int target_xcopy_setup_pt(void)
+ memset(&xcopy_pt_sess, 0, sizeof(struct se_session));
+ ret = transport_init_session(&xcopy_pt_sess);
+ if (ret < 0)
+- return ret;
++ goto destroy_wq;
+
+ xcopy_pt_nacl.se_tpg = &xcopy_pt_tpg;
+ xcopy_pt_nacl.nacl_sess = &xcopy_pt_sess;
+@@ -483,12 +483,19 @@ int target_xcopy_setup_pt(void)
+ xcopy_pt_sess.se_node_acl = &xcopy_pt_nacl;
+
+ return 0;
++
++destroy_wq:
++ destroy_workqueue(xcopy_wq);
++ xcopy_wq = NULL;
++ return ret;
+ }
+
+ void target_xcopy_release_pt(void)
+ {
+- if (xcopy_wq)
++ if (xcopy_wq) {
+ destroy_workqueue(xcopy_wq);
++ transport_uninit_session(&xcopy_pt_sess);
++ }
+ }
+
+ /*
+diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
+index 04b9af7ed9415..2d0e7c7e408dc 100644
+--- a/drivers/tty/serial/8250/8250_exar.c
++++ b/drivers/tty/serial/8250/8250_exar.c
+@@ -744,6 +744,24 @@ static const struct exar8250_board pbn_exar_XR17V35x = {
+ .exit = pci_xr17v35x_exit,
+ };
+
++static const struct exar8250_board pbn_fastcom35x_2 = {
++ .num_ports = 2,
++ .setup = pci_xr17v35x_setup,
++ .exit = pci_xr17v35x_exit,
++};
++
++static const struct exar8250_board pbn_fastcom35x_4 = {
++ .num_ports = 4,
++ .setup = pci_xr17v35x_setup,
++ .exit = pci_xr17v35x_exit,
++};
++
++static const struct exar8250_board pbn_fastcom35x_8 = {
++ .num_ports = 8,
++ .setup = pci_xr17v35x_setup,
++ .exit = pci_xr17v35x_exit,
++};
++
+ static const struct exar8250_board pbn_exar_XR17V4358 = {
+ .num_ports = 12,
+ .setup = pci_xr17v35x_setup,
+@@ -811,9 +829,9 @@ static const struct pci_device_id exar_pci_tbl[] = {
+ EXAR_DEVICE(EXAR, XR17V358, pbn_exar_XR17V35x),
+ EXAR_DEVICE(EXAR, XR17V4358, pbn_exar_XR17V4358),
+ EXAR_DEVICE(EXAR, XR17V8358, pbn_exar_XR17V8358),
+- EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_exar_XR17V35x),
+- EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_exar_XR17V35x),
+- EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_exar_XR17V35x),
++ EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_fastcom35x_2),
++ EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_fastcom35x_4),
++ EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_fastcom35x_8),
+
+ EXAR_DEVICE(COMMTECH, 4222PCI335, pbn_fastcom335_2),
+ EXAR_DEVICE(COMMTECH, 4224PCI335, pbn_fastcom335_4),
+diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
+index 1632f7d25acca..63a6d13f70b80 100644
+--- a/drivers/tty/serial/8250/8250_port.c
++++ b/drivers/tty/serial/8250/8250_port.c
+@@ -2274,6 +2274,10 @@ int serial8250_do_startup(struct uart_port *port)
+
+ if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
+ 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
+@@ -2283,8 +2287,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);
+@@ -2296,9 +2298,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 8efd7c2a34fe8..a8d1edcf252c7 100644
+--- a/drivers/tty/serial/amba-pl011.c
++++ b/drivers/tty/serial/amba-pl011.c
+@@ -2241,9 +2241,8 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
+ clk_disable(uap->clk);
+ }
+
+-static void __init
+-pl011_console_get_options(struct uart_amba_port *uap, int *baud,
+- int *parity, int *bits)
++static void pl011_console_get_options(struct uart_amba_port *uap, int *baud,
++ int *parity, int *bits)
+ {
+ if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) {
+ unsigned int lcr_h, ibrd, fbrd;
+@@ -2276,7 +2275,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
+ }
+ }
+
+-static int __init pl011_console_setup(struct console *co, char *options)
++static int pl011_console_setup(struct console *co, char *options)
+ {
+ struct uart_amba_port *uap;
+ int baud = 38400;
+@@ -2344,8 +2343,8 @@ static int __init pl011_console_setup(struct console *co, char *options)
+ *
+ * Returns 0 if console matches; otherwise non-zero to use default matching
+ */
+-static int __init pl011_console_match(struct console *co, char *name, int idx,
+- char *options)
++static int pl011_console_match(struct console *co, char *name, int idx,
++ char *options)
+ {
+ unsigned char iotype;
+ resource_size_t addr;
+@@ -2616,7 +2615,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 */
+ pl011_write(0, uap, REG_IMSC);
+@@ -2627,6 +2626,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_tty.c b/drivers/tty/serial/samsung_tty.c
+index d913d9b2762a6..815da3e78ad1a 100644
+--- a/drivers/tty/serial/samsung_tty.c
++++ b/drivers/tty/serial/samsung_tty.c
+@@ -1911,9 +1911,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/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
+index 8602ff3573218..b77b41c768fbf 100644
+--- a/drivers/tty/serial/stm32-usart.c
++++ b/drivers/tty/serial/stm32-usart.c
+@@ -962,7 +962,7 @@ static int stm32_init_port(struct stm32_port *stm32port,
+ return ret;
+
+ if (stm32port->info->cfg.has_wakeup) {
+- stm32port->wakeirq = platform_get_irq(pdev, 1);
++ stm32port->wakeirq = platform_get_irq_optional(pdev, 1);
+ if (stm32port->wakeirq <= 0 && stm32port->wakeirq != -ENXIO)
+ return stm32port->wakeirq ? : -ENODEV;
+ }
+diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
+index 42d8c67a481f0..c9ee8e9498d5a 100644
+--- a/drivers/tty/vt/vt.c
++++ b/drivers/tty/vt/vt.c
+@@ -1196,7 +1196,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
+ unsigned int old_rows, old_row_size, first_copied_row;
+ unsigned int new_cols, new_rows, new_row_size, new_screen_size;
+ unsigned int user;
+- unsigned short *newscreen;
++ unsigned short *oldscreen, *newscreen;
+ struct uni_screen *new_uniscr = NULL;
+
+ WARN_CONSOLE_UNLOCKED();
+@@ -1294,10 +1294,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 daf61c28ba766..cbc85c995d92d 100644
+--- a/drivers/tty/vt/vt_ioctl.c
++++ b/drivers/tty/vt/vt_ioctl.c
+@@ -893,12 +893,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/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
+index d5187b50fc828..7499ba118665a 100644
+--- a/drivers/usb/class/cdc-acm.c
++++ b/drivers/usb/class/cdc-acm.c
+@@ -378,21 +378,19 @@ static void acm_ctrl_irq(struct urb *urb)
+ if (current_size < expected_size) {
+ /* notification is transmitted fragmented, reassemble */
+ if (acm->nb_size < expected_size) {
+- if (acm->nb_size) {
+- kfree(acm->notification_buffer);
+- acm->nb_size = 0;
+- }
++ u8 *new_buffer;
+ alloc_size = roundup_pow_of_two(expected_size);
+- /*
+- * kmalloc ensures a valid notification_buffer after a
+- * use of kfree in case the previous allocation was too
+- * small. Final freeing is done on disconnect.
+- */
+- acm->notification_buffer =
+- kmalloc(alloc_size, GFP_ATOMIC);
+- if (!acm->notification_buffer)
++ /* Final freeing is done on disconnect. */
++ new_buffer = krealloc(acm->notification_buffer,
++ alloc_size, GFP_ATOMIC);
++ if (!new_buffer) {
++ acm->nb_index = 0;
+ goto exit;
++ }
++
++ acm->notification_buffer = new_buffer;
+ acm->nb_size = alloc_size;
++ dr = (struct usb_cdc_notification *)acm->notification_buffer;
+ }
+
+ copy_size = min(current_size,
+diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
+index f81606c6a35b0..7e73e989645bd 100644
+--- a/drivers/usb/core/driver.c
++++ b/drivers/usb/core/driver.c
+@@ -905,6 +905,35 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
+ return 0;
+ }
+
++static bool is_dev_usb_generic_driver(struct device *dev)
++{
++ struct usb_device_driver *udd = dev->driver ?
++ to_usb_device_driver(dev->driver) : NULL;
++
++ return udd == &usb_generic_driver;
++}
++
++static int __usb_bus_reprobe_drivers(struct device *dev, void *data)
++{
++ struct usb_device_driver *new_udriver = data;
++ struct usb_device *udev;
++ int ret;
++
++ if (!is_dev_usb_generic_driver(dev))
++ 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))
++ return 0;
++
++ ret = device_reprobe(dev);
++ if (ret && ret != -EPROBE_DEFER)
++ dev_err(dev, "Failed to reprobe device (error %d)\n", ret);
++
++ return 0;
++}
++
+ /**
+ * usb_register_device_driver - register a USB device (not interface) driver
+ * @new_udriver: USB operations for the device driver
+@@ -934,13 +963,20 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver,
+
+ retval = driver_register(&new_udriver->drvwrap.driver);
+
+- if (!retval)
++ if (!retval) {
+ pr_info("%s: registered new device driver %s\n",
+ usbcore_name, new_udriver->name);
+- else
++ /*
++ * Check whether any device could be better served with
++ * this new driver
++ */
++ bus_for_each_dev(&usb_bus_type, NULL, new_udriver,
++ __usb_bus_reprobe_drivers);
++ } else {
+ printk(KERN_ERR "%s: error %d registering device "
+ " driver %s\n",
+ usbcore_name, retval, new_udriver->name);
++ }
+
+ return retval;
+ }
+diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
+index 4626227a6dd22..cd08a47144bd3 100644
+--- a/drivers/usb/core/generic.c
++++ b/drivers/usb/core/generic.c
+@@ -207,8 +207,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data)
+ return 0;
+ if (!udrv->id_table)
+ return 0;
+-
+- return usb_device_match_id(udev, udrv->id_table) != NULL;
++ if (usb_device_match_id(udev, udrv->id_table) != NULL)
++ return 1;
++ return (udrv->match && udrv->match(udev));
+ }
+
+ static bool usb_generic_driver_match(struct usb_device *udev)
+diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
+index c96c50faccf72..2f068e525a374 100644
+--- a/drivers/usb/core/quirks.c
++++ b/drivers/usb/core/quirks.c
+@@ -370,6 +370,10 @@ static const struct usb_device_id usb_quirk_list[] = {
+ { USB_DEVICE(0x0926, 0x0202), .driver_info =
+ USB_QUIRK_ENDPOINT_BLACKLIST },
+
++ /* Sound Devices MixPre-D */
++ { USB_DEVICE(0x0926, 0x0208), .driver_info =
++ USB_QUIRK_ENDPOINT_BLACKLIST },
++
+ /* Keytouch QWERTY Panel keyboard */
+ { USB_DEVICE(0x0926, 0x3333), .driver_info =
+ USB_QUIRK_CONFIG_INTF_STRINGS },
+@@ -465,6 +469,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 },
+
+@@ -509,6 +515,7 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = {
+ */
+ static const struct usb_device_id usb_endpoint_blacklist[] = {
+ { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 },
++ { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0208, 1), .driver_info = 0x85 },
+ { }
+ };
+
+diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
+index 80c3ef134e41d..1739c5ea93c82 100644
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -1054,27 +1054,25 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
+ * dwc3_prepare_one_trb - setup one TRB from one request
+ * @dep: endpoint for which this request is prepared
+ * @req: dwc3_request pointer
++ * @trb_length: buffer size of the TRB
+ * @chain: should this TRB be chained to the next?
+ * @node: only for isochronous endpoints. First TRB needs different type.
+ */
+ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
+- struct dwc3_request *req, unsigned chain, unsigned node)
++ struct dwc3_request *req, unsigned int trb_length,
++ unsigned chain, unsigned node)
+ {
+ struct dwc3_trb *trb;
+- unsigned int length;
+ dma_addr_t dma;
+ unsigned stream_id = req->request.stream_id;
+ unsigned short_not_ok = req->request.short_not_ok;
+ unsigned no_interrupt = req->request.no_interrupt;
+ unsigned is_last = req->request.is_last;
+
+- if (req->request.num_sgs > 0) {
+- length = sg_dma_len(req->start_sg);
++ if (req->request.num_sgs > 0)
+ dma = sg_dma_address(req->start_sg);
+- } else {
+- length = req->request.length;
++ else
+ dma = req->request.dma;
+- }
+
+ trb = &dep->trb_pool[dep->trb_enqueue];
+
+@@ -1086,7 +1084,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
+
+ req->num_trbs++;
+
+- __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node,
++ __dwc3_prepare_one_trb(dep, trb, dma, trb_length, chain, node,
+ stream_id, short_not_ok, no_interrupt, is_last);
+ }
+
+@@ -1096,16 +1094,27 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
+ struct scatterlist *sg = req->start_sg;
+ struct scatterlist *s;
+ int i;
+-
++ unsigned int length = req->request.length;
+ unsigned int remaining = req->request.num_mapped_sgs
+ - req->num_queued_sgs;
+
++ /*
++ * If we resume preparing the request, then get the remaining length of
++ * the request and resume where we left off.
++ */
++ for_each_sg(req->request.sg, s, req->num_queued_sgs, i)
++ length -= sg_dma_len(s);
++
+ for_each_sg(sg, s, remaining, i) {
+- unsigned int length = req->request.length;
+ unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
+ unsigned int rem = length % maxp;
++ unsigned int trb_length;
+ unsigned chain = true;
+
++ trb_length = min_t(unsigned int, length, sg_dma_len(s));
++
++ length -= trb_length;
++
+ /*
+ * IOMMU driver is coalescing the list of sgs which shares a
+ * page boundary into one and giving it to USB driver. With
+@@ -1113,7 +1122,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
+ * sgs passed. So mark the chain bit to false if it isthe last
+ * mapped sg.
+ */
+- if (i == remaining - 1)
++ if ((i == remaining - 1) || !length)
+ chain = false;
+
+ if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
+@@ -1123,7 +1132,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
+ req->needs_extra_trb = true;
+
+ /* prepare normal TRB */
+- dwc3_prepare_one_trb(dep, req, true, i);
++ dwc3_prepare_one_trb(dep, req, trb_length, true, i);
+
+ /* Now prepare one extra TRB to align transfer size */
+ trb = &dep->trb_pool[dep->trb_enqueue];
+@@ -1134,8 +1143,39 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
+ req->request.short_not_ok,
+ req->request.no_interrupt,
+ req->request.is_last);
++ } else if (req->request.zero && req->request.length &&
++ !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
++ !rem && !chain) {
++ struct dwc3 *dwc = dep->dwc;
++ struct dwc3_trb *trb;
++
++ req->needs_extra_trb = true;
++
++ /* Prepare normal TRB */
++ dwc3_prepare_one_trb(dep, req, trb_length, true, i);
++
++ /* Prepare one extra TRB to handle ZLP */
++ trb = &dep->trb_pool[dep->trb_enqueue];
++ req->num_trbs++;
++ __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
++ !req->direction, 1,
++ req->request.stream_id,
++ req->request.short_not_ok,
++ req->request.no_interrupt,
++ req->request.is_last);
++
++ /* Prepare one more TRB to handle MPS alignment */
++ if (!req->direction) {
++ trb = &dep->trb_pool[dep->trb_enqueue];
++ req->num_trbs++;
++ __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp,
++ false, 1, req->request.stream_id,
++ req->request.short_not_ok,
++ req->request.no_interrupt,
++ req->request.is_last);
++ }
+ } else {
+- dwc3_prepare_one_trb(dep, req, chain, i);
++ dwc3_prepare_one_trb(dep, req, trb_length, chain, i);
+ }
+
+ /*
+@@ -1150,6 +1190,16 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
+
+ req->num_queued_sgs++;
+
++ /*
++ * The number of pending SG entries may not correspond to the
++ * number of mapped SG entries. If all the data are queued, then
++ * don't include unused SG entries.
++ */
++ if (length == 0) {
++ req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs;
++ break;
++ }
++
+ if (!dwc3_calc_trbs_left(dep))
+ break;
+ }
+@@ -1169,7 +1219,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
+ req->needs_extra_trb = true;
+
+ /* prepare normal TRB */
+- dwc3_prepare_one_trb(dep, req, true, 0);
++ dwc3_prepare_one_trb(dep, req, length, true, 0);
+
+ /* Now prepare one extra TRB to align transfer size */
+ trb = &dep->trb_pool[dep->trb_enqueue];
+@@ -1180,6 +1230,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
+ req->request.no_interrupt,
+ req->request.is_last);
+ } else if (req->request.zero && req->request.length &&
++ !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
+ (IS_ALIGNED(req->request.length, maxp))) {
+ struct dwc3 *dwc = dep->dwc;
+ struct dwc3_trb *trb;
+@@ -1187,18 +1238,29 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
+ req->needs_extra_trb = true;
+
+ /* prepare normal TRB */
+- dwc3_prepare_one_trb(dep, req, true, 0);
++ dwc3_prepare_one_trb(dep, req, length, true, 0);
+
+- /* Now prepare one extra TRB to handle ZLP */
++ /* Prepare one extra TRB to handle ZLP */
+ trb = &dep->trb_pool[dep->trb_enqueue];
+ req->num_trbs++;
+ __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
+- false, 1, req->request.stream_id,
++ !req->direction, 1, req->request.stream_id,
+ req->request.short_not_ok,
+ req->request.no_interrupt,
+ req->request.is_last);
++
++ /* Prepare one more TRB to handle MPS alignment for OUT */
++ if (!req->direction) {
++ trb = &dep->trb_pool[dep->trb_enqueue];
++ req->num_trbs++;
++ __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp,
++ false, 1, req->request.stream_id,
++ req->request.short_not_ok,
++ req->request.no_interrupt,
++ req->request.is_last);
++ }
+ } else {
+- dwc3_prepare_one_trb(dep, req, false, 0);
++ dwc3_prepare_one_trb(dep, req, length, false, 0);
+ }
+ }
+
+@@ -2649,8 +2711,17 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
+ status);
+
+ if (req->needs_extra_trb) {
++ unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
++
+ ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
+ status);
++
++ /* Reclaim MPS padding TRB for ZLP */
++ if (!req->direction && req->request.zero && req->request.length &&
++ !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
++ (IS_ALIGNED(req->request.length, maxp)))
++ ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status);
++
+ req->needs_extra_trb = false;
+ }
+
+diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
+index 1d900081b1f0c..b4206b0dede54 100644
+--- a/drivers/usb/gadget/function/f_ncm.c
++++ b/drivers/usb/gadget/function/f_ncm.c
+@@ -1181,12 +1181,15 @@ static int ncm_unwrap_ntb(struct gether *port,
+ int ndp_index;
+ unsigned dg_len, dg_len2;
+ unsigned ndp_len;
++ unsigned block_len;
+ struct sk_buff *skb2;
+ int ret = -EINVAL;
+- unsigned max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
++ unsigned ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
++ unsigned frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize);
+ const struct ndp_parser_opts *opts = ncm->parser_opts;
+ unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
+ int dgram_counter;
++ bool ndp_after_header;
+
+ /* dwSignature */
+ if (get_unaligned_le32(tmp) != opts->nth_sign) {
+@@ -1205,25 +1208,37 @@ static int ncm_unwrap_ntb(struct gether *port,
+ }
+ tmp++; /* skip wSequence */
+
++ block_len = get_ncm(&tmp, opts->block_length);
+ /* (d)wBlockLength */
+- if (get_ncm(&tmp, opts->block_length) > max_size) {
++ if (block_len > ntb_max) {
+ INFO(port->func.config->cdev, "OUT size exceeded\n");
+ goto err;
+ }
+
+ ndp_index = get_ncm(&tmp, opts->ndp_index);
++ ndp_after_header = false;
+
+ /* Run through all the NDP's in the NTB */
+ do {
+- /* NCM 3.2 */
+- if (((ndp_index % 4) != 0) &&
+- (ndp_index < opts->nth_size)) {
++ /*
++ * NCM 3.2
++ * dwNdpIndex
++ */
++ if (((ndp_index % 4) != 0) ||
++ (ndp_index < opts->nth_size) ||
++ (ndp_index > (block_len -
++ opts->ndp_size))) {
+ INFO(port->func.config->cdev, "Bad index: %#X\n",
+ ndp_index);
+ goto err;
+ }
++ if (ndp_index == opts->nth_size)
++ ndp_after_header = true;
+
+- /* walk through NDP */
++ /*
++ * walk through NDP
++ * dwSignature
++ */
+ tmp = (void *)(skb->data + ndp_index);
+ if (get_unaligned_le32(tmp) != ncm->ndp_sign) {
+ INFO(port->func.config->cdev, "Wrong NDP SIGN\n");
+@@ -1234,14 +1249,15 @@ static int ncm_unwrap_ntb(struct gether *port,
+ ndp_len = get_unaligned_le16(tmp++);
+ /*
+ * NCM 3.3.1
++ * wLength
+ * entry is 2 items
+ * item size is 16/32 bits, opts->dgram_item_len * 2 bytes
+ * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry
+ * Each entry is a dgram index and a dgram length.
+ */
+ if ((ndp_len < opts->ndp_size
+- + 2 * 2 * (opts->dgram_item_len * 2))
+- || (ndp_len % opts->ndplen_align != 0)) {
++ + 2 * 2 * (opts->dgram_item_len * 2)) ||
++ (ndp_len % opts->ndplen_align != 0)) {
+ INFO(port->func.config->cdev, "Bad NDP length: %#X\n",
+ ndp_len);
+ goto err;
+@@ -1258,8 +1274,21 @@ static int ncm_unwrap_ntb(struct gether *port,
+
+ do {
+ index = index2;
++ /* wDatagramIndex[0] */
++ if ((index < opts->nth_size) ||
++ (index > block_len - opts->dpe_size)) {
++ INFO(port->func.config->cdev,
++ "Bad index: %#X\n", index);
++ goto err;
++ }
++
+ dg_len = dg_len2;
+- if (dg_len < 14 + crc_len) { /* ethernet hdr + crc */
++ /*
++ * wDatagramLength[0]
++ * ethernet hdr + crc or larger than max frame size
++ */
++ if ((dg_len < 14 + crc_len) ||
++ (dg_len > frame_max)) {
+ INFO(port->func.config->cdev,
+ "Bad dgram length: %#X\n", dg_len);
+ goto err;
+@@ -1283,6 +1312,37 @@ static int ncm_unwrap_ntb(struct gether *port,
+ index2 = get_ncm(&tmp, opts->dgram_item_len);
+ dg_len2 = get_ncm(&tmp, opts->dgram_item_len);
+
++ if (index2 == 0 || dg_len2 == 0)
++ break;
++
++ /* wDatagramIndex[1] */
++ if (ndp_after_header) {
++ if (index2 < opts->nth_size + opts->ndp_size) {
++ INFO(port->func.config->cdev,
++ "Bad index: %#X\n", index2);
++ goto err;
++ }
++ } else {
++ if (index2 < opts->nth_size + opts->dpe_size) {
++ INFO(port->func.config->cdev,
++ "Bad index: %#X\n", index2);
++ goto err;
++ }
++ }
++ if (index2 > block_len - opts->dpe_size) {
++ INFO(port->func.config->cdev,
++ "Bad index: %#X\n", index2);
++ goto err;
++ }
++
++ /* wDatagramLength[1] */
++ if ((dg_len2 < 14 + crc_len) ||
++ (dg_len2 > frame_max)) {
++ INFO(port->func.config->cdev,
++ "Bad dgram length: %#X\n", dg_len);
++ goto err;
++ }
++
+ /*
+ * Copy the data into a new skb.
+ * This ensures the truesize is correct
+@@ -1299,9 +1359,6 @@ static int ncm_unwrap_ntb(struct gether *port,
+ ndp_len -= 2 * (opts->dgram_item_len * 2);
+
+ dgram_counter++;
+-
+- if (index2 == 0 || dg_len2 == 0)
+- break;
+ } while (ndp_len > 2 * (opts->dgram_item_len * 2));
+ } while (ndp_index);
+
+diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
+index eaf556ceac32b..0a45b4ef66a67 100644
+--- a/drivers/usb/gadget/function/f_tcm.c
++++ b/drivers/usb/gadget/function/f_tcm.c
+@@ -753,12 +753,13 @@ static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream)
+ goto err_sts;
+
+ return 0;
++
+ err_sts:
+- usb_ep_free_request(fu->ep_status, stream->req_status);
+- stream->req_status = NULL;
+-err_out:
+ usb_ep_free_request(fu->ep_out, stream->req_out);
+ stream->req_out = NULL;
++err_out:
++ usb_ep_free_request(fu->ep_in, stream->req_in);
++ stream->req_in = NULL;
+ out:
+ return -ENOMEM;
+ }
+diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
+index eaa13fd3dc7f3..e313c3b8dcb19 100644
+--- a/drivers/usb/gadget/u_f.h
++++ b/drivers/usb/gadget/u_f.h
+@@ -14,6 +14,7 @@
+ #define __U_F_H__
+
+ #include <linux/usb/gadget.h>
++#include <linux/overflow.h>
+
+ /* Variable Length Array Macros **********************************************/
+ #define vla_group(groupname) size_t groupname##__next = 0
+@@ -21,21 +22,36 @@
+
+ #define vla_item(groupname, type, name, n) \
+ size_t groupname##_##name##__offset = ({ \
+- size_t align_mask = __alignof__(type) - 1; \
+- size_t offset = (groupname##__next + align_mask) & ~align_mask;\
+- size_t size = (n) * sizeof(type); \
+- groupname##__next = offset + size; \
++ size_t offset = 0; \
++ if (groupname##__next != SIZE_MAX) { \
++ size_t align_mask = __alignof__(type) - 1; \
++ size_t size = array_size(n, sizeof(type)); \
++ offset = (groupname##__next + align_mask) & \
++ ~align_mask; \
++ if (check_add_overflow(offset, size, \
++ &groupname##__next)) { \
++ groupname##__next = SIZE_MAX; \
++ offset = 0; \
++ } \
++ } \
+ offset; \
+ })
+
+ #define vla_item_with_sz(groupname, type, name, n) \
+- size_t groupname##_##name##__sz = (n) * sizeof(type); \
+- size_t groupname##_##name##__offset = ({ \
+- size_t align_mask = __alignof__(type) - 1; \
+- size_t offset = (groupname##__next + align_mask) & ~align_mask;\
+- size_t size = groupname##_##name##__sz; \
+- groupname##__next = offset + size; \
+- offset; \
++ size_t groupname##_##name##__sz = array_size(n, sizeof(type)); \
++ size_t groupname##_##name##__offset = ({ \
++ size_t offset = 0; \
++ if (groupname##__next != SIZE_MAX) { \
++ size_t align_mask = __alignof__(type) - 1; \
++ offset = (groupname##__next + align_mask) & \
++ ~align_mask; \
++ if (check_add_overflow(offset, groupname##_##name##__sz,\
++ &groupname##__next)) { \
++ groupname##__next = SIZE_MAX; \
++ offset = 0; \
++ } \
++ } \
++ offset; \
+ })
+
+ #define vla_ptr(ptr, groupname, name) \
+diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
+index bd40e597f2566..5f5e8a64c8e2e 100644
+--- a/drivers/usb/host/ohci-exynos.c
++++ b/drivers/usb/host/ohci-exynos.c
+@@ -171,9 +171,8 @@ static int exynos_ohci_probe(struct platform_device *pdev)
+ 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-debugfs.c b/drivers/usb/host/xhci-debugfs.c
+index 76c3f29562d2b..448d7b11dec4c 100644
+--- a/drivers/usb/host/xhci-debugfs.c
++++ b/drivers/usb/host/xhci-debugfs.c
+@@ -273,7 +273,7 @@ static int xhci_slot_context_show(struct seq_file *s, void *unused)
+
+ static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
+ {
+- int dci;
++ int ep_index;
+ dma_addr_t dma;
+ struct xhci_hcd *xhci;
+ struct xhci_ep_ctx *ep_ctx;
+@@ -282,9 +282,9 @@ static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
+
+ xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
+
+- for (dci = 1; dci < 32; dci++) {
+- ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci);
+- dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params);
++ for (ep_index = 0; ep_index < 31; ep_index++) {
++ ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
++ dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
+ seq_printf(s, "%pad: %s\n", &dma,
+ xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info),
+ le32_to_cpu(ep_ctx->ep_info2),
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
+index f37316d2c8fa4..fa8f7935c2abe 100644
+--- a/drivers/usb/host/xhci-hub.c
++++ b/drivers/usb/host/xhci-hub.c
+@@ -740,15 +740,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
+ */
+@@ -770,6 +761,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/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c
+index 59b1965ad0a3f..f97ac9f52bf4d 100644
+--- a/drivers/usb/host/xhci-pci-renesas.c
++++ b/drivers/usb/host/xhci-pci-renesas.c
+@@ -50,20 +50,6 @@
+ #define RENESAS_RETRY 10000
+ #define RENESAS_DELAY 10
+
+-#define ROM_VALID_01 0x2013
+-#define ROM_VALID_02 0x2026
+-
+-static int renesas_verify_fw_version(struct pci_dev *pdev, u32 version)
+-{
+- switch (version) {
+- case ROM_VALID_01:
+- case ROM_VALID_02:
+- return 0;
+- }
+- dev_err(&pdev->dev, "FW has invalid version :%d\n", version);
+- return -EINVAL;
+-}
+-
+ static int renesas_fw_download_image(struct pci_dev *dev,
+ const u32 *fw, size_t step, bool rom)
+ {
+@@ -202,10 +188,7 @@ static int renesas_check_rom_state(struct pci_dev *pdev)
+
+ version &= RENESAS_FW_VERSION_FIELD;
+ version = version >> RENESAS_FW_VERSION_OFFSET;
+-
+- err = renesas_verify_fw_version(pdev, version);
+- if (err)
+- return err;
++ dev_dbg(&pdev->dev, "Found ROM version: %x\n", version);
+
+ /*
+ * Test if ROM is present and loaded, if so we can skip everything
+diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
+index ee6bf01775bba..545bdecc8f15e 100644
+--- a/drivers/usb/host/xhci-tegra.c
++++ b/drivers/usb/host/xhci-tegra.c
+@@ -1136,7 +1136,7 @@ static struct phy *tegra_xusb_get_phy(struct tegra_xusb *tegra, char *name,
+ unsigned int i, phy_count = 0;
+
+ for (i = 0; i < tegra->soc->num_types; i++) {
+- if (!strncmp(tegra->soc->phy_types[i].name, "usb2",
++ if (!strncmp(tegra->soc->phy_types[i].name, name,
+ strlen(name)))
+ return tegra->phys[phy_count+port];
+
+@@ -1258,6 +1258,8 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra)
+
+ INIT_WORK(&tegra->id_work, tegra_xhci_id_work);
+ tegra->id_nb.notifier_call = tegra_xhci_id_notify;
++ tegra->otg_usb2_port = -EINVAL;
++ tegra->otg_usb3_port = -EINVAL;
+
+ for (i = 0; i < tegra->num_usb_phys; i++) {
+ struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
+diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
+index ed468eed299c5..113ab5d3cbfe5 100644
+--- a/drivers/usb/host/xhci.c
++++ b/drivers/usb/host/xhci.c
+@@ -3236,10 +3236,11 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
+
+ wait_for_completion(cfg_cmd->completion);
+
+- ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
+ xhci_free_command(xhci, cfg_cmd);
+ cleanup:
+ xhci_free_command(xhci, stop_cmd);
++ if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE)
++ ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
+ }
+
+ static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
+diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
+index 407fe7570f3bc..f8686139d6f39 100644
+--- a/drivers/usb/misc/lvstest.c
++++ b/drivers/usb/misc/lvstest.c
+@@ -426,7 +426,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 fc8a5da4a07c9..0734e6dd93862 100644
+--- a/drivers/usb/misc/sisusbvga/sisusb.c
++++ b/drivers/usb/misc/sisusbvga/sisusb.c
+@@ -761,7 +761,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 be0505b8b5d4e..785080f790738 100644
+--- a/drivers/usb/misc/yurex.c
++++ b/drivers/usb/misc/yurex.c
+@@ -492,7 +492,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 b6a9a74516201..e5f9557690f9e 100644
+--- a/drivers/usb/storage/unusual_devs.h
++++ b/drivers/usb/storage/unusual_devs.h
+@@ -2328,7 +2328,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 <wrar@altlinux.org> */
+ UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
+diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
+index 162b09d69f62f..711ab240058c7 100644
+--- a/drivers/usb/storage/unusual_uas.h
++++ b/drivers/usb/storage/unusual_uas.h
+@@ -28,6 +28,13 @@
+ * and don't forget to CC: the USB development list <linux-usb@vger.kernel.org>
+ */
+
++/* Reported-by: Till Dörges <doerges@pre-sense.de> */
++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ß <julian.g@posteo.de> */
+ UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
+ "LaCie",
+@@ -80,6 +87,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+ US_FL_BROKEN_FUA),
+
++/* Reported-by: Thinh Nguyen <thinhn@synopsys.com> */
++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 <hdegoede@redhat.com> */
+ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
+ "VIA",
+diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
+index 82b19ebd7838e..b2111fe6d140a 100644
+--- a/drivers/usb/typec/tcpm/tcpm.c
++++ b/drivers/usb/typec/tcpm/tcpm.c
+@@ -3321,13 +3321,31 @@ static void run_state_machine(struct tcpm_port *port)
+ tcpm_set_state(port, SNK_HARD_RESET_SINK_OFF, 0);
+ break;
+ case SRC_HARD_RESET_VBUS_OFF:
+- tcpm_set_vconn(port, true);
++ /*
++ * 7.1.5 Response to Hard Resets
++ * Hard Reset Signaling indicates a communication failure has occurred and the
++ * Source Shall stop driving VCONN, Shall remove Rp from the VCONN pin and Shall
++ * drive VBUS to vSafe0V as shown in Figure 7-9.
++ */
++ tcpm_set_vconn(port, false);
+ tcpm_set_vbus(port, false);
+ tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE,
+ tcpm_data_role_for_source(port));
+- tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);
++ /*
++ * If tcpc fails to notify vbus off, TCPM will wait for PD_T_SAFE_0V +
++ * PD_T_SRC_RECOVER before turning vbus back on.
++ * From Table 7-12 Sequence Description for a Source Initiated Hard Reset:
++ * 4. Policy Engine waits tPSHardReset after sending Hard Reset Signaling and then
++ * tells the Device Policy Manager to instruct the power supply to perform a
++ * Hard Reset. The transition to vSafe0V Shall occur within tSafe0V (t2).
++ * 5. After tSrcRecover the Source applies power to VBUS in an attempt to
++ * re-establish communication with the Sink and resume USB Default Operation.
++ * The transition to vSafe5V Shall occur within tSrcTurnOn(t4).
++ */
++ tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SAFE_0V + PD_T_SRC_RECOVER);
+ break;
+ case SRC_HARD_RESET_VBUS_ON:
++ tcpm_set_vconn(port, true);
+ tcpm_set_vbus(port, true);
+ port->tcpc->set_pd_rx(port->tcpc, true);
+ tcpm_set_attached_state(port, true);
+@@ -3887,7 +3905,11 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)
+ tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0);
+ break;
+ case SRC_HARD_RESET_VBUS_OFF:
+- tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, 0);
++ /*
++ * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait
++ * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V.
++ */
++ tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);
+ break;
+ case HARD_RESET_SEND:
+ break;
+diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
+index 048381c058a5b..261131c9e37c6 100644
+--- a/drivers/usb/typec/ucsi/displayport.c
++++ b/drivers/usb/typec/ucsi/displayport.c
+@@ -288,8 +288,6 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
+ struct typec_altmode *alt;
+ struct ucsi_dp *dp;
+
+- mutex_lock(&con->lock);
+-
+ /* We can't rely on the firmware with the capabilities. */
+ desc->vdo |= DP_CAP_DP_SIGNALING | DP_CAP_RECEPTACLE;
+
+@@ -298,15 +296,12 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
+ desc->vdo |= all_assignments << 16;
+
+ alt = typec_port_register_altmode(con->port, desc);
+- if (IS_ERR(alt)) {
+- mutex_unlock(&con->lock);
++ if (IS_ERR(alt))
+ return alt;
+- }
+
+ dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);
+ if (!dp) {
+ typec_unregister_altmode(alt);
+- mutex_unlock(&con->lock);
+ return ERR_PTR(-ENOMEM);
+ }
+
+@@ -319,7 +314,5 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
+ alt->ops = &ucsi_displayport_ops;
+ typec_altmode_set_drvdata(alt, dp);
+
+- mutex_unlock(&con->lock);
+-
+ return alt;
+ }
+diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
+index d0c63afaf345d..2999217c81090 100644
+--- a/drivers/usb/typec/ucsi/ucsi.c
++++ b/drivers/usb/typec/ucsi/ucsi.c
+@@ -146,40 +146,33 @@ static int ucsi_exec_command(struct ucsi *ucsi, u64 cmd)
+ return UCSI_CCI_LENGTH(cci);
+ }
+
+-static int ucsi_run_command(struct ucsi *ucsi, u64 command,
+- void *data, size_t size)
++int ucsi_send_command(struct ucsi *ucsi, u64 command,
++ void *data, size_t size)
+ {
+ u8 length;
+ int ret;
+
++ mutex_lock(&ucsi->ppm_lock);
++
+ ret = ucsi_exec_command(ucsi, command);
+ if (ret < 0)
+- return ret;
++ goto out;
+
+ length = ret;
+
+ if (data) {
+ ret = ucsi->ops->read(ucsi, UCSI_MESSAGE_IN, data, size);
+ if (ret)
+- return ret;
++ goto out;
+ }
+
+ ret = ucsi_acknowledge_command(ucsi);
+ if (ret)
+- return ret;
+-
+- return length;
+-}
+-
+-int ucsi_send_command(struct ucsi *ucsi, u64 command,
+- void *retval, size_t size)
+-{
+- int ret;
++ goto out;
+
+- mutex_lock(&ucsi->ppm_lock);
+- ret = ucsi_run_command(ucsi, command, retval, size);
++ ret = length;
++out:
+ mutex_unlock(&ucsi->ppm_lock);
+-
+ return ret;
+ }
+ EXPORT_SYMBOL_GPL(ucsi_send_command);
+@@ -205,7 +198,7 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
+ int i;
+
+ command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num);
+- ret = ucsi_run_command(con->ucsi, command, &cur, sizeof(cur));
++ ret = ucsi_send_command(con->ucsi, command, &cur, sizeof(cur));
+ if (ret < 0) {
+ if (con->ucsi->version > 0x0100) {
+ dev_err(con->ucsi->dev,
+@@ -354,7 +347,7 @@ ucsi_register_altmodes_nvidia(struct ucsi_connector *con, u8 recipient)
+ command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
+ command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
+ command |= UCSI_GET_ALTMODE_OFFSET(i);
+- len = ucsi_run_command(con->ucsi, command, &alt, sizeof(alt));
++ len = ucsi_send_command(con->ucsi, command, &alt, sizeof(alt));
+ /*
+ * We are collecting all altmodes first and then registering.
+ * Some type-C device will return zero length data beyond last
+@@ -431,7 +424,7 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
+ command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
+ command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
+ command |= UCSI_GET_ALTMODE_OFFSET(i);
+- len = ucsi_run_command(con->ucsi, command, alt, sizeof(alt));
++ len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));
+ if (len <= 0)
+ return len;
+
+@@ -502,7 +495,7 @@ static void ucsi_get_pdos(struct ucsi_connector *con, int is_partner)
+ command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner);
+ command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1);
+ command |= UCSI_GET_PDOS_SRC_PDOS;
+- ret = ucsi_run_command(ucsi, command, con->src_pdos,
++ ret = ucsi_send_command(ucsi, command, con->src_pdos,
+ sizeof(con->src_pdos));
+ if (ret < 0) {
+ dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
+@@ -681,7 +674,7 @@ static void ucsi_handle_connector_change(struct work_struct *work)
+ */
+ command = UCSI_GET_CAM_SUPPORTED;
+ command |= UCSI_CONNECTOR_NUMBER(con->num);
+- ucsi_run_command(con->ucsi, command, NULL, 0);
++ ucsi_send_command(con->ucsi, command, NULL, 0);
+ }
+
+ if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE)
+@@ -736,20 +729,24 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
+ u32 cci;
+ int ret;
+
++ mutex_lock(&ucsi->ppm_lock);
++
+ ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,
+ sizeof(command));
+ if (ret < 0)
+- return ret;
++ goto out;
+
+ tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);
+
+ do {
+- if (time_is_before_jiffies(tmo))
+- return -ETIMEDOUT;
++ if (time_is_before_jiffies(tmo)) {
++ ret = -ETIMEDOUT;
++ goto out;
++ }
+
+ ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
+ if (ret)
+- return ret;
++ goto out;
+
+ /* If the PPM is still doing something else, reset it again. */
+ if (cci & ~UCSI_CCI_RESET_COMPLETE) {
+@@ -757,13 +754,15 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
+ &command,
+ sizeof(command));
+ if (ret < 0)
+- return ret;
++ goto out;
+ }
+
+ msleep(20);
+ } while (!(cci & UCSI_CCI_RESET_COMPLETE));
+
+- return 0;
++out:
++ mutex_unlock(&ucsi->ppm_lock);
++ return ret;
+ }
+
+ static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
+@@ -775,9 +774,7 @@ static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
+ u64 c;
+
+ /* PPM most likely stopped responding. Resetting everything. */
+- mutex_lock(&con->ucsi->ppm_lock);
+ ucsi_reset_ppm(con->ucsi);
+- mutex_unlock(&con->ucsi->ppm_lock);
+
+ c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy;
+ ucsi_send_command(con->ucsi, c, NULL, 0);
+@@ -901,12 +898,15 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
+ con->num = index + 1;
+ con->ucsi = ucsi;
+
++ /* Delay other interactions with the con until registration is complete */
++ mutex_lock(&con->lock);
++
+ /* Get connector capability */
+ command = UCSI_GET_CONNECTOR_CAPABILITY;
+ command |= UCSI_CONNECTOR_NUMBER(con->num);
+- ret = ucsi_run_command(ucsi, command, &con->cap, sizeof(con->cap));
++ ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
+ if (ret < 0)
+- return ret;
++ goto out;
+
+ if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)
+ cap->data = TYPEC_PORT_DRD;
+@@ -938,27 +938,32 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
+
+ ret = ucsi_register_port_psy(con);
+ if (ret)
+- return ret;
++ goto out;
+
+ /* Register the connector */
+ con->port = typec_register_port(ucsi->dev, cap);
+- if (IS_ERR(con->port))
+- return PTR_ERR(con->port);
++ if (IS_ERR(con->port)) {
++ ret = PTR_ERR(con->port);
++ goto out;
++ }
+
+ /* Alternate modes */
+ ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_CON);
+- if (ret)
++ if (ret) {
+ dev_err(ucsi->dev, "con%d: failed to register alt modes\n",
+ con->num);
++ goto out;
++ }
+
+ /* Get the status */
+ command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num);
+- ret = ucsi_run_command(ucsi, command, &con->status,
+- sizeof(con->status));
++ ret = ucsi_send_command(ucsi, command, &con->status, sizeof(con->status));
+ if (ret < 0) {
+ dev_err(ucsi->dev, "con%d: failed to get status\n", con->num);
+- return 0;
++ ret = 0;
++ goto out;
+ }
++ ret = 0; /* ucsi_send_command() returns length on success */
+
+ switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
+ case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+@@ -983,17 +988,21 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
+
+ if (con->partner) {
+ ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP);
+- if (ret)
++ if (ret) {
+ dev_err(ucsi->dev,
+ "con%d: failed to register alternate modes\n",
+ con->num);
+- else
++ ret = 0;
++ } else {
+ ucsi_altmode_update_active(con);
++ }
+ }
+
+ trace_ucsi_register_port(con->num, &con->status);
+
+- return 0;
++out:
++ mutex_unlock(&con->lock);
++ return ret;
+ }
+
+ /**
+@@ -1009,8 +1018,6 @@ int ucsi_init(struct ucsi *ucsi)
+ int ret;
+ int i;
+
+- mutex_lock(&ucsi->ppm_lock);
+-
+ /* Reset the PPM */
+ ret = ucsi_reset_ppm(ucsi);
+ if (ret) {
+@@ -1021,13 +1028,13 @@ int ucsi_init(struct ucsi *ucsi)
+ /* Enable basic notifications */
+ ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR;
+ command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
+- ret = ucsi_run_command(ucsi, command, NULL, 0);
++ ret = ucsi_send_command(ucsi, command, NULL, 0);
+ if (ret < 0)
+ goto err_reset;
+
+ /* Get PPM capabilities */
+ command = UCSI_GET_CAPABILITY;
+- ret = ucsi_run_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
++ ret = ucsi_send_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
+ if (ret < 0)
+ goto err_reset;
+
+@@ -1054,12 +1061,10 @@ int ucsi_init(struct ucsi *ucsi)
+ /* Enable all notifications */
+ ucsi->ntfy = UCSI_ENABLE_NTFY_ALL;
+ command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
+- ret = ucsi_run_command(ucsi, command, NULL, 0);
++ ret = ucsi_send_command(ucsi, command, NULL, 0);
+ if (ret < 0)
+ goto err_unregister;
+
+- mutex_unlock(&ucsi->ppm_lock);
+-
+ return 0;
+
+ err_unregister:
+@@ -1074,8 +1079,6 @@ err_unregister:
+ err_reset:
+ ucsi_reset_ppm(ucsi);
+ err:
+- mutex_unlock(&ucsi->ppm_lock);
+-
+ return ret;
+ }
+ EXPORT_SYMBOL_GPL(ucsi_init);
+diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
+index 2305d425e6c9a..9d7d642022d1f 100644
+--- a/drivers/usb/usbip/stub_dev.c
++++ b/drivers/usb/usbip/stub_dev.c
+@@ -461,6 +461,11 @@ static void stub_disconnect(struct usb_device *udev)
+ return;
+ }
+
++static bool usbip_match(struct usb_device *udev)
++{
++ return true;
++}
++
+ #ifdef CONFIG_PM
+
+ /* These functions need usb_port_suspend and usb_port_resume,
+@@ -486,6 +491,7 @@ struct usb_device_driver stub_driver = {
+ .name = "usbip-host",
+ .probe = stub_probe,
+ .disconnect = stub_disconnect,
++ .match = usbip_match,
+ #ifdef CONFIG_PM
+ .suspend = stub_suspend,
+ .resume = stub_resume,
+diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h
+index f4554412e607f..29efa75cdfce5 100644
+--- a/drivers/vdpa/ifcvf/ifcvf_base.h
++++ b/drivers/vdpa/ifcvf/ifcvf_base.h
+@@ -84,7 +84,7 @@ struct ifcvf_hw {
+ void __iomem * const *base;
+ char config_msix_name[256];
+ struct vdpa_callback config_cb;
+-
++ unsigned int config_irq;
+ };
+
+ struct ifcvf_adapter {
+diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
+index f5a60c14b9799..7a6d899e541df 100644
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -53,6 +53,7 @@ static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues)
+ for (i = 0; i < queues; i++)
+ devm_free_irq(&pdev->dev, vf->vring[i].irq, &vf->vring[i]);
+
++ devm_free_irq(&pdev->dev, vf->config_irq, vf);
+ ifcvf_free_irq_vectors(pdev);
+ }
+
+@@ -72,10 +73,14 @@ static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
+ snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n",
+ pci_name(pdev));
+ vector = 0;
+- irq = pci_irq_vector(pdev, vector);
+- ret = devm_request_irq(&pdev->dev, irq,
++ vf->config_irq = pci_irq_vector(pdev, vector);
++ ret = devm_request_irq(&pdev->dev, vf->config_irq,
+ ifcvf_config_changed, 0,
+ vf->config_msix_name, vf);
++ if (ret) {
++ IFCVF_ERR(pdev, "Failed to request config irq\n");
++ return ret;
++ }
+
+ for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++) {
+ snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n",
+diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c
+index 9c4f1be856eca..547abeb39f87a 100644
+--- a/drivers/video/fbdev/controlfb.c
++++ b/drivers/video/fbdev/controlfb.c
+@@ -49,6 +49,8 @@
+ #include <linux/cuda.h>
+ #ifdef CONFIG_PPC_PMAC
+ #include <asm/prom.h>
++#endif
++#ifdef CONFIG_BOOTX_TEXT
+ #include <asm/btext.h>
+ #endif
+
+diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
+index e2a490c5ae08f..fbf10e62bcde9 100644
+--- a/drivers/video/fbdev/core/fbcon.c
++++ b/drivers/video/fbdev/core/fbcon.c
+@@ -2191,6 +2191,9 @@ static void updatescrollmode(struct fbcon_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)
+ {
+@@ -2200,6 +2203,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,
+@@ -2652,7 +2673,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
+ 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 */
+@@ -2668,7 +2689,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
+ 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/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
+index 30e73ec4ad5c8..da7c88ffaa6a8 100644
+--- a/drivers/video/fbdev/core/fbmem.c
++++ b/drivers/video/fbdev/core/fbmem.c
+@@ -957,7 +957,6 @@ static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var,
+ int
+ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
+ {
+- int flags = info->flags;
+ int ret = 0;
+ u32 activate;
+ struct fb_var_screeninfo old_var;
+@@ -1052,9 +1051,6 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
+ event.data = &mode;
+ fb_notifier_call_chain(FB_EVENT_MODE_CHANGE, &event);
+
+- if (flags & FBINFO_MISC_USEREVENT)
+- fbcon_update_vcs(info, activate & FB_ACTIVATE_ALL);
+-
+ return 0;
+ }
+ EXPORT_SYMBOL(fb_set_var);
+@@ -1105,9 +1101,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
+ return -EFAULT;
+ console_lock();
+ lock_fb_info(info);
+- info->flags |= FBINFO_MISC_USEREVENT;
+ ret = fb_set_var(info, &var);
+- info->flags &= ~FBINFO_MISC_USEREVENT;
++ if (!ret)
++ fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL);
+ unlock_fb_info(info);
+ console_unlock();
+ if (!ret && copy_to_user(argp, &var, sizeof(var)))
+diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
+index d54c88f88991d..65dae05fff8e6 100644
+--- a/drivers/video/fbdev/core/fbsysfs.c
++++ b/drivers/video/fbdev/core/fbsysfs.c
+@@ -91,9 +91,9 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var)
+
+ var->activate |= FB_ACTIVATE_FORCE;
+ console_lock();
+- fb_info->flags |= FBINFO_MISC_USEREVENT;
+ err = fb_set_var(fb_info, var);
+- fb_info->flags &= ~FBINFO_MISC_USEREVENT;
++ if (!err)
++ fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL);
+ console_unlock();
+ if (err)
+ return err;
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
+index 4a16798b2ecd8..e2b572761bf61 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
+@@ -520,8 +520,11 @@ int dispc_runtime_get(void)
+ DSSDBG("dispc_runtime_get\n");
+
+ r = pm_runtime_get_sync(&dispc.pdev->dev);
+- WARN_ON(r < 0);
+- return r < 0 ? r : 0;
++ if (WARN_ON(r < 0)) {
++ pm_runtime_put_sync(&dispc.pdev->dev);
++ return r;
++ }
++ return 0;
+ }
+ EXPORT_SYMBOL(dispc_runtime_get);
+
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+index d620376216e1d..6f9c25fec9946 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+@@ -1137,8 +1137,11 @@ static int dsi_runtime_get(struct platform_device *dsidev)
+ DSSDBG("dsi_runtime_get\n");
+
+ r = pm_runtime_get_sync(&dsi->pdev->dev);
+- WARN_ON(r < 0);
+- return r < 0 ? r : 0;
++ if (WARN_ON(r < 0)) {
++ pm_runtime_put_sync(&dsi->pdev->dev);
++ return r;
++ }
++ return 0;
+ }
+
+ static void dsi_runtime_put(struct platform_device *dsidev)
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
+index bfc5c4c5a26ad..a6b1c1598040d 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
+@@ -768,8 +768,11 @@ int dss_runtime_get(void)
+ DSSDBG("dss_runtime_get\n");
+
+ r = pm_runtime_get_sync(&dss.pdev->dev);
+- WARN_ON(r < 0);
+- return r < 0 ? r : 0;
++ if (WARN_ON(r < 0)) {
++ pm_runtime_put_sync(&dss.pdev->dev);
++ return r;
++ }
++ return 0;
+ }
+
+ void dss_runtime_put(void)
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+index 7060ae56c062c..4804aab342981 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+@@ -39,9 +39,10 @@ static int hdmi_runtime_get(void)
+ DSSDBG("hdmi_runtime_get\n");
+
+ r = pm_runtime_get_sync(&hdmi.pdev->dev);
+- WARN_ON(r < 0);
+- if (r < 0)
++ if (WARN_ON(r < 0)) {
++ pm_runtime_put_sync(&hdmi.pdev->dev);
+ return r;
++ }
+
+ return 0;
+ }
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+index ac49531e47327..a06b6f1355bdb 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+@@ -43,9 +43,10 @@ static int hdmi_runtime_get(void)
+ DSSDBG("hdmi_runtime_get\n");
+
+ r = pm_runtime_get_sync(&hdmi.pdev->dev);
+- WARN_ON(r < 0);
+- if (r < 0)
++ if (WARN_ON(r < 0)) {
++ pm_runtime_put_sync(&hdmi.pdev->dev);
+ return r;
++ }
+
+ return 0;
+ }
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+index d5404d56c922f..0b0ad20afd630 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+@@ -348,8 +348,11 @@ static int venc_runtime_get(void)
+ DSSDBG("venc_runtime_get\n");
+
+ r = pm_runtime_get_sync(&venc.pdev->dev);
+- WARN_ON(r < 0);
+- return r < 0 ? r : 0;
++ if (WARN_ON(r < 0)) {
++ pm_runtime_put_sync(&venc.pdev->dev);
++ return r;
++ }
++ return 0;
+ }
+
+ static void venc_runtime_put(void)
+diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
+index 9df78fb772672..203c254f8f6cb 100644
+--- a/drivers/video/fbdev/ps3fb.c
++++ b/drivers/video/fbdev/ps3fb.c
+@@ -29,6 +29,7 @@
+ #include <linux/freezer.h>
+ #include <linux/uaccess.h>
+ #include <linux/fb.h>
++#include <linux/fbcon.h>
+ #include <linux/init.h>
+
+ #include <asm/cell-regs.h>
+@@ -824,12 +825,12 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
+ var = info->var;
+ fb_videomode_to_var(&var, vmode);
+ console_lock();
+- info->flags |= FBINFO_MISC_USEREVENT;
+ /* Force, in case only special bits changed */
+ var.activate |= FB_ACTIVATE_FORCE;
+ par->new_mode_id = val;
+ retval = fb_set_var(info, &var);
+- info->flags &= ~FBINFO_MISC_USEREVENT;
++ if (!retval)
++ fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL);
+ console_unlock();
+ }
+ break;
+diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
+index 140c7bf33a989..90b8f56fbadb1 100644
+--- a/drivers/xen/events/events_base.c
++++ b/drivers/xen/events/events_base.c
+@@ -156,7 +156,7 @@ int get_evtchn_to_irq(evtchn_port_t 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. */
+@@ -377,7 +377,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);
+ }
+@@ -426,14 +426,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);
+
+@@ -603,7 +603,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
+ static void __unbind_from_irq(unsigned int irq)
+ {
+ evtchn_port_t 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--;
+@@ -1108,7 +1108,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;
+@@ -1142,7 +1142,7 @@ int evtchn_make_refcounted(evtchn_port_t evtchn)
+ if (irq == -1)
+ return -ENOENT;
+
+- info = irq_get_handler_data(irq);
++ info = irq_get_chip_data(irq);
+
+ if (!info)
+ return -ENOENT;
+@@ -1170,7 +1170,7 @@ int evtchn_get(evtchn_port_t 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/ctree.h b/fs/btrfs/ctree.h
+index 6fdb3392a06d5..284d9afa900b3 100644
+--- a/fs/btrfs/ctree.h
++++ b/fs/btrfs/ctree.h
+@@ -2468,7 +2468,7 @@ int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
+ u64 bytenr, u64 num_bytes);
+ int btrfs_exclude_logged_extents(struct extent_buffer *eb);
+ int btrfs_cross_ref_exist(struct btrfs_root *root,
+- u64 objectid, u64 offset, u64 bytenr);
++ u64 objectid, u64 offset, u64 bytenr, bool strict);
+ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ u64 parent, u64 root_objectid,
+@@ -2854,7 +2854,7 @@ struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,
+ u64 start, u64 len);
+ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+ u64 *orig_start, u64 *orig_block_len,
+- u64 *ram_bytes);
++ u64 *ram_bytes, bool strict);
+
+ void __btrfs_del_delalloc_inode(struct btrfs_root *root,
+ struct btrfs_inode *inode);
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
+index 66618a1794ea7..983f4d58ae59b 100644
+--- a/fs/btrfs/disk-io.c
++++ b/fs/btrfs/disk-io.c
+@@ -4574,6 +4574,7 @@ static void btrfs_cleanup_bg_io(struct btrfs_block_group *cache)
+ cache->io_ctl.inode = NULL;
+ iput(inode);
+ }
++ ASSERT(cache->io_ctl.pages == NULL);
+ btrfs_put_block_group(cache);
+ }
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index de6fe176fdfb3..5871ef78edbac 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2306,7 +2306,8 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+
+ static noinline int check_committed_ref(struct btrfs_root *root,
+ struct btrfs_path *path,
+- u64 objectid, u64 offset, u64 bytenr)
++ u64 objectid, u64 offset, u64 bytenr,
++ bool strict)
+ {
+ struct btrfs_fs_info *fs_info = root->fs_info;
+ struct btrfs_root *extent_root = fs_info->extent_root;
+@@ -2348,9 +2349,13 @@ static noinline int check_committed_ref(struct btrfs_root *root,
+ btrfs_extent_inline_ref_size(BTRFS_EXTENT_DATA_REF_KEY))
+ goto out;
+
+- /* If extent created before last snapshot => it's definitely shared */
+- if (btrfs_extent_generation(leaf, ei) <=
+- btrfs_root_last_snapshot(&root->root_item))
++ /*
++ * If extent created before last snapshot => it's shared unless the
++ * snapshot has been deleted. Use the heuristic if strict is false.
++ */
++ if (!strict &&
++ (btrfs_extent_generation(leaf, ei) <=
++ btrfs_root_last_snapshot(&root->root_item)))
+ goto out;
+
+ iref = (struct btrfs_extent_inline_ref *)(ei + 1);
+@@ -2375,7 +2380,7 @@ out:
+ }
+
+ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
+- u64 bytenr)
++ u64 bytenr, bool strict)
+ {
+ struct btrfs_path *path;
+ int ret;
+@@ -2386,7 +2391,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
+
+ do {
+ ret = check_committed_ref(root, path, objectid,
+- offset, bytenr);
++ offset, bytenr, strict);
+ if (ret && ret != -ENOENT)
+ goto out;
+
+diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
+index 1523aa4eaff07..e485f0275e1a6 100644
+--- a/fs/btrfs/file.c
++++ b/fs/btrfs/file.c
+@@ -1568,7 +1568,7 @@ int btrfs_check_can_nocow(struct btrfs_inode *inode, loff_t pos,
+ }
+
+ ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes,
+- NULL, NULL, NULL);
++ NULL, NULL, NULL, false);
+ if (ret <= 0) {
+ ret = 0;
+ if (!nowait)
+@@ -3176,14 +3176,14 @@ reserve_space:
+ if (ret < 0)
+ goto out;
+ space_reserved = true;
+- ret = btrfs_qgroup_reserve_data(inode, &data_reserved,
+- alloc_start, bytes_to_reserve);
+- if (ret)
+- goto out;
+ ret = btrfs_punch_hole_lock_range(inode, lockstart, lockend,
+ &cached_state);
+ if (ret)
+ goto out;
++ ret = btrfs_qgroup_reserve_data(inode, &data_reserved,
++ alloc_start, bytes_to_reserve);
++ if (ret)
++ goto out;
+ ret = btrfs_prealloc_file_range(inode, mode, alloc_start,
+ alloc_end - alloc_start,
+ i_blocksize(inode),
+diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
+index 6f7b6bca6dc5b..53cfcf017b8db 100644
+--- a/fs/btrfs/free-space-cache.c
++++ b/fs/btrfs/free-space-cache.c
+@@ -1186,7 +1186,6 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
+ ret = update_cache_item(trans, root, inode, path, offset,
+ io_ctl->entries, io_ctl->bitmaps);
+ out:
+- io_ctl_free(io_ctl);
+ if (ret) {
+ invalidate_inode_pages2(inode->i_mapping);
+ BTRFS_I(inode)->generation = 0;
+@@ -1346,6 +1345,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
+ * them out later
+ */
+ io_ctl_drop_pages(io_ctl);
++ io_ctl_free(io_ctl);
+
+ unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
+ i_size_read(inode) - 1, &cached_state);
+diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
+index 7ba1218b1630e..cb2a6893ec417 100644
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -1611,7 +1611,7 @@ next_slot:
+ goto out_check;
+ ret = btrfs_cross_ref_exist(root, ino,
+ found_key.offset -
+- extent_offset, disk_bytenr);
++ extent_offset, disk_bytenr, false);
+ if (ret) {
+ /*
+ * ret could be -EIO if the above fails to read
+@@ -6957,7 +6957,7 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode,
+ */
+ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+ u64 *orig_start, u64 *orig_block_len,
+- u64 *ram_bytes)
++ u64 *ram_bytes, bool strict)
+ {
+ struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+ struct btrfs_path *path;
+@@ -7035,8 +7035,9 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+ * Do the same check as in btrfs_cross_ref_exist but without the
+ * unnecessary search.
+ */
+- if (btrfs_file_extent_generation(leaf, fi) <=
+- btrfs_root_last_snapshot(&root->root_item))
++ if (!strict &&
++ (btrfs_file_extent_generation(leaf, fi) <=
++ btrfs_root_last_snapshot(&root->root_item)))
+ goto out;
+
+ backref_offset = btrfs_file_extent_offset(leaf, fi);
+@@ -7072,7 +7073,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+ */
+
+ ret = btrfs_cross_ref_exist(root, btrfs_ino(BTRFS_I(inode)),
+- key.offset - backref_offset, disk_bytenr);
++ key.offset - backref_offset, disk_bytenr,
++ strict);
+ if (ret) {
+ ret = 0;
+ goto out;
+@@ -7293,7 +7295,7 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map,
+ block_start = em->block_start + (start - em->start);
+
+ if (can_nocow_extent(inode, start, &len, &orig_start,
+- &orig_block_len, &ram_bytes) == 1 &&
++ &orig_block_len, &ram_bytes, false) == 1 &&
+ btrfs_inc_nocow_writers(fs_info, block_start)) {
+ struct extent_map *em2;
+
+@@ -8640,7 +8642,7 @@ void btrfs_destroy_inode(struct inode *inode)
+ btrfs_put_ordered_extent(ordered);
+ }
+ }
+- btrfs_qgroup_check_reserved_leak(inode);
++ btrfs_qgroup_check_reserved_leak(BTRFS_I(inode));
+ inode_tree_del(inode);
+ btrfs_drop_extent_cache(BTRFS_I(inode), 0, (u64)-1, 0);
+ btrfs_inode_clear_file_extent_range(BTRFS_I(inode), 0, (u64)-1);
+@@ -10103,7 +10105,7 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
+ free_extent_map(em);
+ em = NULL;
+
+- ret = can_nocow_extent(inode, start, &len, NULL, NULL, NULL);
++ ret = can_nocow_extent(inode, start, &len, NULL, NULL, NULL, true);
+ if (ret < 0) {
+ goto out;
+ } else if (ret) {
+diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
+index 5bd4089ad0e1a..574a669894774 100644
+--- a/fs/btrfs/qgroup.c
++++ b/fs/btrfs/qgroup.c
+@@ -3742,7 +3742,7 @@ void btrfs_qgroup_convert_reserved_meta(struct btrfs_root *root, int num_bytes)
+ * Check qgroup reserved space leaking, normally at destroy inode
+ * time
+ */
+-void btrfs_qgroup_check_reserved_leak(struct inode *inode)
++void btrfs_qgroup_check_reserved_leak(struct btrfs_inode *inode)
+ {
+ struct extent_changeset changeset;
+ struct ulist_node *unode;
+@@ -3750,19 +3750,19 @@ void btrfs_qgroup_check_reserved_leak(struct inode *inode)
+ int ret;
+
+ extent_changeset_init(&changeset);
+- ret = clear_record_extent_bits(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
++ ret = clear_record_extent_bits(&inode->io_tree, 0, (u64)-1,
+ EXTENT_QGROUP_RESERVED, &changeset);
+
+ WARN_ON(ret < 0);
+ if (WARN_ON(changeset.bytes_changed)) {
+ ULIST_ITER_INIT(&iter);
+ while ((unode = ulist_next(&changeset.range_changed, &iter))) {
+- btrfs_warn(BTRFS_I(inode)->root->fs_info,
+- "leaking qgroup reserved space, ino: %lu, start: %llu, end: %llu",
+- inode->i_ino, unode->val, unode->aux);
++ btrfs_warn(inode->root->fs_info,
++ "leaking qgroup reserved space, ino: %llu, start: %llu, end: %llu",
++ btrfs_ino(inode), unode->val, unode->aux);
+ }
+- btrfs_qgroup_free_refroot(BTRFS_I(inode)->root->fs_info,
+- BTRFS_I(inode)->root->root_key.objectid,
++ btrfs_qgroup_free_refroot(inode->root->fs_info,
++ inode->root->root_key.objectid,
+ changeset.bytes_changed, BTRFS_QGROUP_RSV_DATA);
+
+ }
+diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
+index 1bc6544594690..406366f20cb0a 100644
+--- a/fs/btrfs/qgroup.h
++++ b/fs/btrfs/qgroup.h
+@@ -399,7 +399,7 @@ void btrfs_qgroup_free_meta_all_pertrans(struct btrfs_root *root);
+ */
+ void btrfs_qgroup_convert_reserved_meta(struct btrfs_root *root, int num_bytes);
+
+-void btrfs_qgroup_check_reserved_leak(struct inode *inode);
++void btrfs_qgroup_check_reserved_leak(struct btrfs_inode *inode);
+
+ /* btrfs_qgroup_swapped_blocks related functions */
+ void btrfs_qgroup_init_swapped_blocks(
+diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
+index 56cd2cf571588..9eb03b0e0dd43 100644
+--- a/fs/btrfs/super.c
++++ b/fs/btrfs/super.c
+@@ -558,6 +558,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
+ } else if (strncmp(args[0].from, "lzo", 3) == 0) {
+ compress_type = "lzo";
+ info->compress_type = BTRFS_COMPRESS_LZO;
++ info->compress_level = 0;
+ btrfs_set_opt(info->mount_opt, COMPRESS);
+ btrfs_clear_opt(info->mount_opt, NODATACOW);
+ btrfs_clear_opt(info->mount_opt, NODATASUM);
+diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
+index d22ff1e0963c6..065439b4bdda5 100644
+--- a/fs/btrfs/tree-log.c
++++ b/fs/btrfs/tree-log.c
+@@ -3449,11 +3449,13 @@ fail:
+ btrfs_free_path(path);
+ out_unlock:
+ mutex_unlock(&dir->log_mutex);
+- if (ret == -ENOSPC) {
++ if (err == -ENOSPC) {
+ btrfs_set_log_full_commit(trans);
+- ret = 0;
+- } else if (ret < 0)
+- btrfs_abort_transaction(trans, 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, err);
++ }
+
+ btrfs_end_log_trans(root);
+
+diff --git a/fs/buffer.c b/fs/buffer.c
+index 64fe82ec65ff1..75a8849abb5d2 100644
+--- a/fs/buffer.c
++++ b/fs/buffer.c
+@@ -3160,6 +3160,15 @@ int __sync_dirty_buffer(struct buffer_head *bh, int op_flags)
+ WARN_ON(atomic_read(&bh->b_count) < 1);
+ lock_buffer(bh);
+ if (test_clear_buffer_dirty(bh)) {
++ /*
++ * The bh should be mapped, but it might not be if the
++ * device was hot-removed. Not much we can do but fail the I/O.
++ */
++ if (!buffer_mapped(bh)) {
++ unlock_buffer(bh);
++ return -EIO;
++ }
++
+ get_bh(bh);
+ bh->b_end_io = end_buffer_write_sync;
+ ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
+diff --git a/fs/ceph/file.c b/fs/ceph/file.c
+index 160644ddaeed7..d51c3f2fdca02 100644
+--- a/fs/ceph/file.c
++++ b/fs/ceph/file.c
+@@ -1538,6 +1538,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
+ struct inode *inode = file_inode(filp);
+ struct ceph_inode_info *ci = ceph_inode(inode);
+ struct page *pinned_page = NULL;
++ bool direct_lock = iocb->ki_flags & IOCB_DIRECT;
+ ssize_t ret;
+ int want, got = 0;
+ int retry_op = 0, read = 0;
+@@ -1546,7 +1547,7 @@ again:
+ dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
+ inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len, inode);
+
+- if (iocb->ki_flags & IOCB_DIRECT)
++ if (direct_lock)
+ ceph_start_io_direct(inode);
+ else
+ ceph_start_io_read(inode);
+@@ -1603,7 +1604,7 @@ again:
+ }
+ ceph_put_cap_refs(ci, got);
+
+- if (iocb->ki_flags & IOCB_DIRECT)
++ if (direct_lock)
+ ceph_end_io_direct(inode);
+ else
+ ceph_end_io_read(inode);
+diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
+index 946f9a92658ab..903b6a35b321b 100644
+--- a/fs/ceph/mds_client.c
++++ b/fs/ceph/mds_client.c
+@@ -4285,6 +4285,9 @@ static void delayed_work(struct work_struct *work)
+
+ dout("mdsc delayed_work\n");
+
++ 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 +
+@@ -4660,7 +4663,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/ext4/block_validity.c b/fs/ext4/block_validity.c
+index e830a9d4e10d3..11aa37693e436 100644
+--- a/fs/ext4/block_validity.c
++++ b/fs/ext4/block_validity.c
+@@ -254,14 +254,6 @@ int ext4_setup_system_zone(struct super_block *sb)
+ int flex_size = ext4_flex_bg_size(sbi);
+ int ret;
+
+- if (!test_opt(sb, BLOCK_VALIDITY)) {
+- if (sbi->system_blks)
+- ext4_release_system_zone(sb);
+- return 0;
+- }
+- if (sbi->system_blks)
+- return 0;
+-
+ system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL);
+ if (!system_blks)
+ return -ENOMEM;
+diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
+index 42815304902b8..ff46defc65683 100644
+--- a/fs/ext4/ext4.h
++++ b/fs/ext4/ext4.h
+@@ -1054,6 +1054,7 @@ struct ext4_inode_info {
+ struct timespec64 i_crtime;
+
+ /* mballoc */
++ atomic_t i_prealloc_active;
+ struct list_head i_prealloc_list;
+ spinlock_t i_prealloc_lock;
+
+@@ -1501,6 +1502,7 @@ struct ext4_sb_info {
+ unsigned int s_mb_stats;
+ unsigned int s_mb_order2_reqs;
+ unsigned int s_mb_group_prealloc;
++ unsigned int s_mb_max_inode_prealloc;
+ unsigned int s_max_dir_size_kb;
+ /* where last allocation was done - for stream allocation */
+ unsigned long s_mb_last_group;
+@@ -1585,6 +1587,9 @@ struct ext4_sb_info {
+ #ifdef CONFIG_EXT4_DEBUG
+ unsigned long s_simulate_fail;
+ #endif
++ /* Record the errseq of the backing block device */
++ errseq_t s_bdev_wb_err;
++ spinlock_t s_bdev_wb_lock;
+ };
+
+ static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
+@@ -2651,7 +2656,7 @@ extern int ext4_mb_release(struct super_block *);
+ extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
+ struct ext4_allocation_request *, int *);
+ extern int ext4_mb_reserve_blocks(struct super_block *, int);
+-extern void ext4_discard_preallocations(struct inode *);
++extern void ext4_discard_preallocations(struct inode *, unsigned int);
+ extern int __init ext4_init_mballoc(void);
+ extern void ext4_exit_mballoc(void);
+ extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
+diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
+index 0c76cdd44d90d..760b9ee49dc00 100644
+--- a/fs/ext4/ext4_jbd2.c
++++ b/fs/ext4/ext4_jbd2.c
+@@ -195,6 +195,28 @@ static void ext4_journal_abort_handle(const char *caller, unsigned int line,
+ jbd2_journal_abort_handle(handle);
+ }
+
++static void ext4_check_bdev_write_error(struct super_block *sb)
++{
++ struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
++ struct ext4_sb_info *sbi = EXT4_SB(sb);
++ int err;
++
++ /*
++ * If the block device has write error flag, it may have failed to
++ * async write out metadata buffers in the background. In this case,
++ * we could read old data from disk and write it out again, which
++ * may lead to on-disk filesystem inconsistency.
++ */
++ if (errseq_check(&mapping->wb_err, READ_ONCE(sbi->s_bdev_wb_err))) {
++ spin_lock(&sbi->s_bdev_wb_lock);
++ err = errseq_check_and_advance(&mapping->wb_err, &sbi->s_bdev_wb_err);
++ spin_unlock(&sbi->s_bdev_wb_lock);
++ if (err)
++ ext4_error_err(sb, -err,
++ "Error while async write back metadata");
++ }
++}
++
+ int __ext4_journal_get_write_access(const char *where, unsigned int line,
+ handle_t *handle, struct buffer_head *bh)
+ {
+@@ -202,6 +224,9 @@ int __ext4_journal_get_write_access(const char *where, unsigned int line,
+
+ might_sleep();
+
++ if (bh->b_bdev->bd_super)
++ ext4_check_bdev_write_error(bh->b_bdev->bd_super);
++
+ if (ext4_handle_valid(handle)) {
+ err = jbd2_journal_get_write_access(handle, bh);
+ if (err)
+diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
+index d75054570e44c..11a321dd11e7e 100644
+--- a/fs/ext4/extents.c
++++ b/fs/ext4/extents.c
+@@ -100,7 +100,7 @@ static int ext4_ext_trunc_restart_fn(struct inode *inode, int *dropped)
+ * i_mutex. So we can safely drop the i_data_sem here.
+ */
+ BUG_ON(EXT4_JOURNAL(inode) == NULL);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+ up_write(&EXT4_I(inode)->i_data_sem);
+ *dropped = 1;
+ return 0;
+@@ -4268,7 +4268,7 @@ got_allocated_blocks:
+ * not a good idea to call discard here directly,
+ * but otherwise we'd need to call it every free().
+ */
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)
+ fb_flags = EXT4_FREE_BLOCKS_NO_QUOT_UPDATE;
+ ext4_free_blocks(handle, inode, NULL, newblock,
+@@ -5295,7 +5295,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
+ }
+
+ down_write(&EXT4_I(inode)->i_data_sem);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+
+ ret = ext4_es_remove_extent(inode, punch_start,
+ EXT_MAX_BLOCKS - punch_start);
+@@ -5309,7 +5309,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
+ up_write(&EXT4_I(inode)->i_data_sem);
+ goto out_stop;
+ }
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+
+ ret = ext4_ext_shift_extents(inode, handle, punch_stop,
+ punch_stop - punch_start, SHIFT_LEFT);
+@@ -5441,7 +5441,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
+ goto out_stop;
+
+ down_write(&EXT4_I(inode)->i_data_sem);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+
+ path = ext4_find_extent(inode, offset_lblk, NULL, 0);
+ if (IS_ERR(path)) {
+diff --git a/fs/ext4/file.c b/fs/ext4/file.c
+index 8f742b53f1d40..4ee9a4dc01a88 100644
+--- a/fs/ext4/file.c
++++ b/fs/ext4/file.c
+@@ -148,7 +148,7 @@ static int ext4_release_file(struct inode *inode, struct file *filp)
+ !EXT4_I(inode)->i_reserved_data_blocks)
+ {
+ down_write(&EXT4_I(inode)->i_data_sem);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+ up_write(&EXT4_I(inode)->i_data_sem);
+ }
+ if (is_dx(inode) && filp->private_data)
+diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
+index 4026418257121..e8ca405673923 100644
+--- a/fs/ext4/indirect.c
++++ b/fs/ext4/indirect.c
+@@ -696,7 +696,7 @@ static int ext4_ind_trunc_restart_fn(handle_t *handle, struct inode *inode,
+ * i_mutex. So we can safely drop the i_data_sem here.
+ */
+ BUG_ON(EXT4_JOURNAL(inode) == NULL);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+ up_write(&EXT4_I(inode)->i_data_sem);
+ *dropped = 1;
+ return 0;
+diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
+index 92573f8540ab7..9c0629ffb4261 100644
+--- a/fs/ext4/inode.c
++++ b/fs/ext4/inode.c
+@@ -383,7 +383,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
+ */
+ if ((ei->i_reserved_data_blocks == 0) &&
+ !inode_is_open_for_write(inode))
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+ }
+
+ static int __check_block_validity(struct inode *inode, const char *func,
+@@ -4055,7 +4055,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
+ if (stop_block > first_block) {
+
+ down_write(&EXT4_I(inode)->i_data_sem);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+
+ ret = ext4_es_remove_extent(inode, first_block,
+ stop_block - first_block);
+@@ -4210,7 +4210,7 @@ int ext4_truncate(struct inode *inode)
+
+ down_write(&EXT4_I(inode)->i_data_sem);
+
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+
+ if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+ err = ext4_ext_truncate(handle, inode);
+diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
+index 999cf6add39c6..a5fcc238c6693 100644
+--- a/fs/ext4/ioctl.c
++++ b/fs/ext4/ioctl.c
+@@ -202,7 +202,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
+ reset_inode_seed(inode);
+ reset_inode_seed(inode_bl);
+
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+
+ err = ext4_mark_inode_dirty(handle, inode);
+ if (err < 0) {
+diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
+index 38719c156573c..e88eff999bd15 100644
+--- a/fs/ext4/mballoc.c
++++ b/fs/ext4/mballoc.c
+@@ -2177,6 +2177,7 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac,
+ {
+ struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
+ struct super_block *sb = ac->ac_sb;
++ struct ext4_sb_info *sbi = EXT4_SB(sb);
+ bool should_lock = ac->ac_flags & EXT4_MB_STRICT_CHECK;
+ ext4_grpblk_t free;
+ int ret = 0;
+@@ -2195,7 +2196,25 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac,
+
+ /* We only do this if the grp has never been initialized */
+ if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
+- ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS);
++ struct ext4_group_desc *gdp =
++ ext4_get_group_desc(sb, group, NULL);
++ int ret;
++
++ /* cr=0/1 is a very optimistic search to find large
++ * good chunks almost for free. If buddy data is not
++ * ready, then this optimization makes no sense. But
++ * we never skip the first block group in a flex_bg,
++ * since this gets used for metadata block allocation,
++ * and we want to make sure we locate metadata blocks
++ * in the first block group in the flex_bg if possible.
++ */
++ if (cr < 2 &&
++ (!sbi->s_log_groups_per_flex ||
++ ((group & ((1 << sbi->s_log_groups_per_flex) - 1)) != 0)) &&
++ !(ext4_has_group_desc_csum(sb) &&
++ (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))))
++ return 0;
++ ret = ext4_mb_init_group(sb, group, GFP_NOFS);
+ if (ret)
+ return ret;
+ }
+@@ -2736,6 +2755,7 @@ int ext4_mb_init(struct super_block *sb)
+ sbi->s_mb_stats = MB_DEFAULT_STATS;
+ sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD;
+ sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
++ sbi->s_mb_max_inode_prealloc = MB_DEFAULT_MAX_INODE_PREALLOC;
+ /*
+ * The default group preallocation is 512, which for 4k block
+ * sizes translates to 2 megabytes. However for bigalloc file
+@@ -3674,6 +3694,26 @@ void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ mb_debug(sb, "preallocated %d for group %u\n", preallocated, group);
+ }
+
++static void ext4_mb_mark_pa_deleted(struct super_block *sb,
++ struct ext4_prealloc_space *pa)
++{
++ struct ext4_inode_info *ei;
++
++ if (pa->pa_deleted) {
++ ext4_warning(sb, "deleted pa, type:%d, pblk:%llu, lblk:%u, len:%d\n",
++ pa->pa_type, pa->pa_pstart, pa->pa_lstart,
++ pa->pa_len);
++ return;
++ }
++
++ pa->pa_deleted = 1;
++
++ if (pa->pa_type == MB_INODE_PA) {
++ ei = EXT4_I(pa->pa_inode);
++ atomic_dec(&ei->i_prealloc_active);
++ }
++}
++
+ static void ext4_mb_pa_callback(struct rcu_head *head)
+ {
+ struct ext4_prealloc_space *pa;
+@@ -3706,7 +3746,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
+ return;
+ }
+
+- pa->pa_deleted = 1;
++ ext4_mb_mark_pa_deleted(sb, pa);
+ spin_unlock(&pa->pa_lock);
+
+ grp_blk = pa->pa_pstart;
+@@ -3830,6 +3870,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
+ spin_lock(pa->pa_obj_lock);
+ list_add_rcu(&pa->pa_inode_list, &ei->i_prealloc_list);
+ spin_unlock(pa->pa_obj_lock);
++ atomic_inc(&ei->i_prealloc_active);
+ }
+
+ /*
+@@ -4040,7 +4081,7 @@ repeat:
+ }
+
+ /* seems this one can be freed ... */
+- pa->pa_deleted = 1;
++ ext4_mb_mark_pa_deleted(sb, pa);
+
+ /* we can trust pa_free ... */
+ free += pa->pa_free;
+@@ -4103,7 +4144,7 @@ out_dbg:
+ *
+ * FIXME!! Make sure it is valid at all the call sites
+ */
+-void ext4_discard_preallocations(struct inode *inode)
++void ext4_discard_preallocations(struct inode *inode, unsigned int needed)
+ {
+ struct ext4_inode_info *ei = EXT4_I(inode);
+ struct super_block *sb = inode->i_sb;
+@@ -4121,15 +4162,19 @@ void ext4_discard_preallocations(struct inode *inode)
+
+ mb_debug(sb, "discard preallocation for inode %lu\n",
+ inode->i_ino);
+- trace_ext4_discard_preallocations(inode);
++ trace_ext4_discard_preallocations(inode,
++ atomic_read(&ei->i_prealloc_active), needed);
+
+ INIT_LIST_HEAD(&list);
+
++ if (needed == 0)
++ needed = UINT_MAX;
++
+ repeat:
+ /* first, collect all pa's in the inode */
+ spin_lock(&ei->i_prealloc_lock);
+- while (!list_empty(&ei->i_prealloc_list)) {
+- pa = list_entry(ei->i_prealloc_list.next,
++ while (!list_empty(&ei->i_prealloc_list) && needed) {
++ pa = list_entry(ei->i_prealloc_list.prev,
+ struct ext4_prealloc_space, pa_inode_list);
+ BUG_ON(pa->pa_obj_lock != &ei->i_prealloc_lock);
+ spin_lock(&pa->pa_lock);
+@@ -4146,10 +4191,11 @@ repeat:
+
+ }
+ if (pa->pa_deleted == 0) {
+- pa->pa_deleted = 1;
++ ext4_mb_mark_pa_deleted(sb, pa);
+ spin_unlock(&pa->pa_lock);
+ list_del_rcu(&pa->pa_inode_list);
+ list_add(&pa->u.pa_tmp_list, &list);
++ needed--;
+ continue;
+ }
+
+@@ -4450,7 +4496,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb,
+ BUG_ON(pa->pa_type != MB_GROUP_PA);
+
+ /* seems this one can be freed ... */
+- pa->pa_deleted = 1;
++ ext4_mb_mark_pa_deleted(sb, pa);
+ spin_unlock(&pa->pa_lock);
+
+ list_del_rcu(&pa->pa_inode_list);
+@@ -4548,11 +4594,30 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)
+ return ;
+ }
+
++/*
++ * if per-inode prealloc list is too long, trim some PA
++ */
++static void ext4_mb_trim_inode_pa(struct inode *inode)
++{
++ struct ext4_inode_info *ei = EXT4_I(inode);
++ struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
++ int count, delta;
++
++ count = atomic_read(&ei->i_prealloc_active);
++ delta = (sbi->s_mb_max_inode_prealloc >> 2) + 1;
++ if (count > sbi->s_mb_max_inode_prealloc + delta) {
++ count -= sbi->s_mb_max_inode_prealloc;
++ ext4_discard_preallocations(inode, count);
++ }
++}
++
+ /*
+ * release all resource we used in allocation
+ */
+ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
+ {
++ struct inode *inode = ac->ac_inode;
++ struct ext4_inode_info *ei = EXT4_I(inode);
+ struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
+ struct ext4_prealloc_space *pa = ac->ac_pa;
+ if (pa) {
+@@ -4579,6 +4644,17 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
+ spin_unlock(pa->pa_obj_lock);
+ ext4_mb_add_n_trim(ac);
+ }
++
++ if (pa->pa_type == MB_INODE_PA) {
++ /*
++ * treat per-inode prealloc list as a lru list, then try
++ * to trim the least recently used PA.
++ */
++ spin_lock(pa->pa_obj_lock);
++ list_move(&pa->pa_inode_list, &ei->i_prealloc_list);
++ spin_unlock(pa->pa_obj_lock);
++ }
++
+ ext4_mb_put_pa(ac, ac->ac_sb, pa);
+ }
+ if (ac->ac_bitmap_page)
+@@ -4588,6 +4664,7 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
+ if (ac->ac_flags & EXT4_MB_HINT_GROUP_ALLOC)
+ mutex_unlock(&ac->ac_lg->lg_mutex);
+ ext4_mb_collect_stats(ac);
++ ext4_mb_trim_inode_pa(inode);
+ return 0;
+ }
+
+diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h
+index 6b4d17c2935d6..e75b4749aa1c2 100644
+--- a/fs/ext4/mballoc.h
++++ b/fs/ext4/mballoc.h
+@@ -73,6 +73,10 @@
+ */
+ #define MB_DEFAULT_GROUP_PREALLOC 512
+
++/*
++ * maximum length of inode prealloc list
++ */
++#define MB_DEFAULT_MAX_INODE_PREALLOC 512
+
+ struct ext4_free_data {
+ /* this links the free block information from sb_info */
+diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
+index 1ed86fb6c3026..0d601b8228753 100644
+--- a/fs/ext4/move_extent.c
++++ b/fs/ext4/move_extent.c
+@@ -686,8 +686,8 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
+
+ out:
+ if (*moved_len) {
+- ext4_discard_preallocations(orig_inode);
+- ext4_discard_preallocations(donor_inode);
++ ext4_discard_preallocations(orig_inode, 0);
++ ext4_discard_preallocations(donor_inode, 0);
+ }
+
+ ext4_ext_drop_refs(path);
+diff --git a/fs/ext4/super.c b/fs/ext4/super.c
+index 330957ed1f05c..0b38bf29c07e0 100644
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -66,10 +66,10 @@ static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
+ unsigned long journal_devnum);
+ static int ext4_show_options(struct seq_file *seq, struct dentry *root);
+ static int ext4_commit_super(struct super_block *sb, int sync);
+-static void ext4_mark_recovery_complete(struct super_block *sb,
++static int ext4_mark_recovery_complete(struct super_block *sb,
+ struct ext4_super_block *es);
+-static void ext4_clear_journal_err(struct super_block *sb,
+- struct ext4_super_block *es);
++static int ext4_clear_journal_err(struct super_block *sb,
++ struct ext4_super_block *es);
+ static int ext4_sync_fs(struct super_block *sb, int wait);
+ static int ext4_remount(struct super_block *sb, int *flags, char *data);
+ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
+@@ -1123,6 +1123,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
+ inode_set_iversion(&ei->vfs_inode, 1);
+ spin_lock_init(&ei->i_raw_lock);
+ INIT_LIST_HEAD(&ei->i_prealloc_list);
++ atomic_set(&ei->i_prealloc_active, 0);
+ spin_lock_init(&ei->i_prealloc_lock);
+ ext4_es_init_tree(&ei->i_es_tree);
+ rwlock_init(&ei->i_es_lock);
+@@ -1216,7 +1217,7 @@ void ext4_clear_inode(struct inode *inode)
+ {
+ invalidate_inode_buffers(inode);
+ clear_inode(inode);
+- ext4_discard_preallocations(inode);
++ ext4_discard_preallocations(inode, 0);
+ ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
+ dquot_drop(inode);
+ if (EXT4_I(inode)->jinode) {
+@@ -4698,11 +4699,13 @@ no_journal:
+
+ ext4_set_resv_clusters(sb);
+
+- err = ext4_setup_system_zone(sb);
+- if (err) {
+- ext4_msg(sb, KERN_ERR, "failed to initialize system "
+- "zone (%d)", err);
+- goto failed_mount4a;
++ if (test_opt(sb, BLOCK_VALIDITY)) {
++ err = ext4_setup_system_zone(sb);
++ if (err) {
++ ext4_msg(sb, KERN_ERR, "failed to initialize system "
++ "zone (%d)", err);
++ goto failed_mount4a;
++ }
+ }
+
+ ext4_ext_init(sb);
+@@ -4765,12 +4768,23 @@ no_journal:
+ }
+ #endif /* CONFIG_QUOTA */
+
++ /*
++ * Save the original bdev mapping's wb_err value which could be
++ * 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);
++ sb->s_bdev->bd_super = sb;
+ EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
+ ext4_orphan_cleanup(sb, es);
+ EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
+ if (needs_recovery) {
+ ext4_msg(sb, KERN_INFO, "recovery complete");
+- ext4_mark_recovery_complete(sb, es);
++ err = ext4_mark_recovery_complete(sb, es);
++ if (err)
++ goto failed_mount8;
+ }
+ if (EXT4_SB(sb)->s_journal) {
+ if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
+@@ -4813,10 +4827,8 @@ cantfind_ext4:
+ ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
+ goto failed_mount;
+
+-#ifdef CONFIG_QUOTA
+ failed_mount8:
+ ext4_unregister_sysfs(sb);
+-#endif
+ failed_mount7:
+ ext4_unregister_li_request(sb);
+ failed_mount6:
+@@ -4956,7 +4968,8 @@ static journal_t *ext4_get_journal(struct super_block *sb,
+ struct inode *journal_inode;
+ journal_t *journal;
+
+- BUG_ON(!ext4_has_feature_journal(sb));
++ if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
++ return NULL;
+
+ journal_inode = ext4_get_journal_inode(sb, journal_inum);
+ if (!journal_inode)
+@@ -4986,7 +4999,8 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
+ struct ext4_super_block *es;
+ struct block_device *bdev;
+
+- BUG_ON(!ext4_has_feature_journal(sb));
++ if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
++ return NULL;
+
+ bdev = ext4_blkdev_get(j_dev, sb);
+ if (bdev == NULL)
+@@ -5077,8 +5091,10 @@ static int ext4_load_journal(struct super_block *sb,
+ dev_t journal_dev;
+ int err = 0;
+ int really_read_only;
++ int journal_dev_ro;
+
+- BUG_ON(!ext4_has_feature_journal(sb));
++ if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
++ return -EFSCORRUPTED;
+
+ if (journal_devnum &&
+ journal_devnum != le32_to_cpu(es->s_journal_dev)) {
+@@ -5088,7 +5104,31 @@ static int ext4_load_journal(struct super_block *sb,
+ } else
+ journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
+
+- really_read_only = bdev_read_only(sb->s_bdev);
++ if (journal_inum && journal_dev) {
++ ext4_msg(sb, KERN_ERR,
++ "filesystem has both journal inode and journal device!");
++ return -EINVAL;
++ }
++
++ if (journal_inum) {
++ journal = ext4_get_journal(sb, journal_inum);
++ if (!journal)
++ return -EINVAL;
++ } else {
++ journal = ext4_get_dev_journal(sb, journal_dev);
++ if (!journal)
++ return -EINVAL;
++ }
++
++ journal_dev_ro = bdev_read_only(journal->j_dev);
++ really_read_only = bdev_read_only(sb->s_bdev) | journal_dev_ro;
++
++ if (journal_dev_ro && !sb_rdonly(sb)) {
++ ext4_msg(sb, KERN_ERR,
++ "journal device read-only, try mounting with '-o ro'");
++ err = -EROFS;
++ goto err_out;
++ }
+
+ /*
+ * Are we loading a blank journal or performing recovery after a
+@@ -5103,27 +5143,14 @@ static int ext4_load_journal(struct super_block *sb,
+ ext4_msg(sb, KERN_ERR, "write access "
+ "unavailable, cannot proceed "
+ "(try mounting with noload)");
+- return -EROFS;
++ err = -EROFS;
++ goto err_out;
+ }
+ ext4_msg(sb, KERN_INFO, "write access will "
+ "be enabled during recovery");
+ }
+ }
+
+- if (journal_inum && journal_dev) {
+- ext4_msg(sb, KERN_ERR, "filesystem has both journal "
+- "and inode journals!");
+- return -EINVAL;
+- }
+-
+- if (journal_inum) {
+- if (!(journal = ext4_get_journal(sb, journal_inum)))
+- return -EINVAL;
+- } else {
+- if (!(journal = ext4_get_dev_journal(sb, journal_dev)))
+- return -EINVAL;
+- }
+-
+ if (!(journal->j_flags & JBD2_BARRIER))
+ ext4_msg(sb, KERN_INFO, "barriers disabled");
+
+@@ -5143,12 +5170,16 @@ static int ext4_load_journal(struct super_block *sb,
+
+ if (err) {
+ ext4_msg(sb, KERN_ERR, "error loading journal");
+- jbd2_journal_destroy(journal);
+- return err;
++ goto err_out;
+ }
+
+ EXT4_SB(sb)->s_journal = journal;
+- ext4_clear_journal_err(sb, es);
++ err = ext4_clear_journal_err(sb, es);
++ if (err) {
++ EXT4_SB(sb)->s_journal = NULL;
++ jbd2_journal_destroy(journal);
++ return err;
++ }
+
+ if (!really_read_only && journal_devnum &&
+ journal_devnum != le32_to_cpu(es->s_journal_dev)) {
+@@ -5159,6 +5190,10 @@ static int ext4_load_journal(struct super_block *sb,
+ }
+
+ return 0;
++
++err_out:
++ jbd2_journal_destroy(journal);
++ return err;
+ }
+
+ static int ext4_commit_super(struct super_block *sb, int sync)
+@@ -5170,13 +5205,6 @@ static int ext4_commit_super(struct super_block *sb, int sync)
+ if (!sbh || block_device_ejected(sb))
+ return error;
+
+- /*
+- * The superblock bh should be mapped, but it might not be if the
+- * device was hot-removed. Not much we can do but fail the I/O.
+- */
+- if (!buffer_mapped(sbh))
+- return error;
+-
+ /*
+ * If the file system is mounted read-only, don't update the
+ * superblock write time. This avoids updating the superblock
+@@ -5244,26 +5272,32 @@ static int ext4_commit_super(struct super_block *sb, int sync)
+ * remounting) the filesystem readonly, then we will end up with a
+ * consistent fs on disk. Record that fact.
+ */
+-static void ext4_mark_recovery_complete(struct super_block *sb,
+- struct ext4_super_block *es)
++static int ext4_mark_recovery_complete(struct super_block *sb,
++ struct ext4_super_block *es)
+ {
++ int err;
+ journal_t *journal = EXT4_SB(sb)->s_journal;
+
+ if (!ext4_has_feature_journal(sb)) {
+- BUG_ON(journal != NULL);
+- return;
++ if (journal != NULL) {
++ ext4_error(sb, "Journal got removed while the fs was "
++ "mounted!");
++ return -EFSCORRUPTED;
++ }
++ return 0;
+ }
+ jbd2_journal_lock_updates(journal);
+- if (jbd2_journal_flush(journal) < 0)
++ err = jbd2_journal_flush(journal);
++ if (err < 0)
+ goto out;
+
+ if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) {
+ ext4_clear_feature_journal_needs_recovery(sb);
+ ext4_commit_super(sb, 1);
+ }
+-
+ out:
+ jbd2_journal_unlock_updates(journal);
++ return err;
+ }
+
+ /*
+@@ -5271,14 +5305,17 @@ out:
+ * has recorded an error from a previous lifetime, move that error to the
+ * main filesystem now.
+ */
+-static void ext4_clear_journal_err(struct super_block *sb,
++static int ext4_clear_journal_err(struct super_block *sb,
+ struct ext4_super_block *es)
+ {
+ journal_t *journal;
+ int j_errno;
+ const char *errstr;
+
+- BUG_ON(!ext4_has_feature_journal(sb));
++ if (!ext4_has_feature_journal(sb)) {
++ ext4_error(sb, "Journal got removed while the fs was mounted!");
++ return -EFSCORRUPTED;
++ }
+
+ journal = EXT4_SB(sb)->s_journal;
+
+@@ -5303,6 +5340,7 @@ static void ext4_clear_journal_err(struct super_block *sb,
+ jbd2_journal_clear_err(journal);
+ jbd2_journal_update_sb_errno(journal);
+ }
++ return 0;
+ }
+
+ /*
+@@ -5445,7 +5483,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
+ {
+ struct ext4_super_block *es;
+ struct ext4_sb_info *sbi = EXT4_SB(sb);
+- unsigned long old_sb_flags;
++ unsigned long old_sb_flags, vfs_flags;
+ struct ext4_mount_options old_opts;
+ int enable_quota = 0;
+ ext4_group_t g;
+@@ -5488,6 +5526,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
+ if (sbi->s_journal && sbi->s_journal->j_task->io_context)
+ journal_ioprio = sbi->s_journal->j_task->io_context->ioprio;
+
++ /*
++ * Some options can be enabled by ext4 and/or by VFS mount flag
++ * either way we need to make sure it matches in both *flags and
++ * s_flags. Copy those selected flags from *flags to s_flags
++ */
++ vfs_flags = SB_LAZYTIME | SB_I_VERSION;
++ sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags);
++
+ if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) {
+ err = -EINVAL;
+ goto restore_opts;
+@@ -5541,9 +5587,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
+ set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
+ }
+
+- if (*flags & SB_LAZYTIME)
+- sb->s_flags |= SB_LAZYTIME;
+-
+ if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) {
+ if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) {
+ err = -EROFS;
+@@ -5573,8 +5616,13 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
+ (sbi->s_mount_state & EXT4_VALID_FS))
+ es->s_state = cpu_to_le16(sbi->s_mount_state);
+
+- if (sbi->s_journal)
++ if (sbi->s_journal) {
++ /*
++ * We let remount-ro finish even if marking fs
++ * as clean failed...
++ */
+ ext4_mark_recovery_complete(sb, es);
++ }
+ if (sbi->s_mmp_tsk)
+ kthread_stop(sbi->s_mmp_tsk);
+ } else {
+@@ -5616,14 +5664,25 @@ 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
+ * been changed by e2fsck since we originally mounted
+ * the partition.)
+ */
+- if (sbi->s_journal)
+- ext4_clear_journal_err(sb, es);
++ if (sbi->s_journal) {
++ err = ext4_clear_journal_err(sb, es);
++ if (err)
++ goto restore_opts;
++ }
+ sbi->s_mount_state = le16_to_cpu(es->s_state);
+
+ err = ext4_setup_super(sb, es, 0);
+@@ -5653,7 +5712,17 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
+ ext4_register_li_request(sb, first_not_zeroed);
+ }
+
+- ext4_setup_system_zone(sb);
++ /*
++ * Handle creation of system zone data early because it can fail.
++ * Releasing of existing data is done when we are sure remount will
++ * succeed.
++ */
++ if (test_opt(sb, BLOCK_VALIDITY) && !sbi->system_blks) {
++ err = ext4_setup_system_zone(sb);
++ if (err)
++ goto restore_opts;
++ }
++
+ if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
+ err = ext4_commit_super(sb, 1);
+ if (err)
+@@ -5674,8 +5743,16 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
+ }
+ }
+ #endif
++ if (!test_opt(sb, BLOCK_VALIDITY) && sbi->system_blks)
++ ext4_release_system_zone(sb);
++
++ /*
++ * Some options can be enabled by ext4 and/or by VFS mount flag
++ * either way we need to make sure it matches in both *flags and
++ * s_flags. Copy those selected flags from s_flags to *flags
++ */
++ *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags);
+
+- *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME);
+ ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data);
+ kfree(orig_data);
+ return 0;
+@@ -5689,6 +5766,8 @@ restore_opts:
+ sbi->s_commit_interval = old_opts.s_commit_interval;
+ sbi->s_min_batch_time = old_opts.s_min_batch_time;
+ sbi->s_max_batch_time = old_opts.s_max_batch_time;
++ if (!test_opt(sb, BLOCK_VALIDITY) && sbi->system_blks)
++ ext4_release_system_zone(sb);
+ #ifdef CONFIG_QUOTA
+ sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
+ for (i = 0; i < EXT4_MAXQUOTAS; i++) {
+diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
+index 6c9fc9e21c138..92f04e9e94413 100644
+--- a/fs/ext4/sysfs.c
++++ b/fs/ext4/sysfs.c
+@@ -215,6 +215,7 @@ EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
+ EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
+ EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
+ EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
++EXT4_RW_ATTR_SBI_UI(mb_max_inode_prealloc, s_mb_max_inode_prealloc);
+ EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb);
+ EXT4_ATTR(trigger_fs_error, 0200, trigger_test_error);
+ EXT4_RW_ATTR_SBI_UI(err_ratelimit_interval_ms, s_err_ratelimit_state.interval);
+@@ -257,6 +258,7 @@ static struct attribute *ext4_attrs[] = {
+ ATTR_LIST(mb_order2_req),
+ ATTR_LIST(mb_stream_req),
+ ATTR_LIST(mb_group_prealloc),
++ ATTR_LIST(mb_max_inode_prealloc),
+ ATTR_LIST(max_writeback_mb_bump),
+ ATTR_LIST(extent_max_zeroout_kb),
+ ATTR_LIST(trigger_fs_error),
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
+index b35a50f4953c5..7d9afd54e9d8f 100644
+--- a/fs/f2fs/f2fs.h
++++ b/fs/f2fs/f2fs.h
+@@ -3287,7 +3287,7 @@ bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid);
+ void f2fs_alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid);
+ void f2fs_alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid);
+ int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink);
+-void f2fs_recover_inline_xattr(struct inode *inode, struct page *page);
++int f2fs_recover_inline_xattr(struct inode *inode, struct page *page);
+ int f2fs_recover_xattr_data(struct inode *inode, struct page *page);
+ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page);
+ int f2fs_restore_node_summary(struct f2fs_sb_info *sbi,
+@@ -3750,7 +3750,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page);
+ int f2fs_convert_inline_inode(struct inode *inode);
+ int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry);
+ int f2fs_write_inline_data(struct inode *inode, struct page *page);
+-bool f2fs_recover_inline_data(struct inode *inode, struct page *npage);
++int f2fs_recover_inline_data(struct inode *inode, struct page *npage);
+ struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
+ const struct f2fs_filename *fname,
+ struct page **res_page);
+diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
+index dbade310dc792..cf2c347bd7a3d 100644
+--- a/fs/f2fs/inline.c
++++ b/fs/f2fs/inline.c
+@@ -253,7 +253,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
+ return 0;
+ }
+
+-bool f2fs_recover_inline_data(struct inode *inode, struct page *npage)
++int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
+ {
+ struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+ struct f2fs_inode *ri = NULL;
+@@ -275,7 +275,8 @@ bool f2fs_recover_inline_data(struct inode *inode, struct page *npage)
+ ri && (ri->i_inline & F2FS_INLINE_DATA)) {
+ process_inline:
+ ipage = f2fs_get_node_page(sbi, inode->i_ino);
+- f2fs_bug_on(sbi, IS_ERR(ipage));
++ if (IS_ERR(ipage))
++ return PTR_ERR(ipage);
+
+ f2fs_wait_on_page_writeback(ipage, NODE, true, true);
+
+@@ -288,21 +289,25 @@ process_inline:
+
+ set_page_dirty(ipage);
+ f2fs_put_page(ipage, 1);
+- return true;
++ return 1;
+ }
+
+ if (f2fs_has_inline_data(inode)) {
+ ipage = f2fs_get_node_page(sbi, inode->i_ino);
+- f2fs_bug_on(sbi, IS_ERR(ipage));
++ if (IS_ERR(ipage))
++ return PTR_ERR(ipage);
+ f2fs_truncate_inline_inode(inode, ipage, 0);
+ clear_inode_flag(inode, FI_INLINE_DATA);
+ f2fs_put_page(ipage, 1);
+ } else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) {
+- if (f2fs_truncate_blocks(inode, 0, false))
+- return false;
++ int ret;
++
++ ret = f2fs_truncate_blocks(inode, 0, false);
++ if (ret)
++ return ret;
+ goto process_inline;
+ }
+- return false;
++ return 0;
+ }
+
+ struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
+index e61ce7fb0958b..98736d0598b8d 100644
+--- a/fs/f2fs/node.c
++++ b/fs/f2fs/node.c
+@@ -2576,7 +2576,7 @@ int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
+ return nr - nr_shrink;
+ }
+
+-void f2fs_recover_inline_xattr(struct inode *inode, struct page *page)
++int f2fs_recover_inline_xattr(struct inode *inode, struct page *page)
+ {
+ void *src_addr, *dst_addr;
+ size_t inline_size;
+@@ -2584,7 +2584,8 @@ void f2fs_recover_inline_xattr(struct inode *inode, struct page *page)
+ struct f2fs_inode *ri;
+
+ ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
+- f2fs_bug_on(F2FS_I_SB(inode), IS_ERR(ipage));
++ if (IS_ERR(ipage))
++ return PTR_ERR(ipage);
+
+ ri = F2FS_INODE(page);
+ if (ri->i_inline & F2FS_INLINE_XATTR) {
+@@ -2603,6 +2604,7 @@ void f2fs_recover_inline_xattr(struct inode *inode, struct page *page)
+ update_inode:
+ f2fs_update_inode(inode, ipage);
+ f2fs_put_page(ipage, 1);
++ return 0;
+ }
+
+ int f2fs_recover_xattr_data(struct inode *inode, struct page *page)
+diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
+index ae5310f02e7ff..2807251944668 100644
+--- a/fs/f2fs/recovery.c
++++ b/fs/f2fs/recovery.c
+@@ -544,7 +544,9 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
+
+ /* step 1: recover xattr */
+ if (IS_INODE(page)) {
+- f2fs_recover_inline_xattr(inode, page);
++ err = f2fs_recover_inline_xattr(inode, page);
++ if (err)
++ goto out;
+ } else if (f2fs_has_xattr_block(ofs_of_node(page))) {
+ err = f2fs_recover_xattr_data(inode, page);
+ if (!err)
+@@ -553,8 +555,12 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
+ }
+
+ /* step 2: recover inline data */
+- if (f2fs_recover_inline_data(inode, page))
++ err = f2fs_recover_inline_data(inode, page);
++ if (err) {
++ if (err == 1)
++ err = 0;
+ goto out;
++ }
+
+ /* step 3: recover data indices */
+ start = f2fs_start_bidx_of_node(ofs_of_node(page), inode);
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
+index 20e56b0fa46a9..0deb839da0a03 100644
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -1173,6 +1173,9 @@ static void f2fs_put_super(struct super_block *sb)
+ int i;
+ bool dropped;
+
++ /* unregister procfs/sysfs entries in advance to avoid race case */
++ f2fs_unregister_sysfs(sbi);
++
+ f2fs_quota_off_umount(sb);
+
+ /* prevent remaining shrinker jobs */
+@@ -1238,8 +1241,6 @@ static void f2fs_put_super(struct super_block *sb)
+
+ kvfree(sbi->ckpt);
+
+- f2fs_unregister_sysfs(sbi);
+-
+ sb->s_fs_info = NULL;
+ if (sbi->s_chksum_driver)
+ crypto_free_shash(sbi->s_chksum_driver);
+diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
+index e877c59b9fdb4..c5e32ceb94827 100644
+--- a/fs/f2fs/sysfs.c
++++ b/fs/f2fs/sysfs.c
+@@ -223,6 +223,13 @@ static ssize_t avg_vblocks_show(struct f2fs_attr *a,
+ }
+ #endif
+
++static ssize_t main_blkaddr_show(struct f2fs_attr *a,
++ struct f2fs_sb_info *sbi, char *buf)
++{
++ return snprintf(buf, PAGE_SIZE, "%llu\n",
++ (unsigned long long)MAIN_BLKADDR(sbi));
++}
++
+ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
+ struct f2fs_sb_info *sbi, char *buf)
+ {
+@@ -522,7 +529,6 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time);
+ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode);
+ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode);
+ F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
+-F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, main_blkaddr, main_blkaddr);
+ F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards);
+ F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity);
+ F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks);
+@@ -565,6 +571,7 @@ F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
+ F2FS_GENERAL_RO_ATTR(unusable);
+ F2FS_GENERAL_RO_ATTR(encoding);
+ F2FS_GENERAL_RO_ATTR(mounted_time_sec);
++F2FS_GENERAL_RO_ATTR(main_blkaddr);
+ #ifdef CONFIG_F2FS_STAT_FS
+ F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
+ F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
+diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
+index a605c3dddabc7..ae17d64a3e189 100644
+--- a/fs/fs-writeback.c
++++ b/fs/fs-writeback.c
+@@ -42,7 +42,6 @@
+ 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;
+@@ -144,7 +143,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);
+ }
+@@ -1122,7 +1123,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);
+ }
+ EXPORT_SYMBOL(inode_io_list_del);
+@@ -1172,8 +1175,10 @@ void sb_clear_inode_writeback(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;
+
+@@ -1182,6 +1187,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);
+ }
+
+ /*
+@@ -1220,16 +1233,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;
+@@ -1237,21 +1247,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)
+@@ -1289,18 +1295,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)
+@@ -1394,7 +1404,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;
+ }
+
+@@ -1414,7 +1424,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) {
+ /*
+@@ -1422,10 +1432,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);
+@@ -1669,8 +1680,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) {
+@@ -1811,7 +1822,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);
+@@ -1831,7 +1842,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,
+@@ -1839,14 +1850,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 (;;) {
+@@ -1880,14 +1888,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
+@@ -2289,11 +2297,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/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
+index ef5313f9c78fe..f936bcf02cce7 100644
+--- a/fs/hugetlbfs/inode.c
++++ b/fs/hugetlbfs/inode.c
+@@ -1364,6 +1364,12 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)
+ sb->s_magic = HUGETLBFS_MAGIC;
+ sb->s_op = &hugetlbfs_ops;
+ sb->s_time_gran = 1;
++
++ /*
++ * Due to the special and limited functionality of hugetlbfs, it does
++ * not work well as a stacking filesystem.
++ */
++ sb->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH;
+ sb->s_root = d_make_root(hugetlbfs_get_root(sb, ctx));
+ if (!sb->s_root)
+ goto out_free;
+diff --git a/fs/io-wq.c b/fs/io-wq.c
+index 47c5f3aeb4600..cb9e5a444fba7 100644
+--- a/fs/io-wq.c
++++ b/fs/io-wq.c
+@@ -929,6 +929,24 @@ static bool io_wq_worker_cancel(struct io_worker *worker, void *data)
+ return match->nr_running && !match->cancel_all;
+ }
+
++static inline void io_wqe_remove_pending(struct io_wqe *wqe,
++ struct io_wq_work *work,
++ struct io_wq_work_node *prev)
++{
++ unsigned int hash = io_get_work_hash(work);
++ struct io_wq_work *prev_work = NULL;
++
++ if (io_wq_is_hashed(work) && work == wqe->hash_tail[hash]) {
++ if (prev)
++ prev_work = container_of(prev, struct io_wq_work, list);
++ if (prev_work && io_get_work_hash(prev_work) == hash)
++ wqe->hash_tail[hash] = prev_work;
++ else
++ wqe->hash_tail[hash] = NULL;
++ }
++ wq_list_del(&wqe->work_list, &work->list, prev);
++}
++
+ static void io_wqe_cancel_pending_work(struct io_wqe *wqe,
+ struct io_cb_cancel_data *match)
+ {
+@@ -942,8 +960,7 @@ retry:
+ work = container_of(node, struct io_wq_work, list);
+ if (!match->fn(work, match->data))
+ continue;
+-
+- wq_list_del(&wqe->work_list, node, prev);
++ io_wqe_remove_pending(wqe, work, prev);
+ spin_unlock_irqrestore(&wqe->lock, flags);
+ io_run_cancel(work, wqe);
+ match->nr_pending++;
+diff --git a/fs/io_uring.c b/fs/io_uring.c
+index 26978630378e0..4115bfedf15dc 100644
+--- a/fs/io_uring.c
++++ b/fs/io_uring.c
+@@ -1810,6 +1810,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
+
+ req = list_first_entry(done, struct io_kiocb, list);
+ if (READ_ONCE(req->result) == -EAGAIN) {
++ req->result = 0;
+ req->iopoll_completed = 0;
+ list_move_tail(&req->list, &again);
+ continue;
+@@ -2517,6 +2518,11 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
+ return import_iovec(rw, buf, sqe_len, UIO_FASTIOV, iovec, iter);
+ }
+
++static inline loff_t *io_kiocb_ppos(struct kiocb *kiocb)
++{
++ return kiocb->ki_filp->f_mode & FMODE_STREAM ? NULL : &kiocb->ki_pos;
++}
++
+ /*
+ * For files that don't have ->read_iter() and ->write_iter(), handle them
+ * by looping over ->read() or ->write() manually.
+@@ -2552,10 +2558,10 @@ static ssize_t loop_rw_iter(int rw, struct file *file, struct kiocb *kiocb,
+
+ if (rw == READ) {
+ nr = file->f_op->read(file, iovec.iov_base,
+- iovec.iov_len, &kiocb->ki_pos);
++ iovec.iov_len, io_kiocb_ppos(kiocb));
+ } else {
+ nr = file->f_op->write(file, iovec.iov_base,
+- iovec.iov_len, &kiocb->ki_pos);
++ iovec.iov_len, io_kiocb_ppos(kiocb));
+ }
+
+ if (iov_iter_is_bvec(iter))
+@@ -2680,7 +2686,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock)
+ goto copy_iov;
+
+ iov_count = iov_iter_count(&iter);
+- ret = rw_verify_area(READ, req->file, &kiocb->ki_pos, iov_count);
++ ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), iov_count);
+ if (!ret) {
+ ssize_t ret2;
+
+@@ -2779,7 +2785,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock)
+ goto copy_iov;
+
+ iov_count = iov_iter_count(&iter);
+- ret = rw_verify_area(WRITE, req->file, &kiocb->ki_pos, iov_count);
++ ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), iov_count);
+ if (!ret) {
+ ssize_t ret2;
+
+@@ -4113,7 +4119,8 @@ struct io_poll_table {
+ int error;
+ };
+
+-static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
++static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb,
++ bool twa_signal_ok)
+ {
+ struct task_struct *tsk = req->task;
+ struct io_ring_ctx *ctx = req->ctx;
+@@ -4126,7 +4133,7 @@ static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
+ * will do the job.
+ */
+ notify = 0;
+- if (!(ctx->flags & IORING_SETUP_SQPOLL))
++ if (!(ctx->flags & IORING_SETUP_SQPOLL) && twa_signal_ok)
+ notify = TWA_SIGNAL;
+
+ ret = task_work_add(tsk, cb, notify);
+@@ -4140,6 +4147,7 @@ static int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll,
+ __poll_t mask, task_work_func_t func)
+ {
+ struct task_struct *tsk;
++ bool twa_signal_ok;
+ int ret;
+
+ /* for instances that support it check for an event match first: */
+@@ -4155,13 +4163,21 @@ static int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll,
+ init_task_work(&req->task_work, func);
+ percpu_ref_get(&req->ctx->refs);
+
++ /*
++ * If we using the signalfd wait_queue_head for this wakeup, then
++ * it's not safe to use TWA_SIGNAL as we could be recursing on the
++ * tsk->sighand->siglock on doing the wakeup. Should not be needed
++ * either, as the normal wakeup will suffice.
++ */
++ twa_signal_ok = (poll->head != &req->task->sighand->signalfd_wqh);
++
+ /*
+ * If this fails, then the task is exiting. When a task exits, the
+ * work gets canceled, so just cancel this request as well instead
+ * of executing it. We can't safely execute it anyway, as we may not
+ * have the needed state needed for it anyway.
+ */
+- ret = io_req_task_work_add(req, &req->task_work);
++ ret = io_req_task_work_add(req, &req->task_work, twa_signal_ok);
+ if (unlikely(ret)) {
+ WRITE_ONCE(poll->canceled, true);
+ tsk = io_wq_get_task(req->ctx->io_wq);
+@@ -4492,12 +4508,20 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
+ struct async_poll *apoll;
+ struct io_poll_table ipt;
+ __poll_t mask, ret;
++ int rw;
+
+ if (!req->file || !file_can_poll(req->file))
+ return false;
+ if (req->flags & (REQ_F_MUST_PUNT | REQ_F_POLLED))
+ return false;
+- if (!def->pollin && !def->pollout)
++ if (def->pollin)
++ rw = READ;
++ else if (def->pollout)
++ rw = WRITE;
++ else
++ return false;
++ /* if we can't nonblock try, then no point in arming a poll handler */
++ if (!io_file_supports_async(req->file, rw))
+ return false;
+
+ apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
+diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
+index e91aad3637a23..6250c9faa4cbe 100644
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -2026,6 +2026,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;
+ }
+@@ -2117,6 +2120,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));
+@@ -2141,11 +2145,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
+ jbd2_journal_put_journal_head(jh);
+ 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;
+ }
+
+@@ -2572,6 +2591,13 @@ bool __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/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
+index c9056316a0b35..cea682ce8aa12 100644
+--- a/fs/nfsd/nfs4state.c
++++ b/fs/nfsd/nfs4state.c
+@@ -4597,6 +4597,8 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
+ if (!i_am_nfsd())
+ return NULL;
+ rqst = kthread_data(current);
++ if (!rqst->rq_lease_breaker)
++ return NULL;
+ clp = *(rqst->rq_lease_breaker);
+ return dl->dl_stid.sc_client == clp;
+ }
+diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
+index b5dfb66548422..4504d215cd590 100644
+--- a/fs/xfs/libxfs/xfs_trans_inode.c
++++ b/fs/xfs/libxfs/xfs_trans_inode.c
+@@ -36,6 +36,7 @@ xfs_trans_ijoin(
+
+ ASSERT(iip->ili_lock_flags == 0);
+ iip->ili_lock_flags = lock_flags;
++ ASSERT(!xfs_iflags_test(ip, XFS_ISTALE));
+
+ /*
+ * Get a log_item_desc to point at the new item.
+@@ -89,6 +90,7 @@ xfs_trans_log_inode(
+
+ ASSERT(ip->i_itemp != NULL);
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
++ ASSERT(!xfs_iflags_test(ip, XFS_ISTALE));
+
+ /*
+ * Don't bother with i_lock for the I_DIRTY_TIME check here, as races
+diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
+index 5daef654956cb..59dea8178ae3c 100644
+--- a/fs/xfs/xfs_icache.c
++++ b/fs/xfs/xfs_icache.c
+@@ -1141,7 +1141,7 @@ restart:
+ goto out_ifunlock;
+ xfs_iunpin_wait(ip);
+ }
+- if (xfs_iflags_test(ip, XFS_ISTALE) || xfs_inode_clean(ip)) {
++ if (xfs_inode_clean(ip)) {
+ xfs_ifunlock(ip);
+ goto reclaim;
+ }
+@@ -1228,6 +1228,7 @@ reclaim:
+ xfs_ilock(ip, XFS_ILOCK_EXCL);
+ xfs_qm_dqdetach(ip);
+ xfs_iunlock(ip, XFS_ILOCK_EXCL);
++ ASSERT(xfs_inode_clean(ip));
+
+ __xfs_inode_free(ip);
+ return error;
+diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
+index 9aea7d68d8ab9..6d70daf1c92a7 100644
+--- a/fs/xfs/xfs_inode.c
++++ b/fs/xfs/xfs_inode.c
+@@ -1740,10 +1740,31 @@ xfs_inactive_ifree(
+ return error;
+ }
+
++ /*
++ * We do not hold the inode locked across the entire rolling transaction
++ * here. We only need to hold it for the first transaction that
++ * xfs_ifree() builds, which may mark the inode XFS_ISTALE if the
++ * underlying cluster buffer is freed. Relogging an XFS_ISTALE inode
++ * here breaks the relationship between cluster buffer invalidation and
++ * stale inode invalidation on cluster buffer item journal commit
++ * completion, and can result in leaving dirty stale inodes hanging
++ * around in memory.
++ *
++ * We have no need for serialising this inode operation against other
++ * operations - we freed the inode and hence reallocation is required
++ * and that will serialise on reallocating the space the deferops need
++ * to free. Hence we can unlock the inode on the first commit of
++ * the transaction rather than roll it right through the deferops. This
++ * avoids relogging the XFS_ISTALE inode.
++ *
++ * We check that xfs_ifree() hasn't grown an internal transaction roll
++ * by asserting that the inode is still locked when it returns.
++ */
+ xfs_ilock(ip, XFS_ILOCK_EXCL);
+- xfs_trans_ijoin(tp, ip, 0);
++ xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
+
+ error = xfs_ifree(tp, ip);
++ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
+ if (error) {
+ /*
+ * If we fail to free the inode, shut down. The cancel
+@@ -1756,7 +1777,6 @@ xfs_inactive_ifree(
+ xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
+ }
+ xfs_trans_cancel(tp);
+- xfs_iunlock(ip, XFS_ILOCK_EXCL);
+ return error;
+ }
+
+@@ -1774,7 +1794,6 @@ xfs_inactive_ifree(
+ xfs_notice(mp, "%s: xfs_trans_commit returned error %d",
+ __func__, error);
+
+- xfs_iunlock(ip, XFS_ILOCK_EXCL);
+ return 0;
+ }
+
+diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h
+index 4fc9a43ac45a8..aafd07388eb7b 100644
+--- a/include/drm/drm_modeset_lock.h
++++ b/include/drm/drm_modeset_lock.h
+@@ -164,6 +164,8 @@ int drm_modeset_lock_all_ctx(struct drm_device *dev,
+ * is 0, so no error checking is necessary
+ */
+ #define DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, flags, ret) \
++ if (!drm_drv_uses_atomic_modeset(dev)) \
++ mutex_lock(&dev->mode_config.mutex); \
+ drm_modeset_acquire_init(&ctx, flags); \
+ modeset_lock_retry: \
+ ret = drm_modeset_lock_all_ctx(dev, &ctx); \
+@@ -172,6 +174,7 @@ modeset_lock_retry: \
+
+ /**
+ * DRM_MODESET_LOCK_ALL_END - Helper to release and cleanup modeset locks
++ * @dev: drm device
+ * @ctx: local modeset acquire context, will be dereferenced
+ * @ret: local ret/err/etc variable to track error status
+ *
+@@ -188,7 +191,7 @@ modeset_lock_retry: \
+ * to that failure. In both of these cases the code between BEGIN/END will not
+ * be run, so the failure will reflect the inability to grab the locks.
+ */
+-#define DRM_MODESET_LOCK_ALL_END(ctx, ret) \
++#define DRM_MODESET_LOCK_ALL_END(dev, ctx, ret) \
+ modeset_lock_fail: \
+ if (ret == -EDEADLK) { \
+ ret = drm_modeset_backoff(&ctx); \
+@@ -196,6 +199,8 @@ modeset_lock_fail: \
+ goto modeset_lock_retry; \
+ } \
+ drm_modeset_drop_locks(&ctx); \
+- drm_modeset_acquire_fini(&ctx);
++ drm_modeset_acquire_fini(&ctx); \
++ if (!drm_drv_uses_atomic_modeset(dev)) \
++ mutex_unlock(&dev->mode_config.mutex);
+
+ #endif /* DRM_MODESET_LOCK_H_ */
+diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
+index ab2e20cba9514..ba22952c24e24 100644
+--- a/include/linux/dma-direct.h
++++ b/include/linux/dma-direct.h
+@@ -67,9 +67,6 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
+ }
+
+ u64 dma_direct_get_required_mask(struct device *dev);
+-gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
+- u64 *phys_mask);
+-bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size);
+ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
+ gfp_t gfp, unsigned long attrs);
+ void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,
+diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
+index a33ed3954ed46..0dc08701d7b7e 100644
+--- a/include/linux/dma-mapping.h
++++ b/include/linux/dma-mapping.h
+@@ -715,8 +715,9 @@ void *dma_common_pages_remap(struct page **pages, size_t size,
+ pgprot_t prot, const void *caller);
+ void dma_common_free_remap(void *cpu_addr, size_t size);
+
+-void *dma_alloc_from_pool(struct device *dev, size_t size,
+- struct page **ret_page, gfp_t flags);
++struct page *dma_alloc_from_pool(struct device *dev, size_t size,
++ void **cpu_addr, gfp_t flags,
++ bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t));
+ bool dma_free_from_pool(struct device *dev, void *start, size_t size);
+
+ int
+diff --git a/include/linux/efi.h b/include/linux/efi.h
+index 05c47f857383e..73db1ae04cef8 100644
+--- a/include/linux/efi.h
++++ b/include/linux/efi.h
+@@ -606,7 +606,11 @@ extern void *efi_get_pal_addr (void);
+ extern void efi_map_pal_code (void);
+ extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
+ extern void efi_gettimeofday (struct timespec64 *ts);
++#ifdef CONFIG_EFI
+ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
++#else
++static inline void efi_enter_virtual_mode (void) {}
++#endif
+ #ifdef CONFIG_X86
+ extern efi_status_t efi_query_variable_store(u32 attributes,
+ unsigned long size,
+diff --git a/include/linux/fb.h b/include/linux/fb.h
+index 3b4b2f0c6994d..b11eb02cad6d3 100644
+--- a/include/linux/fb.h
++++ b/include/linux/fb.h
+@@ -400,8 +400,6 @@ struct fb_tile_ops {
+ #define FBINFO_HWACCEL_YPAN 0x2000 /* optional */
+ #define FBINFO_HWACCEL_YWRAP 0x4000 /* optional */
+
+-#define FBINFO_MISC_USEREVENT 0x10000 /* event request
+- from userspace */
+ #define FBINFO_MISC_TILEBLITTING 0x20000 /* use tile blitting */
+
+ /* A driver may set this flag to indicate that it does want a set_par to be
+diff --git a/include/linux/fs.h b/include/linux/fs.h
+index 2dab217c6047f..ac1e89872db4f 100644
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -2168,6 +2168,10 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
+ *
+ * I_DONTCACHE Evict inode as soon as it is not used anymore.
+ *
++ * 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)
+@@ -2185,12 +2189,12 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
+ #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_OVL_INUSE (1 << 14)
+ #define I_CREATING (1 << 15)
+ #define I_DONTCACHE (1 << 16)
++#define I_SYNC_QUEUED (1 << 17)
+
+ #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
+ #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
+diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
+index aac42c28fe62d..9b67394471e1c 100644
+--- a/include/linux/netfilter_ipv6.h
++++ b/include/linux/netfilter_ipv6.h
+@@ -58,7 +58,6 @@ struct nf_ipv6_ops {
+ int (*output)(struct net *, struct sock *, struct sk_buff *));
+ int (*reroute)(struct sk_buff *skb, const struct nf_queue_entry *entry);
+ #if IS_MODULE(CONFIG_IPV6)
+- int (*br_defrag)(struct net *net, struct sk_buff *skb, u32 user);
+ int (*br_fragment)(struct net *net, struct sock *sk,
+ struct sk_buff *skb,
+ struct nf_bridge_frag_data *data,
+@@ -117,23 +116,6 @@ static inline int nf_ip6_route(struct net *net, struct dst_entry **dst,
+
+ #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
+
+-static inline int nf_ipv6_br_defrag(struct net *net, struct sk_buff *skb,
+- u32 user)
+-{
+-#if IS_MODULE(CONFIG_IPV6)
+- const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
+-
+- if (!v6_ops)
+- return 1;
+-
+- return v6_ops->br_defrag(net, skb, user);
+-#elif IS_BUILTIN(CONFIG_IPV6)
+- return nf_ct_frag6_gather(net, skb, user);
+-#else
+- return 1;
+-#endif
+-}
+-
+ int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
+ struct nf_bridge_frag_data *data,
+ int (*output)(struct net *, struct sock *sk,
+diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
+index cc41d692ae8ed..628db6a07fda0 100644
+--- a/include/trace/events/ext4.h
++++ b/include/trace/events/ext4.h
+@@ -746,24 +746,29 @@ TRACE_EVENT(ext4_mb_release_group_pa,
+ );
+
+ TRACE_EVENT(ext4_discard_preallocations,
+- TP_PROTO(struct inode *inode),
++ TP_PROTO(struct inode *inode, unsigned int len, unsigned int needed),
+
+- TP_ARGS(inode),
++ TP_ARGS(inode, len, needed),
+
+ TP_STRUCT__entry(
+- __field( dev_t, dev )
+- __field( ino_t, ino )
++ __field( dev_t, dev )
++ __field( ino_t, ino )
++ __field( unsigned int, len )
++ __field( unsigned int, needed )
+
+ ),
+
+ TP_fast_assign(
+ __entry->dev = inode->i_sb->s_dev;
+ __entry->ino = inode->i_ino;
++ __entry->len = len;
++ __entry->needed = needed;
+ ),
+
+- TP_printk("dev %d,%d ino %lu",
++ TP_printk("dev %d,%d ino %lu len: %u needed %u",
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+- (unsigned long) __entry->ino)
++ (unsigned long) __entry->ino, __entry->len,
++ __entry->needed)
+ );
+
+ TRACE_EVENT(ext4_mb_discard_preallocations,
+diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
+index 10f5d1fa73476..7565dcd596973 100644
+--- a/include/trace/events/writeback.h
++++ b/include/trace/events/writeback.h
+@@ -498,8 +498,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)
+@@ -509,19 +510,17 @@ TRACE_EVENT(writeback_queue_io,
+ __field(ino_t, cgroup_ino)
+ ),
+ TP_fast_assign(
+- unsigned long *older_than_this = work->older_than_this;
+ strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 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;
+ __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
+ ),
+ TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%lu",
+ __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),
+ (unsigned long)__entry->cgroup_ino
+diff --git a/kernel/Makefile b/kernel/Makefile
+index f3218bc5ec69f..155b5380500ad 100644
+--- a/kernel/Makefile
++++ b/kernel/Makefile
+@@ -125,6 +125,7 @@ obj-$(CONFIG_WATCH_QUEUE) += watch_queue.o
+
+ obj-$(CONFIG_SYSCTL_KUNIT_TEST) += sysctl-test.o
+
++CFLAGS_stackleak.o += $(DISABLE_STACKLEAK_PLUGIN)
+ obj-$(CONFIG_GCC_PLUGIN_STACKLEAK) += stackleak.o
+ KASAN_SANITIZE_stackleak.o := n
+ KCSAN_SANITIZE_stackleak.o := n
+diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
+index dd612b80b9fea..3c18090cd73dc 100644
+--- a/kernel/bpf/bpf_iter.c
++++ b/kernel/bpf/bpf_iter.c
+@@ -64,6 +64,9 @@ static void bpf_iter_done_stop(struct seq_file *seq)
+ iter_priv->done_stop = true;
+ }
+
++/* maximum visited objects before bailing out */
++#define MAX_ITER_OBJECTS 1000000
++
+ /* bpf_seq_read, a customized and simpler version for bpf iterator.
+ * no_llseek is assumed for this file.
+ * The following are differences from seq_read():
+@@ -76,7 +79,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
+ {
+ struct seq_file *seq = file->private_data;
+ size_t n, offs, copied = 0;
+- int err = 0;
++ int err = 0, num_objs = 0;
+ void *p;
+
+ mutex_lock(&seq->lock);
+@@ -132,6 +135,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
+ while (1) {
+ loff_t pos = seq->index;
+
++ num_objs++;
+ offs = seq->count;
+ p = seq->op->next(seq, p, &seq->index);
+ if (pos == seq->index) {
+@@ -150,6 +154,15 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
+ if (seq->count >= size)
+ break;
+
++ if (num_objs >= MAX_ITER_OBJECTS) {
++ if (offs == 0) {
++ err = -EAGAIN;
++ seq->op->stop(seq, p);
++ goto done;
++ }
++ break;
++ }
++
+ err = seq->op->show(seq, p);
+ if (err > 0) {
+ bpf_iter_dec_seq_num(seq);
+diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
+index a4a0fb4f94cc1..323def936be24 100644
+--- a/kernel/bpf/task_iter.c
++++ b/kernel/bpf/task_iter.c
+@@ -28,8 +28,9 @@ static struct task_struct *task_seq_get_next(struct pid_namespace *ns,
+
+ rcu_read_lock();
+ retry:
+- pid = idr_get_next(&ns->idr, tid);
++ pid = find_ge_pid(*tid, ns);
+ if (pid) {
++ *tid = pid_nr_ns(pid, ns);
+ task = get_pid_task(pid, PIDTYPE_PID);
+ if (!task) {
+ ++*tid;
+diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
+index 67f060b86a73f..f17aec9d01f0c 100644
+--- a/kernel/dma/direct.c
++++ b/kernel/dma/direct.c
+@@ -45,7 +45,7 @@ u64 dma_direct_get_required_mask(struct device *dev)
+ return (1ULL << (fls64(max_dma) - 1)) * 2 - 1;
+ }
+
+-gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
++static gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
+ u64 *phys_limit)
+ {
+ u64 dma_limit = min_not_zero(dma_mask, dev->bus_dma_limit);
+@@ -70,7 +70,7 @@ gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
+ return 0;
+ }
+
+-bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size)
++static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size)
+ {
+ return phys_to_dma_direct(dev, phys) + size - 1 <=
+ min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit);
+@@ -163,8 +163,13 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size,
+ size = PAGE_ALIGN(size);
+
+ if (dma_should_alloc_from_pool(dev, gfp, attrs)) {
+- ret = dma_alloc_from_pool(dev, size, &page, gfp);
+- if (!ret)
++ u64 phys_mask;
++
++ gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
++ &phys_mask);
++ page = dma_alloc_from_pool(dev, size, &ret, gfp,
++ dma_coherent_ok);
++ if (!page)
+ return NULL;
+ goto done;
+ }
+diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
+index 6bc74a2d51273..1281c0f0442bc 100644
+--- a/kernel/dma/pool.c
++++ b/kernel/dma/pool.c
+@@ -3,7 +3,9 @@
+ * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2020 Google LLC
+ */
++#include <linux/cma.h>
+ #include <linux/debugfs.h>
++#include <linux/dma-contiguous.h>
+ #include <linux/dma-direct.h>
+ #include <linux/dma-noncoherent.h>
+ #include <linux/init.h>
+@@ -55,11 +57,34 @@ static void dma_atomic_pool_size_add(gfp_t gfp, size_t size)
+ pool_size_kernel += size;
+ }
+
++static bool cma_in_zone(gfp_t gfp)
++{
++ unsigned long size;
++ phys_addr_t end;
++ struct cma *cma;
++
++ cma = dev_get_cma_area(NULL);
++ if (!cma)
++ return false;
++
++ size = cma_get_size(cma);
++ if (!size)
++ return false;
++
++ /* CMA can't cross zone boundaries, see cma_activate_area() */
++ end = cma_get_base(cma) + size - 1;
++ if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
++ return end <= DMA_BIT_MASK(zone_dma_bits);
++ if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
++ return end <= DMA_BIT_MASK(32);
++ return true;
++}
++
+ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
+ gfp_t gfp)
+ {
+ unsigned int order;
+- struct page *page;
++ struct page *page = NULL;
+ void *addr;
+ int ret = -ENOMEM;
+
+@@ -68,7 +93,11 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
+
+ do {
+ pool_size = 1 << (PAGE_SHIFT + order);
+- page = alloc_pages(gfp, order);
++ if (cma_in_zone(gfp))
++ page = dma_alloc_from_contiguous(NULL, 1 << order,
++ order, false);
++ if (!page)
++ page = alloc_pages(gfp, order);
+ } while (!page && order-- > 0);
+ if (!page)
+ goto out;
+@@ -196,93 +225,75 @@ static int __init dma_atomic_pool_init(void)
+ }
+ postcore_initcall(dma_atomic_pool_init);
+
+-static inline struct gen_pool *dma_guess_pool_from_device(struct device *dev)
++static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp)
+ {
+- u64 phys_mask;
+- gfp_t gfp;
+-
+- gfp = dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
+- &phys_mask);
+- if (IS_ENABLED(CONFIG_ZONE_DMA) && gfp == GFP_DMA)
++ if (prev == NULL) {
++ if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
++ return atomic_pool_dma32;
++ if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
++ return atomic_pool_dma;
++ return atomic_pool_kernel;
++ }
++ if (prev == atomic_pool_kernel)
++ return atomic_pool_dma32 ? atomic_pool_dma32 : atomic_pool_dma;
++ if (prev == atomic_pool_dma32)
+ return atomic_pool_dma;
+- if (IS_ENABLED(CONFIG_ZONE_DMA32) && gfp == GFP_DMA32)
+- return atomic_pool_dma32;
+- return atomic_pool_kernel;
++ return NULL;
+ }
+
+-static inline struct gen_pool *dma_get_safer_pool(struct gen_pool *bad_pool)
++static struct page *__dma_alloc_from_pool(struct device *dev, size_t size,
++ struct gen_pool *pool, void **cpu_addr,
++ bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t))
+ {
+- if (bad_pool == atomic_pool_kernel)
+- return atomic_pool_dma32 ? : atomic_pool_dma;
++ unsigned long addr;
++ phys_addr_t phys;
+
+- if (bad_pool == atomic_pool_dma32)
+- return atomic_pool_dma;
++ addr = gen_pool_alloc(pool, size);
++ if (!addr)
++ return NULL;
+
+- return NULL;
+-}
++ phys = gen_pool_virt_to_phys(pool, addr);
++ if (phys_addr_ok && !phys_addr_ok(dev, phys, size)) {
++ gen_pool_free(pool, addr, size);
++ return NULL;
++ }
+
+-static inline struct gen_pool *dma_guess_pool(struct device *dev,
+- struct gen_pool *bad_pool)
+-{
+- if (bad_pool)
+- return dma_get_safer_pool(bad_pool);
++ if (gen_pool_avail(pool) < atomic_pool_size)
++ schedule_work(&atomic_pool_work);
+
+- return dma_guess_pool_from_device(dev);
++ *cpu_addr = (void *)addr;
++ memset(*cpu_addr, 0, size);
++ return pfn_to_page(__phys_to_pfn(phys));
+ }
+
+-void *dma_alloc_from_pool(struct device *dev, size_t size,
+- struct page **ret_page, gfp_t flags)
++struct page *dma_alloc_from_pool(struct device *dev, size_t size,
++ void **cpu_addr, gfp_t gfp,
++ bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t))
+ {
+ struct gen_pool *pool = NULL;
+- unsigned long val = 0;
+- void *ptr = NULL;
+- phys_addr_t phys;
+-
+- while (1) {
+- pool = dma_guess_pool(dev, pool);
+- if (!pool) {
+- WARN(1, "Failed to get suitable pool for %s\n",
+- dev_name(dev));
+- break;
+- }
+-
+- val = gen_pool_alloc(pool, size);
+- if (!val)
+- continue;
+-
+- phys = gen_pool_virt_to_phys(pool, val);
+- if (dma_coherent_ok(dev, phys, size))
+- break;
+-
+- gen_pool_free(pool, val, size);
+- val = 0;
+- }
+-
+-
+- if (val) {
+- *ret_page = pfn_to_page(__phys_to_pfn(phys));
+- ptr = (void *)val;
+- memset(ptr, 0, size);
++ struct page *page;
+
+- if (gen_pool_avail(pool) < atomic_pool_size)
+- schedule_work(&atomic_pool_work);
++ while ((pool = dma_guess_pool(pool, gfp))) {
++ page = __dma_alloc_from_pool(dev, size, pool, cpu_addr,
++ phys_addr_ok);
++ if (page)
++ return page;
+ }
+
+- return ptr;
++ WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
++ return NULL;
+ }
+
+ bool dma_free_from_pool(struct device *dev, void *start, size_t size)
+ {
+ struct gen_pool *pool = NULL;
+
+- while (1) {
+- pool = dma_guess_pool(dev, pool);
+- if (!pool)
+- return false;
+-
+- if (gen_pool_has_addr(pool, (unsigned long)start, size)) {
+- gen_pool_free(pool, (unsigned long)start, size);
+- return true;
+- }
++ while ((pool = dma_guess_pool(pool, 0))) {
++ if (!gen_pool_has_addr(pool, (unsigned long)start, size))
++ continue;
++ gen_pool_free(pool, (unsigned long)start, size);
++ return true;
+ }
++
++ return false;
+ }
+diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
+index 30cc217b86318..651a4ad6d711f 100644
+--- a/kernel/irq/matrix.c
++++ b/kernel/irq/matrix.c
+@@ -380,6 +380,13 @@ int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
+ unsigned int cpu, bit;
+ struct cpumap *cm;
+
++ /*
++ * Not required in theory, but matrix_find_best_cpu() uses
++ * for_each_cpu() which ignores the cpumask on UP .
++ */
++ if (cpumask_empty(msk))
++ return -EINVAL;
++
+ cpu = matrix_find_best_cpu(m, msk);
+ if (cpu == UINT_MAX)
+ return -ENOSPC;
+diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
+index 5525cd3ba0c83..02ef87f50df29 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/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
+index 588e8e3960197..1bd6563939e59 100644
+--- a/kernel/trace/blktrace.c
++++ b/kernel/trace/blktrace.c
+@@ -536,6 +536,18 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
+ #endif
+ bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);
+
++ /*
++ * As blktrace relies on debugfs for its interface the debugfs directory
++ * is required, contrary to the usual mantra of not checking for debugfs
++ * files or directories.
++ */
++ if (IS_ERR_OR_NULL(dir)) {
++ pr_warn("debugfs_dir not present for %s so skipping\n",
++ buts->name);
++ ret = -ENOENT;
++ goto err;
++ }
++
+ bt->dev = dev;
+ atomic_set(&bt->dropped, 0);
+ INIT_LIST_HEAD(&bt->running_list);
+diff --git a/mm/khugepaged.c b/mm/khugepaged.c
+index 1d6a9b0b6a9fd..dd592ea9a4a06 100644
+--- a/mm/khugepaged.c
++++ b/mm/khugepaged.c
+@@ -431,7 +431,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);
+ }
+
+ static bool hugepage_vma_check(struct vm_area_struct *vma,
+@@ -1100,9 +1100,6 @@ static void collapse_huge_page(struct mm_struct *mm,
+ * handled by the anon_vma lock + PG_lock.
+ */
+ mmap_write_lock(mm);
+- result = SCAN_ANY_PROCESS;
+- if (!mmget_still_valid(mm))
+- goto out;
+ result = hugepage_vma_revalidate(mm, address, &vma);
+ if (result)
+ goto out;
+diff --git a/mm/page_counter.c b/mm/page_counter.c
+index b4663844c9b37..afe22ad335ccc 100644
+--- a/mm/page_counter.c
++++ b/mm/page_counter.c
+@@ -77,8 +77,8 @@ void page_counter_charge(struct page_counter *counter, unsigned long nr_pages)
+ * This is indeed racy, but we can live with some
+ * inaccuracy in the watermark.
+ */
+- if (new > c->watermark)
+- c->watermark = new;
++ if (new > READ_ONCE(c->watermark))
++ WRITE_ONCE(c->watermark, new);
+ }
+ }
+
+@@ -119,9 +119,10 @@ bool page_counter_try_charge(struct page_counter *counter,
+ propagate_protected_usage(c, new);
+ /*
+ * This is racy, but we can live with some
+- * inaccuracy in the failcnt.
++ * inaccuracy in the failcnt which is only used
++ * to report stats.
+ */
+- c->failcnt++;
++ data_race(c->failcnt++);
+ *fail = c;
+ goto failed;
+ }
+@@ -130,8 +131,8 @@ bool page_counter_try_charge(struct page_counter *counter,
+ * Just like with failcnt, we can live with some
+ * inaccuracy in the watermark.
+ */
+- if (new > c->watermark)
+- c->watermark = new;
++ if (new > READ_ONCE(c->watermark))
++ WRITE_ONCE(c->watermark, new);
+ }
+ return true;
+
+diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c
+index 8096732223828..8d033a75a766e 100644
+--- a/net/bridge/netfilter/nf_conntrack_bridge.c
++++ b/net/bridge/netfilter/nf_conntrack_bridge.c
+@@ -168,6 +168,7 @@ static unsigned int nf_ct_br_defrag4(struct sk_buff *skb,
+ static unsigned int nf_ct_br_defrag6(struct sk_buff *skb,
+ const struct nf_hook_state *state)
+ {
++#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
+ u16 zone_id = NF_CT_DEFAULT_ZONE_ID;
+ enum ip_conntrack_info ctinfo;
+ struct br_input_skb_cb cb;
+@@ -180,14 +181,17 @@ static unsigned int nf_ct_br_defrag6(struct sk_buff *skb,
+
+ br_skb_cb_save(skb, &cb, sizeof(struct inet6_skb_parm));
+
+- err = nf_ipv6_br_defrag(state->net, skb,
+- IP_DEFRAG_CONNTRACK_BRIDGE_IN + zone_id);
++ err = nf_ct_frag6_gather(state->net, skb,
++ IP_DEFRAG_CONNTRACK_BRIDGE_IN + zone_id);
+ /* queued */
+ if (err == -EINPROGRESS)
+ return NF_STOLEN;
+
+ br_skb_cb_restore(skb, &cb, IP6CB(skb)->frag_max_size);
+ return err == 0 ? NF_ACCEPT : NF_DROP;
++#else
++ return NF_ACCEPT;
++#endif
+ }
+
+ static int nf_ct_br_ip_check(const struct sk_buff *skb)
+diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
+index dbd215cbc53d8..a8dd956b5e8e1 100644
+--- a/net/can/j1939/transport.c
++++ b/net/can/j1939/transport.c
+@@ -1803,7 +1803,20 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
+ }
+
+ tpdat = se_skb->data;
+- memcpy(&tpdat[offset], &dat[1], nbytes);
++ if (!session->transmission) {
++ memcpy(&tpdat[offset], &dat[1], nbytes);
++ } else {
++ int err;
++
++ err = memcmp(&tpdat[offset], &dat[1], nbytes);
++ if (err)
++ netdev_err_once(priv->ndev,
++ "%s: 0x%p: Data of RX-looped back packet (%*ph) doesn't match TX data (%*ph)!\n",
++ __func__, session,
++ nbytes, &dat[1],
++ nbytes, &tpdat[offset]);
++ }
++
+ if (packet == session->pkt.rx)
+ session->pkt.rx++;
+
+diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
+index 409e79b84a830..6d0e942d082d4 100644
+--- a/net/ipv6/netfilter.c
++++ b/net/ipv6/netfilter.c
+@@ -245,9 +245,6 @@ static const struct nf_ipv6_ops ipv6ops = {
+ .route_input = ip6_route_input,
+ .fragment = ip6_fragment,
+ .reroute = nf_ip6_reroute,
+-#if IS_MODULE(CONFIG_IPV6) && IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
+- .br_defrag = nf_ct_frag6_gather,
+-#endif
+ #if IS_MODULE(CONFIG_IPV6)
+ .br_fragment = br_ip6_fragment,
+ #endif
+diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
+index 88325b264737f..d31832d32e028 100644
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -2037,7 +2037,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
+
+ if (nla[NFTA_CHAIN_HOOK]) {
+ if (!nft_is_base_chain(chain))
+- return -EBUSY;
++ return -EEXIST;
+
+ err = nft_chain_parse_hook(ctx->net, nla, &hook, ctx->family,
+ false);
+@@ -2047,21 +2047,21 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
+ basechain = nft_base_chain(chain);
+ if (basechain->type != hook.type) {
+ nft_chain_release_hook(&hook);
+- return -EBUSY;
++ return -EEXIST;
+ }
+
+ if (ctx->family == NFPROTO_NETDEV) {
+ if (!nft_hook_list_equal(&basechain->hook_list,
+ &hook.list)) {
+ nft_chain_release_hook(&hook);
+- return -EBUSY;
++ return -EEXIST;
+ }
+ } else {
+ ops = &basechain->ops;
+ if (ops->hooknum != hook.num ||
+ ops->priority != hook.priority) {
+ nft_chain_release_hook(&hook);
+- return -EBUSY;
++ return -EEXIST;
+ }
+ }
+ nft_chain_release_hook(&hook);
+@@ -5160,10 +5160,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
+ if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA) ^
+ nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) ||
+ nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) ^
+- nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF)) {
+- err = -EBUSY;
++ nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF))
+ goto err_element_clash;
+- }
+ if ((nft_set_ext_exists(ext, NFT_SET_EXT_DATA) &&
+ nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) &&
+ memcmp(nft_set_ext_data(ext),
+@@ -5171,7 +5169,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
+ (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF) &&
+ nft_set_ext_exists(ext2, NFT_SET_EXT_OBJREF) &&
+ *nft_set_ext_obj(ext) != *nft_set_ext_obj(ext2)))
+- err = -EBUSY;
++ goto err_element_clash;
+ else if (!(nlmsg_flags & NLM_F_EXCL))
+ err = 0;
+ } else if (err == -ENOTEMPTY) {
+@@ -6308,7 +6306,7 @@ static int nft_register_flowtable_net_hooks(struct net *net,
+ list_for_each_entry(hook2, &ft->hook_list, list) {
+ if (hook->ops.dev == hook2->ops.dev &&
+ hook->ops.pf == hook2->ops.pf) {
+- err = -EBUSY;
++ err = -EEXIST;
+ goto err_unregister_net_hooks;
+ }
+ }
+diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
+index 94b024534987a..03b81aa99975b 100644
+--- a/net/openvswitch/datapath.c
++++ b/net/openvswitch/datapath.c
+@@ -1736,6 +1736,7 @@ err:
+ /* Called with ovs_mutex. */
+ static void __dp_destroy(struct datapath *dp)
+ {
++ struct flow_table *table = &dp->table;
+ int i;
+
+ for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
+@@ -1754,7 +1755,14 @@ static void __dp_destroy(struct datapath *dp)
+ */
+ ovs_dp_detach_port(ovs_vport_ovsl(dp, OVSP_LOCAL));
+
+- /* RCU destroy the flow table */
++ /* Flush sw_flow in the tables. RCU cb only releases resource
++ * such as dp, ports and tables. That may avoid some issues
++ * such as RCU usage warning.
++ */
++ table_instance_flow_flush(table, ovsl_dereference(table->ti),
++ ovsl_dereference(table->ufid_ti));
++
++ /* RCU destroy the ports, meters and flow tables. */
+ call_rcu(&dp->rcu, destroy_dp_rcu);
+ }
+
+diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
+index 2398d72383005..f198bbb0c517a 100644
+--- a/net/openvswitch/flow_table.c
++++ b/net/openvswitch/flow_table.c
+@@ -345,19 +345,15 @@ static void table_instance_flow_free(struct flow_table *table,
+ flow_mask_remove(table, flow->mask);
+ }
+
+-static void table_instance_destroy(struct flow_table *table,
+- struct table_instance *ti,
+- struct table_instance *ufid_ti,
+- bool deferred)
++/* Must be called with OVS mutex held. */
++void table_instance_flow_flush(struct flow_table *table,
++ struct table_instance *ti,
++ struct table_instance *ufid_ti)
+ {
+ int i;
+
+- if (!ti)
+- return;
+-
+- BUG_ON(!ufid_ti);
+ if (ti->keep_flows)
+- goto skip_flows;
++ return;
+
+ for (i = 0; i < ti->n_buckets; i++) {
+ struct sw_flow *flow;
+@@ -369,18 +365,16 @@ static void table_instance_destroy(struct flow_table *table,
+
+ table_instance_flow_free(table, ti, ufid_ti,
+ flow, false);
+- ovs_flow_free(flow, deferred);
++ ovs_flow_free(flow, true);
+ }
+ }
++}
+
+-skip_flows:
+- if (deferred) {
+- call_rcu(&ti->rcu, flow_tbl_destroy_rcu_cb);
+- call_rcu(&ufid_ti->rcu, flow_tbl_destroy_rcu_cb);
+- } else {
+- __table_instance_destroy(ti);
+- __table_instance_destroy(ufid_ti);
+- }
++static void table_instance_destroy(struct table_instance *ti,
++ struct table_instance *ufid_ti)
++{
++ call_rcu(&ti->rcu, flow_tbl_destroy_rcu_cb);
++ call_rcu(&ufid_ti->rcu, flow_tbl_destroy_rcu_cb);
+ }
+
+ /* No need for locking this function is called from RCU callback or
+@@ -393,7 +387,7 @@ void ovs_flow_tbl_destroy(struct flow_table *table)
+
+ free_percpu(table->mask_cache);
+ kfree_rcu(rcu_dereference_raw(table->mask_array), rcu);
+- table_instance_destroy(table, ti, ufid_ti, false);
++ table_instance_destroy(ti, ufid_ti);
+ }
+
+ struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *ti,
+@@ -511,7 +505,8 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table)
+ flow_table->count = 0;
+ flow_table->ufid_count = 0;
+
+- table_instance_destroy(flow_table, old_ti, old_ufid_ti, true);
++ table_instance_flow_flush(flow_table, old_ti, old_ufid_ti);
++ table_instance_destroy(old_ti, old_ufid_ti);
+ return 0;
+
+ err_free_ti:
+diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h
+index 8a5cea6ae1116..8ea8fc9573776 100644
+--- a/net/openvswitch/flow_table.h
++++ b/net/openvswitch/flow_table.h
+@@ -86,4 +86,7 @@ bool ovs_flow_cmp(const struct sw_flow *, const struct sw_flow_match *);
+
+ void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
+ bool full, const struct sw_flow_mask *mask);
++void table_instance_flow_flush(struct flow_table *table,
++ struct table_instance *ti,
++ struct table_instance *ufid_ti);
+ #endif /* flow_table.h */
+diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
+index a080d63a9b456..4490dd7469d99 100644
+--- a/sound/pci/cs46xx/cs46xx_lib.c
++++ b/sound/pci/cs46xx/cs46xx_lib.c
+@@ -766,7 +766,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 6b536fc23ca62..1f90ca723f4df 100644
+--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
++++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
+@@ -1716,7 +1716,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 803978d69e3c4..ea7f16dd1f73c 100644
+--- a/sound/pci/hda/hda_codec.c
++++ b/sound/pci/hda/hda_codec.c
+@@ -3427,7 +3427,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 f4e9d9445e18f..201a3b6b0b0f6 100644
+--- a/sound/pci/hda/hda_generic.c
++++ b/sound/pci/hda/hda_generic.c
+@@ -813,7 +813,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/hda_intel.c b/sound/pci/hda/hda_intel.c
+index 4c23b169ac67e..1a26940a3fd7c 100644
+--- a/sound/pci/hda/hda_intel.c
++++ b/sound/pci/hda/hda_intel.c
+@@ -2747,6 +2747,8 @@ static const struct pci_device_id azx_ids[] = {
+ .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_HDMI },
+ /* Zhaoxin */
+ { PCI_DEVICE(0x1d17, 0x3288), .driver_data = AZX_DRIVER_ZHAOXIN },
++ /* Loongson */
++ { PCI_DEVICE(0x0014, 0x7a07), .driver_data = AZX_DRIVER_GENERIC },
+ { 0, }
+ };
+ MODULE_DEVICE_TABLE(pci, azx_ids);
+diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
+index cd46247988e4d..f0c6d2907e396 100644
+--- a/sound/pci/hda/patch_hdmi.c
++++ b/sound/pci/hda/patch_hdmi.c
+@@ -160,6 +160,7 @@ struct hdmi_spec {
+
+ bool use_acomp_notifier; /* use eld_notify callback for hotplug */
+ bool acomp_registered; /* audio component registered in this driver */
++ bool force_connect; /* force connectivity */
+ struct drm_audio_component_audio_ops drm_audio_ops;
+ int (*port2pin)(struct hda_codec *, int); /* reverse port/pin mapping */
+
+@@ -1701,7 +1702,8 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
+ * all device entries on the same pin
+ */
+ config = snd_hda_codec_get_pincfg(codec, pin_nid);
+- if (get_defcfg_connect(config) == AC_JACK_PORT_NONE)
++ if (get_defcfg_connect(config) == AC_JACK_PORT_NONE &&
++ !spec->force_connect)
+ return 0;
+
+ /*
+@@ -1803,11 +1805,19 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
+ return 0;
+ }
+
++static const struct snd_pci_quirk force_connect_list[] = {
++ SND_PCI_QUIRK(0x103c, 0x870f, "HP", 1),
++ SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1),
++ {}
++};
++
+ static int hdmi_parse_codec(struct hda_codec *codec)
+ {
++ struct hdmi_spec *spec = codec->spec;
+ hda_nid_t start_nid;
+ unsigned int caps;
+ int i, nodes;
++ const struct snd_pci_quirk *q;
+
+ nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid);
+ if (!start_nid || nodes < 0) {
+@@ -1815,6 +1825,11 @@ static int hdmi_parse_codec(struct hda_codec *codec)
+ return -EINVAL;
+ }
+
++ q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list);
++
++ if (q && q->value)
++ spec->force_connect = true;
++
+ /*
+ * hdmi_add_pin() assumes total amount of converters to
+ * be known, so first discover all converters
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
+index b10d005786d07..da23c2d4ca51e 100644
+--- a/sound/pci/hda/patch_realtek.c
++++ b/sound/pci/hda/patch_realtek.c
+@@ -6167,6 +6167,7 @@ enum {
+ ALC269_FIXUP_CZC_L101,
+ ALC269_FIXUP_LEMOTE_A1802,
+ ALC269_FIXUP_LEMOTE_A190X,
++ ALC256_FIXUP_INTEL_NUC8_RUGGED,
+ };
+
+ static const struct hda_fixup alc269_fixups[] = {
+@@ -7488,6 +7489,15 @@ static const struct hda_fixup alc269_fixups[] = {
+ },
+ .chain_id = ALC269_FIXUP_DMIC,
+ },
++ [ALC256_FIXUP_INTEL_NUC8_RUGGED] = {
++ .type = HDA_FIXUP_PINS,
++ .v.pins = (const struct hda_pintbl[]) {
++ { 0x1b, 0x01a1913c }, /* use as headset mic, without its own jack detect */
++ { }
++ },
++ .chained = true,
++ .chain_id = ALC269_FIXUP_HEADSET_MODE
++ },
+ };
+
+ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
+@@ -7787,6 +7797,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
+ SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
+ SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
+ SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
++ SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
+
+ #if 0
+ /* Below is a quirk table taken from the old code.
+@@ -7958,6 +7969,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
+ {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
+ {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
+ {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
++ {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
+ {}
+ };
+ #define ALC225_STANDARD_PINS \
+diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
+index a608d0486ae49..2bea11d62d3e9 100644
+--- a/sound/pci/hda/patch_sigmatel.c
++++ b/sound/pci/hda/patch_sigmatel.c
+@@ -832,7 +832,7 @@ static int stac_auto_create_beep_ctls(struct hda_codec *codec,
+ static const 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 8df14f63b10df..096ec76f53046 100644
+--- a/sound/pci/ice1712/prodigy192.c
++++ b/sound/pci/ice1712/prodigy192.c
+@@ -32,7 +32,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 <tiwai@suse.de>
+diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
+index c3f8721624cd4..b90421a1d909a 100644
+--- a/sound/pci/oxygen/xonar_dg.c
++++ b/sound/pci/oxygen/xonar_dg.c
+@@ -29,7 +29,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/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
+index ca42445b649d4..b471892d84778 100644
+--- a/sound/soc/codecs/wm8958-dsp2.c
++++ b/sound/soc/codecs/wm8958-dsp2.c
+@@ -412,8 +412,12 @@ int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+ {
+ struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
++ struct wm8994 *control = dev_get_drvdata(component->dev->parent);
+ int i;
+
++ if (control->type != WM8958)
++ return 0;
++
+ switch (event) {
+ case SND_SOC_DAPM_POST_PMU:
+ case SND_SOC_DAPM_PRE_PMU:
+diff --git a/sound/soc/img/img-i2s-in.c b/sound/soc/img/img-i2s-in.c
+index e30b66b94bf67..0843235d73c91 100644
+--- a/sound/soc/img/img-i2s-in.c
++++ b/sound/soc/img/img-i2s-in.c
+@@ -343,8 +343,10 @@ static int img_i2s_in_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+ chan_control_mask = IMG_I2S_IN_CH_CTL_CLK_TRANS_MASK;
+
+ ret = pm_runtime_get_sync(i2s->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_noidle(i2s->dev);
+ return ret;
++ }
+
+ for (i = 0; i < i2s->active_channels; i++)
+ img_i2s_in_ch_disable(i2s, i);
+diff --git a/sound/soc/img/img-parallel-out.c b/sound/soc/img/img-parallel-out.c
+index 5ddbe3a31c2e9..4da49a42e8547 100644
+--- a/sound/soc/img/img-parallel-out.c
++++ b/sound/soc/img/img-parallel-out.c
+@@ -163,8 +163,10 @@ static int img_prl_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+ }
+
+ ret = pm_runtime_get_sync(prl->dev);
+- if (ret < 0)
++ if (ret < 0) {
++ pm_runtime_put_noidle(prl->dev);
+ return ret;
++ }
+
+ reg = img_prl_out_readl(prl, IMG_PRL_OUT_CTL);
+ reg = (reg & ~IMG_PRL_OUT_CTL_EDGE_MASK) | control_set;
+diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.h b/sound/soc/intel/boards/skl_hda_dsp_common.h
+index 507750ef67f30..4b0b3959182e5 100644
+--- a/sound/soc/intel/boards/skl_hda_dsp_common.h
++++ b/sound/soc/intel/boards/skl_hda_dsp_common.h
+@@ -33,6 +33,7 @@ struct skl_hda_private {
+ int dai_index;
+ const char *platform_name;
+ bool common_hdmi_codec_drv;
++ bool idisp_codec;
+ };
+
+ extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
+diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
+index 79c8947f840b9..ca4900036ead9 100644
+--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
++++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
+@@ -79,6 +79,9 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
+ link->platforms->name = ctx->platform_name;
+ link->nonatomic = 1;
+
++ if (!ctx->idisp_codec)
++ return 0;
++
+ if (strstr(link->name, "HDMI")) {
+ ret = skl_hda_hdmi_add_pcm(card, ctx->pcm_count);
+
+@@ -118,19 +121,20 @@ static char hda_soc_components[30];
+ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
+ {
+ struct snd_soc_card *card = &hda_soc_card;
++ struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
+ struct snd_soc_dai_link *dai_link;
+- u32 codec_count, codec_mask, idisp_mask;
++ u32 codec_count, codec_mask;
+ int i, num_links, num_route;
+
+ codec_mask = mach_params->codec_mask;
+ codec_count = hweight_long(codec_mask);
+- idisp_mask = codec_mask & IDISP_CODEC_MASK;
++ ctx->idisp_codec = !!(codec_mask & IDISP_CODEC_MASK);
+
+ if (!codec_count || codec_count > 2 ||
+- (codec_count == 2 && !idisp_mask))
++ (codec_count == 2 && !ctx->idisp_codec))
+ return -EINVAL;
+
+- if (codec_mask == idisp_mask) {
++ if (codec_mask == IDISP_CODEC_MASK) {
+ /* topology with iDisp as the only HDA codec */
+ num_links = IDISP_DAI_COUNT + DMIC_DAI_COUNT;
+ num_route = IDISP_ROUTE_COUNT;
+@@ -152,7 +156,7 @@ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
+ num_route = ARRAY_SIZE(skl_hda_map);
+ card->dapm_widgets = skl_hda_widgets;
+ card->num_dapm_widgets = ARRAY_SIZE(skl_hda_widgets);
+- if (!idisp_mask) {
++ if (!ctx->idisp_codec) {
+ for (i = 0; i < IDISP_DAI_COUNT; i++) {
+ skl_hda_be_dai_links[i].codecs = dummy_codec;
+ skl_hda_be_dai_links[i].num_codecs =
+@@ -211,6 +215,8 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
+ if (!mach)
+ return -EINVAL;
+
++ snd_soc_card_set_drvdata(&hda_soc_card, ctx);
++
+ ret = skl_hda_fill_card_info(&mach->mach_params);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "Unsupported HDAudio/iDisp configuration found\n");
+@@ -223,7 +229,6 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
+ ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
+
+ hda_soc_card.dev = &pdev->dev;
+- snd_soc_card_set_drvdata(&hda_soc_card, ctx);
+
+ if (mach->mach_params.dmic_num > 0) {
+ snprintf(hda_soc_components, sizeof(hda_soc_components),
+diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
+index 1bfd9613449e9..95a119a2d354e 100644
+--- a/sound/soc/intel/boards/sof_sdw.c
++++ b/sound/soc/intel/boards/sof_sdw.c
+@@ -184,6 +184,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
+ .direction = {true, true},
+ .dai_name = "rt711-aif1",
+ .init = sof_sdw_rt711_init,
++ .exit = sof_sdw_rt711_exit,
+ },
+ {
+ .id = 0x1308,
+diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h
+index 69b363b8a6869..fdd2385049e1e 100644
+--- a/sound/soc/intel/boards/sof_sdw_common.h
++++ b/sound/soc/intel/boards/sof_sdw_common.h
+@@ -84,6 +84,7 @@ int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
+ struct snd_soc_dai_link *dai_links,
+ struct sof_sdw_codec_info *info,
+ bool playback);
++int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
+
+ /* RT700 support */
+ int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
+diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c
+index d4d75c8dc6b78..0cb9f1c1f8676 100644
+--- a/sound/soc/intel/boards/sof_sdw_rt711.c
++++ b/sound/soc/intel/boards/sof_sdw_rt711.c
+@@ -133,6 +133,21 @@ static int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd)
+ return ret;
+ }
+
++int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link)
++{
++ struct device *sdw_dev;
++
++ sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL,
++ dai_link->codecs[0].name);
++ if (!sdw_dev)
++ return -EINVAL;
++
++ device_remove_properties(sdw_dev);
++ put_device(sdw_dev);
++
++ return 0;
++}
++
+ int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
+ struct snd_soc_dai_link *dai_links,
+ struct sof_sdw_codec_info *info,
+diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
+index 635eacbd28d47..156e3b9d613c6 100644
+--- a/sound/soc/tegra/tegra30_ahub.c
++++ b/sound/soc/tegra/tegra30_ahub.c
+@@ -643,8 +643,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 d59882ec48f16..db5a8587bfa4c 100644
+--- a/sound/soc/tegra/tegra30_i2s.c
++++ b/sound/soc/tegra/tegra30_i2s.c
+@@ -567,8 +567,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/mixer.c b/sound/usb/mixer.c
+index eab0fd4fd7c33..e0b7174c10430 100644
+--- a/sound/usb/mixer.c
++++ b/sound/usb/mixer.c
+@@ -2367,7 +2367,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
+ int num_ins;
+ struct usb_mixer_elem_info *cval;
+ struct snd_kcontrol *kctl;
+- int i, err, nameid, type, len;
++ int i, err, nameid, type, len, val;
+ const struct procunit_info *info;
+ const struct procunit_value_info *valinfo;
+ const struct usbmix_name_map *map;
+@@ -2470,6 +2470,12 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
+ break;
+ }
+
++ err = get_cur_ctl_value(cval, cval->control << 8, &val);
++ if (err < 0) {
++ usb_mixer_elem_info_free(cval);
++ return -EINVAL;
++ }
++
+ kctl = snd_ctl_new1(&mixer_procunit_ctl, cval);
+ if (!kctl) {
+ usb_mixer_elem_info_free(cval);
+diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
+index a53eb67ad4bd8..366faaa4ba82c 100644
+--- a/sound/usb/quirks-table.h
++++ b/sound/usb/quirks-table.h
+@@ -2678,6 +2678,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),
+ .ifnum = QUIRK_ANY_INTERFACE,
+ .type = QUIRK_COMPOSITE,
+ .data = (const struct snd_usb_audio_quirk[]) {
++ {
++ .ifnum = 0,
++ .type = QUIRK_AUDIO_STANDARD_MIXER,
++ },
+ {
+ .ifnum = 0,
+ .type = QUIRK_AUDIO_FIXED_ENDPOINT,
+@@ -2690,6 +2694,32 @@ YAMAHA_DEVICE(0x7010, "UB99"),
+ .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
+ .endpoint = 0x01,
+ .ep_attr = USB_ENDPOINT_XFER_ISOC,
++ .datainterval = 1,
++ .maxpacksize = 0x024c,
++ .rates = SNDRV_PCM_RATE_44100 |
++ SNDRV_PCM_RATE_48000,
++ .rate_min = 44100,
++ .rate_max = 48000,
++ .nr_rates = 2,
++ .rate_table = (unsigned int[]) {
++ 44100, 48000
++ }
++ }
++ },
++ {
++ .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,
++ .attributes = 0,
++ .endpoint = 0x82,
++ .ep_attr = USB_ENDPOINT_XFER_ISOC,
++ .datainterval = 1,
++ .maxpacksize = 0x0126,
+ .rates = SNDRV_PCM_RATE_44100 |
+ SNDRV_PCM_RATE_48000,
+ .rate_min = 44100,
+@@ -3697,8 +3727,8 @@ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
+ * 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/bpf/bpftool/btf_dumper.c b/tools/bpf/bpftool/btf_dumper.c
+index ede162f83eea0..0e9310727281a 100644
+--- a/tools/bpf/bpftool/btf_dumper.c
++++ b/tools/bpf/bpftool/btf_dumper.c
+@@ -67,7 +67,7 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d,
+ if (!info->btf_id || !info->nr_func_info ||
+ btf__get_from_id(info->btf_id, &prog_btf))
+ goto print;
+- finfo = (struct bpf_func_info *)info->func_info;
++ finfo = u64_to_ptr(info->func_info);
+ func_type = btf__type_by_id(prog_btf, finfo->type_id);
+ if (!func_type || !btf_is_func(func_type))
+ goto print;
+diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
+index fca57ee8fafe4..dea691c83afca 100644
+--- a/tools/bpf/bpftool/link.c
++++ b/tools/bpf/bpftool/link.c
+@@ -101,7 +101,7 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
+ switch (info->type) {
+ case BPF_LINK_TYPE_RAW_TRACEPOINT:
+ jsonw_string_field(json_wtr, "tp_name",
+- (const char *)info->raw_tracepoint.tp_name);
++ u64_to_ptr(info->raw_tracepoint.tp_name));
+ break;
+ case BPF_LINK_TYPE_TRACING:
+ err = get_prog_info(info->prog_id, &prog_info);
+@@ -177,7 +177,7 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
+ switch (info->type) {
+ case BPF_LINK_TYPE_RAW_TRACEPOINT:
+ printf("\n\ttp '%s' ",
+- (const char *)info->raw_tracepoint.tp_name);
++ (const char *)u64_to_ptr(info->raw_tracepoint.tp_name));
+ break;
+ case BPF_LINK_TYPE_TRACING:
+ err = get_prog_info(info->prog_id, &prog_info);
+diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
+index 5cdf0bc049bd9..5917484c2e027 100644
+--- a/tools/bpf/bpftool/main.h
++++ b/tools/bpf/bpftool/main.h
+@@ -21,7 +21,15 @@
+ /* Make sure we do not use kernel-only integer typedefs */
+ #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
+
+-#define ptr_to_u64(ptr) ((__u64)(unsigned long)(ptr))
++static inline __u64 ptr_to_u64(const void *ptr)
++{
++ return (__u64)(unsigned long)ptr;
++}
++
++static inline void *u64_to_ptr(__u64 ptr)
++{
++ return (void *)(unsigned long)ptr;
++}
+
+ #define NEXT_ARG() ({ argc--; argv++; if (argc < 0) usage(); })
+ #define NEXT_ARGP() ({ (*argc)--; (*argv)++; if (*argc < 0) usage(); })
+diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
+index a5eff83496f2d..2c6f7e160b248 100644
+--- a/tools/bpf/bpftool/prog.c
++++ b/tools/bpf/bpftool/prog.c
+@@ -537,14 +537,14 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
+ p_info("no instructions returned");
+ return -1;
+ }
+- buf = (unsigned char *)(info->jited_prog_insns);
++ buf = u64_to_ptr(info->jited_prog_insns);
+ member_len = info->jited_prog_len;
+ } else { /* DUMP_XLATED */
+ if (info->xlated_prog_len == 0 || !info->xlated_prog_insns) {
+ p_err("error retrieving insn dump: kernel.kptr_restrict set?");
+ return -1;
+ }
+- buf = (unsigned char *)info->xlated_prog_insns;
++ buf = u64_to_ptr(info->xlated_prog_insns);
+ member_len = info->xlated_prog_len;
+ }
+
+@@ -553,7 +553,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
+ return -1;
+ }
+
+- func_info = (void *)info->func_info;
++ func_info = u64_to_ptr(info->func_info);
+
+ if (info->nr_line_info) {
+ prog_linfo = bpf_prog_linfo__new(info);
+@@ -571,7 +571,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
+
+ n = write(fd, buf, member_len);
+ close(fd);
+- if (n != member_len) {
++ if (n != (ssize_t)member_len) {
+ p_err("error writing output file: %s",
+ n < 0 ? strerror(errno) : "short write");
+ return -1;
+@@ -601,13 +601,13 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
+ __u32 i;
+ if (info->nr_jited_ksyms) {
+ kernel_syms_load(&dd);
+- ksyms = (__u64 *) info->jited_ksyms;
++ ksyms = u64_to_ptr(info->jited_ksyms);
+ }
+
+ if (json_output)
+ jsonw_start_array(json_wtr);
+
+- lens = (__u32 *) info->jited_func_lens;
++ lens = u64_to_ptr(info->jited_func_lens);
+ for (i = 0; i < info->nr_jited_func_lens; i++) {
+ if (ksyms) {
+ sym = kernel_syms_search(&dd, ksyms[i]);
+@@ -668,7 +668,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
+ } else {
+ kernel_syms_load(&dd);
+ dd.nr_jited_ksyms = info->nr_jited_ksyms;
+- dd.jited_ksyms = (__u64 *) info->jited_ksyms;
++ dd.jited_ksyms = u64_to_ptr(info->jited_ksyms);
+ dd.btf = btf;
+ dd.func_info = func_info;
+ dd.finfo_rec_size = info->func_info_rec_size;
+@@ -1790,7 +1790,7 @@ static char *profile_target_name(int tgt_fd)
+ goto out;
+ }
+
+- func_info = (struct bpf_func_info *)(info_linear->info.func_info);
++ func_info = u64_to_ptr(info_linear->info.func_info);
+ t = btf__type_by_id(btf, func_info[0].type_id);
+ if (!t) {
+ p_err("btf %d doesn't have type %d",
+diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
+index e7642a6e39f9e..3ac0094706b81 100644
+--- a/tools/lib/bpf/libbpf.c
++++ b/tools/lib/bpf/libbpf.c
+@@ -2237,7 +2237,7 @@ static int bpf_object__init_user_btf_maps(struct bpf_object *obj, bool strict,
+ data = elf_getdata(scn, NULL);
+ if (!scn || !data) {
+ pr_warn("failed to get Elf_Data from map section %d (%s)\n",
+- obj->efile.maps_shndx, MAPS_ELF_SEC);
++ obj->efile.btf_maps_shndx, MAPS_ELF_SEC);
+ return -EINVAL;
+ }
+
+@@ -3319,10 +3319,11 @@ bpf_object__probe_global_data(struct bpf_object *obj)
+
+ map = bpf_create_map_xattr(&map_attr);
+ if (map < 0) {
+- cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
++ ret = -errno;
++ cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg));
+ pr_warn("Error in %s():%s(%d). Couldn't create simple array map.\n",
+- __func__, cp, errno);
+- return -errno;
++ __func__, cp, -ret);
++ return ret;
+ }
+
+ insns[0].imm = map;
+@@ -5779,9 +5780,10 @@ int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
+ }
+
+ if (bpf_obj_pin(prog->instances.fds[instance], path)) {
+- cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
++ err = -errno;
++ cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg));
+ pr_warn("failed to pin program: %s\n", cp);
+- return -errno;
++ return err;
+ }
+ pr_debug("pinned program '%s'\n", path);
+
+diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c b/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c
+index 7afa4160416f6..284d5921c3458 100644
+--- a/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c
++++ b/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c
+@@ -159,15 +159,15 @@ void test_bpf_obj_id(void)
+ /* Check getting link info */
+ info_len = sizeof(struct bpf_link_info) * 2;
+ bzero(&link_infos[i], info_len);
+- link_infos[i].raw_tracepoint.tp_name = (__u64)&tp_name;
++ link_infos[i].raw_tracepoint.tp_name = ptr_to_u64(&tp_name);
+ link_infos[i].raw_tracepoint.tp_name_len = sizeof(tp_name);
+ err = bpf_obj_get_info_by_fd(bpf_link__fd(links[i]),
+ &link_infos[i], &info_len);
+ if (CHECK(err ||
+ link_infos[i].type != BPF_LINK_TYPE_RAW_TRACEPOINT ||
+ link_infos[i].prog_id != prog_infos[i].id ||
+- link_infos[i].raw_tracepoint.tp_name != (__u64)&tp_name ||
+- strcmp((char *)link_infos[i].raw_tracepoint.tp_name,
++ link_infos[i].raw_tracepoint.tp_name != ptr_to_u64(&tp_name) ||
++ strcmp(u64_to_ptr(link_infos[i].raw_tracepoint.tp_name),
+ "sys_enter") ||
+ info_len != sizeof(struct bpf_link_info),
+ "get-link-info(fd)",
+@@ -178,7 +178,7 @@ void test_bpf_obj_id(void)
+ link_infos[i].type, BPF_LINK_TYPE_RAW_TRACEPOINT,
+ link_infos[i].id,
+ link_infos[i].prog_id, prog_infos[i].id,
+- (char *)link_infos[i].raw_tracepoint.tp_name,
++ (const char *)u64_to_ptr(link_infos[i].raw_tracepoint.tp_name),
+ "sys_enter"))
+ goto done;
+
+diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
+index cb33a7ee4e04f..39fb81d9daeb5 100644
+--- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c
++++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c
+@@ -12,15 +12,16 @@ void btf_dump_printf(void *ctx, const char *fmt, va_list args)
+ static struct btf_dump_test_case {
+ const char *name;
+ const char *file;
++ bool known_ptr_sz;
+ struct btf_dump_opts opts;
+ } btf_dump_test_cases[] = {
+- {"btf_dump: syntax", "btf_dump_test_case_syntax", {}},
+- {"btf_dump: ordering", "btf_dump_test_case_ordering", {}},
+- {"btf_dump: padding", "btf_dump_test_case_padding", {}},
+- {"btf_dump: packing", "btf_dump_test_case_packing", {}},
+- {"btf_dump: bitfields", "btf_dump_test_case_bitfields", {}},
+- {"btf_dump: multidim", "btf_dump_test_case_multidim", {}},
+- {"btf_dump: namespacing", "btf_dump_test_case_namespacing", {}},
++ {"btf_dump: syntax", "btf_dump_test_case_syntax", true, {}},
++ {"btf_dump: ordering", "btf_dump_test_case_ordering", false, {}},
++ {"btf_dump: padding", "btf_dump_test_case_padding", true, {}},
++ {"btf_dump: packing", "btf_dump_test_case_packing", true, {}},
++ {"btf_dump: bitfields", "btf_dump_test_case_bitfields", true, {}},
++ {"btf_dump: multidim", "btf_dump_test_case_multidim", false, {}},
++ {"btf_dump: namespacing", "btf_dump_test_case_namespacing", false, {}},
+ };
+
+ static int btf_dump_all_types(const struct btf *btf,
+@@ -62,6 +63,18 @@ static int test_btf_dump_case(int n, struct btf_dump_test_case *t)
+ goto done;
+ }
+
++ /* tests with t->known_ptr_sz have no "long" or "unsigned long" type,
++ * so it's impossible to determine correct pointer size; but if they
++ * do, it should be 8 regardless of host architecture, becaues BPF
++ * target is always 64-bit
++ */
++ if (!t->known_ptr_sz) {
++ btf__set_pointer_size(btf, 8);
++ } else {
++ CHECK(btf__pointer_size(btf) != 8, "ptr_sz", "exp %d, got %zu\n",
++ 8, btf__pointer_size(btf));
++ }
++
+ snprintf(out_file, sizeof(out_file), "/tmp/%s.output.XXXXXX", t->file);
+ fd = mkstemp(out_file);
+ if (CHECK(fd < 0, "create_tmp", "failed to create file: %d\n", fd)) {
+diff --git a/tools/testing/selftests/bpf/prog_tests/core_extern.c b/tools/testing/selftests/bpf/prog_tests/core_extern.c
+index b093787e94489..1931a158510e0 100644
+--- a/tools/testing/selftests/bpf/prog_tests/core_extern.c
++++ b/tools/testing/selftests/bpf/prog_tests/core_extern.c
+@@ -159,8 +159,8 @@ void test_core_extern(void)
+ exp = (uint64_t *)&t->data;
+ for (j = 0; j < n; j++) {
+ CHECK(got[j] != exp[j], "check_res",
+- "result #%d: expected %lx, but got %lx\n",
+- j, exp[j], got[j]);
++ "result #%d: expected %llx, but got %llx\n",
++ j, (__u64)exp[j], (__u64)got[j]);
+ }
+ cleanup:
+ test_core_extern__destroy(skel);
+diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
+index 084ed26a7d78c..a54eafc5e4b31 100644
+--- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
++++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
+@@ -237,8 +237,8 @@
+ .union_sz = sizeof(((type *)0)->union_field), \
+ .arr_sz = sizeof(((type *)0)->arr_field), \
+ .arr_elem_sz = sizeof(((type *)0)->arr_field[0]), \
+- .ptr_sz = sizeof(((type *)0)->ptr_field), \
+- .enum_sz = sizeof(((type *)0)->enum_field), \
++ .ptr_sz = 8, /* always 8-byte pointer for BPF */ \
++ .enum_sz = sizeof(((type *)0)->enum_field), \
+ }
+
+ #define SIZE_CASE(name) { \
+@@ -432,20 +432,20 @@ static struct core_reloc_test_case test_cases[] = {
+ .sb4 = -1,
+ .sb20 = -0x17654321,
+ .u32 = 0xBEEF,
+- .s32 = -0x3FEDCBA987654321,
++ .s32 = -0x3FEDCBA987654321LL,
+ }),
+ BITFIELDS_CASE(bitfields___bitfield_vs_int, {
+- .ub1 = 0xFEDCBA9876543210,
++ .ub1 = 0xFEDCBA9876543210LL,
+ .ub2 = 0xA6,
+- .ub7 = -0x7EDCBA987654321,
+- .sb4 = -0x6123456789ABCDE,
+- .sb20 = 0xD00D,
++ .ub7 = -0x7EDCBA987654321LL,
++ .sb4 = -0x6123456789ABCDELL,
++ .sb20 = 0xD00DLL,
+ .u32 = -0x76543,
+- .s32 = 0x0ADEADBEEFBADB0B,
++ .s32 = 0x0ADEADBEEFBADB0BLL,
+ }),
+ BITFIELDS_CASE(bitfields___just_big_enough, {
+- .ub1 = 0xF,
+- .ub2 = 0x0812345678FEDCBA,
++ .ub1 = 0xFLL,
++ .ub2 = 0x0812345678FEDCBALL,
+ }),
+ BITFIELDS_ERR_CASE(bitfields___err_too_big_bitfield),
+
+diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
+index a895bfed55db0..197d0d217b56b 100644
+--- a/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
++++ b/tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
+@@ -16,7 +16,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
+ __u32 duration = 0, retval;
+ struct bpf_map *data_map;
+ const int zero = 0;
+- u64 *result = NULL;
++ __u64 *result = NULL;
+
+ err = bpf_prog_load(target_obj_file, BPF_PROG_TYPE_UNSPEC,
+ &pkt_obj, &pkt_fd);
+@@ -29,7 +29,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
+
+ link = calloc(sizeof(struct bpf_link *), prog_cnt);
+ prog = calloc(sizeof(struct bpf_program *), prog_cnt);
+- result = malloc((prog_cnt + 32 /* spare */) * sizeof(u64));
++ result = malloc((prog_cnt + 32 /* spare */) * sizeof(__u64));
+ if (CHECK(!link || !prog || !result, "alloc_memory",
+ "failed to alloc memory"))
+ goto close_prog;
+@@ -72,7 +72,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
+ goto close_prog;
+
+ for (i = 0; i < prog_cnt; i++)
+- if (CHECK(result[i] != 1, "result", "fexit_bpf2bpf failed err %ld\n",
++ if (CHECK(result[i] != 1, "result", "fexit_bpf2bpf failed err %llu\n",
+ result[i]))
+ goto close_prog;
+
+diff --git a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
+index f11f187990e95..cd6dc80edf18e 100644
+--- a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
++++ b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c
+@@ -591,7 +591,7 @@ void test_flow_dissector(void)
+ CHECK_ATTR(tattr.data_size_out != sizeof(flow_keys) ||
+ err || tattr.retval != 1,
+ tests[i].name,
+- "err %d errno %d retval %d duration %d size %u/%lu\n",
++ "err %d errno %d retval %d duration %d size %u/%zu\n",
+ err, errno, tattr.retval, tattr.duration,
+ tattr.data_size_out, sizeof(flow_keys));
+ CHECK_FLOW_KEYS(tests[i].name, flow_keys, tests[i].keys);
+diff --git a/tools/testing/selftests/bpf/prog_tests/global_data.c b/tools/testing/selftests/bpf/prog_tests/global_data.c
+index e3cb62b0a110e..9efa7e50eab27 100644
+--- a/tools/testing/selftests/bpf/prog_tests/global_data.c
++++ b/tools/testing/selftests/bpf/prog_tests/global_data.c
+@@ -5,7 +5,7 @@
+ static void test_global_data_number(struct bpf_object *obj, __u32 duration)
+ {
+ int i, err, map_fd;
+- uint64_t num;
++ __u64 num;
+
+ map_fd = bpf_find_map(__func__, obj, "result_number");
+ if (CHECK_FAIL(map_fd < 0))
+@@ -14,7 +14,7 @@ static void test_global_data_number(struct bpf_object *obj, __u32 duration)
+ struct {
+ char *name;
+ uint32_t key;
+- uint64_t num;
++ __u64 num;
+ } tests[] = {
+ { "relocate .bss reference", 0, 0 },
+ { "relocate .data reference", 1, 42 },
+@@ -32,7 +32,7 @@ static void test_global_data_number(struct bpf_object *obj, __u32 duration)
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ err = bpf_map_lookup_elem(map_fd, &tests[i].key, &num);
+ CHECK(err || num != tests[i].num, tests[i].name,
+- "err %d result %lx expected %lx\n",
++ "err %d result %llx expected %llx\n",
+ err, num, tests[i].num);
+ }
+ }
+diff --git a/tools/testing/selftests/bpf/prog_tests/mmap.c b/tools/testing/selftests/bpf/prog_tests/mmap.c
+index 43d0b5578f461..9c3c5c0f068fb 100644
+--- a/tools/testing/selftests/bpf/prog_tests/mmap.c
++++ b/tools/testing/selftests/bpf/prog_tests/mmap.c
+@@ -21,7 +21,7 @@ void test_mmap(void)
+ const long page_size = sysconf(_SC_PAGE_SIZE);
+ int err, duration = 0, i, data_map_fd, data_map_id, tmp_fd, rdmap_fd;
+ struct bpf_map *data_map, *bss_map;
+- void *bss_mmaped = NULL, *map_mmaped = NULL, *tmp1, *tmp2;
++ void *bss_mmaped = NULL, *map_mmaped = NULL, *tmp0, *tmp1, *tmp2;
+ struct test_mmap__bss *bss_data;
+ struct bpf_map_info map_info;
+ __u32 map_info_sz = sizeof(map_info);
+@@ -183,16 +183,23 @@ void test_mmap(void)
+
+ /* check some more advanced mmap() manipulations */
+
++ tmp0 = mmap(NULL, 4 * page_size, PROT_READ, MAP_SHARED | MAP_ANONYMOUS,
++ -1, 0);
++ if (CHECK(tmp0 == MAP_FAILED, "adv_mmap0", "errno %d\n", errno))
++ goto cleanup;
++
+ /* map all but last page: pages 1-3 mapped */
+- tmp1 = mmap(NULL, 3 * page_size, PROT_READ, MAP_SHARED,
++ tmp1 = mmap(tmp0, 3 * page_size, PROT_READ, MAP_SHARED | MAP_FIXED,
+ data_map_fd, 0);
+- if (CHECK(tmp1 == MAP_FAILED, "adv_mmap1", "errno %d\n", errno))
++ if (CHECK(tmp0 != tmp1, "adv_mmap1", "tmp0: %p, tmp1: %p\n", tmp0, tmp1)) {
++ munmap(tmp0, 4 * page_size);
+ goto cleanup;
++ }
+
+ /* unmap second page: pages 1, 3 mapped */
+ err = munmap(tmp1 + page_size, page_size);
+ if (CHECK(err, "adv_mmap2", "errno %d\n", errno)) {
+- munmap(tmp1, map_sz);
++ munmap(tmp1, 4 * page_size);
+ goto cleanup;
+ }
+
+@@ -201,7 +208,7 @@ void test_mmap(void)
+ MAP_SHARED | MAP_FIXED, data_map_fd, 0);
+ if (CHECK(tmp2 == MAP_FAILED, "adv_mmap3", "errno %d\n", errno)) {
+ munmap(tmp1, page_size);
+- munmap(tmp1 + 2*page_size, page_size);
++ munmap(tmp1 + 2*page_size, 2 * page_size);
+ goto cleanup;
+ }
+ CHECK(tmp1 + page_size != tmp2, "adv_mmap4",
+@@ -211,7 +218,7 @@ void test_mmap(void)
+ tmp2 = mmap(tmp1, 4 * page_size, PROT_READ, MAP_SHARED | MAP_FIXED,
+ data_map_fd, 0);
+ if (CHECK(tmp2 == MAP_FAILED, "adv_mmap5", "errno %d\n", errno)) {
+- munmap(tmp1, 3 * page_size); /* unmap page 1 */
++ munmap(tmp1, 4 * page_size); /* unmap page 1 */
+ goto cleanup;
+ }
+ CHECK(tmp1 != tmp2, "adv_mmap6", "tmp1: %p, tmp2: %p\n", tmp1, tmp2);
+diff --git a/tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c b/tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c
+index dde2b7ae7bc9e..935a294f049a2 100644
+--- a/tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c
++++ b/tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c
+@@ -28,7 +28,7 @@ void test_prog_run_xattr(void)
+ "err %d errno %d retval %d\n", err, errno, tattr.retval);
+
+ CHECK_ATTR(tattr.data_size_out != sizeof(pkt_v4), "data_size_out",
+- "incorrect output size, want %lu have %u\n",
++ "incorrect output size, want %zu have %u\n",
+ sizeof(pkt_v4), tattr.data_size_out);
+
+ CHECK_ATTR(buf[5] != 0, "overflow",
+diff --git a/tools/testing/selftests/bpf/prog_tests/skb_ctx.c b/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
+index 7021b92af3134..c61b2b69710a9 100644
+--- a/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
++++ b/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
+@@ -80,7 +80,7 @@ void test_skb_ctx(void)
+
+ CHECK_ATTR(tattr.ctx_size_out != sizeof(skb),
+ "ctx_size_out",
+- "incorrect output size, want %lu have %u\n",
++ "incorrect output size, want %zu have %u\n",
+ sizeof(skb), tattr.ctx_size_out);
+
+ for (i = 0; i < 5; i++)
+diff --git a/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c b/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
+index 25b068591e9a4..193002b14d7f6 100644
+--- a/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
++++ b/tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
+@@ -19,7 +19,7 @@ static int libbpf_debug_print(enum libbpf_print_level level,
+ log_buf = va_arg(args, char *);
+ if (!log_buf)
+ goto out;
+- if (strstr(log_buf, err_str) == 0)
++ if (err_str && strstr(log_buf, err_str) == 0)
+ found = true;
+ out:
+ printf(format, log_buf);
+diff --git a/tools/testing/selftests/bpf/progs/core_reloc_types.h b/tools/testing/selftests/bpf/progs/core_reloc_types.h
+index 34d84717c9464..69139ed662164 100644
+--- a/tools/testing/selftests/bpf/progs/core_reloc_types.h
++++ b/tools/testing/selftests/bpf/progs/core_reloc_types.h
+@@ -1,5 +1,10 @@
+ #include <stdint.h>
+ #include <stdbool.h>
++
++void preserce_ptr_sz_fn(long x) {}
++
++#define __bpf_aligned __attribute__((aligned(8)))
++
+ /*
+ * KERNEL
+ */
+@@ -444,51 +449,51 @@ struct core_reloc_primitives {
+ char a;
+ int b;
+ enum core_reloc_primitives_enum c;
+- void *d;
+- int (*f)(const char *);
++ void *d __bpf_aligned;
++ int (*f)(const char *) __bpf_aligned;
+ };
+
+ struct core_reloc_primitives___diff_enum_def {
+ char a;
+ int b;
+- void *d;
+- int (*f)(const char *);
++ void *d __bpf_aligned;
++ int (*f)(const char *) __bpf_aligned;
+ enum {
+ X = 100,
+ Y = 200,
+- } c; /* inline enum def with differing set of values */
++ } c __bpf_aligned; /* inline enum def with differing set of values */
+ };
+
+ struct core_reloc_primitives___diff_func_proto {
+- void (*f)(int); /* incompatible function prototype */
+- void *d;
+- enum core_reloc_primitives_enum c;
++ void (*f)(int) __bpf_aligned; /* incompatible function prototype */
++ void *d __bpf_aligned;
++ enum core_reloc_primitives_enum c __bpf_aligned;
+ int b;
+ char a;
+ };
+
+ struct core_reloc_primitives___diff_ptr_type {
+- const char * const d; /* different pointee type + modifiers */
+- char a;
++ const char * const d __bpf_aligned; /* different pointee type + modifiers */
++ char a __bpf_aligned;
+ int b;
+ enum core_reloc_primitives_enum c;
+- int (*f)(const char *);
++ int (*f)(const char *) __bpf_aligned;
+ };
+
+ struct core_reloc_primitives___err_non_enum {
+ char a[1];
+ int b;
+ int c; /* int instead of enum */
+- void *d;
+- int (*f)(const char *);
++ void *d __bpf_aligned;
++ int (*f)(const char *) __bpf_aligned;
+ };
+
+ struct core_reloc_primitives___err_non_int {
+ char a[1];
+- int *b; /* ptr instead of int */
+- enum core_reloc_primitives_enum c;
+- void *d;
+- int (*f)(const char *);
++ int *b __bpf_aligned; /* ptr instead of int */
++ enum core_reloc_primitives_enum c __bpf_aligned;
++ void *d __bpf_aligned;
++ int (*f)(const char *) __bpf_aligned;
+ };
+
+ struct core_reloc_primitives___err_non_ptr {
+@@ -496,7 +501,7 @@ struct core_reloc_primitives___err_non_ptr {
+ int b;
+ enum core_reloc_primitives_enum c;
+ int d; /* int instead of ptr */
+- int (*f)(const char *);
++ int (*f)(const char *) __bpf_aligned;
+ };
+
+ /*
+@@ -507,7 +512,7 @@ struct core_reloc_mods_output {
+ };
+
+ typedef const int int_t;
+-typedef const char *char_ptr_t;
++typedef const char *char_ptr_t __bpf_aligned;
+ typedef const int arr_t[7];
+
+ struct core_reloc_mods_substruct {
+@@ -523,9 +528,9 @@ typedef struct {
+ struct core_reloc_mods {
+ int a;
+ int_t b;
+- char *c;
++ char *c __bpf_aligned;
+ char_ptr_t d;
+- int e[3];
++ int e[3] __bpf_aligned;
+ arr_t f;
+ struct core_reloc_mods_substruct g;
+ core_reloc_mods_substruct_t h;
+@@ -535,9 +540,9 @@ struct core_reloc_mods {
+ struct core_reloc_mods___mod_swap {
+ int b;
+ int_t a;
+- char *d;
++ char *d __bpf_aligned;
+ char_ptr_t c;
+- int f[3];
++ int f[3] __bpf_aligned;
+ arr_t e;
+ struct {
+ int y;
+@@ -555,7 +560,7 @@ typedef arr1_t arr2_t;
+ typedef arr2_t arr3_t;
+ typedef arr3_t arr4_t;
+
+-typedef const char * const volatile fancy_char_ptr_t;
++typedef const char * const volatile fancy_char_ptr_t __bpf_aligned;
+
+ typedef core_reloc_mods_substruct_t core_reloc_mods_substruct_tt;
+
+@@ -567,7 +572,7 @@ struct core_reloc_mods___typedefs {
+ arr4_t e;
+ fancy_char_ptr_t d;
+ fancy_char_ptr_t c;
+- int3_t b;
++ int3_t b __bpf_aligned;
+ int3_t a;
+ };
+
+@@ -739,19 +744,19 @@ struct core_reloc_bitfields___bit_sz_change {
+ int8_t sb4: 1; /* 4 -> 1 */
+ int32_t sb20: 30; /* 20 -> 30 */
+ /* non-bitfields */
+- uint16_t u32; /* 32 -> 16 */
+- int64_t s32; /* 32 -> 64 */
++ uint16_t u32; /* 32 -> 16 */
++ int64_t s32 __bpf_aligned; /* 32 -> 64 */
+ };
+
+ /* turn bitfield into non-bitfield and vice versa */
+ struct core_reloc_bitfields___bitfield_vs_int {
+ uint64_t ub1; /* 3 -> 64 non-bitfield */
+ uint8_t ub2; /* 20 -> 8 non-bitfield */
+- int64_t ub7; /* 7 -> 64 non-bitfield signed */
+- int64_t sb4; /* 4 -> 64 non-bitfield signed */
+- uint64_t sb20; /* 20 -> 16 non-bitfield unsigned */
+- int32_t u32: 20; /* 32 non-bitfield -> 20 bitfield */
+- uint64_t s32: 60; /* 32 non-bitfield -> 60 bitfield */
++ int64_t ub7 __bpf_aligned; /* 7 -> 64 non-bitfield signed */
++ int64_t sb4 __bpf_aligned; /* 4 -> 64 non-bitfield signed */
++ uint64_t sb20 __bpf_aligned; /* 20 -> 16 non-bitfield unsigned */
++ int32_t u32: 20; /* 32 non-bitfield -> 20 bitfield */
++ uint64_t s32: 60 __bpf_aligned; /* 32 non-bitfield -> 60 bitfield */
+ };
+
+ struct core_reloc_bitfields___just_big_enough {
+diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
+index 305fae8f80a98..c75fc6447186a 100644
+--- a/tools/testing/selftests/bpf/test_btf.c
++++ b/tools/testing/selftests/bpf/test_btf.c
+@@ -3883,7 +3883,7 @@ static int test_big_btf_info(unsigned int test_num)
+ info_garbage.garbage = 0;
+ err = bpf_obj_get_info_by_fd(btf_fd, info, &info_len);
+ if (CHECK(err || info_len != sizeof(*info),
+- "err:%d errno:%d info_len:%u sizeof(*info):%lu",
++ "err:%d errno:%d info_len:%u sizeof(*info):%zu",
+ err, errno, info_len, sizeof(*info))) {
+ err = -1;
+ goto done;
+@@ -4094,7 +4094,7 @@ static int do_test_get_info(unsigned int test_num)
+ if (CHECK(err || !info.id || info_len != sizeof(info) ||
+ info.btf_size != raw_btf_size ||
+ (ret = memcmp(raw_btf, user_btf, expected_nbytes)),
+- "err:%d errno:%d info.id:%u info_len:%u sizeof(info):%lu raw_btf_size:%u info.btf_size:%u expected_nbytes:%u memcmp:%d",
++ "err:%d errno:%d info.id:%u info_len:%u sizeof(info):%zu raw_btf_size:%u info.btf_size:%u expected_nbytes:%u memcmp:%d",
+ err, errno, info.id, info_len, sizeof(info),
+ raw_btf_size, info.btf_size, expected_nbytes, ret)) {
+ err = -1;
+@@ -4730,7 +4730,7 @@ ssize_t get_pprint_expected_line(enum pprint_mapv_kind_t mapv_kind,
+
+ nexpected_line = snprintf(expected_line, line_size,
+ "%s%u: {%u,0,%d,0x%x,0x%x,0x%x,"
+- "{%lu|[%u,%u,%u,%u,%u,%u,%u,%u]},%s,"
++ "{%llu|[%u,%u,%u,%u,%u,%u,%u,%u]},%s,"
+ "%u,0x%x,[[%d,%d],[%d,%d]]}\n",
+ percpu_map ? "\tcpu" : "",
+ percpu_map ? cpu : next_key,
+@@ -4738,7 +4738,7 @@ ssize_t get_pprint_expected_line(enum pprint_mapv_kind_t mapv_kind,
+ v->unused_bits2a,
+ v->bits28,
+ v->unused_bits2b,
+- v->ui64,
++ (__u64)v->ui64,
+ v->ui8a[0], v->ui8a[1],
+ v->ui8a[2], v->ui8a[3],
+ v->ui8a[4], v->ui8a[5],
+diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
+index b809246039181..b5670350e3263 100644
+--- a/tools/testing/selftests/bpf/test_progs.h
++++ b/tools/testing/selftests/bpf/test_progs.h
+@@ -133,6 +133,11 @@ static inline __u64 ptr_to_u64(const void *ptr)
+ return (__u64) (unsigned long) ptr;
+ }
+
++static inline void *u64_to_ptr(__u64 ptr)
++{
++ return (void *) (unsigned long) ptr;
++}
++
+ int bpf_find_map(const char *test, struct bpf_object *obj, const char *name);
+ int compare_map_keys(int map1_fd, int map2_fd);
+ int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len);
+diff --git a/tools/testing/selftests/net/icmp_redirect.sh b/tools/testing/selftests/net/icmp_redirect.sh
+index 18c5de53558af..bf361f30d6ef9 100755
+--- a/tools/testing/selftests/net/icmp_redirect.sh
++++ b/tools/testing/selftests/net/icmp_redirect.sh
+@@ -180,6 +180,8 @@ setup()
+ ;;
+ r[12]) ip netns exec $ns sysctl -q -w net.ipv4.ip_forward=1
+ ip netns exec $ns sysctl -q -w net.ipv4.conf.all.send_redirects=1
++ ip netns exec $ns sysctl -q -w net.ipv4.conf.default.rp_filter=0
++ ip netns exec $ns sysctl -q -w net.ipv4.conf.all.rp_filter=0
+
+ ip netns exec $ns sysctl -q -w net.ipv6.conf.all.forwarding=1
+ ip netns exec $ns sysctl -q -w net.ipv6.route.mtu_expires=10
+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 a2d7b0e3dca97..a26ac122c759f 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 bc893813483ee..bb9f587fa76e8 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 dcd351d203289..9ae795ce314e6 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 94c99c12c0f23..4b45a2e70f62b 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 dfbc5c3ad52d7..21537d6eb6b7d 100644
+--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
+@@ -396,8 +396,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 ca2f7d729155b..b208bf6ad58d3 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 ac3e6e182614a..ba2681a12cc7b 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 b8242e9d97d2d..791d37ba327b5 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 a05c0e18ded63..9b0f70d597020 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 153ebc92234fd..2904c741e04e5 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 eadad75ed7e6f..b29f8ba22d1e6 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);