aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2015-07-07 08:07:27 -0400
committerThomas Gleixner <tglx@linutronix.de>2015-07-07 12:46:47 -0400
commite0454311903d3fd0f12a86c9e65d7b271c2bb05d (patch)
treeaf71d5c4bd86cbdcd1ff4e5c7ebd97e89a0818bd
parent8eb231261fdd20768db23863d00ef277de4b0543 (diff)
tick/broadcast: Sanity check the shutdown of the local clock_event
The broadcast code shuts down the local clock event unconditionally even if no broadcast device is installed or if the broadcast device is hrtimer based. Add proper sanity checks. [ Split out from a larger combo patch ] Reported-and-tested-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Suzuki Poulose <Suzuki.Poulose@arm.com> Cc: Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com> Cc: Catalin Marinas <Catalin.Marinas@arm.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1507070929360.3916@nanos
-rw-r--r--kernel/time/tick-broadcast.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index a76204089f78..9877d0b0aefc 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -159,7 +159,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
159{ 159{
160 struct clock_event_device *bc = tick_broadcast_device.evtdev; 160 struct clock_event_device *bc = tick_broadcast_device.evtdev;
161 unsigned long flags; 161 unsigned long flags;
162 int ret; 162 int ret = 0;
163 163
164 raw_spin_lock_irqsave(&tick_broadcast_lock, flags); 164 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
165 165
@@ -221,13 +221,14 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
221 * If we kept the cpu in the broadcast mask, 221 * If we kept the cpu in the broadcast mask,
222 * tell the caller to leave the per cpu device 222 * tell the caller to leave the per cpu device
223 * in shutdown state. The periodic interrupt 223 * in shutdown state. The periodic interrupt
224 * is delivered by the broadcast device. 224 * is delivered by the broadcast device, if
225 * the broadcast device exists and is not
226 * hrtimer based.
225 */ 227 */
226 ret = cpumask_test_cpu(cpu, tick_broadcast_mask); 228 if (bc && !(bc->features & CLOCK_EVT_FEAT_HRTIMER))
229 ret = cpumask_test_cpu(cpu, tick_broadcast_mask);
227 break; 230 break;
228 default: 231 default:
229 /* Nothing to do */
230 ret = 0;
231 break; 232 break;
232 } 233 }
233 } 234 }
@@ -373,8 +374,16 @@ void tick_broadcast_control(enum tick_broadcast_mode mode)
373 case TICK_BROADCAST_ON: 374 case TICK_BROADCAST_ON:
374 cpumask_set_cpu(cpu, tick_broadcast_on); 375 cpumask_set_cpu(cpu, tick_broadcast_on);
375 if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) { 376 if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) {
376 if (tick_broadcast_device.mode == 377 /*
377 TICKDEV_MODE_PERIODIC) 378 * Only shutdown the cpu local device, if:
379 *
380 * - the broadcast device exists
381 * - the broadcast device is not a hrtimer based one
382 * - the broadcast device is in periodic mode to
383 * avoid a hickup during switch to oneshot mode
384 */
385 if (bc && !(bc->features & CLOCK_EVT_FEAT_HRTIMER) &&
386 tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
378 clockevents_shutdown(dev); 387 clockevents_shutdown(dev);
379 } 388 }
380 break; 389 break;