From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Russell King <linux@arm.linux.org.uk>, Arnd Bergmann <arnd@arndb.de>, David Daney <david.daney@cavium.com>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Bjorn Helgaas <bhelgaas@google.com>, Yinghai Lu <yinghai@kernel.org> Subject: [PATCH v3 1/4] PCI: add generic code to claim bus resources Date: Wed, 8 Jun 2016 12:04:47 +0100 [thread overview] Message-ID: <1465383890-13538-2-git-send-email-lorenzo.pieralisi@arm.com> (raw) In-Reply-To: <1465383890-13538-1-git-send-email-lorenzo.pieralisi@arm.com> PCI core code contains a set of functions, eg: pci_assign_unassigned_bus_resources() that allow to assign the PCI resources for a given bus after enumeration. On systems where the PCI BARs are immutable (ie they must not and can not be assigned), PCI bus resources should still be inserted in the PCI resources tree (even if they are not (re)-assigned), but there is no generic PCI kernel function for that purpose. Currently the PCI bus resources insertion in the resources tree is implemented in an arch specific fashion through arch specific callbacks that rely on the PCI resources claiming API (for bridges and devices) which resulted in arches implementations that contain duplicated code to claim resources for a given PCI bus hierarchy. Based on the x86/ia64 resources claiming arch implementations, implement a set of functions in core PCI code that provides a PCI core interface for resources claiming for a given PCI bus hierarchy, paving the way for further resource claiming consolidation across architectures. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Yinghai Lu <yinghai@kernel.org> --- drivers/pci/setup-bus.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 69 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 55641a3..1d1a2c9 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1423,6 +1423,74 @@ void pci_bus_assign_resources(const struct pci_bus *bus) } EXPORT_SYMBOL(pci_bus_assign_resources); +static void pci_claim_device_resources(struct pci_dev *dev) +{ + int i; + + for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { + struct resource *r = &dev->resource[i]; + + if (!r->flags || r->parent) + continue; + + pci_claim_resource(dev, i); + } +} + +static void pci_claim_bridge_resources(struct pci_dev *dev) +{ + int i; + + for (i = PCI_BRIDGE_RESOURCES; i < PCI_NUM_RESOURCES; i++) { + struct resource *r = &dev->resource[i]; + + if (!r->flags || r->parent) + continue; + + pci_claim_bridge_resource(dev, i); + } +} + +static void pci_bus_allocate_dev_resources(struct pci_bus *b) +{ + struct pci_dev *dev; + struct pci_bus *child; + + list_for_each_entry(dev, &b->devices, bus_list) { + pci_claim_device_resources(dev); + + child = dev->subordinate; + if (child) + pci_bus_allocate_dev_resources(child); + } +} + +static void pci_bus_allocate_resources(struct pci_bus *b) +{ + struct pci_bus *child; + + /* + * Carry out a depth-first search on the PCI bus + * tree to allocate bridge apertures. Read the + * programmed bridge bases and recursively claim + * the respective bridge resources. + */ + if (b->self) { + pci_read_bridge_bases(b); + pci_claim_bridge_resources(b->self); + } + + list_for_each_entry(child, &b->children, node) + pci_bus_allocate_resources(child); +} + +void pci_bus_claim_resources(struct pci_bus *b) +{ + pci_bus_allocate_resources(b); + pci_bus_allocate_dev_resources(b); +} +EXPORT_SYMBOL(pci_bus_claim_resources); + static void __pci_bridge_assign_resources(const struct pci_dev *bridge, struct list_head *add_head, struct list_head *fail_head) diff --git a/include/linux/pci.h b/include/linux/pci.h index b67e4df..cea1a66 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1114,6 +1114,7 @@ int pci_set_vpd_size(struct pci_dev *dev, size_t len); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx); void pci_bus_assign_resources(const struct pci_bus *bus); +void pci_bus_claim_resources(struct pci_bus *bus); void pci_bus_size_bridges(struct pci_bus *bus); int pci_claim_resource(struct pci_dev *, int); int pci_claim_bridge_resource(struct pci_dev *bridge, int i); -- 2.6.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/4] PCI: add generic code to claim bus resources Date: Wed, 8 Jun 2016 12:04:47 +0100 [thread overview] Message-ID: <1465383890-13538-2-git-send-email-lorenzo.pieralisi@arm.com> (raw) In-Reply-To: <1465383890-13538-1-git-send-email-lorenzo.pieralisi@arm.com> PCI core code contains a set of functions, eg: pci_assign_unassigned_bus_resources() that allow to assign the PCI resources for a given bus after enumeration. On systems where the PCI BARs are immutable (ie they must not and can not be assigned), PCI bus resources should still be inserted in the PCI resources tree (even if they are not (re)-assigned), but there is no generic PCI kernel function for that purpose. Currently the PCI bus resources insertion in the resources tree is implemented in an arch specific fashion through arch specific callbacks that rely on the PCI resources claiming API (for bridges and devices) which resulted in arches implementations that contain duplicated code to claim resources for a given PCI bus hierarchy. Based on the x86/ia64 resources claiming arch implementations, implement a set of functions in core PCI code that provides a PCI core interface for resources claiming for a given PCI bus hierarchy, paving the way for further resource claiming consolidation across architectures. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Yinghai Lu <yinghai@kernel.org> --- drivers/pci/setup-bus.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 69 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 55641a3..1d1a2c9 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1423,6 +1423,74 @@ void pci_bus_assign_resources(const struct pci_bus *bus) } EXPORT_SYMBOL(pci_bus_assign_resources); +static void pci_claim_device_resources(struct pci_dev *dev) +{ + int i; + + for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { + struct resource *r = &dev->resource[i]; + + if (!r->flags || r->parent) + continue; + + pci_claim_resource(dev, i); + } +} + +static void pci_claim_bridge_resources(struct pci_dev *dev) +{ + int i; + + for (i = PCI_BRIDGE_RESOURCES; i < PCI_NUM_RESOURCES; i++) { + struct resource *r = &dev->resource[i]; + + if (!r->flags || r->parent) + continue; + + pci_claim_bridge_resource(dev, i); + } +} + +static void pci_bus_allocate_dev_resources(struct pci_bus *b) +{ + struct pci_dev *dev; + struct pci_bus *child; + + list_for_each_entry(dev, &b->devices, bus_list) { + pci_claim_device_resources(dev); + + child = dev->subordinate; + if (child) + pci_bus_allocate_dev_resources(child); + } +} + +static void pci_bus_allocate_resources(struct pci_bus *b) +{ + struct pci_bus *child; + + /* + * Carry out a depth-first search on the PCI bus + * tree to allocate bridge apertures. Read the + * programmed bridge bases and recursively claim + * the respective bridge resources. + */ + if (b->self) { + pci_read_bridge_bases(b); + pci_claim_bridge_resources(b->self); + } + + list_for_each_entry(child, &b->children, node) + pci_bus_allocate_resources(child); +} + +void pci_bus_claim_resources(struct pci_bus *b) +{ + pci_bus_allocate_resources(b); + pci_bus_allocate_dev_resources(b); +} +EXPORT_SYMBOL(pci_bus_claim_resources); + static void __pci_bridge_assign_resources(const struct pci_dev *bridge, struct list_head *add_head, struct list_head *fail_head) diff --git a/include/linux/pci.h b/include/linux/pci.h index b67e4df..cea1a66 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1114,6 +1114,7 @@ int pci_set_vpd_size(struct pci_dev *dev, size_t len); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx); void pci_bus_assign_resources(const struct pci_bus *bus); +void pci_bus_claim_resources(struct pci_bus *bus); void pci_bus_size_bridges(struct pci_bus *bus); int pci_claim_resource(struct pci_dev *, int); int pci_claim_bridge_resource(struct pci_dev *bridge, int i); -- 2.6.4
next prev parent reply other threads:[~2016-06-08 11:04 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-06-08 11:04 [PATCH v3 0/4] ARM/ARM64: PCI: PCI_PROBE_ONLY clean-up Lorenzo Pieralisi 2016-06-08 11:04 ` Lorenzo Pieralisi 2016-06-08 11:04 ` Lorenzo Pieralisi [this message] 2016-06-08 11:04 ` [PATCH v3 1/4] PCI: add generic code to claim bus resources Lorenzo Pieralisi 2016-06-08 11:04 ` [PATCH v3 2/4] PCI: host-generic: claim bus resources on PCI_PROBE_ONLY set-ups Lorenzo Pieralisi 2016-06-08 11:04 ` Lorenzo Pieralisi 2016-06-08 11:04 ` [PATCH v3 3/4] ARM64/PCI: remove arch specific pcibios_enable_device() Lorenzo Pieralisi 2016-06-08 11:04 ` Lorenzo Pieralisi 2016-06-08 11:04 ` [PATCH v3 4/4] ARM/PCI: " Lorenzo Pieralisi 2016-06-08 11:04 ` Lorenzo Pieralisi 2016-06-22 22:43 ` Bjorn Helgaas 2016-06-22 22:43 ` Bjorn Helgaas 2016-06-23 10:55 ` Lorenzo Pieralisi 2016-06-23 10:55 ` Lorenzo Pieralisi 2016-06-22 23:07 ` Bjorn Helgaas 2016-06-22 23:07 ` Bjorn Helgaas 2016-06-23 10:39 ` Xuetao Guan 2016-06-23 10:39 ` Xuetao Guan 2016-06-23 16:41 ` Bjorn Helgaas 2016-06-23 16:41 ` Bjorn Helgaas 2016-06-30 14:01 ` Xuetao Guan 2016-06-30 14:01 ` Xuetao Guan 2016-06-22 23:01 ` [PATCH v3 0/4] ARM/ARM64: PCI: PCI_PROBE_ONLY clean-up Bjorn Helgaas 2016-06-22 23:01 ` Bjorn Helgaas
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1465383890-13538-2-git-send-email-lorenzo.pieralisi@arm.com \ --to=lorenzo.pieralisi@arm.com \ --cc=arnd@arndb.de \ --cc=bhelgaas@google.com \ --cc=catalin.marinas@arm.com \ --cc=david.daney@cavium.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-pci@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=will.deacon@arm.com \ --cc=yinghai@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.