kernel-ark/kernel/time
Viresh Kumar 8fff52fd50 clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state
When no timers/hrtimers are pending, the expiry time is set to a
special value: 'KTIME_MAX'. This normally happens with
NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.

When 'expiry == KTIME_MAX', we either cancel the 'tick-sched' hrtimer
(NOHZ_MODE_HIGHRES) or skip reprogramming clockevent device
(NOHZ_MODE_LOWRES).  But, the clockevent device is already
reprogrammed from the tick-handler for next tick.

As the clock event device is programmed in ONESHOT mode it will at
least fire one more time (unnecessarily). Timers on few
implementations (like arm_arch_timer, etc.) only support PERIODIC mode
and their drivers emulate ONESHOT over that. Which means that on these
platforms we will get spurious interrupts periodically (at last
programmed interval rate, normally tick rate).

In order to avoid spurious interrupts, the clockevent device should be
stopped or its interrupts should be masked.

A simple (yet hacky) solution to get this fixed could be: update
hrtimer_force_reprogram() to always reprogram clockevent device and
update clockevent drivers to STOP generating events (or delay it to
max time) when 'expires' is set to KTIME_MAX. But the drawback here is
that every clockevent driver has to be hacked for this particular case
and its very easy for new ones to miss this.

However, Thomas suggested to add an optional state ONESHOT_STOPPED to
solve this problem: lkml.org/lkml/2014/5/9/508.

This patch adds support for ONESHOT_STOPPED state in clockevents
core. It will only be available to drivers that implement the
state-specific callbacks instead of the legacy ->set_mode() callback.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Preeti U. Murthy <preeti@linux.vnet.ibm.com>
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: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/b8b383a03ac07b13312c16850b5106b82e4245b5.1428031396.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-05-19 16:18:02 +02:00
..
alarmtimer.c alarmtimer: Get rid of unused return value 2015-04-22 17:06:52 +02:00
clockevents.c clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state 2015-05-19 16:18:02 +02:00
clocksource.c clocksource: Improve comment explaining clocks_calc_max_nsecs()'s 50% safety margin 2015-04-03 08:18:35 +02:00
hrtimer.c hrtimer: Allow concurrent hrtimer_start() for self restarting timers 2015-04-22 17:06:52 +02:00
itimer.c
jiffies.c tick: Move clocksource related stuff to timekeeping.h 2015-04-01 14:22:58 +02:00
Kconfig clockevents: Remove CONFIG_GENERIC_CLOCKEVENTS_BUILD 2015-04-01 14:22:57 +02:00
Makefile time: Move timeconst.h into include/generated 2015-05-19 15:13:45 +02:00
ntp_internal.h
ntp.c time: Add y2038 safe update_persistent_clock64() 2015-04-03 08:18:20 +02:00
posix-clock.c
posix-cpu-timers.c all arches, signal: move restart_block to struct task_struct 2015-02-12 18:54:12 -08:00
posix-timers.c hrtimer: Get rid of hrtimer_get_res() 2015-04-22 17:06:49 +02:00
sched_clock.c timers, sched/clock: Clean up the code a bit 2015-03-27 08:34:01 +01:00
test_udelay.c time: Rename udelay_test.c to test_udelay.c 2014-11-21 11:59:55 -08:00
tick-broadcast-hrtimer.c tick: hrtimer-broadcast: Prevent endless restarting when broadcast device is unused 2015-05-05 15:34:21 +02:00
tick-broadcast.c tick: broadcast: Simplify oneshot logic and shorten lock region 2015-05-05 10:25:23 +02:00
tick-common.c hrtimer: Get rid of hrtimer softirq 2015-04-22 17:06:50 +02:00
tick-internal.h tick: Nohz: Rework next timer evaluation 2015-04-22 17:06:50 +02:00
tick-oneshot.c clockevents: Manage device's state separately for the core 2015-03-27 10:26:19 +01:00
tick-sched.c nohz: Fix !HIGH_RES_TIMERS hang 2015-05-07 16:15:50 +02:00
tick-sched.h tick: Nohz: Rework next timer evaluation 2015-04-22 17:06:50 +02:00
time.c time: Refactor msecs_to_jiffies 2015-05-19 15:13:46 +02:00
timeconst.bc time: Move timeconst.h into include/generated 2015-05-19 15:13:45 +02:00
timeconv.c
timecounter.c timecounter: keep track of accumulated fractional nanoseconds 2014-12-30 18:29:27 -05:00
timekeeping_debug.c
timekeeping_internal.h clocksource: Move cycle_last validation to core code 2014-07-23 15:01:51 -07:00
timekeeping.c hrtimer: Make offset update smarter 2015-04-22 17:06:49 +02:00
timekeeping.h hrtimer: Make offset update smarter 2015-04-22 17:06:49 +02:00
timer_list.c clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state 2015-05-19 16:18:02 +02:00
timer_stats.c
timer.c timer: Use timer->base for flag checks 2015-05-05 10:40:43 +02:00