summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-04-02 23:34:05 -0400
committerThomas Gleixner <tglx@linutronix.de>2015-05-19 10:18:11 -0400
commitd25408756accbd2171abaa0678f986adae139e6f (patch)
tree151e54ed16e45ab33ede5b9896b88a28f99fc164 /kernel
parent8fff52fd50934580c5108afed12043a774edf728 (diff)
clockevents: Stop unused clockevent devices
To avoid getting spurious interrupts on a tickless CPU, clockevent device can now be stopped by switching to ONESHOT_STOPPED state. The natural place for handling this transition is tick_program_event(). On 'expires == KTIME_MAX', we skip programming the event and so we need to fix such call sites as well, to always call tick_program_event() irrespective of the expires value. Once the clockevent device is required again, check if it was earlier put into ONESHOT_STOPPED state. If yes, switch its state to ONESHOT before programming its event. To make sure we haven't missed any corner case, add a WARN() for the case where we try to reprogram clockevent device while we aren't configured in ONESHOT_STOPPED state. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Cc: linaro-kernel@lists.linaro.org Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Kevin Hilman <khilman@linaro.org> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/5146b07be7f0bc497e0ebae036590ec2fa73e540.1428031396.git.viresh.kumar@linaro.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/clockevents.c4
-rw-r--r--kernel/time/hrtimer.c6
-rw-r--r--kernel/time/tick-oneshot.c16
3 files changed, 22 insertions, 4 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index dc6afb485027..4922f1b805ea 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -331,6 +331,10 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
331 if (dev->state == CLOCK_EVT_STATE_SHUTDOWN) 331 if (dev->state == CLOCK_EVT_STATE_SHUTDOWN)
332 return 0; 332 return 0;
333 333
334 /* We must be in ONESHOT state here */
335 WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, "Current state: %d\n",
336 dev->state);
337
334 /* Shortcut for clockevent devices that can deal with ktime. */ 338 /* Shortcut for clockevent devices that can deal with ktime. */
335 if (dev->features & CLOCK_EVT_FEAT_KTIME) 339 if (dev->features & CLOCK_EVT_FEAT_KTIME)
336 return dev->set_next_ktime(expires, dev); 340 return dev->set_next_ktime(expires, dev);
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 4adf32067862..278d4b36fd94 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -550,8 +550,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
550 if (cpu_base->hang_detected) 550 if (cpu_base->hang_detected)
551 return; 551 return;
552 552
553 if (cpu_base->expires_next.tv64 != KTIME_MAX) 553 tick_program_event(cpu_base->expires_next, 1);
554 tick_program_event(cpu_base->expires_next, 1);
555} 554}
556 555
557/* 556/*
@@ -1237,8 +1236,7 @@ retry:
1237 raw_spin_unlock(&cpu_base->lock); 1236 raw_spin_unlock(&cpu_base->lock);
1238 1237
1239 /* Reprogramming necessary ? */ 1238 /* Reprogramming necessary ? */
1240 if (expires_next.tv64 == KTIME_MAX || 1239 if (!tick_program_event(expires_next, 0)) {
1241 !tick_program_event(expires_next, 0)) {
1242 cpu_base->hang_detected = 0; 1240 cpu_base->hang_detected = 0;
1243 return; 1241 return;
1244 } 1242 }
diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c
index 67a64b1670bf..f8de75715c2f 100644
--- a/kernel/time/tick-oneshot.c
+++ b/kernel/time/tick-oneshot.c
@@ -28,6 +28,22 @@ int tick_program_event(ktime_t expires, int force)
28{ 28{
29 struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); 29 struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
30 30
31 if (unlikely(expires.tv64 == KTIME_MAX)) {
32 /*
33 * We don't need the clock event device any more, stop it.
34 */
35 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED);
36 return 0;
37 }
38
39 if (unlikely(dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED)) {
40 /*
41 * We need the clock event again, configure it in ONESHOT mode
42 * before using it.
43 */
44 clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
45 }
46
31 return clockevents_program_event(dev, expires, force); 47 return clockevents_program_event(dev, expires, force);
32} 48}
33 49