From: Arvind Yadav <arvind.yadav@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com,
thomas.hellstrom@linux.intel.com, rodrigo.vivi@intel.com
Subject: [PATCH 09/13] drm/xe: Isolate a wedged device before notifying userspace
Date: Thu, 27 Aug 2026 15:47:57 +0530 [thread overview]
Message-ID: <20260827101801.1247654-10-arvind.yadav@intel.com> (raw)
In-Reply-To: <20260827101801.1247654-1-arvind.yadav@intel.com>
A permanently wedged device must stop interrupt and DMA activity before
userspace is notified that recovery is required.
Run the sleepable isolation steps from the wedge worker. Shut down and
unregister the display, invalidate VRAM mappings, suspend interrupts and
clear PCI bus mastering before sending the event. GTs are declared
wedged before the work is queued, so pending fences are signalled before
the worker waits for fault-side SRCU readers.
Track display and isolation state so later teardown does not repeat these
steps. Display shutdown already disables display power, so skip the
runtime PM disable when unregister follows shutdown.
System suspend may see the wedge flag before the worker is queued. Use a
completion to close this window and flush the worker before skipping
normal device suspend. The IRQ serialization keeps a racing resume from
enabling interrupts after isolation.
For a wedged device, resume restores PCI configuration and clears bus
mastering. Do not call pci_enable_device() because suspend did not take
the matching disable reference.
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
---
drivers/gpu/drm/xe/display/xe_display.c | 18 +++++++++---
drivers/gpu/drm/xe/xe_device.c | 38 +++++++++++++++++++++++--
drivers/gpu/drm/xe/xe_device_types.h | 9 ++++++
drivers/gpu/drm/xe/xe_pci.c | 23 ++++++++++++++-
4 files changed, 81 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
index 7b25c0814674..ce9ebc6701ff 100644
--- a/drivers/gpu/drm/xe/display/xe_display.c
+++ b/drivers/gpu/drm/xe/display/xe_display.c
@@ -150,21 +150,28 @@ void xe_display_register(struct xe_device *xe)
{
struct intel_display *display = xe->display;
- if (!xe->info.probe_display)
+ if (!xe->info.probe_display || xe->display_registered)
return;
intel_display_driver_register(display);
intel_display_driver_runtime_pm_enable(display);
+
+ xe->display_registered = true;
}
void xe_display_unregister(struct xe_device *xe)
{
struct intel_display *display = xe->display;
- if (!xe->info.probe_display)
+ if (!xe->info.probe_display || !xe->display_registered)
return;
- intel_display_driver_runtime_pm_disable(display);
+ /* Make display unregister idempotent. */
+ xe->display_registered = false;
+
+ if (!xe->display_shutdown)
+ intel_display_driver_runtime_pm_disable(display);
+
intel_display_driver_unregister(display);
}
@@ -172,7 +179,8 @@ void xe_display_shutdown(struct xe_device *xe)
{
struct intel_display *display = xe->display;
- if (!xe->info.probe_display)
+ if (!xe->info.probe_display || !xe->display_registered ||
+ xe->display_shutdown)
return;
intel_display_driver_shutdown(display);
@@ -180,6 +188,8 @@ void xe_display_shutdown(struct xe_device *xe)
intel_opregion_suspend(display, PCI_D3cold);
intel_dmc_suspend(display);
+
+ xe->display_shutdown = true;
}
void xe_display_shutdown_late(struct xe_device *xe)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 98ef5123c841..101cfa8e2102 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -538,6 +538,7 @@ int xe_device_init_early(struct xe_device *xe)
int err;
INIT_WORK(&xe->wedged.work, xe_device_wedged_work);
+ init_completion(&xe->wedged.prepared);
xe->wedged.reported_method = ~0UL;
err = ttm_device_init(&xe->ttm, &xe_ttm_funcs, xe->drm.dev,
@@ -958,14 +959,44 @@ static int xe_debug_page_size_alloc_ctrl_init(struct xe_device *xe)
}
#endif
+/*
+ * Isolate a permanently wedged device.
+ *
+ * May sleep and must be called from process context.
+ */
+static void xe_device_wedged_isolate(struct xe_device *xe)
+{
+ /*
+ * Wait until xe_device_declare_wedged() has finished scanning GT
+ * submission state before isolating the device.
+ */
+ wait_for_completion(&xe->wedged.prepared);
+
+ if (!xe->wedged.isolated) {
+ xe_display_shutdown(xe);
+ xe_display_unregister(xe);
+
+ /*
+ * Drain faults and unmap VRAM before disabling IRQs and
+ * DMA.
+ */
+ xe_bo_wedged_invalidate_mmaps(xe);
+
+ /* Drain handlers before preventing any further device DMA. */
+ xe_irq_suspend(xe);
+ pci_clear_master(to_pci_dev(xe->drm.dev));
+
+ xe->wedged.isolated = true;
+ }
+}
+
static void xe_device_wedged_work(struct work_struct *work)
{
struct xe_device *xe =
container_of(work, struct xe_device, wedged.work);
unsigned long method;
- /* Drain faults and invalidate existing VRAM mappings. */
- xe_bo_wedged_invalidate_mmaps(xe);
+ xe_device_wedged_isolate(xe);
/* Report at most one recovery method per worker invocation. */
method = READ_ONCE(xe->wedged.method);
@@ -1556,6 +1587,9 @@ void xe_device_declare_wedged(struct xe_device *xe)
READ_ONCE(xe->wedged.method) !=
READ_ONCE(xe->wedged.reported_method))
queue_work(xe->unordered_wq, &xe->wedged.work);
+
+ if (first)
+ complete_all(&xe->wedged.prepared);
}
/**
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index dda4d9919ca6..508ba3872e72 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -6,6 +6,7 @@
#ifndef _XE_DEVICE_TYPES_H_
#define _XE_DEVICE_TYPES_H_
+#include <linux/completion.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/srcu.h>
@@ -113,6 +114,10 @@ struct xe_device {
#if IS_ENABLED(CONFIG_DRM_XE_DISPLAY)
/** @display: display device data, must be placed after drm device member */
struct intel_display *display;
+ /** @display_registered: Display userspace interfaces are registered */
+ bool display_registered;
+ /** @display_shutdown: Display hardware shutdown has completed */
+ bool display_shutdown;
#endif
/** @devcoredump: device coredump */
@@ -547,8 +552,12 @@ struct xe_device {
bool inconsistent_reset;
/** @wedged.work: Runs sleepable wedge handling */
struct work_struct work;
+ /** @wedged.prepared: First wedge declaration finished and work was queued */
+ struct completion prepared;
/** @wedged.reported_method: Last recovery method reported to userspace */
unsigned long reported_method;
+ /** @wedged.isolated: Terminal device isolation has completed */
+ bool isolated;
} wedged;
/** @devres_group: devres group */
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index ab4da1d9a9f1..aaeb7d068175 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -1332,6 +1332,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;
+ }
+
err = xe_pm_suspend(xe);
if (err)
return err;
@@ -1353,6 +1363,7 @@ static int xe_pci_suspend(struct device *dev)
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*/
@@ -1364,13 +1375,23 @@ static int xe_pci_resume(struct device *dev)
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;
+ }
+
err = pci_enable_device(pdev);
if (err)
return err;
pci_set_master(pdev);
- err = xe_pm_resume(pdev_to_xe_device(pdev));
+ err = xe_pm_resume(xe);
if (err)
return err;
--
2.43.0
next prev parent reply other threads:[~2026-08-27 10:18 UTC|newest]
Thread overview: 28+ 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-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-27 10:17 ` [PATCH 04/13] drm/xe: Stop VM work " Arvind Yadav
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-27 10:17 ` Arvind Yadav [this message]
2026-08-27 10:35 ` [PATCH 09/13] drm/xe: Isolate a wedged device before notifying userspace sashiko-bot
2026-08-27 10:17 ` [PATCH 10/13] drm/xe/ttm: Reject VRAM allocations on wedged devices Arvind Yadav
2026-08-27 10:17 ` [PATCH 11/13] drm/xe/guc: Skip timeout recovery on a wedged device Arvind Yadav
2026-08-27 10:18 ` [PATCH 12/13] drm/xe: Skip PM notifier preparation for wedged devices Arvind Yadav
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
2026-08-27 10:24 ` ✗ CI.checkpatch: warning for drm/xe: Isolate wedged devices from hardware access Patchwork
2026-08-27 10:26 ` ✓ CI.KUnit: success " Patchwork
2026-08-27 11:03 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-27 12:16 ` ✓ Xe.CI.FULL: " 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=20260827101801.1247654-10-arvind.yadav@intel.com \
--to=arvind.yadav@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/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