From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v7 1/2] drm/xe: Disallow freq changes while mert cap is active
Date: Wed, 2 Dec 2026 21:54:47 -0500 [thread overview]
Message-ID: <axDZ95k5VFI_Do0B@intel.com> (raw)
In-Reply-To: <20261202180655.2231347-3-vinay.belgaumkar@intel.com>
On Wed, Dec 02, 2026 at 10:06:56AM -0800, Vinay Belgaumkar wrote:
> When Wa_22019338487 is applied, GT freq is capped until GSC load is done.
> During this time, it is possible that users can access sysfs to set min/max
> GT frequencies. Modifying the frequencies between save/restore could cause
> inconsistency. Prevent this by introducing a flag which tracks if the cap
> is active and defer user min/max requests until the cap is lifted.
>
> While we are here, fix the minor issue where mert cap is removed only on a
> successful GSC load. Also, don't restore mert cap if GT is already in a
> reset.
>
> v2: Restore mert cap even after GSC load fails (Sashiko)
> v5: Return stashed value for min/max during cap (Sashiko)
> v6: Fix bug and set mert cap to false in xe_guc_pc_stop() (Sashiko)
> v7: Don't restore mert cap if freq_ready is false (Sashiko) and other
> comments (Anirban)
>
> Fixes: 3b1592fb7835 ("drm/xe/lnl: Apply Wa_22019338487")
> Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gsc.c | 6 +-
> drivers/gpu/drm/xe/xe_guc_pc.c | 89 +++++++++++++++++++++-------
> drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 +
> 3 files changed, 73 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
> index 8edb8cee3cbd..c818a4e7863e 100644
> --- a/drivers/gpu/drm/xe/xe_gsc.c
> +++ b/drivers/gpu/drm/xe/xe_gsc.c
> @@ -290,9 +290,6 @@ static int gsc_upload_and_init(struct xe_gsc *gsc)
>
> xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_TRANSFERRED);
>
> - /* GSC load is done, restore expected GT frequencies */
> - xe_gt_sanitize_freq(gt);
> -
> xe_gt_dbg(gt, "GSC FW async load completed\n");
>
> /* HuC auth failure is not fatal */
> @@ -376,6 +373,9 @@ static void gsc_work(struct work_struct *work)
> xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_LOAD_FAIL);
> else
> xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_RUNNING);
> +
> + /* Undo the mert cap now that GSC load was attempted */
> + xe_gt_sanitize_freq(gt);
> }
>
> if (actions & GSC_ACTION_SW_PROXY)
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index 9558d7196a51..cc1869e6bcbe 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
> @@ -344,13 +344,18 @@ static void pc_set_cur_freq(struct xe_guc_pc *pc, u32 freq)
> pc_set_manual_rp_ctrl(pc, false);
> }
>
> -static int pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
> +static bool pc_freq_in_range(struct xe_guc_pc *pc, u32 freq)
> {
> /*
> * Let's only check for the rpn-rp0 range. If max < min,
> * min becomes a fixed request.
> */
> - if (freq < pc->rpn_freq || freq > pc->rp0_freq)
> + return freq >= pc->rpn_freq && freq <= pc->rp0_freq;
> +}
> +
> +static int pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
> +{
> + if (!pc_freq_in_range(pc, freq))
> return -EINVAL;
>
> /*
> @@ -377,12 +382,8 @@ static int pc_get_max_freq(struct xe_guc_pc *pc)
>
> static int pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
> {
> - /*
> - * Let's only check for the rpn-rp0 range. If max < min,
> - * min becomes a fixed request.
> - * Also, overclocking is not supported.
> - */
> - if (freq < pc->rpn_freq || freq > pc->rp0_freq)
> + /* Overclocking is not supported. */
> + if (!pc_freq_in_range(pc, freq))
> return -EINVAL;
>
> return pc_action_set_param(pc,
> @@ -612,6 +613,12 @@ static int xe_guc_pc_get_min_freq_locked(struct xe_guc_pc *pc, u32 *freq)
> if (!pc->freq_ready)
> return -EAGAIN;
>
> + /* In the middle of a temporary freq cap, return stashed or min freq */
> + if (pc->mert_freq_cap_active) {
> + *freq = pc->user_requested_min ?: pc->stashed_min_freq;
> + return 0;
> + }
> +
> ret = pc_action_query_task_state(pc);
> if (ret)
> return ret;
> @@ -638,17 +645,26 @@ int xe_guc_pc_get_min_freq(struct xe_guc_pc *pc, u32 *freq)
>
> static int xe_guc_pc_set_min_freq_locked(struct xe_guc_pc *pc, u32 freq)
> {
> - int ret;
> -
> lockdep_assert_held(&pc->freq_lock);
>
> /* Might be in the middle of a gt reset */
> if (!pc->freq_ready)
> return -EAGAIN;
>
> - ret = pc_set_min_freq(pc, freq);
> - if (ret)
> - return ret;
> + /*
> + * While the Wa_22019338487 cap is active, defer applying the new min
> + * to GuC; xe_guc_pc_restore_stashed_freq() will apply it once the
> + * cap is removed.
> + */
> + if (pc->mert_freq_cap_active) {
> + if (!pc_freq_in_range(pc, freq))
> + return -EINVAL;
> + } else {
> + int ret = pc_set_min_freq(pc, freq);
> +
> + if (ret)
> + return ret;
> + }
>
> pc->user_requested_min = freq;
>
> @@ -681,6 +697,12 @@ static int xe_guc_pc_get_max_freq_locked(struct xe_guc_pc *pc, u32 *freq)
> if (!pc->freq_ready)
> return -EAGAIN;
>
> + /* In the middle of a temporary freq cap, return stashed value */
> + if (pc->mert_freq_cap_active) {
> + *freq = pc->user_requested_max ?: pc->stashed_max_freq;
> + return 0;
> + }
> +
> ret = pc_action_query_task_state(pc);
> if (ret)
> return ret;
> @@ -707,17 +729,26 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq)
>
> static int xe_guc_pc_set_max_freq_locked(struct xe_guc_pc *pc, u32 freq)
> {
> - int ret;
> -
> lockdep_assert_held(&pc->freq_lock);
>
> /* Might be in the middle of a gt reset */
> if (!pc->freq_ready)
> return -EAGAIN;
>
> - ret = pc_set_max_freq(pc, freq);
> - if (ret)
> - return ret;
> + /*
> + * While the Wa_22019338487 cap is active, defer applying the new max
> + * to GuC; xe_guc_pc_restore_stashed_freq() will apply it once the
> + * cap is lifted.
> + */
> + if (pc->mert_freq_cap_active) {
> + if (!pc_freq_in_range(pc, freq))
> + return -EINVAL;
> + } else {
> + int ret = pc_set_max_freq(pc, freq);
> +
> + if (ret)
> + return ret;
> + }
>
> pc->user_requested_max = freq;
>
> @@ -1094,11 +1125,14 @@ static int pc_set_mert_freq_cap(struct xe_guc_pc *pc)
> if (!ret)
> ret = pc_set_max_freq(pc, min(pc->rp0_freq, pc_max_freq_cap(pc)));
>
> + if (!ret)
> + pc->mert_freq_cap_active = true;
> +
> return ret;
> }
>
> /**
> - * xe_guc_pc_restore_stashed_freq - Set min/max back to stashed values
> + * xe_guc_pc_restore_stashed_freq - Set min/max back to stashed/user requested values
> * @pc: The GuC PC
> *
> * Returns: 0 on success,
> @@ -1112,9 +1146,20 @@ int xe_guc_pc_restore_stashed_freq(struct xe_guc_pc *pc)
> return 0;
>
> mutex_lock(&pc->freq_lock);
> - ret = pc_set_max_freq(pc, pc->stashed_max_freq);
> +
> + /* Restore not needed any more */
> + if (!pc->freq_ready || !pc->mert_freq_cap_active)
> + goto done;
> +
> + /* Apply any user min/max request made while the cap was active, else the stash. */
> + ret = pc_set_max_freq(pc, pc->user_requested_max ?: pc->stashed_max_freq);
> +
> if (!ret)
> - ret = pc_set_min_freq(pc, pc->stashed_min_freq);
> + ret = pc_set_min_freq(pc, pc->user_requested_min ?: pc->stashed_min_freq);
> + if (!ret)
> + pc->mert_freq_cap_active = false;
> +
> +done:
> mutex_unlock(&pc->freq_lock);
>
> return ret;
> @@ -1345,6 +1390,8 @@ void xe_guc_pc_stop(struct xe_guc_pc *pc)
> return;
>
> mutex_lock(&pc->freq_lock);
> + /* GT reset could occur while mert cap is active */
> + pc->mert_freq_cap_active = false;
> pc->freq_ready = false;
> mutex_unlock(&pc->freq_lock);
> }
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h b/drivers/gpu/drm/xe/xe_guc_pc_types.h
> index 711bbcdcb0d3..9a6ea2904e33 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
> +++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
> @@ -35,6 +35,8 @@ struct xe_guc_pc {
> bool freq_ready;
> /** @power_profile: Base or power_saving profile */
> u32 power_profile;
> + /** @mert_freq_cap_active: Wa_22019338487 min/max cap is currently in force */
> + bool mert_freq_cap_active;
> };
>
> #endif /* _XE_GUC_PC_TYPES_H_ */
> --
> 2.53.0
>
prev parent reply other threads:[~2026-12-03 2:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 18:06 [PATCH v7 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
2026-12-02 18:06 ` [PATCH v7 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
2026-12-02 18:37 ` ✓ CI.KUnit: success for series starting with [v7,1/2] drm/xe: Disallow freq changes while mert cap is active Patchwork
2026-12-02 19:08 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-12-03 3:00 ` Rodrigo Vivi
2026-12-03 2:54 ` Rodrigo Vivi [this message]
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=axDZ95k5VFI_Do0B@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=vinay.belgaumkar@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