From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <michal.wajdeczko@intel.com>
Subject: Re: [PATCH v12 2/4] drm/xe: Update wedged.mode only after successful reset policy change
Date: Thu, 8 Jan 2026 16:06:43 -0500 [thread overview]
Message-ID: <aWAcYyjjgE5kAIGd@intel.com> (raw)
In-Reply-To: <20260107174741.29163-3-lukasz.laguna@intel.com>
On Wed, Jan 07, 2026 at 06:47:39PM +0100, Lukasz Laguna wrote:
> Previously, the driver's internal wedged.mode state was updated without
> verifying whether the corresponding engine reset policy update in GuC
> succeeded. This could leave the driver reporting a wedged.mode state
> that doesn't match the actual reset behavior programmed in GuC.
>
> With this change, the reset policy is updated first, and the driver's
> wedged.mode state is modified only if the policy update succeeds on all
> available GTs.
>
> This patch also introduces two functional improvements:
>
> - The policy is sent to GuC only when a change is required. An update
> is needed only when entering or leaving XE_WEDGED_MODE_UPON_ANY_HANG,
> because only in that case the reset policy changes. For example,
> switching between XE_WEDGED_MODE_UPON_CRITICAL_ERROR and
> XE_WEDGED_MODE_NEVER doesn't affect the reset policy, so there is no
> need to send the same value to GuC.
>
> - An inconsistent_reset flag is added to track cases where reset policy
> update succeeds only on a subset of GTs. If such inconsistency is
> detected, future wedged mode configuration will force a retry of the
> reset policy update to restore a consistent state across all GTs.
>
> Fixes: 6b8ef44cc0a9 ("drm/xe: Introduce the wedged_mode debugfs")
> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> v12:
> - rename helpers to make wedged mode context explicit (Rodrigo).
> ---
> drivers/gpu/drm/xe/xe_debugfs.c | 70 ++++++++++++++++++++++------
> drivers/gpu/drm/xe/xe_device_types.h | 2 +
> drivers/gpu/drm/xe/xe_guc_ads.c | 14 +++---
> drivers/gpu/drm/xe/xe_guc_ads.h | 5 +-
> 4 files changed, 71 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index db2afd60d8bc..844cfafe1ec7 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> @@ -254,14 +254,64 @@ static ssize_t wedged_mode_show(struct file *f, char __user *ubuf,
> return simple_read_from_buffer(ubuf, size, pos, buf, len);
> }
>
> +static int __wedged_mode_set_reset_policy(struct xe_gt *gt, enum xe_wedged_mode mode)
> +{
> + bool enable_engine_reset;
> + int ret;
> +
> + enable_engine_reset = (mode != XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET);
> + ret = xe_guc_ads_scheduler_policy_toggle_reset(>->uc.guc.ads,
> + enable_engine_reset);
> + if (ret)
> + xe_gt_err(gt, "Failed to update GuC ADS scheduler policy (%pe)\n", ERR_PTR(ret));
> +
> + return ret;
> +}
> +
> +static int wedged_mode_set_reset_policy(struct xe_device *xe, enum xe_wedged_mode mode)
> +{
> + struct xe_gt *gt;
> + int ret;
> + u8 id;
> +
> + guard(xe_pm_runtime)(xe);
> + for_each_gt(gt, xe, id) {
> + ret = __wedged_mode_set_reset_policy(gt, mode);
> + if (ret) {
> + if (id > 0) {
> + xe->wedged.inconsistent_reset = true;
> + drm_err(&xe->drm, "Inconsistent reset policy state between GTs\n");
> + }
> + return ret;
> + }
> + }
> +
> + xe->wedged.inconsistent_reset = false;
> +
> + return 0;
> +}
> +
> +static bool wedged_mode_needs_policy_update(struct xe_device *xe, enum xe_wedged_mode mode)
> +{
> + if (xe->wedged.inconsistent_reset)
> + return true;
> +
> + if (xe->wedged.mode == mode)
> + return false;
> +
> + if (xe->wedged.mode == XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET ||
> + mode == XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET)
> + return true;
> +
> + return false;
> +}
> +
> static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf,
> size_t size, loff_t *pos)
> {
> struct xe_device *xe = file_inode(f)->i_private;
> - struct xe_gt *gt;
> u32 wedged_mode;
> ssize_t ret;
> - u8 id;
>
> ret = kstrtouint_from_user(ubuf, size, 0, &wedged_mode);
> if (ret)
> @@ -271,20 +321,14 @@ static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf,
> if (ret)
> return ret;
>
> - if (xe->wedged.mode == wedged_mode)
> - return size;
> + if (wedged_mode_needs_policy_update(xe, wedged_mode)) {
> + ret = wedged_mode_set_reset_policy(xe, wedged_mode);
> + if (ret)
> + return ret;
> + }
>
> xe->wedged.mode = wedged_mode;
>
> - guard(xe_pm_runtime)(xe);
> - for_each_gt(gt, xe, id) {
> - ret = xe_guc_ads_scheduler_policy_toggle_reset(>->uc.guc.ads);
> - if (ret) {
> - xe_gt_err(gt, "Failed to update GuC ADS scheduler policy. GuC may still cause engine reset even with wedged_mode=2\n");
> - return -EIO;
> - }
> - }
> -
> return size;
> }
>
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index d790129a06db..4dab3057f58d 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -648,6 +648,8 @@ struct xe_device {
> enum xe_wedged_mode mode;
> /** @wedged.method: Recovery method to be sent in the drm device wedged uevent */
> unsigned long method;
> + /** @wedged.inconsistent_reset: Inconsistent reset policy state between GTs */
> + bool inconsistent_reset;
> } wedged;
>
> /** @bo_device: Struct to control async free of BOs */
> diff --git a/drivers/gpu/drm/xe/xe_guc_ads.c b/drivers/gpu/drm/xe/xe_guc_ads.c
> index 2b47e897d2ea..7e1cb6093de7 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ads.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ads.c
> @@ -983,16 +983,17 @@ static int guc_ads_action_update_policies(struct xe_guc_ads *ads, u32 policy_off
> /**
> * xe_guc_ads_scheduler_policy_toggle_reset - Toggle reset policy
> * @ads: Additional data structures object
> + * @enable_engine_reset: true to enable engine resets, false otherwise
> *
> - * This function update the GuC's engine reset policy based on wedged.mode.
> + * This function update the GuC's engine reset policy.
> *
> * Return: 0 on success, and negative error code otherwise.
> */
> -int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads)
> +int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads,
> + bool enable_engine_reset)
> {
> struct guc_policies *policies;
> struct xe_guc *guc = ads_to_guc(ads);
> - struct xe_device *xe = ads_to_xe(ads);
> CLASS(xe_guc_buf, buf)(&guc->buf, sizeof(*policies));
>
> if (!xe_guc_buf_is_valid(buf))
> @@ -1004,10 +1005,11 @@ int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads)
> policies->dpc_promote_time = ads_blob_read(ads, policies.dpc_promote_time);
> policies->max_num_work_items = ads_blob_read(ads, policies.max_num_work_items);
> policies->is_valid = 1;
> - if (xe->wedged.mode == XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET)
> - policies->global_flags |= GLOBAL_POLICY_DISABLE_ENGINE_RESET;
> - else
> +
> + if (enable_engine_reset)
> policies->global_flags &= ~GLOBAL_POLICY_DISABLE_ENGINE_RESET;
> + else
> + policies->global_flags |= GLOBAL_POLICY_DISABLE_ENGINE_RESET;
>
> return guc_ads_action_update_policies(ads, xe_guc_buf_flush(buf));
> }
> diff --git a/drivers/gpu/drm/xe/xe_guc_ads.h b/drivers/gpu/drm/xe/xe_guc_ads.h
> index 2e6674c760ff..7a39f361cb17 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ads.h
> +++ b/drivers/gpu/drm/xe/xe_guc_ads.h
> @@ -6,6 +6,8 @@
> #ifndef _XE_GUC_ADS_H_
> #define _XE_GUC_ADS_H_
>
> +#include <linux/types.h>
> +
> struct xe_guc_ads;
>
> int xe_guc_ads_init(struct xe_guc_ads *ads);
> @@ -13,6 +15,7 @@ int xe_guc_ads_init_post_hwconfig(struct xe_guc_ads *ads);
> void xe_guc_ads_populate(struct xe_guc_ads *ads);
> void xe_guc_ads_populate_minimal(struct xe_guc_ads *ads);
> void xe_guc_ads_populate_post_load(struct xe_guc_ads *ads);
> -int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads);
> +int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads,
> + bool enable_engine_reset);
>
> #endif
> --
> 2.40.0
>
next prev parent reply other threads:[~2026-01-08 21:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 17:47 [PATCH v12 0/4] drm/xe: Improve wedged mode handling Lukasz Laguna
2026-01-07 17:47 ` [PATCH v12 1/4] drm/xe: Validate wedged_mode parameter and define enum for modes Lukasz Laguna
2026-01-07 17:47 ` [PATCH v12 2/4] drm/xe: Update wedged.mode only after successful reset policy change Lukasz Laguna
2026-01-08 21:06 ` Rodrigo Vivi [this message]
2026-01-18 14:39 ` Thomas Hellström
2026-01-20 8:27 ` Laguna, Lukasz
2026-01-07 17:47 ` [PATCH v12 3/4] drm/xe/vf: Disallow setting wedged mode to upon-any-hang Lukasz Laguna
2026-01-07 17:47 ` [PATCH v12 4/4] drm/xe/pf: Allow upon-any-hang wedged mode only in debug config Lukasz Laguna
2026-01-07 17:55 ` ✓ CI.KUnit: success for drm/xe: Improve wedged mode handling (rev12) Patchwork
2026-01-07 18:33 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-07 19:54 ` ✗ Xe.CI.Full: 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=aWAcYyjjgE5kAIGd@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lukasz.laguna@intel.com \
--cc=michal.wajdeczko@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