[PATCH 2/4] dmaengine: stm32-dma3: set LL base address when transfer starts

From: Amelie Delaunay

Date: Fri Nov 20 2026 - 04:18:25 EST


Linked-list (LL) is allocated in stm32_dma3_chan_desc_alloc(). The LL is
then used when starting the transfer in stm32_dma3_chan_start(). Nothing
prevents a user from preparing another transfer before starting the
previous one. If, for the same channel, another kind of transfer is
prepared (using dmaengine_prep_xxx API), the LL base address may change.
This address could be overwritten in the CxLBAR register if the channel is
disabled, or the CxLBAR might not be updated if the channel is enabled,
leading to a mismatch between the transfer being started and the LL pointed
to by CxLBAR register.
To avoid this, write the LL base address in CxLBAR when starting the
transfer instead of when the linked-list is allocated.

Fixes: f561ec8b2b33 ("dmaengine: Add STM32 DMA3 support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Amelie Delaunay <amelie.delaunay@xxxxxxxxxxx>
---
drivers/dma/stm32/stm32-dma3.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
index a464e0cefd64..a056f73fbe02 100644
--- a/drivers/dma/stm32/stm32-dma3.c
+++ b/drivers/dma/stm32/stm32-dma3.c
@@ -396,7 +396,6 @@ static void stm32_dma3_chan_dump_hwdesc(struct stm32_dma3_chan *chan,

static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_chan *chan, u32 count)
{
- struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan);
struct stm32_dma3_swdesc *swdesc;
int i;

@@ -423,10 +422,6 @@ static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_ch
}
swdesc->ccr = 0;

- /* Set LL base address */
- writel_relaxed(swdesc->lli[0].hwdesc_addr & CLBAR_LBA,
- ddata->base + STM32_DMA3_CLBAR(chan->id));
-
/* Set LL allocated port */
swdesc->ccr &= ~CCR_LAP;

@@ -790,6 +785,10 @@ static void stm32_dma3_chan_start(struct stm32_dma3_chan *chan)
writel_relaxed(hwdesc->cdar, ddata->base + STM32_DMA3_CDAR(id));
writel_relaxed(hwdesc->cllr, ddata->base + STM32_DMA3_CLLR(id));

+ /* Set LL base address */
+ writel_relaxed(chan->swdesc->lli[0].hwdesc_addr & CLBAR_LBA,
+ ddata->base + STM32_DMA3_CLBAR(chan->id));
+
/* Clear any pending interrupts */
csr = readl_relaxed(ddata->base + STM32_DMA3_CSR(id));
if (csr & CSR_ALL_F)

--
2.43.0