Re: [PATCH] dmaengine: mediatek: uart: clear the active descriptor on termination
From: Frank Li
Date: Tue Oct 27 2026 - 12:41:54 EST
On Thu, Oct 22, 2026 at 03:11:41PM -0600, James Hilliard wrote:
> mtk_uart_apdma_issue_pending() keeps the active descriptor in desc_issued
> and stores an alias in c->desc. Terminating the channel collects and frees
> that list, but leaves c->desc pointing at the retired descriptor unless
> the completion interrupt has already cleared it.
>
> The next issue_pending() requires c->desc to be NULL before starting a
> transfer. Canceling an active transfer can therefore leave the channel
> unable to start subsequent transfers, even after synchronization.
>
> Clear c->desc under the virtual-channel lock when collecting the terminated
> descriptors, after the existing interrupt shutdown and synchronization.
>
> Fixes: 2537b40b0a4f ("dmaengine: mediatek: do not issue a new desc if one is still current")
> Cc: stable@xxxxxxxxxxxxxxx
> 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..d9427d56bc50 100644
> --- a/drivers/dma/mediatek/mtk-uart-apdma.c
> +++ b/drivers/dma/mediatek/mtk-uart-apdma.c
> @@ -433,6 +433,7 @@ static int mtk_uart_apdma_terminate_all(struct dma_chan *chan)
>
> spin_lock_irqsave(&c->vc.lock, flags);
> vchan_get_all_descriptors(&c->vc, &head);
> + c->desc = NULL;
> spin_unlock_irqrestore(&c->vc.lock, flags);
>
> vchan_dma_desc_free_list(&c->vc, &head);
>
> ---
> base-commit: 93f51579e7df248780214094418f205253383cc5
> change-id: 20261022-submit-mtk-uart-dma-retire-v1-fe71753c51ff
>
> Best regards,
> --
> James Hilliard <james.hilliard1@xxxxxxxxx>
>