From: Andrew Morton Dopey div-by-zero workaround for HPET fallback. http://lkml.org/lkml/2005/6/8/34 Cc: Robert Picco Cc: "Pallipadi, Venkatesh" Signed-off-by: Andrew Morton --- arch/x86_64/kernel/time.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff -puN arch/x86_64/kernel/time.c~x86_64-div-by-zero-fix arch/x86_64/kernel/time.c --- devel/arch/x86_64/kernel/time.c~x86_64-div-by-zero-fix 2005-09-20 00:43:32.000000000 -0700 +++ devel-akpm/arch/x86_64/kernel/time.c 2005-09-20 00:44:05.000000000 -0700 @@ -91,6 +91,11 @@ int xprintk_count = 200; static int enable_xprintk(char *s) { xprintk = 1; return 0; } __setup("xprintk",enable_xprintk); +static inline unsigned long fixed_hpet_tick(void) +{ + return hpet_tick ? hpet_tick : 1; +} + /* * do_gettimeoffset() returns microseconds since last timer interrupt was * triggered by hardware. A memory read of HPET is slower than a register read @@ -319,7 +324,7 @@ unsigned long long monotonic_clock(void) this_offset = hpet_readl(HPET_COUNTER); } while (read_seqretry(&xtime_lock, seq)); offset = (this_offset - last_offset); - offset *=(NSEC_PER_SEC/HZ)/hpet_tick; + offset *=(NSEC_PER_SEC/HZ)/fixed_hpet_tick(); return base + offset; }else{ do { @@ -424,11 +429,11 @@ int main_timer_handler(struct pt_regs *r if (vxtime.mode == VXTIME_HPET) { if (offset - vxtime.last > hpet_tick) { - lost = (offset - vxtime.last) / hpet_tick - 1; + lost = (offset - vxtime.last) / fixed_hpet_tick() - 1; } - monotonic_base += - (offset - vxtime.last)*(NSEC_PER_SEC/HZ) / hpet_tick; + monotonic_base += (offset - vxtime.last)*(NSEC_PER_SEC/HZ) / + fixed_hpet_tick(); vxtime.last = offset; #ifdef CONFIG_X86_PM_TIMER _