--- /dev/null
+From 6faaa943d8c14c602be706a75fd83cf777b28676 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 14 Jul 2020 14:35:07 +0800
+Subject: ARM: dts: Fix dcan driver probe failed on am437x platform
+
+From: dillon min <dillon.minfei@gmail.com>
+
+[ Upstream commit 2a4117df9b436a0e4c79d211284ab2097bcd00dc ]
+
+Got following d_can probe errors with kernel 5.8-rc1 on am437x
+
+[ 10.730822] CAN device driver interface
+Starting Wait for Network to be Configured...
+[ OK ] Reached target Network.
+[ 10.787363] c_can_platform 481cc000.can: probe failed
+[ 10.792484] c_can_platform: probe of 481cc000.can failed with error -2
+[ 10.799457] c_can_platform 481d0000.can: probe failed
+[ 10.804617] c_can_platform: probe of 481d0000.can failed with error -2
+
+actually, Tony has fixed this issue on am335x with the patch [3]
+
+Since am437x has the same clock structure with am335x
+[1][2], so reuse the code from Tony Lindgren's patch [3] to fix it.
+
+[1]: https://www.ti.com/lit/pdf/spruh73 Chapter-23, Figure 23-1. DCAN
+ Integration
+[2]: https://www.ti.com/lit/pdf/spruhl7 Chapter-25, Figure 25-1. DCAN
+ Integration
+[3]: commit 516f1117d0fb ("ARM: dts: Configure osc clock for d_can on
+ am335x")
+
+Fixes: 1a5cd7c23cc5 ("bus: ti-sysc: Enable all clocks directly during init to read revision")
+Signed-off-by: dillon min <dillon.minfei@gmail.com>
+[tony@atomide.com: aligned commit message a bit for readability]
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/am437x-l4.dtsi | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/arch/arm/boot/dts/am437x-l4.dtsi b/arch/arm/boot/dts/am437x-l4.dtsi
+index 49c6a872052e4..e30089e96263a 100644
+--- a/arch/arm/boot/dts/am437x-l4.dtsi
++++ b/arch/arm/boot/dts/am437x-l4.dtsi
+@@ -1544,8 +1544,9 @@ target-module@cc000 { /* 0x481cc000, ap 50 46.0 */
+ reg = <0xcc020 0x4>;
+ reg-names = "rev";
+ /* Domains (P, C): per_pwrdm, l4ls_clkdm */
+- clocks = <&l4ls_clkctrl AM4_L4LS_D_CAN0_CLKCTRL 0>;
+- clock-names = "fck";
++ clocks = <&l4ls_clkctrl AM4_L4LS_D_CAN0_CLKCTRL 0>,
++ <&dcan0_fck>;
++ clock-names = "fck", "osc";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges = <0x0 0xcc000 0x2000>;
+@@ -1553,6 +1554,8 @@ target-module@cc000 { /* 0x481cc000, ap 50 46.0 */
+ dcan0: can@0 {
+ compatible = "ti,am4372-d_can", "ti,am3352-d_can";
+ reg = <0x0 0x2000>;
++ clocks = <&dcan0_fck>;
++ clock-names = "fck";
+ syscon-raminit = <&scm_conf 0x644 0>;
+ interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+ status = "disabled";
+@@ -1564,8 +1567,9 @@ target-module@d0000 { /* 0x481d0000, ap 52 3a.0 */
+ reg = <0xd0020 0x4>;
+ reg-names = "rev";
+ /* Domains (P, C): per_pwrdm, l4ls_clkdm */
+- clocks = <&l4ls_clkctrl AM4_L4LS_D_CAN1_CLKCTRL 0>;
+- clock-names = "fck";
++ clocks = <&l4ls_clkctrl AM4_L4LS_D_CAN1_CLKCTRL 0>,
++ <&dcan1_fck>;
++ clock-names = "fck", "osc";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges = <0x0 0xd0000 0x2000>;
+@@ -1573,6 +1577,8 @@ target-module@d0000 { /* 0x481d0000, ap 52 3a.0 */
+ dcan1: can@0 {
+ compatible = "ti,am4372-d_can", "ti,am3352-d_can";
+ reg = <0x0 0x2000>;
++ clocks = <&dcan1_fck>;
++ clock-name = "fck";
+ syscon-raminit = <&scm_conf 0x644 1>;
+ interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+ status = "disabled";
+--
+2.25.1
+
--- /dev/null
+From 1281e2181f6dc52d855712a7802031bc9861d874 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 26 Jun 2020 10:06:02 +0200
+Subject: ARM: dts: socfpga: Align L2 cache-controller nodename with dtschema
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit d7adfe5ffed9faa05f8926223086b101e14f700d ]
+
+Fix dtschema validator warnings like:
+ l2-cache@fffff000: $nodename:0:
+ 'l2-cache@fffff000' does not match '^(cache-controller|cpu)(@[0-9a-f,]+)*$'
+
+Fixes: 475dc86d08de ("arm: dts: socfpga: Add a base DTSI for Altera's Arria10 SOC")
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/socfpga.dtsi | 2 +-
+ arch/arm/boot/dts/socfpga_arria10.dtsi | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
+index 4f3993cc02279..4510308972209 100644
+--- a/arch/arm/boot/dts/socfpga.dtsi
++++ b/arch/arm/boot/dts/socfpga.dtsi
+@@ -710,7 +710,7 @@ ocram-ecc@ffd08144 {
+ };
+ };
+
+- L2: l2-cache@fffef000 {
++ L2: cache-controller@fffef000 {
+ compatible = "arm,pl310-cache";
+ reg = <0xfffef000 0x1000>;
+ interrupts = <0 38 0x04>;
+diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi b/arch/arm/boot/dts/socfpga_arria10.dtsi
+index 3b8571b8b4129..8f614c4b0e3eb 100644
+--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
++++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
+@@ -636,7 +636,7 @@ sdr: sdr@ffcfb100 {
+ reg = <0xffcfb100 0x80>;
+ };
+
+- L2: l2-cache@fffff000 {
++ L2: cache-controller@fffff000 {
+ compatible = "arm,pl310-cache";
+ reg = <0xfffff000 0x1000>;
+ interrupts = <0 18 IRQ_TYPE_LEVEL_HIGH>;
+--
+2.25.1
+
--- /dev/null
+From d2f4ec5e0abbe02d7b4ca0a1e9fda3bccd34a90a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 Jun 2020 14:53:46 +0200
+Subject: arm64: dts: meson: add missing gxl rng clock
+
+From: Jerome Brunet <jbrunet@baylibre.com>
+
+[ Upstream commit 95ca6f06dd4827ff63be5154120c7a8511cd9a41 ]
+
+The peripheral clock of the RNG is missing for gxl while it is present
+for gxbb.
+
+Fixes: 1b3f6d148692 ("ARM64: dts: meson-gx: add clock CLKID_RNG0 to hwrng node")
+Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
+Signed-off-by: Kevin Hilman <khilman@baylibre.com>
+Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
+Link: https://lore.kernel.org/r/20200617125346.1163527-1-jbrunet@baylibre.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+index 259d863993905..887c43119e632 100644
+--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
++++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+@@ -298,6 +298,11 @@ clkc: clock-controller {
+ };
+ };
+
++&hwrng {
++ clocks = <&clkc CLKID_RNG0>;
++ clock-names = "core";
++};
++
+ &i2c_A {
+ clocks = <&clkc CLKID_I2C>;
+ };
+--
+2.25.1
+
--- /dev/null
+From f221791fb4e4e55d5f27f02d40d4d2f0067433f9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Jun 2020 15:27:37 +0200
+Subject: arm64: dts: meson-gxl-s805x: reduce initial Mali450 core frequency
+
+From: Neil Armstrong <narmstrong@baylibre.com>
+
+[ Upstream commit b2037dafcf082cd24b88ae9283af628235df36e1 ]
+
+When starting at 744MHz, the Mali 450 core crashes on S805X based boards:
+ lima d00c0000.gpu: IRQ ppmmu3 not found
+ lima d00c0000.gpu: IRQ ppmmu4 not found
+ lima d00c0000.gpu: IRQ ppmmu5 not found
+ lima d00c0000.gpu: IRQ ppmmu6 not found
+ lima d00c0000.gpu: IRQ ppmmu7 not found
+ Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP
+ Modules linked in:
+ CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.7.2+ #492
+ Hardware name: Libre Computer AML-S805X-AC (DT)
+ pstate: 40000005 (nZcv daif -PAN -UAO)
+ pc : lima_gp_init+0x28/0x188
+ ...
+ Call trace:
+ lima_gp_init+0x28/0x188
+ lima_device_init+0x334/0x534
+ lima_pdev_probe+0xa4/0xe4
+ ...
+ Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
+
+Reverting to a safer 666Mhz frequency on the S805X that doesn't use the
+GP0 PLL makes it more stable.
+
+Fixes: fd47716479f5 ("ARM64: dts: add S805X based P241 board")
+Fixes: 0449b8e371ac ("arm64: dts: meson: add libretech aml-s805x-ac board")
+Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
+Signed-off-by: Kevin Hilman <khilman@baylibre.com>
+Link: https://lore.kernel.org/r/20200618132737.14243-1-narmstrong@baylibre.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../amlogic/meson-gxl-s805x-libretech-ac.dts | 2 +-
+ .../boot/dts/amlogic/meson-gxl-s805x-p241.dts | 2 +-
+ .../boot/dts/amlogic/meson-gxl-s805x.dtsi | 24 +++++++++++++++++++
+ 3 files changed, 26 insertions(+), 2 deletions(-)
+ create mode 100644 arch/arm64/boot/dts/amlogic/meson-gxl-s805x.dtsi
+
+diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dts
+index 4d59494965966..c6ae5622a532e 100644
+--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dts
++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-libretech-ac.dts
+@@ -9,7 +9,7 @@
+
+ #include <dt-bindings/input/input.h>
+
+-#include "meson-gxl-s905x.dtsi"
++#include "meson-gxl-s805x.dtsi"
+
+ / {
+ compatible = "libretech,aml-s805x-ac", "amlogic,s805x",
+diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-p241.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-p241.dts
+index a1119cfb0280c..85f78a9454074 100644
+--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-p241.dts
++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s805x-p241.dts
+@@ -9,7 +9,7 @@
+
+ #include <dt-bindings/input/input.h>
+
+-#include "meson-gxl-s905x.dtsi"
++#include "meson-gxl-s805x.dtsi"
+
+ / {
+ compatible = "amlogic,p241", "amlogic,s805x", "amlogic,meson-gxl";
+diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s805x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-s805x.dtsi
+new file mode 100644
+index 0000000000000..f9d705648426e
+--- /dev/null
++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s805x.dtsi
+@@ -0,0 +1,24 @@
++// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
++/*
++ * Copyright (c) 2020 BayLibre SAS
++ * Author: Neil Armstrong <narmstrong@baylibre.com>
++ */
++
++#include "meson-gxl-s905x.dtsi"
++
++/ {
++ compatible = "amlogic,s805x", "amlogic,meson-gxl";
++};
++
++/* The S805X Package doesn't seem to handle the 744MHz OPP correctly */
++&mali {
++ assigned-clocks = <&clkc CLKID_MALI_0_SEL>,
++ <&clkc CLKID_MALI_0>,
++ <&clkc CLKID_MALI>; /* Glitch free mux */
++ assigned-clock-parents = <&clkc CLKID_FCLK_DIV3>,
++ <0>, /* Do Nothing */
++ <&clkc CLKID_MALI_0>;
++ assigned-clock-rates = <0>, /* Do Nothing */
++ <666666666>,
++ <0>; /* Do Nothing */
++};
+--
+2.25.1
+
--- /dev/null
+From 2eb0d346bde2c9fb23f87a10f962789a46ed80e4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 Jun 2020 10:16:29 +0200
+Subject: arm64: dts: spcfpga: Align GIC, NAND and UART nodenames with dtschema
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit 681a5c71fb829fc2193e3bb524af41525477f5c3 ]
+
+Fix dtschema validator warnings like:
+ intc@fffc1000: $nodename:0:
+ 'intc@fffc1000' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
+
+Fixes: 78cd6a9d8e15 ("arm64: dts: Add base stratix 10 dtsi")
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
+index d1fc9c2055f49..9498d1de730ce 100644
+--- a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
++++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
+@@ -77,7 +77,7 @@ psci {
+ method = "smc";
+ };
+
+- intc: intc@fffc1000 {
++ intc: interrupt-controller@fffc1000 {
+ compatible = "arm,gic-400", "arm,cortex-a15-gic";
+ #interrupt-cells = <3>;
+ interrupt-controller;
+@@ -302,7 +302,7 @@ mmc: dwmmc0@ff808000 {
+ status = "disabled";
+ };
+
+- nand: nand@ffb90000 {
++ nand: nand-controller@ffb90000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "altr,socfpga-denali-nand";
+@@ -445,7 +445,7 @@ timer3: timer3@ffd00100 {
+ clock-names = "timer";
+ };
+
+- uart0: serial0@ffc02000 {
++ uart0: serial@ffc02000 {
+ compatible = "snps,dw-apb-uart";
+ reg = <0xffc02000 0x100>;
+ interrupts = <0 108 4>;
+@@ -456,7 +456,7 @@ uart0: serial0@ffc02000 {
+ status = "disabled";
+ };
+
+- uart1: serial1@ffc02100 {
++ uart1: serial@ffc02100 {
+ compatible = "snps,dw-apb-uart";
+ reg = <0xffc02100 0x100>;
+ interrupts = <0 109 4>;
+--
+2.25.1
+
--- /dev/null
+From 83a584883a8af68fdf9f9ad830e067d03eae33f7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Jul 2020 13:57:14 -0700
+Subject: bus: ti-sysc: Do not disable on suspend for no-idle
+
+From: Tony Lindgren <tony@atomide.com>
+
+[ Upstream commit a55de412228cc5a2b4bf8d2a09849898102633e2 ]
+
+If we have "ti,no-idle" specified for a module we must not disable
+the the module on suspend to keep things backwards compatible.
+
+Fixes: 386cb76681ca ("bus: ti-sysc: Handle missed no-idle property in addition to no-idle-on-init")
+Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/bus/ti-sysc.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
+index a3a279f30177c..3b0417a014946 100644
+--- a/drivers/bus/ti-sysc.c
++++ b/drivers/bus/ti-sysc.c
+@@ -1278,7 +1278,8 @@ static int __maybe_unused sysc_noirq_suspend(struct device *dev)
+
+ ddata = dev_get_drvdata(dev);
+
+- if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
++ if (ddata->cfg.quirks &
++ (SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_NO_IDLE))
+ return 0;
+
+ return pm_runtime_force_suspend(dev);
+@@ -1290,7 +1291,8 @@ static int __maybe_unused sysc_noirq_resume(struct device *dev)
+
+ ddata = dev_get_drvdata(dev);
+
+- if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
++ if (ddata->cfg.quirks &
++ (SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_NO_IDLE))
+ return 0;
+
+ return pm_runtime_force_resume(dev);
+--
+2.25.1
+
--- /dev/null
+From 9393d9ba7df2c491708c7ddd9c15c1e098c6bd99 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Jul 2020 10:41:02 -0700
+Subject: bus: ti-sysc: Fix sleeping function called from invalid context for
+ RTC quirk
+
+From: Tony Lindgren <tony@atomide.com>
+
+[ Upstream commit afe6f1eeb08f85e57f0a02b71efb5a0839606aac ]
+
+With CONFIG_DEBUG_ATOMIC_SLEEP enabled we can see the following with RTC probe:
+
+BUG: sleeping function called from invalid context at drivers/bus/ti-sysc.c:1736
+...
+(sysc_quirk_rtc) from [<c060d01c>] (sysc_write_sysconfig+0x1c/0x60)
+(sysc_write_sysconfig) from [<c060d9f4>] (sysc_enable_module+0x11c/0x274)
+(sysc_enable_module) from [<c060f37c>] (sysc_probe+0xe9c/0x1380)
+(sysc_probe) from [<c06e9384>] (platform_drv_probe+0x48/0x98)
+
+Fixes: e8639e1c986a ("bus: ti-sysc: Handle module unlock quirk needed for some RTC")
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/bus/ti-sysc.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
+index a160c3a1f09a3..a3a279f30177c 100644
+--- a/drivers/bus/ti-sysc.c
++++ b/drivers/bus/ti-sysc.c
+@@ -1727,8 +1727,8 @@ static void sysc_quirk_rtc(struct sysc *ddata, bool lock)
+
+ local_irq_save(flags);
+ /* RTC_STATUS BUSY bit may stay active for 1/32768 seconds (~30 usec) */
+- error = readl_poll_timeout(ddata->module_va + 0x44, val,
+- !(val & BIT(0)), 100, 50);
++ error = readl_poll_timeout_atomic(ddata->module_va + 0x44, val,
++ !(val & BIT(0)), 100, 50);
+ if (error)
+ dev_warn(ddata->dev, "rtc busy timeout\n");
+ /* Now we have ~15 microseconds to read/write various registers */
+--
+2.25.1
+
--- /dev/null
+From ba27435cda7cf7a94fbc0145a1b4063479e511c6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Jul 2020 10:44:20 -0700
+Subject: bus: ti-sysc: Fix wakeirq sleeping function called from invalid
+ context
+
+From: Tony Lindgren <tony@atomide.com>
+
+[ Upstream commit 9f9113925018d500a95df539014d9ff11ac2c02d ]
+
+With CONFIG_DEBUG_ATOMIC_SLEEP enabled we can see the following with
+wakeirqs and serial console idled:
+
+BUG: sleeping function called from invalid context at drivers/bus/ti-sysc.c:242
+...
+(sysc_wait_softreset) from [<c0606894>] (sysc_enable_module+0x48/0x274)
+(sysc_enable_module) from [<c0606c5c>] (sysc_runtime_resume+0x19c/0x1d8)
+(sysc_runtime_resume) from [<c0606cf0>] (sysc_child_runtime_resume+0x58/0x84)
+(sysc_child_runtime_resume) from [<c06eb7bc>] (__rpm_callback+0x30/0x12c)
+(__rpm_callback) from [<c06eb8d8>] (rpm_callback+0x20/0x80)
+(rpm_callback) from [<c06eb434>] (rpm_resume+0x638/0x7fc)
+(rpm_resume) from [<c06eb658>] (__pm_runtime_resume+0x60/0x9c)
+(__pm_runtime_resume) from [<c06edc08>] (handle_threaded_wake_irq+0x24/0x60)
+(handle_threaded_wake_irq) from [<c01befec>] (irq_thread_fn+0x1c/0x78)
+(irq_thread_fn) from [<c01bf30c>] (irq_thread+0x140/0x26c)
+
+We have __pm_runtime_resume() call the sysc_runtime_resume() with spinlock
+held and interrupts disabled.
+
+Fixes: d46f9fbec719 ("bus: ti-sysc: Use optional clocks on for enable and wait for softreset bit")
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/bus/ti-sysc.c | 13 ++++++-------
+ 1 file changed, 6 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
+index db9541f385055..a160c3a1f09a3 100644
+--- a/drivers/bus/ti-sysc.c
++++ b/drivers/bus/ti-sysc.c
+@@ -236,15 +236,14 @@ static int sysc_wait_softreset(struct sysc *ddata)
+ syss_done = ddata->cfg.syss_mask;
+
+ if (syss_offset >= 0) {
+- error = readx_poll_timeout(sysc_read_sysstatus, ddata, rstval,
+- (rstval & ddata->cfg.syss_mask) ==
+- syss_done,
+- 100, MAX_MODULE_SOFTRESET_WAIT);
++ error = readx_poll_timeout_atomic(sysc_read_sysstatus, ddata,
++ rstval, (rstval & ddata->cfg.syss_mask) ==
++ syss_done, 100, MAX_MODULE_SOFTRESET_WAIT);
+
+ } else if (ddata->cfg.quirks & SYSC_QUIRK_RESET_STATUS) {
+- error = readx_poll_timeout(sysc_read_sysconfig, ddata, rstval,
+- !(rstval & sysc_mask),
+- 100, MAX_MODULE_SOFTRESET_WAIT);
++ error = readx_poll_timeout_atomic(sysc_read_sysconfig, ddata,
++ rstval, !(rstval & sysc_mask),
++ 100, MAX_MODULE_SOFTRESET_WAIT);
+ }
+
+ return error;
+--
+2.25.1
+
--- /dev/null
+From 52dcbe57393f19de906ca01a59b86347fe7afaf0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Jul 2020 14:57:05 -0500
+Subject: clk: AST2600: Add mux for EMMC clock
+
+From: Eddie James <eajames@linux.ibm.com>
+
+[ Upstream commit c2407ab3bd55064d459bc822efd1c134e852798c ]
+
+The EMMC clock can be derived from either the HPLL or the MPLL. Register
+a clock mux so that the rate is calculated correctly based upon the
+parent.
+
+Signed-off-by: Eddie James <eajames@linux.ibm.com>
+Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
+Link: https://lore.kernel.org/r/20200709195706.12741-2-eajames@linux.ibm.com
+Acked-by: Joel Stanley <joel@jms.id.au>
+Fixes: d3d04f6c330a ("clk: Add support for AST2600 SoC")
+Signed-off-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/clk-ast2600.c | 49 ++++++++++++++++++++++++++++++++-------
+ 1 file changed, 41 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c
+index 99afc949925f0..177368cac6dd6 100644
+--- a/drivers/clk/clk-ast2600.c
++++ b/drivers/clk/clk-ast2600.c
+@@ -131,6 +131,18 @@ static const struct clk_div_table ast2600_eclk_div_table[] = {
+ { 0 }
+ };
+
++static const struct clk_div_table ast2600_emmc_extclk_div_table[] = {
++ { 0x0, 2 },
++ { 0x1, 4 },
++ { 0x2, 6 },
++ { 0x3, 8 },
++ { 0x4, 10 },
++ { 0x5, 12 },
++ { 0x6, 14 },
++ { 0x7, 16 },
++ { 0 }
++};
++
+ static const struct clk_div_table ast2600_mac_div_table[] = {
+ { 0x0, 4 },
+ { 0x1, 4 },
+@@ -390,6 +402,11 @@ static struct clk_hw *aspeed_g6_clk_hw_register_gate(struct device *dev,
+ return hw;
+ }
+
++static const char *const emmc_extclk_parent_names[] = {
++ "emmc_extclk_hpll_in",
++ "mpll",
++};
++
+ static const char * const vclk_parent_names[] = {
+ "dpll",
+ "d1pll",
+@@ -459,16 +476,32 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev)
+ return PTR_ERR(hw);
+ aspeed_g6_clk_data->hws[ASPEED_CLK_UARTX] = hw;
+
+- /* EMMC ext clock divider */
+- hw = clk_hw_register_gate(dev, "emmc_extclk_gate", "hpll", 0,
+- scu_g6_base + ASPEED_G6_CLK_SELECTION1, 15, 0,
+- &aspeed_g6_clk_lock);
++ /* EMMC ext clock */
++ hw = clk_hw_register_fixed_factor(dev, "emmc_extclk_hpll_in", "hpll",
++ 0, 1, 2);
+ if (IS_ERR(hw))
+ return PTR_ERR(hw);
+- hw = clk_hw_register_divider_table(dev, "emmc_extclk", "emmc_extclk_gate", 0,
+- scu_g6_base + ASPEED_G6_CLK_SELECTION1, 12, 3, 0,
+- ast2600_div_table,
+- &aspeed_g6_clk_lock);
++
++ hw = clk_hw_register_mux(dev, "emmc_extclk_mux",
++ emmc_extclk_parent_names,
++ ARRAY_SIZE(emmc_extclk_parent_names), 0,
++ scu_g6_base + ASPEED_G6_CLK_SELECTION1, 11, 1,
++ 0, &aspeed_g6_clk_lock);
++ if (IS_ERR(hw))
++ return PTR_ERR(hw);
++
++ hw = clk_hw_register_gate(dev, "emmc_extclk_gate", "emmc_extclk_mux",
++ 0, scu_g6_base + ASPEED_G6_CLK_SELECTION1,
++ 15, 0, &aspeed_g6_clk_lock);
++ if (IS_ERR(hw))
++ return PTR_ERR(hw);
++
++ hw = clk_hw_register_divider_table(dev, "emmc_extclk",
++ "emmc_extclk_gate", 0,
++ scu_g6_base +
++ ASPEED_G6_CLK_SELECTION1, 12,
++ 3, 0, ast2600_emmc_extclk_div_table,
++ &aspeed_g6_clk_lock);
+ if (IS_ERR(hw))
+ return PTR_ERR(hw);
+ aspeed_g6_clk_data->hws[ASPEED_CLK_EMMC] = hw;
+--
+2.25.1
+
--- /dev/null
+From f10666ee0b96566b50fab78a31922dd68e609085 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Jul 2020 13:11:29 -0700
+Subject: clk: mvebu: ARMADA_AP_CPU_CLK needs to select ARMADA_AP_CP_HELPER
+
+From: Nathan Chancellor <natechancellor@gmail.com>
+
+[ Upstream commit 8e3709d7e3a67e2d3f42bd1fc2052353a5678944 ]
+
+When building arm32 allmodconfig:
+
+ld.lld: error: undefined symbol: ap_cp_unique_name
+>>> referenced by ap-cpu-clk.c
+>>> clk/mvebu/ap-cpu-clk.o:(ap_cpu_clock_probe) in archive drivers/built-in.a
+
+ap_cp_unique_name is only compiled into the kernel image when
+CONFIG_ARMADA_AP_CP_HELPER is selected (as it is not user selectable).
+However, CONFIG_ARMADA_AP_CPU_CLK does not select it.
+
+This has been a problem since the driver was added to the kernel but it
+was not built before commit c318ea261749 ("cpufreq: ap806: fix cpufreq
+driver needs ap cpu clk") so it was never noticed.
+
+Fixes: f756e362d938 ("clk: mvebu: add CPU clock driver for Armada 7K/8K")
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Link: https://lore.kernel.org/r/20200701201128.2448427-1-natechancellor@gmail.com
+Signed-off-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/mvebu/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/clk/mvebu/Kconfig b/drivers/clk/mvebu/Kconfig
+index ded07b0bd0d5e..557d6213783c7 100644
+--- a/drivers/clk/mvebu/Kconfig
++++ b/drivers/clk/mvebu/Kconfig
+@@ -42,6 +42,7 @@ config ARMADA_AP806_SYSCON
+
+ config ARMADA_AP_CPU_CLK
+ bool
++ select ARMADA_AP_CP_HELPER
+
+ config ARMADA_CP110_SYSCON
+ bool
+--
+2.25.1
+
--- /dev/null
+From 0d70788a5fdb472a215736a3ae2826616325f610 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 16 Mar 2020 18:20:06 +0530
+Subject: counter: 104-quad-8: Add lock guards - differential encoder
+
+From: Syed Nayyar Waris <syednwaris@gmail.com>
+
+[ Upstream commit 708d98932893cea609386cefdfd190f757f5a61c ]
+
+Add lock protection from race conditions to 104-quad-8 counter driver
+for differential encoder status code changes. Mutex lock calls used for
+protection.
+
+Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>
+Fixes: 954ab5cc5f3e ("counter: 104-quad-8: Support Differential Encoder Cable Status")
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/counter/104-quad-8.c | 18 +++++++++++++++---
+ 1 file changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c
+index aa13708c2bc30..9364dc188f8ff 100644
+--- a/drivers/counter/104-quad-8.c
++++ b/drivers/counter/104-quad-8.c
+@@ -1274,18 +1274,26 @@ static ssize_t quad8_signal_cable_fault_read(struct counter_device *counter,
+ struct counter_signal *signal,
+ void *private, char *buf)
+ {
+- const struct quad8_iio *const priv = counter->priv;
++ struct quad8_iio *const priv = counter->priv;
+ const size_t channel_id = signal->id / 2;
+- const bool disabled = !(priv->cable_fault_enable & BIT(channel_id));
++ bool disabled;
+ unsigned int status;
+ unsigned int fault;
+
+- if (disabled)
++ mutex_lock(&priv->lock);
++
++ disabled = !(priv->cable_fault_enable & BIT(channel_id));
++
++ if (disabled) {
++ mutex_unlock(&priv->lock);
+ return -EINVAL;
++ }
+
+ /* Logic 0 = cable fault */
+ status = inb(priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS);
+
++ mutex_unlock(&priv->lock);
++
+ /* Mask respective channel and invert logic */
+ fault = !(status & BIT(channel_id));
+
+@@ -1317,6 +1325,8 @@ static ssize_t quad8_signal_cable_fault_enable_write(
+ if (ret)
+ return ret;
+
++ mutex_lock(&priv->lock);
++
+ if (enable)
+ priv->cable_fault_enable |= BIT(channel_id);
+ else
+@@ -1327,6 +1337,8 @@ static ssize_t quad8_signal_cable_fault_enable_write(
+
+ outb(cable_fault_enable, priv->base + QUAD8_DIFF_ENCODER_CABLE_STATUS);
+
++ mutex_unlock(&priv->lock);
++
+ return len;
+ }
+
+--
+2.25.1
+
--- /dev/null
+From 7b21d06da427db89c2b09da55c4ffc2a65d066e9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 16 Mar 2020 18:20:46 +0530
+Subject: counter: 104-quad-8: Add lock guards - filter clock prescaler
+
+From: Syed Nayyar Waris <syednwaris@gmail.com>
+
+[ Upstream commit d5ed76adb926a90fada98f518abc1ab6ef07d28f ]
+
+Add lock protection from race conditions to the 104-quad-8 counter
+driver for filter clock prescaler code changes. Mutex calls used for
+protection.
+
+Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>
+Fixes: de65d0556343 ("counter: 104-quad-8: Support Filter Clock Prescaler")
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/counter/104-quad-8.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c
+index 9364dc188f8ff..d22cfae1b0198 100644
+--- a/drivers/counter/104-quad-8.c
++++ b/drivers/counter/104-quad-8.c
+@@ -1365,6 +1365,8 @@ static ssize_t quad8_signal_fck_prescaler_write(struct counter_device *counter,
+ if (ret)
+ return ret;
+
++ mutex_lock(&priv->lock);
++
+ priv->fck_prescaler[channel_id] = prescaler;
+
+ /* Reset Byte Pointer */
+@@ -1375,6 +1377,8 @@ static ssize_t quad8_signal_fck_prescaler_write(struct counter_device *counter,
+ outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_PRESET_PSC,
+ base_offset + 1);
+
++ mutex_unlock(&priv->lock);
++
+ return len;
+ }
+
+--
+2.25.1
+
--- /dev/null
+From 171789655f47cc8b8290addbc104937d2d83e0f6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Jul 2020 13:12:25 +0300
+Subject: dmaengine: dmatest: stop completed threads when running without set
+ channel
+
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+
+[ Upstream commit fd17d1abce426b4224a916a242b57be94272771b ]
+
+The completed threads were not cleared and consequent run would result
+threads accumulating:
+
+echo 800000 > /sys/module/dmatest/parameters/test_buf_size
+echo 2000 > /sys/module/dmatest/parameters/timeout
+echo 50 > /sys/module/dmatest/parameters/iterations
+echo 1 > /sys/module/dmatest/parameters/max_channels
+echo "" > /sys/module/dmatest/parameters/channel
+[ 237.507265] dmatest: Added 1 threads using dma1chan2
+echo 1 > /sys/module/dmatest/parameters/run
+[ 244.713360] dmatest: Started 1 threads using dma1chan2
+[ 246.117680] dmatest: dma1chan2-copy0: summary 50 tests, 0 failures 2437.47 iops 977623 KB/s (0)
+
+echo 1 > /sys/module/dmatest/parameters/run
+[ 292.381471] dmatest: No channels configured, continue with any
+[ 292.389307] dmatest: Added 1 threads using dma1chan3
+[ 292.394302] dmatest: Started 1 threads using dma1chan2
+[ 292.399454] dmatest: Started 1 threads using dma1chan3
+[ 293.800835] dmatest: dma1chan3-copy0: summary 50 tests, 0 failures 2624.53 iops 975014 KB/s (0)
+
+echo 1 > /sys/module/dmatest/parameters/run
+[ 307.301429] dmatest: No channels configured, continue with any
+[ 307.309212] dmatest: Added 1 threads using dma1chan4
+[ 307.314197] dmatest: Started 1 threads using dma1chan2
+[ 307.319343] dmatest: Started 1 threads using dma1chan3
+[ 307.324492] dmatest: Started 1 threads using dma1chan4
+[ 308.730773] dmatest: dma1chan4-copy0: summary 50 tests, 0 failures 2390.28 iops 965436 KB/s (0)
+
+Fixes: 6b41030fdc79 ("dmaengine: dmatest: Restore default for channel")
+Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Link: https://lore.kernel.org/r/20200701101225.8607-1-peter.ujfalusi@ti.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/dmatest.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
+index 0425984db118a..62d9825a49e9d 100644
+--- a/drivers/dma/dmatest.c
++++ b/drivers/dma/dmatest.c
+@@ -1168,6 +1168,8 @@ static int dmatest_run_set(const char *val, const struct kernel_param *kp)
+ } else if (dmatest_run) {
+ if (!is_threaded_test_pending(info)) {
+ pr_info("No channels configured, continue with any\n");
++ if (!is_threaded_test_run(info))
++ stop_threaded_test(info);
+ add_threaded_test(info);
+ }
+ start_threaded_tests(info);
+--
+2.25.1
+
--- /dev/null
+From ddae8e4d34db9539da6f5674722ff35cfbe84969 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 5 Jul 2020 14:56:20 +0300
+Subject: dmaengine: dw: Initialize channel before each transfer
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+[ Upstream commit 99ba8b9b0d9780e9937eb1d488d120e9e5c2533d ]
+
+In some cases DMA can be used only with a consumer which does runtime power
+management and on the platforms, that have DMA auto power gating logic
+(see comments in the drivers/acpi/acpi_lpss.c), may result in DMA losing
+its context. Simple mitigation of this issue is to initialize channel
+each time the consumer initiates a transfer.
+
+Fixes: cfdf5b6cc598 ("dw_dmac: add support for Lynxpoint DMA controllers")
+Reported-by: Tsuchiya Yuto <kitakar@gmail.com>
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206403
+Link: https://lore.kernel.org/r/20200705115620.51929-1-andriy.shevchenko@linux.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/dw/core.c | 12 ------------
+ 1 file changed, 12 deletions(-)
+
+diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
+index 21cb2a58dbd29..a1b56f52db2f2 100644
+--- a/drivers/dma/dw/core.c
++++ b/drivers/dma/dw/core.c
+@@ -118,16 +118,11 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
+ {
+ struct dw_dma *dw = to_dw_dma(dwc->chan.device);
+
+- if (test_bit(DW_DMA_IS_INITIALIZED, &dwc->flags))
+- return;
+-
+ dw->initialize_chan(dwc);
+
+ /* Enable interrupts */
+ channel_set_bit(dw, MASK.XFER, dwc->mask);
+ channel_set_bit(dw, MASK.ERROR, dwc->mask);
+-
+- set_bit(DW_DMA_IS_INITIALIZED, &dwc->flags);
+ }
+
+ /*----------------------------------------------------------------------*/
+@@ -954,8 +949,6 @@ static void dwc_issue_pending(struct dma_chan *chan)
+
+ void do_dw_dma_off(struct dw_dma *dw)
+ {
+- unsigned int i;
+-
+ dma_writel(dw, CFG, 0);
+
+ channel_clear_bit(dw, MASK.XFER, dw->all_chan_mask);
+@@ -966,9 +959,6 @@ void do_dw_dma_off(struct dw_dma *dw)
+
+ while (dma_readl(dw, CFG) & DW_CFG_DMA_EN)
+ cpu_relax();
+-
+- for (i = 0; i < dw->dma.chancnt; i++)
+- clear_bit(DW_DMA_IS_INITIALIZED, &dw->chan[i].flags);
+ }
+
+ void do_dw_dma_on(struct dw_dma *dw)
+@@ -1032,8 +1022,6 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
+ /* Clear custom channel configuration */
+ memset(&dwc->dws, 0, sizeof(struct dw_dma_slave));
+
+- clear_bit(DW_DMA_IS_INITIALIZED, &dwc->flags);
+-
+ /* Disable interrupts */
+ channel_clear_bit(dw, MASK.XFER, dwc->mask);
+ channel_clear_bit(dw, MASK.BLOCK, dwc->mask);
+--
+2.25.1
+
--- /dev/null
+From 329ec1b81a1b997c0dc7f223ec7bc50c64ebcf2f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 Jun 2020 12:17:42 -0700
+Subject: dmaengine: idxd: cleanup workqueue config after disabling
+
+From: Dave Jiang <dave.jiang@intel.com>
+
+[ Upstream commit da32b28c95a79e399e18c03f8178f41aec9c66e4 ]
+
+After disabling a device, we should clean up the internal state for
+the wqs and zero out the configuration registers. Without doing so can cause
+issues when the user reprogram the wqs.
+
+Fixes: c52ca478233c ("dmaengine: idxd: add configuration component of driver")
+Reported-by: Yixin Zhang <yixin.zhang@intel.com>
+Signed-off-by: Dave Jiang <dave.jiang@intel.com>
+Tested-by: Yixin Zhang <yixin.zhang@intel.com>
+Link: https://lore.kernel.org/r/159311264246.1198.11955791213681679428.stgit@djiang5-desk3.ch.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/idxd/device.c | 25 +++++++++++++++++++++++++
+ drivers/dma/idxd/idxd.h | 1 +
+ drivers/dma/idxd/sysfs.c | 5 +++++
+ 3 files changed, 31 insertions(+)
+
+diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
+index 8d79a8787104d..8d2718c585dc6 100644
+--- a/drivers/dma/idxd/device.c
++++ b/drivers/dma/idxd/device.c
+@@ -320,6 +320,31 @@ void idxd_wq_unmap_portal(struct idxd_wq *wq)
+ devm_iounmap(dev, wq->dportal);
+ }
+
++void idxd_wq_disable_cleanup(struct idxd_wq *wq)
++{
++ struct idxd_device *idxd = wq->idxd;
++ struct device *dev = &idxd->pdev->dev;
++ int i, wq_offset;
++
++ lockdep_assert_held(&idxd->dev_lock);
++ memset(&wq->wqcfg, 0, sizeof(wq->wqcfg));
++ wq->type = IDXD_WQT_NONE;
++ wq->size = 0;
++ wq->group = NULL;
++ wq->threshold = 0;
++ wq->priority = 0;
++ clear_bit(WQ_FLAG_DEDICATED, &wq->flags);
++ memset(wq->name, 0, WQ_NAME_SIZE);
++
++ for (i = 0; i < 8; i++) {
++ wq_offset = idxd->wqcfg_offset + wq->id * 32 + i * sizeof(u32);
++ iowrite32(0, idxd->reg_base + wq_offset);
++ dev_dbg(dev, "WQ[%d][%d][%#x]: %#x\n",
++ wq->id, i, wq_offset,
++ ioread32(idxd->reg_base + wq_offset));
++ }
++}
++
+ /* Device control bits */
+ static inline bool idxd_is_enabled(struct idxd_device *idxd)
+ {
+diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
+index b8f8a363b4a71..908c8d0ef3ab6 100644
+--- a/drivers/dma/idxd/idxd.h
++++ b/drivers/dma/idxd/idxd.h
+@@ -290,6 +290,7 @@ int idxd_wq_enable(struct idxd_wq *wq);
+ int idxd_wq_disable(struct idxd_wq *wq);
+ int idxd_wq_map_portal(struct idxd_wq *wq);
+ void idxd_wq_unmap_portal(struct idxd_wq *wq);
++void idxd_wq_disable_cleanup(struct idxd_wq *wq);
+
+ /* submission */
+ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc);
+diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
+index 3999827970aba..fbb455ece81e8 100644
+--- a/drivers/dma/idxd/sysfs.c
++++ b/drivers/dma/idxd/sysfs.c
+@@ -315,6 +315,11 @@ static int idxd_config_bus_remove(struct device *dev)
+ idxd_unregister_dma_device(idxd);
+ spin_lock_irqsave(&idxd->dev_lock, flags);
+ rc = idxd_device_disable(idxd);
++ for (i = 0; i < idxd->max_wqs; i++) {
++ struct idxd_wq *wq = &idxd->wqs[i];
++
++ idxd_wq_disable_cleanup(wq);
++ }
+ spin_unlock_irqrestore(&idxd->dev_lock, flags);
+ module_put(THIS_MODULE);
+ if (rc < 0)
+--
+2.25.1
+
--- /dev/null
+From f66fbf276f99f0b76896329f65a9107cc1a288f2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Jun 2020 13:38:34 -0700
+Subject: dmaengine: idxd: fix cdev locking for open and release
+
+From: Nikhil Rao <nikhil.rao@intel.com>
+
+[ Upstream commit 66983bc18fad17d10766650b3685045f6f092d73 ]
+
+add the wq lock in cdev open and release call. This fixes
+race conditions observed in the open and close routines.
+
+Fixes: 42d279f9137a ("dmaengine: idxd: add char driver to expose submission portal to userland")
+Signed-off-by: Nikhil Rao <nikhil.rao@intel.com>
+Signed-off-by: Dave Jiang <dave.jiang@intel.com>
+Link: https://lore.kernel.org/r/159285824892.64944.2905413694915141834.stgit@djiang5-desk3.ch.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/idxd/cdev.c | 19 ++++++++++++++++---
+ 1 file changed, 16 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
+index ff49847e37a86..cb376cf6a2d2c 100644
+--- a/drivers/dma/idxd/cdev.c
++++ b/drivers/dma/idxd/cdev.c
+@@ -74,6 +74,7 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
+ struct idxd_device *idxd;
+ struct idxd_wq *wq;
+ struct device *dev;
++ int rc = 0;
+
+ wq = inode_wq(inode);
+ idxd = wq->idxd;
+@@ -81,17 +82,27 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
+
+ dev_dbg(dev, "%s called: %d\n", __func__, idxd_wq_refcount(wq));
+
+- if (idxd_wq_refcount(wq) > 0 && wq_dedicated(wq))
+- return -EBUSY;
+-
+ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
++ mutex_lock(&wq->wq_lock);
++
++ if (idxd_wq_refcount(wq) > 0 && wq_dedicated(wq)) {
++ rc = -EBUSY;
++ goto failed;
++ }
++
+ ctx->wq = wq;
+ filp->private_data = ctx;
+ idxd_wq_get(wq);
++ mutex_unlock(&wq->wq_lock);
+ return 0;
++
++ failed:
++ mutex_unlock(&wq->wq_lock);
++ kfree(ctx);
++ return rc;
+ }
+
+ static int idxd_cdev_release(struct inode *node, struct file *filep)
+@@ -105,7 +116,9 @@ static int idxd_cdev_release(struct inode *node, struct file *filep)
+ filep->private_data = NULL;
+
+ kfree(ctx);
++ mutex_lock(&wq->wq_lock);
+ idxd_wq_put(wq);
++ mutex_unlock(&wq->wq_lock);
+ return 0;
+ }
+
+--
+2.25.1
+
--- /dev/null
+From 7924bd5ff2786544e1fc76f466dde1d71f366988 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 Jun 2020 12:16:54 -0700
+Subject: dmaengine: idxd: fix misc interrupt handler thread unmasking
+
+From: Dave Jiang <dave.jiang@intel.com>
+
+[ Upstream commit e3122822a74033ba8d6d9af855078f9ab741e33f ]
+
+Fix unmasking of misc interrupt handler when completing normal. It exits
+early and skips the unmasking with the current implementation. Fix to
+unmask interrupt when exiting normally.
+
+Fixes: bfe1d56091c1 ("dmaengine: idxd: Init and probe for Intel data accelerators")
+Signed-off-by: Dave Jiang <dave.jiang@intel.com>
+Link: https://lore.kernel.org/r/159311256528.855.11527922406329728512.stgit@djiang5-desk3.ch.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/idxd/irq.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c
+index 6510791b9921b..8a35f58da6890 100644
+--- a/drivers/dma/idxd/irq.c
++++ b/drivers/dma/idxd/irq.c
+@@ -141,7 +141,7 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
+
+ iowrite32(cause, idxd->reg_base + IDXD_INTCAUSE_OFFSET);
+ if (!err)
+- return IRQ_HANDLED;
++ goto out;
+
+ gensts.bits = ioread32(idxd->reg_base + IDXD_GENSTATS_OFFSET);
+ if (gensts.state == IDXD_DEVICE_STATE_HALT) {
+@@ -162,6 +162,7 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
+ spin_unlock_bh(&idxd->dev_lock);
+ }
+
++ out:
+ idxd_unmask_msix_vector(idxd, irq_entry->id);
+ return IRQ_HANDLED;
+ }
+--
+2.25.1
+
--- /dev/null
+From 3fbddac3c15330aba80e4318ba1172f900e41a6f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Jun 2020 21:07:33 +0900
+Subject: dmaengine: sh: usb-dmac: set tx_result parameters
+
+From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+
+[ Upstream commit 466257d9968ac79575831250b039dc07566c7b13 ]
+
+A client driver (renesas_usbhs) assumed that
+dmaengine_tx_status() could return the residue even if
+the transfer was completed. However, this was not correct
+usage [1] and this caused to break getting the residue after
+the commit 24461d9792c2 ("dmaengine: virt-dma: Fix access after
+free in vchan_complete()") actually. So, this is possible to get
+wrong received size if the usb controller gets a short packet.
+For example, g_zero driver causes "bad OUT byte" errors.
+
+To use the tx_result from the renesas_usbhs driver when
+the transfer is completed, set the tx_result parameters.
+
+Notes that the renesas_usbhs driver needs to update for it.
+
+[1]
+https://lore.kernel.org/dmaengine/20200616165550.GP2324254@vkoul-mobl/
+
+Reported-by: Hien Dang <hien.dang.eb@renesas.com>
+Fixes: 24461d9792c2 ("dmaengine: virt-dma: Fix access after free in vchan_complete()")
+Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+Link: https://lore.kernel.org/r/1592482053-19433-1-git-send-email-yoshihiro.shimoda.uh@renesas.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/sh/usb-dmac.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
+index b218a013c2600..8f7ceb698226c 100644
+--- a/drivers/dma/sh/usb-dmac.c
++++ b/drivers/dma/sh/usb-dmac.c
+@@ -586,6 +586,8 @@ static void usb_dmac_isr_transfer_end(struct usb_dmac_chan *chan)
+ desc->residue = usb_dmac_get_current_residue(chan, desc,
+ desc->sg_index - 1);
+ desc->done_cookie = desc->vd.tx.cookie;
++ desc->vd.tx_result.result = DMA_TRANS_NOERROR;
++ desc->vd.tx_result.residue = desc->residue;
+ vchan_cookie_complete(&desc->vd);
+
+ /* Restart the next transfer if this driver has a next desc */
+--
+2.25.1
+
--- /dev/null
+From 42f4f3a1d48638127bf68d2ac9ad441daddc7154 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Jun 2020 14:40:04 +0300
+Subject: dmaengine: ti: k3-udma: Fix delayed_work usage for tx drain
+ workaround
+
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+
+[ Upstream commit d964d5ff68dba21b53368656adec3fb5f50426bb ]
+
+INIT_DELAYED_WORK_ONSTACK() must be used with on-stack delayed work, which
+is not the case here.
+Use normal delayed_work for the channels instead.
+
+Fixes: 25dcb5dd7b7c ("dmaengine: ti: New driver for K3 UDMA")
+Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Link: https://lore.kernel.org/r/20200618114004.6268-1-peter.ujfalusi@ti.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/ti/k3-udma.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
+index baf7ab64f1d7d..9760d67aa612a 100644
+--- a/drivers/dma/ti/k3-udma.c
++++ b/drivers/dma/ti/k3-udma.c
+@@ -1925,8 +1925,6 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
+
+ udma_reset_rings(uc);
+
+- INIT_DELAYED_WORK_ONSTACK(&uc->tx_drain.work,
+- udma_check_tx_completion);
+ return 0;
+
+ err_irq_free:
+@@ -3038,7 +3036,6 @@ static void udma_free_chan_resources(struct dma_chan *chan)
+ }
+
+ cancel_delayed_work_sync(&uc->tx_drain.work);
+- destroy_delayed_work_on_stack(&uc->tx_drain.work);
+
+ if (uc->irq_num_ring > 0) {
+ free_irq(uc->irq_num_ring, uc);
+@@ -3727,6 +3724,7 @@ static int udma_probe(struct platform_device *pdev)
+ tasklet_init(&uc->vc.task, udma_vchan_complete,
+ (unsigned long)&uc->vc);
+ init_completion(&uc->teardown_completed);
++ INIT_DELAYED_WORK(&uc->tx_drain.work, udma_check_tx_completion);
+ }
+
+ ret = dma_async_device_register(&ud->ddev);
+--
+2.25.1
+
--- /dev/null
+From cc68edecd905b25d853bfdcdecc362ccc8c83310 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 27 May 2020 09:53:57 +0300
+Subject: dmaengine: ti: k3-udma: Use correct node to read "ti,udma-atype"
+
+From: Peter Ujfalusi <peter.ujfalusi@ti.com>
+
+[ Upstream commit 9f2f3ce3daed229eecf647acac44defbdee1f7c0 ]
+
+The "ti,udma-atype" property is expected in the UDMA node and not in the
+parent navss node.
+
+Fixes: 0ebcf1a274c5 ("dmaengine: ti: k3-udma: Implement support for atype (for virtualization)")
+Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
+Link: https://lore.kernel.org/r/20200527065357.30791-1-peter.ujfalusi@ti.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/ti/k3-udma.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
+index a90e154b0ae0d..baf7ab64f1d7d 100644
+--- a/drivers/dma/ti/k3-udma.c
++++ b/drivers/dma/ti/k3-udma.c
+@@ -3609,7 +3609,7 @@ static int udma_probe(struct platform_device *pdev)
+ return ret;
+ }
+
+- ret = of_property_read_u32(navss_node, "ti,udma-atype", &ud->atype);
++ ret = of_property_read_u32(dev->of_node, "ti,udma-atype", &ud->atype);
+ if (!ret && ud->atype > 2) {
+ dev_err(dev, "Invalid atype: %u\n", ud->atype);
+ return -EINVAL;
+--
+2.25.1
+
--- /dev/null
+From bee817e5273349760625361ff8a51f6086fac123 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 Jun 2020 12:39:51 +0300
+Subject: fuse: don't ignore errors from fuse_writepages_fill()
+
+From: Vasily Averin <vvs@virtuozzo.com>
+
+[ Upstream commit 7779b047a57f6824a43d0e1f70de2741b7426b9d ]
+
+fuse_writepages() ignores some errors taken from fuse_writepages_fill() I
+believe it is a bug: if .writepages is called with WB_SYNC_ALL it should
+either guarantee that all data was successfully saved or return error.
+
+Fixes: 26d614df1da9 ("fuse: Implement writepages callback")
+Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
+Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/fuse/file.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/fs/fuse/file.c b/fs/fuse/file.c
+index e3afceecaa6b1..93763e844cd42 100644
+--- a/fs/fuse/file.c
++++ b/fs/fuse/file.c
+@@ -2148,10 +2148,8 @@ static int fuse_writepages(struct address_space *mapping,
+
+ err = write_cache_pages(mapping, wbc, fuse_writepages_fill, &data);
+ if (data.wpa) {
+- /* Ignore errors if we can write at least one page */
+ WARN_ON(!data.wpa->ia.ap.num_pages);
+ fuse_writepages_send(&data);
+- err = 0;
+ }
+ if (data.ff)
+ fuse_file_put(data.ff, false, false);
+--
+2.25.1
+
--- /dev/null
+From ebd6df6156395bc41d502dee9283e1d03cf09868 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 17 May 2020 11:59:53 +0200
+Subject: iio: adc: ad7780: Fix a resource handling path in 'ad7780_probe()'
+
+From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+
+[ Upstream commit b0536f9826a5ed3328d527b4fc1686867a9f3041 ]
+
+If 'ad7780_init_gpios()' fails, we must not release some resources that
+have not been allocated yet. Return directly instead.
+
+Fixes: 5bb30e7daf00 ("staging: iio: ad7780: move regulator to after GPIO init")
+Fixes: 9085daa4abcc ("staging: iio: ad7780: add gain & filter gpio support")
+Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+Acked-by: Renato Lui Geh <renatogeh@gmail.com>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/adc/ad7780.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
+index 291c1a898129d..643771ed3f835 100644
+--- a/drivers/iio/adc/ad7780.c
++++ b/drivers/iio/adc/ad7780.c
+@@ -310,7 +310,7 @@ static int ad7780_probe(struct spi_device *spi)
+
+ ret = ad7780_init_gpios(&spi->dev, st);
+ if (ret)
+- goto error_cleanup_buffer_and_trigger;
++ return ret;
+
+ st->reg = devm_regulator_get(&spi->dev, "avdd");
+ if (IS_ERR(st->reg))
+--
+2.25.1
+
--- /dev/null
+From 60f3df80b8761f4cd670cf1c086823dbef5d8407 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 17 May 2020 18:29:57 +0100
+Subject: iio:health:afe4404 Fix timestamp alignment and prevent data leak.
+
+From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+
+[ Upstream commit f88ecccac4be348bbcc6d056bdbc622a8955c04d ]
+
+One of a class of bugs pointed out by Lars in a recent review.
+iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
+to the size of the timestamp (8 bytes). This is not guaranteed in
+this driver which uses a 40 byte array of smaller elements on the stack.
+As Lars also noted this anti pattern can involve a leak of data to
+userspace and that indeed can happen here. We close both issues by
+moving to a suitable structure in the iio_priv() data with alignment
+explicitly requested. This data is allocated with kzalloc so no
+data can leak appart from previous readings.
+
+Fixes: 87aec56e27ef ("iio: health: Add driver for the TI AFE4404 heart monitor")
+Reported-by: Lars-Peter Clausen <lars@metafoo.de>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Acked-by: Andrew F. Davis <afd@ti.com>
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/health/afe4404.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c
+index e728bbb21ca88..cebb1fd4d0b15 100644
+--- a/drivers/iio/health/afe4404.c
++++ b/drivers/iio/health/afe4404.c
+@@ -83,6 +83,7 @@ static const struct reg_field afe4404_reg_fields[] = {
+ * @regulator: Pointer to the regulator for the IC
+ * @trig: IIO trigger for this device
+ * @irq: ADC_RDY line interrupt number
++ * @buffer: Used to construct a scan to push to the iio buffer.
+ */
+ struct afe4404_data {
+ struct device *dev;
+@@ -91,6 +92,7 @@ struct afe4404_data {
+ struct regulator *regulator;
+ struct iio_trigger *trig;
+ int irq;
++ s32 buffer[10] __aligned(8);
+ };
+
+ enum afe4404_chan_id {
+@@ -328,17 +330,17 @@ static irqreturn_t afe4404_trigger_handler(int irq, void *private)
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct afe4404_data *afe = iio_priv(indio_dev);
+ int ret, bit, i = 0;
+- s32 buffer[10];
+
+ for_each_set_bit(bit, indio_dev->active_scan_mask,
+ indio_dev->masklength) {
+ ret = regmap_read(afe->regmap, afe4404_channel_values[bit],
+- &buffer[i++]);
++ &afe->buffer[i++]);
+ if (ret)
+ goto err;
+ }
+
+- iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
++ iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer,
++ pf->timestamp);
+ err:
+ iio_trigger_notify_done(indio_dev->trig);
+
+--
+2.25.1
+
--- /dev/null
+From 5cadb06e8a7e056fa0e79292f1deb7304c57701e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Jul 2020 23:28:38 +0100
+Subject: keys: asymmetric: fix error return code in software_key_query()
+
+From: Wei Yongjun <weiyongjun1@huawei.com>
+
+[ Upstream commit 6cbba1f9114a8134cff9138c79add15012fd52b9 ]
+
+Fix to return negative error code -ENOMEM from kmalloc() error handling
+case instead of 0, as done elsewhere in this function.
+
+Fixes: f1774cb8956a ("X.509: parse public key parameters from x509 for akcipher")
+Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
+Signed-off-by: David Howells <dhowells@redhat.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ crypto/asymmetric_keys/public_key.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
+index d7f43d4ea925a..e5fae4e838c06 100644
+--- a/crypto/asymmetric_keys/public_key.c
++++ b/crypto/asymmetric_keys/public_key.c
+@@ -119,6 +119,7 @@ static int software_key_query(const struct kernel_pkey_params *params,
+ if (IS_ERR(tfm))
+ return PTR_ERR(tfm);
+
++ ret = -ENOMEM;
+ key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen,
+ GFP_KERNEL);
+ if (!key)
+--
+2.25.1
+
--- /dev/null
+From bd657b703982d0b59cd0ac49a2cb9e1eea61ccc6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Jul 2020 10:33:40 -0400
+Subject: NFS: Fix interrupted slots by sending a solo SEQUENCE operation
+
+From: Anna Schumaker <Anna.Schumaker@Netapp.com>
+
+[ Upstream commit 913fadc5b105c3619d9e8d0fe8899ff1593cc737 ]
+
+We used to do this before 3453d5708b33, but this was changed to better
+handle the NFS4ERR_SEQ_MISORDERED error code. This commit fixed the slot
+re-use case when the server doesn't receive the interrupted operation,
+but if the server does receive the operation then it could still end up
+replying to the client with mis-matched operations from the reply cache.
+
+We can fix this by sending a SEQUENCE to the server while recovering from
+a SEQ_MISORDERED error when we detect that we are in an interrupted slot
+situation.
+
+Fixes: 3453d5708b33 (NFSv4.1: Avoid false retries when RPC calls are interrupted)
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/nfs/nfs4proc.c | 20 ++++++++++++++++++--
+ 1 file changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
+index e32717fd1169a..2e2dac29a9e91 100644
+--- a/fs/nfs/nfs4proc.c
++++ b/fs/nfs/nfs4proc.c
+@@ -774,6 +774,14 @@ static void nfs4_slot_sequence_acked(struct nfs4_slot *slot,
+ slot->seq_nr_last_acked = seqnr;
+ }
+
++static void nfs4_probe_sequence(struct nfs_client *client, const struct cred *cred,
++ struct nfs4_slot *slot)
++{
++ struct rpc_task *task = _nfs41_proc_sequence(client, cred, slot, true);
++ if (!IS_ERR(task))
++ rpc_put_task_async(task);
++}
++
+ static int nfs41_sequence_process(struct rpc_task *task,
+ struct nfs4_sequence_res *res)
+ {
+@@ -790,6 +798,7 @@ static int nfs41_sequence_process(struct rpc_task *task,
+ goto out;
+
+ session = slot->table->session;
++ clp = session->clp;
+
+ trace_nfs4_sequence_done(session, res);
+
+@@ -804,7 +813,6 @@ static int nfs41_sequence_process(struct rpc_task *task,
+ nfs4_slot_sequence_acked(slot, slot->seq_nr);
+ /* Update the slot's sequence and clientid lease timer */
+ slot->seq_done = 1;
+- clp = session->clp;
+ do_renew_lease(clp, res->sr_timestamp);
+ /* Check sequence flags */
+ nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags,
+@@ -852,10 +860,18 @@ static int nfs41_sequence_process(struct rpc_task *task,
+ /*
+ * Were one or more calls using this slot interrupted?
+ * If the server never received the request, then our
+- * transmitted slot sequence number may be too high.
++ * transmitted slot sequence number may be too high. However,
++ * if the server did receive the request then it might
++ * accidentally give us a reply with a mismatched operation.
++ * We can sort this out by sending a lone sequence operation
++ * to the server on the same slot.
+ */
+ if ((s32)(slot->seq_nr - slot->seq_nr_last_acked) > 1) {
+ slot->seq_nr--;
++ if (task->tk_msg.rpc_proc != &nfs4_procedures[NFSPROC4_CLNT_SEQUENCE]) {
++ nfs4_probe_sequence(clp, task->tk_msg.rpc_cred, slot);
++ res->sr_slot = NULL;
++ }
+ goto retry_nowait;
+ }
+ /*
+--
+2.25.1
+
--- /dev/null
+From a7a58e5639ee27f7e13ee8e7929dc6def2936b53 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 14 Jul 2020 13:11:59 +0200
+Subject: nvme: explicitly update mpath disk capacity on revalidation
+
+From: Anthony Iliopoulos <ailiop@suse.com>
+
+[ Upstream commit 05b29021fba5e725dd385151ef00b6340229b500 ]
+
+Commit 3b4b19721ec652 ("nvme: fix possible deadlock when I/O is
+blocked") reverted multipath head disk revalidation due to deadlocks
+caused by holding the bd_mutex during revalidate.
+
+Updating the multipath disk blockdev size is still required though for
+userspace to be able to observe any resizing while the device is
+mounted. Directly update the bdev inode size to avoid unnecessarily
+holding the bdev->bd_mutex.
+
+Fixes: 3b4b19721ec652 ("nvme: fix possible deadlock when I/O is
+blocked")
+
+Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/core.c | 1 +
+ drivers/nvme/host/nvme.h | 13 +++++++++++++
+ 2 files changed, 14 insertions(+)
+
+diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
+index 71d63ed62071e..137d7bcc13585 100644
+--- a/drivers/nvme/host/core.c
++++ b/drivers/nvme/host/core.c
+@@ -1916,6 +1916,7 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
+ if (ns->head->disk) {
+ nvme_update_disk_info(ns->head->disk, ns, id);
+ blk_queue_stack_limits(ns->head->disk->queue, ns->queue);
++ nvme_mpath_update_disk_size(ns->head->disk);
+ }
+ #endif
+ }
+diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
+index 719342600be62..46f965f8c9bcd 100644
+--- a/drivers/nvme/host/nvme.h
++++ b/drivers/nvme/host/nvme.h
+@@ -583,6 +583,16 @@ static inline void nvme_trace_bio_complete(struct request *req,
+ req->bio, status);
+ }
+
++static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
++{
++ struct block_device *bdev = bdget_disk(disk, 0);
++
++ if (bdev) {
++ bd_set_size(bdev, get_capacity(disk) << SECTOR_SHIFT);
++ bdput(bdev);
++ }
++}
++
+ extern struct device_attribute dev_attr_ana_grpid;
+ extern struct device_attribute dev_attr_ana_state;
+ extern struct device_attribute subsys_attr_iopolicy;
+@@ -658,6 +668,9 @@ static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
+ static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
+ {
+ }
++static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
++{
++}
+ #endif /* CONFIG_NVME_MULTIPATH */
+
+ #ifdef CONFIG_NVM
+--
+2.25.1
+
--- /dev/null
+From 170e4bc48d190c489e51b272a20d728b392dced2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 25 May 2020 21:08:57 +0800
+Subject: phy: rockchip: Fix return value of inno_dsidphy_probe()
+
+From: Tiezhu Yang <yangtiezhu@loongson.cn>
+
+[ Upstream commit fdc355a03df537bc8d8909b86d1688fe07c7032b ]
+
+When call function devm_platform_ioremap_resource(), we should use IS_ERR()
+to check the return value and return PTR_ERR() if failed.
+
+Fixes: b7535a3bc0ba ("phy/rockchip: Add support for Innosilicon MIPI/LVDS/TTL PHY")
+Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
+Reviewed-by: Heiko Stuebner <heiko@sntech.de>
+Link: https://lore.kernel.org/r/1590412138-13903-1-git-send-email-yangtiezhu@loongson.cn
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c b/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c
+index a7c6c940a3a8c..8af8c6c5cc028 100644
+--- a/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c
++++ b/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c
+@@ -607,8 +607,8 @@ static int inno_dsidphy_probe(struct platform_device *pdev)
+ platform_set_drvdata(pdev, inno);
+
+ inno->phy_base = devm_platform_ioremap_resource(pdev, 0);
+- if (!inno->phy_base)
+- return -ENOMEM;
++ if (IS_ERR(inno->phy_base))
++ return PTR_ERR(inno->phy_base);
+
+ inno->ref_clk = devm_clk_get(dev, "ref");
+ if (IS_ERR(inno->ref_clk)) {
+--
+2.25.1
+
--- /dev/null
+From 79a07eb2aba2d541cad9ac2943a2a057203876b6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 Jun 2020 13:44:28 +0100
+Subject: phy: sun4i-usb: fix dereference of pointer phy0 before it is null
+ checked
+
+From: Colin Ian King <colin.king@canonical.com>
+
+[ Upstream commit 38b1927e5bf9bcad4a2e33189ef1c5569f9599ba ]
+
+Currently pointer phy0 is being dereferenced via the assignment of
+phy on the call to phy_get_drvdata before phy0 is null checked, this
+can lead to a null pointer dereference. Fix this by performing the
+null check on phy0 before the call to phy_get_drvdata. Also replace
+the phy0 == NULL check with the more usual !phy0 idiom.
+
+Addresses-Coverity: ("Dereference before null check")
+Fixes: e6f32efb1b12 ("phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode")
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Link: https://lore.kernel.org/r/20200625124428.83564-1-colin.king@canonical.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/phy/allwinner/phy-sun4i-usb.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
+index 8569273822487..e5842e48a5e07 100644
+--- a/drivers/phy/allwinner/phy-sun4i-usb.c
++++ b/drivers/phy/allwinner/phy-sun4i-usb.c
+@@ -545,13 +545,14 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
+ struct sun4i_usb_phy_data *data =
+ container_of(work, struct sun4i_usb_phy_data, detect.work);
+ struct phy *phy0 = data->phys[0].phy;
+- struct sun4i_usb_phy *phy = phy_get_drvdata(phy0);
++ struct sun4i_usb_phy *phy;
+ bool force_session_end, id_notify = false, vbus_notify = false;
+ int id_det, vbus_det;
+
+- if (phy0 == NULL)
++ if (!phy0)
+ return;
+
++ phy = phy_get_drvdata(phy0);
+ id_det = sun4i_usb_phy0_get_id_det(data);
+ vbus_det = sun4i_usb_phy0_get_vbus_det(data);
+
+--
+2.25.1
+
--- /dev/null
+From b63fc970dc377f20eb8b678549f43056c590039a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Jul 2020 16:46:15 -0700
+Subject: regmap: debugfs: Don't sleep while atomic for fast_io regmaps
+
+From: Douglas Anderson <dianders@chromium.org>
+
+[ Upstream commit 299632e54b2e692d2830af84be51172480dc1e26 ]
+
+If a regmap has "fast_io" set then its lock function uses a spinlock.
+That doesn't work so well with the functions:
+* regmap_cache_only_write_file()
+* regmap_cache_bypass_write_file()
+
+Both of the above functions have the pattern:
+1. Lock the regmap.
+2. Call:
+ debugfs_write_file_bool()
+ copy_from_user()
+ __might_fault()
+ __might_sleep()
+
+Let's reorder things a bit so that we do all of our sleepable
+functions before we grab the lock.
+
+Fixes: d3dc5430d68f ("regmap: debugfs: Allow writes to cache state settings")
+Signed-off-by: Douglas Anderson <dianders@chromium.org>
+Link: https://lore.kernel.org/r/20200715164611.1.I35b3533e8a80efde0cec1cc70f71e1e74b2fa0da@changeid
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/regmap/regmap-debugfs.c | 52 ++++++++++++++++------------
+ 1 file changed, 29 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
+index e72843fe41dfe..e16afa27700db 100644
+--- a/drivers/base/regmap/regmap-debugfs.c
++++ b/drivers/base/regmap/regmap-debugfs.c
+@@ -457,29 +457,31 @@ static ssize_t regmap_cache_only_write_file(struct file *file,
+ {
+ struct regmap *map = container_of(file->private_data,
+ struct regmap, cache_only);
+- ssize_t result;
+- bool was_enabled, require_sync = false;
++ bool new_val, require_sync = false;
+ int err;
+
+- map->lock(map->lock_arg);
++ err = kstrtobool_from_user(user_buf, count, &new_val);
++ /* Ignore malforned data like debugfs_write_file_bool() */
++ if (err)
++ return count;
+
+- was_enabled = map->cache_only;
++ err = debugfs_file_get(file->f_path.dentry);
++ if (err)
++ return err;
+
+- result = debugfs_write_file_bool(file, user_buf, count, ppos);
+- if (result < 0) {
+- map->unlock(map->lock_arg);
+- return result;
+- }
++ map->lock(map->lock_arg);
+
+- if (map->cache_only && !was_enabled) {
++ if (new_val && !map->cache_only) {
+ dev_warn(map->dev, "debugfs cache_only=Y forced\n");
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+- } else if (!map->cache_only && was_enabled) {
++ } else if (!new_val && map->cache_only) {
+ dev_warn(map->dev, "debugfs cache_only=N forced: syncing cache\n");
+ require_sync = true;
+ }
++ map->cache_only = new_val;
+
+ map->unlock(map->lock_arg);
++ debugfs_file_put(file->f_path.dentry);
+
+ if (require_sync) {
+ err = regcache_sync(map);
+@@ -487,7 +489,7 @@ static ssize_t regmap_cache_only_write_file(struct file *file,
+ dev_err(map->dev, "Failed to sync cache %d\n", err);
+ }
+
+- return result;
++ return count;
+ }
+
+ static const struct file_operations regmap_cache_only_fops = {
+@@ -502,28 +504,32 @@ static ssize_t regmap_cache_bypass_write_file(struct file *file,
+ {
+ struct regmap *map = container_of(file->private_data,
+ struct regmap, cache_bypass);
+- ssize_t result;
+- bool was_enabled;
++ bool new_val;
++ int err;
+
+- map->lock(map->lock_arg);
++ err = kstrtobool_from_user(user_buf, count, &new_val);
++ /* Ignore malforned data like debugfs_write_file_bool() */
++ if (err)
++ return count;
+
+- was_enabled = map->cache_bypass;
++ err = debugfs_file_get(file->f_path.dentry);
++ if (err)
++ return err;
+
+- result = debugfs_write_file_bool(file, user_buf, count, ppos);
+- if (result < 0)
+- goto out;
++ map->lock(map->lock_arg);
+
+- if (map->cache_bypass && !was_enabled) {
++ if (new_val && !map->cache_bypass) {
+ dev_warn(map->dev, "debugfs cache_bypass=Y forced\n");
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+- } else if (!map->cache_bypass && was_enabled) {
++ } else if (!new_val && map->cache_bypass) {
+ dev_warn(map->dev, "debugfs cache_bypass=N forced\n");
+ }
++ map->cache_bypass = new_val;
+
+-out:
+ map->unlock(map->lock_arg);
++ debugfs_file_put(file->f_path.dentry);
+
+- return result;
++ return count;
+ }
+
+ static const struct file_operations regmap_cache_bypass_fops = {
+--
+2.25.1
+
--- /dev/null
+From 19cbe565e828d23944702d0ef45b4ba5ab5167c3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Jul 2020 12:34:12 +0200
+Subject: Revert "thermal: mediatek: fix register index error"
+
+From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
+
+[ Upstream commit a8f62f183021be389561570ab5f8c701a5e70298 ]
+
+This reverts commit eb9aecd90d1a39601e91cd08b90d5fee51d321a6
+
+The above patch is supposed to fix a register index error on mt2701. It
+is not clear if the problem solved is a hang or just an invalid value
+returned, my guess is the second. The patch introduces, though, a new
+hang on MT8173 device making them unusable. So, seems reasonable, revert
+the patch because introduces a worst issue.
+
+The reason I send a revert instead of trying to fix the issue for MT8173
+is because the information needed to fix the issue is in the datasheet
+and is not public. So I am not really able to fix it.
+
+Fixes the following bug when CONFIG_MTK_THERMAL is set on MT8173
+devices.
+
+[ 2.222488] Unable to handle kernel paging request at virtual address ffff8000125f5001
+[ 2.230421] Mem abort info:
+[ 2.233207] ESR = 0x96000021
+[ 2.236261] EC = 0x25: DABT (current EL), IL = 32 bits
+[ 2.241571] SET = 0, FnV = 0
+[ 2.244623] EA = 0, S1PTW = 0
+[ 2.247762] Data abort info:
+[ 2.250640] ISV = 0, ISS = 0x00000021
+[ 2.254473] CM = 0, WnR = 0
+[ 2.257544] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000041850000
+[ 2.264251] [ffff8000125f5001] pgd=000000013ffff003, pud=000000013fffe003, pmd=000000013fff9003, pte=006800001100b707
+[ 2.274867] Internal error: Oops: 96000021 [#1] PREEMPT SMP
+[ 2.280432] Modules linked in:
+[ 2.283483] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.7.0-rc6+ #162
+[ 2.289914] Hardware name: Google Elm (DT)
+[ 2.294003] pstate: 20000005 (nzCv daif -PAN -UAO)
+[ 2.298792] pc : mtk_read_temp+0xb8/0x1c8
+[ 2.302793] lr : mtk_read_temp+0x7c/0x1c8
+[ 2.306794] sp : ffff80001003b930
+[ 2.310100] x29: ffff80001003b930 x28: 0000000000000000
+[ 2.315404] x27: 0000000000000002 x26: ffff0000f9550b10
+[ 2.320709] x25: ffff0000f9550a80 x24: 0000000000000090
+[ 2.326014] x23: ffff80001003ba24 x22: 00000000610344c0
+[ 2.331318] x21: 0000000000002710 x20: 00000000000001f4
+[ 2.336622] x19: 0000000000030d40 x18: ffff800011742ec0
+[ 2.341926] x17: 0000000000000001 x16: 0000000000000001
+[ 2.347230] x15: ffffffffffffffff x14: ffffff0000000000
+[ 2.352535] x13: ffffffffffffffff x12: 0000000000000028
+[ 2.357839] x11: 0000000000000003 x10: ffff800011295ec8
+[ 2.363143] x9 : 000000000000291b x8 : 0000000000000002
+[ 2.368447] x7 : 00000000000000a8 x6 : 0000000000000004
+[ 2.373751] x5 : 0000000000000000 x4 : ffff800011295cb0
+[ 2.379055] x3 : 0000000000000002 x2 : ffff8000125f5001
+[ 2.384359] x1 : 0000000000000001 x0 : ffff0000f9550a80
+[ 2.389665] Call trace:
+[ 2.392105] mtk_read_temp+0xb8/0x1c8
+[ 2.395760] of_thermal_get_temp+0x2c/0x40
+[ 2.399849] thermal_zone_get_temp+0x78/0x160
+[ 2.404198] thermal_zone_device_update.part.0+0x3c/0x1f8
+[ 2.409589] thermal_zone_device_update+0x34/0x48
+[ 2.414286] of_thermal_set_mode+0x58/0x88
+[ 2.418375] thermal_zone_of_sensor_register+0x1a8/0x1d8
+[ 2.423679] devm_thermal_zone_of_sensor_register+0x64/0xb0
+[ 2.429242] mtk_thermal_probe+0x690/0x7d0
+[ 2.433333] platform_drv_probe+0x5c/0xb0
+[ 2.437335] really_probe+0xe4/0x448
+[ 2.440901] driver_probe_device+0xe8/0x140
+[ 2.445077] device_driver_attach+0x7c/0x88
+[ 2.449252] __driver_attach+0xac/0x178
+[ 2.453082] bus_for_each_dev+0x78/0xc8
+[ 2.456909] driver_attach+0x2c/0x38
+[ 2.460476] bus_add_driver+0x14c/0x230
+[ 2.464304] driver_register+0x6c/0x128
+[ 2.468131] __platform_driver_register+0x50/0x60
+[ 2.472831] mtk_thermal_driver_init+0x24/0x30
+[ 2.477268] do_one_initcall+0x50/0x298
+[ 2.481098] kernel_init_freeable+0x1ec/0x264
+[ 2.485450] kernel_init+0x1c/0x110
+[ 2.488931] ret_from_fork+0x10/0x1c
+[ 2.492502] Code: f9401081 f9400402 b8a67821 8b010042 (b9400042)
+[ 2.498599] ---[ end trace e43e3105ed27dc99 ]---
+[ 2.503367] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
+[ 2.511020] SMP: stopping secondary CPUs
+[ 2.514941] Kernel Offset: disabled
+[ 2.518421] CPU features: 0x090002,25006005
+[ 2.522595] Memory Limit: none
+[ 2.525644] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]--
+
+Cc: Michael Kao <michael.kao@mediatek.com>
+Fixes: eb9aecd90d1a ("thermal: mediatek: fix register index error")
+Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
+Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
+Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
+Link: https://lore.kernel.org/r/20200707103412.1010823-1-enric.balletbo@collabora.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/thermal/mtk_thermal.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
+index 6b7ef1993d7e2..42c9cd0e5f775 100644
+--- a/drivers/thermal/mtk_thermal.c
++++ b/drivers/thermal/mtk_thermal.c
+@@ -594,8 +594,7 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
+ u32 raw;
+
+ for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) {
+- raw = readl(mt->thermal_base +
+- conf->msr[conf->bank_data[bank->id].sensors[i]]);
++ raw = readl(mt->thermal_base + conf->msr[i]);
+
+ temp = raw_to_mcelsius(mt,
+ conf->bank_data[bank->id].sensors[i],
+@@ -736,8 +735,7 @@ static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num,
+
+ for (i = 0; i < conf->bank_data[num].num_sensors; i++)
+ writel(conf->sensor_mux_values[conf->bank_data[num].sensors[i]],
+- mt->thermal_base +
+- conf->adcpnp[conf->bank_data[num].sensors[i]]);
++ mt->thermal_base + conf->adcpnp[i]);
+
+ writel((1 << conf->bank_data[num].num_sensors) - 1,
+ controller_base + TEMP_MONCTL0);
+--
+2.25.1
+
--- /dev/null
+From 952d5b3574c43056ca3f49b0d1ebc6616adbb06a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Jul 2020 00:49:03 +0300
+Subject: serial: core: Initialise spin lock before use in
+ uart_configure_port()
+
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+
+[ Upstream commit f743061a85f5e9989df22ccbf07c80c98fc90e08 ]
+
+The comment near to uart_port_spin_lock_init() says:
+
+ Ensure that the serial console lock is initialised early.
+ If this port is a console, then the spinlock is already initialised.
+
+and there is nothing about enabled or disabled consoles. The commit
+a3cb39d258ef ("serial: core: Allow detach and attach serial device
+for console") made a change, which follows the comment, and also to
+prevent reinitialisation of the lock in use, when user detaches and
+attaches back the same console device. But this change discovers
+another issue, that uart_add_one_port() tries to access a spin lock
+that now may be uninitialised. This happens when a driver expects
+the serial core to register a console on its behalf. In this case
+we must initialise a spin lock before use.
+
+Fixes: a3cb39d258ef ("serial: core: Allow detach and attach serial device for console")
+Reported-by: Marc Zyngier <maz@kernel.org>
+Reported-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
+Reported-by: Guenter Roeck <linux@roeck-us.net>
+Reported-by: Anatoly Pugachev <matorola@gmail.com>
+Acked-by: Marc Zyngier <maz@kernel.org>
+Tested-by: Tony Lindgren <tony@atomide.com>
+Cc: Geert Uytterhoeven <geert@linux-m68k.org>
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
+Link: https://lore.kernel.org/r/20200706214903.56148-1-andriy.shevchenko@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/serial_core.c | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
+index 66a5e2faf57ea..ca5e6212bf1ce 100644
+--- a/drivers/tty/serial/serial_core.c
++++ b/drivers/tty/serial/serial_core.c
+@@ -1916,6 +1916,12 @@ static inline bool uart_console_enabled(struct uart_port *port)
+ return uart_console(port) && (port->cons->flags & CON_ENABLED);
+ }
+
++static void __uart_port_spin_lock_init(struct uart_port *port)
++{
++ spin_lock_init(&port->lock);
++ lockdep_set_class(&port->lock, &port_lock_key);
++}
++
+ /*
+ * Ensure that the serial console lock is initialised early.
+ * If this port is a console, then the spinlock is already initialised.
+@@ -1925,8 +1931,7 @@ static inline void uart_port_spin_lock_init(struct uart_port *port)
+ if (uart_console(port))
+ return;
+
+- spin_lock_init(&port->lock);
+- lockdep_set_class(&port->lock, &port_lock_key);
++ __uart_port_spin_lock_init(port);
+ }
+
+ #if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL)
+@@ -2372,6 +2377,13 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
+ /* Power up port for set_mctrl() */
+ uart_change_pm(state, UART_PM_STATE_ON);
+
++ /*
++ * If this driver supports console, and it hasn't been
++ * successfully registered yet, initialise spin lock for it.
++ */
++ if (port->cons && !(port->cons->flags & CON_ENABLED))
++ __uart_port_spin_lock_init(port);
++
+ /*
+ * Ensure that the modem control lines are de-activated.
+ * keep the DTR setting that is set in uart_set_options()
+--
+2.25.1
+
spi-spi-fsl-dspi-fix-lockup-if-device-is-shutdown-du.patch
io_uring-fix-recvmsg-memory-leak-with-buffer-selection.patch
input-mms114-add-extra-compatible-for-mms345l.patch
+iio-health-afe4404-fix-timestamp-alignment-and-preve.patch
+counter-104-quad-8-add-lock-guards-differential-enco.patch
+counter-104-quad-8-add-lock-guards-filter-clock-pres.patch
+dmaengine-ti-k3-udma-use-correct-node-to-read-ti-udm.patch
+soundwire-intel-fix-memory-leak-with-devm_kasprintf.patch
+dmaengine-idxd-fix-cdev-locking-for-open-and-release.patch
+dmaengine-ti-k3-udma-fix-delayed_work-usage-for-tx-d.patch
+dmaengine-sh-usb-dmac-set-tx_result-parameters.patch
+phy-rockchip-fix-return-value-of-inno_dsidphy_probe.patch
+phy-sun4i-usb-fix-dereference-of-pointer-phy0-before.patch
+arm64-dts-meson-add-missing-gxl-rng-clock.patch
+arm64-dts-meson-gxl-s805x-reduce-initial-mali450-cor.patch
+dmaengine-idxd-cleanup-workqueue-config-after-disabl.patch
+dmaengine-idxd-fix-misc-interrupt-handler-thread-unm.patch
+bus-ti-sysc-fix-wakeirq-sleeping-function-called-fro.patch
+bus-ti-sysc-fix-sleeping-function-called-from-invali.patch
+bus-ti-sysc-do-not-disable-on-suspend-for-no-idle.patch
+iio-adc-ad7780-fix-a-resource-handling-path-in-ad778.patch
+dmaengine-dw-initialize-channel-before-each-transfer.patch
+dmaengine-dmatest-stop-completed-threads-when-runnin.patch
+spi-spi-sun6i-sun6i_spi_transfer_one-fix-setting-of-.patch
+usb-gadget-udc-atmel-fix-uninitialized-read-in-debug.patch
+staging-comedi-verify-array-index-is-correct-before-.patch
+serial-core-initialise-spin-lock-before-use-in-uart_.patch
+clk-mvebu-armada_ap_cpu_clk-needs-to-select-armada_a.patch
+clk-ast2600-add-mux-for-emmc-clock.patch
+xprtrdma-fix-double-free-in-rpcrdma_ep_create.patch
+xprtrdma-fix-recursion-into-rpcrdma_xprt_disconnect.patch
+xprtrdma-fix-return-code-from-rpcrdma_xprt_connect.patch
+xprtrdma-fix-handling-of-connect-errors.patch
+nfs-fix-interrupted-slots-by-sending-a-solo-sequence.patch
+fuse-don-t-ignore-errors-from-fuse_writepages_fill.patch
+arm-dts-fix-dcan-driver-probe-failed-on-am437x-platf.patch
+revert-thermal-mediatek-fix-register-index-error.patch
+xprtrdma-fix-incorrect-header-size-calculations.patch
+arm-dts-socfpga-align-l2-cache-controller-nodename-w.patch
+arm64-dts-spcfpga-align-gic-nand-and-uart-nodenames-.patch
+keys-asymmetric-fix-error-return-code-in-software_ke.patch
+nvme-explicitly-update-mpath-disk-capacity-on-revali.patch
+regmap-debugfs-don-t-sleep-while-atomic-for-fast_io-.patch
--- /dev/null
+From 11f54b0d441cf9e64a2bb4b912154c592c392569 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 Jun 2020 11:35:36 -0500
+Subject: soundwire: intel: fix memory leak with devm_kasprintf
+
+From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+
+[ Upstream commit bf6d6e68d2028a2d82f4c106f50ec75cc1e6ef89 ]
+
+The dais are allocated with devm_kcalloc() but their name isn't
+resourced managed and never freed. Fix by also using devm_ for the dai
+names as well.
+
+Fixes: c46302ec554c5 ('soundwire: intel: Add audio DAI ops')
+Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com>
+Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
+Reviewed-by: Rander Wang <rander.wang@linux.intel.com>
+Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
+Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
+Link: https://lore.kernel.org/r/20200617163536.17401-1-pierre-louis.bossart@linux.intel.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/soundwire/intel.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c
+index 3c83e76c6bf90..cab425070e641 100644
+--- a/drivers/soundwire/intel.c
++++ b/drivers/soundwire/intel.c
+@@ -930,8 +930,9 @@ static int intel_create_dai(struct sdw_cdns *cdns,
+
+ /* TODO: Read supported rates/formats from hardware */
+ for (i = off; i < (off + num); i++) {
+- dais[i].name = kasprintf(GFP_KERNEL, "SDW%d Pin%d",
+- cdns->instance, i);
++ dais[i].name = devm_kasprintf(cdns->dev, GFP_KERNEL,
++ "SDW%d Pin%d",
++ cdns->instance, i);
+ if (!dais[i].name)
+ return -ENOMEM;
+
+--
+2.25.1
+
--- /dev/null
+From 800bdddb2ece8b4fd1c38796212a39a96545bbf3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 Jul 2020 16:34:34 +0200
+Subject: spi: spi-sun6i: sun6i_spi_transfer_one(): fix setting of clock rate
+
+From: Marc Kleine-Budde <mkl@pengutronix.de>
+
+[ Upstream commit ed7815db70d17b1741883f2da8e1d80bc2efe517 ]
+
+A SPI transfer defines the _maximum_ speed of the SPI transfer. However the
+driver doesn't take into account that the clock divider is always rounded down
+(due to integer arithmetics). This results in a too high clock rate for the SPI
+transfer.
+
+E.g.: with a mclk_rate of 24 MHz and a SPI transfer speed of 10 MHz, the
+original code calculates a reg of "0", which results in a effective divider of
+"2" and a 12 MHz clock for the SPI transfer.
+
+This patch fixes the issue by using DIV_ROUND_UP() instead of a plain
+integer division.
+
+While there simplify the divider calculation for the CDR1 case, use
+order_base_2() instead of two ilog2() calculations.
+
+Fixes: 3558fe900e8a ("spi: sunxi: Add Allwinner A31 SPI controller driver")
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Acked-by: Maxime Ripard <mripard@kernel.org>
+Link: https://lore.kernel.org/r/20200706143443.9855-2-mkl@pengutronix.de
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-sun6i.c | 14 ++++++--------
+ 1 file changed, 6 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
+index ec7967be9e2f5..956df79035d56 100644
+--- a/drivers/spi/spi-sun6i.c
++++ b/drivers/spi/spi-sun6i.c
+@@ -198,7 +198,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
+ struct spi_transfer *tfr)
+ {
+ struct sun6i_spi *sspi = spi_master_get_devdata(master);
+- unsigned int mclk_rate, div, timeout;
++ unsigned int mclk_rate, div, div_cdr1, div_cdr2, timeout;
+ unsigned int start, end, tx_time;
+ unsigned int trig_level;
+ unsigned int tx_len = 0;
+@@ -287,14 +287,12 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
+ * First try CDR2, and if we can't reach the expected
+ * frequency, fall back to CDR1.
+ */
+- div = mclk_rate / (2 * tfr->speed_hz);
+- if (div <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) {
+- if (div > 0)
+- div--;
+-
+- reg = SUN6I_CLK_CTL_CDR2(div) | SUN6I_CLK_CTL_DRS;
++ div_cdr1 = DIV_ROUND_UP(mclk_rate, tfr->speed_hz);
++ div_cdr2 = DIV_ROUND_UP(div_cdr1, 2);
++ if (div_cdr2 <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) {
++ reg = SUN6I_CLK_CTL_CDR2(div_cdr2 - 1) | SUN6I_CLK_CTL_DRS;
+ } else {
+- div = ilog2(mclk_rate) - ilog2(tfr->speed_hz);
++ div = min(SUN6I_CLK_CTL_CDR1_MASK, order_base_2(div_cdr1));
+ reg = SUN6I_CLK_CTL_CDR1(div);
+ }
+
+--
+2.25.1
+
--- /dev/null
+From 066fe2e01d58001e4a334ed29fd79b837b61d515 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Jul 2020 13:29:36 +0300
+Subject: staging: comedi: verify array index is correct before using it
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+[ Upstream commit ef75e14a6c935eec82abac07ab68e388514e39bc ]
+
+This code reads from the array before verifying that "trig" is a valid
+index. If the index is wildly out of bounds then reading from an
+invalid address could lead to an Oops.
+
+Fixes: a8c66b684efa ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions")
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
+Link: https://lore.kernel.org/r/20200709102936.GA20875@mwanda
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/staging/comedi/drivers/addi_apci_1500.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c
+index 45ad4ba92f94f..689acd69a1b9c 100644
+--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
++++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
+@@ -456,9 +456,9 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
+ unsigned int lo_mask = data[5] << shift;
+ unsigned int chan_mask = hi_mask | lo_mask;
+ unsigned int old_mask = (1 << shift) - 1;
+- unsigned int pm = devpriv->pm[trig] & old_mask;
+- unsigned int pt = devpriv->pt[trig] & old_mask;
+- unsigned int pp = devpriv->pp[trig] & old_mask;
++ unsigned int pm;
++ unsigned int pt;
++ unsigned int pp;
+
+ if (trig > 1) {
+ dev_dbg(dev->class_dev,
+@@ -471,6 +471,10 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
+ return -EINVAL;
+ }
+
++ pm = devpriv->pm[trig] & old_mask;
++ pt = devpriv->pt[trig] & old_mask;
++ pp = devpriv->pp[trig] & old_mask;
++
+ switch (data[2]) {
+ case COMEDI_DIGITAL_TRIG_DISABLE:
+ /* clear trigger configuration */
+--
+2.25.1
+
--- /dev/null
+From 4a671d95a549eef6de9204db8274f3acdd2cc8b9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 28 May 2020 20:35:54 +0200
+Subject: usb: gadget: udc: atmel: fix uninitialized read in debug printk
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
+
+[ Upstream commit 30517ffeb3bff842e1355cbc32f1959d9dbb5414 ]
+
+Fixed commit moved the assignment of 'req', but did not update a
+reference in the DBG() call. Use the argument as it was renamed.
+
+Fixes: 5fb694f96e7c ("usb: gadget: udc: atmel: fix possible oops when unloading module")
+Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
+Signed-off-by: Felipe Balbi <balbi@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
+index b771a854e29c3..cfdc66e118717 100644
+--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
++++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
+@@ -871,7 +871,7 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
+ u32 status;
+
+ DBG(DBG_GADGET | DBG_QUEUE, "ep_dequeue: %s, req %p\n",
+- ep->ep.name, req);
++ ep->ep.name, _req);
+
+ spin_lock_irqsave(&udc->lock, flags);
+
+--
+2.25.1
+
--- /dev/null
+From f8e01d65ca13348a66fe8b856c475ca39f303d2a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 Jun 2020 12:35:04 -0400
+Subject: xprtrdma: Fix double-free in rpcrdma_ep_create()
+
+From: Chuck Lever <chuck.lever@oracle.com>
+
+[ Upstream commit 85bfd71bc34e20d9fadb745131f6314c36d0f75b ]
+
+In the error paths, there's no need to call kfree(ep) after calling
+rpcrdma_ep_put(ep).
+
+Fixes: e28ce90083f0 ("xprtrdma: kmalloc rpcrdma_ep separate from rpcrdma_xprt")
+Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sunrpc/xprtrdma/verbs.c | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
+index db0259c6467ef..4cb91dde849b9 100644
+--- a/net/sunrpc/xprtrdma/verbs.c
++++ b/net/sunrpc/xprtrdma/verbs.c
+@@ -404,8 +404,8 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
+
+ id = rpcrdma_create_id(r_xprt, ep);
+ if (IS_ERR(id)) {
+- rc = PTR_ERR(id);
+- goto out_free;
++ kfree(ep);
++ return PTR_ERR(id);
+ }
+ __module_get(THIS_MODULE);
+ device = id->device;
+@@ -504,9 +504,6 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
+ out_destroy:
+ rpcrdma_ep_put(ep);
+ rdma_destroy_id(id);
+-out_free:
+- kfree(ep);
+- r_xprt->rx_ep = NULL;
+ return rc;
+ }
+
+--
+2.25.1
+
--- /dev/null
+From b66382e7cc70d358e78b64c30245217988cb460f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 Jun 2020 12:35:20 -0400
+Subject: xprtrdma: Fix handling of connect errors
+
+From: Chuck Lever <chuck.lever@oracle.com>
+
+[ Upstream commit af667527b0e34912d2cb3586d585f66db4e4f486 ]
+
+Ensure that the connect worker is awoken if an attempt to establish
+a connection is unsuccessful. Otherwise the worker waits forever
+and the transport workload hangs.
+
+Connect errors should not attempt to destroy the ep, since the
+connect worker continues to use it after the handler runs, so these
+errors are now handled independently of DISCONNECTED events.
+
+Reported-by: Dan Aloni <dan@kernelim.com>
+Fixes: e28ce90083f0 ("xprtrdma: kmalloc rpcrdma_ep separate from rpcrdma_xprt")
+Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sunrpc/xprtrdma/verbs.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
+index 220c2d2eeb3e5..26e89c65ba564 100644
+--- a/net/sunrpc/xprtrdma/verbs.c
++++ b/net/sunrpc/xprtrdma/verbs.c
+@@ -279,17 +279,19 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
+ break;
+ case RDMA_CM_EVENT_CONNECT_ERROR:
+ ep->re_connect_status = -ENOTCONN;
+- goto disconnected;
++ goto wake_connect_worker;
+ case RDMA_CM_EVENT_UNREACHABLE:
+ ep->re_connect_status = -ENETUNREACH;
+- goto disconnected;
++ goto wake_connect_worker;
+ case RDMA_CM_EVENT_REJECTED:
+ dprintk("rpcrdma: connection to %pISpc rejected: %s\n",
+ sap, rdma_reject_msg(id, event->status));
+ ep->re_connect_status = -ECONNREFUSED;
+ if (event->status == IB_CM_REJ_STALE_CONN)
+ ep->re_connect_status = -ENOTCONN;
+- goto disconnected;
++wake_connect_worker:
++ wake_up_all(&ep->re_connect_wait);
++ return 0;
+ case RDMA_CM_EVENT_DISCONNECTED:
+ ep->re_connect_status = -ECONNABORTED;
+ disconnected:
+--
+2.25.1
+
--- /dev/null
+From d59edd4cb1099550502e187493c53f4678ba1327 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Jul 2020 17:26:04 +0100
+Subject: xprtrdma: fix incorrect header size calculations
+
+From: Colin Ian King <colin.king@canonical.com>
+
+[ Upstream commit 912288442cb2f431bf3c8cb097a5de83bc6dbac1 ]
+
+Currently the header size calculations are using an assignment
+operator instead of a += operator when accumulating the header
+size leading to incorrect sizes. Fix this by using the correct
+operator.
+
+Addresses-Coverity: ("Unused value")
+Fixes: 302d3deb2068 ("xprtrdma: Prevent inline overflow")
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sunrpc/xprtrdma/rpc_rdma.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
+index 57118e342c8eb..06a8268edf3b4 100644
+--- a/net/sunrpc/xprtrdma/rpc_rdma.c
++++ b/net/sunrpc/xprtrdma/rpc_rdma.c
+@@ -71,7 +71,7 @@ static unsigned int rpcrdma_max_call_header_size(unsigned int maxsegs)
+ size = RPCRDMA_HDRLEN_MIN;
+
+ /* Maximum Read list size */
+- size = maxsegs * rpcrdma_readchunk_maxsz * sizeof(__be32);
++ size += maxsegs * rpcrdma_readchunk_maxsz * sizeof(__be32);
+
+ /* Minimal Read chunk size */
+ size += sizeof(__be32); /* segment count */
+@@ -94,7 +94,7 @@ static unsigned int rpcrdma_max_reply_header_size(unsigned int maxsegs)
+ size = RPCRDMA_HDRLEN_MIN;
+
+ /* Maximum Write list size */
+- size = sizeof(__be32); /* segment count */
++ size += sizeof(__be32); /* segment count */
+ size += maxsegs * rpcrdma_segment_maxsz * sizeof(__be32);
+ size += sizeof(__be32); /* list discriminator */
+
+--
+2.25.1
+
--- /dev/null
+From 8f4ee2decb789bf1a9379484aea41b63ff9c5c31 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 Jun 2020 12:35:09 -0400
+Subject: xprtrdma: Fix recursion into rpcrdma_xprt_disconnect()
+
+From: Chuck Lever <chuck.lever@oracle.com>
+
+[ Upstream commit 4cf44be6f1e86da302085bf3e1dc2c86f3cdaaaa ]
+
+Both Dan and I have observed two processes invoking
+rpcrdma_xprt_disconnect() concurrently. In my case:
+
+1. The connect worker invokes rpcrdma_xprt_disconnect(), which
+ drains the QP and waits for the final completion
+2. This causes the newly posted Receive to flush and invoke
+ xprt_force_disconnect()
+3. xprt_force_disconnect() sets CLOSE_WAIT and wakes up the RPC task
+ that is holding the transport lock
+4. The RPC task invokes xprt_connect(), which calls ->ops->close
+5. xprt_rdma_close() invokes rpcrdma_xprt_disconnect(), which tries
+ to destroy the QP.
+
+Deadlock.
+
+To prevent xprt_force_disconnect() from waking anything, handle the
+clean up after a failed connection attempt in the xprt's sndtask.
+
+The retry loop is removed from rpcrdma_xprt_connect() to ensure
+that the newly allocated ep and id are properly released before
+a REJECTED connection attempt can be retried.
+
+Reported-by: Dan Aloni <dan@kernelim.com>
+Fixes: e28ce90083f0 ("xprtrdma: kmalloc rpcrdma_ep separate from rpcrdma_xprt")
+Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sunrpc/xprtrdma/transport.c | 5 +++++
+ net/sunrpc/xprtrdma/verbs.c | 10 ++--------
+ 2 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
+index 659da37020a46..3b5fb1f57aeb7 100644
+--- a/net/sunrpc/xprtrdma/transport.c
++++ b/net/sunrpc/xprtrdma/transport.c
+@@ -249,6 +249,11 @@ xprt_rdma_connect_worker(struct work_struct *work)
+ xprt->stat.connect_start;
+ xprt_set_connected(xprt);
+ rc = -EAGAIN;
++ } else {
++ /* Force a call to xprt_rdma_close to clean up */
++ spin_lock(&xprt->transport_lock);
++ set_bit(XPRT_CLOSE_WAIT, &xprt->state);
++ spin_unlock(&xprt->transport_lock);
+ }
+ xprt_wake_pending_tasks(xprt, rc);
+ }
+diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
+index 4cb91dde849b9..00ee62579137b 100644
+--- a/net/sunrpc/xprtrdma/verbs.c
++++ b/net/sunrpc/xprtrdma/verbs.c
+@@ -288,7 +288,7 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
+ sap, rdma_reject_msg(id, event->status));
+ ep->re_connect_status = -ECONNREFUSED;
+ if (event->status == IB_CM_REJ_STALE_CONN)
+- ep->re_connect_status = -EAGAIN;
++ ep->re_connect_status = -ENOTCONN;
+ goto disconnected;
+ case RDMA_CM_EVENT_DISCONNECTED:
+ ep->re_connect_status = -ECONNABORTED;
+@@ -519,8 +519,6 @@ int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt)
+ struct rpcrdma_ep *ep;
+ int rc;
+
+-retry:
+- rpcrdma_xprt_disconnect(r_xprt);
+ rc = rpcrdma_ep_create(r_xprt);
+ if (rc)
+ return rc;
+@@ -549,17 +547,13 @@ int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt)
+ wait_event_interruptible(ep->re_connect_wait,
+ ep->re_connect_status != 0);
+ if (ep->re_connect_status <= 0) {
+- if (ep->re_connect_status == -EAGAIN)
+- goto retry;
+ rc = ep->re_connect_status;
+ goto out;
+ }
+
+ rc = rpcrdma_reqs_setup(r_xprt);
+- if (rc) {
+- rpcrdma_xprt_disconnect(r_xprt);
++ if (rc)
+ goto out;
+- }
+ rpcrdma_mrs_create(r_xprt);
+
+ out:
+--
+2.25.1
+
--- /dev/null
+From 093b1d3572a7e38f42ff4bff86cd0487e78575c4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 Jun 2020 12:35:15 -0400
+Subject: xprtrdma: Fix return code from rpcrdma_xprt_connect()
+
+From: Chuck Lever <chuck.lever@oracle.com>
+
+[ Upstream commit dda9a951dd6dd6073bbaf2c8d3119da2f8fe2d5b ]
+
+I noticed that when rpcrdma_xprt_connect() returns -ENOMEM,
+instead of retrying the connect, the RPC client kills the
+RPC task that requested the connection. We want a retry
+here.
+
+Fixes: cb586decbb88 ("xprtrdma: Make sendctx queue lifetime the same as connection lifetime")
+Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
+Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sunrpc/xprtrdma/verbs.c | 16 ++++++++++------
+ 1 file changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
+index 00ee62579137b..220c2d2eeb3e5 100644
+--- a/net/sunrpc/xprtrdma/verbs.c
++++ b/net/sunrpc/xprtrdma/verbs.c
+@@ -398,7 +398,7 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
+
+ ep = kzalloc(sizeof(*ep), GFP_NOFS);
+ if (!ep)
+- return -EAGAIN;
++ return -ENOTCONN;
+ ep->re_xprt = &r_xprt->rx_xprt;
+ kref_init(&ep->re_kref);
+
+@@ -534,10 +534,6 @@ int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt)
+ rpcrdma_ep_get(ep);
+ rpcrdma_post_recvs(r_xprt, true);
+
+- rc = rpcrdma_sendctxs_create(r_xprt);
+- if (rc)
+- goto out;
+-
+ rc = rdma_connect(ep->re_id, &ep->re_remote_cma);
+ if (rc)
+ goto out;
+@@ -551,9 +547,17 @@ int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt)
+ goto out;
+ }
+
++ rc = rpcrdma_sendctxs_create(r_xprt);
++ if (rc) {
++ rc = -ENOTCONN;
++ goto out;
++ }
++
+ rc = rpcrdma_reqs_setup(r_xprt);
+- if (rc)
++ if (rc) {
++ rc = -ENOTCONN;
+ goto out;
++ }
+ rpcrdma_mrs_create(r_xprt);
+
+ out:
+--
+2.25.1
+