Hello John Zhao,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/34145
to review the following change.
Change subject: src/cpu/intel: Add sanity check for cpu turbo mode capability ......................................................................
src/cpu/intel: Add sanity check for cpu turbo mode capability
It is properly to check cpu turbo mode capability after it is intended for enabling. If processor exhibits the presence of hardware support for turbo, turbo global state will be updated with TURBO_ENABLE. Otherwise, TURBO_UNAVAILABLE is applied to turbo global state.
Change-Id: Ib1bc37fb339b4a0bb6a7cdc6cd4391575b22b55a Signed-off-by: John Zhao john.zhao@intel.com --- M src/cpu/intel/turbo/turbo.c 1 file changed, 16 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/45/34145/1
diff --git a/src/cpu/intel/turbo/turbo.c b/src/cpu/intel/turbo/turbo.c index 12cbfc0..e71c858 100644 --- a/src/cpu/intel/turbo/turbo.c +++ b/src/cpu/intel/turbo/turbo.c @@ -92,7 +92,9 @@ */ void enable_turbo(void) { + struct cpuid_result cpuid_regs; msr_t msr; + int turbo_cap, turbo_state;
/* Only possible if turbo is available but hidden */ if (get_turbo_state() == TURBO_DISABLED) { @@ -101,9 +103,21 @@ msr.hi &= ~H_MISC_DISABLE_TURBO; wrmsr(IA32_MISC_ENABLE, msr);
+ cpuid_regs = cpuid(CPUID_LEAF_PM); + turbo_cap = !!(cpuid_regs.eax & PM_CAP_TURBO_MODE); + + if (!turbo_cap) { + /* Unavailable */ + turbo_state = TURBO_UNAVAILABLE; + printk(BIOS_INFO, "Turbo is unavailable\n"); + } else { + /* Available */ + turbo_state = TURBO_ENABLED; + printk(BIOS_INFO, "Turbo has been enabled\n"); + } + /* Update cached turbo state */ - set_global_turbo_state(TURBO_ENABLED); - printk(BIOS_INFO, "Turbo has been enabled\n"); + set_global_turbo_state(turbo_state); } }