[PATCH v2 0/8] dmaengine: idxd: More error handling fixes

From: Vinicius Costa Gomes

Date: Wed Nov 25 2026 - 18:50:09 EST


This series fixes error handling in the idxd driver.

1/8 and 3/8 fix crashes seen in a kdump kernel, where the device reset
fails during probe. 2/8 fixes the same kind of double free for failures
after idxd_setup_internals(). Jingyi Li tested them on 10 systems with
DSA. 1/8 to 3/8 should be backported together: with only 1/8, a probe
failure after idxd_setup_internals() still destroys the workqueue
twice, and a failed device reset still double frees in idxd_free().

4/8 to 6/8 fix the device registration, idxd_cdev_open() and WQ setup
error paths.

7/8 and 8/8 fix terminate_all(). Since v7.0 it releases the WQ's
interrupt handle, so later transfers on the channel fail with "Device
error 0x19". It also sleeps, and frees descriptors the device may still
use.

7/8 and 8/8 overlap with two patches of Daniel Byrne's series, "dmaengine:
idxd: keep the interrupt handle across terminate_all" and "dmaengine:
idxd: quarantine terminate_all's descriptor slots until the device has
drained":
https://lore.kernel.org/r/20261019150630.4026341-7-daniel1.byrne@xxxxxxxxx
https://lore.kernel.org/r/20261019150630.4026341-10-daniel1.byrne@xxxxxxxxx

Left for a separate series: currently, on a shared WQ, two opens by
the same mm share one PASID entry, and closing the first one removes
it, so the completion records of the other's page faults are
dropped (pointed out by Sashiko on v1 5/6). Proper support will be
added on a later series.

An AI coding assistant was used to triage the v1 review comments, to
help write and review the v2 changes to 4/8 and 5/8, to help write 6/8,
8/8 and the INVALID_INT_HANDLE check in 7/8, and with the testing.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@xxxxxxxxx>
---
Changes in v2:
- 1/8, 3/8: use () after function names (Frank); add my Signed-off-by
instead of the Acked-by (Dave)
- 1/8, 2/8, 3/8: add Cc: stable and Jingyi's Tested-by
- Move "Fix potential double free on probe error path" (v1 3/6) to 2/8,
next to 1/8, as they need to be backported together
- 2/8: keep flushing the device workqueue in idxd_cleanup_internals(),
before the registers are unmapped (added after Jingyi's Tested-by and
Dave's Reviewed-by)
- 4/8: also stop the registration error paths from dropping the
device references that idxd_cleanup() drops again (Sashiko)
- 5/8: fail the open on xa_insert() errors other than -EBUSY (Sashiko),
and disable the PASID of a dedicated WQ when ida_alloc() fails
(Sashiko)
- New 6/8: initialize the WQ XArray before the WQ can be released
- 7/8 (v1 6/6): don't release an interrupt handle that is already
invalid (Sashiko); add Cc: stable
- New 8/8: don't sleep or free descriptors in terminate_all(), leave
that to synchronize(), after the drain (Sashiko)
- Link to v1: https://patch.msgid.link/20261012-wt-idxd-fixes-v1-0-30a35a445077@xxxxxxxxx

---
Steve Wahl (2):
dmaengine: idxd: Do not call destroy_workqueue() with null idxd->wq
dmaengine: idxd: fix duplicate memory frees on initialization error path

Vinicius Costa Gomes (6):
dmaengine: idxd: Fix potential double free on probe error path
dmaengine: idxd: Fix the device registration error paths
dmaengine: idxd: Fix error handling in idxd_cdev_open()
dmaengine: idxd: Initialize the WQ XArray before the WQ can be released
dmaengine: idxd: Do not release interrupt handles on terminate_all()
dmaengine: idxd: Don't flush the descriptors on terminate_all()

drivers/dma/idxd/cdev.c | 12 ++++++++++--
drivers/dma/idxd/device.c | 24 ++++++++++++++++++------
drivers/dma/idxd/dma.c | 47 ++++++++++++++++++++++++++++++++++++++---------
drivers/dma/idxd/idxd.h | 4 ++++
drivers/dma/idxd/init.c | 27 ++++++++++-----------------
drivers/dma/idxd/irq.c | 1 +
drivers/dma/idxd/sysfs.c | 43 +++++++++++++------------------------------
7 files changed, 94 insertions(+), 64 deletions(-)
---
base-commit: d460a02aa0ac6ba9e5d87f8462f75d78be83146e
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git fixes
change-id: 20260803-wt-idxd-fixes-1a06bb69b1e0

Best regards,
--
Vinicius