x86/tsc: Mark TSC frequency determined by CPUID as known
authorBin Gao <bin.gao@linux.intel.com>
Tue, 15 Nov 2016 20:27:22 +0000 (12:27 -0800)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 18 Nov 2016 09:58:30 +0000 (10:58 +0100)
CPUs/SoCs with CPUID leaf 0x15 come with a known frequency and will report
the frequency to software via CPUID instruction. This hardware provided
frequency is the "real" frequency of TSC.

Set the X86_FEATURE_TSC_KNOWN_FREQ flag for such systems to skip the
software calibration process.

A 24 hours test on one of the CPUID 0x15 capable platforms was
conducted. PIT calibrated frequency resulted in more than 3 seconds drift
whereas the CPUID determined frequency showed less than 0.5 second
drift.

Signed-off-by: Bin Gao <bin.gao@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1479241644-234277-3-git-send-email-bin.gao@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/tsc.c

index d2c4ee4e486677d2756925dd9fc506fd71b1956d..e58c31959666cac9a3c608c4cf9c28b01b8ac6c0 100644 (file)
@@ -702,6 +702,13 @@ unsigned long native_calibrate_tsc(void)
                }
        }
 
+       /*
+        * TSC frequency determined by CPUID is a "hardware reported"
+        * frequency and is the most accurate one so far we have. This
+        * is considered a known frequency.
+        */
+       setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+
        return crystal_khz * ebx_numerator / eax_denominator;
 }