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>,
"Gustavo Pimentel" <Gustavo.Pimentel@synopsys.com>,
"Kees Cook" <kees@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Christoph Hellwig" <hch@lst.de>,
"Serge Semin" <fancer.lancer@gmail.com>,
"Cai Huoqing" <cai.huoqing@linux.dev>,
"Niklas Cassel" <cassel@kernel.org>,
"Devendra K Verma" <devendra.verma@amd.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/17] dmaengine: dw-edma: Serialize channel state checks
Date: Mon, 15 Jun 2026 13:47:48 -0500 [thread overview]
Message-ID: <ajBI1NKC34P4fA9Y@SMW015318> (raw)
In-Reply-To: <20260615154111.2174161-6-den@valinux.co.jp>
On Tue, Jun 16, 2026 at 12:40:59AM +0900, Koichiro Den wrote:
> pause() and resume() read and update channel state without holding
> vc.lock, while the interrupt handlers update the same state under it.
> Take the same lock around those state checks so that request, status,
> and configured stay consistent.
>
> For example, pause() can observe EDMA_ST_BUSY right before the interrupt
> handler completes the final descriptor and moves the channel to
> EDMA_ST_IDLE, and then record EDMA_REQ_PAUSE on an already idle channel.
> No further interrupt will acknowledge the request, and since
> issue_pending() requires EDMA_REQ_NONE, the channel is wedged for good:
> terminate_all() leaves the stale request behind, so even reconfiguring
> the channel does not recover it.
>
> issue_pending() already runs under vc.lock, but it tests configured
> before taking it. Move that test under the lock as well, so that the
> decision to start work is made against the current value rather than one
> observed before a concurrent terminate_all() deconfigured the channel.
>
> 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>
> drivers/dma/dw-edma/dw-edma-core.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index 2777dc0b2aed..489f7fe49840 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -177,8 +177,10 @@ dw_edma_device_get_config(struct dma_chan *dchan,
> static int dw_edma_device_pause(struct dma_chan *dchan)
> {
> struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
> + unsigned long flags;
> int err = 0;
>
> + spin_lock_irqsave(&chan->vc.lock, flags);
> if (!chan->configured)
> err = -EPERM;
> else if (chan->status != EDMA_ST_BUSY)
> @@ -187,6 +189,7 @@ static int dw_edma_device_pause(struct dma_chan *dchan)
> err = -EPERM;
> else
> chan->request = EDMA_REQ_PAUSE;
> + spin_unlock_irqrestore(&chan->vc.lock, flags);
>
> return err;
> }
> @@ -194,8 +197,10 @@ static int dw_edma_device_pause(struct dma_chan *dchan)
> static int dw_edma_device_resume(struct dma_chan *dchan)
> {
> struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
> + unsigned long flags;
> int err = 0;
>
> + spin_lock_irqsave(&chan->vc.lock, flags);
> if (!chan->configured) {
> err = -EPERM;
> } else if (chan->status != EDMA_ST_PAUSE) {
> @@ -206,6 +211,7 @@ static int dw_edma_device_resume(struct dma_chan *dchan)
> chan->status = EDMA_ST_BUSY;
> dw_edma_start_transfer(chan);
> }
> + spin_unlock_irqrestore(&chan->vc.lock, flags);
>
> return err;
> }
> @@ -249,11 +255,9 @@ static void dw_edma_device_issue_pending(struct dma_chan *dchan)
> struct dw_edma_chan *chan = dchan2dw_edma_chan(dchan);
> unsigned long flags;
>
> - if (!chan->configured)
> - return;
> -
> spin_lock_irqsave(&chan->vc.lock, flags);
> - if (vchan_issue_pending(&chan->vc) && chan->request == EDMA_REQ_NONE &&
> + if (chan->configured && vchan_issue_pending(&chan->vc) &&
> + chan->request == EDMA_REQ_NONE &&
> chan->status == EDMA_ST_IDLE) {
> chan->status = EDMA_ST_BUSY;
> dw_edma_start_transfer(chan);
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-06-15 18:48 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 15:40 [PATCH 00/17] dmaengine: dw-edma: Support dynamic LL appends Koichiro Den
2026-06-15 15:40 ` [PATCH 01/17] dmaengine: dw-edma: Fix residue burst index in tx_status() Koichiro Den
2026-06-15 18:29 ` Frank Li
2026-06-15 15:40 ` [PATCH 02/17] dmaengine: dw-edma: Fix HDMA channel status register access Koichiro Den
2026-06-15 18:31 ` Frank Li
2026-06-15 15:40 ` [PATCH 03/17] dmaengine: dw-edma: Terminate STOP requests without callbacks Koichiro Den
2026-06-15 18:37 ` Frank Li
2026-06-16 5:27 ` Koichiro Den
2026-06-15 15:40 ` [PATCH 04/17] dmaengine: dw-edma: Clean up vchan descriptors on termination Koichiro Den
2026-06-15 18:43 ` Frank Li
2026-06-16 6:24 ` Koichiro Den
2026-06-15 15:40 ` [PATCH 05/17] dmaengine: dw-edma: Serialize channel state checks Koichiro Den
2026-06-15 18:47 ` Frank Li [this message]
2026-06-15 15:41 ` [PATCH 06/17] dmaengine: dw-edma: Add dw_edma_core_ll_cur_idx() to get current LL entry index Koichiro Den
2026-06-15 15:41 ` [PATCH 07/17] dmaengine: dw-edma: Move dw_hdma_set_callback_result() up Koichiro Den
2026-06-15 15:41 ` [PATCH 08/17] dmaengine: dw-edma: Make DMA link list work as a circular buffer Koichiro Den
2026-06-15 15:41 ` [PATCH 09/17] dmaengine: dw-edma: Add LL interrupt placement policy Koichiro Den
2026-06-15 15:41 ` [PATCH 10/17] dmaengine: dw-edma: Reclaim issued descriptors from LL progress Koichiro Den
2026-06-15 15:41 ` [PATCH 11/17] dmaengine: dw-edma: Use HDMA watermarks as progress events Koichiro Den
2026-06-15 15:41 ` [PATCH 12/17] dmaengine: dw-edma: Clear LL data entries on reset Koichiro Den
2026-06-15 15:41 ` [PATCH 13/17] dmaengine: dw-edma: Dispatch DONE interrupts by channel request Koichiro Den
2026-06-15 15:41 ` [PATCH 14/17] dmaengine: dw-edma: Reset LL state after terminate and abort Koichiro Den
2026-06-15 15:41 ` [PATCH 15/17] dmaengine: dw-edma: Dynamically append requests while running Koichiro Den
2026-06-15 15:41 ` [PATCH 16/17] dmaengine: dw-edma: Recover stopped HDMA from tx_status Koichiro Den
2026-06-15 15:41 ` [PATCH 17/17] dmaengine: dw-edma: Add trace support Koichiro Den
2026-06-16 9:13 ` [PATCH 00/17] dmaengine: dw-edma: Support dynamic LL appends Niklas Cassel
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=ajBI1NKC34P4fA9Y@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=Gustavo.Pimentel@synopsys.com \
--cc=bhelgaas@google.com \
--cc=cai.huoqing@linux.dev \
--cc=cassel@kernel.org \
--cc=den@valinux.co.jp \
--cc=devendra.verma@amd.com \
--cc=dmaengine@vger.kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=hch@lst.de \
--cc=kees@kernel.org \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox