From: sashiko-bot@kernel.org
To: "Arvind Yadav" <arvind.yadav@intel.com>
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 09/13] drm/xe: Isolate a wedged device before notifying userspace
Date: Thu, 27 Aug 2026 10:35:05 +0000 [thread overview]
Message-ID: <20260827103506.77AF91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827101801.1247654-10-arvind.yadav@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] TOCTOU race in `xe_pci_suspend` allows concurrent execution of `xe_pm_suspend` and the asynchronous wedge worker, leading to unbalanced PCI enable counts and unsafe MMIO accesses.
- [High] The xe_pci_resume function unconditionally toggles D3Cold, leading to unbalanced power state changes when the device is wedged.
--
commit fc050bbcfed735c33773bd7fb0bbf0a5e4fe47a1
Author: Arvind Yadav <arvind.yadav@intel.com>
drm/xe: Isolate a wedged device before notifying userspace
This commit introduces a sleepable wedge worker to safely isolate a permanently
wedged device. It stops interrupt and DMA activity, invalidates VRAM mappings,
and updates the suspend and resume paths to wait for device isolation and skip
normal PM transitions when the device is wedged.
> diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> index 1e04e8ef2611f..beaa79d136198 100644
> --- a/drivers/gpu/drm/xe/xe_pci.c
> +++ b/drivers/gpu/drm/xe/xe_pci.c
> @@ -1331,6 +1331,16 @@ static int xe_pci_suspend(struct device *dev)
> if (xe_survivability_mode_is_boot_enabled(xe))
> return -EBUSY;
>
> + /*
> + * Wait until wedge work is queued, then wait for isolation to
> + * finish before skipping normal suspend.
> + */
> + if (xe_device_wedged(xe)) {
> + wait_for_completion(&xe->wedged.prepared);
> + flush_work(&xe->wedged.work);
> + return 0;
> + }
> +
[Severity: High]
Does this lockless check open a TOCTOU race window before proceeding to the
normal PM suspend flow and pci_disable_device()?
If the device is declared wedged immediately after the lockless
xe_device_wedged(xe) check evaluates to false, xe_pci_suspend() will
proceed with executing xe_pm_suspend() and eventually calling
pci_disable_device(pdev). Meanwhile, xe_device_wedged_work() executes
concurrently with xe_pm_suspend().
Later during system resume, xe_pci_resume() will see xe_device_wedged(xe)
as true and return early without calling pci_enable_device(pdev). This
results in an unbalanced pci_disable_device() leaving enable_cnt decremented
without a matching increment.
Could this happen if a hardware timeout occurs during the suspend process
itself (e.g., during GT suspend or eviction timeout)?
Also, if the device is already wedged and xe_pci_suspend() returns 0 here,
it skips the d3cold_toggle(pdev, D3COLD_ENABLE) call which occurs later in
this function.
[ ... ]
> @@ -1352,6 +1362,7 @@ static int xe_pci_resume(struct device *dev)
> {
> struct pci_dev *pdev = to_pci_dev(dev);
> + struct xe_device *xe = pdev_to_xe_device(pdev);
> int err;
>
> /* Give back the D3Cold decision to the runtime P M*/
> d3cold_toggle(pdev, D3COLD_DISABLE);
>
> err = pci_set_power_state(pdev, PCI_D0);
> if (err)
> return err;
>
> pci_restore_state(pdev);
>
> + /*
> + * Suspend skipped PCI disable for an already isolated device. Avoid
> + * incrementing enable_cnt and clear bus mastering restored from the
> + * saved configuration.
> + */
> + if (xe_device_wedged(xe)) {
> + pci_clear_master(pdev);
> + return 0;
> + }
[Severity: High]
Does this unconditionally toggle D3Cold before checking if the device is
wedged?
If the device is wedged before xe_pci_suspend() is called, it returns early
and skips the balancing d3cold_toggle(pdev, D3COLD_ENABLE) call. However,
on system resume, xe_pci_resume() unconditionally calls
d3cold_toggle(pdev, D3COLD_DISABLE) before checking if the device is wedged.
Can this lead to an unbalanced call to pci_d3cold_disable(root_pdev) (which
increments no_d3cold) on every suspend/resume cycle once the device has been
permanently wedged, eventually breaking D3Cold power management for the
root port?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827101801.1247654-1-arvind.yadav@intel.com?part=9
next prev parent reply other threads:[~2026-08-27 10:35 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 10:17 [PATCH 00/13] drm/xe: Isolate wedged devices from hardware access Arvind Yadav
2026-08-27 10:17 ` [PATCH 01/13] drm/xe/irq: Always free requested IRQs on uninstall Arvind Yadav
2026-08-27 10:39 ` Ghimiray, Himal Prasad
2026-08-31 20:30 ` Rodrigo Vivi
2026-09-01 9:32 ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 02/13] drm/xe: Separate AER reset state from device wedging Arvind Yadav
2026-08-27 10:36 ` sashiko-bot
2026-08-27 21:55 ` Andi Shyti
2026-08-28 3:32 ` Yadav, Arvind
2026-08-28 11:36 ` [PATCH 2/13] " Raag Jadav
2026-08-27 10:17 ` [PATCH 03/13] drm/xe: Drop queued page faults when device I/O is blocked Arvind Yadav
2026-08-31 20:43 ` Rodrigo Vivi
2026-09-02 4:49 ` Yadav, Arvind
2026-09-02 5:30 ` Matthew Brost
2026-09-02 5:33 ` Matthew Brost
2026-08-27 10:17 ` [PATCH 04/13] drm/xe: Stop VM work " Arvind Yadav
2026-08-31 20:55 ` Rodrigo Vivi
2026-09-01 9:11 ` Yadav, Arvind
2026-09-02 5:40 ` Matthew Brost
2026-08-27 10:17 ` [PATCH 05/13] drm/xe: Send wedged notification from a worker Arvind Yadav
2026-08-27 22:12 ` Andi Shyti
2026-08-28 3:39 ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 06/13] drm/xe: Reuse one dummy page per BO after wedge Arvind Yadav
2026-08-27 10:30 ` sashiko-bot
2026-08-27 10:17 ` [PATCH 07/13] drm/xe: Invalidate existing VRAM mappings on wedge Arvind Yadav
2026-08-27 10:17 ` [PATCH 08/13] drm/xe/irq: Serialize IRQ suspend and resume Arvind Yadav
2026-08-31 21:06 ` Rodrigo Vivi
2026-09-01 9:07 ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 09/13] drm/xe: Isolate a wedged device before notifying userspace Arvind Yadav
2026-08-27 10:35 ` sashiko-bot [this message]
2026-08-27 10:17 ` [PATCH 10/13] drm/xe/ttm: Reject VRAM allocations on wedged devices Arvind Yadav
2026-08-31 21:03 ` Rodrigo Vivi
2026-09-01 8:19 ` Yadav, Arvind
2026-08-27 10:17 ` [PATCH 11/13] drm/xe/guc: Skip timeout recovery on a wedged device Arvind Yadav
2026-08-31 21:01 ` Rodrigo Vivi
2026-08-27 10:18 ` [PATCH 12/13] drm/xe: Skip PM notifier preparation for wedged devices Arvind Yadav
2026-08-31 21:00 ` Rodrigo Vivi
2026-09-01 7:03 ` Yadav, Arvind
2026-09-02 19:21 ` Rodrigo Vivi
2026-08-27 10:18 ` [PATCH 13/13] drm/xe: Block BO VM access when device I/O is unavailable Arvind Yadav
2026-08-27 10:30 ` sashiko-bot
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=20260827103506.77AF91F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arvind.yadav@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox