From: sashiko-bot@kernel.org
To: "Vinay Belgaumkar" <vinay.belgaumkar@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 1/2] drm/xe: Disallow freq changes while mert cap is active
Date: Thu, 19 Nov 2026 22:57:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-224163@kernel.org> (raw)
In-Reply-To: <20261119222958.1239889-3-vinay.belgaumkar@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/xe: permanent mert cap lockout in
xe_guc_pc_restore_stashed_freq()
- [Medium] drm/xe: stale MERT cap returned by
xe_guc_pc_get_min/max_freq() when capped
--
commit 46a723833f6fec7f60471a2ef5a3e851858c10f2
Author: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
drm/xe: Disallow freq changes while mert cap is active
This commit tracks whether the Wa_22019338487 MERT frequency cap is active,
defers user min/max frequency requests until the cap is lifted, and ensures
frequencies are restored even if GSC firmware loading fails.
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index 9558d7196a51a..ea47b0ded83a4 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
[ ... ]
> @@ -638,17 +639,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;
>
> @@ -707,17 +717,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;
[Severity: Medium]
Should xe_guc_pc_get_min_freq_locked() and xe_guc_pc_get_max_freq_locked()
return the deferred or stashed frequencies when pc->mert_freq_cap_active is
true?
Right now, both getters still query GuC SLPC directly and return the
temporary MERT cap (such as 800 MHz on Lunar Lake). Aside from reading
back 800 MHz right after a sysfs write succeeds, if a userspace tool or
test reads min_freq and max_freq to save the initial limits while the cap
is active and writes those values back to restore them,
pc->user_requested_max becomes 800 MHz and
xe_guc_pc_restore_stashed_freq() will prefer it over pc->stashed_max_freq,
leaving the GT permanently capped.
[ ... ]
> @@ -1112,9 +1134,13 @@ 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->user_requested_max ?: pc->stashed_max_freq);
> + /* 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->user_requested_min ?: pc->stashed_min_freq);
> if (!ret)
> - ret = pc_set_min_freq(pc, pc->stashed_min_freq);
> + pc->mert_freq_cap_active = false;
> mutex_unlock(&pc->freq_lock);
>
> return ret;
[Severity: Medium]
Can a failure in pc_set_max_freq() or pc_set_min_freq() here leave
pc->mert_freq_cap_active stuck true forever?
All callers of xe_gt_sanitize_freq() ignore its return value without
retrying, so if either SLPC H2G request fails (for example if gsc_work()
races with a GT reset while pc->freq_ready is false), every future sysfs
write in xe_guc_pc_set_min_freq_locked() and
xe_guc_pc_set_max_freq_locked() will defer applying frequencies
indefinitely.
Also, since xe_guc_pc_restore_stashed_freq() does not check
pc->mert_freq_cap_active or pc->freq_ready before sending H2G requests,
redundant calls to xe_gt_sanitize_freq() (such as when xe_device_probe()
and gsc_work() both call it) will unconditionally re-send SLPC commands
even after the cap has already been lifted.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119222958.1239889-3-vinay.belgaumkar@intel.com?part=1
next prev parent reply other threads:[~2026-11-19 22:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 22:29 [PATCH v4 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
2026-11-19 22:30 ` [PATCH v4 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
2026-11-19 22:50 ` sashiko-bot
2026-11-19 22:57 ` sashiko-bot [this message]
2026-11-20 1:52 ` ✗ CI.checkpatch: warning for series starting with [v4,1/2] drm/xe: Disallow freq changes while mert cap is active Patchwork
2026-11-20 1:54 ` ✓ CI.KUnit: success " Patchwork
2026-11-20 2:30 ` ✗ Xe.CI.BAT: 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=sashiko-outbox-224163@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.