[PATCH] vfio: pci: Advertise INTx only if LINE is connected

Christophe Leroy christophe.leroy at csgroup.eu
Tue Mar 25 18:13:35 AEDT 2025



Le 18/03/2025 à 18:29, Shivaprasad G Bhat a écrit :
> 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://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fqemu-devel%2F20250131150201.048aa3bf.alex.williamson%40redhat.com%2F&data=05%7C02%7Cchristophe.leroy2%40cs-soprasteria.com%7Ce0fb1d4bf2064e115ce408dd6642796b%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C638779157886704638%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=egZuT5CZsC6S%2Bd7bZTuO4RcKL8IJREPbxIMGZZkZeMQ%3D&reserved=0
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat at linux.ibm.com>
> Suggested-By: Alex Williamson <alex.williamson at redhat.com>
> ---
>   drivers/vfio/pci/vfio_pci_core.c |    4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index 586e49efb81b..4ce70f05b4a8 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -734,6 +734,10 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typ
>   			return 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

>   
>   		return pin ? 1 : 0;
>   	} else if (irq_type == VFIO_PCI_MSI_IRQ_INDEX) {
> 
> 
> 



More information about the Linuxppc-dev mailing list