From: sashiko-bot@kernel.org
To: "Daniel Byrne" <daniel1.byrne@intel.com>, dmaengine@vger.kernel.org
Cc: vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v2 10/10] dmaengine: idxd: test a queue under its lock before quiescing it
Date: Mon, 30 Nov 2026 20:09:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-241935@kernel.org> (raw)
In-Reply-To: <20261130194721.1900266-11-daniel1.byrne@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dmaengine: idxd: deadlock on wq_lock vs cmd_done in
idxd_wqs_quiesce()
--
commit 36a9678a1a099380b2c088bef490159f8c968311
Author: Daniel Byrne <daniel1.byrne@intel.com>
dmaengine: idxd: test a queue under its lock before quiescing it
This commit re-checks wq->state and wq->type under wq->wq_lock in
idxd_wqs_quiesce() before calling __idxd_wq_quiesce(), while keeping the
unlocked check ahead of mutex_lock(&wq->wq_lock).
> diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
> index 4b827a3297564..4f3693fb7975d 100644
> --- a/drivers/dma/idxd/init.c
> +++ b/drivers/dma/idxd/init.c
> @@ -1242,8 +1242,26 @@ void idxd_wqs_quiesce(struct idxd_device *idxd)
>
> for (i = 0; i < idxd->max_wqs; i++) {
> wq = idxd->wqs[i];
> + /*
> + * Skip a queue that does not read as an enabled kernel
> + * queue without taking its lock. This runs in the thread
> + * that completes the device commands, and the enable of a
> + * kernel queue and a cdev open hold the lock of such a
> + * queue while they wait for a command. An unbind holds the
> + * lock of an enabled kernel queue across its commands, and
> + * this waits behind it.
> + */
> + if (wq->state != IDXD_WQ_ENABLED || wq->type != IDXD_WQT_KERNEL)
> + continue;
> + /*
> + * Test again under the lock. The enable and the disable of
> + * a queue hold it from end to end, so a queue that reads
> + * enabled here has its reference.
> + */
> + mutex_lock(&wq->wq_lock);
> if (wq->state == IDXD_WQ_ENABLED && wq->type == IDXD_WQT_KERNEL)
> - idxd_wq_quiesce(wq);
> + __idxd_wq_quiesce(wq);
> + mutex_unlock(&wq->wq_lock);
> }
> }
[Severity: Medium]
Can idxd_misc_thread() still deadlock on wq->wq_lock against a command
waiter in idxd_drv_enable_wq() or idxd_drv_disable_wq()?
idxd_drv_enable_wq() sets wq->state = IDXD_WQ_ENABLED inside
idxd_wq_enable() while wq->type is already IDXD_WQT_KERNEL, and then
issues IDXD_CMD_REQUEST_INT_HANDLE via idxd_wq_request_irq() (and
IDXD_CMD_DRAIN_WQ / IDXD_CMD_RESET_WQ on its err_map_portal unwind path)
while still holding wq->wq_lock. Likewise, idxd_drv_disable_wq() holds
wq->wq_lock on an enabled kernel queue while issuing drain and reset
commands.
Because those commands wait in idxd_cmd_exec() for idxd_misc_thread() to
complete idxd->cmd_done, the unlocked filter does not skip the queue and
idxd_misc_thread() blocks on wq->wq_lock before reaching the
IDXD_INTC_CMD check:
CPU0 CPU1 (idxd_misc_thread)
idxd_drv_enable_wq()
mutex_lock(&wq->wq_lock)
idxd_wq_enable()
wq->state = IDXD_WQ_ENABLED
idxd_wq_request_irq()
...
idxd_cmd_exec()
idxd_halt()
idxd_wqs_quiesce()
mutex_lock(&wq->wq_lock)
wait_for_completion(&done) <-- deadlock
complete(idxd->cmd_done) (never reached)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130194721.1900266-1-daniel1.byrne@intel.com?part=10
prev parent reply other threads:[~2026-11-30 20:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 19:47 [PATCH v2 00/10] dmaengine: idxd: event log, cdev and prep fixes Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 01/10] dmaengine: idxd: don't queue EVL fault work for kernel WQs Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 02/10] dmaengine: idxd: detach the user fault workqueue under the event log lock Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 03/10] dmaengine: idxd: free the event log fault item when no record is copied Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 04/10] dmaengine: idxd: refuse a memcpy longer than the WQ max transfer size Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 05/10] dmaengine: idxd: take an mm_users reference for the completion record copy Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 06/10] dmaengine: idxd: read GENCFG before clearing the event log enable Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 07/10] dmaengine: idxd: don't sleep for a descriptor in the prep callbacks Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 08/10] dmaengine: idxd: read the event log size under its lock in the setup Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 09/10] dmaengine: idxd: free the queue interrupt when the percpu_ref setup fails Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 10/10] dmaengine: idxd: test a queue under its lock before quiescing it Daniel Byrne
2026-11-30 20:09 ` sashiko-bot [this message]
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-241935@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=daniel1.byrne@intel.com \
--cc=dmaengine@vger.kernel.org \
--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