PCI/MSI: Move pci_enable_msix_range() to api.c

To disentangle the maze in msi.c, all exported device-driver MSI APIs are
now to be grouped in one file, api.c.

Move pci_enable_msix_range() and make its kernel-doc comprehensive.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20221111122014.813792885@linutronix.de
This commit is contained in:
Ahmed S. Darwish 2022-11-11 14:54:48 +01:00 committed by Thomas Gleixner
parent bbda340798
commit be7496c1ef
3 changed files with 39 additions and 26 deletions

View File

@ -58,3 +58,35 @@ void pci_disable_msi(struct pci_dev *dev)
msi_unlock_descs(&dev->dev);
}
EXPORT_SYMBOL(pci_disable_msi);
/**
* pci_enable_msix_range() - Enable MSI-X interrupt mode on device
* @dev: the PCI device to operate on
* @entries: input/output parameter, array of MSI-X configuration entries
* @minvec: minimum required number of MSI-X vectors
* @maxvec: maximum desired number of MSI-X vectors
*
* Legacy device driver API to enable MSI-X interrupt mode on device and
* configure its MSI-X capability structure as appropriate. The passed
* @entries array must have each of its members "entry" field set to a
* desired (valid) MSI-X vector number, where the range of valid MSI-X
* vector numbers can be queried through pci_msix_vec_count(). If
* successful, the driver must invoke pci_disable_msix() on cleanup.
*
* NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API
* pair should, in general, be used instead.
*
* Return: number of MSI-X vectors allocated (which might be smaller
* than @maxvecs), where Linux IRQ numbers for such allocated vectors
* are saved back in the @entries array elements' "vector" field. Return
* -ENOSPC if less than @minvecs interrupt vectors are available.
* Return -EINVAL if one of the passed @entries members "entry" field
* was invalid or a duplicate, or if plain MSI interrupts mode was
* earlier enabled on device. Return other errnos otherwise.
*/
int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
int minvec, int maxvec)
{
return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0);
}
EXPORT_SYMBOL(pci_enable_msix_range);

View File

@ -844,7 +844,7 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
}
}
static int __pci_enable_msix_range(struct pci_dev *dev,
int __pci_enable_msix_range(struct pci_dev *dev,
struct msix_entry *entries, int minvec,
int maxvec, struct irq_affinity *affd,
int flags)
@ -886,28 +886,6 @@ static int __pci_enable_msix_range(struct pci_dev *dev,
}
}
/**
* pci_enable_msix_range - configure device's MSI-X capability structure
* @dev: pointer to the pci_dev data structure of MSI-X device function
* @entries: pointer to an array of MSI-X entries
* @minvec: minimum number of MSI-X IRQs requested
* @maxvec: maximum number of MSI-X IRQs requested
*
* Setup the MSI-X capability structure of device function with a maximum
* possible number of interrupts in the range between @minvec and @maxvec
* upon its software driver call to request for MSI-X mode enabled on its
* hardware device function. It returns a negative errno if an error occurs.
* If it succeeds, it returns the actual number of interrupts allocated and
* indicates the successful configuration of MSI-X capability structure
* with new allocated MSI-X interrupts.
**/
int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
int minvec, int maxvec)
{
return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0);
}
EXPORT_SYMBOL(pci_enable_msix_range);
/**
* pci_alloc_irq_vectors_affinity - allocate multiple IRQs for a device
* @dev: PCI device to operate on

View File

@ -88,8 +88,11 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc)
void pci_msi_shutdown(struct pci_dev *dev);
void pci_free_msi_irqs(struct pci_dev *dev);
int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd);
int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec,
int maxvec, struct irq_affinity *affd, int flags);
/* Legacy (!IRQDOMAIN) fallbacks */
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev);