Commit eec94b8a authored by Johannes Berg's avatar Johannes Berg Committed by Richard Weinberger

um: time-travel: Fix periodic timers

Periodic timers are broken, because the also only fire once.
As it happens, Linux doesn't care because it only sets the
timer to periodic very briefly during boot, and then switches
it only between one-shot and off later.

Nevertheless, fix the logic (we shouldn't even be looking at
time_travel_timer_expiry unless the timer is enabled) and
change the code to fire the timer periodically in periodic
mode, in case it ever gets used in the future.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 786b2384
......@@ -43,6 +43,11 @@ static inline void time_travel_set_timer_expiry(unsigned long long expiry)
{
time_travel_timer_expiry = expiry;
}
static inline void time_travel_set_timer_interval(unsigned long long interval)
{
time_travel_timer_interval = interval;
}
#else
#define time_travel_mode TT_MODE_OFF
#define time_travel_time 0
......@@ -61,6 +66,10 @@ static inline void time_travel_set_timer_expiry(unsigned long long expiry)
{
}
static inline void time_travel_set_timer_interval(unsigned long long interval)
{
}
#define time_travel_timer_mode TT_TMR_DISABLED
#endif
......
......@@ -210,7 +210,12 @@ static void time_travel_sleep(unsigned long long duration)
if (time_travel_mode != TT_MODE_INFCPU)
os_timer_disable();
if (time_travel_timer_mode != TT_TMR_DISABLED ||
while (time_travel_timer_mode == TT_TMR_PERIODIC &&
time_travel_timer_expiry < time_travel_time)
time_travel_set_timer_expiry(time_travel_timer_expiry +
time_travel_timer_interval);
if (time_travel_timer_mode != TT_TMR_DISABLED &&
time_travel_timer_expiry < next) {
if (time_travel_timer_mode == TT_TMR_ONESHOT)
time_travel_set_timer_mode(TT_TMR_DISABLED);
......
......@@ -65,6 +65,7 @@ static int itimer_set_periodic(struct clock_event_device *evt)
if (time_travel_mode != TT_MODE_OFF) {
time_travel_set_timer_mode(TT_TMR_PERIODIC);
time_travel_set_timer_expiry(time_travel_time + interval);
time_travel_set_timer_interval(interval);
}
if (time_travel_mode != TT_MODE_INFCPU)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment