diff options
author | Sheng Yang <sheng.yang@intel.com> | 2008-03-12 22:22:26 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-27 05:00:23 -0400 |
commit | 308b0f239e8d6754b8b903d279e5b5b987e257ac (patch) | |
tree | 7d5787dd227874b89d1e5935080aa903dc7f1875 /arch/x86 | |
parent | e0f63cb9277b64850854aee301762beeeb463473 (diff) |
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')
-rw-r--r-- | arch/x86/kvm/i8254.c | 30 | ||||
-rw-r--r-- | arch/x86/kvm/i8254.h | 1 |
2 files changed, 20 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) | |||
478 | return (addr == KVM_SPEAKER_BASE_ADDRESS); | 478 | return (addr == KVM_SPEAKER_BASE_ADDRESS); |
479 | } | 479 | } |
480 | 480 | ||
481 | struct kvm_pit *kvm_create_pit(struct kvm *kvm) | 481 | void kvm_pit_reset(struct kvm_pit *pit) |
482 | { | 482 | { |
483 | int i; | 483 | int i; |
484 | struct kvm_kpit_channel_state *c; | ||
485 | |||
486 | mutex_lock(&pit->pit_state.lock); | ||
487 | for (i = 0; i < 3; i++) { | ||
488 | c = &pit->pit_state.channels[i]; | ||
489 | c->mode = 0xff; | ||
490 | c->gate = (i != 2); | ||
491 | pit_load_count(pit->kvm, i, 0); | ||
492 | } | ||
493 | mutex_unlock(&pit->pit_state.lock); | ||
494 | |||
495 | atomic_set(&pit->pit_state.pit_timer.pending, 0); | ||
496 | pit->pit_state.inject_pending = 1; | ||
497 | } | ||
498 | |||
499 | struct kvm_pit *kvm_create_pit(struct kvm *kvm) | ||
500 | { | ||
484 | struct kvm_pit *pit; | 501 | struct kvm_pit *pit; |
485 | struct kvm_kpit_state *pit_state; | 502 | struct kvm_kpit_state *pit_state; |
486 | struct kvm_kpit_channel_state *c; | ||
487 | 503 | ||
488 | pit = kzalloc(sizeof(struct kvm_pit), GFP_KERNEL); | 504 | pit = kzalloc(sizeof(struct kvm_pit), GFP_KERNEL); |
489 | if (!pit) | 505 | if (!pit) |
@@ -512,17 +528,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm) | |||
512 | pit_state->pit = pit; | 528 | pit_state->pit = pit; |
513 | hrtimer_init(&pit_state->pit_timer.timer, | 529 | hrtimer_init(&pit_state->pit_timer.timer, |
514 | CLOCK_MONOTONIC, HRTIMER_MODE_ABS); | 530 | CLOCK_MONOTONIC, HRTIMER_MODE_ABS); |
515 | atomic_set(&pit_state->pit_timer.pending, 0); | ||
516 | for (i = 0; i < 3; i++) { | ||
517 | c = &pit_state->channels[i]; | ||
518 | c->mode = 0xff; | ||
519 | c->gate = (i != 2); | ||
520 | pit_load_count(kvm, i, 0); | ||
521 | } | ||
522 | |||
523 | mutex_unlock(&pit->pit_state.lock); | 531 | mutex_unlock(&pit->pit_state.lock); |
524 | 532 | ||
525 | pit->pit_state.inject_pending = 1; | 533 | kvm_pit_reset(pit); |
526 | 534 | ||
527 | return pit; | 535 | return pit; |
528 | } | 536 | } |
diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h index fe09eced7783..db25c2a6c8c4 100644 --- a/arch/x86/kvm/i8254.h +++ b/arch/x86/kvm/i8254.h | |||
@@ -58,5 +58,6 @@ void kvm_pit_timer_intr_post(struct kvm_vcpu *vcpu, int vec); | |||
58 | void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val); | 58 | void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val); |
59 | struct kvm_pit *kvm_create_pit(struct kvm *kvm); | 59 | struct kvm_pit *kvm_create_pit(struct kvm *kvm); |
60 | void kvm_free_pit(struct kvm *kvm); | 60 | void kvm_free_pit(struct kvm *kvm); |
61 | void kvm_pit_reset(struct kvm_pit *pit); | ||
61 | 62 | ||
62 | #endif | 63 | #endif |