From: Fei Yu <fei.yu@intel.com>
To: Vinod Koul <vkoul@kernel.org>, dmaengine@vger.kernel.org
Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Dave Jiang <dave.jiang@intel.com>, Frank Li <Frank.Li@kernel.org>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated without shared wq support
Date: Mon, 30 Nov 2026 15:13:37 +0800 [thread overview]
Message-ID: <20261130071338.3120264-2-fei.yu@intel.com> (raw)
In-Reply-To: <20261130071338.3120264-1-fei.yu@intel.com>
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
next prev parent reply other threads:[~2026-11-30 7:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 7:13 [PATCH 0/2] dmaengine: idxd: No shared wqs " Fei Yu
2026-11-30 7:13 ` Fei Yu [this message]
2026-11-30 7:13 ` [PATCH 2/2] dmaengine: idxd: Reject shared wq mode " Fei Yu
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=20261130071338.3120264-2-fei.yu@intel.com \
--to=fei.yu@intel.com \
--cc=Frank.Li@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--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®