Lines Matching refs:alarm
160 static void alarmtimer_enqueue(struct alarm_base *base, struct alarm *alarm) in alarmtimer_enqueue() argument
162 if (alarm->state & ALARMTIMER_STATE_ENQUEUED) in alarmtimer_enqueue()
163 timerqueue_del(&base->timerqueue, &alarm->node); in alarmtimer_enqueue()
165 timerqueue_add(&base->timerqueue, &alarm->node); in alarmtimer_enqueue()
166 alarm->state |= ALARMTIMER_STATE_ENQUEUED; in alarmtimer_enqueue()
178 static void alarmtimer_dequeue(struct alarm_base *base, struct alarm *alarm) in alarmtimer_dequeue() argument
180 if (!(alarm->state & ALARMTIMER_STATE_ENQUEUED)) in alarmtimer_dequeue()
183 timerqueue_del(&base->timerqueue, &alarm->node); in alarmtimer_dequeue()
184 alarm->state &= ~ALARMTIMER_STATE_ENQUEUED; in alarmtimer_dequeue()
199 struct alarm *alarm = container_of(timer, struct alarm, timer); in alarmtimer_fired() local
200 struct alarm_base *base = &alarm_bases[alarm->type]; in alarmtimer_fired()
206 alarmtimer_dequeue(base, alarm); in alarmtimer_fired()
209 if (alarm->function) in alarmtimer_fired()
210 restart = alarm->function(alarm, base->get_ktime()); in alarmtimer_fired()
214 hrtimer_set_expires(&alarm->timer, alarm->node.expires); in alarmtimer_fired()
215 alarmtimer_enqueue(base, alarm); in alarmtimer_fired()
220 trace_alarmtimer_fired(alarm, base->get_ktime()); in alarmtimer_fired()
225 ktime_t alarm_expires_remaining(const struct alarm *alarm) in alarm_expires_remaining() argument
227 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_expires_remaining()
228 return ktime_sub(alarm->node.expires, base->get_ktime()); in alarm_expires_remaining()
326 __alarm_init(struct alarm *alarm, enum alarmtimer_type type, in __alarm_init() argument
327 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) in __alarm_init() argument
329 timerqueue_init(&alarm->node); in __alarm_init()
330 alarm->timer.function = alarmtimer_fired; in __alarm_init()
331 alarm->function = function; in __alarm_init()
332 alarm->type = type; in __alarm_init()
333 alarm->state = ALARMTIMER_STATE_INACTIVE; in __alarm_init()
342 void alarm_init(struct alarm *alarm, enum alarmtimer_type type, in alarm_init() argument
343 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) in alarm_init() argument
345 hrtimer_init(&alarm->timer, alarm_bases[type].base_clockid, in alarm_init()
347 __alarm_init(alarm, type, function); in alarm_init()
356 void alarm_start(struct alarm *alarm, ktime_t start) in alarm_start() argument
358 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_start()
362 alarm->node.expires = start; in alarm_start()
363 alarmtimer_enqueue(base, alarm); in alarm_start()
364 hrtimer_start(&alarm->timer, alarm->node.expires, HRTIMER_MODE_ABS); in alarm_start()
367 trace_alarmtimer_start(alarm, base->get_ktime()); in alarm_start()
376 void alarm_start_relative(struct alarm *alarm, ktime_t start) in alarm_start_relative() argument
378 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_start_relative()
381 alarm_start(alarm, start); in alarm_start_relative()
385 void alarm_restart(struct alarm *alarm) in alarm_restart() argument
387 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_restart()
391 hrtimer_set_expires(&alarm->timer, alarm->node.expires); in alarm_restart()
392 hrtimer_restart(&alarm->timer); in alarm_restart()
393 alarmtimer_enqueue(base, alarm); in alarm_restart()
405 int alarm_try_to_cancel(struct alarm *alarm) in alarm_try_to_cancel() argument
407 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_try_to_cancel()
412 ret = hrtimer_try_to_cancel(&alarm->timer); in alarm_try_to_cancel()
414 alarmtimer_dequeue(base, alarm); in alarm_try_to_cancel()
417 trace_alarmtimer_cancel(alarm, base->get_ktime()); in alarm_try_to_cancel()
429 int alarm_cancel(struct alarm *alarm) in alarm_cancel() argument
432 int ret = alarm_try_to_cancel(alarm); in alarm_cancel()
435 hrtimer_cancel_wait_running(&alarm->timer); in alarm_cancel()
441 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval) in alarm_forward() argument
446 delta = ktime_sub(now, alarm->node.expires); in alarm_forward()
456 alarm->node.expires = ktime_add_ns(alarm->node.expires, in alarm_forward()
459 if (alarm->node.expires > now) in alarm_forward()
468 alarm->node.expires = ktime_add_safe(alarm->node.expires, interval); in alarm_forward()
473 u64 alarm_forward_now(struct alarm *alarm, ktime_t interval) in alarm_forward_now() argument
475 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_forward_now()
477 return alarm_forward(alarm, base->get_ktime(), interval); in alarm_forward_now()
536 static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, in alarm_handle_timer() argument
539 struct k_itimer *ptr = container_of(alarm, struct k_itimer, in alarm_handle_timer()
540 it.alarm.alarmtimer); in alarm_handle_timer()
556 ptr->it_overrun += alarm_forward_now(alarm, ptr->it_interval); in alarm_handle_timer()
572 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_rearm() local
574 timr->it_overrun += alarm_forward_now(alarm, timr->it_interval); in alarm_timer_rearm()
575 alarm_start(alarm, alarm->node.expires); in alarm_timer_rearm()
585 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_forward() local
587 return alarm_forward(alarm, timr->it_interval, now); in alarm_timer_forward()
597 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_remaining() local
599 return ktime_sub(alarm->node.expires, now); in alarm_timer_remaining()
608 return alarm_try_to_cancel(&timr->it.alarm.alarmtimer); in alarm_timer_try_to_cancel()
621 hrtimer_cancel_wait_running(&timr->it.alarm.alarmtimer.timer); in alarm_timer_wait_running()
634 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_arm() local
635 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_timer_arm()
640 alarm->node.expires = expires; in alarm_timer_arm()
642 alarm_start(&timr->it.alarm.alarmtimer, expires); in alarm_timer_arm()
714 alarm_init(&new_timer->it.alarm.alarmtimer, type, alarm_handle_timer); in alarm_timer_create()
727 static enum alarmtimer_restart alarmtimer_nsleep_wakeup(struct alarm *alarm, in alarmtimer_nsleep_wakeup() argument
730 struct task_struct *task = (struct task_struct *)alarm->data; in alarmtimer_nsleep_wakeup()
732 alarm->data = NULL; in alarmtimer_nsleep_wakeup()
746 static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp, in alarmtimer_do_nsleep() argument
750 alarm->data = (void *)current; in alarmtimer_do_nsleep()
753 alarm_start(alarm, absexp); in alarmtimer_do_nsleep()
754 if (likely(alarm->data)) in alarmtimer_do_nsleep()
757 alarm_cancel(alarm); in alarmtimer_do_nsleep()
758 } while (alarm->data && !signal_pending(current)); in alarmtimer_do_nsleep()
762 destroy_hrtimer_on_stack(&alarm->timer); in alarmtimer_do_nsleep()
764 if (!alarm->data) in alarmtimer_do_nsleep()
786 alarm_init_on_stack(struct alarm *alarm, enum alarmtimer_type type, in alarm_init_on_stack() argument
787 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) in alarm_init_on_stack() argument
789 hrtimer_init_on_stack(&alarm->timer, alarm_bases[type].base_clockid, in alarm_init_on_stack()
791 __alarm_init(alarm, type, function); in alarm_init_on_stack()
804 struct alarm alarm; in alarm_timer_nsleep_restart() local
806 alarm_init_on_stack(&alarm, type, alarmtimer_nsleep_wakeup); in alarm_timer_nsleep_restart()
808 return alarmtimer_do_nsleep(&alarm, exp, type); in alarm_timer_nsleep_restart()
824 struct alarm alarm; in alarm_timer_nsleep() local
837 alarm_init_on_stack(&alarm, type, alarmtimer_nsleep_wakeup); in alarm_timer_nsleep()
849 ret = alarmtimer_do_nsleep(&alarm, exp, type); in alarm_timer_nsleep()