Skip to contentSkip to conversation

vfio/pci: Quiet broken INTx whining when INTx is unsupported by device

PATCH Superseded Alex Williamson 1 participant 1 message Mar 15, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio/pci: Quiet broken INTx whining when INTx is unsupported by device

The intent of commit 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it") was to disallow the user from seeing that the device supports INTx if the platform is incapable of enabling it. The detection of this case however incorrectly includes devices which natively do not support INTx, such as SR-IOV VFs. We don't need the nointx handling code for such devices, nor do we want to issue a broken INTx masking warning. Check whether the device supports INTx before enabling nointx.

Fixes 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it")
---
 drivers/vfio/pci/vfio_pci.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/vfio/pci/vfio_pci.c +14 -1
index ad18ed266dc0..f2ca24644a2c 100644
@@ -192,6 +192,8 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev);
  */
 static bool vfio_pci_nointx(struct pci_dev *pdev)
 {
+	u8 pin;
+
 	switch (pdev->vendor) {
 	case PCI_VENDOR_ID_INTEL:
 		switch (pdev->device) {
@@ -207,7 +209,18 @@ static bool vfio_pci_nointx(struct pci_dev *pdev)
 		}
 	}
 
-	if (!pdev->irq)
+	pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
+
+	/*
+	 * If the device supports INTx, but it cannot be enabled, invoke
+	 * nointx to mask the pin value and INTx IRQ_INFO to the user.
+	 *
+	 * NB. Generally nointx depends on at least being able to prevent the
+	 * device from generating INTx, so ideally we might check if INTx
+	 * masking is supported, but perhaps we can interpret lack of an irq
+	 * as lack of routing and presume the INTx line is unwired.
+	 */
+	if (pin && !pdev->irq)
 		return true;
 
 	return false;