diff options
-rw-r--r-- | arch/x86_64/kernel/time.c | 2 | ||||
-rw-r--r-- | include/asm-i386/hpet.h | 1 | ||||
-rw-r--r-- | include/asm-x86_64/hpet.h | 2 | ||||
-rw-r--r-- | include/linux/jiffies.h | 6 | ||||
-rw-r--r-- | kernel/timer.c | 2 |
5 files changed, 12 insertions, 1 deletions
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 2eeaa95edff0..7392570f975d 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c | |||
@@ -917,6 +917,8 @@ void __init time_init(void) | |||
917 | vxtime.hpet_address = 0; | 917 | vxtime.hpet_address = 0; |
918 | 918 | ||
919 | if (hpet_use_timer) { | 919 | if (hpet_use_timer) { |
920 | /* set tick_nsec to use the proper rate for HPET */ | ||
921 | tick_nsec = TICK_NSEC_HPET; | ||
920 | cpu_khz = hpet_calibrate_tsc(); | 922 | cpu_khz = hpet_calibrate_tsc(); |
921 | timename = "HPET"; | 923 | timename = "HPET"; |
922 | #ifdef CONFIG_X86_PM_TIMER | 924 | #ifdef CONFIG_X86_PM_TIMER |
diff --git a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h index 16ef9f996e3f..7f1a8a6ee32f 100644 --- a/include/asm-i386/hpet.h +++ b/include/asm-i386/hpet.h | |||
@@ -89,6 +89,7 @@ | |||
89 | * then 32 bit HPET counter wrapsaround in less than 0.5 sec. | 89 | * then 32 bit HPET counter wrapsaround in less than 0.5 sec. |
90 | */ | 90 | */ |
91 | #define HPET_MIN_PERIOD (100000UL) | 91 | #define HPET_MIN_PERIOD (100000UL) |
92 | #define HPET_TICK_RATE (HZ * 100000UL) | ||
92 | 93 | ||
93 | extern unsigned long hpet_tick; /* hpet clks count per tick */ | 94 | extern unsigned long hpet_tick; /* hpet clks count per tick */ |
94 | extern unsigned long hpet_address; /* hpet memory map physical address */ | 95 | extern unsigned long hpet_address; /* hpet memory map physical address */ |
diff --git a/include/asm-x86_64/hpet.h b/include/asm-x86_64/hpet.h index 08b75c15269a..18ff7ee9e774 100644 --- a/include/asm-x86_64/hpet.h +++ b/include/asm-x86_64/hpet.h | |||
@@ -51,6 +51,8 @@ | |||
51 | 51 | ||
52 | #define HPET_TN_ROUTE_SHIFT 9 | 52 | #define HPET_TN_ROUTE_SHIFT 9 |
53 | 53 | ||
54 | #define HPET_TICK_RATE (HZ * 100000UL) | ||
55 | |||
54 | extern int is_hpet_enabled(void); | 56 | extern int is_hpet_enabled(void); |
55 | extern int hpet_rtc_timer_init(void); | 57 | extern int hpet_rtc_timer_init(void); |
56 | extern int oem_force_hpet_timer(void); | 58 | extern int oem_force_hpet_timer(void); |
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 | ||
diff --git a/kernel/timer.c b/kernel/timer.c index c3a874f1393c..471ab8710b8f 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -1455,7 +1455,7 @@ static void time_interpolator_update(long delta_nsec) | |||
1455 | */ | 1455 | */ |
1456 | if (jiffies % INTERPOLATOR_ADJUST == 0) | 1456 | if (jiffies % INTERPOLATOR_ADJUST == 0) |
1457 | { | 1457 | { |
1458 | if (time_interpolator->skips == 0 && time_interpolator->offset > TICK_NSEC) | 1458 | if (time_interpolator->skips == 0 && time_interpolator->offset > tick_nsec) |
1459 | time_interpolator->nsec_per_cyc--; | 1459 | time_interpolator->nsec_per_cyc--; |
1460 | if (time_interpolator->ns_skipped > INTERPOLATOR_MAX_SKIP && time_interpolator->offset == 0) | 1460 | if (time_interpolator->ns_skipped > INTERPOLATOR_MAX_SKIP && time_interpolator->offset == 0) |
1461 | time_interpolator->nsec_per_cyc++; | 1461 | time_interpolator->nsec_per_cyc++; |