[PATCH 09/17] vfio/pci: Converge similar code flows

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

 



vfio_intx_set_signal() and vfio_msi_set_vector_signal() have similar
code flows that can be shared.

Modify vfio_intx_set_signal()'s signature to resemble that of
vfio_msi_set_vector_signal() by also providing the vector and interrupt
type as parameters. For vfio_intx_set_signal() these two additional
parameters are redundant and unused since the vector is always 0 and
the interrupt type is always INTx. Adding these parameters make it
possible to refactor vfio_intx_set_signal() to call INTx specific
functions with the same signature as the MSI/MSI-X specific functions
in preparation for these interrupt type specific functions to be called
by shared code.

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

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 70f2382c9c0c..98b099f58b2b 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -260,7 +260,9 @@ static int vfio_intx_enable(struct vfio_pci_core_device *vdev)
 	return 0;
 }
 
-static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev, int fd)
+static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev,
+				unsigned int vector, int fd,
+				unsigned int index)
 {
 	struct pci_dev *pdev = vdev->pdev;
 	unsigned long irqflags = IRQF_SHARED;
@@ -330,7 +332,7 @@ static void vfio_intx_disable(struct vfio_pci_core_device *vdev)
 		vfio_virqfd_disable(&ctx->unmask);
 		vfio_virqfd_disable(&ctx->mask);
 	}
-	vfio_intx_set_signal(vdev, -1);
+	vfio_intx_set_signal(vdev, 0, -1, VFIO_PCI_INTX_IRQ_INDEX);
 	vdev->irq_type = VFIO_PCI_NUM_IRQS;
 	vfio_irq_ctx_free(vdev, ctx, 0);
 }
@@ -674,13 +676,13 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,
 		int ret;
 
 		if (is_intx(vdev))
-			return vfio_intx_set_signal(vdev, fd);
+			return vfio_intx_set_signal(vdev, start, fd, index);
 
 		ret = vfio_intx_enable(vdev);
 		if (ret)
 			return ret;
 
-		ret = vfio_intx_set_signal(vdev, fd);
+		ret = vfio_intx_set_signal(vdev, start, fd, index);
 		if (ret)
 			vfio_intx_disable(vdev);
 
-- 
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