#endif
}
-/*
- * Lost tick detection and compensation
- */
-static inline void detect_lost_tick(void)
-{
- /* read time since last interrupt */
- unsigned long delta = timer->get_offset();
- static unsigned long dbg_print;
-
- /* check if delta is greater then two ticks */
- if(delta >= 2*(1000000/HZ)){
-
- /*
- * only print debug info first 5 times
- */
- /*
- * AKPM: disable this for now; it's nice, but irritating.
- */
- if (0 && dbg_print < 5) {
- printk(KERN_WARNING "\nWarning! Detected %lu "
- "micro-second gap between interrupts.\n",
- delta);
- printk(KERN_WARNING " Compensating for %lu lost "
- "ticks.\n",
- delta/(1000000/HZ)-1);
- dump_stack();
- dbg_print++;
- }
- /* calculate number of missed ticks */
- delta = delta/(1000000/HZ)-1;
- jiffies += delta;
- }
-
-}
-
/*
* This is the same as the above, except we _also_ save the current
* Time Stamp Counter value at the time of the timer interrupt, so that
*/
write_seqlock(&xtime_lock);
- detect_lost_tick();
timer->mark_offset();
do_timer_interrupt(irq, NULL, regs);
#include <asm/fixmap.h>
extern spinlock_t i8253_lock;
+extern unsigned long jiffies;
extern unsigned long calibrate_tsc(void);
/* Number of usecs that the last interrupt was delayed */
static void mark_offset_cyclone(void)
{
+ unsigned long lost, delay;
+ unsigned long delta = last_cyclone_low;
int count;
unsigned long long this_offset, last_offset;
count |= inb(0x40) << 8;
spin_unlock(&i8253_lock);
+ /* lost tick compensation */
+ delta = last_cyclone_low - delta;
+ delta /=(CYCLONE_TIMER_FREQ/1000000);
+ delta += delay_at_last_interrupt;
+ lost = delta/(1000000/HZ);
+ delay = delta%(1000000/HZ);
+ if(lost >= 2)
+ jiffies += lost-1;
+
/* update the monotonic base value */
this_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low;
monotonic_base += (this_offset - last_offset) & CYCLONE_TIMER_MASK;
/* calculate delay_at_last_interrupt */
count = ((LATCH-1) - count) * TICK_SIZE;
delay_at_last_interrupt = (count + LATCH/2) / LATCH;
+
+ /* catch corner case where tick rollover
+ * occured between cyclone and pit reads
+ */
+ if(abs(delay - delay_at_last_interrupt) > 900)
+ jiffies++;
}
static unsigned long get_offset_cyclone(void)
int tsc_disable __initdata = 0;
extern spinlock_t i8253_lock;
+extern unsigned long jiffies;
static int use_tsc;
/* Number of usecs that the last interrupt was delayed */
static void mark_offset_tsc(void)
{
+ unsigned long lost,delay;
+ unsigned long delta = last_tsc_low;
int count;
int countmp;
static int count1 = 0;
}
}
+ /* lost tick compensation */
+ delta = last_tsc_low - delta;
+ {
+ register unsigned long eax, edx;
+ eax = delta;
+ __asm__("mull %2"
+ :"=a" (eax), "=d" (edx)
+ :"rm" (fast_gettimeoffset_quotient),
+ "0" (eax));
+ delta = edx;
+ }
+ delta += delay_at_last_interrupt;
+ lost = delta/(1000000/HZ);
+ delay = delta%(1000000/HZ);
+ if(lost >= 2)
+ jiffies += lost-1;
+
/* update the monotonic base value */
this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
monotonic_base += cycles_2_ns(this_offset - last_offset);
/* calculate delay_at_last_interrupt */
count = ((LATCH-1) - count) * TICK_SIZE;
delay_at_last_interrupt = (count + LATCH/2) / LATCH;
+
+ /* catch corner case where tick rollover
+ * occured between tsc and pit reads
+ */
+ if(abs(delay - delay_at_last_interrupt) > 900)
+ jiffies++;
}
static void delay_tsc(unsigned long loops)