diff options
author | Jordan Hargrave <jordan_hargrave@dell.com> | 2006-04-07 13:50:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-09 14:53:53 -0400 |
commit | b20367a6c2a0cd937cb1f0a8cf848f1402fef99c (patch) | |
tree | 8624096baed40f8f89e757b2d170a7b4d1844575 /include/linux | |
parent | 49c93e84d8b2d602a07c302c7e3cd4fa09095fbb (diff) |
[PATCH] x86_64: Fix drift with HPET timer enabled
If the HPET timer is enabled, the clock can drift by ~3 seconds a day.
This is due to the HPET timer not being initialized with the correct
setting (still using PIT count).
If HZ changes, this drift can become even more pronounced.
HPET patch initializes tick_nsec with correct tick_nsec settings for
HPET timer.
Vojtech comments:
"It's not entirely correct (it assumes the HPET ticks totally
exactly), but it's significantly better than assuming the PIT error
there."
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/jiffies.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 99905e180532..043376920f51 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
@@ -36,6 +36,8 @@ | |||
36 | /* LATCH is used in the interval timer and ftape setup. */ | 36 | /* LATCH is used in the interval timer and ftape setup. */ |
37 | #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ | 37 | #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ |
38 | 38 | ||
39 | #define LATCH_HPET ((HPET_TICK_RATE + HZ/2) / HZ) | ||
40 | |||
39 | /* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can | 41 | /* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can |
40 | * improve accuracy by shifting LSH bits, hence calculating: | 42 | * improve accuracy by shifting LSH bits, hence calculating: |
41 | * (NOM << LSH) / DEN | 43 | * (NOM << LSH) / DEN |
@@ -51,9 +53,13 @@ | |||
51 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ | 53 | /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ |
52 | #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) | 54 | #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) |
53 | 55 | ||
56 | #define ACTHZ_HPET (SH_DIV (HPET_TICK_RATE, LATCH_HPET, 8)) | ||
57 | |||
54 | /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ | 58 | /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ |
55 | #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) | 59 | #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) |
56 | 60 | ||
61 | #define TICK_NSEC_HPET (SH_DIV(1000000UL * 1000, ACTHZ_HPET, 8)) | ||
62 | |||
57 | /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ | 63 | /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ |
58 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) | 64 | #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) |
59 | 65 | ||