aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-27 15:48:52 -0400
committerPaul Mackerras <paulus@samba.org>2008-11-05 17:31:52 -0500
commitfd6852c8fa060bd45c82a2593e18f933f6c6204f (patch)
treea0534b189bc6a791e93bce5894f892634aa4ab0c /arch/powerpc/kernel
parentb5ae5f911d221ad85090d6805ab9ab020f6e4703 (diff)
powerpc/pci: Fix various pseries PCI hotplug issues
The pseries PCI hotplug code has a number of issues, ranging from incorrect resource setup to crashes, depending on what is added, when, whether it contains a bridge, etc etc.... This fixes a whole bunch of these, while actually simplifying the code a bit, using more generic code in the process and factoring out common code between adding of a PHB, a slot or a device. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/pci-common.c41
-rw-r--r--arch/powerpc/kernel/rtas_pci.c48
2 files changed, 37 insertions, 52 deletions
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index f965397a6105..f3fd7eb90a7b 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -203,7 +203,7 @@ char __devinit *pcibios_setup(char *str)
203 return str; 203 return str;
204} 204}
205 205
206void __devinit pcibios_setup_new_device(struct pci_dev *dev) 206static void __devinit pcibios_setup_new_device(struct pci_dev *dev)
207{ 207{
208 struct dev_archdata *sd = &dev->dev.archdata; 208 struct dev_archdata *sd = &dev->dev.archdata;
209 209
@@ -221,7 +221,6 @@ void __devinit pcibios_setup_new_device(struct pci_dev *dev)
221 if (ppc_md.pci_dma_dev_setup) 221 if (ppc_md.pci_dma_dev_setup)
222 ppc_md.pci_dma_dev_setup(dev); 222 ppc_md.pci_dma_dev_setup(dev);
223} 223}
224EXPORT_SYMBOL(pcibios_setup_new_device);
225 224
226/* 225/*
227 * Reads the interrupt pin to determine if interrupt is use by card. 226 * Reads the interrupt pin to determine if interrupt is use by card.
@@ -1397,9 +1396,10 @@ void __init pcibios_resource_survey(void)
1397 1396
1398#ifdef CONFIG_HOTPLUG 1397#ifdef CONFIG_HOTPLUG
1399 1398
1400/* This is used by the pSeries hotplug driver to allocate resource 1399/* This is used by the PCI hotplug driver to allocate resource
1401 * of newly plugged busses. We can try to consolidate with the 1400 * of newly plugged busses. We can try to consolidate with the
1402 * rest of the code later, for now, keep it as-is 1401 * rest of the code later, for now, keep it as-is as our main
1402 * resource allocation function doesn't deal with sub-trees yet.
1403 */ 1403 */
1404void __devinit pcibios_claim_one_bus(struct pci_bus *bus) 1404void __devinit pcibios_claim_one_bus(struct pci_bus *bus)
1405{ 1405{
@@ -1414,6 +1414,14 @@ void __devinit pcibios_claim_one_bus(struct pci_bus *bus)
1414 1414
1415 if (r->parent || !r->start || !r->flags) 1415 if (r->parent || !r->start || !r->flags)
1416 continue; 1416 continue;
1417
1418 pr_debug("PCI: Claiming %s: "
1419 "Resource %d: %016llx..%016llx [%x]\n",
1420 pci_name(dev), i,
1421 (unsigned long long)r->start,
1422 (unsigned long long)r->end,
1423 (unsigned int)r->flags);
1424
1417 pci_claim_resource(dev, i); 1425 pci_claim_resource(dev, i);
1418 } 1426 }
1419 } 1427 }
@@ -1422,6 +1430,31 @@ void __devinit pcibios_claim_one_bus(struct pci_bus *bus)
1422 pcibios_claim_one_bus(child_bus); 1430 pcibios_claim_one_bus(child_bus);
1423} 1431}
1424EXPORT_SYMBOL_GPL(pcibios_claim_one_bus); 1432EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
1433
1434
1435/* pcibios_finish_adding_to_bus
1436 *
1437 * This is to be called by the hotplug code after devices have been
1438 * added to a bus, this include calling it for a PHB that is just
1439 * being added
1440 */
1441void pcibios_finish_adding_to_bus(struct pci_bus *bus)
1442{
1443 pr_debug("PCI: Finishing adding to hotplug bus %04x:%02x\n",
1444 pci_domain_nr(bus), bus->number);
1445
1446 /* Allocate bus and devices resources */
1447 pcibios_allocate_bus_resources(bus);
1448 pcibios_claim_one_bus(bus);
1449
1450 /* Add new devices to global lists. Register in proc, sysfs. */
1451 pci_bus_add_devices(bus);
1452
1453 /* Fixup EEH */
1454 eeh_add_device_tree_late(bus);
1455}
1456EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);
1457
1425#endif /* CONFIG_HOTPLUG */ 1458#endif /* CONFIG_HOTPLUG */
1426 1459
1427int pcibios_enable_device(struct pci_dev *dev, int mask) 1460int pcibios_enable_device(struct pci_dev *dev, int mask)
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 589a2797eac2..8869001ab5d7 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -301,51 +301,3 @@ void __init find_and_init_phbs(void)
301#endif /* CONFIG_PPC32 */ 301#endif /* CONFIG_PPC32 */
302 } 302 }
303} 303}
304
305/* RPA-specific bits for removing PHBs */
306int pcibios_remove_root_bus(struct pci_controller *phb)
307{
308 struct pci_bus *b = phb->bus;
309 struct resource *res;
310 int rc, i;
311
312 res = b->resource[0];
313 if (!res->flags) {
314 printk(KERN_ERR "%s: no IO resource for PHB %s\n", __func__,
315 b->name);
316 return 1;
317 }
318
319 rc = pcibios_unmap_io_space(b);
320 if (rc) {
321 printk(KERN_ERR "%s: failed to unmap IO on bus %s\n",
322 __func__, b->name);
323 return 1;
324 }
325
326 if (release_resource(res)) {
327 printk(KERN_ERR "%s: failed to release IO on bus %s\n",
328 __func__, b->name);
329 return 1;
330 }
331
332 for (i = 1; i < 3; ++i) {
333 res = b->resource[i];
334 if (!res->flags && i == 0) {
335 printk(KERN_ERR "%s: no MEM resource for PHB %s\n",
336 __func__, b->name);
337 return 1;
338 }
339 if (res->flags && release_resource(res)) {
340 printk(KERN_ERR
341 "%s: failed to release IO %d on bus %s\n",
342 __func__, i, b->name);
343 return 1;
344 }
345 }
346
347 pcibios_free_controller(phb);
348
349 return 0;
350}
351EXPORT_SYMBOL(pcibios_remove_root_bus);