]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
vfio-pci: Release all MSI-X vectors when disabled
authorAlex Williamson <alex.williamson@redhat.com>
Fri, 6 Dec 2013 18:16:40 +0000 (11:16 -0700)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Fri, 21 Feb 2014 06:34:40 +0000 (00:34 -0600)
We were relying on msix_unset_vector_notifiers() to release all the
vectors when we disable MSI-X, but this only happens when MSI-X is
still enabled on the device.  Perform further cleanup by releasing
any remaining vectors listed as in-use after this call.  This caused
a leak of IRQ routes on hotplug depending on how the guest OS prepared
the device for removal.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-stable@nongnu.org
(cherry picked from commit 3e40ba0faf0822fa78336fe6cd9d677ea9b14f1b)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/misc/vfio.c

index f7f8a19ee8b0127b758d03ada9499e564aa091f5..355b0189c83a79728d6d11f3fedf22a1e4fca62b 100644 (file)
@@ -878,8 +878,20 @@ static void vfio_disable_msi_common(VFIODevice *vdev)
 
 static void vfio_disable_msix(VFIODevice *vdev)
 {
+    int i;
+
     msix_unset_vector_notifiers(&vdev->pdev);
 
+    /*
+     * MSI-X will only release vectors if MSI-X is still enabled on the
+     * device, check through the rest and release it ourselves if necessary.
+     */
+    for (i = 0; i < vdev->nr_vectors; i++) {
+        if (vdev->msi_vectors[i].use) {
+            vfio_msix_vector_release(&vdev->pdev, i);
+        }
+    }
+
     if (vdev->nr_vectors) {
         vfio_disable_irqindex(vdev, VFIO_PCI_MSIX_IRQ_INDEX);
     }