Skip to content

Commit 288a059

Browse files
stonezdmgregkh
authored andcommitted
dmaengine: mediatek: Fix deadlock caused by synchronize_irq()
[ Upstream commit 01f1ae2 ] 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: 9135408 ("dmaengine: mediatek: Add MediaTek UART APDMA support") Signed-off-by: Duoming Zhou <[email protected]> Reviewed-by: Eugen Hristev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 17c653d commit 288a059

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/dma/mediatek/mtk-uart-apdma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,8 @@ static int mtk_uart_apdma_device_pause(struct dma_chan *chan)
451451
mtk_uart_apdma_write(c, VFF_EN, VFF_EN_CLR_B);
452452
mtk_uart_apdma_write(c, VFF_INT_EN, VFF_INT_EN_CLR_B);
453453

454-
synchronize_irq(c->irq);
455-
456454
spin_unlock_irqrestore(&c->vc.lock, flags);
455+
synchronize_irq(c->irq);
457456

458457
return 0;
459458
}

0 commit comments

Comments
 (0)