2 From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 Signed-off-by: Olaf Hering <olh@suse.de>
7 arch/powerpc/include/asm/pci.h | 2
8 arch/powerpc/kernel/pci-common.c | 110 ++++++++++++++---------------
9 arch/powerpc/platforms/pseries/pci_dlpar.c | 2
10 3 files changed, 59 insertions(+), 55 deletions(-)
12 --- a/arch/powerpc/include/asm/pci.h
13 +++ b/arch/powerpc/include/asm/pci.h
14 @@ -196,6 +196,8 @@ extern void pcibios_setup_new_device(str
16 extern void pcibios_claim_one_bus(struct pci_bus *b);
18 +extern void pcibios_allocate_bus_resources(struct pci_bus *bus);
20 extern void pcibios_resource_survey(void);
22 extern struct pci_controller *init_phb_dynamic(struct device_node *dn);
23 --- a/arch/powerpc/kernel/pci-common.c
24 +++ b/arch/powerpc/kernel/pci-common.c
25 @@ -986,69 +986,66 @@ static int __init reparent_resources(str
29 -static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
30 +void pcibios_allocate_bus_resources(struct pci_bus *bus)
32 - struct pci_bus *bus;
35 struct resource *res, *pr;
37 - /* Depth-First Search on bus tree */
38 - list_for_each_entry(bus, bus_list, node) {
39 - for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
40 - if ((res = bus->resource[i]) == NULL || !res->flags
41 - || res->start > res->end)
43 - if (bus->parent == NULL)
44 - pr = (res->flags & IORESOURCE_IO) ?
45 - &ioport_resource : &iomem_resource;
47 - /* Don't bother with non-root busses when
48 - * re-assigning all resources. We clear the
49 - * resource flags as if they were colliding
50 - * and as such ensure proper re-allocation
52 + for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
53 + if ((res = bus->resource[i]) == NULL || !res->flags
54 + || res->start > res->end)
56 + if (bus->parent == NULL)
57 + pr = (res->flags & IORESOURCE_IO) ?
58 + &ioport_resource : &iomem_resource;
60 + /* Don't bother with non-root busses when
61 + * re-assigning all resources. We clear the
62 + * resource flags as if they were colliding
63 + * and as such ensure proper re-allocation
66 + if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)
67 + goto clear_resource;
68 + pr = pci_find_parent_resource(bus->self, res);
70 + /* this happens when the generic PCI
71 + * code (wrongly) decides that this
72 + * bridge is transparent -- paulus
74 - if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)
75 - goto clear_resource;
76 - pr = pci_find_parent_resource(bus->self, res);
78 - /* this happens when the generic PCI
79 - * code (wrongly) decides that this
80 - * bridge is transparent -- paulus
88 - DBG("PCI: %s (bus %d) bridge rsrc %d: %016llx-%016llx "
89 - "[0x%x], parent %p (%s)\n",
90 - bus->self ? pci_name(bus->self) : "PHB",
92 - (unsigned long long)res->start,
93 - (unsigned long long)res->end,
94 - (unsigned int)res->flags,
95 - pr, (pr && pr->name) ? pr->name : "nil");
97 - if (pr && !(pr->flags & IORESOURCE_UNSET)) {
98 - if (request_resource(pr, res) == 0)
101 - * Must be a conflict with an existing entry.
102 - * Move that entry (or entries) under the
103 - * bridge resource and try again.
105 - if (reparent_resources(pr, res) == 0)
108 - printk(KERN_WARNING
109 - "PCI: Cannot allocate resource region "
110 - "%d of PCI bridge %d, will remap\n",
114 + DBG("PCI: %s (bus %d) bridge rsrc %d: %016llx-%016llx "
115 + "[0x%x], parent %p (%s)\n",
116 + bus->self ? pci_name(bus->self) : "PHB",
118 + (unsigned long long)res->start,
119 + (unsigned long long)res->end,
120 + (unsigned int)res->flags,
121 + pr, (pr && pr->name) ? pr->name : "nil");
123 + if (pr && !(pr->flags & IORESOURCE_UNSET)) {
124 + if (request_resource(pr, res) == 0)
127 + * Must be a conflict with an existing entry.
128 + * Move that entry (or entries) under the
129 + * bridge resource and try again.
131 + if (reparent_resources(pr, res) == 0)
134 - pcibios_allocate_bus_resources(&bus->children);
135 + printk(KERN_WARNING "PCI: Cannot allocate resource region "
136 + "%d of PCI bridge %d, will remap\n", i, bus->number);
141 + list_for_each_entry(b, &bus->children, node)
142 + pcibios_allocate_bus_resources(b);
145 static inline void __devinit alloc_resource(struct pci_dev *dev, int idx)
146 @@ -1119,10 +1116,13 @@ static void __init pcibios_allocate_reso
148 void __init pcibios_resource_survey(void)
152 /* Allocate and assign resources. If we re-assign everything, then
153 * we skip the allocate phase
155 - pcibios_allocate_bus_resources(&pci_root_buses);
156 + list_for_each_entry(b, &pci_root_buses, node)
157 + pcibios_allocate_bus_resources(b);
159 if (!(ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)) {
160 pcibios_allocate_resources(0);
161 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c
162 +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
163 @@ -189,6 +189,7 @@ struct pci_controller * __devinit init_p
165 struct pci_controller *phb;
169 primary = list_empty(&hose_list);
170 phb = pcibios_alloc_controller(dn);
171 @@ -203,6 +204,7 @@ struct pci_controller * __devinit init_p
172 eeh_add_device_tree_early(dn);
175 + pcibios_allocate_bus_resources(phb->bus);
176 pcibios_fixup_new_pci_devices(phb->bus);
177 pci_bus_add_devices(phb->bus);
178 eeh_add_device_tree_late(phb->bus);