mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-15 09:34:17 +00:00
PCI/MSI: Allow arch code to return the number of MSI-X available
There is code in msix_capability_init() which, when the requested number of MSI-X couldn't be allocated, calculates how many MSI-X /could/ be allocated and returns that to the driver. That allows the driver to then make a second request, with a number of MSIs that should succeed. The current code requires the arch code to setup as many msi_descs as it can, and then return to the generic code. On some platforms the arch code may already know how many MSI-X it can allocate, before it sets up any of the msi_descs. So change the logic such that if the arch code returns a positive error code, that is taken to be the number of MSI-X that could be allocated. If the error code is negative we still calculate the number available using the old method. Because it's a little subtle, make sure the error return code from arch_setup_msi_irq() is always negative. That way only implementations of arch_setup_msi_irqs() need to be careful about returning a positive error code. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
35e1801ea6
commit
b5fbf53324
@ -42,8 +42,10 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
|
|||||||
|
|
||||||
list_for_each_entry(entry, &dev->msi_list, list) {
|
list_for_each_entry(entry, &dev->msi_list, list) {
|
||||||
ret = arch_setup_msi_irq(dev, entry);
|
ret = arch_setup_msi_irq(dev, entry);
|
||||||
if (ret)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
if (ret > 0)
|
||||||
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -487,7 +489,9 @@ static int msix_capability_init(struct pci_dev *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
|
ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
|
||||||
if (ret) {
|
if (ret < 0) {
|
||||||
|
/* If we had some success report the number of irqs
|
||||||
|
* we succeeded in setting up. */
|
||||||
int avail = 0;
|
int avail = 0;
|
||||||
list_for_each_entry(entry, &dev->msi_list, list) {
|
list_for_each_entry(entry, &dev->msi_list, list) {
|
||||||
if (entry->irq != 0) {
|
if (entry->irq != 0) {
|
||||||
@ -495,14 +499,13 @@ static int msix_capability_init(struct pci_dev *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msi_free_irqs(dev);
|
if (avail != 0)
|
||||||
|
ret = avail;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we had some success report the number of irqs
|
if (ret) {
|
||||||
* we succeeded in setting up.
|
msi_free_irqs(dev);
|
||||||
*/
|
return ret;
|
||||||
if (avail == 0)
|
|
||||||
avail = ret;
|
|
||||||
return avail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user