From: Ziyu Zhang <ziyuzhang201@gmail.com>
To: vinicius.gomes@intel.com, vkoul@kernel.org
Cc: dave.jiang@intel.com, Frank.Li@kernel.org, kevin.tian@intel.com,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
baijiaju1990@gmail.com, ziyuzhang201@gmail.com
Subject: [PATCH] dmaengine: idxd: Fix deadlock on interrupt handle revocation
Date: Wed, 25 Nov 2026 19:35:53 +0800 [thread overview]
Message-ID: <20261125113553.94215-1-ziyuzhang201@gmail.com> (raw)
idxd_misc_thread() is the threaded handler of the misc MSI-X vector and
the only context that completes idxd device commands: it calls
complete(idxd->cmd_done) for IDXD_INTC_CMD. On an
IDXD_INTC_INT_HANDLE_REVOKED interrupt it allocated a work item with
GFP_ATOMIC and, if that allocation failed, called idxd_wqs_quiesce()
inline to fall back. The quiesce takes wq_lock of every enabled kernel
work queue, so the misc thread can block there behind a command
submitter that holds wq_lock and waits for cmd_done, which only the
misc thread can complete. Nothing bounds that wait.
This potential deadlock was found by our experimental static analysis
tool, which analyzes lock usage and completion-based synchronization.
Embed the work item in struct idxd_device and queue it unconditionally,
removing the allocation and its synchronous quiesce fallback.
Revokes received while the work is pending are coalesced; the queued
work refreshes all valid interrupt handles. A revoke received while the
work is running can queue another execution to refresh handles that
have already been processed. Reusing the same work item on the same
workqueue also serialises revoke handling.
Fixes: 56fc39f5a367 ("dmaengine: idxd: handle interrupt handle revoked event")
Signed-off-by: Ziyu Zhang <ziyuzhang201@gmail.com>
---
drivers/dma/idxd/idxd.h | 2 ++
drivers/dma/idxd/init.c | 1 +
drivers/dma/idxd/irq.c | 27 ++++-----------------------
3 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
index ce78b9a7c641..03a73da22596 100644
--- a/drivers/dma/idxd/idxd.h
+++ b/drivers/dma/idxd/idxd.h
@@ -366,6 +366,7 @@ struct idxd_device {
struct idxd_dma_dev *idxd_dma;
struct workqueue_struct *wq;
struct work_struct work;
+ struct work_struct int_handle_revoke_work;
struct idxd_pmu *idxd_pmu;
@@ -762,6 +763,7 @@ int idxd_load_iaa_device_defaults(struct idxd_device *idxd);
/* device interrupt control */
irqreturn_t idxd_misc_thread(int vec, void *data);
+void idxd_int_handle_revoke(struct work_struct *work);
irqreturn_t idxd_wq_thread(int irq, void *data);
void idxd_mask_error_interrupts(struct idxd_device *idxd);
void idxd_unmask_error_interrupts(struct idxd_device *idxd);
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 4b827a329756..f3ade8036ddb 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -108,6 +108,7 @@ static int idxd_setup_interrupts(struct idxd_device *idxd)
}
dev_dbg(dev, "Enabled %d msix vectors\n", msixcnt);
+ INIT_WORK(&idxd->int_handle_revoke_work, idxd_int_handle_revoke);
ie = idxd_get_ie(idxd, 0);
ie->vector = pci_irq_vector(pdev, 0);
diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c
index 6a25e1fd0e62..6d3355ce88f7 100644
--- a/drivers/dma/idxd/irq.c
+++ b/drivers/dma/idxd/irq.c
@@ -24,11 +24,6 @@ struct idxd_resubmit {
struct idxd_desc *desc;
};
-struct idxd_int_handle_revoke {
- struct work_struct work;
- struct idxd_device *idxd;
-};
-
static void idxd_device_reinit(struct work_struct *work)
{
struct idxd_device *idxd = container_of(work, struct idxd_device, work);
@@ -127,17 +122,15 @@ static void idxd_abort_invalid_int_handle_descs(struct idxd_irq_entry *ie)
}
}
-static void idxd_int_handle_revoke(struct work_struct *work)
+void idxd_int_handle_revoke(struct work_struct *work)
{
- struct idxd_int_handle_revoke *revoke =
- container_of(work, struct idxd_int_handle_revoke, work);
- struct idxd_device *idxd = revoke->idxd;
+ struct idxd_device *idxd =
+ container_of(work, struct idxd_device, int_handle_revoke_work);
struct pci_dev *pdev = idxd->pdev;
struct device *dev = &pdev->dev;
int i, new_handle, rc;
if (!idxd->request_int_handles) {
- kfree(revoke);
dev_warn(dev, "Unexpected int handle refresh interrupt.\n");
return;
}
@@ -216,7 +209,6 @@ static void idxd_int_handle_revoke(struct work_struct *work)
udelay(100);
idxd_int_handle_revoke_drain(ie);
}
- kfree(revoke);
}
static void idxd_evl_fault_work(struct work_struct *work)
@@ -504,20 +496,9 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
}
if (cause & IDXD_INTC_INT_HANDLE_REVOKED) {
- struct idxd_int_handle_revoke *revoke;
-
val |= IDXD_INTC_INT_HANDLE_REVOKED;
- revoke = kzalloc_obj(*revoke, GFP_ATOMIC);
- if (revoke) {
- revoke->idxd = idxd;
- INIT_WORK(&revoke->work, idxd_int_handle_revoke);
- queue_work(idxd->wq, &revoke->work);
-
- } else {
- dev_err(dev, "Failed to allocate work for int handle revoke\n");
- idxd_wqs_quiesce(idxd);
- }
+ queue_work(idxd->wq, &idxd->int_handle_revoke_work);
}
if (cause & IDXD_INTC_CMD) {
--
2.34.1
reply other threads:[~2026-11-25 11:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261125113553.94215-1-ziyuzhang201@gmail.com \
--to=ziyuzhang201@gmail.com \
--cc=Frank.Li@kernel.org \
--cc=baijiaju1990@gmail.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vinicius.gomes@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®