Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active
@ 2026-11-20  2:16 Vinay Belgaumkar
  2026-11-20  2:16 ` [PATCH v5 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
  2026-11-20  2:29 ` [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active sashiko-bot
  0 siblings, 2 replies; 4+ messages in thread
From: Vinay Belgaumkar @ 2026-11-20  2:16 UTC (permalink / raw)
  To: intel-xe; +Cc: Vinay Belgaumkar

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.

v2: Restore mert cap even after GSC load fails (Sashiko)
v5: Return stashed value for min/max during cap (Sashiko)

Fixes: 3b1592fb7835 ("drm/xe/lnl: Apply Wa_22019338487")
Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
---
 drivers/gpu/drm/xe/xe_gsc.c          |  6 +--
 drivers/gpu/drm/xe/xe_guc_pc.c       | 74 ++++++++++++++++++++--------
 drivers/gpu/drm/xe/xe_guc_pc_types.h |  2 +
 3 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
index 8edb8cee3cbd..d750a4c5075b 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);
+
+		/* Restore 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..7e9700f16bfb 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,10 @@ 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 value */
+	if (XE_GT_WA(pc_to_gt(pc), 22019338487) && pc->mert_freq_cap_active)
+		return pc->stashed_min_freq;
+
 	ret = pc_action_query_task_state(pc);
 	if (ret)
 		return ret;
@@ -638,17 +643,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 +695,10 @@ 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 (XE_GT_WA(pc_to_gt(pc), 22019338487) && pc->mert_freq_cap_active)
+		return pc->stashed_max_freq;
+
 	ret = pc_action_query_task_state(pc);
 	if (ret)
 		return ret;
@@ -707,17 +725,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,6 +1121,9 @@ 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;
 }
 
@@ -1112,9 +1142,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->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;
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v5 2/2] drm/xe: Add sysfs to disable RPe
  2026-11-20  2:16 [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
@ 2026-11-20  2:16 ` Vinay Belgaumkar
  2026-11-20  2:35   ` sashiko-bot
  2026-11-20  2:29 ` [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: Vinay Belgaumkar @ 2026-11-20  2:16 UTC (permalink / raw)
  To: intel-xe; +Cc: Vinay Belgaumkar, Sk Anirban

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)
v4: Disable RPe inside pc_adjust_freq_bounds (Sashiko), make use_rpe a
bool (Anirban)
v5: Restore use_rpe while under pc->freq_lock(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       | 81 ++++++++++++++++++++++++----
 drivers/gpu/drm/xe/xe_guc_pc.h       |  1 +
 drivers/gpu/drm/xe/xe_guc_pc_types.h |  2 +
 4 files changed, 110 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 7e9700f16bfb..68e54e0b756d 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);
@@ -943,6 +951,15 @@ static int pc_adjust_freq_bounds(struct xe_guc_pc *pc)
 
 	lockdep_assert_held(&pc->freq_lock);
 
+	/*
+	 * GuC enables RPe by default during SLPC reset, regardless of
+	 * use_rpe. Disable it so min_freq below reflects the true GT min
+	 * freq.
+	 */
+	ret = pc_set_ignore_eff_freq(pc, 1);
+	if (ret)
+		goto out;
+
 	ret = pc_action_query_task_state(pc);
 	if (ret)
 		goto out;
@@ -1099,12 +1116,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.
 	 */
@@ -1117,7 +1145,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)));
 
@@ -1144,9 +1174,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);
@@ -1178,6 +1210,11 @@ static int pc_init_freqs(struct xe_guc_pc *pc)
 
 	pc_init_pcode_freq(pc);
 
+	/* Restore use_rpe */
+	ret = pc_set_ignore_eff_freq(pc, !pc->use_rpe);
+	if (unlikely(ret))
+		return ret;
+
 	/*
 	 * The frequencies are really ready for use only after the user
 	 * requested ones got restored.
@@ -1200,6 +1237,31 @@ 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)
+{
+	int ret = 0;
+
+	guard(mutex)(&pc->freq_lock);
+
+	/* Might be in the middle of a gt reset */
+	if (!pc->freq_ready)
+		return -EAGAIN;
+
+	if (!pc->mert_freq_cap_active) {
+		/*
+		 * 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) {
@@ -1434,6 +1496,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;
 
 	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..d59e7c935738 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 */
+	bool use_rpe;
 };
 
 #endif	/* _XE_GUC_PC_TYPES_H_ */
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active
  2026-11-20  2:16 [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
  2026-11-20  2:16 ` [PATCH v5 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
@ 2026-11-20  2:29 ` sashiko-bot
  1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-20  2:29 UTC (permalink / raw)
  To: Vinay Belgaumkar, intel-xe

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/xe: xe_guc_pc_get_min/max_freq_locked() return freq instead
  of 0
- [Medium] drm/xe: mert_freq_cap_active is not cleared on GuC PC stop or
  restart
--

commit a5ffc89a51c9df2129a3327ea1a0076ff70c2a90
Author: Vinay Belgaumkar <vinay.belgaumkar@intel.com>

drm/xe: Disallow freq changes while mert cap is active

This commit tracks when the Wa_22019338487 MERT frequency cap is active,
defers user min/max frequency changes until the cap is lifted, and lifts
the cap even if GSC firmware load fails.

> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index 9558d7196a51a..7e9700f16bfb6 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c

[ ... ]

> @@ -612,6 +613,10 @@ 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 value */
> +	if (XE_GT_WA(pc_to_gt(pc), 22019338487) && pc->mert_freq_cap_active)
> +		return pc->stashed_min_freq;
> +
>  	ret = pc_action_query_task_state(pc);
>  	if (ret)
>  		return ret;

[ ... ]

> @@ -681,6 +695,10 @@ 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 (XE_GT_WA(pc_to_gt(pc), 22019338487) && pc->mert_freq_cap_active)
> +		return pc->stashed_max_freq;
> +
>  	ret = pc_action_query_task_state(pc);
>  	if (ret)
>  		return ret;

[Severity: High]
Should xe_guc_pc_get_min_freq_locked() and xe_guc_pc_get_max_freq_locked()
write the frequency into *freq and return 0 here instead of returning the
positive frequency value as the status code?

Callers such as min_freq_show() and max_freq_show() check if (ret) return
ret;, so returning a positive MHz value leaves *freq unassigned and causes
the sysfs show callbacks to return that positive integer as the byte count
without writing to buf.  In addition, if a user sets a new min or max
frequency while the cap is active, it is saved in pc->user_requested_min /
pc->user_requested_max rather than pc->stashed_min_freq /
pc->stashed_max_freq, so *freq should probably be assigned
pc->user_requested_min ?: pc->stashed_min_freq (and similarly for max) to
match xe_guc_pc_restore_stashed_freq().

[ ... ]

> @@ -1094,6 +1121,9 @@ 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;
>  }

[Severity: Medium]
What happens if GuC PC is stopped and restarted (for example during a GT
reset) while pc->mert_freq_cap_active is still true?

Neither xe_guc_pc_stop() nor pc_set_mert_freq_cap() clears
pc->mert_freq_cap_active.  When xe_guc_pc_start() calls
pc_set_mert_freq_cap() after pc_init_freqs(), its calls to
xe_guc_pc_get_min_freq_locked() and xe_guc_pc_get_max_freq_locked() will
hit the pc->mert_freq_cap_active early return instead of querying the
newly initialized SLPC state from GuC.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120021606.1360244-3-vinay.belgaumkar@intel.com?part=1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5 2/2] drm/xe: Add sysfs to disable RPe
  2026-11-20  2:16 ` [PATCH v5 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
@ 2026-11-20  2:35   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-20  2:35 UTC (permalink / raw)
  To: Vinay Belgaumkar, intel-xe

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/xe: missing mutex_unlock() on error path in pc_init_freqs()
--

commit 8eaf500b6aad45a924c81aec805cef3e5c7913ef
Author: Vinay Belgaumkar <vinay.belgaumkar@intel.com>

drm/xe: Add sysfs to disable RPe

This commit adds a use_rpe sysfs attribute to control whether GuC SLPC
elevates the minimum GT frequency to the efficient frequency (RPe), and
disables RPe before stashing or adjusting frequency bounds.

> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index 7e9700f16bfb6..68e54e0b756de 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c

[ ... ]

> @@ -1178,6 +1210,11 @@ static int pc_init_freqs(struct xe_guc_pc *pc)
>  
>  	pc_init_pcode_freq(pc);
>  
> +	/* Restore use_rpe */
> +	ret = pc_set_ignore_eff_freq(pc, !pc->use_rpe);
> +	if (unlikely(ret))
> +		return ret;
> +
>  	/*
>  	 * The frequencies are really ready for use only after the user
>  	 * requested ones got restored.

[Severity: High]
Does this error return leave pc->freq_lock held when
pc_set_ignore_eff_freq() fails?  pc_init_freqs() acquires pc->freq_lock
at the start and releases it at the out label, so returning directly here
will deadlock any later caller that takes pc->freq_lock.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120021606.1360244-3-vinay.belgaumkar@intel.com?part=2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-20  2:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  2:16 [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
2026-11-20  2:16 ` [PATCH v5 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
2026-11-20  2:35   ` sashiko-bot
2026-11-20  2:29 ` [PATCH v5 1/2] drm/xe: Disallow freq changes while mert cap is active sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox