Skip to content

Commit f662280

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Do not restart SW timer when it is expired
LoongArch VCPUs have their own separate HW timers. SW timer is to wake up blocked vcpu thread, rather than HW timer emulation. When blocking vcpu scheduled out, SW timer is used to wakeup blocked vcpu thread and injects timer interrupt. It does not care about whether guest timer is in period mode or oneshot mode, and SW timer needs not to be restarted since vcpu has been woken. This patch does not restart SW timer when it is expired. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 8bc15d0 commit f662280

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

arch/loongarch/kvm/timer.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,6 @@ static inline u64 tick_to_ns(struct kvm_vcpu *vcpu, u64 tick)
2323
return div_u64(tick * MNSEC_PER_SEC, vcpu->arch.timer_mhz);
2424
}
2525

26-
/*
27-
* Push timer forward on timeout.
28-
* Handle an hrtimer event by push the hrtimer forward a period.
29-
*/
30-
static enum hrtimer_restart kvm_count_timeout(struct kvm_vcpu *vcpu)
31-
{
32-
unsigned long cfg, period;
33-
34-
/* Add periodic tick to current expire time */
35-
cfg = kvm_read_sw_gcsr(vcpu->arch.csr, LOONGARCH_CSR_TCFG);
36-
if (cfg & CSR_TCFG_PERIOD) {
37-
period = tick_to_ns(vcpu, cfg & CSR_TCFG_VAL);
38-
hrtimer_add_expires_ns(&vcpu->arch.swtimer, period);
39-
return HRTIMER_RESTART;
40-
} else
41-
return HRTIMER_NORESTART;
42-
}
43-
4426
/* Low level hrtimer wake routine */
4527
enum hrtimer_restart kvm_swtimer_wakeup(struct hrtimer *timer)
4628
{
@@ -50,7 +32,7 @@ enum hrtimer_restart kvm_swtimer_wakeup(struct hrtimer *timer)
5032
kvm_queue_irq(vcpu, INT_TI);
5133
rcuwait_wake_up(&vcpu->wait);
5234

53-
return kvm_count_timeout(vcpu);
35+
return HRTIMER_NORESTART;
5436
}
5537

5638
/*

0 commit comments

Comments
 (0)