Skip to content

Commit e1cab97

Browse files
committed
drm/i915/slpc: Let's fix the PCODE min freq table setup for SLPC
We need to inform PCODE of a desired ring frequencies so PCODE update the memory frequencies to us. rps->min_freq and rps->max_freq are the frequencies used in that request. However they were unset when SLPC was enabled and PCODE never updated the memory freq. v2 (as Suggested by Ashutosh): if SLPC is in use, let's pick the right frequencies from the get_ia_constants instead of the fake init of rps' min and max. v3: don't forget the max <= min return v4: Move all the freq conversion to intel_rps.c. And the max <= min check to where it belongs. v5: (Ashutosh) Fix old comment s/50 HZ/50 MHz and add a doc explaining the "raw format" Fixes: 7ba79a6 ("drm/i915/guc/slpc: Gate Host RPS when SLPC is enabled") Cc: <[email protected]> # v5.15+ Cc: Ashutosh Dixit <[email protected]> Tested-by: Sushma Venkatesh Reddy <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Reviewed-by: Ashutosh Dixit <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 018a7bd) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent edca5a2 commit e1cab97

File tree

3 files changed

+61
-10
lines changed

3 files changed

+61
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "intel_llc.h"
1313
#include "intel_mchbar_regs.h"
1414
#include "intel_pcode.h"
15+
#include "intel_rps.h"
1516

1617
struct ia_constants {
1718
unsigned int min_gpu_freq;
@@ -55,23 +56,15 @@ static bool get_ia_constants(struct intel_llc *llc,
5556
if (!HAS_LLC(i915) || IS_DGFX(i915))
5657
return false;
5758

58-
if (rps->max_freq <= rps->min_freq)
59-
return false;
60-
6159
consts->max_ia_freq = cpu_max_MHz();
6260

6361
consts->min_ring_freq =
6462
intel_uncore_read(llc_to_gt(llc)->uncore, DCLK) & 0xf;
6563
/* convert DDR frequency from units of 266.6MHz to bandwidth */
6664
consts->min_ring_freq = mult_frac(consts->min_ring_freq, 8, 3);
6765

68-
consts->min_gpu_freq = rps->min_freq;
69-
consts->max_gpu_freq = rps->max_freq;
70-
if (GRAPHICS_VER(i915) >= 9) {
71-
/* Convert GT frequency to 50 HZ units */
72-
consts->min_gpu_freq /= GEN9_FREQ_SCALER;
73-
consts->max_gpu_freq /= GEN9_FREQ_SCALER;
74-
}
66+
consts->min_gpu_freq = intel_rps_get_min_raw_freq(rps);
67+
consts->max_gpu_freq = intel_rps_get_max_raw_freq(rps);
7568

7669
return true;
7770
}
@@ -130,6 +123,12 @@ static void gen6_update_ring_freq(struct intel_llc *llc)
130123
if (!get_ia_constants(llc, &consts))
131124
return;
132125

126+
/*
127+
* Although this is unlikely on any platform during initialization,
128+
* let's ensure we don't get accidentally into infinite loop
129+
*/
130+
if (consts.max_gpu_freq <= consts.min_gpu_freq)
131+
return;
133132
/*
134133
* For each potential GPU frequency, load a ring frequency we'd like
135134
* to use for memory access. We do this by specifying the IA frequency

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,31 @@ u32 intel_rps_get_max_frequency(struct intel_rps *rps)
21262126
return intel_gpu_freq(rps, rps->max_freq_softlimit);
21272127
}
21282128

2129+
/**
2130+
* intel_rps_get_max_raw_freq - returns the max frequency in some raw format.
2131+
* @rps: the intel_rps structure
2132+
*
2133+
* Returns the max frequency in a raw format. In newer platforms raw is in
2134+
* units of 50 MHz.
2135+
*/
2136+
u32 intel_rps_get_max_raw_freq(struct intel_rps *rps)
2137+
{
2138+
struct intel_guc_slpc *slpc = rps_to_slpc(rps);
2139+
u32 freq;
2140+
2141+
if (rps_uses_slpc(rps)) {
2142+
return DIV_ROUND_CLOSEST(slpc->rp0_freq,
2143+
GT_FREQUENCY_MULTIPLIER);
2144+
} else {
2145+
freq = rps->max_freq;
2146+
if (GRAPHICS_VER(rps_to_i915(rps)) >= 9) {
2147+
/* Convert GT frequency to 50 MHz units */
2148+
freq /= GEN9_FREQ_SCALER;
2149+
}
2150+
return freq;
2151+
}
2152+
}
2153+
21292154
u32 intel_rps_get_rp0_frequency(struct intel_rps *rps)
21302155
{
21312156
struct intel_guc_slpc *slpc = rps_to_slpc(rps);
@@ -2214,6 +2239,31 @@ u32 intel_rps_get_min_frequency(struct intel_rps *rps)
22142239
return intel_gpu_freq(rps, rps->min_freq_softlimit);
22152240
}
22162241

2242+
/**
2243+
* intel_rps_get_min_raw_freq - returns the min frequency in some raw format.
2244+
* @rps: the intel_rps structure
2245+
*
2246+
* Returns the min frequency in a raw format. In newer platforms raw is in
2247+
* units of 50 MHz.
2248+
*/
2249+
u32 intel_rps_get_min_raw_freq(struct intel_rps *rps)
2250+
{
2251+
struct intel_guc_slpc *slpc = rps_to_slpc(rps);
2252+
u32 freq;
2253+
2254+
if (rps_uses_slpc(rps)) {
2255+
return DIV_ROUND_CLOSEST(slpc->min_freq,
2256+
GT_FREQUENCY_MULTIPLIER);
2257+
} else {
2258+
freq = rps->min_freq;
2259+
if (GRAPHICS_VER(rps_to_i915(rps)) >= 9) {
2260+
/* Convert GT frequency to 50 MHz units */
2261+
freq /= GEN9_FREQ_SCALER;
2262+
}
2263+
return freq;
2264+
}
2265+
}
2266+
22172267
static int set_min_freq(struct intel_rps *rps, u32 val)
22182268
{
22192269
int ret = 0;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ u32 intel_rps_get_cagf(struct intel_rps *rps, u32 rpstat1);
3737
u32 intel_rps_read_actual_frequency(struct intel_rps *rps);
3838
u32 intel_rps_get_requested_frequency(struct intel_rps *rps);
3939
u32 intel_rps_get_min_frequency(struct intel_rps *rps);
40+
u32 intel_rps_get_min_raw_freq(struct intel_rps *rps);
4041
int intel_rps_set_min_frequency(struct intel_rps *rps, u32 val);
4142
u32 intel_rps_get_max_frequency(struct intel_rps *rps);
43+
u32 intel_rps_get_max_raw_freq(struct intel_rps *rps);
4244
int intel_rps_set_max_frequency(struct intel_rps *rps, u32 val);
4345
u32 intel_rps_get_rp0_frequency(struct intel_rps *rps);
4446
u32 intel_rps_get_rp1_frequency(struct intel_rps *rps);

0 commit comments

Comments
 (0)