From 1beaee0c3abda3a8e71fa5d9f50493cedc11ef8a Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 16 May 2016 12:18:30 +0000 Subject: [PATCH] Call ofw_bus_msimap to find the parent MSI controller, it may not use the msi-parent property. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/dev/pci/pci_host_generic.c | 39 +++++++++++++++++----------------- sys/dev/pci/pci_host_generic.h | 1 - 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index 9be0a03f1ef6..8cc0b798cd4c 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -235,10 +235,6 @@ pci_host_generic_attach(device_t dev) node = ofw_bus_get_node(dev); ofw_bus_setup_iinfo(node, &sc->pci_iinfo, sizeof(cell_t)); - /* Find the MSI interrupt handler */ - OF_searchencprop(node, "msi-parent", &sc->msi_parent, - sizeof(sc->msi_parent)); - device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } @@ -671,10 +667,11 @@ generic_pcie_alloc_msi(device_t pci, device_t child, int count, int maxcount, int *irqs) { #if defined(INTRNG) - struct generic_pcie_softc *sc; + phandle_t msi_parent; - sc = device_get_softc(pci); - return (intr_alloc_msi(pci, child, sc->msi_parent, count, maxcount, + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_alloc_msi(pci, child, msi_parent, count, maxcount, irqs)); #elif defined(__aarch64__) return (arm_alloc_msi(pci, child, count, maxcount, irqs)); @@ -687,10 +684,11 @@ static int generic_pcie_release_msi(device_t pci, device_t child, int count, int *irqs) { #if defined(INTRNG) - struct generic_pcie_softc *sc; + phandle_t msi_parent; - sc = device_get_softc(pci); - return (intr_release_msi(pci, child, sc->msi_parent, count, irqs)); + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_release_msi(pci, child, msi_parent, count, irqs)); #elif defined(__aarch64__) return (arm_release_msi(pci, child, count, irqs)); #else @@ -703,10 +701,11 @@ generic_pcie_map_msi(device_t pci, device_t child, int irq, uint64_t *addr, uint32_t *data) { #if defined(INTRNG) - struct generic_pcie_softc *sc; + phandle_t msi_parent; - sc = device_get_softc(pci); - return (intr_map_msi(pci, child, sc->msi_parent, irq, addr, data)); + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_map_msi(pci, child, msi_parent, irq, addr, data)); #elif defined(__aarch64__) return (arm_map_msi(pci, child, irq, addr, data)); #else @@ -718,10 +717,11 @@ static int generic_pcie_alloc_msix(device_t pci, device_t child, int *irq) { #if defined(INTRNG) - struct generic_pcie_softc *sc; + phandle_t msi_parent; - sc = device_get_softc(pci); - return (intr_alloc_msix(pci, child, sc->msi_parent, irq)); + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_alloc_msix(pci, child, msi_parent, irq)); #elif defined(__aarch64__) return (arm_alloc_msix(pci, child, irq)); #else @@ -733,10 +733,11 @@ static int generic_pcie_release_msix(device_t pci, device_t child, int irq) { #if defined(INTRNG) - struct generic_pcie_softc *sc; + phandle_t msi_parent; - sc = device_get_softc(pci); - return (intr_release_msix(pci, child, sc->msi_parent, irq)); + ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, + NULL); + return (intr_release_msix(pci, child, msi_parent, irq)); #elif defined(__aarch64__) return (arm_release_msix(pci, child, irq)); #else diff --git a/sys/dev/pci/pci_host_generic.h b/sys/dev/pci/pci_host_generic.h index 050ac6da6a26..2f8bd8341a99 100644 --- a/sys/dev/pci/pci_host_generic.h +++ b/sys/dev/pci/pci_host_generic.h @@ -60,7 +60,6 @@ struct generic_pcie_softc { bus_space_handle_t ioh; #ifdef FDT struct ofw_bus_iinfo pci_iinfo; - phandle_t msi_parent; #endif };