Re: [PATCH] PCI: Fix build error when CONFIG_PCI_MSI disabled
From: Bjorn Helgaas
Date: Tue Feb 14 2023 - 17:24:10 EST
On Thu, Feb 09, 2023 at 01:49:00PM -0800, Reinette Chatre wrote:
> pci_msix_alloc_irq_at() and pci_msix_free_irq() are not
> declared when CONFIG_PCI_MSI is disabled.
>
> Users of these two calls do not yet exist but when users
> do appear (shown below is an attempt to use the new API
> in vfio-pci) the following errors will be encountered when
> compiling with CONFIG_PCI_MSI disabled:
> drivers/vfio/pci/vfio_pci_intrs.c:461:4: error: implicit declaration of\
> function 'pci_msix_free_irq' is invalid in C99\
> [-Werror,-Wimplicit-function-declaration]
> pci_msix_free_irq(pdev, msix_map);
> ^
> drivers/vfio/pci/vfio_pci_intrs.c:461:4: note: did you mean 'pci_ims_free_irq'?
> include/linux/pci.h:2516:6: note: 'pci_ims_free_irq' declared here
> void pci_ims_free_irq(struct pci_dev *pdev, struct msi_map map);
> ^
> drivers/vfio/pci/vfio_pci_intrs.c:511:15: error: implicit declaration of\
> function 'pci_msix_alloc_irq_at' is invalid in C99\
> [-Werror,-Wimplicit-function-declaration]
> msix_map = pci_msix_alloc_irq_at(pdev, vector, NULL);
> ^
> drivers/vfio/pci/vfio_pci_intrs.c:511:15: note: did you mean 'pci_ims_alloc_irq'?
> include/linux/pci.h:2514:16: note: 'pci_ims_alloc_irq' declared here
> struct msi_map pci_ims_alloc_irq(struct pci_dev *pdev,\
> union msi_instance_cookie *icookie,
>
> Provide definitions for pci_msix_alloc_irq_at() and pci_msix_free_irq() in
> preparation for users that need to compile when CONFIG_PCI_MSI is
> disabled.
I think this should have a "Fixes:" tag to connect it with the commit
that added pci_msix_alloc_irq_at() and pci_msix_free_irq().
Looks like 34026364df8e ("PCI/MSI: Provide post-enable dynamic
allocation interfaces for MSI-X").
Thomas merged 34026364df8e, so it would be best if he took the fixup
as well.
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> ---
>
> checkpatch.pl warns about the usage of -ENOSYS but it does appear
> to be the custom.
>
> include/linux/pci.h | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index adffd65e84b4..448482d1c4fe 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1621,6 +1621,19 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
> flags, NULL);
> }
>
> +static inline struct msi_map
> +pci_msix_alloc_irq_at(struct pci_dev *dev, unsigned int index,
> + const struct irq_affinity_desc *affdesc)
> +{
> + struct msi_map map = { .index = -ENOSYS };
> +
> + return map;
> +}
> +
> +static inline void pci_msix_free_irq(struct pci_dev *pdev, struct msi_map map)
> +{
> +}
> +
> static inline void pci_free_irq_vectors(struct pci_dev *dev)
> {
> }
> --
> 2.34.1
>