Skip to content

Commit e19bdba

Browse files
ADESTMvinodkoul
authored andcommitted
dmaengine: stm32-dma: configure next sg only if there are more than 2 sgs
DMA operates in Double Buffer Mode (DBM) when the transfer is cyclic and there are at least two periods. When DBM is enabled, the DMA toggles between two memory targets (SxM0AR and SxM1AR), indicated by the SxSCR.CT bit (Current Target). There is no need to update the next memory address if two periods are configured, as SxM0AR and SxM1AR are already properly set up before the transfer begins in the stm32_dma_start_transfer() function. This avoids unnecessary updates to SxM0AR/SxM1AR, thereby preventing potential Transfer Errors. Specifically, when the channel is enabled, SxM0AR and SxM1AR can only be written if SxSCR.CT=1 and SxSCR.CT=0, respectively. Otherwise, a Transfer Error interrupt is triggered, and the stream is automatically disabled. Signed-off-by: Amelie Delaunay <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 0a78bd5 commit e19bdba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/dma/stm32/stm32-dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan, u32 scr)
744744
/* cyclic while CIRC/DBM disable => post resume reconfiguration needed */
745745
if (!(scr & (STM32_DMA_SCR_CIRC | STM32_DMA_SCR_DBM)))
746746
stm32_dma_post_resume_reconfigure(chan);
747-
else if (scr & STM32_DMA_SCR_DBM)
747+
else if (scr & STM32_DMA_SCR_DBM && chan->desc->num_sgs > 2)
748748
stm32_dma_configure_next_sg(chan);
749749
} else {
750750
chan->busy = false;

0 commit comments

Comments
 (0)