Re: [PATCH 1/3] dmaengine: dw-edma: Implement device_synchronize() callback
From: Manivannan Sadhasivam
Date: Tue Jul 14 2026 - 03:50:28 EST
On Mon, Jun 29, 2026 at 09:20:56AM -0500, Frank Li wrote:
> On Mon, Jun 29, 2026 at 10:45:15AM +0200, Manivannan Sadhasivam via B4 Relay wrote:
> >
> > From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>
> >
> > device_synchronize() callback is required by the client drivers to ensure
> > all the DMA operations are completed so that they can free the memory
> > associated with the complete callbacks.
> >
> > So implement this callback by first making sure that all the in-flight DMA
> > operations are completed and then call vchan_synchronize() to drain the
> > DMA tasklet.
> >
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxxxxxxxx>
> > ---
> > drivers/dma/dw-edma/dw-edma-core.c | 16 ++++++++++++++++
> > 1 file changed, 16 insertions(+)
> >
> > diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> > index c2feb3adc79f..7b12dfe8cfd3 100644
> > --- a/drivers/dma/dw-edma/dw-edma-core.c
> > +++ b/drivers/dma/dw-edma/dw-edma-core.c
> > @@ -331,6 +331,21 @@ static int dw_edma_device_terminate_all(struct dma_chan *dchan)
> > return err;
> > }
> >
> > +static void dw_edma_device_synchronize(struct dma_chan *dchan)
> > +{
> > + struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
> > + unsigned long timeout = jiffies + msecs_to_jiffies(5000);
> > +
> > + /*
> > + * Make sure all the in-flight DMA operations are completed before
> > + * draining the tasklet using vchan_synchronize().
> > + */
> > + while (chan->status == EDMA_ST_BUSY && time_before(jiffies, timeout))
> > + cpu_relax();
>
> read_poll_timeout(...), Does need READ_ONCE(chan->status)?
>
Yeah, makes sense. I'll use:
read_poll_timeout(READ_ONCE, chan->status, chan->status != EDMA_ST_BUSY,
10, 0, false, chan->status);
- Mani
--
மணிவண்ணன் சதாசிவம்