DMA Engine development
 help / color / mirror / Atom feed
From: Alain Volmat <alain.volmat@foss.st.com>
To: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: Vinod Koul <vkoul@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	M'boumba Cedric Madianga <cedric.madianga@gmail.com>,
	Pierre-Yves MORDRET <pierre-yves.mordret@st.com>,
	<stable@vger.kernel.org>, <dmaengine@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running
Date: Mon, 9 Oct 2023 11:02:13 +0200	[thread overview]
Message-ID: <20231009090213.GA1547647@gnbcxd0016.gnb.st.com> (raw)
In-Reply-To: <20231009082450.452877-1-amelie.delaunay@foss.st.com>

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
> 

  reply	other threads:[~2023-10-09  9:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09  8:24 [PATCH] dmaengine: stm32-mdma: correct desc prep when channel running Amelie Delaunay
2023-10-09  9:02 ` Alain Volmat [this message]
2023-10-16 11:11   ` Vinod Koul
2023-10-16 11:13 ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231009090213.GA1547647@gnbcxd0016.gnb.st.com \
    --to=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=amelie.delaunay@foss.st.com \
    --cc=cedric.madianga@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=pierre-yves.mordret@st.com \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox