Lines Matching refs:alarm
159 static void alarmtimer_enqueue(struct alarm_base *base, struct alarm *alarm) in alarmtimer_enqueue() argument
161 if (alarm->state & ALARMTIMER_STATE_ENQUEUED) in alarmtimer_enqueue()
162 timerqueue_del(&base->timerqueue, &alarm->node); in alarmtimer_enqueue()
164 timerqueue_add(&base->timerqueue, &alarm->node); in alarmtimer_enqueue()
165 alarm->state |= ALARMTIMER_STATE_ENQUEUED; in alarmtimer_enqueue()
177 static void alarmtimer_dequeue(struct alarm_base *base, struct alarm *alarm) in alarmtimer_dequeue() argument
179 if (!(alarm->state & ALARMTIMER_STATE_ENQUEUED)) in alarmtimer_dequeue()
182 timerqueue_del(&base->timerqueue, &alarm->node); in alarmtimer_dequeue()
183 alarm->state &= ~ALARMTIMER_STATE_ENQUEUED; in alarmtimer_dequeue()
198 struct alarm *alarm = container_of(timer, struct alarm, timer); in alarmtimer_fired() local
199 struct alarm_base *base = &alarm_bases[alarm->type]; in alarmtimer_fired()
205 alarmtimer_dequeue(base, alarm); in alarmtimer_fired()
208 if (alarm->function) in alarmtimer_fired()
209 restart = alarm->function(alarm, base->get_ktime()); in alarmtimer_fired()
213 hrtimer_set_expires(&alarm->timer, alarm->node.expires); in alarmtimer_fired()
214 alarmtimer_enqueue(base, alarm); in alarmtimer_fired()
219 trace_alarmtimer_fired(alarm, base->get_ktime()); in alarmtimer_fired()
224 ktime_t alarm_expires_remaining(const struct alarm *alarm) in alarm_expires_remaining() argument
226 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_expires_remaining()
227 return ktime_sub(alarm->node.expires, base->get_ktime()); in alarm_expires_remaining()
325 __alarm_init(struct alarm *alarm, enum alarmtimer_type type, in __alarm_init() argument
326 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) in __alarm_init() argument
328 timerqueue_init(&alarm->node); in __alarm_init()
329 alarm->timer.function = alarmtimer_fired; in __alarm_init()
330 alarm->function = function; in __alarm_init()
331 alarm->type = type; in __alarm_init()
332 alarm->state = ALARMTIMER_STATE_INACTIVE; in __alarm_init()
341 void alarm_init(struct alarm *alarm, enum alarmtimer_type type, in alarm_init() argument
342 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) in alarm_init() argument
344 hrtimer_init(&alarm->timer, alarm_bases[type].base_clockid, in alarm_init()
346 __alarm_init(alarm, type, function); in alarm_init()
355 void alarm_start(struct alarm *alarm, ktime_t start) in alarm_start() argument
357 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_start()
361 alarm->node.expires = start; in alarm_start()
362 alarmtimer_enqueue(base, alarm); in alarm_start()
363 hrtimer_start(&alarm->timer, alarm->node.expires, HRTIMER_MODE_ABS); in alarm_start()
366 trace_alarmtimer_start(alarm, base->get_ktime()); in alarm_start()
375 void alarm_start_relative(struct alarm *alarm, ktime_t start) in alarm_start_relative() argument
377 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_start_relative()
380 alarm_start(alarm, start); in alarm_start_relative()
384 void alarm_restart(struct alarm *alarm) in alarm_restart() argument
386 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_restart()
390 hrtimer_set_expires(&alarm->timer, alarm->node.expires); in alarm_restart()
391 hrtimer_restart(&alarm->timer); in alarm_restart()
392 alarmtimer_enqueue(base, alarm); in alarm_restart()
404 int alarm_try_to_cancel(struct alarm *alarm) in alarm_try_to_cancel() argument
406 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_try_to_cancel()
411 ret = hrtimer_try_to_cancel(&alarm->timer); in alarm_try_to_cancel()
413 alarmtimer_dequeue(base, alarm); in alarm_try_to_cancel()
416 trace_alarmtimer_cancel(alarm, base->get_ktime()); in alarm_try_to_cancel()
428 int alarm_cancel(struct alarm *alarm) in alarm_cancel() argument
431 int ret = alarm_try_to_cancel(alarm); in alarm_cancel()
434 hrtimer_cancel_wait_running(&alarm->timer); in alarm_cancel()
440 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval) in alarm_forward() argument
445 delta = ktime_sub(now, alarm->node.expires); in alarm_forward()
455 alarm->node.expires = ktime_add_ns(alarm->node.expires, in alarm_forward()
458 if (alarm->node.expires > now) in alarm_forward()
467 alarm->node.expires = ktime_add_safe(alarm->node.expires, interval); in alarm_forward()
472 static u64 __alarm_forward_now(struct alarm *alarm, ktime_t interval, bool throttle) in __alarm_forward_now() argument
474 struct alarm_base *base = &alarm_bases[alarm->type]; in __alarm_forward_now()
495 return alarm_forward(alarm, now, interval); in __alarm_forward_now()
498 u64 alarm_forward_now(struct alarm *alarm, ktime_t interval) in alarm_forward_now() argument
500 return __alarm_forward_now(alarm, interval, false); in alarm_forward_now()
559 static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, in alarm_handle_timer() argument
562 struct k_itimer *ptr = container_of(alarm, struct k_itimer, in alarm_handle_timer()
563 it.alarm.alarmtimer); in alarm_handle_timer()
580 ptr->it_overrun += __alarm_forward_now(alarm, ptr->it_interval, true); in alarm_handle_timer()
596 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_rearm() local
598 timr->it_overrun += alarm_forward_now(alarm, timr->it_interval); in alarm_timer_rearm()
599 alarm_start(alarm, alarm->node.expires); in alarm_timer_rearm()
609 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_forward() local
611 return alarm_forward(alarm, timr->it_interval, now); in alarm_timer_forward()
621 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_remaining() local
623 return ktime_sub(alarm->node.expires, now); in alarm_timer_remaining()
632 return alarm_try_to_cancel(&timr->it.alarm.alarmtimer); in alarm_timer_try_to_cancel()
645 hrtimer_cancel_wait_running(&timr->it.alarm.alarmtimer.timer); in alarm_timer_wait_running()
658 struct alarm *alarm = &timr->it.alarm.alarmtimer; in alarm_timer_arm() local
659 struct alarm_base *base = &alarm_bases[alarm->type]; in alarm_timer_arm()
664 alarm->node.expires = expires; in alarm_timer_arm()
666 alarm_start(&timr->it.alarm.alarmtimer, expires); in alarm_timer_arm()
738 alarm_init(&new_timer->it.alarm.alarmtimer, type, alarm_handle_timer); in alarm_timer_create()
751 static enum alarmtimer_restart alarmtimer_nsleep_wakeup(struct alarm *alarm, in alarmtimer_nsleep_wakeup() argument
754 struct task_struct *task = alarm->data; in alarmtimer_nsleep_wakeup()
756 alarm->data = NULL; in alarmtimer_nsleep_wakeup()
770 static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp, in alarmtimer_do_nsleep() argument
774 alarm->data = (void *)current; in alarmtimer_do_nsleep()
777 alarm_start(alarm, absexp); in alarmtimer_do_nsleep()
778 if (likely(alarm->data)) in alarmtimer_do_nsleep()
781 alarm_cancel(alarm); in alarmtimer_do_nsleep()
782 } while (alarm->data && !signal_pending(current)); in alarmtimer_do_nsleep()
786 destroy_hrtimer_on_stack(&alarm->timer); in alarmtimer_do_nsleep()
788 if (!alarm->data) in alarmtimer_do_nsleep()
810 alarm_init_on_stack(struct alarm *alarm, enum alarmtimer_type type, in alarm_init_on_stack() argument
811 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) in alarm_init_on_stack() argument
813 hrtimer_init_on_stack(&alarm->timer, alarm_bases[type].base_clockid, in alarm_init_on_stack()
815 __alarm_init(alarm, type, function); in alarm_init_on_stack()
828 struct alarm alarm; in alarm_timer_nsleep_restart() local
830 alarm_init_on_stack(&alarm, type, alarmtimer_nsleep_wakeup); in alarm_timer_nsleep_restart()
832 return alarmtimer_do_nsleep(&alarm, exp, type); in alarm_timer_nsleep_restart()
848 struct alarm alarm; in alarm_timer_nsleep() local
861 alarm_init_on_stack(&alarm, type, alarmtimer_nsleep_wakeup); in alarm_timer_nsleep()
873 ret = alarmtimer_do_nsleep(&alarm, exp, type); in alarm_timer_nsleep()