From: Frank Li <Frank.li@oss.nxp.com>
To: Ziheng Wei <zihengw03@163.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>,
Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: at_xdmac: handle empty transfer list in tx_status
Date: Tue, 17 Nov 2026 13:17:18 -0500 [thread overview]
Message-ID: <avyaLhOo8fdAIvUi@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20261115080245.910534-1-zihengw03@163.com>
On Sun, Nov 15, 2026 at 04:02:45PM +0800, Ziheng Wei wrote:
> at_xdmac_device_terminate_all() removes every descriptor from
> atchan->xfers_list without completing their cookies, so
> dma_cookie_status() keeps reporting a terminated cookie as
> DMA_IN_PROGRESS. at_xdmac_tx_status() then calls list_first_entry()
> on the empty list and uses the list head, which lives inside struct
> at_xdmac_chan, as a descriptor: active_xfer and xfer_size are read
> from neighbouring channel fields, and if active_xfer happens to be
> non-zero the residue loop walks a descs_list made of those fields.
>
> For audio this is a routine path. The generic dmaengine PCM calls
> dmaengine_terminate_async() on TRIGGER_STOP and later
> dmaengine_tx_status() on the same cookie from
> snd_dmaengine_pcm_sync_stop() and on close. What happens depends on
> the struct layout. On a 32-bit build active_xfer overlays
> sconfig.device_fc, which is normally false, so only a bogus residue
> is reported. With CONFIG_DEBUG_SPINLOCK the larger spinlock_t puts
> active_xfer on the held lock word and descs_list on the owner_cpu and
> owner fields, so the loop follows a pointer that is not a descriptor.
>
> Report a residue of 0 when no descriptor is queued.
>
> Found by LLM-assisted source review. Not tested on hardware; the
> layout analysis above is from reading the code only.
>
> Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ziheng Wei <zihengw03@163.com>
> ---
suppose below patch can fix this problem
https://lore.kernel.org/dmaengine/avdni52GEjf_B3vE@lizhi-Precision-Tower-5810/
Frank
>
> Notes:
> The changelog was drafted with an AI assistant from my analysis;
> I have reviewed the code, the fix and the text.
>
> drivers/dma/at_xdmac.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index ef0dfe9d3..bcfbb41ea 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1553,7 +1553,16 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
>
> spin_lock_irqsave(&atchan->lock, flags);
>
> - desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, xfer_node);
> + desc = list_first_entry_or_null(&atchan->xfers_list, struct at_xdmac_desc,
> + xfer_node);
> + /*
> + * The list is empty once the channel has been terminated, while the
> + * cookie of the terminated transfer is still reported as in progress.
> + */
> + if (!desc) {
> + dma_set_residue(txstate, 0);
> + goto spin_unlock;
> + }
>
> /*
> * If the transfer has not been started yet, don't need to compute the
>
> base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-11-17 18:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 8:02 Ziheng Wei
2026-11-17 18:17 ` Frank Li [this message]
2026-11-17 19:13 ` Ziheng Wei
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=avyaLhOo8fdAIvUi@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=zihengw03@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®