diff options
author | Jordan Crouse <jordan.crouse@amd.com> | 2008-01-22 17:30:16 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-22 17:30:16 -0500 |
commit | 667984d9e481e43a930a478c588dced98cb61fea (patch) | |
tree | 46d16e4d45ebdaca7b01c593bd19d049776568d9 /arch/x86 | |
parent | 889c94a14e38e749c8060f597ee7825ea0764229 (diff) |
x86: GEODE fix a race condition in the MFGPT timer tick
When we set the MFGPT timer tick, there is a chance that we'll
immediately assert an event. If for some reason the IRQ routing
for this clock has been setup for some other purpose, then we
could end up firing an interrupt into the SMM handler or worse.
This rearranges the timer tick init function to initalize the handler
before we set up the MFGPT clock to make sure that even if we get
an event, it will go to the handler.
Furthermore, in the handler we need to make sure that we clear the
event, even if the timer isn't running.
Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>
Tested-by: Arnd Hannemann <hannemann@i4.informatik.rwth-aachen.de>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/mfgpt_32.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86/kernel/mfgpt_32.c b/arch/x86/kernel/mfgpt_32.c index 0ab680f2d9db..3960ab7e1497 100644 --- a/arch/x86/kernel/mfgpt_32.c +++ b/arch/x86/kernel/mfgpt_32.c | |||
@@ -278,12 +278,12 @@ static int mfgpt_next_event(unsigned long delta, struct clock_event_device *evt) | |||
278 | 278 | ||
279 | static irqreturn_t mfgpt_tick(int irq, void *dev_id) | 279 | static irqreturn_t mfgpt_tick(int irq, void *dev_id) |
280 | { | 280 | { |
281 | /* Turn off the clock (and clear the event) */ | ||
282 | mfgpt_disable_timer(mfgpt_event_clock); | ||
283 | |||
281 | if (mfgpt_tick_mode == CLOCK_EVT_MODE_SHUTDOWN) | 284 | if (mfgpt_tick_mode == CLOCK_EVT_MODE_SHUTDOWN) |
282 | return IRQ_HANDLED; | 285 | return IRQ_HANDLED; |
283 | 286 | ||
284 | /* Turn off the clock */ | ||
285 | mfgpt_disable_timer(mfgpt_event_clock); | ||
286 | |||
287 | /* Clear the counter */ | 287 | /* Clear the counter */ |
288 | geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_COUNTER, 0); | 288 | geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_COUNTER, 0); |
289 | 289 | ||
@@ -319,10 +319,6 @@ static int __init mfgpt_timer_setup(void) | |||
319 | } | 319 | } |
320 | 320 | ||
321 | mfgpt_event_clock = timer; | 321 | mfgpt_event_clock = timer; |
322 | /* Set the clock scale and enable the event mode for CMP2 */ | ||
323 | val = MFGPT_SCALE | (3 << 8); | ||
324 | |||
325 | geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_SETUP, val); | ||
326 | 322 | ||
327 | /* Set up the IRQ on the MFGPT side */ | 323 | /* Set up the IRQ on the MFGPT side */ |
328 | if (geode_mfgpt_setup_irq(mfgpt_event_clock, MFGPT_CMP2, irq)) { | 324 | if (geode_mfgpt_setup_irq(mfgpt_event_clock, MFGPT_CMP2, irq)) { |
@@ -339,6 +335,11 @@ static int __init mfgpt_timer_setup(void) | |||
339 | goto err; | 335 | goto err; |
340 | } | 336 | } |
341 | 337 | ||
338 | /* Set the clock scale and enable the event mode for CMP2 */ | ||
339 | val = MFGPT_SCALE | (3 << 8); | ||
340 | |||
341 | geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_SETUP, val); | ||
342 | |||
342 | /* Set up the clock event */ | 343 | /* Set up the clock event */ |
343 | mfgpt_clockevent.mult = div_sc(MFGPT_HZ, NSEC_PER_SEC, 32); | 344 | mfgpt_clockevent.mult = div_sc(MFGPT_HZ, NSEC_PER_SEC, 32); |
344 | mfgpt_clockevent.min_delta_ns = clockevent_delta2ns(0xF, | 345 | mfgpt_clockevent.min_delta_ns = clockevent_delta2ns(0xF, |