Lines Matching +full:period +full:- +full:scale
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
11 * ktime_to_tick() - Scale ktime_t to timer tick value.
18 return div_u64(delta * vcpu->arch.timer_mhz, MNSEC_PER_SEC); in ktime_to_tick()
23 return div_u64(tick * MNSEC_PER_SEC, vcpu->arch.timer_mhz); in tick_to_ns()
33 rcuwait_wake_up(&vcpu->wait); in kvm_swtimer_wakeup()
43 vcpu->arch.timer_mhz = timer_hz >> 20; in kvm_init_timer()
46 kvm_write_sw_gcsr(vcpu->arch.csr, LOONGARCH_CSR_TVAL, 0); in kvm_init_timer()
55 unsigned long ticks, delta, period; in kvm_restore_timer() local
57 struct loongarch_csrs *csr = vcpu->arch.csr; in kvm_restore_timer()
76 * Freeze the soft-timer and sync the guest stable timer with it. in kvm_restore_timer()
79 hrtimer_cancel(&vcpu->arch.swtimer); in kvm_restore_timer()
83 * If oneshot timer is fired, CSR TVAL will be -1, there are two in kvm_restore_timer()
95 * and set CSR TVAL with -1 in kvm_restore_timer()
101 * timer interrupt, and CSR TVAL keeps unchanged with -1, it in kvm_restore_timer()
114 expire = vcpu->arch.expire; in kvm_restore_timer()
118 period = cfg & CSR_TCFG_VAL; in kvm_restore_timer()
120 delta = period - (delta % period); in kvm_restore_timer()
142 struct loongarch_csrs *csr = vcpu->arch.csr; in _kvm_save_timer()
149 * If period timer is fired, CSR TVAL will be reloaded from CSR TCFG in _kvm_save_timer()
150 * If oneshot timer is fired, CSR TVAL will be -1 in _kvm_save_timer()
151 * Here judge one-shot timer fired by checking whether TVAL is larger in _kvm_save_timer()
160 vcpu->arch.expire = expire; in _kvm_save_timer()
168 hrtimer_start(&vcpu->arch.swtimer, expire, HRTIMER_MODE_ABS_PINNED_HARD); in _kvm_save_timer()
178 struct loongarch_csrs *csr = vcpu->arch.csr; in kvm_save_timer()
188 /* Save timer-related state to vCPU context */ in kvm_save_timer()