From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
rkrcmar@redhat.com, david@redhat.com
Subject: [PATCH v1 11/22] KVM: x86: push usage of slots_lock down
Date: Tue, 14 Mar 2017 14:34:39 +0100 [thread overview]
Message-ID: <20170314133450.13259-12-david@redhat.com> (raw)
In-Reply-To: <20170314133450.13259-1-david@redhat.com>
Let's just move it to the place where it is actually needed.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
arch/x86/kvm/i8259.c | 2 ++
arch/x86/kvm/ioapic.c | 2 ++
arch/x86/kvm/x86.c | 4 ----
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 64e4b92..e77e8c3 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -657,9 +657,11 @@ void kvm_pic_destroy(struct kvm *kvm)
{
struct kvm_pic *vpic = kvm->arch.vpic;
+ mutex_lock(&kvm->slots_lock);
kvm_io_bus_unregister_dev(vpic->kvm, KVM_PIO_BUS, &vpic->dev_master);
kvm_io_bus_unregister_dev(vpic->kvm, KVM_PIO_BUS, &vpic->dev_slave);
kvm_io_bus_unregister_dev(vpic->kvm, KVM_PIO_BUS, &vpic->dev_eclr);
+ mutex_unlock(&kvm->slots_lock);
kvm->arch.vpic = NULL;
kfree(vpic);
diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 427e5f9..1a30320 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -634,7 +634,9 @@ void kvm_ioapic_destroy(struct kvm *kvm)
struct kvm_ioapic *ioapic = kvm->arch.vioapic;
cancel_delayed_work_sync(&ioapic->eoi_inject);
+ mutex_lock(&kvm->slots_lock);
kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &ioapic->dev);
+ mutex_unlock(&kvm->slots_lock);
kvm->arch.vioapic = NULL;
kfree(ioapic);
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index db1a5ff..8d6418e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4019,9 +4019,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
r = kvm_ioapic_init(kvm);
if (r) {
- mutex_lock(&kvm->slots_lock);
kvm_pic_destroy(kvm);
- mutex_unlock(&kvm->slots_lock);
goto create_irqchip_unlock;
}
@@ -4029,10 +4027,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
r = kvm_setup_default_irq_routing(kvm);
if (r) {
kvm->arch.irqchip_mode = KVM_IRQCHIP_NONE;
- mutex_lock(&kvm->slots_lock);
kvm_ioapic_destroy(kvm);
kvm_pic_destroy(kvm);
- mutex_unlock(&kvm->slots_lock);
goto create_irqchip_unlock;
}
/* Write kvm->irq_routing before enabling irqchip_in_kernel. */
--
2.9.3
next prev parent reply other threads:[~2017-03-14 13:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 13:34 [PATCH v1 00/22] pic/ioapic/irqchip cleanups + minor fixes David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 01/22] KVM: x86: race between KVM_SET_GSI_ROUTING and KVM_CREATE_IRQCHIP David Hildenbrand
2017-03-15 6:24 ` Peter Xu
2017-03-15 9:19 ` David Hildenbrand
2017-03-15 9:28 ` Peter Xu
2017-03-14 13:34 ` [PATCH v1 02/22] KVM: x86: check against irqchip_mode in kvm_set_routing_entry() David Hildenbrand
2017-03-15 6:33 ` Peter Xu
2017-03-15 9:35 ` David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 03/22] KVM: x86: check against irqchip_mode in pic_in_kernel() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 04/22] KVM: x86: check against irqchip_mode in ioapic_in_kernel() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 05/22] KVM: x86: get rid of pic_irqchip() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 06/22] KVM: x86: get rid of ioapic_irqchip() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 07/22] KVM: x86: use ioapic_in_kernel() to check for ioapic existence David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 08/22] KVM: x86: remove duplicate checks for ioapic David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 09/22] KVM: x86: convert kvm_(set|get)_ioapic() into void David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 10/22] KVM: x86: don't take kvm->irq_lock when creating IRQCHIP David Hildenbrand
2017-03-14 13:34 ` David Hildenbrand [this message]
2017-03-14 13:34 ` [PATCH v1 12/22] KVM: x86: KVM_IRQCHIP_PIC_MASTER only has 8 pins David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 13/22] KVM: x86: remove all-vcpu request from kvm_ioapic_init() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 14/22] KVM: x86: directly call kvm_make_scan_ioapic_request() in ioapic.c David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 15/22] KVM: x86: rename kvm_vcpu_request_scan_ioapic() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 16/22] KVM: x86: drop goto label in kvm_set_routing_entry() David Hildenbrand
2017-03-15 8:23 ` Peter Xu
2017-03-15 9:11 ` David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 17/22] KVM: x86: simplify pic_unlock() David Hildenbrand
2017-03-15 8:27 ` Peter Xu
2017-03-15 9:07 ` David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 18/22] KVM: x86: make kvm_pic_reset() static David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 19/22] KVM: x86: drop picdev_in_range() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 20/22] KVM: x86: set data directly in picdev_read() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 21/22] KVM: x86: simplify pic_ioport_read() David Hildenbrand
2017-03-14 13:34 ` [PATCH v1 22/22] KVM: x86: use irqchip_kernel() to check for pic+ioapic David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170314133450.13259-12-david@redhat.com \
--to=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox