]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/tsc: Enumerate BXT tsc_khz via CPUID
authorLen Brown <len.brown@intel.com>
Fri, 17 Jun 2016 05:22:52 +0000 (01:22 -0400)
committerIngo Molnar <mingo@kernel.org>
Mon, 11 Jul 2016 19:30:13 +0000 (21:30 +0200)
Hard code the BXT crystal clock (aka ART - Always Running Timer)
to 19.200 MHz, and use CPUID leaf 0x15 to determine the BXT TSC frequency.

Use tsc_khz to sanity check BXT cpu_khz,
which can be erroneous in some configurations.

(I simplified the original patch from Bin Gao.)

Original-From: Bin Gao <bin.gao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/bf4e7c175acd6d09719c47c319b10ff1f0627ff8.1466138954.git.len.brown@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/tsc.c

index e1496b79c28ac874713fb6a2ea51a434ad42d026..2a952fcb1516357023469fb5f5921cb79876220d 100644 (file)
@@ -693,7 +693,11 @@ unsigned long native_calibrate_tsc(void)
                switch (boot_cpu_data.x86_model) {
                case 0x4E:      /* SKL */
                case 0x5E:      /* SKL */
-                       crystal_khz = 24000;    /* 24 MHz */
+                       crystal_khz = 24000;    /* 24.0 MHz */
+                       break;
+               case 0x5C:      /* BXT */
+                       crystal_khz = 19200;    /* 19.2 MHz */
+                       break;
                }
        }
 
@@ -895,6 +899,8 @@ int recalibrate_cpu_khz(void)
        tsc_khz = x86_platform.calibrate_tsc();
        if (tsc_khz == 0)
                tsc_khz = cpu_khz;
+       else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz)
+               cpu_khz = tsc_khz;
        cpu_data(0).loops_per_jiffy = cpufreq_scale(cpu_data(0).loops_per_jiffy,
                                                    cpu_khz_old, cpu_khz);
 
@@ -1302,8 +1308,16 @@ void __init tsc_init(void)
 
        cpu_khz = x86_platform.calibrate_cpu();
        tsc_khz = x86_platform.calibrate_tsc();
+
+       /*
+        * Trust non-zero tsc_khz as authorative,
+        * and use it to sanity check cpu_khz,
+        * which will be off if system timer is off.
+        */
        if (tsc_khz == 0)
                tsc_khz = cpu_khz;
+       else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz)
+               cpu_khz = tsc_khz;
 
        if (!tsc_khz) {
                mark_tsc_unstable("could not calculate TSC khz");