]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dmaengine: stm32-mdma: correct desc prep when channel running
authorAlain Volmat <alain.volmat@foss.st.com>
Mon, 9 Oct 2023 08:24:50 +0000 (10:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 16:56:31 +0000 (16:56 +0000)
commit 03f25d53b145bc2f7ccc82fc04e4482ed734f524 upstream.

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: a4ffb13c8946 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/stm32-mdma.c

index 58248c8c25a70d3c3fb837b111ae4b517b4d7da6..76202029a3f0c440e3e023763e2e7b0d0c79a24f 100644 (file)
@@ -509,7 +509,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan,
        src_maxburst = chan->dma_config.src_maxburst;
        dst_maxburst = chan->dma_config.dst_maxburst;
 
-       ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id));
+       ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)) & ~STM32_MDMA_CCR_EN;
        ctcr = stm32_mdma_read(dmadev, STM32_MDMA_CTCR(chan->id));
        ctbr = stm32_mdma_read(dmadev, STM32_MDMA_CTBR(chan->id));
 
@@ -937,7 +937,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src,
        if (!desc)
                return NULL;
 
-       ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id));
+       ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)) & ~STM32_MDMA_CCR_EN;
        ctcr = stm32_mdma_read(dmadev, STM32_MDMA_CTCR(chan->id));
        ctbr = stm32_mdma_read(dmadev, STM32_MDMA_CTBR(chan->id));
        cbndtr = stm32_mdma_read(dmadev, STM32_MDMA_CBNDTR(chan->id));