[PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort

Frank Li Frank.li at oss.nxp.com
Tue Nov 24 11:34:06 PST 2026


On Mon, Nov 23, 2026 at 03:56:43PM +0100, Andrea della Porta wrote:
> From: Dom Cobley <popcornmix at gmail.com>
>
> There is a problem with the current abort scheme
> when dma is blocked on a DREQ which prevents halting.
>
> This is triggered by SPI driver which aborts dma
> in this state and so leads to a halt timeout.
>
> We attempt to abort the channel, which will work
> if there is no blocked DREQ.

use imperative mood descript the problem

>
> It it times out, we can assume there is no AXI
> transfer in progress and reset anyway.
>
> The length of the timeout is observed at ~20us.

wrap at 75 char

>
> Signed-off-by: Dom Cobley <popcornmix at gmail.com>
> Signed-off-by: Andrea della Porta <andrea.porta at suse.com>
> ---
>  drivers/dma/bcm2835-dma.c | 32 +++++++++++++++++++++++---------
>  1 file changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 063e1b2aabe3..51e3a40dbaec 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
> @@ -419,7 +419,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
>  static void bcm2835_dma_abort(struct bcm2835_chan *c)
>  {
>  	void __iomem *chan_base = c->chan_base;
> -	long timeout = 10000;
> +	long timeout = 100;
>
>  	/*
>  	 * A zero control block address means the channel is idle.
> @@ -428,19 +428,33 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c)
>  	if (!readl(chan_base + BCM2835_DMA_ADDR))
>  		return;
>
> -	/* Write 0 to the active bit - Pause the DMA */
> -	writel(0, chan_base + BCM2835_DMA_CS);
> +	/* We need to clear the next DMA block pending */
> +	writel(0, chan_base + BCM2835_DMA_NEXTCB);
> +
> +	/* Abort the DMA, which needs to be enabled to complete */
> +	writel(readl(chan_base + BCM2835_DMA_CS) | BCM2835_DMA_ABORT | BCM2835_DMA_ACTIVE,
> +	       chan_base + BCM2835_DMA_CS);
>
> -	/* Wait for any current AXI transfer to complete */
> -	while ((readl(chan_base + BCM2835_DMA_CS) &
> -		BCM2835_DMA_WAITING_FOR_WRITES) && --timeout)
> +	/* wait for DMA to be aborted */
> +	while ((readl(chan_base + BCM2835_DMA_CS) & BCM2835_DMA_ABORT) && --timeout)
>  		cpu_relax();

use read_poll_timeout()

Frank
>
> -	/* Peripheral might be stuck and fail to signal AXI write responses */
> -	if (!timeout)
> +	/* Write 0 to the active bit - Pause the DMA */
> +	writel(readl(chan_base + BCM2835_DMA_CS) & ~BCM2835_DMA_ACTIVE,
> +	       chan_base + BCM2835_DMA_CS);
> +
> +	/*
> +	 * Peripheral might be stuck and fail to complete
> +	 * This is expected when dreqs are enabled but not asserted
> +	 * so only report error in non dreq case
> +	 */
> +	if (!timeout && !(readl(chan_base + BCM2835_DMA_TI) &
> +	   (BCM2835_DMA_S_DREQ | BCM2835_DMA_D_DREQ)))
>  		dev_err(c->vc.chan.device->dev,
> -			"failed to complete outstanding writes\n");
> +			"failed to complete pause on dma %d (CS:%08x)\n", c->ch,
> +			readl(chan_base + BCM2835_DMA_CS));
>
> +	/* Set CS back to default state and reset the DMA */
>  	writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS);
>  }
>
> --
> 2.51.0
>



More information about the linux-arm-kernel mailing list