From: "Belgaumkar, Vinay" <vinay.belgaumkar@intel.com>
To: "Anirban, Sk" <sk.anirban@intel.com>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v3 2/2] drm/xe: Add sysfs to disable RPe
Date: Thu, 19 Nov 2026 10:35:12 -0800 [thread overview]
Message-ID: <8b40e8a8-4e46-499d-9b3e-70aff38fb4ef@intel.com> (raw)
In-Reply-To: <35f34587-ba42-4adf-9d1b-ac6ecb7e06e0@intel.com>
On 11/19/2026 7:56 AM, Anirban, Sk wrote:
> Hi Vinay,
>
>
> On 18-11-2026 06:54, Vinay Belgaumkar wrote:
>> When SLPC is initialized, GuC sets the GT min freq to RPe(efficient) by
>> default. This frequency is desgined for optimal perf/power ratio.
>> However,
>> certain use cases may want to run at lower frequencies. This sysfs
>> allows
>> user to disable use of default RPe behavior.
>>
>> Efficient frequency will now be controlled by this interface alone.
>> Setting
>> min_freq < efficient will not disable RPe. When RPe is enabled, GuC
>> raises
>> min to RPe and lowers it back when disabled.
>>
>> Update pc_set_mert_freq_cap() to now disable RPe before stashing min
>> freq.
>> This ensures we are saving the real min freq instead of the elevated
>> one.
>>
>> $ cat /sys/class/drm/card0/device/tile0/gt1/freq0/use_rpe
>> 1
>>
>> v2: Address Sashiko comments.
>> v3: Disable RPe before stashing freq before mert cap (Sashiko)
>>
>> Cc: Sk Anirban <sk.anirban@intel.com>
>> Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_gt_freq.c | 35 +++++++++++++
>> drivers/gpu/drm/xe/xe_guc_pc.c | 76 ++++++++++++++++++++++++----
>> drivers/gpu/drm/xe/xe_guc_pc.h | 1 +
>> drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 +
>> 4 files changed, 105 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c
>> b/drivers/gpu/drm/xe/xe_gt_freq.c
>> index a40dd074106f..38c4f17ba99c 100644
>> --- a/drivers/gpu/drm/xe/xe_gt_freq.c
>> +++ b/drivers/gpu/drm/xe/xe_gt_freq.c
>> @@ -242,6 +242,40 @@ static ssize_t power_profile_store(struct
>> kobject *kobj,
>> }
>> static struct kobj_attribute attr_power_profile =
>> __ATTR_RW(power_profile);
>> +static ssize_t use_rpe_show(struct kobject *kobj,
>> + struct kobj_attribute *attr,
>> + char *buff)
>> +{
>> + struct device *dev = kobj_to_dev(kobj);
>> + struct xe_guc_pc *pc = dev_to_pc(dev);
>> +
>> + return sysfs_emit(buff, "%u\n", pc->use_rpe);
>> +}
>> +
>> +static ssize_t use_rpe_store(struct kobject *kobj,
>> + struct kobj_attribute *attr,
>> + const char *buff, size_t count)
>> +{
>> + struct device *dev = kobj_to_dev(kobj);
>> + struct xe_guc_pc *pc = dev_to_pc(dev);
>> + int err;
>> + u32 val;
>> +
>> + err = kstrtou32(buff, 0, &val);
>> + if (err)
>> + return err;
>> +
>> + if (val > 1)
>> + return -EINVAL;
>> +
>> + guard(xe_pm_runtime)(dev_to_xe(dev));
>> + err = xe_guc_pc_set_use_rpe(pc, val);
>> +
>> + return err ?: count;
>> +}
>> +
>> +static struct kobj_attribute attr_use_rpe = __ATTR_RW(use_rpe);
>> +
>> static const struct attribute *freq_attrs[] = {
>> &attr_act_freq.attr,
>> &attr_cur_freq.attr,
>> @@ -252,6 +286,7 @@ static const struct attribute *freq_attrs[] = {
>> &attr_min_freq.attr,
>> &attr_max_freq.attr,
>> &attr_power_profile.attr,
>> + &attr_use_rpe.attr,
>> NULL
>> };
>> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c
>> b/drivers/gpu/drm/xe/xe_guc_pc.c
>> index ea47b0ded83a..5ff3df99464b 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
>> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
>> @@ -344,6 +344,21 @@ static void pc_set_cur_freq(struct xe_guc_pc
>> *pc, u32 freq)
>> pc_set_manual_rp_ctrl(pc, false);
>> }
>> +static int pc_set_ignore_eff_freq(struct xe_guc_pc *pc, u32 val)
>> +{
>> + struct xe_gt *gt = pc_to_gt(pc);
>> + int ret;
>> +
>> + xe_device_assert_mem_access(pc_to_xe(pc));
>> +
>> + ret = pc_action_set_param(pc,
>> SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY, val);
>> + if (ret)
>> + xe_gt_err_once(gt, "Failed to set ignore_eff_freq to %u,
>> %pe\n",
>> + val, ERR_PTR(ret));
>> +
>> + return ret;
>> +}
>> +
>> static bool pc_freq_in_range(struct xe_guc_pc *pc, u32 freq)
>> {
>> /*
>> @@ -358,13 +373,6 @@ static int pc_set_min_freq(struct xe_guc_pc *pc,
>> u32 freq)
>> if (!pc_freq_in_range(pc, freq))
>> return -EINVAL;
>> - /*
>> - * GuC policy is to elevate minimum frequency to the efficient
>> levels
>> - * Our goal is to have the admin choices respected.
>> - */
>> - pc_action_set_param(pc, SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY,
>> - freq < xe_guc_pc_get_rpe_freq(pc));
>> -
>> return pc_action_set_param(pc,
>> SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ,
>> freq);
>> @@ -1091,12 +1099,23 @@ void xe_guc_pc_remove_flush_freq_limit(struct
>> xe_guc_pc *pc)
>> static int pc_set_mert_freq_cap(struct xe_guc_pc *pc)
>> {
>> int ret;
>> + u32 mert_freq_cap;
>> if (!XE_GT_WA(pc_to_gt(pc), 22019338487))
>> return 0;
>> guard(mutex)(&pc->freq_lock);
>> + /*
>> + * Disable the RPe floor so the min queried below reflects the real
>> + * underlying minimum (RPn or user_requested_min) instead of a
>> value
>> + * GuC may have elevated to RPe. This stays disabled until
>> + * xe_guc_pc_restore_stashed_freq() reinstates it.
>> + */
>> + ret = pc_set_ignore_eff_freq(pc, 1);
>> + if (ret)
>> + return ret;
>> +
>> /*
>> * Get updated min/max and stash them.
>> */
>> @@ -1109,7 +1128,9 @@ static int pc_set_mert_freq_cap(struct
>> xe_guc_pc *pc)
>> /*
>> * Ensure min and max are bound by MERT_FREQ_CAP until driver
>> loads.
>> */
>> - ret = pc_set_min_freq(pc, min(xe_guc_pc_get_rpe_freq(pc),
>> pc_max_freq_cap(pc)));
>> + mert_freq_cap = min(xe_guc_pc_get_rpe_freq(pc),
>> pc_max_freq_cap(pc));
>> +
>> + ret = pc_set_min_freq(pc, mert_freq_cap);
>> if (!ret)
>> ret = pc_set_max_freq(pc, min(pc->rp0_freq,
>> pc_max_freq_cap(pc)));
>> @@ -1136,9 +1157,11 @@ int xe_guc_pc_restore_stashed_freq(struct
>> xe_guc_pc *pc)
>> mutex_lock(&pc->freq_lock);
>> /* 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);
>> + /* Restore ignore_eff_freq override from pc_set_mert_freq_cap(). */
>> + if (!ret)
>> + ret = pc_set_ignore_eff_freq(pc, !pc->use_rpe);
>> if (!ret)
>> pc->mert_freq_cap_active = false;
>> mutex_unlock(&pc->freq_lock);
>> @@ -1192,6 +1215,36 @@ static int pc_action_set_strategy(struct
>> xe_guc_pc *pc, u32 val)
>> return ret;
>> }
>> +int xe_guc_pc_set_use_rpe(struct xe_guc_pc *pc, u32 val)
> as this is not a static function, better to add description like it's
> neighbours.
>> +{
>> + int ret = 0;
>> +
>> + guard(mutex)(&pc->freq_lock);
>> +
>> + /* Might be in the middle of a gt reset */
>> + if (!pc->freq_ready)
>> + return -EAGAIN;
>> +
>> + /*
>> + * While the Wa_22019338487 cap is active, ignore_eff_freq must
>> stay
>> + * forced off. xe_guc_pc_restore_stashed_freq() will apply this
>> value
> In pc_set_mert_freq_cap() we are enabling ignore_eff_freq , so here
> looks like better to refactor the sentence.
>> + * once the cap is lifted.
>> + */
>> + if (!pc->mert_freq_cap_active) {
>> + /**
> /* as it's inside function body.
>> + * If use_rpe == 1, ignore_eff_freq = false. GuC elevates
>> min_freq to
>> + * RPe when enabled, and resets it back to the previously
>> set min
>> + * when disabled, so no explicit set_min_freq request is
>> needed here.
>> + */
>> + ret = pc_set_ignore_eff_freq(pc, !val);
>> + }
>> +
>> + if (!ret)
>> + pc->use_rpe = val;
>> +
>> + return ret;
>> +}
>> +
>> static const char *power_profile_to_string(struct xe_guc_pc *pc)
>> {
>> switch (pc->power_profile) {
>> @@ -1340,6 +1393,10 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
>> if (ret)
>> return ret;
>> + ret = pc_set_ignore_eff_freq(pc, !pc->use_rpe);
>> + if (unlikely(ret))
>> + return ret;
> If we return from here in that case the pc_init_freqs() will never be
> called, Imo better to just print error message here.
I will be moving this to after pc_init_freqs as per Sashiko comment.
Though, if the h2g fails for any reason, we should still continue to
fail the probe since env may be unstable.
>> +
>> ret = pc_init_freqs(pc);
>> if (ret)
>> return ret;
>> @@ -1426,6 +1483,7 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
>> pc->bo = bo;
>> pc->power_profile = SLPC_POWER_PROFILE_BASE;
>> + pc->use_rpe = true;
>
> use_rpe is u32 in the struct, maybe we can use this is bool everywhere.
I'll just define it as bool in the struct and keep the u32 in usage
functions.
Thanks,
Vinay.
>
> Thanks,
> Anirban
>
>> return devm_add_action_or_reset(xe->drm.dev,
>> xe_guc_pc_fini_hw, pc);
>> }
>> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.h
>> b/drivers/gpu/drm/xe/xe_guc_pc.h
>> index 1025a2b15f5f..dc52f349a6a2 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_pc.h
>> +++ b/drivers/gpu/drm/xe/xe_guc_pc.h
>> @@ -31,6 +31,7 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc,
>> u32 *freq);
>> int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq);
>> int xe_guc_pc_set_power_profile(struct xe_guc_pc *pc, const char
>> *buf);
>> void xe_guc_pc_get_power_profile(struct xe_guc_pc *pc, char *profile);
>> +int xe_guc_pc_set_use_rpe(struct xe_guc_pc *pc, u32 val);
>> enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc);
>> u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc);
>> diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> b/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> index 9a6ea2904e33..36bc25fc6753 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> +++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> @@ -37,6 +37,8 @@ struct xe_guc_pc {
>> u32 power_profile;
>> /** @mert_freq_cap_active: Wa_22019338487 min/max cap is
>> currently in force */
>> bool mert_freq_cap_active;
>> + /** @use_rpe: Toggle use of efficient frequency */
>> + u32 use_rpe;
>> };
>> #endif /* _XE_GUC_PC_TYPES_H_ */
next prev parent reply other threads:[~2026-11-19 18:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 1:24 [PATCH v3 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
2026-11-18 1:24 ` [PATCH v3 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
2026-11-18 1:50 ` sashiko-bot
2026-11-19 15:56 ` Anirban, Sk
2026-11-19 18:35 ` Belgaumkar, Vinay [this message]
2026-11-18 1:34 ` ✓ CI.KUnit: success for series starting with [v3,1/2] drm/xe: Disallow freq changes while mert cap is active Patchwork
2026-11-18 2:01 ` [PATCH v3 1/2] " sashiko-bot
2026-11-18 2:10 ` ✗ Xe.CI.BAT: failure for series starting with [v3,1/2] " Patchwork
2026-11-18 15:33 ` ✗ Xe.CI.FULL: " 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=8b40e8a8-4e46-499d-9b3e-70aff38fb4ef@intel.com \
--to=vinay.belgaumkar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=sk.anirban@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