From owner-svn-src-head@freebsd.org Thu Mar 16 17:49:39 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61716D0FA9D; Thu, 16 Mar 2017 17:49:39 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2370D1AF6; Thu, 16 Mar 2017 17:49:39 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2GHncVM059954; Thu, 16 Mar 2017 17:49:38 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2GHncYp059950; Thu, 16 Mar 2017 17:49:38 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201703161749.v2GHncYp059950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 16 Mar 2017 17:49:38 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2017 17:49:39 -0000 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);