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


Groups > linux.kernel > #1342682

[PATCH v10 01/59] PCI: Add pci_find_root_bus_resource()

From Yinghai Lu <yinghai@kernel.org>
Newsgroups linux.kernel
Subject [PATCH v10 01/59] PCI: Add pci_find_root_bus_resource()
Date 2016-02-25 03:40 +0100
Message-ID <r5U0p-5vw-11@gated-at.bofh.it> (permalink)
References <r5TH3-5ok-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add pci_find_root_bus_resource() to return root bus resource
for input resource.

For sparc mem64 support, We need that host bridge window res:
  1. we need direct parent for request_resource_conflict() calling in
      pci_register_legacy_regions().
  2. check if return is NULL to decide if region is valid or not.

Convert old pci_find_parent_resource() to pci_find_bus_resource(),
and use it in pci_find_root_bus_resource() and new
pci_find_parent_resource().

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/pci.c   | 36 +++++++++++++++++++++++++-----------
 include/linux/pci.h |  2 ++
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 602eb42..db4025f 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -415,18 +415,9 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap)
 }
 EXPORT_SYMBOL_GPL(pci_find_ht_capability);
 
-/**
- * pci_find_parent_resource - return resource region of parent bus of given region
- * @dev: PCI device structure contains resources to be searched
- * @res: child resource record for which parent is sought
- *
- *  For given resource region of given device, return the resource
- *  region of parent bus the given region is contained in.
- */
-struct resource *pci_find_parent_resource(const struct pci_dev *dev,
-					  struct resource *res)
+static struct resource *pci_find_bus_resource(const struct pci_bus *bus,
+					      struct resource *res)
 {
-	const struct pci_bus *bus = dev->bus;
 	struct resource *r;
 	int i;
 
@@ -456,8 +447,31 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev,
 	}
 	return NULL;
 }
+
+/**
+ * pci_find_parent_resource - return resource region of parent bus of given region
+ * @dev: PCI device structure contains resources to be searched
+ * @res: child resource record for which parent is sought
+ *
+ *  For given resource region of given device, return the resource
+ *  region of parent bus the given region is contained in.
+ */
+struct resource *pci_find_parent_resource(const struct pci_dev *dev,
+					  struct resource *res)
+{
+	return pci_find_bus_resource(dev->bus, res);
+}
 EXPORT_SYMBOL(pci_find_parent_resource);
 
+struct resource *pci_find_root_bus_resource(struct pci_bus *bus,
+					    struct resource *res)
+{
+	while (bus->parent)
+		bus = bus->parent;
+
+	return pci_find_bus_resource(bus, res);
+}
+
 /**
  * pci_find_pcie_root_port - return PCIe Root Port
  * @dev: PCI device to query
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 27df4a6..dd603a668 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -792,6 +792,8 @@ void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
 			     struct resource *res);
 void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region);
+struct resource *pci_find_root_bus_resource(struct pci_bus *bus,
+					    struct resource *res);
 void pcibios_scan_specific_bus(int busn);
 struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-- 
1.8.4.5

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


Thread

[PATCH v10 00/59] PCI: Resource allocation cleanup for v4.6 Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 16/59] PCI: Don't release fixed resource for realloc Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 12/59] PCI: Only treat non-pref mmio64 as pref if all bridges have MEM_64 Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 04/59] sparc/PCI: Add IORESOURCE_MEM_64 for 64-bit resource in OF parsing Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 14/59] PCI: Only treat non-pref mmio64 as pref if host bridge has mmio64 Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 41/59] PCI: Skip required+optional if there is no optional Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 01/59] PCI: Add pci_find_root_bus_resource() Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 07/59] PCI: Ignore BAR for ALi M1533 PCI-ISA bridge Yinghai Lu <yinghai@kernel.org> - 2016-02-25 03:40 +0100
  [PATCH v10 13/59] PCI: Add has_mem64 for struct host_bridge Yinghai Lu <yinghai@kernel.org> - 2016-02-25 04:20 +0100
  [PATCH v10 27/59] PCI: Optimize bus align/size calculation for optional during sizing Yinghai Lu <yinghai@kernel.org> - 2016-02-25 04:20 +0100
  [PATCH v10 33/59] PCI: Add debug printout during releasing partial assigned resources Yinghai Lu <yinghai@kernel.org> - 2016-02-25 04:20 +0100
  [PATCH v10 19/59] PCI: Separate realloc list checking after allocation Yinghai Lu <yinghai@kernel.org> - 2016-02-25 04:20 +0100
  [PATCH v10 23/59] PCI: Cleanup res_to_dev_res() printout Yinghai Lu <yinghai@kernel.org> - 2016-02-25 04:20 +0100

csiph-web