From: Raag Jadav <raag.jadav@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: riana.tauro@intel.com, michal.wajdeczko@intel.com,
lukasz.laguna@intel.com, matthew.d.roper@intel.com,
matthew.brost@intel.com, rodrigo.vivi@intel.com,
Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v2 2/5] drm/xe: Make xe_device_declare_wedged() IRQ safe
Date: Mon, 31 Aug 2026 09:55:50 +0530 [thread overview]
Message-ID: <20260831042633.1760474-3-raag.jadav@intel.com> (raw)
In-Reply-To: <20260831042633.1760474-1-raag.jadav@intel.com>
Currently, xe_device_declare_wedged() implementation wedges the GTs and
sends wedged uevent to userspace. This is problematic for usecases which
require declaring the device as wedged in IRQ context, as it allocates
memory for event buffer and acquires mutexes deep into it's call path.
Fix this by deferring wedge handling into its dedicated worker, so that
xe_device_declare_wedged() can be called in IRQ context.
First user of this requirement is introduced in commit def675cf3f10
("drm/xe/mert: Improve handling of MERT CAT errors"), which declares the
device as wedged on catastrophic errors received in form of an IRQ.
Fixes: def675cf3f10 ("drm/xe/mert: Improve handling of MERT CAT errors")
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 54 ++++++++++++++++++----------
drivers/gpu/drm/xe/xe_device_types.h | 2 ++
2 files changed, 37 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 74d566693dfd..49e3f6f66588 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -924,14 +924,25 @@ static void detect_preproduction_hw(struct xe_device *xe)
}
}
+static void wedged_work(struct work_struct *work);
+
static void xe_device_wedged_fini(struct drm_device *drm, void *arg)
{
struct xe_device *xe = arg;
+ disable_work_sync(&xe->wedged.work);
+
if (atomic_read(&xe->wedged.flag))
xe_pm_runtime_put(xe);
}
+static int xe_device_wedged_init(struct xe_device *xe)
+{
+ INIT_WORK(&xe->wedged.work, wedged_work);
+
+ return drmm_add_action_or_reset(&xe->drm, xe_device_wedged_fini, xe);
+}
+
#ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE
static int xe_debug_page_size_alloc_ctrl_init(struct xe_device *xe)
{
@@ -1148,7 +1159,7 @@ int xe_device_probe(struct xe_device *xe)
detect_preproduction_hw(xe);
- err = drmm_add_action_or_reset(&xe->drm, xe_device_wedged_fini, xe);
+ err = xe_device_wedged_init(xe);
if (err)
goto err_unregister_display;
@@ -1443,6 +1454,26 @@ void xe_device_set_wedged_method(struct xe_device *xe, unsigned long method)
xe->wedged.method = method;
}
+static void wedged_work(struct work_struct *work)
+{
+ struct xe_device *xe = container_of(work, struct xe_device, wedged.work);
+
+ /*
+ * XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET is intended for debugging
+ * hangs, so wedge the device with 'none' recovery method and have
+ * it available to the user for debugging.
+ */
+ if (xe->wedged.mode == XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET)
+ xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_NONE);
+ /* If no wedge recovery method is set, use default */
+ else if (!xe->wedged.method)
+ xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_REBIND |
+ DRM_WEDGE_RECOVERY_BUS_RESET);
+
+ /* Notify userspace of wedged device */
+ drm_dev_wedged_event(&xe->drm, xe->wedged.method, NULL);
+}
+
#define WEDGED_URL "https://docs.kernel.org/gpu/drm-uapi.html#device-wedging"
#define XE_BUG_URL "https://gitlab.freedesktop.org/drm/xe/kernel/issues/new"
@@ -1483,26 +1514,11 @@ void xe_device_declare_wedged(struct xe_device *xe)
"For recovery procedure, refer to %s\n"
"Please file a _new_ bug report at %s\n",
WEDGED_URL, XE_BUG_URL);
- }
- for_each_gt(gt, xe, id)
- xe_gt_declare_wedged(gt);
+ for_each_gt(gt, xe, id)
+ xe_gt_declare_wedged(gt);
- if (xe_device_wedged(xe)) {
- /*
- * XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET is intended for debugging
- * hangs, so wedge the device with 'none' recovery method and have
- * it available to the user for debugging.
- */
- if (xe->wedged.mode == XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET)
- xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_NONE);
- /* If no wedge recovery method is set, use default */
- else if (!xe->wedged.method)
- xe_device_set_wedged_method(xe, DRM_WEDGE_RECOVERY_REBIND |
- DRM_WEDGE_RECOVERY_BUS_RESET);
-
- /* Notify userspace of wedged device */
- drm_dev_wedged_event(&xe->drm, xe->wedged.method, NULL);
+ schedule_work(&xe->wedged.work);
}
}
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 180d450a6deb..7d83f79f27f4 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -534,6 +534,8 @@ struct xe_device {
unsigned long method;
/** @wedged.inconsistent_reset: Inconsistent reset policy state between GTs */
bool inconsistent_reset;
+ /** @wedged.work: Worker for wedge handling */
+ struct work_struct work;
} wedged;
/** @devres_group: devres group */
--
2.43.0
next prev parent reply other threads:[~2026-08-31 4:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 4:25 [PATCH v2 0/5] Introduce xe_wedge Raag Jadav
2026-08-31 4:25 ` [PATCH v2 1/5] drm/xe/gt: Use GT ordered workqueue for wedging Raag Jadav
2026-08-31 4:25 ` Raag Jadav [this message]
2026-08-31 4:40 ` [PATCH v2 2/5] drm/xe: Make xe_device_declare_wedged() IRQ safe sashiko-bot
2026-08-31 4:25 ` [PATCH v2 3/5] drm/xe: Introduce xe_wedge Raag Jadav
2026-09-02 17:56 ` Rodrigo Vivi
2026-08-31 4:25 ` [PATCH v2 4/5] drm/xe/debugfs: Consolidate wedged_mode debt into xe_wedge Raag Jadav
2026-08-31 4:25 ` [PATCH v2 5/5] drm/xe/wedge: Update naming to match with xe_wedge Raag Jadav
2026-08-31 4:35 ` sashiko-bot
2026-08-31 4:33 ` ✗ CI.checkpatch: warning for Introduce xe_wedge Patchwork
2026-08-31 4:34 ` ✗ CI.KUnit: failure " 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=20260831042633.1760474-3-raag.jadav@intel.com \
--to=raag.jadav@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lukasz.laguna@intel.com \
--cc=matthew.brost@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@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