* [PATCH 01/12] PCI: add helpers for building PCI bus resource lists
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
@ 2011-10-11 3:18 ` Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 02/12] PCI: pass available resources into pci_create_bus() Bjorn Helgaas
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:18 UTC (permalink / raw)
To: linux-pci; +Cc: 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 [flat|nested] 15+ messages in thread* [PATCH 02/12] PCI: pass available resources into pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 01/12] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
@ 2011-10-11 3:18 ` Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 03/12] MIPS: PCI: supply root bus resources to pci_create_bus() Bjorn Helgaas
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:18 UTC (permalink / raw)
To: linux-pci; +Cc: Deng-Cheng Zhu, linux-kernel
The default resources given to a bus by pci_create_bus()
are ioport_resource and iomem_resource, i.e., the entire address
space. Architectures are expected to correct these later, typically
in pcibios_fixup_bus(), but code such as PCI quirks that run in the
interim see incorrect resource information.
This patch adds a "resources" argument to pci_create_bus() so
architecture code can supply the correct resources at the beginning.
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
CC: Deng-Cheng Zhu <dczhu@mips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/microblaze/pci/pci-common.c | 3 ++-
arch/powerpc/kernel/pci-common.c | 3 ++-
arch/sparc/kernel/pci.c | 3 ++-
arch/x86/pci/acpi.c | 2 +-
drivers/pci/probe.c | 17 +++++++++++++----
include/linux/pci.h | 3 ++-
6 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 4cfae20..9c35aa6 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1581,7 +1581,8 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
node ? node->full_name : "<NO NAME>");
/* Create an empty bus for the toplevel */
- bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+ bus = pci_create_bus(hose->parent, hose->first_busno,
+ hose->ops, hose, NULL);
if (bus == NULL) {
printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
hose->global_number);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 32656f1..2ede26a 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1703,7 +1703,8 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
node ? node->full_name : "<NO NAME>");
/* Create an empty bus for the toplevel */
- bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+ bus = pci_create_bus(hose->parent, hose->first_busno,
+ hose->ops, hose, NULL);
if (bus == NULL) {
pr_err("Failed to create bus for PCI domain %04x\n",
hose->global_number);
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 1e94f94..77c38bb 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -689,7 +689,8 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
printk("PCI: Scanning PBM %s\n", node->full_name);
- bus = pci_create_bus(parent, pbm->pci_first_busno, pbm->pci_ops, pbm);
+ bus = pci_create_bus(parent, pbm->pci_first_busno,
+ pbm->pci_ops, pbm, NULL);
if (!bus) {
printk(KERN_ERR "Failed to create bus for %s\n",
node->full_name);
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 039d913..9bf7aaa 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -353,7 +353,7 @@ 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);
+ bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd, NULL);
if (bus) {
get_current_resources(device, busnum, domain, bus);
bus->subordinate = pci_scan_child_bus(bus);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6ab6bd3..6a8e1c6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1529,11 +1529,13 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
}
struct pci_bus * pci_create_bus(struct device *parent,
- int bus, struct pci_ops *ops, void *sysdata)
+ int bus, struct pci_ops *ops, void *sysdata,
+ struct list_head *resources)
{
int error;
struct pci_bus *b, *b2;
struct device *dev;
+ struct pci_bus_resource *bus_res, *n;
b = pci_alloc_bus();
if (!b)
@@ -1583,8 +1585,15 @@ 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;
+ }
return b;
@@ -1605,7 +1614,7 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
{
struct pci_bus *b;
- b = pci_create_bus(parent, bus, ops, sysdata);
+ b = pci_create_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..f5e1b4a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -667,7 +667,8 @@ static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *o
return root_bus;
}
struct pci_bus *pci_create_bus(struct device *parent, int bus,
- struct pci_ops *ops, void *sysdata);
+ struct pci_ops *ops, void *sysdata,
+ struct list_head *resources);
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 [flat|nested] 15+ messages in thread* [PATCH 03/12] MIPS: PCI: supply root bus resources to pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 01/12] PCI: add helpers for building PCI bus resource lists Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 02/12] PCI: pass available resources into pci_create_bus() Bjorn Helgaas
@ 2011-10-11 3:18 ` Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 04/12] x86/PCI: " Bjorn Helgaas
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:18 UTC (permalink / raw)
To: linux-pci; +Cc: Deng-Cheng Zhu, linux-kernel
Use the new interface of pci_create_bus() so that system controller's
resources are added to the root bus upon bus creation, thereby avoiding
conflicts with PCI quirks before pcibios_fixup_bus() gets the chance to
fixup the root bus resources in pci_scan_child_bus().
Based on original patch by Deng-Cheng Zhu.
Reference: https://lkml.org/lkml/2011/8/26/89
CC: Deng-Cheng Zhu <dczhu@mips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/mips/pci/pci.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 33bba7b..4c7866d 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,17 @@ 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, ctrl->mem_resource);
+ pci_add_resource(&resources, ctrl->io_resource);
+ bus = pci_create_bus(NULL, next_busno, hose->pci_ops, hose, &resources);
+ if (bus) {
+ bus->subordinate = pci_scan_child_bus(bus);
+ pci_bus_add_devices(bus);
+ } else {
+ pci_free_resource_list(&resources);
+ }
+
hose->bus = bus;
need_domain_info = need_domain_info || hose->index;
@@ -265,15 +276,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 [flat|nested] 15+ messages in thread* [PATCH 04/12] x86/PCI: supply root bus resources to pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (2 preceding siblings ...)
2011-10-11 3:18 ` [PATCH 03/12] MIPS: PCI: supply root bus resources to pci_create_bus() Bjorn Helgaas
@ 2011-10-11 3:18 ` Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 05/12] powerpc/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
` (7 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:18 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
Parse ACPI host bridge _CRS resources first, so we can build a list of
resources available on the root bus and pass it to pci_create_bus().
Note that as before, we parse the ACPI _CRS even if we aren't paying
attention to it so we can print it for debugging purposes.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/x86/pci/acpi.c | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 9bf7aaa..6269545 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,27 +250,27 @@ 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)
+static struct list_head *
+get_current_resources(struct acpi_device *device, int busnum, int domain)
{
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 = kmalloc(sizeof(struct list_head), GFP_KERNEL);
+ if (!info.resources)
+ return NULL;
+
+ INIT_LIST_HEAD(info.resources);
acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource,
&info);
if (!info.res_num)
- return;
+ goto res_alloc_fail;
size = sizeof(*info.res) * info.res_num;
info.res = kmalloc(size, GFP_KERNEL);
@@ -286,12 +286,12 @@ get_current_resources(struct acpi_device *device, int busnum,
&info);
add_resources(&info);
- return;
+ return info.resources;
name_alloc_fail:
kfree(info.res);
res_alloc_fail:
- return;
+ return info.resources;
}
struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
@@ -299,6 +299,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 +354,21 @@ 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, NULL);
- if (bus) {
- get_current_resources(device, busnum, domain, bus);
+ resources = get_current_resources(device, busnum, domain);
+ if (!pci_use_crs) {
+ pci_free_resource_list(resources);
+ resources = NULL;
+ }
+
+ bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd,
+ resources);
+ if (bus)
bus->subordinate = pci_scan_child_bus(bus);
+ else {
+ if (resources)
+ pci_free_resource_list(resources);
}
+ kfree(resources);
}
/* After the PCI-E bus has been walked and all devices discovered,
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH 05/12] powerpc/pci: make pcibios_setup_phb_resources() static
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (3 preceding siblings ...)
2011-10-11 3:18 ` [PATCH 04/12] x86/PCI: " Bjorn Helgaas
@ 2011-10-11 3:18 ` Bjorn Helgaas
2011-10-11 3:18 ` [PATCH 06/12] powerpc/pci: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:18 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
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 2ede26a..1ba357cd 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 [flat|nested] 15+ messages in thread* [PATCH 06/12] powerpc/pci: split PHB part out of pcibios_map_io_space()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (4 preceding siblings ...)
2011-10-11 3:18 ` [PATCH 05/12] powerpc/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
@ 2011-10-11 3:18 ` Bjorn Helgaas
2011-10-11 3:19 ` [PATCH 07/12] powerpc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:18 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
No functional change. This is so we can use pcibios_phb_map_io_space()
before we have a struct pci_bus.
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 [flat|nested] 15+ messages in thread* [PATCH 07/12] powerpc/pci: supply root bus resources to pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (5 preceding siblings ...)
2011-10-11 3:18 ` [PATCH 06/12] powerpc/pci: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
@ 2011-10-11 3:19 ` Bjorn Helgaas
2011-10-11 3:19 ` [PATCH 08/12] microblaze/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:19 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
Pass root bus resources to pci_create_bus() so the bus resources are
correct from the beginning.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/powerpc/kernel/pci-common.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 1ba357cd..52bbe83 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,23 +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, NULL);
+ 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 [flat|nested] 15+ messages in thread* [PATCH 08/12] microblaze/pci: make pcibios_setup_phb_resources() static
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (6 preceding siblings ...)
2011-10-11 3:19 ` [PATCH 07/12] powerpc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
@ 2011-10-11 3:19 ` Bjorn Helgaas
2011-10-11 3:19 ` [PATCH 09/12] microblaze/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:19 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
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 9c35aa6..de71bd9 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1509,7 +1509,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 [flat|nested] 15+ messages in thread* [PATCH 09/12] microblaze/pci: supply root bus resources to pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (7 preceding siblings ...)
2011-10-11 3:19 ` [PATCH 08/12] microblaze/pci: make pcibios_setup_phb_resources() static Bjorn Helgaas
@ 2011-10-11 3:19 ` Bjorn Helgaas
2011-10-11 3:19 ` [PATCH 10/12] sparc/pci: " Bjorn Helgaas
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:19 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
Pass root bus resources to pci_create_bus() so the bus resources are
correct from the beginning.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/microblaze/pci/pci-common.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index de71bd9..a5a79ac 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1509,14 +1509,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"
@@ -1532,6 +1531,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) {
@@ -1549,12 +1549,12 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
res->flags = IORESOURCE_MEM;
}
- 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",
@@ -1572,6 +1572,7 @@ 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;
@@ -1580,25 +1581,26 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
pr_debug("PCI: Scanning PHB %s\n",
node ? node->full_name : "<NO NAME>");
+ /* 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;
+
+ 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, NULL);
+ 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 [flat|nested] 15+ messages in thread* [PATCH 10/12] sparc/pci: supply root bus resources to pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (8 preceding siblings ...)
2011-10-11 3:19 ` [PATCH 09/12] microblaze/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
@ 2011-10-11 3:19 ` Bjorn Helgaas
2011-10-11 3:33 ` David Miller
2011-10-11 3:19 ` [PATCH 11/12] sparc/pci: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
2011-10-11 3:19 ` [PATCH 12/12] sparc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
11 siblings, 1 reply; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:19 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
Pass root bus resources to pci_create_bus() so the bus resources are
correct from the beginning.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/sparc/kernel/pci.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 77c38bb..68013f9 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -684,24 +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);
+ INIT_LIST_HEAD(&resources);
+ pci_add_resource(&resources, &pbm->io_space);
+ pci_add_resource(&resources, &pbm->mem_space);
bus = pci_create_bus(parent, pbm->pci_first_busno,
- pbm->pci_ops, pbm, NULL);
+ 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);
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH 11/12] sparc/pci: use pci_create_bus() instead of pci_scan_bus_parented()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (9 preceding siblings ...)
2011-10-11 3:19 ` [PATCH 10/12] sparc/pci: " Bjorn Helgaas
@ 2011-10-11 3:19 ` Bjorn Helgaas
2011-10-11 3:19 ` [PATCH 12/12] sparc/pci: supply root bus resources to pci_create_bus() Bjorn Helgaas
11 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:19 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
Convert to pci_create_bus() so we can supply the correct root bus
resources up front.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/sparc/kernel/leon_pci.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index a8a9a27..a9cd28c 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -20,21 +20,24 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
{
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;
+ root_bus = pci_create_bus(&ofdev->dev, 0, info->ops, info, NULL);
+ if (!root_bus)
+ return;
- /* Init all PCI devices into PCI tree */
- pci_bus_add_devices(root_bus);
+ root_bus->subordinate = pci_scan_child_bus(root_bus);
- /* Setup IRQs of all devices using custom routines */
- pci_fixup_irqs(pci_common_swizzle, info->map_irq);
+ root_bus->resource[0] = &info->io_space;
+ root_bus->resource[1] = &info->mem_space;
+ root_bus->resource[2] = NULL;
- /* Assign devices with resources */
- pci_assign_unassigned_resources();
- }
+ /* Init all PCI devices into PCI tree */
+ pci_bus_add_devices(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();
}
/* PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH 12/12] sparc/pci: supply root bus resources to pci_create_bus()
2011-10-11 3:18 [RFC PATCH 00/12] Create PCI root buses with correct resources Bjorn Helgaas
` (10 preceding siblings ...)
2011-10-11 3:19 ` [PATCH 11/12] sparc/pci: use pci_create_bus() instead of pci_scan_bus_parented() Bjorn Helgaas
@ 2011-10-11 3:19 ` Bjorn Helgaas
2011-10-11 3:33 ` David Miller
11 siblings, 1 reply; 15+ messages in thread
From: Bjorn Helgaas @ 2011-10-11 3:19 UTC (permalink / raw)
To: linux-pci; +Cc: linux-kernel
Pass root bus resources to pci_create_bus() so the bus resources are
correct from the beginning.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
arch/sparc/kernel/leon_pci.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index a9cd28c..e2d3870 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -18,18 +18,19 @@
*/
void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
{
+ struct list_head resources;
struct pci_bus *root_bus;
+ INIT_LIST_HEAD(&resources);
+ pci_add_resource(&resources, &info->io_space);
+ pci_add_resource(&resources, &info->mem_space);
+
root_bus = pci_create_bus(&ofdev->dev, 0, info->ops, info, NULL);
if (!root_bus)
return;
root_bus->subordinate = pci_scan_child_bus(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);
^ permalink raw reply [flat|nested] 15+ messages in thread