Lines Matching refs:timr

126 static inline void unlock_timer(struct k_itimer *timr, unsigned long flags)  in unlock_timer()  argument
128 spin_unlock_irqrestore(&timr->it_lock, flags); in unlock_timer()
236 static inline int timer_overrun_to_int(struct k_itimer *timr, int baseval) in timer_overrun_to_int() argument
238 s64 sum = timr->it_overrun_last + (s64)baseval; in timer_overrun_to_int()
243 static void common_hrtimer_rearm(struct k_itimer *timr) in common_hrtimer_rearm() argument
245 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_rearm()
247 timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(), in common_hrtimer_rearm()
248 timr->it_interval); in common_hrtimer_rearm()
259 struct k_itimer *timr; in posixtimer_rearm() local
262 timr = lock_timer(info->si_tid, &flags); in posixtimer_rearm()
263 if (!timr) in posixtimer_rearm()
266 if (timr->it_interval && timr->it_requeue_pending == info->si_sys_private) { in posixtimer_rearm()
267 timr->kclock->timer_rearm(timr); in posixtimer_rearm()
269 timr->it_active = 1; in posixtimer_rearm()
270 timr->it_overrun_last = timr->it_overrun; in posixtimer_rearm()
271 timr->it_overrun = -1LL; in posixtimer_rearm()
272 ++timr->it_requeue_pending; in posixtimer_rearm()
274 info->si_overrun = timer_overrun_to_int(timr, info->si_overrun); in posixtimer_rearm()
277 unlock_timer(timr, flags); in posixtimer_rearm()
280 int posix_timer_queue_signal(struct k_itimer *timr) in posix_timer_queue_signal() argument
285 lockdep_assert_held(&timr->it_lock); in posix_timer_queue_signal()
287 timr->it_active = 0; in posix_timer_queue_signal()
288 if (timr->it_interval) in posix_timer_queue_signal()
289 si_private = ++timr->it_requeue_pending; in posix_timer_queue_signal()
302 timr->sigq->info.si_sys_private = si_private; in posix_timer_queue_signal()
304 type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID; in posix_timer_queue_signal()
305 ret = send_sigqueue(timr->sigq, timr->it_pid, type); in posix_timer_queue_signal()
319 struct k_itimer *timr = container_of(timer, struct k_itimer, it.real.timer); in posix_timer_fn() local
323 spin_lock_irqsave(&timr->it_lock, flags); in posix_timer_fn()
325 if (posix_timer_queue_signal(timr)) { in posix_timer_fn()
332 if (timr->it_interval != 0) { in posix_timer_fn()
363 if (timr->it_interval < kj) in posix_timer_fn()
367 timr->it_overrun += hrtimer_forward(timer, now, timr->it_interval); in posix_timer_fn()
369 ++timr->it_requeue_pending; in posix_timer_fn()
370 timr->it_active = 1; in posix_timer_fn()
374 unlock_timer(timr, flags); in posix_timer_fn()
563 struct k_itimer *timr; in __lock_timer() local
594 timr = posix_timer_by_id(timer_id); in __lock_timer()
595 if (timr) { in __lock_timer()
596 spin_lock_irqsave(&timr->it_lock, *flags); in __lock_timer()
601 if (timr->it_signal == current->signal) { in __lock_timer()
603 return timr; in __lock_timer()
605 spin_unlock_irqrestore(&timr->it_lock, *flags); in __lock_timer()
612 static ktime_t common_hrtimer_remaining(struct k_itimer *timr, ktime_t now) in common_hrtimer_remaining() argument
614 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_remaining()
619 static s64 common_hrtimer_forward(struct k_itimer *timr, ktime_t now) in common_hrtimer_forward() argument
621 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_forward()
623 return hrtimer_forward(timer, now, timr->it_interval); in common_hrtimer_forward()
638 void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting) in common_timer_get() argument
640 const struct k_clock *kc = timr->kclock; in common_timer_get()
644 sig_none = timr->it_sigev_notify == SIGEV_NONE; in common_timer_get()
645 iv = timr->it_interval; in common_timer_get()
650 } else if (!timr->it_active) { in common_timer_get()
663 now = kc->clock_get_ktime(timr->it_clock); in common_timer_get()
670 if (iv && (timr->it_requeue_pending & REQUEUE_PENDING || sig_none)) in common_timer_get()
671 timr->it_overrun += kc->timer_forward(timr, now); in common_timer_get()
673 remaining = kc->timer_remaining(timr, now); in common_timer_get()
700 struct k_itimer *timr; in do_timer_gettime() local
704 timr = lock_timer(timer_id, &flags); in do_timer_gettime()
705 if (!timr) in do_timer_gettime()
709 kc = timr->kclock; in do_timer_gettime()
713 kc->timer_get(timr, setting); in do_timer_gettime()
715 unlock_timer(timr, flags); in do_timer_gettime()
770 struct k_itimer *timr; in SYSCALL_DEFINE1() local
774 timr = lock_timer(timer_id, &flags); in SYSCALL_DEFINE1()
775 if (!timr) in SYSCALL_DEFINE1()
778 overrun = timer_overrun_to_int(timr, 0); in SYSCALL_DEFINE1()
779 unlock_timer(timr, flags); in SYSCALL_DEFINE1()
784 static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires, in common_hrtimer_arm() argument
787 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_arm()
800 if (timr->it_clock == CLOCK_REALTIME) in common_hrtimer_arm()
801 timr->kclock = absolute ? &clock_realtime : &clock_monotonic; in common_hrtimer_arm()
803 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); in common_hrtimer_arm()
804 timr->it.real.timer.function = posix_timer_fn; in common_hrtimer_arm()
814 static int common_hrtimer_try_to_cancel(struct k_itimer *timr) in common_hrtimer_try_to_cancel() argument
816 return hrtimer_try_to_cancel(&timr->it.real.timer); in common_hrtimer_try_to_cancel()
878 int common_timer_set(struct k_itimer *timr, int flags, in common_timer_set() argument
882 const struct k_clock *kc = timr->kclock; in common_timer_set()
887 common_timer_get(timr, old_setting); in common_timer_set()
890 timr->it_interval = 0; in common_timer_set()
895 if (kc->timer_try_to_cancel(timr) < 0) in common_timer_set()
898 timr->it_active = 0; in common_timer_set()
899 posix_timer_set_common(timr, new_setting); in common_timer_set()
907 expires = timens_ktime_to_host(timr->it_clock, expires); in common_timer_set()
908 sigev_none = timr->it_sigev_notify == SIGEV_NONE; in common_timer_set()
910 kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none); in common_timer_set()
911 timr->it_active = !sigev_none; in common_timer_set()
920 struct k_itimer *timr; in do_timer_settime() local
931 timr = lock_timer(timer_id, &flags); in do_timer_settime()
933 if (!timr) in do_timer_settime()
937 old_spec64->it_interval = ktime_to_timespec64(timr->it_interval); in do_timer_settime()
939 kc = timr->kclock; in do_timer_settime()
943 error = kc->timer_set(timr, tmr_flags, new_spec64, old_spec64); in do_timer_settime()
949 timr = timer_wait_running(timr, &flags); in do_timer_settime()
952 unlock_timer(timr, flags); in do_timer_settime()