Skip to content

Commit 03f25d5

Browse files
Alain Volmatvinodkoul
authored andcommitted
dmaengine: stm32-mdma: correct desc prep when channel running
In case of the prep descriptor while the channel is already running, the CCR register value stored into the channel could already have its EN bit set. This would lead to a bad transfer since, at start transfer time, enabling the channel while other registers aren't yet properly set. To avoid this, ensure to mask the CCR_EN bit when storing the ccr value into the mdma channel structure. Fixes: a4ffb13 ("dmaengine: Add STM32 MDMA driver") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Cc: stable@vger.kernel.org Tested-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://lore.kernel.org/r/20231009082450.452877-1-amelie.delaunay@foss.st.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 495e18b commit 03f25d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/dma/stm32-mdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan,
488488
src_maxburst = chan->dma_config.src_maxburst;
489489
dst_maxburst = chan->dma_config.dst_maxburst;
490490

491-
ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id));
491+
ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)) & ~STM32_MDMA_CCR_EN;
492492
ctcr = stm32_mdma_read(dmadev, STM32_MDMA_CTCR(chan->id));
493493
ctbr = stm32_mdma_read(dmadev, STM32_MDMA_CTBR(chan->id));
494494

@@ -966,7 +966,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src,
966966
if (!desc)
967967
return NULL;
968968

969-
ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id));
969+
ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)) & ~STM32_MDMA_CCR_EN;
970970
ctcr = stm32_mdma_read(dmadev, STM32_MDMA_CTCR(chan->id));
971971
ctbr = stm32_mdma_read(dmadev, STM32_MDMA_CTBR(chan->id));
972972
cbndtr = stm32_mdma_read(dmadev, STM32_MDMA_CBNDTR(chan->id));

0 commit comments

Comments
 (0)