linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/29] Create PCI root buses with correct resources
@ 2011-10-14  4:27 Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
                   ` (29 more replies)
  0 siblings, 30 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

The most generic way to create a PCI root bus is with pci_scan_bus(), but
that doesn't allow you to specify what resources are available on the bus,
i.e., what the host bridge apertures are.

That means that pci_create_bus() has to fill in some incorrect defaults
(ioport_resource and iomem_resource), and the architecture has to fix
them later in pcibios_fixup_bus().  Between creation and fixup, we
run quirks, and they see the wrong bus resources:

  pci_scan_bus or pci_scan_bus_parented
    pci_create_bus                     <-- A create with default resources
    pci_scan_child_bus
      pci_scan_slot
        pci_scan_single_device
          pci_scan_device
            pci_setup_device
              pci_fixup_device(early)  <-- B
          pci_device_add
            pci_fixup_device(header)   <-- C
      pcibios_fixup_bus                <-- D fill in correct resources

Early and header quirks at B and C use the default (incorrect) root
bus resources rather than those filled in at D.  If they request any
regions, they get the wrong parent.  quirk_piix4_acpi() tripped over
this on MIPS and caused a driver to fail with unexpected conflicts
(http://www.spinics.net/lists/mips/msg41654.html).

A few architectures avoid this problem by using pci_create_bus()
directly and fixing the root bus resources before scanning the bus.
But that's ugly and is normally done because the arch needs a different
bus scanner, such as pci_of_scan_bus().

This series fixes the problem by adding new interfaces that take a list
of bus resources:

    pci_scan_root_bus()
    pci_create_root_bus()

To reduce backporting issues and remove cross-arch dependencies, I retained the
following interfaces unchanged, but marked them "deprecated."  

    pci_scan_bus()
    pci_scan_bus_parented() (replace with pci_scan_root_bus/pci_scan_child_bus)
    pci_create_bus()

I'm open to suggestions for improving pci_scan_root_bus().  For instance,
I wonder whether it should take a domain argument, so we could move some
of the PCI domain support into the core.

Changes since V1:
    - left existing interfaces unchanged, but deprecated
    - added pci_create_root_bus() and pci_scan_root_bus()
    - fixed many more architectures

---

Bjorn Helgaas (29):
      PCI: add helpers for building PCI bus resource lists
      PCI: add pci_create_root_bus(), deprecate pci_create_bus()
      PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented()
      MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources
      x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented()
      x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
      powerpc/PCI: make pcibios_setup_phb_resources() static
      powerpc/PCI: split PHB part out of pcibios_map_io_space()
      powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources
      microblaze/PCI: fix pci_bus_for_each_resource() usage
      microblaze/PCI: make pcibios_setup_phb_resources() static
      microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources
      microblaze/PCI: use pci_scan_root_bus()
      sparc/PCI: convert to pci_create_root_bus() for correct root bus resources
      sparc32,leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
      ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented()
      ia64/PCI: convert to pci_create_root_bus() for correct root bus resources
      parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
      parisc/PCI: supply root bus resources to pci_create_root_bus()
      parisc/PCI: deal with LMMIO/PAT overlaps before creating PCI root bus
      parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
      parisc/PCI: supply root bus resources to pci_create_root_bus()
      xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
      alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources
      arm/PCI: convert to pci_scan_root_bus() for correct root bus resources
      frv/PCI: convert to pci_scan_root_bus() for correct root bus resources
      mn10300/PCI: convert to pci_scan_root_bus() for correct root bus resources
      sh/PCI: convert to pci_scan_root_bus() for correct root bus resources
      xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources


 arch/alpha/kernel/pci.c                  |   37 +++++++------
 arch/arm/common/it8152.c                 |    6 +-
 arch/arm/common/via82c505.c              |    3 +
 arch/arm/include/asm/mach/pci.h          |    2 -
 arch/arm/kernel/bios32.c                 |   27 +++-------
 arch/arm/mach-cns3xxx/pcie.c             |    8 +--
 arch/arm/mach-dove/pcie.c                |    9 +--
 arch/arm/mach-footbridge/dc21285.c       |    8 +--
 arch/arm/mach-integrator/pci_v3.c        |   19 ++++---
 arch/arm/mach-iop13xx/pci.c              |   17 +++---
 arch/arm/mach-ixp2000/enp2611.c          |    3 +
 arch/arm/mach-ixp2000/pci.c              |    8 +--
 arch/arm/mach-ixp23xx/pci.c              |    8 +--
 arch/arm/mach-ixp4xx/common-pci.c        |    8 +--
 arch/arm/mach-kirkwood/pcie.c            |    8 +--
 arch/arm/mach-ks8695/pci.c               |    8 +--
 arch/arm/mach-mv78xx0/pcie.c             |    8 +--
 arch/arm/mach-orion5x/pci.c              |   16 +++---
 arch/arm/mach-sa1100/pci-nanoengine.c    |    9 ++-
 arch/arm/mach-tegra/pcie.c               |    9 ++-
 arch/arm/mach-versatile/pci.c            |   19 ++++---
 arch/arm/plat-iop/pci.c                  |    8 +--
 arch/frv/mb93090-mb00/pci-vdk.c          |   26 +++++++--
 arch/ia64/pci/pci.c                      |   40 ++++++--------
 arch/microblaze/include/asm/pci-bridge.h |    1 
 arch/microblaze/pci/pci-common.c         |   39 ++++++--------
 arch/mips/pci/pci.c                      |   18 ++++--
 arch/mn10300/unit-asb2305/pci.c          |   14 +++--
 arch/powerpc/include/asm/pci-bridge.h    |    1 
 arch/powerpc/kernel/pci-common.c         |   27 ++++++----
 arch/powerpc/kernel/pci_64.c             |   40 +++++++-------
 arch/sh/drivers/pci/pci.c                |   19 ++++---
 arch/sparc/kernel/leon_pci.c             |   26 +++------
 arch/sparc/kernel/pci.c                  |   18 ++----
 arch/x86/include/asm/topology.h          |    2 -
 arch/x86/pci/acpi.c                      |   31 ++++++-----
 arch/x86/pci/bus_numa.c                  |   31 ++++++-----
 arch/x86/pci/common.c                    |   21 +++++--
 arch/x86/pci/legacy.c                    |    3 -
 arch/x86/pci/numaq_32.c                  |    2 -
 arch/xtensa/kernel/pci.c                 |   85 +++++++++++++++---------------
 drivers/parisc/dino.c                    |   48 ++++++++---------
 drivers/parisc/lba_pci.c                 |   73 ++++++++++++++------------
 drivers/pci/bus.c                        |   30 +++++++++--
 drivers/pci/probe.c                      |   75 ++++++++++++++++++++++++--
 drivers/pci/xen-pcifront.c               |    7 +-
 include/linux/pci.h                      |   24 +++++---
 47 files changed, 522 insertions(+), 427 deletions(-)

-- 
Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 02/29] PCI: add pci_create_root_bus(), deprecate pci_create_bus() Bjorn Helgaas
                   ` (28 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

We'd like to supply a list of resources when we create a new PCI bus,
e.g., the root bus under a PCI host bridge.  These are helpers for
constructing that list.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/bus.c   |   30 +++++++++++++++++++++++++-----
 include/linux/pci.h |    2 ++
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 1e2ad92..79fc31a 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -18,6 +18,30 @@
 
 #include "pci.h"
 
+void pci_add_resource(struct list_head *resources, struct resource *res)
+{
+	struct pci_bus_resource *bus_res;
+
+	bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
+	if (!bus_res) {
+		printk(KERN_ERR "PCI: can't add bus resource %pR\n", res);
+		return;
+	}
+
+	bus_res->res = res;
+	list_add_tail(&bus_res->list, resources);
+}
+
+void pci_free_resource_list(struct list_head *resources)
+{
+	struct pci_bus_resource *bus_res, *tmp;
+
+	list_for_each_entry_safe(bus_res, tmp, resources, list) {
+		list_del(&bus_res->list);
+		kfree(bus_res);
+	}
+}
+
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
 			  unsigned int flags)
 {
@@ -52,16 +76,12 @@ EXPORT_SYMBOL_GPL(pci_bus_resource_n);
 
 void pci_bus_remove_resources(struct pci_bus *bus)
 {
-	struct pci_bus_resource *bus_res, *tmp;
 	int i;
 
 	for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
 		bus->resource[i] = NULL;
 
-	list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
-		list_del(&bus_res->list);
-		kfree(bus_res);
-	}
+	pci_free_resource_list(&bus->resources);
 }
 
 /**
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9fc0122..6841e7f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -907,6 +907,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
 void pci_release_selected_regions(struct pci_dev *, int);
 
 /* drivers/pci/bus.c */
+void pci_add_resource(struct list_head *resources, struct resource *res);
+void pci_free_resource_list(struct list_head *resources);
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
 struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
 void pci_bus_remove_resources(struct pci_bus *bus);

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists
  2011-10-14  4:27 ` [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

We'd like to supply a list of resources when we create a new PCI bus,
e.g., the root bus under a PCI host bridge.  These are helpers for
constructing that list.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/bus.c   |   30 +++++++++++++++++++++++++-----
 include/linux/pci.h |    2 ++
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 1e2ad92..79fc31a 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -18,6 +18,30 @@
 
 #include "pci.h"
 
+void pci_add_resource(struct list_head *resources, struct resource *res)
+{
+	struct pci_bus_resource *bus_res;
+
+	bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
+	if (!bus_res) {
+		printk(KERN_ERR "PCI: can't add bus resource %pR\n", res);
+		return;
+	}
+
+	bus_res->res = res;
+	list_add_tail(&bus_res->list, resources);
+}
+
+void pci_free_resource_list(struct list_head *resources)
+{
+	struct pci_bus_resource *bus_res, *tmp;
+
+	list_for_each_entry_safe(bus_res, tmp, resources, list) {
+		list_del(&bus_res->list);
+		kfree(bus_res);
+	}
+}
+
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
 			  unsigned int flags)
 {
@@ -52,16 +76,12 @@ EXPORT_SYMBOL_GPL(pci_bus_resource_n);
 
 void pci_bus_remove_resources(struct pci_bus *bus)
 {
-	struct pci_bus_resource *bus_res, *tmp;
 	int i;
 
 	for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
 		bus->resource[i] = NULL;
 
-	list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
-		list_del(&bus_res->list);
-		kfree(bus_res);
-	}
+	pci_free_resource_list(&bus->resources);
 }
 
 /**
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9fc0122..6841e7f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -907,6 +907,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
 void pci_release_selected_regions(struct pci_dev *, int);
 
 /* drivers/pci/bus.c */
+void pci_add_resource(struct list_head *resources, struct resource *res);
+void pci_free_resource_list(struct list_head *resources);
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
 struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
 void pci_bus_remove_resources(struct pci_bus *bus);


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 02/29] PCI: add pci_create_root_bus(), deprecate pci_create_bus()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 03/29] PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented() Bjorn Helgaas
                   ` (27 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Deng-Cheng Zhu, linux-kernel

pci_create_bus() assigns ioport_resource and iomem_resource as the default
bus resources, i.e., the entire address space.  Architectures fix these
later, typically in pcibios_fixup_bus() or after pci_scan_bus_parented()
returns, but code that runs in the interim sees incorrect resource
information.

This patch adds a new pci_create_root_bus() that sets the bus resources
correctly from a supplied list of resources and marks pci_create_bus() as
deprecated.

Most architectures use pci_scan_bus() or pci_scan_bus_parented() instead of
calling pci_create_bus() directly.  Those that use pci_create_bus()
directly (usually because they need different bus scanning than
pci_scan_child_bus()) should switch to pci_create_root_bus().

Based on original patch by Deng-Cheng Zhu.

Reference: http://www.spinics.net/lists/mips/msg41654.html
Reference: https://lkml.org/lkml/2011/8/26/88
Signed-off-by: Deng-Cheng Zhu <dczhu@mips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   36 ++++++++++++++++++++++++++++++------
 include/linux/pci.h |    5 ++++-
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6ab6bd3..20d2d40 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1528,12 +1528,14 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
 	return max;
 }
 
-struct pci_bus * pci_create_bus(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
+struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
-	int error;
+	int error, i;
 	struct pci_bus *b, *b2;
 	struct device *dev;
+	struct pci_bus_resource *bus_res, *n;
+	struct resource *res;
 
 	b = pci_alloc_bus();
 	if (!b)
@@ -1583,8 +1585,23 @@ struct pci_bus * pci_create_bus(struct device *parent,
 	pci_create_legacy_files(b);
 
 	b->number = b->secondary = bus;
-	b->resource[0] = &ioport_resource;
-	b->resource[1] = &iomem_resource;
+
+	/* Add initial resources to the bus */
+	if (resources) {
+		list_for_each_entry_safe(bus_res, n, resources, list)
+			list_move_tail(&bus_res->list, &b->resources);
+	} else {
+		b->resource[0] = &ioport_resource;
+		b->resource[1] = &iomem_resource;
+	}
+
+	if (parent)
+		dev_info(parent, "PCI host bridge to %s\n",
+			 dev_name(&b->dev));
+	pci_bus_for_each_resource(b, res, i) {
+		if (res)
+			dev_info(&b->dev, "root bus resource %pR\n", res);
+	}
 
 	return b;
 
@@ -1600,12 +1617,19 @@ err_out:
 	return NULL;
 }
 
+/* Deprecated; use pci_create_root_bus() with non-NULL resources instead */
+struct pci_bus *pci_create_bus(struct device *parent,
+		int bus, struct pci_ops *ops, void *sysdata)
+{
+	return pci_create_root_bus(parent, bus, ops, sysdata, NULL);
+}
+
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
 		int bus, struct pci_ops *ops, void *sysdata)
 {
 	struct pci_bus *b;
 
-	b = pci_create_bus(parent, bus, ops, sysdata);
+	b = pci_create_root_bus(parent, bus, ops, sysdata, NULL);
 	if (b)
 		b->subordinate = pci_scan_child_bus(b);
 	return b;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6841e7f..6bdf854 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -666,8 +666,11 @@ static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *o
 		pci_bus_add_devices(root_bus);
 	return root_bus;
 }
+struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+				    struct pci_ops *ops, void *sysdata,
+				    struct list_head *resources);
 struct pci_bus *pci_create_bus(struct device *parent, int bus,
-			       struct pci_ops *ops, void *sysdata);
+			       struct pci_ops *ops, void *sysdata) __deprecated;
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 02/29] PCI: add pci_create_root_bus(), deprecate pci_create_bus()
  2011-10-14  4:27 ` [PATCH v2 02/29] PCI: add pci_create_root_bus(), deprecate pci_create_bus() Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Deng-Cheng Zhu, linux-kernel

pci_create_bus() assigns ioport_resource and iomem_resource as the default
bus resources, i.e., the entire address space.  Architectures fix these
later, typically in pcibios_fixup_bus() or after pci_scan_bus_parented()
returns, but code that runs in the interim sees incorrect resource
information.

This patch adds a new pci_create_root_bus() that sets the bus resources
correctly from a supplied list of resources and marks pci_create_bus() as
deprecated.

Most architectures use pci_scan_bus() or pci_scan_bus_parented() instead of
calling pci_create_bus() directly.  Those that use pci_create_bus()
directly (usually because they need different bus scanning than
pci_scan_child_bus()) should switch to pci_create_root_bus().

Based on original patch by Deng-Cheng Zhu.

Reference: http://www.spinics.net/lists/mips/msg41654.html
Reference: https://lkml.org/lkml/2011/8/26/88
Signed-off-by: Deng-Cheng Zhu <dczhu@mips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   36 ++++++++++++++++++++++++++++++------
 include/linux/pci.h |    5 ++++-
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6ab6bd3..20d2d40 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1528,12 +1528,14 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
 	return max;
 }
 
-struct pci_bus * pci_create_bus(struct device *parent,
-		int bus, struct pci_ops *ops, void *sysdata)
+struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
 {
-	int error;
+	int error, i;
 	struct pci_bus *b, *b2;
 	struct device *dev;
+	struct pci_bus_resource *bus_res, *n;
+	struct resource *res;
 
 	b = pci_alloc_bus();
 	if (!b)
@@ -1583,8 +1585,23 @@ struct pci_bus * pci_create_bus(struct device *parent,
 	pci_create_legacy_files(b);
 
 	b->number = b->secondary = bus;
-	b->resource[0] = &ioport_resource;
-	b->resource[1] = &iomem_resource;
+
+	/* Add initial resources to the bus */
+	if (resources) {
+		list_for_each_entry_safe(bus_res, n, resources, list)
+			list_move_tail(&bus_res->list, &b->resources);
+	} else {
+		b->resource[0] = &ioport_resource;
+		b->resource[1] = &iomem_resource;
+	}
+
+	if (parent)
+		dev_info(parent, "PCI host bridge to %s\n",
+			 dev_name(&b->dev));
+	pci_bus_for_each_resource(b, res, i) {
+		if (res)
+			dev_info(&b->dev, "root bus resource %pR\n", res);
+	}
 
 	return b;
 
@@ -1600,12 +1617,19 @@ err_out:
 	return NULL;
 }
 
+/* Deprecated; use pci_create_root_bus() with non-NULL resources instead */
+struct pci_bus *pci_create_bus(struct device *parent,
+		int bus, struct pci_ops *ops, void *sysdata)
+{
+	return pci_create_root_bus(parent, bus, ops, sysdata, NULL);
+}
+
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
 		int bus, struct pci_ops *ops, void *sysdata)
 {
 	struct pci_bus *b;
 
-	b = pci_create_bus(parent, bus, ops, sysdata);
+	b = pci_create_root_bus(parent, bus, ops, sysdata, NULL);
 	if (b)
 		b->subordinate = pci_scan_child_bus(b);
 	return b;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6841e7f..6bdf854 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -666,8 +666,11 @@ static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *o
 		pci_bus_add_devices(root_bus);
 	return root_bus;
 }
+struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
+				    struct pci_ops *ops, void *sysdata,
+				    struct list_head *resources);
 struct pci_bus *pci_create_bus(struct device *parent, int bus,
-			       struct pci_ops *ops, void *sysdata);
+			       struct pci_ops *ops, void *sysdata) __deprecated;
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 				int busnr);
 void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 03/29] PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 02/29] PCI: add pci_create_root_bus(), deprecate pci_create_bus() Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 04/29] MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
                   ` (26 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

"Early" and "header" quirks use incorrect bus resources because they see
the default resources assigned by pci_create_bus(), before the architecture
fixes them up (typically in pcibios_fixup_bus()).  Regions reserved by
these quirks end up with the wrong parents.

Here's the standard path for scanning a PCI root bus:

  pci_scan_bus or pci_scan_bus_parented
    pci_create_bus                     <-- A create with default resources
    pci_scan_child_bus
      pci_scan_slot
        pci_scan_single_device
          pci_scan_device
            pci_setup_device
              pci_fixup_device(early)  <-- B
          pci_device_add
            pci_fixup_device(header)   <-- C
      pcibios_fixup_bus                <-- D fill in correct resources

Early and header quirks at B and C use the default (incorrect) root bus
resources rather than those filled in at D.

This patch adds a new pci_scan_root_bus() function that sets the bus
resources correctly from a supplied list of resources.  It also marks
pci_scan_bus() and pci_scan_bus_parented() as deprecated.

Callers of pci_scan_bus() should switch to pci_scan_root_bus().  Callers of
pci_scan_bus_parented() should use pci_create_root_bus() followed by
pci_scan_child_bus().  In both cases, root bus resource fixups, e.g.,
in pcibios_fixup_bus(), should be removed.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   39 +++++++++++++++++++++++++++++++++++++--
 include/linux/pci.h |   19 ++++++++-----------
 2 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 20d2d40..9cb7158 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1624,18 +1624,53 @@ struct pci_bus *pci_create_bus(struct device *parent,
 	return pci_create_root_bus(parent, bus, ops, sysdata, NULL);
 }
 
+/*
+ * Deprecated; use pci_create_root_bus() with non-NULL resources and
+ * pci_scan_child_bus() instead
+ */
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
 		int bus, struct pci_ops *ops, void *sysdata)
 {
 	struct pci_bus *b;
 
 	b = pci_create_root_bus(parent, bus, ops, sysdata, NULL);
-	if (b)
-		b->subordinate = pci_scan_child_bus(b);
+	if (!b)
+		return NULL;
+
+	b->subordinate = pci_scan_child_bus(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_bus_parented);
 
+/* Deprecated; use pci_scan_root_bus() with non-NULL resources instead */
+struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
+		void *sysdata)
+{
+	struct pci_bus *b;
+
+	b = pci_create_root_bus(NULL, bus, ops, sysdata, NULL);
+	if (!b)
+		return NULL;
+
+	b->subordinate = pci_scan_child_bus(b);
+	pci_bus_add_devices(b);
+	return b;
+}
+
+struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus_num,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_bus *bus;
+
+	bus = pci_create_root_bus(parent, bus_num, ops, sysdata, resources);
+	if (!bus)
+		return NULL;
+
+	bus->subordinate = pci_scan_child_bus(bus);
+	pci_bus_add_devices(bus);
+	return bus;
+}
+
 #ifdef CONFIG_HOTPLUG
 /**
  * pci_rescan_bus - scan a PCI bus for devices.
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6bdf854..03c6089 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -655,20 +655,17 @@ void pci_fixup_cardbus(struct pci_bus *);
 void pcibios_scan_specific_bus(int busn);
 extern struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
-static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
-					   void *sysdata)
-{
-	struct pci_bus *root_bus;
-	root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
-	if (root_bus)
-		pci_bus_add_devices(root_bus);
-	return root_bus;
-}
+struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,
+					     struct pci_ops *ops, void *sysdata,
+					     struct list_head *resources);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
+struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
+				      struct pci_ops *ops, void *sysdata)
+				      __deprecated;
+struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
+					void *sysdata) __deprecated;
 struct pci_bus *pci_create_bus(struct device *parent, int bus,
 			       struct pci_ops *ops, void *sysdata) __deprecated;
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 03/29] PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented()
  2011-10-14  4:27 ` [PATCH v2 03/29] PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

"Early" and "header" quirks use incorrect bus resources because they see
the default resources assigned by pci_create_bus(), before the architecture
fixes them up (typically in pcibios_fixup_bus()).  Regions reserved by
these quirks end up with the wrong parents.

Here's the standard path for scanning a PCI root bus:

  pci_scan_bus or pci_scan_bus_parented
    pci_create_bus                     <-- A create with default resources
    pci_scan_child_bus
      pci_scan_slot
        pci_scan_single_device
          pci_scan_device
            pci_setup_device
              pci_fixup_device(early)  <-- B
          pci_device_add
            pci_fixup_device(header)   <-- C
      pcibios_fixup_bus                <-- D fill in correct resources

Early and header quirks at B and C use the default (incorrect) root bus
resources rather than those filled in at D.

This patch adds a new pci_scan_root_bus() function that sets the bus
resources correctly from a supplied list of resources.  It also marks
pci_scan_bus() and pci_scan_bus_parented() as deprecated.

Callers of pci_scan_bus() should switch to pci_scan_root_bus().  Callers of
pci_scan_bus_parented() should use pci_create_root_bus() followed by
pci_scan_child_bus().  In both cases, root bus resource fixups, e.g.,
in pcibios_fixup_bus(), should be removed.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c |   39 +++++++++++++++++++++++++++++++++++++--
 include/linux/pci.h |   19 ++++++++-----------
 2 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 20d2d40..9cb7158 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1624,18 +1624,53 @@ struct pci_bus *pci_create_bus(struct device *parent,
 	return pci_create_root_bus(parent, bus, ops, sysdata, NULL);
 }
 
+/*
+ * Deprecated; use pci_create_root_bus() with non-NULL resources and
+ * pci_scan_child_bus() instead
+ */
 struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
 		int bus, struct pci_ops *ops, void *sysdata)
 {
 	struct pci_bus *b;
 
 	b = pci_create_root_bus(parent, bus, ops, sysdata, NULL);
-	if (b)
-		b->subordinate = pci_scan_child_bus(b);
+	if (!b)
+		return NULL;
+
+	b->subordinate = pci_scan_child_bus(b);
 	return b;
 }
 EXPORT_SYMBOL(pci_scan_bus_parented);
 
+/* Deprecated; use pci_scan_root_bus() with non-NULL resources instead */
+struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
+		void *sysdata)
+{
+	struct pci_bus *b;
+
+	b = pci_create_root_bus(NULL, bus, ops, sysdata, NULL);
+	if (!b)
+		return NULL;
+
+	b->subordinate = pci_scan_child_bus(b);
+	pci_bus_add_devices(b);
+	return b;
+}
+
+struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus_num,
+		struct pci_ops *ops, void *sysdata, struct list_head *resources)
+{
+	struct pci_bus *bus;
+
+	bus = pci_create_root_bus(parent, bus_num, ops, sysdata, resources);
+	if (!bus)
+		return NULL;
+
+	bus->subordinate = pci_scan_child_bus(bus);
+	pci_bus_add_devices(bus);
+	return bus;
+}
+
 #ifdef CONFIG_HOTPLUG
 /**
  * pci_rescan_bus - scan a PCI bus for devices.
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6bdf854..03c6089 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -655,20 +655,17 @@ void pci_fixup_cardbus(struct pci_bus *);
 void pcibios_scan_specific_bus(int busn);
 extern struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(const struct pci_bus *bus);
-struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
-				      struct pci_ops *ops, void *sysdata);
-static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
-					   void *sysdata)
-{
-	struct pci_bus *root_bus;
-	root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
-	if (root_bus)
-		pci_bus_add_devices(root_bus);
-	return root_bus;
-}
+struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,
+					     struct pci_ops *ops, void *sysdata,
+					     struct list_head *resources);
 struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 				    struct pci_ops *ops, void *sysdata,
 				    struct list_head *resources);
+struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
+				      struct pci_ops *ops, void *sysdata)
+				      __deprecated;
+struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
+					void *sysdata) __deprecated;
 struct pci_bus *pci_create_bus(struct device *parent, int bus,
 			       struct pci_ops *ops, void *sysdata) __deprecated;
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 04/29] MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (2 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 03/29] PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 05/29] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
                   ` (25 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Deng-Cheng Zhu, linux-kernel, Ralf Baechle

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

Based on original patch by Deng-Cheng Zhu.

Reference: https://lkml.org/lkml/2011/8/26/89
CC: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Deng-Cheng Zhu <dczhu@mips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/mips/pci/pci.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 33bba7b..8ce4979 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -80,6 +80,7 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
 {
 	static int next_busno;
 	static int need_domain_info;
+	struct list_head resources;
 	struct pci_bus *bus;
 
 	if (!hose->iommu)
@@ -88,7 +89,14 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
 	if (hose->get_busno && pci_probe_only)
 		next_busno = (*hose->get_busno)();
 
-	bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, hose->mem_resource);
+	pci_add_resource(&resources, hose->io_resource);
+	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
+				&resources);
+	if (!bus)
+		pci_free_resource_list(&resources);
+
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
@@ -265,15 +273,11 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	/* Propagate hose info into the subordinate devices.  */
 
-	struct pci_controller *hose = bus->sysdata;
 	struct list_head *ln;
 	struct pci_dev *dev = bus->self;
 
-	if (!dev) {
-		bus->resource[0] = hose->io_resource;
-		bus->resource[1] = hose->mem_resource;
-	} else if (pci_probe_only &&
-		   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
+	if (pci_probe_only && dev &&
+	    (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
 		pci_read_bridge_bases(bus);
 		pcibios_fixup_device_resources(dev, bus);
 	}

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 04/29] MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 ` [PATCH v2 04/29] MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Deng-Cheng Zhu, linux-kernel, Ralf Baechle

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

Based on original patch by Deng-Cheng Zhu.

Reference: https://lkml.org/lkml/2011/8/26/89
CC: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Deng-Cheng Zhu <dczhu@mips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/mips/pci/pci.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 33bba7b..8ce4979 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -80,6 +80,7 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
 {
 	static int next_busno;
 	static int need_domain_info;
+	struct list_head resources;
 	struct pci_bus *bus;
 
 	if (!hose->iommu)
@@ -88,7 +89,14 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
 	if (hose->get_busno && pci_probe_only)
 		next_busno = (*hose->get_busno)();
 
-	bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, hose->mem_resource);
+	pci_add_resource(&resources, hose->io_resource);
+	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
+				&resources);
+	if (!bus)
+		pci_free_resource_list(&resources);
+
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
@@ -265,15 +273,11 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	/* Propagate hose info into the subordinate devices.  */
 
-	struct pci_controller *hose = bus->sysdata;
 	struct list_head *ln;
 	struct pci_dev *dev = bus->self;
 
-	if (!dev) {
-		bus->resource[0] = hose->io_resource;
-		bus->resource[1] = hose->mem_resource;
-	} else if (pci_probe_only &&
-		   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
+	if (pci_probe_only && dev &&
+	    (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
 		pci_read_bridge_bases(bus);
 		pcibios_fixup_device_resources(dev, bus);
 	}


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 05/29] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (3 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 04/29] MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus() Bjorn Helgaas
                   ` (24 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

This doesn't change any functionality, but it makes a subsequent patch
slightly simpler.

pci_scan_bus(NULL, ...) and pci_scan_bus_parented() are identical except
that pci_scan_bus() also calls pci_bus_add_devices():

  pci_scan_bus_parented
    pci_create_bus
    pci_scan_child_bus

  pci_scan_bus
    pci_create_bus
    pci_scan_child_bus
    pci_bus_add_devices

All callers of pcibios_scan_root() call pci_bus_add_devices() explicitly,
and we don't pass a parent device, so we might as well use pci_scan_bus().

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/common.c   |    2 +-
 arch/x86/pci/legacy.c   |    3 ---
 arch/x86/pci/numaq_32.c |    2 --
 3 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 92df322..b389a2d 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -456,7 +456,7 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
 	sd->node = get_mp_bus_to_node(busnum);
 
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
+	bus = pci_scan_bus(busnum, &pci_root_ops, sd);
 	if (!bus)
 		kfree(sd);
 
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c
index c89266b..6e3f26a 100644
--- a/arch/x86/pci/legacy.c
+++ b/arch/x86/pci/legacy.c
@@ -30,9 +30,6 @@ int __init pci_legacy_init(void)
 
 	printk("PCI: Probing PCI hardware\n");
 	pci_root_bus = pcibios_scan_root(0);
-	if (pci_root_bus)
-		pci_bus_add_devices(pci_root_bus);
-
 	return 0;
 }
 
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c
index 512a88c..2b94aa9 100644
--- a/arch/x86/pci/numaq_32.c
+++ b/arch/x86/pci/numaq_32.c
@@ -153,8 +153,6 @@ int __init pci_numaq_init(void)
 	raw_pci_ops = &pci_direct_conf1_mq;
 
 	pci_root_bus = pcibios_scan_root(0);
-	if (pci_root_bus)
-		pci_bus_add_devices(pci_root_bus);
 	if (num_online_nodes() > 1)
 		for_each_online_node(quad) {
 			if (quad == 0)

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 05/29] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:27 ` [PATCH v2 05/29] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

This doesn't change any functionality, but it makes a subsequent patch
slightly simpler.

pci_scan_bus(NULL, ...) and pci_scan_bus_parented() are identical except
that pci_scan_bus() also calls pci_bus_add_devices():

  pci_scan_bus_parented
    pci_create_bus
    pci_scan_child_bus

  pci_scan_bus
    pci_create_bus
    pci_scan_child_bus
    pci_bus_add_devices

All callers of pcibios_scan_root() call pci_bus_add_devices() explicitly,
and we don't pass a parent device, so we might as well use pci_scan_bus().

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/pci/common.c   |    2 +-
 arch/x86/pci/legacy.c   |    3 ---
 arch/x86/pci/numaq_32.c |    2 --
 3 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 92df322..b389a2d 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -456,7 +456,7 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
 	sd->node = get_mp_bus_to_node(busnum);
 
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
+	bus = pci_scan_bus(busnum, &pci_root_ops, sd);
 	if (!bus)
 		kfree(sd);
 
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c
index c89266b..6e3f26a 100644
--- a/arch/x86/pci/legacy.c
+++ b/arch/x86/pci/legacy.c
@@ -30,9 +30,6 @@ int __init pci_legacy_init(void)
 
 	printk("PCI: Probing PCI hardware\n");
 	pci_root_bus = pcibios_scan_root(0);
-	if (pci_root_bus)
-		pci_bus_add_devices(pci_root_bus);
-
 	return 0;
 }
 
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c
index 512a88c..2b94aa9 100644
--- a/arch/x86/pci/numaq_32.c
+++ b/arch/x86/pci/numaq_32.c
@@ -153,8 +153,6 @@ int __init pci_numaq_init(void)
 	raw_pci_ops = &pci_direct_conf1_mq;
 
 	pci_root_bus = pcibios_scan_root(0);
-	if (pci_root_bus)
-		pci_bus_add_devices(pci_root_bus);
 	if (num_online_nodes() > 1)
 		for_each_online_node(quad) {
 			if (quad == 0)


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (4 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 05/29] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  5:30   ` Yinghai Lu
  2011-10-14  4:27 ` [PATCH v2 07/29] powerpc/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
                   ` (23 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Yinghai Lu, linux-kernel

x86 has two kinds of PCI root bus scanning:

(1) ACPI-based, using _CRS resources.  This used pci_create_bus() because
    ACPI hotplug needed to split the pci_bus_add_devices() into a separate
    .start() method.

    This patch parses the _CRS resources earlier, so we can build a list of
    resources and pass it to pci_create_root_bus().

    Note that as before, we parse the _CRS even if we aren't going to use
    it so we can print it for debugging purposes.

(2) All other, which used either default resources (ioport_resource and
    iomem_resource) or information read from the hardware via amd_bus.c or
    similar.  This used pci_scan_bus().

    This patch converts x86_pci_root_bus_res_quirks() (previously called
    from pcibios_fixup_bus()) to x86_pci_root_bus_resources(), which builds
    a list of resources before we call pci_scan_root_bus().

    We also use x86_pci_root_bus_resources() if we have ACPI but are
    ignoring _CRS.

CC: Yinghai Lu <yinghai.lu@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/x86/include/asm/topology.h |    2 +-
 arch/x86/pci/acpi.c             |   31 +++++++++++++++++--------------
 arch/x86/pci/bus_numa.c         |   31 ++++++++++++++++++-------------
 arch/x86/pci/common.c           |   21 ++++++++++++++-------
 4 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index c006924..5f83b13 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -174,7 +174,7 @@ static inline void arch_fix_phys_package_id(int num, u32 slot)
 }
 
 struct pci_bus;
-void x86_pci_root_bus_res_quirks(struct pci_bus *b);
+void x86_pci_root_bus_resources(int bus, struct list_head *resources);
 
 #ifdef CONFIG_SMP
 #define mc_capable()	((boot_cpu_data.x86_max_cores > 1) && \
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 039d913..77bb332 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -12,7 +12,7 @@ struct pci_root_info {
 	char *name;
 	unsigned int res_num;
 	struct resource *res;
-	struct pci_bus *bus;
+	struct list_head *resources;
 	int busnum;
 };
 
@@ -250,23 +250,20 @@ static void add_resources(struct pci_root_info *info)
 				 "ignoring host bridge window %pR (conflicts with %s %pR)\n",
 				 res, conflict->name, conflict);
 		else
-			pci_bus_add_resource(info->bus, res, 0);
+			pci_add_resource(info->resources, res);
 	}
 }
 
 static void
 get_current_resources(struct acpi_device *device, int busnum,
-			int domain, struct pci_bus *bus)
+		      int domain, struct list_head *resources)
 {
 	struct pci_root_info info;
 	size_t size;
 
-	if (pci_use_crs)
-		pci_bus_remove_resources(bus);
-
 	info.bridge = device;
-	info.bus = bus;
 	info.res_num = 0;
+	info.resources = resources;
 	acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
 				&info);
 	if (!info.res_num)
@@ -275,7 +272,7 @@ get_current_resources(struct acpi_device *device, int busnum,
 	size = sizeof(*info.res) * info.res_num;
 	info.res = kmalloc(size, GFP_KERNEL);
 	if (!info.res)
-		goto res_alloc_fail;
+		return;
 
 	info.name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum);
 	if (!info.name)
@@ -290,8 +287,6 @@ get_current_resources(struct acpi_device *device, int busnum,
 
 name_alloc_fail:
 	kfree(info.res);
-res_alloc_fail:
-	return;
 }
 
 struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
@@ -299,6 +294,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct acpi_device *device = root->device;
 	int domain = root->segment;
 	int busnum = root->secondary.start;
+	struct list_head resources;
 	struct pci_bus *bus;
 	struct pci_sysdata *sd;
 	int node;
@@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
 		memcpy(bus->sysdata, sd, sizeof(*sd));
 		kfree(sd);
 	} else {
-		bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
-		if (bus) {
-			get_current_resources(device, busnum, domain, bus);
-			bus->subordinate = pci_scan_child_bus(bus);
+		INIT_LIST_HEAD(&resources);
+		get_current_resources(device, busnum, domain, &resources);
+		if (!pci_use_crs) {
+			pci_free_resource_list(&resources);
+			x86_pci_root_bus_resources(busnum, &resources);
 		}
+		bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd,
+					  &resources);
+		if (bus)
+			bus->subordinate = pci_scan_child_bus(bus);
+		else
+			pci_free_resource_list(&resources);
 	}
 
 	/* After the PCI-E bus has been walked and all devices discovered,
diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
index 64a1228..fd3f655 100644
--- a/arch/x86/pci/bus_numa.c
+++ b/arch/x86/pci/bus_numa.c
@@ -7,45 +7,50 @@
 int pci_root_num;
 struct pci_root_info pci_root_info[PCI_ROOT_NR];
 
-void x86_pci_root_bus_res_quirks(struct pci_bus *b)
+void x86_pci_root_bus_resources(int bus, struct list_head *resources)
 {
 	int i;
 	int j;
 	struct pci_root_info *info;
 
-	/* don't go for it if _CRS is used already */
-	if (b->resource[0] != &ioport_resource ||
-	    b->resource[1] != &iomem_resource)
-		return;
-
 	if (!pci_root_num)
-		return;
+		goto default_resources;
 
 	for (i = 0; i < pci_root_num; i++) {
-		if (pci_root_info[i].bus_min == b->number)
+		if (pci_root_info[i].bus_min == bus)
 			break;
 	}
 
 	if (i == pci_root_num)
-		return;
+		goto default_resources;
 
-	printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
-			b->number);
+	printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n",
+	       bus);
 
-	pci_bus_remove_resources(b);
 	info = &pci_root_info[i];
 	for (j = 0; j < info->res_num; j++) {
 		struct resource *res;
 		struct resource *root;
 
 		res = &info->res[j];
-		pci_bus_add_resource(b, res, 0);
+		pci_add_resource(resources, res);
 		if (res->flags & IORESOURCE_IO)
 			root = &ioport_resource;
 		else
 			root = &iomem_resource;
 		insert_resource(root, res);
 	}
+	return;
+
+default_resources:
+	/*
+	 * We don't have any host bridge aperture information from the
+	 * "native host bridge drivers," e.g., amd_bus or broadcom_bus,
+	 * so fall back to the defaults historically used by pci_create_bus().
+	 */
+	printk(KERN_DEBUG "PCI: root bus %02x: using default resources\n", bus);
+	pci_add_resource(resources, &ioport_resource);
+	pci_add_resource(resources, &iomem_resource);
 }
 
 void __devinit update_res(struct pci_root_info *info, resource_size_t start,
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index b389a2d..7f595cc 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -164,9 +164,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
 {
 	struct pci_dev *dev;
 
-	/* root bus? */
-	if (!b->parent)
-		x86_pci_root_bus_res_quirks(b);
 	pci_read_bridge_bases(b);
 	list_for_each_entry(dev, &b->devices, bus_list)
 		pcibios_fixup_device_resources(dev);
@@ -433,6 +430,7 @@ void __init dmi_check_pciprobe(void)
 
 struct pci_bus * __devinit pcibios_scan_root(int busnum)
 {
+	struct list_head resources;
 	struct pci_bus *bus = NULL;
 	struct pci_sysdata *sd;
 
@@ -456,9 +454,13 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
 	sd->node = get_mp_bus_to_node(busnum);
 
 	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
-	bus = pci_scan_bus(busnum, &pci_root_ops, sd);
-	if (!bus)
+	INIT_LIST_HEAD(&resources);
+	x86_pci_root_bus_resources(busnum, &resources);
+	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
+	if (!bus) {
+		pci_free_resource_list(&resources);
 		kfree(sd);
+	}
 
 	return bus;
 }
@@ -639,6 +641,7 @@ int pci_ext_cfg_avail(struct pci_dev *dev)
 
 struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
 {
+	struct list_head resources;
 	struct pci_bus *bus = NULL;
 	struct pci_sysdata *sd;
 
@@ -653,9 +656,13 @@ struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops,
 		return NULL;
 	}
 	sd->node = node;
-	bus = pci_scan_bus(busno, ops, sd);
-	if (!bus)
+	INIT_LIST_HEAD(&resources);
+	x86_pci_root_bus_resources(busno, &resources);
+	bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources);
+	if (!bus) {
+		pci_free_resource_list(&resources);
 		kfree(sd);
+	}
 
 	return bus;
 }

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 07/29] powerpc/PCI: make pcibios_setup_phb_resources() static
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (5 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus() Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 08/29] powerpc/PCI: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
                   ` (22 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt, linux-kernel

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/pci-bridge.h |    1 -
 arch/powerpc/kernel/pci-common.c      |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 56b879a..31bf836 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -222,7 +222,6 @@ extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
 /* Allocate & free a PCI host bridge structure */
 extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
 extern void pcibios_free_controller(struct pci_controller *phb);
-extern void pcibios_setup_phb_resources(struct pci_controller *hose);
 
 #ifdef CONFIG_PCI
 extern int pcibios_vaddr_is_ioport(void __iomem *address);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 32656f1..942ced2 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1554,7 +1554,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 {
 	struct pci_bus *bus = hose->bus;
 	struct resource *res;

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 07/29] powerpc/PCI: make pcibios_setup_phb_resources() static
  2011-10-14  4:27 ` [PATCH v2 07/29] powerpc/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt, linux-kernel

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/include/asm/pci-bridge.h |    1 -
 arch/powerpc/kernel/pci-common.c      |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 56b879a..31bf836 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -222,7 +222,6 @@ extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
 /* Allocate & free a PCI host bridge structure */
 extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
 extern void pcibios_free_controller(struct pci_controller *phb);
-extern void pcibios_setup_phb_resources(struct pci_controller *hose);
 
 #ifdef CONFIG_PCI
 extern int pcibios_vaddr_is_ioport(void __iomem *address);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 32656f1..942ced2 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1554,7 +1554,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 {
 	struct pci_bus *bus = hose->bus;
 	struct resource *res;


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 08/29] powerpc/PCI: split PHB part out of pcibios_map_io_space()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (6 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 07/29] powerpc/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:27 ` [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
                   ` (21 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt, linux-kernel

No functional change.  This is so we can use pcibios_phb_map_io_space()
before we have a struct pci_bus.

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/kernel/pci_64.c |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index ab34046..4401425 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -130,30 +130,13 @@ EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
 
 #endif /* CONFIG_HOTPLUG */
 
-int __devinit pcibios_map_io_space(struct pci_bus *bus)
+static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose)
 {
 	struct vm_struct *area;
 	unsigned long phys_page;
 	unsigned long size_page;
 	unsigned long io_virt_offset;
-	struct pci_controller *hose;
-
-	WARN_ON(bus == NULL);
-
-	/* If this not a PHB, nothing to do, page tables still exist and
-	 * thus HPTEs will be faulted in when needed
-	 */
-	if (bus->self) {
-		pr_debug("IO mapping for PCI-PCI bridge %s\n",
-			 pci_name(bus->self));
-		pr_debug("  virt=0x%016llx...0x%016llx\n",
-			 bus->resource[0]->start + _IO_BASE,
-			 bus->resource[0]->end + _IO_BASE);
-		return 0;
-	}
 
-	/* Get the host bridge */
-	hose = pci_bus_to_host(bus);
 	phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
 	size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
 
@@ -197,11 +180,30 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
 
 	return 0;
 }
+
+int __devinit pcibios_map_io_space(struct pci_bus *bus)
+{
+	WARN_ON(bus == NULL);
+
+	/* If this not a PHB, nothing to do, page tables still exist and
+	 * thus HPTEs will be faulted in when needed
+	 */
+	if (bus->self) {
+		pr_debug("IO mapping for PCI-PCI bridge %s\n",
+			 pci_name(bus->self));
+		pr_debug("  virt=0x%016llx...0x%016llx\n",
+			 bus->resource[0]->start + _IO_BASE,
+			 bus->resource[0]->end + _IO_BASE);
+		return 0;
+	}
+
+	return pcibios_phb_map_phb_io_space(pci_bus_to_host(bus));
+}
 EXPORT_SYMBOL_GPL(pcibios_map_io_space);
 
 void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
 {
-	pcibios_map_io_space(hose->bus);
+	pcibios_map_phb_io_space(hose);
 }
 
 #define IOBASE_BRIDGE_NUMBER	0

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 08/29] powerpc/PCI: split PHB part out of pcibios_map_io_space()
  2011-10-14  4:27 ` [PATCH v2 08/29] powerpc/PCI: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt, linux-kernel

No functional change.  This is so we can use pcibios_phb_map_io_space()
before we have a struct pci_bus.

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/kernel/pci_64.c |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index ab34046..4401425 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -130,30 +130,13 @@ EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
 
 #endif /* CONFIG_HOTPLUG */
 
-int __devinit pcibios_map_io_space(struct pci_bus *bus)
+static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose)
 {
 	struct vm_struct *area;
 	unsigned long phys_page;
 	unsigned long size_page;
 	unsigned long io_virt_offset;
-	struct pci_controller *hose;
-
-	WARN_ON(bus == NULL);
-
-	/* If this not a PHB, nothing to do, page tables still exist and
-	 * thus HPTEs will be faulted in when needed
-	 */
-	if (bus->self) {
-		pr_debug("IO mapping for PCI-PCI bridge %s\n",
-			 pci_name(bus->self));
-		pr_debug("  virt=0x%016llx...0x%016llx\n",
-			 bus->resource[0]->start + _IO_BASE,
-			 bus->resource[0]->end + _IO_BASE);
-		return 0;
-	}
 
-	/* Get the host bridge */
-	hose = pci_bus_to_host(bus);
 	phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
 	size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
 
@@ -197,11 +180,30 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
 
 	return 0;
 }
+
+int __devinit pcibios_map_io_space(struct pci_bus *bus)
+{
+	WARN_ON(bus == NULL);
+
+	/* If this not a PHB, nothing to do, page tables still exist and
+	 * thus HPTEs will be faulted in when needed
+	 */
+	if (bus->self) {
+		pr_debug("IO mapping for PCI-PCI bridge %s\n",
+			 pci_name(bus->self));
+		pr_debug("  virt=0x%016llx...0x%016llx\n",
+			 bus->resource[0]->start + _IO_BASE,
+			 bus->resource[0]->end + _IO_BASE);
+		return 0;
+	}
+
+	return pcibios_phb_map_phb_io_space(pci_bus_to_host(bus));
+}
 EXPORT_SYMBOL_GPL(pcibios_map_io_space);
 
 void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
 {
-	pcibios_map_io_space(hose->bus);
+	pcibios_map_phb_io_space(hose);
 }
 
 #define IOBASE_BRIDGE_NUMBER	0


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (7 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 08/29] powerpc/PCI: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  7:34   ` Benjamin Herrenschmidt
  2011-10-14  4:27 ` [PATCH v2 10/29] microblaze/PCI: fix pci_bus_for_each_resource() usage Bjorn Helgaas
                   ` (20 subsequent siblings)
  29 siblings, 2 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt, linux-kernel

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This patch doesn't fix anything
because powerpc fixed them before scanning the bus, but it makes it more
consistent with other architectures.

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/kernel/pci-common.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 942ced2..2dbef49 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1554,14 +1554,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
 {
-	struct pci_bus *bus = hose->bus;
 	struct resource *res;
 	int i;
 
 	/* Hookup PHB IO resource */
-	bus->resource[0] = res = &hose->io_resource;
+	res = &hose->io_resource;
 
 	if (!res->flags) {
 		printk(KERN_WARNING "PCI: I/O resource not set for host"
@@ -1579,6 +1578,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 		 (unsigned long long)res->start,
 		 (unsigned long long)res->end,
 		 (unsigned long)res->flags);
+	pci_add_resource(resources, res);
 
 	/* Hookup PHB Memory resources */
 	for (i = 0; i < 3; ++i) {
@@ -1596,12 +1596,12 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 			res->flags = IORESOURCE_MEM;
 #endif /* CONFIG_PPC32 */
 		}
-		bus->resource[i+1] = res;
 
 		pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
 			 (unsigned long long)res->start,
 			 (unsigned long long)res->end,
 			 (unsigned long)res->flags);
+		pci_add_resource(resources, res);
 	}
 
 	pr_debug("PCI: PHB MEM offset     = %016llx\n",
@@ -1695,6 +1695,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
  */
 void __devinit pcibios_scan_phb(struct pci_controller *hose)
 {
+	struct list_head resources;
 	struct pci_bus *bus;
 	struct device_node *node = hose->dn;
 	int mode;
@@ -1702,22 +1703,26 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
 	pr_debug("PCI: Scanning PHB %s\n",
 		 node ? node->full_name : "<NO NAME>");
 
+	INIT_LIST_HEAD(&resources);
+
+	/* Get some IO space for the new PHB */
+	pcibios_setup_phb_io_space(hose);
+
+	/* Wire up PHB bus resources */
+	pcibios_setup_phb_resources(hose, &resources);
+
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+	bus = pci_create_root_bus(hose->parent, hose->first_busno,
+				  hose->ops, hose, resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
+		pci_free_resource_list(&resources);
 		return;
 	}
 	bus->secondary = hose->first_busno;
 	hose->bus = bus;
 
-	/* Get some IO space for the new PHB */
-	pcibios_setup_phb_io_space(hose);
-
-	/* Wire up PHB bus resources */
-	pcibios_setup_phb_resources(hose);
-
 	/* Get probe mode and perform scan */
 	mode = PCI_PROBE_NORMAL;
 	if (node && ppc_md.pci_probe_mode)

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:27 ` [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  7:34   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt, linux-kernel

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This patch doesn't fix anything
because powerpc fixed them before scanning the bus, but it makes it more
consistent with other architectures.

CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/powerpc/kernel/pci-common.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 942ced2..2dbef49 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1554,14 +1554,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
 {
-	struct pci_bus *bus = hose->bus;
 	struct resource *res;
 	int i;
 
 	/* Hookup PHB IO resource */
-	bus->resource[0] = res = &hose->io_resource;
+	res = &hose->io_resource;
 
 	if (!res->flags) {
 		printk(KERN_WARNING "PCI: I/O resource not set for host"
@@ -1579,6 +1578,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 		 (unsigned long long)res->start,
 		 (unsigned long long)res->end,
 		 (unsigned long)res->flags);
+	pci_add_resource(resources, res);
 
 	/* Hookup PHB Memory resources */
 	for (i = 0; i < 3; ++i) {
@@ -1596,12 +1596,12 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 			res->flags = IORESOURCE_MEM;
 #endif /* CONFIG_PPC32 */
 		}
-		bus->resource[i+1] = res;
 
 		pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
 			 (unsigned long long)res->start,
 			 (unsigned long long)res->end,
 			 (unsigned long)res->flags);
+		pci_add_resource(resources, res);
 	}
 
 	pr_debug("PCI: PHB MEM offset     = %016llx\n",
@@ -1695,6 +1695,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
  */
 void __devinit pcibios_scan_phb(struct pci_controller *hose)
 {
+	struct list_head resources;
 	struct pci_bus *bus;
 	struct device_node *node = hose->dn;
 	int mode;
@@ -1702,22 +1703,26 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
 	pr_debug("PCI: Scanning PHB %s\n",
 		 node ? node->full_name : "<NO NAME>");
 
+	INIT_LIST_HEAD(&resources);
+
+	/* Get some IO space for the new PHB */
+	pcibios_setup_phb_io_space(hose);
+
+	/* Wire up PHB bus resources */
+	pcibios_setup_phb_resources(hose, &resources);
+
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+	bus = pci_create_root_bus(hose->parent, hose->first_busno,
+				  hose->ops, hose, resources);
 	if (bus == NULL) {
 		pr_err("Failed to create bus for PCI domain %04x\n",
 			hose->global_number);
+		pci_free_resource_list(&resources);
 		return;
 	}
 	bus->secondary = hose->first_busno;
 	hose->bus = bus;
 
-	/* Get some IO space for the new PHB */
-	pcibios_setup_phb_io_space(hose);
-
-	/* Wire up PHB bus resources */
-	pcibios_setup_phb_resources(hose);
-
 	/* Get probe mode and perform scan */
 	mode = PCI_PROBE_NORMAL;
 	if (node && ppc_md.pci_probe_mode)


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 10/29] microblaze/PCI: fix pci_bus_for_each_resource() usage
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (8 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:27 ` Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 11/29] microblaze/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
                   ` (19 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

The pci_bus_for_each_resource() iterator sets "res" itself, so there's
no need to look it up in the bus->resource[] table.

Logically part of 89a74ecccd and 8a66da71fa.

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/pci/pci-common.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 4cfae20..9df5e5b 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1018,7 +1018,6 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
 	struct pci_dev *dev = bus->self;
 
 	pci_bus_for_each_resource(bus, res, i) {
-		res = bus->resource[i];
 		if (!res)
 			continue;
 		if (!res->flags)
@@ -1218,7 +1217,6 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
 		 pci_domain_nr(bus), bus->number);
 
 	pci_bus_for_each_resource(bus, res, i) {
-		res = bus->resource[i];
 		if (!res || !res->flags
 		    || res->start > res->end || res->parent)
 			continue;

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 10/29] microblaze/PCI: fix pci_bus_for_each_resource() usage
  2011-10-14  4:27 ` [PATCH v2 10/29] microblaze/PCI: fix pci_bus_for_each_resource() usage Bjorn Helgaas
@ 2011-10-14  4:27   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:27 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

The pci_bus_for_each_resource() iterator sets "res" itself, so there's
no need to look it up in the bus->resource[] table.

Logically part of 89a74ecccd and 8a66da71fa.

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/pci/pci-common.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 4cfae20..9df5e5b 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1018,7 +1018,6 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
 	struct pci_dev *dev = bus->self;
 
 	pci_bus_for_each_resource(bus, res, i) {
-		res = bus->resource[i];
 		if (!res)
 			continue;
 		if (!res->flags)
@@ -1218,7 +1217,6 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
 		 pci_domain_nr(bus), bus->number);
 
 	pci_bus_for_each_resource(bus, res, i) {
-		res = bus->resource[i];
 		if (!res || !res->flags
 		    || res->start > res->end || res->parent)
 			continue;


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 11/29] microblaze/PCI: make pcibios_setup_phb_resources() static
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (9 preceding siblings ...)
  2011-10-14  4:27 ` [PATCH v2 10/29] microblaze/PCI: fix pci_bus_for_each_resource() usage Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 12/29] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
                   ` (18 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/include/asm/pci-bridge.h |    1 -
 arch/microblaze/pci/pci-common.c         |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/microblaze/include/asm/pci-bridge.h b/arch/microblaze/include/asm/pci-bridge.h
index 32764cd..e9834b2 100644
--- a/arch/microblaze/include/asm/pci-bridge.h
+++ b/arch/microblaze/include/asm/pci-bridge.h
@@ -140,7 +140,6 @@ extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
 /* Allocate & free a PCI host bridge structure */
 extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
 extern void pcibios_free_controller(struct pci_controller *phb);
-extern void pcibios_setup_phb_resources(struct pci_controller *hose);
 
 #endif	/* __KERNEL__ */
 #endif	/* _ASM_MICROBLAZE_PCI_BRIDGE_H */
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9df5e5b..9dde153 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1507,7 +1507,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 {
 	struct pci_bus *bus = hose->bus;
 	struct resource *res;

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 11/29] microblaze/PCI: make pcibios_setup_phb_resources() static
  2011-10-14  4:28 ` [PATCH v2 11/29] microblaze/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/include/asm/pci-bridge.h |    1 -
 arch/microblaze/pci/pci-common.c         |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/microblaze/include/asm/pci-bridge.h b/arch/microblaze/include/asm/pci-bridge.h
index 32764cd..e9834b2 100644
--- a/arch/microblaze/include/asm/pci-bridge.h
+++ b/arch/microblaze/include/asm/pci-bridge.h
@@ -140,7 +140,6 @@ extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
 /* Allocate & free a PCI host bridge structure */
 extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
 extern void pcibios_free_controller(struct pci_controller *phb);
-extern void pcibios_setup_phb_resources(struct pci_controller *hose);
 
 #endif	/* __KERNEL__ */
 #endif	/* _ASM_MICROBLAZE_PCI_BRIDGE_H */
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9df5e5b..9dde153 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1507,7 +1507,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 {
 	struct pci_bus *bus = hose->bus;
 	struct resource *res;


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 12/29] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (10 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 11/29] microblaze/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 13/29] microblaze/PCI: use pci_scan_root_bus() Bjorn Helgaas
                   ` (17 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This patch doesn't fix anything
because microblaze fixed them before scanning the bus, but it makes it more
consistent with other architectures.  It also allows us to use the
pci_scan_root_bus() path safely.

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/pci/pci-common.c |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9dde153..9382869 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1507,14 +1507,18 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
 {
-	struct pci_bus *bus = hose->bus;
 	struct resource *res;
 	int i;
 
 	/* Hookup PHB IO resource */
-	bus->resource[0] = res = &hose->io_resource;
+	res = &hose->io_resource;
+
+	/* Fixup IO space offset */
+	io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
+	res->start = (res->start + io_offset) & 0xffffffffu;
+	res->end = (res->end + io_offset) & 0xffffffffu;
 
 	if (!res->flags) {
 		printk(KERN_WARNING "PCI: I/O resource not set for host"
@@ -1525,6 +1529,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 		res->end = res->start + IO_SPACE_LIMIT;
 		res->flags = IORESOURCE_IO;
 	}
+	pci_add_resource(resources, res);
 
 	pr_debug("PCI: PHB IO resource    = %016llx-%016llx [%lx]\n",
 		 (unsigned long long)res->start,
@@ -1547,7 +1552,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 			res->flags = IORESOURCE_MEM;
 
 		}
-		bus->resource[i+1] = res;
+		pci_add_resource(resources, res);
 
 		pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n",
 			i, (unsigned long long)res->start,
@@ -1570,32 +1575,28 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 
 static void __devinit pcibios_scan_phb(struct pci_controller *hose)
 {
+	struct list_head resources;
 	struct pci_bus *bus;
 	struct device_node *node = hose->dn;
-	unsigned long io_offset;
-	struct resource *res = &hose->io_resource;
 
 	pr_debug("PCI: Scanning PHB %s\n",
 		 node ? node->full_name : "<NO NAME>");
 
+	INIT_LIST_HEAD(&resources);
+	pcibios_setup_phb_resources(hose, &resources);
+
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+	bus = pci_create_root_bus(hose->parent, hose->first_busno, hose->ops,
+				  hose, &resources);
 	if (bus == NULL) {
 		printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
+		pci_free_resource_list(&resources);
 		return;
 	}
 	bus->secondary = hose->first_busno;
 	hose->bus = bus;
 
-	/* Fixup IO space offset */
-	io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
-	res->start = (res->start + io_offset) & 0xffffffffu;
-	res->end = (res->end + io_offset) & 0xffffffffu;
-
-	/* Wire up PHB bus resources */
-	pcibios_setup_phb_resources(hose);
-
 	/* Scan children */
 	hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
 }

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 12/29] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:28 ` [PATCH v2 12/29] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This patch doesn't fix anything
because microblaze fixed them before scanning the bus, but it makes it more
consistent with other architectures.  It also allows us to use the
pci_scan_root_bus() path safely.

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/pci/pci-common.c |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9dde153..9382869 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1507,14 +1507,18 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	return pci_enable_resources(dev, mask);
 }
 
-static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
 {
-	struct pci_bus *bus = hose->bus;
 	struct resource *res;
 	int i;
 
 	/* Hookup PHB IO resource */
-	bus->resource[0] = res = &hose->io_resource;
+	res = &hose->io_resource;
+
+	/* Fixup IO space offset */
+	io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
+	res->start = (res->start + io_offset) & 0xffffffffu;
+	res->end = (res->end + io_offset) & 0xffffffffu;
 
 	if (!res->flags) {
 		printk(KERN_WARNING "PCI: I/O resource not set for host"
@@ -1525,6 +1529,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 		res->end = res->start + IO_SPACE_LIMIT;
 		res->flags = IORESOURCE_IO;
 	}
+	pci_add_resource(resources, res);
 
 	pr_debug("PCI: PHB IO resource    = %016llx-%016llx [%lx]\n",
 		 (unsigned long long)res->start,
@@ -1547,7 +1552,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
 			res->flags = IORESOURCE_MEM;
 
 		}
-		bus->resource[i+1] = res;
+		pci_add_resource(resources, res);
 
 		pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n",
 			i, (unsigned long long)res->start,
@@ -1570,32 +1575,28 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
 
 static void __devinit pcibios_scan_phb(struct pci_controller *hose)
 {
+	struct list_head resources;
 	struct pci_bus *bus;
 	struct device_node *node = hose->dn;
-	unsigned long io_offset;
-	struct resource *res = &hose->io_resource;
 
 	pr_debug("PCI: Scanning PHB %s\n",
 		 node ? node->full_name : "<NO NAME>");
 
+	INIT_LIST_HEAD(&resources);
+	pcibios_setup_phb_resources(hose, &resources);
+
 	/* Create an empty bus for the toplevel */
-	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+	bus = pci_create_root_bus(hose->parent, hose->first_busno, hose->ops,
+				  hose, &resources);
 	if (bus == NULL) {
 		printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
+		pci_free_resource_list(&resources);
 		return;
 	}
 	bus->secondary = hose->first_busno;
 	hose->bus = bus;
 
-	/* Fixup IO space offset */
-	io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
-	res->start = (res->start + io_offset) & 0xffffffffu;
-	res->end = (res->end + io_offset) & 0xffffffffu;
-
-	/* Wire up PHB bus resources */
-	pcibios_setup_phb_resources(hose);
-
 	/* Scan children */
 	hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
 }


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 13/29] microblaze/PCI: use pci_scan_root_bus()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (11 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 12/29] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
                   ` (16 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

Microblaze doesn't need to replace pci_scan_child_bus() or do anything
special before pci_bus_add_devices(), so we can use the more generic PCI
path in pci_scan_root_bus().

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/pci/pci-common.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9382869..c78c754 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1585,9 +1585,8 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
 	INIT_LIST_HEAD(&resources);
 	pcibios_setup_phb_resources(hose, &resources);
 
-	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno, hose->ops,
-				  hose, &resources);
+	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
+				hose->ops, hose, &resources);
 	if (bus == NULL) {
 		printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
@@ -1597,8 +1596,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
 	bus->secondary = hose->first_busno;
 	hose->bus = bus;
 
-	/* Scan children */
-	hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
+	hose->last_busno = bus->subordinate;
 }
 
 static int __init pcibios_init(void)
@@ -1612,8 +1610,6 @@ static int __init pcibios_init(void)
 	list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
 		hose->last_busno = 0xff;
 		pcibios_scan_phb(hose);
-		printk(KERN_INFO "calling pci_bus_add_devices()\n");
-		pci_bus_add_devices(hose->bus);
 		if (next_busno <= hose->last_busno)
 			next_busno = hose->last_busno + 1;
 	}

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 13/29] microblaze/PCI: use pci_scan_root_bus()
  2011-10-14  4:28 ` [PATCH v2 13/29] microblaze/PCI: use pci_scan_root_bus() Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Michal Simek, linux-kernel

Microblaze doesn't need to replace pci_scan_child_bus() or do anything
special before pci_bus_add_devices(), so we can use the more generic PCI
path in pci_scan_root_bus().

CC: Michal Simek <monstr@monstr.eu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/microblaze/pci/pci-common.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9382869..c78c754 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1585,9 +1585,8 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
 	INIT_LIST_HEAD(&resources);
 	pcibios_setup_phb_resources(hose, &resources);
 
-	/* Create an empty bus for the toplevel */
-	bus = pci_create_root_bus(hose->parent, hose->first_busno, hose->ops,
-				  hose, &resources);
+	bus = pci_scan_root_bus(hose->parent, hose->first_busno,
+				hose->ops, hose, &resources);
 	if (bus == NULL) {
 		printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
 		       hose->global_number);
@@ -1597,8 +1596,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
 	bus->secondary = hose->first_busno;
 	hose->bus = bus;
 
-	/* Scan children */
-	hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
+	hose->last_busno = bus->subordinate;
 }
 
 static int __init pcibios_init(void)
@@ -1612,8 +1610,6 @@ static int __init pcibios_init(void)
 	list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
 		hose->last_busno = 0xff;
 		pcibios_scan_phb(hose);
-		printk(KERN_INFO "calling pci_bus_add_devices()\n");
-		pci_bus_add_devices(hose->bus);
 		if (next_busno <= hose->last_busno)
 			next_busno = hose->last_busno + 1;
 	}


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (12 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 13/29] microblaze/PCI: use pci_scan_root_bus() Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:46   ` David Miller
  2011-10-14  4:28 ` [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() " Bjorn Helgaas
                   ` (15 subsequent siblings)
  29 siblings, 2 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel, David S. Miller

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This patch doesn't fix anything
because sparc fixed them before scanning the bus, but it makes it more
consistent with other architectures.

I didn't work out where pcibios_fixup_bus() is called.  I don't see a
use of pci_scan_bus(), pci_scan_bus_parented(), or pci_scan_child_bus().

CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 1e94f94..929e7a2 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -684,23 +684,26 @@ static void __devinit pci_bus_register_of_sysfs(struct pci_bus *bus)
 struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
 					    struct device *parent)
 {
+	struct list_head resources;
 	struct device_node *node = pbm->op->dev.of_node;
 	struct pci_bus *bus;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
-	bus = pci_create_bus(parent, pbm->pci_first_busno, pbm->pci_ops, pbm);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &pbm->io_space);
+	pci_add_resource(&resources, &pbm->mem_space);
+	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
+				  pbm, resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
+		pci_free_resource_list(&resources);
 		return NULL;
 	}
 	bus->secondary = pbm->pci_first_busno;
 	bus->subordinate = pbm->pci_last_busno;
 
-	bus->resource[0] = &pbm->io_space;
-	bus->resource[1] = &pbm->mem_space;
-
 	pci_of_scan_bus(pbm, node, bus);
 	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
@@ -710,13 +713,6 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
 
 void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
 {
-	struct pci_pbm_info *pbm = pbus->sysdata;
-
-	/* Generic PCI bus probing sets these to point at
-	 * &io{port,mem}_resouce which is wrong for us.
-	 */
-	pbus->resource[0] = &pbm->io_space;
-	pbus->resource[1] = &pbm->mem_space;
 }
 
 void pcibios_update_irq(struct pci_dev *pdev, int irq)

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:28 ` [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:46   ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel, David S. Miller

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This patch doesn't fix anything
because sparc fixed them before scanning the bus, but it makes it more
consistent with other architectures.

I didn't work out where pcibios_fixup_bus() is called.  I don't see a
use of pci_scan_bus(), pci_scan_bus_parented(), or pci_scan_child_bus().

CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/pci.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 1e94f94..929e7a2 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -684,23 +684,26 @@ static void __devinit pci_bus_register_of_sysfs(struct pci_bus *bus)
 struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
 					    struct device *parent)
 {
+	struct list_head resources;
 	struct device_node *node = pbm->op->dev.of_node;
 	struct pci_bus *bus;
 
 	printk("PCI: Scanning PBM %s\n", node->full_name);
 
-	bus = pci_create_bus(parent, pbm->pci_first_busno, pbm->pci_ops, pbm);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &pbm->io_space);
+	pci_add_resource(&resources, &pbm->mem_space);
+	bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
+				  pbm, resources);
 	if (!bus) {
 		printk(KERN_ERR "Failed to create bus for %s\n",
 		       node->full_name);
+		pci_free_resource_list(&resources);
 		return NULL;
 	}
 	bus->secondary = pbm->pci_first_busno;
 	bus->subordinate = pbm->pci_last_busno;
 
-	bus->resource[0] = &pbm->io_space;
-	bus->resource[1] = &pbm->mem_space;
-
 	pci_of_scan_bus(pbm, node, bus);
 	pci_bus_add_devices(bus);
 	pci_bus_register_of_sysfs(bus);
@@ -710,13 +713,6 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
 
 void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
 {
-	struct pci_pbm_info *pbm = pbus->sysdata;
-
-	/* Generic PCI bus probing sets these to point at
-	 * &io{port,mem}_resouce which is wrong for us.
-	 */
-	pbus->resource[0] = &pbm->io_space;
-	pbus->resource[1] = &pbm->mem_space;
 }
 
 void pcibios_update_irq(struct pci_dev *pdev, int irq)


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (13 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:43   ` David Miller
  2011-10-14  4:28 ` [PATCH v2 16/29] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
                   ` (14 subsequent siblings)
  29 siblings, 2 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel, David S. Miller

Convert from pci_scan_bus_parented() to pci_scan_root_bus() and remove root
bus resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

pci_scan_root_bus() also includes the pci_bus_add_devices() so we don't
need to do that separately.

CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/leon_pci.c |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index a8a9a27..b7f2e9a 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -18,22 +18,23 @@
  */
 void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 {
+	struct list_head resources;
 	struct pci_bus *root_bus;
 
-	root_bus = pci_scan_bus_parented(&ofdev->dev, 0, info->ops, info);
-	if (root_bus) {
-		root_bus->resource[0] = &info->io_space;
-		root_bus->resource[1] = &info->mem_space;
-		root_bus->resource[2] = NULL;
-
-		/* Init all PCI devices into PCI tree */
-		pci_bus_add_devices(root_bus);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &info->io_space);
+	pci_add_resource(&resources, &info->mem_space);
 
+	root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
+				     &resources);
+	if (root_bus) {
 		/* Setup IRQs of all devices using custom routines */
 		pci_fixup_irqs(pci_common_swizzle, info->map_irq);
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+	} else {
+		pci_free_resource_list(&resources);
 	}
 }
 
@@ -82,15 +83,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
 	int i, has_io, has_mem;
 	u16 cmd;
 
-	/* Generic PCI bus probing sets these to point at
-	 * &io{port,mem}_resouce which is wrong for us.
-	 */
-	if (pbus->self == NULL) {
-		pbus->resource[0] = &info->io_space;
-		pbus->resource[1] = &info->mem_space;
-		pbus->resource[2] = NULL;
-	}
-
 	list_for_each_entry(dev, &pbus->devices, bus_list) {
 		/*
 		 * We can not rely on that the bootloader has enabled I/O

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:28 ` [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() " Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:43   ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel, David S. Miller

Convert from pci_scan_bus_parented() to pci_scan_root_bus() and remove root
bus resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

pci_scan_root_bus() also includes the pci_bus_add_devices() so we don't
need to do that separately.

CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sparc/kernel/leon_pci.c |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index a8a9a27..b7f2e9a 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -18,22 +18,23 @@
  */
 void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 {
+	struct list_head resources;
 	struct pci_bus *root_bus;
 
-	root_bus = pci_scan_bus_parented(&ofdev->dev, 0, info->ops, info);
-	if (root_bus) {
-		root_bus->resource[0] = &info->io_space;
-		root_bus->resource[1] = &info->mem_space;
-		root_bus->resource[2] = NULL;
-
-		/* Init all PCI devices into PCI tree */
-		pci_bus_add_devices(root_bus);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &info->io_space);
+	pci_add_resource(&resources, &info->mem_space);
 
+	root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
+				     &resources);
+	if (root_bus) {
 		/* Setup IRQs of all devices using custom routines */
 		pci_fixup_irqs(pci_common_swizzle, info->map_irq);
 
 		/* Assign devices with resources */
 		pci_assign_unassigned_resources();
+	} else {
+		pci_free_resource_list(&resources);
 	}
 }
 
@@ -82,15 +83,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
 	int i, has_io, has_mem;
 	u16 cmd;
 
-	/* Generic PCI bus probing sets these to point at
-	 * &io{port,mem}_resouce which is wrong for us.
-	 */
-	if (pbus->self == NULL) {
-		pbus->resource[0] = &info->io_space;
-		pbus->resource[1] = &info->mem_space;
-		pbus->resource[2] = NULL;
-	}
-
 	list_for_each_entry(dev, &pbus->devices, bus_list) {
 		/*
 		 * We can not rely on that the bootloader has enabled I/O


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 16/29] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (14 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() " Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 17/29] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
                   ` (13 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Tony Luck, linux-kernel

This doesn't change any functionality, but it makes a subsequent patch
slightly simpler.

CC: Tony Luck <tony.luck@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index aa2533a..d7e47a9 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -386,8 +386,11 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
+	pbus = pci_create_bus(NULL, bus, &pci_root_ops, controller, NULL);
+	if (!pbus)
+		return NULL;
 
+	pbus->subordinate = pci_scan_child_bus(pbus);
 	return pbus;
 
 out3:

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 16/29] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:28 ` [PATCH v2 16/29] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Tony Luck, linux-kernel

This doesn't change any functionality, but it makes a subsequent patch
slightly simpler.

CC: Tony Luck <tony.luck@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index aa2533a..d7e47a9 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -386,8 +386,11 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
+	pbus = pci_create_bus(NULL, bus, &pci_root_ops, controller, NULL);
+	if (!pbus)
+		return NULL;
 
+	pbus->subordinate = pci_scan_child_bus(pbus);
 	return pbus;
 
 out3:


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 17/29] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (15 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 16/29] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 18/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
                   ` (12 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Tony Luck, linux-kernel

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This fixes the problem of "early"
and "header" quirks seeing incorrect root bus resources.

We can't use pci_scan_root_bus() because, like x86, ACPI hotplug currently
requires pci_bus_add_devices() in a separate host bridge .start() method.

CC: Tony Luck <tony.luck@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   39 ++++++++++++++-------------------------
 1 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index d7e47a9..a7949b5 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -133,6 +133,7 @@ alloc_pci_controller (int seg)
 struct pci_root_info {
 	struct acpi_device *bridge;
 	struct pci_controller *controller;
+	struct list_head resources;
 	char *name;
 };
 
@@ -314,24 +315,13 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
 				 &window->resource);
 	}
 
-	return AE_OK;
-}
+	/* HP's firmware has a hack to work around a Windows bug.
+	 * Ignore these tiny memory ranges */
+	if (!((res->flags & IORESOURCE_MEM) &&
+	      (res->end - res->start < 16)))
+		pci_add_resource(&info->resources, &window->resource);
 
-static void __devinit
-pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
-{
-	int i;
-
-	pci_bus_remove_resources(bus);
-	for (i = 0; i < ctrl->windows; i++) {
-		struct resource *res = &ctrl->window[i].resource;
-		/* HP's firmware has a hack to work around a Windows bug.
-		 * Ignore these tiny memory ranges */
-		if ((res->flags & IORESOURCE_MEM) &&
-		    (res->end - res->start < 16))
-			continue;
-		pci_bus_add_resource(bus, res, 0);
-	}
+	return AE_OK;
 }
 
 struct pci_bus * __devinit
@@ -342,6 +332,7 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 	int bus = root->secondary.start;
 	struct pci_controller *controller;
 	unsigned int windows = 0;
+	struct pci_root_info info;
 	struct pci_bus *pbus;
 	char *name;
 	int pxm;
@@ -358,11 +349,10 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 		controller->node = pxm_to_node(pxm);
 #endif
 
+	INIT_LIST_HEAD(&info.resources);
 	acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
 			&windows);
 	if (windows) {
-		struct pci_root_info info;
-
 		controller->window =
 			kmalloc_node(sizeof(*controller->window) * windows,
 				     GFP_KERNEL, controller->node);
@@ -386,9 +376,12 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_bus(NULL, bus, &pci_root_ops, controller, NULL);
-	if (!pbus)
+	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
+				   &info.resources);
+	if (!pbus) {
+		pci_free_resource_list(&info.resources);
 		return NULL;
+	}
 
 	pbus->subordinate = pci_scan_child_bus(pbus);
 	return pbus;
@@ -506,14 +499,10 @@ pcibios_fixup_bus (struct pci_bus *b)
 	if (b->self) {
 		pci_read_bridge_bases(b);
 		pcibios_fixup_bridge_resources(b->self);
-	} else {
-		pcibios_setup_root_windows(b, b->sysdata);
 	}
 	list_for_each_entry(dev, &b->devices, bus_list)
 		pcibios_fixup_device_resources(dev);
 	platform_pci_fixup_bus(b);
-
-	return;
 }
 
 void __devinit

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 17/29] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:28 ` [PATCH v2 17/29] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Tony Luck, linux-kernel

Convert from pci_create_bus() to pci_create_root_bus().  This way the root
bus resources are correct immediately.  This fixes the problem of "early"
and "header" quirks seeing incorrect root bus resources.

We can't use pci_scan_root_bus() because, like x86, ACPI hotplug currently
requires pci_bus_add_devices() in a separate host bridge .start() method.

CC: Tony Luck <tony.luck@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/ia64/pci/pci.c |   39 ++++++++++++++-------------------------
 1 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index d7e47a9..a7949b5 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -133,6 +133,7 @@ alloc_pci_controller (int seg)
 struct pci_root_info {
 	struct acpi_device *bridge;
 	struct pci_controller *controller;
+	struct list_head resources;
 	char *name;
 };
 
@@ -314,24 +315,13 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
 				 &window->resource);
 	}
 
-	return AE_OK;
-}
+	/* HP's firmware has a hack to work around a Windows bug.
+	 * Ignore these tiny memory ranges */
+	if (!((res->flags & IORESOURCE_MEM) &&
+	      (res->end - res->start < 16)))
+		pci_add_resource(&info->resources, &window->resource);
 
-static void __devinit
-pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
-{
-	int i;
-
-	pci_bus_remove_resources(bus);
-	for (i = 0; i < ctrl->windows; i++) {
-		struct resource *res = &ctrl->window[i].resource;
-		/* HP's firmware has a hack to work around a Windows bug.
-		 * Ignore these tiny memory ranges */
-		if ((res->flags & IORESOURCE_MEM) &&
-		    (res->end - res->start < 16))
-			continue;
-		pci_bus_add_resource(bus, res, 0);
-	}
+	return AE_OK;
 }
 
 struct pci_bus * __devinit
@@ -342,6 +332,7 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 	int bus = root->secondary.start;
 	struct pci_controller *controller;
 	unsigned int windows = 0;
+	struct pci_root_info info;
 	struct pci_bus *pbus;
 	char *name;
 	int pxm;
@@ -358,11 +349,10 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 		controller->node = pxm_to_node(pxm);
 #endif
 
+	INIT_LIST_HEAD(&info.resources);
 	acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
 			&windows);
 	if (windows) {
-		struct pci_root_info info;
-
 		controller->window =
 			kmalloc_node(sizeof(*controller->window) * windows,
 				     GFP_KERNEL, controller->node);
@@ -386,9 +376,12 @@ pci_acpi_scan_root(struct acpi_pci_root *root)
 	 * should handle the case here, but it appears that IA64 hasn't
 	 * such quirk. So we just ignore the case now.
 	 */
-	pbus = pci_create_bus(NULL, bus, &pci_root_ops, controller, NULL);
-	if (!pbus)
+	pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller,
+				   &info.resources);
+	if (!pbus) {
+		pci_free_resource_list(&info.resources);
 		return NULL;
+	}
 
 	pbus->subordinate = pci_scan_child_bus(pbus);
 	return pbus;
@@ -506,14 +499,10 @@ pcibios_fixup_bus (struct pci_bus *b)
 	if (b->self) {
 		pci_read_bridge_bases(b);
 		pcibios_fixup_bridge_resources(b->self);
-	} else {
-		pcibios_setup_root_windows(b, b->sysdata);
 	}
 	list_for_each_entry(dev, &b->devices, bus_list)
 		pcibios_fixup_device_resources(dev);
 	platform_pci_fixup_bus(b);
-
-	return;
 }
 
 void __devinit


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 18/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (16 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 17/29] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 19/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
                   ` (11 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

No functional change here; just converting from the deprecated
pci_scan_bus_parented() to pci_create_root_bus() to make a future
patch simpler.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index bcd5d54..fba5636 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -1007,22 +1007,24 @@ static int __init dino_probe(struct parisc_device *dev)
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_scan_bus_parented(&dev->dev,
-			 dino_current_bus, &dino_cfg_ops, NULL);
-
-	if(bus) {
-		/* This code *depends* on scanning being single threaded
-		 * if it isn't, this global bus number count will fail
-		 */
-		dino_current_bus = bus->subordinate + 1;
-		pci_bus_assign_resources(bus);
-		pci_bus_add_devices(bus);
-	} else {
+	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+			 dino_current_bus, &dino_cfg_ops, NULL, NULL);
+	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
 		       dev_name(&dev->dev), dino_current_bus);
 		/* increment the bus number in case of duplicates */
 		dino_current_bus++;
+		return 0;
 	}
+
+	bus->subordinate = pci_scan_child_bus(bus);
+
+	/* This code *depends* on scanning being single threaded
+	 * if it isn't, this global bus number count will fail
+	 */
+	dino_current_bus = bus->subordinate + 1;
+	pci_bus_assign_resources(bus);
+	pci_bus_add_devices(bus);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 18/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:28 ` [PATCH v2 18/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

No functional change here; just converting from the deprecated
pci_scan_bus_parented() to pci_create_root_bus() to make a future
patch simpler.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index bcd5d54..fba5636 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -1007,22 +1007,24 @@ static int __init dino_probe(struct parisc_device *dev)
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
-	dino_dev->hba.hba_bus = bus = pci_scan_bus_parented(&dev->dev,
-			 dino_current_bus, &dino_cfg_ops, NULL);
-
-	if(bus) {
-		/* This code *depends* on scanning being single threaded
-		 * if it isn't, this global bus number count will fail
-		 */
-		dino_current_bus = bus->subordinate + 1;
-		pci_bus_assign_resources(bus);
-		pci_bus_add_devices(bus);
-	} else {
+	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
+			 dino_current_bus, &dino_cfg_ops, NULL, NULL);
+	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
 		       dev_name(&dev->dev), dino_current_bus);
 		/* increment the bus number in case of duplicates */
 		dino_current_bus++;
+		return 0;
 	}
+
+	bus->subordinate = pci_scan_child_bus(bus);
+
+	/* This code *depends* on scanning being single threaded
+	 * if it isn't, this global bus number count will fail
+	 */
+	dino_current_bus = bus->subordinate + 1;
+	pci_bus_assign_resources(bus);
+	pci_bus_add_devices(bus);
 	return 0;
 }
 


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 19/29] parisc/PCI: supply root bus resources to pci_create_root_bus()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (17 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 18/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 20/29] parisc/PCI: deal with LMMIO/PAT overlaps before creating PCI root bus Bjorn Helgaas
                   ` (10 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

Supply root bus resources to pci_create_root_bus() so they're correct
immediately.  This fixes the problem of "early" and "header" quirks seeing
incorrect root bus resources.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index fba5636..2aca77f 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -562,19 +562,6 @@ dino_fixup_bus(struct pci_bus *bus)
 	/* Firmware doesn't set up card-mode dino, so we have to */
 	if (is_card_dino(&dino_dev->hba.dev->id)) {
 		dino_card_setup(bus, dino_dev->hba.base_addr);
-	} else if(bus->parent == NULL) {
-		/* must have a dino above it, reparent the resources
-		 * into the dino window */
-		int i;
-		struct resource *res = &dino_dev->hba.lmmio_space;
-
-		bus->resource[0] = &(dino_dev->hba.io_space);
-		for(i = 0; i < DINO_MAX_LMMIO_RESOURCES; i++) {
-			if(res[i].flags == 0)
-				break;
-			bus->resource[i+1] = &res[i];
-		}
-
 	} else if (bus->parent) {
 		int i;
 
@@ -927,6 +914,7 @@ static int __init dino_probe(struct parisc_device *dev)
 	const char *version = "unknown";
 	char *name;
 	int is_cujo = 0;
+	struct list_head resources;
 	struct pci_bus *bus;
 	unsigned long hpa = dev->hpa.start;
 
@@ -1003,15 +991,25 @@ static int __init dino_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = dino_dev;
 
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &dino_dev->hba.io_space);
+	if (dino_dev->hba.lmmio_space.flags)
+		pci_add_resource(&resources, &dino_dev->hba.lmmio_space);
+	if (dino_dev->hba.elmmio_space.flags)
+		pci_add_resource(&resources, &dino_dev->hba.elmmio_space);
+	if (dino_dev->hba.gmmio_space.flags)
+		pci_add_resource(&resources, &dino_dev->hba.gmmio_space);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
 	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
-			 dino_current_bus, &dino_cfg_ops, NULL, NULL);
+			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
 		       dev_name(&dev->dev), dino_current_bus);
+		pci_free_resource_list(&resources);
 		/* increment the bus number in case of duplicates */
 		dino_current_bus++;
 		return 0;

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 19/29] parisc/PCI: supply root bus resources to pci_create_root_bus()
  2011-10-14  4:28 ` [PATCH v2 19/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

Supply root bus resources to pci_create_root_bus() so they're correct
immediately.  This fixes the problem of "early" and "header" quirks seeing
incorrect root bus resources.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/dino.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index fba5636..2aca77f 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -562,19 +562,6 @@ dino_fixup_bus(struct pci_bus *bus)
 	/* Firmware doesn't set up card-mode dino, so we have to */
 	if (is_card_dino(&dino_dev->hba.dev->id)) {
 		dino_card_setup(bus, dino_dev->hba.base_addr);
-	} else if(bus->parent == NULL) {
-		/* must have a dino above it, reparent the resources
-		 * into the dino window */
-		int i;
-		struct resource *res = &dino_dev->hba.lmmio_space;
-
-		bus->resource[0] = &(dino_dev->hba.io_space);
-		for(i = 0; i < DINO_MAX_LMMIO_RESOURCES; i++) {
-			if(res[i].flags == 0)
-				break;
-			bus->resource[i+1] = &res[i];
-		}
-
 	} else if (bus->parent) {
 		int i;
 
@@ -927,6 +914,7 @@ static int __init dino_probe(struct parisc_device *dev)
 	const char *version = "unknown";
 	char *name;
 	int is_cujo = 0;
+	struct list_head resources;
 	struct pci_bus *bus;
 	unsigned long hpa = dev->hpa.start;
 
@@ -1003,15 +991,25 @@ static int __init dino_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = dino_dev;
 
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &dino_dev->hba.io_space);
+	if (dino_dev->hba.lmmio_space.flags)
+		pci_add_resource(&resources, &dino_dev->hba.lmmio_space);
+	if (dino_dev->hba.elmmio_space.flags)
+		pci_add_resource(&resources, &dino_dev->hba.elmmio_space);
+	if (dino_dev->hba.gmmio_space.flags)
+		pci_add_resource(&resources, &dino_dev->hba.gmmio_space);
+
 	/*
 	** It's not used to avoid chicken/egg problems
 	** with configuration accessor functions.
 	*/
 	dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev,
-			 dino_current_bus, &dino_cfg_ops, NULL, NULL);
+			 dino_current_bus, &dino_cfg_ops, NULL, &resources);
 	if (!bus) {
 		printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
 		       dev_name(&dev->dev), dino_current_bus);
+		pci_free_resource_list(&resources);
 		/* increment the bus number in case of duplicates */
 		dino_current_bus++;
 		return 0;


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 20/29] parisc/PCI: deal with LMMIO/PAT overlaps before creating PCI root bus
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (18 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 19/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 21/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

This moves the truncate_pat_collision() call out of the pcibios_fixup_bus()
path so that when a future patch builds a list of root bus resources for
pci_create_bus(), it can use the truncated LMMIO range.

truncate_pat_collision() used to be called in this path:

    pci_scan_bus_parented
      pci_create_bus
      pci_scan_child_bus
        pcibios_fixup_bus
	  lba_fixup_bus
	    truncate_pat_collision

All of the PAT and lba_dev resource setup must be done before we call
pci_scan_bus_parented(), so it should be safe to move the
truncate_pat_collision() to just before pci_scan_bus_parented().

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/lba_pci.c |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 3aeb327..2c7edf3 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -689,23 +689,7 @@ lba_fixup_bus(struct pci_bus *bus)
 				bus->resource[i++] = &(ldev->hba.elmmio_space);
 		}
 
-
-		/*   Overlaps with elmmio can (and should) fail here.
-		 *   We will prune (or ignore) the distributed range.
-		 *
-		 *   FIXME: SBA code should register all elmmio ranges first.
-		 *      that would take care of elmmio ranges routed
-		 *	to a different rope (already discovered) from
-		 *	getting registered *after* LBA code has already
-		 *	registered it's distributed lmmio range.
-		 */
-		if (truncate_pat_collision(&iomem_resource,
-				       	&(ldev->hba.lmmio_space))) {
-
-			printk(KERN_WARNING "LBA: lmmio_space [%lx/%lx] duplicate!\n",
-					(long)ldev->hba.lmmio_space.start,
-					(long)ldev->hba.lmmio_space.end);
-		} else {
+		if (ldev->hba.lmmio_space.flags) {
 			err = request_resource(&iomem_resource, &(ldev->hba.lmmio_space));
 			if (err < 0) {
 				printk(KERN_ERR "FAILED: lba_fixup_bus() request for "
@@ -1518,6 +1502,23 @@ lba_driver_probe(struct parisc_device *dev)
 	if (lba_dev->hba.bus_num.start < lba_next_bus)
 		lba_dev->hba.bus_num.start = lba_next_bus;
 
+	/*   Overlaps with elmmio can (and should) fail here.
+	 *   We will prune (or ignore) the distributed range.
+	 *
+	 *   FIXME: SBA code should register all elmmio ranges first.
+	 *      that would take care of elmmio ranges routed
+	 *	to a different rope (already discovered) from
+	 *	getting registered *after* LBA code has already
+	 *	registered it's distributed lmmio range.
+	 */
+	if (truncate_pat_collision(&iomem_resource,
+				   &(lba_dev->hba.lmmio_space))) {
+		printk(KERN_WARNING "LBA: lmmio_space [%lx/%lx] duplicate!\n",
+				(long)lba_dev->hba.lmmio_space.start,
+				(long)lba_dev->hba.lmmio_space.end);
+		lba_dev->hba.lmmio_space.flags = 0;
+	}
+
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
 		pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 21/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (19 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 20/29] parisc/PCI: deal with LMMIO/PAT overlaps before creating PCI root bus Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:28 ` [PATCH v2 22/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
                   ` (8 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

No functional change here; just converting from the deprecated
pci_scan_bus_parented() to pci_create_root_bus() to make a future
patch simpler.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/lba_pci.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 2c7edf3..d62c268 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1521,8 +1521,12 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,
-				cfg_ops, NULL);
+		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+				    cfg_ops, NULL, NULL);
+	if (!lba_bus)
+		return 0;
+
+	lba_bus->subordinate = pci_scan_child_bus(lba_bus);
 
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
@@ -1552,10 +1556,8 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	if (lba_bus) {
-		lba_next_bus = lba_bus->subordinate + 1;
-		pci_bus_add_devices(lba_bus);
-	}
+	lba_next_bus = lba_bus->subordinate + 1;
+	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
 	return 0;

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 21/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:28 ` [PATCH v2 21/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

No functional change here; just converting from the deprecated
pci_scan_bus_parented() to pci_create_root_bus() to make a future
patch simpler.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/lba_pci.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 2c7edf3..d62c268 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1521,8 +1521,12 @@ lba_driver_probe(struct parisc_device *dev)
 
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
-		pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,
-				cfg_ops, NULL);
+		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
+				    cfg_ops, NULL, NULL);
+	if (!lba_bus)
+		return 0;
+
+	lba_bus->subordinate = pci_scan_child_bus(lba_bus);
 
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
@@ -1552,10 +1556,8 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
 	}
 
-	if (lba_bus) {
-		lba_next_bus = lba_bus->subordinate + 1;
-		pci_bus_add_devices(lba_bus);
-	}
+	lba_next_bus = lba_bus->subordinate + 1;
+	pci_bus_add_devices(lba_bus);
 
 	/* Whew! Finally done! Tell services we got this one covered. */
 	return 0;


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 22/29] parisc/PCI: supply root bus resources to pci_create_root_bus()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (20 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 21/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:28 ` Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 23/29] xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
                   ` (7 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

Supply root bus resources to pci_create_root_bus() so they're correct
immediately.  This fixes the problem of "early" and "header" quirks seeing
incorrect root bus resources.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/lba_pci.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index d62c268..7dd5699 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -653,7 +653,7 @@ lba_fixup_bus(struct pci_bus *bus)
 		}
 	} else {
 		/* Host-PCI Bridge */
-		int err, i;
+		int err;
 
 		DBG("lba_fixup_bus() %s [%lx/%lx]/%lx\n",
 			ldev->hba.io_space.name,
@@ -669,9 +669,6 @@ lba_fixup_bus(struct pci_bus *bus)
 			lba_dump_res(&ioport_resource, 2);
 			BUG();
 		}
-		/* advertize Host bridge resources to PCI bus */
-		bus->resource[0] = &(ldev->hba.io_space);
-		i = 1;
 
 		if (ldev->hba.elmmio_space.start) {
 			err = request_resource(&iomem_resource,
@@ -685,8 +682,7 @@ lba_fixup_bus(struct pci_bus *bus)
 
 				/* lba_dump_res(&iomem_resource, 2); */
 				/* BUG(); */
-			} else
-				bus->resource[i++] = &(ldev->hba.elmmio_space);
+			}
 		}
 
 		if (ldev->hba.lmmio_space.flags) {
@@ -696,8 +692,7 @@ lba_fixup_bus(struct pci_bus *bus)
 					"lmmio_space [%lx/%lx]\n",
 					(long)ldev->hba.lmmio_space.start,
 					(long)ldev->hba.lmmio_space.end);
-			} else
-				bus->resource[i++] = &(ldev->hba.lmmio_space);
+			}
 		}
 
 #ifdef CONFIG_64BIT
@@ -712,7 +707,6 @@ lba_fixup_bus(struct pci_bus *bus)
 				lba_dump_res(&iomem_resource, 2);
 				BUG();
 			}
-			bus->resource[i++] = &(ldev->hba.gmmio_space);
 		}
 #endif
 
@@ -1388,6 +1382,7 @@ static int __init
 lba_driver_probe(struct parisc_device *dev)
 {
 	struct lba_device *lba_dev;
+	struct list_head resources;
 	struct pci_bus *lba_bus;
 	struct pci_ops *cfg_ops;
 	u32 func_class;
@@ -1519,12 +1514,23 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->hba.lmmio_space.flags = 0;
 	}
 
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &lba_dev->hba.io_space);
+	if (lba_dev->hba.elmmio_space.start)
+		pci_add_resource(&resources, &lba_dev->hba.elmmio_space);
+	if (lba_dev->hba.lmmio_space.flags)
+		pci_add_resource(&resources, &lba_dev->hba.lmmio_space);
+	if (lba_dev->hba.gmmio_space.flags)
+		pci_add_resource(&resources, &lba_dev->hba.gmmio_space);
+
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
 		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
-				    cfg_ops, NULL, NULL);
-	if (!lba_bus)
+				    cfg_ops, NULL, &resources);
+	if (!lba_bus) {
+		pci_free_resource_list(&resources);
 		return 0;
+	}
 
 	lba_bus->subordinate = pci_scan_child_bus(lba_bus);
 

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 22/29] parisc/PCI: supply root bus resources to pci_create_root_bus()
  2011-10-14  4:28 ` [PATCH v2 22/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
@ 2011-10-14  4:28   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:28 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

Supply root bus resources to pci_create_root_bus() so they're correct
immediately.  This fixes the problem of "early" and "header" quirks seeing
incorrect root bus resources.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/parisc/lba_pci.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index d62c268..7dd5699 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -653,7 +653,7 @@ lba_fixup_bus(struct pci_bus *bus)
 		}
 	} else {
 		/* Host-PCI Bridge */
-		int err, i;
+		int err;
 
 		DBG("lba_fixup_bus() %s [%lx/%lx]/%lx\n",
 			ldev->hba.io_space.name,
@@ -669,9 +669,6 @@ lba_fixup_bus(struct pci_bus *bus)
 			lba_dump_res(&ioport_resource, 2);
 			BUG();
 		}
-		/* advertize Host bridge resources to PCI bus */
-		bus->resource[0] = &(ldev->hba.io_space);
-		i = 1;
 
 		if (ldev->hba.elmmio_space.start) {
 			err = request_resource(&iomem_resource,
@@ -685,8 +682,7 @@ lba_fixup_bus(struct pci_bus *bus)
 
 				/* lba_dump_res(&iomem_resource, 2); */
 				/* BUG(); */
-			} else
-				bus->resource[i++] = &(ldev->hba.elmmio_space);
+			}
 		}
 
 		if (ldev->hba.lmmio_space.flags) {
@@ -696,8 +692,7 @@ lba_fixup_bus(struct pci_bus *bus)
 					"lmmio_space [%lx/%lx]\n",
 					(long)ldev->hba.lmmio_space.start,
 					(long)ldev->hba.lmmio_space.end);
-			} else
-				bus->resource[i++] = &(ldev->hba.lmmio_space);
+			}
 		}
 
 #ifdef CONFIG_64BIT
@@ -712,7 +707,6 @@ lba_fixup_bus(struct pci_bus *bus)
 				lba_dump_res(&iomem_resource, 2);
 				BUG();
 			}
-			bus->resource[i++] = &(ldev->hba.gmmio_space);
 		}
 #endif
 
@@ -1388,6 +1382,7 @@ static int __init
 lba_driver_probe(struct parisc_device *dev)
 {
 	struct lba_device *lba_dev;
+	struct list_head resources;
 	struct pci_bus *lba_bus;
 	struct pci_ops *cfg_ops;
 	u32 func_class;
@@ -1519,12 +1514,23 @@ lba_driver_probe(struct parisc_device *dev)
 		lba_dev->hba.lmmio_space.flags = 0;
 	}
 
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &lba_dev->hba.io_space);
+	if (lba_dev->hba.elmmio_space.start)
+		pci_add_resource(&resources, &lba_dev->hba.elmmio_space);
+	if (lba_dev->hba.lmmio_space.flags)
+		pci_add_resource(&resources, &lba_dev->hba.lmmio_space);
+	if (lba_dev->hba.gmmio_space.flags)
+		pci_add_resource(&resources, &lba_dev->hba.gmmio_space);
+
 	dev->dev.platform_data = lba_dev;
 	lba_bus = lba_dev->hba.hba_bus =
 		pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
-				    cfg_ops, NULL, NULL);
-	if (!lba_bus)
+				    cfg_ops, NULL, &resources);
+	if (!lba_bus) {
+		pci_free_resource_list(&resources);
 		return 0;
+	}
 
 	lba_bus->subordinate = pci_scan_child_bus(lba_bus);
 


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 23/29] xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (21 preceding siblings ...)
  2011-10-14  4:28 ` [PATCH v2 22/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29   ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 24/29] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
                   ` (6 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel, Konrad Rzeszutek Wilk

No functional change here; just converting from the deprecated
pci_scan_bus_parented() to pci_create_root_bus().

I don't see that Xen ever updates the root bus resources, but in
general, the default resources (ioport_resource and iomem_resource)
installed by pci_create_bus() are incorrect.

CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 6fa215a..3a07b33 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -470,8 +470,8 @@ static int __devinit pcifront_scan_root(struct pcifront_device *pdev,
 	}
 	pcifront_init_sd(sd, domain, bus, pdev);
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_create_root_bus(&pdev->xdev->dev, bus, &pcifront_bus_ops, sd,
+				NULL);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
@@ -479,11 +479,12 @@ static int __devinit pcifront_scan_root(struct pcifront_device *pdev,
 		goto err_out;
 	}
 
+	b->subordinate = pci_scan_child_bus(b);
 	bus_entry->bus = b;
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_child_bus skips devices which do not have
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 23/29] xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented()
  2011-10-14  4:29 ` [PATCH v2 23/29] xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:29   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel, Konrad Rzeszutek Wilk

No functional change here; just converting from the deprecated
pci_scan_bus_parented() to pci_create_root_bus().

I don't see that Xen ever updates the root bus resources, but in
general, the default resources (ioport_resource and iomem_resource)
installed by pci_create_bus() are incorrect.

CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/xen-pcifront.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 6fa215a..3a07b33 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -470,8 +470,8 @@ static int __devinit pcifront_scan_root(struct pcifront_device *pdev,
 	}
 	pcifront_init_sd(sd, domain, bus, pdev);
 
-	b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-				  &pcifront_bus_ops, sd);
+	b = pci_create_root_bus(&pdev->xdev->dev, bus, &pcifront_bus_ops, sd,
+				NULL);
 	if (!b) {
 		dev_err(&pdev->xdev->dev,
 			"Error creating PCI Frontend Bus!\n");
@@ -479,11 +479,12 @@ static int __devinit pcifront_scan_root(struct pcifront_device *pdev,
 		goto err_out;
 	}
 
+	b->subordinate = pci_scan_child_bus(b);
 	bus_entry->bus = b;
 
 	list_add(&bus_entry->list, &pdev->root_buses);
 
-	/* pci_scan_bus_parented skips devices which do not have a have
+	/* pci_scan_child_bus skips devices which do not have
 	* devfn==0. The pcifront_scan_bus enumerates all devfn. */
 	err = pcifront_scan_bus(pdev, domain, bus, b);
 


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 24/29] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (22 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 23/29] xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29   ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 25/29] arm/PCI: " Bjorn Helgaas
                   ` (5 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c9ab94e..e9e78a2 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -286,22 +286,7 @@ pcibios_fixup_bus(struct pci_bus *bus)
 	struct pci_controller *hose = bus->sysdata;
 	struct pci_dev *dev = bus->self;
 
-	if (!dev) {
-		/* Root bus. */
-		u32 pci_mem_end;
-		u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
-		unsigned long end;
-
-		bus->resource[0] = hose->io_space;
-		bus->resource[1] = hose->mem_space;
-
-		/* Adjust hose mem_space limit to prevent PCI allocations
-		   in the iommu windows. */
-		pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
-		end = hose->mem_space->start + pci_mem_end;
-		if (hose->mem_space->end > end)
-			hose->mem_space->end = end;
- 	} else if (pci_probe_only &&
+	if (pci_probe_only && dev &&
  		   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
  		pci_read_bridge_bases(bus);
  		pcibios_fixup_device_resources(dev, bus);
@@ -414,13 +399,31 @@ void __init
 common_init_pci(void)
 {
 	struct pci_controller *hose;
+	struct list_head resources;
 	struct pci_bus *bus;
 	int next_busno;
 	int need_domain_info = 0;
+	u32 pci_mem_end;
+	u32 sg_base;
+	unsigned long end;
 
 	/* Scan all of the recorded PCI controllers.  */
 	for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
-		bus = pci_scan_bus(next_busno, alpha_mv.pci_ops, hose);
+		sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
+
+		/* Adjust hose mem_space limit to prevent PCI allocations
+		   in the iommu windows. */
+		pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
+		end = hose->mem_space->start + pci_mem_end;
+		if (hose->mem_space->end > end)
+			hose->mem_space->end = end;
+
+		INIT_LIST_HEAD(&resources);
+		pci_add_resource(&resources, &hose->io_space);
+		pci_add_resource(&resources, &hose->mem_space);
+
+		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
+					hose, &resources);
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->subordinate + 1;

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 24/29] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:29 ` [PATCH v2 24/29] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:29   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/alpha/kernel/pci.c |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c9ab94e..e9e78a2 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -286,22 +286,7 @@ pcibios_fixup_bus(struct pci_bus *bus)
 	struct pci_controller *hose = bus->sysdata;
 	struct pci_dev *dev = bus->self;
 
-	if (!dev) {
-		/* Root bus. */
-		u32 pci_mem_end;
-		u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
-		unsigned long end;
-
-		bus->resource[0] = hose->io_space;
-		bus->resource[1] = hose->mem_space;
-
-		/* Adjust hose mem_space limit to prevent PCI allocations
-		   in the iommu windows. */
-		pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
-		end = hose->mem_space->start + pci_mem_end;
-		if (hose->mem_space->end > end)
-			hose->mem_space->end = end;
- 	} else if (pci_probe_only &&
+	if (pci_probe_only && dev &&
  		   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
  		pci_read_bridge_bases(bus);
  		pcibios_fixup_device_resources(dev, bus);
@@ -414,13 +399,31 @@ void __init
 common_init_pci(void)
 {
 	struct pci_controller *hose;
+	struct list_head resources;
 	struct pci_bus *bus;
 	int next_busno;
 	int need_domain_info = 0;
+	u32 pci_mem_end;
+	u32 sg_base;
+	unsigned long end;
 
 	/* Scan all of the recorded PCI controllers.  */
 	for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
-		bus = pci_scan_bus(next_busno, alpha_mv.pci_ops, hose);
+		sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
+
+		/* Adjust hose mem_space limit to prevent PCI allocations
+		   in the iommu windows. */
+		pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
+		end = hose->mem_space->start + pci_mem_end;
+		if (hose->mem_space->end > end)
+			hose->mem_space->end = end;
+
+		INIT_LIST_HEAD(&resources);
+		pci_add_resource(&resources, &hose->io_space);
+		pci_add_resource(&resources, &hose->mem_space);
+
+		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
+					hose, &resources);
 		hose->bus = bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->subordinate + 1;


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 25/29] arm/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (23 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 24/29] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 26/29] frv/PCI: " Bjorn Helgaas
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Russell King, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/arm/common/it8152.c              |    6 +++---
 arch/arm/common/via82c505.c           |    3 ++-
 arch/arm/include/asm/mach/pci.h       |    2 +-
 arch/arm/kernel/bios32.c              |   27 ++++++++-------------------
 arch/arm/mach-cns3xxx/pcie.c          |    8 ++++----
 arch/arm/mach-dove/pcie.c             |    9 ++++-----
 arch/arm/mach-footbridge/dc21285.c    |    8 ++++----
 arch/arm/mach-integrator/pci_v3.c     |   19 ++++++++++---------
 arch/arm/mach-iop13xx/pci.c           |   17 ++++++++---------
 arch/arm/mach-ixp2000/enp2611.c       |    3 ++-
 arch/arm/mach-ixp2000/pci.c           |    8 ++++----
 arch/arm/mach-ixp23xx/pci.c           |    8 ++++----
 arch/arm/mach-ixp4xx/common-pci.c     |    8 ++++----
 arch/arm/mach-kirkwood/pcie.c         |    8 ++++----
 arch/arm/mach-ks8695/pci.c            |    8 ++++----
 arch/arm/mach-mv78xx0/pcie.c          |    8 ++++----
 arch/arm/mach-orion5x/pci.c           |   16 ++++++++--------
 arch/arm/mach-sa1100/pci-nanoengine.c |    9 +++++----
 arch/arm/mach-tegra/pcie.c            |    9 +++++----
 arch/arm/mach-versatile/pci.c         |   19 ++++++++++---------
 arch/arm/plat-iop/pci.c               |    8 ++++----
 21 files changed, 102 insertions(+), 109 deletions(-)

diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c
index a7934ba..e663a41 100644
--- a/arch/arm/common/it8152.c
+++ b/arch/arm/common/it8152.c
@@ -298,8 +298,8 @@ int __init it8152_pci_setup(int nr, struct pci_sys_data *sys)
 		goto err1;
 	}
 
-	sys->resource[0] = &it8152_io;
-	sys->resource[1] = &it8152_mem;
+	pci_add_resource(&sys->resources, &it8152_io);
+	pci_add_resource(&sys->resources, &it8152_mem);
 
 	if (platform_notify || platform_notify_remove) {
 		printk(KERN_ERR "PCI: Can't use platform_notify\n");
@@ -351,7 +351,7 @@ void pcibios_set_master(struct pci_dev *dev)
 
 struct pci_bus * __init it8152_pci_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(nr, &it8152_ops, sys);
+	return pci_scan_root_bus(NULL, nr, &it8152_ops, sys, &sys->resources);
 }
 
 EXPORT_SYMBOL(dma_set_coherent_mask);
diff --git a/arch/arm/common/via82c505.c b/arch/arm/common/via82c505.c
index 8421d39..67dd2af 100644
--- a/arch/arm/common/via82c505.c
+++ b/arch/arm/common/via82c505.c
@@ -86,7 +86,8 @@ int __init via82c505_setup(int nr, struct pci_sys_data *sys)
 struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
 	if (nr == 0)
-		return pci_scan_bus(0, &via82c505_ops, sysdata);
+		return pci_scan_root_bus(NULL, 0, &via82c505_ops, sysdata,
+					 &sysdata->resources);
 
 	return NULL;
 }
diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h
index 186efd4..d943b7d 100644
--- a/arch/arm/include/asm/mach/pci.h
+++ b/arch/arm/include/asm/mach/pci.h
@@ -40,7 +40,7 @@ struct pci_sys_data {
 	u64		mem_offset;	/* bus->cpu memory mapping offset	*/
 	unsigned long	io_offset;	/* bus->cpu IO mapping offset		*/
 	struct pci_bus	*bus;		/* PCI bus				*/
-	struct resource *resource[3];	/* Primary PCI bus resources		*/
+	struct list_head resources;	/* root bus resources (apertures)       */
 					/* Bridge swizzling			*/
 	u8		(*swizzle)(struct pci_dev *, u8 *);
 					/* IRQ mapping				*/
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index d6df359..ebdeb3b 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -316,21 +316,6 @@ pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev)
 	}
 }
 
-static void __devinit
-pbus_assign_bus_resources(struct pci_bus *bus, struct pci_sys_data *root)
-{
-	struct pci_dev *dev = bus->self;
-	int i;
-
-	if (!dev) {
-		/*
-		 * Assign root bus resources.
-		 */
-		for (i = 0; i < 3; i++)
-			bus->resource[i] = root->resource[i];
-	}
-}
-
 /*
  * pcibios_fixup_bus - Called after each bus is probed,
  * but before its children are examined.
@@ -341,8 +326,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 	struct pci_dev *dev;
 	u16 features = PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_FAST_BACK;
 
-	pbus_assign_bus_resources(bus, root);
-
 	/*
 	 * Walk the devices on this bus, working out what we can
 	 * and can't support.
@@ -509,12 +492,18 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
 		sys->busnr   = busnr;
 		sys->swizzle = hw->swizzle;
 		sys->map_irq = hw->map_irq;
-		sys->resource[0] = &ioport_resource;
-		sys->resource[1] = &iomem_resource;
+		INIT_LIST_HEAD(&sys->resources);
 
 		ret = hw->setup(nr, sys);
 
 		if (ret > 0) {
+			if (list_empty(&sys->resources)) {
+				pci_add_resource(&sys->resources,
+						 &ioport_resource);
+				pci_add_resource(&sys->resources,
+						 &iomem_resource);
+			}
+
 			sys->bus = hw->scan(nr, sys);
 
 			if (!sys->bus)
diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c
index 0f8fca4..e159d69 100644
--- a/arch/arm/mach-cns3xxx/pcie.c
+++ b/arch/arm/mach-cns3xxx/pcie.c
@@ -151,13 +151,12 @@ static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
 	struct cns3xxx_pcie *cnspci = sysdata_to_cnspci(sys);
 	struct resource *res_io = &cnspci->res_io;
 	struct resource *res_mem = &cnspci->res_mem;
-	struct resource **sysres = sys->resource;
 
 	BUG_ON(request_resource(&iomem_resource, res_io) ||
 	       request_resource(&iomem_resource, res_mem));
 
-	sysres[0] = res_io;
-	sysres[1] = res_mem;
+	pci_add_resource(&sys->resources, res_io);
+	pci_add_resource(&sys->resources, res_mem);
 
 	return 1;
 }
@@ -169,7 +168,8 @@ static struct pci_ops cns3xxx_pcie_ops = {
 
 static struct pci_bus *cns3xxx_pci_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &cns3xxx_pcie_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &cns3xxx_pcie_ops, sys,
+				 &sys->resources);
 }
 
 static int cns3xxx_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index aa2b3a0..d5b5dce 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -69,7 +69,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
 	pp->res[0].flags = IORESOURCE_IO;
 	if (request_resource(&ioport_resource, &pp->res[0]))
 		panic("Request PCIe IO resource failed\n");
-	sys->resource[0] = &pp->res[0];
+	pci_add_resource(&sys->resources, &pp->res[0]);
 
 	/*
 	 * IORESOURCE_MEM
@@ -88,9 +88,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
 	pp->res[1].flags = IORESOURCE_MEM;
 	if (request_resource(&iomem_resource, &pp->res[1]))
 		panic("Request PCIe Memory resource failed\n");
-	sys->resource[1] = &pp->res[1];
-
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &pp->res[1]);
 
 	return 1;
 }
@@ -184,7 +182,8 @@ dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pci_bus *bus;
 
 	if (nr < num_pcie_ports) {
-		bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+		bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+					&sys->resources);
 	} else {
 		bus = NULL;
 		BUG();
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index 18c32a5..f685650 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -275,9 +275,9 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
 	allocate_resource(&iomem_resource, &res[0], 0x40000000,
 			  0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
 
-	sys->resource[0] = &ioport_resource;
-	sys->resource[1] = &res[0];
-	sys->resource[2] = &res[1];
+	pci_add_resource(&sys->resources, &ioport_resource);
+	pci_add_resource(&sys->resources, &res[0]);
+	pci_add_resource(&sys->resources, &res[1]);
 	sys->mem_offset  = DC21285_PCI_MEM;
 
 	return 1;
@@ -285,7 +285,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
 
 struct pci_bus * __init dc21285_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(0, &dc21285_ops, sys);
+	return pci_scan_root_bus(NULL, 0, &dc21285_ops, sys, &sys->resources);
 }
 
 #define dc21285_request_irq(_a, _b, _c, _d, _e) \
diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c
index 11b86e5..a8c0abb 100644
--- a/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -359,7 +359,7 @@ static struct resource pre_mem = {
 	.flags	= IORESOURCE_MEM | IORESOURCE_PREFETCH,
 };
 
-static int __init pci_v3_setup_resources(struct resource **resource)
+static int __init pci_v3_setup_resources(struct list_head *resources)
 {
 	if (request_resource(&iomem_resource, &non_mem)) {
 		printk(KERN_ERR "PCI: unable to allocate non-prefetchable "
@@ -374,13 +374,13 @@ static int __init pci_v3_setup_resources(struct resource **resource)
 	}
 
 	/*
-	 * bus->resource[0] is the IO resource for this bus
-	 * bus->resource[1] is the mem resource for this bus
-	 * bus->resource[2] is the prefetch mem resource for this bus
+	 * the IO resource for this bus
+	 * the mem resource for this bus
+	 * the prefetch mem resource for this bus
 	 */
-	resource[0] = &ioport_resource;
-	resource[1] = &non_mem;
-	resource[2] = &pre_mem;
+	pci_add_resource(resources, &ioport_resource);
+	pci_add_resource(resources, &non_mem);
+	pci_add_resource(resources, &pre_mem);
 
 	return 1;
 }
@@ -481,7 +481,7 @@ int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
 
 	if (nr == 0) {
 		sys->mem_offset = PHYS_PCI_MEM_BASE;
-		ret = pci_v3_setup_resources(sys->resource);
+		ret = pci_v3_setup_resources(&sys->resources);
 	}
 
 	return ret;
@@ -489,7 +489,8 @@ int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
 
 struct pci_bus * __init pci_v3_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &pci_v3_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &pci_v3_ops, sys,
+				 &sys->resources);
 }
 
 /*
diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/pci.c
index 251c408..3738a28 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -536,14 +536,14 @@ struct pci_bus *iop13xx_scan_bus(int nr, struct pci_sys_data *sys)
 			while(time_before(jiffies, atux_trhfa_timeout))
 				udelay(100);
 
-		bus = pci_bus_atux = pci_scan_bus(sys->busnr,
-						  &iop13xx_atux_ops,
-						  sys);
+		bus = pci_bus_atux = pci_scan_root_bus(NULL, sys->busnr,
+						       &iop13xx_atux_ops,
+						       sys, &sys->resources);
 		break;
 	case IOP13XX_INIT_ATU_ATUE:
-		bus = pci_bus_atue = pci_scan_bus(sys->busnr,
-						  &iop13xx_atue_ops,
-						  sys);
+		bus = pci_bus_atue = pci_scan_root_bus(NULL, sys->busnr,
+						       &iop13xx_atue_ops,
+						       sys, &sys->resources);
 		break;
 	}
 
@@ -1083,9 +1083,8 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
 	request_resource(&ioport_resource, &res[0]);
 	request_resource(&iomem_resource, &res[1]);
 
-	sys->resource[0] = &res[0];
-	sys->resource[1] = &res[1];
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &res[0]);
+	pci_add_resource(&sys->resources, &res[1]);
 
 	return 1;
 }
diff --git a/arch/arm/mach-ixp2000/enp2611.c b/arch/arm/mach-ixp2000/enp2611.c
index 62c60ad..2f5dd72 100644
--- a/arch/arm/mach-ixp2000/enp2611.c
+++ b/arch/arm/mach-ixp2000/enp2611.c
@@ -145,7 +145,8 @@ static struct pci_ops enp2611_pci_ops = {
 static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
 						struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &enp2611_pci_ops, sys,
+				 &sys->resources);
 }
 
 static int __init enp2611_pci_map_irq(const struct pci_dev *dev, u8 slot,
diff --git a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
index f5098b3..626fda4 100644
--- a/arch/arm/mach-ixp2000/pci.c
+++ b/arch/arm/mach-ixp2000/pci.c
@@ -132,7 +132,8 @@ static struct pci_ops ixp2000_pci_ops = {
 
 struct pci_bus *ixp2000_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
-	return pci_scan_bus(sysdata->busnr, &ixp2000_pci_ops, sysdata);
+	return pci_scan_root_bus(NULL, sysdata->busnr, &ixp2000_pci_ops,
+				 sysdata, &sysdata->resources);
 }
 
 
@@ -242,9 +243,8 @@ int ixp2000_pci_setup(int nr, struct pci_sys_data *sys)
 	if (nr >= 1)
 		return 0;
 
-	sys->resource[0] = &ixp2000_pci_io_space;
-	sys->resource[1] = &ixp2000_pci_mem_space;
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &ixp2000_pci_io_space);
+	pci_add_resource(&sys->resources, &ixp2000_pci_mem_space);
 
 	return 1;
 }
diff --git a/arch/arm/mach-ixp23xx/pci.c b/arch/arm/mach-ixp23xx/pci.c
index e6be571..25b5c46 100644
--- a/arch/arm/mach-ixp23xx/pci.c
+++ b/arch/arm/mach-ixp23xx/pci.c
@@ -143,7 +143,8 @@ struct pci_ops ixp23xx_pci_ops = {
 
 struct pci_bus *ixp23xx_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
-	return pci_scan_bus(sysdata->busnr, &ixp23xx_pci_ops, sysdata);
+	return pci_scan_root_bus(NULL, sysdata->busnr, &ixp23xx_pci_ops,
+				 sysdata, &sysdata->resources);
 }
 
 int ixp23xx_pci_abort_handler(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
@@ -280,9 +281,8 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
 	if (nr >= 1)
 		return 0;
 
-	sys->resource[0] = &ixp23xx_pci_io_space;
-	sys->resource[1] = &ixp23xx_pci_mem_space;
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &ixp23xx_pci_io_space);
+	pci_add_resource(&sys->resources, &ixp23xx_pci_mem_space);
 
 	return 1;
 }
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 2131832..b81dedb 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -470,9 +470,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
 	request_resource(&ioport_resource, &res[0]);
 	request_resource(&iomem_resource, &res[1]);
 
-	sys->resource[0] = &res[0];
-	sys->resource[1] = &res[1];
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &res[0]);
+	pci_add_resource(&sys->resources, &res[1]);
 
 	platform_notify = ixp4xx_pci_platform_notify;
 	platform_notify_remove = ixp4xx_pci_platform_notify_remove;
@@ -482,7 +481,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
 
 struct pci_bus * __devinit ixp4xx_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &ixp4xx_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &ixp4xx_ops, sys,
+				 &sys->resources);
 }
 
 int dma_set_coherent_mask(struct device *dev, u64 mask)
diff --git a/arch/arm/mach-kirkwood/pcie.c b/arch/arm/mach-kirkwood/pcie.c
index 74b992d..9ca38de 100644
--- a/arch/arm/mach-kirkwood/pcie.c
+++ b/arch/arm/mach-kirkwood/pcie.c
@@ -198,9 +198,8 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
 	if (request_resource(&iomem_resource, &pp->res[1]))
 		panic("Request PCIe%d Memory resource failed\n", index);
 
-	sys->resource[0] = &pp->res[0];
-	sys->resource[1] = &pp->res[1];
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &pp->res[0]);
+	pci_add_resource(&sys->resources, &pp->res[1]);
 	sys->io_offset = 0;
 
 	/*
@@ -236,7 +235,8 @@ kirkwood_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pci_bus *bus;
 
 	if (nr < num_pcie_ports) {
-		bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+		bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+					&sys->resources);
 	} else {
 		bus = NULL;
 		BUG();
diff --git a/arch/arm/mach-ks8695/pci.c b/arch/arm/mach-ks8695/pci.c
index c7c9a18..b26f992 100644
--- a/arch/arm/mach-ks8695/pci.c
+++ b/arch/arm/mach-ks8695/pci.c
@@ -143,7 +143,8 @@ static struct pci_ops ks8695_pci_ops = {
 
 static struct pci_bus* __init ks8695_pci_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &ks8695_pci_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &ks8695_pci_ops, sys,
+				 &sys->resources);
 }
 
 static struct resource pci_mem = {
@@ -168,9 +169,8 @@ static int __init ks8695_pci_setup(int nr, struct pci_sys_data *sys)
 	request_resource(&iomem_resource, &pci_mem);
 	request_resource(&ioport_resource, &pci_io);
 
-	sys->resource[0] = &pci_io;
-	sys->resource[1] = &pci_mem;
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &pci_io);
+	pci_add_resource(&sys->resources, &pci_mem);
 
 	/* Assign and enable processor bridge */
 	ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA);
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index c51af1c..c701135 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -155,9 +155,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
 	orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
 	orion_pcie_setup(pp->base, &mv78xx0_mbus_dram_info);
 
-	sys->resource[0] = &pp->res[0];
-	sys->resource[1] = &pp->res[1];
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &pp->res[0]);
+	pci_add_resource(&sys->resources, &pp->res[1]);
 
 	return 1;
 }
@@ -251,7 +250,8 @@ mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pci_bus *bus;
 
 	if (nr < num_pcie_ports) {
-		bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+		bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+					&sys->resources);
 	} else {
 		bus = NULL;
 		BUG();
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c
index bc4a920..4eb9364 100644
--- a/arch/arm/mach-orion5x/pci.c
+++ b/arch/arm/mach-orion5x/pci.c
@@ -176,7 +176,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
 	res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1;
 	if (request_resource(&ioport_resource, &res[0]))
 		panic("Request PCIe IO resource failed\n");
-	sys->resource[0] = &res[0];
+	pci_add_resource(&sys->resources, &res[0]);
 
 	/*
 	 * IORESOURCE_MEM
@@ -187,9 +187,8 @@ static int __init pcie_setup(struct pci_sys_data *sys)
 	res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1;
 	if (request_resource(&iomem_resource, &res[1]))
 		panic("Request PCIe Memory resource failed\n");
-	sys->resource[1] = &res[1];
+	pci_add_resource(&sys->resources, &res[1]);
 
-	sys->resource[2] = NULL;
 	sys->io_offset = 0;
 
 	return 1;
@@ -505,7 +504,7 @@ static int __init pci_setup(struct pci_sys_data *sys)
 	res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1;
 	if (request_resource(&ioport_resource, &res[0]))
 		panic("Request PCI IO resource failed\n");
-	sys->resource[0] = &res[0];
+	pci_add_resource(&sys->resources, &res[0]);
 
 	/*
 	 * IORESOURCE_MEM
@@ -516,9 +515,8 @@ static int __init pci_setup(struct pci_sys_data *sys)
 	res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1;
 	if (request_resource(&iomem_resource, &res[1]))
 		panic("Request PCI Memory resource failed\n");
-	sys->resource[1] = &res[1];
+	pci_add_resource(&sys->resources, &res[1]);
 
-	sys->resource[2] = NULL;
 	sys->io_offset = 0;
 
 	return 1;
@@ -579,9 +577,11 @@ struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys
 	struct pci_bus *bus;
 
 	if (nr == 0) {
-		bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+		bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+					&sys->resources);
 	} else if (nr == 1 && !orion5x_pci_disabled) {
-		bus = pci_scan_bus(sys->busnr, &pci_ops, sys);
+		bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
+					&sys->resources);
 	} else {
 		bus = NULL;
 		BUG();
diff --git a/arch/arm/mach-sa1100/pci-nanoengine.c b/arch/arm/mach-sa1100/pci-nanoengine.c
index dd39fee..f9b20d3 100644
--- a/arch/arm/mach-sa1100/pci-nanoengine.c
+++ b/arch/arm/mach-sa1100/pci-nanoengine.c
@@ -131,7 +131,8 @@ static int __init pci_nanoengine_map_irq(const struct pci_dev *dev, u8 slot,
 
 struct pci_bus * __init pci_nanoengine_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &pci_nano_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &pci_nano_ops, sys,
+				 &sys->resources);
 }
 
 static struct resource pci_io_ports = {
@@ -243,9 +244,9 @@ static int __init pci_nanoengine_setup_resources(struct resource **resource)
 		printk(KERN_ERR "PCI: unable to allocate prefetchable\n");
 		return -EBUSY;
 	}
-	resource[0] = &pci_io_ports;
-	resource[1] = &pci_non_prefetchable_memory;
-	resource[2] = &pci_prefetchable_memory;
+	pci_add_resource(&sys->resources, &pci_io_ports);
+	pci_add_resource(&sys->resources, &pci_non_prefetchable_memory);
+	pci_add_resource(&sys->resources, &pci_prefetchable_memory);
 
 	return 1;
 }
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c
index f1f699d..e3f0d15 100644
--- a/arch/arm/mach-tegra/pcie.c
+++ b/arch/arm/mach-tegra/pcie.c
@@ -406,7 +406,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
 	pp->res[0].flags = IORESOURCE_IO;
 	if (request_resource(&ioport_resource, &pp->res[0]))
 		panic("Request PCIe IO resource failed\n");
-	sys->resource[0] = &pp->res[0];
+	pci_add_resource(&sys->resources, &pp->res[0]);
 
 	/*
 	 * IORESOURCE_MEM
@@ -425,7 +425,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
 	pp->res[1].flags = IORESOURCE_MEM;
 	if (request_resource(&iomem_resource, &pp->res[1]))
 		panic("Request PCIe Memory resource failed\n");
-	sys->resource[1] = &pp->res[1];
+	pci_add_resource(&sys->resources, &pp->res[1]);
 
 	/*
 	 * IORESOURCE_MEM | IORESOURCE_PREFETCH
@@ -444,7 +444,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
 	pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 	if (request_resource(&iomem_resource, &pp->res[2]))
 		panic("Request PCIe Prefetch Memory resource failed\n");
-	sys->resource[2] = &pp->res[2];
+	pci_add_resource(&sys->resources, &pp->res[2]);
 
 	return 1;
 }
@@ -465,7 +465,8 @@ static struct pci_bus __init *tegra_pcie_scan_bus(int nr,
 	pp = tegra_pcie.port + nr;
 	pp->root_bus_nr = sys->busnr;
 
-	return pci_scan_bus(sys->busnr, &tegra_pcie_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &tegra_pcie_ops, sys,
+				 &sys->resources);
 }
 
 static struct hw_pci tegra_pcie_hw __initdata = {
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index c898deb..90069bc 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -191,7 +191,7 @@ static struct resource pre_mem = {
 	.flags	= IORESOURCE_MEM | IORESOURCE_PREFETCH,
 };
 
-static int __init pci_versatile_setup_resources(struct resource **resource)
+static int __init pci_versatile_setup_resources(struct list_head *resources)
 {
 	int ret = 0;
 
@@ -215,13 +215,13 @@ static int __init pci_versatile_setup_resources(struct resource **resource)
 	}
 
 	/*
-	 * bus->resource[0] is the IO resource for this bus
-	 * bus->resource[1] is the mem resource for this bus
-	 * bus->resource[2] is the prefetch mem resource for this bus
+	 * the IO resource for this bus
+	 * the mem resource for this bus
+	 * the prefetch mem resource for this bus
 	 */
-	resource[0] = &io_mem;
-	resource[1] = &non_mem;
-	resource[2] = &pre_mem;
+	pci_add_resource(resources, &io_mem);
+	pci_add_resource(resources, &non_mem);
+	pci_add_resource(resources, &pre_mem);
 
 	goto out;
 
@@ -250,7 +250,7 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
 
 	if (nr == 0) {
 		sys->mem_offset = 0;
-		ret = pci_versatile_setup_resources(sys->resource);
+		ret = pci_versatile_setup_resources(&sys->resources);
 		if (ret < 0) {
 			printk("pci_versatile_setup: resources... oops?\n");
 			goto out;
@@ -306,7 +306,8 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
 
 struct pci_bus * __init pci_versatile_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &pci_versatile_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &pci_versatile_ops, sys,
+				 &sys->resources);
 }
 
 void __init pci_versatile_preinit(void)
diff --git a/arch/arm/plat-iop/pci.c b/arch/arm/plat-iop/pci.c
index 845549c..f4d40a2 100644
--- a/arch/arm/plat-iop/pci.c
+++ b/arch/arm/plat-iop/pci.c
@@ -215,16 +215,16 @@ int iop3xx_pci_setup(int nr, struct pci_sys_data *sys)
 	sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0;
 	sys->io_offset  = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR;
 
-	sys->resource[0] = &res[0];
-	sys->resource[1] = &res[1];
-	sys->resource[2] = NULL;
+	pci_add_resource(&sys->resources, &res[0]);
+	pci_add_resource(&sys->resources, &res[1]);
 
 	return 1;
 }
 
 struct pci_bus *iop3xx_pci_scan_bus(int nr, struct pci_sys_data *sys)
 {
-	return pci_scan_bus(sys->busnr, &iop3xx_ops, sys);
+	return pci_scan_root_bus(NULL, sys->busnr, &iop3xx_ops, sys,
+				 &sys->resources);
 }
 
 void __init iop3xx_atu_setup(void)

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 26/29] frv/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (24 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 25/29] arm/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29   ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 27/29] mn10300/PCI: " Bjorn Helgaas
                   ` (3 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, David Howells, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: David Howells <dhowells@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/frv/mb93090-mb00/pci-vdk.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index f8dd37e..a27c5db 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -226,6 +226,7 @@ static struct pci_ops * __init pci_check_direct(void)
  */
 static void __init pcibios_fixup_peer_bridges(void)
 {
+	struct list_head resources;
 	struct pci_bus bus;
 	struct pci_dev dev;
 	int n;
@@ -245,7 +246,17 @@ static void __init pcibios_fixup_peer_bridges(void)
 			    l != 0x0000 && l != 0xffff) {
 				printk("Found device at %02x:%02x [%04x]\n", n, dev.devfn, l);
 				printk("PCI: Discovered peer bus %02x\n", n);
-				pci_scan_bus(n, pci_root_ops, NULL);
+				/*
+				 * It's wrong to give peer root buses the same
+				 * resources as the first one, but that's what
+				 * we did before via pcibios_fixup_bus(), so
+				 * this doesn't change it.
+				 */
+				INIT_LIST_HEAD(&resources);
+				pci_add_resource(&resources, &pci_ioport_resource);
+				pci_add_resource(&resources, &pci_iomem_resource);
+				pci_scan_root_bus(NULL, n, pci_root_ops, NULL,
+						  &resources);
 				break;
 			}
 	}
@@ -327,11 +338,6 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
 	printk("### PCIBIOS_FIXUP_BUS(%d)\n",bus->number);
 #endif
 
-	if (bus->number == 0) {
-		bus->resource[0] = &pci_ioport_resource;
-		bus->resource[1] = &pci_iomem_resource;
-	}
-
 	pci_read_bridge_bases(bus);
 
 	if (bus->number == 0) {
@@ -357,6 +363,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
 int __init pcibios_init(void)
 {
 	struct pci_ops *dir = NULL;
+	struct list_head resources;
 
 	if (!mb93090_mb00_detected)
 		return -ENXIO;
@@ -419,8 +426,13 @@ int __init pcibios_init(void)
 		return -ENXIO;
 	}
 
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &pci_ioport_resource);
+	pci_add_resource(&resources, &pci_iomem_resource);
+
 	printk("PCI: Probing PCI hardware\n");
-	pci_root_bus = pci_scan_bus(0, pci_root_ops, NULL);
+	pci_root_bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL,
+					 &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_peer_bridges();

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 26/29] frv/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:29 ` [PATCH v2 26/29] frv/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, David Howells, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: David Howells <dhowells@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/frv/mb93090-mb00/pci-vdk.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index f8dd37e..a27c5db 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -226,6 +226,7 @@ static struct pci_ops * __init pci_check_direct(void)
  */
 static void __init pcibios_fixup_peer_bridges(void)
 {
+	struct list_head resources;
 	struct pci_bus bus;
 	struct pci_dev dev;
 	int n;
@@ -245,7 +246,17 @@ static void __init pcibios_fixup_peer_bridges(void)
 			    l != 0x0000 && l != 0xffff) {
 				printk("Found device at %02x:%02x [%04x]\n", n, dev.devfn, l);
 				printk("PCI: Discovered peer bus %02x\n", n);
-				pci_scan_bus(n, pci_root_ops, NULL);
+				/*
+				 * It's wrong to give peer root buses the same
+				 * resources as the first one, but that's what
+				 * we did before via pcibios_fixup_bus(), so
+				 * this doesn't change it.
+				 */
+				INIT_LIST_HEAD(&resources);
+				pci_add_resource(&resources, &pci_ioport_resource);
+				pci_add_resource(&resources, &pci_iomem_resource);
+				pci_scan_root_bus(NULL, n, pci_root_ops, NULL,
+						  &resources);
 				break;
 			}
 	}
@@ -327,11 +338,6 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
 	printk("### PCIBIOS_FIXUP_BUS(%d)\n",bus->number);
 #endif
 
-	if (bus->number == 0) {
-		bus->resource[0] = &pci_ioport_resource;
-		bus->resource[1] = &pci_iomem_resource;
-	}
-
 	pci_read_bridge_bases(bus);
 
 	if (bus->number == 0) {
@@ -357,6 +363,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
 int __init pcibios_init(void)
 {
 	struct pci_ops *dir = NULL;
+	struct list_head resources;
 
 	if (!mb93090_mb00_detected)
 		return -ENXIO;
@@ -419,8 +426,13 @@ int __init pcibios_init(void)
 		return -ENXIO;
 	}
 
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &pci_ioport_resource);
+	pci_add_resource(&resources, &pci_iomem_resource);
+
 	printk("PCI: Probing PCI hardware\n");
-	pci_root_bus = pci_scan_bus(0, pci_root_ops, NULL);
+	pci_root_bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL,
+					 &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_peer_bridges();


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 27/29] mn10300/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (25 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 26/29] frv/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29   ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 28/29] sh/PCI: " Bjorn Helgaas
                   ` (2 subsequent siblings)
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, David Howells, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: David Howells <dhowells@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/mn10300/unit-asb2305/pci.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index a4954fe..4cc7136 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -380,11 +380,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_dev *dev;
 
-	if (bus->number == 0) {
-		bus->resource[0] = &pci_ioport_resource;
-		bus->resource[1] = &pci_iomem_resource;
-	}
-
 	if (bus->self) {
 		pci_read_bridge_bases(bus);
 		pcibios_fixup_device_resources(bus->self);
@@ -402,6 +397,8 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct list_head resources;
+
 	ioport_resource.start	= 0xA0000000;
 	ioport_resource.end	= 0xDFFFFFFF;
 	iomem_resource.start	= 0xA0000000;
@@ -423,7 +420,12 @@ static int __init pcibios_init(void)
 	printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n",
 	       MEM_PAGING_REG);
 
-	pci_root_bus = pci_scan_bus(0, &pci_direct_ampci, NULL);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &pci_ioport_resource);
+	pci_add_resource(&resources, &pci_iomem_resource);
+
+	pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL,
+					 &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 27/29] mn10300/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:29 ` [PATCH v2 27/29] mn10300/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, David Howells, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: David Howells <dhowells@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/mn10300/unit-asb2305/pci.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index a4954fe..4cc7136 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -380,11 +380,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_dev *dev;
 
-	if (bus->number == 0) {
-		bus->resource[0] = &pci_ioport_resource;
-		bus->resource[1] = &pci_iomem_resource;
-	}
-
 	if (bus->self) {
 		pci_read_bridge_bases(bus);
 		pcibios_fixup_device_resources(bus->self);
@@ -402,6 +397,8 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
  */
 static int __init pcibios_init(void)
 {
+	struct list_head resources;
+
 	ioport_resource.start	= 0xA0000000;
 	ioport_resource.end	= 0xDFFFFFFF;
 	iomem_resource.start	= 0xA0000000;
@@ -423,7 +420,12 @@ static int __init pcibios_init(void)
 	printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n",
 	       MEM_PAGING_REG);
 
-	pci_root_bus = pci_scan_bus(0, &pci_direct_ampci, NULL);
+	INIT_LIST_HEAD(&resources);
+	pci_add_resource(&resources, &pci_ioport_resource);
+	pci_add_resource(&resources, &pci_iomem_resource);
+
+	pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL,
+					 &resources);
 
 	pcibios_irq_init();
 	pcibios_fixup_irqs();


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 28/29] sh/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (26 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 27/29] mn10300/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29   ` Bjorn Helgaas
  2011-10-14  4:29 ` [PATCH v2 29/29] xtensa/PCI: " Bjorn Helgaas
  2011-10-14 15:14 ` [PATCH v2 00/29] Create PCI root buses with correct resources James Bottomley
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Paul Mundt, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sh/drivers/pci/pci.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 194231c..d8dc68b 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -35,9 +35,16 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
 {
 	static int next_busno;
 	static int need_domain_info;
+	struct list_head resources;
+	int i;
 	struct pci_bus *bus;
 
-	bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
+	INIT_LIST_HEAD(&resources);
+	for (i = 0; i < hose->nr_resources; i++)
+		pci_add_resource(&resources, hose->resources + i);
+
+	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
+				&resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
@@ -54,6 +61,8 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
 		pci_enable_bridges(bus);
+	} else {
+		pci_free_resource_list(&resources);
 	}
 }
 
@@ -163,14 +172,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_dev *dev = bus->self;
 	struct list_head *ln;
-	struct pci_channel *hose = bus->sysdata;
-
-	if (!dev) {
-		int i;
-
-		for (i = 0; i < hose->nr_resources; i++)
-			bus->resource[i] = hose->resources + i;
-	}
 
 	for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
 		dev = pci_dev_b(ln);

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 28/29] sh/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:29 ` [PATCH v2 28/29] sh/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Paul Mundt, linux-kernel

Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups.  This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.

CC: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/sh/drivers/pci/pci.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 194231c..d8dc68b 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -35,9 +35,16 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
 {
 	static int next_busno;
 	static int need_domain_info;
+	struct list_head resources;
+	int i;
 	struct pci_bus *bus;
 
-	bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
+	INIT_LIST_HEAD(&resources);
+	for (i = 0; i < hose->nr_resources; i++)
+		pci_add_resource(&resources, hose->resources + i);
+
+	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
+				&resources);
 	hose->bus = bus;
 
 	need_domain_info = need_domain_info || hose->index;
@@ -54,6 +61,8 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
 		pci_bus_size_bridges(bus);
 		pci_bus_assign_resources(bus);
 		pci_enable_bridges(bus);
+	} else {
+		pci_free_resource_list(&resources);
 	}
 }
 
@@ -163,14 +172,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_dev *dev = bus->self;
 	struct list_head *ln;
-	struct pci_channel *hose = bus->sysdata;
-
-	if (!dev) {
-		int i;
-
-		for (i = 0; i < hose->nr_resources; i++)
-			bus->resource[i] = hose->resources + i;
-	}
 
 	for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
 		dev = pci_dev_b(ln);


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 29/29] xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (27 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 28/29] sh/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29 ` Bjorn Helgaas
  2011-10-14  4:29   ` Bjorn Helgaas
  2011-10-14 15:14 ` [PATCH v2 00/29] Create PCI root buses with correct resources James Bottomley
  29 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Chris Zankel, linux-kernel

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.

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..d35325c 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;
+
+	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;
+	}
+	io_offset = (unsigned long)pci_ctrl->io_space.base;
+	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);
 

^ permalink raw reply related	[flat|nested] 82+ messages in thread

* [PATCH v2 29/29] xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:29 ` [PATCH v2 29/29] xtensa/PCI: " Bjorn Helgaas
@ 2011-10-14  4:29   ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14  4:29 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-arch, Chris Zankel, linux-kernel

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.

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..d35325c 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;
+
+	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;
+	}
+	io_offset = (unsigned long)pci_ctrl->io_space.base;
+	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);
 


^ permalink raw reply related	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
  2011-10-14  4:28 ` [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() " Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
@ 2011-10-14  4:43   ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: David Miller @ 2011-10-14  4:43 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

From: Bjorn Helgaas <bhelgaas@google.com>
Date: Thu, 13 Oct 2011 22:28:23 -0600

> Convert from pci_scan_bus_parented() to pci_scan_root_bus() and remove root
> bus resource fixups.  This fixes the problem of "early" and "header" quirks
> seeing incorrect root bus resources.
> 
> pci_scan_root_bus() also includes the pci_bus_add_devices() so we don't
> need to do that separately.
> 
> CC: David S. Miller <davem@davemloft.net>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:28 ` [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
  2011-10-14  4:28   ` Bjorn Helgaas
@ 2011-10-14  4:46   ` David Miller
  2011-10-14  4:46     ` David Miller
  2011-10-14  4:49     ` David Miller
  1 sibling, 2 replies; 82+ messages in thread
From: David Miller @ 2011-10-14  4:46 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

From: Bjorn Helgaas <bhelgaas@google.com>
Date: Thu, 13 Oct 2011 22:28:18 -0600

> Convert from pci_create_bus() to pci_create_root_bus().  This way the root
> bus resources are correct immediately.  This patch doesn't fix anything
> because sparc fixed them before scanning the bus, but it makes it more
> consistent with other architectures.
> 
> I didn't work out where pcibios_fixup_bus() is called.  I don't see a
> use of pci_scan_bus(), pci_scan_bus_parented(), or pci_scan_child_bus().
> 
> CC: David S. Miller <davem@davemloft.net>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

The pcibios_fixup_bus() case here (sparc64) is an artifact from when
we actually probed the PCI config space for device probing on sparc64,
and pci_bus_probe() would invoke it.

Unfortunately we can't delete this function now even though it's empty
with your changes, because drivers/pci/probe.o is unconditionally
linked into the kernel when CONFIG_PCI even when an architecture
(such as sparc64) doesn't use the majority of the code in it.

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:46   ` David Miller
@ 2011-10-14  4:46     ` David Miller
  2011-10-14  4:49     ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: David Miller @ 2011-10-14  4:46 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

From: Bjorn Helgaas <bhelgaas@google.com>
Date: Thu, 13 Oct 2011 22:28:18 -0600

> Convert from pci_create_bus() to pci_create_root_bus().  This way the root
> bus resources are correct immediately.  This patch doesn't fix anything
> because sparc fixed them before scanning the bus, but it makes it more
> consistent with other architectures.
> 
> I didn't work out where pcibios_fixup_bus() is called.  I don't see a
> use of pci_scan_bus(), pci_scan_bus_parented(), or pci_scan_child_bus().
> 
> CC: David S. Miller <davem@davemloft.net>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

The pcibios_fixup_bus() case here (sparc64) is an artifact from when
we actually probed the PCI config space for device probing on sparc64,
and pci_bus_probe() would invoke it.

Unfortunately we can't delete this function now even though it's empty
with your changes, because drivers/pci/probe.o is unconditionally
linked into the kernel when CONFIG_PCI even when an architecture
(such as sparc64) doesn't use the majority of the code in it.


^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:46   ` David Miller
  2011-10-14  4:46     ` David Miller
@ 2011-10-14  4:49     ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: David Miller @ 2011-10-14  4:49 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

From: David Miller <davem@davemloft.net>
Date: Fri, 14 Oct 2011 00:46:54 -0400 (EDT)

> From: Bjorn Helgaas <bhelgaas@google.com>
> Date: Thu, 13 Oct 2011 22:28:18 -0600
> 
>> Convert from pci_create_bus() to pci_create_root_bus().  This way the root
>> bus resources are correct immediately.  This patch doesn't fix anything
>> because sparc fixed them before scanning the bus, but it makes it more
>> consistent with other architectures.
>> 
>> I didn't work out where pcibios_fixup_bus() is called.  I don't see a
>> use of pci_scan_bus(), pci_scan_bus_parented(), or pci_scan_child_bus().
>> 
>> CC: David S. Miller <davem@davemloft.net>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> The pcibios_fixup_bus() case here (sparc64) is an artifact from when
> we actually probed the PCI config space for device probing on sparc64,
> and pci_bus_probe() would invoke it.
> 
> Unfortunately we can't delete this function now even though it's empty
> with your changes, because drivers/pci/probe.o is unconditionally
> linked into the kernel when CONFIG_PCI even when an architecture
> (such as sparc64) doesn't use the majority of the code in it.

Sorry, forgot to give this an ACK :-)

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14  4:27 ` [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus() Bjorn Helgaas
@ 2011-10-14  5:30   ` Yinghai Lu
  2011-10-14 20:32     ` Bjorn Helgaas
  0 siblings, 1 reply; 82+ messages in thread
From: Yinghai Lu @ 2011-10-14  5:30 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On 10/13/2011 09:27 PM, Bjorn Helgaas wrote:

> x86 has two kinds of PCI root bus scanning:
> 
> (1) ACPI-based, using _CRS resources.  This used pci_create_bus() because
>     ACPI hotplug needed to split the pci_bus_add_devices() into a separate
>     .start() method.
> 
>     This patch parses the _CRS resources earlier, so we can build a list of
>     resources and pass it to pci_create_root_bus().
> 
>     Note that as before, we parse the _CRS even if we aren't going to use
>     it so we can print it for debugging purposes.
> 
> (2) All other, which used either default resources (ioport_resource and
>     iomem_resource) or information read from the hardware via amd_bus.c or
>     similar.  This used pci_scan_bus().
> 
>     This patch converts x86_pci_root_bus_res_quirks() (previously called
>     from pcibios_fixup_bus()) to x86_pci_root_bus_resources(), which builds
>     a list of resources before we call pci_scan_root_bus().
> 
>     We also use x86_pci_root_bus_resources() if we have ACPI but are
>     ignoring _CRS.
> 
> CC: Yinghai Lu <yinghai.lu@oracle.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/x86/include/asm/topology.h |    2 +-
>  arch/x86/pci/acpi.c             |   31 +++++++++++++++++--------------
>  arch/x86/pci/bus_numa.c         |   31 ++++++++++++++++++-------------
>  arch/x86/pci/common.c           |   21 ++++++++++++++-------
>  4 files changed, 50 insertions(+), 35 deletions(-)
> 
> diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
> index c006924..5f83b13 100644
> --- a/arch/x86/include/asm/topology.h
> +++ b/arch/x86/include/asm/topology.h
> @@ -174,7 +174,7 @@ static inline void arch_fix_phys_package_id(int num, u32 slot)
>  }
>  
>  struct pci_bus;
> -void x86_pci_root_bus_res_quirks(struct pci_bus *b);
> +void x86_pci_root_bus_resources(int bus, struct list_head *resources);
>  
>  #ifdef CONFIG_SMP
>  #define mc_capable()	((boot_cpu_data.x86_max_cores > 1) && \
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 039d913..77bb332 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -12,7 +12,7 @@ struct pci_root_info {
>  	char *name;
>  	unsigned int res_num;
>  	struct resource *res;
> -	struct pci_bus *bus;
> +	struct list_head *resources;
>  	int busnum;
>  };
>  
> @@ -250,23 +250,20 @@ static void add_resources(struct pci_root_info *info)
>  				 "ignoring host bridge window %pR (conflicts with %s %pR)\n",
>  				 res, conflict->name, conflict);
>  		else
> -			pci_bus_add_resource(info->bus, res, 0);
> +			pci_add_resource(info->resources, res);
>  	}
>  }
>  
>  static void
>  get_current_resources(struct acpi_device *device, int busnum,
> -			int domain, struct pci_bus *bus)
> +		      int domain, struct list_head *resources)
>  {
>  	struct pci_root_info info;
>  	size_t size;
>  
> -	if (pci_use_crs)
> -		pci_bus_remove_resources(bus);
> -
>  	info.bridge = device;
> -	info.bus = bus;
>  	info.res_num = 0;
> +	info.resources = resources;
>  	acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
>  				&info);
>  	if (!info.res_num)
> @@ -275,7 +272,7 @@ get_current_resources(struct acpi_device *device, int busnum,
>  	size = sizeof(*info.res) * info.res_num;
>  	info.res = kmalloc(size, GFP_KERNEL);
>  	if (!info.res)
> -		goto res_alloc_fail;
> +		return;
>  
>  	info.name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum);
>  	if (!info.name)
> @@ -290,8 +287,6 @@ get_current_resources(struct acpi_device *device, int busnum,
>  
>  name_alloc_fail:
>  	kfree(info.res);
> -res_alloc_fail:
> -	return;
>  }
>  
>  struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
> @@ -299,6 +294,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>  	struct acpi_device *device = root->device;
>  	int domain = root->segment;
>  	int busnum = root->secondary.start;
> +	struct list_head resources;
>  	struct pci_bus *bus;
>  	struct pci_sysdata *sd;
>  	int node;
> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>  		memcpy(bus->sysdata, sd, sizeof(*sd));
>  		kfree(sd);
>  	} else {
> -		bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
> -		if (bus) {
> -			get_current_resources(device, busnum, domain, bus);
> -			bus->subordinate = pci_scan_child_bus(bus);
> +		INIT_LIST_HEAD(&resources);
> +		get_current_resources(device, busnum, domain, &resources);
> +		if (!pci_use_crs) {
> +			pci_free_resource_list(&resources);
> +			x86_pci_root_bus_resources(busnum, &resources);
>  		}


You may need to update get_current_resources() to return status about handling _CRS...
and check that status insteaf of !pci_use_crs.

Thanks


> +		bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd,
> +					  &resources);
> +		if (bus)
> +			bus->subordinate = pci_scan_child_bus(bus);
> +		else
> +			pci_free_resource_list(&resources);
>  	}

>  

>  	/* After the PCI-E bus has been walked and all devices discovered,
> diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
> index 64a1228..fd3f655 100644
> --- a/arch/x86/pci/bus_numa.c
> +++ b/arch/x86/pci/bus_numa.c
> @@ -7,45 +7,50 @@
>  int pci_root_num;
>  struct pci_root_info pci_root_info[PCI_ROOT_NR];
>  
> -void x86_pci_root_bus_res_quirks(struct pci_bus *b)
> +void x86_pci_root_bus_resources(int bus, struct list_head *resources)
>  {
>  	int i;
>  	int j;
>  	struct pci_root_info *info;
>  
> -	/* don't go for it if _CRS is used already */
> -	if (b->resource[0] != &ioport_resource ||
> -	    b->resource[1] != &iomem_resource)
> -		return;
> -
>  	if (!pci_root_num)
> -		return;
> +		goto default_resources;
>  
>  	for (i = 0; i < pci_root_num; i++) {
> -		if (pci_root_info[i].bus_min == b->number)
> +		if (pci_root_info[i].bus_min == bus)
>  			break;
>  	}
>  
>  	if (i == pci_root_num)
> -		return;
> +		goto default_resources;
>  
> -	printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
> -			b->number);
> +	printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n",
> +	       bus);
>  
> -	pci_bus_remove_resources(b);
>  	info = &pci_root_info[i];
>  	for (j = 0; j < info->res_num; j++) {
>  		struct resource *res;
>  		struct resource *root;
>  
>  		res = &info->res[j];
> -		pci_bus_add_resource(b, res, 0);
> +		pci_add_resource(resources, res);
>  		if (res->flags & IORESOURCE_IO)
>  			root = &ioport_resource;
>  		else
>  			root = &iomem_resource;
>  		insert_resource(root, res);
>  	}
> +	return;
> +
> +default_resources:
> +	/*
> +	 * We don't have any host bridge aperture information from the
> +	 * "native host bridge drivers," e.g., amd_bus or broadcom_bus,
> +	 * so fall back to the defaults historically used by pci_create_bus().
> +	 */
> +	printk(KERN_DEBUG "PCI: root bus %02x: using default resources\n", bus);
> +	pci_add_resource(resources, &ioport_resource);
> +	pci_add_resource(resources, &iomem_resource);
>  }
>  
>  void __devinit update_res(struct pci_root_info *info, resource_size_t start,
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index b389a2d..7f595cc 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -164,9 +164,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
>  {
>  	struct pci_dev *dev;
>  
> -	/* root bus? */
> -	if (!b->parent)
> -		x86_pci_root_bus_res_quirks(b);
>  	pci_read_bridge_bases(b);
>  	list_for_each_entry(dev, &b->devices, bus_list)
>  		pcibios_fixup_device_resources(dev);
> @@ -433,6 +430,7 @@ void __init dmi_check_pciprobe(void)
>  
>  struct pci_bus * __devinit pcibios_scan_root(int busnum)
>  {
> +	struct list_head resources;
>  	struct pci_bus *bus = NULL;
>  	struct pci_sysdata *sd;
>  
> @@ -456,9 +454,13 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
>  	sd->node = get_mp_bus_to_node(busnum);
>  
>  	printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
> -	bus = pci_scan_bus(busnum, &pci_root_ops, sd);
> -	if (!bus)
> +	INIT_LIST_HEAD(&resources);
> +	x86_pci_root_bus_resources(busnum, &resources);
> +	bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
> +	if (!bus) {
> +		pci_free_resource_list(&resources);
>  		kfree(sd);
> +	}
>  
>  	return bus;
>  }
> @@ -639,6 +641,7 @@ int pci_ext_cfg_avail(struct pci_dev *dev)
>  
>  struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
>  {
> +	struct list_head resources;
>  	struct pci_bus *bus = NULL;
>  	struct pci_sysdata *sd;
>  
> @@ -653,9 +656,13 @@ struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops,
>  		return NULL;
>  	}
>  	sd->node = node;
> -	bus = pci_scan_bus(busno, ops, sd);
> -	if (!bus)
> +	INIT_LIST_HEAD(&resources);
> +	x86_pci_root_bus_resources(busno, &resources);
> +	bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources);
> +	if (!bus) {
> +		pci_free_resource_list(&resources);
>  		kfree(sd);
> +	}
>  
>  	return bus;
>  }
> 


well, that will break 
arch/x86/pci/broadcom_bus.c

it is using

DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
                        cnb20le_res);


to fill pci_root_info...

need to update it to fill that array early.


amd_bus.c is using 
postcore_initcall(amd_postcore_init);

and my local intel_bus.c is using

/*
 * need to call it just after pci_arch_init
 * so we can have mmconf ready
 */
int __init intel_postarch_init(void)
{
        if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
                return 0;

        if (!pci_ext_cfg_avail(NULL))
                return 0;

        postarch_check_pci_devs();

        return 0;
}

so they are ok.

Thanks

Yinghai Lu

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources
  2011-10-14  4:27 ` [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
  2011-10-14  4:27   ` Bjorn Helgaas
@ 2011-10-14  7:34   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 82+ messages in thread
From: Benjamin Herrenschmidt @ 2011-10-14  7:34 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel

On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
> Convert from pci_create_bus() to pci_create_root_bus().  This way the root
> bus resources are correct immediately.  This patch doesn't fix anything
> because powerpc fixed them before scanning the bus, but it makes it more
> consistent with other architectures.

All 3 look ok but of course like anything like that, need testing :-) I
won't be able to do that until I'm back to Australia, early November.

Cheers,
Ben.

> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/powerpc/kernel/pci-common.c |   27 ++++++++++++++++-----------
>  1 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 942ced2..2dbef49 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1554,14 +1554,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
>  	return pci_enable_resources(dev, mask);
>  }
>  
> -static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
> +static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
>  {
> -	struct pci_bus *bus = hose->bus;
>  	struct resource *res;
>  	int i;
>  
>  	/* Hookup PHB IO resource */
> -	bus->resource[0] = res = &hose->io_resource;
> +	res = &hose->io_resource;
>  
>  	if (!res->flags) {
>  		printk(KERN_WARNING "PCI: I/O resource not set for host"
> @@ -1579,6 +1578,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
>  		 (unsigned long long)res->start,
>  		 (unsigned long long)res->end,
>  		 (unsigned long)res->flags);
> +	pci_add_resource(resources, res);
>  
>  	/* Hookup PHB Memory resources */
>  	for (i = 0; i < 3; ++i) {
> @@ -1596,12 +1596,12 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
>  			res->flags = IORESOURCE_MEM;
>  #endif /* CONFIG_PPC32 */
>  		}
> -		bus->resource[i+1] = res;
>  
>  		pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
>  			 (unsigned long long)res->start,
>  			 (unsigned long long)res->end,
>  			 (unsigned long)res->flags);
> +		pci_add_resource(resources, res);
>  	}
>  
>  	pr_debug("PCI: PHB MEM offset     = %016llx\n",
> @@ -1695,6 +1695,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
>   */
>  void __devinit pcibios_scan_phb(struct pci_controller *hose)
>  {
> +	struct list_head resources;
>  	struct pci_bus *bus;
>  	struct device_node *node = hose->dn;
>  	int mode;
> @@ -1702,22 +1703,26 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
>  	pr_debug("PCI: Scanning PHB %s\n",
>  		 node ? node->full_name : "<NO NAME>");
>  
> +	INIT_LIST_HEAD(&resources);
> +
> +	/* Get some IO space for the new PHB */
> +	pcibios_setup_phb_io_space(hose);
> +
> +	/* Wire up PHB bus resources */
> +	pcibios_setup_phb_resources(hose, &resources);
> +
>  	/* Create an empty bus for the toplevel */
> -	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
> +	bus = pci_create_root_bus(hose->parent, hose->first_busno,
> +				  hose->ops, hose, resources);
>  	if (bus == NULL) {
>  		pr_err("Failed to create bus for PCI domain %04x\n",
>  			hose->global_number);
> +		pci_free_resource_list(&resources);
>  		return;
>  	}
>  	bus->secondary = hose->first_busno;
>  	hose->bus = bus;
>  
> -	/* Get some IO space for the new PHB */
> -	pcibios_setup_phb_io_space(hose);
> -
> -	/* Wire up PHB bus resources */
> -	pcibios_setup_phb_resources(hose);
> -
>  	/* Get probe mode and perform scan */
>  	mode = PCI_PROBE_NORMAL;
>  	if (node && ppc_md.pci_probe_mode)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
                   ` (28 preceding siblings ...)
  2011-10-14  4:29 ` [PATCH v2 29/29] xtensa/PCI: " Bjorn Helgaas
@ 2011-10-14 15:14 ` James Bottomley
  2011-10-14 15:14   ` James Bottomley
  2011-10-14 15:33   ` Bjorn Helgaas
  29 siblings, 2 replies; 82+ messages in thread
From: James Bottomley @ 2011-10-14 15:14 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel

On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
> The most generic way to create a PCI root bus is with pci_scan_bus(), but
> that doesn't allow you to specify what resources are available on the bus,
> i.e., what the host bridge apertures are.

Do you have an actual tree for this?  The PARISC pieces look a bit
non-trivial and I'd like to test them out on the various sba/astro/dino
systems.

James

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 15:14 ` [PATCH v2 00/29] Create PCI root buses with correct resources James Bottomley
@ 2011-10-14 15:14   ` James Bottomley
  2011-10-14 15:33   ` Bjorn Helgaas
  1 sibling, 0 replies; 82+ messages in thread
From: James Bottomley @ 2011-10-14 15:14 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel

On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
> The most generic way to create a PCI root bus is with pci_scan_bus(), but
> that doesn't allow you to specify what resources are available on the bus,
> i.e., what the host bridge apertures are.

Do you have an actual tree for this?  The PARISC pieces look a bit
non-trivial and I'd like to test them out on the various sba/astro/dino
systems.

James



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 15:14 ` [PATCH v2 00/29] Create PCI root buses with correct resources James Bottomley
  2011-10-14 15:14   ` James Bottomley
@ 2011-10-14 15:33   ` Bjorn Helgaas
  2011-10-14 15:45     ` James Bottomley
  1 sibling, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14 15:33 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
>> The most generic way to create a PCI root bus is with pci_scan_bus(), but
>> that doesn't allow you to specify what resources are available on the bus,
>> i.e., what the host bridge apertures are.
>
> Do you have an actual tree for this?  The PARISC pieces look a bit
> non-trivial and I'd like to test them out on the various sba/astro/dino
> systems.

I don't yet, but it'd be great if you were willing to test them out,
so I'll set one up.

While this is on your mind, I'm dubious about the pci_enable_bridges()
call in lba_driver_probe() and the pci_bus_assign_resources() call in
dino_probe().  These stand out as exceptions because no other arches
do that.

If they weren't there, both places could use pci_scan_root_bus() like
most other arches.

Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 15:33   ` Bjorn Helgaas
@ 2011-10-14 15:45     ` James Bottomley
  2011-10-14 15:45       ` James Bottomley
                         ` (2 more replies)
  0 siblings, 3 replies; 82+ messages in thread
From: James Bottomley @ 2011-10-14 15:45 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, 2011-10-14 at 09:33 -0600, Bjorn Helgaas wrote:
> On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
> <James.Bottomley@hansenpartnership.com> wrote:
> > On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
> >> The most generic way to create a PCI root bus is with pci_scan_bus(), but
> >> that doesn't allow you to specify what resources are available on the bus,
> >> i.e., what the host bridge apertures are.
> >
> > Do you have an actual tree for this?  The PARISC pieces look a bit
> > non-trivial and I'd like to test them out on the various sba/astro/dino
> > systems.
> 
> I don't yet, but it'd be great if you were willing to test them out,
> so I'll set one up.
> 
> While this is on your mind, I'm dubious about the pci_enable_bridges()
> call in lba_driver_probe() and the pci_bus_assign_resources() call in
> dino_probe().  These stand out as exceptions because no other arches
> do that.
> 
> If they weren't there, both places could use pci_scan_root_bus() like
> most other arches.

Right, the dino code actually has to rearrange some of the PCI resources
to make sure we get our apertures correct.  That's the specific bit I
was planning to test.  I think it's only relevant for dino SBA cards
where the bridge doesn't set up the card correctly so we have to do it
after the fact.

James

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 15:45     ` James Bottomley
@ 2011-10-14 15:45       ` James Bottomley
  2011-10-14 17:21       ` Bjorn Helgaas
  2011-12-20 15:55       ` Bjorn Helgaas
  2 siblings, 0 replies; 82+ messages in thread
From: James Bottomley @ 2011-10-14 15:45 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, 2011-10-14 at 09:33 -0600, Bjorn Helgaas wrote:
> On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
> <James.Bottomley@hansenpartnership.com> wrote:
> > On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
> >> The most generic way to create a PCI root bus is with pci_scan_bus(), but
> >> that doesn't allow you to specify what resources are available on the bus,
> >> i.e., what the host bridge apertures are.
> >
> > Do you have an actual tree for this?  The PARISC pieces look a bit
> > non-trivial and I'd like to test them out on the various sba/astro/dino
> > systems.
> 
> I don't yet, but it'd be great if you were willing to test them out,
> so I'll set one up.
> 
> While this is on your mind, I'm dubious about the pci_enable_bridges()
> call in lba_driver_probe() and the pci_bus_assign_resources() call in
> dino_probe().  These stand out as exceptions because no other arches
> do that.
> 
> If they weren't there, both places could use pci_scan_root_bus() like
> most other arches.

Right, the dino code actually has to rearrange some of the PCI resources
to make sure we get our apertures correct.  That's the specific bit I
was planning to test.  I think it's only relevant for dino SBA cards
where the bridge doesn't set up the card correctly so we have to do it
after the fact.

James



^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 15:45     ` James Bottomley
  2011-10-14 15:45       ` James Bottomley
@ 2011-10-14 17:21       ` Bjorn Helgaas
  2011-10-14 17:21         ` Bjorn Helgaas
  2011-12-20 15:55       ` Bjorn Helgaas
  2 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14 17:21 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, Oct 14, 2011 at 9:45 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Fri, 2011-10-14 at 09:33 -0600, Bjorn Helgaas wrote:
>> On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
>> <James.Bottomley@hansenpartnership.com> wrote:
>> > On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
>> >> The most generic way to create a PCI root bus is with pci_scan_bus(), but
>> >> that doesn't allow you to specify what resources are available on the bus,
>> >> i.e., what the host bridge apertures are.
>> >
>> > Do you have an actual tree for this?  The PARISC pieces look a bit
>> > non-trivial and I'd like to test them out on the various sba/astro/dino
>> > systems.
>>
>> I don't yet, but it'd be great if you were willing to test them out,
>> so I'll set one up.
>>
>> While this is on your mind, I'm dubious about the pci_enable_bridges()
>> call in lba_driver_probe() and the pci_bus_assign_resources() call in
>> dino_probe().  These stand out as exceptions because no other arches
>> do that.
>>
>> If they weren't there, both places could use pci_scan_root_bus() like
>> most other arches.
>
> Right, the dino code actually has to rearrange some of the PCI resources
> to make sure we get our apertures correct.  That's the specific bit I
> was planning to test.  I think it's only relevant for dino SBA cards
> where the bridge doesn't set up the card correctly so we have to do it
> after the fact.

I put these patches here: git://github.com/bjorn-helgaas/linux.git on
the "pci-scan" branch.

Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 17:21       ` Bjorn Helgaas
@ 2011-10-14 17:21         ` Bjorn Helgaas
  0 siblings, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14 17:21 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, Oct 14, 2011 at 9:45 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Fri, 2011-10-14 at 09:33 -0600, Bjorn Helgaas wrote:
>> On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
>> <James.Bottomley@hansenpartnership.com> wrote:
>> > On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
>> >> The most generic way to create a PCI root bus is with pci_scan_bus(), but
>> >> that doesn't allow you to specify what resources are available on the bus,
>> >> i.e., what the host bridge apertures are.
>> >
>> > Do you have an actual tree for this?  The PARISC pieces look a bit
>> > non-trivial and I'd like to test them out on the various sba/astro/dino
>> > systems.
>>
>> I don't yet, but it'd be great if you were willing to test them out,
>> so I'll set one up.
>>
>> While this is on your mind, I'm dubious about the pci_enable_bridges()
>> call in lba_driver_probe() and the pci_bus_assign_resources() call in
>> dino_probe().  These stand out as exceptions because no other arches
>> do that.
>>
>> If they weren't there, both places could use pci_scan_root_bus() like
>> most other arches.
>
> Right, the dino code actually has to rearrange some of the PCI resources
> to make sure we get our apertures correct.  That's the specific bit I
> was planning to test.  I think it's only relevant for dino SBA cards
> where the bridge doesn't set up the card correctly so we have to do it
> after the fact.

I put these patches here: git://github.com/bjorn-helgaas/linux.git on
the "pci-scan" branch.

Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14  5:30   ` Yinghai Lu
@ 2011-10-14 20:32     ` Bjorn Helgaas
  2011-10-14 20:39       ` Yinghai Lu
  0 siblings, 1 reply; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14 20:32 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On Thu, Oct 13, 2011 at 11:30 PM, Yinghai Lu <yinghai.lu@oracle.com> wrote:
> On 10/13/2011 09:27 PM, Bjorn Helgaas wrote:
>
>> x86 has two kinds of PCI root bus scanning:
>>
>> (1) ACPI-based, using _CRS resources.  This used pci_create_bus() because
>>     ACPI hotplug needed to split the pci_bus_add_devices() into a separate
>>     .start() method.
>>
>>     This patch parses the _CRS resources earlier, so we can build a list of
>>     resources and pass it to pci_create_root_bus().
>>
>>     Note that as before, we parse the _CRS even if we aren't going to use
>>     it so we can print it for debugging purposes.
>>
>> (2) All other, which used either default resources (ioport_resource and
>>     iomem_resource) or information read from the hardware via amd_bus.c or
>>     similar.  This used pci_scan_bus().
>>
>>     This patch converts x86_pci_root_bus_res_quirks() (previously called
>>     from pcibios_fixup_bus()) to x86_pci_root_bus_resources(), which builds
>>     a list of resources before we call pci_scan_root_bus().
>>
>>     We also use x86_pci_root_bus_resources() if we have ACPI but are
>>     ignoring _CRS.
>>
>> CC: Yinghai Lu <yinghai.lu@oracle.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/x86/include/asm/topology.h |    2 +-
>>  arch/x86/pci/acpi.c             |   31 +++++++++++++++++--------------
>>  arch/x86/pci/bus_numa.c         |   31 ++++++++++++++++++-------------
>>  arch/x86/pci/common.c           |   21 ++++++++++++++-------
>>  4 files changed, 50 insertions(+), 35 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
>> index c006924..5f83b13 100644
>> --- a/arch/x86/include/asm/topology.h
>> +++ b/arch/x86/include/asm/topology.h
>> @@ -174,7 +174,7 @@ static inline void arch_fix_phys_package_id(int num, u32 slot)
>>  }
>>
>>  struct pci_bus;
>> -void x86_pci_root_bus_res_quirks(struct pci_bus *b);
>> +void x86_pci_root_bus_resources(int bus, struct list_head *resources);
>>
>>  #ifdef CONFIG_SMP
>>  #define mc_capable() ((boot_cpu_data.x86_max_cores > 1) && \
>> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
>> index 039d913..77bb332 100644
>> --- a/arch/x86/pci/acpi.c
>> +++ b/arch/x86/pci/acpi.c
>> @@ -12,7 +12,7 @@ struct pci_root_info {
>>       char *name;
>>       unsigned int res_num;
>>       struct resource *res;
>> -     struct pci_bus *bus;
>> +     struct list_head *resources;
>>       int busnum;
>>  };
>>
>> @@ -250,23 +250,20 @@ static void add_resources(struct pci_root_info *info)
>>                                "ignoring host bridge window %pR (conflicts with %s %pR)\n",
>>                                res, conflict->name, conflict);
>>               else
>> -                     pci_bus_add_resource(info->bus, res, 0);
>> +                     pci_add_resource(info->resources, res);
>>       }
>>  }
>>
>>  static void
>>  get_current_resources(struct acpi_device *device, int busnum,
>> -                     int domain, struct pci_bus *bus)
>> +                   int domain, struct list_head *resources)
>>  {
>>       struct pci_root_info info;
>>       size_t size;
>>
>> -     if (pci_use_crs)
>> -             pci_bus_remove_resources(bus);
>> -
>>       info.bridge = device;
>> -     info.bus = bus;
>>       info.res_num = 0;
>> +     info.resources = resources;
>>       acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
>>                               &info);
>>       if (!info.res_num)
>> @@ -275,7 +272,7 @@ get_current_resources(struct acpi_device *device, int busnum,
>>       size = sizeof(*info.res) * info.res_num;
>>       info.res = kmalloc(size, GFP_KERNEL);
>>       if (!info.res)
>> -             goto res_alloc_fail;
>> +             return;
>>
>>       info.name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum);
>>       if (!info.name)
>> @@ -290,8 +287,6 @@ get_current_resources(struct acpi_device *device, int busnum,
>>
>>  name_alloc_fail:
>>       kfree(info.res);
>> -res_alloc_fail:
>> -     return;
>>  }
>>
>>  struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>> @@ -299,6 +294,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>       struct acpi_device *device = root->device;
>>       int domain = root->segment;
>>       int busnum = root->secondary.start;
>> +     struct list_head resources;
>>       struct pci_bus *bus;
>>       struct pci_sysdata *sd;
>>       int node;
>> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>               memcpy(bus->sysdata, sd, sizeof(*sd));
>>               kfree(sd);
>>       } else {
>> -             bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
>> -             if (bus) {
>> -                     get_current_resources(device, busnum, domain, bus);
>> -                     bus->subordinate = pci_scan_child_bus(bus);
>> +             INIT_LIST_HEAD(&resources);
>> +             get_current_resources(device, busnum, domain, &resources);
>> +             if (!pci_use_crs) {
>> +                     pci_free_resource_list(&resources);
>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>               }
>
>
> You may need to update get_current_resources() to return status about handling _CRS...
> and check that status insteaf of !pci_use_crs.

Is the current patch broken here?  I don't think it will be simpler to
have get_current_resources() return a status and check that.  But if
something's actually broken, I want to fix it, of course.

>> +             bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd,
>> +                                       &resources);
>> +             if (bus)
>> +                     bus->subordinate = pci_scan_child_bus(bus);
>> +             else
>> +                     pci_free_resource_list(&resources);
>>       }
>
>>
>
>>       /* After the PCI-E bus has been walked and all devices discovered,
>> diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
>> index 64a1228..fd3f655 100644
>> --- a/arch/x86/pci/bus_numa.c
>> +++ b/arch/x86/pci/bus_numa.c
>> @@ -7,45 +7,50 @@
>>  int pci_root_num;
>>  struct pci_root_info pci_root_info[PCI_ROOT_NR];
>>
>> -void x86_pci_root_bus_res_quirks(struct pci_bus *b)
>> +void x86_pci_root_bus_resources(int bus, struct list_head *resources)
>>  {
>>       int i;
>>       int j;
>>       struct pci_root_info *info;
>>
>> -     /* don't go for it if _CRS is used already */
>> -     if (b->resource[0] != &ioport_resource ||
>> -         b->resource[1] != &iomem_resource)
>> -             return;
>> -
>>       if (!pci_root_num)
>> -             return;
>> +             goto default_resources;
>>
>>       for (i = 0; i < pci_root_num; i++) {
>> -             if (pci_root_info[i].bus_min == b->number)
>> +             if (pci_root_info[i].bus_min == bus)
>>                       break;
>>       }
>>
>>       if (i == pci_root_num)
>> -             return;
>> +             goto default_resources;
>>
>> -     printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
>> -                     b->number);
>> +     printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n",
>> +            bus);
>>
>> -     pci_bus_remove_resources(b);
>>       info = &pci_root_info[i];
>>       for (j = 0; j < info->res_num; j++) {
>>               struct resource *res;
>>               struct resource *root;
>>
>>               res = &info->res[j];
>> -             pci_bus_add_resource(b, res, 0);
>> +             pci_add_resource(resources, res);
>>               if (res->flags & IORESOURCE_IO)
>>                       root = &ioport_resource;
>>               else
>>                       root = &iomem_resource;
>>               insert_resource(root, res);
>>       }
>> +     return;
>> +
>> +default_resources:
>> +     /*
>> +      * We don't have any host bridge aperture information from the
>> +      * "native host bridge drivers," e.g., amd_bus or broadcom_bus,
>> +      * so fall back to the defaults historically used by pci_create_bus().
>> +      */
>> +     printk(KERN_DEBUG "PCI: root bus %02x: using default resources\n", bus);
>> +     pci_add_resource(resources, &ioport_resource);
>> +     pci_add_resource(resources, &iomem_resource);
>>  }
>>
>>  void __devinit update_res(struct pci_root_info *info, resource_size_t start,
>> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
>> index b389a2d..7f595cc 100644
>> --- a/arch/x86/pci/common.c
>> +++ b/arch/x86/pci/common.c
>> @@ -164,9 +164,6 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
>>  {
>>       struct pci_dev *dev;
>>
>> -     /* root bus? */
>> -     if (!b->parent)
>> -             x86_pci_root_bus_res_quirks(b);
>>       pci_read_bridge_bases(b);
>>       list_for_each_entry(dev, &b->devices, bus_list)
>>               pcibios_fixup_device_resources(dev);
>> @@ -433,6 +430,7 @@ void __init dmi_check_pciprobe(void)
>>
>>  struct pci_bus * __devinit pcibios_scan_root(int busnum)
>>  {
>> +     struct list_head resources;
>>       struct pci_bus *bus = NULL;
>>       struct pci_sysdata *sd;
>>
>> @@ -456,9 +454,13 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
>>       sd->node = get_mp_bus_to_node(busnum);
>>
>>       printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
>> -     bus = pci_scan_bus(busnum, &pci_root_ops, sd);
>> -     if (!bus)
>> +     INIT_LIST_HEAD(&resources);
>> +     x86_pci_root_bus_resources(busnum, &resources);
>> +     bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
>> +     if (!bus) {
>> +             pci_free_resource_list(&resources);
>>               kfree(sd);
>> +     }
>>
>>       return bus;
>>  }
>> @@ -639,6 +641,7 @@ int pci_ext_cfg_avail(struct pci_dev *dev)
>>
>>  struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
>>  {
>> +     struct list_head resources;
>>       struct pci_bus *bus = NULL;
>>       struct pci_sysdata *sd;
>>
>> @@ -653,9 +656,13 @@ struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops,
>>               return NULL;
>>       }
>>       sd->node = node;
>> -     bus = pci_scan_bus(busno, ops, sd);
>> -     if (!bus)
>> +     INIT_LIST_HEAD(&resources);
>> +     x86_pci_root_bus_resources(busno, &resources);
>> +     bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources);
>> +     if (!bus) {
>> +             pci_free_resource_list(&resources);
>>               kfree(sd);
>> +     }
>>
>>       return bus;
>>  }
>>
>
>
> well, that will break
> arch/x86/pci/broadcom_bus.c
>
> it is using
>
> DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
>                        cnb20le_res);

Oooh, you're right!  Thanks for pointing that out.  I added another
patch to read the CNB20LE info early.  I'll see if I can get Ira to
test it.

Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14 20:32     ` Bjorn Helgaas
@ 2011-10-14 20:39       ` Yinghai Lu
  2011-10-14 20:54         ` Bjorn Helgaas
  0 siblings, 1 reply; 82+ messages in thread
From: Yinghai Lu @ 2011-10-14 20:39 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On 10/14/2011 01:32 PM, Bjorn Helgaas wrote:


>>>       int node;
>>> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>>               memcpy(bus->sysdata, sd, sizeof(*sd));
>>>               kfree(sd);
>>>       } else {
>>> -             bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
>>> -             if (bus) {
>>> -                     get_current_resources(device, busnum, domain, bus);
>>> -                     bus->subordinate = pci_scan_child_bus(bus);
>>> +             INIT_LIST_HEAD(&resources);
>>> +             get_current_resources(device, busnum, domain, &resources);
>>> +             if (!pci_use_crs) {
>>> +                     pci_free_resource_list(&resources);
>>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>>               }
>>
>>
>> You may need to update get_current_resources() to return status about handling _CRS...
>> and check that status insteaf of !pci_use_crs.
> 
> Is the current patch broken here?  I don't think it will be simpler to
> have get_current_resources() return a status and check that.  But if
> something's actually broken, I want to fix it, of course.
> 


yes. if for some reason, _CRS is not handled right, that root bus resources will not get set to default res.

+             status = get_current_resources(device, busnum, domain, &resources);
+             if (status) {
+                     pci_free_resource_list(&resources);
+                     x86_pci_root_bus_resources(busnum, &resources);
              }

get_current_resources() will not return 0 if _CRS is not really used.

Thanks

	Yinghai

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14 20:39       ` Yinghai Lu
@ 2011-10-14 20:54         ` Bjorn Helgaas
  2011-10-14 20:54           ` Bjorn Helgaas
  2011-10-14 21:15           ` Yinghai Lu
  0 siblings, 2 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14 20:54 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On Fri, Oct 14, 2011 at 2:39 PM, Yinghai Lu <yinghai.lu@oracle.com> wrote:
> On 10/14/2011 01:32 PM, Bjorn Helgaas wrote:
>
>
>>>>       int node;
>>>> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>>>               memcpy(bus->sysdata, sd, sizeof(*sd));
>>>>               kfree(sd);
>>>>       } else {
>>>> -             bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
>>>> -             if (bus) {
>>>> -                     get_current_resources(device, busnum, domain, bus);
>>>> -                     bus->subordinate = pci_scan_child_bus(bus);
>>>> +             INIT_LIST_HEAD(&resources);
>>>> +             get_current_resources(device, busnum, domain, &resources);
>>>> +             if (!pci_use_crs) {
>>>> +                     pci_free_resource_list(&resources);
>>>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>>>               }
>>>
>>>
>>> You may need to update get_current_resources() to return status about handling _CRS...
>>> and check that status insteaf of !pci_use_crs.
>>
>> Is the current patch broken here?  I don't think it will be simpler to
>> have get_current_resources() return a status and check that.  But if
>> something's actually broken, I want to fix it, of course.
>>
>
>
> yes. if for some reason, _CRS is not handled right, that root bus resources will not get set to default res.
>
> +             status = get_current_resources(device, busnum, domain, &resources);
> +             if (status) {
> +                     pci_free_resource_list(&resources);
> +                     x86_pci_root_bus_resources(busnum, &resources);
>              }
>
> get_current_resources() will not return 0 if _CRS is not really used.

OK.  I think it was that way before, too.  We created the bus with
default resources, but the first thing get_current_resources() did was
clear them all out.  If there was a problem parsing _CRS, we never
went back and put the defaults back in.

But I think this will do what you suggest and is nicer than what I had before:

                INIT_LIST_HEAD(&resources);
                get_current_resources(device, busnum, domain, &resources);
                if (list_empty(&resources))
                        x86_pci_root_bus_resources(busnum, &resources);

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14 20:54         ` Bjorn Helgaas
@ 2011-10-14 20:54           ` Bjorn Helgaas
  2011-10-14 21:15           ` Yinghai Lu
  1 sibling, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-10-14 20:54 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On Fri, Oct 14, 2011 at 2:39 PM, Yinghai Lu <yinghai.lu@oracle.com> wrote:
> On 10/14/2011 01:32 PM, Bjorn Helgaas wrote:
>
>
>>>>       int node;
>>>> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>>>               memcpy(bus->sysdata, sd, sizeof(*sd));
>>>>               kfree(sd);
>>>>       } else {
>>>> -             bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
>>>> -             if (bus) {
>>>> -                     get_current_resources(device, busnum, domain, bus);
>>>> -                     bus->subordinate = pci_scan_child_bus(bus);
>>>> +             INIT_LIST_HEAD(&resources);
>>>> +             get_current_resources(device, busnum, domain, &resources);
>>>> +             if (!pci_use_crs) {
>>>> +                     pci_free_resource_list(&resources);
>>>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>>>               }
>>>
>>>
>>> You may need to update get_current_resources() to return status about handling _CRS...
>>> and check that status insteaf of !pci_use_crs.
>>
>> Is the current patch broken here?  I don't think it will be simpler to
>> have get_current_resources() return a status and check that.  But if
>> something's actually broken, I want to fix it, of course.
>>
>
>
> yes. if for some reason, _CRS is not handled right, that root bus resources will not get set to default res.
>
> +             status = get_current_resources(device, busnum, domain, &resources);
> +             if (status) {
> +                     pci_free_resource_list(&resources);
> +                     x86_pci_root_bus_resources(busnum, &resources);
>              }
>
> get_current_resources() will not return 0 if _CRS is not really used.

OK.  I think it was that way before, too.  We created the bus with
default resources, but the first thing get_current_resources() did was
clear them all out.  If there was a problem parsing _CRS, we never
went back and put the defaults back in.

But I think this will do what you suggest and is nicer than what I had before:

                INIT_LIST_HEAD(&resources);
                get_current_resources(device, busnum, domain, &resources);
                if (list_empty(&resources))
                        x86_pci_root_bus_resources(busnum, &resources);

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14 20:54         ` Bjorn Helgaas
  2011-10-14 20:54           ` Bjorn Helgaas
@ 2011-10-14 21:15           ` Yinghai Lu
  2011-10-14 21:15             ` Yinghai Lu
  1 sibling, 1 reply; 82+ messages in thread
From: Yinghai Lu @ 2011-10-14 21:15 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On 10/14/2011 01:54 PM, Bjorn Helgaas wrote:

> On Fri, Oct 14, 2011 at 2:39 PM, Yinghai Lu <yinghai.lu@oracle.com> wrote:
>> On 10/14/2011 01:32 PM, Bjorn Helgaas wrote:
>>
>>
>>>>>       int node;
>>>>> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>>>>               memcpy(bus->sysdata, sd, sizeof(*sd));
>>>>>               kfree(sd);
>>>>>       } else {
>>>>> -             bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
>>>>> -             if (bus) {
>>>>> -                     get_current_resources(device, busnum, domain, bus);
>>>>> -                     bus->subordinate = pci_scan_child_bus(bus);
>>>>> +             INIT_LIST_HEAD(&resources);
>>>>> +             get_current_resources(device, busnum, domain, &resources);
>>>>> +             if (!pci_use_crs) {
>>>>> +                     pci_free_resource_list(&resources);
>>>>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>>>>               }
>>>>
>>>>
>>>> You may need to update get_current_resources() to return status about handling _CRS...
>>>> and check that status insteaf of !pci_use_crs.
>>>
>>> Is the current patch broken here?  I don't think it will be simpler to
>>> have get_current_resources() return a status and check that.  But if
>>> something's actually broken, I want to fix it, of course.
>>>
>>
>>
>> yes. if for some reason, _CRS is not handled right, that root bus resources will not get set to default res.
>>
>> +             status = get_current_resources(device, busnum, domain, &resources);
>> +             if (status) {
>> +                     pci_free_resource_list(&resources);
>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>              }
>>
>> get_current_resources() will not return 0 if _CRS is not really used.
> 
> OK.  I think it was that way before, too.  We created the bus with
> default resources, but the first thing get_current_resources() did was
> clear them all out.  If there was a problem parsing _CRS, we never
> went back and put the defaults back in.


that means you broke it when you clean up it last time. 

> 
> But I think this will do what you suggest and is nicer than what I had before:
> 
>                 INIT_LIST_HEAD(&resources);
>                 get_current_resources(device, busnum, domain, &resources);
>                 if (list_empty(&resources))
>                         x86_pci_root_bus_resources(busnum, &resources);


yes, that should work.

Yinghai

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  2011-10-14 21:15           ` Yinghai Lu
@ 2011-10-14 21:15             ` Yinghai Lu
  0 siblings, 0 replies; 82+ messages in thread
From: Yinghai Lu @ 2011-10-14 21:15 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-kernel, Jesse Barnes

On 10/14/2011 01:54 PM, Bjorn Helgaas wrote:

> On Fri, Oct 14, 2011 at 2:39 PM, Yinghai Lu <yinghai.lu@oracle.com> wrote:
>> On 10/14/2011 01:32 PM, Bjorn Helgaas wrote:
>>
>>
>>>>>       int node;
>>>>> @@ -353,11 +349,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
>>>>>               memcpy(bus->sysdata, sd, sizeof(*sd));
>>>>>               kfree(sd);
>>>>>       } else {
>>>>> -             bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
>>>>> -             if (bus) {
>>>>> -                     get_current_resources(device, busnum, domain, bus);
>>>>> -                     bus->subordinate = pci_scan_child_bus(bus);
>>>>> +             INIT_LIST_HEAD(&resources);
>>>>> +             get_current_resources(device, busnum, domain, &resources);
>>>>> +             if (!pci_use_crs) {
>>>>> +                     pci_free_resource_list(&resources);
>>>>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>>>>               }
>>>>
>>>>
>>>> You may need to update get_current_resources() to return status about handling _CRS...
>>>> and check that status insteaf of !pci_use_crs.
>>>
>>> Is the current patch broken here?  I don't think it will be simpler to
>>> have get_current_resources() return a status and check that.  But if
>>> something's actually broken, I want to fix it, of course.
>>>
>>
>>
>> yes. if for some reason, _CRS is not handled right, that root bus resources will not get set to default res.
>>
>> +             status = get_current_resources(device, busnum, domain, &resources);
>> +             if (status) {
>> +                     pci_free_resource_list(&resources);
>> +                     x86_pci_root_bus_resources(busnum, &resources);
>>              }
>>
>> get_current_resources() will not return 0 if _CRS is not really used.
> 
> OK.  I think it was that way before, too.  We created the bus with
> default resources, but the first thing get_current_resources() did was
> clear them all out.  If there was a problem parsing _CRS, we never
> went back and put the defaults back in.


that means you broke it when you clean up it last time. 

> 
> But I think this will do what you suggest and is nicer than what I had before:
> 
>                 INIT_LIST_HEAD(&resources);
>                 get_current_resources(device, busnum, domain, &resources);
>                 if (list_empty(&resources))
>                         x86_pci_root_bus_resources(busnum, &resources);


yes, that should work.

Yinghai

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-10-14 15:45     ` James Bottomley
  2011-10-14 15:45       ` James Bottomley
  2011-10-14 17:21       ` Bjorn Helgaas
@ 2011-12-20 15:55       ` Bjorn Helgaas
  2011-12-20 15:55         ` Bjorn Helgaas
  2011-12-22 18:59         ` David Miller
  2 siblings, 2 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-12-20 15:55 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, Oct 14, 2011 at 9:45 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Fri, 2011-10-14 at 09:33 -0600, Bjorn Helgaas wrote:
>> On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
>> <James.Bottomley@hansenpartnership.com> wrote:
>> > On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
>> >> The most generic way to create a PCI root bus is with pci_scan_bus(), but
>> >> that doesn't allow you to specify what resources are available on the bus,
>> >> i.e., what the host bridge apertures are.
>> >
>> > Do you have an actual tree for this?  The PARISC pieces look a bit
>> > non-trivial and I'd like to test them out on the various sba/astro/dino
>> > systems.
>>
>> I don't yet, but it'd be great if you were willing to test them out,
>> so I'll set one up.
>>
>> While this is on your mind, I'm dubious about the pci_enable_bridges()
>> call in lba_driver_probe() and the pci_bus_assign_resources() call in
>> dino_probe().  These stand out as exceptions because no other arches
>> do that.
>>
>> If they weren't there, both places could use pci_scan_root_bus() like
>> most other arches.
>
> Right, the dino code actually has to rearrange some of the PCI resources
> to make sure we get our apertures correct.  That's the specific bit I
> was planning to test.  I think it's only relevant for dino SBA cards
> where the bridge doesn't set up the card correctly so we have to do it
> after the fact.

This series has been in linux-next for a while now (via Jesse's PCI
tree), so this would be a good time to try it out if you haven't
already.

I know ia64 has been exercised a bit (thanks, Tony), but I haven't
heard anything about arm, mips, parisc, powerpc, sparc, etc.

There is one outstanding bug fix for alpha that Jesse hasn't
integrated yet, but as far as I know, everything else is in good
shape.

Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-12-20 15:55       ` Bjorn Helgaas
@ 2011-12-20 15:55         ` Bjorn Helgaas
  2011-12-22 18:59         ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: Bjorn Helgaas @ 2011-12-20 15:55 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-pci, linux-arch, linux-kernel

On Fri, Oct 14, 2011 at 9:45 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Fri, 2011-10-14 at 09:33 -0600, Bjorn Helgaas wrote:
>> On Fri, Oct 14, 2011 at 9:14 AM, James Bottomley
>> <James.Bottomley@hansenpartnership.com> wrote:
>> > On Thu, 2011-10-13 at 22:27 -0600, Bjorn Helgaas wrote:
>> >> The most generic way to create a PCI root bus is with pci_scan_bus(), but
>> >> that doesn't allow you to specify what resources are available on the bus,
>> >> i.e., what the host bridge apertures are.
>> >
>> > Do you have an actual tree for this?  The PARISC pieces look a bit
>> > non-trivial and I'd like to test them out on the various sba/astro/dino
>> > systems.
>>
>> I don't yet, but it'd be great if you were willing to test them out,
>> so I'll set one up.
>>
>> While this is on your mind, I'm dubious about the pci_enable_bridges()
>> call in lba_driver_probe() and the pci_bus_assign_resources() call in
>> dino_probe().  These stand out as exceptions because no other arches
>> do that.
>>
>> If they weren't there, both places could use pci_scan_root_bus() like
>> most other arches.
>
> Right, the dino code actually has to rearrange some of the PCI resources
> to make sure we get our apertures correct.  That's the specific bit I
> was planning to test.  I think it's only relevant for dino SBA cards
> where the bridge doesn't set up the card correctly so we have to do it
> after the fact.

This series has been in linux-next for a while now (via Jesse's PCI
tree), so this would be a good time to try it out if you haven't
already.

I know ia64 has been exercised a bit (thanks, Tony), but I haven't
heard anything about arm, mips, parisc, powerpc, sparc, etc.

There is one outstanding bug fix for alpha that Jesse hasn't
integrated yet, but as far as I know, everything else is in good
shape.

Bjorn

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-12-20 15:55       ` Bjorn Helgaas
  2011-12-20 15:55         ` Bjorn Helgaas
@ 2011-12-22 18:59         ` David Miller
  2011-12-22 19:15           ` David Miller
  1 sibling, 1 reply; 82+ messages in thread
From: David Miller @ 2011-12-22 18:59 UTC (permalink / raw)
  To: bhelgaas; +Cc: James.Bottomley, linux-pci, linux-arch, linux-kernel

From: Bjorn Helgaas <bhelgaas@google.com>
Date: Tue, 20 Dec 2011 08:55:53 -0700

> This series has been in linux-next for a while now (via Jesse's PCI
> tree), so this would be a good time to try it out if you haven't
> already.
> 
> I know ia64 has been exercised a bit (thanks, Tony), but I haven't
> heard anything about arm, mips, parisc, powerpc, sparc, etc.
> 
> There is one outstanding bug fix for alpha that Jesse hasn't
> integrated yet, but as far as I know, everything else is in good
> shape.

I'll give it a quick test on sparc64 today.

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-12-22 18:59         ` David Miller
@ 2011-12-22 19:15           ` David Miller
  2011-12-22 19:15             ` David Miller
  2011-12-22 19:56             ` David Miller
  0 siblings, 2 replies; 82+ messages in thread
From: David Miller @ 2011-12-22 19:15 UTC (permalink / raw)
  To: bhelgaas; +Cc: James.Bottomley, linux-pci, linux-arch, linux-kernel

From: David Miller <davem@davemloft.net>
Date: Thu, 22 Dec 2011 13:59:11 -0500 (EST)

> From: Bjorn Helgaas <bhelgaas@google.com>
> Date: Tue, 20 Dec 2011 08:55:53 -0700
> 
>> This series has been in linux-next for a while now (via Jesse's PCI
>> tree), so this would be a good time to try it out if you haven't
>> already.
>> 
>> I know ia64 has been exercised a bit (thanks, Tony), but I haven't
>> heard anything about arm, mips, parisc, powerpc, sparc, etc.
>> 
>> There is one outstanding bug fix for alpha that Jesse hasn't
>> integrated yet, but as far as I know, everything else is in good
>> shape.
> 
> I'll give it a quick test on sparc64 today.

Jesse's linux-next GIT branch boots up fine, but I get tons of
warnings that kobject_put() is being performed on an uninitialized
kobject.

It looks like populate_msi_sysfs() is where these kobjects are
supposed to be initialized.

Anyways, two examples:

[2766595.475642] mpt2sas1: 32 BIT PCI BUS DMA ADDRESSING SUPPORTED, total mem (7767632 kB)
[2766595.491604] ------------[ cut here ]------------
[2766595.500986] WARNING: at lib/kobject.c:595 kobject_put+0x48/0x80()
[2766595.513482] kobject: '(null)' (fffff801f9b7a620): is not initialized, yet kobject_put() is being called.
[2766595.532762] Modules linked in:
[2766595.539152] Call Trace:
[2766595.544391]  [000000000046944c] warn_slowpath_fmt+0x2c/0x40
[2766595.555837]  [00000000005ed188] kobject_put+0x48/0x80
[2766595.566261]  [0000000000622b68] free_msi_irqs+0xc8/0x120
[2766595.577196]  [0000000000623870] pci_enable_msix+0x270/0x420
[2766595.588665]  [00000000006a9fe8] mpt2sas_base_map_resources+0x2c8/0x480
[2766595.602023]  [00000000006acb8c] mpt2sas_base_attach+0xac/0x1280
[2766595.614166]  [00000000006b5c20] _scsih_probe+0x2a0/0x480
[2766595.625113]  [000000000061d048] pci_device_probe+0x108/0x120
[2766595.636746]  [0000000000671464] driver_probe_device+0x64/0x180
[2766595.648716]  [0000000000671600] __driver_attach+0x80/0xa0
[2766595.659838]  [0000000000670570] bus_for_each_dev+0x50/0x80
[2766595.671115]  [0000000000670cdc] bus_add_driver+0x9c/0x260
[2766595.682217]  [000000000067190c] driver_register+0x6c/0x160
[2766595.693508]  [000000000061d4d4] __pci_register_driver+0x34/0xc0
[2766595.705652]  [000000000096912c] _scsih_init+0x150/0x17c
[2766595.716413]  [0000000000426ad8] do_one_initcall+0x18/0x160
[2766595.727697] ---[ end trace 1cc904a40b8d2c88 ]---

--------------------

[2766607.786504] ------------[ cut here ]------------
[2766607.786519] WARNING: at lib/kobject.c:595 kobject_put+0x48/0x80()
[2766607.786529] kobject: '(null)' (fffff801fbec1280): is not initialized, yet kobject_put() is being called.
[2766607.786540] Modules linked in: igb(+) ehci_hcd(+) n2_rng rng_core
[2766607.786554] Call Trace:
[2766607.786568]  [000000000046944c] warn_slowpath_fmt+0x2c/0x40
[2766607.786581]  [00000000005ed188] kobject_put+0x48/0x80
[2766607.786596]  [0000000000622b68] free_msi_irqs+0xc8/0x120
[2766607.786610]  [0000000000622e1c] pci_enable_msi_block+0x25c/0x2c0
[2766607.786644]  [0000000010054b78] igb_probe+0x514/0xfc0 [igb]
[2766607.786658]  [000000000061d048] pci_device_probe+0x108/0x120
[2766607.786672]  [0000000000671464] driver_probe_device+0x64/0x180
[2766607.786683]  [0000000000671600] __driver_attach+0x80/0xa0
[2766607.786694]  [0000000000670570] bus_for_each_dev+0x50/0x80
[2766607.786707]  [0000000000670cdc] bus_add_driver+0x9c/0x260
[2766607.786718]  [000000000067190c] driver_register+0x6c/0x160
[2766607.786730]  [000000000061d4d4] __pci_register_driver+0x34/0xc0
[2766607.786743]  [0000000000426ad8] do_one_initcall+0x18/0x160
[2766607.786756]  [00000000004a33ec] SyS_init_module+0x6c/0x1c0
[2766607.786771]  [0000000000406194] linux_sparc_syscall32+0x34/0x40
[2766607.786779] ---[ end trace 1cc904a40b8d2c9d ]---

--------------------

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-12-22 19:15           ` David Miller
@ 2011-12-22 19:15             ` David Miller
  2011-12-22 19:56             ` David Miller
  1 sibling, 0 replies; 82+ messages in thread
From: David Miller @ 2011-12-22 19:15 UTC (permalink / raw)
  To: bhelgaas; +Cc: James.Bottomley, linux-pci, linux-arch, linux-kernel

From: David Miller <davem@davemloft.net>
Date: Thu, 22 Dec 2011 13:59:11 -0500 (EST)

> From: Bjorn Helgaas <bhelgaas@google.com>
> Date: Tue, 20 Dec 2011 08:55:53 -0700
> 
>> This series has been in linux-next for a while now (via Jesse's PCI
>> tree), so this would be a good time to try it out if you haven't
>> already.
>> 
>> I know ia64 has been exercised a bit (thanks, Tony), but I haven't
>> heard anything about arm, mips, parisc, powerpc, sparc, etc.
>> 
>> There is one outstanding bug fix for alpha that Jesse hasn't
>> integrated yet, but as far as I know, everything else is in good
>> shape.
> 
> I'll give it a quick test on sparc64 today.

Jesse's linux-next GIT branch boots up fine, but I get tons of
warnings that kobject_put() is being performed on an uninitialized
kobject.

It looks like populate_msi_sysfs() is where these kobjects are
supposed to be initialized.

Anyways, two examples:

[2766595.475642] mpt2sas1: 32 BIT PCI BUS DMA ADDRESSING SUPPORTED, total mem (7767632 kB)
[2766595.491604] ------------[ cut here ]------------
[2766595.500986] WARNING: at lib/kobject.c:595 kobject_put+0x48/0x80()
[2766595.513482] kobject: '(null)' (fffff801f9b7a620): is not initialized, yet kobject_put() is being called.
[2766595.532762] Modules linked in:
[2766595.539152] Call Trace:
[2766595.544391]  [000000000046944c] warn_slowpath_fmt+0x2c/0x40
[2766595.555837]  [00000000005ed188] kobject_put+0x48/0x80
[2766595.566261]  [0000000000622b68] free_msi_irqs+0xc8/0x120
[2766595.577196]  [0000000000623870] pci_enable_msix+0x270/0x420
[2766595.588665]  [00000000006a9fe8] mpt2sas_base_map_resources+0x2c8/0x480
[2766595.602023]  [00000000006acb8c] mpt2sas_base_attach+0xac/0x1280
[2766595.614166]  [00000000006b5c20] _scsih_probe+0x2a0/0x480
[2766595.625113]  [000000000061d048] pci_device_probe+0x108/0x120
[2766595.636746]  [0000000000671464] driver_probe_device+0x64/0x180
[2766595.648716]  [0000000000671600] __driver_attach+0x80/0xa0
[2766595.659838]  [0000000000670570] bus_for_each_dev+0x50/0x80
[2766595.671115]  [0000000000670cdc] bus_add_driver+0x9c/0x260
[2766595.682217]  [000000000067190c] driver_register+0x6c/0x160
[2766595.693508]  [000000000061d4d4] __pci_register_driver+0x34/0xc0
[2766595.705652]  [000000000096912c] _scsih_init+0x150/0x17c
[2766595.716413]  [0000000000426ad8] do_one_initcall+0x18/0x160
[2766595.727697] ---[ end trace 1cc904a40b8d2c88 ]---

--------------------

[2766607.786504] ------------[ cut here ]------------
[2766607.786519] WARNING: at lib/kobject.c:595 kobject_put+0x48/0x80()
[2766607.786529] kobject: '(null)' (fffff801fbec1280): is not initialized, yet kobject_put() is being called.
[2766607.786540] Modules linked in: igb(+) ehci_hcd(+) n2_rng rng_core
[2766607.786554] Call Trace:
[2766607.786568]  [000000000046944c] warn_slowpath_fmt+0x2c/0x40
[2766607.786581]  [00000000005ed188] kobject_put+0x48/0x80
[2766607.786596]  [0000000000622b68] free_msi_irqs+0xc8/0x120
[2766607.786610]  [0000000000622e1c] pci_enable_msi_block+0x25c/0x2c0
[2766607.786644]  [0000000010054b78] igb_probe+0x514/0xfc0 [igb]
[2766607.786658]  [000000000061d048] pci_device_probe+0x108/0x120
[2766607.786672]  [0000000000671464] driver_probe_device+0x64/0x180
[2766607.786683]  [0000000000671600] __driver_attach+0x80/0xa0
[2766607.786694]  [0000000000670570] bus_for_each_dev+0x50/0x80
[2766607.786707]  [0000000000670cdc] bus_add_driver+0x9c/0x260
[2766607.786718]  [000000000067190c] driver_register+0x6c/0x160
[2766607.786730]  [000000000061d4d4] __pci_register_driver+0x34/0xc0
[2766607.786743]  [0000000000426ad8] do_one_initcall+0x18/0x160
[2766607.786756]  [00000000004a33ec] SyS_init_module+0x6c/0x1c0
[2766607.786771]  [0000000000406194] linux_sparc_syscall32+0x34/0x40
[2766607.786779] ---[ end trace 1cc904a40b8d2c9d ]---

--------------------

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-12-22 19:15           ` David Miller
  2011-12-22 19:15             ` David Miller
@ 2011-12-22 19:56             ` David Miller
  2011-12-22 22:02               ` David Miller
  1 sibling, 1 reply; 82+ messages in thread
From: David Miller @ 2011-12-22 19:56 UTC (permalink / raw)
  To: bhelgaas; +Cc: James.Bottomley, linux-pci, linux-arch, linux-kernel, jbarnes

From: David Miller <davem@davemloft.net>
Date: Thu, 22 Dec 2011 14:15:37 -0500 (EST)

> It looks like populate_msi_sysfs() is where these kobjects are
> supposed to be initialized.

Ok, it looks like we violate the invariant the free_msi_irqs() should
only be invoked after populate_msi_sysfs() has successfully been run.

For example, in msix_capability_init(), if arch_setup_msi_irqs() fails
we will branch to "error" and do free_msi_irqs().

free_msi_irqs() unconditionally does puts on the MSI entry kobjects,
but we haven't initialized them in populate_msi_sysfs() and thus we
get the warnings.

Even if we did execute populate_msi_sysfs(), if that function
encountered an error part way through the MSI entry list, we'll still
hit this kobject_put() warning for the MSI entrys we did not process
and init.

In my case arch_setup_msi_irqs() is failing simply because MSI has
not been enabled on these PCI host bridges.  It should, and I'm
trying to figure out if this is some strange interaction with the
new resource code.

But this is independent of the above bugs that can result in erroneous
kobject puts.

^ permalink raw reply	[flat|nested] 82+ messages in thread

* Re: [PATCH v2 00/29] Create PCI root buses with correct resources
  2011-12-22 19:56             ` David Miller
@ 2011-12-22 22:02               ` David Miller
  0 siblings, 0 replies; 82+ messages in thread
From: David Miller @ 2011-12-22 22:02 UTC (permalink / raw)
  To: bhelgaas; +Cc: James.Bottomley, linux-pci, linux-arch, linux-kernel, jbarnes

From: David Miller <davem@davemloft.net>
Date: Thu, 22 Dec 2011 14:56:29 -0500 (EST)

> In my case arch_setup_msi_irqs() is failing simply because MSI has
> not been enabled on these PCI host bridges.  It should, and I'm
> trying to figure out if this is some strange interaction with the
> new resource code.

It wasn't a problem with the resource changes, it's a sparc64 problem
that only triggers on more recent systems.

The MSI SYSFS error handling is, of course, still needing to be fixed.

^ permalink raw reply	[flat|nested] 82+ messages in thread

end of thread, other threads:[~2011-12-22 22:02 UTC | newest]

Thread overview: 82+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-14  4:27 [PATCH v2 00/29] Create PCI root buses with correct resources Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 01/29] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 02/29] PCI: add pci_create_root_bus(), deprecate pci_create_bus() Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 03/29] PCI: add pci_scan_root_bus(), deprecate pci_scan_bus() and pci_scan_bus_parented() Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 04/29] MIPS: PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 05/29] x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 06/29] x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus() Bjorn Helgaas
2011-10-14  5:30   ` Yinghai Lu
2011-10-14 20:32     ` Bjorn Helgaas
2011-10-14 20:39       ` Yinghai Lu
2011-10-14 20:54         ` Bjorn Helgaas
2011-10-14 20:54           ` Bjorn Helgaas
2011-10-14 21:15           ` Yinghai Lu
2011-10-14 21:15             ` Yinghai Lu
2011-10-14  4:27 ` [PATCH v2 07/29] powerpc/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 08/29] powerpc/PCI: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:27 ` [PATCH v2 09/29] powerpc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  7:34   ` Benjamin Herrenschmidt
2011-10-14  4:27 ` [PATCH v2 10/29] microblaze/PCI: fix pci_bus_for_each_resource() usage Bjorn Helgaas
2011-10-14  4:27   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 11/29] microblaze/PCI: make pcibios_setup_phb_resources() static Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 12/29] microblaze/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 13/29] microblaze/PCI: use pci_scan_root_bus() Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 14/29] sparc/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:46   ` David Miller
2011-10-14  4:46     ` David Miller
2011-10-14  4:49     ` David Miller
2011-10-14  4:28 ` [PATCH v2 15/29] sparc32, leon/PCI: convert to pci_scan_root_bus() " Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:43   ` David Miller
2011-10-14  4:28 ` [PATCH v2 16/29] ia64/PCI: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 17/29] ia64/PCI: convert to pci_create_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 18/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 19/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 20/29] parisc/PCI: deal with LMMIO/PAT overlaps before creating PCI root bus Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 21/29] parisc/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:28 ` [PATCH v2 22/29] parisc/PCI: supply root bus resources to pci_create_root_bus() Bjorn Helgaas
2011-10-14  4:28   ` Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 23/29] xen/PCI: use pci_create_root_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-14  4:29   ` Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 24/29] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2011-10-14  4:29   ` Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 25/29] arm/PCI: " Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 26/29] frv/PCI: " Bjorn Helgaas
2011-10-14  4:29   ` Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 27/29] mn10300/PCI: " Bjorn Helgaas
2011-10-14  4:29   ` Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 28/29] sh/PCI: " Bjorn Helgaas
2011-10-14  4:29   ` Bjorn Helgaas
2011-10-14  4:29 ` [PATCH v2 29/29] xtensa/PCI: " Bjorn Helgaas
2011-10-14  4:29   ` Bjorn Helgaas
2011-10-14 15:14 ` [PATCH v2 00/29] Create PCI root buses with correct resources James Bottomley
2011-10-14 15:14   ` James Bottomley
2011-10-14 15:33   ` Bjorn Helgaas
2011-10-14 15:45     ` James Bottomley
2011-10-14 15:45       ` James Bottomley
2011-10-14 17:21       ` Bjorn Helgaas
2011-10-14 17:21         ` Bjorn Helgaas
2011-12-20 15:55       ` Bjorn Helgaas
2011-12-20 15:55         ` Bjorn Helgaas
2011-12-22 18:59         ` David Miller
2011-12-22 19:15           ` David Miller
2011-12-22 19:15             ` David Miller
2011-12-22 19:56             ` David Miller
2011-12-22 22:02               ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).