aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/emulate.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2009-11-02 07:02:31 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-11-05 00:51:05 -0500
commit544c6761bb05a1dd19a39cb9bed096273f9bdb36 (patch)
tree66fde2d24a61c3be4712ac2701263aca04f26ebb /arch/powerpc/kvm/emulate.c
parentc8240bd6f0b4b1b21ffd36dd44114d05c7afe0c0 (diff)
Use hrtimers for the decrementer
Following S390's good example we should use hrtimers for the decrementer too! This patch converts the timer from the old mechanism to hrtimers. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kvm/emulate.c')
-rw-r--r--arch/powerpc/kvm/emulate.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 1ec5e07b81eb..4a9ac6640fad 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -18,7 +18,7 @@
18 */ 18 */
19 19
20#include <linux/jiffies.h> 20#include <linux/jiffies.h>
21#include <linux/timer.h> 21#include <linux/hrtimer.h>
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/kvm_host.h> 24#include <linux/kvm_host.h>
@@ -79,12 +79,13 @@ static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu)
79 79
80void kvmppc_emulate_dec(struct kvm_vcpu *vcpu) 80void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
81{ 81{
82 unsigned long nr_jiffies; 82 unsigned long dec_nsec;
83 83
84 pr_debug("mtDEC: %x\n", vcpu->arch.dec);
84#ifdef CONFIG_PPC64 85#ifdef CONFIG_PPC64
85 /* POWER4+ triggers a dec interrupt if the value is < 0 */ 86 /* POWER4+ triggers a dec interrupt if the value is < 0 */
86 if (vcpu->arch.dec & 0x80000000) { 87 if (vcpu->arch.dec & 0x80000000) {
87 del_timer(&vcpu->arch.dec_timer); 88 hrtimer_try_to_cancel(&vcpu->arch.dec_timer);
88 kvmppc_core_queue_dec(vcpu); 89 kvmppc_core_queue_dec(vcpu);
89 return; 90 return;
90 } 91 }
@@ -94,12 +95,15 @@ void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
94 * that's how we convert the guest DEC value to the number of 95 * that's how we convert the guest DEC value to the number of
95 * host ticks. */ 96 * host ticks. */
96 97
98 hrtimer_try_to_cancel(&vcpu->arch.dec_timer);
99 dec_nsec = vcpu->arch.dec;
100 dec_nsec *= 1000;
101 dec_nsec /= tb_ticks_per_usec;
102 hrtimer_start(&vcpu->arch.dec_timer, ktime_set(0, dec_nsec),
103 HRTIMER_MODE_REL);
97 vcpu->arch.dec_jiffies = get_tb(); 104 vcpu->arch.dec_jiffies = get_tb();
98 nr_jiffies = vcpu->arch.dec / tb_ticks_per_jiffy;
99 mod_timer(&vcpu->arch.dec_timer,
100 get_jiffies_64() + nr_jiffies);
101 } else { 105 } else {
102 del_timer(&vcpu->arch.dec_timer); 106 hrtimer_try_to_cancel(&vcpu->arch.dec_timer);
103 } 107 }
104} 108}
105 109