aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-20 19:06:29 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-10-22 19:42:44 -0400
commita1c19894b786f10c76ac40e93c6b5d70c9b946d2 (patch)
tree4a03c1d7b9958c6fe328eeea13ee31a0edbb4478 /drivers/pci
parent0b8b0dca9aad94878adaf4520f3f12bf9813f329 (diff)
PCI: Workaround invalid P2P bridge bus numbers
Some firmware fail to properly configure P2P bridges, leaving them with invalid bus numbers. In some cases, this happens on some embedded 4xx boards as the result of the kernel allocating different bus space than the firmware does to host bridges while not setting pcibios_assign_all_busses() for various reasons. In other cases, it can just be bogus firmware. This adds some sanity checking to the PCI probing code. If a bridge is found whose primary bus number doesn't match the bus it's sitting on, or whose secondary bus number not strictly above it's primary bus number, then the bridge bus numbers are deconfigured in the first pass of pci_scan_bridge() to be re-assigned in the second pass. Tested-by: "Ayman El-Khashab" <AymanE@tanisys.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/probe.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index aaaf0a1fed22..6f1e51d77bce 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -480,19 +480,27 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
480 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); 480 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
481 u32 buses, i, j = 0; 481 u32 buses, i, j = 0;
482 u16 bctl; 482 u16 bctl;
483 int broken = 0;
483 484
484 pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); 485 pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
485 486
486 dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n", 487 dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
487 buses & 0xffffff, pass); 488 buses & 0xffffff, pass);
488 489
490 /* Check if setup is sensible at all */
491 if (!pass &&
492 ((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= bus->number)) {
493 dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n");
494 broken = 1;
495 }
496
489 /* Disable MasterAbortMode during probing to avoid reporting 497 /* Disable MasterAbortMode during probing to avoid reporting
490 of bus errors (in some architectures) */ 498 of bus errors (in some architectures) */
491 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); 499 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl);
492 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, 500 pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
493 bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); 501 bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
494 502
495 if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus) { 503 if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus && !broken) {
496 unsigned int cmax, busnr; 504 unsigned int cmax, busnr;
497 /* 505 /*
498 * Bus already configured by firmware, process it in the first 506 * Bus already configured by firmware, process it in the first
@@ -530,7 +538,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
530 * do in the second pass. 538 * do in the second pass.
531 */ 539 */
532 if (!pass) { 540 if (!pass) {
533 if (pcibios_assign_all_busses()) 541 if (pcibios_assign_all_busses() || broken)
534 /* Temporarily disable forwarding of the 542 /* Temporarily disable forwarding of the
535 configuration cycles on all bridges in 543 configuration cycles on all bridges in
536 this bus segment to avoid possible 544 this bus segment to avoid possible