aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-06-03 03:39:46 -0400
committerThomas Gleixner <tglx@linutronix.de>2015-07-06 03:41:00 -0400
commit5aac644a9944bea93b4f05ced1883a902a2535f6 (patch)
tree4e6e013b1d10f267d646b05ae84ec795f426e323
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
x86/tsc: Let high latency PIT fail fast in quick_pit_calibrate()
If it takes longer than 12us to read the PIT counter lsb/msb, then the error margin will never fall below 500ppm within 50ms, and Fast TSC calibration will always fail. This patch detects when that will happen and fails fast. Note the failure message is not printed in that case because: 1. it will always happen on that class of hardware 2. the absence of the message is more informative than its presence Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Len Brown <lenb@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/556EB717.9070607@intel.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/kernel/tsc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 505449700e0c..7437b41f6a47 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -598,10 +598,19 @@ static unsigned long quick_pit_calibrate(void)
598 if (!pit_expect_msb(0xff-i, &delta, &d2)) 598 if (!pit_expect_msb(0xff-i, &delta, &d2))
599 break; 599 break;
600 600
601 delta -= tsc;
602
603 /*
604 * Extrapolate the error and fail fast if the error will
605 * never be below 500 ppm.
606 */
607 if (i == 1 &&
608 d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11)
609 return 0;
610
601 /* 611 /*
602 * Iterate until the error is less than 500 ppm 612 * Iterate until the error is less than 500 ppm
603 */ 613 */
604 delta -= tsc;
605 if (d1+d2 >= delta >> 11) 614 if (d1+d2 >= delta >> 11)
606 continue; 615 continue;
607 616