diff mbox

[1/2] PCI/msi: check that we have a legacy interrupt line before using it

Message ID 1485956503-8194-2-git-send-email-hch@lst.de (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Christoph Hellwig Feb. 1, 2017, 1:41 p.m. UTC
It seems like there are some devices (e.g. the PCIe root port driver) that
may not always have a INTx interrupt.  Check for dev->irq before returning
a legacy interrupt in pci_irq_alloc_vectors to properly handle this case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/pci/msi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 16dda43..98525f6 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1217,9 +1217,11 @@  int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
 	}
 
 	/* use legacy irq if allowed */
-	if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1) {
-		pci_intx(dev, 1);
-		return 1;
+	if (flags & PCI_IRQ_LEGACY) {
+		if (min_vecs == 1 && dev->irq) {
+			pci_intx(dev, 1);
+			return 1;
+		}
 	}
 
 	return vecs;