[PATCH 2.6.13-rc5-gitNOW] msleep() cannot be used from interrupt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Linus,
  can you apply patch below?

Since beginning of July my Opteron box was randomly crashing and being rebooted
by hardware watchdog.  Today it finally did it in front of me, and this patch
will hopefully fix it.

Problem is that at the end of June (28th, commit 
47f176fdaf8924bc83fddcf9658f2fd3ef60d573, [PATCH] Using msleep() instead of HZ) 
rtc_get_rtc_time was converted to use msleep() instead of busy waiting.  But
rtc_get_rtc_time is used by hpet_rtc_interrupt, and scheduling is not allowed
during interrupt.  So I'm reverting this part of original change, replacing
msleep() back with busy loop.

Original old code was busy waiting for 20ms, while on my hardware in the worst
case update-in-progress bit was asserted for at most 363 passes through loop
(on 2GHz dual Opteron), much less than even one jiffie, not even talking
about 20ms.  So I changed code to just wait only as long as necessary.  Otherwise
when RTC was set to generate 8192Hz timer, it stopped doing anything for
20ms (160 pulses were skipped!) from time to time, and this is rather suboptimal
as far as I can tell.

						Thanks,
							Petr Vandrovec


Signed-off-by: Petr Vandrovec <[email protected]>

diff -urdN linux/drivers/char/rtc.c linux/drivers/char/rtc.c
--- linux/drivers/char/rtc.c	2005-08-05 12:43:54.000000000 +0000
+++ linux/drivers/char/rtc.c	2005-08-05 13:26:48.000000000 +0000
@@ -1209,6 +1209,7 @@
 
 void rtc_get_rtc_time(struct rtc_time *rtc_tm)
 {
+	unsigned long uip_watchdog = jiffies;
 	unsigned char ctrl;
 #ifdef CONFIG_MACH_DECSTATION
 	unsigned int real_year;
@@ -1224,8 +1225,10 @@
 	 * Once the read clears, read the RTC time (again via ioctl). Easy.
 	 */
 
-	if (rtc_is_updating() != 0)
-		msleep(20);
+	while (rtc_is_updating() != 0 && jiffies - uip_watchdog < 2*HZ/100) {
+		barrier();
+		cpu_relax();
+	}
 
 	/*
 	 * Only the values that we read from the RTC are set. We leave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux