From: Sasha Levin Date: Mon, 16 Oct 2023 02:50:06 +0000 (-0400) Subject: Fixes for 5.10 X-Git-Tag: v5.15.136~24^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd6043a0e0875c5e51d63c9b1f41d2966896a37b;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/dmaengine-mediatek-fix-deadlock-caused-by-synchroniz.patch b/queue-5.10/dmaengine-mediatek-fix-deadlock-caused-by-synchroniz.patch new file mode 100644 index 00000000000..d1b09727ad0 --- /dev/null +++ b/queue-5.10/dmaengine-mediatek-fix-deadlock-caused-by-synchroniz.patch @@ -0,0 +1,53 @@ +From 0cc423e7a6fdf89fec7d60f4d39d56d1db68fc13 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 6 Aug 2023 11:25:11 +0800 +Subject: dmaengine: mediatek: Fix deadlock caused by synchronize_irq() + +From: Duoming Zhou + +[ Upstream commit 01f1ae2733e2bb4de92fefcea5fda847d92aede1 ] + +The synchronize_irq(c->irq) will not return until the IRQ handler +mtk_uart_apdma_irq_handler() is completed. If the synchronize_irq() +holds a spin_lock and waits the IRQ handler to complete, but the +IRQ handler also needs the same spin_lock. The deadlock will happen. +The process is shown below: + + cpu0 cpu1 +mtk_uart_apdma_device_pause() | mtk_uart_apdma_irq_handler() + spin_lock_irqsave() | + | spin_lock_irqsave() + //hold the lock to wait | + synchronize_irq() | + +This patch reorders the synchronize_irq(c->irq) outside the spin_lock +in order to mitigate the bug. + +Fixes: 9135408c3ace ("dmaengine: mediatek: Add MediaTek UART APDMA support") +Signed-off-by: Duoming Zhou +Reviewed-by: Eugen Hristev +Link: https://lore.kernel.org/r/20230806032511.45263-1-duoming@zju.edu.cn +Signed-off-by: Vinod Koul +Signed-off-by: Sasha Levin +--- + drivers/dma/mediatek/mtk-uart-apdma.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c +index a1517ef1f4a01..0acf6a92a4ad3 100644 +--- a/drivers/dma/mediatek/mtk-uart-apdma.c ++++ b/drivers/dma/mediatek/mtk-uart-apdma.c +@@ -451,9 +451,8 @@ static int mtk_uart_apdma_device_pause(struct dma_chan *chan) + mtk_uart_apdma_write(c, VFF_EN, VFF_EN_CLR_B); + mtk_uart_apdma_write(c, VFF_INT_EN, VFF_INT_EN_CLR_B); + +- synchronize_irq(c->irq); +- + spin_unlock_irqrestore(&c->vc.lock, flags); ++ synchronize_irq(c->irq); + + return 0; + } +-- +2.40.1 + diff --git a/queue-5.10/powerpc-64e-fix-wrong-test-in-__ptep_test_and_clear_.patch b/queue-5.10/powerpc-64e-fix-wrong-test-in-__ptep_test_and_clear_.patch new file mode 100644 index 00000000000..1a8911bab5c --- /dev/null +++ b/queue-5.10/powerpc-64e-fix-wrong-test-in-__ptep_test_and_clear_.patch @@ -0,0 +1,52 @@ +From 03576feebf27ff87685a00f024dd040f47a4c4e0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Sep 2023 20:31:16 +0200 +Subject: powerpc/64e: Fix wrong test in __ptep_test_and_clear_young() + +From: Christophe Leroy + +[ Upstream commit 5ea0bbaa32e8f54e9a57cfee4a3b8769b80be0d2 ] + +Commit 45201c879469 ("powerpc/nohash: Remove hash related code from +nohash headers.") replaced: + + if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0) + return 0; + +By: + + if (pte_young(*ptep)) + return 0; + +But it should be: + + if (!pte_young(*ptep)) + return 0; + +Fix it. + +Fixes: 45201c879469 ("powerpc/nohash: Remove hash related code from nohash headers.") +Signed-off-by: Christophe Leroy +Signed-off-by: Michael Ellerman +Link: https://msgid.link/8bb7f06494e21adada724ede47a4c3d97e879d40.1695659959.git.christophe.leroy@csgroup.eu +Signed-off-by: Sasha Levin +--- + arch/powerpc/include/asm/nohash/64/pgtable.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h +index a4d475c0fc2c0..6075fac882862 100644 +--- a/arch/powerpc/include/asm/nohash/64/pgtable.h ++++ b/arch/powerpc/include/asm/nohash/64/pgtable.h +@@ -216,7 +216,7 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, + { + unsigned long old; + +- if (pte_young(*ptep)) ++ if (!pte_young(*ptep)) + return 0; + old = pte_update(mm, addr, ptep, _PAGE_ACCESSED, 0, 0); + return (old & _PAGE_ACCESSED) != 0; +-- +2.40.1 + diff --git a/queue-5.10/powerpc-8xx-fix-pte_access_permitted-for-page_none.patch b/queue-5.10/powerpc-8xx-fix-pte_access_permitted-for-page_none.patch new file mode 100644 index 00000000000..a2f9b4b81b9 --- /dev/null +++ b/queue-5.10/powerpc-8xx-fix-pte_access_permitted-for-page_none.patch @@ -0,0 +1,62 @@ +From 26c1034f00f600a89c899e775ea6cb3867257daa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 25 Sep 2023 20:31:15 +0200 +Subject: powerpc/8xx: Fix pte_access_permitted() for PAGE_NONE + +From: Christophe Leroy + +[ Upstream commit 5d9cea8a552ee122e21fbd5a3c5d4eb85f648e06 ] + +On 8xx, PAGE_NONE is handled by setting _PAGE_NA instead of clearing +_PAGE_USER. + +But then pte_user() returns 1 also for PAGE_NONE. + +As _PAGE_NA prevent reads, add a specific version of pte_read() +that returns 0 when _PAGE_NA is set instead of always returning 1. + +Fixes: 351750331fc1 ("powerpc/mm: Introduce _PAGE_NA") +Signed-off-by: Christophe Leroy +Signed-off-by: Michael Ellerman +Link: https://msgid.link/57bcfbe578e43123f9ed73e040229b80f1ad56ec.1695659959.git.christophe.leroy@csgroup.eu +Signed-off-by: Sasha Levin +--- + arch/powerpc/include/asm/nohash/32/pte-8xx.h | 7 +++++++ + arch/powerpc/include/asm/nohash/pgtable.h | 2 ++ + 2 files changed, 9 insertions(+) + +diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h +index 1581204467e1d..2b06da0ffd2d2 100644 +--- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h ++++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h +@@ -94,6 +94,13 @@ static inline pte_t pte_wrprotect(pte_t pte) + + #define pte_wrprotect pte_wrprotect + ++static inline int pte_read(pte_t pte) ++{ ++ return (pte_val(pte) & _PAGE_RO) != _PAGE_NA; ++} ++ ++#define pte_read pte_read ++ + static inline int pte_write(pte_t pte) + { + return !(pte_val(pte) & _PAGE_RO); +diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h +index ac75f4ab0dba1..7ad1d1b042a60 100644 +--- a/arch/powerpc/include/asm/nohash/pgtable.h ++++ b/arch/powerpc/include/asm/nohash/pgtable.h +@@ -45,7 +45,9 @@ static inline int pte_write(pte_t pte) + return pte_val(pte) & _PAGE_RW; + } + #endif ++#ifndef pte_read + static inline int pte_read(pte_t pte) { return 1; } ++#endif + static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } + static inline int pte_special(pte_t pte) { return pte_val(pte) & _PAGE_SPECIAL; } + static inline int pte_none(pte_t pte) { return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; } +-- +2.40.1 + diff --git a/queue-5.10/series b/queue-5.10/series index 79a0d7f1fd7..cbee4ff6a84 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -59,3 +59,6 @@ pinctrl-avoid-unsafe-code-pattern-in-find_pinctrl.patch counter-microchip-tcb-capture-fix-the-use-of-internal-gclk-logic.patch usb-gadget-udc-xilinx-replace-memcpy-with-memcpy_toio.patch usb-gadget-ncm-handle-decoding-of-multiple-ntb-s-in-unwrap-call.patch +dmaengine-mediatek-fix-deadlock-caused-by-synchroniz.patch +powerpc-8xx-fix-pte_access_permitted-for-page_none.patch +powerpc-64e-fix-wrong-test-in-__ptep_test_and_clear_.patch