* [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support
@ 2026-11-23 14:56 Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo Andrea della Porta
` (27 more replies)
0 siblings, 28 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, David Airlie, dri-devel,
Jaroslav Kysela, Liam Girdwood, linux-mmc, linux-sound, linux-spi,
Maarten Lankhorst, Maíra Canal, Mark Brown,
Raspberry Pi Kernel Maintenance, Simona Vetter, Takashi Iwai,
Thomas Zimmermann, Ulf Hansson
The BCM2711 has 4 DMA channels with a 40-bit address range, allowing them
to access the whole memory of a Pi 4, and the BCM2712 has 6 of them. This
series adds support for them to the bcm2835-dma driver, on top of the
platform abstraction from Stefan Wahren and some features from the
downstream Raspberry Pi kernel.
The main change since v2 is the handling of the slave (peripheral)
addresses, as requested in the v1/v2 discussions [1][2][3]: instead of
hardcoding the 0x4_0000_0000 offset of the 40-bit channels and relying on
clients passing pre-translated VideoCore bus addresses, the clients now
pass CPU physical addresses and the DMA driver translates them with
dma_map_resource(). Since the conversion of dma_map_resource() to
dma_map_phys() with DMA_ATTR_MMIO, the dma-direct implementation honours
the dma-ranges of the device, which was the open question raised by
Robin in [1].
To keep old device trees working (they only describe the RAM in
dma-ranges), the driver detects at probe time whether the peripheral
window is described in dma-ranges, by looking up its own registers, and
otherwise falls back to reverting the translation given by the ranges of
the parent bus, as suggested by Dave in [3]. Addresses outside of the
ranges are passed through, so that out of tree clients still providing
bus addresses keep working with old device trees. The same fallback
works for the BCM2712 40-bit channels, whose bus maps the peripherals
1:1, while the BCM2711 40-bit channels see the peripherals 16 GiB above
their VideoCore bus address, which cannot be derived from the ranges:
they require dma-ranges, which all the device trees describing them
(the downstream ones and the one added here) provide.
Structure of the series:
1-5: preparatory patches and features from downstream (per-channel
flags, wide accesses, bursts, abort fixes)
6-7: generic dma-channel-mask property
8-13: hardware abstraction (Stefan Wahren)
14-19: slave address translation with dma_map_resource(), conversion
of the clients (spi, mmc, ASoC, vc4 HDMI) and dma-ranges
20-23: BCM2711 40-bit channels
24-26: BCM2712 40-bit channels
27: DMA flags for the HDMI audio of BCM283x
28: HDMI audio on BCM2712 through the 40-bit channels
Changes in v3:
- Drop the hardcoded addr_offset, translate slave addresses with
dma_map_resource() in device_config() and unmap them on
reconfiguration and when freeing the channel.
- Convert spi-bcm2835, mmc/bcm2835, bcm2835-i2s and vc4_hdmi to provide
CPU physical addresses, and describe the peripheral window in the
dma-ranges of the BCM283x/BCM2711 soc bus.
- Put the BCM2711 40-bit controller in its own bus, whose dma-ranges map
the peripherals at 0x4_7c000000, instead of the scb bus, to not change
the DMA configuration of PCIe and GENET and to avoid refactoring the
entire DTS to fit the cell size.
- Fix the abort sequences, which were swapped between the legacy and the
40-bit channels, breaking terminate_all on all the Raspberry Pis.
- Fix the interrupt acknowledge of the 40-bit channels, which used the
INTEN bit of the TI register instead of the INT bit of CS.
- Make the abort sequence a platform callback, drop the CS/TI masks only
used by it.
- Keep the period handling of bcm2835_dma_create_cb_set_length(), which
v2 changed to flag every control block of cyclic transfers.
- Use the platform cb_append_extra() callback for every control block,
and convert every control block address with to_cb_addr().
- Preserve the width and burst settings of SRCI/DESTI when setting the
addresses of slave_sg transfers.
- Fix the argument order of cb_init() in the patch introducing it, to
keep the series bisectable.
- Fix the free_irq() cookie, which did not match the request_irq() one.
- Derive the first channel of an instance from the physical register
address instead of the ioremap()ed one, initialize all the IRQ array
entries, and split this into its own patch.
- Refuse to probe the 40-bit channels if dma_addr_t is 32-bit wide, and
avoid shifting dma_addr_t by 32 bits.
- Include linux/bitfield.h, fixing COMPILE_TEST builds.
- Drop the unused bcm2835_dma_count_frames_for_sg(), resurrected by a
rebase, and the dead code and duplicated defines of the 40-bit patch.
- Split out the style changes from the 40-bit patch (Stefan), reword the
subject of the first patch (Florian).
- dt-bindings: sort the compatibles (Krzysztof), document the flags in
the DREQ cell (Stefan), allow the generic dma-channel-mask, constrain
the interrupts of the new compatibles. The Acked-by of v2 has been
dropped because of the additional changes.
- Use the generic dma-channel-mask in the new nodes (Krzysztof).
- Use the DMA specifier flags for the HDMI audio channels of BCM283x,
so that patches 2-4 have in-tree users (Stefan)
- Describe in the platform data which channels of the DMA block use its
programming model and ignore the others, so that nodes describing
channels with another model under the same compatible (as the
downstream BCM2712 device tree does) are not driven with the wrong one.
- Add BCM2712 support.
Backward compatibility with installed device trees:
- Upstream device trees without the peripheral window in dma-ranges keep
working through the ranges fallback, which yields the same bus
addresses the clients used to provide.
- Downstream Raspberry Pi device trees already describe the peripheral
window in dma-ranges (for both the soc and scb buses), and their
40-bit controllers are handled through dma_map_resource().
- The node of the downstream BCM2712 device tree describing channels 0-5
is rejected instead of being driven with the wrong programming model.
- The current upstream device trees do not describe any 40-bit DMA
controller, so the new compatibles have no legacy to support. A
brcm,bcm2711-dma node without dma-ranges makes the probe fail instead
of programming wrong addresses.
- Older kernels booted with the new device trees are not affected: the
extra dma-ranges entries do not change the DMA limits of the existing
devices and the new nodes use compatibles unknown to them.
Not supported yet: No device tree consumer is converted to the 40-bit
channels either.
This patchset has been tested on Rpi3/4/5 with both downstream and
upstream DTBs. The upstream DTBs have been customized to allow for several
peripherals (SPI, I2S, HDMI audio, mem2mem) to be tested against dma40,
an example of which can be found in patch 28.
Future patches will convert said consumer nodes to use the new dma
controller.
This version has been prepared with the help of an AI coding assistant
(Claude Opus 5.5).
[1] https://lore.kernel.org/linux-arm-kernel/ee19a95d-fe1e-4f3f-bc81-bdef38475469@arm.com/
[2] https://lore.kernel.org/all/CAPY8ntCcz7ysTq_78Rb8ohLLETTYZeoZ3DXdPFvDLAkPc9jPWw@mail.gmail.com/
[3] https://lore.kernel.org/all/CAPY8ntByJYzSv0kTAc1kY0Dp=vwrzcA0oWiPpyg7x7_BQwGSnA@mail.gmail.com/
Previous versions:
v2: https://lore.kernel.org/all/cover.1710226514.git.andrea.porta@suse.com/
v1: https://lore.kernel.org/linux-arm-kernel/cover.1706948717.git.andrea.porta@suse.com/
Andrea della Porta (24):
dmaengine: bcm2835: Fix coding style issues and a typo
dt-bindings: dma: brcm,bcm2835-dma: Document dma-channel-mask and DREQ
flags
dmaengine: bcm2835: Support common dma-channel-mask
dmaengine: bcm2835: move CB info generation into separate function
dmaengine: bcm2835: move CB final extra info generation into function
dmaengine: bcm2835: make address increment platform independent
dmaengine: bcm2835: drop info parameters
dmaengine: bcm2835: pass dma_chan to generic functions
dmaengine: bcm2835: introduce multi platform support
dmaengine: bcm2835: Use dma_map_resource() to translate slave
addresses
spi: bcm2835: Pass the CPU physical address of the FIFO to the DMA
engine
mmc: bcm2835: Pass the CPU physical address of SDDATA to the DMA
engine
ASoC: bcm2835-i2s: Pass the CPU physical address of the FIFO to the
DMA engine
drm/vc4: hdmi: Pass the CPU physical address of MAI_DATA to the DMA
engine
ARM: dts: broadcom: Describe the peripheral window in dma-ranges
dmaengine: bcm2835: Support channel subsets in a controller instance
dt-bindings: dma: brcm,bcm2835-dma: Add BCM2711 40-bit DMA
dmaengine: bcm2835: Add BCM2711 40-bit DMA support
ARM: dts: bcm2711: Add the 40-bit DMA controller
dt-bindings: dma: brcm,bcm2835-dma: Add BCM2712 40-bit DMA
dmaengine: bcm2835: Add BCM2712 40-bit DMA support
arm64: dts: broadcom: bcm2712: Add the 40-bit DMA controller
ARM: dts: broadcom: Set the DMA flags of the HDMI audio channel on
BCM283x
arm64: dts: broadcom: bcm2712: Enable HDMI audio
Dom Cobley (2):
dmaengine: bcm2835: Support dma flags for multi-beat burst
dmaengine: bcm2835: Fixes for dma_abort
Phil Elwell (2):
dmaengine: bcm2835: Add support for per-channel flags
dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and
DMA_WIDE_DEST flag
.../bindings/dma/brcm,bcm2835-dma.yaml | 88 +-
arch/arm/boot/dts/broadcom/bcm2711.dtsi | 40 +-
.../arm/boot/dts/broadcom/bcm2835-common.dtsi | 3 +-
arch/arm/boot/dts/broadcom/bcm2835.dtsi | 3 +-
arch/arm/boot/dts/broadcom/bcm2836.dtsi | 3 +-
arch/arm/boot/dts/broadcom/bcm2837.dtsi | 3 +-
.../boot/dts/broadcom/bcm2712-d-rpi-5-b.dts | 9 +
arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 26 +
drivers/dma/bcm2835-dma.c | 1229 ++++++++++++++---
drivers/gpu/drm/vc4/vc4_hdmi.c | 16 +-
drivers/mmc/host/bcm2835.c | 20 +-
drivers/spi/spi-bcm2835.c | 27 +-
sound/soc/bcm/bcm2835-i2s.c | 19 +-
13 files changed, 1229 insertions(+), 257 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 15:05 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 02/28] dmaengine: bcm2835: Add support for per-channel flags Andrea della Porta
` (26 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
Fix the coding style issues reported by checkpatch: use u32 instead of
uint32_t, add the missing parentheses around macro arguments, which
could lead to operator precedence issues, drop superfluous parentheses
and long int, and align the function arguments. Also fix a typo in a
comment ('missmatch').
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 83 ++++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 41 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 06d830d36882..b19182c6e3df 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -51,13 +51,13 @@ struct bcm2835_dmadev {
};
struct bcm2835_dma_cb {
- uint32_t info;
- uint32_t src;
- uint32_t dst;
- uint32_t length;
- uint32_t stride;
- uint32_t next;
- uint32_t pad[2];
+ u32 info;
+ u32 src;
+ u32 dst;
+ u32 length;
+ u32 stride;
+ u32 next;
+ u32 pad[2];
};
struct bcm2835_cb_entry {
@@ -116,8 +116,8 @@ struct bcm2835_desc {
* AXI-write to ack
*/
#define BCM2835_DMA_ERR BIT(8)
-#define BCM2835_DMA_PRIORITY(x) ((x & 15) << 16) /* AXI priority */
-#define BCM2835_DMA_PANIC_PRIORITY(x) ((x & 15) << 20) /* panic priority */
+#define BCM2835_DMA_PRIORITY(x) (((x) & 15) << 16) /* AXI priority */
+#define BCM2835_DMA_PANIC_PRIORITY(x) (((x) & 15) << 20) /* panic priority */
/* current value of TI.BCM2835_DMA_WAIT_RESP */
#define BCM2835_DMA_WAIT_FOR_WRITES BIT(28)
#define BCM2835_DMA_DIS_DEBUG BIT(29) /* disable debug pause signal */
@@ -136,9 +136,9 @@ struct bcm2835_desc {
#define BCM2835_DMA_S_WIDTH BIT(9) /* 128bit writes if set */
#define BCM2835_DMA_S_DREQ BIT(10) /* enable SREQ for source */
#define BCM2835_DMA_S_IGNORE BIT(11) /* ignore source reads - read 0 */
-#define BCM2835_DMA_BURST_LENGTH(x) ((x & 15) << 12)
-#define BCM2835_DMA_PER_MAP(x) ((x & 31) << 16) /* REQ source */
-#define BCM2835_DMA_WAIT(x) ((x & 31) << 21) /* add DMA-wait cycles */
+#define BCM2835_DMA_BURST_LENGTH(x) (((x) & 15) << 12)
+#define BCM2835_DMA_PER_MAP(x) (((x) & 31) << 16) /* REQ source */
+#define BCM2835_DMA_WAIT(x) (((x) & 31) << 21) /* add DMA-wait cycles */
#define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */
/* debug register bits */
@@ -214,17 +214,15 @@ static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
static void bcm2835_dma_desc_free(struct virt_dma_desc *vd)
{
- bcm2835_dma_free_cb_chain(
- container_of(vd, struct bcm2835_desc, vd));
+ bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd));
}
-static void bcm2835_dma_create_cb_set_length(
- struct bcm2835_chan *chan,
- struct bcm2835_dma_cb *control_block,
- size_t len,
- size_t period_len,
- size_t *total_len,
- u32 finalextrainfo)
+static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
+ struct bcm2835_dma_cb *control_block,
+ size_t len,
+ size_t period_len,
+ size_t *total_len,
+ u32 finalextrainfo)
{
size_t max_len = bcm2835_dma_max_frame_length(chan);
@@ -281,10 +279,13 @@ static void bcm2835_dma_create_cb_set_length(
* @gfp: the GFP flag to use for allocation
*/
static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
- struct dma_chan *chan, enum dma_transfer_direction direction,
- bool cyclic, u32 info, u32 finalextrainfo, size_t frames,
- dma_addr_t src, dma_addr_t dst, size_t buf_len,
- size_t period_len, gfp_t gfp)
+ struct dma_chan *chan,
+ enum dma_transfer_direction direction,
+ bool cyclic, u32 info,
+ u32 finalextrainfo,
+ size_t frames, dma_addr_t src,
+ dma_addr_t dst, size_t buf_len,
+ size_t period_len, gfp_t gfp)
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
size_t len = buf_len, total_len;
@@ -326,10 +327,10 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
/* set up length in control_block if requested */
if (buf_len) {
/* calculate length honoring period_length */
- bcm2835_dma_create_cb_set_length(
- c, control_block,
- len, period_len, &total_len,
- cyclic ? finalextrainfo : 0);
+ bcm2835_dma_create_cb_set_length(c, control_block,
+ len, period_len,
+ &total_len,
+ cyclic ? finalextrainfo : 0);
/* calculate new remaining length */
len -= control_block->length;
@@ -353,7 +354,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
d->cb_list[d->frames - 1].cb->info |= finalextrainfo;
/* detect a size mismatch */
- if (buf_len && (d->size != buf_len))
+ if (buf_len && d->size != buf_len)
goto error_cb;
return d;
@@ -393,7 +394,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 int timeout = 10000;
+ long timeout = 10000;
/*
* A zero control block address means the channel is idle.
@@ -421,7 +422,6 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c)
static void bcm2835_dma_start_desc(struct bcm2835_chan *c)
{
struct virt_dma_desc *vd = vchan_next_desc(&c->vc);
- struct bcm2835_desc *d;
if (!vd) {
c->desc = NULL;
@@ -430,9 +430,9 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c)
list_del(&vd->node);
- c->desc = d = to_bcm2835_dma_desc(&vd->tx);
+ c->desc = to_bcm2835_dma_desc(&vd->tx);
- writel(d->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR);
+ writel(c->desc->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR);
writel(BCM2835_DMA_ACTIVE, c->chan_base + BCM2835_DMA_CS);
}
@@ -543,7 +543,8 @@ static size_t bcm2835_dma_desc_size_pos(struct bcm2835_desc *d, dma_addr_t addr)
}
static enum dma_status bcm2835_dma_tx_status(struct dma_chan *chan,
- dma_cookie_t cookie, struct dma_tx_state *txstate)
+ dma_cookie_t cookie,
+ struct dma_tx_state *txstate)
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct virt_dma_desc *vd;
@@ -843,7 +844,7 @@ static const struct of_device_id bcm2835_dma_of_match[] = {
MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match);
static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec,
- struct of_dma *ofdma)
+ struct of_dma *ofdma)
{
struct bcm2835_dmadev *d = ofdma->of_dma_data;
struct dma_chan *chan;
@@ -887,7 +888,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
int i, j;
int irq[BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED + 1];
int irq_flags;
- uint32_t chans_available;
+ u32 chans_available;
char chan_name[BCM2835_DMA_CHAN_NAME_SIZE];
if (!pdev->dev.dma_mask)
@@ -946,8 +947,8 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
/* Request DMA channel mask from device tree */
if (of_property_read_u32(pdev->dev.of_node,
- "brcm,dma-channel-mask",
- &chans_available)) {
+ "brcm,dma-channel-mask",
+ &chans_available)) {
dev_err(&pdev->dev, "Failed to get channel mask\n");
rc = -EINVAL;
goto err_no_dma;
@@ -986,7 +987,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
/* check if there are other channels that also use this irq */
irq_flags = 0;
for (j = 0; j <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; j++)
- if ((i != j) && (irq[j] == irq[i])) {
+ if (i != j && irq[j] == irq[i]) {
irq_flags = IRQF_SHARED;
break;
}
@@ -1001,7 +1002,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
/* Device-tree DMA controller registration */
rc = of_dma_controller_register(pdev->dev.of_node,
- bcm2835_dma_xlate, od);
+ bcm2835_dma_xlate, od);
if (rc) {
dev_err(&pdev->dev, "Failed to register DMA controller\n");
goto err_no_dma;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 02/28] dmaengine: bcm2835: Add support for per-channel flags
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 03/28] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag Andrea della Porta
` (25 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
From: Phil Elwell <phil@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 motivation for this
change is the ability to set the DISDEBUG flag for SD card transfers
to avoid corruption when using the VPU debugger.
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index b19182c6e3df..690f5ba1c439 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -137,6 +137,10 @@ struct bcm2835_desc {
#define BCM2835_DMA_S_DREQ BIT(10) /* enable SREQ for source */
#define BCM2835_DMA_S_IGNORE BIT(11) /* ignore source reads - read 0 */
#define BCM2835_DMA_BURST_LENGTH(x) (((x) & 15) << 12)
+#define BCM2835_DMA_CS_FLAGS(x) ((x) & (BCM2835_DMA_PRIORITY(15) | \
+ BCM2835_DMA_PANIC_PRIORITY(15) | \
+ BCM2835_DMA_WAIT_FOR_WRITES | \
+ BCM2835_DMA_DIS_DEBUG))
#define BCM2835_DMA_PER_MAP(x) (((x) & 31) << 16) /* REQ source */
#define BCM2835_DMA_WAIT(x) (((x) & 31) << 21) /* add DMA-wait cycles */
#define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */
@@ -433,7 +437,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)
@@ -460,7 +465,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;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 03/28] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 02/28] dmaengine: bcm2835: Add support for per-channel flags Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 15:09 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 04/28] dmaengine: bcm2835: Support dma flags for multi-beat burst Andrea della Porta
` (24 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
From: Phil Elwell <phil@raspberrypi.com>
Use bit 27 of the dreq value (the second cell of the DT DMA descriptor)
to request that the WAIT_RESP bit is not set.
Use (reserved) bits 24 and 25 of the dreq value
(the second cell of the DT DMA descriptor) to request
that wide source reads or wide dest writes are required
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Co-developed-by: Andrea della Porta <andrea.porta@suse.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 690f5ba1c439..118ba2f71dc8 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -145,6 +145,21 @@ struct bcm2835_desc {
#define BCM2835_DMA_WAIT(x) (((x) & 31) << 21) /* add DMA-wait cycles */
#define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */
+/* A fake bit to request that the driver doesn't set the WAIT_RESP bit. */
+#define BCM2835_DMA_NO_WAIT_RESP BIT(27)
+#define WAIT_RESP(x) (((x) & BCM2835_DMA_NO_WAIT_RESP) ? \
+ 0 : BCM2835_DMA_WAIT_RESP)
+
+/* A fake bit to request that the driver requires wide reads */
+#define BCM2835_DMA_WIDE_SOURCE BIT(24)
+#define WIDE_SOURCE(x) (((x) & BCM2835_DMA_WIDE_SOURCE) ? \
+ BCM2835_DMA_S_WIDTH : 0)
+
+/* A fake bit to request that the driver requires wide writes */
+#define BCM2835_DMA_WIDE_DEST BIT(25)
+#define WIDE_DEST(x) (((x) & BCM2835_DMA_WIDE_DEST) ? \
+ BCM2835_DMA_D_WIDTH : 0)
+
/* debug register bits */
#define BCM2835_DMA_DEBUG_LAST_NOT_SET_ERR BIT(0)
#define BCM2835_DMA_DEBUG_FIFO_ERR BIT(1)
@@ -605,8 +620,9 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
- u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC;
- u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP;
+ u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC |
+ WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
+ u32 extra = BCM2835_DMA_INT_EN;
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -636,7 +652,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src = 0, dst = 0;
- u32 info = BCM2835_DMA_WAIT_RESP;
+ u32 info = WAIT_RESP(c->dreq) |
+ WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
u32 extra = BCM2835_DMA_INT_EN;
size_t frames;
@@ -688,7 +705,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src, dst;
- u32 info = BCM2835_DMA_WAIT_RESP;
+ u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
u32 extra = 0;
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 04/28] dmaengine: bcm2835: Support dma flags for multi-beat burst
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (2 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 03/28] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort Andrea della Porta
` (23 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
From: Dom Cobley <popcornmix@gmail.com>
Add a control bit to enable a multi-beat burst on a DMA.
This improves DMA performance and is required for HDMI audio.
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 118ba2f71dc8..063e1b2aabe3 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -137,6 +137,7 @@ struct bcm2835_desc {
#define BCM2835_DMA_S_DREQ BIT(10) /* enable SREQ for source */
#define BCM2835_DMA_S_IGNORE BIT(11) /* ignore source reads - read 0 */
#define BCM2835_DMA_BURST_LENGTH(x) (((x) & 15) << 12)
+#define BCM2835_DMA_GET_BURST_LENGTH(x) (((x) >> 12) & 15)
#define BCM2835_DMA_CS_FLAGS(x) ((x) & (BCM2835_DMA_PRIORITY(15) | \
BCM2835_DMA_PANIC_PRIORITY(15) | \
BCM2835_DMA_WAIT_FOR_WRITES | \
@@ -160,6 +161,11 @@ struct bcm2835_desc {
#define WIDE_DEST(x) (((x) & BCM2835_DMA_WIDE_DEST) ? \
BCM2835_DMA_D_WIDTH : 0)
+/* A fake bit to request that the driver requires multi-beat burst */
+#define BCM2835_DMA_BURST BIT(30)
+#define BURST_LENGTH(x) (((x) & BCM2835_DMA_BURST) ? \
+ BCM2835_DMA_BURST_LENGTH(3) : 0)
+
/* debug register bits */
#define BCM2835_DMA_DEBUG_LAST_NOT_SET_ERR BIT(0)
#define BCM2835_DMA_DEBUG_FIFO_ERR BIT(1)
@@ -621,7 +627,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC |
- WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
+ WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
+ WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
u32 extra = BCM2835_DMA_INT_EN;
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -652,8 +659,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src = 0, dst = 0;
- u32 info = WAIT_RESP(c->dreq) |
- WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
+ u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
+ WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
u32 extra = BCM2835_DMA_INT_EN;
size_t frames;
@@ -705,7 +712,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src, dst;
- u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
+ u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
+ WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
u32 extra = 0;
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (3 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 04/28] dmaengine: bcm2835: Support dma flags for multi-beat burst Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 15:08 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 06/28] dt-bindings: dma: brcm,bcm2835-dma: Document dma-channel-mask and DREQ flags Andrea della Porta
` (22 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
From: Dom Cobley <popcornmix@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.
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.
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Andrea della Porta <andrea.porta@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();
- /* 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
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 06/28] dt-bindings: dma: brcm,bcm2835-dma: Document dma-channel-mask and DREQ flags
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (4 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 07/28] dmaengine: bcm2835: Support common dma-channel-mask Andrea della Porta
` (21 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
The available channels are currently described by the vendor specific
brcm,dma-channel-mask property, while the generic dma-channel-mask
property from dma-common.yaml carries exactly the same information.
Allow the generic property and mark the vendor one as deprecated,
requiring at least one of them, so that device trees can provide both
for compatibility with older kernels.
The single specifier cell is also not limited to the DREQ number: the
driver interprets some of the upper bits as per-channel flags (AXI
priorities, wide accesses, burst and write-response handling). Document
the meaning of those bits.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
.../bindings/dma/brcm,bcm2835-dma.yaml | 26 ++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
index c9b9a5490826..f619e395cf0d 100644
--- a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
+++ b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
@@ -37,15 +37,30 @@ properties:
maxItems: 16
'#dma-cells':
- description: The single cell represents the DREQ number.
+ description: |
+ The single cell contains the DREQ number in bits 0-4, optionally
+ combined with the following per-channel flags:
+ bits 16-19: AXI priority
+ bits 20-23: AXI panic priority
+ bit 24: use wide (128-bit) source reads
+ bit 25: use wide (128-bit) destination writes
+ bit 27: do not wait for AXI write responses
+ bit 28: wait for outstanding writes before signalling completion
+ bit 29: do not pause the channel when the debug signal is asserted
+ bit 30: use multi-beat bursts
const: 1
+ dma-channel-mask:
+ maxItems: 1
+
brcm,dma-channel-mask:
$ref: /schemas/types.yaml#/definitions/uint32
+ deprecated: true
description:
Bitmask of available DMA channels in ascending order that are
not reserved by firmware and are available to the
kernel. i.e. first channel corresponds to LSB.
+ Use the generic dma-channel-mask property instead.
unevaluatedProperties: false
@@ -54,7 +69,12 @@ required:
- reg
- interrupts
- "#dma-cells"
- - brcm,dma-channel-mask
+
+anyOf:
+ - required:
+ - dma-channel-mask
+ - required:
+ - brcm,dma-channel-mask
examples:
- |
@@ -96,7 +116,7 @@ examples:
"dma14",
"dma-shared-all";
#dma-cells = <1>;
- brcm,dma-channel-mask = <0x7f35>;
+ dma-channel-mask = <0x7f35>;
};
...
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 07/28] dmaengine: bcm2835: Support common dma-channel-mask
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (5 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 06/28] dt-bindings: dma: brcm,bcm2835-dma: Document dma-channel-mask and DREQ flags Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 08/28] dmaengine: bcm2835: move CB info generation into separate function Andrea della Porta
` (20 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
Nowadays there is a generic property for dma-channel-mask in the DMA
controller binding. So prefer this one instead of the old vendor specific
one. Print a warning in case the old one is used. Btw use the result of
of_property_read_u32() as return code in error case.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 51e3a40dbaec..1087157fb242 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -991,12 +991,19 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
}
/* Request DMA channel mask from device tree */
- if (of_property_read_u32(pdev->dev.of_node,
- "brcm,dma-channel-mask",
- &chans_available)) {
- dev_err(&pdev->dev, "Failed to get channel mask\n");
- rc = -EINVAL;
- goto err_no_dma;
+ rc = of_property_read_u32(pdev->dev.of_node, "dma-channel-mask",
+ &chans_available);
+
+ if (rc) {
+ /* Try deprecated property */
+ if (of_property_read_u32(pdev->dev.of_node,
+ "brcm,dma-channel-mask",
+ &chans_available)) {
+ dev_err(&pdev->dev, "Failed to get channel mask\n");
+ goto err_no_dma;
+ }
+
+ dev_warn(&pdev->dev, "Please update DT blob\n");
}
/* get irqs for each channel that we support */
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 08/28] dmaengine: bcm2835: move CB info generation into separate function
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (6 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 07/28] dmaengine: bcm2835: Support common dma-channel-mask Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 09/28] dmaengine: bcm2835: move CB final extra info generation into function Andrea della Porta
` (19 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
Actually the generation of the Control Block info follows some simple
rules. So handle this with a separate function to avoid open coding
for every DMA operation. Another advantage is that we can easier
introduce other platforms with different info bits.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 53 +++++++++++++++++++++++----------------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 1087157fb242..adf3508246ec 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -226,6 +226,33 @@ static inline struct bcm2835_desc *to_bcm2835_dma_desc(
return container_of(t, struct bcm2835_desc, vd.tx);
}
+static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c,
+ enum dma_transfer_direction direction,
+ bool zero_page)
+{
+ u32 result = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
+ WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
+
+ if (direction == DMA_MEM_TO_MEM)
+ return result | BCM2835_DMA_D_INC | BCM2835_DMA_S_INC;
+
+ /* Setup DREQ channel */
+ if (c->dreq != 0)
+ result |= BCM2835_DMA_PER_MAP(c->dreq);
+
+ if (direction == DMA_DEV_TO_MEM) {
+ result |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
+ } else {
+ result |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
+
+ /* non-lite channels can write zeroes w/o accessing memory */
+ if (zero_page && !c->is_lite_channel)
+ result |= BCM2835_DMA_S_IGNORE;
+ }
+
+ return result;
+}
+
static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
{
size_t i;
@@ -640,9 +667,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
- u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC |
- WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
- WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
+ u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false);
u32 extra = BCM2835_DMA_INT_EN;
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -673,8 +698,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src = 0, dst = 0;
- u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
- WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
+ u32 info = bcm2835_dma_prepare_cb_info(c, direction, false);
u32 extra = BCM2835_DMA_INT_EN;
size_t frames;
@@ -684,19 +708,14 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
return NULL;
}
- if (c->dreq != 0)
- info |= BCM2835_DMA_PER_MAP(c->dreq);
-
if (direction == DMA_DEV_TO_MEM) {
if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
src = c->cfg.src_addr;
- info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
} else {
if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
dst = c->cfg.dst_addr;
- info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
}
/* count frames in sg list */
@@ -726,8 +745,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src, dst;
- u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) |
- WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq);
+ u32 info = bcm2835_dma_prepare_cb_info(c, direction,
+ buf_addr == od->zero_page);
u32 extra = 0;
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -758,26 +777,16 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
"%s: buffer_length (%zd) is not a multiple of period_len (%zd)\n",
__func__, buf_len, period_len);
- /* Setup DREQ channel */
- if (c->dreq != 0)
- info |= BCM2835_DMA_PER_MAP(c->dreq);
-
if (direction == DMA_DEV_TO_MEM) {
if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
src = c->cfg.src_addr;
dst = buf_addr;
- info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
} else {
if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
dst = c->cfg.dst_addr;
src = buf_addr;
- info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
-
- /* non-lite channels can write zeroes w/o accessing memory */
- if (buf_addr == od->zero_page && !c->is_lite_channel)
- info |= BCM2835_DMA_S_IGNORE;
}
/* calculate number of frames */
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 09/28] dmaengine: bcm2835: move CB final extra info generation into function
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (7 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 08/28] dmaengine: bcm2835: move CB info generation into separate function Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 15:01 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 10/28] dmaengine: bcm2835: make address increment platform independent Andrea della Porta
` (18 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
Similar to the info generation, generate the final extra info with a
separate function. This is necessary to introduce other platforms
with different info bits.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index adf3508246ec..77b3e2f58ac5 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -253,6 +253,26 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c,
return result;
}
+static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c,
+ enum dma_transfer_direction direction,
+ bool cyclic, bool final,
+ unsigned long flags)
+{
+ u32 result = 0;
+
+ if (cyclic) {
+ if (flags & DMA_PREP_INTERRUPT)
+ result |= BCM2835_DMA_INT_EN;
+ } else {
+ if (!final)
+ return 0;
+
+ result |= BCM2835_DMA_INT_EN;
+ }
+
+ return result;
+}
+
static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
{
size_t i;
@@ -668,7 +688,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false);
- u32 extra = BCM2835_DMA_INT_EN;
+ u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false,
+ true, 0);
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -699,7 +720,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
struct bcm2835_desc *d;
dma_addr_t src = 0, dst = 0;
u32 info = bcm2835_dma_prepare_cb_info(c, direction, false);
- u32 extra = BCM2835_DMA_INT_EN;
+ u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0);
size_t frames;
if (!is_slave_direction(direction)) {
@@ -747,7 +768,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
dma_addr_t src, dst;
u32 info = bcm2835_dma_prepare_cb_info(c, direction,
buf_addr == od->zero_page);
- u32 extra = 0;
+ u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0);
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -763,9 +784,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
return NULL;
}
- if (flags & DMA_PREP_INTERRUPT)
- extra |= BCM2835_DMA_INT_EN;
- else
+ if (!(flags & DMA_PREP_INTERRUPT))
period_len = buf_len;
/*
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 10/28] dmaengine: bcm2835: make address increment platform independent
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (8 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 09/28] dmaengine: bcm2835: move CB final extra info generation into function Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 11/28] dmaengine: bcm2835: drop info parameters Andrea della Porta
` (17 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
Actually the criteria to increment source & destination address isn't
based on platform specific bits. It's just the DMA transfer direction which
is translated into the info bits. So introduce two new helper functions
and get the rid of these platform specifics.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 77b3e2f58ac5..6180a2737e07 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -273,6 +273,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c,
return result;
}
+static inline bool need_src_incr(enum dma_transfer_direction direction)
+{
+ return direction != DMA_DEV_TO_MEM;
+}
+
+static inline bool need_dst_incr(enum dma_transfer_direction direction)
+{
+ switch (direction) {
+ case DMA_MEM_TO_MEM:
+ case DMA_DEV_TO_MEM:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
{
size_t i;
@@ -338,10 +356,8 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
* @cyclic: it is a cyclic transfer
* @info: the default info bits to apply per controlblock
* @frames: number of controlblocks to allocate
- * @src: the src address to assign (if the S_INC bit is set
- * in @info, then it gets incremented)
- * @dst: the dst address to assign (if the D_INC bit is set
- * in @info, then it gets incremented)
+ * @src: the src address to assign
+ * @dst: the dst address to assign
* @buf_len: the full buffer length (may also be 0)
* @period_len: the period length when to apply @finalextrainfo
* in addition to the last transfer
@@ -413,9 +429,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
d->cb_list[frame - 1].cb->next = cb_entry->paddr;
/* update src and dst and length */
- if (src && (info & BCM2835_DMA_S_INC))
+ if (src && need_src_incr(direction))
src += control_block->length;
- if (dst && (info & BCM2835_DMA_D_INC))
+ if (dst && need_dst_incr(direction))
dst += control_block->length;
/* Length of total transfer */
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 11/28] dmaengine: bcm2835: drop info parameters
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (9 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 10/28] dmaengine: bcm2835: make address increment platform independent Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 12/28] dmaengine: bcm2835: pass dma_chan to generic functions Andrea della Porta
` (16 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
The parameters info and finalextrainfo are platform specific. So drop
them by generating them within bcm2835_dma_create_cb_chain().
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 80 +++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 41 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 6180a2737e07..1d322cad4ca3 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -307,12 +307,11 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd)
bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd));
}
-static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
+static bool bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
struct bcm2835_dma_cb *control_block,
size_t len,
size_t period_len,
- size_t *total_len,
- u32 finalextrainfo)
+ size_t *total_len)
{
size_t max_len = bcm2835_dma_max_frame_length(chan);
@@ -321,7 +320,7 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
/* finished if we have no period_length */
if (!period_len)
- return;
+ return false;
/*
* period_len means: that we need to generate
@@ -335,7 +334,7 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
if (*total_len + control_block->length < period_len) {
/* update number of bytes in this period so far */
*total_len += control_block->length;
- return;
+ return false;
}
/* calculate the length that remains to reach period_length */
@@ -344,8 +343,7 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
/* reset total_length for next period */
*total_len = 0;
- /* add extrainfo bits in info */
- control_block->info |= finalextrainfo;
+ return true;
}
/**
@@ -354,7 +352,6 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
* @chan: the @dma_chan for which we run this
* @direction: the direction in which we transfer
* @cyclic: it is a cyclic transfer
- * @info: the default info bits to apply per controlblock
* @frames: number of controlblocks to allocate
* @src: the src address to assign
* @dst: the dst address to assign
@@ -362,25 +359,27 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
* @period_len: the period length when to apply @finalextrainfo
* in addition to the last transfer
* this will also break some control-blocks early
- * @finalextrainfo: additional bits in last controlblock
- * (or when period_len is reached in case of cyclic)
* @gfp: the GFP flag to use for allocation
+ * @flags: the dmaengine prep flags (DMA_PREP_*) of the transfer
*/
static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
struct dma_chan *chan,
enum dma_transfer_direction direction,
- bool cyclic, u32 info,
- u32 finalextrainfo,
- size_t frames, dma_addr_t src,
- dma_addr_t dst, size_t buf_len,
- size_t period_len, gfp_t gfp)
+ bool cyclic, size_t frames,
+ dma_addr_t src, dma_addr_t dst,
+ size_t buf_len, size_t period_len,
+ gfp_t gfp, unsigned long flags)
{
+ struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
size_t len = buf_len, total_len;
size_t frame;
struct bcm2835_desc *d;
struct bcm2835_cb_entry *cb_entry;
struct bcm2835_dma_cb *control_block;
+ u32 extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic,
+ false, flags);
+ bool zero_page = false;
if (!frames)
return NULL;
@@ -394,6 +393,14 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
d->dir = direction;
d->cyclic = cyclic;
+ switch (direction) {
+ case DMA_MEM_TO_MEM:
+ case DMA_DEV_TO_MEM:
+ break;
+ default:
+ zero_page = src == od->zero_page;
+ }
+
/*
* Iterate over all frames, create a control block
* for each frame and link them together.
@@ -407,7 +414,8 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
/* fill in the control block */
control_block = cb_entry->cb;
- control_block->info = info;
+ control_block->info = bcm2835_dma_prepare_cb_info(c, direction,
+ zero_page);
control_block->src = src;
control_block->dst = dst;
control_block->stride = 0;
@@ -415,10 +423,12 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
/* set up length in control_block if requested */
if (buf_len) {
/* calculate length honoring period_length */
- bcm2835_dma_create_cb_set_length(c, control_block,
- len, period_len,
- &total_len,
- cyclic ? finalextrainfo : 0);
+ if (bcm2835_dma_create_cb_set_length(c, control_block,
+ len, period_len,
+ &total_len)) {
+ /* add extrainfo bits in info */
+ control_block->info |= extrainfo;
+ }
/* calculate new remaining length */
len -= control_block->length;
@@ -439,7 +449,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
}
/* the last frame requires extra flags */
- d->cb_list[d->frames - 1].cb->info |= finalextrainfo;
+ extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, true,
+ flags);
+ d->cb_list[d->frames - 1].cb->info |= extrainfo;
/* detect a size mismatch */
if (buf_len && d->size != buf_len)
@@ -703,9 +715,6 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
- u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false);
- u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false,
- true, 0);
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -717,9 +726,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
frames = bcm2835_dma_frames_for_length(len, max_len);
/* allocate the CB chain - this also fills in the pointers */
- d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false,
- info, extra, frames,
- src, dst, len, 0, GFP_KERNEL);
+ d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false, frames,
+ src, dst, len, 0, GFP_KERNEL, 0);
if (!d)
return NULL;
@@ -735,8 +743,6 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src = 0, dst = 0;
- u32 info = bcm2835_dma_prepare_cb_info(c, direction, false);
- u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0);
size_t frames;
if (!is_slave_direction(direction)) {
@@ -759,10 +765,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
frames = sg_nents_for_dma(sgl, sg_len, bcm2835_dma_max_frame_length(c));
/* allocate the CB chain */
- d = bcm2835_dma_create_cb_chain(chan, direction, false,
- info, extra,
- frames, src, dst, 0, 0,
- GFP_NOWAIT);
+ d = bcm2835_dma_create_cb_chain(chan, direction, false, frames, src,
+ dst, 0, 0, GFP_NOWAIT, 0);
if (!d)
return NULL;
@@ -778,13 +782,9 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
size_t period_len, enum dma_transfer_direction direction,
unsigned long flags)
{
- struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src, dst;
- u32 info = bcm2835_dma_prepare_cb_info(c, direction,
- buf_addr == od->zero_page);
- u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0);
size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
@@ -835,10 +835,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
* note that we need to use GFP_NOWAIT, as the ALSA i2s dmaengine
* implementation calls prep_dma_cyclic with interrupts disabled.
*/
- d = bcm2835_dma_create_cb_chain(chan, direction, true,
- info, extra,
- frames, src, dst, buf_len,
- period_len, GFP_NOWAIT);
+ d = bcm2835_dma_create_cb_chain(chan, direction, true, frames, src, dst,
+ buf_len, period_len, GFP_NOWAIT, flags);
if (!d)
return NULL;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 12/28] dmaengine: bcm2835: pass dma_chan to generic functions
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (10 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 11/28] dmaengine: bcm2835: drop info parameters Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 13/28] dmaengine: bcm2835: introduce multi platform support Andrea della Porta
` (15 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
In preparation to support more platforms pass the dma_chan to the
generic functions. This provides access to the DMA device and possible
platform specific data.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 1d322cad4ca3..d048cb00ce5d 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -307,13 +307,14 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd)
bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd));
}
-static bool bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan,
+static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan,
struct bcm2835_dma_cb *control_block,
size_t len,
size_t period_len,
size_t *total_len)
{
- size_t max_len = bcm2835_dma_max_frame_length(chan);
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
+ size_t max_len = bcm2835_dma_max_frame_length(c);
/* set the length taking lite-channel limitations into account */
control_block->length = min_t(u32, len, max_len);
@@ -423,7 +424,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
/* set up length in control_block if requested */
if (buf_len) {
/* calculate length honoring period_length */
- if (bcm2835_dma_create_cb_set_length(c, control_block,
+ if (bcm2835_dma_create_cb_set_length(chan, control_block,
len, period_len,
&total_len)) {
/* add extrainfo bits in info */
@@ -491,8 +492,9 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
}
}
-static void bcm2835_dma_abort(struct bcm2835_chan *c)
+static void bcm2835_dma_abort(struct dma_chan *chan)
{
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
void __iomem *chan_base = c->chan_base;
long timeout = 100;
@@ -533,8 +535,9 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c)
writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS);
}
-static void bcm2835_dma_start_desc(struct bcm2835_chan *c)
+static void bcm2835_dma_start_desc(struct dma_chan *chan)
{
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct virt_dma_desc *vd = vchan_next_desc(&c->vc);
if (!vd) {
@@ -553,7 +556,8 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c)
static irqreturn_t bcm2835_dma_callback(int irq, void *data)
{
- struct bcm2835_chan *c = data;
+ struct dma_chan *chan = data;
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
unsigned long flags;
@@ -587,7 +591,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
vchan_cyclic_callback(&d->vd);
} else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) {
vchan_cookie_complete(&c->desc->vd);
- bcm2835_dma_start_desc(c);
+ bcm2835_dma_start_desc(chan);
}
}
@@ -615,7 +619,7 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan)
}
return request_irq(c->irq_number, bcm2835_dma_callback,
- c->irq_flags, "DMA IRQ", c);
+ c->irq_flags, "DMA IRQ", chan);
}
static void bcm2835_dma_free_chan_resources(struct dma_chan *chan)
@@ -623,7 +627,7 @@ static void bcm2835_dma_free_chan_resources(struct dma_chan *chan)
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
vchan_free_chan_resources(&c->vc);
- free_irq(c->irq_number, c);
+ free_irq(c->irq_number, chan);
dma_pool_destroy(c->cb_pool);
dev_dbg(c->vc.chan.device->dev, "Freeing DMA channel %u\n", c->ch);
@@ -704,7 +708,7 @@ static void bcm2835_dma_issue_pending(struct dma_chan *chan)
spin_lock_irqsave(&c->vc.lock, flags);
if (vchan_issue_pending(&c->vc) && !c->desc)
- bcm2835_dma_start_desc(c);
+ bcm2835_dma_start_desc(chan);
spin_unlock_irqrestore(&c->vc.lock, flags);
}
@@ -868,7 +872,7 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
if (c->desc) {
vchan_terminate_vdesc(&c->desc->vd);
c->desc = NULL;
- bcm2835_dma_abort(c);
+ bcm2835_dma_abort(chan);
}
vchan_get_all_descriptors(&c->vc, &head);
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 13/28] dmaengine: bcm2835: introduce multi platform support
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (11 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 12/28] dmaengine: bcm2835: pass dma_chan to generic functions Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 14/28] dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses Andrea della Porta
` (14 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
This finally moves all platform specific stuff into a separate structure,
which is initialized on the OF compatible during probing. Since the DMA
control block is different on the BCM2711 platform, we introduce a common
control block to reserve the necessary space and adequate methods for
access.
The abort sequence is completely different on the 40-bit channels, so
make it a platform callback instead of trying to describe it through
register offsets and bit masks.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 337 ++++++++++++++++++++++++++++++--------
1 file changed, 266 insertions(+), 71 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index d048cb00ce5d..f8b2202096d6 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -48,6 +48,11 @@ struct bcm2835_dmadev {
struct dma_device ddev;
void __iomem *base;
dma_addr_t zero_page;
+ const struct bcm2835_dma_cfg *cfg;
+};
+
+struct bcm_dma_cb {
+ u32 rsvd[8];
};
struct bcm2835_dma_cb {
@@ -61,7 +66,7 @@ struct bcm2835_dma_cb {
};
struct bcm2835_cb_entry {
- struct bcm2835_dma_cb *cb;
+ struct bcm_dma_cb *cb;
dma_addr_t paddr;
};
@@ -82,6 +87,59 @@ struct bcm2835_chan {
bool is_lite_channel;
};
+/**
+ * struct bcm2835_dma_cfg - platform specific description of the DMA channels
+ * @cs_reg: offset of the control and status register
+ * @cb_reg: offset of the control block address register
+ * @int_mask: interrupt status bit in the CS register
+ * @active_mask: channel active bit in the CS register
+ * @cb_get_length: get the transfer length of a control block
+ * @cb_get_addr: get the memory side address of a control block
+ * @cb_init: initialize a control block
+ * @cb_set_src: set the source address of a control block
+ * @cb_set_dst: set the destination address of a control block
+ * @cb_set_next: link a control block to the next one
+ * @cb_set_length: set the transfer length of a control block
+ * @cb_append_extra: add the interrupt and completion bits to a control block
+ * @to_cb_addr: convert a control block bus address to its register format
+ * @chan_plat_init: platform specific channel initialization
+ * @read_addr: read the current memory side address of a channel
+ * @cs_flags: per-channel flags for the CS register
+ * @abort: stop and reset a channel
+ */
+struct bcm2835_dma_cfg {
+ u32 cs_reg;
+ u32 cb_reg;
+
+ u32 int_mask;
+ u32 active_mask;
+
+ u32 (*cb_get_length)(void *data);
+ dma_addr_t (*cb_get_addr)(void *data, enum dma_transfer_direction);
+
+ void (*cb_init)(void *data, struct bcm2835_chan *c,
+ enum dma_transfer_direction direction, dma_addr_t src,
+ dma_addr_t dst, bool zero_page);
+ void (*cb_set_src)(void *data, enum dma_transfer_direction direction,
+ dma_addr_t src);
+ void (*cb_set_dst)(void *data, enum dma_transfer_direction direction,
+ dma_addr_t dst);
+ void (*cb_set_next)(void *data, u32 next);
+ void (*cb_set_length)(void *data, u32 length);
+ void (*cb_append_extra)(void *data,
+ struct bcm2835_chan *c,
+ enum dma_transfer_direction direction,
+ bool cyclic, bool final, unsigned long flags);
+
+ u32 (*to_cb_addr)(dma_addr_t addr);
+
+ void (*chan_plat_init)(struct bcm2835_chan *c);
+ dma_addr_t (*read_addr)(struct bcm2835_chan *c,
+ enum dma_transfer_direction direction);
+ u32 (*cs_flags)(struct bcm2835_chan *c);
+ void (*abort)(struct bcm2835_chan *c);
+};
+
struct bcm2835_desc {
struct bcm2835_chan *c;
struct virt_dma_desc vd;
@@ -215,6 +273,13 @@ static inline struct bcm2835_dmadev *to_bcm2835_dma_dev(struct dma_device *d)
return container_of(d, struct bcm2835_dmadev, ddev);
}
+static inline const struct bcm2835_dma_cfg *to_bcm2835_cfg(struct dma_device *d)
+{
+ struct bcm2835_dmadev *od = container_of(d, struct bcm2835_dmadev, ddev);
+
+ return od->cfg;
+}
+
static inline struct bcm2835_chan *to_bcm2835_dma_chan(struct dma_chan *c)
{
return container_of(c, struct bcm2835_chan, vc.chan);
@@ -291,6 +356,109 @@ static inline bool need_dst_incr(enum dma_transfer_direction direction)
return false;
}
+static inline u32 bcm2835_dma_cb_get_length(void *data)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ return cb->length;
+}
+
+static inline dma_addr_t
+bcm2835_dma_cb_get_addr(void *data, enum dma_transfer_direction direction)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ if (direction == DMA_DEV_TO_MEM)
+ return cb->dst;
+
+ return cb->src;
+}
+
+static inline void
+bcm2835_dma_cb_init(void *data, struct bcm2835_chan *c,
+ enum dma_transfer_direction direction, dma_addr_t src,
+ dma_addr_t dst, bool zero_page)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ cb->info = bcm2835_dma_prepare_cb_info(c, direction, zero_page);
+ cb->src = src;
+ cb->dst = dst;
+ cb->stride = 0;
+ cb->next = 0;
+}
+
+static inline void
+bcm2835_dma_cb_set_src(void *data, enum dma_transfer_direction direction,
+ dma_addr_t src)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ cb->src = src;
+}
+
+static inline void
+bcm2835_dma_cb_set_dst(void *data, enum dma_transfer_direction direction,
+ dma_addr_t dst)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ cb->dst = dst;
+}
+
+static inline void bcm2835_dma_cb_set_next(void *data, u32 next)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ cb->next = next;
+}
+
+static inline void bcm2835_dma_cb_set_length(void *data, u32 length)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ cb->length = length;
+}
+
+static inline void
+bcm2835_dma_cb_append_extra(void *data, struct bcm2835_chan *c,
+ enum dma_transfer_direction direction,
+ bool cyclic, bool final, unsigned long flags)
+{
+ struct bcm2835_dma_cb *cb = data;
+
+ cb->info |= bcm2835_dma_prepare_cb_extra(c, direction, cyclic, final,
+ flags);
+}
+
+static inline u32 bcm2835_dma_to_cb_addr(dma_addr_t addr)
+{
+ return addr;
+}
+
+static void bcm2835_dma_chan_plat_init(struct bcm2835_chan *c)
+{
+ /* check in DEBUG register if this is a LITE channel */
+ if (readl(c->chan_base + BCM2835_DMA_DEBUG) & BCM2835_DMA_DEBUG_LITE)
+ c->is_lite_channel = true;
+}
+
+static dma_addr_t bcm2835_dma_read_addr(struct bcm2835_chan *c,
+ enum dma_transfer_direction direction)
+{
+ if (direction == DMA_MEM_TO_DEV)
+ return readl(c->chan_base + BCM2835_DMA_SOURCE_AD);
+ else if (direction == DMA_DEV_TO_MEM)
+ return readl(c->chan_base + BCM2835_DMA_DEST_AD);
+
+ return 0;
+}
+
+static u32 bcm2835_dma_cs_flags(struct bcm2835_chan *c)
+{
+ return BCM2835_DMA_CS_FLAGS(c->dreq);
+}
+
static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
{
size_t i;
@@ -308,16 +476,19 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd)
}
static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan,
- struct bcm2835_dma_cb *control_block,
+ void *data,
size_t len,
size_t period_len,
size_t *total_len)
{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
size_t max_len = bcm2835_dma_max_frame_length(c);
/* set the length taking lite-channel limitations into account */
- control_block->length = min_t(u32, len, max_len);
+ u32 length = min_t(u32, len, max_len);
+
+ cfg->cb_set_length(data, length);
/* finished if we have no period_length */
if (!period_len)
@@ -332,14 +503,14 @@ static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan,
*/
/* have we filled in period_length yet? */
- if (*total_len + control_block->length < period_len) {
+ if (*total_len + length < period_len) {
/* update number of bytes in this period so far */
- *total_len += control_block->length;
+ *total_len += length;
return false;
}
/* calculate the length that remains to reach period_length */
- control_block->length = period_len - *total_len;
+ cfg->cb_set_length(data, period_len - *total_len);
/* reset total_length for next period */
*total_len = 0;
@@ -371,15 +542,14 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
size_t buf_len, size_t period_len,
gfp_t gfp, unsigned long flags)
{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
size_t len = buf_len, total_len;
size_t frame;
struct bcm2835_desc *d;
struct bcm2835_cb_entry *cb_entry;
- struct bcm2835_dma_cb *control_block;
- u32 extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic,
- false, flags);
+ struct bcm_dma_cb *control_block;
bool zero_page = false;
if (!frames)
@@ -415,12 +585,8 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
/* fill in the control block */
control_block = cb_entry->cb;
- control_block->info = bcm2835_dma_prepare_cb_info(c, direction,
- zero_page);
- control_block->src = src;
- control_block->dst = dst;
- control_block->stride = 0;
- control_block->next = 0;
+ cfg->cb_init(control_block, c, direction, src, dst, zero_page);
+
/* set up length in control_block if requested */
if (buf_len) {
/* calculate length honoring period_length */
@@ -428,31 +594,33 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
len, period_len,
&total_len)) {
/* add extrainfo bits in info */
- control_block->info |= extrainfo;
+ cfg->cb_append_extra(control_block, c,
+ direction, cyclic,
+ false, flags);
}
/* calculate new remaining length */
- len -= control_block->length;
+ len -= cfg->cb_get_length(control_block);
}
/* link this the last controlblock */
if (frame)
- d->cb_list[frame - 1].cb->next = cb_entry->paddr;
+ cfg->cb_set_next(d->cb_list[frame - 1].cb,
+ cfg->to_cb_addr(cb_entry->paddr));
/* update src and dst and length */
if (src && need_src_incr(direction))
- src += control_block->length;
+ src += cfg->cb_get_length(control_block);
if (dst && need_dst_incr(direction))
- dst += control_block->length;
+ dst += cfg->cb_get_length(control_block);
/* Length of total transfer */
- d->size += control_block->length;
+ d->size += cfg->cb_get_length(control_block);
}
/* the last frame requires extra flags */
- extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, true,
- flags);
- d->cb_list[d->frames - 1].cb->info |= extrainfo;
+ cfg->cb_append_extra(d->cb_list[d->frames - 1].cb, c, direction, cyclic,
+ true, flags);
/* detect a size mismatch */
if (buf_len && d->size != buf_len)
@@ -472,6 +640,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
struct scatterlist *sgl,
unsigned int sg_len)
{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
size_t len, max_len;
unsigned int i;
@@ -482,29 +651,21 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
for_each_sg(sgl, sgent, sg_len, i) {
for (addr = sg_dma_address(sgent), len = sg_dma_len(sgent);
len > 0;
- addr += cb->cb->length, len -= cb->cb->length, cb++) {
+ addr += cfg->cb_get_length(cb->cb), len -= cfg->cb_get_length(cb->cb), cb++) {
if (direction == DMA_DEV_TO_MEM)
- cb->cb->dst = addr;
+ cfg->cb_set_dst(cb->cb, direction, addr);
else
- cb->cb->src = addr;
- cb->cb->length = min(len, max_len);
+ cfg->cb_set_src(cb->cb, direction, addr);
+ cfg->cb_set_length(cb->cb, min(len, max_len));
}
}
}
-static void bcm2835_dma_abort(struct dma_chan *chan)
+static void bcm2835_dma_abort_chan(struct bcm2835_chan *c)
{
- struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
void __iomem *chan_base = c->chan_base;
long timeout = 100;
- /*
- * A zero control block address means the channel is idle.
- * (The ACTIVE flag in the CS register is not a reliable indicator.)
- */
- if (!readl(chan_base + BCM2835_DMA_ADDR))
- return;
-
/* We need to clear the next DMA block pending */
writel(0, chan_base + BCM2835_DMA_NEXTCB);
@@ -535,8 +696,24 @@ static void bcm2835_dma_abort(struct dma_chan *chan)
writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS);
}
+static void bcm2835_dma_abort(struct dma_chan *chan)
+{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
+
+ /*
+ * A zero control block address means the channel is idle.
+ * (The ACTIVE flag in the CS register is not a reliable indicator.)
+ */
+ if (!readl(c->chan_base + cfg->cb_reg))
+ return;
+
+ cfg->abort(c);
+}
+
static void bcm2835_dma_start_desc(struct dma_chan *chan)
{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct virt_dma_desc *vd = vchan_next_desc(&c->vc);
@@ -549,14 +726,15 @@ static void bcm2835_dma_start_desc(struct dma_chan *chan)
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 | BCM2835_DMA_CS_FLAGS(c->dreq),
- c->chan_base + BCM2835_DMA_CS);
+ writel(cfg->to_cb_addr(c->desc->cb_list[0].paddr), c->chan_base + cfg->cb_reg);
+ writel(cfg->active_mask | cfg->cs_flags(c),
+ c->chan_base + cfg->cs_reg);
}
static irqreturn_t bcm2835_dma_callback(int irq, void *data)
{
struct dma_chan *chan = data;
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
unsigned long flags;
@@ -564,9 +742,9 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
/* check the shared interrupt */
if (c->irq_flags & IRQF_SHARED) {
/* check if the interrupt is enabled */
- flags = readl(c->chan_base + BCM2835_DMA_CS);
+ flags = readl(c->chan_base + cfg->cs_reg);
/* if not set then we are not the reason for the irq */
- if (!(flags & BCM2835_DMA_INT))
+ if (!(flags & cfg->int_mask))
return IRQ_NONE;
}
@@ -579,9 +757,7 @@ 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 |
- BCM2835_DMA_CS_FLAGS(c->dreq),
- c->chan_base + BCM2835_DMA_CS);
+ writel(cfg->int_mask | cfg->active_mask | cfg->cs_flags(c), c->chan_base + cfg->cs_reg);
d = c->desc;
@@ -589,7 +765,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data)
if (d->cyclic) {
/* call the cyclic callback */
vchan_cyclic_callback(&d->vd);
- } else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) {
+ } else if (!readl(c->chan_base + cfg->cb_reg)) {
vchan_cookie_complete(&c->desc->vd);
bcm2835_dma_start_desc(chan);
}
@@ -612,7 +788,7 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan)
* (32 byte) aligned address (BCM2835 ARM Peripherals, sec. 4.2.1.1).
*/
c->cb_pool = dma_pool_create(dev_name(dev), dev,
- sizeof(struct bcm2835_dma_cb), 32, 0);
+ sizeof(struct bcm_dma_cb), 32, 0);
if (!c->cb_pool) {
dev_err(dev, "unable to allocate descriptor pool\n");
return -ENOMEM;
@@ -638,20 +814,16 @@ static size_t bcm2835_dma_desc_size(struct bcm2835_desc *d)
return d->size;
}
-static size_t bcm2835_dma_desc_size_pos(struct bcm2835_desc *d, dma_addr_t addr)
+static size_t bcm2835_dma_desc_size_pos(const struct bcm2835_dma_cfg *cfg,
+ struct bcm2835_desc *d, dma_addr_t addr)
{
unsigned int i;
size_t size;
for (size = i = 0; i < d->frames; i++) {
- struct bcm2835_dma_cb *control_block = d->cb_list[i].cb;
- size_t this_size = control_block->length;
- dma_addr_t dma;
-
- if (d->dir == DMA_DEV_TO_MEM)
- dma = control_block->dst;
- else
- dma = control_block->src;
+ struct bcm_dma_cb *control_block = d->cb_list[i].cb;
+ size_t this_size = cfg->cb_get_length(control_block);
+ dma_addr_t dma = cfg->cb_get_addr(control_block, d->dir);
if (size)
size += this_size;
@@ -666,6 +838,7 @@ static enum dma_status bcm2835_dma_tx_status(struct dma_chan *chan,
dma_cookie_t cookie,
struct dma_tx_state *txstate)
{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct virt_dma_desc *vd;
enum dma_status ret;
@@ -684,14 +857,8 @@ static enum dma_status bcm2835_dma_tx_status(struct dma_chan *chan,
struct bcm2835_desc *d = c->desc;
dma_addr_t pos;
- if (d->dir == DMA_MEM_TO_DEV)
- pos = readl(c->chan_base + BCM2835_DMA_SOURCE_AD);
- else if (d->dir == DMA_DEV_TO_MEM)
- pos = readl(c->chan_base + BCM2835_DMA_DEST_AD);
- else
- pos = 0;
-
- txstate->residue = bcm2835_dma_desc_size_pos(d, pos);
+ pos = cfg->read_addr(c, d->dir);
+ txstate->residue = bcm2835_dma_desc_size_pos(cfg, d, pos);
} else {
txstate->residue = 0;
}
@@ -786,6 +953,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
size_t period_len, enum dma_transfer_direction direction,
unsigned long flags)
{
+ const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device);
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
struct bcm2835_desc *d;
dma_addr_t src, dst;
@@ -845,7 +1013,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
return NULL;
/* wrap around into a loop */
- d->cb_list[d->frames - 1].cb->next = d->cb_list[0].paddr;
+ cfg->cb_set_next(d->cb_list[d->frames - 1].cb,
+ cfg->to_cb_addr(d->cb_list[0].paddr));
return vchan_tx_prep(&c->vc, &d->vd, flags);
}
@@ -906,10 +1075,7 @@ static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id,
c->irq_number = irq;
c->irq_flags = irq_flags;
- /* check in DEBUG register if this is a LITE channel */
- if (readl(c->chan_base + BCM2835_DMA_DEBUG) &
- BCM2835_DMA_DEBUG_LITE)
- c->is_lite_channel = true;
+ d->cfg->chan_plat_init(c);
return 0;
}
@@ -928,8 +1094,32 @@ static void bcm2835_dma_free(struct bcm2835_dmadev *od)
DMA_TO_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
}
+static const struct bcm2835_dma_cfg bcm2835_data = {
+ .cs_reg = BCM2835_DMA_CS,
+ .cb_reg = BCM2835_DMA_ADDR,
+
+ .int_mask = BCM2835_DMA_INT,
+ .active_mask = BCM2835_DMA_ACTIVE,
+
+ .cb_get_length = bcm2835_dma_cb_get_length,
+ .cb_get_addr = bcm2835_dma_cb_get_addr,
+ .cb_init = bcm2835_dma_cb_init,
+ .cb_set_src = bcm2835_dma_cb_set_src,
+ .cb_set_dst = bcm2835_dma_cb_set_dst,
+ .cb_set_next = bcm2835_dma_cb_set_next,
+ .cb_set_length = bcm2835_dma_cb_set_length,
+ .cb_append_extra = bcm2835_dma_cb_append_extra,
+
+ .to_cb_addr = bcm2835_dma_to_cb_addr,
+
+ .chan_plat_init = bcm2835_dma_chan_plat_init,
+ .read_addr = bcm2835_dma_read_addr,
+ .cs_flags = bcm2835_dma_cs_flags,
+ .abort = bcm2835_dma_abort_chan,
+};
+
static const struct of_device_id bcm2835_dma_of_match[] = {
- { .compatible = "brcm,bcm2835-dma", },
+ { .compatible = "brcm,bcm2835-dma", .data = &bcm2835_data },
{},
};
MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match);
@@ -960,7 +1150,7 @@ static int bcm2835_dma_suspend_late(struct device *dev)
void __iomem *chan_base = c->chan_base;
/* Check if DMA channel is busy */
- if (readl(chan_base + BCM2835_DMA_ADDR))
+ if (readl(chan_base + od->cfg->cb_reg))
return -EBUSY;
}
@@ -995,6 +1185,11 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
if (!od)
return -ENOMEM;
+ od->cfg = device_get_match_data(&pdev->dev);
+ if (!od->cfg)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "Failed to match compatible string\n");
+
dma_set_max_seg_size(&pdev->dev, 0x3FFFFFFF);
base = devm_platform_ioremap_resource(pdev, 0);
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 14/28] dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (12 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 13/28] dmaengine: bcm2835: introduce multi platform support Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 15:21 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 15/28] spi: bcm2835: Pass the CPU physical address of the FIFO to the DMA engine Andrea della Porta
` (13 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
Slave addresses in struct dma_slave_config are CPU physical addresses
and it is up to the DMA controller driver to translate them into the
addresses it has to program into the hardware. The BCM2835 DMA driver
instead uses them verbatim, which only works because its clients pass
pre-translated bus addresses read straight from their DT node, bypassing
the bus translations described there.
Translate the addresses with dma_map_resource(), which applies the
dma-ranges of the DMA controller since the conversion of
dma_map_resource() to dma_map_phys() with DMA_ATTR_MMIO, and map them
once in device_config() instead of at every prep call. The mappings are
released when the channel is reconfigured or freed.
Existing device trees only describe the RAM in dma-ranges, so
dma_map_resource() would fail for any peripheral. Detect this case at
probe time, by looking for the controller registers themselves in the
dma-ranges of the closest ancestor bus, and fall back to reverting the
translation given by the ranges property of the parent bus, which is
how the VideoCore bus addresses of the peripherals have been derived so
far. Addresses not covered by those ranges are passed through, so that
clients still providing bus addresses keep working.
The fallback translation is a platform callback, as different kinds of
channels see the peripherals at different addresses; implement the one
of the legacy channels.
Link: https://lore.kernel.org/linux-arm-kernel/ee19a95d-fe1e-4f3f-bc81-bdef38475469@arm.com/
Link: https://lore.kernel.org/all/CAPY8ntByJYzSv0kTAc1kY0Dp=vwrzcA0oWiPpyg7x7_BQwGSnA@mail.gmail.com/
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 180 ++++++++++++++++++++++++++++++++++++--
1 file changed, 175 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index f8b2202096d6..3ff30c41dc63 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -30,6 +30,7 @@
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/of_dma.h>
#include "virt-dma.h"
@@ -43,12 +44,16 @@
* @base: base address of register map
* @zero_page: bus address of zero page (to detect transactions copying from
* zero page and avoid accessing memory if so)
+ * @cfg: platform specific description of the DMA channels
+ * @map_resource: the peripheral window is described by dma-ranges, so slave
+ * addresses can be translated with dma_map_resource()
*/
struct bcm2835_dmadev {
struct dma_device ddev;
void __iomem *base;
dma_addr_t zero_page;
const struct bcm2835_dma_cfg *cfg;
+ bool map_resource;
};
struct bcm_dma_cb {
@@ -70,10 +75,24 @@ struct bcm2835_cb_entry {
dma_addr_t paddr;
};
+/**
+ * struct bcm2835_slave_addr - bus address of a slave FIFO
+ * @addr: address as seen by the DMA controller
+ * @size: size of the mapping
+ * @mapped: @addr has been obtained from dma_map_resource()
+ */
+struct bcm2835_slave_addr {
+ dma_addr_t addr;
+ size_t size;
+ bool mapped;
+};
+
struct bcm2835_chan {
struct virt_dma_chan vc;
struct dma_slave_config cfg;
+ struct bcm2835_slave_addr slave_src;
+ struct bcm2835_slave_addr slave_dst;
unsigned int dreq;
int ch;
@@ -106,6 +125,8 @@ struct bcm2835_chan {
* @read_addr: read the current memory side address of a channel
* @cs_flags: per-channel flags for the CS register
* @abort: stop and reset a channel
+ * @legacy_bus_addr: translate a slave address for device trees which do not
+ * describe the peripheral window in dma-ranges
*/
struct bcm2835_dma_cfg {
u32 cs_reg;
@@ -138,6 +159,8 @@ struct bcm2835_dma_cfg {
enum dma_transfer_direction direction);
u32 (*cs_flags)(struct bcm2835_chan *c);
void (*abort)(struct bcm2835_chan *c);
+
+ u64 (*legacy_bus_addr)(struct device *dev, phys_addr_t phys);
};
struct bcm2835_desc {
@@ -798,11 +821,30 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan)
c->irq_flags, "DMA IRQ", chan);
}
+static void bcm2835_dma_unmap_slave_addr(struct dma_chan *chan,
+ struct bcm2835_slave_addr *sa,
+ enum dma_data_direction dir)
+{
+ if (sa->mapped)
+ dma_unmap_resource(chan->device->dev, sa->addr, sa->size, dir, 0);
+
+ memset(sa, 0, sizeof(*sa));
+}
+
+static void bcm2835_dma_unmap_slave_addrs(struct dma_chan *chan)
+{
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
+
+ bcm2835_dma_unmap_slave_addr(chan, &c->slave_src, DMA_FROM_DEVICE);
+ bcm2835_dma_unmap_slave_addr(chan, &c->slave_dst, DMA_TO_DEVICE);
+}
+
static void bcm2835_dma_free_chan_resources(struct dma_chan *chan)
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
vchan_free_chan_resources(&c->vc);
+ bcm2835_dma_unmap_slave_addrs(chan);
free_irq(c->irq_number, chan);
dma_pool_destroy(c->cb_pool);
@@ -925,11 +967,11 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
if (direction == DMA_DEV_TO_MEM) {
if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
- src = c->cfg.src_addr;
+ src = c->slave_src.addr;
} else {
if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
- dst = c->cfg.dst_addr;
+ dst = c->slave_dst.addr;
}
/* count frames in sg list */
@@ -987,12 +1029,12 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
if (direction == DMA_DEV_TO_MEM) {
if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
- src = c->cfg.src_addr;
+ src = c->slave_src.addr;
dst = buf_addr;
} else {
if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
return NULL;
- dst = c->cfg.dst_addr;
+ dst = c->slave_dst.addr;
src = buf_addr;
}
@@ -1019,10 +1061,87 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
return vchan_tx_prep(&c->vc, &d->vd, flags);
}
+/*
+ * Device trees which do not describe the peripheral window in dma-ranges
+ * are handled by assuming that the legacy DMA channels see the peripherals
+ * at the same address as the bus they sit on, i.e. by reverting the
+ * translation described by the ranges property of the parent bus. This is
+ * how the VideoCore bus addresses have always been derived. Addresses which
+ * are not CPU physical addresses of that bus are passed through unchanged,
+ * as legacy clients used to provide bus addresses.
+ */
+static u64 bcm2835_dma_legacy_bus_addr(struct device *dev, phys_addr_t phys)
+{
+ struct device_node *bus = of_get_parent(dev->of_node);
+ struct of_range_parser parser;
+ struct of_range range;
+ u64 addr = phys;
+
+ if (bus && !of_range_parser_init(&parser, bus)) {
+ for_each_of_range(&parser, &range) {
+ if (phys >= range.cpu_addr &&
+ phys - range.cpu_addr < range.size) {
+ addr = range.bus_addr + (phys - range.cpu_addr);
+ break;
+ }
+ }
+ }
+
+ of_node_put(bus);
+
+ return addr;
+}
+
+static int bcm2835_dma_map_slave_addr(struct dma_chan *chan,
+ struct bcm2835_slave_addr *sa,
+ phys_addr_t phys,
+ enum dma_slave_buswidth width,
+ enum dma_data_direction dir)
+{
+ struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device);
+ struct device *dev = chan->device->dev;
+ size_t size = width ? width : DMA_SLAVE_BUSWIDTH_4_BYTES;
+
+ if (!phys)
+ return 0;
+
+ if (!od->map_resource) {
+ sa->addr = od->cfg->legacy_bus_addr(dev, phys);
+ return 0;
+ }
+
+ sa->addr = dma_map_resource(dev, phys, size, dir, 0);
+ if (dma_mapping_error(dev, sa->addr)) {
+ dev_err(dev, "failed to map slave address %pa\n", &phys);
+ sa->addr = 0;
+ return -EINVAL;
+ }
+
+ sa->size = size;
+ sa->mapped = true;
+
+ return 0;
+}
+
static int bcm2835_dma_slave_config(struct dma_chan *chan,
struct dma_slave_config *cfg)
{
struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
+ int ret;
+
+ bcm2835_dma_unmap_slave_addrs(chan);
+
+ ret = bcm2835_dma_map_slave_addr(chan, &c->slave_src, cfg->src_addr,
+ cfg->src_addr_width, DMA_FROM_DEVICE);
+ if (ret)
+ return ret;
+
+ ret = bcm2835_dma_map_slave_addr(chan, &c->slave_dst, cfg->dst_addr,
+ cfg->dst_addr_width, DMA_TO_DEVICE);
+ if (ret) {
+ bcm2835_dma_unmap_slave_addrs(chan);
+ return ret;
+ }
c->cfg = *cfg;
@@ -1116,6 +1235,8 @@ static const struct bcm2835_dma_cfg bcm2835_data = {
.read_addr = bcm2835_dma_read_addr,
.cs_flags = bcm2835_dma_cs_flags,
.abort = bcm2835_dma_abort_chan,
+
+ .legacy_bus_addr = bcm2835_dma_legacy_bus_addr,
};
static const struct of_device_id bcm2835_dma_of_match[] = {
@@ -1157,6 +1278,48 @@ static int bcm2835_dma_suspend_late(struct device *dev)
return 0;
}
+/*
+ * The DMA controller registers sit in the same peripheral window as the
+ * FIFOs of its clients, so the window is described by dma-ranges if and
+ * only if the controller registers are.
+ */
+static bool bcm2835_dma_mmio_in_dma_ranges(struct device *dev,
+ phys_addr_t mmio)
+{
+ struct of_range_parser parser;
+ struct of_range range;
+ struct device_node *np;
+ bool found = false;
+
+ for (np = of_get_parent(dev->of_node); np; np = of_get_next_parent(np))
+ if (of_property_present(np, "dma-ranges"))
+ break;
+
+ /*
+ * Without any dma-ranges the translation is unknown: the peripherals
+ * are not at their CPU physical address on any of these SoCs.
+ */
+ if (!np)
+ return false;
+
+ if (!of_pci_dma_range_parser_init(&parser, np)) {
+ /* An empty dma-ranges describes a 1:1 translation too */
+ found = !of_range_count(&parser);
+
+ for_each_of_range(&parser, &range) {
+ if (mmio >= range.cpu_addr &&
+ mmio - range.cpu_addr < range.size) {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ of_node_put(np);
+
+ return found;
+}
+
static const struct dev_pm_ops bcm2835_dma_pm_ops = {
LATE_SYSTEM_SLEEP_PM_OPS(bcm2835_dma_suspend_late, NULL)
};
@@ -1164,6 +1327,7 @@ static const struct dev_pm_ops bcm2835_dma_pm_ops = {
static int bcm2835_dma_probe(struct platform_device *pdev)
{
struct bcm2835_dmadev *od;
+ struct resource *res;
void __iomem *base;
int rc;
int i, j;
@@ -1192,12 +1356,18 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
dma_set_max_seg_size(&pdev->dev, 0x3FFFFFFF);
- base = devm_platform_ioremap_resource(pdev, 0);
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
od->base = base;
+ od->map_resource = bcm2835_dma_mmio_in_dma_ranges(&pdev->dev,
+ res->start);
+ if (!od->map_resource)
+ dev_info(&pdev->dev,
+ "peripheral window missing in dma-ranges, please update DT blob\n");
+
dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 15/28] spi: bcm2835: Pass the CPU physical address of the FIFO to the DMA engine
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (13 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 14/28] dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 16/28] mmc: bcm2835: Pass the CPU physical address of SDDATA " Andrea della Porta
` (12 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta, Mark Brown,
linux-spi
The addresses in struct dma_slave_config are CPU physical addresses, and
the DMA controller driver is responsible for translating them into its
own view of the bus. The driver instead reads the untranslated address
out of its reg property, which only happens to be what the BCM2835 DMA
controller expects because the DMA engine driver used the address
verbatim.
Now that the DMA engine driver translates slave addresses itself, use the
CPU physical address of the register resource, which also gets rid of
the open coded parsing of the DT node.
Also zero-initialize the slave configuration: the TX channel only sets
the destination address, while the DMA engine driver now maps every
address that is provided.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/spi/spi-bcm2835.c | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index cc5748973281..c40157e4516a 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -24,7 +24,6 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h> /* FIXME: using GPIO lookup tables */
@@ -888,23 +887,12 @@ static void bcm2835_dma_release(struct spi_controller *ctlr,
}
static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
- struct bcm2835_spi *bs)
+ struct bcm2835_spi *bs, phys_addr_t phys_base)
{
- struct dma_slave_config slave_config;
+ struct dma_slave_config slave_config = {};
struct device *tx_dma_dev;
- const __be32 *addr;
- dma_addr_t dma_reg_base;
int ret;
- /* base address in dma-space */
- addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL);
- if (!addr) {
- dev_err(dev, "could not get DMA-register address - not using dma mode\n");
- /* Fall back to interrupt mode */
- return 0;
- }
- dma_reg_base = be32_to_cpup(addr);
-
/* get tx/rx dma */
ctlr->dma_tx = dma_request_chan(dev, "tx");
if (IS_ERR(ctlr->dma_tx)) {
@@ -926,7 +914,7 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
* or, in case of an RX-only transfer, cyclically copies from the zero
* page to the FIFO using a preallocated, reusable descriptor.
*/
- slave_config.dst_addr = (u32)(dma_reg_base + BCM2835_SPI_FIFO);
+ slave_config.dst_addr = phys_base + BCM2835_SPI_FIFO;
slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
ret = dmaengine_slave_config(ctlr->dma_tx, &slave_config);
@@ -967,9 +955,9 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
* RX FIFO or, in case of a TX-only transfer, cyclically writes a
* precalculated value to the CS register to clear the RX FIFO.
*/
- slave_config.src_addr = (u32)(dma_reg_base + BCM2835_SPI_FIFO);
+ slave_config.src_addr = phys_base + BCM2835_SPI_FIFO;
slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
- slave_config.dst_addr = (u32)(dma_reg_base + BCM2835_SPI_CS);
+ slave_config.dst_addr = phys_base + BCM2835_SPI_CS;
slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
ret = dmaengine_slave_config(ctlr->dma_rx, &slave_config);
@@ -1355,6 +1343,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
{
struct spi_controller *ctlr;
struct bcm2835_spi *bs;
+ struct resource *res;
int err;
ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*bs));
@@ -1377,7 +1366,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
bs = spi_controller_get_devdata(ctlr);
bs->ctlr = ctlr;
- bs->regs = devm_platform_ioremap_resource(pdev, 0);
+ bs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(bs->regs))
return PTR_ERR(bs->regs);
@@ -1394,7 +1383,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
bs->clk_hz = clk_get_rate(bs->clk);
- err = bcm2835_dma_init(ctlr, &pdev->dev, bs);
+ err = bcm2835_dma_init(ctlr, &pdev->dev, bs, res->start);
if (err)
return err;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 16/28] mmc: bcm2835: Pass the CPU physical address of SDDATA to the DMA engine
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (14 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 15/28] spi: bcm2835: Pass the CPU physical address of the FIFO to the DMA engine Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 17/28] ASoC: bcm2835-i2s: Pass the CPU physical address of the FIFO " Andrea della Porta
` (11 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta, Ulf Hansson,
linux-mmc
The addresses in struct dma_slave_config are CPU physical addresses, and
the DMA controller driver is responsible for translating them into its
own view of the bus. The driver instead reads the untranslated address
out of its reg property, which only happens to be what the BCM2835 DMA
controller expects because the DMA engine driver used the address
verbatim.
Now that the DMA engine driver translates slave addresses itself, use the
CPU physical address of the register resource, which also gets rid of
the open coded parsing of the DT node.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/mmc/host/bcm2835.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index efd1903c3ccd..cea7b2b6d2f0 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -38,7 +38,6 @@
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/module.h>
-#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
@@ -147,7 +146,7 @@ struct bcm2835_host {
struct mutex mutex;
void __iomem *ioaddr;
- u32 phys_addr;
+ phys_addr_t phys_addr;
struct clk *clk;
struct platform_device *pdev;
@@ -1369,7 +1368,7 @@ static int bcm2835_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct bcm2835_host *host;
struct mmc_host *mmc;
- const __be32 *regaddr_p;
+ struct resource *res;
int ret;
dev_dbg(dev, "%s\n", __func__);
@@ -1382,23 +1381,14 @@ static int bcm2835_probe(struct platform_device *pdev)
host->pdev = pdev;
spin_lock_init(&host->lock);
- host->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+ host->ioaddr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(host->ioaddr)) {
ret = PTR_ERR(host->ioaddr);
goto err;
}
- /* Parse OF address directly to get the physical address for
- * DMA to our registers.
- */
- regaddr_p = of_get_address(pdev->dev.of_node, 0, NULL, NULL);
- if (!regaddr_p) {
- dev_err(dev, "Can't get phys address\n");
- ret = -EINVAL;
- goto err;
- }
-
- host->phys_addr = be32_to_cpup(regaddr_p);
+ /* the DMA engine translates the address into its own view of the bus */
+ host->phys_addr = res->start;
host->dma_chan = NULL;
host->dma_desc = NULL;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 17/28] ASoC: bcm2835-i2s: Pass the CPU physical address of the FIFO to the DMA engine
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (15 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 16/28] mmc: bcm2835: Pass the CPU physical address of SDDATA " Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 18/28] drm/vc4: hdmi: Pass the CPU physical address of MAI_DATA " Andrea della Porta
` (10 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai, linux-sound
The address of the DMA slave is handed to the DMA engine through the
dma_slave_config, where it is meant to be a CPU physical address that
the DMA controller driver translates into its own view of the bus. The
driver instead reads the untranslated address out of its reg property,
which only happens to be what the BCM2835 DMA controller expects because
the DMA engine driver used the address verbatim.
Now that the DMA engine driver translates slave addresses itself, use the
CPU physical address of the register resource, which also gets rid of
the open coded parsing of the DT node.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
sound/soc/bcm/bcm2835-i2s.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c
index 208977828254..ad95412cc8b5 100644
--- a/sound/soc/bcm/bcm2835-i2s.c
+++ b/sound/soc/bcm/bcm2835-i2s.c
@@ -30,7 +30,6 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
-#include <linux/of_address.h>
#include <linux/slab.h>
#include <sound/core.h>
@@ -843,8 +842,7 @@ static int bcm2835_i2s_probe(struct platform_device *pdev)
struct bcm2835_i2s_dev *dev;
int ret;
void __iomem *base;
- const __be32 *addr;
- dma_addr_t dma_base;
+ struct resource *res;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev),
GFP_KERNEL);
@@ -859,7 +857,7 @@ static int bcm2835_i2s_probe(struct platform_device *pdev)
"could not get clk\n");
/* Request ioarea */
- base = devm_platform_ioremap_resource(pdev, 0);
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
@@ -868,19 +866,12 @@ static int bcm2835_i2s_probe(struct platform_device *pdev)
if (IS_ERR(dev->i2s_regmap))
return PTR_ERR(dev->i2s_regmap);
- /* Set the DMA address - we have to parse DT ourselves */
- addr = of_get_address(pdev->dev.of_node, 0, NULL, NULL);
- if (!addr) {
- dev_err(&pdev->dev, "could not get DMA-register address\n");
- return -EINVAL;
- }
- dma_base = be32_to_cpup(addr);
-
+ /* Set the DMA address, the DMA engine translates it */
dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
- dma_base + BCM2835_I2S_FIFO_A_REG;
+ res->start + BCM2835_I2S_FIFO_A_REG;
dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
- dma_base + BCM2835_I2S_FIFO_A_REG;
+ res->start + BCM2835_I2S_FIFO_A_REG;
/* Set the bus width */
dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr_width =
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 18/28] drm/vc4: hdmi: Pass the CPU physical address of MAI_DATA to the DMA engine
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (16 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 17/28] ASoC: bcm2835-i2s: Pass the CPU physical address of the FIFO " Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 19/28] ARM: dts: broadcom: Describe the peripheral window in dma-ranges Andrea della Porta
` (9 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta,
Maíra Canal, Raspberry Pi Kernel Maintenance,
Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
dri-devel
The address of the DMA slave is handed to the DMA engine through the
dma_slave_config, where it is meant to be a CPU physical address that
the DMA controller driver translates into its own view of the bus. The
driver instead reads the untranslated address out of its reg property,
which only happens to be what the BCM2835 DMA controller expects because
the DMA engine driver used the address verbatim.
Now that the DMA engine driver translates slave addresses itself, use the
CPU physical address of the register resource and drop the comment
describing the old workaround.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 2cc46036f11d..9dc1a67aa7fd 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -47,7 +47,6 @@
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/of.h>
-#include <linux/of_address.h>
#include <linux/pm_runtime.h>
#include <linux/rational.h>
#include <linux/reset.h>
@@ -2288,7 +2287,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
struct snd_soc_dai_link *dai_link = &vc4_hdmi->audio.link;
struct snd_soc_card *card = &vc4_hdmi->audio.card;
struct device *dev = &vc4_hdmi->pdev->dev;
- const __be32 *addr;
+ struct resource *res;
int index, len;
int ret;
@@ -2324,22 +2323,19 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
}
/*
- * Get the physical address of VC4_HD_MAI_DATA. We need to retrieve
- * the bus address specified in the DT, because the physical address
- * (the one returned by platform_get_resource()) is not appropriate
- * for DMA transfers.
- * This VC/MMU should probably be exposed to avoid this kind of hacks.
+ * Get the physical address of VC4_HD_MAI_DATA. The DMA engine
+ * translates it into the address its controller has to use.
*/
index = of_property_match_string(dev->of_node, "reg-names", "hd");
/* Before BCM2711, we don't have a named register range */
if (index < 0)
index = 1;
- addr = of_get_address(dev->of_node, index, NULL, NULL);
- if (!addr)
+ res = platform_get_resource(vc4_hdmi->pdev, IORESOURCE_MEM, index);
+ if (!res)
return -EINVAL;
- vc4_hdmi->audio.dma_data.addr = be32_to_cpup(addr) + mai_data->offset;
+ vc4_hdmi->audio.dma_data.addr = res->start + mai_data->offset;
vc4_hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
vc4_hdmi->audio.dma_data.maxburst = 2;
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 19/28] ARM: dts: broadcom: Describe the peripheral window in dma-ranges
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (17 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 18/28] drm/vc4: hdmi: Pass the CPU physical address of MAI_DATA " Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 15:17 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 20/28] dmaengine: bcm2835: Support channel subsets in a controller instance Andrea della Porta
` (8 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
The DMA controllers of the BCM283x family and of BCM2711 see the
peripherals at their VideoCore bus addresses, i.e. at the child
addresses of the soc bus. This translation is not described by the
dma-ranges property, which only covers the RAM, so that the DMA engine
driver cannot translate the CPU physical addresses of the peripheral
FIFOs and had to rely on its clients providing bus addresses instead.
Add the peripheral window to dma-ranges, mirroring the ranges property
(minus the ARM local peripherals, which are not reachable by the DMA
controllers), so that dma_map_resource() can do the translation.
This does not change the bus DMA limit of the devices on these buses,
which is still given by the RAM window except on BCM2835, where it is
raised from 0x5fffffff to 0x7fffffff without affecting the DMA mask
derived from it.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
arch/arm/boot/dts/broadcom/bcm2711.dtsi | 8 ++++++--
arch/arm/boot/dts/broadcom/bcm2835.dtsi | 3 ++-
arch/arm/boot/dts/broadcom/bcm2836.dtsi | 3 ++-
arch/arm/boot/dts/broadcom/bcm2837.dtsi | 3 ++-
4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/arm/boot/dts/broadcom/bcm2711.dtsi b/arch/arm/boot/dts/broadcom/bcm2711.dtsi
index 5e3b4bb39396..f475422796d8 100644
--- a/arch/arm/boot/dts/broadcom/bcm2711.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2711.dtsi
@@ -41,8 +41,12 @@ soc {
ranges = <0x7e000000 0x0 0xfe000000 0x01800000>,
<0x7c000000 0x0 0xfc000000 0x02000000>,
<0x40000000 0x0 0xff800000 0x00800000>;
- /* Emulate a contiguous 30-bit address range for DMA */
- dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>;
+ /*
+ * Emulate a contiguous 30-bit address range for DMA, and
+ * let the DMA controllers reach the peripherals
+ */
+ dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>,
+ <0x7c000000 0x0 0xfc000000 0x03800000>;
/*
* This node is the provider for the enable-method for
diff --git a/arch/arm/boot/dts/broadcom/bcm2835.dtsi b/arch/arm/boot/dts/broadcom/bcm2835.dtsi
index 15cb331febbb..3a9719e2fadc 100644
--- a/arch/arm/boot/dts/broadcom/bcm2835.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2835.dtsi
@@ -35,7 +35,8 @@ cpu@0 {
soc {
ranges = <0x7e000000 0x20000000 0x02000000>;
- dma-ranges = <0x40000000 0x00000000 0x20000000>;
+ dma-ranges = <0x40000000 0x00000000 0x20000000>,
+ <0x7e000000 0x20000000 0x02000000>;
};
arm-pmu {
diff --git a/arch/arm/boot/dts/broadcom/bcm2836.dtsi b/arch/arm/boot/dts/broadcom/bcm2836.dtsi
index 783fe624ba68..4ab7769c056a 100644
--- a/arch/arm/boot/dts/broadcom/bcm2836.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2836.dtsi
@@ -8,7 +8,8 @@ / {
soc {
ranges = <0x7e000000 0x3f000000 0x1000000>,
<0x40000000 0x40000000 0x00001000>;
- dma-ranges = <0xc0000000 0x00000000 0x3f000000>;
+ dma-ranges = <0xc0000000 0x00000000 0x3f000000>,
+ <0x7e000000 0x3f000000 0x01000000>;
local_intc: interrupt-controller@40000000 {
compatible = "brcm,bcm2836-l1-intc";
diff --git a/arch/arm/boot/dts/broadcom/bcm2837.dtsi b/arch/arm/boot/dts/broadcom/bcm2837.dtsi
index c281697142b1..ba44cfb07668 100644
--- a/arch/arm/boot/dts/broadcom/bcm2837.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2837.dtsi
@@ -7,7 +7,8 @@ / {
soc {
ranges = <0x7e000000 0x3f000000 0x1000000>,
<0x40000000 0x40000000 0x00001000>;
- dma-ranges = <0xc0000000 0x00000000 0x3f000000>;
+ dma-ranges = <0xc0000000 0x00000000 0x3f000000>,
+ <0x7e000000 0x3f000000 0x01000000>;
local_intc: interrupt-controller@40000000 {
compatible = "brcm,bcm2836-l1-intc";
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 20/28] dmaengine: bcm2835: Support channel subsets in a controller instance
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (18 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 19/28] ARM: dts: broadcom: Describe the peripheral window in dma-ranges Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 21/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2711 40-bit DMA Andrea della Porta
` (7 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
On BCM2711 the last four channels of the DMA block use a different, 40-bit
programming model, and are going to be described by a separate DT node
whose reg property only covers those channels. The driver however
assumes that the register range always starts with channel 0.
Derive the index of the first channel from the physical address of the
register range, which is possible since the DMA block is 4 KiB aligned,
and only consider the channels covered by it. Channel numbers, and thus
the dma-channel-mask and interrupt-names properties, keep referring to
the whole DMA block.
Also describe in the platform data which channels of the block use its
programming model, and ignore the other ones: some device trees, e.g. the
downstream BCM2712 one, describe channels with different programming
models using the same compatible, and driving them with the wrong one
could corrupt memory.
While at it, initialize all the entries of the IRQ array, as the
detection of shared interrupts looks at all of them, and report the
number of channels actually initialized.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 58 +++++++++++++++++++++++++++++++++------
1 file changed, 49 insertions(+), 9 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 3ff30c41dc63..0ea903274286 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -42,6 +42,7 @@
* struct bcm2835_dmadev - BCM2835 DMA controller
* @ddev: DMA device
* @base: base address of register map
+ * @chan_start: index of the first channel in the register map
* @zero_page: bus address of zero page (to detect transactions copying from
* zero page and avoid accessing memory if so)
* @cfg: platform specific description of the DMA channels
@@ -51,6 +52,7 @@
struct bcm2835_dmadev {
struct dma_device ddev;
void __iomem *base;
+ unsigned int chan_start;
dma_addr_t zero_page;
const struct bcm2835_dma_cfg *cfg;
bool map_resource;
@@ -127,6 +129,7 @@ struct bcm2835_chan {
* @abort: stop and reset a channel
* @legacy_bus_addr: translate a slave address for device trees which do not
* describe the peripheral window in dma-ranges
+ * @chan_mask: channels of the DMA block using this programming model
*/
struct bcm2835_dma_cfg {
u32 cs_reg;
@@ -161,6 +164,7 @@ struct bcm2835_dma_cfg {
void (*abort)(struct bcm2835_chan *c);
u64 (*legacy_bus_addr)(struct device *dev, phys_addr_t phys);
+ u32 chan_mask;
};
struct bcm2835_desc {
@@ -271,7 +275,8 @@ struct bcm2835_desc {
#define BCM2835_DMA_DATA_TYPE_S128 16
/* Valid only for channels 0 - 14, 15 has its own base address */
-#define BCM2835_DMA_CHAN(n) ((n) << 8) /* Base address */
+#define BCM2835_DMA_CHAN_SIZE 0x100
+#define BCM2835_DMA_CHAN(n) ((n) * BCM2835_DMA_CHAN_SIZE) /* Base address */
#define BCM2835_DMA_CHANIO(base, n) ((base) + BCM2835_DMA_CHAN(n))
/* the max dma length for different channels */
@@ -1189,7 +1194,7 @@ static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id,
c->vc.desc_free = bcm2835_dma_desc_free;
vchan_init(&c->vc, &d->ddev);
- c->chan_base = BCM2835_DMA_CHANIO(d->base, chan_id);
+ c->chan_base = BCM2835_DMA_CHANIO(d->base, chan_id - d->chan_start);
c->ch = chan_id;
c->irq_number = irq;
c->irq_flags = irq_flags;
@@ -1237,6 +1242,7 @@ static const struct bcm2835_dma_cfg bcm2835_data = {
.abort = bcm2835_dma_abort_chan,
.legacy_bus_addr = bcm2835_dma_legacy_bus_addr,
+ .chan_mask = GENMASK(BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED, 0),
};
static const struct of_device_id bcm2835_dma_of_match[] = {
@@ -1335,6 +1341,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
int irq_flags;
u32 chans_available;
char chan_name[BCM2835_DMA_CHAN_NAME_SIZE];
+ int chan_count, chan_start, chan_end;
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
@@ -1360,7 +1367,19 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
if (IS_ERR(base))
return PTR_ERR(base);
+ /*
+ * The channels of a DMA block can be split across multiple instances,
+ * e.g. because they have a different programming model. The block
+ * itself is 4 KiB aligned, so the position of the first channel of
+ * this instance can be derived from the physical register address.
+ */
+ chan_start = (res->start / BCM2835_DMA_CHAN_SIZE) & 0xf;
+ chan_count = resource_size(res) / BCM2835_DMA_CHAN_SIZE;
+ chan_end = min(chan_start + chan_count,
+ BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED + 1);
+
od->base = base;
+ od->chan_start = chan_start;
od->map_resource = bcm2835_dma_mmio_in_dma_ranges(&pdev->dev,
res->start);
@@ -1417,13 +1436,30 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "Please update DT blob\n");
}
+ /*
+ * Never drive channels with a different programming model, which
+ * some device trees put in the same node.
+ */
+ if (chans_available & ~od->cfg->chan_mask) {
+ dev_warn(&pdev->dev, "ignoring unsupported channels %#x\n",
+ chans_available & ~od->cfg->chan_mask);
+ chans_available &= od->cfg->chan_mask;
+ if (!chans_available) {
+ rc = -ENODEV;
+ goto err_no_dma;
+ }
+ }
+
+ for (i = 0; i <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; i++)
+ irq[i] = -1;
+
/* get irqs for each channel that we support */
- for (i = 0; i <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; i++) {
+ for (i = chan_start; i < chan_end; i++) {
+ int index = i - chan_start;
+
/* skip masked out channels */
- if (!(chans_available & (1 << i))) {
- irq[i] = -1;
+ if (!(chans_available & (1 << i)))
continue;
- }
/* get the named irq */
snprintf(chan_name, sizeof(chan_name), "dma%i", i);
@@ -1438,11 +1474,13 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
* in case of channel >= 11
* use the 11th interrupt and that is shared
*/
- irq[i] = platform_get_irq(pdev, i < 11 ? i : 11);
+ irq[i] = platform_get_irq(pdev, index < 11 ? index : 11);
}
+ chan_count = 0;
+
/* get irqs for each channel */
- for (i = 0; i <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; i++) {
+ for (i = chan_start; i < chan_end; i++) {
/* skip channels without irq */
if (irq[i] < 0)
continue;
@@ -1459,9 +1497,11 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
rc = bcm2835_dma_chan_init(od, i, irq[i], irq_flags);
if (rc)
goto err_no_dma;
+
+ chan_count++;
}
- dev_dbg(&pdev->dev, "Initialized %i DMA channels\n", i);
+ dev_dbg(&pdev->dev, "Initialized %i DMA channels\n", chan_count);
/* Device-tree DMA controller registration */
rc = of_dma_controller_register(pdev->dev.of_node,
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 21/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2711 40-bit DMA
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (19 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 20/28] dmaengine: bcm2835: Support channel subsets in a controller instance Andrea della Porta
@ 2026-11-23 14:56 ` Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 22/28] dmaengine: bcm2835: Add BCM2711 40-bit DMA support Andrea della Porta
` (6 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
On BCM2711 the last four channels of the DMA block (11 to 14) have a
different programming model allowing them to address 40 bits, and are
described by a separate node with their own compatible. Each of them
has a dedicated interrupt.
Constrain the interrupt names, whose numbering refers to the whole DMA
block also for nodes describing a subset of the channels, and require
them for the new compatible.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
.../bindings/dma/brcm,bcm2835-dma.yaml | 47 ++++++++++++++++++-
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
index f619e395cf0d..b53652d5146b 100644
--- a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
+++ b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
@@ -9,18 +9,41 @@ title: BCM2835 DMA controller
maintainers:
- Nicolas Saenz Julienne <nsaenz@kernel.org>
-description:
+description: |
The BCM2835 DMA controller has 16 channels in total. Only the lower
13 channels have an associated IRQ. Some arbitrary channels are used by the
VideoCore firmware (1,3,6,7 in the current firmware version). The channels
0, 2 and 3 have special functionality and should not be used by the driver.
+ On BCM2711 the channels 11 to 14 of the same DMA block have a different
+ programming model, which allows them to address 40 bits, and are described
+ by a separate node.
+
+ The channel numbers used in the channel mask and in the interrupt names
+ always refer to the whole DMA block, also when a node only describes some
+ of its channels.
+
allOf:
- $ref: dma-controller.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: brcm,bcm2711-dma
+ then:
+ properties:
+ interrupts:
+ maxItems: 4
+ interrupt-names:
+ maxItems: 4
+ required:
+ - interrupt-names
properties:
compatible:
- const: brcm,bcm2835-dma
+ enum:
+ - brcm,bcm2711-dma
+ - brcm,bcm2835-dma
reg:
maxItems: 1
@@ -35,6 +58,8 @@ properties:
interrupt-names:
minItems: 1
maxItems: 16
+ items:
+ pattern: "^dma([0-9]|1[0-4]|-shared-all)$"
'#dma-cells':
description: |
@@ -119,4 +144,22 @@ examples:
dma-channel-mask = <0x7f35>;
};
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ dma-controller@7e007b00 {
+ compatible = "brcm,bcm2711-dma";
+ reg = <0x7e007b00 0x400>;
+ interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "dma11",
+ "dma12",
+ "dma13",
+ "dma14";
+ #dma-cells = <1>;
+ dma-channel-mask = <0x7000>;
+ };
+
...
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 22/28] dmaengine: bcm2835: Add BCM2711 40-bit DMA support
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (20 preceding siblings ...)
2026-11-23 14:56 ` [PATCH v3 21/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2711 40-bit DMA Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
2026-11-23 15:09 ` sashiko-bot
2026-11-23 14:57 ` [PATCH v3 23/28] ARM: dts: bcm2711: Add the 40-bit DMA controller Andrea della Porta
` (5 subsequent siblings)
27 siblings, 1 reply; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
BCM2711 has 4 DMA channels with a 40-bit address range, allowing them
to access the full memory of a Pi 4. They are part of the same DMA
block as the legacy channels, but have a different register layout and
control block format, and are described by a separate DT node.
The memory side addresses are programmed as-is, while slave addresses
are translated by dma_map_resource() using the dma-ranges of the
controller, which map the peripherals into the upper part of the 40-bit
address space. This translation cannot be derived from the ranges of
the parent bus, so there is no fallback for device trees not describing
it: the 40-bit channels are only described by device trees which come
with the proper dma-ranges, i.e. the downstream ones and the one added
by this series. Since the peripherals are only reachable there,
refuse to probe the 40-bit channels if dma_addr_t is only 32-bit wide.
The DMA mask describes the 40-bit capability of the channels, the
reachable range being limited by the dma-ranges of their bus. The control
blocks are however addressed through 32-bit registers holding bits 36:5
of their address, so limit the coherent DMA mask, used for their
allocation, to 37 bits.
Unlike the legacy channels, the 40-bit ones are stopped by pausing them,
waiting for the outstanding AXI transactions and resetting them through
the DEBUG register.
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 343 ++++++++++++++++++++++++++++++++++++--
1 file changed, 331 insertions(+), 12 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 0ea903274286..a98ea67d3406 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -17,6 +17,7 @@
* MARVELL MMP Peripheral DMA Driver
* Copyright 2012 Marvell International Ltd.
*/
+#include <linux/bitfield.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
@@ -72,6 +73,17 @@ struct bcm2835_dma_cb {
u32 pad[2];
};
+struct bcm2711_dma40_scb {
+ u32 ti;
+ u32 src;
+ u32 srci;
+ u32 dst;
+ u32 dsti;
+ u32 len;
+ u32 next_cb;
+ u32 rsvd;
+};
+
struct bcm2835_cb_entry {
struct bcm_dma_cb *cb;
dma_addr_t paddr;
@@ -114,6 +126,7 @@ struct bcm2835_chan {
* @cb_reg: offset of the control block address register
* @int_mask: interrupt status bit in the CS register
* @active_mask: channel active bit in the CS register
+ * @dma_mask: addressing capability of the channels
* @cb_get_length: get the transfer length of a control block
* @cb_get_addr: get the memory side address of a control block
* @cb_init: initialize a control block
@@ -128,7 +141,8 @@ struct bcm2835_chan {
* @cs_flags: per-channel flags for the CS register
* @abort: stop and reset a channel
* @legacy_bus_addr: translate a slave address for device trees which do not
- * describe the peripheral window in dma-ranges
+ * describe the peripheral window in dma-ranges, NULL if they cannot be
+ * supported
* @chan_mask: channels of the DMA block using this programming model
*/
struct bcm2835_dma_cfg {
@@ -138,6 +152,8 @@ struct bcm2835_dma_cfg {
u32 int_mask;
u32 active_mask;
+ u64 dma_mask;
+
u32 (*cb_get_length)(void *data);
dma_addr_t (*cb_get_addr)(void *data, enum dma_transfer_direction);
@@ -283,6 +299,67 @@ struct bcm2835_desc {
#define MAX_DMA_LEN SZ_1G
#define MAX_LITE_DMA_LEN (SZ_64K - 4)
+/* 40-bit DMA channel registers */
+#define BCM2711_DMA40_CS 0x00
+#define BCM2711_DMA40_CB 0x04
+#define BCM2711_DMA40_DEBUG 0x0c
+#define BCM2711_DMA40_TI 0x10
+#define BCM2711_DMA40_SRC 0x14
+#define BCM2711_DMA40_SRCI 0x18
+#define BCM2711_DMA40_DEST 0x1c
+#define BCM2711_DMA40_DESTI 0x20
+#define BCM2711_DMA40_LEN 0x24
+#define BCM2711_DMA40_NEXT_CB 0x28
+#define BCM2711_DMA40_DEBUG2 0x2c
+
+/* 40-bit DMA CS Control and Status bits */
+#define BCM2711_DMA40_ACTIVE BIT(0)
+#define BCM2711_DMA40_END BIT(1)
+#define BCM2711_DMA40_INT BIT(2)
+#define BCM2711_DMA40_DREQ BIT(3) /* DREQ state */
+#define BCM2711_DMA40_RD_PAUSED BIT(4) /* Reading is paused */
+#define BCM2711_DMA40_WR_PAUSED BIT(5) /* Writing is paused */
+#define BCM2711_DMA40_DREQ_PAUSED BIT(6) /* Is paused by DREQ flow control */
+#define BCM2711_DMA40_WAITING_FOR_WRITES BIT(7) /* Waiting for last write */
+#define BCM2711_DMA40_PROT GENMASK(9, 8) /* AXI protection, supervisor mode */
+#define BCM2711_DMA40_ERR BIT(10)
+#define BCM2711_DMA40_QOS(x) FIELD_PREP(GENMASK(19, 16), x)
+#define BCM2711_DMA40_PANIC_QOS(x) FIELD_PREP(GENMASK(23, 20), x)
+#define BCM2711_DMA40_TRANSACTIONS BIT(25) /* AXI transactions outstanding */
+#define BCM2711_DMA40_WAIT_FOR_WRITES BIT(28)
+#define BCM2711_DMA40_DISDEBUG BIT(29)
+#define BCM2711_DMA40_ABORT BIT(30)
+#define BCM2711_DMA40_HALT BIT(31)
+#define BCM2711_DMA40_CS_FLAGS(x) ((x) & (BCM2711_DMA40_QOS(15) | \
+ BCM2711_DMA40_PANIC_QOS(15) | \
+ BCM2711_DMA40_WAIT_FOR_WRITES | \
+ BCM2711_DMA40_DISDEBUG))
+
+/* 40-bit DMA transfer information bits */
+#define BCM2711_DMA40_INTEN BIT(0)
+#define BCM2711_DMA40_TDMODE BIT(1) /* 2D-Mode */
+#define BCM2711_DMA40_WAIT_RESP BIT(2) /* wait for AXI write to be acked */
+#define BCM2711_DMA40_WAIT_RD_RESP BIT(3) /* wait for AXI read to complete */
+#define BCM2711_DMA40_PER_MAP(x) FIELD_PREP(GENMASK(13, 9), x) /* REQ source */
+#define BCM2711_DMA40_S_DREQ BIT(14) /* enable SREQ for source */
+#define BCM2711_DMA40_D_DREQ BIT(15) /* enable DREQ for destination */
+#define BCM2711_DMA40_S_WAIT(x) FIELD_PREP(GENMASK(23, 16), x) /* read-wait cycles */
+#define BCM2711_DMA40_D_WAIT(x) FIELD_PREP(GENMASK(31, 24), x) /* write-wait cycles */
+
+/* 40-bit DMA source and destination information bits */
+#define BCM2711_DMA40_ADDR_HI GENMASK(7, 0) /* bits 39:32 of the address */
+#define BCM2711_DMA40_BURST_LEN(x) FIELD_PREP(GENMASK(11, 8), x)
+#define BCM2711_DMA40_INC BIT(12)
+#define BCM2711_DMA40_SIZE_32 FIELD_PREP(GENMASK(14, 13), 0)
+#define BCM2711_DMA40_SIZE_64 FIELD_PREP(GENMASK(14, 13), 1)
+#define BCM2711_DMA40_SIZE_128 FIELD_PREP(GENMASK(14, 13), 2)
+#define BCM2711_DMA40_SIZE_256 FIELD_PREP(GENMASK(14, 13), 3)
+#define BCM2711_DMA40_IGNORE BIT(15)
+#define BCM2711_DMA40_STRIDE(x) FIELD_PREP(GENMASK(31, 16), x) /* For 2D mode */
+
+/* 40-bit DMA debug register bits */
+#define BCM2711_DMA40_DEBUG_RESET BIT(23)
+
static inline size_t bcm2835_dma_max_frame_length(struct bcm2835_chan *c)
{
/* lite and normal channels have different max frame length */
@@ -487,6 +564,199 @@ static u32 bcm2835_dma_cs_flags(struct bcm2835_chan *c)
return BCM2835_DMA_CS_FLAGS(c->dreq);
}
+static inline u32 to_bcm2711_ti(u32 info)
+{
+ return ((info & BCM2835_DMA_INT_EN) ? BCM2711_DMA40_INTEN : 0) |
+ ((info & BCM2835_DMA_WAIT_RESP) ? BCM2711_DMA40_WAIT_RESP : 0) |
+ ((info & BCM2835_DMA_S_DREQ) ?
+ (BCM2711_DMA40_S_DREQ | BCM2711_DMA40_WAIT_RD_RESP) : 0) |
+ ((info & BCM2835_DMA_D_DREQ) ? BCM2711_DMA40_D_DREQ : 0) |
+ BCM2711_DMA40_PER_MAP((info >> 16) & 0x1f);
+}
+
+static inline u32 to_bcm2711_srci(u32 info)
+{
+ return ((info & BCM2835_DMA_S_INC) ? BCM2711_DMA40_INC : 0) |
+ ((info & BCM2835_DMA_S_WIDTH) ? BCM2711_DMA40_SIZE_128 : 0) |
+ BCM2711_DMA40_BURST_LEN(BCM2835_DMA_GET_BURST_LENGTH(info));
+}
+
+static inline u32 to_bcm2711_dsti(u32 info)
+{
+ return ((info & BCM2835_DMA_D_INC) ? BCM2711_DMA40_INC : 0) |
+ ((info & BCM2835_DMA_D_WIDTH) ? BCM2711_DMA40_SIZE_128 : 0) |
+ BCM2711_DMA40_BURST_LEN(BCM2835_DMA_GET_BURST_LENGTH(info));
+}
+
+static inline dma_addr_t bcm2711_dma40_addr(u32 lo, u32 info)
+{
+ return (dma_addr_t)(((u64)FIELD_GET(BCM2711_DMA40_ADDR_HI, info) << 32) | lo);
+}
+
+static inline u32 bcm2711_dma40_info_addr(u32 info, dma_addr_t addr)
+{
+ return (info & ~BCM2711_DMA40_ADDR_HI) |
+ FIELD_PREP(BCM2711_DMA40_ADDR_HI, upper_32_bits(addr));
+}
+
+static u32 bcm2711_dma_prepare_cb_extra(struct bcm2835_chan *c,
+ enum dma_transfer_direction direction,
+ bool cyclic, bool final,
+ unsigned long flags)
+{
+ u32 result = 0;
+
+ if (cyclic) {
+ if (flags & DMA_PREP_INTERRUPT)
+ result |= BCM2711_DMA40_INTEN;
+ } else {
+ if (!final)
+ return 0;
+
+ result |= BCM2711_DMA40_INTEN;
+
+ if (direction == DMA_MEM_TO_MEM)
+ result |= BCM2711_DMA40_WAIT_RESP;
+ }
+
+ return result;
+}
+
+static inline u32 bcm2711_dma_cb_get_length(void *data)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ return scb->len;
+}
+
+static inline dma_addr_t
+bcm2711_dma_cb_get_addr(void *data, enum dma_transfer_direction direction)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ if (direction == DMA_DEV_TO_MEM)
+ return bcm2711_dma40_addr(scb->dst, scb->dsti);
+
+ return bcm2711_dma40_addr(scb->src, scb->srci);
+}
+
+static inline void
+bcm2711_dma_cb_init(void *data, struct bcm2835_chan *c,
+ enum dma_transfer_direction direction, dma_addr_t src,
+ dma_addr_t dst, bool zero_page)
+{
+ struct bcm2711_dma40_scb *scb = data;
+ u32 info = bcm2835_dma_prepare_cb_info(c, direction, zero_page);
+
+ scb->ti = to_bcm2711_ti(info);
+ scb->src = lower_32_bits(src);
+ scb->srci = bcm2711_dma40_info_addr(to_bcm2711_srci(info), src);
+ scb->dst = lower_32_bits(dst);
+ scb->dsti = bcm2711_dma40_info_addr(to_bcm2711_dsti(info), dst);
+ scb->len = 0;
+ scb->next_cb = 0;
+ scb->rsvd = 0;
+}
+
+static inline void
+bcm2711_dma_cb_set_src(void *data, enum dma_transfer_direction direction,
+ dma_addr_t src)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ scb->src = lower_32_bits(src);
+ scb->srci = bcm2711_dma40_info_addr(scb->srci, src);
+}
+
+static inline void
+bcm2711_dma_cb_set_dst(void *data, enum dma_transfer_direction direction,
+ dma_addr_t dst)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ scb->dst = lower_32_bits(dst);
+ scb->dsti = bcm2711_dma40_info_addr(scb->dsti, dst);
+}
+
+static inline void bcm2711_dma_cb_set_next(void *data, u32 next)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ scb->next_cb = next;
+}
+
+static inline void bcm2711_dma_cb_set_length(void *data, u32 length)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ scb->len = length;
+}
+
+static inline void
+bcm2711_dma_cb_append_extra(void *data, struct bcm2835_chan *c,
+ enum dma_transfer_direction direction,
+ bool cyclic, bool final, unsigned long flags)
+{
+ struct bcm2711_dma40_scb *scb = data;
+
+ scb->ti |= bcm2711_dma_prepare_cb_extra(c, direction, cyclic, final,
+ flags);
+}
+
+/* control blocks are 32 byte aligned, the register holds bits 36:5 */
+static inline u32 bcm2711_dma_to_cb_addr(dma_addr_t addr)
+{
+ WARN_ON_ONCE(addr & 0x1f);
+
+ return (u64)addr >> 5;
+}
+
+static dma_addr_t bcm2711_dma_read_addr(struct bcm2835_chan *c,
+ enum dma_transfer_direction direction)
+{
+ if (direction == DMA_MEM_TO_DEV)
+ return bcm2711_dma40_addr(readl(c->chan_base + BCM2711_DMA40_SRC),
+ readl(c->chan_base + BCM2711_DMA40_SRCI));
+ else if (direction == DMA_DEV_TO_MEM)
+ return bcm2711_dma40_addr(readl(c->chan_base + BCM2711_DMA40_DEST),
+ readl(c->chan_base + BCM2711_DMA40_DESTI));
+
+ return 0;
+}
+
+static u32 bcm2711_dma_cs_flags(struct bcm2835_chan *c)
+{
+ return BCM2711_DMA40_CS_FLAGS(c->dreq) | BCM2711_DMA40_PROT;
+}
+
+static void bcm2711_dma_abort_chan(struct bcm2835_chan *c)
+{
+ void __iomem *chan_base = c->chan_base;
+ long timeout = 100;
+
+ /* Pause the current DMA */
+ writel(readl(chan_base + BCM2711_DMA40_CS) & ~BCM2711_DMA40_ACTIVE,
+ chan_base + BCM2711_DMA40_CS);
+
+ /* wait for outstanding transactions to complete */
+ while ((readl(chan_base + BCM2711_DMA40_CS) & BCM2711_DMA40_TRANSACTIONS) &&
+ --timeout)
+ cpu_relax();
+
+ /* Peripheral might be stuck and fail to complete */
+ if (!timeout)
+ dev_err(c->vc.chan.device->dev,
+ "failed to complete pause on dma %d (CS:%08x)\n", c->ch,
+ readl(chan_base + BCM2711_DMA40_CS));
+
+ /* Set CS back to default state */
+ writel(BCM2711_DMA40_PROT, chan_base + BCM2711_DMA40_CS);
+
+ /* Reset the DMA */
+ writel(readl(chan_base + BCM2711_DMA40_DEBUG) | BCM2711_DMA40_DEBUG_RESET,
+ chan_base + BCM2711_DMA40_DEBUG);
+}
+
static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc)
{
size_t i;
@@ -1199,7 +1469,8 @@ static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id,
c->irq_number = irq;
c->irq_flags = irq_flags;
- d->cfg->chan_plat_init(c);
+ if (d->cfg->chan_plat_init)
+ d->cfg->chan_plat_init(c);
return 0;
}
@@ -1225,6 +1496,8 @@ static const struct bcm2835_dma_cfg bcm2835_data = {
.int_mask = BCM2835_DMA_INT,
.active_mask = BCM2835_DMA_ACTIVE,
+ .dma_mask = DMA_BIT_MASK(32),
+
.cb_get_length = bcm2835_dma_cb_get_length,
.cb_get_addr = bcm2835_dma_cb_get_addr,
.cb_init = bcm2835_dma_cb_init,
@@ -1245,7 +1518,35 @@ static const struct bcm2835_dma_cfg bcm2835_data = {
.chan_mask = GENMASK(BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED, 0),
};
+static const struct bcm2835_dma_cfg bcm2711_data = {
+ .cs_reg = BCM2711_DMA40_CS,
+ .cb_reg = BCM2711_DMA40_CB,
+
+ .int_mask = BCM2711_DMA40_INT,
+ .active_mask = BCM2711_DMA40_ACTIVE,
+
+ .dma_mask = DMA_BIT_MASK(40),
+
+ .cb_get_length = bcm2711_dma_cb_get_length,
+ .cb_get_addr = bcm2711_dma_cb_get_addr,
+ .cb_init = bcm2711_dma_cb_init,
+ .cb_set_src = bcm2711_dma_cb_set_src,
+ .cb_set_dst = bcm2711_dma_cb_set_dst,
+ .cb_set_next = bcm2711_dma_cb_set_next,
+ .cb_set_length = bcm2711_dma_cb_set_length,
+ .cb_append_extra = bcm2711_dma_cb_append_extra,
+
+ .to_cb_addr = bcm2711_dma_to_cb_addr,
+
+ .read_addr = bcm2711_dma_read_addr,
+ .cs_flags = bcm2711_dma_cs_flags,
+ .abort = bcm2711_dma_abort_chan,
+
+ .chan_mask = GENMASK(14, 11),
+};
+
static const struct of_device_id bcm2835_dma_of_match[] = {
+ { .compatible = "brcm,bcm2711-dma", .data = &bcm2711_data },
{ .compatible = "brcm,bcm2835-dma", .data = &bcm2835_data },
{},
};
@@ -1343,15 +1644,6 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
char chan_name[BCM2835_DMA_CHAN_NAME_SIZE];
int chan_count, chan_start, chan_end;
- if (!pdev->dev.dma_mask)
- pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
-
- rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
- if (rc) {
- dev_err(&pdev->dev, "Unable to set DMA mask\n");
- return rc;
- }
-
od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL);
if (!od)
return -ENOMEM;
@@ -1361,6 +1653,28 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, -EINVAL,
"Failed to match compatible string\n");
+ /* the peripherals are only reachable above 4 GiB by 40-bit channels */
+ if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
+ od->cfg->dma_mask > DMA_BIT_MASK(32))
+ return dev_err_probe(&pdev->dev, -ENODEV,
+ "40-bit DMA channels need a 64-bit dma_addr_t\n");
+
+ if (!pdev->dev.dma_mask)
+ pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+
+ /*
+ * The control blocks are addressed through 32-bit registers holding
+ * at most bits 36:5 of their address.
+ */
+ rc = dma_set_mask(&pdev->dev, od->cfg->dma_mask);
+ if (!rc)
+ rc = dma_set_coherent_mask(&pdev->dev,
+ min(od->cfg->dma_mask, DMA_BIT_MASK(37)));
+ if (rc) {
+ dev_err(&pdev->dev, "Unable to set DMA mask\n");
+ return rc;
+ }
+
dma_set_max_seg_size(&pdev->dev, 0x3FFFFFFF);
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
@@ -1383,9 +1697,14 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
od->map_resource = bcm2835_dma_mmio_in_dma_ranges(&pdev->dev,
res->start);
- if (!od->map_resource)
+ if (!od->map_resource) {
+ if (!od->cfg->legacy_bus_addr)
+ return dev_err_probe(&pdev->dev, -EINVAL,
+ "peripheral window missing in dma-ranges\n");
+
dev_info(&pdev->dev,
"peripheral window missing in dma-ranges, please update DT blob\n");
+ }
dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 23/28] ARM: dts: bcm2711: Add the 40-bit DMA controller
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (21 preceding siblings ...)
2026-11-23 14:57 ` [PATCH v3 22/28] dmaengine: bcm2835: Add BCM2711 40-bit DMA support Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 24/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2712 40-bit DMA Andrea della Porta
` (4 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
BCM2711 has 4 DMA channels with a 40-bit address range, allowing them
to access the whole memory of a Pi 4. Add a node describing them.
The 40-bit channels see the RAM at its CPU physical address and the
peripherals at 0x4_7c000000. Describe this through the dma-ranges of a
dedicated bus, rather than adding them to the scb bus, as the latter
would change the DMA configuration of the PCIe and Ethernet controllers
too. The RAM window skips the peripheral window of the CPU address map,
so that the peripheral FIFOs are not translated 1:1.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
arch/arm/boot/dts/broadcom/bcm2711.dtsi | 32 +++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/arch/arm/boot/dts/broadcom/bcm2711.dtsi b/arch/arm/boot/dts/broadcom/bcm2711.dtsi
index f475422796d8..d152edc069bc 100644
--- a/arch/arm/boot/dts/broadcom/bcm2711.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2711.dtsi
@@ -436,6 +436,38 @@ emmc2: mmc@7e340000 {
};
};
+ /*
+ * The 40-bit DMA channels see the RAM at its CPU physical address,
+ * and the peripherals in the upper part of their address space. Give
+ * them their own bus, so as to not affect the other devices.
+ */
+ dma40-bus@fe007b00 {
+ compatible = "simple-bus";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ ranges = <0x0 0x7e007b00 0x0 0xfe007b00 0x0 0x00000400>;
+ dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0xfc000000>,
+ <0x1 0x00000000 0x1 0x00000000 0x3 0x00000000>,
+ <0x4 0x7c000000 0x0 0xfc000000 0x0 0x03800000>;
+
+ dma40: dma-controller@7e007b00 {
+ compatible = "brcm,bcm2711-dma";
+ reg = <0x0 0x7e007b00 0x0 0x400>;
+ interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>, /* dma4 11 */
+ <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>, /* dma4 12 */
+ <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>, /* dma4 13 */
+ <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>; /* dma4 14 */
+ interrupt-names = "dma11",
+ "dma12",
+ "dma13",
+ "dma14";
+ #dma-cells = <1>;
+ /* The VPU firmware uses DMA channel 11 for VCHIQ */
+ dma-channel-mask = <0x7000>;
+ };
+ };
+
pmu {
compatible = "arm,cortex-a72-pmu";
interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 24/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2712 40-bit DMA
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (22 preceding siblings ...)
2026-11-23 14:57 ` [PATCH v3 23/28] ARM: dts: bcm2711: Add the 40-bit DMA controller Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 25/28] dmaengine: bcm2835: Add BCM2712 40-bit DMA support Andrea della Porta
` (3 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
BCM2712 has six DMA channels (6 to 11) with the same 40-bit programming
model as the BCM2711 ones, each with a dedicated interrupt. Add a
compatible for them.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
.../bindings/dma/brcm,bcm2835-dma.yaml | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
index b53652d5146b..0c74cc1d223e 100644
--- a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
+++ b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
@@ -17,7 +17,8 @@ description: |
On BCM2711 the channels 11 to 14 of the same DMA block have a different
programming model, which allows them to address 40 bits, and are described
- by a separate node.
+ by a separate node. BCM2712 has six channels with the same programming
+ model, numbered from 6 to 11.
The channel numbers used in the channel mask and in the interrupt names
always refer to the whole DMA block, also when a node only describes some
@@ -38,11 +39,25 @@ allOf:
maxItems: 4
required:
- interrupt-names
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: brcm,bcm2712-dma
+ then:
+ properties:
+ interrupts:
+ maxItems: 6
+ interrupt-names:
+ maxItems: 6
+ required:
+ - interrupt-names
properties:
compatible:
enum:
- brcm,bcm2711-dma
+ - brcm,bcm2712-dma
- brcm,bcm2835-dma
reg:
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 25/28] dmaengine: bcm2835: Add BCM2712 40-bit DMA support
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (23 preceding siblings ...)
2026-11-23 14:57 ` [PATCH v3 24/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2712 40-bit DMA Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 26/28] arm64: dts: broadcom: bcm2712: Add the 40-bit DMA controller Andrea della Porta
` (2 subsequent siblings)
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
BCM2712 has six DMA channels (6 to 11) with the same programming model
as the BCM2711 40-bit channels.
These channels see both the RAM and the peripherals at their CPU
physical address. The bus they sit on maps them 1:1, so device trees
without dma-ranges are handled by the same fallback as the legacy
channels, i.e. by reverting the ranges of the parent bus.
The remaining channels (0 to 5) use the legacy control block format,
extended with the upper address bits stored in the stride field, and are
not supported for now. The downstream device tree describes them with
the same compatible, in a separate node: such a node is rejected thanks
to the channel mask of the platform data.
Link: https://github.com/raspberrypi/linux/commit/99c26cc709c0e3658c3f8d78cfb856cc20bdd0e3
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
drivers/dma/bcm2835-dma.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index a98ea67d3406..cf435dfb04dc 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -1545,8 +1545,38 @@ static const struct bcm2835_dma_cfg bcm2711_data = {
.chan_mask = GENMASK(14, 11),
};
+static const struct bcm2835_dma_cfg bcm2712_data = {
+ .cs_reg = BCM2711_DMA40_CS,
+ .cb_reg = BCM2711_DMA40_CB,
+
+ .int_mask = BCM2711_DMA40_INT,
+ .active_mask = BCM2711_DMA40_ACTIVE,
+
+ .dma_mask = DMA_BIT_MASK(40),
+
+ .cb_get_length = bcm2711_dma_cb_get_length,
+ .cb_get_addr = bcm2711_dma_cb_get_addr,
+ .cb_init = bcm2711_dma_cb_init,
+ .cb_set_src = bcm2711_dma_cb_set_src,
+ .cb_set_dst = bcm2711_dma_cb_set_dst,
+ .cb_set_next = bcm2711_dma_cb_set_next,
+ .cb_set_length = bcm2711_dma_cb_set_length,
+ .cb_append_extra = bcm2711_dma_cb_append_extra,
+
+ .to_cb_addr = bcm2711_dma_to_cb_addr,
+
+ .read_addr = bcm2711_dma_read_addr,
+ .cs_flags = bcm2711_dma_cs_flags,
+ .abort = bcm2711_dma_abort_chan,
+
+ /* the parent bus maps the peripherals 1:1 on BCM2712 */
+ .legacy_bus_addr = bcm2835_dma_legacy_bus_addr,
+ .chan_mask = GENMASK(11, 6),
+};
+
static const struct of_device_id bcm2835_dma_of_match[] = {
{ .compatible = "brcm,bcm2711-dma", .data = &bcm2711_data },
+ { .compatible = "brcm,bcm2712-dma", .data = &bcm2712_data },
{ .compatible = "brcm,bcm2835-dma", .data = &bcm2835_data },
{},
};
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 26/28] arm64: dts: broadcom: bcm2712: Add the 40-bit DMA controller
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (24 preceding siblings ...)
2026-11-23 14:57 ` [PATCH v3 25/28] dmaengine: bcm2835: Add BCM2712 40-bit DMA support Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 27/28] ARM: dts: broadcom: Set the DMA flags of the HDMI audio channel on BCM283x Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 28/28] arm64: dts: broadcom: bcm2712: Enable HDMI audio Andrea della Porta
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
BCM2712 has six DMA channels (6 to 11) with a 40-bit address range. Add a
node describing them. The axi bus already describes a 1:1 translation for
both the RAM and the peripherals in its dma-ranges.
Channel 11 is used by the VPU firmware.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/arm64/boot/dts/broadcom/bcm2712.dtsi b/arch/arm64/boot/dts/broadcom/bcm2712.dtsi
index edae2f3584a8..7ba0fc540257 100644
--- a/arch/arm64/boot/dts/broadcom/bcm2712.dtsi
+++ b/arch/arm64/boot/dts/broadcom/bcm2712.dtsi
@@ -676,6 +676,26 @@ iommuc: iommuc@1000005b00 {
reg = <0x10 0x5b00 0x0 0x80>;
};
+ dma40: dma-controller@1000010600 {
+ compatible = "brcm,bcm2712-dma";
+ reg = <0x10 0x00010600 0x00 0x600>;
+ interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "dma6",
+ "dma7",
+ "dma8",
+ "dma9",
+ "dma10",
+ "dma11";
+ #dma-cells = <1>;
+ /* The VPU firmware uses DMA channel 11 for VCHIQ */
+ dma-channel-mask = <0x07c0>;
+ };
+
mip0: msi-controller@1000130000 {
compatible = "brcm,bcm2712-mip";
reg = <0x10 0x00130000 0x00 0xc0>,
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 27/28] ARM: dts: broadcom: Set the DMA flags of the HDMI audio channel on BCM283x
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (25 preceding siblings ...)
2026-11-23 14:57 ` [PATCH v3 26/28] arm64: dts: broadcom: bcm2712: Add the 40-bit DMA controller Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 28/28] arm64: dts: broadcom: bcm2712: Enable HDMI audio Andrea della Porta
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
The upper bits of the DMA specifier of the BCM2835 DMA controller carry
per-channel flags, which nothing uses in the upstream device trees so
far.
Request wide (128-bit) source reads and skip waiting for the AXI write
responses on the HDMI audio channel of BCM283x, as done for years by the
downstream Raspberry Pi device trees. This reduces the bus traffic
needed to feed the MAI FIFO.
BCM2711 is left alone: the downstream device trees route its HDMI audio
through the 40-bit channels, so there is no established set of flags for
its legacy channels.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
arch/arm/boot/dts/broadcom/bcm2835-common.dtsi | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi b/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi
index 39eea8ce1058..6267f0a67565 100644
--- a/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi
@@ -130,7 +130,8 @@ hdmi: hdmi@7e902000 {
clocks = <&clocks BCM2835_PLLH_PIX>,
<&clocks BCM2835_CLOCK_HSM>;
clock-names = "pixel", "hdmi";
- dmas = <&dma 17>;
+ /* DREQ 17, no AXI write response wait, wide source reads */
+ dmas = <&dma (17 | (1 << 27) | (1 << 24))>;
dma-names = "audio-rx";
status = "disabled";
};
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 28/28] arm64: dts: broadcom: bcm2712: Enable HDMI audio
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
` (26 preceding siblings ...)
2026-11-23 14:57 ` [PATCH v3 27/28] ARM: dts: broadcom: Set the DMA flags of the HDMI audio channel on BCM283x Andrea della Porta
@ 2026-11-23 14:57 ` Andrea della Porta
27 siblings, 0 replies; 36+ messages in thread
From: Andrea della Porta @ 2026-11-23 14:57 UTC (permalink / raw)
To: Vinod Koul
Cc: Frank Li, dmaengine, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, devicetree, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Saenz Julienne, Stefan Wahren, Dave Stevenson, Phil Elwell,
Dom Cobley, Maxime Ripard, Robin Murphy, linux-rpi-kernel,
linux-arm-kernel, linux-kernel, Andrea della Porta
The HDMI controllers of BCM2712 feed their MAI FIFO through the 40-bit
DMA channels. Describe them, so that vc4 registers the HDMI audio
devices.
The DREQ lines of the HDMI audio changed between the C1 and D0 steppings
(10/17 and 12/13 respectively), while the flags request multi-beat
bursts, wide source reads and the AXI priorities used by the downstream
Raspberry Pi device trees, where these values come from.
Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
---
arch/arm64/boot/dts/broadcom/bcm2712-d-rpi-5-b.dts | 9 +++++++++
arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/arch/arm64/boot/dts/broadcom/bcm2712-d-rpi-5-b.dts b/arch/arm64/boot/dts/broadcom/bcm2712-d-rpi-5-b.dts
index ae4b7c587dbc..97a4b819c01a 100644
--- a/arch/arm64/boot/dts/broadcom/bcm2712-d-rpi-5-b.dts
+++ b/arch/arm64/boot/dts/broadcom/bcm2712-d-rpi-5-b.dts
@@ -8,6 +8,15 @@ / {
model = "Raspberry Pi 5 d0 Stepping";
};
+/* The HDMI audio DREQs changed on D0 */
+&hdmi0 {
+ dmas = <&dma40 (12 | (1 << 30) | (1 << 24) | (10 << 16) | (15 << 20))>;
+};
+
+&hdmi1 {
+ dmas = <&dma40 (13 | (1 << 30) | (1 << 24) | (10 << 16) | (15 << 20))>;
+};
+
&gio_aon {
brcm,gpio-bank-widths = <15 6>;
diff --git a/arch/arm64/boot/dts/broadcom/bcm2712.dtsi b/arch/arm64/boot/dts/broadcom/bcm2712.dtsi
index 7ba0fc540257..b7d7623ee9c8 100644
--- a/arch/arm64/boot/dts/broadcom/bcm2712.dtsi
+++ b/arch/arm64/boot/dts/broadcom/bcm2712.dtsi
@@ -483,6 +483,9 @@ hdmi0: hdmi@7c701400 {
interrupt-names = "cec-tx", "cec-rx", "cec-low",
"hpd-connected", "hpd-removed";
ddc = <&ddc0>;
+ /* DREQ 10, burst, wide source reads, priority 10, panic 15 */
+ dmas = <&dma40 (10 | (1 << 30) | (1 << 24) | (10 << 16) | (15 << 20))>;
+ dma-names = "audio-rx";
status = "disabled";
};
@@ -513,6 +516,9 @@ hdmi1: hdmi@7c706400 {
interrupt-names = "cec-tx", "cec-rx", "cec-low",
"hpd-connected", "hpd-removed";
ddc = <&ddc1>;
+ /* DREQ 17, burst, wide source reads, priority 10, panic 15 */
+ dmas = <&dma40 (17 | (1 << 30) | (1 << 24) | (10 << 16) | (15 << 20))>;
+ dma-names = "audio-rx";
status = "disabled";
};
--
2.51.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH v3 09/28] dmaengine: bcm2835: move CB final extra info generation into function
2026-11-23 14:56 ` [PATCH v3 09/28] dmaengine: bcm2835: move CB final extra info generation into function Andrea della Porta
@ 2026-11-23 15:01 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:01 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] dmaengine: bcm2835: missing flags in
bcm2835_dma_prep_dma_cyclic()
--
commit 1144e8bbc4cd12d7e2def4ac967c328f6f4a0c4f
Author: Andrea della Porta <andrea.porta@suse.com>
dmaengine: bcm2835: move CB final extra info generation into function
This commit moves the generation of the final control block extra info
bits into a new helper function, bcm2835_dma_prepare_cb_extra().
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index adf3508246ec3..77b3e2f58ac50 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
> @@ -253,6 +253,26 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c,
> return result;
> }
>
> +static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c,
> + enum dma_transfer_direction direction,
> + bool cyclic, bool final,
> + unsigned long flags)
> +{
> + u32 result = 0;
> +
> + if (cyclic) {
> + if (flags & DMA_PREP_INTERRUPT)
> + result |= BCM2835_DMA_INT_EN;
> + } else {
> + if (!final)
> + return 0;
> +
> + result |= BCM2835_DMA_INT_EN;
> + }
> +
> + return result;
> +}
[ ... ]
> @@ -747,7 +768,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
> dma_addr_t src, dst;
> u32 info = bcm2835_dma_prepare_cb_info(c, direction,
> buf_addr == od->zero_page);
> - u32 extra = 0;
> + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0);
> size_t max_len = bcm2835_dma_max_frame_length(c);
> size_t frames;
>
> @@ -763,9 +784,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
> return NULL;
> }
>
> - if (flags & DMA_PREP_INTERRUPT)
> - extra |= BCM2835_DMA_INT_EN;
> - else
> + if (!(flags & DMA_PREP_INTERRUPT))
> period_len = buf_len;
[Severity: High]
Should bcm2835_dma_prep_dma_cyclic() pass flags instead of 0 to
bcm2835_dma_prepare_cb_extra()? Passing 0 prevents BCM2835_DMA_INT_EN
from ever being set on cyclic transfers when DMA_PREP_INTERRUPT is
requested, so cyclic period interrupts never fire.
This regression is resolved later in the series by commit "dmaengine:
bcm2835: drop info parameters", which moves the
bcm2835_dma_prepare_cb_extra() call into bcm2835_dma_create_cb_chain()
and passes flags, but cyclic DMA remains broken at this commit during
git bisection.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=9
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo
2026-11-23 14:56 ` [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo Andrea della Porta
@ 2026-11-23 15:05 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:05 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dmaengine: bcm2835: commit message claims nonexistent typo fix
--
commit 90d915a14d82485dbf4682dc628270b622babb4c
Author: Andrea della Porta <andrea.porta@suse.com>
> dmaengine: bcm2835: Fix coding style issues and a typo
>
> Fix the coding style issues reported by checkpatch: use u32 instead of
> uint32_t, add the missing parentheses around macro arguments, which
> could lead to operator precedence issues, drop superfluous parentheses
> and long int, and align the function arguments. Also fix a typo in a
> comment ('missmatch').
>
> Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
[Severity: Low]
This isn't a bug, but the "missmatch" comment typo in
bcm2835_dma_create_cb_chain() was already fixed by commit a688efea0f2a
("dmaengine: Fix spelling mistakes"), so this patch does not fix any
typo. The changelog also omits removing the local variable d and the
chained assignment in bcm2835_dma_start_desc().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=1
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort
2026-11-23 14:56 ` [PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort Andrea della Porta
@ 2026-11-23 15:08 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:08 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] dmaengine: bcm2835: broken NEXTCB abort and write drain in
bcm2835_dma_abort()
--
commit a058188488f658c2a3df2427a8957114d4f32435
Author: Dom Cobley <popcornmix@gmail.com>
dmaengine: bcm2835: Fixes for dma_abort
This commit updates bcm2835_dma_abort() to clear BCM2835_DMA_NEXTCB,
issue BCM2835_DMA_ABORT with a shorter poll timeout, and suppress the
timeout error message when DREQ pacing is enabled.
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 063e1b2aabe3c..51e3a40dbaece 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();
>
> - /* 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);
> }
[Severity: High]
Does this reintroduce the abort regressions fixed by commit 9e528c799d17
("dmaengine: bcm2835: Fix abort of transactions")?
Commit 9e528c799d17 replaced this BCM2835_DMA_NEXTCB and
BCM2835_DMA_ABORT sequence with pausing the channel, waiting for
BCM2835_DMA_WAITING_FOR_WRITES to clear, and asserting BCM2835_DMA_RESET.
When a channel is blocked on an unasserted DREQ, no AXI write is in
flight, so BCM2835_DMA_WAITING_FOR_WRITES is already clear and the
existing pause-and-reset path completes immediately without timing out.
Reverting to BCM2835_DMA_ABORT introduces three problems:
1. BCM2835_DMA_NEXTCB is written while BCM2835_DMA_ACTIVE is still set,
which per the BCM2835 ARM Peripherals specification is only safe when the
channel is paused; racing with control block completion can cause
BCM2835_DMA_ABORT to abort only the current control block and start the
next one.
2. After clearing BCM2835_DMA_ACTIVE, the code writes BCM2835_DMA_RESET
without waiting for BCM2835_DMA_WAITING_FOR_WRITES to clear, so
bcm2835_dma_terminate_all() can reset the channel and free descriptors
while AXI writes are still in flight.
3. Because BCM2835_DMA_ABORT never completes while a channel is held on
an unasserted DREQ, every termination of a DREQ-blocked channel (such as
dmaengine_terminate_async() on the companion channel at the end of
one-way transfers in bcm2835_spi_dma_rx_done() and
bcm2835_spi_dma_tx_done()) now busy-waits for the full 100-iteration
(~20 us) timeout with interrupts disabled under c->vc.lock.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=5
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 22/28] dmaengine: bcm2835: Add BCM2711 40-bit DMA support
2026-11-23 14:57 ` [PATCH v3 22/28] dmaengine: bcm2835: Add BCM2711 40-bit DMA support Andrea della Porta
@ 2026-11-23 15:09 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:09 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dmaengine: bcm2835: missing BCM2711_DMA40_IGNORE in
to_bcm2711_srci()
--
commit 43d03cc19b62f4a54ac975aa54643cf367639895
Author: Andrea della Porta <andrea.porta@suse.com>
dmaengine: bcm2835: Add BCM2711 40-bit DMA support
This commit adds support for the BCM2711 40-bit DMA channels, which use a
different register layout and control block format than the legacy BCM2835
DMA channels.
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 0ea903274286f..a98ea67d3406e 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
[ ... ]
> @@ -487,6 +564,199 @@ static u32 bcm2835_dma_cs_flags(struct bcm2835_chan *c)
> return BCM2835_DMA_CS_FLAGS(c->dreq);
> }
>
> +static inline u32 to_bcm2711_ti(u32 info)
> +{
> + return ((info & BCM2835_DMA_INT_EN) ? BCM2711_DMA40_INTEN : 0) |
> + ((info & BCM2835_DMA_WAIT_RESP) ? BCM2711_DMA40_WAIT_RESP : 0) |
> + ((info & BCM2835_DMA_S_DREQ) ?
> + (BCM2711_DMA40_S_DREQ | BCM2711_DMA40_WAIT_RD_RESP) : 0) |
> + ((info & BCM2835_DMA_D_DREQ) ? BCM2711_DMA40_D_DREQ : 0) |
> + BCM2711_DMA40_PER_MAP((info >> 16) & 0x1f);
> +}
> +
> +static inline u32 to_bcm2711_srci(u32 info)
> +{
> + return ((info & BCM2835_DMA_S_INC) ? BCM2711_DMA40_INC : 0) |
> + ((info & BCM2835_DMA_S_WIDTH) ? BCM2711_DMA40_SIZE_128 : 0) |
> + BCM2711_DMA40_BURST_LEN(BCM2835_DMA_GET_BURST_LENGTH(info));
> +}
[Severity: Medium]
Should to_bcm2711_srci() also translate BCM2835_DMA_S_IGNORE into
BCM2711_DMA40_IGNORE?
bcm2711_dma_cb_init() calls bcm2835_dma_prepare_cb_info(), which sets
BCM2835_DMA_S_IGNORE in info when zero_page is true, and passes info to
to_bcm2711_srci(). Because to_bcm2711_srci() drops that bit,
BCM2711_DMA40_IGNORE is left unused and zero-page transfers on 40-bit
channels will read from DRAM instead of letting the hardware synthesize
zeroes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=22
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 03/28] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag
2026-11-23 14:56 ` [PATCH v3 03/28] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag Andrea della Porta
@ 2026-11-23 15:09 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:09 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dmaengine: bcm2835: stale c->dreq flags used in
bcm2835_dma_prep_dma_memcpy()
--
commit 05a74b3bafa3990da181e6875af63b349a17f80c
Author: Phil Elwell <phil@raspberrypi.com>
dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag
This commit adds support for the BCM2835_DMA_NO_WAIT_RESP,
BCM2835_DMA_WIDE_SOURCE, and BCM2835_DMA_WIDE_DEST flags encoded in the DT
DMA dreq cell and applies them when preparing DMA descriptors.
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index 690f5ba1c4399..118ba2f71dc8b 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
[ ... ]
> @@ -605,8 +620,9 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
> {
> struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
> struct bcm2835_desc *d;
> - u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC;
> - u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP;
> + u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC |
> + WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq);
> + u32 extra = BCM2835_DMA_INT_EN;
[Severity: Medium]
Can bcm2835_dma_prep_dma_memcpy() inherit stale c->dreq flags from a
previously released DT slave channel?
c->dreq is only set in bcm2835_dma_xlate() and is not cleared in
bcm2835_dma_free_chan_resources() or bcm2835_dma_alloc_chan_resources().
If a DT slave channel with upper flag bits in c->dreq is freed and later
allocated by a non-DT DMA_MEMCPY caller via dma_request_chan_by_mask()
(such as vc4_dsi_bind() for 4-byte register writes in
dsi_dma_workaround_write()), bcm2835_dma_prep_dma_memcpy() will program
control blocks with unintended 128-bit transfer widths or without
BCM2835_DMA_WAIT_RESP.
Resetting c->dreq to 0 in bcm2835_dma_free_chan_resources() would avoid
leaking DT flags across channel allocations.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=3
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 19/28] ARM: dts: broadcom: Describe the peripheral window in dma-ranges
2026-11-23 14:56 ` [PATCH v3 19/28] ARM: dts: broadcom: Describe the peripheral window in dma-ranges Andrea della Porta
@ 2026-11-23 15:17 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:17 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ARM: dts: broadcom: bcm2711 /soc dma-ranges breaks arm64
ZONE_DMA limit
--
commit 62f5c2b6b29c90da76685d8a93502df302796458
Author: Andrea della Porta <andrea.porta@suse.com>
ARM: dts: broadcom: Describe the peripheral window in dma-ranges
This commit adds the VideoCore peripheral address windows to the /soc
dma-ranges properties on BCM2835, BCM2836, BCM2837, and BCM2711 so that
dma_map_resource() can translate peripheral FIFO physical addresses to
DMA bus addresses.
> diff --git a/arch/arm/boot/dts/broadcom/bcm2711.dtsi b/arch/arm/boot/dts/broadcom/bcm2711.dtsi
> index 5e3b4bb393967..f475422796d8e 100644
> --- a/arch/arm/boot/dts/broadcom/bcm2711.dtsi
> +++ b/arch/arm/boot/dts/broadcom/bcm2711.dtsi
> @@ -41,8 +41,12 @@ soc {
> ranges = <0x7e000000 0x0 0xfe000000 0x01800000>,
> <0x7c000000 0x0 0xfc000000 0x02000000>,
> <0x40000000 0x0 0xff800000 0x00800000>;
> - /* Emulate a contiguous 30-bit address range for DMA */
> - dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>;
> + /*
> + * Emulate a contiguous 30-bit address range for DMA, and
> + * let the DMA controllers reach the peripherals
> + */
> + dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>,
> + <0x7c000000 0x0 0xfc000000 0x03800000>;
[Severity: High]
Does adding the 0xfc000000 peripheral window to /soc dma-ranges raise
the arm64 ZONE_DMA limit above the 1 GiB RAM window that /soc devices
can actually reach?
On arm64, dma_limits_init() sizes ZONE_DMA and sets arm64_dma_phys_limit
from of_dma_get_max_cpu_address(NULL), which takes the highest
cpu_addr + size - 1 across all entries in a node's dma-ranges before
taking the minimum across nodes:
drivers/of/address.c:of_dma_get_max_cpu_address() {
...
for_each_of_range(&parser, &range)
if (range.cpu_addr + range.size > cpu_end)
cpu_end = range.cpu_addr + range.size - 1;
if (max_cpu_addr > cpu_end)
max_cpu_addr = cpu_end;
...
}
This raises /soc's cpu_end from 0x3fffffff (1 GiB - 1) to 0xff7fffff.
Because the Raspberry Pi firmware rewrites emmc2bus dma-ranges on newer
BCM2711 revisions, /soc is the only node keeping the system-wide limit
at 1 GiB. On boards with more than 1 GiB of RAM, ZONE_DMA and the
SWIOTLB bounce pool expand up to 3 GiB (0xbfffffff, from pcie0), so
GFP_DMA allocations and SWIOTLB bounce buffers can be placed above 1 GiB
where /soc devices have no RAM dma-ranges translation and fail DMA
mapping.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=19
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 14/28] dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses
2026-11-23 14:56 ` [PATCH v3 14/28] dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses Andrea della Porta
@ 2026-11-23 15:21 ` sashiko-bot
0 siblings, 0 replies; 36+ messages in thread
From: sashiko-bot @ 2026-11-23 15:21 UTC (permalink / raw)
To: Andrea della Porta; +Cc: dmaengine, devicetree, robh, conor+dt, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] dmaengine: bcm2835: inverted DMA direction in
bcm2835_dma_slave_config()
- [Medium] dmaengine: bcm2835: redundant slave remapping in
bcm2835_dma_slave_config()
--
commit d1ee75073d9e0c52f103b1cc6d74fd59a5d9e874
Author: Andrea della Porta <andrea.porta@suse.com>
dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses
This commit translates slave FIFO physical addresses in
bcm2835_dma_slave_config() via dma_map_resource(), falling back to parent
bus range translation when the peripheral window is absent from
dma-ranges.
Link: https://lore.kernel.org/linux-arm-kernel/ee19a95d-fe1e-4f3f-bc81-bdef38475469@arm.com/
Link: https://lore.kernel.org/all/CAPY8ntByJYzSv0kTAc1kY0Dp=vwrzcA0oWiPpyg7x7_BQwGSnA@mail.gmail.com/
> diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
> index f8b2202096d65..3ff30c41dc63f 100644
> --- a/drivers/dma/bcm2835-dma.c
> +++ b/drivers/dma/bcm2835-dma.c
[ ... ]
> @@ -798,11 +821,30 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan)
> c->irq_flags, "DMA IRQ", chan);
> }
>
> +static void bcm2835_dma_unmap_slave_addr(struct dma_chan *chan,
> + struct bcm2835_slave_addr *sa,
> + enum dma_data_direction dir)
> +{
> + if (sa->mapped)
> + dma_unmap_resource(chan->device->dev, sa->addr, sa->size, dir, 0);
> +
> + memset(sa, 0, sizeof(*sa));
> +}
> +
> +static void bcm2835_dma_unmap_slave_addrs(struct dma_chan *chan)
> +{
> + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
> +
> + bcm2835_dma_unmap_slave_addr(chan, &c->slave_src, DMA_FROM_DEVICE);
> + bcm2835_dma_unmap_slave_addr(chan, &c->slave_dst, DMA_TO_DEVICE);
> +}
[ ... ]
> @@ -1019,10 +1061,87 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
> return vchan_tx_prep(&c->vc, &d->vd, flags);
> }
>
> +/*
> + * Device trees which do not describe the peripheral window in dma-ranges
> + * are handled by assuming that the legacy DMA channels see the peripherals
> + * at the same address as the bus they sit on, i.e. by reverting the
> + * translation described by the ranges property of the parent bus. This is
> + * how the VideoCore bus addresses have always been derived. Addresses which
> + * are not CPU physical addresses of that bus are passed through unchanged,
> + * as legacy clients used to provide bus addresses.
> + */
> +static u64 bcm2835_dma_legacy_bus_addr(struct device *dev, phys_addr_t phys)
> +{
> + struct device_node *bus = of_get_parent(dev->of_node);
> + struct of_range_parser parser;
> + struct of_range range;
> + u64 addr = phys;
> +
> + if (bus && !of_range_parser_init(&parser, bus)) {
> + for_each_of_range(&parser, &range) {
> + if (phys >= range.cpu_addr &&
> + phys - range.cpu_addr < range.size) {
> + addr = range.bus_addr + (phys - range.cpu_addr);
> + break;
> + }
> + }
> + }
> +
> + of_node_put(bus);
> +
> + return addr;
> +}
> +
> +static int bcm2835_dma_map_slave_addr(struct dma_chan *chan,
> + struct bcm2835_slave_addr *sa,
> + phys_addr_t phys,
> + enum dma_slave_buswidth width,
> + enum dma_data_direction dir)
> +{
> + struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device);
> + struct device *dev = chan->device->dev;
> + size_t size = width ? width : DMA_SLAVE_BUSWIDTH_4_BYTES;
> +
> + if (!phys)
> + return 0;
> +
> + if (!od->map_resource) {
> + sa->addr = od->cfg->legacy_bus_addr(dev, phys);
> + return 0;
> + }
> +
> + sa->addr = dma_map_resource(dev, phys, size, dir, 0);
> + if (dma_mapping_error(dev, sa->addr)) {
> + dev_err(dev, "failed to map slave address %pa\n", &phys);
> + sa->addr = 0;
> + return -EINVAL;
> + }
> +
> + sa->size = size;
> + sa->mapped = true;
> +
> + return 0;
> +}
> +
> static int bcm2835_dma_slave_config(struct dma_chan *chan,
> struct dma_slave_config *cfg)
> {
> struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
> + int ret;
> +
> + bcm2835_dma_unmap_slave_addrs(chan);
[Severity: Medium]
Does unmapping both c->slave_src and c->slave_dst unconditionally here
cause every MMC transfer to tear down and recreate the slave mapping?
drivers/mmc/host/bcm2835.c shares one rx-tx channel and calls
dmaengine_slave_config() in bcm2835_prepare_dma() before every request,
passing either dma_cfg_rx (with dst_addr = 0) or dma_cfg_tx (with
src_addr = 0). When !od->map_resource, every MMC request walks the parent
device tree node and parses ranges under devtree_lock in
bcm2835_dma_legacy_bus_addr(); when od->map_resource is true, every
request calls dma_unmap_resource() and dma_map_resource() again instead of
reusing the existing mapping.
> +
> + ret = bcm2835_dma_map_slave_addr(chan, &c->slave_src, cfg->src_addr,
> + cfg->src_addr_width, DMA_FROM_DEVICE);
> + if (ret)
> + return ret;
> +
> + ret = bcm2835_dma_map_slave_addr(chan, &c->slave_dst, cfg->dst_addr,
> + cfg->dst_addr_width, DMA_TO_DEVICE);
[Severity: Medium]
Are DMA_FROM_DEVICE and DMA_TO_DEVICE swapped here and in
bcm2835_dma_unmap_slave_addrs()?
dma_map_resource() is called on the DMA controller device
(chan->device->dev), which is the DMA master. For c->slave_src
(DMA_DEV_TO_MEM), the DMA controller reads from the slave FIFO, which is
DMA_TO_DEVICE (IOMMU_READ); for c->slave_dst (DMA_MEM_TO_DEV), the DMA
controller writes to the slave FIFO, which is DMA_FROM_DEVICE
(IOMMU_WRITE). With an IOMMU or direction-checking DMA backend, the
inverted directions grant write-only permission to the source FIFO and
read-only permission to the destination FIFO.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123145728.29082-1-andrea.porta@suse.com?part=14
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2026-11-23 15:21 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:56 [PATCH v3 00/28] dmaengine: bcm2835: add BCM2711 and BCM2712 40-bit DMA support Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 01/28] dmaengine: bcm2835: Fix coding style issues and a typo Andrea della Porta
2026-11-23 15:05 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 02/28] dmaengine: bcm2835: Add support for per-channel flags Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 03/28] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag Andrea della Porta
2026-11-23 15:09 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 04/28] dmaengine: bcm2835: Support dma flags for multi-beat burst Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 05/28] dmaengine: bcm2835: Fixes for dma_abort Andrea della Porta
2026-11-23 15:08 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 06/28] dt-bindings: dma: brcm,bcm2835-dma: Document dma-channel-mask and DREQ flags Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 07/28] dmaengine: bcm2835: Support common dma-channel-mask Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 08/28] dmaengine: bcm2835: move CB info generation into separate function Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 09/28] dmaengine: bcm2835: move CB final extra info generation into function Andrea della Porta
2026-11-23 15:01 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 10/28] dmaengine: bcm2835: make address increment platform independent Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 11/28] dmaengine: bcm2835: drop info parameters Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 12/28] dmaengine: bcm2835: pass dma_chan to generic functions Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 13/28] dmaengine: bcm2835: introduce multi platform support Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 14/28] dmaengine: bcm2835: Use dma_map_resource() to translate slave addresses Andrea della Porta
2026-11-23 15:21 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 15/28] spi: bcm2835: Pass the CPU physical address of the FIFO to the DMA engine Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 16/28] mmc: bcm2835: Pass the CPU physical address of SDDATA " Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 17/28] ASoC: bcm2835-i2s: Pass the CPU physical address of the FIFO " Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 18/28] drm/vc4: hdmi: Pass the CPU physical address of MAI_DATA " Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 19/28] ARM: dts: broadcom: Describe the peripheral window in dma-ranges Andrea della Porta
2026-11-23 15:17 ` sashiko-bot
2026-11-23 14:56 ` [PATCH v3 20/28] dmaengine: bcm2835: Support channel subsets in a controller instance Andrea della Porta
2026-11-23 14:56 ` [PATCH v3 21/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2711 40-bit DMA Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 22/28] dmaengine: bcm2835: Add BCM2711 40-bit DMA support Andrea della Porta
2026-11-23 15:09 ` sashiko-bot
2026-11-23 14:57 ` [PATCH v3 23/28] ARM: dts: bcm2711: Add the 40-bit DMA controller Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 24/28] dt-bindings: dma: brcm,bcm2835-dma: Add BCM2712 40-bit DMA Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 25/28] dmaengine: bcm2835: Add BCM2712 40-bit DMA support Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 26/28] arm64: dts: broadcom: bcm2712: Add the 40-bit DMA controller Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 27/28] ARM: dts: broadcom: Set the DMA flags of the HDMI audio channel on BCM283x Andrea della Porta
2026-11-23 14:57 ` [PATCH v3 28/28] arm64: dts: broadcom: bcm2712: Enable HDMI audio Andrea della Porta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox