From: Mark McLoughlin <markmc@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH 5/5] KVM: split out kvm_free_assigned_irq()
Date: Mon, 1 Dec 2008 13:57:49 +0000 [thread overview]
Message-ID: <1228139869-5848-5-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1228139869-5848-4-git-send-email-markmc@redhat.com>
Split out the logic corresponding to undoing assign_irq() and
clean it up a bit.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
virt/kvm/kvm_main.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 63fd882..e41d39d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -200,14 +200,11 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
enable_irq(dev->host_irq);
}
-static void kvm_free_assigned_device(struct kvm *kvm,
- struct kvm_assigned_dev_kernel
- *assigned_dev)
+static void kvm_free_assigned_irq(struct kvm *kvm,
+ struct kvm_assigned_dev_kernel *assigned_dev)
{
- if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested_type)
- free_irq(assigned_dev->host_irq, (void *)assigned_dev);
- if (assigned_dev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)
- pci_disable_msi(assigned_dev->dev);
+ if (!irqchip_in_kernel(kvm))
+ return;
kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier);
@@ -215,12 +212,30 @@ static void kvm_free_assigned_device(struct kvm *kvm,
kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
assigned_dev->irq_source_id = -1;
+ if (!assigned_dev->irq_requested_type)
+ return;
+
if (cancel_work_sync(&assigned_dev->interrupt_work))
/* We had pending work. That means we will have to take
* care of kvm_put_kvm.
*/
kvm_put_kvm(kvm);
+ free_irq(assigned_dev->host_irq, (void *)assigned_dev);
+
+ if (assigned_dev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)
+ pci_disable_msi(assigned_dev->dev);
+
+ assigned_dev->irq_requested_type = 0;
+}
+
+
+static void kvm_free_assigned_device(struct kvm *kvm,
+ struct kvm_assigned_dev_kernel
+ *assigned_dev)
+{
+ kvm_free_assigned_irq(kvm, assigned_dev);
+
pci_reset_function(assigned_dev->dev);
pci_release_regions(assigned_dev->dev);
--
1.5.4.3
next prev parent reply other threads:[~2008-12-01 13:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-20 8:07 [PATCH 1/1] KVM: IRQ ACK notifier should be used with in-kernel irqchip Sheng Yang
2008-10-22 10:26 ` Avi Kivity
2008-11-28 10:25 ` Mark McLoughlin
2008-11-28 10:26 ` [PATCH 1/4] KVM: remove the IRQ ACK notifier assertions Mark McLoughlin
2008-11-28 10:26 ` [PATCH 2/4] KVM: make kvm_unregister_irq_ack_notifier() safe Mark McLoughlin
2008-11-28 10:26 ` [PATCH 3/4] KVM: gracefully handle zero in kvm_free_irq_source_id() Mark McLoughlin
2008-11-28 10:26 ` [PATCH 4/4] KVM: split out kvm_free_assigned_irq() Mark McLoughlin
2008-11-30 10:28 ` [PATCH 3/4] KVM: gracefully handle zero in kvm_free_irq_source_id() Avi Kivity
2008-12-01 13:56 ` Mark McLoughlin
2008-12-01 13:57 ` [PATCH 1/5] KVM: remove the IRQ ACK notifier assertions Mark McLoughlin
2008-12-01 13:57 ` [PATCH 2/5] KVM: make kvm_unregister_irq_ack_notifier() safe Mark McLoughlin
2008-12-01 13:57 ` [PATCH 3/5] KVM: don't fee an unallocated irq source id Mark McLoughlin
2008-12-01 13:57 ` [PATCH 4/5] KVM: add KVM_USERSPACE_IRQ_SOURCE_ID assertions Mark McLoughlin
2008-12-01 13:57 ` Mark McLoughlin [this message]
2008-12-02 12:41 ` Avi Kivity
2008-12-02 12:39 ` [PATCH 1/5] KVM: remove the IRQ ACK notifier assertions Avi Kivity
2008-12-01 2:31 ` [PATCH 1/1] KVM: IRQ ACK notifier should be used with in-kernel irqchip Sheng Yang
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=1228139869-5848-5-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.