Index: arch/mips/kernel/time.c =================================================================== RCS file: /home/cvs/linux/arch/mips/kernel/time.c,v retrieving revision 1.53 diff -u -r1.53 time.c --- arch/mips/kernel/time.c 17 Apr 2003 22:55:51 -0000 1.53 +++ arch/mips/kernel/time.c 23 Apr 2003 01:01:39 -0000 @@ -148,23 +148,8 @@ /* Cycle counter value at the previous timer interrupt.. */ static unsigned int timerhi, timerlo; -/* - * Cycle counter value after which next timer interrupt is considered "missed". - * Suppose we are serving timer interrupt scheduled at time t, the theorectical - * expiriing point for next interrupt is t + 2 * cycles_per_jiffy. - * In practice, we set it a little earlier, which is - * t + 2 * cycles_per_jiffy - EXTRA_CUSHION_CYCLES - * just to make sure we still have some time to set registers after we - * decide whether a timer interrupt is missed. - */ -static unsigned int expirehi, expirelo; - -/* - * extra "cushion" cycles used when we decide whether we have missed an - * timer interrupt (in the case of using cpu counter). It should be long - * enough to cover at least 20 instructions. - */ -#define EXTRA_CUSHION_CYCLES 200 +/* expirelo is the count value for next CPU timer interrupt */ +static unsigned int expirelo; /* last time when xtime and rtc are sync'ed up */ static long last_rtc_update; @@ -356,41 +341,26 @@ * high-level timer interrupt service routines. This function * is set as irqaction->handler and is invoked through do_IRQ. */ -static inline int -bit64_compare(unsigned hi1, unsigned lo1, unsigned hi2, unsigned lo2) -{ - if (hi1 == hi2) - return lo1 - lo2; - else - return hi1 - hi2; -} - void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { if (cpu_has_counter) { unsigned int count; - /* - * The cycle counter is only 32 bit which is good for about - * a minute at current count rates of upto 150MHz or so. - */ + /* ack timer interrupt, and try to set next interrupt */ + expirelo += cycles_per_jiffy; + write_c0_compare(expirelo); count = read_c0_count(); - timerhi += count < timerlo; /* Wrap around */ - timerlo = count; - /* check to see if we have missed a timer interrupt */ - if (bit64_compare(timerhi, timerlo, expirehi, expirelo) < 0) { - unsigned int old_expirelo=expirelo; - expirelo += cycles_per_jiffy; - expirehi += expirelo < old_expirelo; - write_c0_compare(old_expirelo + EXTRA_CUSHION_CYCLES); - } else { - // missed_timer_count ++; - /* we have missed at least one timer interrupt */ - expirelo = timerlo + cycles_per_jiffy*2 - EXTRA_CUSHION_CYCLES; - expirehi = timerhi + (expirelo < timerlo); - write_c0_compare(timerlo + cycles_per_jiffy); + /* check to see if we have missed any timer interrupts */ + if ((count - expirelo) < 0x7fffffff) { + /* missed_timer_count ++; */ + expirelo = count + cycles_per_jiffy; + write_c0_compare(expirelo); } + + /* Update timerhi/timerlo for intra-jiffy calibration. */ + timerhi += count < timerlo; /* Wrap around */ + timerlo = count; } /* @@ -558,7 +528,7 @@ */ write_c0_compare(cycles_per_jiffy); write_c0_count(0); - expirelo = cycles_per_jiffy * 2 - EXTRA_CUSHION_CYCLES; + expirelo = cycles_per_jiffy; } /* Index: arch/mips64/kernel/time.c =================================================================== RCS file: /home/cvs/linux/arch/mips64/kernel/time.c,v retrieving revision 1.16 diff -u -r1.16 time.c --- arch/mips64/kernel/time.c 17 Apr 2003 22:55:51 -0000 1.16 +++ arch/mips64/kernel/time.c 23 Apr 2003 01:01:39 -0000 @@ -148,23 +148,8 @@ /* Cycle counter value at the previous timer interrupt.. */ static unsigned int timerhi, timerlo; -/* - * Cycle counter value after which next timer interrupt is considered "missed". - * Suppose we are serving timer interrupt scheduled at time t, the theorectical - * expiriing point for next interrupt is t + 2 * cycles_per_jiffy. - * In practice, we set it a little earlier, which is - * t + 2 * cycles_per_jiffy - EXTRA_CUSHION_CYCLES - * just to make sure we still have some time to set registers after we - * decide whether a timer interrupt is missed. - */ -static unsigned int expirehi, expirelo; - -/* - * extra "cushion" cycles used when we decide whether we have missed an - * timer interrupt (in the case of using cpu counter). It should be long - * enough to cover at least 20 instructions. - */ -#define EXTRA_CUSHION_CYCLES 200 +/* expirelo is the count value for next CPU timer interrupt */ +static unsigned int expirelo; /* last time when xtime and rtc are sync'ed up */ static long last_rtc_update; @@ -356,41 +341,26 @@ * high-level timer interrupt service routines. This function * is set as irqaction->handler and is invoked through do_IRQ. */ -static inline int -bit64_compare(unsigned hi1, unsigned lo1, unsigned hi2, unsigned lo2) -{ - if (hi1 == hi2) - return lo1 - lo2; - else - return hi1 - hi2; -} - void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { if (cpu_has_counter) { unsigned int count; - /* - * The cycle counter is only 32 bit which is good for about - * a minute at current count rates of upto 150MHz or so. - */ + /* ack timer interrupt, and try to set next interrupt */ + expirelo += cycles_per_jiffy; + write_c0_compare(expirelo); count = read_c0_count(); - timerhi += count < timerlo; /* Wrap around */ - timerlo = count; - /* check to see if we have missed a timer interrupt */ - if (bit64_compare(timerhi, timerlo, expirehi, expirelo) < 0) { - unsigned int old_expirelo=expirelo; - expirelo += cycles_per_jiffy; - expirehi += expirelo < old_expirelo; - write_c0_compare(old_expirelo + EXTRA_CUSHION_CYCLES); - } else { - // missed_timer_count ++; - /* we have missed at least one timer interrupt */ - expirelo = timerlo + cycles_per_jiffy*2 - EXTRA_CUSHION_CYCLES; - expirehi = timerhi + (expirelo < timerlo); - write_c0_compare(timerlo + cycles_per_jiffy); + /* check to see if we have missed any timer interrupts */ + if ((count - expirelo) < 0x7fffffff) { + /* missed_timer_count ++; */ + expirelo = count + cycles_per_jiffy; + write_c0_compare(expirelo); } + + /* Update timerhi/timerlo for intra-jiffy calibration. */ + timerhi += count < timerlo; /* Wrap around */ + timerlo = count; } /* @@ -558,7 +528,7 @@ */ write_c0_compare(cycles_per_jiffy); write_c0_count(0); - expirelo = cycles_per_jiffy * 2 - EXTRA_CUSHION_CYCLES; + expirelo = cycles_per_jiffy; } /*