Re: [PATCH] dmaengine: idxd: Fix deadlock on interrupt handle revocation

From: ziyu zhang

Date: Mon Nov 30 2026 - 21:56:07 EST


On Tue, 1 Dec 2026 at 00:13, Dave Jiang <dave.jiang@xxxxxxxxx> wrote:
>
>
>
> On 11/25/26 4:35 AM, Ziyu Zhang wrote:
> > 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@xxxxxxxxx>
>
> Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
>
> Looks reasonable to me. Were you able to test this?

Hi Dave,

Thanks for the review. I found the potential deadlock with our experimental
static analysis tool. I don't have access to a setup that can exercise the
interrupt handle revocation path, so I haven't run any runtime tests.

I posted v2 before your reply. It updates the revoke work initialization
and IRQ teardown handling:

https://lore.kernel.org/r/20261125133123.98687-1-ziyuzhang201@xxxxxxxxx

Thanks,
Ziyu



>
> DJ
>
>
> > ---
> > 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) {
>