* [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching
2025-10-29 11:20 [PATCH v5 0/2] drm/xe/guc: Remove cached frequency values for GuC SLPC Sk Anirban
@ 2025-10-29 11:20 ` Sk Anirban
0 siblings, 0 replies; 6+ messages in thread
From: Sk Anirban @ 2025-10-29 11:20 UTC (permalink / raw)
To: intel-xe
Cc: anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa,
raag.jadav, soham.purkait, mallesh.koujalagi, vinay.belgaumkar,
rodrigo.vivi, Sk Anirban
Remove the cached pc->rpa_freq field and refactor RPA frequency handling
to fetch values directly from hardware registers on each request.
Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Suggested-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Sk Anirban <sk.anirban@intel.com>
---
drivers/gpu/drm/xe/xe_guc_pc.c | 55 +++++++++++++---------------
drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 -
2 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
index 08deaa64aa85..379b9aac1b42 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.c
+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
@@ -362,7 +362,7 @@ static int pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
freq);
}
-static void mtl_update_rpa_value(struct xe_guc_pc *pc)
+static u32 mtl_get_rpa_freq(struct xe_guc_pc *pc)
{
struct xe_gt *gt = pc_to_gt(pc);
u32 reg;
@@ -372,7 +372,7 @@ static void mtl_update_rpa_value(struct xe_guc_pc *pc)
else
reg = xe_mmio_read32(>->mmio, MTL_GT_RPA_FREQUENCY);
- pc->rpa_freq = decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
+ return decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
}
static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
@@ -388,24 +388,28 @@ static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
return decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg));
}
-static void tgl_update_rpa_value(struct xe_guc_pc *pc)
+static u32 pvc_get_rpa_freq(struct xe_guc_pc *pc)
{
- struct xe_gt *gt = pc_to_gt(pc);
- struct xe_device *xe = gt_to_xe(gt);
- u32 reg;
-
/*
* For PVC we still need to use fused RP0 as the approximation for RPa
* For other platforms than PVC we get the resolved RPa directly from
* PCODE at a different register
*/
- if (xe->info.platform == XE_PVC) {
- reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
- pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
- } else {
- reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
- pc->rpa_freq = REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
- }
+
+ struct xe_gt *gt = pc_to_gt(pc);
+ u32 reg;
+
+ reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
+ return REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
+}
+
+static u32 tgl_get_rpa_freq(struct xe_guc_pc *pc)
+{
+ struct xe_gt *gt = pc_to_gt(pc);
+ u32 reg;
+
+ reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
+ return REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
}
static u32 pvc_get_rpe_freq(struct xe_guc_pc *pc)
@@ -426,17 +430,6 @@ static u32 tgl_get_rpe_freq(struct xe_guc_pc *pc)
return REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
}
-static void pc_update_rp_values(struct xe_guc_pc *pc)
-{
- struct xe_gt *gt = pc_to_gt(pc);
- struct xe_device *xe = gt_to_xe(gt);
-
- if (GRAPHICS_VERx100(xe) >= 1270)
- mtl_update_rpa_value(pc);
- else
- tgl_update_rpa_value(pc);
-}
-
/**
* xe_guc_pc_get_act_freq - Get Actual running frequency
* @pc: The GuC PC
@@ -535,9 +528,15 @@ u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc)
*/
u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc)
{
- pc_update_rp_values(pc);
+ struct xe_gt *gt = pc_to_gt(pc);
+ struct xe_device *xe = gt_to_xe(gt);
- return pc->rpa_freq;
+ if (xe->info.platform == XE_PVC)
+ return pvc_get_rpa_freq(pc);
+ else if (GRAPHICS_VERx100(xe) >= 1270)
+ return mtl_get_rpa_freq(pc);
+ else
+ return tgl_get_rpa_freq(pc);
}
/**
@@ -1141,8 +1140,6 @@ static int pc_init_freqs(struct xe_guc_pc *pc)
if (ret)
goto out;
- pc_update_rp_values(pc);
-
pc_init_pcode_freq(pc);
/*
diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h b/drivers/gpu/drm/xe/xe_guc_pc_types.h
index f27c05d81706..711bbcdcb0d3 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
+++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
@@ -19,8 +19,6 @@ struct xe_guc_pc {
atomic_t flush_freq_limit;
/** @rp0_freq: HW RP0 frequency - The Maximum one */
u32 rp0_freq;
- /** @rpa_freq: HW RPa frequency - The Achievable one */
- u32 rpa_freq;
/** @rpn_freq: HW RPN frequency - The Minimum one */
u32 rpn_freq;
/** @user_requested_min: Stash the minimum requested freq by user */
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v5 0/2] drm/xe/guc: Remove cached frequency values for GuC SLPC
@ 2025-11-04 10:42 Sk Anirban
2025-11-04 10:42 ` [PATCH v5 1/2] drm/xe/guc: Eliminate RPe caching for SLPC parameter handling Sk Anirban
2025-11-04 10:42 ` [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching Sk Anirban
0 siblings, 2 replies; 6+ messages in thread
From: Sk Anirban @ 2025-11-04 10:42 UTC (permalink / raw)
To: intel-xe
Cc: anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa,
raag.jadav, soham.purkait, mallesh.koujalagi, vinay.belgaumkar,
rodrigo.vivi, Sk Anirban
This series eliminates cached frequency values that were causing stale
data in GuC SLPC parameter handling. Both RPe and RPa frequencies are
now read live from hardware registers on each request.
Sk Anirban (2):
drm/xe/guc: Eliminate RPe caching for SLPC parameter handling
drm/xe/guc: Eliminate RPa frequency caching
drivers/gpu/drm/xe/xe_guc_pc.c | 107 +++++++++++++--------------
drivers/gpu/drm/xe/xe_guc_pc_types.h | 4 -
2 files changed, 53 insertions(+), 58 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 1/2] drm/xe/guc: Eliminate RPe caching for SLPC parameter handling
2025-11-04 10:42 [PATCH v5 0/2] drm/xe/guc: Remove cached frequency values for GuC SLPC Sk Anirban
@ 2025-11-04 10:42 ` Sk Anirban
2025-11-04 10:42 ` [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching Sk Anirban
1 sibling, 0 replies; 6+ messages in thread
From: Sk Anirban @ 2025-11-04 10:42 UTC (permalink / raw)
To: intel-xe
Cc: anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa,
raag.jadav, soham.purkait, mallesh.koujalagi, vinay.belgaumkar,
rodrigo.vivi, Sk Anirban
RPe is runtime-determined by PCODE and caching it caused stale values,
leading to incorrect GuC SLPC parameter settings.
Drop the cached rpe_freq field and query fresh values from hardware
on each use to ensure GuC SLPC parameters reflect current RPe.
v2: Remove cached RPe frequency field (Rodrigo)
v3: Remove extra variable (Vinay)
Modify function name (Vinay)
v4: Maintain a separate function for PVC (Rodrigo)
v5: Avoid RPn update while fetching RPe frequency (Rodrigo)
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/5166
Signed-off-by: Sk Anirban <sk.anirban@intel.com>
---
drivers/gpu/drm/xe/xe_guc_pc.c | 68 ++++++++++++++--------------
drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 -
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
index 3c0feb50a1e2..a9c29f123b37 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.c
+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
@@ -330,7 +330,7 @@ static int pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
* Our goal is to have the admin choices respected.
*/
pc_action_set_param(pc, SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY,
- freq < pc->rpe_freq);
+ freq < xe_guc_pc_get_rpe_freq(pc));
return pc_action_set_param(pc,
SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ,
@@ -375,7 +375,7 @@ static void mtl_update_rpa_value(struct xe_guc_pc *pc)
pc->rpa_freq = decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
}
-static void mtl_update_rpe_value(struct xe_guc_pc *pc)
+static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
{
struct xe_gt *gt = pc_to_gt(pc);
u32 reg;
@@ -385,7 +385,7 @@ static void mtl_update_rpe_value(struct xe_guc_pc *pc)
else
reg = xe_mmio_read32(>->mmio, MTL_GT_RPE_FREQUENCY);
- pc->rpe_freq = decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg));
+ return decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg));
}
static void tgl_update_rpa_value(struct xe_guc_pc *pc)
@@ -408,24 +408,22 @@ static void tgl_update_rpa_value(struct xe_guc_pc *pc)
}
}
-static void tgl_update_rpe_value(struct xe_guc_pc *pc)
+static u32 pvc_get_rpe_freq(struct xe_guc_pc *pc)
{
struct xe_gt *gt = pc_to_gt(pc);
- struct xe_device *xe = gt_to_xe(gt);
u32 reg;
- /*
- * For PVC we still need to use fused RP1 as the approximation for RPe
- * For other platforms than PVC we get the resolved RPe directly from
- * PCODE at a different register
- */
- if (xe->info.platform == XE_PVC) {
- reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
- pc->rpe_freq = REG_FIELD_GET(RP1_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
- } else {
- reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
- pc->rpe_freq = REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
- }
+ reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
+ return REG_FIELD_GET(RP1_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
+}
+
+static u32 tgl_get_rpe_freq(struct xe_guc_pc *pc)
+{
+ struct xe_gt *gt = pc_to_gt(pc);
+ u32 reg;
+
+ reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
+ return REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
}
static void pc_update_rp_values(struct xe_guc_pc *pc)
@@ -433,20 +431,10 @@ static void pc_update_rp_values(struct xe_guc_pc *pc)
struct xe_gt *gt = pc_to_gt(pc);
struct xe_device *xe = gt_to_xe(gt);
- if (GRAPHICS_VERx100(xe) >= 1270) {
+ if (GRAPHICS_VERx100(xe) >= 1270)
mtl_update_rpa_value(pc);
- mtl_update_rpe_value(pc);
- } else {
+ else
tgl_update_rpa_value(pc);
- tgl_update_rpe_value(pc);
- }
-
- /*
- * RPe is decided at runtime by PCODE. In the rare case where that's
- * smaller than the fused min, we will trust the PCODE and use that
- * as our minimum one.
- */
- pc->rpn_freq = min(pc->rpn_freq, pc->rpe_freq);
}
/**
@@ -560,9 +548,23 @@ u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc)
*/
u32 xe_guc_pc_get_rpe_freq(struct xe_guc_pc *pc)
{
- pc_update_rp_values(pc);
+ struct xe_gt *gt = pc_to_gt(pc);
+ struct xe_device *xe = gt_to_xe(gt);
+ u32 freq;
- return pc->rpe_freq;
+ /*
+ * For PVC we still need to use fused RP1 as the approximation for RPe
+ * For other platforms than PVC we get the resolved RPe directly from
+ * PCODE at a different register
+ */
+ if (GRAPHICS_VERx100(xe) >= 1260)
+ freq = pvc_get_rpe_freq(pc);
+ else if (GRAPHICS_VERx100(xe) >= 1270)
+ freq = mtl_get_rpe_freq(pc);
+ else
+ freq = tgl_get_rpe_freq(pc);
+
+ return freq;
}
/**
@@ -1021,7 +1023,7 @@ 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(pc->rpe_freq, pc_max_freq_cap(pc)));
+ ret = pc_set_min_freq(pc, min(xe_guc_pc_get_rpe_freq(pc), pc_max_freq_cap(pc)));
if (!ret)
ret = pc_set_max_freq(pc, min(pc->rp0_freq, pc_max_freq_cap(pc)));
@@ -1339,7 +1341,7 @@ static void xe_guc_pc_fini_hw(void *arg)
XE_WARN_ON(xe_guc_pc_stop(pc));
/* Bind requested freq to mert_freq_cap before unload */
- pc_set_cur_freq(pc, min(pc_max_freq_cap(pc), pc->rpe_freq));
+ pc_set_cur_freq(pc, min(pc_max_freq_cap(pc), xe_guc_pc_get_rpe_freq(pc)));
xe_force_wake_put(gt_to_fw(pc_to_gt(pc)), fw_ref);
}
diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h b/drivers/gpu/drm/xe/xe_guc_pc_types.h
index 5e4ea53fbee6..f27c05d81706 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
+++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
@@ -21,8 +21,6 @@ struct xe_guc_pc {
u32 rp0_freq;
/** @rpa_freq: HW RPa frequency - The Achievable one */
u32 rpa_freq;
- /** @rpe_freq: HW RPe frequency - The Efficient one */
- u32 rpe_freq;
/** @rpn_freq: HW RPN frequency - The Minimum one */
u32 rpn_freq;
/** @user_requested_min: Stash the minimum requested freq by user */
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching
2025-11-04 10:42 [PATCH v5 0/2] drm/xe/guc: Remove cached frequency values for GuC SLPC Sk Anirban
2025-11-04 10:42 ` [PATCH v5 1/2] drm/xe/guc: Eliminate RPe caching for SLPC parameter handling Sk Anirban
@ 2025-11-04 10:42 ` Sk Anirban
2025-11-04 14:47 ` Nilawar, Badal
1 sibling, 1 reply; 6+ messages in thread
From: Sk Anirban @ 2025-11-04 10:42 UTC (permalink / raw)
To: intel-xe
Cc: anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa,
raag.jadav, soham.purkait, mallesh.koujalagi, vinay.belgaumkar,
rodrigo.vivi, Sk Anirban
Remove the cached pc->rpa_freq field and refactor RPA frequency handling
to fetch values directly from hardware registers on each request.
v2: Check graphics version instead of platform (Rodrigo)
Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Suggested-by: Badal Nilawar <badal.nilawar@intel.com>
Signed-off-by: Sk Anirban <sk.anirban@intel.com>
---
drivers/gpu/drm/xe/xe_guc_pc.c | 55 +++++++++++++---------------
drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 -
2 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
index a9c29f123b37..01fc8ecb373d 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.c
+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
@@ -362,7 +362,7 @@ static int pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
freq);
}
-static void mtl_update_rpa_value(struct xe_guc_pc *pc)
+static u32 mtl_get_rpa_freq(struct xe_guc_pc *pc)
{
struct xe_gt *gt = pc_to_gt(pc);
u32 reg;
@@ -372,7 +372,7 @@ static void mtl_update_rpa_value(struct xe_guc_pc *pc)
else
reg = xe_mmio_read32(>->mmio, MTL_GT_RPA_FREQUENCY);
- pc->rpa_freq = decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
+ return decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
}
static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
@@ -388,24 +388,28 @@ static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
return decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg));
}
-static void tgl_update_rpa_value(struct xe_guc_pc *pc)
+static u32 pvc_get_rpa_freq(struct xe_guc_pc *pc)
{
- struct xe_gt *gt = pc_to_gt(pc);
- struct xe_device *xe = gt_to_xe(gt);
- u32 reg;
-
/*
* For PVC we still need to use fused RP0 as the approximation for RPa
* For other platforms than PVC we get the resolved RPa directly from
* PCODE at a different register
*/
- if (xe->info.platform == XE_PVC) {
- reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
- pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
- } else {
- reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
- pc->rpa_freq = REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
- }
+
+ struct xe_gt *gt = pc_to_gt(pc);
+ u32 reg;
+
+ reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
+ return REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
+}
+
+static u32 tgl_get_rpa_freq(struct xe_guc_pc *pc)
+{
+ struct xe_gt *gt = pc_to_gt(pc);
+ u32 reg;
+
+ reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
+ return REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
}
static u32 pvc_get_rpe_freq(struct xe_guc_pc *pc)
@@ -426,17 +430,6 @@ static u32 tgl_get_rpe_freq(struct xe_guc_pc *pc)
return REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
}
-static void pc_update_rp_values(struct xe_guc_pc *pc)
-{
- struct xe_gt *gt = pc_to_gt(pc);
- struct xe_device *xe = gt_to_xe(gt);
-
- if (GRAPHICS_VERx100(xe) >= 1270)
- mtl_update_rpa_value(pc);
- else
- tgl_update_rpa_value(pc);
-}
-
/**
* xe_guc_pc_get_act_freq - Get Actual running frequency
* @pc: The GuC PC
@@ -535,9 +528,15 @@ u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc)
*/
u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc)
{
- pc_update_rp_values(pc);
+ struct xe_gt *gt = pc_to_gt(pc);
+ struct xe_device *xe = gt_to_xe(gt);
- return pc->rpa_freq;
+ if (GRAPHICS_VERx100(xe) >= 1260)
+ return pvc_get_rpa_freq(pc);
+ else if (GRAPHICS_VERx100(xe) >= 1270)
+ return mtl_get_rpa_freq(pc);
+ else
+ return tgl_get_rpa_freq(pc);
}
/**
@@ -1134,8 +1133,6 @@ static int pc_init_freqs(struct xe_guc_pc *pc)
if (ret)
goto out;
- pc_update_rp_values(pc);
-
pc_init_pcode_freq(pc);
/*
diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h b/drivers/gpu/drm/xe/xe_guc_pc_types.h
index f27c05d81706..711bbcdcb0d3 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
+++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
@@ -19,8 +19,6 @@ struct xe_guc_pc {
atomic_t flush_freq_limit;
/** @rp0_freq: HW RP0 frequency - The Maximum one */
u32 rp0_freq;
- /** @rpa_freq: HW RPa frequency - The Achievable one */
- u32 rpa_freq;
/** @rpn_freq: HW RPN frequency - The Minimum one */
u32 rpn_freq;
/** @user_requested_min: Stash the minimum requested freq by user */
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching
2025-11-04 10:42 ` [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching Sk Anirban
@ 2025-11-04 14:47 ` Nilawar, Badal
2025-11-04 20:09 ` Anirban, Sk
0 siblings, 1 reply; 6+ messages in thread
From: Nilawar, Badal @ 2025-11-04 14:47 UTC (permalink / raw)
To: Sk Anirban, intel-xe
Cc: anshuman.gupta, riana.tauro, karthik.poosa, raag.jadav,
soham.purkait, mallesh.koujalagi, vinay.belgaumkar, rodrigo.vivi
On 04-11-2025 16:12, Sk Anirban wrote:
> Remove the cached pc->rpa_freq field and refactor RPA frequency handling
> to fetch values directly from hardware registers on each request.
>
> v2: Check graphics version instead of platform (Rodrigo)
>
> Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Suggested-by: Badal Nilawar <badal.nilawar@intel.com>
> Signed-off-by: Sk Anirban <sk.anirban@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_pc.c | 55 +++++++++++++---------------
> drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 -
> 2 files changed, 26 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index a9c29f123b37..01fc8ecb373d 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
> @@ -362,7 +362,7 @@ static int pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
> freq);
> }
>
> -static void mtl_update_rpa_value(struct xe_guc_pc *pc)
> +static u32 mtl_get_rpa_freq(struct xe_guc_pc *pc)
> {
> struct xe_gt *gt = pc_to_gt(pc);
> u32 reg;
> @@ -372,7 +372,7 @@ static void mtl_update_rpa_value(struct xe_guc_pc *pc)
> else
> reg = xe_mmio_read32(>->mmio, MTL_GT_RPA_FREQUENCY);
>
> - pc->rpa_freq = decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
> + return decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
> }
>
> static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
> @@ -388,24 +388,28 @@ static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
> return decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg));
> }
>
> -static void tgl_update_rpa_value(struct xe_guc_pc *pc)
> +static u32 pvc_get_rpa_freq(struct xe_guc_pc *pc)
> {
> - struct xe_gt *gt = pc_to_gt(pc);
> - struct xe_device *xe = gt_to_xe(gt);
> - u32 reg;
> -
> /*
> * For PVC we still need to use fused RP0 as the approximation for RPa
> * For other platforms than PVC we get the resolved RPa directly from
> * PCODE at a different register
> */
> - if (xe->info.platform == XE_PVC) {
> - reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
> - pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
> - } else {
> - reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
> - pc->rpa_freq = REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
> - }
> +
> + struct xe_gt *gt = pc_to_gt(pc);
> + u32 reg;
> +
> + reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
> + return REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
> +}
> +
> +static u32 tgl_get_rpa_freq(struct xe_guc_pc *pc)
> +{
> + struct xe_gt *gt = pc_to_gt(pc);
> + u32 reg;
> +
> + reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
> + return REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
> }
>
> static u32 pvc_get_rpe_freq(struct xe_guc_pc *pc)
> @@ -426,17 +430,6 @@ static u32 tgl_get_rpe_freq(struct xe_guc_pc *pc)
> return REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
> }
>
> -static void pc_update_rp_values(struct xe_guc_pc *pc)
> -{
> - struct xe_gt *gt = pc_to_gt(pc);
> - struct xe_device *xe = gt_to_xe(gt);
> -
> - if (GRAPHICS_VERx100(xe) >= 1270)
> - mtl_update_rpa_value(pc);
> - else
> - tgl_update_rpa_value(pc);
> -}
> -
> /**
> * xe_guc_pc_get_act_freq - Get Actual running frequency
> * @pc: The GuC PC
> @@ -535,9 +528,15 @@ u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc)
> */
> u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc)
> {
> - pc_update_rp_values(pc);
> + struct xe_gt *gt = pc_to_gt(pc);
> + struct xe_device *xe = gt_to_xe(gt);
>
> - return pc->rpa_freq;
> + if (GRAPHICS_VERx100(xe) >= 1260)
> + return pvc_get_rpa_freq(pc);
> + else if (GRAPHICS_VERx100(xe) >= 1270)
> + return mtl_get_rpa_freq(pc);
This code will never execute in its current position; it should be
checked first. The correct order is:
if (GRAPHICS_VERx100(xe) >= 1270)
return mtl_get_rpa_freq(pc);
else if (GRAPHICS_VERx100(xe) >= 1260)
return pvc_get_rpa_freq(pc);
Regards, Badal
> + else
> + return tgl_get_rpa_freq(pc);
> }
>
> /**
> @@ -1134,8 +1133,6 @@ static int pc_init_freqs(struct xe_guc_pc *pc)
> if (ret)
> goto out;
>
> - pc_update_rp_values(pc);
> -
> pc_init_pcode_freq(pc);
>
> /*
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h b/drivers/gpu/drm/xe/xe_guc_pc_types.h
> index f27c05d81706..711bbcdcb0d3 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
> +++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
> @@ -19,8 +19,6 @@ struct xe_guc_pc {
> atomic_t flush_freq_limit;
> /** @rp0_freq: HW RP0 frequency - The Maximum one */
> u32 rp0_freq;
> - /** @rpa_freq: HW RPa frequency - The Achievable one */
> - u32 rpa_freq;
> /** @rpn_freq: HW RPN frequency - The Minimum one */
> u32 rpn_freq;
> /** @user_requested_min: Stash the minimum requested freq by user */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching
2025-11-04 14:47 ` Nilawar, Badal
@ 2025-11-04 20:09 ` Anirban, Sk
0 siblings, 0 replies; 6+ messages in thread
From: Anirban, Sk @ 2025-11-04 20:09 UTC (permalink / raw)
To: Nilawar, Badal, intel-xe
Cc: anshuman.gupta, riana.tauro, karthik.poosa, raag.jadav,
soham.purkait, mallesh.koujalagi, vinay.belgaumkar, rodrigo.vivi
Hi,
On 04-11-2025 20:17, Nilawar, Badal wrote:
>
> On 04-11-2025 16:12, Sk Anirban wrote:
>> Remove the cached pc->rpa_freq field and refactor RPA frequency handling
>> to fetch values directly from hardware registers on each request.
>>
>> v2: Check graphics version instead of platform (Rodrigo)
>>
>> Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> Suggested-by: Badal Nilawar <badal.nilawar@intel.com>
>> Signed-off-by: Sk Anirban <sk.anirban@intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_guc_pc.c | 55 +++++++++++++---------------
>> drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 -
>> 2 files changed, 26 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c
>> b/drivers/gpu/drm/xe/xe_guc_pc.c
>> index a9c29f123b37..01fc8ecb373d 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
>> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
>> @@ -362,7 +362,7 @@ static int pc_set_max_freq(struct xe_guc_pc *pc,
>> u32 freq)
>> freq);
>> }
>> -static void mtl_update_rpa_value(struct xe_guc_pc *pc)
>> +static u32 mtl_get_rpa_freq(struct xe_guc_pc *pc)
>> {
>> struct xe_gt *gt = pc_to_gt(pc);
>> u32 reg;
>> @@ -372,7 +372,7 @@ static void mtl_update_rpa_value(struct xe_guc_pc
>> *pc)
>> else
>> reg = xe_mmio_read32(>->mmio, MTL_GT_RPA_FREQUENCY);
>> - pc->rpa_freq = decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
>> + return decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg));
>> }
>> static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
>> @@ -388,24 +388,28 @@ static u32 mtl_get_rpe_freq(struct xe_guc_pc *pc)
>> return decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg));
>> }
>> -static void tgl_update_rpa_value(struct xe_guc_pc *pc)
>> +static u32 pvc_get_rpa_freq(struct xe_guc_pc *pc)
>> {
>> - struct xe_gt *gt = pc_to_gt(pc);
>> - struct xe_device *xe = gt_to_xe(gt);
>> - u32 reg;
>> -
>> /*
>> * For PVC we still need to use fused RP0 as the approximation
>> for RPa
>> * For other platforms than PVC we get the resolved RPa
>> directly from
>> * PCODE at a different register
>> */
>> - if (xe->info.platform == XE_PVC) {
>> - reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
>> - pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) *
>> GT_FREQUENCY_MULTIPLIER;
>> - } else {
>> - reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
>> - pc->rpa_freq = REG_FIELD_GET(RPA_MASK, reg) *
>> GT_FREQUENCY_MULTIPLIER;
>> - }
>> +
>> + struct xe_gt *gt = pc_to_gt(pc);
>> + u32 reg;
>> +
>> + reg = xe_mmio_read32(>->mmio, PVC_RP_STATE_CAP);
>> + return REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
>> +}
>> +
>> +static u32 tgl_get_rpa_freq(struct xe_guc_pc *pc)
>> +{
>> + struct xe_gt *gt = pc_to_gt(pc);
>> + u32 reg;
>> +
>> + reg = xe_mmio_read32(>->mmio, FREQ_INFO_REC);
>> + return REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
>> }
>> static u32 pvc_get_rpe_freq(struct xe_guc_pc *pc)
>> @@ -426,17 +430,6 @@ static u32 tgl_get_rpe_freq(struct xe_guc_pc *pc)
>> return REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
>> }
>> -static void pc_update_rp_values(struct xe_guc_pc *pc)
>> -{
>> - struct xe_gt *gt = pc_to_gt(pc);
>> - struct xe_device *xe = gt_to_xe(gt);
>> -
>> - if (GRAPHICS_VERx100(xe) >= 1270)
>> - mtl_update_rpa_value(pc);
>> - else
>> - tgl_update_rpa_value(pc);
>> -}
>> -
>> /**
>> * xe_guc_pc_get_act_freq - Get Actual running frequency
>> * @pc: The GuC PC
>> @@ -535,9 +528,15 @@ u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc)
>> */
>> u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc)
>> {
>> - pc_update_rp_values(pc);
>> + struct xe_gt *gt = pc_to_gt(pc);
>> + struct xe_device *xe = gt_to_xe(gt);
>> - return pc->rpa_freq;
>> + if (GRAPHICS_VERx100(xe) >= 1260)
>> + return pvc_get_rpa_freq(pc);
>> + else if (GRAPHICS_VERx100(xe) >= 1270)
>> + return mtl_get_rpa_freq(pc);
>
> This code will never execute in its current position; it should be
> checked first. The correct order is:
>
> if (GRAPHICS_VERx100(xe) >= 1270)
> return mtl_get_rpa_freq(pc);
> else if (GRAPHICS_VERx100(xe) >= 1260)
> return pvc_get_rpa_freq(pc);
> Regards, Badal
>
I had intended to check only for PVC here, my mistake. I've sent the
corrected version.
Thanks,
Anirban
>> + else
>> + return tgl_get_rpa_freq(pc);
>> }
>> /**
>> @@ -1134,8 +1133,6 @@ static int pc_init_freqs(struct xe_guc_pc *pc)
>> if (ret)
>> goto out;
>> - pc_update_rp_values(pc);
>> -
>> pc_init_pcode_freq(pc);
>> /*
>> diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> b/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> index f27c05d81706..711bbcdcb0d3 100644
>> --- a/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> +++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h
>> @@ -19,8 +19,6 @@ struct xe_guc_pc {
>> atomic_t flush_freq_limit;
>> /** @rp0_freq: HW RP0 frequency - The Maximum one */
>> u32 rp0_freq;
>> - /** @rpa_freq: HW RPa frequency - The Achievable one */
>> - u32 rpa_freq;
>> /** @rpn_freq: HW RPN frequency - The Minimum one */
>> u32 rpn_freq;
>> /** @user_requested_min: Stash the minimum requested freq by
>> user */
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-04 20:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 10:42 [PATCH v5 0/2] drm/xe/guc: Remove cached frequency values for GuC SLPC Sk Anirban
2025-11-04 10:42 ` [PATCH v5 1/2] drm/xe/guc: Eliminate RPe caching for SLPC parameter handling Sk Anirban
2025-11-04 10:42 ` [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching Sk Anirban
2025-11-04 14:47 ` Nilawar, Badal
2025-11-04 20:09 ` Anirban, Sk
-- strict thread matches above, loose matches on Subject: below --
2025-10-29 11:20 [PATCH v5 0/2] drm/xe/guc: Remove cached frequency values for GuC SLPC Sk Anirban
2025-10-29 11:20 ` [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching Sk Anirban
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox