public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lost RTC interrupts
@ 2004-06-04 10:44 Dinakar Guniguntala
  0 siblings, 0 replies; only message in thread
From: Dinakar Guniguntala @ 2004-06-04 10:44 UTC (permalink / raw)
  To: p_gortmaker; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

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

[-- Attachment #2: rtc-lost-ticks.patch --]
[-- Type: text/plain, Size: 1533 bytes --]

diff -Naurp linux-2.6.7-rc2/drivers/char/rtc.c linux-2.6.7-rc2-rtc/drivers/char/rtc.c
--- linux-2.6.7-rc2/drivers/char/rtc.c	2004-05-30 11:56:50.000000000 +0530
+++ linux-2.6.7-rc2-rtc/drivers/char/rtc.c	2004-06-03 13:09:04.000000000 +0530
@@ -169,6 +169,9 @@ static unsigned long rtc_freq = 0;	/* Cu
 static 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, void 
 
 	spin_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 lon
 	if (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 lon
 
 	spin_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 */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-04 10:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-04 10:44 [PATCH] lost RTC interrupts Dinakar Guniguntala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox