Re: [PATCH v4 19/24] dmaengine: dw-edma: Drain LL entries for STOP and PAUSE

[email protected] Wed, 29 Jul 2026 14:56:56 +0000
Newsgroups org.kernel.vger.dmaengine
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:
- [High] Infinite loop in dw_edma_wait_termination() leading to hung tasks =
if hardware stalls or is removed.
--

--- Patch [19]: [PATCH v4 19/24] dmaengine: dw-edma: Drain LL entries for S=
TOP and PAUSE ---
commit 7c90dd7ea15ac01e52b8a14ed044dee1a6a2bfde
Author: Koichiro Den <[email protected]>
Subject: dmaengine: dw-edma: Drain LL entries for STOP and PAUSE

This commit changes the channel termination process to wait for the
hardware to consume all published LL entries when a STOP or PAUSE is
requested, rather than discarding the ring state immediately.

> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-=
edma-core.c
> index b0e3f67d3942f..977392689205f 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c

[ ... ]

> @@ -1590,18 +1638,21 @@ static void dw_edma_wait_termination(struct dma_c=
han *dchan)
>  	 * A STOP may be deferred to a later interrupt while the channel is sti=
ll
>  	 * running. Wait until that handler completes the termination.
>  	 */
> -	while (time_before(jiffies, timeout)) {
> +	for (;;) {
>  		scoped_guard(spinlock_irqsave, &chan->vc.lock)
>  			stopping =3D chan->request =3D=3D EDMA_REQ_STOP;
> =20
>  		if (!stopping)
>  			return;
> =20
> +		if (time_after_eq(jiffies, timeout)) {
> +			dev_warn(chan->dw->chip->dev,
> +				 "timeout waiting for channel termination; still waiting\n");
> +			timeout =3D jiffies + msecs_to_jiffies(5000);
> +		}
> +
>  		fsleep(1000);
>  	}

[Severity: High]
Does this change introduce a potential infinite loop? By removing the absol=
ute
timeout and converting this to an unbounded for (;;) loop, the function will
hang forever if the hardware stalls, drops an interrupt, or is
surprise-removed.

If chan->request never transitions away from EDMA_REQ_STOP (for example, if
dw->teardown is set and no further interrupts arrive),
dmaengine_terminate_sync() will block indefinitely. This could prevent driv=
er
unbind, system suspend, or process exit.

Is there a fallback mechanism to eventually break out of this loop if the
hardware never recovers?

> -
> -	dev_warn(chan->dw->chip->dev,
> -		 "timeout waiting for channel termination\n");
>  }
> =20
>  static void dw_edma_device_synchronize(struct dma_chan *dchan)

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260729143036.3087=
[email protected]?part=3D19