x86: Initialize IA32_MSR_ENERGY_PERF_BIAS

The lowest 4 bits of the MSR serves as a hint to the hardware to
favor performance or energy saving. 0 means a hint preference for
highest performance while 15 corresponds to the maximum energy
savings. A value of 7 translates into a hint to balance performance
with energy savings.

The default reset value of the MSR is 0. If BIOS doesn't intialize
the MSR, the hardware will run in performance state. This patch
initialize the MSR with value of 7 for balance between performance
and energy savings

Signed-off-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
This commit is contained in:
Yongcong Du 2012-04-03 23:46:51 +08:00 committed by Fredrik Holmqvist
parent 17ce10a770
commit 19187c464b
2 changed files with 21 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#define IA32_MSR_SYSENTER_CS 0x174
#define IA32_MSR_SYSENTER_ESP 0x175
#define IA32_MSR_SYSENTER_EIP 0x176
#define IA32_MSR_ENERGY_PERF_BIAS 0x1b0
#define IA32_MSR_MTRR_DEFAULT_TYPE 0x2ff
#define IA32_MSR_MTRR_PHYSICAL_BASE_0 0x200
#define IA32_MSR_MTRR_PHYSICAL_MASK_0 0x201

View File

@ -70,6 +70,16 @@ static const struct cpu_vendor_info vendor_info[VENDOR_NUM] = {
#define K8_CMPHALT (K8_SMIONCMPHALT | K8_C1EONCMPHALT)
/*
* 0 favors highest performance while 15 corresponds to the maximum energy
* savings. 7 means balance between performance and energy savings.
* Refer to Section 14.3.4 in <Intel 64 and IA-32 Architectures Software
* Developer's Manual Volume 3> for details
*/
#define ENERGY_PERF_BIAS_PERFORMANCE 0
#define ENERGY_PERF_BIAS_BALANCE 7
#define ENERGY_PERF_BIAS_POWERSAVE 15
struct set_mtrr_parameter {
int32 index;
uint64 base;
@ -787,6 +797,16 @@ arch_cpu_init_percpu(kernel_args *args, int cpu)
else
gCpuIdleFunc = halt_idle;
}
if (x86_check_feature(IA32_FEATURE_EPB, FEATURE_6_ECX)) {
uint64 msr = x86_read_msr(IA32_MSR_ENERGY_PERF_BIAS);
if ((msr & 0xf) == ENERGY_PERF_BIAS_PERFORMANCE) {
msr &= ~0xf;
msr |= ENERGY_PERF_BIAS_BALANCE;
x86_write_msr(IA32_MSR_ENERGY_PERF_BIAS, msr);
}
}
return 0;
}