All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rui Wang" <wr574332525@163.com>
Cc: dmaengine@vger.kernel.org, Frank.Li@kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v6] dmaengine: dw-axi-dmac: report paused state and residue in tx_status
Date: Mon, 28 Sep 2026 04:02:47 +0000	[thread overview]
Message-ID: <20260928040248.6809E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928035133.2046-1-wr574332525@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dmaengine: false block matching on overlapping physical memory
--

commit 401af67dfb5740614a39aa65705b156a731bba3f
Author: Rui Wang <wr574332525@163.com>
Subject: dmaengine: dw-axi-dmac: report paused state and residue in tx_status

This commit updates device_tx_status to report the paused state when
appropriate. It also improves the residue computation for in-flight
transfers by reading the current hardware pointer to calculate the
transferred bytes, rather than relying solely on completed block counts.

> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index eebed2474210d..0fa97b83be828 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c

[ ... ]

> @@ -352,33 +352,110 @@ static void vchan_desc_put(struct virt_dma_desc *vdesc)

[ ... ]

> +static u32 axi_chan_get_xferred(struct axi_dma_chan *chan,
> +				struct axi_dma_desc *desc)
> +{
> +	struct axi_dma_hw_desc *hw_desc;
> +	bool dst = chan->direction == DMA_DEV_TO_MEM;
> +	u64 pos, start;
> +	u32 xferred = 0;
> +	int i;
> +
> +	pos = axi_chan_readq(chan, dst ? CH_DAR : CH_SAR);
> +
> +	for (i = 0; i < desc->nr_hw_descs; i++) {
> +		hw_desc = &desc->hw_desc[i];
> +		start = le64_to_cpu(dst ? hw_desc->lli->dar : hw_desc->lli->sar);
> +
> +		/* Current position is inside this block: partial progress */
> +		if (pos >= start && pos <= start + hw_desc->len)
> +			return xferred + (u32)(pos - start);

[Severity: Medium]
Will this condition falsely match the wrong block if a scatter-gather list
maps the same physical address multiple times?

If a client driver submits a multi-block scatter-gather list with overlapping
physical memory regions (such as repeating a single dummy zero-page for SPI
TX/RX), this linear scan could match an earlier block in the list while the
hardware is actually executing a later block.

Does this mask actual progress and cause the reported transferred byte count
to repeatedly loop back to 0, corrupting the residue computation when queried
via dmaengine_tx_status()?

> +
> +		xferred += hw_desc->len;
> +	}
> +
> +	/* Position doesn't match any block, be conservative */
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260928035133.2046-1-wr574332525@163.com?part=1

  reply	other threads:[~2026-09-28  4:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  3:51 [PATCH v6] dmaengine: dw-axi-dmac: report paused state and residue in tx_status Rui Wang
2026-09-28  4:02 ` sashiko-bot [this message]
2026-10-13  4:08 ` Rui Wang
2026-10-13 14:45 ` 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=20260928040248.6809E1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=wr574332525@163.com \
    /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.