From: Frank Li <Frank.li@oss.nxp.com>
To: Koichiro Den <den@valinux.co.jp>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
Cai Huoqing <cai.huoqing@linux.dev>,
Serge Semin <fancer.lancer@gmail.com>,
Gustavo Pimentel <Gustavo.Pimentel@synopsys.com>,
Devendra K Verma <devendra.verma@amd.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] dmaengine: dw-edma: Terminate STOP requests without callbacks
Date: Sat, 11 Jul 2026 09:27:16 -0500 [thread overview]
Message-ID: <alJSxEn-OkE9lKNm@SMW015318> (raw)
In-Reply-To: <20260710080903.2392888-3-den@valinux.co.jp>
On Fri, Jul 10, 2026 at 05:08:58PM +0900, Koichiro Den wrote:
> The STOP request path handles device_terminate_all(). The DMA Engine
> client documentation says in the "Terminate APIs" section of
> Documentation/driver-api/dmaengine/client.rst:
>
> "No callback functions will be called for any incomplete transfers."
>
> dw-edma used vchan_cookie_complete() for a stopped descriptor. This
> queues the descriptor on the completed list and schedules its callback.
> A late callback after dmaengine_terminate_sync() can dereference
> callback state, such as a request object, that the client has already
> freed.
>
> Move the stopped descriptor to the terminated list. Complete the cookie
> before doing so, so cookie polling observes that the transfer is no
> longer in flight, but do not schedule the completion callback. Add a
> synchronize callback so virt-dma can release terminated descriptors.
>
> Fixes: e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver")
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Changes in v2:
> - Split out into this preparation series (was patch 03/17 of
> the dynamic LL appends v1).
> - No changes.
>
> drivers/dma/dw-edma/dw-edma-core.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index 89a4c498a17b..4e0dc52397e2 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -201,6 +201,13 @@ static int dw_edma_start_transfer(struct dw_edma_chan *chan)
> return 1;
> }
>
> +static void dw_edma_terminate_vdesc(struct virt_dma_desc *vd)
> +{
> + list_del(&vd->node);
> + dma_cookie_complete(&vd->tx);
> + vchan_terminate_vdesc(vd);
> +}
> +
> static void dw_edma_device_caps(struct dma_chan *dchan,
> struct dma_slave_caps *caps)
> {
> @@ -673,8 +680,7 @@ static void dw_edma_done_interrupt(struct dw_edma_chan *chan)
> break;
>
> case EDMA_REQ_STOP:
> - list_del(&vd->node);
> - vchan_cookie_complete(vd);
> + dw_edma_terminate_vdesc(vd);
> chan->request = EDMA_REQ_NONE;
> chan->status = EDMA_ST_IDLE;
> break;
> @@ -856,6 +862,13 @@ static int dw_edma_alloc_chan_resources(struct dma_chan *dchan)
> return 0;
> }
>
> +static void dw_edma_device_synchronize(struct dma_chan *dchan)
> +{
> + struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
> +
> + vchan_synchronize(&chan->vc);
> +}
> +
> static void dw_edma_free_chan_resources(struct dma_chan *dchan)
> {
> unsigned long timeout = jiffies + msecs_to_jiffies(5000);
> @@ -968,6 +981,7 @@ static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc)
> dma->device_pause = dw_edma_device_pause;
> dma->device_resume = dw_edma_device_resume;
> dma->device_terminate_all = dw_edma_device_terminate_all;
> + dma->device_synchronize = dw_edma_device_synchronize;
> dma->device_issue_pending = dw_edma_device_issue_pending;
> dma->device_tx_status = dw_edma_device_tx_status;
> dma->device_prep_slave_sg = dw_edma_device_prep_slave_sg;
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-07-11 14:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 8:08 [PATCH 0/7] dmaengine: dw-edma: Fixes and interrupt-path groundwork Koichiro Den
2026-07-10 8:08 ` [PATCH 1/7] dmaengine: dw-edma: Fix HDMA channel status register access Koichiro Den
2026-07-10 8:19 ` sashiko-bot
2026-07-10 21:26 ` Frank Li
2026-07-13 5:17 ` Koichiro Den
2026-07-10 8:08 ` [PATCH 2/7] dmaengine: dw-edma: Terminate STOP requests without callbacks Koichiro Den
2026-07-10 8:26 ` sashiko-bot
2026-07-11 14:27 ` Frank Li [this message]
2026-07-10 8:08 ` [PATCH 3/7] dmaengine: dw-edma: Clean up vchan descriptors on termination Koichiro Den
2026-07-10 8:24 ` sashiko-bot
2026-07-11 14:39 ` Frank Li
2026-07-10 8:09 ` [PATCH 4/7] dmaengine: dw-edma: Serialize channel state checks Koichiro Den
2026-07-10 8:28 ` sashiko-bot
2026-07-10 8:09 ` [PATCH 5/7] dmaengine: dw-edma-pcie: Drop redundant pci_free_irq_vectors() Koichiro Den
2026-07-11 14:41 ` Frank Li
2026-07-10 8:09 ` [PATCH 6/7] dmaengine: dw-edma: Snapshot the v0 interrupt status once per handler pass Koichiro Den
2026-07-11 14:44 ` Frank Li
2026-07-10 8:09 ` [PATCH 7/7] dmaengine: dw-edma: Defer channel IRQ handling to workqueue Koichiro Den
2026-07-10 8:24 ` sashiko-bot
2026-07-11 14:55 ` 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=alJSxEn-OkE9lKNm@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=Gustavo.Pimentel@synopsys.com \
--cc=cai.huoqing@linux.dev \
--cc=den@valinux.co.jp \
--cc=devendra.verma@amd.com \
--cc=dmaengine@vger.kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@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 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.