diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2014-05-09 11:58:42 +0530 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2014-09-05 09:52:51 +0530 |
commit | a8bcaba5c5a3d0d95246a3920235a8fd8d88d2b7 (patch) | |
tree | 87de0828d6efbf102ec55c1c7461484db127f95b | |
parent | 862a178f89c792765d33e12a068af2e4de23858a (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 824109060a33..ce00eba8c698 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; } /** |