* [PATCH] dmaengine: sun6i: constrain descriptor addresses through the DMA mask
@ 2026-10-21 21:11 James Hilliard
2026-10-22 16:10 ` Frank Li
0 siblings, 1 reply; 3+ messages in thread
From: James Hilliard @ 2026-10-21 21:11 UTC (permalink / raw)
To: Vinod Koul, Frank Li, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: dmaengine, linux-arm-kernel, linux-sunxi, linux-kernel, James Hilliard
Descriptor allocations pass GFP_DMA32 to dma_pool_alloc(). The DMA API
chooses the memory zone from the device address mask, rather than accepting
zone-selection flags from the driver. These flags can also reach the pool
metadata allocation and trigger a slab allocator warning, as observed on
H616 when preparing the first UART receive-DMA chain.
Set a 32-bit coherent DMA mask before creating the descriptor pool and
remove GFP_DMA32 from its allocations. The driver does not encode the
extra descriptor-address bits supported by some variants, so descriptor
links must remain below 4 GiB. Keep the streaming mask unchanged for
variants with wider source and destination addresses.
Fixes: ec31c5c59492 ("dmaengine: sun6i: Add support for 34-bit physical addresses")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/dma/sun6i-dma.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index 7704b016aed8..0ef6ed1f936e 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -684,7 +684,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
if (!txd)
return NULL;
- v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
+ v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
if (!v_lli) {
dev_err(sdev->slave.dev, "Failed to alloc lli memory\n");
goto err_txd_free;
@@ -743,7 +743,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(
return NULL;
for_each_sg(sgl, sg, sg_len, i) {
- v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
+ v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
if (!v_lli)
goto err_lli_free;
@@ -826,7 +826,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(
return NULL;
for (i = 0; i < periods; i++) {
- v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
+ v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
if (!v_lli) {
dev_err(sdev->slave.dev, "Failed to alloc lli memory\n");
goto err_lli_free;
@@ -1345,6 +1345,11 @@ static int sun6i_dma_probe(struct platform_device *pdev)
return PTR_ERR(sdc->rstc);
}
+ /* This driver uses unextended 32-bit addresses for descriptor links. */
+ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret)
+ return ret;
+
sdc->pool = dmam_pool_create(dev_name(&pdev->dev), &pdev->dev,
sizeof(struct sun6i_dma_lli), 4, 0);
if (!sdc->pool) {
---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20261021-submit-sun6i-dma-descriptor-mask-v1-35bb381b932a
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: sun6i: constrain descriptor addresses through the DMA mask
2026-10-21 21:11 [PATCH] dmaengine: sun6i: constrain descriptor addresses through the DMA mask James Hilliard
@ 2026-10-22 16:10 ` Frank Li
2026-10-22 19:13 ` James Hilliard
0 siblings, 1 reply; 3+ messages in thread
From: Frank Li @ 2026-10-22 16:10 UTC (permalink / raw)
To: James Hilliard
Cc: Vinod Koul, Frank Li, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland, dmaengine, linux-arm-kernel, linux-sunxi,
linux-kernel
On Wed, Oct 21, 2026 at 03:11:29PM -0600, James Hilliard wrote:
> Descriptor allocations pass GFP_DMA32 to dma_pool_alloc(). The DMA API
> chooses the memory zone from the device address mask, rather than accepting
> zone-selection flags from the driver. These flags can also reach the pool
> metadata allocation and trigger a slab allocator warning, as observed on
> H616 when preparing the first UART receive-DMA chain.
>
> Set a 32-bit coherent DMA mask before creating the descriptor pool and
> remove GFP_DMA32 from its allocations. The driver does not encode the
> extra descriptor-address bits supported by some variants, so descriptor
> links must remain below 4 GiB. Keep the streaming mask unchanged for
> variants with wider source and destination addresses.
Spouse other dma address in src/dest in descriptor also limited to 32bit.
Do you means only descripor address have 32bit limiation, other have not
such limiation?
Frank
>
> Fixes: ec31c5c59492 ("dmaengine: sun6i: Add support for 34-bit physical addresses")
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> drivers/dma/sun6i-dma.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index 7704b016aed8..0ef6ed1f936e 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -684,7 +684,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
> if (!txd)
> return NULL;
>
> - v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
> + v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
> if (!v_lli) {
> dev_err(sdev->slave.dev, "Failed to alloc lli memory\n");
> goto err_txd_free;
> @@ -743,7 +743,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(
> return NULL;
>
> for_each_sg(sgl, sg, sg_len, i) {
> - v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
> + v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
> if (!v_lli)
> goto err_lli_free;
>
> @@ -826,7 +826,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(
> return NULL;
>
> for (i = 0; i < periods; i++) {
> - v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
> + v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
> if (!v_lli) {
> dev_err(sdev->slave.dev, "Failed to alloc lli memory\n");
> goto err_lli_free;
> @@ -1345,6 +1345,11 @@ static int sun6i_dma_probe(struct platform_device *pdev)
> return PTR_ERR(sdc->rstc);
> }
>
> + /* This driver uses unextended 32-bit addresses for descriptor links. */
> + ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> + if (ret)
> + return ret;
> +
> sdc->pool = dmam_pool_create(dev_name(&pdev->dev), &pdev->dev,
> sizeof(struct sun6i_dma_lli), 4, 0);
> if (!sdc->pool) {
>
> ---
> base-commit: 93f51579e7df248780214094418f205253383cc5
> change-id: 20261021-submit-sun6i-dma-descriptor-mask-v1-35bb381b932a
>
> Best regards,
> --
> James Hilliard <james.hilliard1@gmail.com>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: sun6i: constrain descriptor addresses through the DMA mask
2026-10-22 16:10 ` Frank Li
@ 2026-10-22 19:13 ` James Hilliard
0 siblings, 0 replies; 3+ messages in thread
From: James Hilliard @ 2026-10-22 19:13 UTC (permalink / raw)
To: Frank Li
Cc: Vinod Koul, Frank Li, Chen-Yu Tsai, Jernej Skrabec,
Samuel Holland, dmaengine, linux-arm-kernel, linux-sunxi,
linux-kernel
On Thu, Oct 22, 2026 at 10:10 AM Frank Li <Frank.li@oss.nxp.com> wrote:
>
> On Wed, Oct 21, 2026 at 03:11:29PM -0600, James Hilliard wrote:
> > Descriptor allocations pass GFP_DMA32 to dma_pool_alloc(). The DMA API
> > chooses the memory zone from the device address mask, rather than accepting
> > zone-selection flags from the driver. These flags can also reach the pool
> > metadata allocation and trigger a slab allocator warning, as observed on
> > H616 when preparing the first UART receive-DMA chain.
> >
> > Set a 32-bit coherent DMA mask before creating the descriptor pool and
> > remove GFP_DMA32 from its allocations. The driver does not encode the
> > extra descriptor-address bits supported by some variants, so descriptor
> > links must remain below 4 GiB. Keep the streaming mask unchanged for
> > variants with wider source and destination addresses.
>
> Spouse other dma address in src/dest in descriptor also limited to 32bit.
The src and dst fields contain the low 32 bits, but on variants with
has_high_addr, sun6i_dma_set_addr() stores address bits 33:32 in the
descriptor's para word: bits 17:16 for the source and bits 19:18 for the
destination. Those variants therefore support 34-bit payload addresses.
Variants without that capability retain 32-bit addressing.
> Do you means only descripor address have 32bit limiation, other have not
> such limiation?
For the current driver, yes: descriptor addresses must remain below
4 GiB, while payload addresses can use the wider range on supported
variants.
The descriptor restriction is not necessarily a hardware limitation.
Some variants also support extended descriptor addresses, but require
encoding their high bits into the otherwise-unused low address bits.
The driver does not implement that encoding: it writes the descriptor
address directly to DMA_CHAN_LLI_ADDR and stores the next descriptor
address directly in p_lli_next.
The patch preserves that existing restriction by setting the coherent
DMA mask used by dma_pool_alloc(), instead of passing GFP_DMA32.
The streaming mask and existing payload-address encoding remain
unchanged.
> Frank
> >
> > Fixes: ec31c5c59492 ("dmaengine: sun6i: Add support for 34-bit physical addresses")
> > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > ---
> > drivers/dma/sun6i-dma.c | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> > index 7704b016aed8..0ef6ed1f936e 100644
> > --- a/drivers/dma/sun6i-dma.c
> > +++ b/drivers/dma/sun6i-dma.c
> > @@ -684,7 +684,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
> > if (!txd)
> > return NULL;
> >
> > - v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
> > + v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
> > if (!v_lli) {
> > dev_err(sdev->slave.dev, "Failed to alloc lli memory\n");
> > goto err_txd_free;
> > @@ -743,7 +743,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(
> > return NULL;
> >
> > for_each_sg(sgl, sg, sg_len, i) {
> > - v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
> > + v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
> > if (!v_lli)
> > goto err_lli_free;
> >
> > @@ -826,7 +826,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(
> > return NULL;
> >
> > for (i = 0; i < periods; i++) {
> > - v_lli = dma_pool_alloc(sdev->pool, GFP_DMA32 | GFP_NOWAIT, &p_lli);
> > + v_lli = dma_pool_alloc(sdev->pool, GFP_NOWAIT, &p_lli);
> > if (!v_lli) {
> > dev_err(sdev->slave.dev, "Failed to alloc lli memory\n");
> > goto err_lli_free;
> > @@ -1345,6 +1345,11 @@ static int sun6i_dma_probe(struct platform_device *pdev)
> > return PTR_ERR(sdc->rstc);
> > }
> >
> > + /* This driver uses unextended 32-bit addresses for descriptor links. */
> > + ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> > + if (ret)
> > + return ret;
> > +
> > sdc->pool = dmam_pool_create(dev_name(&pdev->dev), &pdev->dev,
> > sizeof(struct sun6i_dma_lli), 4, 0);
> > if (!sdc->pool) {
> >
> > ---
> > base-commit: 93f51579e7df248780214094418f205253383cc5
> > change-id: 20261021-submit-sun6i-dma-descriptor-mask-v1-35bb381b932a
> >
> > Best regards,
> > --
> > James Hilliard <james.hilliard1@gmail.com>
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-22 19:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 21:11 [PATCH] dmaengine: sun6i: constrain descriptor addresses through the DMA mask James Hilliard
2026-10-22 16:10 ` Frank Li
2026-10-22 19:13 ` James Hilliard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®