Newer processors implement cpuid extension to determine CPU frequency from cpuid. This patch adds a function that can do this early in boot.
Signed-off-by: Pavel Tatashin <pasha.tatas...@oracle.com> --- arch/x86/kernel/tsc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 1c9fc23..58bd575 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -743,14 +743,14 @@ unsigned long native_calibrate_tsc(void) return tsc_khz; } -static unsigned long cpu_khz_from_cpuid(void) +static unsigned long cpu_khz_from_cpuid_early(int vendor, int cpuid_level) { unsigned int eax_base_mhz, ebx_max_mhz, ecx_bus_mhz, edx; - if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) + if (vendor != X86_VENDOR_INTEL) return 0; - if (boot_cpu_data.cpuid_level < 0x16) + if (cpuid_level < 0x16) return 0; eax_base_mhz = ebx_max_mhz = ecx_bus_mhz = edx = 0; @@ -770,7 +770,9 @@ unsigned long native_calibrate_cpu(void) unsigned long flags, latch, ms, fast_calibrate; int hpet = is_hpet_enabled(), i, loopmin; - fast_calibrate = cpu_khz_from_cpuid(); + fast_calibrate = cpu_khz_from_cpuid_early(boot_cpu_data.x86_vendor, + boot_cpu_data.cpuid_level); + if (fast_calibrate) return fast_calibrate; -- 1.8.3.1