diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2014-05-09 11:58:42 +0530 |
---|---|---|
committer | Gary S. Robertson <gary.robertson@linaro.org> | 2015-07-22 16:17:08 -0500 |
commit | 61655b40f050e503b0d7a2720878328fc650746d (patch) | |
tree | 88ea16b89a58d3602108cec8d760da0c013467a0 | |
parent | c25bd30f4b5919d9fa87c4d298d8920e3f2c39b7 (diff) |
tick: SHUTDOWN event-dev if no events are required for KTIME_MAX
When expires is set to KTIME_MAX in tick_program_event(), we are sure that there
are no events enqueued for a very long time and so there is no point keeping
event device running. We will get interrupted without any work to do many a
times, for example when timer's counter overflows.
So, its better to SHUTDOWN the event device then and restart it ones we get a
request for next event. For implementing this a new field 'last_mode' is added
to 'struct clock_event_device' to keep track of last mode used.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r-- | kernel/time/tick-oneshot.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c index 7ce740e78e1b..47eea9e69e6b 100644 --- a/kernel/time/tick-oneshot.c +++ b/kernel/time/tick-oneshot.c @@ -27,8 +27,19 @@ int tick_program_event(ktime_t expires, int force) { struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); + int ret = 0; - return clockevents_program_event(dev, expires, force); + /* Shut down event device if it is not required for long */ + if (unlikely(expires.tv64 == KTIME_MAX)) { + clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN); + } else { + /* restore mode when restarting event dev */ + if (unlikely(dev->mode == CLOCK_EVT_MODE_SHUTDOWN)) + clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT); + ret = clockevents_program_event(dev, expires, force); + } + + return ret; } /** |