* [PATCH 0/2] dmaengine: dw-axi-dmac: Fix burst length encoding and LLI dump
@ 2026-08-28 0:48 Jia Wang
2026-08-28 0:48 ` [PATCH 1/2] dmaengine: dw-axi-dmac: Fix AXI burst length encoding Jia Wang
2026-08-28 0:48 ` [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access Jia Wang
0 siblings, 2 replies; 6+ messages in thread
From: Jia Wang @ 2026-08-28 0:48 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Pandith N,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, Jia Wang
The first patch converts the configured AXI burst length from a beat count
to the ARLEN/AWLEN encoding when constructing hardware descriptors. Without
this conversion, a 256-beat burst overflows the 8-bit hardware fields and
may cause DMA transfer errors.
The second patch bounds the error-path LLI dump by the number of
descriptors in the current transaction. This prevents an original DMA error
from being followed by an out-of-bounds access and kernel panic while
dumping LLIs.
The series was tested with dmatest on all eight channels using
snps,axi-max-burst-len = <256>. All channels completed without errors.
Signed-off-by: Jia Wang <wangjia@ultrarisc.com>
---
Jia Wang (2):
dmaengine: dw-axi-dmac: Fix AXI burst length encoding
dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
---
base-commit: 1b78070aaef63512688aebfbc82365ef9d6660f1
change-id: 20260827-dma-fix-c2b27795ce12
Best regards,
--
Jia Wang <wangjia@ultrarisc.com>
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] dmaengine: dw-axi-dmac: Fix AXI burst length encoding
2026-08-28 0:48 [PATCH 0/2] dmaengine: dw-axi-dmac: Fix burst length encoding and LLI dump Jia Wang
@ 2026-08-28 0:48 ` Jia Wang
2026-08-28 19:32 ` Frank Li
2026-08-28 0:48 ` [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access Jia Wang
1 sibling, 1 reply; 6+ messages in thread
From: Jia Wang @ 2026-08-28 0:48 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Pandith N,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, Jia Wang
The snps,axi-max-burst-len property describes the number of beats in an
AXI burst, while the ARLEN and AWLEN fields encode that value minus one.
The driver keeps axi_rw_burst_len as the actual burst length so that
dma_device.max_burst reports the correct value. However, it also programs
that unencoded value directly into the hardware fields. A value of 256
therefore overflows the 8-bit fields and can cause AXI decode errors.
Subtract one only when constructing hardware descriptors, while keeping
the actual value for dma_device.max_burst.
Fixes: c454d16a7d5a ("dmaengine: dw-axi-dmac: Burst length settings")
Signed-off-by: Jia Wang <wangjia@ultrarisc.com>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index eebed2474210..742e08cfab43 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -706,7 +706,7 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
ctlhi = CH_CTL_H_LLI_VALID;
if (chan->chip->dw->hdata->restrict_axi_burst_len) {
- burst_len = chan->chip->dw->hdata->axi_rw_burst_len;
+ burst_len = chan->chip->dw->hdata->axi_rw_burst_len - 1;
ctlhi |= CH_CTL_H_ARLEN_EN | CH_CTL_H_AWLEN_EN |
burst_len << CH_CTL_H_ARLEN_POS |
burst_len << CH_CTL_H_AWLEN_POS;
@@ -975,7 +975,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr,
reg = CH_CTL_H_LLI_VALID;
if (chan->chip->dw->hdata->restrict_axi_burst_len) {
- u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len;
+ u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len - 1;
reg |= (CH_CTL_H_ARLEN_EN |
burst_len << CH_CTL_H_ARLEN_POS |
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] dmaengine: dw-axi-dmac: Fix AXI burst length encoding
2026-08-28 0:48 ` [PATCH 1/2] dmaengine: dw-axi-dmac: Fix AXI burst length encoding Jia Wang
@ 2026-08-28 19:32 ` Frank Li
0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2026-08-28 19:32 UTC (permalink / raw)
To: Jia Wang
Cc: Eugeniy Paltsev, Vinod Koul, Frank Li, Pandith N,
Andy Shevchenko, Sia Jee Heng, dmaengine, linux-kernel
On Fri, Aug 28, 2026 at 08:48:26AM +0800, Jia Wang wrote:
> The snps,axi-max-burst-len property describes the number of beats in an
> AXI burst, while the ARLEN and AWLEN fields encode that value minus one.
>
> The driver keeps axi_rw_burst_len as the actual burst length so that
> dma_device.max_burst reports the correct value. However, it also programs
> that unencoded value directly into the hardware fields. A value of 256
> therefore overflows the 8-bit fields and can cause AXI decode errors.
>
> Subtract one only when constructing hardware descriptors, while keeping
> the actual value for dma_device.max_burst.
>
> Fixes: c454d16a7d5a ("dmaengine: dw-axi-dmac: Burst length settings")
> Signed-off-by: Jia Wang <wangjia@ultrarisc.com>
> ---
suggest switch to use FIELD_PREP() later
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index eebed2474210..742e08cfab43 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> @@ -706,7 +706,7 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
> ctlhi = CH_CTL_H_LLI_VALID;
>
> if (chan->chip->dw->hdata->restrict_axi_burst_len) {
> - burst_len = chan->chip->dw->hdata->axi_rw_burst_len;
> + burst_len = chan->chip->dw->hdata->axi_rw_burst_len - 1;
> ctlhi |= CH_CTL_H_ARLEN_EN | CH_CTL_H_AWLEN_EN |
> burst_len << CH_CTL_H_ARLEN_POS |
> burst_len << CH_CTL_H_AWLEN_POS;
> @@ -975,7 +975,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr,
>
> reg = CH_CTL_H_LLI_VALID;
> if (chan->chip->dw->hdata->restrict_axi_burst_len) {
> - u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len;
> + u32 burst_len = chan->chip->dw->hdata->axi_rw_burst_len - 1;
>
> reg |= (CH_CTL_H_ARLEN_EN |
> burst_len << CH_CTL_H_ARLEN_POS |
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access
2026-08-28 0:48 [PATCH 0/2] dmaengine: dw-axi-dmac: Fix burst length encoding and LLI dump Jia Wang
2026-08-28 0:48 ` [PATCH 1/2] dmaengine: dw-axi-dmac: Fix AXI burst length encoding Jia Wang
@ 2026-08-28 0:48 ` Jia Wang
2026-08-28 7:01 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Jia Wang @ 2026-08-28 0:48 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Pandith N,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, Jia Wang
axi_chan_list_dump_lli() uses the channel-wide descs_allocated count to
walk the hw_desc[] array of a single transaction. If multiple
transactions have allocated LLIs, the channel count can exceed the
transaction-local nr_hw_descs and make the DMA error path read past the
end of hw_desc[].
Use the descriptor-local nr_hw_descs count when dumping LLIs.
Fixes: ef6fb2d6f1ab ("dmaengine: dw-axi-dmac: simplify descriptor management")
Signed-off-by: Jia Wang <wangjia@ultrarisc.com>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 742e08cfab43..858004b5a846 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1052,10 +1052,9 @@ static void axi_chan_dump_lli(struct axi_dma_chan *chan,
static void axi_chan_list_dump_lli(struct axi_dma_chan *chan,
struct axi_dma_desc *desc_head)
{
- int count = atomic_read(&chan->descs_allocated);
int i;
- for (i = 0; i < count; i++)
+ for (i = 0; i < desc_head->nr_hw_descs; i++)
axi_chan_dump_lli(chan, &desc_head->hw_desc[i]);
}
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access
2026-08-28 0:48 ` [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access Jia Wang
@ 2026-08-28 7:01 ` Andy Shevchenko
2026-08-28 9:34 ` Jia Wang
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-08-28 7:01 UTC (permalink / raw)
To: Jia Wang
Cc: Eugeniy Paltsev, Vinod Koul, Frank Li, Pandith N, Sia Jee Heng,
dmaengine, linux-kernel
On Fri, Aug 28, 2026 at 08:48:27AM +0800, Jia Wang wrote:
> axi_chan_list_dump_lli() uses the channel-wide descs_allocated count to
> walk the hw_desc[] array of a single transaction. If multiple
> transactions have allocated LLIs, the channel count can exceed the
> transaction-local nr_hw_descs and make the DMA error path read past the
> end of hw_desc[].
>
> Use the descriptor-local nr_hw_descs count when dumping LLIs.
...
> {
> - int count = atomic_read(&chan->descs_allocated);
> int i;
>
> - for (i = 0; i < count; i++)
> + for (i = 0; i < desc_head->nr_hw_descs; i++)
While at it,
for (unsigned int i = 0; i < desc_head->nr_hw_descs; i++)
and drop that 'int i;' as well.
> axi_chan_dump_lli(chan, &desc_head->hw_desc[i]);
> }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access
2026-08-28 7:01 ` Andy Shevchenko
@ 2026-08-28 9:34 ` Jia Wang
0 siblings, 0 replies; 6+ messages in thread
From: Jia Wang @ 2026-08-28 9:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jia Wang, Eugeniy Paltsev, Vinod Koul, Frank Li, Pandith N,
Sia Jee Heng, dmaengine, linux-kernel
On 2026-08-28 10:01 +0300, Andy Shevchenko wrote:
> On Fri, Aug 28, 2026 at 08:48:27AM +0800, Jia Wang wrote:
> > axi_chan_list_dump_lli() uses the channel-wide descs_allocated count to
> > walk the hw_desc[] array of a single transaction. If multiple
> > transactions have allocated LLIs, the channel count can exceed the
> > transaction-local nr_hw_descs and make the DMA error path read past the
> > end of hw_desc[].
> >
> > Use the descriptor-local nr_hw_descs count when dumping LLIs.
>
> ...
>
> > {
> > - int count = atomic_read(&chan->descs_allocated);
> > int i;
> >
> > - for (i = 0; i < count; i++)
> > + for (i = 0; i < desc_head->nr_hw_descs; i++)
>
> While at it,
>
> for (unsigned int i = 0; i < desc_head->nr_hw_descs; i++)
>
> and drop that 'int i;' as well.
>
Will update it in v2, thanks.
> > axi_chan_dump_lli(chan, &desc_head->hw_desc[i]);
> > }
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
>
Best regards,
Jia Wang
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-28 19:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 0:48 [PATCH 0/2] dmaengine: dw-axi-dmac: Fix burst length encoding and LLI dump Jia Wang
2026-08-28 0:48 ` [PATCH 1/2] dmaengine: dw-axi-dmac: Fix AXI burst length encoding Jia Wang
2026-08-28 19:32 ` Frank Li
2026-08-28 0:48 ` [PATCH 2/2] dmaengine: dw-axi-dmac: Fix LLI dump out-of-bounds access Jia Wang
2026-08-28 7:01 ` Andy Shevchenko
2026-08-28 9:34 ` Jia Wang
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®