diff options
Diffstat (limited to 'arch/x86/kvm/i8254.c')
-rw-r--r-- | arch/x86/kvm/i8254.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 15578f180e59..294698b6daff 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -242,11 +242,11 @@ static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian) | |||
242 | { | 242 | { |
243 | struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state, | 243 | struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state, |
244 | irq_ack_notifier); | 244 | irq_ack_notifier); |
245 | spin_lock(&ps->inject_lock); | 245 | raw_spin_lock(&ps->inject_lock); |
246 | if (atomic_dec_return(&ps->pit_timer.pending) < 0) | 246 | if (atomic_dec_return(&ps->pit_timer.pending) < 0) |
247 | atomic_inc(&ps->pit_timer.pending); | 247 | atomic_inc(&ps->pit_timer.pending); |
248 | ps->irq_ack = 1; | 248 | ps->irq_ack = 1; |
249 | spin_unlock(&ps->inject_lock); | 249 | raw_spin_unlock(&ps->inject_lock); |
250 | } | 250 | } |
251 | 251 | ||
252 | void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu) | 252 | void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu) |
@@ -605,7 +605,7 @@ static const struct kvm_io_device_ops speaker_dev_ops = { | |||
605 | .write = speaker_ioport_write, | 605 | .write = speaker_ioport_write, |
606 | }; | 606 | }; |
607 | 607 | ||
608 | /* Caller must have writers lock on slots_lock */ | 608 | /* Caller must hold slots_lock */ |
609 | struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) | 609 | struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) |
610 | { | 610 | { |
611 | struct kvm_pit *pit; | 611 | struct kvm_pit *pit; |
@@ -624,7 +624,7 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) | |||
624 | 624 | ||
625 | mutex_init(&pit->pit_state.lock); | 625 | mutex_init(&pit->pit_state.lock); |
626 | mutex_lock(&pit->pit_state.lock); | 626 | mutex_lock(&pit->pit_state.lock); |
627 | spin_lock_init(&pit->pit_state.inject_lock); | 627 | raw_spin_lock_init(&pit->pit_state.inject_lock); |
628 | 628 | ||
629 | kvm->arch.vpit = pit; | 629 | kvm->arch.vpit = pit; |
630 | pit->kvm = kvm; | 630 | pit->kvm = kvm; |
@@ -645,13 +645,13 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) | |||
645 | kvm_register_irq_mask_notifier(kvm, 0, &pit->mask_notifier); | 645 | kvm_register_irq_mask_notifier(kvm, 0, &pit->mask_notifier); |
646 | 646 | ||
647 | kvm_iodevice_init(&pit->dev, &pit_dev_ops); | 647 | kvm_iodevice_init(&pit->dev, &pit_dev_ops); |
648 | ret = __kvm_io_bus_register_dev(&kvm->pio_bus, &pit->dev); | 648 | ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, &pit->dev); |
649 | if (ret < 0) | 649 | if (ret < 0) |
650 | goto fail; | 650 | goto fail; |
651 | 651 | ||
652 | if (flags & KVM_PIT_SPEAKER_DUMMY) { | 652 | if (flags & KVM_PIT_SPEAKER_DUMMY) { |
653 | kvm_iodevice_init(&pit->speaker_dev, &speaker_dev_ops); | 653 | kvm_iodevice_init(&pit->speaker_dev, &speaker_dev_ops); |
654 | ret = __kvm_io_bus_register_dev(&kvm->pio_bus, | 654 | ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, |
655 | &pit->speaker_dev); | 655 | &pit->speaker_dev); |
656 | if (ret < 0) | 656 | if (ret < 0) |
657 | goto fail_unregister; | 657 | goto fail_unregister; |
@@ -660,11 +660,12 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) | |||
660 | return pit; | 660 | return pit; |
661 | 661 | ||
662 | fail_unregister: | 662 | fail_unregister: |
663 | __kvm_io_bus_unregister_dev(&kvm->pio_bus, &pit->dev); | 663 | kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->dev); |
664 | 664 | ||
665 | fail: | 665 | fail: |
666 | if (pit->irq_source_id >= 0) | 666 | kvm_unregister_irq_mask_notifier(kvm, 0, &pit->mask_notifier); |
667 | kvm_free_irq_source_id(kvm, pit->irq_source_id); | 667 | kvm_unregister_irq_ack_notifier(kvm, &pit_state->irq_ack_notifier); |
668 | kvm_free_irq_source_id(kvm, pit->irq_source_id); | ||
668 | 669 | ||
669 | kfree(pit); | 670 | kfree(pit); |
670 | return NULL; | 671 | return NULL; |
@@ -723,12 +724,12 @@ void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu) | |||
723 | /* Try to inject pending interrupts when | 724 | /* Try to inject pending interrupts when |
724 | * last one has been acked. | 725 | * last one has been acked. |
725 | */ | 726 | */ |
726 | spin_lock(&ps->inject_lock); | 727 | raw_spin_lock(&ps->inject_lock); |
727 | if (atomic_read(&ps->pit_timer.pending) && ps->irq_ack) { | 728 | if (atomic_read(&ps->pit_timer.pending) && ps->irq_ack) { |
728 | ps->irq_ack = 0; | 729 | ps->irq_ack = 0; |
729 | inject = 1; | 730 | inject = 1; |
730 | } | 731 | } |
731 | spin_unlock(&ps->inject_lock); | 732 | raw_spin_unlock(&ps->inject_lock); |
732 | if (inject) | 733 | if (inject) |
733 | __inject_pit_timer_intr(kvm); | 734 | __inject_pit_timer_intr(kvm); |
734 | } | 735 | } |