From: Bjorn Helgaas <bhelgaas@google.com>
To: linux-pci@vger.kernel.org
Cc: linux-arch@vger.kernel.org, Chris Zankel <chris@zankel.net>
Subject: [PATCH v3 33/34] xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources
Date: Fri, 28 Oct 2011 16:28:19 -0600 [thread overview]
Message-ID: <20111028222819.30729.1845.stgit@bhelgaas.mtv.corp.google.com> (raw)
In-Reply-To: <20111028222432.30729.8431.stgit@bhelgaas.mtv.corp.google.com>
Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
fixups. This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.
This arch was unusual because it filled in bus->resource[0..3] in
pcibios_init(), then overwrote them, applied io_space.offset and
checked for unset resources in pcibios_fixup_bus(). I moved all of
that to a new pci_controller_apertures() that we can use before
scanning the root bus.
CC: Chris Zankel <chris@zankel.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/xtensa/kernel/pci.c | 85 +++++++++++++++++++++++-----------------------
1 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index cd10269..48ec2a8 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -134,9 +134,46 @@ struct pci_controller * __init pcibios_alloc_controller(void)
return pci_ctrl;
}
+static void __init pci_controller_apertures(struct pci_controller *pci_ctrl,
+ struct list_head *resources)
+{
+ struct resource *res;
+ unsigned long io_offset;
+ int i;
+
+ io_offset = (unsigned long)pci_ctrl->io_space.base;
+ res = &pci_ctrl->io_resource;
+ if (!res->flags) {
+ if (io_offset)
+ printk (KERN_ERR "I/O resource not set for host"
+ " bridge %d\n", pci_ctrl->index);
+ res->start = 0;
+ res->end = IO_SPACE_LIMIT;
+ res->flags = IORESOURCE_IO;
+ }
+ res->start += io_offset;
+ res->end += io_offset;
+ pci_add_resource(resources, res);
+
+ for (i = 0; i < 3; i++) {
+ res = &pci_ctrl->mem_resources[i];
+ if (!res->flags) {
+ if (i > 0)
+ continue;
+ printk(KERN_ERR "Memory resource not set for "
+ "host bridge %d\n", pci_ctrl->index);
+ res->start = 0;
+ res->end = ~0U;
+ res->flags = IORESOURCE_MEM;
+ }
+ pci_add_resource(resources, res);
+ }
+}
+
static int __init pcibios_init(void)
{
struct pci_controller *pci_ctrl;
+ struct list_head resources;
struct pci_bus *bus;
int next_busno = 0, i;
@@ -145,19 +182,10 @@ static int __init pcibios_init(void)
/* Scan all of the recorded PCI controllers. */
for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next) {
pci_ctrl->last_busno = 0xff;
- bus = pci_scan_bus(pci_ctrl->first_busno, pci_ctrl->ops,
- pci_ctrl);
- if (pci_ctrl->io_resource.flags) {
- unsigned long offs;
-
- offs = (unsigned long)pci_ctrl->io_space.base;
- pci_ctrl->io_resource.start += offs;
- pci_ctrl->io_resource.end += offs;
- bus->resource[0] = &pci_ctrl->io_resource;
- }
- for (i = 0; i < 3; ++i)
- if (pci_ctrl->mem_resources[i].flags)
- bus->resource[i+1] =&pci_ctrl->mem_resources[i];
+ INIT_LIST_HEAD(&resources);
+ pci_controller_apertures(pci_ctrl, &resources);
+ bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno,
+ pci_ctrl->ops, pci_ctrl, &resources);
pci_ctrl->bus = bus;
pci_ctrl->last_busno = bus->subordinate;
if (next_busno <= pci_ctrl->last_busno)
@@ -178,36 +206,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
int i;
io_offset = (unsigned long)pci_ctrl->io_space.base;
- if (bus->parent == NULL) {
- /* this is a host bridge - fill in its resources */
- pci_ctrl->bus = bus;
-
- bus->resource[0] = res = &pci_ctrl->io_resource;
- if (!res->flags) {
- if (io_offset)
- printk (KERN_ERR "I/O resource not set for host"
- " bridge %d\n", pci_ctrl->index);
- res->start = 0;
- res->end = IO_SPACE_LIMIT;
- res->flags = IORESOURCE_IO;
- }
- res->start += io_offset;
- res->end += io_offset;
-
- for (i = 0; i < 3; i++) {
- res = &pci_ctrl->mem_resources[i];
- if (!res->flags) {
- if (i > 0)
- continue;
- printk(KERN_ERR "Memory resource not set for "
- "host bridge %d\n", pci_ctrl->index);
- res->start = 0;
- res->end = ~0U;
- res->flags = IORESOURCE_MEM;
- }
- bus->resource[i+1] = res;
- }
- } else {
+ if (bus->parent) {
/* This is a subordinate bridge */
pci_read_bridge_bases(bus);
next prev parent reply other threads:[~2011-10-28 22:28 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-28 22:25 [PATCH v3 00/34] Create PCI root buses with correct resources Bjorn Helgaas
2011-10-28 22:25 ` [PATCH v3 01/34] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
2011-12-05 19:54 ` Jesse Barnes
2011-10-28 22:25 ` [PATCH v3 02/34] PCI: show host bridges and root bus resources Bjorn Helgaas
2011-10-28 22:25 ` Bjorn Helgaas
2011-10-28 22:25 ` [PATCH v3 03/34] PCI: add pci_create_root_bus() that accepts resource list Bjorn Helgaas
2011-10-28 22:25 ` [PATCH v3 04/34] PCI: add pci_scan_root_bus() " Bjorn Helgaas
2011-10-28 22:25 ` [PATCH v3 05/34] PCI: convert pci_scan_bus() to use pci_create_root_bus() Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 06/34] PCI: convert pci_scan_bus_parented() " Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 07/34] PCI: deprecate pci_scan_bus_parented() Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 08/34] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-12-16 21:24 ` Bjorn Helgaas
2012-01-04 17:38 ` Jesse Barnes
2012-01-04 17:38 ` Jesse Barnes
2011-10-28 22:26 ` [PATCH v3 09/34] arm/PCI: " Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-12-23 1:10 ` Bjorn Helgaas
2012-01-04 17:28 ` Jesse Barnes
2012-01-04 17:28 ` Jesse Barnes
2011-10-28 22:26 ` [PATCH v3 10/34] frv/PCI: " Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 11/34] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 12/34] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 13/34] microblaze/PCI: fix pci_bus_for_each_resource() usage Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 14/34] microblaze/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 15/34] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 16/34] microblaze/PCI: use pci_scan_root_bus() Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:26 ` [PATCH v3 17/34] mips/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:26 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 18/34] mn10300/PCI: " Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 19/34] parisc/PCI: dino: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 20/34] parisc/PCI: dino: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 21/34] parisc/PCI: lba: deal with LMMIO/PAT overlaps before creating PCI root bus Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 22/34] parisc/PCI: lba: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 23/34] parisc/PCI: lba: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 24/34] powerpc/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 25/34] powerpc/PCI: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-12-06 18:07 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 26/34] powerpc/PCI: convert to pci_create_root_bus() Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-12-06 18:09 ` Bjorn Helgaas
2011-12-06 18:09 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 27/34] sh/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 28/34] sparc/PCI: convert to pci_create_root_bus() Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:27 ` [PATCH v3 29/34] sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-28 22:27 ` Bjorn Helgaas
2011-10-28 22:28 ` [PATCH v3 30/34] x86/PCI: read Broadcom CNB20LE host bridge info before PCI scan Bjorn Helgaas
2011-10-28 22:28 ` [PATCH v3 31/34] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-28 22:28 ` Bjorn Helgaas
2011-10-28 22:28 ` [PATCH v3 32/34] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus() Bjorn Helgaas
2011-10-28 22:28 ` Bjorn Helgaas
2011-10-28 22:28 ` Bjorn Helgaas [this message]
2011-10-28 22:28 ` [PATCH v3 34/34] PCI: remove pci_create_bus() Bjorn Helgaas
2011-10-29 16:25 ` [PATCH v3 00/34] Create PCI root buses with correct resources Bjorn Helgaas
2011-11-11 16:40 ` Bjorn Helgaas
2011-11-11 16:40 ` Bjorn Helgaas
2011-11-28 18:58 ` Bjorn Helgaas
2011-11-28 18:58 ` 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=20111028222819.30729.1845.stgit@bhelgaas.mtv.corp.google.com \
--to=bhelgaas@google.com \
--cc=chris@zankel.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-pci@vger.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox