Skip to content

Commit 240a8da

Browse files
spandruvadarafaeljw
authored andcommitted
cpufreq: intel_pstate: Allow model specific EPPs
The current implementation allows model specific EPP override for balanced_performance. Add feature to allow model specific EPP for all predefined EPP strings. For example for some CPU models, even changing performance EPP has benefits Use a mask of EPPs as driver_data instead of just balanced_performance. Signed-off-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 4615ac9 commit 240a8da

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/acpi.h>
2626
#include <linux/vmalloc.h>
2727
#include <linux/pm_qos.h>
28+
#include <linux/bitfield.h>
2829
#include <trace/events/power.h>
2930

3031
#include <asm/cpu.h>
@@ -3401,14 +3402,29 @@ static bool intel_pstate_hwp_is_enabled(void)
34013402
return !!(value & 0x1);
34023403
}
34033404

3404-
static const struct x86_cpu_id intel_epp_balance_perf[] = {
3405+
#define POWERSAVE_MASK GENMASK(7, 0)
3406+
#define BALANCE_POWER_MASK GENMASK(15, 8)
3407+
#define BALANCE_PERFORMANCE_MASK GENMASK(23, 16)
3408+
#define PERFORMANCE_MASK GENMASK(31, 24)
3409+
3410+
#define HWP_SET_EPP_VALUES(powersave, balance_power, balance_perf, performance) \
3411+
(FIELD_PREP_CONST(POWERSAVE_MASK, powersave) |\
3412+
FIELD_PREP_CONST(BALANCE_POWER_MASK, balance_power) |\
3413+
FIELD_PREP_CONST(BALANCE_PERFORMANCE_MASK, balance_perf) |\
3414+
FIELD_PREP_CONST(PERFORMANCE_MASK, performance))
3415+
3416+
#define HWP_SET_DEF_BALANCE_PERF_EPP(balance_perf) \
3417+
(HWP_SET_EPP_VALUES(HWP_EPP_POWERSAVE, HWP_EPP_BALANCE_POWERSAVE,\
3418+
balance_perf, HWP_EPP_PERFORMANCE))
3419+
3420+
static const struct x86_cpu_id intel_epp_default[] = {
34053421
/*
34063422
* Set EPP value as 102, this is the max suggested EPP
34073423
* which can result in one core turbo frequency for
34083424
* AlderLake Mobile CPUs.
34093425
*/
3410-
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, 102),
3411-
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, 32),
3426+
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, HWP_SET_DEF_BALANCE_PERF_EPP(102)),
3427+
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, HWP_SET_DEF_BALANCE_PERF_EPP(32)),
34123428
{}
34133429
};
34143430

@@ -3506,11 +3522,24 @@ static int __init intel_pstate_init(void)
35063522
intel_pstate_sysfs_expose_params();
35073523

35083524
if (hwp_active) {
3509-
const struct x86_cpu_id *id = x86_match_cpu(intel_epp_balance_perf);
3525+
const struct x86_cpu_id *id = x86_match_cpu(intel_epp_default);
35103526
const struct x86_cpu_id *hybrid_id = x86_match_cpu(intel_hybrid_scaling_factor);
35113527

3512-
if (id)
3513-
epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = id->driver_data;
3528+
if (id) {
3529+
epp_values[EPP_INDEX_POWERSAVE] =
3530+
FIELD_GET(POWERSAVE_MASK, id->driver_data);
3531+
epp_values[EPP_INDEX_BALANCE_POWERSAVE] =
3532+
FIELD_GET(BALANCE_POWER_MASK, id->driver_data);
3533+
epp_values[EPP_INDEX_BALANCE_PERFORMANCE] =
3534+
FIELD_GET(BALANCE_PERFORMANCE_MASK, id->driver_data);
3535+
epp_values[EPP_INDEX_PERFORMANCE] =
3536+
FIELD_GET(PERFORMANCE_MASK, id->driver_data);
3537+
pr_debug("Updated EPPs powersave:%x balanced power:%x balanced perf:%x performance:%x\n",
3538+
epp_values[EPP_INDEX_POWERSAVE],
3539+
epp_values[EPP_INDEX_BALANCE_POWERSAVE],
3540+
epp_values[EPP_INDEX_BALANCE_PERFORMANCE],
3541+
epp_values[EPP_INDEX_PERFORMANCE]);
3542+
}
35143543

35153544
if (hybrid_id) {
35163545
hybrid_scaling_factor = hybrid_id->driver_data;

0 commit comments

Comments
 (0)