Lines Matching refs:stimer

188 	struct kvm_vcpu_hv_stimer *stimer;  in kvm_hv_notify_acked_sint()  local
198 for (idx = 0; idx < ARRAY_SIZE(hv_vcpu->stimer); idx++) { in kvm_hv_notify_acked_sint()
199 stimer = &hv_vcpu->stimer[idx]; in kvm_hv_notify_acked_sint()
200 if (stimer->msg_pending && in kvm_hv_notify_acked_sint()
201 (stimer->config & HV_STIMER_ENABLE) && in kvm_hv_notify_acked_sint()
202 HV_STIMER_SINT(stimer->config) == sint) { in kvm_hv_notify_acked_sint()
203 set_bit(stimer->index, in kvm_hv_notify_acked_sint()
445 static void stimer_mark_pending(struct kvm_vcpu_hv_stimer *stimer, in stimer_mark_pending() argument
448 struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer); in stimer_mark_pending()
450 set_bit(stimer->index, in stimer_mark_pending()
457 static void stimer_cleanup(struct kvm_vcpu_hv_stimer *stimer) in stimer_cleanup() argument
459 struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer); in stimer_cleanup()
461 trace_kvm_hv_stimer_cleanup(stimer_to_vcpu(stimer)->vcpu_id, in stimer_cleanup()
462 stimer->index); in stimer_cleanup()
464 hrtimer_cancel(&stimer->timer); in stimer_cleanup()
465 clear_bit(stimer->index, in stimer_cleanup()
467 stimer->msg_pending = false; in stimer_cleanup()
468 stimer->exp_time = 0; in stimer_cleanup()
473 struct kvm_vcpu_hv_stimer *stimer; in stimer_timer_callback() local
475 stimer = container_of(timer, struct kvm_vcpu_hv_stimer, timer); in stimer_timer_callback()
476 trace_kvm_hv_stimer_callback(stimer_to_vcpu(stimer)->vcpu_id, in stimer_timer_callback()
477 stimer->index); in stimer_timer_callback()
478 stimer_mark_pending(stimer, true); in stimer_timer_callback()
488 static int stimer_start(struct kvm_vcpu_hv_stimer *stimer) in stimer_start() argument
493 time_now = get_time_ref_counter(stimer_to_vcpu(stimer)->kvm); in stimer_start()
496 if (stimer->config & HV_STIMER_PERIODIC) { in stimer_start()
497 if (stimer->exp_time) { in stimer_start()
498 if (time_now >= stimer->exp_time) { in stimer_start()
501 div64_u64_rem(time_now - stimer->exp_time, in stimer_start()
502 stimer->count, &remainder); in stimer_start()
503 stimer->exp_time = in stimer_start()
504 time_now + (stimer->count - remainder); in stimer_start()
507 stimer->exp_time = time_now + stimer->count; in stimer_start()
510 stimer_to_vcpu(stimer)->vcpu_id, in stimer_start()
511 stimer->index, in stimer_start()
512 time_now, stimer->exp_time); in stimer_start()
514 hrtimer_start(&stimer->timer, in stimer_start()
516 100 * (stimer->exp_time - time_now)), in stimer_start()
520 stimer->exp_time = stimer->count; in stimer_start()
521 if (time_now >= stimer->count) { in stimer_start()
528 stimer_mark_pending(stimer, false); in stimer_start()
532 trace_kvm_hv_stimer_start_one_shot(stimer_to_vcpu(stimer)->vcpu_id, in stimer_start()
533 stimer->index, in stimer_start()
534 time_now, stimer->count); in stimer_start()
536 hrtimer_start(&stimer->timer, in stimer_start()
537 ktime_add_ns(ktime_now, 100 * (stimer->count - time_now)), in stimer_start()
542 static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config, in stimer_set_config() argument
545 trace_kvm_hv_stimer_set_config(stimer_to_vcpu(stimer)->vcpu_id, in stimer_set_config()
546 stimer->index, config, host); in stimer_set_config()
548 stimer_cleanup(stimer); in stimer_set_config()
549 if ((stimer->config & HV_STIMER_ENABLE) && HV_STIMER_SINT(config) == 0) in stimer_set_config()
551 stimer->config = config; in stimer_set_config()
552 stimer_mark_pending(stimer, false); in stimer_set_config()
556 static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count, in stimer_set_count() argument
559 trace_kvm_hv_stimer_set_count(stimer_to_vcpu(stimer)->vcpu_id, in stimer_set_count()
560 stimer->index, count, host); in stimer_set_count()
562 stimer_cleanup(stimer); in stimer_set_count()
563 stimer->count = count; in stimer_set_count()
564 if (stimer->count == 0) in stimer_set_count()
565 stimer->config &= ~HV_STIMER_ENABLE; in stimer_set_count()
566 else if (stimer->config & HV_STIMER_AUTOENABLE) in stimer_set_count()
567 stimer->config |= HV_STIMER_ENABLE; in stimer_set_count()
568 stimer_mark_pending(stimer, false); in stimer_set_count()
572 static int stimer_get_config(struct kvm_vcpu_hv_stimer *stimer, u64 *pconfig) in stimer_get_config() argument
574 *pconfig = stimer->config; in stimer_get_config()
578 static int stimer_get_count(struct kvm_vcpu_hv_stimer *stimer, u64 *pcount) in stimer_get_count() argument
580 *pcount = stimer->count; in stimer_get_count()
625 static int stimer_send_msg(struct kvm_vcpu_hv_stimer *stimer) in stimer_send_msg() argument
627 struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer); in stimer_send_msg()
628 struct hv_message *msg = &stimer->msg; in stimer_send_msg()
632 payload->expiration_time = stimer->exp_time; in stimer_send_msg()
635 HV_STIMER_SINT(stimer->config), msg); in stimer_send_msg()
638 static void stimer_expiration(struct kvm_vcpu_hv_stimer *stimer) in stimer_expiration() argument
642 stimer->msg_pending = true; in stimer_expiration()
643 r = stimer_send_msg(stimer); in stimer_expiration()
644 trace_kvm_hv_stimer_expiration(stimer_to_vcpu(stimer)->vcpu_id, in stimer_expiration()
645 stimer->index, r); in stimer_expiration()
647 stimer->msg_pending = false; in stimer_expiration()
648 if (!(stimer->config & HV_STIMER_PERIODIC)) in stimer_expiration()
649 stimer->config &= ~HV_STIMER_ENABLE; in stimer_expiration()
656 struct kvm_vcpu_hv_stimer *stimer; in kvm_hv_process_stimers() local
660 for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) in kvm_hv_process_stimers()
662 stimer = &hv_vcpu->stimer[i]; in kvm_hv_process_stimers()
663 if (stimer->config & HV_STIMER_ENABLE) { in kvm_hv_process_stimers()
664 exp_time = stimer->exp_time; in kvm_hv_process_stimers()
670 stimer_expiration(stimer); in kvm_hv_process_stimers()
673 if ((stimer->config & HV_STIMER_ENABLE) && in kvm_hv_process_stimers()
674 stimer->count) { in kvm_hv_process_stimers()
675 if (!stimer->msg_pending) in kvm_hv_process_stimers()
676 stimer_start(stimer); in kvm_hv_process_stimers()
678 stimer_cleanup(stimer); in kvm_hv_process_stimers()
688 for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) in kvm_hv_vcpu_uninit()
689 stimer_cleanup(&hv_vcpu->stimer[i]); in kvm_hv_vcpu_uninit()
692 static void stimer_prepare_msg(struct kvm_vcpu_hv_stimer *stimer) in stimer_prepare_msg() argument
694 struct hv_message *msg = &stimer->msg; in stimer_prepare_msg()
702 payload->timer_index = stimer->index; in stimer_prepare_msg()
707 static void stimer_init(struct kvm_vcpu_hv_stimer *stimer, int timer_index) in stimer_init() argument
709 memset(stimer, 0, sizeof(*stimer)); in stimer_init()
710 stimer->index = timer_index; in stimer_init()
711 hrtimer_init(&stimer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); in stimer_init()
712 stimer->timer.function = stimer_timer_callback; in stimer_init()
713 stimer_prepare_msg(stimer); in stimer_init()
724 for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) in kvm_hv_vcpu_init()
725 stimer_init(&hv_vcpu->stimer[i], i); in kvm_hv_vcpu_init()