Commit 1a0c009a authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Ingo Molnar

x86: unregister PIT clocksource when PIT is disabled

The following scenario might leave PIT as a disfunctional clock source:

    PIT is registered as clocksource
    PM_TIMER is registered as clocksource and enables highres/dyntick mode
    PIT is switched to oneshot mode
    -> now the readout of PIT is bogus, but the user might select PIT
    via the sysfs override, which would break the box as the time
    readout is unusable.

Unregister the PIT clocksource when the PIT clock event device is switched
into shutdown / oneshot mode.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 4713e22c
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
DEFINE_SPINLOCK(i8253_lock); DEFINE_SPINLOCK(i8253_lock);
EXPORT_SYMBOL(i8253_lock); EXPORT_SYMBOL(i8253_lock);
#ifdef CONFIG_X86_32
static void pit_disable_clocksource(void);
#else
static inline void pit_disable_clocksource(void) { }
#endif
/* /*
* HPET replaces the PIT, when enabled. So we need to know, which of * HPET replaces the PIT, when enabled. So we need to know, which of
* the two timers is used * the two timers is used
...@@ -52,11 +58,13 @@ static void init_pit_timer(enum clock_event_mode mode, ...@@ -52,11 +58,13 @@ static void init_pit_timer(enum clock_event_mode mode,
outb_p(0, PIT_CH0); outb_p(0, PIT_CH0);
outb_p(0, PIT_CH0); outb_p(0, PIT_CH0);
} }
pit_disable_clocksource();
break; break;
case CLOCK_EVT_MODE_ONESHOT: case CLOCK_EVT_MODE_ONESHOT:
/* One shot setup */ /* One shot setup */
outb_p(0x38, PIT_MODE); outb_p(0x38, PIT_MODE);
pit_disable_clocksource();
break; break;
case CLOCK_EVT_MODE_RESUME: case CLOCK_EVT_MODE_RESUME:
...@@ -196,6 +204,17 @@ static struct clocksource clocksource_pit = { ...@@ -196,6 +204,17 @@ static struct clocksource clocksource_pit = {
.shift = 20, .shift = 20,
}; };
static void pit_disable_clocksource(void)
{
/*
* Use mult to check whether it is registered or not
*/
if (clocksource_pit.mult) {
clocksource_unregister(&clocksource_pit);
clocksource_pit.mult = 0;
}
}
static int __init init_pit_clocksource(void) static int __init init_pit_clocksource(void)
{ {
/* /*
......
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