Commit 403fe5ae authored by Petr Vandrovec's avatar Petr Vandrovec Committed by Linus Torvalds

[PATCH] rtc: msleep() cannot be used from interrupt

Since the 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.

The problem is that at the end of June (the 28th, to be exact: commit
47f176fd, "[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.

The original code was busy waiting for up to 20ms, but 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.
Signed-off-by: default avatarPetr Vandrovec <vandrove@vc.cvut.cz>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2f60f8d3
...@@ -1209,6 +1209,7 @@ static int rtc_proc_open(struct inode *inode, struct file *file) ...@@ -1209,6 +1209,7 @@ static int rtc_proc_open(struct inode *inode, struct file *file)
void rtc_get_rtc_time(struct rtc_time *rtc_tm) void rtc_get_rtc_time(struct rtc_time *rtc_tm)
{ {
unsigned long uip_watchdog = jiffies;
unsigned char ctrl; unsigned char ctrl;
#ifdef CONFIG_MACH_DECSTATION #ifdef CONFIG_MACH_DECSTATION
unsigned int real_year; unsigned int real_year;
...@@ -1224,8 +1225,10 @@ void rtc_get_rtc_time(struct rtc_time *rtc_tm) ...@@ -1224,8 +1225,10 @@ void rtc_get_rtc_time(struct rtc_time *rtc_tm)
* Once the read clears, read the RTC time (again via ioctl). Easy. * Once the read clears, read the RTC time (again via ioctl). Easy.
*/ */
if (rtc_is_updating() != 0) while (rtc_is_updating() != 0 && jiffies - uip_watchdog < 2*HZ/100) {
msleep(20); barrier();
cpu_relax();
}
/* /*
* Only the values that we read from the RTC are set. We leave * Only the values that we read from the RTC are set. We leave
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment