Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1228278

[PATCH] PCI/MSI: Fix MSI IRQ domains for SR-IOV

From Alex Williamson <alex.williamson@redhat.com>
Newsgroups linux.kernel
Subject [PATCH] PCI/MSI: Fix MSI IRQ domains for SR-IOV
Date 2015-09-18 23:10 +0200
Message-ID <qab4R-5Kv-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


SR-IOV creates a virtual bus where bus->self is NULL.  This results
in a segfault as VFs are added and we scan for an MSI domain without
taking that into account.  Detect this and scan up to the parent bus
until we find a real bridge.

Fixes: 44aa0c657e3e ("PCI/MSI: Add hooks to populate the msi_domain field")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/pci/probe.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0b2be17..b42419e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -676,15 +676,20 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
 static void pci_set_bus_msi_domain(struct pci_bus *bus)
 {
 	struct irq_domain *d;
+	struct pci_bus *b;
 
 	/*
-	 * Either bus is the root, and we must obtain it from the
-	 * firmware, or we inherit it from the bridge device.
+	 * The bus can be a root bus, a subordinate bus, or a virtual bus
+	 * created by an SR-IOV device.  Walk up to the first bridge device
+	 * found or derive the domain from the host bridge.
 	 */
-	if (pci_is_root_bus(bus))
-		d = pci_host_bridge_msi_domain(bus);
-	else
-		d = dev_get_msi_domain(&bus->self->dev);
+	for (b = bus, d = NULL; !d && !pci_is_root_bus(b); b = b->parent) {
+		if (b->self)
+			d = dev_get_msi_domain(&b->self->dev);
+	}
+
+	if (!d)
+		d = pci_host_bridge_msi_domain(b);
 
 	dev_set_msi_domain(&bus->dev, d);
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] PCI/MSI: Fix MSI IRQ domains for SR-IOV Alex Williamson <alex.williamson@redhat.com> - 2015-09-18 23:10 +0200
  Re: [PATCH] PCI/MSI: Fix MSI IRQ domains for SR-IOV Marc Zyngier <marc.zyngier@arm.com> - 2015-09-20 14:00 +0200
    Re: [PATCH] PCI/MSI: Fix MSI IRQ domains for SR-IOV Alex Williamson <alwillia@redhat.com> - 2015-09-21 23:30 +0200

csiph-web