Skip to content

Commit f5c8cf2

Browse files
committed
cpufreq: intel_pstate: hybrid: Use known scaling factor for P-cores
Commit 46573fd ("cpufreq: intel_pstate: hybrid: Rework HWP calibration") attempted to use the information from CPPC (the nominal performance in particular) to obtain the scaling factor allowing the frequency to be computed if the HWP performance level of the given CPU is known or vice versa. However, it turns out that on some platforms this doesn't work, because the CPPC information on them does not align with the contents of the MSR_HWP_CAPABILITIES registers. This basically means that the only way to make intel_pstate work on all of the hybrid platforms to date is to use the observation that on all of them the scaling factor between the HWP performance levels and frequency for P-cores is 78741 (approximately 100000/1.27). For E-cores it is 100000, which is the same as for all of the non-hybrid "core" platforms and does not require any changes. Accordingly, make intel_pstate use 78741 as the scaling factor between HWP performance levels and frequency for P-cores on all hybrid platforms and drop the dependency of the HWP calibration code on CPPC. Fixes: 46573fd ("cpufreq: intel_pstate: hybrid: Rework HWP calibration") Reported-by: Srinivas Pandruvada <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Tested-by: Srinivas Pandruvada <[email protected]> Cc: 5.15+ <[email protected]> # 5.15+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8dbab94 commit f5c8cf2

File tree

1 file changed

+15
-54
lines changed

1 file changed

+15
-54
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/pm_qos.h>
2828
#include <trace/events/power.h>
2929

30+
#include <asm/cpu.h>
3031
#include <asm/div64.h>
3132
#include <asm/msr.h>
3233
#include <asm/cpu_device_id.h>
@@ -398,16 +399,6 @@ static int intel_pstate_get_cppc_guaranteed(int cpu)
398399

399400
return cppc_perf.nominal_perf;
400401
}
401-
402-
static u32 intel_pstate_cppc_nominal(int cpu)
403-
{
404-
u64 nominal_perf;
405-
406-
if (cppc_get_nominal_perf(cpu, &nominal_perf))
407-
return 0;
408-
409-
return nominal_perf;
410-
}
411402
#else /* CONFIG_ACPI_CPPC_LIB */
412403
static inline void intel_pstate_set_itmt_prio(int cpu)
413404
{
@@ -532,34 +523,17 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
532523
int perf_ctl_max_phys = cpu->pstate.max_pstate_physical;
533524
int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling;
534525
int perf_ctl_turbo = pstate_funcs.get_turbo(cpu->cpu);
535-
int turbo_freq = perf_ctl_turbo * perf_ctl_scaling;
536526
int scaling = cpu->pstate.scaling;
537527

538528
pr_debug("CPU%d: perf_ctl_max_phys = %d\n", cpu->cpu, perf_ctl_max_phys);
539-
pr_debug("CPU%d: perf_ctl_max = %d\n", cpu->cpu, pstate_funcs.get_max(cpu->cpu));
540529
pr_debug("CPU%d: perf_ctl_turbo = %d\n", cpu->cpu, perf_ctl_turbo);
541530
pr_debug("CPU%d: perf_ctl_scaling = %d\n", cpu->cpu, perf_ctl_scaling);
542531
pr_debug("CPU%d: HWP_CAP guaranteed = %d\n", cpu->cpu, cpu->pstate.max_pstate);
543532
pr_debug("CPU%d: HWP_CAP highest = %d\n", cpu->cpu, cpu->pstate.turbo_pstate);
544533
pr_debug("CPU%d: HWP-to-frequency scaling factor: %d\n", cpu->cpu, scaling);
545534

546-
/*
547-
* If the product of the HWP performance scaling factor and the HWP_CAP
548-
* highest performance is greater than the maximum turbo frequency
549-
* corresponding to the pstate_funcs.get_turbo() return value, the
550-
* scaling factor is too high, so recompute it to make the HWP_CAP
551-
* highest performance correspond to the maximum turbo frequency.
552-
*/
553-
cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * scaling;
554-
if (turbo_freq < cpu->pstate.turbo_freq) {
555-
cpu->pstate.turbo_freq = turbo_freq;
556-
scaling = DIV_ROUND_UP(turbo_freq, cpu->pstate.turbo_pstate);
557-
cpu->pstate.scaling = scaling;
558-
559-
pr_debug("CPU%d: refined HWP-to-frequency scaling factor: %d\n",
560-
cpu->cpu, scaling);
561-
}
562-
535+
cpu->pstate.turbo_freq = rounddown(cpu->pstate.turbo_pstate * scaling,
536+
perf_ctl_scaling);
563537
cpu->pstate.max_freq = rounddown(cpu->pstate.max_pstate * scaling,
564538
perf_ctl_scaling);
565539

@@ -1965,37 +1939,24 @@ static int knl_get_turbo_pstate(int cpu)
19651939
return ret;
19661940
}
19671941

1968-
#ifdef CONFIG_ACPI_CPPC_LIB
1969-
static u32 hybrid_ref_perf;
1970-
1971-
static int hybrid_get_cpu_scaling(int cpu)
1942+
static void hybrid_get_type(void *data)
19721943
{
1973-
return DIV_ROUND_UP(core_get_scaling() * hybrid_ref_perf,
1974-
intel_pstate_cppc_nominal(cpu));
1944+
u8 *cpu_type = data;
1945+
1946+
*cpu_type = get_this_hybrid_cpu_type();
19751947
}
19761948

1977-
static void intel_pstate_cppc_set_cpu_scaling(void)
1949+
static int hybrid_get_cpu_scaling(int cpu)
19781950
{
1979-
u32 min_nominal_perf = U32_MAX;
1980-
int cpu;
1951+
u8 cpu_type = 0;
19811952

1982-
for_each_present_cpu(cpu) {
1983-
u32 nominal_perf = intel_pstate_cppc_nominal(cpu);
1953+
smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1);
1954+
/* P-cores have a smaller perf level-to-freqency scaling factor. */
1955+
if (cpu_type == 0x40)
1956+
return 78741;
19841957

1985-
if (nominal_perf && nominal_perf < min_nominal_perf)
1986-
min_nominal_perf = nominal_perf;
1987-
}
1988-
1989-
if (min_nominal_perf < U32_MAX) {
1990-
hybrid_ref_perf = min_nominal_perf;
1991-
pstate_funcs.get_cpu_scaling = hybrid_get_cpu_scaling;
1992-
}
1958+
return core_get_scaling();
19931959
}
1994-
#else
1995-
static inline void intel_pstate_cppc_set_cpu_scaling(void)
1996-
{
1997-
}
1998-
#endif /* CONFIG_ACPI_CPPC_LIB */
19991960

20001961
static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
20011962
{
@@ -3450,7 +3411,7 @@ static int __init intel_pstate_init(void)
34503411
default_driver = &intel_pstate;
34513412

34523413
if (boot_cpu_has(X86_FEATURE_HYBRID_CPU))
3453-
intel_pstate_cppc_set_cpu_scaling();
3414+
pstate_funcs.get_cpu_scaling = hybrid_get_cpu_scaling;
34543415

34553416
goto hwp_cpu_matched;
34563417
}

0 commit comments

Comments
 (0)