* [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running
@ 2023-10-09 8:24 Amelie Delaunay
2023-10-09 9:02 ` Alain Volmat
2023-10-16 11:13 ` Vinod Koul
0 siblings, 2 replies; 4+ messages in thread
From: Amelie Delaunay @ 2023-10-09 8:24 UTC (permalink / raw)
To: Vinod Koul, Maxime Coquelin, Alexandre Torgue,
M'boumba Cedric Madianga, Pierre-Yves MORDRET
Cc: Alain Volmat, Amelie Delaunay, stable, dmaengine, linux-stm32,
linux-arm-kernel, linux-kernel
From: Alain Volmat <alain.volmat@foss.st.com>
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
---
drivers/dma/stm32-mdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
index bae08b3f55c7..f414efdbd809 100644
--- a/drivers/dma/stm32-mdma.c
+++ b/drivers/dma/stm32-mdma.c
@@ -489,7 +489,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));
@@ -965,7 +965,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));
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running
2023-10-09 8:24 [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running Amelie Delaunay
@ 2023-10-09 9:02 ` Alain Volmat
2023-10-16 11:11 ` Vinod Koul
2023-10-16 11:13 ` Vinod Koul
1 sibling, 1 reply; 4+ messages in thread
From: Alain Volmat @ 2023-10-09 9:02 UTC (permalink / raw)
To: Amelie Delaunay
Cc: Vinod Koul, Maxime Coquelin, Alexandre Torgue,
M'boumba Cedric Madianga, Pierre-Yves MORDRET, stable,
dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
Hi Amélie,
thanks a lot.
Tested-by: Alain Volmat <alain.volmat@foss.st.com>
Regards,
Alain
On Mon, Oct 09, 2023 at 10:24:50AM +0200, Amelie Delaunay wrote:
> From: Alain Volmat <alain.volmat@foss.st.com>
>
> 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
> ---
> drivers/dma/stm32-mdma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
> index bae08b3f55c7..f414efdbd809 100644
> --- a/drivers/dma/stm32-mdma.c
> +++ b/drivers/dma/stm32-mdma.c
> @@ -489,7 +489,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));
>
> @@ -965,7 +965,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));
> --
> 2.25.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running
2023-10-09 9:02 ` Alain Volmat
@ 2023-10-16 11:11 ` Vinod Koul
0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2023-10-16 11:11 UTC (permalink / raw)
To: Amelie Delaunay, Maxime Coquelin, Alexandre Torgue,
M'boumba Cedric Madianga, Pierre-Yves MORDRET, stable,
dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
On 09-10-23, 11:02, Alain Volmat wrote:
> Hi Amélie,
>
> thanks a lot.
>
> Tested-by: Alain Volmat <alain.volmat@foss.st.com>
Please **do ** not ** top post!
>
> Regards,
> Alain
>
> On Mon, Oct 09, 2023 at 10:24:50AM +0200, Amelie Delaunay wrote:
> > From: Alain Volmat <alain.volmat@foss.st.com>
> >
> > 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
> > ---
> > drivers/dma/stm32-mdma.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
> > index bae08b3f55c7..f414efdbd809 100644
> > --- a/drivers/dma/stm32-mdma.c
> > +++ b/drivers/dma/stm32-mdma.c
> > @@ -489,7 +489,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));
> >
> > @@ -965,7 +965,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));
> > --
> > 2.25.1
> >
--
~Vinod
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running
2023-10-09 8:24 [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running Amelie Delaunay
2023-10-09 9:02 ` Alain Volmat
@ 2023-10-16 11:13 ` Vinod Koul
1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2023-10-16 11:13 UTC (permalink / raw)
To: Maxime Coquelin, Alexandre Torgue, M'boumba Cedric Madianga,
Pierre-Yves MORDRET, Amelie Delaunay
Cc: Alain Volmat, stable, dmaengine, linux-stm32, linux-arm-kernel,
linux-kernel
On Mon, 09 Oct 2023 10:24:50 +0200, Amelie Delaunay wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] dmaengine: stm32-mdma: correct desc prep when channel running
commit: 03f25d53b145bc2f7ccc82fc04e4482ed734f524
Best regards,
--
~Vinod
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-16 11:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 8:24 [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running Amelie Delaunay
2023-10-09 9:02 ` Alain Volmat
2023-10-16 11:11 ` Vinod Koul
2023-10-16 11:13 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).