DMA Engine development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
Cc: Vinod Koul <vkoul@kernel.org>, Greg Ungerer <gerg@linux-m68k.org>,
	imx@lists.linux.dev, dmaengine@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] dma: fsl-edma: Add write barrier after TCD descriptor fill
Date: Mon, 24 Nov 2025 10:57:49 -0500	[thread overview]
Message-ID: <aSSAfW9xLTRN5Fwk@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20251124-dma-coldfire-v1-1-dc8f93185464@yoseli.org>

On Mon, Nov 24, 2025 at 01:50:22PM +0100, Jean-Michel Hautbois wrote:
> Add dma_wmb() barrier after filling TCD descriptors to ensure all
> descriptor writes are visible to the DMA engine before starting
> transfers. This prevents potential race conditions where the DMA
> hardware might read partially written descriptors.
>
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> ---
>  drivers/dma/fsl-edma-common.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
> index 4976d7dde08090d16277af4b9f784b9745485320..db36a6aafc910364d75ce6c5d334fd19d2120b6b 100644
> --- a/drivers/dma/fsl-edma-common.c
> +++ b/drivers/dma/fsl-edma-common.c
> @@ -553,6 +553,9 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
>  	fsl_edma_set_tcd_to_le(fsl_chan, tcd, csr, csr);
>
>  	trace_edma_fill_tcd(fsl_chan, tcd);
> +
> +	/* Ensure descriptor writes are visible to DMA engine */
> +	dma_wmb();

This is not necessary because there are writel() in
fsl_edma_issue_pending(), which will do memory barrier in writel().

currently, edma use vchan, descriptior have not dymantically to appending
to running queue. so writel() in fsl_edma_issue_pending() is enough.

Even though edma will support append to running queue in future, dma_wmd()
should be just before update csr.

 	dma_wmb();  // just before indicate TCD is ready to use.
	fsl_edma_set_tcd_to_le(fsl_chan, tcd, csr, csr);

Frank
>  }
>
>  static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan,
>
> --
> 2.39.5
>

  reply	other threads:[~2025-11-24 15:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 12:50 [PATCH 0/7] dma: fsl/mcf-edma: Bug fixes and enhancements for ColdFire support Jean-Michel Hautbois
2025-11-24 12:50 ` [PATCH 1/7] dma: fsl-edma: Add write barrier after TCD descriptor fill Jean-Michel Hautbois
2025-11-24 15:57   ` Frank Li [this message]
2025-11-25  8:18     ` Jean-Michel Hautbois
2025-11-24 12:50 ` [PATCH 2/7] dma: fsl-edma: Add FSL_EDMA_DRV_MCF flag for ColdFire eDMA Jean-Michel Hautbois
2025-11-24 16:03   ` Frank Li
2025-11-24 12:50 ` [PATCH 3/7] dma: mcf-edma: Add per-channel IRQ naming for debugging Jean-Michel Hautbois
2025-11-24 13:05   ` Geert Uytterhoeven
2025-11-25  8:35   ` kernel test robot
2025-11-25 12:06   ` kernel test robot
2025-11-24 12:50 ` [PATCH 4/7] dma: mcf-edma: Fix interrupt handler for 64 DMA channels Jean-Michel Hautbois
2025-11-24 16:09   ` Frank Li
2025-11-25  8:02     ` Jean-Michel Hautbois
2025-11-25 16:14       ` Frank Li
2025-11-24 12:50 ` [PATCH 5/7] dma: fsl-edma: Move error handler out of header file Jean-Michel Hautbois
2025-11-24 16:10   ` Frank Li
2025-11-24 12:50 ` [PATCH 6/7] dma: mcf-edma: Fix error handler for all 64 DMA channels Jean-Michel Hautbois
2025-11-24 16:16   ` Frank Li
2025-11-24 12:50 ` [PATCH 7/7] dma: fsl-edma: Support source stride for interleaved DMA transfers Jean-Michel Hautbois
2025-11-24 16:29   ` Frank Li

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=aSSAfW9xLTRN5Fwk@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gerg@linux-m68k.org \
    --cc=imx@lists.linux.dev \
    --cc=jeanmichel.hautbois@yoseli.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.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