diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-09-16 14:32:50 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-09-16 16:47:02 -0400 |
commit | 2344abbcbdb82140050e8be29d3d55e4f6fe860b (patch) | |
tree | 46c1842fc2a47aa4d7ee0c2c558f54bc50772b69 /kernel | |
parent | f1926ce63b996b42772b39e4b47bb4ef4ba748b4 (diff) |
clockevents: make device shutdown robust
The device shut down does not cleanup the next_event variable of the
clock event device. So when the device is reactivated the possible
stale next_event value can prevent the device to be reprogrammed as it
claims to wait on a event already.
This is the root cause of the resurfacing suspend/resume problem,
where systems need key press to come back to life.
Fix this by setting next_event to KTIME_MAX when the device is shut
down. Use a separate function for shutdown which takes care of that
and only keep the direct set mode call in the broadcast code, where we
can not touch the next_event value.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/clockevents.c | 12 | ||||
-rw-r--r-- | kernel/time/tick-broadcast.c | 9 | ||||
-rw-r--r-- | kernel/time/tick-common.c | 4 | ||||
-rw-r--r-- | kernel/time/tick-internal.h | 2 |
4 files changed, 19 insertions, 8 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 1876b526c778..f8d968063cea 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -72,6 +72,16 @@ void clockevents_set_mode(struct clock_event_device *dev, | |||
72 | } | 72 | } |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * clockevents_shutdown - shutdown the device and clear next_event | ||
76 | * @dev: device to shutdown | ||
77 | */ | ||
78 | void clockevents_shutdown(struct clock_event_device *dev) | ||
79 | { | ||
80 | clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN); | ||
81 | dev->next_event.tv64 = KTIME_MAX; | ||
82 | } | ||
83 | |||
84 | /** | ||
75 | * clockevents_program_event - Reprogram the clock event device. | 85 | * clockevents_program_event - Reprogram the clock event device. |
76 | * @expires: absolute expiry time (monotonic clock) | 86 | * @expires: absolute expiry time (monotonic clock) |
77 | * | 87 | * |
@@ -206,7 +216,7 @@ void clockevents_exchange_device(struct clock_event_device *old, | |||
206 | 216 | ||
207 | if (new) { | 217 | if (new) { |
208 | BUG_ON(new->mode != CLOCK_EVT_MODE_UNUSED); | 218 | BUG_ON(new->mode != CLOCK_EVT_MODE_UNUSED); |
209 | clockevents_set_mode(new, CLOCK_EVT_MODE_SHUTDOWN); | 219 | clockevents_shutdown(new); |
210 | } | 220 | } |
211 | local_irq_restore(flags); | 221 | local_irq_restore(flags); |
212 | } | 222 | } |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index 2f5a38294bf9..f1f3eee28113 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
@@ -236,8 +236,7 @@ static void tick_do_broadcast_on_off(void *why) | |||
236 | if (!cpu_isset(cpu, tick_broadcast_mask)) { | 236 | if (!cpu_isset(cpu, tick_broadcast_mask)) { |
237 | cpu_set(cpu, tick_broadcast_mask); | 237 | cpu_set(cpu, tick_broadcast_mask); |
238 | if (td->mode == TICKDEV_MODE_PERIODIC) | 238 | if (td->mode == TICKDEV_MODE_PERIODIC) |
239 | clockevents_set_mode(dev, | 239 | clockevents_shutdown(dev); |
240 | CLOCK_EVT_MODE_SHUTDOWN); | ||
241 | } | 240 | } |
242 | if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE) | 241 | if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE) |
243 | tick_broadcast_force = 1; | 242 | tick_broadcast_force = 1; |
@@ -254,7 +253,7 @@ static void tick_do_broadcast_on_off(void *why) | |||
254 | 253 | ||
255 | if (cpus_empty(tick_broadcast_mask)) { | 254 | if (cpus_empty(tick_broadcast_mask)) { |
256 | if (!bc_stopped) | 255 | if (!bc_stopped) |
257 | clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN); | 256 | clockevents_shutdown(bc); |
258 | } else if (bc_stopped) { | 257 | } else if (bc_stopped) { |
259 | if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) | 258 | if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) |
260 | tick_broadcast_start_periodic(bc); | 259 | tick_broadcast_start_periodic(bc); |
@@ -306,7 +305,7 @@ void tick_shutdown_broadcast(unsigned int *cpup) | |||
306 | 305 | ||
307 | if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) { | 306 | if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) { |
308 | if (bc && cpus_empty(tick_broadcast_mask)) | 307 | if (bc && cpus_empty(tick_broadcast_mask)) |
309 | clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN); | 308 | clockevents_shutdown(bc); |
310 | } | 309 | } |
311 | 310 | ||
312 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 311 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
@@ -321,7 +320,7 @@ void tick_suspend_broadcast(void) | |||
321 | 320 | ||
322 | bc = tick_broadcast_device.evtdev; | 321 | bc = tick_broadcast_device.evtdev; |
323 | if (bc) | 322 | if (bc) |
324 | clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN); | 323 | clockevents_shutdown(bc); |
325 | 324 | ||
326 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 325 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
327 | } | 326 | } |
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index c4777193d567..019315ebf9de 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c | |||
@@ -249,7 +249,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
249 | * not give it back to the clockevents layer ! | 249 | * not give it back to the clockevents layer ! |
250 | */ | 250 | */ |
251 | if (tick_is_broadcast_device(curdev)) { | 251 | if (tick_is_broadcast_device(curdev)) { |
252 | clockevents_set_mode(curdev, CLOCK_EVT_MODE_SHUTDOWN); | 252 | clockevents_shutdown(curdev); |
253 | curdev = NULL; | 253 | curdev = NULL; |
254 | } | 254 | } |
255 | clockevents_exchange_device(curdev, newdev); | 255 | clockevents_exchange_device(curdev, newdev); |
@@ -311,7 +311,7 @@ static void tick_suspend(void) | |||
311 | unsigned long flags; | 311 | unsigned long flags; |
312 | 312 | ||
313 | spin_lock_irqsave(&tick_device_lock, flags); | 313 | spin_lock_irqsave(&tick_device_lock, flags); |
314 | clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_SHUTDOWN); | 314 | clockevents_shutdown(td->evtdev); |
315 | spin_unlock_irqrestore(&tick_device_lock, flags); | 315 | spin_unlock_irqrestore(&tick_device_lock, flags); |
316 | } | 316 | } |
317 | 317 | ||
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index 0ffc2918ea6f..6e9db9734aa6 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h | |||
@@ -10,6 +10,8 @@ extern int tick_do_timer_cpu __read_mostly; | |||
10 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); | 10 | extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast); |
11 | extern void tick_handle_periodic(struct clock_event_device *dev); | 11 | extern void tick_handle_periodic(struct clock_event_device *dev); |
12 | 12 | ||
13 | extern void clockevents_shutdown(struct clock_event_device *dev); | ||
14 | |||
13 | /* | 15 | /* |
14 | * NO_HZ / high resolution timer shared code | 16 | * NO_HZ / high resolution timer shared code |
15 | */ | 17 | */ |