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_event(struct k_itimer *timr, int si_private) in posix_timer_event() argument
295 timr->sigq->info.si_sys_private = si_private; in posix_timer_event()
297 type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID; in posix_timer_event()
298 ret = send_sigqueue(timr->sigq, timr->it_pid, type); in posix_timer_event()
313 struct k_itimer *timr; in posix_timer_fn() local
317 timr = container_of(timer, struct k_itimer, it.real.timer); in posix_timer_fn()
318 spin_lock_irqsave(&timr->it_lock, flags); in posix_timer_fn()
320 timr->it_active = 0; in posix_timer_fn()
321 if (timr->it_interval != 0) in posix_timer_fn()
322 si_private = ++timr->it_requeue_pending; in posix_timer_fn()
324 if (posix_timer_event(timr, si_private)) { in posix_timer_fn()
331 if (timr->it_interval != 0) { in posix_timer_fn()
362 if (timr->it_interval < kj) in posix_timer_fn()
366 timr->it_overrun += hrtimer_forward(timer, now, timr->it_interval); in posix_timer_fn()
368 ++timr->it_requeue_pending; in posix_timer_fn()
369 timr->it_active = 1; in posix_timer_fn()
373 unlock_timer(timr, flags); in posix_timer_fn()
562 struct k_itimer *timr; in __lock_timer() local
593 timr = posix_timer_by_id(timer_id); in __lock_timer()
594 if (timr) { in __lock_timer()
595 spin_lock_irqsave(&timr->it_lock, *flags); in __lock_timer()
600 if (timr->it_signal == current->signal) { in __lock_timer()
602 return timr; in __lock_timer()
604 spin_unlock_irqrestore(&timr->it_lock, *flags); in __lock_timer()
611 static ktime_t common_hrtimer_remaining(struct k_itimer *timr, ktime_t now) in common_hrtimer_remaining() argument
613 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_remaining()
618 static s64 common_hrtimer_forward(struct k_itimer *timr, ktime_t now) in common_hrtimer_forward() argument
620 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_forward()
622 return hrtimer_forward(timer, now, timr->it_interval); in common_hrtimer_forward()
637 void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting) in common_timer_get() argument
639 const struct k_clock *kc = timr->kclock; in common_timer_get()
643 sig_none = timr->it_sigev_notify == SIGEV_NONE; in common_timer_get()
644 iv = timr->it_interval; in common_timer_get()
649 } else if (!timr->it_active) { in common_timer_get()
662 now = kc->clock_get_ktime(timr->it_clock); in common_timer_get()
669 if (iv && (timr->it_requeue_pending & REQUEUE_PENDING || sig_none)) in common_timer_get()
670 timr->it_overrun += kc->timer_forward(timr, now); in common_timer_get()
672 remaining = kc->timer_remaining(timr, now); in common_timer_get()
699 struct k_itimer *timr; in do_timer_gettime() local
703 timr = lock_timer(timer_id, &flags); in do_timer_gettime()
704 if (!timr) in do_timer_gettime()
708 kc = timr->kclock; in do_timer_gettime()
712 kc->timer_get(timr, setting); in do_timer_gettime()
714 unlock_timer(timr, flags); in do_timer_gettime()
769 struct k_itimer *timr; in SYSCALL_DEFINE1() local
773 timr = lock_timer(timer_id, &flags); in SYSCALL_DEFINE1()
774 if (!timr) in SYSCALL_DEFINE1()
777 overrun = timer_overrun_to_int(timr, 0); in SYSCALL_DEFINE1()
778 unlock_timer(timr, flags); in SYSCALL_DEFINE1()
783 static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires, in common_hrtimer_arm() argument
786 struct hrtimer *timer = &timr->it.real.timer; in common_hrtimer_arm()
799 if (timr->it_clock == CLOCK_REALTIME) in common_hrtimer_arm()
800 timr->kclock = absolute ? &clock_realtime : &clock_monotonic; in common_hrtimer_arm()
802 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); in common_hrtimer_arm()
803 timr->it.real.timer.function = posix_timer_fn; in common_hrtimer_arm()
813 static int common_hrtimer_try_to_cancel(struct k_itimer *timr) in common_hrtimer_try_to_cancel() argument
815 return hrtimer_try_to_cancel(&timr->it.real.timer); in common_hrtimer_try_to_cancel()
860 int common_timer_set(struct k_itimer *timr, int flags, in common_timer_set() argument
864 const struct k_clock *kc = timr->kclock; in common_timer_set()
869 common_timer_get(timr, old_setting); in common_timer_set()
872 timr->it_interval = 0; in common_timer_set()
877 if (kc->timer_try_to_cancel(timr) < 0) in common_timer_set()
880 timr->it_active = 0; in common_timer_set()
881 timr->it_requeue_pending = (timr->it_requeue_pending + 2) & in common_timer_set()
883 timr->it_overrun_last = 0; in common_timer_set()
889 timr->it_interval = timespec64_to_ktime(new_setting->it_interval); in common_timer_set()
892 expires = timens_ktime_to_host(timr->it_clock, expires); in common_timer_set()
893 sigev_none = timr->it_sigev_notify == SIGEV_NONE; in common_timer_set()
895 kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none); in common_timer_set()
896 timr->it_active = !sigev_none; in common_timer_set()
905 struct k_itimer *timr; in do_timer_settime() local
916 timr = lock_timer(timer_id, &flags); in do_timer_settime()
918 if (!timr) in do_timer_settime()
921 kc = timr->kclock; in do_timer_settime()
925 error = kc->timer_set(timr, tmr_flags, new_spec64, old_spec64); in do_timer_settime()
931 timr = timer_wait_running(timr, &flags); in do_timer_settime()
934 unlock_timer(timr, flags); in do_timer_settime()