diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-09 17:20:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-12 12:53:39 -0400 |
commit | 4936a3b90d79dd8775c6ac23c2cf2dcebe29abde (patch) | |
tree | ab4fb288fd00bb50b5aebcc93fa476cc2c1d53be | |
parent | deda2e81961e96be4f2c09328baca4710a2fd1a0 (diff) |
x86/hpet: Use the FSEC_PER_SEC constant for femto-second periods
The current computation, introduced with f12a15be63, of FSEC_PER_SEC using
the multiplication of (FSEC_PER_NSEC * NSEC_PER_SEC) is performed only
with 32bit integers on small machines, resulting in an overflow and a
*very* short intervals being programmed. An interrupt storm follows.
Note that we also have to specify FSEC_PER_SEC as being long long to
overcome the same limitations.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/kernel/hpet.c | 4 | ||||
-rw-r--r-- | include/linux/time.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 33dbcc4ec5ff..351f9c0fea1f 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c | |||
@@ -582,7 +582,7 @@ static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu) | |||
582 | * scaled math multiplication factor for nanosecond to hpet tick | 582 | * scaled math multiplication factor for nanosecond to hpet tick |
583 | * conversion. | 583 | * conversion. |
584 | */ | 584 | */ |
585 | hpet_freq = 1000000000000000ULL; | 585 | hpet_freq = FSEC_PER_SEC; |
586 | do_div(hpet_freq, hpet_period); | 586 | do_div(hpet_freq, hpet_period); |
587 | evt->mult = div_sc((unsigned long) hpet_freq, | 587 | evt->mult = div_sc((unsigned long) hpet_freq, |
588 | NSEC_PER_SEC, evt->shift); | 588 | NSEC_PER_SEC, evt->shift); |
@@ -837,7 +837,7 @@ static int hpet_clocksource_register(void) | |||
837 | * cyc/sec = FSEC_PER_SEC/hpet_period(fsec/cyc) | 837 | * cyc/sec = FSEC_PER_SEC/hpet_period(fsec/cyc) |
838 | * cyc/sec = (FSEC_PER_NSEC * NSEC_PER_SEC)/hpet_period | 838 | * cyc/sec = (FSEC_PER_NSEC * NSEC_PER_SEC)/hpet_period |
839 | */ | 839 | */ |
840 | hpet_freq = FSEC_PER_NSEC * NSEC_PER_SEC; | 840 | hpet_freq = FSEC_PER_SEC; |
841 | do_div(hpet_freq, hpet_period); | 841 | do_div(hpet_freq, hpet_period); |
842 | clocksource_register_hz(&clocksource_hpet, (u32)hpet_freq); | 842 | clocksource_register_hz(&clocksource_hpet, (u32)hpet_freq); |
843 | 843 | ||
diff --git a/include/linux/time.h b/include/linux/time.h index cb34e35fabac..12612701b1ae 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -38,7 +38,7 @@ extern struct timezone sys_tz; | |||
38 | #define NSEC_PER_MSEC 1000000L | 38 | #define NSEC_PER_MSEC 1000000L |
39 | #define USEC_PER_SEC 1000000L | 39 | #define USEC_PER_SEC 1000000L |
40 | #define NSEC_PER_SEC 1000000000L | 40 | #define NSEC_PER_SEC 1000000000L |
41 | #define FSEC_PER_SEC 1000000000000000L | 41 | #define FSEC_PER_SEC 1000000000000000LL |
42 | 42 | ||
43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) | 43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) |
44 | 44 | ||