Skip to content

Commit 860be25

Browse files
committed
vfio/pci: Handle INTx IRQ_NOTCONNECTED
Some systems report INTx as not routed by setting pdev->irq to IRQ_NOTCONNECTED, resulting in a -ENOTCONN error when trying to setup eventfd signaling. Include this in the set of conditions for which the PIN register is virtualized to zero. Additionally consolidate vfio_pci_get_irq_count() to use this virtualized value in reporting INTx support via ioctl and sanity checking ioctl paths since pdev->irq is re-used when the device is in MSI mode. The combination of these results in both the config space of the device and the ioctl interface behaving as if the device does not support INTx. Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20250311230623.1264283-1-alex.williamson@redhat.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 384a530 commit 860be25

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

drivers/vfio/pci/vfio_pci_config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,8 @@ int vfio_config_init(struct vfio_pci_core_device *vdev)
18141814
cpu_to_le16(PCI_COMMAND_MEMORY);
18151815
}
18161816

1817-
if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) || vdev->nointx)
1817+
if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) || vdev->nointx ||
1818+
vdev->pdev->irq == IRQ_NOTCONNECTED)
18181819
vconfig[PCI_INTERRUPT_PIN] = 0;
18191820

18201821
ret = vfio_cap_init(vdev);

drivers/vfio/pci/vfio_pci_core.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -727,15 +727,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_finish_enable);
727727
static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_type)
728728
{
729729
if (irq_type == VFIO_PCI_INTX_IRQ_INDEX) {
730-
u8 pin;
731-
732-
if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) ||
733-
vdev->nointx || vdev->pdev->is_virtfn)
734-
return 0;
735-
736-
pci_read_config_byte(vdev->pdev, PCI_INTERRUPT_PIN, &pin);
737-
738-
return pin ? 1 : 0;
730+
return vdev->vconfig[PCI_INTERRUPT_PIN] ? 1 : 0;
739731
} else if (irq_type == VFIO_PCI_MSI_IRQ_INDEX) {
740732
u8 pos;
741733
u16 flags;

drivers/vfio/pci/vfio_pci_intrs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int vfio_intx_enable(struct vfio_pci_core_device *vdev,
259259
if (!is_irq_none(vdev))
260260
return -EINVAL;
261261

262-
if (!pdev->irq)
262+
if (!pdev->irq || pdev->irq == IRQ_NOTCONNECTED)
263263
return -ENODEV;
264264

265265
name = kasprintf(GFP_KERNEL_ACCOUNT, "vfio-intx(%s)", pci_name(pdev));

0 commit comments

Comments
 (0)