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-11-05 02:23:18.000000000 -0800 +++ devel-akpm/arch/x86_64/kernel/time.c 2005-11-05 02:23:18.000000000 -0800 @@ -79,6 +79,11 @@ static inline void rdtscll_sync(unsigned rdtscll(*tsc); } +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 @@ -300,7 +305,7 @@ unsigned long long monotonic_clock(void) } 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 { @@ -395,11 +400,11 @@ static irqreturn_t timer_interrupt(int i 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 _