From: sashiko-bot@kernel.org
To: "Jeff C. Jensen" <kernel@nullptr.com>, dmaengine@vger.kernel.org
Cc: vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v2 3/3] dmaengine: xilinx_dma: Allocate AXI DMA segments in ring order
Date: Mon, 16 Nov 2026 04:07:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-216160@kernel.org> (raw)
In-Reply-To: <20261115-xilinx-dma-work-v2-3-681ed00c15a1@nullptr.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dmaengine: xilinx_dma: leak and race on reset in
xilinx_dma_tx_submit()
--
commit 80f9ff890add7d4c1438b6a3f62d632e08397edb
Author: Jeff C. Jensen <kernel@nullptr.com>
dmaengine: xilinx_dma: Allocate AXI DMA segments in ring order
This commit replaces the AXI DMA segment free list with a bitmap and ring
cursor so that descriptors reserve consecutive hardware segments in ring
order.
Link: https://lore.kernel.org/all/20260817094004.A74621F000E9@smtp.kernel.org/ [1]
> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
> index ba4fa1aafc501..69f61ba1652bd 100644
> --- a/drivers/dma/xilinx/xilinx_dma.c
> +++ b/drivers/dma/xilinx/xilinx_dma.c
[ ... ]
> @@ -2117,8 +2270,11 @@ static dma_cookie_t xilinx_dma_tx_submit(struct dma_async_tx_descriptor *tx)
> unsigned long flags;
> int err;
>
> + spin_lock_irqsave(&chan->lock, flags);
> +
> if (chan->cyclic) {
> - xilinx_dma_free_tx_descriptor(chan, desc);
> + xilinx_dma_cancel_tx_descriptor(chan, desc);
> + spin_unlock_irqrestore(&chan->lock, flags);
> return -EBUSY;
> }
>
> @@ -2127,13 +2283,13 @@ static dma_cookie_t xilinx_dma_tx_submit(struct dma_async_tx_descriptor *tx)
> * If reset fails, need to hard reset the system.
> * Channel is no longer functional
> */
> + spin_unlock_irqrestore(&chan->lock, flags);
> err = xilinx_dma_chan_reset(chan);
> if (err < 0)
> return err;
> + spin_lock_irqsave(&chan->lock, flags);
> }
>
> - spin_lock_irqsave(&chan->lock, flags);
> -
> cookie = dma_cookie_assign(tx);
[Severity: Medium]
Does the chan->err path leak desc and its reserved segments when
xilinx_dma_chan_reset() fails, or allow a concurrent submission to race
when chan->lock is dropped?
If xilinx_dma_chan_reset() returns an error, xilinx_dma_tx_submit()
returns without calling xilinx_dma_cancel_tx_descriptor(chan, desc),
leaking desc, leaving its bits set in chan->seg_used, and leaving
chan->seg_next advanced.
Even when the reset succeeds, dropping chan->lock after desc has reserved
its ring positions lets a second caller prepare and submit a newer
descriptor (or set chan->cyclic) before this thread re-acquires
chan->lock, queuing the two descriptors in chan->pending_list out of ring
order:
CPU0 CPU1
prep_slave_sg() -> desc A
reserve_segments() [0..1]
xilinx_dma_tx_submit(A)
lock(&chan->lock)
if (chan->err)
unlock(&chan->lock)
xilinx_dma_chan_reset()
chan->err = false
prep_slave_sg() -> desc B
reserve_segments() [2..3]
xilinx_dma_tx_submit(B)
lock(&chan->lock)
append_desc_queue(chan, B)
unlock(&chan->lock)
lock(&chan->lock)
append_desc_queue(chan, A) <-- queued after B, out of ring order
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-xilinx-dma-work-v2-0-681ed00c15a1@nullptr.com?part=3
next prev parent reply other threads:[~2026-11-16 4:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 3:43 [PATCH v2 0/3] dmaengine: xilinx_dma: Fix AXI DMA descriptor ring ordering Jeff C. Jensen via B4 Relay
2026-11-16 3:43 ` [PATCH v2 1/3] dmaengine: xilinx_dma: Reject transfers that map no data Jeff C. Jensen via B4 Relay
2026-11-16 3:43 ` [PATCH v2 2/3] dmaengine: xilinx_dma: Fix cyclic period count truncation Jeff C. Jensen via B4 Relay
2026-11-16 3:43 ` [PATCH v2 3/3] dmaengine: xilinx_dma: Allocate AXI DMA segments in ring order Jeff C. Jensen via B4 Relay
2026-11-16 4:07 ` sashiko-bot [this message]
2026-11-16 7:10 ` Jeff C. Jensen
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-216160@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=kernel@nullptr.com \
--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