Commit 112a62dd authored by john stultz's avatar john stultz Committed by Greg Kroah-Hartman

PIT fixes to unbreak suspend/resume (bug #14222)

Resolved differently upstream in commit 8cab02dc

Ondrej Zary reported a suspend/resume hang with 2.6.31 in bug #14222.

http://bugzilla.kernel.org/show_bug.cgi?id=14222

The hang was bisected to c7121843
however, that was really just the last straw that caused the issue.

The problem was that on suspend, the PIT is removed as a clocksource,
and was using the mult value essentially as a is_enabled() flag. The
mult adjustments done in the commit above caused that usage to break,
causing bad list manipulation and the oops.

Further, on resume, the PIT clocksource is never restored, causing the
system to run in a degraded mode with jiffies as the clocksource.

This issue has since been resolved in 2.6.32-rc by commit
8cab02dc which removes the clocksource
disabling on suspend. Testing shows no issues there.

So the following patch rectifies the situation for 2.6.31 users of the
PIT clocksource that use suspend and resume (which is probably not that
many).

Many thanks to Ondrej for helping narrow down what was happening, what
caused it, and verifying the fix.

---------------

Avoid using the unprotected clocksource.mult value as an "is_registered"
flag, instead us an explicit flag variable. This avoids possible list
corruption if the clocksource is double-unregistered.

Also re-register the PIT clocksource on resume so folks don't have to
use jiffies after suspend.
Signed-off-by: default avatarJohn Stultz <johnstul@us.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5a69ea23
...@@ -21,8 +21,10 @@ EXPORT_SYMBOL(i8253_lock); ...@@ -21,8 +21,10 @@ EXPORT_SYMBOL(i8253_lock);
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
static void pit_disable_clocksource(void); static void pit_disable_clocksource(void);
static void pit_enable_clocksource(void);
#else #else
static inline void pit_disable_clocksource(void) { } static inline void pit_disable_clocksource(void) { }
static inline void pit_enable_clocksource(void) { }
#endif #endif
/* /*
...@@ -67,7 +69,7 @@ static void init_pit_timer(enum clock_event_mode mode, ...@@ -67,7 +69,7 @@ static void init_pit_timer(enum clock_event_mode mode,
break; break;
case CLOCK_EVT_MODE_RESUME: case CLOCK_EVT_MODE_RESUME:
/* Nothing to do here */ pit_enable_clocksource();
break; break;
} }
spin_unlock(&i8253_lock); spin_unlock(&i8253_lock);
...@@ -200,19 +202,27 @@ static struct clocksource pit_cs = { ...@@ -200,19 +202,27 @@ static struct clocksource pit_cs = {
.shift = 20, .shift = 20,
}; };
int pit_cs_registered;
static void pit_disable_clocksource(void) static void pit_disable_clocksource(void)
{ {
/* if (pit_cs_registered) {
* Use mult to check whether it is registered or not
*/
if (pit_cs.mult) {
clocksource_unregister(&pit_cs); clocksource_unregister(&pit_cs);
pit_cs.mult = 0; pit_cs_registered = 0;
}
}
static void pit_enable_clocksource(void)
{
if (!pit_cs_registered && !clocksource_register(&pit_cs)) {
pit_cs_registered = 1;
} }
} }
static int __init init_pit_clocksource(void) static int __init init_pit_clocksource(void)
{ {
int ret;
/* /*
* Several reasons not to register PIT as a clocksource: * Several reasons not to register PIT as a clocksource:
* *
...@@ -226,7 +236,10 @@ static int __init init_pit_clocksource(void) ...@@ -226,7 +236,10 @@ static int __init init_pit_clocksource(void)
pit_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, pit_cs.shift); pit_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, pit_cs.shift);
return clocksource_register(&pit_cs); ret = clocksource_register(&pit_cs);
if (!ret)
pit_cs_registered = 1;
return ret;
} }
arch_initcall(init_pit_clocksource); arch_initcall(init_pit_clocksource);
......
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