From: Rosen Penev <rosenp@gmail.com>
To: dmaengine@vger.kernel.org
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
Harninder Rai <harninder.rai@freescale.com>,
Xuelin Shi <xuelin.shi@freescale.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] dmaengine: fsl_raid: don't invoke client callback under desc_lock
Date: Fri, 17 Jul 2026 22:30:10 -0700 [thread overview]
Message-ID: <20260718053010.3074329-1-rosenp@gmail.com> (raw)
fsl_re_dequeue() holds re_chan->desc_lock while calling
fsl_re_desc_done(), which synchronously invokes the DMA client completion
callback via dmaengine_desc_get_callback_invoke(). If that callback
submits new work (e.g. fsl_re_tx_submit()), it tries to reacquire the
same desc_lock and deadlocks on the spinlock.
Collect completed descriptors into a local list under the lock, then
release the lock and invoke the callbacks before moving the descriptors
to the ack queue.
Fixes: ad80da658bbc ("dmaengine: Driver support for FSL RaidEngine device.")
Assisted-by: opencode:hy3-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/dma/fsl_raid.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c
index 2d86f61105e5..bfaef6245695 100644
--- a/drivers/dma/fsl_raid.c
+++ b/drivers/dma/fsl_raid.c
@@ -162,6 +162,7 @@ static void fsl_re_dequeue(struct tasklet_struct *t)
struct fsl_re_hw_desc *hwdesc;
unsigned long flags;
unsigned int count, oub_count;
+ LIST_HEAD(completed);
int found;
fsl_re_cleanup_descs(re_chan);
@@ -182,8 +183,7 @@ static void fsl_re_dequeue(struct tasklet_struct *t)
}
if (found) {
- fsl_re_desc_done(desc);
- list_move_tail(&desc->node, &re_chan->ack_q);
+ list_move_tail(&desc->node, &completed);
} else {
dev_err(re_chan->dev,
"found hwdesc not in sw queue, discard it\n");
@@ -196,6 +196,17 @@ static void fsl_re_dequeue(struct tasklet_struct *t)
FSL_RE_RMVD_JOB(1));
}
spin_unlock_irqrestore(&re_chan->desc_lock, flags);
+
+ /* Invoke the client callbacks outside the channel lock. The callback
+ * may submit new work which re-acquires desc_lock, so holding it here
+ * would deadlock.
+ */
+ list_for_each_entry_safe(desc, _desc, &completed, node) {
+ fsl_re_desc_done(desc);
+ spin_lock_irqsave(&re_chan->desc_lock, flags);
+ list_move_tail(&desc->node, &re_chan->ack_q);
+ spin_unlock_irqrestore(&re_chan->desc_lock, flags);
+ }
}
/* Per Job Ring interrupt handler */
--
2.55.0
next reply other threads:[~2026-07-18 5:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 5:30 Rosen Penev [this message]
2026-07-18 5:45 ` [PATCH] dmaengine: fsl_raid: don't invoke client callback under desc_lock sashiko-bot
2026-07-18 14:15 ` 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=20260718053010.3074329-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=harninder.rai@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=xuelin.shi@freescale.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