From: "Neeli, Srinivas" <srneeli@amd.com>
To: sashiko-reviews@lists.linux.dev, Srinivas Neeli <srinivas.neeli@amd.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCH V3 2/4] dmaengine: xilinx_dma: Move descriptors to done list based on completion bit
Date: Thu, 9 Jul 2026 21:18:07 +0530 [thread overview]
Message-ID: <354c4e2c-bf6f-4f32-9f30-a5ca2463cdca@amd.com> (raw)
In-Reply-To: <20260709101123.F2F9E1F00A3D@smtp.kernel.org>
hi,
On 7/9/2026 3:41 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Software state mismatch leading to hardware corruption and channel hang in AXI MCDMA.
> - [Medium] Missing read memory barrier (`dma_rmb()`) after checking the DMA completion flag in coherent memory.
> --
>
> --- Patch [2]: [PATCH V3 2/4] dmaengine: xilinx_dma: Move descriptors to done list based on completion bit ---
> commit d59255ad1a6d4a4beb643022da1f9820716a0752
> Author: Srinivas Neeli <srinivas.neeli@amd.com>
>
> dmaengine: xilinx_dma: Move descriptors to done list based on completion bit
>
> In AXI MCDMA scatter-gather mode, xilinx_dma_complete_descriptor() previously
> moved all active descriptors to the done list unconditionally. This commit adds
> a check for the descriptor completion bit before moving entries, handling
> scenarios where interrupt coalescing causes interrupts before all queued
> descriptors are processed.
>
>> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
>> index 965fb69a2a3ad..9b8b6f1acd4ea 100644
>> --- a/drivers/dma/xilinx/xilinx_dma.c
>> +++ b/drivers/dma/xilinx/xilinx_dma.c
>> @@ -1773,6 +1773,17 @@ static void xilinx_dma_complete_descriptor(struct xilinx_dma_chan *chan)
>> struct xilinx_axidma_tx_segment, node);
>> if (!(seg->hw.status & XILINX_DMA_BD_COMP_MASK) && chan->has_sg)
>> break;
>> + } else if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIMCDMA) {
>> + struct xilinx_aximcdma_tx_segment *seg;
>> + u32 status;
>> +
>> + seg = list_last_entry(&desc->segments,
>> + struct xilinx_aximcdma_tx_segment,
>> + node);
>> + status = (chan->direction == DMA_DEV_TO_MEM) ?
>> + seg->hw.s2mm_status : seg->hw.mm2s_status;
>> + if (!(status & XILINX_DMA_BD_COMP_MASK))
> [Severity: Medium]
> Is a read memory barrier needed after checking this completion status?
>
> The CPU polls the s2mm_status or mm2s_status field in coherent memory to
> check the completion bit. Without a dma_rmb() here, could weakly ordered
> architectures speculatively execute subsequent descriptor reads out of
> order?
>
> This might result in stale reads of the descriptor fields later on
> (for instance, during residue calculation) before the hardware has
> actually confirmed completion.
The MCDMA descriptors are allocated using dma_alloc_coherent(), which
provides cache-coherent memory between CPU and device.
On coherent DMA memory, the CPU sees device writes without requiring
explicit barriers, so dma_rmb() is not needed here.
>> + break;
> [Severity: High]
> Does breaking out early here create a state mismatch with the IRQ handler?
>
> If this check breaks out leaving descriptors in the active list, the
> channel is technically still running. However, looking at the call chain,
> xilinx_mcdma_irq_handler() immediately forces the channel idle and
> starts a new transfer:
>
> xilinx_mcdma_irq_handler() {
> ...
> xilinx_dma_complete_descriptor(chan);
> chan->idle = true;
> chan->start_transfer(chan);
> ...
> }
>
> This appears to bypass the idle safety check in
> xilinx_mcdma_start_transfer() and overwrite the CDESC hardware register
> while the DMA engine is actively processing the remaining active list.
> Could this software-splice new descriptors without establishing hardware
> links, leading to a permanent channel hang?
I believe this analysis was run against an older version of the driver.
The list_empty() guard was added in a recent patch series:
https://lore.kernel.org/all/20260626092656.1563871-1-suraj.gupta2@amd.com/
The current code in xilinx_mcdma_irq_handler() has this protection:
xilinx_dma_complete_descriptor(chan);
if (list_empty(&chan->active_list)) {
chan->idle = true;
chan->start_transfer(chan);
}
When the completion check breaks early (leaving incomplete descriptors
in active_list), the list won't be empty, so neither chan->idle = true
nor start_transfer() will execute. The hardware state remains consistent.
Thanks
Neeli Srinivas
>
>> + }
>> if (chan->has_sg && chan->xdev->dma_config->dmatype !=
>> XDMA_TYPE_VDMA)
> [ ... ]
>
next prev parent reply other threads:[~2026-07-09 15:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 10:06 [PATCH V3 0/4] dmaengine: xilinx_dma: MCDMA descriptor and metadata handling improvements Srinivas Neeli
2026-07-08 10:06 ` [PATCH V3 1/4] dmaengine: xilinx_dma: Fix MCDMA descriptor fields based on DMA direction Srinivas Neeli
2026-07-08 15:32 ` Pandey, Radhey Shyam
2026-07-08 10:06 ` [PATCH V3 2/4] dmaengine: xilinx_dma: Move descriptors to done list based on completion bit Srinivas Neeli
2026-07-08 15:56 ` Pandey, Radhey Shyam
2026-07-09 10:11 ` sashiko-bot
2026-07-09 15:48 ` Neeli, Srinivas [this message]
2026-07-08 10:06 ` [PATCH V3 3/4] net: xilinx: axienet: Derive RX frame length from DMA residue Srinivas Neeli
2026-07-08 16:41 ` Pandey, Radhey Shyam
2026-07-09 10:11 ` sashiko-bot
2026-07-09 16:18 ` Neeli, Srinivas
2026-07-08 10:06 ` [PATCH V3 4/4] dmaengine: xilinx_dma: Extend metadata handling for AXI DMA and MCDMA Srinivas Neeli
2026-07-09 10:11 ` sashiko-bot
2026-07-09 16:28 ` Neeli, Srinivas
2026-07-09 14:13 ` Pandey, Radhey Shyam
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=354c4e2c-bf6f-4f32-9f30-a5ca2463cdca@amd.com \
--to=srneeli@amd.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=srinivas.neeli@amd.com \
--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.