From: Andrew Morton Dopey div-by-zero workaround for HPET fallback. 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 --- 25/arch/x86_64/kernel/time.c~x86_64-div-by-zero-fix 2005-06-20 20:57:50.000000000 -0700 +++ 25-akpm/arch/x86_64/kernel/time.c 2005-06-20 21:25:58.000000000 -0700 @@ -76,6 +76,11 @@ unsigned long __wall_jiffies __section_w struct timespec __xtime __section_xtime; struct timezone __sys_tz __section_sys_tz; +static inline unsigned long fixed_hpet_tick(void) +{ + return hpet_tick ? hpet_tick : 1; +} + static inline void rdtscll_sync(unsigned long *tsc) { #ifdef CONFIG_SMP @@ -308,7 +313,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 { @@ -403,11 +408,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 _