Skip to content

Commit 01b8c2e

Browse files
Don Hiattrodrigovivi
authored andcommitted
drm/i915: Use GEN12_RPSTAT register for GT freq
On GEN12+ use GEN12_RPSTAT register to get actual resolved GT freq. GEN12_RPSTAT does not require a forcewake and will return 0 freq if GT is in RC6. v2: - Fixed review comments(Ashutosh) - Added function intel_rps_read_rpstat_fw to read RPSTAT without forcewake, required especially for GEN6_RPSTAT1 (Ashutosh, Tvrtko) v3: - Updated commit title and message for more clarity (Ashutosh) - Replaced intel_rps_read_rpstat with direct read to GEN12_RPSTAT1 in read_cagf (Ashutosh) v4: Remove GEN12_CAGF_SHIFT and use REG_FIELD_GET (Rodrigo) Cc: Don Hiatt <[email protected]> Cc: Andi Shyti <[email protected]> Signed-off-by: Don Hiatt <[email protected]> Signed-off-by: Badal Nilawar <[email protected]> Signed-off-by: Ashutosh Dixit <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 2c0a284 commit 01b8c2e

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

drivers/gpu/drm/i915/gt/intel_gt_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,7 @@
15451545

15461546
#define GEN12_RPSTAT1 _MMIO(0x1381b4)
15471547
#define GEN12_VOLTAGE_MASK REG_GENMASK(10, 0)
1548+
#define GEN12_CAGF_MASK REG_GENMASK(19, 11)
15481549

15491550
#define GEN11_GT_INTR_DW(x) _MMIO(0x190018 + ((x) * 4))
15501551
#define GEN11_CSME (31)

drivers/gpu/drm/i915/gt/intel_rps.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,12 +2074,34 @@ void intel_rps_sanitize(struct intel_rps *rps)
20742074
rps_disable_interrupts(rps);
20752075
}
20762076

2077+
u32 intel_rps_read_rpstat_fw(struct intel_rps *rps)
2078+
{
2079+
struct drm_i915_private *i915 = rps_to_i915(rps);
2080+
i915_reg_t rpstat;
2081+
2082+
rpstat = (GRAPHICS_VER(i915) >= 12) ? GEN12_RPSTAT1 : GEN6_RPSTAT1;
2083+
2084+
return intel_uncore_read_fw(rps_to_gt(rps)->uncore, rpstat);
2085+
}
2086+
2087+
u32 intel_rps_read_rpstat(struct intel_rps *rps)
2088+
{
2089+
struct drm_i915_private *i915 = rps_to_i915(rps);
2090+
i915_reg_t rpstat;
2091+
2092+
rpstat = (GRAPHICS_VER(i915) >= 12) ? GEN12_RPSTAT1 : GEN6_RPSTAT1;
2093+
2094+
return intel_uncore_read(rps_to_gt(rps)->uncore, rpstat);
2095+
}
2096+
20772097
u32 intel_rps_get_cagf(struct intel_rps *rps, u32 rpstat)
20782098
{
20792099
struct drm_i915_private *i915 = rps_to_i915(rps);
20802100
u32 cagf;
20812101

2082-
if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
2102+
if (GRAPHICS_VER(i915) >= 12)
2103+
cagf = REG_FIELD_GET(GEN12_CAGF_MASK, rpstat);
2104+
else if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
20832105
cagf = REG_FIELD_GET(RPE_MASK, rpstat);
20842106
else if (GRAPHICS_VER(i915) >= 9)
20852107
cagf = REG_FIELD_GET(GEN9_CAGF_MASK, rpstat);
@@ -2099,7 +2121,9 @@ static u32 read_cagf(struct intel_rps *rps)
20992121
struct intel_uncore *uncore = rps_to_uncore(rps);
21002122
u32 freq;
21012123

2102-
if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
2124+
if (GRAPHICS_VER(i915) >= 12) {
2125+
freq = intel_uncore_read(uncore, GEN12_RPSTAT1);
2126+
} else if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
21032127
vlv_punit_get(i915);
21042128
freq = vlv_punit_read(i915, PUNIT_REG_GPU_FREQ_STS);
21052129
vlv_punit_put(i915);
@@ -2265,7 +2289,7 @@ static void rps_frequency_dump(struct intel_rps *rps, struct drm_printer *p)
22652289
rpinclimit = intel_uncore_read(uncore, GEN6_RP_UP_THRESHOLD);
22662290
rpdeclimit = intel_uncore_read(uncore, GEN6_RP_DOWN_THRESHOLD);
22672291

2268-
rpstat = intel_uncore_read(uncore, GEN6_RPSTAT1);
2292+
rpstat = intel_rps_read_rpstat(rps);
22692293
rpcurupei = intel_uncore_read(uncore, GEN6_RP_CUR_UP_EI) & GEN6_CURICONT_MASK;
22702294
rpcurup = intel_uncore_read(uncore, GEN6_RP_CUR_UP) & GEN6_CURBSYTAVG_MASK;
22712295
rpprevup = intel_uncore_read(uncore, GEN6_RP_PREV_UP) & GEN6_CURBSYTAVG_MASK;
@@ -2400,7 +2424,7 @@ static void slpc_frequency_dump(struct intel_rps *rps, struct drm_printer *p)
24002424
drm_printf(p, "PM MASK=0x%08x\n", pm_mask);
24012425
drm_printf(p, "pm_intrmsk_mbz: 0x%08x\n",
24022426
rps->pm_intrmsk_mbz);
2403-
drm_printf(p, "RPSTAT1: 0x%08x\n", intel_uncore_read(uncore, GEN6_RPSTAT1));
2427+
drm_printf(p, "RPSTAT1: 0x%08x\n", intel_rps_read_rpstat(rps));
24042428
drm_printf(p, "RPNSWREQ: %dMHz\n", intel_rps_get_requested_frequency(rps));
24052429
drm_printf(p, "Lowest (RPN) frequency: %dMHz\n",
24062430
intel_gpu_freq(rps, caps.min_freq));

drivers/gpu/drm/i915/gt/intel_rps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ u32 intel_rps_get_rp1_frequency(struct intel_rps *rps);
4848
u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
4949
u32 intel_rps_read_punit_req(struct intel_rps *rps);
5050
u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
51+
u32 intel_rps_read_rpstat(struct intel_rps *rps);
52+
u32 intel_rps_read_rpstat_fw(struct intel_rps *rps);
5153
void gen6_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
5254
void intel_rps_raise_unslice(struct intel_rps *rps);
5355
void intel_rps_lower_unslice(struct intel_rps *rps);

drivers/gpu/drm/i915/i915_pmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ static void
371371
frequency_sample(struct intel_gt *gt, unsigned int period_ns)
372372
{
373373
struct drm_i915_private *i915 = gt->i915;
374-
struct intel_uncore *uncore = gt->uncore;
375374
struct i915_pmu *pmu = &i915->pmu;
376375
struct intel_rps *rps = &gt->rps;
377376

@@ -394,7 +393,7 @@ frequency_sample(struct intel_gt *gt, unsigned int period_ns)
394393
* case we assume the system is running at the intended
395394
* frequency. Fortunately, the read should rarely fail!
396395
*/
397-
val = intel_uncore_read_fw(uncore, GEN6_RPSTAT1);
396+
val = intel_rps_read_rpstat_fw(rps);
398397
if (val)
399398
val = intel_rps_get_cagf(rps, val);
400399
else

0 commit comments

Comments
 (0)