]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.19
authorSasha Levin <sashal@kernel.org>
Thu, 9 Jul 2020 18:56:15 +0000 (14:56 -0400)
committerSasha Levin <sashal@kernel.org>
Thu, 9 Jul 2020 18:56:15 +0000 (14:56 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.19/kvm-s390-reduce-number-of-io-pins-to-1.patch [new file with mode: 0644]
queue-4.19/series [new file with mode: 0644]
queue-4.19/spi-spi-fsl-dspi-adding-shutdown-hook.patch [new file with mode: 0644]
queue-4.19/spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch [new file with mode: 0644]
queue-4.19/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch [new file with mode: 0644]
queue-4.19/spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch [new file with mode: 0644]

diff --git a/queue-4.19/kvm-s390-reduce-number-of-io-pins-to-1.patch b/queue-4.19/kvm-s390-reduce-number-of-io-pins-to-1.patch
new file mode 100644 (file)
index 0000000..f48b4a4
--- /dev/null
@@ -0,0 +1,73 @@
+From a7c8065a78bda7d623866bc8a98f32787492db42 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 Jun 2020 10:36:20 +0200
+Subject: KVM: s390: reduce number of IO pins to 1
+
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+
+[ Upstream commit 774911290c589e98e3638e73b24b0a4d4530e97c ]
+
+The current number of KVM_IRQCHIP_NUM_PINS results in an order 3
+allocation (32kb) for each guest start/restart. This can result in OOM
+killer activity even with free swap when the memory is fragmented
+enough:
+
+kernel: qemu-system-s39 invoked oom-killer: gfp_mask=0x440dc0(GFP_KERNEL_ACCOUNT|__GFP_COMP|__GFP_ZERO), order=3, oom_score_adj=0
+kernel: CPU: 1 PID: 357274 Comm: qemu-system-s39 Kdump: loaded Not tainted 5.4.0-29-generic #33-Ubuntu
+kernel: Hardware name: IBM 8562 T02 Z06 (LPAR)
+kernel: Call Trace:
+kernel: ([<00000001f848fe2a>] show_stack+0x7a/0xc0)
+kernel:  [<00000001f8d3437a>] dump_stack+0x8a/0xc0
+kernel:  [<00000001f8687032>] dump_header+0x62/0x258
+kernel:  [<00000001f8686122>] oom_kill_process+0x172/0x180
+kernel:  [<00000001f8686abe>] out_of_memory+0xee/0x580
+kernel:  [<00000001f86e66b8>] __alloc_pages_slowpath+0xd18/0xe90
+kernel:  [<00000001f86e6ad4>] __alloc_pages_nodemask+0x2a4/0x320
+kernel:  [<00000001f86b1ab4>] kmalloc_order+0x34/0xb0
+kernel:  [<00000001f86b1b62>] kmalloc_order_trace+0x32/0xe0
+kernel:  [<00000001f84bb806>] kvm_set_irq_routing+0xa6/0x2e0
+kernel:  [<00000001f84c99a4>] kvm_arch_vm_ioctl+0x544/0x9e0
+kernel:  [<00000001f84b8936>] kvm_vm_ioctl+0x396/0x760
+kernel:  [<00000001f875df66>] do_vfs_ioctl+0x376/0x690
+kernel:  [<00000001f875e304>] ksys_ioctl+0x84/0xb0
+kernel:  [<00000001f875e39a>] __s390x_sys_ioctl+0x2a/0x40
+kernel:  [<00000001f8d55424>] system_call+0xd8/0x2c8
+
+As far as I can tell s390x does not use the iopins as we bail our for
+anything other than KVM_IRQ_ROUTING_S390_ADAPTER and the chip/pin is
+only used for KVM_IRQ_ROUTING_IRQCHIP. So let us use a small number to
+reduce the memory footprint.
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: David Hildenbrand <david@redhat.com>
+Link: https://lore.kernel.org/r/20200617083620.5409-1-borntraeger@de.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/s390/include/asm/kvm_host.h | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
+index dad110e9f41b3..be8fa30a6ea6d 100644
+--- a/arch/s390/include/asm/kvm_host.h
++++ b/arch/s390/include/asm/kvm_host.h
+@@ -30,12 +30,12 @@
+ #define KVM_USER_MEM_SLOTS 32
+ /*
+- * These seem to be used for allocating ->chip in the routing table,
+- * which we don't use. 4096 is an out-of-thin-air value. If we need
+- * to look at ->chip later on, we'll need to revisit this.
++ * These seem to be used for allocating ->chip in the routing table, which we
++ * don't use. 1 is as small as we can get to reduce the needed memory. If we
++ * need to look at ->chip later on, we'll need to revisit this.
+  */
+ #define KVM_NR_IRQCHIPS 1
+-#define KVM_IRQCHIP_NUM_PINS 4096
++#define KVM_IRQCHIP_NUM_PINS 1
+ #define KVM_HALT_POLL_NS_DEFAULT 80000
+ /* s390-specific vcpu->requests bit members */
+-- 
+2.25.1
+
diff --git a/queue-4.19/series b/queue-4.19/series
new file mode 100644 (file)
index 0000000..253dba9
--- /dev/null
@@ -0,0 +1,5 @@
+kvm-s390-reduce-number-of-io-pins-to-1.patch
+spi-spi-fsl-dspi-adding-shutdown-hook.patch
+spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch
+spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch
+spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch
diff --git a/queue-4.19/spi-spi-fsl-dspi-adding-shutdown-hook.patch b/queue-4.19/spi-spi-fsl-dspi-adding-shutdown-hook.patch
new file mode 100644 (file)
index 0000000..81b8f8f
--- /dev/null
@@ -0,0 +1,79 @@
+From 4cd046a104fa5c26261e16614e0fbe0e430a3134 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Apr 2020 14:12:16 +0800
+Subject: spi: spi-fsl-dspi: Adding shutdown hook
+
+From: Peng Ma <peng.ma@nxp.com>
+
+[ Upstream commit dc234825997ec6ff05980ca9e2204f4ac3f8d695 ]
+
+We need to ensure dspi controller could be stopped in order for kexec
+to start the next kernel.
+So add the shutdown operation support.
+
+Signed-off-by: Peng Ma <peng.ma@nxp.com>
+Link: https://lore.kernel.org/r/20200424061216.27445-1-peng.ma@nxp.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-fsl-dspi.c | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
+index 3082e72e4f6c6..9296bcbbd32ce 100644
+--- a/drivers/spi/spi-fsl-dspi.c
++++ b/drivers/spi/spi-fsl-dspi.c
+@@ -1,6 +1,7 @@
+ // SPDX-License-Identifier: GPL-2.0+
+ //
+ // Copyright 2013 Freescale Semiconductor, Inc.
++// Copyright 2020 NXP
+ //
+ // Freescale DSPI driver
+ // This file contains a driver for the Freescale DSPI
+@@ -43,6 +44,9 @@
+ #define SPI_MCR_CLR_TXF       (1 << 11)
+ #define SPI_MCR_CLR_RXF       (1 << 10)
+ #define SPI_MCR_XSPI          (1 << 3)
++#define SPI_MCR_DIS_TXF               (1 << 13)
++#define SPI_MCR_DIS_RXF               (1 << 12)
++#define SPI_MCR_HALT          (1 << 0)
+ #define SPI_TCR                       0x08
+ #define SPI_TCR_GET_TCNT(x)   (((x) & 0xffff0000) >> 16)
+@@ -1140,6 +1144,24 @@ static int dspi_remove(struct platform_device *pdev)
+       return 0;
+ }
++static void dspi_shutdown(struct platform_device *pdev)
++{
++      struct spi_controller *ctlr = platform_get_drvdata(pdev);
++      struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
++
++      /* Disable RX and TX */
++      regmap_update_bits(dspi->regmap, SPI_MCR,
++                         SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF,
++                         SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF);
++
++      /* Stop Running */
++      regmap_update_bits(dspi->regmap, SPI_MCR, SPI_MCR_HALT, SPI_MCR_HALT);
++
++      dspi_release_dma(dspi);
++      clk_disable_unprepare(dspi->clk);
++      spi_unregister_controller(dspi->master);
++}
++
+ static struct platform_driver fsl_dspi_driver = {
+       .driver.name    = DRIVER_NAME,
+       .driver.of_match_table = fsl_dspi_dt_ids,
+@@ -1147,6 +1169,7 @@ static struct platform_driver fsl_dspi_driver = {
+       .driver.pm = &dspi_pm,
+       .probe          = dspi_probe,
+       .remove         = dspi_remove,
++      .shutdown       = dspi_shutdown,
+ };
+ module_platform_driver(fsl_dspi_driver);
+-- 
+2.25.1
+
diff --git a/queue-4.19/spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch b/queue-4.19/spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch
new file mode 100644 (file)
index 0000000..ec7505a
--- /dev/null
@@ -0,0 +1,127 @@
+From 291870598bda6362efb12c5b67a8a77bb87ee5db Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Jun 2020 13:05:42 +0200
+Subject: spi: spi-fsl-dspi: Fix external abort on interrupt in resume or exit
+ paths
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit 3d87b613d6a3c6f0980e877ab0895785a2dde581 ]
+
+If shared interrupt comes late, during probe error path or device remove
+(could be triggered with CONFIG_DEBUG_SHIRQ), the interrupt handler
+dspi_interrupt() will access registers with the clock being disabled.
+This leads to external abort on non-linefetch on Toradex Colibri VF50
+module (with Vybrid VF5xx):
+
+    $ echo 4002d000.spi > /sys/devices/platform/soc/40000000.bus/4002d000.spi/driver/unbind
+
+    Unhandled fault: external abort on non-linefetch (0x1008) at 0x8887f02c
+    Internal error: : 1008 [#1] ARM
+    Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree)
+    Backtrace:
+      (regmap_mmio_read32le)
+      (regmap_mmio_read)
+      (_regmap_bus_reg_read)
+      (_regmap_read)
+      (regmap_read)
+      (dspi_interrupt)
+      (free_irq)
+      (devm_irq_release)
+      (release_nodes)
+      (devres_release_all)
+      (device_release_driver_internal)
+
+The resource-managed framework should not be used for shared interrupt
+handling, because the interrupt handler might be called after releasing
+other resources and disabling clocks.
+
+Similar bug could happen during suspend - the shared interrupt handler
+could be invoked after suspending the device.  Each device sharing this
+interrupt line should disable the IRQ during suspend so handler will be
+invoked only in following cases:
+1. None suspended,
+2. All devices resumed.
+
+Fixes: 349ad66c0ab0 ("spi:Add Freescale DSPI driver for Vybrid VF610 platform")
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
+Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20200622110543.5035-3-krzk@kernel.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-fsl-dspi.c | 17 +++++++++++++----
+ 1 file changed, 13 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
+index 9ab8c52a5ba6d..2844c9a72a980 100644
+--- a/drivers/spi/spi-fsl-dspi.c
++++ b/drivers/spi/spi-fsl-dspi.c
+@@ -897,6 +897,8 @@ static int dspi_suspend(struct device *dev)
+       struct spi_master *master = dev_get_drvdata(dev);
+       struct fsl_dspi *dspi = spi_master_get_devdata(master);
++      if (dspi->irq)
++              disable_irq(dspi->irq);
+       spi_master_suspend(master);
+       clk_disable_unprepare(dspi->clk);
+@@ -917,6 +919,8 @@ static int dspi_resume(struct device *dev)
+       if (ret)
+               return ret;
+       spi_master_resume(master);
++      if (dspi->irq)
++              enable_irq(dspi->irq);
+       return 0;
+ }
+@@ -1094,8 +1098,8 @@ static int dspi_probe(struct platform_device *pdev)
+               goto out_clk_put;
+       }
+-      ret = devm_request_irq(&pdev->dev, dspi->irq, dspi_interrupt,
+-                             IRQF_SHARED, pdev->name, dspi);
++      ret = request_threaded_irq(dspi->irq, dspi_interrupt, NULL,
++                                 IRQF_SHARED, pdev->name, dspi);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "Unable to attach DSPI interrupt\n");
+               goto out_clk_put;
+@@ -1105,7 +1109,7 @@ static int dspi_probe(struct platform_device *pdev)
+               ret = dspi_request_dma(dspi, res->start);
+               if (ret < 0) {
+                       dev_err(&pdev->dev, "can't get dma channels\n");
+-                      goto out_clk_put;
++                      goto out_free_irq;
+               }
+       }
+@@ -1118,11 +1122,14 @@ static int dspi_probe(struct platform_device *pdev)
+       ret = spi_register_master(master);
+       if (ret != 0) {
+               dev_err(&pdev->dev, "Problem registering DSPI master\n");
+-              goto out_clk_put;
++              goto out_free_irq;
+       }
+       return ret;
++out_free_irq:
++      if (dspi->irq)
++              free_irq(dspi->irq, dspi);
+ out_clk_put:
+       clk_disable_unprepare(dspi->clk);
+ out_master_put:
+@@ -1148,6 +1155,8 @@ static int dspi_remove(struct platform_device *pdev)
+       regmap_update_bits(dspi->regmap, SPI_MCR, SPI_MCR_HALT, SPI_MCR_HALT);
+       dspi_release_dma(dspi);
++      if (dspi->irq)
++              free_irq(dspi->irq, dspi);
+       clk_disable_unprepare(dspi->clk);
+       return 0;
+-- 
+2.25.1
+
diff --git a/queue-4.19/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch b/queue-4.19/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch
new file mode 100644 (file)
index 0000000..b2e114f
--- /dev/null
@@ -0,0 +1,56 @@
+From 8b974a1540c49ec0f60d34c77c8b9a18a192c7b2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Jun 2020 13:05:40 +0200
+Subject: spi: spi-fsl-dspi: Fix lockup if device is removed during SPI
+ transfer
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+[ Upstream commit 7684580d45bd3d84ed9b453a4cadf7a9a5605a3f ]
+
+During device removal, the driver should unregister the SPI controller
+and stop the hardware.  Otherwise the dspi_transfer_one_message() could
+wait on completion infinitely.
+
+Additionally, calling spi_unregister_controller() first in device
+removal reverse-matches the probe function, where SPI controller is
+registered at the end.
+
+Fixes: 05209f457069 ("spi: fsl-dspi: add missing clk_disable_unprepare() in dspi_remove()")
+Reported-by: Vladimir Oltean <olteanv@gmail.com>
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20200622110543.5035-1-krzk@kernel.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-fsl-dspi.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
+index 9296bcbbd32ce..970ffdb976d73 100644
+--- a/drivers/spi/spi-fsl-dspi.c
++++ b/drivers/spi/spi-fsl-dspi.c
+@@ -1137,9 +1137,18 @@ static int dspi_remove(struct platform_device *pdev)
+       struct fsl_dspi *dspi = spi_master_get_devdata(master);
+       /* Disconnect from the SPI framework */
++      spi_unregister_controller(dspi->master);
++
++      /* Disable RX and TX */
++      regmap_update_bits(dspi->regmap, SPI_MCR,
++                         SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF,
++                         SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF);
++
++      /* Stop Running */
++      regmap_update_bits(dspi->regmap, SPI_MCR, SPI_MCR_HALT, SPI_MCR_HALT);
++
+       dspi_release_dma(dspi);
+       clk_disable_unprepare(dspi->clk);
+-      spi_unregister_master(dspi->master);
+       return 0;
+ }
+-- 
+2.25.1
+
diff --git a/queue-4.19/spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch b/queue-4.19/spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch
new file mode 100644 (file)
index 0000000..699b264
--- /dev/null
@@ -0,0 +1,39 @@
+From f7c842291cf022ee21d3de06eb3175dc7362a9e0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 Oct 2018 11:11:16 +0800
+Subject: spi: spi-fsl-dspi: use IRQF_SHARED mode to request IRQ
+
+From: Chuanhua Han <chuanhua.han@nxp.com>
+
+[ Upstream commit 13aed23927414137a017ac2f7d567001f714293f ]
+
+Some SoC share one irq number between DSPI controllers.
+For example, on the LX2160 board, DSPI0 and DSPI1 share one irq number.
+In this case, only one DSPI controller can register successfully,
+and others will fail.
+
+Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-fsl-dspi.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
+index 970ffdb976d73..9ab8c52a5ba6d 100644
+--- a/drivers/spi/spi-fsl-dspi.c
++++ b/drivers/spi/spi-fsl-dspi.c
+@@ -1094,8 +1094,8 @@ static int dspi_probe(struct platform_device *pdev)
+               goto out_clk_put;
+       }
+-      ret = devm_request_irq(&pdev->dev, dspi->irq, dspi_interrupt, 0,
+-                      pdev->name, dspi);
++      ret = devm_request_irq(&pdev->dev, dspi->irq, dspi_interrupt,
++                             IRQF_SHARED, pdev->name, dspi);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "Unable to attach DSPI interrupt\n");
+               goto out_clk_put;
+-- 
+2.25.1
+