aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-03-17 10:58:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-17 10:58:26 -0400
commita6a80e1d8cf82b46a69f88e659da02749231eb36 (patch)
tree307db5dba0a4217e9e3298d74b16593b3674a02e /arch/x86
parent19695ec03d492f1eeb760727d3bd10c7d2f31c1d (diff)
Fix potential fast PIT TSC calibration startup glitch
During bootup, when we reprogram the PIT (programmable interval timer) to start counting down from 0xffff in order to use it for the fast TSC calibration, we should also make sure to delay a bit afterwards to allow the PIT hardware to actually start counting with the new value. That will happens at the next CLK pulse (1.193182 MHz), so the easiest way to do that is to just wait at least one microsecond after programming the new PIT counter value. We do that by just reading the counter value back once - which will take about 2us on PC hardware. Reported-and-tested-by: john stultz <johnstul@us.ibm.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/tsc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 599e58168631..9e80207c96a2 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -315,6 +315,15 @@ static unsigned long quick_pit_calibrate(void)
315 outb(0xff, 0x42); 315 outb(0xff, 0x42);
316 outb(0xff, 0x42); 316 outb(0xff, 0x42);
317 317
318 /*
319 * The PIT starts counting at the next edge, so we
320 * need to delay for a microsecond. The easiest way
321 * to do that is to just read back the 16-bit counter
322 * once from the PIT.
323 */
324 inb(0x42);
325 inb(0x42);
326
318 if (pit_expect_msb(0xff)) { 327 if (pit_expect_msb(0xff)) {
319 int i; 328 int i;
320 u64 t1, t2, delta; 329 u64 t1, t2, delta;