DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fei Yu" <fei.yu@intel.com>, dmaengine@vger.kernel.org
Cc: vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH 1/2] dmaengine: idxd: Keep wqs dedicated without shared wq support
Date: Mon, 30 Nov 2026 07:23:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-240584@kernel.org> (raw)
In-Reply-To: <20261130071338.3120264-2-fei.yu@intel.com>

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

  reply	other threads:[~2026-11-30  7:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [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=sashiko-outbox-240584@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=fei.yu@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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