Skip to content

Commit 4ecc933

Browse files
spandruvadarafaeljw
authored andcommitted
x86: intel_epb: Allow model specific normal EPB value
The current EPB "normal" is defined as 6 and set whenever power-up EPB value is 0. This setting resulted in the desired out of box power and performance for several CPU generations. But this value is not suitable for AlderLake mobile CPUs, as this resulted in higher uncore power. Since EPB is model specific, this is not unreasonable to have different behavior. Allow a capability where "normal" EPB can be redefined. For AlderLake mobile CPUs this desired normal value is 7. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent c9e6606 commit 4ecc933

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

arch/x86/kernel/cpu/intel_epb.c

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/syscore_ops.h>
1717
#include <linux/pm.h>
1818

19+
#include <asm/cpu_device_id.h>
1920
#include <asm/cpufeature.h>
2021
#include <asm/msr.h>
2122

@@ -58,6 +59,22 @@ static DEFINE_PER_CPU(u8, saved_epb);
5859
#define EPB_SAVED 0x10ULL
5960
#define MAX_EPB EPB_MASK
6061

62+
enum energy_perf_value_index {
63+
EPB_INDEX_PERFORMANCE,
64+
EPB_INDEX_BALANCE_PERFORMANCE,
65+
EPB_INDEX_NORMAL,
66+
EPB_INDEX_BALANCE_POWERSAVE,
67+
EPB_INDEX_POWERSAVE,
68+
};
69+
70+
static u8 energ_perf_values[] = {
71+
[EPB_INDEX_PERFORMANCE] = ENERGY_PERF_BIAS_PERFORMANCE,
72+
[EPB_INDEX_BALANCE_PERFORMANCE] = ENERGY_PERF_BIAS_BALANCE_PERFORMANCE,
73+
[EPB_INDEX_NORMAL] = ENERGY_PERF_BIAS_NORMAL,
74+
[EPB_INDEX_BALANCE_POWERSAVE] = ENERGY_PERF_BIAS_BALANCE_POWERSAVE,
75+
[EPB_INDEX_POWERSAVE] = ENERGY_PERF_BIAS_POWERSAVE,
76+
};
77+
6178
static int intel_epb_save(void)
6279
{
6380
u64 epb;
@@ -90,7 +107,7 @@ static void intel_epb_restore(void)
90107
*/
91108
val = epb & EPB_MASK;
92109
if (val == ENERGY_PERF_BIAS_PERFORMANCE) {
93-
val = ENERGY_PERF_BIAS_NORMAL;
110+
val = energ_perf_values[EPB_INDEX_NORMAL];
94111
pr_warn_once("ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\n");
95112
}
96113
}
@@ -103,18 +120,11 @@ static struct syscore_ops intel_epb_syscore_ops = {
103120
};
104121

105122
static const char * const energy_perf_strings[] = {
106-
"performance",
107-
"balance-performance",
108-
"normal",
109-
"balance-power",
110-
"power"
111-
};
112-
static const u8 energ_perf_values[] = {
113-
ENERGY_PERF_BIAS_PERFORMANCE,
114-
ENERGY_PERF_BIAS_BALANCE_PERFORMANCE,
115-
ENERGY_PERF_BIAS_NORMAL,
116-
ENERGY_PERF_BIAS_BALANCE_POWERSAVE,
117-
ENERGY_PERF_BIAS_POWERSAVE
123+
[EPB_INDEX_PERFORMANCE] = "performance",
124+
[EPB_INDEX_BALANCE_PERFORMANCE] = "balance-performance",
125+
[EPB_INDEX_NORMAL] = "normal",
126+
[EPB_INDEX_BALANCE_POWERSAVE] = "balance-power",
127+
[EPB_INDEX_POWERSAVE] = "power",
118128
};
119129

120130
static ssize_t energy_perf_bias_show(struct device *dev,
@@ -193,13 +203,22 @@ static int intel_epb_offline(unsigned int cpu)
193203
return 0;
194204
}
195205

206+
static const struct x86_cpu_id intel_epb_normal[] = {
207+
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, 7),
208+
{}
209+
};
210+
196211
static __init int intel_epb_init(void)
197212
{
213+
const struct x86_cpu_id *id = x86_match_cpu(intel_epb_normal);
198214
int ret;
199215

200216
if (!boot_cpu_has(X86_FEATURE_EPB))
201217
return -ENODEV;
202218

219+
if (id)
220+
energ_perf_values[EPB_INDEX_NORMAL] = id->driver_data;
221+
203222
ret = cpuhp_setup_state(CPUHP_AP_X86_INTEL_EPB_ONLINE,
204223
"x86/intel/epb:online", intel_epb_online,
205224
intel_epb_offline);

0 commit comments

Comments
 (0)