From: Sasha Levin Date: Thu, 9 Jul 2020 18:56:14 +0000 (-0400) Subject: Fixes for 5.7 X-Git-Tag: v5.7.9~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=524c9272ed0f401ef5f98af1689ce28f9ef03340;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.7 Signed-off-by: Sasha Levin --- diff --git a/queue-5.7/kvm-s390-reduce-number-of-io-pins-to-1.patch b/queue-5.7/kvm-s390-reduce-number-of-io-pins-to-1.patch new file mode 100644 index 00000000000..05e7f569fdf --- /dev/null +++ b/queue-5.7/kvm-s390-reduce-number-of-io-pins-to-1.patch @@ -0,0 +1,73 @@ +From 53e7c2648db8d04e79e08cbbebc50ba2f069d2f7 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 d6bcd34f3ec32..ec65bc2bd084e 100644 +--- a/arch/s390/include/asm/kvm_host.h ++++ b/arch/s390/include/asm/kvm_host.h +@@ -31,12 +31,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 50000 + + /* s390-specific vcpu->requests bit members */ +-- +2.25.1 + diff --git a/queue-5.7/series b/queue-5.7/series new file mode 100644 index 00000000000..f25facc5904 --- /dev/null +++ b/queue-5.7/series @@ -0,0 +1,3 @@ +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 diff --git a/queue-5.7/spi-spi-fsl-dspi-adding-shutdown-hook.patch b/queue-5.7/spi-spi-fsl-dspi-adding-shutdown-hook.patch new file mode 100644 index 00000000000..95154adb87b --- /dev/null +++ b/queue-5.7/spi-spi-fsl-dspi-adding-shutdown-hook.patch @@ -0,0 +1,79 @@ +From c985b8a875aa9c0522f1feac174cfd58c69bae4a 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 | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c +index 856a4a0edcc7a..89d403dfb3bdf 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 +@@ -26,6 +27,9 @@ + #define SPI_MCR_CLR_TXF BIT(11) + #define SPI_MCR_CLR_RXF BIT(10) + #define SPI_MCR_XSPI BIT(3) ++#define SPI_MCR_DIS_TXF BIT(13) ++#define SPI_MCR_DIS_RXF BIT(12) ++#define SPI_MCR_HALT BIT(0) + + #define SPI_TCR 0x08 + #define SPI_TCR_GET_TCNT(x) (((x) & GENMASK(31, 16)) >> 16) +@@ -1446,6 +1450,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->ctlr); ++} ++ + static struct platform_driver fsl_dspi_driver = { + .driver.name = DRIVER_NAME, + .driver.of_match_table = fsl_dspi_dt_ids, +@@ -1453,6 +1475,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-5.7/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch b/queue-5.7/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch new file mode 100644 index 00000000000..3650bde72a7 --- /dev/null +++ b/queue-5.7/spi-spi-fsl-dspi-fix-lockup-if-device-is-removed-dur.patch @@ -0,0 +1,58 @@ +From e9ee3a566324bd4227291eba2709666748317870 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 89d403dfb3bdf..38d337f0967db 100644 +--- a/drivers/spi/spi-fsl-dspi.c ++++ b/drivers/spi/spi-fsl-dspi.c +@@ -1441,11 +1441,20 @@ static int dspi_remove(struct platform_device *pdev) + struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr); + + /* Disconnect from the SPI framework */ ++ spi_unregister_controller(dspi->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); + if (dspi->irq) + free_irq(dspi->irq, dspi); + clk_disable_unprepare(dspi->clk); +- spi_unregister_controller(dspi->ctlr); + + return 0; + } +-- +2.25.1 +