yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vfio-pci-Release-all-MSI-X-vectors-when-disabled.patch

9ae3a8
From 4e1c9f340ef7820e28c55ad286a631cb9e63967a Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <4e1c9f340ef7820e28c55ad286a631cb9e63967a.1387276076.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <e610718166120379517e80d1a7aa12d60294209b.1387276076.git.minovotn@redhat.com>
9ae3a8
References: <e610718166120379517e80d1a7aa12d60294209b.1387276076.git.minovotn@redhat.com>
9ae3a8
From: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Date: Mon, 9 Dec 2013 17:48:46 +0100
9ae3a8
Subject: [PATCH 06/16] vfio-pci: Release all MSI-X vectors when disabled
9ae3a8
9ae3a8
RH-Author: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Message-id: <20131209174830.21963.40720.stgit@bling.home>
9ae3a8
Patchwork-id: 56091
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH] vfio-pci: Release all MSI-X vectors when disabled
9ae3a8
Bugzilla: 1029743
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Bandan Das <bsd@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
9ae3a8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1029743
9ae3a8
Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=6696250
9ae3a8
Upstream: 3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b
9ae3a8
9ae3a8
We were relying on msix_unset_vector_notifiers() to release all the
9ae3a8
vectors when we disable MSI-X, but this only happens when MSI-X is
9ae3a8
still enabled on the device.  Perform further cleanup by releasing
9ae3a8
any remaining vectors listed as in-use after this call.  This caused
9ae3a8
a leak of IRQ routes on hotplug depending on how the guest OS prepared
9ae3a8
the device for removal.
9ae3a8
9ae3a8
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Cc: qemu-stable@nongnu.org
9ae3a8
---
9ae3a8
 hw/misc/vfio.c |   12 ++++++++++++
9ae3a8
 1 file changed, 12 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 hw/misc/vfio.c | 12 ++++++++++++
9ae3a8
 1 file changed, 12 insertions(+)
9ae3a8
9ae3a8
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
9ae3a8
index 5a6925c..250f96f 100644
9ae3a8
--- a/hw/misc/vfio.c
9ae3a8
+++ b/hw/misc/vfio.c
9ae3a8
@@ -886,8 +886,20 @@ static void vfio_disable_msi_common(VFIODevice *vdev)
9ae3a8
 
9ae3a8
 static void vfio_disable_msix(VFIODevice *vdev)
9ae3a8
 {
9ae3a8
+    int i;
9ae3a8
+
9ae3a8
     msix_unset_vector_notifiers(&vdev->pdev);
9ae3a8
 
9ae3a8
+    /*
9ae3a8
+     * MSI-X will only release vectors if MSI-X is still enabled on the
9ae3a8
+     * device, check through the rest and release it ourselves if necessary.
9ae3a8
+     */
9ae3a8
+    for (i = 0; i < vdev->nr_vectors; i++) {
9ae3a8
+        if (vdev->msi_vectors[i].use) {
9ae3a8
+            vfio_msix_vector_release(&vdev->pdev, i);
9ae3a8
+        }
9ae3a8
+    }
9ae3a8
+
9ae3a8
     if (vdev->nr_vectors) {
9ae3a8
         vfio_disable_irqindex(vdev, VFIO_PCI_MSIX_IRQ_INDEX);
9ae3a8
     }
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8