[PATCH 16/17] vfio/pci: Move vfio_msi_disable() to be with other MSI/MSI-X management code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The interrupt management code is mostly organized in four sections:
shared code (interrupt type checking and interrupt context management),
INTx management code, MSI/MSI-X management code, and IOCTL support.

vfio_msi_disable() is separate from the other MSI/MSI-X code. This may
have been required because vfio_msi_disable() relies on
vfio_irq_set_vector_signal() within the IOCTL support.

Since vfio_irq_set_vector_signal() is declared earlier it is not
required for MSI/MSI-X management code to be mixed with the IOCTL
support.

Move vfio_msi_disable() to be located with all the other MSI/MSI-X
management code.

This move makes it simpler to initialize the interrupt management
callbacks with vfio_msi_disable() so that it can be provided to the
IOCTL support code.

Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
---
 drivers/vfio/pci/vfio_pci_intrs.c | 58 +++++++++++++++----------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 9217fea3f636..daa84a317f40 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -404,6 +404,35 @@ static int vfio_msi_enable(struct vfio_pci_core_device *vdev,
 	return 0;
 }
 
+static void vfio_msi_disable(struct vfio_pci_core_device *vdev,
+			     unsigned int index)
+{
+	struct pci_dev *pdev = vdev->pdev;
+	struct vfio_pci_irq_ctx *ctx;
+	unsigned long i;
+	u16 cmd;
+
+	xa_for_each(&vdev->ctx, i, ctx) {
+		vfio_virqfd_disable(&ctx->unmask);
+		vfio_virqfd_disable(&ctx->mask);
+		vfio_irq_set_vector_signal(vdev, i, -1, index);
+		vfio_irq_ctx_free(vdev, ctx, i);
+	}
+
+	cmd = vfio_pci_memory_lock_and_enable(vdev);
+	pci_free_irq_vectors(pdev);
+	vfio_pci_memory_unlock_and_restore(vdev, cmd);
+
+	/*
+	 * Both disable paths above use pci_intx_for_msi() to clear DisINTx
+	 * via their shutdown paths.  Restore for NoINTx devices.
+	 */
+	if (vdev->nointx)
+		pci_intx(pdev, 0);
+
+	vdev->irq_type = VFIO_PCI_NUM_IRQS;
+}
+
 /*
  * vfio_msi_alloc_irq() returns the Linux IRQ number of an MSI or MSI-X device
  * interrupt vector. If a Linux IRQ number is not available then a new
@@ -617,35 +646,6 @@ static int vfio_irq_set_block(struct vfio_pci_core_device *vdev,
 	return ret;
 }
 
-static void vfio_msi_disable(struct vfio_pci_core_device *vdev,
-			     unsigned int index)
-{
-	struct pci_dev *pdev = vdev->pdev;
-	struct vfio_pci_irq_ctx *ctx;
-	unsigned long i;
-	u16 cmd;
-
-	xa_for_each(&vdev->ctx, i, ctx) {
-		vfio_virqfd_disable(&ctx->unmask);
-		vfio_virqfd_disable(&ctx->mask);
-		vfio_irq_set_vector_signal(vdev, i, -1, index);
-		vfio_irq_ctx_free(vdev, ctx, i);
-	}
-
-	cmd = vfio_pci_memory_lock_and_enable(vdev);
-	pci_free_irq_vectors(pdev);
-	vfio_pci_memory_unlock_and_restore(vdev, cmd);
-
-	/*
-	 * Both disable paths above use pci_intx_for_msi() to clear DisINTx
-	 * via their shutdown paths.  Restore for NoINTx devices.
-	 */
-	if (vdev->nointx)
-		pci_intx(pdev, 0);
-
-	vdev->irq_type = VFIO_PCI_NUM_IRQS;
-}
-
 /*
  * IOCTL support
  */
-- 
2.34.1





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux