lost RTC interrupts
PATCH 1/1 lost RTC interrupts
Paul,
The calculation for the number of interrupts lost when the RTC stops generating interrupts seems to be broken for HZ=1000
Also, the following patch returns more accurate lost interrupt data (At the cost of some accounting for every interrupt) Let me know if you think the accounting is unnecessary
Thanks
Dinakar
drivers/char/rtc.c +13 -1
@@ -169,6 +169,9 @@ static unsigned long rtc_freq = 0; /* Custatic unsigned long rtc_irq_data =0 ;/* our output to the world */ static unsigned long rtc_max_user_freq =64 ;/* > this, need CAP_SYS_RESOURCE */ +static unsigned long prev_jiffies =0 ; +static unsigned long rtcticks_in_pjiffies =0 ; +#ifdef RTC_IRQ /* * rtc_task_lock nests inside rtc_lock.
@@ -239,6 +242,12 @@ irqreturn_t rtc_interrupt(int irq, voidspin_unlock (&rtc_lock); +if (jiffies != prev_jiffies) { + prev_jiffies = jiffies; + rtcticks_in_pjiffies =0 ; + } + rtcticks_in_pjiffies++; +/* Now do the rest of the actions */ spin_lock (&rtc_task_lock);if (rtc_callback)
@@ -1094,7 +1103,7 @@ static void rtc_dropped_irq(unsigned lonif (rtc_status &RTC_TIMER_ON )mod_timer (&rtc_irq_timer, jiffies +HZ /rtc_freq +2 *HZ /100 ); - rtc_irq_data += ((rtc_freq/HZ )<<8 ); + rtc_irq_data += ((rtc_freq/HZ *2 *HZ /100 - rtcticks_in_pjiffies)<<8 ); rtc_irq_data &= ~0xff ; rtc_irq_data |= (CMOS_READ (RTC_INTR_FLAGS ) &0xF0 );/* restart */
@@ -1102,6 +1111,9 @@ static void rtc_dropped_irq(unsigned lonspin_unlock_irq (&rtc_lock); + prev_jiffies = jiffies; + rtcticks_in_pjiffies =1 ; +printk (KERN_WARNING "rtc: lost some interrupts at %ldHz.\n" , freq);/* Now we have new data */