All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: dmaengine@vger.kernel.org, Vinod Koul <vkoul@kernel.org>,
	Frank Li <Frank.Li@kernel.org>,
	Maciej Sosnowski <maciej.sosnowski@intel.com>,
	Lennert Buytenhek <buytenh@marvell.com>,
	Dan Williams <djbw@kernel.org>, Saeed Bishara <saeed@marvell.com>,
	Nicolas Pitre <nico@marvell.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: mv_xor: add missing dma_wmb() barriers before descriptor chain start
Date: Wed, 9 Sep 2026 20:29:24 -0500	[thread overview]
Message-ID: <aqIH9NnlUuGXu3Wf@SMW015318> (raw)
In-Reply-To: <20260909234646.102344-1-rosenp@gmail.com>

On Wed, Sep 09, 2026 at 04:46:46PM -0700, Rosen Penev wrote:
> The descriptor data written to coherent memory must be visible to the
> DMA engine before the HW registers that trigger processing are written.
>
> Add a dma_wmb() before mv_chan_set_next_descriptor() in
> mv_chan_start_new_chain() to order descriptor fields before the
> descriptor-pointer write.
>
> Add a dma_wmb() after mv_desc_set_next_desc() in
> mv_chan_handle_chain_append() to order the chain link write before
> the subsequent check of the current-descriptor register. Without the
> barrier the hardware may observe stale descriptor data.
>
> Fixes: ff7b04796d98 ("DMA engine driver for Marvell XOR engine")
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/dma/mv_xor.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
> index 24f22db5dfa1..6db7dafac9c8 100644
> --- a/drivers/dma/mv_xor.c
> +++ b/drivers/dma/mv_xor.c
> @@ -181,6 +181,7 @@ static void mv_chan_start_new_chain(struct mv_xor_chan *mv_chan,
>  	dev_dbg(mv_chan_to_devp(mv_chan), "%s %d: sw_desc %p\n",
>  		__func__, __LINE__, sw_desc);
>
> +	dma_wmb();
>  	/* set the hardware chain */
>  	mv_chan_set_next_descriptor(mv_chan, sw_desc->async_tx.phys);
>
> @@ -409,6 +410,7 @@ mv_xor_tx_submit(struct dma_async_tx_descriptor *tx)
>
>  		/* fix up the hardware chain */
>  		mv_desc_set_next_desc(old_chain_tail, sw_desc->async_tx.phys);
> +		dma_wmb();

mv_chan_set_next_descriptor() implement is wrong, it should use writel()
instead of writel_relax().

Frank

>
>  		/* if the channel is not busy */
>  		if (!mv_chan_is_busy(mv_chan)) {
> --
> 2.55.0
>

      parent reply	other threads:[~2026-09-10  1:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 23:46 [PATCH] dmaengine: mv_xor: add missing dma_wmb() barriers before descriptor chain start Rosen Penev
2026-09-09 23:57 ` sashiko-bot
2026-09-10  1:29 ` Frank Li [this message]

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=aqIH9NnlUuGXu3Wf@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=buytenh@marvell.com \
    --cc=djbw@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.sosnowski@intel.com \
    --cc=nico@marvell.com \
    --cc=rosenp@gmail.com \
    --cc=saeed@marvell.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.