vfio: pci: Advertise INTx only if LINE is connected
Subsystems (2)
PATCH 1/1 vfio: pci: Advertise INTx only if LINE is connected
On POWER systems, when the device is behind the io expander, not all PCI slots would have the PCI_INTERRUPT_LINE connected. The firmware assigns a valid PCI_INTERRUPT_PIN though. In such configuration, the irq_info ioctl currently advertizes the irq count as 1 as the PCI_INTERRUPT_PIN is valid.
The patch adds the additional check[1] if the irq is assigned for the PIN which is done iff the LINE is connected.
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/vfio/pci/vfio_pci_core.c +4 -0
@@ -734,6 +734,10 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typreturn 0 ;pci_read_config_byte (vdev->pdev,PCI_INTERRUPT_PIN , &pin); +#if IS_ENABLED (CONFIG_PPC64 ) +if (!vdev->pdev->irq) + pin =0 ; +#endif return pin ?1 :0 ; }else if (irq_type ==VFIO_PCI_MSI_IRQ_INDEX ) {
Quoted 24 lines · On Tue, 18 Mar 2025 17:29:21 +0000 Shivaprasad G Bhat <[email protected]>…
On POWER systems, when the device is behind the io expander, not all PCI slots would have the
PCI_INTERRUPT_LINEconnected. The firmware assigns a validPCI_INTERRUPT_PINthough. In such configuration, theirq_infoioctl currently advertizes the irq count as 1 as thePCI_INTERRUPT_PINis valid.The patch adds the additional check[1] if the irq is assigned for the PIN which is done iff the LINE is connected.
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by Shivaprasad G Bhat <[email protected]>Suggested-By Alex Williamson <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0
drivers/vfio/pci/vfio_pci_core.c static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typ · line 743
Quoted 10 lines
drivers/vfio/pci/vfio_pci_core.c +4
-0@@ -734,6 +734,10 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typreturn 0 ;pci_read_config_byte (vdev->pdev,PCI_INTERRUPT_PIN , &pin); +#if IS_ENABLED (CONFIG_PPC64 ) +if (!vdev->pdev->irq) + pin =0 ; +#endif return pin ?1 :0 ; }else if (irq_type ==VFIO_PCI_MSI_IRQ_INDEX ) {
See:
https://lore.kernel.org/all/[email protected]/
Do we need to expand that to test !vdev->pdev->irq in vfio_config_init()? We don't allow a zero irq to be enabled in vfio_intx_enable(), so we might as well not report it as supported. I don't see why any of this needs to be POWER specific. Thanks,
Alex
Quoted 39 lines · Alex Williamson
Quoted 24 lines · On Tue, 18 Mar 2025 17:29:21 +0000 Shivaprasad G Bhat <[email protected]>…
On POWER systems, when the device is behind the io expander, not all PCI slots would have the
PCI_INTERRUPT_LINEconnected. The firmware assigns a validPCI_INTERRUPT_PINthough. In such configuration, theirq_infoioctl currently advertizes the irq count as 1 as thePCI_INTERRUPT_PINis valid.The patch adds the additional check[1] if the irq is assigned for the PIN which is done iff the LINE is connected.
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by Shivaprasad G Bhat <[email protected]>Suggested-By Alex Williamson <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typ · line 743
Quoted 10 lines
drivers/vfio/pci/vfio_pci_core.c +4
-0@@ -734,6 +734,10 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typreturn 0 ;pci_read_config_byte (vdev->pdev,PCI_INTERRUPT_PIN , &pin); +#if IS_ENABLED (CONFIG_PPC64 ) +if (!vdev->pdev->irq) + pin =0 ; +#endif return pin ?1 :0 ; }else if (irq_type ==VFIO_PCI_MSI_IRQ_INDEX ) {See:
Quoted 4 lines
https://lore.kernel.org/all/[email protected]/
Do we need to expand that to test !vdev->pdev->irq in
vfio_config_init()?
Yes. Looks to be the better option. I did try this and it works.
I see your patch has already got Reviewed-by. Are you planning
for v2 Or want me to post a separate patch with this new check?
Quoted 2 lines
We don't allow a zero irq to be enabled in
vfio_intx_enable(), so we might as well not report it as supported.
Yes. I agree.
Thank you!
Regards,
Shivaprasad
Quoted 45 lines · On Thu, 20 Mar 2025 23:24:49 +0530 Shivaprasad G Bhat <[email protected]>…
Quoted 39 lines · Alex Williamson
Quoted 24 lines · On Tue, 18 Mar 2025 17:29:21 +0000 Shivaprasad G Bhat <[email protected]>…
On POWER systems, when the device is behind the io expander, not all PCI slots would have the
PCI_INTERRUPT_LINEconnected. The firmware assigns a validPCI_INTERRUPT_PINthough. In such configuration, theirq_infoioctl currently advertizes the irq count as 1 as thePCI_INTERRUPT_PINis valid.The patch adds the additional check[1] if the irq is assigned for the PIN which is done iff the LINE is connected.
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by Shivaprasad G Bhat <[email protected]>Suggested-By Alex Williamson <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0drivers/vfio/pci/vfio_pci_core.c static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typ · line 743
Quoted 10 lines
drivers/vfio/pci/vfio_pci_core.c +4
-0@@ -734,6 +734,10 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typreturn 0 ;pci_read_config_byte (vdev->pdev,PCI_INTERRUPT_PIN , &pin); +#if IS_ENABLED (CONFIG_PPC64 ) +if (!vdev->pdev->irq) + pin =0 ; +#endif return pin ?1 :0 ; }else if (irq_type ==VFIO_PCI_MSI_IRQ_INDEX ) {See:
Quoted 4 lines
https://lore.kernel.org/all/[email protected]/
Do we need to expand that to test !vdev->pdev->irq in
vfio_config_init()?
Quoted 6 lines
Yes. Looks to be the better option. I did try this and it works.
I see your patch has already got Reviewed-by. Are you planning
for v2 Or want me to post a separate patch with this new check?
It seems worth noting this as an additional vector for virtualizing the PIN register since we'd often expect the PIN is already zero if pdev->irq is zero. I posted a patch[1], please review/test. Thanks,
Alex
Le 18/03/2025 à 18:29, Shivaprasad G Bhat a écrit :
Quoted 22 lines
On POWER systems, when the device is behind the io expander, not all PCI slots would have the
PCI_INTERRUPT_LINEconnected. The firmware assigns a validPCI_INTERRUPT_PINthough. In such configuration, theirq_infoioctl currently advertizes the irq count as 1 as thePCI_INTERRUPT_PINis valid.The patch adds the additional check[1] if the irq is assigned for the PIN which is done iff the LINE is connected.
Signed-off-by Shivaprasad G Bhat <[email protected]>Suggested-By Alex Williamson <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/vfio/pci/vfio_pci_core.c +0
-0
drivers/vfio/pci/vfio_pci_core.c static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typ · line 740
Quoted 7 lines
drivers/vfio/pci/vfio_pci_core.c +4
-0@@ -734,6 +734,10 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typreturn 0 ;pci_read_config_byte (vdev->pdev,PCI_INTERRUPT_PIN , &pin); +#if IS_ENABLED (CONFIG_PPC64 ) +if (!vdev->pdev->irq) + pin =0 ; +#endif
I see no reason for #ifdef here, please instead do:
if (IS_ENABLED(CONFIG_PPC64) && !vdev->pdev->irq)
See https://docs.kernel.org/process/coding-style.html#conditional-compilation
Quoted 6 lines
drivers/vfio/pci/vfio_pci_core.c +0
-0return pin ?1 :0 ; }else if (irq_type ==VFIO_PCI_MSI_IRQ_INDEX ) {