DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wolfram Sang" <wsa+renesas@sang-engineering.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH 6/8] dmaengine: plx_dma: unmap descriptor before completing cookie
Date: Sat, 10 Oct 2026 12:56:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-166553@kernel.org> (raw)
In-Reply-To: <20261010124348.19055-7-wsa+renesas@sang-engineering.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] dmaengine: plx_dma: deadlock in plx_dma_process_desc due to missing _bh
- [High] dmaengine: plx_dma: recursive deadlock when client submits from callback
--

commit ad3cf51e19996d2f8cb3cdd66ceba6e9d034f3e7
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>

dmaengine: plx_dma: unmap descriptor before completing cookie

To ensure that buffers are flushed, make sure that the descriptor gets
unmapped before completing the cookie.

Link: https://lore.kernel.org/r/20261009093745.539924-1-vkoul@kernel.org

> diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
> index 409898e92c320..7b0fd9843b6a1 100644
> --- a/drivers/dma/plx_dma.c
> +++ b/drivers/dma/plx_dma.c
> @@ -156,8 +156,8 @@ static void plx_dma_process_desc(struct plx_dma_dev *plxdev)
>  		else
>  			res.result = DMA_TRANS_READ_FAILED;
>  
> -		dma_cookie_complete(&desc->txd);
>  		dma_descriptor_unmap(&desc->txd);
> +		dma_cookie_complete(&desc->txd);
>  		dmaengine_desc_get_callback_invoke(&desc->txd, &res);

[Severity: High]
Is it possible for a deadlock to occur here due to how ring_lock is acquired?

In plx_dma_process_desc(), ring_lock is acquired using spin_lock() without
disabling bottom halves. If it is called from process context via
plx_dma_tx_status() or plx_dma_abort_desc() and is interrupted by the
plx_dma_desc_task() tasklet, the tasklet will attempt to acquire ring_lock
on the same CPU.

[Severity: High]
Does this code risk a recursive deadlock if a client submits a new
transaction from its completion callback?

plx_dma_process_desc() invokes the client callback synchronously while
holding ring_lock. If a client callback queues the next transaction via
dmaengine_prep_dma_memcpy(), it will enter plx_dma_prep_memcpy() which
attempts to acquire ring_lock again, deadlocking on the same CPU:

drivers/dma/plx_dma.c:plx_dma_prep_memcpy() {
    ...
    spin_lock_bh(&plxdev->ring_lock);
    ...
}

Standard DMA engine patterns require drivers to drop their primary locks
before invoking client callbacks.

>  		desc->txd.callback = NULL;
>  		desc->txd.callback_result = NULL;
> @@ -183,8 +183,8 @@ static void plx_dma_abort_desc(struct plx_dma_dev *plxdev)
>  		res.residue = desc->orig_size;
>  		res.result = DMA_TRANS_ABORTED;
>  
> -		dma_cookie_complete(&desc->txd);
>  		dma_descriptor_unmap(&desc->txd);
> +		dma_cookie_complete(&desc->txd);
>  		dmaengine_desc_get_callback_invoke(&desc->txd, &res);

[Severity: High]
Can a recursive deadlock also happen during abort operations?

Similar to plx_dma_process_desc(), plx_dma_abort_desc() invokes the client
callback synchronously while holding ring_lock (acquired via
spin_lock_bh()). A client queuing a new transaction from this callback
would attempt to acquire the same lock.

>  		desc->txd.callback = NULL;
>  		desc->txd.callback_result = NULL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010124348.19055-1-wsa+renesas@sang-engineering.com?part=6

  reply	other threads:[~2026-10-10 12:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 12:43 [PATCH 0/8] dmaengine: unmap descriptor before completing cookie Wolfram Sang
2026-10-10 12:43 ` [PATCH 1/8] dmaengine: ptdma: " Wolfram Sang
2026-10-10 12:57   ` sashiko-bot
2026-10-12 14:51   ` Frank Li
2026-10-10 12:43 ` [PATCH 2/8] dmaengine: fsl_raid: " Wolfram Sang
2026-10-10 12:43 ` [PATCH 3/8] dmaengine: idxd: " Wolfram Sang
2026-10-10 12:43 ` [PATCH 4/8] dmaengine: ioat: " Wolfram Sang
2026-10-10 12:43 ` [PATCH 5/8] dmaengine: mv_xor_v2: " Wolfram Sang
2026-10-10 12:54   ` sashiko-bot
2026-10-10 12:43 ` [PATCH 6/8] dmaengine: plx_dma: " Wolfram Sang
2026-10-10 12:56   ` sashiko-bot [this message]
2026-10-10 12:43 ` [PATCH 7/8] dmaengine: switchtec-dma: " Wolfram Sang
2026-10-10 12:54   ` sashiko-bot
2026-10-10 12:43 ` [PATCH 8/8] dmaengine: xgene-dma: " Wolfram Sang
2026-10-12 10:42 ` [PATCH 0/8] dmaengine: " Wolfram Sang

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-166553@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=wsa+renesas@sang-engineering.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