Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Mar 2017 17:49:38 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315421 - in head/sys: arm64/cavium dev/pci
Message-ID:  <201703161749.v2GHncYp059950@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Thu Mar 16 17:49:37 2017
New Revision: 315421
URL: https://svnweb.freebsd.org/changeset/base/315421

Log:
  If ofw_bus_msimap fails don't try to use the invalid MSI/MSI-X parent node.
  
  Sponsored by:	ABT Systems Ltd

Modified:
  head/sys/arm64/cavium/thunder_pcie_pem_fdt.c
  head/sys/dev/pci/pci_host_generic_fdt.c

Modified: head/sys/arm64/cavium/thunder_pcie_pem_fdt.c
==============================================================================
--- head/sys/arm64/cavium/thunder_pcie_pem_fdt.c	Thu Mar 16 16:53:22 2017	(r315420)
+++ head/sys/arm64/cavium/thunder_pcie_pem_fdt.c	Thu Mar 16 17:49:37 2017	(r315421)
@@ -114,9 +114,12 @@ thunder_pem_fdt_alloc_msi(device_t pci, 
     int *irqs)
 {
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_alloc_msi(pci, child, msi_parent, count, maxcount,
 	    irqs));
 }
@@ -125,9 +128,12 @@ static int
 thunder_pem_fdt_release_msi(device_t pci, device_t child, int count, int *irqs)
 {
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_release_msi(pci, child, msi_parent, count, irqs));
 }
 
@@ -135,9 +141,12 @@ static int
 thunder_pem_fdt_alloc_msix(device_t pci, device_t child, int *irq)
 {
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_alloc_msix(pci, child, msi_parent, irq));
 }
 
@@ -145,9 +154,12 @@ static int
 thunder_pem_fdt_release_msix(device_t pci, device_t child, int irq)
 {
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_release_msix(pci, child, msi_parent, irq));
 }
 
@@ -156,9 +168,12 @@ thunder_pem_fdt_map_msi(device_t pci, de
     uint32_t *data)
 {
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_map_msi(pci, child, msi_parent, irq, addr, data));
 }
 
@@ -167,6 +182,7 @@ thunder_pem_fdt_get_id(device_t dev, dev
     uintptr_t *id)
 {
 	phandle_t node;
+	int err;
 	uint32_t rid;
 	uint16_t pci_rid;
 
@@ -176,7 +192,9 @@ thunder_pem_fdt_get_id(device_t dev, dev
 	node = ofw_bus_get_node(dev);
 	pci_rid = pci_get_rid(child);
 
-	ofw_bus_msimap(node, pci_rid, NULL, &rid);
+	err = ofw_bus_msimap(node, pci_rid, NULL, &rid);
+	if (err != 0)
+		return (err);
 	*id = rid;
 
 	return (0);

Modified: head/sys/dev/pci/pci_host_generic_fdt.c
==============================================================================
--- head/sys/dev/pci/pci_host_generic_fdt.c	Thu Mar 16 16:53:22 2017	(r315420)
+++ head/sys/dev/pci/pci_host_generic_fdt.c	Thu Mar 16 17:49:37 2017	(r315421)
@@ -461,9 +461,12 @@ generic_pcie_fdt_alloc_msi(device_t pci,
 {
 #if defined(INTRNG)
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_alloc_msi(pci, child, msi_parent, count, maxcount,
 	    irqs));
 #else
@@ -476,9 +479,12 @@ generic_pcie_fdt_release_msi(device_t pc
 {
 #if defined(INTRNG)
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_release_msi(pci, child, msi_parent, count, irqs));
 #else
 	return (ENXIO);
@@ -491,9 +497,12 @@ generic_pcie_fdt_map_msi(device_t pci, d
 {
 #if defined(INTRNG)
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_map_msi(pci, child, msi_parent, irq, addr, data));
 #else
 	return (ENXIO);
@@ -505,9 +514,12 @@ generic_pcie_fdt_alloc_msix(device_t pci
 {
 #if defined(INTRNG)
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_alloc_msix(pci, child, msi_parent, irq));
 #else
 	return (ENXIO);
@@ -519,9 +531,12 @@ generic_pcie_fdt_release_msix(device_t p
 {
 #if defined(INTRNG)
 	phandle_t msi_parent;
+	int err;
 
-	ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent,
-	    NULL);
+	err = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child),
+	    &msi_parent, NULL);
+	if (err != 0)
+		return (err);
 	return (intr_release_msix(pci, child, msi_parent, irq));
 #else
 	return (ENXIO);
@@ -533,6 +548,7 @@ generic_pcie_get_id(device_t pci, device
     uintptr_t *id)
 {
 	phandle_t node;
+	int err;
 	uint32_t rid;
 	uint16_t pci_rid;
 
@@ -542,7 +558,9 @@ generic_pcie_get_id(device_t pci, device
 	node = ofw_bus_get_node(pci);
 	pci_rid = pci_get_rid(child);
 
-	ofw_bus_msimap(node, pci_rid, NULL, &rid);
+	err = ofw_bus_msimap(node, pci_rid, NULL, &rid);
+	if (err != 0)
+		return (err);
 	*id = rid;
 
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703161749.v2GHncYp059950>