From 459df6697a150e0be5dd0378d98ef54eff520641 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 10 Apr 2019 11:36:58 +0530 Subject: [PATCH] soc/intel/cpulib: Factor out IA32_PERF_CTL (0x199) MSR code This patch replaces multiple IA32_PERF_CTL programming with single helper function. TEST=Build and boot WHL and CML platform. Change-Id: I212daa61aa11191dd832630461b517d3dbedd6e1 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/32281 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans Reviewed-by: Duncan Laurie --- src/soc/intel/common/block/cpu/cpulib.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/soc/intel/common/block/cpu/cpulib.c b/src/soc/intel/common/block/cpu/cpulib.c index c847390d40..9964f2b02c 100644 --- a/src/soc/intel/common/block/cpu/cpulib.c +++ b/src/soc/intel/common/block/cpu/cpulib.c @@ -73,6 +73,13 @@ int cpu_config_tdp_levels(void) return (platform_info.hi >> 1) & 3; } +static void set_perf_control_msr(msr_t msr) +{ + wrmsr(IA32_PERF_CTL, msr); + printk(BIOS_DEBUG, "CPU: frequency set to %d MHz\n", + ((msr.lo >> 8) & 0xff) * CONFIG_CPU_BCLK_MHZ); +} + /* * TURBO_RATIO_LIMIT MSR (0x1AD) Bits 31:0 indicates the * factory configured values for of 1-core, 2-core, 3-core @@ -93,9 +100,7 @@ void cpu_set_p_state_to_turbo_ratio(void) perf_ctl.lo = (msr.lo & 0xff) << 8; perf_ctl.hi = 0; - wrmsr(IA32_PERF_CTL, perf_ctl); - printk(BIOS_DEBUG, "CPU: frequency set to %d MHz\n", - ((perf_ctl.lo >> 8) & 0xff) * CONFIG_CPU_BCLK_MHZ); + set_perf_control_msr(perf_ctl); } /* @@ -113,9 +118,7 @@ void cpu_set_p_state_to_nominal_tdp_ratio(void) perf_ctl.lo = (msr.lo & 0xff) << 8; perf_ctl.hi = 0; - wrmsr(IA32_PERF_CTL, perf_ctl); - printk(BIOS_DEBUG, "CPU: frequency set to %d MHz\n", - ((perf_ctl.lo >> 8) & 0xff) * CONFIG_CPU_BCLK_MHZ); + set_perf_control_msr(perf_ctl); } /* @@ -133,9 +136,7 @@ void cpu_set_p_state_to_max_non_turbo_ratio(void) perf_ctl.lo = msr.lo & 0xff00; perf_ctl.hi = 0; - wrmsr(IA32_PERF_CTL, perf_ctl); - printk(BIOS_DEBUG, "CPU: frequency set to %d MHz\n", - ((perf_ctl.lo >> 8) & 0xff) * CONFIG_CPU_BCLK_MHZ); + set_perf_control_msr(perf_ctl); } /* @@ -152,9 +153,8 @@ void cpu_set_p_state_to_min_clock_ratio(void) min_ratio = cpu_get_min_ratio(); perf_ctl.lo = (min_ratio << 8) & 0xff00; perf_ctl.hi = 0; - wrmsr(IA32_PERF_CTL, perf_ctl); - printk(BIOS_DEBUG, "CPU: frequency set to %u MHz\n", - (min_ratio * CONFIG_CPU_BCLK_MHZ)); + + set_perf_control_msr(perf_ctl); } /*