linux-stable/drivers/pci
Ming Lei 5ab9b2bc8a PCI/MSI: Return -ENOSPC from pci_alloc_irq_vectors_affinity()
[ Upstream commit 77f88abd4a ]

The API of pci_alloc_irq_vectors_affinity() says it returns -ENOSPC if
fewer than @min_vecs interrupt vectors are available for @dev.

However, if a device supports MSI-X but not MSI and a caller requests
@min_vecs that can't be satisfied by MSI-X, we previously returned -EINVAL
(from the failed attempt to enable MSI), not -ENOSPC.

When -ENOSPC is returned, callers may reduce the number IRQs they request
and try again.  Most callers can use the @min_vecs and @max_vecs
parameters to avoid this retry loop, but that doesn't work when using IRQ
affinity "nr_sets" because rebalancing the sets is driver-specific.

This return value bug has been present since pci_alloc_irq_vectors() was
added in v4.10 by aff171641d ("PCI: Provide sensible IRQ vector
alloc/free routines"), but it wasn't an issue because @min_vecs/@max_vecs
removed the need for callers to iteratively reduce the number of IRQs
requested and retry the allocation, so they didn't need to distinguish
-ENOSPC from -EINVAL.

In v5.0, 6da4b3ab9a ("genirq/affinity: Add support for allocating
interrupt sets") added IRQ sets to the interface, which reintroduced the
need to check for -ENOSPC and possibly reduce the number of IRQs requested
and retry the allocation.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-12-05 15:37:55 +01:00
..
dwc PCI: keystone: Use quirk to limit MRRS for K2G 2019-12-01 09:14:13 +01:00
endpoint PCI: endpoint: Use EPC's device in dma_alloc_coherent()/dma_free_coherent() 2019-03-27 14:13:55 +09:00
host PCI: vmd: Detach resources after stopping root bus 2019-12-01 09:13:40 +01:00
hotplug PCI: rpadlpar: Fix leaked device_node references in add/remove paths 2019-06-15 11:54:56 +02:00
pcie PCI/PME: Fix possible use-after-free on remove 2019-11-06 12:42:59 +01:00
switch switchtec: Fix SWITCHTEC_IOCTL_EVENT_IDX_ALL flags overwrite 2019-02-12 19:46:04 +01:00
access.c
ats.c
bus.c
ecam.c
host-bridge.c
hotplug-pci.c
htirq.c
iov.c
irq.c
Kconfig
Makefile
mmap.c
msi.c PCI/MSI: Return -ENOSPC from pci_alloc_irq_vectors_affinity() 2019-12-05 15:37:55 +01:00
of.c
pci-acpi.c PCI / ACPI: Enable wake automatically for power managed bridges 2018-11-13 11:14:58 -08:00
pci-driver.c PCI: Always allow probing with driver_override 2019-09-19 09:08:06 +02:00
pci-label.c
pci-mid.c x86/cpu: Sanitize FAM6_ATOM naming 2019-05-14 19:18:42 +02:00
pci-stub.c
pci-sysfs.c PCI: sysfs: Ignore lockdep for remove attribute 2019-07-31 07:28:52 +02:00
pci.c PCI: PM: Fix pci_power_up() 2019-10-29 09:17:45 +01:00
pci.h
probe.c PCI: Skip MPS logic for Virtual Functions (VFs) 2018-08-24 13:09:22 +02:00
proc.c
quirks.c PCI: Work around Pericom PCIe-to-PCI bridge Retrain Link erratum 2019-05-25 18:25:32 +02:00
remove.c PCI/ASPM: Fix link_state teardown on device removal 2018-11-13 11:15:07 -08:00
rom.c
search.c
setup-bus.c
setup-irq.c
setup-res.c
slot.c
syscall.c
vc.c
vpd.c
xen-pcifront.c