Re: [PATCH v3 2/2] dmaengine: mediatek: uart: synchronize completion callbacks

From: Frank Li

Date: Tue Oct 27 2026 - 16:02:29 EST


On Tue, Oct 27, 2026 at 12:22:27PM -0600, James Hilliard wrote:
> Terminating a UART APDMA channel waits for its interrupt handler, but
> completion callbacks run in the virt-dma tasklet. A callback already
> removed from desc_completed can still be running after termination
> returns. With no device_synchronize hook, dmaengine_synchronize() does
> not wait for that callback either.
>
> Use vchan_dma_synchronize() as the UART APDMA device_synchronize callback
> so clients can wait for completion callbacks before reusing callback
> state or freeing DMA buffers. Keep the callback wait separate from
> device_terminate_all so it can run without locks acquired by the callback.
>
> Fixes: 9135408c3ace ("dmaengine: mediatek: Add MediaTek UART APDMA support")
> Suggested-by: Frank Li <Frank.li@xxxxxxxxxxx>
> Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> drivers/dma/mediatek/mtk-uart-apdma.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
> index f74e9a328588..6bc4f20d8b06 100644
> --- a/drivers/dma/mediatek/mtk-uart-apdma.c
> +++ b/drivers/dma/mediatek/mtk-uart-apdma.c
> @@ -514,6 +514,7 @@ static int mtk_uart_apdma_probe(struct platform_device *pdev)
> mtkd->ddev.device_config = mtk_uart_apdma_slave_config;
> mtkd->ddev.device_pause = mtk_uart_apdma_device_pause;
> mtkd->ddev.device_terminate_all = mtk_uart_apdma_terminate_all;
> + mtkd->ddev.device_synchronize = vchan_dma_synchronize;
> mtkd->ddev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE);
> mtkd->ddev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE);
> mtkd->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
>
> --
> 2.53.0
>