Skip to content

Commit 5c0997d

Browse files
Ahmed S. DarwishKAGA-KOKO
authored andcommitted
PCI/MSI: Move pci_alloc_irq_vectors() 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. Make pci_alloc_irq_vectors() a real function instead of wrapper and add proper kernel doc to it. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent be7496c commit 5c0997d

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

drivers/pci/msi/api.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,36 @@ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
9090
return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0);
9191
}
9292
EXPORT_SYMBOL(pci_enable_msix_range);
93+
94+
/**
95+
* pci_alloc_irq_vectors() - Allocate multiple device interrupt vectors
96+
* @dev: the PCI device to operate on
97+
* @min_vecs: minimum required number of vectors (must be >= 1)
98+
* @max_vecs: maximum desired number of vectors
99+
* @flags: One or more of:
100+
* %PCI_IRQ_MSIX Allow trying MSI-X vector allocations
101+
* %PCI_IRQ_MSI Allow trying MSI vector allocations
102+
* %PCI_IRQ_LEGACY Allow trying legacy INTx interrupts, if
103+
* and only if @min_vecs == 1
104+
* %PCI_IRQ_AFFINITY Auto-manage IRQs affinity by spreading
105+
* the vectors around available CPUs
106+
*
107+
* Allocate up to @max_vecs interrupt vectors on device. MSI-X irq
108+
* vector allocation has a higher precedence over plain MSI, which has a
109+
* higher precedence over legacy INTx emulation.
110+
*
111+
* Upon a successful allocation, the caller should use pci_irq_vector()
112+
* to get the Linux IRQ number to be passed to request_threaded_irq().
113+
* The driver must call pci_free_irq_vectors() on cleanup.
114+
*
115+
* Return: number of allocated vectors (which might be smaller than
116+
* @max_vecs), -ENOSPC if less than @min_vecs interrupt vectors are
117+
* available, other errnos otherwise.
118+
*/
119+
int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
120+
unsigned int max_vecs, unsigned int flags)
121+
{
122+
return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
123+
flags, NULL);
124+
}
125+
EXPORT_SYMBOL(pci_alloc_irq_vectors);

include/linux/pci.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,8 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev,
15531553
return rc;
15541554
return 0;
15551555
}
1556+
int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
1557+
unsigned int max_vecs, unsigned int flags);
15561558
int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
15571559
unsigned int max_vecs, unsigned int flags,
15581560
struct irq_affinity *affd);
@@ -1586,6 +1588,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
15861588
return 1;
15871589
return -ENOSPC;
15881590
}
1591+
static inline int
1592+
pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
1593+
unsigned int max_vecs, unsigned int flags)
1594+
{
1595+
return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
1596+
flags, NULL);
1597+
}
15891598

15901599
static inline void pci_free_irq_vectors(struct pci_dev *dev)
15911600
{
@@ -1898,15 +1907,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
18981907
{
18991908
return -ENOSPC;
19001909
}
1901-
#endif /* CONFIG_PCI */
1902-
19031910
static inline int
19041911
pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
19051912
unsigned int max_vecs, unsigned int flags)
19061913
{
1907-
return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags,
1908-
NULL);
1914+
return -ENOSPC;
19091915
}
1916+
#endif /* CONFIG_PCI */
19101917

19111918
/* Include architecture-dependent settings and functions */
19121919

0 commit comments

Comments
 (0)