From 4d47141da05dec3552121848db4520146fe25de0 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Tue, 7 May 2024 07:49:17 -0400 Subject: [PATCH] Fixes for 6.6 Signed-off-by: Sasha Levin --- ...qcom-smd-rpm-restore-msm8976-num_clk.patch | 36 ++++++++ ...reparent-cpux-during-pll-cpux-rate-c.patch | 72 ++++++++++++++++ ...iommu-lpar-panics-during-boot-up-wit.patch | 83 +++++++++++++++++++ ...make-max-polling-consistent-for-long.patch | 76 +++++++++++++++++ queue-6.6/series | 5 ++ ...se-restricted-pool-list_head-when-sw.patch | 62 ++++++++++++++ 6 files changed, 334 insertions(+) create mode 100644 queue-6.6/clk-qcom-smd-rpm-restore-msm8976-num_clk.patch create mode 100644 queue-6.6/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch create mode 100644 queue-6.6/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch create mode 100644 queue-6.6/powerpc-pseries-make-max-polling-consistent-for-long.patch create mode 100644 queue-6.6/swiotlb-initialise-restricted-pool-list_head-when-sw.patch diff --git a/queue-6.6/clk-qcom-smd-rpm-restore-msm8976-num_clk.patch b/queue-6.6/clk-qcom-smd-rpm-restore-msm8976-num_clk.patch new file mode 100644 index 00000000000..24c6ab95f77 --- /dev/null +++ b/queue-6.6/clk-qcom-smd-rpm-restore-msm8976-num_clk.patch @@ -0,0 +1,36 @@ +From d07be0012a72b79e43f116d26b8af8ac5e36b1e0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 1 Apr 2024 19:16:39 +0200 +Subject: clk: qcom: smd-rpm: Restore msm8976 num_clk + +From: Adam Skladowski + +[ Upstream commit 0d4ce2458cd7d1d66a5ee2f3c036592fb663d5bc ] + +During rework somehow msm8976 num_clk got removed, restore it. + +Fixes: d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out interconnect bus clocks") +Signed-off-by: Adam Skladowski +Reviewed-by: Konrad Dybcio +Link: https://lore.kernel.org/r/20240401171641.8979-1-a39.skl@gmail.com +Signed-off-by: Bjorn Andersson +Signed-off-by: Sasha Levin +--- + drivers/clk/qcom/clk-smd-rpm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c +index 0191fc0dd7dac..789903a1b3f2b 100644 +--- a/drivers/clk/qcom/clk-smd-rpm.c ++++ b/drivers/clk/qcom/clk-smd-rpm.c +@@ -758,6 +758,7 @@ static struct clk_smd_rpm *msm8976_clks[] = { + + static const struct rpm_smd_clk_desc rpm_clk_msm8976 = { + .clks = msm8976_clks, ++ .num_clks = ARRAY_SIZE(msm8976_clks), + .icc_clks = bimc_pcnoc_snoc_smmnoc_icc_clks, + .num_icc_clks = ARRAY_SIZE(bimc_pcnoc_snoc_smmnoc_icc_clks), + }; +-- +2.43.0 + diff --git a/queue-6.6/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch b/queue-6.6/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch new file mode 100644 index 00000000000..617cde95bd1 --- /dev/null +++ b/queue-6.6/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch @@ -0,0 +1,72 @@ +From 376e5703badd4b211dc543a7569df4ba85cf20bc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 13 Oct 2023 20:17:12 +0200 +Subject: clk: sunxi-ng: h6: Reparent CPUX during PLL CPUX rate change + +From: Jernej Skrabec + +[ Upstream commit 7e91ed763dc07437777bd012af7a2bd4493731ff ] + +While PLL CPUX clock rate change when CPU is running from it works in +vast majority of cases, now and then it causes instability. This leads +to system crashes and other undefined behaviour. After a lot of testing +(30+ hours) while also doing a lot of frequency switches, we can't +observe any instability issues anymore when doing reparenting to stable +clock like 24 MHz oscillator. + +Fixes: 524353ea480b ("clk: sunxi-ng: add support for the Allwinner H6 CCU") +Reported-by: Chad Wagner +Link: https://forum.libreelec.tv/thread/27295-orange-pi-3-lts-freezes/ +Tested-by: Chad Wagner +Reviewed-by: Chen-Yu Tsai +Link: https://lore.kernel.org/r/20231013181712.2128037-1-jernej.skrabec@gmail.com +Signed-off-by: Jernej Skrabec +Signed-off-by: Sasha Levin +--- + drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 19 +++++++++++++++++-- + 1 file changed, 17 insertions(+), 2 deletions(-) + +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c +index 42568c6161814..892df807275c8 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c +@@ -1181,11 +1181,18 @@ static const u32 usb2_clk_regs[] = { + SUN50I_H6_USB3_CLK_REG, + }; + ++static struct ccu_mux_nb sun50i_h6_cpu_nb = { ++ .common = &cpux_clk.common, ++ .cm = &cpux_clk.mux, ++ .delay_us = 1, ++ .bypass_index = 0, /* index of 24 MHz oscillator */ ++}; ++ + static int sun50i_h6_ccu_probe(struct platform_device *pdev) + { + void __iomem *reg; ++ int i, ret; + u32 val; +- int i; + + reg = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(reg)) +@@ -1252,7 +1259,15 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev) + val |= BIT(24); + writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG); + +- return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc); ++ if (ret) ++ return ret; ++ ++ /* Reparent CPU during PLL CPUX rate changes */ ++ ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, ++ &sun50i_h6_cpu_nb); ++ ++ return 0; + } + + static const struct of_device_id sun50i_h6_ccu_ids[] = { +-- +2.43.0 + diff --git a/queue-6.6/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch b/queue-6.6/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch new file mode 100644 index 00000000000..04bd47ec545 --- /dev/null +++ b/queue-6.6/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch @@ -0,0 +1,83 @@ +From fb8d87b069c99037e00b7fba496bdf28a4a05b3d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 22 Apr 2024 15:51:41 -0500 +Subject: powerpc/pseries/iommu: LPAR panics during boot up with a frozen PE + +From: Gaurav Batra + +[ Upstream commit 49a940dbdc3107fecd5e6d3063dc07128177e058 ] + +At the time of LPAR boot up, partition firmware provides Open Firmware +property ibm,dma-window for the PE. This property is provided on the PCI +bus the PE is attached to. + +There are execptions where the partition firmware might not provide this +property for the PE at the time of LPAR boot up. One of the scenario is +where the firmware has frozen the PE due to some error condition. This +PE is frozen for 24 hours or unless the whole system is reinitialized. + +Within this time frame, if the LPAR is booted, the frozen PE will be +presented to the LPAR but ibm,dma-window property could be missing. + +Today, under these circumstances, the LPAR oopses with NULL pointer +dereference, when configuring the PCI bus the PE is attached to. + + BUG: Kernel NULL pointer dereference on read at 0x000000c8 + Faulting instruction address: 0xc0000000001024c0 + Oops: Kernel access of bad area, sig: 7 [#1] + LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries + Modules linked in: + Supported: Yes + CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.4.0-150600.9-default #1 + Hardware name: IBM,9043-MRX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NM1060_023) hv:phyp pSeries + NIP: c0000000001024c0 LR: c0000000001024b0 CTR: c000000000102450 + REGS: c0000000037db5c0 TRAP: 0300 Not tainted (6.4.0-150600.9-default) + MSR: 8000000002009033 CR: 28000822 XER: 00000000 + CFAR: c00000000010254c DAR: 00000000000000c8 DSISR: 00080000 IRQMASK: 0 + ... + NIP [c0000000001024c0] pci_dma_bus_setup_pSeriesLP+0x70/0x2a0 + LR [c0000000001024b0] pci_dma_bus_setup_pSeriesLP+0x60/0x2a0 + Call Trace: + pci_dma_bus_setup_pSeriesLP+0x60/0x2a0 (unreliable) + pcibios_setup_bus_self+0x1c0/0x370 + __of_scan_bus+0x2f8/0x330 + pcibios_scan_phb+0x280/0x3d0 + pcibios_init+0x88/0x12c + do_one_initcall+0x60/0x320 + kernel_init_freeable+0x344/0x3e4 + kernel_init+0x34/0x1d0 + ret_from_kernel_user_thread+0x14/0x1c + +Fixes: b1fc44eaa9ba ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window") +Signed-off-by: Gaurav Batra +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20240422205141.10662-1-gbatra@linux.ibm.com +Signed-off-by: Sasha Levin +--- + arch/powerpc/platforms/pseries/iommu.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c +index e8c4129697b14..b1e6d275cda9e 100644 +--- a/arch/powerpc/platforms/pseries/iommu.c ++++ b/arch/powerpc/platforms/pseries/iommu.c +@@ -786,8 +786,16 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus) + * parent bus. During reboot, there will be ibm,dma-window property to + * define DMA window. For kdump, there will at least be default window or DDW + * or both. ++ * There is an exception to the above. In case the PE goes into frozen ++ * state, firmware may not provide ibm,dma-window property at the time ++ * of LPAR boot up. + */ + ++ if (!pdn) { ++ pr_debug(" no ibm,dma-window property !\n"); ++ return; ++ } ++ + ppci = PCI_DN(pdn); + + pr_debug(" parent is %pOF, iommu_table: 0x%p\n", +-- +2.43.0 + diff --git a/queue-6.6/powerpc-pseries-make-max-polling-consistent-for-long.patch b/queue-6.6/powerpc-pseries-make-max-polling-consistent-for-long.patch new file mode 100644 index 00000000000..da3d8f9c3b7 --- /dev/null +++ b/queue-6.6/powerpc-pseries-make-max-polling-consistent-for-long.patch @@ -0,0 +1,76 @@ +From e4f58091aaf7818bdfef75ea2c63666d0c0a20a5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Apr 2024 23:12:30 -0400 +Subject: powerpc/pseries: make max polling consistent for longer H_CALLs + +From: Nayna Jain + +[ Upstream commit 784354349d2c988590c63a5a001ca37b2a6d4da1 ] + +Currently, plpks_confirm_object_flushed() function polls for 5msec in +total instead of 5sec. + +Keep max polling time consistent for all the H_CALLs, which take longer +than expected, to be 5sec. Also, make use of fsleep() everywhere to +insert delay. + +Reported-by: Nageswara R Sastry +Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore") +Signed-off-by: Nayna Jain +Tested-by: Nageswara R Sastry +Reviewed-by: Andrew Donnellan +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20240418031230.170954-1-nayna@linux.ibm.com +Signed-off-by: Sasha Levin +--- + arch/powerpc/include/asm/plpks.h | 5 ++--- + arch/powerpc/platforms/pseries/plpks.c | 10 +++++----- + 2 files changed, 7 insertions(+), 8 deletions(-) + +diff --git a/arch/powerpc/include/asm/plpks.h b/arch/powerpc/include/asm/plpks.h +index 23b77027c9163..7a84069759b03 100644 +--- a/arch/powerpc/include/asm/plpks.h ++++ b/arch/powerpc/include/asm/plpks.h +@@ -44,9 +44,8 @@ + #define PLPKS_MAX_DATA_SIZE 4000 + + // Timeouts for PLPKS operations +-#define PLPKS_MAX_TIMEOUT 5000 // msec +-#define PLPKS_FLUSH_SLEEP 10 // msec +-#define PLPKS_FLUSH_SLEEP_RANGE 400 ++#define PLPKS_MAX_TIMEOUT (5 * USEC_PER_SEC) ++#define PLPKS_FLUSH_SLEEP 10000 // usec + + struct plpks_var { + char *component; +diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c +index 2d40304eb6c16..ed492d38f6ad6 100644 +--- a/arch/powerpc/platforms/pseries/plpks.c ++++ b/arch/powerpc/platforms/pseries/plpks.c +@@ -415,8 +415,7 @@ static int plpks_confirm_object_flushed(struct label *label, + break; + } + +- usleep_range(PLPKS_FLUSH_SLEEP, +- PLPKS_FLUSH_SLEEP + PLPKS_FLUSH_SLEEP_RANGE); ++ fsleep(PLPKS_FLUSH_SLEEP); + timeout = timeout + PLPKS_FLUSH_SLEEP; + } while (timeout < PLPKS_MAX_TIMEOUT); + +@@ -464,9 +463,10 @@ int plpks_signed_update_var(struct plpks_var *var, u64 flags) + + continuetoken = retbuf[0]; + if (pseries_status_to_err(rc) == -EBUSY) { +- int delay_ms = get_longbusy_msecs(rc); +- mdelay(delay_ms); +- timeout += delay_ms; ++ int delay_us = get_longbusy_msecs(rc) * 1000; ++ ++ fsleep(delay_us); ++ timeout += delay_us; + } + rc = pseries_status_to_err(rc); + } while (rc == -EBUSY && timeout < PLPKS_MAX_TIMEOUT); +-- +2.43.0 + diff --git a/queue-6.6/series b/queue-6.6/series index 7b45557f018..91ea37e18cb 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -87,3 +87,8 @@ ipv4-fix-uninit-value-access-in-__ip_make_skb.patch net-gro-parse-ipv6-ext-headers-without-frag0-invalid.patch net-gro-fix-udp-bad-offset-in-socket-lookup-by-addin.patch net-gro-add-flush-check-in-udp_gro_receive_segment.patch +clk-qcom-smd-rpm-restore-msm8976-num_clk.patch +clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch +powerpc-pseries-make-max-polling-consistent-for-long.patch +powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch +swiotlb-initialise-restricted-pool-list_head-when-sw.patch diff --git a/queue-6.6/swiotlb-initialise-restricted-pool-list_head-when-sw.patch b/queue-6.6/swiotlb-initialise-restricted-pool-list_head-when-sw.patch new file mode 100644 index 00000000000..fdcf0827ec8 --- /dev/null +++ b/queue-6.6/swiotlb-initialise-restricted-pool-list_head-when-sw.patch @@ -0,0 +1,62 @@ +From c98ed3aac1462b663fe90bd3ff807b29806fbdfc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 2 May 2024 10:37:23 +0100 +Subject: swiotlb: initialise restricted pool list_head when SWIOTLB_DYNAMIC=y + +From: Will Deacon + +[ Upstream commit 75961ffb5cb3e5196f19cae7683f35cc88b50800 ] + +Using restricted DMA pools (CONFIG_DMA_RESTRICTED_POOL=y) in conjunction +with dynamic SWIOTLB (CONFIG_SWIOTLB_DYNAMIC=y) leads to the following +crash when initialising the restricted pools at boot-time: + + | Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 + | Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP + | pc : rmem_swiotlb_device_init+0xfc/0x1ec + | lr : rmem_swiotlb_device_init+0xf0/0x1ec + | Call trace: + | rmem_swiotlb_device_init+0xfc/0x1ec + | of_reserved_mem_device_init_by_idx+0x18c/0x238 + | of_dma_configure_id+0x31c/0x33c + | platform_dma_configure+0x34/0x80 + +faddr2line reveals that the crash is in the list validation code: + + include/linux/list.h:83 + include/linux/rculist.h:79 + include/linux/rculist.h:106 + kernel/dma/swiotlb.c:306 + kernel/dma/swiotlb.c:1695 + +because add_mem_pool() is trying to list_add_rcu() to a NULL +'mem->pools'. + +Fix the crash by initialising the 'mem->pools' list_head in +rmem_swiotlb_device_init() before calling add_mem_pool(). + +Reported-by: Nikita Ioffe +Tested-by: Nikita Ioffe +Fixes: 1aaa736815eb ("swiotlb: allocate a new memory pool when existing pools are full") +Signed-off-by: Will Deacon +Signed-off-by: Christoph Hellwig +Signed-off-by: Sasha Levin +--- + kernel/dma/swiotlb.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c +index 675ae318f74f8..a7d5fb473b324 100644 +--- a/kernel/dma/swiotlb.c ++++ b/kernel/dma/swiotlb.c +@@ -1692,6 +1692,7 @@ static int rmem_swiotlb_device_init(struct reserved_mem *rmem, + mem->for_alloc = true; + #ifdef CONFIG_SWIOTLB_DYNAMIC + spin_lock_init(&mem->lock); ++ INIT_LIST_HEAD_RCU(&mem->pools); + #endif + add_mem_pool(mem, pool); + +-- +2.43.0 + -- 2.47.2