diff options
Diffstat (limited to 'arch/x86/kvm/i8254.c')
-rw-r--r-- | arch/x86/kvm/i8254.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 11c6725fb798..59ebd37ad79e 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -545,6 +545,14 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm) | |||
545 | if (!pit) | 545 | if (!pit) |
546 | return NULL; | 546 | return NULL; |
547 | 547 | ||
548 | mutex_lock(&kvm->lock); | ||
549 | pit->irq_source_id = kvm_request_irq_source_id(kvm); | ||
550 | mutex_unlock(&kvm->lock); | ||
551 | if (pit->irq_source_id < 0) { | ||
552 | kfree(pit); | ||
553 | return NULL; | ||
554 | } | ||
555 | |||
548 | mutex_init(&pit->pit_state.lock); | 556 | mutex_init(&pit->pit_state.lock); |
549 | mutex_lock(&pit->pit_state.lock); | 557 | mutex_lock(&pit->pit_state.lock); |
550 | spin_lock_init(&pit->pit_state.inject_lock); | 558 | spin_lock_init(&pit->pit_state.inject_lock); |
@@ -587,6 +595,7 @@ void kvm_free_pit(struct kvm *kvm) | |||
587 | mutex_lock(&kvm->arch.vpit->pit_state.lock); | 595 | mutex_lock(&kvm->arch.vpit->pit_state.lock); |
588 | timer = &kvm->arch.vpit->pit_state.pit_timer.timer; | 596 | timer = &kvm->arch.vpit->pit_state.pit_timer.timer; |
589 | hrtimer_cancel(timer); | 597 | hrtimer_cancel(timer); |
598 | kvm_free_irq_source_id(kvm, kvm->arch.vpit->irq_source_id); | ||
590 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); | 599 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); |
591 | kfree(kvm->arch.vpit); | 600 | kfree(kvm->arch.vpit); |
592 | } | 601 | } |
@@ -595,8 +604,8 @@ void kvm_free_pit(struct kvm *kvm) | |||
595 | static void __inject_pit_timer_intr(struct kvm *kvm) | 604 | static void __inject_pit_timer_intr(struct kvm *kvm) |
596 | { | 605 | { |
597 | mutex_lock(&kvm->lock); | 606 | mutex_lock(&kvm->lock); |
598 | kvm_set_irq(kvm, 0, 1); | 607 | kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1); |
599 | kvm_set_irq(kvm, 0, 0); | 608 | kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0); |
600 | mutex_unlock(&kvm->lock); | 609 | mutex_unlock(&kvm->lock); |
601 | } | 610 | } |
602 | 611 | ||