All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael J. Ruhl" <michael.j.ruhl@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 09/10] drm/xe/vsec: Support late bind fw information
Date: Wed, 12 Aug 2026 19:54:20 +0000	[thread overview]
Message-ID: <20260812195421.15EE31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812193742.2170188-21-michael.j.ruhl@intel.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Double `xe_pm_runtime_put(xe)` in the success path of `xe_pmt_write_reg`.
- [High] The late bind delayed work is cancelled via a `devm` action, causing a race during teardown that registers child devices on a deleted parent.
- [Medium] Using asynchronous `xe_pm_runtime_put()` during device teardown can leave hardware active indefinitely.
- [Medium] `wait_for_fw` places the calling process in uninterruptible sleep (`D` state) for up to 20 seconds.
--

--- Patch [9]: [PATCH v2 09/10] drm/xe/vsec: Support late bind fw information ---
commit 5901be98f83d9c07e1385a372c7e330c405c0188
Author: Michael J. Ruhl <michael.j.ruhl@intel.com>

drm/xe/vsec: Support late bind fw information

CRI FW is loaded on power on.  Because of this, access to
the FW cannot be done until it is running.

Update the XE PMT probe and access to check for late bind
devices, verify, and wait for the appropriate FW state
before probe or access.

> diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
> --- a/drivers/gpu/drm/xe/xe_vsec.c
> +++ b/drivers/gpu/drm/xe/xe_vsec.c
[ ... ]
> +static bool wait_for_fw(struct xe_device *xe)
> +{
> +	int retries = VSEC_LATE_BIND_RETRY;  /* wait up to 20 secs */
> +
> +	if (xe->info.platform != XE_CRESCENTISLAND)
> +		return true;
> +
> +	while (retries--) {
> +		if (xe_is_oobmsm_fw_ready(xe))
> +			return true;
> +
> +		msleep(VSEC_LATE_BIND_DELAY_MSEC);

[Severity: Medium]
Does this msleep() place the calling process in an uninterruptible sleep
for up to 20 seconds?

If the firmware is unresponsive, userspace processes reading or writing the
PMT sysfs interface might become unkillable and hang while calling
xe_pmt_telem_read(), xe_pmt_read_reg(), or xe_pmt_write_reg().

[ ... ]
> @@ -416,6 +488,10 @@ static int xe_pmt_write_reg(struct device *dev, u32 guid, u32 reg, u32 offset)
>  	disc_addr += CRI_DISCOVERY_OFFSET + inst + offset;
>  
>  	xe_pm_runtime_get(xe);
> +	if (!wait_for_fw(xe)) {
> +		ret = -ENODATA;
> +		goto runtime_exit;
> +	}
>  	mutex_lock(&xe->pmt.lock);
>  
>  	xe->soc_remapper.set_telem_region(xe, CRI_IDX_TELEM_DISCOVERY);
> @@ -425,6 +501,9 @@ static int xe_pmt_write_reg(struct device *dev, u32 guid, u32 reg, u32 offset)
>  	mutex_unlock(&xe->pmt.lock);
>  	xe_pm_runtime_put(xe);
>  
> +runtime_exit:
> +	xe_pm_runtime_put(xe);
> +
>  dev_exit:
>  	drm_dev_exit(idx);

[Severity: High]
Will the success path fall through here and execute the newly added
runtime_exit cleanup path?

It appears that if wait_for_fw() succeeds, the function calls
xe_pm_runtime_put() once right after mutex_unlock(), and then immediately
falls through to the runtime_exit label, resulting in two sequential
xe_pm_runtime_put() calls. 

This could drop the PM usage counter below its baseline, potentially
powering off the device prematurely while it is still in use.

[ ... ]
> +static void vsec_disable_late_bind_work(void *arg)
> +{
> +	struct xe_device *xe = arg;
> +
> +	/*
> +	 * If was work was cancelled while it was still pending, we need to
> +	 * take care of releasing the runtime reference
> +	 */
> +	if (disable_delayed_work_sync(&xe->pmt.work))
> +		xe_pm_runtime_put(xe);

[Severity: Medium]
Should this use a synchronous put instead of an asynchronous one?

Using an asynchronous xe_pm_runtime_put() during device teardown can leave
the hardware active indefinitely. The pending async idle/suspend work can
be cancelled by pm_runtime_disable() during the device removal path.

[Severity: High]
Can this devm action race with cri_late_bind_probe_work() during teardown?

If the device is unbound during the 20-second firmware initialization
window, the driver core removes all children via device_del() before
starting devres release. The disable_delayed_work_sync() here blocks until
the work completes.

Concurrently, if cri_late_bind_probe_work() executes:

static void cri_late_bind_probe_work(struct work_struct *work)
{
	...
	if (xe_is_oobmsm_fw_ready(xe)) {
		cri_late_bind_probe(xe);
		...

It could proceed to call intel_vsec_register().

Would this register a child device on a parent that has already been
deleted, causing devres list corruption or a sysfs use-after-free?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812193742.2170188-12-michael.j.ruhl@intel.com?part=9

  reply	other threads:[~2026-08-12 22:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 19:37 [PATCH v2 00/10] Crescent Island PMT support Michael J. Ruhl
2026-08-12 19:37 ` [PATCH v2 01/10] platform/x86/intel/pmt: complete pcidev to device update Michael J. Ruhl
2026-08-12 19:37 ` [PATCH v2 02/10] platform/x86/intel/pmt: Add register access callbacks Michael J. Ruhl
2026-08-12 19:49   ` sashiko-bot
2026-08-12 19:37 ` [PATCH v2 03/10] drm/xe/vsec: Protect against missing config Michael J. Ruhl
2026-08-12 19:37 ` [PATCH v2 04/10] drm/xe/vsec: Use correct pm state get Michael J. Ruhl
2026-08-12 19:37 ` [PATCH v2 05/10] drm/xe/vsec: Support possible hotplug exit Michael J. Ruhl
2026-08-12 19:51   ` sashiko-bot
2026-08-12 19:37 ` [PATCH v2 06/10] drm/xe/vsec: Support Crescent Island PMT Michael J. Ruhl
2026-08-12 19:49   ` sashiko-bot
2026-08-12 19:37 ` [PATCH v2 07/10] drm/xe/vsec: Crescent Island PMT decode Michael J. Ruhl
2026-08-12 19:51   ` sashiko-bot
2026-08-12 19:37 ` [PATCH v2 08/10] drm/xe/vsec: Crescent Island PMT callbacks Michael J. Ruhl
2026-08-12 19:57   ` sashiko-bot
2026-08-12 19:37 ` [PATCH v2 09/10] drm/xe/vsec: Support late bind fw information Michael J. Ruhl
2026-08-12 19:54   ` sashiko-bot [this message]
2026-08-12 20:12   ` Ruhl, Michael J
2026-08-12 19:37 ` [PATCH v2 10/10] drm/xe/vsec: Update PMT internal access for CRI Michael J. Ruhl
2026-08-12 20:04   ` sashiko-bot
2026-08-12 20:24 ` ✓ CI.KUnit: success for Crescent Island PMT support (rev4) Patchwork
2026-08-12 21:16 ` ✓ Xe.CI.BAT: " Patchwork

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=20260812195421.15EE31F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michael.j.ruhl@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.