Skip to contentSkip to conversation

drm/xe/guc: Remove cached frequency values for GuC SLPC

PATCH Superseded Sk Anirban 2 participants 5 messages Nov 4, 2025

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Sk Anirban

author
#0 lore raw

v5 cover drm/xe/guc: Remove cached frequency values for GuC SLPC

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(-)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v5 1/2 drm/xe/guc: Eliminate RPe caching for SLPC parameter handling

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)

---
 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(-)
drivers/gpu/drm/xe/xe_guc_pc.c +35 -33
index 3c0feb50a1e2..a9c29f123b37 100644
@@ -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(&gt->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(&gt->mmio, PVC_RP_STATE_CAP);
-		pc->rpe_freq = REG_FIELD_GET(RP1_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
-	} else {
-		reg = xe_mmio_read32(&gt->mmio, FREQ_INFO_REC);
-		pc->rpe_freq = REG_FIELD_GET(RPE_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
-	}
+	reg = xe_mmio_read32(&gt->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(&gt->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);
 }
drivers/gpu/drm/xe/xe_guc_pc_types.h +0 -2
index 5e4ea53fbee6..f27c05d81706 100644
@@ -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 */
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v5 2/2 drm/xe/guc: Eliminate RPa frequency caching

In reply to 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)

---
 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(-)
drivers/gpu/drm/xe/xe_guc_pc.c +26 -29
index a9c29f123b37..01fc8ecb373d 100644
@@ -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(&gt->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(&gt->mmio, PVC_RP_STATE_CAP);
-		pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
-	} else {
-		reg = xe_mmio_read32(&gt->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(&gt->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(&gt->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);
 
 	/*
drivers/gpu/drm/xe/xe_guc_pc_types.h +0 -2
index f27c05d81706..711bbcdcb0d3 100644
@@ -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 */
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching

Quoted 97 lines · 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)

---
  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(-)
drivers/gpu/drm/xe/xe_guc_pc.c +18 -25
index a9c29f123b37..01fc8ecb373d 100644
@@ -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(&gt->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(&gt->mmio, PVC_RP_STATE_CAP);
-		pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) * GT_FREQUENCY_MULTIPLIER;
-	} else {
-		reg = xe_mmio_read32(&gt->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(&gt->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(&gt->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)

drivers/gpu/drm/xe/xe_guc_pc.c u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc) · line 537

Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_pc.c +6 -2
  {
-	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

Quoted 27 lines
drivers/gpu/drm/xe/xe_guc_pc.c +2 -2
+	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);
 
  	/*
drivers/gpu/drm/xe/xe_guc_pc_types.h +0 -2
index f27c05d81706..711bbcdcb0d3 100644
@@ -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 */
#4 lore raw

Re: [PATCH v5 2/2] drm/xe/guc: Eliminate RPa frequency caching

Hi,

Quoted 109 lines · Badal
Quoted 94 lines · 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)

---
  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(-)
drivers/gpu/drm/xe/xe_guc_pc.c +1 -0
index a9c29f123b37..01fc8ecb373d 100644
@@ -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;

drivers/gpu/drm/xe/xe_guc_pc.c +0 -0
@@ -372,7 +372,7 @@ static void mtl_update_rpa_value(struct xe_guc_pc 
 *pc)

      else
          reg = xe_mmio_read32(&gt->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)

drivers/gpu/drm/xe/xe_guc_pc.c +16 -11
@@ -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(&gt->mmio, PVC_RP_STATE_CAP);
-        pc->rpa_freq = REG_FIELD_GET(RP0_MASK, reg) * 
 GT_FREQUENCY_MULTIPLIER;
-    } else {
-        reg = xe_mmio_read32(&gt->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(&gt->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(&gt->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)

drivers/gpu/drm/xe/xe_guc_pc.c +0 -10
@@ -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)
    */

drivers/gpu/drm/xe/xe_guc_pc.c u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc) · line 537

Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_pc.c +6 -1
   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:

Quoted 6 lines

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

Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/xe/xe_guc_pc.c +2 -1
+    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);
         /*
drivers/gpu/drm/xe/xe_guc_pc_types.h +0 -2
index f27c05d81706..711bbcdcb0d3 100644
@@ -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 */