From: Sasha Levin Date: Thu, 9 Jul 2020 18:56:16 +0000 (-0400) Subject: Fixes for 4.14 X-Git-Tag: v5.7.9~49 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29cfd6bbf0a0dc6c03bb4c8e2a3777807c56abee;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/kvm-s390-reduce-number-of-io-pins-to-1.patch b/queue-4.14/kvm-s390-reduce-number-of-io-pins-to-1.patch new file mode 100644 index 00000000000..735ba6af1e4 --- /dev/null +++ b/queue-4.14/kvm-s390-reduce-number-of-io-pins-to-1.patch @@ -0,0 +1,73 @@ +From 834244c41350dc45044ec3e4d800eaf9ca3a393e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Jun 2020 10:36:20 +0200 +Subject: KVM: s390: reduce number of IO pins to 1 + +From: Christian Borntraeger + +[ 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 +Reviewed-by: Cornelia Huck +Reviewed-by: David Hildenbrand +Link: https://lore.kernel.org/r/20200617083620.5409-1-borntraeger@de.ibm.com +Signed-off-by: Sasha Levin +--- + 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 3fdc0bb974d92..82d76ac71d2ec 100644 +--- a/arch/s390/include/asm/kvm_host.h ++++ b/arch/s390/include/asm/kvm_host.h +@@ -33,12 +33,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.14/series b/queue-4.14/series new file mode 100644 index 00000000000..253dba996b6 --- /dev/null +++ b/queue-4.14/series @@ -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.14/spi-spi-fsl-dspi-adding-shutdown-hook.patch b/queue-4.14/spi-spi-fsl-dspi-adding-shutdown-hook.patch new file mode 100644 index 00000000000..8d5a01f2443 --- /dev/null +++ b/queue-4.14/spi-spi-fsl-dspi-adding-shutdown-hook.patch @@ -0,0 +1,71 @@ +From a427c20703e0ea0ddc93445b51f987dac7352d11 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 24 Apr 2020 14:12:16 +0800 +Subject: spi: spi-fsl-dspi: Adding shutdown hook + +From: Peng Ma + +[ 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 +Link: https://lore.kernel.org/r/20200424061216.27445-1-peng.ma@nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-fsl-dspi.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c +index ca013dd4ff6bb..d5b56b7814fe3 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -49,6 +49,9 @@ + #define SPI_MCR_PCSIS (0x3F << 16) + #define SPI_MCR_CLR_TXF (1 << 11) + #define SPI_MCR_CLR_RXF (1 << 10) ++#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) +@@ -1074,6 +1077,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, +@@ -1081,6 +1102,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.14/spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch b/queue-4.14/spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch new file mode 100644 index 00000000000..c5d9695d414 --- /dev/null +++ b/queue-4.14/spi-spi-fsl-dspi-fix-external-abort-on-interrupt-in-.patch @@ -0,0 +1,127 @@ +From 0f35b45ff434f8784c89bac8484bbdbe3b9a3243 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Tested-by: Vladimir Oltean +Reviewed-by: Vladimir Oltean +Cc: +Link: https://lore.kernel.org/r/20200622110543.5035-3-krzk@kernel.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + 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 4402e531b1bfd..dabff9718d426 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -906,6 +906,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); + +@@ -926,6 +928,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; + } +@@ -1027,8 +1031,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; +@@ -1038,7 +1042,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; + } + } + +@@ -1051,11 +1055,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: +@@ -1081,6 +1088,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.14/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch b/queue-4.14/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch new file mode 100644 index 00000000000..ea1873efbb9 --- /dev/null +++ b/queue-4.14/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch @@ -0,0 +1,56 @@ +From 9267af0ae3c8dfe3bafb1def4154dff903814d41 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Signed-off-by: Krzysztof Kozlowski +Cc: +Link: https://lore.kernel.org/r/20200622110543.5035-1-krzk@kernel.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + 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 d5b56b7814fe3..baf5274485004 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -1070,9 +1070,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.14/spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch b/queue-4.14/spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch new file mode 100644 index 00000000000..ec430773943 --- /dev/null +++ b/queue-4.14/spi-spi-fsl-dspi-use-irqf_shared-mode-to-request-irq.patch @@ -0,0 +1,39 @@ +From b2ddace232017fa1e55ad3412a87200e3c373a5f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 29 Oct 2018 11:11:16 +0800 +Subject: spi: spi-fsl-dspi: use IRQF_SHARED mode to request IRQ + +From: Chuanhua Han + +[ 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 +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + 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 baf5274485004..4402e531b1bfd 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -1027,8 +1027,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 +