diff options
author | Sheng Yang <sheng.yang@intel.com> | 2008-03-13 10:22:26 +0800 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-27 12:00:23 +0300 |
commit | 308b0f239e8d6754b8b903d279e5b5b987e257ac (patch) | |
tree | 7d5787dd227874b89d1e5935080aa903dc7f1875 /arch/x86/kvm/i8254.c | |
parent | e0f63cb9277b64850854aee301762beeeb463473 (diff) | |
download | linux-308b0f239e8d6754b8b903d279e5b5b987e257ac.tar.gz linux-308b0f239e8d6754b8b903d279e5b5b987e257ac.tar.bz2 linux-308b0f239e8d6754b8b903d279e5b5b987e257ac.zip |
KVM: Add reset support for in kernel PIT
Separate the reset part and prepare for reset support.
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/i8254.c')
-rw-r--r-- | arch/x86/kvm/i8254.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 8642f9d1206a..9f118e2f350d 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -478,12 +478,28 @@ static int speaker_in_range(struct kvm_io_device *this, gpa_t addr) return (addr == KVM_SPEAKER_BASE_ADDRESS); } -struct kvm_pit *kvm_create_pit(struct kvm *kvm) +void kvm_pit_reset(struct kvm_pit *pit) { int i; + struct kvm_kpit_channel_state *c; + + mutex_lock(&pit->pit_state.lock); + for (i = 0; i < 3; i++) { + c = &pit->pit_state.channels[i]; + c->mode = 0xff; + c->gate = (i != 2); + pit_load_count(pit->kvm, i, 0); + } + mutex_unlock(&pit->pit_state.lock); + + atomic_set(&pit->pit_state.pit_timer.pending, 0); + pit->pit_state.inject_pending = 1; +} + +struct kvm_pit *kvm_create_pit(struct kvm *kvm) +{ struct kvm_pit *pit; struct kvm_kpit_state *pit_state; - struct kvm_kpit_channel_state *c; pit = kzalloc(sizeof(struct kvm_pit), GFP_KERNEL); if (!pit) @@ -512,17 +528,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm) pit_state->pit = pit; hrtimer_init(&pit_state->pit_timer.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); - atomic_set(&pit_state->pit_timer.pending, 0); - for (i = 0; i < 3; i++) { - c = &pit_state->channels[i]; - c->mode = 0xff; - c->gate = (i != 2); - pit_load_count(kvm, i, 0); - } - mutex_unlock(&pit->pit_state.lock); - pit->pit_state.inject_pending = 1; + kvm_pit_reset(pit); return pit; } |