linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Gordeev <agordeev@redhat.com>, linux-pci@vger.kernel.org
Subject: [PATCH 1/2] PCI/msi: check that we have a legacy interrupt line before using it
Date: Wed,  1 Feb 2017 14:41:42 +0100	[thread overview]
Message-ID: <1485956503-8194-2-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1485956503-8194-1-git-send-email-hch@lst.de>

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 --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;
-- 
2.1.4

  reply	other threads:[~2017-02-01 13:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 13:41 convert the PCIe portdrv to pci_alloc_irq_vectors Christoph Hellwig
2017-02-01 13:41 ` Christoph Hellwig [this message]
2017-02-01 13:41 ` [PATCH 2/2] PCI/portdrv: use pci_irq_alloc_vectors Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1485956503-8194-2-git-send-email-hch@lst.de \
    --to=hch@lst.de \
    --cc=agordeev@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).