mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-07 06:52:07 +00:00
posix-timers: Add active flag to k_itimer
Keep track of the activation state of posix timers. This is a preparatory change for making common_timer_get() usable by both hrtimer and alarm timer implementations. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: John Stultz <john.stultz@linaro.org> Link: http://lkml.kernel.org/r/20170530211656.967783982@linutronix.de
This commit is contained in:
parent
f37fb0aa4f
commit
21e55c1f83
2 changed files with 9 additions and 1 deletions
|
@ -59,6 +59,7 @@ struct cpu_timer_list {
|
||||||
* @kclock: Pointer to the k_clock struct handling this timer
|
* @kclock: Pointer to the k_clock struct handling this timer
|
||||||
* @it_clock: The posix timer clock id
|
* @it_clock: The posix timer clock id
|
||||||
* @it_id: The posix timer id for identifying the timer
|
* @it_id: The posix timer id for identifying the timer
|
||||||
|
* @it_active: Marker that timer is active
|
||||||
* @it_overrun: The overrun counter for pending signals
|
* @it_overrun: The overrun counter for pending signals
|
||||||
* @it_overrun_last: The overrun at the time of the last delivered signal
|
* @it_overrun_last: The overrun at the time of the last delivered signal
|
||||||
* @it_requeue_pending: Indicator that timer waits for being requeued on
|
* @it_requeue_pending: Indicator that timer waits for being requeued on
|
||||||
|
@ -79,6 +80,7 @@ struct k_itimer {
|
||||||
const struct k_clock *kclock;
|
const struct k_clock *kclock;
|
||||||
clockid_t it_clock;
|
clockid_t it_clock;
|
||||||
timer_t it_id;
|
timer_t it_id;
|
||||||
|
int it_active;
|
||||||
int it_overrun;
|
int it_overrun;
|
||||||
int it_overrun_last;
|
int it_overrun_last;
|
||||||
int it_requeue_pending;
|
int it_requeue_pending;
|
||||||
|
|
|
@ -316,6 +316,7 @@ void posixtimer_rearm(struct siginfo *info)
|
||||||
if (timr->it_requeue_pending == info->si_sys_private) {
|
if (timr->it_requeue_pending == info->si_sys_private) {
|
||||||
timr->kclock->timer_rearm(timr);
|
timr->kclock->timer_rearm(timr);
|
||||||
|
|
||||||
|
timr->it_active = 1;
|
||||||
timr->it_overrun_last = timr->it_overrun;
|
timr->it_overrun_last = timr->it_overrun;
|
||||||
timr->it_overrun = -1;
|
timr->it_overrun = -1;
|
||||||
++timr->it_requeue_pending;
|
++timr->it_requeue_pending;
|
||||||
|
@ -371,6 +372,7 @@ static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
|
||||||
timr = container_of(timer, struct k_itimer, it.real.timer);
|
timr = container_of(timer, struct k_itimer, it.real.timer);
|
||||||
spin_lock_irqsave(&timr->it_lock, flags);
|
spin_lock_irqsave(&timr->it_lock, flags);
|
||||||
|
|
||||||
|
timr->it_active = 0;
|
||||||
if (timr->it_interval != 0)
|
if (timr->it_interval != 0)
|
||||||
si_private = ++timr->it_requeue_pending;
|
si_private = ++timr->it_requeue_pending;
|
||||||
|
|
||||||
|
@ -418,6 +420,7 @@ static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer)
|
||||||
timr->it_interval);
|
timr->it_interval);
|
||||||
ret = HRTIMER_RESTART;
|
ret = HRTIMER_RESTART;
|
||||||
++timr->it_requeue_pending;
|
++timr->it_requeue_pending;
|
||||||
|
timr->it_active = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,6 +740,7 @@ common_timer_set(struct k_itimer *timr, int flags,
|
||||||
if (hrtimer_try_to_cancel(timer) < 0)
|
if (hrtimer_try_to_cancel(timer) < 0)
|
||||||
return TIMER_RETRY;
|
return TIMER_RETRY;
|
||||||
|
|
||||||
|
timr->it_active = 0;
|
||||||
timr->it_requeue_pending = (timr->it_requeue_pending + 2) &
|
timr->it_requeue_pending = (timr->it_requeue_pending + 2) &
|
||||||
~REQUEUE_PENDING;
|
~REQUEUE_PENDING;
|
||||||
timr->it_overrun_last = 0;
|
timr->it_overrun_last = 0;
|
||||||
|
@ -763,6 +767,7 @@ common_timer_set(struct k_itimer *timr, int flags,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timr->it_active = 1;
|
||||||
hrtimer_start_expires(timer, mode);
|
hrtimer_start_expires(timer, mode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -821,6 +826,7 @@ static int common_timer_del(struct k_itimer *timer)
|
||||||
|
|
||||||
if (hrtimer_try_to_cancel(&timer->it.real.timer) < 0)
|
if (hrtimer_try_to_cancel(&timer->it.real.timer) < 0)
|
||||||
return TIMER_RETRY;
|
return TIMER_RETRY;
|
||||||
|
timer->it_active = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue