[PATCH] dmaengine: sh: rz-dmac: Set DMA_PRIVATE to avoid channel stealing by async_tx
From: John Madieu
Date: Wed Jun 10 2026 - 13:43:37 EST
When CONFIG_ASYNC_TX_DMA is enabled, the async_tx framework calls
dmaengine_get() at boot, which walks dma_channel_rebalance() ->
min_chan() to populate its per-CPU channel table with channels usable
for memory offload operations. These public pool paths only skip
devices that have DMA_PRIVATE set in their capability mask.
The rz-dmac driver advertises DMA_MEMCPY but does not set DMA_PRIVATE,
so async_tx claims its channels at boot. When a peripheral driver later
requests its dedicated channel through the DT-based path
(dma_request_chan()), the channel has already been taken and the
request fails. This is observed with the sound driver on the RZ/G3E
SMARC EVK, where audio DMA channel allocation fails, but any rz-dmac
consumer can be affected.
Set DMA_PRIVATE in the capability mask to keep rz-dmac channels out of
the public pool. Legitimate consumer paths are unaffected: the DT path
(of_dma_request_slave_channel() -> dma_get_slave_channel()) does not
reject DMA_PRIVATE devices (it sets the flag and increments privatecnt
itself), and the filter-based path (dma_request_channel() ->
private_candidate()), used for instance by dmatest, does not filter
them out either.
Signed-off-by: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>
---
drivers/dma/sh/rz-dmac.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index ca76f1bb45c4..4acf6463a5f6 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -1488,6 +1488,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
dma_cap_set(DMA_SLAVE, engine->cap_mask);
dma_cap_set(DMA_MEMCPY, engine->cap_mask);
dma_cap_set(DMA_CYCLIC, engine->cap_mask);
+ dma_cap_set(DMA_PRIVATE, engine->cap_mask);
engine->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
engine->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
rz_dmac_writel(dmac, DCTRL_DEFAULT, CHANNEL_0_7_COMMON_BASE + DCTRL);
--
2.25.1