DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: dmaengine@vger.kernel.org, linux-serial@vger.kernel.org,
	vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v11 4/7] dmaengine: dw: use virt-dma for descriptor and callback ownership
Date: Fri, 20 Nov 2026 20:08:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-225998@kernel.org> (raw)
In-Reply-To: <20261120-submit-dw-dma-synchronize-v1-v11-4-9b9166bc2cc7@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dmaengine: dw: unnecessary per-channel spinlock in
  dw_dma_tasklet()
--

commit 08af3593b8765b38f061156136ab91bdf9ca8c59
Author: James Hilliard <james.hilliard1@gmail.com>

dmaengine: dw: use virt-dma for descriptor and callback ownership

This commit converts the DesignWare DMA driver to use virt-dma for
transaction queues, cookie completion, callback delivery, and channel
synchronization.

Link: https://lore.kernel.org/r/20240911184710.4207-2-fancer.lancer@gmail.com [1]

> diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
> index 3df696e41ff2e..0d2407c6472be 100644
> --- a/drivers/dma/dw/core.c
> +++ b/drivers/dma/dw/core.c
[ ... ]
> @@ -431,42 +401,46 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc)
[ ... ]
>  static void dw_dma_tasklet(struct tasklet_struct *t)
>  {
>  	struct dw_dma *dw = from_tasklet(dw, t, tasklet);
>  	struct dw_dma_chan *dwc;
> -	u32 status_xfer;
> -	u32 status_err;
> +	unsigned long flags;
>  	unsigned int i;
> +	u32 status;
>  
> -	status_xfer = dma_readl(dw, RAW.XFER);
> -	status_err = dma_readl(dw, RAW.ERROR);
> +	/* Channel release may have drained a polled completion before this run. */
> +	if (!dw->in_use)
> +		return;
>  
> -	dev_vdbg(dw->dma.dev, "%s: status_err=%x\n", __func__, status_err);
> +	status = dma_readl(dw, RAW.XFER) | dma_readl(dw, RAW.ERROR);
>  
>  	for (i = 0; i < dw->dma.chancnt; i++) {
>  		dwc = &dw->chan[i];
> -		if (test_bit(DW_DMA_IS_CYCLIC, &dwc->flags))
> -			dev_vdbg(dw->dma.dev, "Cyclic xfer is not implemented\n");
> -		else if (status_err & (1 << i))
> -			dwc_handle_error(dw, dwc);
> -		else if (status_xfer & (1 << i))
> -			dwc_scan_descriptors(dw, dwc);
> +		spin_lock_irqsave(&dwc->vc.lock, flags);
> +		/* The snapshot selects work; recheck events under the channel lock. */
> +		if (status & dwc->mask)
> +			dwc_handle_channel(dw, dwc);
> +		spin_unlock_irqrestore(&dwc->vc.lock, flags);
>  	}

[Severity: Low]
Should status & dwc->mask be checked before taking dwc->vc.lock?  Both
status and dwc->mask are invariant across the lock, so taking
dwc->vc.lock unconditionally on every channel adds unnecessary lock
contention on idle or unrelated channels during every tasklet run.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-submit-dw-dma-synchronize-v1-v11-0-9b9166bc2cc7@gmail.com?part=4

  reply	other threads:[~2026-11-20 20:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 19:29 [PATCH v11 0/7] dmaengine: dw: serialize completion and termination James Hilliard
2026-11-20 19:29 ` [PATCH v11 1/7] dmaengine: dw: Fix XFER bit set, but channel not idle error James Hilliard
2026-11-20 19:29 ` [PATCH v11 2/7] dmaengine: dw: serialize error recovery with channel termination James Hilliard
2026-11-20 19:29 ` [PATCH v11 3/7] dmaengine: dw: embed a virt-dma channel James Hilliard
2026-11-20 19:29 ` [PATCH v11 4/7] dmaengine: dw: use virt-dma for descriptor and callback ownership James Hilliard
2026-11-20 20:08   ` sashiko-bot [this message]
2026-11-20 19:29 ` [PATCH v11 5/7] dmaengine: dw: extract hardware-LLP residue calculation James Hilliard
2026-11-20 19:29 ` [PATCH v11 6/7] dmaengine: dw: calculate residue in the status getter James Hilliard
2026-11-20 19:29 ` [PATCH v11 7/7] dmaengine: dw: report residue for queued transfers James Hilliard

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=sashiko-outbox-225998@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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