From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <riana.tauro@intel.com>,
<michal.wajdeczko@intel.com>, <lukasz.laguna@intel.com>,
<matthew.d.roper@intel.com>, <matthew.brost@intel.com>,
<mallesh.koujalagi@intel.com>
Subject: Re: [PATCH v6 4/7] drm/xe: Make xe_device_declare_wedged() IRQ safe
Date: Wed, 14 Oct 2026 14:07:53 -0400 [thread overview]
Message-ID: <as_E-S4FKmBTc4wZ@intel.com> (raw)
In-Reply-To: <20261014055215.330408-5-raag.jadav@intel.com>
On Wed, Oct 14, 2026 at 11:21:21AM +0530, Raag Jadav wrote:
> 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>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> v2: Split fixes into separate patches (Rodrigo, Michal)
> v5: Drop IRQ safe wedging for its flawed design
> v6: Include IRQ safe wedging with redesign
> ---
> drivers/gpu/drm/xe/xe_device.c | 33 ++++++++++++++++++++--------
> drivers/gpu/drm/xe/xe_device_types.h | 2 ++
> 2 files changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index d05d2791b9a0..b7461edad5ad 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -697,8 +697,16 @@ static int xe_device_vram_alloc(struct xe_device *xe)
> return 0;
> }
>
> +static void wedged_work(struct work_struct *work);
> static void xe_device_wedged_fini(struct drm_device *drm, void *arg);
>
> +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);
> +}
> +
> /**
> * xe_device_probe_early: Device early probe
> * @xe: xe device instance
> @@ -767,7 +775,7 @@ int xe_device_probe_early(struct xe_device *xe)
> if (err)
> return err;
>
> - err = drmm_add_action_or_reset(&xe->drm, xe_device_wedged_fini, xe);
> + err = xe_device_wedged_init(xe);
> if (err)
> return err;
>
> @@ -1380,6 +1388,14 @@ u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address)
> * firmware and restore device to normal operation.
> */
>
> +static void wedged_work(struct work_struct *work)
> +{
> + struct xe_device *xe = container_of(work, struct xe_device, wedged.work);
> +
> + /* 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"
>
> @@ -1412,29 +1428,28 @@ void xe_device_declare_wedged(struct xe_device *xe, unsigned long method)
>
> if (!atomic_xchg(&xe->wedged.flag, 1)) {
> xe->needs_flr_on_fini = true;
> - xe_pm_runtime_get_noresume(xe);
> + pm_runtime_get_noresume(xe->drm.dev);
oh! I had missed that, please let's only use xe_pm_runtime functions
>
> xe_log_err_fatal(xe, WEDGED, -EIO, "Device declared wedged!\n");
> xe_err_once(xe, "IOCTLs and executions are now blocked!\n"
> "For recovery procedure, refer to %s\n"
> "Please file a _new_ bug report at %s\n",
> WEDGED_URL, XE_BUG_URL);
> - }
>
> - for_each_initialized_gt(gt, xe, id)
> - xe_gt_declare_wedged(gt);
> + for_each_initialized_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)
> - method = DRM_WEDGE_RECOVERY_NONE;
> + xe->wedged.method = DRM_WEDGE_RECOVERY_NONE;
> + else
> + xe->wedged.method = method;
>
> - /* Notify userspace of wedged device */
> - drm_dev_wedged_event(&xe->drm, 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 4e0e1bc040c1..ec5c1f0b8f00 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -547,6 +547,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-10-14 18:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 5:51 [PATCH v6 0/7] Introduce xe_wedge Raag Jadav
2026-10-14 5:51 ` [PATCH v6 1/7] drm/xe/gt: Use GT ordered workqueue for wedging Raag Jadav
2026-10-14 6:14 ` sashiko-bot
2026-10-14 18:03 ` Rodrigo Vivi
2026-10-14 18:09 ` Rodrigo Vivi
2026-10-14 5:51 ` [PATCH v6 2/7] drm/xe: Drop xe_device_set_wedged_method() Raag Jadav
2026-10-14 5:51 ` [PATCH v6 3/7] drm/xe: Move xe_device_wedged_fini() registration to xe_device_probe_early() Raag Jadav
2026-10-14 5:51 ` [PATCH v6 4/7] drm/xe: Make xe_device_declare_wedged() IRQ safe Raag Jadav
2026-10-14 6:13 ` sashiko-bot
2026-10-14 18:07 ` Rodrigo Vivi [this message]
2026-10-14 5:51 ` [PATCH v6 5/7] drm/xe/pci_error: Flush GT wedge worker before bus reset Raag Jadav
2026-10-14 18:09 ` Rodrigo Vivi
2026-10-14 5:51 ` [PATCH v6 6/7] drm/xe: Introduce xe_wedge Raag Jadav
2026-10-14 6:05 ` sashiko-bot
2026-10-14 5:51 ` [PATCH v6 7/7] drm/xe/ras: Move xe_ras_process_errors() to xe_ras Raag Jadav
2026-10-14 6:14 ` sashiko-bot
2026-10-14 5:59 ` ✗ CI.checkpatch: warning for Introduce xe_wedge (rev5) Patchwork
2026-10-14 6:02 ` ✓ CI.KUnit: success " Patchwork
2026-10-14 11:33 ` ✓ 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=as_E-S4FKmBTc4wZ@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lukasz.laguna@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=matthew.brost@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@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