diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-06-13 19:04:30 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-06-13 19:04:30 -0400 |
commit | 4d17e8516a0b24240cd3f5d024b2ca10cb0b5208 (patch) | |
tree | 0b9f48d5f107dfe289f66d3f83484cae326904d8 | |
parent | cfaf025112d3856637ff34a767ef785ef5cf2ca9 (diff) | |
parent | 06aef8cec7563c40c7d7501d13ec1ed12f5e495b (diff) |
Merge branch 'topic/yinghai-busn-alloc' into next
* topic/yinghai-busn-alloc: (33 commits)
PCI: hotplug: remove pci_do_scan_bus()
PCI: sgihp: use generic pci_hp_add_bridge()
PCI: ibmhp: use generic pci_hp_add_bridge()
PCI: cpqhp: use generic pci_hp_add_bridge()
PCI: shpchp: use generic pci_hp_add_bridge()
PCI: cpci_hotplug: use generic pci_hp_add_bridge()
PCI: pciehp: use generic pci_hp_add_bridge()
PCI: add generic pci_hp_add_bridge()
PCI: sgihp: register busn_res
PCI: ibmhp: register busn_res
PCI: cpqhp: register busn_res
PCI: shpchp: register busn_res
PCI: cpci_hotplug: register busn_res
PCI: insert busn_res for child bus
PCI: register busn_res for iov bus
tile/PCI: use pci_scan_root_bus instead pci_scan_bus
parisc/PCI: register busn_res for root buses
powerpc/PCI: register busn_res for root buses
sparc/PCI: register busn_res for root buses
ia64/PCI: register busn_res for root buses
...
44 files changed, 367 insertions, 245 deletions
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 1a629636cc16..53229a496311 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c | |||
@@ -359,7 +359,7 @@ common_init_pci(void) | |||
359 | hose, &resources); | 359 | hose, &resources); |
360 | hose->bus = bus; | 360 | hose->bus = bus; |
361 | hose->need_domain_info = need_domain_info; | 361 | hose->need_domain_info = need_domain_info; |
362 | next_busno = bus->subordinate + 1; | 362 | next_busno = bus->busn_res.end + 1; |
363 | /* Don't allow 8-bit bus number overflow inside the hose - | 363 | /* Don't allow 8-bit bus number overflow inside the hose - |
364 | reserve some space for bridges. */ | 364 | reserve some space for bridges. */ |
365 | if (next_busno > 224) { | 365 | if (next_busno > 224) { |
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 25552508c3fd..f07710849b58 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c | |||
@@ -461,7 +461,7 @@ static void __init pcibios_init_hw(struct hw_pci *hw, struct list_head *head) | |||
461 | if (!sys->bus) | 461 | if (!sys->bus) |
462 | panic("PCI: unable to scan bus!"); | 462 | panic("PCI: unable to scan bus!"); |
463 | 463 | ||
464 | busnr = sys->bus->subordinate + 1; | 464 | busnr = sys->bus->busn_res.end + 1; |
465 | 465 | ||
466 | list_add(&sys->node, head); | 466 | list_add(&sys->node, head); |
467 | } else { | 467 | } else { |
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 524df4295c90..d173a88d744a 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -351,6 +351,8 @@ pci_acpi_scan_root(struct acpi_pci_root *root) | |||
351 | #endif | 351 | #endif |
352 | 352 | ||
353 | INIT_LIST_HEAD(&info.resources); | 353 | INIT_LIST_HEAD(&info.resources); |
354 | /* insert busn resource at first */ | ||
355 | pci_add_resource(&info.resources, &root->secondary); | ||
354 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, | 356 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, |
355 | &windows); | 357 | &windows); |
356 | if (windows) { | 358 | if (windows) { |
@@ -384,7 +386,7 @@ pci_acpi_scan_root(struct acpi_pci_root *root) | |||
384 | return NULL; | 386 | return NULL; |
385 | } | 387 | } |
386 | 388 | ||
387 | pbus->subordinate = pci_scan_child_bus(pbus); | 389 | pci_scan_child_bus(pbus); |
388 | return pbus; | 390 | return pbus; |
389 | 391 | ||
390 | out3: | 392 | out3: |
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index ed22bfc5db14..9b32483cd0c0 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c | |||
@@ -1506,10 +1506,10 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose) | |||
1506 | pci_free_resource_list(&resources); | 1506 | pci_free_resource_list(&resources); |
1507 | return; | 1507 | return; |
1508 | } | 1508 | } |
1509 | bus->secondary = hose->first_busno; | 1509 | bus->busn_res.start = hose->first_busno; |
1510 | hose->bus = bus; | 1510 | hose->bus = bus; |
1511 | 1511 | ||
1512 | hose->last_busno = bus->subordinate; | 1512 | hose->last_busno = bus->busn_res.end; |
1513 | } | 1513 | } |
1514 | 1514 | ||
1515 | static int __init pcibios_init(void) | 1515 | static int __init pcibios_init(void) |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 271e8c4a54c7..0a9bf778edb5 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -102,7 +102,7 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose) | |||
102 | need_domain_info = need_domain_info || hose->index; | 102 | need_domain_info = need_domain_info || hose->index; |
103 | hose->need_domain_info = need_domain_info; | 103 | hose->need_domain_info = need_domain_info; |
104 | if (bus) { | 104 | if (bus) { |
105 | next_busno = bus->subordinate + 1; | 105 | next_busno = bus->busn_res.end + 1; |
106 | /* Don't allow 8-bit bus number overflow inside the hose - | 106 | /* Don't allow 8-bit bus number overflow inside the hose - |
107 | reserve some space for bridges. */ | 107 | reserve some space for bridges. */ |
108 | if (next_busno > 224) { | 108 | if (next_busno > 224) { |
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index ac39e6a3b25a..8cccbee61519 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h | |||
@@ -30,6 +30,7 @@ struct pci_controller { | |||
30 | int first_busno; | 30 | int first_busno; |
31 | int last_busno; | 31 | int last_busno; |
32 | int self_busno; | 32 | int self_busno; |
33 | struct resource busn; | ||
33 | 34 | ||
34 | void __iomem *io_base_virt; | 35 | void __iomem *io_base_virt; |
35 | #ifdef CONFIG_PPC64 | 36 | #ifdef CONFIG_PPC64 |
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 8e78e93c8185..7320f3685523 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -1637,6 +1637,11 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose) | |||
1637 | /* Wire up PHB bus resources */ | 1637 | /* Wire up PHB bus resources */ |
1638 | pcibios_setup_phb_resources(hose, &resources); | 1638 | pcibios_setup_phb_resources(hose, &resources); |
1639 | 1639 | ||
1640 | hose->busn.start = hose->first_busno; | ||
1641 | hose->busn.end = hose->last_busno; | ||
1642 | hose->busn.flags = IORESOURCE_BUS; | ||
1643 | pci_add_resource(&resources, &hose->busn); | ||
1644 | |||
1640 | /* Create an empty bus for the toplevel */ | 1645 | /* Create an empty bus for the toplevel */ |
1641 | bus = pci_create_root_bus(hose->parent, hose->first_busno, | 1646 | bus = pci_create_root_bus(hose->parent, hose->first_busno, |
1642 | hose->ops, hose, &resources); | 1647 | hose->ops, hose, &resources); |
@@ -1646,7 +1651,6 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose) | |||
1646 | pci_free_resource_list(&resources); | 1651 | pci_free_resource_list(&resources); |
1647 | return; | 1652 | return; |
1648 | } | 1653 | } |
1649 | bus->secondary = hose->first_busno; | ||
1650 | hose->bus = bus; | 1654 | hose->bus = bus; |
1651 | 1655 | ||
1652 | /* Get probe mode and perform scan */ | 1656 | /* Get probe mode and perform scan */ |
@@ -1654,13 +1658,14 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose) | |||
1654 | if (node && ppc_md.pci_probe_mode) | 1658 | if (node && ppc_md.pci_probe_mode) |
1655 | mode = ppc_md.pci_probe_mode(bus); | 1659 | mode = ppc_md.pci_probe_mode(bus); |
1656 | pr_debug(" probe mode: %d\n", mode); | 1660 | pr_debug(" probe mode: %d\n", mode); |
1657 | if (mode == PCI_PROBE_DEVTREE) { | 1661 | if (mode == PCI_PROBE_DEVTREE) |
1658 | bus->subordinate = hose->last_busno; | ||
1659 | of_scan_bus(node, bus); | 1662 | of_scan_bus(node, bus); |
1660 | } | ||
1661 | 1663 | ||
1662 | if (mode == PCI_PROBE_NORMAL) | 1664 | if (mode == PCI_PROBE_NORMAL) { |
1663 | hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); | 1665 | pci_bus_update_busn_res_end(bus, 255); |
1666 | hose->last_busno = pci_scan_child_bus(bus); | ||
1667 | pci_bus_update_busn_res_end(bus, hose->last_busno); | ||
1668 | } | ||
1664 | 1669 | ||
1665 | /* Platform gets a chance to do some global fixups before | 1670 | /* Platform gets a chance to do some global fixups before |
1666 | * we proceed to resource allocation | 1671 | * we proceed to resource allocation |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 94a54f61d341..4ff190ff24a0 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -236,7 +236,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, | |||
236 | 236 | ||
237 | for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { | 237 | for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { |
238 | bus = pci_bus_b(ln); | 238 | bus = pci_bus_b(ln); |
239 | if (in_bus >= bus->number && in_bus <= bus->subordinate) | 239 | if (in_bus >= bus->number && in_bus <= bus->busn_res.end) |
240 | break; | 240 | break; |
241 | bus = NULL; | 241 | bus = NULL; |
242 | } | 242 | } |
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 89dde171a6fa..ae5ea5e04d65 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c | |||
@@ -240,7 +240,7 @@ void __devinit of_scan_pci_bridge(struct pci_dev *dev) | |||
240 | } | 240 | } |
241 | 241 | ||
242 | bus->primary = dev->bus->number; | 242 | bus->primary = dev->bus->number; |
243 | bus->subordinate = busrange[1]; | 243 | pci_bus_insert_busn_res(bus, busrange[0], busrange[1]); |
244 | bus->bridge_ctl = 0; | 244 | bus->bridge_ctl = 0; |
245 | 245 | ||
246 | /* parse ranges property */ | 246 | /* parse ranges property */ |
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index fbdd74dac3ac..9cda6a1ad0cf 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c | |||
@@ -589,7 +589,7 @@ static int __devinit pnv_ioda_configure_pe(struct pnv_phb *phb, | |||
589 | dcomp = OPAL_IGNORE_RID_DEVICE_NUMBER; | 589 | dcomp = OPAL_IGNORE_RID_DEVICE_NUMBER; |
590 | fcomp = OPAL_IGNORE_RID_FUNCTION_NUMBER; | 590 | fcomp = OPAL_IGNORE_RID_FUNCTION_NUMBER; |
591 | parent = pe->pbus->self; | 591 | parent = pe->pbus->self; |
592 | count = pe->pbus->subordinate - pe->pbus->secondary + 1; | 592 | count = pe->pbus->busn_res.end - pe->pbus->busn_res.start + 1; |
593 | switch(count) { | 593 | switch(count) { |
594 | case 1: bcomp = OpalPciBusAll; break; | 594 | case 1: bcomp = OpalPciBusAll; break; |
595 | case 2: bcomp = OpalPciBus7Bits; break; | 595 | case 2: bcomp = OpalPciBus7Bits; break; |
@@ -816,11 +816,11 @@ static void __devinit pnv_ioda_setup_bus_PE(struct pci_dev *dev, | |||
816 | pe->pdev = NULL; | 816 | pe->pdev = NULL; |
817 | pe->tce32_seg = -1; | 817 | pe->tce32_seg = -1; |
818 | pe->mve_number = -1; | 818 | pe->mve_number = -1; |
819 | pe->rid = bus->secondary << 8; | 819 | pe->rid = bus->busn_res.start << 8; |
820 | pe->dma_weight = 0; | 820 | pe->dma_weight = 0; |
821 | 821 | ||
822 | pe_info(pe, "Secondary busses %d..%d associated with PE\n", | 822 | pe_info(pe, "Secondary busses %pR associated with PE\n", |
823 | bus->secondary, bus->subordinate); | 823 | &bus->busn_res); |
824 | 824 | ||
825 | if (pnv_ioda_configure_pe(phb, pe)) { | 825 | if (pnv_ioda_configure_pe(phb, pe)) { |
826 | /* XXX What do we do here ? */ | 826 | /* XXX What do we do here ? */ |
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c index 8b7bafa489c2..3ccebc83dc02 100644 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c | |||
@@ -121,7 +121,7 @@ void pcibios_add_pci_devices(struct pci_bus * bus) | |||
121 | if (!num) | 121 | if (!num) |
122 | return; | 122 | return; |
123 | pcibios_setup_bus_devices(bus); | 123 | pcibios_setup_bus_devices(bus); |
124 | max = bus->secondary; | 124 | max = bus->busn_res.start; |
125 | for (pass=0; pass < 2; pass++) | 125 | for (pass=0; pass < 2; pass++) |
126 | list_for_each_entry(dev, &bus->devices, bus_list) { | 126 | list_for_each_entry(dev, &bus->devices, bus_list) { |
127 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 127 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index 9d10a3cb8797..43068dcb451c 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c | |||
@@ -59,7 +59,7 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose) | |||
59 | need_domain_info = need_domain_info || hose->index; | 59 | need_domain_info = need_domain_info || hose->index; |
60 | hose->need_domain_info = need_domain_info; | 60 | hose->need_domain_info = need_domain_info; |
61 | if (bus) { | 61 | if (bus) { |
62 | next_busno = bus->subordinate + 1; | 62 | next_busno = bus->busn_res.end + 1; |
63 | /* Don't allow 8-bit bus number overflow inside the hose - | 63 | /* Don't allow 8-bit bus number overflow inside the hose - |
64 | reserve some space for bridges. */ | 64 | reserve some space for bridges. */ |
65 | if (next_busno > 224) { | 65 | if (next_busno > 224) { |
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index fdaf21811670..4f92a9aba358 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -535,7 +535,7 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm, | |||
535 | } | 535 | } |
536 | 536 | ||
537 | bus->primary = dev->bus->number; | 537 | bus->primary = dev->bus->number; |
538 | bus->subordinate = busrange[1]; | 538 | pci_bus_insert_busn_res(bus, busrange[0], busrange[1]); |
539 | bus->bridge_ctl = 0; | 539 | bus->bridge_ctl = 0; |
540 | 540 | ||
541 | /* parse ranges property, or cook one up by hand for Simba */ | 541 | /* parse ranges property, or cook one up by hand for Simba */ |
@@ -685,6 +685,10 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm, | |||
685 | pbm->io_space.start); | 685 | pbm->io_space.start); |
686 | pci_add_resource_offset(&resources, &pbm->mem_space, | 686 | pci_add_resource_offset(&resources, &pbm->mem_space, |
687 | pbm->mem_space.start); | 687 | pbm->mem_space.start); |
688 | pbm->busn.start = pbm->pci_first_busno; | ||
689 | pbm->busn.end = pbm->pci_last_busno; | ||
690 | pbm->busn.flags = IORESOURCE_BUS; | ||
691 | pci_add_resource(&resources, &pbm->busn); | ||
688 | bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, | 692 | bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, |
689 | pbm, &resources); | 693 | pbm, &resources); |
690 | if (!bus) { | 694 | if (!bus) { |
@@ -693,8 +697,6 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm, | |||
693 | pci_free_resource_list(&resources); | 697 | pci_free_resource_list(&resources); |
694 | return NULL; | 698 | return NULL; |
695 | } | 699 | } |
696 | bus->secondary = pbm->pci_first_busno; | ||
697 | bus->subordinate = pbm->pci_last_busno; | ||
698 | 700 | ||
699 | pci_of_scan_bus(pbm, node, bus); | 701 | pci_of_scan_bus(pbm, node, bus); |
700 | pci_bus_add_devices(bus); | 702 | pci_bus_add_devices(bus); |
diff --git a/arch/sparc/kernel/pci_impl.h b/arch/sparc/kernel/pci_impl.h index 6beb60df31d0..918a2031c8bb 100644 --- a/arch/sparc/kernel/pci_impl.h +++ b/arch/sparc/kernel/pci_impl.h | |||
@@ -97,6 +97,7 @@ struct pci_pbm_info { | |||
97 | /* PBM I/O and Memory space resources. */ | 97 | /* PBM I/O and Memory space resources. */ |
98 | struct resource io_space; | 98 | struct resource io_space; |
99 | struct resource mem_space; | 99 | struct resource mem_space; |
100 | struct resource busn; | ||
100 | 101 | ||
101 | /* Base of PCI Config space, can be per-PBM or shared. */ | 102 | /* Base of PCI Config space, can be per-PBM or shared. */ |
102 | unsigned long config_space; | 103 | unsigned long config_space; |
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c index b56d12bf5900..87422ed7b834 100644 --- a/arch/tile/kernel/pci.c +++ b/arch/tile/kernel/pci.c | |||
@@ -310,6 +310,7 @@ int __init pcibios_init(void) | |||
310 | if (pci_scan_flags[i] == 0 && controllers[i].ops != NULL) { | 310 | if (pci_scan_flags[i] == 0 && controllers[i].ops != NULL) { |
311 | struct pci_controller *controller = &controllers[i]; | 311 | struct pci_controller *controller = &controllers[i]; |
312 | struct pci_bus *bus; | 312 | struct pci_bus *bus; |
313 | LIST_HEAD(resources); | ||
313 | 314 | ||
314 | if (tile_init_irqs(i, controller)) { | 315 | if (tile_init_irqs(i, controller)) { |
315 | pr_err("PCI: Could not initialize IRQs\n"); | 316 | pr_err("PCI: Could not initialize IRQs\n"); |
@@ -327,9 +328,11 @@ int __init pcibios_init(void) | |||
327 | * This is inlined in linux/pci.h and calls into | 328 | * This is inlined in linux/pci.h and calls into |
328 | * pci_scan_bus_parented() in probe.c. | 329 | * pci_scan_bus_parented() in probe.c. |
329 | */ | 330 | */ |
330 | bus = pci_scan_bus(0, controller->ops, controller); | 331 | pci_add_resource(&resources, &ioport_resource); |
332 | pci_add_resource(&resources, &iomem_resource); | ||
333 | bus = pci_scan_root_bus(NULL, 0, controller->ops, controller, &resources); | ||
331 | controller->root_bus = bus; | 334 | controller->root_bus = bus; |
332 | controller->last_busno = bus->subordinate; | 335 | controller->last_busno = bus->busn_res.end; |
333 | } | 336 | } |
334 | } | 337 | } |
335 | 338 | ||
@@ -366,7 +369,7 @@ int __init pcibios_init(void) | |||
366 | */ | 369 | */ |
367 | if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && | 370 | if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && |
368 | (PCI_SLOT(dev->devfn) == 0)) { | 371 | (PCI_SLOT(dev->devfn) == 0)) { |
369 | next_bus = dev->subordinate; | 372 | next_bus = dev->busn_res.end; |
370 | controllers[i].mem_resources[0] = | 373 | controllers[i].mem_resources[0] = |
371 | *next_bus->resource[0]; | 374 | *next_bus->resource[0]; |
372 | controllers[i].mem_resources[1] = | 375 | controllers[i].mem_resources[1] = |
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index fc09c2754e08..2bb885afe103 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -12,7 +12,6 @@ struct pci_root_info { | |||
12 | char name[16]; | 12 | char name[16]; |
13 | unsigned int res_num; | 13 | unsigned int res_num; |
14 | struct resource *res; | 14 | struct resource *res; |
15 | int busnum; | ||
16 | struct pci_sysdata sd; | 15 | struct pci_sysdata sd; |
17 | }; | 16 | }; |
18 | 17 | ||
@@ -347,7 +346,9 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device, | |||
347 | { | 346 | { |
348 | size_t size; | 347 | size_t size; |
349 | 348 | ||
349 | sprintf(info->name, "PCI Bus %04x:%02x", domain, busnum); | ||
350 | info->bridge = device; | 350 | info->bridge = device; |
351 | |||
351 | info->res_num = 0; | 352 | info->res_num = 0; |
352 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, | 353 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, |
353 | info); | 354 | info); |
@@ -360,8 +361,6 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device, | |||
360 | if (!info->res) | 361 | if (!info->res) |
361 | return; | 362 | return; |
362 | 363 | ||
363 | sprintf(info->name, "PCI Bus %04x:%02x", domain, busnum); | ||
364 | |||
365 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, | 364 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, |
366 | info); | 365 | info); |
367 | } | 366 | } |
@@ -426,6 +425,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
426 | } else { | 425 | } else { |
427 | probe_pci_root_info(info, device, busnum, domain); | 426 | probe_pci_root_info(info, device, busnum, domain); |
428 | 427 | ||
428 | /* insert busn res at first */ | ||
429 | pci_add_resource(&resources, &root->secondary); | ||
429 | /* | 430 | /* |
430 | * _CRS with no apertures is normal, so only fall back to | 431 | * _CRS with no apertures is normal, so only fall back to |
431 | * defaults or native bridge info if we're ignoring _CRS. | 432 | * defaults or native bridge info if we're ignoring _CRS. |
@@ -440,7 +441,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
440 | bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, | 441 | bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, |
441 | &resources); | 442 | &resources); |
442 | if (bus) { | 443 | if (bus) { |
443 | bus->subordinate = pci_scan_child_bus(bus); | 444 | pci_scan_child_bus(bus); |
444 | pci_set_host_bridge_release( | 445 | pci_set_host_bridge_release( |
445 | to_pci_host_bridge(bus->bridge), | 446 | to_pci_host_bridge(bus->bridge), |
446 | release_pci_root_info, info); | 447 | release_pci_root_info, info); |
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c index 5aed49bff058..e9e6ed5cdf94 100644 --- a/arch/x86/pci/amd_bus.c +++ b/arch/x86/pci/amd_bus.c | |||
@@ -121,7 +121,6 @@ static int __init early_fill_mp_bus_info(void) | |||
121 | link = (reg >> 8) & 0x03; | 121 | link = (reg >> 8) & 0x03; |
122 | 122 | ||
123 | info = alloc_pci_root_info(min_bus, max_bus, node, link); | 123 | info = alloc_pci_root_info(min_bus, max_bus, node, link); |
124 | sprintf(info->name, "PCI Bus #%02x", min_bus); | ||
125 | } | 124 | } |
126 | 125 | ||
127 | /* get the default node and link for left over res */ | 126 | /* get the default node and link for left over res */ |
@@ -300,9 +299,9 @@ static int __init early_fill_mp_bus_info(void) | |||
300 | int busnum; | 299 | int busnum; |
301 | struct pci_root_res *root_res; | 300 | struct pci_root_res *root_res; |
302 | 301 | ||
303 | busnum = info->bus_min; | 302 | busnum = info->busn.start; |
304 | printk(KERN_DEBUG "bus: [%02x, %02x] on node %x link %x\n", | 303 | printk(KERN_DEBUG "bus: %pR on node %x link %x\n", |
305 | info->bus_min, info->bus_max, info->node, info->link); | 304 | &info->busn, info->node, info->link); |
306 | list_for_each_entry(root_res, &info->resources, list) | 305 | list_for_each_entry(root_res, &info->resources, list) |
307 | printk(KERN_DEBUG "bus: %02x %pR\n", | 306 | printk(KERN_DEBUG "bus: %02x %pR\n", |
308 | busnum, &root_res->res); | 307 | busnum, &root_res->res); |
diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c index 306579f7d0fd..d37e2fec97e5 100644 --- a/arch/x86/pci/bus_numa.c +++ b/arch/x86/pci/bus_numa.c | |||
@@ -14,7 +14,7 @@ static struct pci_root_info *x86_find_pci_root_info(int bus) | |||
14 | return NULL; | 14 | return NULL; |
15 | 15 | ||
16 | list_for_each_entry(info, &pci_root_infos, list) | 16 | list_for_each_entry(info, &pci_root_infos, list) |
17 | if (info->bus_min == bus) | 17 | if (info->busn.start == bus) |
18 | return info; | 18 | return info; |
19 | 19 | ||
20 | return NULL; | 20 | return NULL; |
@@ -24,6 +24,8 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources) | |||
24 | { | 24 | { |
25 | struct pci_root_info *info = x86_find_pci_root_info(bus); | 25 | struct pci_root_info *info = x86_find_pci_root_info(bus); |
26 | struct pci_root_res *root_res; | 26 | struct pci_root_res *root_res; |
27 | struct pci_host_bridge_window *window; | ||
28 | bool found = false; | ||
27 | 29 | ||
28 | if (!info) | 30 | if (!info) |
29 | goto default_resources; | 31 | goto default_resources; |
@@ -31,6 +33,16 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources) | |||
31 | printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n", | 33 | printk(KERN_DEBUG "PCI: root bus %02x: hardware-probed resources\n", |
32 | bus); | 34 | bus); |
33 | 35 | ||
36 | /* already added by acpi ? */ | ||
37 | list_for_each_entry(window, resources, list) | ||
38 | if (window->res->flags & IORESOURCE_BUS) { | ||
39 | found = true; | ||
40 | break; | ||
41 | } | ||
42 | |||
43 | if (!found) | ||
44 | pci_add_resource(resources, &info->busn); | ||
45 | |||
34 | list_for_each_entry(root_res, &info->resources, list) { | 46 | list_for_each_entry(root_res, &info->resources, list) { |
35 | struct resource *res; | 47 | struct resource *res; |
36 | struct resource *root; | 48 | struct resource *root; |
@@ -66,9 +78,13 @@ struct pci_root_info __init *alloc_pci_root_info(int bus_min, int bus_max, | |||
66 | if (!info) | 78 | if (!info) |
67 | return info; | 79 | return info; |
68 | 80 | ||
81 | sprintf(info->name, "PCI Bus #%02x", bus_min); | ||
82 | |||
69 | INIT_LIST_HEAD(&info->resources); | 83 | INIT_LIST_HEAD(&info->resources); |
70 | info->bus_min = bus_min; | 84 | info->busn.name = info->name; |
71 | info->bus_max = bus_max; | 85 | info->busn.start = bus_min; |
86 | info->busn.end = bus_max; | ||
87 | info->busn.flags = IORESOURCE_BUS; | ||
72 | info->node = node; | 88 | info->node = node; |
73 | info->link = link; | 89 | info->link = link; |
74 | 90 | ||
diff --git a/arch/x86/pci/bus_numa.h b/arch/x86/pci/bus_numa.h index 226a466b2b2b..ff8f65b04574 100644 --- a/arch/x86/pci/bus_numa.h +++ b/arch/x86/pci/bus_numa.h | |||
@@ -13,8 +13,7 @@ struct pci_root_info { | |||
13 | struct list_head list; | 13 | struct list_head list; |
14 | char name[12]; | 14 | char name[12]; |
15 | struct list_head resources; | 15 | struct list_head resources; |
16 | int bus_min; | 16 | struct resource busn; |
17 | int bus_max; | ||
18 | int node; | 17 | int node; |
19 | int link; | 18 | int link; |
20 | }; | 19 | }; |
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index eb30e356f5be..9c57c1e6870c 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c | |||
@@ -187,7 +187,7 @@ static int __init pcibios_init(void) | |||
187 | bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno, | 187 | bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno, |
188 | pci_ctrl->ops, pci_ctrl, &resources); | 188 | pci_ctrl->ops, pci_ctrl, &resources); |
189 | pci_ctrl->bus = bus; | 189 | pci_ctrl->bus = bus; |
190 | pci_ctrl->last_busno = bus->subordinate; | 190 | pci_ctrl->last_busno = bus->busn_res.end; |
191 | if (next_busno <= pci_ctrl->last_busno) | 191 | if (next_busno <= pci_ctrl->last_busno) |
192 | next_busno = pci_ctrl->last_busno+1; | 192 | next_busno = pci_ctrl->last_busno+1; |
193 | } | 193 | } |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b12af2ff8c54..2fb7d1598a68 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -661,7 +661,7 @@ static struct intel_iommu *device_to_iommu(int segment, u8 bus, u8 devfn) | |||
661 | if (drhd->devices[i] && | 661 | if (drhd->devices[i] && |
662 | drhd->devices[i]->subordinate && | 662 | drhd->devices[i]->subordinate && |
663 | drhd->devices[i]->subordinate->number <= bus && | 663 | drhd->devices[i]->subordinate->number <= bus && |
664 | drhd->devices[i]->subordinate->subordinate >= bus) | 664 | drhd->devices[i]->subordinate->busn_res.end >= bus) |
665 | return drhd->iommu; | 665 | return drhd->iommu; |
666 | } | 666 | } |
667 | 667 | ||
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index edeeb516807a..09fa3c687a1f 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -14168,7 +14168,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
14168 | if (bridge->subordinate && | 14168 | if (bridge->subordinate && |
14169 | (bridge->subordinate->number <= | 14169 | (bridge->subordinate->number <= |
14170 | tp->pdev->bus->number) && | 14170 | tp->pdev->bus->number) && |
14171 | (bridge->subordinate->subordinate >= | 14171 | (bridge->subordinate->busn_res.end >= |
14172 | tp->pdev->bus->number)) { | 14172 | tp->pdev->bus->number)) { |
14173 | tg3_flag_set(tp, 5701_DMA_BUG); | 14173 | tg3_flag_set(tp, 5701_DMA_BUG); |
14174 | pci_dev_put(bridge); | 14174 | pci_dev_put(bridge); |
@@ -14196,7 +14196,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
14196 | if (bridge && bridge->subordinate && | 14196 | if (bridge && bridge->subordinate && |
14197 | (bridge->subordinate->number <= | 14197 | (bridge->subordinate->number <= |
14198 | tp->pdev->bus->number) && | 14198 | tp->pdev->bus->number) && |
14199 | (bridge->subordinate->subordinate >= | 14199 | (bridge->subordinate->busn_res.end >= |
14200 | tp->pdev->bus->number)) { | 14200 | tp->pdev->bus->number)) { |
14201 | tg3_flag_set(tp, 40BIT_DMA_BUG); | 14201 | tg3_flag_set(tp, 40BIT_DMA_BUG); |
14202 | pci_dev_put(bridge); | 14202 | pci_dev_put(bridge); |
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 432d4bbcc62a..ffddc4f64268 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c | |||
@@ -174,7 +174,7 @@ static int dino_cfg_read(struct pci_bus *bus, unsigned int devfn, int where, | |||
174 | int size, u32 *val) | 174 | int size, u32 *val) |
175 | { | 175 | { |
176 | struct dino_device *d = DINO_DEV(parisc_walk_tree(bus->bridge)); | 176 | struct dino_device *d = DINO_DEV(parisc_walk_tree(bus->bridge)); |
177 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary; | 177 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->busn_res.start; |
178 | u32 v = DINO_CFG_TOK(local_bus, devfn, where & ~3); | 178 | u32 v = DINO_CFG_TOK(local_bus, devfn, where & ~3); |
179 | void __iomem *base_addr = d->hba.base_addr; | 179 | void __iomem *base_addr = d->hba.base_addr; |
180 | unsigned long flags; | 180 | unsigned long flags; |
@@ -209,7 +209,7 @@ static int dino_cfg_write(struct pci_bus *bus, unsigned int devfn, int where, | |||
209 | int size, u32 val) | 209 | int size, u32 val) |
210 | { | 210 | { |
211 | struct dino_device *d = DINO_DEV(parisc_walk_tree(bus->bridge)); | 211 | struct dino_device *d = DINO_DEV(parisc_walk_tree(bus->bridge)); |
212 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary; | 212 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->busn_res.start; |
213 | u32 v = DINO_CFG_TOK(local_bus, devfn, where & ~3); | 213 | u32 v = DINO_CFG_TOK(local_bus, devfn, where & ~3); |
214 | void __iomem *base_addr = d->hba.base_addr; | 214 | void __iomem *base_addr = d->hba.base_addr; |
215 | unsigned long flags; | 215 | unsigned long flags; |
@@ -554,7 +554,7 @@ dino_fixup_bus(struct pci_bus *bus) | |||
554 | struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge)); | 554 | struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge)); |
555 | 555 | ||
556 | DBG(KERN_WARNING "%s(0x%p) bus %d platform_data 0x%p\n", | 556 | DBG(KERN_WARNING "%s(0x%p) bus %d platform_data 0x%p\n", |
557 | __func__, bus, bus->secondary, | 557 | __func__, bus, bus->busn_res.start, |
558 | bus->bridge->platform_data); | 558 | bus->bridge->platform_data); |
559 | 559 | ||
560 | /* Firmware doesn't set up card-mode dino, so we have to */ | 560 | /* Firmware doesn't set up card-mode dino, so we have to */ |
@@ -898,6 +898,7 @@ static int __init dino_probe(struct parisc_device *dev) | |||
898 | LIST_HEAD(resources); | 898 | LIST_HEAD(resources); |
899 | struct pci_bus *bus; | 899 | struct pci_bus *bus; |
900 | unsigned long hpa = dev->hpa.start; | 900 | unsigned long hpa = dev->hpa.start; |
901 | int max; | ||
901 | 902 | ||
902 | name = "Dino"; | 903 | name = "Dino"; |
903 | if (is_card_dino(&dev->id)) { | 904 | if (is_card_dino(&dev->id)) { |
@@ -983,6 +984,10 @@ static int __init dino_probe(struct parisc_device *dev) | |||
983 | if (dino_dev->hba.gmmio_space.flags) | 984 | if (dino_dev->hba.gmmio_space.flags) |
984 | pci_add_resource(&resources, &dino_dev->hba.gmmio_space); | 985 | pci_add_resource(&resources, &dino_dev->hba.gmmio_space); |
985 | 986 | ||
987 | dino_dev->hba.bus_num.start = dino_current_bus; | ||
988 | dino_dev->hba.bus_num.end = 255; | ||
989 | dino_dev->hba.bus_num.flags = IORESOURCE_BUS; | ||
990 | pci_add_resource(&resources, &dino_dev->hba.bus_num); | ||
986 | /* | 991 | /* |
987 | ** It's not used to avoid chicken/egg problems | 992 | ** It's not used to avoid chicken/egg problems |
988 | ** with configuration accessor functions. | 993 | ** with configuration accessor functions. |
@@ -998,12 +1003,13 @@ static int __init dino_probe(struct parisc_device *dev) | |||
998 | return 0; | 1003 | return 0; |
999 | } | 1004 | } |
1000 | 1005 | ||
1001 | bus->subordinate = pci_scan_child_bus(bus); | 1006 | max = pci_scan_child_bus(bus); |
1007 | pci_bus_update_busn_res_end(bus, max); | ||
1002 | 1008 | ||
1003 | /* This code *depends* on scanning being single threaded | 1009 | /* This code *depends* on scanning being single threaded |
1004 | * if it isn't, this global bus number count will fail | 1010 | * if it isn't, this global bus number count will fail |
1005 | */ | 1011 | */ |
1006 | dino_current_bus = bus->subordinate + 1; | 1012 | dino_current_bus = max + 1; |
1007 | pci_bus_assign_resources(bus); | 1013 | pci_bus_assign_resources(bus); |
1008 | pci_bus_add_devices(bus); | 1014 | pci_bus_add_devices(bus); |
1009 | return 0; | 1015 | return 0; |
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 1f9e9fefb8e7..83380c8fcb6b 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c | |||
@@ -532,7 +532,7 @@ iosapic_xlate_pin(struct iosapic_info *isi, struct pci_dev *pcidev) | |||
532 | intr_slot = PCI_SLOT(pcidev->devfn); | 532 | intr_slot = PCI_SLOT(pcidev->devfn); |
533 | } | 533 | } |
534 | DBG_IRT("iosapic_xlate_pin: bus %d slot %d pin %d\n", | 534 | DBG_IRT("iosapic_xlate_pin: bus %d slot %d pin %d\n", |
535 | pcidev->bus->secondary, intr_slot, intr_pin); | 535 | pcidev->bus->busn_res.start, intr_slot, intr_pin); |
536 | 536 | ||
537 | return irt_find_irqline(isi, intr_slot, intr_pin); | 537 | return irt_find_irqline(isi, intr_slot, intr_pin); |
538 | } | 538 | } |
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index 052fa230bc77..4f9cf2456f4e 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c | |||
@@ -189,8 +189,8 @@ lba_dump_res(struct resource *r, int d) | |||
189 | 189 | ||
190 | static int lba_device_present(u8 bus, u8 dfn, struct lba_device *d) | 190 | static int lba_device_present(u8 bus, u8 dfn, struct lba_device *d) |
191 | { | 191 | { |
192 | u8 first_bus = d->hba.hba_bus->secondary; | 192 | u8 first_bus = d->hba.hba_bus->busn_res.start; |
193 | u8 last_sub_bus = d->hba.hba_bus->subordinate; | 193 | u8 last_sub_bus = d->hba.hba_bus->busn_res.end; |
194 | 194 | ||
195 | if ((bus < first_bus) || | 195 | if ((bus < first_bus) || |
196 | (bus > last_sub_bus) || | 196 | (bus > last_sub_bus) || |
@@ -364,7 +364,7 @@ lba_rd_cfg(struct lba_device *d, u32 tok, u8 reg, u32 size) | |||
364 | static int elroy_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data) | 364 | static int elroy_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data) |
365 | { | 365 | { |
366 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); | 366 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); |
367 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary; | 367 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->busn_res.start; |
368 | u32 tok = LBA_CFG_TOK(local_bus, devfn); | 368 | u32 tok = LBA_CFG_TOK(local_bus, devfn); |
369 | void __iomem *data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA; | 369 | void __iomem *data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA; |
370 | 370 | ||
@@ -380,7 +380,7 @@ static int elroy_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int | |||
380 | return 0; | 380 | return 0; |
381 | } | 381 | } |
382 | 382 | ||
383 | if (LBA_SKIP_PROBE(d) && !lba_device_present(bus->secondary, devfn, d)) { | 383 | if (LBA_SKIP_PROBE(d) && !lba_device_present(bus->busn_res.start, devfn, d)) { |
384 | DBG_CFG("%s(%x+%2x) -> -1 (b)\n", __func__, tok, pos); | 384 | DBG_CFG("%s(%x+%2x) -> -1 (b)\n", __func__, tok, pos); |
385 | /* either don't want to look or know device isn't present. */ | 385 | /* either don't want to look or know device isn't present. */ |
386 | *data = ~0U; | 386 | *data = ~0U; |
@@ -431,7 +431,7 @@ lba_wr_cfg(struct lba_device *d, u32 tok, u8 reg, u32 data, u32 size) | |||
431 | static int elroy_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 data) | 431 | static int elroy_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 data) |
432 | { | 432 | { |
433 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); | 433 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); |
434 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary; | 434 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->busn_res.start; |
435 | u32 tok = LBA_CFG_TOK(local_bus,devfn); | 435 | u32 tok = LBA_CFG_TOK(local_bus,devfn); |
436 | 436 | ||
437 | if ((pos > 255) || (devfn > 255)) | 437 | if ((pos > 255) || (devfn > 255)) |
@@ -444,7 +444,7 @@ static int elroy_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, int | |||
444 | return 0; | 444 | return 0; |
445 | } | 445 | } |
446 | 446 | ||
447 | if (LBA_SKIP_PROBE(d) && (!lba_device_present(bus->secondary, devfn, d))) { | 447 | if (LBA_SKIP_PROBE(d) && (!lba_device_present(bus->busn_res.start, devfn, d))) { |
448 | DBG_CFG("%s(%x+%2x) = 0x%x (b)\n", __func__, tok, pos,data); | 448 | DBG_CFG("%s(%x+%2x) = 0x%x (b)\n", __func__, tok, pos,data); |
449 | return 1; /* New Workaround */ | 449 | return 1; /* New Workaround */ |
450 | } | 450 | } |
@@ -481,7 +481,7 @@ static struct pci_ops elroy_cfg_ops = { | |||
481 | static int mercury_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data) | 481 | static int mercury_cfg_read(struct pci_bus *bus, unsigned int devfn, int pos, int size, u32 *data) |
482 | { | 482 | { |
483 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); | 483 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); |
484 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary; | 484 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->busn_res.start; |
485 | u32 tok = LBA_CFG_TOK(local_bus, devfn); | 485 | u32 tok = LBA_CFG_TOK(local_bus, devfn); |
486 | void __iomem *data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA; | 486 | void __iomem *data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA; |
487 | 487 | ||
@@ -514,7 +514,7 @@ static int mercury_cfg_write(struct pci_bus *bus, unsigned int devfn, int pos, i | |||
514 | { | 514 | { |
515 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); | 515 | struct lba_device *d = LBA_DEV(parisc_walk_tree(bus->bridge)); |
516 | void __iomem *data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA; | 516 | void __iomem *data_reg = d->hba.base_addr + LBA_PCI_CFG_DATA; |
517 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->secondary; | 517 | u32 local_bus = (bus->parent == NULL) ? 0 : bus->busn_res.start; |
518 | u32 tok = LBA_CFG_TOK(local_bus,devfn); | 518 | u32 tok = LBA_CFG_TOK(local_bus,devfn); |
519 | 519 | ||
520 | if ((pos > 255) || (devfn > 255)) | 520 | if ((pos > 255) || (devfn > 255)) |
@@ -636,7 +636,7 @@ lba_fixup_bus(struct pci_bus *bus) | |||
636 | struct lba_device *ldev = LBA_DEV(parisc_walk_tree(bus->bridge)); | 636 | struct lba_device *ldev = LBA_DEV(parisc_walk_tree(bus->bridge)); |
637 | 637 | ||
638 | DBG("lba_fixup_bus(0x%p) bus %d platform_data 0x%p\n", | 638 | DBG("lba_fixup_bus(0x%p) bus %d platform_data 0x%p\n", |
639 | bus, bus->secondary, bus->bridge->platform_data); | 639 | bus, (int)bus->busn_res.start, bus->bridge->platform_data); |
640 | 640 | ||
641 | /* | 641 | /* |
642 | ** Properly Setup MMIO resources for this bus. | 642 | ** Properly Setup MMIO resources for this bus. |
@@ -989,6 +989,7 @@ lba_pat_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev) | |||
989 | case PAT_PBNUM: | 989 | case PAT_PBNUM: |
990 | lba_dev->hba.bus_num.start = p->start; | 990 | lba_dev->hba.bus_num.start = p->start; |
991 | lba_dev->hba.bus_num.end = p->end; | 991 | lba_dev->hba.bus_num.end = p->end; |
992 | lba_dev->hba.bus_num.flags = IORESOURCE_BUS; | ||
992 | break; | 993 | break; |
993 | 994 | ||
994 | case PAT_LMMIO: | 995 | case PAT_LMMIO: |
@@ -1366,6 +1367,7 @@ lba_driver_probe(struct parisc_device *dev) | |||
1366 | void *tmp_obj; | 1367 | void *tmp_obj; |
1367 | char *version; | 1368 | char *version; |
1368 | void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096); | 1369 | void __iomem *addr = ioremap_nocache(dev->hpa.start, 4096); |
1370 | int max; | ||
1369 | 1371 | ||
1370 | /* Read HW Rev First */ | 1372 | /* Read HW Rev First */ |
1371 | func_class = READ_REG32(addr + LBA_FCLASS); | 1373 | func_class = READ_REG32(addr + LBA_FCLASS); |
@@ -1502,6 +1504,8 @@ lba_driver_probe(struct parisc_device *dev) | |||
1502 | if (lba_dev->hba.gmmio_space.flags) | 1504 | if (lba_dev->hba.gmmio_space.flags) |
1503 | pci_add_resource(&resources, &lba_dev->hba.gmmio_space); | 1505 | pci_add_resource(&resources, &lba_dev->hba.gmmio_space); |
1504 | 1506 | ||
1507 | pci_add_resource(&resources, &lba_dev->hba.bus_num); | ||
1508 | |||
1505 | dev->dev.platform_data = lba_dev; | 1509 | dev->dev.platform_data = lba_dev; |
1506 | lba_bus = lba_dev->hba.hba_bus = | 1510 | lba_bus = lba_dev->hba.hba_bus = |
1507 | pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start, | 1511 | pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start, |
@@ -1511,7 +1515,7 @@ lba_driver_probe(struct parisc_device *dev) | |||
1511 | return 0; | 1515 | return 0; |
1512 | } | 1516 | } |
1513 | 1517 | ||
1514 | lba_bus->subordinate = pci_scan_child_bus(lba_bus); | 1518 | max = pci_scan_child_bus(lba_bus); |
1515 | 1519 | ||
1516 | /* This is in lieu of calling pci_assign_unassigned_resources() */ | 1520 | /* This is in lieu of calling pci_assign_unassigned_resources() */ |
1517 | if (is_pdc_pat()) { | 1521 | if (is_pdc_pat()) { |
@@ -1541,7 +1545,7 @@ lba_driver_probe(struct parisc_device *dev) | |||
1541 | lba_dev->flags |= LBA_FLAG_SKIP_PROBE; | 1545 | lba_dev->flags |= LBA_FLAG_SKIP_PROBE; |
1542 | } | 1546 | } |
1543 | 1547 | ||
1544 | lba_next_bus = lba_bus->subordinate + 1; | 1548 | lba_next_bus = max + 1; |
1545 | pci_bus_add_devices(lba_bus); | 1549 | pci_bus_add_devices(lba_bus); |
1546 | 1550 | ||
1547 | /* Whew! Finally done! Tell services we got this one covered. */ | 1551 | /* Whew! Finally done! Tell services we got this one covered. */ |
diff --git a/drivers/pci/hotplug-pci.c b/drivers/pci/hotplug-pci.c index d3509cdeb554..6258dc260d9f 100644 --- a/drivers/pci/hotplug-pci.c +++ b/drivers/pci/hotplug-pci.c | |||
@@ -4,18 +4,26 @@ | |||
4 | #include <linux/export.h> | 4 | #include <linux/export.h> |
5 | #include "pci.h" | 5 | #include "pci.h" |
6 | 6 | ||
7 | 7 | int __ref pci_hp_add_bridge(struct pci_dev *dev) | |
8 | unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) | ||
9 | { | 8 | { |
10 | unsigned int max; | 9 | struct pci_bus *parent = dev->bus; |
11 | 10 | int pass, busnr, start = parent->busn_res.start; | |
12 | max = pci_scan_child_bus(bus); | 11 | int end = parent->busn_res.end; |
13 | 12 | ||
14 | /* | 13 | for (busnr = start; busnr <= end; busnr++) { |
15 | * Make the discovered devices available. | 14 | if (!pci_find_bus(pci_domain_nr(parent), busnr)) |
16 | */ | 15 | break; |
17 | pci_bus_add_devices(bus); | 16 | } |
17 | if (busnr-- > end) { | ||
18 | printk(KERN_ERR "No bus number available for hot-added bridge %s\n", | ||
19 | pci_name(dev)); | ||
20 | return -1; | ||
21 | } | ||
22 | for (pass = 0; pass < 2; pass++) | ||
23 | busnr = pci_scan_bridge(parent, dev, busnr, pass); | ||
24 | if (!dev->subordinate) | ||
25 | return -1; | ||
18 | 26 | ||
19 | return max; | 27 | return 0; |
20 | } | 28 | } |
21 | EXPORT_SYMBOL(pci_do_scan_bus); | 29 | EXPORT_SYMBOL_GPL(pci_hp_add_bridge); |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 806c44fa645a..62d0ae4dfcad 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -100,11 +100,11 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val, | |||
100 | PCI_PRIMARY_BUS, | 100 | PCI_PRIMARY_BUS, |
101 | &buses); | 101 | &buses); |
102 | 102 | ||
103 | if (((buses >> 8) & 0xff) != bus->secondary) { | 103 | if (((buses >> 8) & 0xff) != bus->busn_res.start) { |
104 | buses = (buses & 0xff000000) | 104 | buses = (buses & 0xff000000) |
105 | | ((unsigned int)(bus->primary) << 0) | 105 | | ((unsigned int)(bus->primary) << 0) |
106 | | ((unsigned int)(bus->secondary) << 8) | 106 | | ((unsigned int)(bus->busn_res.start) << 8) |
107 | | ((unsigned int)(bus->subordinate) << 16); | 107 | | ((unsigned int)(bus->busn_res.end) << 16); |
108 | pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); | 108 | pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); |
109 | } | 109 | } |
110 | return NOTIFY_OK; | 110 | return NOTIFY_OK; |
@@ -692,7 +692,7 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | |||
692 | * bus->subordinate value because it could have | 692 | * bus->subordinate value because it could have |
693 | * padding in it. | 693 | * padding in it. |
694 | */ | 694 | */ |
695 | max = bus->secondary; | 695 | max = bus->busn_res.start; |
696 | 696 | ||
697 | list_for_each(tmp, &bus->children) { | 697 | list_for_each(tmp, &bus->children) { |
698 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | 698 | n = pci_bus_max_busnr(pci_bus_b(tmp)); |
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index ae853ccd0cd5..dcc75c785443 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
@@ -285,42 +285,19 @@ int __ref cpci_configure_slot(struct slot *slot) | |||
285 | for (fn = 0; fn < 8; fn++) { | 285 | for (fn = 0; fn < 8; fn++) { |
286 | struct pci_dev *dev; | 286 | struct pci_dev *dev; |
287 | 287 | ||
288 | dev = pci_get_slot(parent, PCI_DEVFN(PCI_SLOT(slot->devfn), fn)); | 288 | dev = pci_get_slot(parent, |
289 | PCI_DEVFN(PCI_SLOT(slot->devfn), fn)); | ||
289 | if (!dev) | 290 | if (!dev) |
290 | continue; | 291 | continue; |
291 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 292 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || |
292 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { | 293 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) |
293 | /* Find an unused bus number for the new bridge */ | 294 | pci_hp_add_bridge(dev); |
294 | struct pci_bus *child; | ||
295 | unsigned char busnr, start = parent->secondary; | ||
296 | unsigned char end = parent->subordinate; | ||
297 | |||
298 | for (busnr = start; busnr <= end; busnr++) { | ||
299 | if (!pci_find_bus(pci_domain_nr(parent), | ||
300 | busnr)) | ||
301 | break; | ||
302 | } | ||
303 | if (busnr >= end) { | ||
304 | err("No free bus for hot-added bridge\n"); | ||
305 | pci_dev_put(dev); | ||
306 | continue; | ||
307 | } | ||
308 | child = pci_add_new_bus(parent, dev, busnr); | ||
309 | if (!child) { | ||
310 | err("Cannot add new bus for %s\n", | ||
311 | pci_name(dev)); | ||
312 | pci_dev_put(dev); | ||
313 | continue; | ||
314 | } | ||
315 | child->subordinate = pci_do_scan_bus(child); | ||
316 | pci_bus_size_bridges(child); | ||
317 | } | ||
318 | pci_dev_put(dev); | 295 | pci_dev_put(dev); |
319 | } | 296 | } |
320 | 297 | ||
321 | pci_bus_assign_resources(parent); | 298 | pci_assign_unassigned_bridge_resources(parent->self); |
299 | |||
322 | pci_bus_add_devices(parent); | 300 | pci_bus_add_devices(parent); |
323 | pci_enable_bridges(parent); | ||
324 | 301 | ||
325 | dbg("%s - exit", __func__); | 302 | dbg("%s - exit", __func__); |
326 | return 0; | 303 | return 0; |
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c index 1c8494021a42..09801c6945ce 100644 --- a/drivers/pci/hotplug/cpqphp_pci.c +++ b/drivers/pci/hotplug/cpqphp_pci.c | |||
@@ -83,7 +83,6 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom | |||
83 | 83 | ||
84 | int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) | 84 | int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) |
85 | { | 85 | { |
86 | unsigned char bus; | ||
87 | struct pci_bus *child; | 86 | struct pci_bus *child; |
88 | int num; | 87 | int num; |
89 | 88 | ||
@@ -106,9 +105,10 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) | |||
106 | } | 105 | } |
107 | 106 | ||
108 | if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 107 | if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
109 | pci_read_config_byte(func->pci_dev, PCI_SECONDARY_BUS, &bus); | 108 | pci_hp_add_bridge(func->pci_dev); |
110 | child = (struct pci_bus*) pci_add_new_bus(func->pci_dev->bus, (func->pci_dev), bus); | 109 | child = func->pci_dev->subordinate; |
111 | pci_do_scan_bus(child); | 110 | if (child) |
111 | pci_bus_add_devices(child); | ||
112 | } | 112 | } |
113 | 113 | ||
114 | pci_dev_put(func->pci_dev); | 114 | pci_dev_put(func->pci_dev); |
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 4fda7e6a86a7..7dccad5fc891 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -775,7 +775,6 @@ static u8 bus_structure_fixup(u8 busno) | |||
775 | 775 | ||
776 | static int ibm_configure_device(struct pci_func *func) | 776 | static int ibm_configure_device(struct pci_func *func) |
777 | { | 777 | { |
778 | unsigned char bus; | ||
779 | struct pci_bus *child; | 778 | struct pci_bus *child; |
780 | int num; | 779 | int num; |
781 | int flag = 0; /* this is to make sure we don't double scan the bus, | 780 | int flag = 0; /* this is to make sure we don't double scan the bus, |
@@ -805,9 +804,10 @@ static int ibm_configure_device(struct pci_func *func) | |||
805 | } | 804 | } |
806 | } | 805 | } |
807 | if (!(flag) && (func->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) { | 806 | if (!(flag) && (func->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) { |
808 | pci_read_config_byte(func->dev, PCI_SECONDARY_BUS, &bus); | 807 | pci_hp_add_bridge(func->dev); |
809 | child = pci_add_new_bus(func->dev->bus, func->dev, bus); | 808 | child = func->dev->subordinate; |
810 | pci_do_scan_bus(child); | 809 | if (child) |
810 | pci_bus_add_devices(child); | ||
811 | } | 811 | } |
812 | 812 | ||
813 | return 0; | 813 | return 0; |
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 47d9dc06b109..09cecaf450c5 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c | |||
@@ -34,29 +34,6 @@ | |||
34 | #include "../pci.h" | 34 | #include "../pci.h" |
35 | #include "pciehp.h" | 35 | #include "pciehp.h" |
36 | 36 | ||
37 | static int __ref pciehp_add_bridge(struct pci_dev *dev) | ||
38 | { | ||
39 | struct pci_bus *parent = dev->bus; | ||
40 | int pass, busnr, start = parent->secondary; | ||
41 | int end = parent->subordinate; | ||
42 | |||
43 | for (busnr = start; busnr <= end; busnr++) { | ||
44 | if (!pci_find_bus(pci_domain_nr(parent), busnr)) | ||
45 | break; | ||
46 | } | ||
47 | if (busnr-- > end) { | ||
48 | err("No bus number available for hot-added bridge %s\n", | ||
49 | pci_name(dev)); | ||
50 | return -1; | ||
51 | } | ||
52 | for (pass = 0; pass < 2; pass++) | ||
53 | busnr = pci_scan_bridge(parent, dev, busnr, pass); | ||
54 | if (!dev->subordinate) | ||
55 | return -1; | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int pciehp_configure_device(struct slot *p_slot) | 37 | int pciehp_configure_device(struct slot *p_slot) |
61 | { | 38 | { |
62 | struct pci_dev *dev; | 39 | struct pci_dev *dev; |
@@ -85,9 +62,8 @@ int pciehp_configure_device(struct slot *p_slot) | |||
85 | if (!dev) | 62 | if (!dev) |
86 | continue; | 63 | continue; |
87 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 64 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || |
88 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { | 65 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) |
89 | pciehp_add_bridge(dev); | 66 | pci_hp_add_bridge(dev); |
90 | } | ||
91 | pci_dev_put(dev); | 67 | pci_dev_put(dev); |
92 | } | 68 | } |
93 | 69 | ||
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index de573113c102..f64ca92253da 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -397,13 +397,11 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
397 | else | 397 | else |
398 | sn_io_slot_fixup(dev); | 398 | sn_io_slot_fixup(dev); |
399 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 399 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
400 | unsigned char sec_bus; | 400 | pci_hp_add_bridge(dev); |
401 | pci_read_config_byte(dev, PCI_SECONDARY_BUS, | 401 | if (dev->subordinate) { |
402 | &sec_bus); | 402 | new_bus = dev->subordinate; |
403 | new_bus = pci_add_new_bus(dev->bus, dev, | 403 | new_ppb = 1; |
404 | sec_bus); | 404 | } |
405 | pci_scan_child_bus(new_bus); | ||
406 | new_ppb = 1; | ||
407 | } | 405 | } |
408 | pci_dev_put(dev); | 406 | pci_dev_put(dev); |
409 | } | 407 | } |
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index df7e4bfadae3..c627ed9957d1 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
@@ -37,9 +37,10 @@ | |||
37 | int __ref shpchp_configure_device(struct slot *p_slot) | 37 | int __ref shpchp_configure_device(struct slot *p_slot) |
38 | { | 38 | { |
39 | struct pci_dev *dev; | 39 | struct pci_dev *dev; |
40 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | ||
41 | int num, fn; | ||
42 | struct controller *ctrl = p_slot->ctrl; | 40 | struct controller *ctrl = p_slot->ctrl; |
41 | struct pci_dev *bridge = ctrl->pci_dev; | ||
42 | struct pci_bus *parent = bridge->subordinate; | ||
43 | int num, fn; | ||
43 | 44 | ||
44 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); | 45 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); |
45 | if (dev) { | 46 | if (dev) { |
@@ -61,39 +62,23 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
61 | if (!dev) | 62 | if (!dev) |
62 | continue; | 63 | continue; |
63 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 64 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || |
64 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { | 65 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) |
65 | /* Find an unused bus number for the new bridge */ | 66 | pci_hp_add_bridge(dev); |
66 | struct pci_bus *child; | 67 | pci_dev_put(dev); |
67 | unsigned char busnr, start = parent->secondary; | 68 | } |
68 | unsigned char end = parent->subordinate; | 69 | |
69 | for (busnr = start; busnr <= end; busnr++) { | 70 | pci_assign_unassigned_bridge_resources(bridge); |
70 | if (!pci_find_bus(pci_domain_nr(parent), | 71 | |
71 | busnr)) | 72 | for (fn = 0; fn < 8; fn++) { |
72 | break; | 73 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); |
73 | } | 74 | if (!dev) |
74 | if (busnr > end) { | 75 | continue; |
75 | ctrl_err(ctrl, | ||
76 | "No free bus for hot-added bridge\n"); | ||
77 | pci_dev_put(dev); | ||
78 | continue; | ||
79 | } | ||
80 | child = pci_add_new_bus(parent, dev, busnr); | ||
81 | if (!child) { | ||
82 | ctrl_err(ctrl, "Cannot add new bus for %s\n", | ||
83 | pci_name(dev)); | ||
84 | pci_dev_put(dev); | ||
85 | continue; | ||
86 | } | ||
87 | child->subordinate = pci_do_scan_bus(child); | ||
88 | pci_bus_size_bridges(child); | ||
89 | } | ||
90 | pci_configure_slot(dev); | 76 | pci_configure_slot(dev); |
91 | pci_dev_put(dev); | 77 | pci_dev_put(dev); |
92 | } | 78 | } |
93 | 79 | ||
94 | pci_bus_assign_resources(parent); | ||
95 | pci_bus_add_devices(parent); | 80 | pci_bus_add_devices(parent); |
96 | pci_enable_bridges(parent); | 81 | |
97 | return 0; | 82 | return 0; |
98 | } | 83 | } |
99 | 84 | ||
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c index efa30da1ae8f..eeb23ceae4a8 100644 --- a/drivers/pci/hotplug/shpchp_sysfs.c +++ b/drivers/pci/hotplug/shpchp_sysfs.c | |||
@@ -73,13 +73,13 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | out += sprintf(out, "Free resources: bus numbers\n"); | 75 | out += sprintf(out, "Free resources: bus numbers\n"); |
76 | for (busnr = bus->secondary; busnr <= bus->subordinate; busnr++) { | 76 | for (busnr = bus->busn_res.start; busnr <= bus->busn_res.end; busnr++) { |
77 | if (!pci_find_bus(pci_domain_nr(bus), busnr)) | 77 | if (!pci_find_bus(pci_domain_nr(bus), busnr)) |
78 | break; | 78 | break; |
79 | } | 79 | } |
80 | if (busnr < bus->subordinate) | 80 | if (busnr < bus->busn_res.end) |
81 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", | 81 | out += sprintf(out, "start = %8.8x, length = %8.8x\n", |
82 | busnr, (bus->subordinate - busnr)); | 82 | busnr, (int)(bus->busn_res.end - busnr)); |
83 | 83 | ||
84 | return out - buf; | 84 | return out - buf; |
85 | } | 85 | } |
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 6554e1a0f634..74bbaf82638d 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -47,7 +47,7 @@ static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr) | |||
47 | if (!child) | 47 | if (!child) |
48 | return NULL; | 48 | return NULL; |
49 | 49 | ||
50 | child->subordinate = busnr; | 50 | pci_bus_insert_busn_res(child, busnr, busnr); |
51 | child->dev.parent = bus->bridge; | 51 | child->dev.parent = bus->bridge; |
52 | rc = pci_bus_add_child(child); | 52 | rc = pci_bus_add_child(child); |
53 | if (rc) { | 53 | if (rc) { |
@@ -327,7 +327,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
327 | iov->offset = offset; | 327 | iov->offset = offset; |
328 | iov->stride = stride; | 328 | iov->stride = stride; |
329 | 329 | ||
330 | if (virtfn_bus(dev, nr_virtfn - 1) > dev->bus->subordinate) { | 330 | if (virtfn_bus(dev, nr_virtfn - 1) > dev->bus->busn_res.end) { |
331 | dev_err(&dev->dev, "SR-IOV: bus number out of range\n"); | 331 | dev_err(&dev->dev, "SR-IOV: bus number out of range\n"); |
332 | return -ENOMEM; | 332 | return -ENOMEM; |
333 | } | 333 | } |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 447e83472c01..aeda6e9c245c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -110,7 +110,7 @@ unsigned char pci_bus_max_busnr(struct pci_bus* bus) | |||
110 | struct list_head *tmp; | 110 | struct list_head *tmp; |
111 | unsigned char max, n; | 111 | unsigned char max, n; |
112 | 112 | ||
113 | max = bus->subordinate; | 113 | max = bus->busn_res.end; |
114 | list_for_each(tmp, &bus->children) { | 114 | list_for_each(tmp, &bus->children) { |
115 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | 115 | n = pci_bus_max_busnr(pci_bus_b(tmp)); |
116 | if(n > max) | 116 | if(n > max) |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index e4943479b234..1c56ea8110b1 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -124,7 +124,7 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } | |||
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | /* Functions for PCI Hotplug drivers to use */ | 126 | /* Functions for PCI Hotplug drivers to use */ |
127 | extern unsigned int pci_do_scan_bus(struct pci_bus *bus); | 127 | int pci_hp_add_bridge(struct pci_dev *dev); |
128 | 128 | ||
129 | #ifdef HAVE_PCI_LEGACY | 129 | #ifdef HAVE_PCI_LEGACY |
130 | extern void pci_create_legacy_files(struct pci_bus *bus); | 130 | extern void pci_create_legacy_files(struct pci_bus *bus); |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 658ac977cb56..08404098080b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -16,10 +16,47 @@ | |||
16 | #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ | 16 | #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ |
17 | #define CARDBUS_RESERVE_BUSNR 3 | 17 | #define CARDBUS_RESERVE_BUSNR 3 |
18 | 18 | ||
19 | struct resource busn_resource = { | ||
20 | .name = "PCI busn", | ||
21 | .start = 0, | ||
22 | .end = 255, | ||
23 | .flags = IORESOURCE_BUS, | ||
24 | }; | ||
25 | |||
19 | /* Ugh. Need to stop exporting this to modules. */ | 26 | /* Ugh. Need to stop exporting this to modules. */ |
20 | LIST_HEAD(pci_root_buses); | 27 | LIST_HEAD(pci_root_buses); |
21 | EXPORT_SYMBOL(pci_root_buses); | 28 | EXPORT_SYMBOL(pci_root_buses); |
22 | 29 | ||
30 | static LIST_HEAD(pci_domain_busn_res_list); | ||
31 | |||
32 | struct pci_domain_busn_res { | ||
33 | struct list_head list; | ||
34 | struct resource res; | ||
35 | int domain_nr; | ||
36 | }; | ||
37 | |||
38 | static struct resource *get_pci_domain_busn_res(int domain_nr) | ||
39 | { | ||
40 | struct pci_domain_busn_res *r; | ||
41 | |||
42 | list_for_each_entry(r, &pci_domain_busn_res_list, list) | ||
43 | if (r->domain_nr == domain_nr) | ||
44 | return &r->res; | ||
45 | |||
46 | r = kzalloc(sizeof(*r), GFP_KERNEL); | ||
47 | if (!r) | ||
48 | return NULL; | ||
49 | |||
50 | r->domain_nr = domain_nr; | ||
51 | r->res.start = 0; | ||
52 | r->res.end = 0xff; | ||
53 | r->res.flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED; | ||
54 | |||
55 | list_add_tail(&r->list, &pci_domain_busn_res_list); | ||
56 | |||
57 | return &r->res; | ||
58 | } | ||
59 | |||
23 | static int find_anything(struct device *dev, void *data) | 60 | static int find_anything(struct device *dev, void *data) |
24 | { | 61 | { |
25 | return 1; | 62 | return 1; |
@@ -381,8 +418,8 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) | |||
381 | if (pci_is_root_bus(child)) /* It's a host bus, nothing to read */ | 418 | if (pci_is_root_bus(child)) /* It's a host bus, nothing to read */ |
382 | return; | 419 | return; |
383 | 420 | ||
384 | dev_info(&dev->dev, "PCI bridge to [bus %02x-%02x]%s\n", | 421 | dev_info(&dev->dev, "PCI bridge to %pR%s\n", |
385 | child->secondary, child->subordinate, | 422 | &child->busn_res, |
386 | dev->transparent ? " (subtractive decode)" : ""); | 423 | dev->transparent ? " (subtractive decode)" : ""); |
387 | 424 | ||
388 | pci_bus_remove_resources(child); | 425 | pci_bus_remove_resources(child); |
@@ -599,9 +636,9 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
599 | * Set up the primary, secondary and subordinate | 636 | * Set up the primary, secondary and subordinate |
600 | * bus numbers. | 637 | * bus numbers. |
601 | */ | 638 | */ |
602 | child->number = child->secondary = busnr; | 639 | child->number = child->busn_res.start = busnr; |
603 | child->primary = parent->secondary; | 640 | child->primary = parent->busn_res.start; |
604 | child->subordinate = 0xff; | 641 | child->busn_res.end = 0xff; |
605 | 642 | ||
606 | if (!bridge) | 643 | if (!bridge) |
607 | return child; | 644 | return child; |
@@ -643,8 +680,8 @@ static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) | |||
643 | if (!pcibios_assign_all_busses()) | 680 | if (!pcibios_assign_all_busses()) |
644 | return; | 681 | return; |
645 | 682 | ||
646 | while (parent->parent && parent->subordinate < max) { | 683 | while (parent->parent && parent->busn_res.end < max) { |
647 | parent->subordinate = max; | 684 | parent->busn_res.end = max; |
648 | pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, max); | 685 | pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, max); |
649 | parent = parent->parent; | 686 | parent = parent->parent; |
650 | } | 687 | } |
@@ -718,15 +755,15 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
718 | if (!child) | 755 | if (!child) |
719 | goto out; | 756 | goto out; |
720 | child->primary = primary; | 757 | child->primary = primary; |
721 | child->subordinate = subordinate; | 758 | pci_bus_insert_busn_res(child, secondary, subordinate); |
722 | child->bridge_ctl = bctl; | 759 | child->bridge_ctl = bctl; |
723 | } | 760 | } |
724 | 761 | ||
725 | cmax = pci_scan_child_bus(child); | 762 | cmax = pci_scan_child_bus(child); |
726 | if (cmax > max) | 763 | if (cmax > max) |
727 | max = cmax; | 764 | max = cmax; |
728 | if (child->subordinate > max) | 765 | if (child->busn_res.end > max) |
729 | max = child->subordinate; | 766 | max = child->busn_res.end; |
730 | } else { | 767 | } else { |
731 | /* | 768 | /* |
732 | * We need to assign a number to this bus which we always | 769 | * We need to assign a number to this bus which we always |
@@ -756,11 +793,12 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
756 | child = pci_add_new_bus(bus, dev, ++max); | 793 | child = pci_add_new_bus(bus, dev, ++max); |
757 | if (!child) | 794 | if (!child) |
758 | goto out; | 795 | goto out; |
796 | pci_bus_insert_busn_res(child, max, 0xff); | ||
759 | } | 797 | } |
760 | buses = (buses & 0xff000000) | 798 | buses = (buses & 0xff000000) |
761 | | ((unsigned int)(child->primary) << 0) | 799 | | ((unsigned int)(child->primary) << 0) |
762 | | ((unsigned int)(child->secondary) << 8) | 800 | | ((unsigned int)(child->busn_res.start) << 8) |
763 | | ((unsigned int)(child->subordinate) << 16); | 801 | | ((unsigned int)(child->busn_res.end) << 16); |
764 | 802 | ||
765 | /* | 803 | /* |
766 | * yenta.c forces a secondary latency timer of 176. | 804 | * yenta.c forces a secondary latency timer of 176. |
@@ -805,8 +843,8 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
805 | break; | 843 | break; |
806 | while (parent->parent) { | 844 | while (parent->parent) { |
807 | if ((!pcibios_assign_all_busses()) && | 845 | if ((!pcibios_assign_all_busses()) && |
808 | (parent->subordinate > max) && | 846 | (parent->busn_res.end > max) && |
809 | (parent->subordinate <= max+i)) { | 847 | (parent->busn_res.end <= max+i)) { |
810 | j = 1; | 848 | j = 1; |
811 | } | 849 | } |
812 | parent = parent->parent; | 850 | parent = parent->parent; |
@@ -827,7 +865,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
827 | /* | 865 | /* |
828 | * Set the subordinate bus number to its real value. | 866 | * Set the subordinate bus number to its real value. |
829 | */ | 867 | */ |
830 | child->subordinate = max; | 868 | pci_bus_update_busn_res_end(child, max); |
831 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); | 869 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); |
832 | } | 870 | } |
833 | 871 | ||
@@ -837,19 +875,19 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
837 | 875 | ||
838 | /* Has only triggered on CardBus, fixup is in yenta_socket */ | 876 | /* Has only triggered on CardBus, fixup is in yenta_socket */ |
839 | while (bus->parent) { | 877 | while (bus->parent) { |
840 | if ((child->subordinate > bus->subordinate) || | 878 | if ((child->busn_res.end > bus->busn_res.end) || |
841 | (child->number > bus->subordinate) || | 879 | (child->number > bus->busn_res.end) || |
842 | (child->number < bus->number) || | 880 | (child->number < bus->number) || |
843 | (child->subordinate < bus->number)) { | 881 | (child->busn_res.end < bus->number)) { |
844 | dev_info(&child->dev, "[bus %02x-%02x] %s " | 882 | dev_info(&child->dev, "%pR %s " |
845 | "hidden behind%s bridge %s [bus %02x-%02x]\n", | 883 | "hidden behind%s bridge %s %pR\n", |
846 | child->number, child->subordinate, | 884 | &child->busn_res, |
847 | (bus->number > child->subordinate && | 885 | (bus->number > child->busn_res.end && |
848 | bus->subordinate < child->number) ? | 886 | bus->busn_res.end < child->number) ? |
849 | "wholly" : "partially", | 887 | "wholly" : "partially", |
850 | bus->self->transparent ? " transparent" : "", | 888 | bus->self->transparent ? " transparent" : "", |
851 | dev_name(&bus->dev), | 889 | dev_name(&bus->dev), |
852 | bus->number, bus->subordinate); | 890 | &bus->busn_res); |
853 | } | 891 | } |
854 | bus = bus->parent; | 892 | bus = bus->parent; |
855 | } | 893 | } |
@@ -1548,7 +1586,7 @@ EXPORT_SYMBOL_GPL(pcie_bus_configure_settings); | |||
1548 | 1586 | ||
1549 | unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) | 1587 | unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) |
1550 | { | 1588 | { |
1551 | unsigned int devfn, pass, max = bus->secondary; | 1589 | unsigned int devfn, pass, max = bus->busn_res.start; |
1552 | struct pci_dev *dev; | 1590 | struct pci_dev *dev; |
1553 | 1591 | ||
1554 | dev_dbg(&bus->dev, "scanning bus\n"); | 1592 | dev_dbg(&bus->dev, "scanning bus\n"); |
@@ -1642,7 +1680,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | |||
1642 | /* Create legacy_io and legacy_mem files for this bus */ | 1680 | /* Create legacy_io and legacy_mem files for this bus */ |
1643 | pci_create_legacy_files(b); | 1681 | pci_create_legacy_files(b); |
1644 | 1682 | ||
1645 | b->number = b->secondary = bus; | 1683 | b->number = b->busn_res.start = bus; |
1646 | 1684 | ||
1647 | if (parent) | 1685 | if (parent) |
1648 | dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev)); | 1686 | dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev)); |
@@ -1654,7 +1692,10 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | |||
1654 | list_move_tail(&window->list, &bridge->windows); | 1692 | list_move_tail(&window->list, &bridge->windows); |
1655 | res = window->res; | 1693 | res = window->res; |
1656 | offset = window->offset; | 1694 | offset = window->offset; |
1657 | pci_bus_add_resource(b, res, 0); | 1695 | if (res->flags & IORESOURCE_BUS) |
1696 | pci_bus_insert_busn_res(b, bus, res->end); | ||
1697 | else | ||
1698 | pci_bus_add_resource(b, res, 0); | ||
1658 | if (offset) { | 1699 | if (offset) { |
1659 | if (resource_type(res) == IORESOURCE_IO) | 1700 | if (resource_type(res) == IORESOURCE_IO) |
1660 | fmt = " (bus address [%#06llx-%#06llx])"; | 1701 | fmt = " (bus address [%#06llx-%#06llx])"; |
@@ -1684,16 +1725,104 @@ err_out: | |||
1684 | return NULL; | 1725 | return NULL; |
1685 | } | 1726 | } |
1686 | 1727 | ||
1728 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) | ||
1729 | { | ||
1730 | struct resource *res = &b->busn_res; | ||
1731 | struct resource *parent_res, *conflict; | ||
1732 | |||
1733 | res->start = bus; | ||
1734 | res->end = bus_max; | ||
1735 | res->flags = IORESOURCE_BUS; | ||
1736 | |||
1737 | if (!pci_is_root_bus(b)) | ||
1738 | parent_res = &b->parent->busn_res; | ||
1739 | else { | ||
1740 | parent_res = get_pci_domain_busn_res(pci_domain_nr(b)); | ||
1741 | res->flags |= IORESOURCE_PCI_FIXED; | ||
1742 | } | ||
1743 | |||
1744 | conflict = insert_resource_conflict(parent_res, res); | ||
1745 | |||
1746 | if (conflict) | ||
1747 | dev_printk(KERN_DEBUG, &b->dev, | ||
1748 | "busn_res: can not insert %pR under %s%pR (conflicts with %s %pR)\n", | ||
1749 | res, pci_is_root_bus(b) ? "domain " : "", | ||
1750 | parent_res, conflict->name, conflict); | ||
1751 | else | ||
1752 | dev_printk(KERN_DEBUG, &b->dev, | ||
1753 | "busn_res: %pR is inserted under %s%pR\n", | ||
1754 | res, pci_is_root_bus(b) ? "domain " : "", | ||
1755 | parent_res); | ||
1756 | |||
1757 | return conflict == NULL; | ||
1758 | } | ||
1759 | |||
1760 | int pci_bus_update_busn_res_end(struct pci_bus *b, int bus_max) | ||
1761 | { | ||
1762 | struct resource *res = &b->busn_res; | ||
1763 | struct resource old_res = *res; | ||
1764 | resource_size_t size; | ||
1765 | int ret; | ||
1766 | |||
1767 | if (res->start > bus_max) | ||
1768 | return -EINVAL; | ||
1769 | |||
1770 | size = bus_max - res->start + 1; | ||
1771 | ret = adjust_resource(res, res->start, size); | ||
1772 | dev_printk(KERN_DEBUG, &b->dev, | ||
1773 | "busn_res: %pR end %s updated to %02x\n", | ||
1774 | &old_res, ret ? "can not be" : "is", bus_max); | ||
1775 | |||
1776 | if (!ret && !res->parent) | ||
1777 | pci_bus_insert_busn_res(b, res->start, res->end); | ||
1778 | |||
1779 | return ret; | ||
1780 | } | ||
1781 | |||
1782 | void pci_bus_release_busn_res(struct pci_bus *b) | ||
1783 | { | ||
1784 | struct resource *res = &b->busn_res; | ||
1785 | int ret; | ||
1786 | |||
1787 | if (!res->flags || !res->parent) | ||
1788 | return; | ||
1789 | |||
1790 | ret = release_resource(res); | ||
1791 | dev_printk(KERN_DEBUG, &b->dev, | ||
1792 | "busn_res: %pR %s released\n", | ||
1793 | res, ret ? "can not be" : "is"); | ||
1794 | } | ||
1795 | |||
1687 | struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, | 1796 | struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, |
1688 | struct pci_ops *ops, void *sysdata, struct list_head *resources) | 1797 | struct pci_ops *ops, void *sysdata, struct list_head *resources) |
1689 | { | 1798 | { |
1799 | struct pci_host_bridge_window *window; | ||
1800 | bool found = false; | ||
1690 | struct pci_bus *b; | 1801 | struct pci_bus *b; |
1802 | int max; | ||
1803 | |||
1804 | list_for_each_entry(window, resources, list) | ||
1805 | if (window->res->flags & IORESOURCE_BUS) { | ||
1806 | found = true; | ||
1807 | break; | ||
1808 | } | ||
1691 | 1809 | ||
1692 | b = pci_create_root_bus(parent, bus, ops, sysdata, resources); | 1810 | b = pci_create_root_bus(parent, bus, ops, sysdata, resources); |
1693 | if (!b) | 1811 | if (!b) |
1694 | return NULL; | 1812 | return NULL; |
1695 | 1813 | ||
1696 | b->subordinate = pci_scan_child_bus(b); | 1814 | if (!found) { |
1815 | dev_info(&b->dev, | ||
1816 | "No busn resource found for root bus, will use [bus %02x-ff]\n", | ||
1817 | bus); | ||
1818 | pci_bus_insert_busn_res(b, bus, 255); | ||
1819 | } | ||
1820 | |||
1821 | max = pci_scan_child_bus(b); | ||
1822 | |||
1823 | if (!found) | ||
1824 | pci_bus_update_busn_res_end(b, max); | ||
1825 | |||
1697 | pci_bus_add_devices(b); | 1826 | pci_bus_add_devices(b); |
1698 | return b; | 1827 | return b; |
1699 | } | 1828 | } |
@@ -1708,9 +1837,10 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, | |||
1708 | 1837 | ||
1709 | pci_add_resource(&resources, &ioport_resource); | 1838 | pci_add_resource(&resources, &ioport_resource); |
1710 | pci_add_resource(&resources, &iomem_resource); | 1839 | pci_add_resource(&resources, &iomem_resource); |
1840 | pci_add_resource(&resources, &busn_resource); | ||
1711 | b = pci_create_root_bus(parent, bus, ops, sysdata, &resources); | 1841 | b = pci_create_root_bus(parent, bus, ops, sysdata, &resources); |
1712 | if (b) | 1842 | if (b) |
1713 | b->subordinate = pci_scan_child_bus(b); | 1843 | pci_scan_child_bus(b); |
1714 | else | 1844 | else |
1715 | pci_free_resource_list(&resources); | 1845 | pci_free_resource_list(&resources); |
1716 | return b; | 1846 | return b; |
@@ -1725,9 +1855,10 @@ struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops, | |||
1725 | 1855 | ||
1726 | pci_add_resource(&resources, &ioport_resource); | 1856 | pci_add_resource(&resources, &ioport_resource); |
1727 | pci_add_resource(&resources, &iomem_resource); | 1857 | pci_add_resource(&resources, &iomem_resource); |
1858 | pci_add_resource(&resources, &busn_resource); | ||
1728 | b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources); | 1859 | b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources); |
1729 | if (b) { | 1860 | if (b) { |
1730 | b->subordinate = pci_scan_child_bus(b); | 1861 | pci_scan_child_bus(b); |
1731 | pci_bus_add_devices(b); | 1862 | pci_bus_add_devices(b); |
1732 | } else { | 1863 | } else { |
1733 | pci_free_resource_list(&resources); | 1864 | pci_free_resource_list(&resources); |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index fd77e2bde2e8..04a4861b4749 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -68,6 +68,7 @@ void pci_remove_bus(struct pci_bus *pci_bus) | |||
68 | 68 | ||
69 | down_write(&pci_bus_sem); | 69 | down_write(&pci_bus_sem); |
70 | list_del(&pci_bus->node); | 70 | list_del(&pci_bus->node); |
71 | pci_bus_release_busn_res(pci_bus); | ||
71 | up_write(&pci_bus_sem); | 72 | up_write(&pci_bus_sem); |
72 | if (!pci_bus->is_added) | 73 | if (!pci_bus->is_added) |
73 | return; | 74 | return; |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 8fa2d4be88de..192172c87b77 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -404,8 +404,8 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
404 | struct resource *res; | 404 | struct resource *res; |
405 | struct pci_bus_region region; | 405 | struct pci_bus_region region; |
406 | 406 | ||
407 | dev_info(&bridge->dev, "CardBus bridge to [bus %02x-%02x]\n", | 407 | dev_info(&bridge->dev, "CardBus bridge to %pR\n", |
408 | bus->secondary, bus->subordinate); | 408 | &bus->busn_res); |
409 | 409 | ||
410 | res = bus->resource[0]; | 410 | res = bus->resource[0]; |
411 | pcibios_resource_to_bus(bridge, ®ion, res); | 411 | pcibios_resource_to_bus(bridge, ®ion, res); |
@@ -553,8 +553,8 @@ static void __pci_setup_bridge(struct pci_bus *bus, unsigned long type) | |||
553 | { | 553 | { |
554 | struct pci_dev *bridge = bus->self; | 554 | struct pci_dev *bridge = bus->self; |
555 | 555 | ||
556 | dev_info(&bridge->dev, "PCI bridge to [bus %02x-%02x]\n", | 556 | dev_info(&bridge->dev, "PCI bridge to %pR\n", |
557 | bus->secondary, bus->subordinate); | 557 | &bus->busn_res); |
558 | 558 | ||
559 | if (type & IORESOURCE_IO) | 559 | if (type & IORESOURCE_IO) |
560 | pci_setup_bridge_io(bus); | 560 | pci_setup_bridge_io(bus); |
@@ -745,8 +745,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
745 | if (!size0 && !size1) { | 745 | if (!size0 && !size1) { |
746 | if (b_res->start || b_res->end) | 746 | if (b_res->start || b_res->end) |
747 | dev_info(&bus->self->dev, "disabling bridge window " | 747 | dev_info(&bus->self->dev, "disabling bridge window " |
748 | "%pR to [bus %02x-%02x] (unused)\n", b_res, | 748 | "%pR to %pR (unused)\n", b_res, |
749 | bus->secondary, bus->subordinate); | 749 | &bus->busn_res); |
750 | b_res->flags = 0; | 750 | b_res->flags = 0; |
751 | return; | 751 | return; |
752 | } | 752 | } |
@@ -757,8 +757,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
757 | if (size1 > size0 && realloc_head) { | 757 | if (size1 > size0 && realloc_head) { |
758 | add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096); | 758 | add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096); |
759 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " | 759 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " |
760 | "%pR to [bus %02x-%02x] add_size %lx\n", b_res, | 760 | "%pR to %pR add_size %lx\n", b_res, |
761 | bus->secondary, bus->subordinate, size1-size0); | 761 | &bus->busn_res, size1-size0); |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
@@ -863,8 +863,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
863 | if (!size0 && !size1) { | 863 | if (!size0 && !size1) { |
864 | if (b_res->start || b_res->end) | 864 | if (b_res->start || b_res->end) |
865 | dev_info(&bus->self->dev, "disabling bridge window " | 865 | dev_info(&bus->self->dev, "disabling bridge window " |
866 | "%pR to [bus %02x-%02x] (unused)\n", b_res, | 866 | "%pR to %pR (unused)\n", b_res, |
867 | bus->secondary, bus->subordinate); | 867 | &bus->busn_res); |
868 | b_res->flags = 0; | 868 | b_res->flags = 0; |
869 | return 1; | 869 | return 1; |
870 | } | 870 | } |
@@ -874,8 +874,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
874 | if (size1 > size0 && realloc_head) { | 874 | if (size1 > size0 && realloc_head) { |
875 | add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align); | 875 | add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align); |
876 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " | 876 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " |
877 | "%pR to [bus %02x-%02x] add_size %llx\n", b_res, | 877 | "%pR to %pR add_size %llx\n", b_res, |
878 | bus->secondary, bus->subordinate, (unsigned long long)size1-size0); | 878 | &bus->busn_res, (unsigned long long)size1-size0); |
879 | } | 879 | } |
880 | return 1; | 880 | return 1; |
881 | } | 881 | } |
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 6e75153c5b4f..24caeaf50529 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c | |||
@@ -73,7 +73,7 @@ int __ref cb_alloc(struct pcmcia_socket *s) | |||
73 | s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0)); | 73 | s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0)); |
74 | pci_fixup_cardbus(bus); | 74 | pci_fixup_cardbus(bus); |
75 | 75 | ||
76 | max = bus->secondary; | 76 | max = bus->busn_res.start; |
77 | for (pass = 0; pass < 2; pass++) | 77 | for (pass = 0; pass < 2; pass++) |
78 | list_for_each_entry(dev, &bus->devices, bus_list) | 78 | list_for_each_entry(dev, &bus->devices, bus_list) |
79 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 79 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index d07f9ac8c41d..667678db1153 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -1048,8 +1048,8 @@ static void yenta_config_init(struct yenta_socket *socket) | |||
1048 | config_writeb(socket, PCI_LATENCY_TIMER, 168); | 1048 | config_writeb(socket, PCI_LATENCY_TIMER, 168); |
1049 | config_writel(socket, PCI_PRIMARY_BUS, | 1049 | config_writel(socket, PCI_PRIMARY_BUS, |
1050 | (176 << 24) | /* sec. latency timer */ | 1050 | (176 << 24) | /* sec. latency timer */ |
1051 | (dev->subordinate->subordinate << 16) | /* subordinate bus */ | 1051 | ((unsigned int)dev->subordinate->busn_res.end << 16) | /* subordinate bus */ |
1052 | (dev->subordinate->secondary << 8) | /* secondary bus */ | 1052 | ((unsigned int)dev->subordinate->busn_res.start << 8) | /* secondary bus */ |
1053 | dev->subordinate->primary); /* primary bus */ | 1053 | dev->subordinate->primary); /* primary bus */ |
1054 | 1054 | ||
1055 | /* | 1055 | /* |
@@ -1086,14 +1086,14 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) | |||
1086 | struct pci_bus *bridge_to_fix = cardbus_bridge->parent; | 1086 | struct pci_bus *bridge_to_fix = cardbus_bridge->parent; |
1087 | 1087 | ||
1088 | /* Check bus numbers are already set up correctly: */ | 1088 | /* Check bus numbers are already set up correctly: */ |
1089 | if (bridge_to_fix->subordinate >= cardbus_bridge->subordinate) | 1089 | if (bridge_to_fix->busn_res.end >= cardbus_bridge->busn_res.end) |
1090 | return; /* The subordinate number is ok, nothing to do */ | 1090 | return; /* The subordinate number is ok, nothing to do */ |
1091 | 1091 | ||
1092 | if (!bridge_to_fix->parent) | 1092 | if (!bridge_to_fix->parent) |
1093 | return; /* Root bridges are ok */ | 1093 | return; /* Root bridges are ok */ |
1094 | 1094 | ||
1095 | /* stay within the limits of the bus range of the parent: */ | 1095 | /* stay within the limits of the bus range of the parent: */ |
1096 | upper_limit = bridge_to_fix->parent->subordinate; | 1096 | upper_limit = bridge_to_fix->parent->busn_res.end; |
1097 | 1097 | ||
1098 | /* check the bus ranges of all silbling bridges to prevent overlap */ | 1098 | /* check the bus ranges of all silbling bridges to prevent overlap */ |
1099 | list_for_each(tmp, &bridge_to_fix->parent->children) { | 1099 | list_for_each(tmp, &bridge_to_fix->parent->children) { |
@@ -1104,36 +1104,36 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) | |||
1104 | * current upper limit, set the new upper limit to | 1104 | * current upper limit, set the new upper limit to |
1105 | * the bus number below the silbling's range: | 1105 | * the bus number below the silbling's range: |
1106 | */ | 1106 | */ |
1107 | if (silbling->secondary > bridge_to_fix->subordinate | 1107 | if (silbling->busn_res.start > bridge_to_fix->busn_res.end |
1108 | && silbling->secondary <= upper_limit) | 1108 | && silbling->busn_res.start <= upper_limit) |
1109 | upper_limit = silbling->secondary - 1; | 1109 | upper_limit = silbling->busn_res.start - 1; |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | /* Show that the wanted subordinate number is not possible: */ | 1112 | /* Show that the wanted subordinate number is not possible: */ |
1113 | if (cardbus_bridge->subordinate > upper_limit) | 1113 | if (cardbus_bridge->busn_res.end > upper_limit) |
1114 | dev_printk(KERN_WARNING, &cardbus_bridge->dev, | 1114 | dev_printk(KERN_WARNING, &cardbus_bridge->dev, |
1115 | "Upper limit for fixing this " | 1115 | "Upper limit for fixing this " |
1116 | "bridge's parent bridge: #%02x\n", upper_limit); | 1116 | "bridge's parent bridge: #%02x\n", upper_limit); |
1117 | 1117 | ||
1118 | /* If we have room to increase the bridge's subordinate number, */ | 1118 | /* If we have room to increase the bridge's subordinate number, */ |
1119 | if (bridge_to_fix->subordinate < upper_limit) { | 1119 | if (bridge_to_fix->busn_res.end < upper_limit) { |
1120 | 1120 | ||
1121 | /* use the highest number of the hidden bus, within limits */ | 1121 | /* use the highest number of the hidden bus, within limits */ |
1122 | unsigned char subordinate_to_assign = | 1122 | unsigned char subordinate_to_assign = |
1123 | min(cardbus_bridge->subordinate, upper_limit); | 1123 | min_t(int, cardbus_bridge->busn_res.end, upper_limit); |
1124 | 1124 | ||
1125 | dev_printk(KERN_INFO, &bridge_to_fix->dev, | 1125 | dev_printk(KERN_INFO, &bridge_to_fix->dev, |
1126 | "Raising subordinate bus# of parent " | 1126 | "Raising subordinate bus# of parent " |
1127 | "bus (#%02x) from #%02x to #%02x\n", | 1127 | "bus (#%02x) from #%02x to #%02x\n", |
1128 | bridge_to_fix->number, | 1128 | bridge_to_fix->number, |
1129 | bridge_to_fix->subordinate, subordinate_to_assign); | 1129 | (int)bridge_to_fix->busn_res.end, subordinate_to_assign); |
1130 | 1130 | ||
1131 | /* Save the new subordinate in the bus struct of the bridge */ | 1131 | /* Save the new subordinate in the bus struct of the bridge */ |
1132 | bridge_to_fix->subordinate = subordinate_to_assign; | 1132 | bridge_to_fix->busn_res.end = subordinate_to_assign; |
1133 | 1133 | ||
1134 | /* and update the PCI config space with the new subordinate */ | 1134 | /* and update the PCI config space with the new subordinate */ |
1135 | pci_write_config_byte(bridge_to_fix->self, | 1135 | pci_write_config_byte(bridge_to_fix->self, |
1136 | PCI_SUBORDINATE_BUS, bridge_to_fix->subordinate); | 1136 | PCI_SUBORDINATE_BUS, bridge_to_fix->busn_res.end); |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | 1139 | ||
diff --git a/include/linux/pci.h b/include/linux/pci.h index d8c379dba6ad..8c8b44d62105 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -368,6 +368,8 @@ static inline int pci_channel_offline(struct pci_dev *pdev) | |||
368 | return (pdev->error_state != pci_channel_io_normal); | 368 | return (pdev->error_state != pci_channel_io_normal); |
369 | } | 369 | } |
370 | 370 | ||
371 | extern struct resource busn_resource; | ||
372 | |||
371 | struct pci_host_bridge_window { | 373 | struct pci_host_bridge_window { |
372 | struct list_head list; | 374 | struct list_head list; |
373 | struct resource *res; /* host bridge aperture (CPU address) */ | 375 | struct resource *res; /* host bridge aperture (CPU address) */ |
@@ -419,6 +421,7 @@ struct pci_bus { | |||
419 | struct list_head slots; /* list of slots on this bus */ | 421 | struct list_head slots; /* list of slots on this bus */ |
420 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; | 422 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; |
421 | struct list_head resources; /* address space routed to this bus */ | 423 | struct list_head resources; /* address space routed to this bus */ |
424 | struct resource busn_res; /* bus numbers routed to this bus */ | ||
422 | 425 | ||
423 | struct pci_ops *ops; /* configuration access functions */ | 426 | struct pci_ops *ops; /* configuration access functions */ |
424 | void *sysdata; /* hook for sys-specific extension */ | 427 | void *sysdata; /* hook for sys-specific extension */ |
@@ -426,8 +429,6 @@ struct pci_bus { | |||
426 | 429 | ||
427 | unsigned char number; /* bus number */ | 430 | unsigned char number; /* bus number */ |
428 | unsigned char primary; /* number of primary bridge */ | 431 | unsigned char primary; /* number of primary bridge */ |
429 | unsigned char secondary; /* number of secondary bridge */ | ||
430 | unsigned char subordinate; /* max number of subordinate buses */ | ||
431 | unsigned char max_bus_speed; /* enum pci_bus_speed */ | 432 | unsigned char max_bus_speed; /* enum pci_bus_speed */ |
432 | unsigned char cur_bus_speed; /* enum pci_bus_speed */ | 433 | unsigned char cur_bus_speed; /* enum pci_bus_speed */ |
433 | 434 | ||
@@ -668,6 +669,9 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata); | |||
668 | struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | 669 | struct pci_bus *pci_create_root_bus(struct device *parent, int bus, |
669 | struct pci_ops *ops, void *sysdata, | 670 | struct pci_ops *ops, void *sysdata, |
670 | struct list_head *resources); | 671 | struct list_head *resources); |
672 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); | ||
673 | int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); | ||
674 | void pci_bus_release_busn_res(struct pci_bus *b); | ||
671 | struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, | 675 | struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, |
672 | struct pci_ops *ops, void *sysdata, | 676 | struct pci_ops *ops, void *sysdata, |
673 | struct list_head *resources); | 677 | struct list_head *resources); |
diff --git a/kernel/resource.c b/kernel/resource.c index e1d2b8ee76d5..dc8b47764443 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -722,14 +722,12 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t | |||
722 | 722 | ||
723 | write_lock(&resource_lock); | 723 | write_lock(&resource_lock); |
724 | 724 | ||
725 | if (!parent) | ||
726 | goto skip; | ||
727 | |||
725 | if ((start < parent->start) || (end > parent->end)) | 728 | if ((start < parent->start) || (end > parent->end)) |
726 | goto out; | 729 | goto out; |
727 | 730 | ||
728 | for (tmp = res->child; tmp; tmp = tmp->sibling) { | ||
729 | if ((tmp->start < start) || (tmp->end > end)) | ||
730 | goto out; | ||
731 | } | ||
732 | |||
733 | if (res->sibling && (res->sibling->start <= end)) | 731 | if (res->sibling && (res->sibling->start <= end)) |
734 | goto out; | 732 | goto out; |
735 | 733 | ||
@@ -741,6 +739,11 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t | |||
741 | goto out; | 739 | goto out; |
742 | } | 740 | } |
743 | 741 | ||
742 | skip: | ||
743 | for (tmp = res->child; tmp; tmp = tmp->sibling) | ||
744 | if ((tmp->start < start) || (tmp->end > end)) | ||
745 | goto out; | ||
746 | |||
744 | res->start = start; | 747 | res->start = start; |
745 | res->end = end; | 748 | res->end = end; |
746 | result = 0; | 749 | result = 0; |