* [PATCH 0/2] dmaengine: idxd: No shared wqs without shared wq support
@ 2026-11-30 7:13 Fei Yu
2026-11-30 7:13 ` [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated " Fei Yu
2026-11-30 7:13 ` [PATCH 2/2] dmaengine: idxd: Reject shared wq mode " Fei Yu
0 siblings, 2 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
A wq is shared unless WQ_FLAG_DEDICATED is set, so on a device without
shared wq support (no ENQCMD, or no PASID) every wq starts out in a
mode the device cannot use, and a wq goes back to that mode when it is
disabled. Since a disabled wq keeps its group, the next device
configuration fails; on the Nova Lake IAA, the restore after an FLR
halts the device once iaa_crypto has released its wq.
Patch 1 makes dedicated the mode of every wq on such devices, at setup
and after disable (the fix, for stable). Patch 2 rejects "shared" in
the wq mode attribute there, so the invalid state cannot be set from
userspace either; it is not needed for stable.
Tested on Nova Lake (v7.3.4 based kernel, idxd and iaa_crypto built
out of tree with this series): module reload, PCI unbind/bind and FLR
10 times each with iaa_crypto bound, all pass. With wq0.0 released by
iaa_crypto, an FLR no longer halts the device ("HALT: iax0 config
fails" before), iax0 stays enabled and wq0.0 stays dedicated.
"echo shared > wq0.0/mode" fails with EOPNOTSUPP.
The series is based on dmaengine/next and also applies on top of
"dmaengine: idxd: More error handling fixes" v2 [1].
[1] https://lore.kernel.org/r/20261125-wt-idxd-fixes-v2-0-25a4691dfb9e@intel.com
Fei Yu (2):
dmaengine: idxd: Keep wqs dedicated without shared wq support
dmaengine: idxd: Reject shared wq mode without shared wq support
drivers/dma/idxd/device.c | 9 +++++++++
drivers/dma/idxd/idxd.h | 13 +++++++++++++
drivers/dma/idxd/init.c | 3 +++
drivers/dma/idxd/sysfs.c | 2 ++
4 files changed, 27 insertions(+)
base-commit: 2e02fb103be058cf8b2fb24112a74a2715e090f0
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [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 7:23 ` sashiko-bot 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 related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated without shared wq support 2026-11-30 7:13 ` [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated " Fei Yu @ 2026-11-30 7:23 ` sashiko-bot 0 siblings, 0 replies; 4+ messages in thread From: sashiko-bot @ 2026-11-30 7:23 UTC (permalink / raw) To: Fei Yu, dmaengine; +Cc: vkoul, Frank.Li Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] dmaengine: idxd: disabled wq still fails idxd_wqs_setup() when shared supported - [Medium] dmaengine: idxd: device_shared_wq_supported() ignores disabled device PASID -- commit 78fa6a3a91a335286fae219516810f795a72cd14 Author: Fei Yu <fei.yu@intel.com> dmaengine: idxd: Keep wqs dedicated without shared wq support This commit introduces device_shared_wq_supported() and keeps workqueues in dedicated mode during initial setup and after workqueue disable on devices that do not support shared workqueues. > diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c > index 131138483b877..e641793f2ce5b 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); [Severity: High] Does disabling a workqueue on a device where device_shared_wq_supported() is true still cause the next idxd_wqs_setup() to fail with -EINVAL? When device_shared_wq_supported(idxd) is true, idxd_wq_disable_cleanup() leaves wq->flags cleared (shared) while keeping wq->group set. Right afterward, idxd_wq_free_resources() (or idxd_user_drv_remove() for user workqueues) resets wq->type to IDXD_WQT_NONE. Because wq_pasid_enabled() requires wq->type to be IDXD_WQT_KERNEL or IDXD_WQT_USER, wq_shared_supported(wq) returns false for any disabled workqueue: drivers/dma/idxd/idxd.h:wq_pasid_enabled() { return (is_idxd_wq_kernel(wq) && device_pasid_enabled(wq->idxd)) || (is_idxd_wq_user(wq) && device_user_pasid_enabled(wq->idxd)); } On the next idxd_device_config() -> idxd_wqs_setup() (for example after an FLR or when enabling another workqueue on the device), the disabled workqueue still has wq->group != NULL, wq_shared(wq) == true, and wq_shared_supported(wq) == false, so idxd_wqs_setup() rejects the configuration with IDXD_SCMD_WQ_NO_SWQ_SUPPORT and halts the device. > diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h > index ce78b9a7c641c..f5fe7442f2169 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; > +} [Severity: Medium] Does device_shared_wq_supported() return true on ENQCMD-capable CPUs even when PASID is not enabled on the device? In idxd_probe(), IDXD_FLAG_USER_PASID_ENABLED is set unconditionally whenever CONFIG_INTEL_IDXD_SVM and sva are enabled, regardless of whether PASID is actually enabled on the device: drivers/dma/idxd/init.c:idxd_probe() { ... if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) { set_bit(IDXD_FLAG_USER_PASID_ENABLED, &idxd->flags); rc = idxd_enable_system_pasid(idxd); if (rc) dev_warn(dev, "No in-kernel DMA with PASID. %d\n", rc); else set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags); } ... } As a result, device_user_pasid_enabled(idxd) is true even when PASID is disabled in the IOMMU or PCIe endpoint, so idxd_setup_wqs() and idxd_wq_disable_cleanup() will not set WQ_FLAG_DEDICATED on ENQCMD systems without PASID enabled. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261130071338.3120264-1-fei.yu@intel.com?part=1 ^ 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 related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-30 7:23 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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:23 ` sashiko-bot 2026-11-30 7:13 ` [PATCH 2/2] dmaengine: idxd: Reject shared wq mode " Fei Yu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox