[PATCH v4 03/28] dmaengine: bcm2835: Add support for per-channel flags
Frank Li
Frank.li at oss.nxp.com
Wed Dec 2 14:47:16 PST 2026
On Fri, Nov 27, 2026 at 01:21:53PM +0100, Andrea della Porta wrote:
> From: Phil Elwell <phil at raspberrypi.org>
>
> Add the ability to interpret the high bits of the dreq specifier as
> flags to be included in the DMA_CS register: the AXI priority and panic
> priority (used e.g. by the HDMI audio channels to keep the MAI FIFO fed),
> the wait for outstanding writes before signalling completion and the
> DISDEBUG flag. The original motivation for this change was the ability
> to set the DISDEBUG flag for SD card transfers to avoid corruption when
> using the VPU debugger.
>
> The flags occupy the same bits as the corresponding fields of the CS
> register, so they only need to be masked.
>
> Since the flags now affect every transfer issued on the channel, clear
> the dreq when the channel is released, so that a later user requesting
> the channel by capability (e.g. for memcpy) does not inherit the flags
> of the previous DT client.
>
> Signed-off-by: Phil Elwell <phil at raspberrypi.org>
> Co-developed-by: Andrea della Porta <andrea.porta at suse.com>
> Signed-off-by: Andrea della Porta <andrea.porta at suse.com>
> ---
Reviewed-by: Frank Li <Frank.Li at nxp.com>
> drivers/dma/bcm2835-dma.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 036a7a1727a5..5a9854a3c08e 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
> @@ -33,6 +33,8 @@
> #include <linux/of.h>
> #include <linux/of_dma.h>
>
> +#include <dt-bindings/dma/brcm,bcm2835-dma.h>
> +
> #include "virt-dma.h"
>
> #define BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED 14
> @@ -143,6 +145,15 @@ struct bcm2835_desc {
> #define BCM2835_DMA_WAIT(x) FIELD_PREP(GENMASK(25, 21), x) /* add DMA-wait cycles */
> #define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */
>
> +/*
> + * Flags of the DMA specifier to be set in the CS register, they have the
> + * same layout as the corresponding CS register fields.
> + */
> +#define BCM2835_DMA_CS_FLAGS(x) ((x) & (BCM2835_DMA_FLAG_PRIORITY(15) | \
> + BCM2835_DMA_FLAG_PANIC_PRIORITY(15) | \
> + BCM2835_DMA_FLAG_WAIT_FOR_WRITES | \
> + BCM2835_DMA_FLAG_DIS_DEBUG))
> +
> /* debug register bits */
> #define BCM2835_DMA_DEBUG_LAST_NOT_SET_ERR BIT(0)
> #define BCM2835_DMA_DEBUG_FIFO_ERR BIT(1)
> @@ -435,7 +446,8 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c)
> c->desc = to_bcm2835_dma_desc(&vd->tx);
>
> writel(c->desc->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR);
> - writel(BCM2835_DMA_ACTIVE, c->chan_base + BCM2835_DMA_CS);
> + writel(BCM2835_DMA_ACTIVE | BCM2835_DMA_CS_FLAGS(c->dreq),
> + c->chan_base + BCM2835_DMA_CS);
> }
>
> static irqreturn_t bcm2835_dma_callback(int irq, void *data)
> @@ -462,7 +474,8 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
> * if this IRQ handler is threaded.) If the channel is finished, it
> * will remain idle despite the ACTIVE flag being set.
> */
> - writel(BCM2835_DMA_INT | BCM2835_DMA_ACTIVE,
> + writel(BCM2835_DMA_INT | BCM2835_DMA_ACTIVE |
> + BCM2835_DMA_CS_FLAGS(c->dreq),
> c->chan_base + BCM2835_DMA_CS);
>
> d = c->desc;
> @@ -512,6 +525,9 @@ static void bcm2835_dma_free_chan_resources(struct dma_chan *chan)
> free_irq(c->irq_number, c);
> dma_pool_destroy(c->cb_pool);
>
> + /* do not leak the flags of a DT client to the next user */
> + c->dreq = 0;
> +
> dev_dbg(c->vc.chan.device->dev, "Freeing DMA channel %u\n", c->ch);
> }
>
> --
> 2.51.0
>
More information about the linux-arm-kernel
mailing list