* [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated without shared wq support
2026-11-30 7:13 [PATCH 0/2] dmaengine: idxd: No shared wqs without shared wq support Fei Yu
@ 2026-11-30 7:13 ` Fei Yu
2026-11-30 16:30 ` Andy Shevchenko
2026-11-30 7:13 ` [PATCH 2/2] dmaengine: idxd: Reject shared wq mode " Fei Yu
1 sibling, 1 reply; 4+ messages in thread
From: Fei Yu @ 2026-11-30 7:13 UTC (permalink / raw)
To: Vinod Koul, dmaengine
Cc: Vinicius Costa Gomes, Dave Jiang, Frank Li, Andy Shevchenko,
linux-kernel
A wq is shared unless WQ_FLAG_DEDICATED is set, and wq->flags starts
out as 0, so every wq is shared by default. That is also the case on
devices without shared wq support (no ENQCMD, or PASID not enabled),
where a shared wq is not a valid configuration.
Since commit 0f225705cf65 ("dmaengine: idxd: fix wq settings post wq
disable"), disabling a wq keeps its size and group, because they can
only change while the device is disabled, but idxd_wq_disable_cleanup()
still clears wq->flags. The wq thus turns into a shared wq that is
still part of the device configuration. On a device without shared wq
support, the next device configuration, e.g. the restore after an FLR,
is rejected by idxd_wqs_setup() and the device halts. On the Nova Lake
IAA, after iaa_crypto releases its wq:
idxd 0000:00:0c.0: No shared wq support but configured.
idxd 0000:00:0c.0: HALT: iax0 config fails
On such devices, make dedicated the mode of a wq when it is set up and
after it is disabled: it is the only mode the wq can have there. The
check is device wide, as the wq type, which tells whether kernel or
user PASID applies, is not known at these points. Devices with shared
wq support keep the current behavior.
Fixes: 0f225705cf65 ("dmaengine: idxd: fix wq settings post wq disable")
Cc: stable@vger.kernel.org
Suggested-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Fei Yu <fei.yu@intel.com>
---
drivers/dma/idxd/device.c | 9 +++++++++
drivers/dma/idxd/idxd.h | 13 +++++++++++++
drivers/dma/idxd/init.c | 3 +++
3 files changed, 25 insertions(+)
diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
index 131138483b87..e641793f2ce5 100644
--- a/drivers/dma/idxd/device.c
+++ b/drivers/dma/idxd/device.c
@@ -387,6 +387,15 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq)
wq->priority = 0;
wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES;
wq->flags = 0;
+ /*
+ * The wq keeps its size and group (see idxd_wq_device_reset_cleanup()),
+ * so it stays part of the device configuration. Without shared wq
+ * support, keep it dedicated: a shared wq would make the configuration
+ * invalid, and the device would fail to be configured again, e.g. after
+ * an FLR.
+ */
+ if (!device_shared_wq_supported(idxd))
+ set_bit(WQ_FLAG_DEDICATED, &wq->flags);
memset(wq->name, 0, WQ_NAME_SIZE);
wq->max_xfer_bytes = WQ_DEFAULT_MAX_XFER;
idxd_wq_set_max_batch_size(idxd->data->type, wq, WQ_DEFAULT_MAX_BATCH);
diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h
index ce78b9a7c641..f5fe7442f216 100644
--- a/drivers/dma/idxd/idxd.h
+++ b/drivers/dma/idxd/idxd.h
@@ -607,6 +607,19 @@ static inline bool wq_shared_supported(struct idxd_wq *wq)
return (support_enqcmd && wq_pasid_enabled(wq));
}
+/*
+ * Can any wq of the device, kernel or user, be a shared wq? Unlike
+ * wq_shared_supported(), this does not depend on the wq type, so it also
+ * answers for a wq whose type is not set yet.
+ */
+static inline bool device_shared_wq_supported(struct idxd_device *idxd)
+{
+ if (!(device_pasid_enabled(idxd) || device_user_pasid_enabled(idxd)))
+ return false;
+
+ return support_enqcmd;
+}
+
enum idxd_portal_prot {
IDXD_PORTAL_UNLIMITED = 0,
IDXD_PORTAL_LIMITED,
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 4b827a329756..5421c1c0c6d6 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -217,6 +217,9 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
idxd_wq_set_max_batch_size(idxd->data->type, wq, WQ_DEFAULT_MAX_BATCH);
idxd_wq_set_init_max_sgl_size(idxd, wq);
wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES;
+ /* Without shared wq support, dedicated is the only valid mode */
+ if (!device_shared_wq_supported(idxd))
+ set_bit(WQ_FLAG_DEDICATED, &wq->flags);
wq->wqcfg = kzalloc_node(idxd->wqcfg_size, GFP_KERNEL, dev_to_node(dev));
if (!wq->wqcfg) {
put_device(conf_dev);
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] dmaengine: idxd: Reject shared wq mode without shared wq support
2026-11-30 7:13 [PATCH 0/2] dmaengine: idxd: No shared wqs without shared wq support Fei Yu
2026-11-30 7:13 ` [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated " Fei Yu
@ 2026-11-30 7:13 ` Fei Yu
1 sibling, 0 replies; 4+ messages in thread
From: Fei Yu @ 2026-11-30 7:13 UTC (permalink / raw)
To: Vinod Koul, dmaengine
Cc: Vinicius Costa Gomes, Dave Jiang, Frank Li, Andy Shevchenko,
linux-kernel
On a device without shared wq support (no ENQCMD, or PASID not
enabled), the wq mode attribute still accepts "shared". The setting
only fails later: enabling the wq fails with "PASID not enabled and
shared wq", and a shared wq that has a group makes every following
device configuration fail.
Reject "shared" with -EOPNOTSUPP on such devices, so that a wq can not
be put into a mode the device does not support.
Suggested-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Fei Yu <fei.yu@intel.com>
---
drivers/dma/idxd/sysfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 2b0524324089..3c0b27dc8c9f 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -693,6 +693,8 @@ static ssize_t wq_mode_store(struct device *dev,
set_bit(WQ_FLAG_DEDICATED, &wq->flags);
wq->threshold = 0;
} else if (sysfs_streq(buf, "shared")) {
+ if (!device_shared_wq_supported(idxd))
+ return -EOPNOTSUPP;
clear_bit(WQ_FLAG_DEDICATED, &wq->flags);
} else {
return -EINVAL;
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread