LinuxKPI: fix pci_alloc_irq_vectors() for MSI
pci_alloc_irq_vectors() is given a min and max vector value. pci_enable_msi() will always succeed independent of these arguments as it does not know about them. Further it will only ever allocate 1 "vector" not supporting any other amount. So upfront check that (a) the available pci_msi_count() can satisfy the requested minv and (b) given the pci_enable_msi() hard coded limit check that minv is not larger than 1. If we cannot satisfy either requirement return an error. This fixes problems with drivers which check that the returned value of allocated "vectors" will match their requests and only otherwise try to fall back to ask for 1 or deal otherwise. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: hselasky (earlier version) Differential Revision: https://reviews.freebsd.org/D37522
This commit is contained in:
parent
75388b9ca5
commit
e9715b1c44
@ -931,6 +931,11 @@ pci_alloc_irq_vectors(struct pci_dev *pdev, int minv, int maxv,
|
||||
return (pdev->dev.irq_end - pdev->dev.irq_start);
|
||||
}
|
||||
if (flags & PCI_IRQ_MSI) {
|
||||
if (pci_msi_count(pdev->dev.bsddev) < minv)
|
||||
return (-ENOSPC);
|
||||
/* We only support 1 vector in pci_enable_msi() */
|
||||
if (minv != 1)
|
||||
return (-ENOSPC);
|
||||
error = pci_enable_msi(pdev);
|
||||
if (error == 0 && pdev->msi_enabled)
|
||||
return (pdev->dev.irq_end - pdev->dev.irq_start);
|
||||
|
Loading…
Reference in New Issue
Block a user