From c4e06576282c5f91549b344fd0f516c421332b68 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 28 Oct 2011 16:27:07 -0600 Subject: parisc/PCI: dino: use pci_create_bus() instead of pci_scan_bus_parented() No functional change here; just converting from pci_scan_bus_parented() to pci_create_bus() to make a future patch simpler. CC: linux-parisc@vger.kernel.org Signed-off-by: Bjorn Helgaas Signed-off-by: Jesse Barnes --- drivers/parisc/dino.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'drivers/parisc') diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index bcd5d54b7d4d..90252c016a08 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -1007,22 +1007,24 @@ static int __init dino_probe(struct parisc_device *dev) ** It's not used to avoid chicken/egg problems ** with configuration accessor functions. */ - dino_dev->hba.hba_bus = bus = pci_scan_bus_parented(&dev->dev, + dino_dev->hba.hba_bus = bus = pci_create_bus(&dev->dev, dino_current_bus, &dino_cfg_ops, NULL); - - if(bus) { - /* This code *depends* on scanning being single threaded - * if it isn't, this global bus number count will fail - */ - dino_current_bus = bus->subordinate + 1; - pci_bus_assign_resources(bus); - pci_bus_add_devices(bus); - } else { + if (!bus) { printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n", dev_name(&dev->dev), dino_current_bus); /* increment the bus number in case of duplicates */ dino_current_bus++; + return 0; } + + bus->subordinate = pci_scan_child_bus(bus); + + /* This code *depends* on scanning being single threaded + * if it isn't, this global bus number count will fail + */ + dino_current_bus = bus->subordinate + 1; + pci_bus_assign_resources(bus); + pci_bus_add_devices(bus); return 0; } -- cgit v1.2.3 From 7590e500ad83d9ac1e55eed4720e053eff14b8e5 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 28 Oct 2011 16:27:12 -0600 Subject: parisc/PCI: dino: convert to pci_create_root_bus() for correct root bus resources Supply root bus resources to pci_create_root_bus() so they're correct immediately. This fixes the problem of "early" and "header" quirks seeing incorrect root bus resources. CC: linux-parisc@vger.kernel.org Signed-off-by: Bjorn Helgaas Signed-off-by: Jesse Barnes --- drivers/parisc/dino.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'drivers/parisc') diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 90252c016a08..7ff10c1e8664 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -562,19 +562,6 @@ dino_fixup_bus(struct pci_bus *bus) /* Firmware doesn't set up card-mode dino, so we have to */ if (is_card_dino(&dino_dev->hba.dev->id)) { dino_card_setup(bus, dino_dev->hba.base_addr); - } else if(bus->parent == NULL) { - /* must have a dino above it, reparent the resources - * into the dino window */ - int i; - struct resource *res = &dino_dev->hba.lmmio_space; - - bus->resource[0] = &(dino_dev->hba.io_space); - for(i = 0; i < DINO_MAX_LMMIO_RESOURCES; i++) { - if(res[i].flags == 0) - break; - bus->resource[i+1] = &res[i]; - } - } else if (bus->parent) { int i; @@ -927,6 +914,7 @@ static int __init dino_probe(struct parisc_device *dev) const char *version = "unknown"; char *name; int is_cujo = 0; + LIST_HEAD(resources); struct pci_bus *bus; unsigned long hpa = dev->hpa.start; @@ -1003,15 +991,24 @@ static int __init dino_probe(struct parisc_device *dev) dev->dev.platform_data = dino_dev; + pci_add_resource(&resources, &dino_dev->hba.io_space); + if (dino_dev->hba.lmmio_space.flags) + pci_add_resource(&resources, &dino_dev->hba.lmmio_space); + if (dino_dev->hba.elmmio_space.flags) + pci_add_resource(&resources, &dino_dev->hba.elmmio_space); + if (dino_dev->hba.gmmio_space.flags) + pci_add_resource(&resources, &dino_dev->hba.gmmio_space); + /* ** It's not used to avoid chicken/egg problems ** with configuration accessor functions. */ - dino_dev->hba.hba_bus = bus = pci_create_bus(&dev->dev, - dino_current_bus, &dino_cfg_ops, NULL); + dino_dev->hba.hba_bus = bus = pci_create_root_bus(&dev->dev, + dino_current_bus, &dino_cfg_ops, NULL, &resources); if (!bus) { printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n", dev_name(&dev->dev), dino_current_bus); + pci_free_resource_list(&resources); /* increment the bus number in case of duplicates */ dino_current_bus++; return 0; -- cgit v1.2.3 From f4d9ea9abf04a6ad9643df5497e6243fbf64196e Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 28 Oct 2011 16:27:17 -0600 Subject: parisc/PCI: lba: deal with LMMIO/PAT overlaps before creating PCI root bus This moves the truncate_pat_collision() call out of the pcibios_fixup_bus() path so that when a future patch builds a list of root bus resources for pci_create_bus(), it can use the truncated LMMIO range. truncate_pat_collision() used to be called in this path: pci_scan_bus_parented pci_create_bus pci_scan_child_bus pcibios_fixup_bus lba_fixup_bus truncate_pat_collision All of the PAT and lba_dev resource setup must be done before we call pci_scan_bus_parented(), so it should be safe to move the truncate_pat_collision() to just before pci_scan_bus_parented(). CC: linux-parisc@vger.kernel.org Signed-off-by: Bjorn Helgaas Signed-off-by: Jesse Barnes --- drivers/parisc/lba_pci.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'drivers/parisc') diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index 3aeb3279c92a..2c7edf3a6cd0 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -689,23 +689,7 @@ lba_fixup_bus(struct pci_bus *bus) bus->resource[i++] = &(ldev->hba.elmmio_space); } - - /* Overlaps with elmmio can (and should) fail here. - * We will prune (or ignore) the distributed range. - * - * FIXME: SBA code should register all elmmio ranges first. - * that would take care of elmmio ranges routed - * to a different rope (already discovered) from - * getting registered *after* LBA code has already - * registered it's distributed lmmio range. - */ - if (truncate_pat_collision(&iomem_resource, - &(ldev->hba.lmmio_space))) { - - printk(KERN_WARNING "LBA: lmmio_space [%lx/%lx] duplicate!\n", - (long)ldev->hba.lmmio_space.start, - (long)ldev->hba.lmmio_space.end); - } else { + if (ldev->hba.lmmio_space.flags) { err = request_resource(&iomem_resource, &(ldev->hba.lmmio_space)); if (err < 0) { printk(KERN_ERR "FAILED: lba_fixup_bus() request for " @@ -1518,6 +1502,23 @@ lba_driver_probe(struct parisc_device *dev) if (lba_dev->hba.bus_num.start < lba_next_bus) lba_dev->hba.bus_num.start = lba_next_bus; + /* Overlaps with elmmio can (and should) fail here. + * We will prune (or ignore) the distributed range. + * + * FIXME: SBA code should register all elmmio ranges first. + * that would take care of elmmio ranges routed + * to a different rope (already discovered) from + * getting registered *after* LBA code has already + * registered it's distributed lmmio range. + */ + if (truncate_pat_collision(&iomem_resource, + &(lba_dev->hba.lmmio_space))) { + printk(KERN_WARNING "LBA: lmmio_space [%lx/%lx] duplicate!\n", + (long)lba_dev->hba.lmmio_space.start, + (long)lba_dev->hba.lmmio_space.end); + lba_dev->hba.lmmio_space.flags = 0; + } + dev->dev.platform_data = lba_dev; lba_bus = lba_dev->hba.hba_bus = pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start, -- cgit v1.2.3 From 42605fa6665ea86bbbd4de61693a0b002830277b Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 28 Oct 2011 16:27:22 -0600 Subject: parisc/PCI: lba: use pci_create_bus() instead of pci_scan_bus_parented() No functional change here; just converting from pci_scan_bus_parented() to pci_create_bus() to make a future patch simpler. CC: linux-parisc@vger.kernel.org Signed-off-by: Bjorn Helgaas Signed-off-by: Jesse Barnes --- drivers/parisc/lba_pci.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/parisc') diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index 2c7edf3a6cd0..e5dfa25e2fdd 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -1521,8 +1521,12 @@ lba_driver_probe(struct parisc_device *dev) dev->dev.platform_data = lba_dev; lba_bus = lba_dev->hba.hba_bus = - pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start, - cfg_ops, NULL); + pci_create_bus(&dev->dev, lba_dev->hba.bus_num.start, + cfg_ops, NULL); + if (!lba_bus) + return 0; + + lba_bus->subordinate = pci_scan_child_bus(lba_bus); /* This is in lieu of calling pci_assign_unassigned_resources() */ if (is_pdc_pat()) { @@ -1552,10 +1556,8 @@ lba_driver_probe(struct parisc_device *dev) lba_dev->flags |= LBA_FLAG_SKIP_PROBE; } - if (lba_bus) { - lba_next_bus = lba_bus->subordinate + 1; - pci_bus_add_devices(lba_bus); - } + lba_next_bus = lba_bus->subordinate + 1; + pci_bus_add_devices(lba_bus); /* Whew! Finally done! Tell services we got this one covered. */ return 0; -- cgit v1.2.3 From dc7dce280a26d069ad5a58bf3da86e5e83415c65 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 28 Oct 2011 16:27:27 -0600 Subject: parisc/PCI: lba: convert to pci_create_root_bus() for correct root bus resources Supply root bus resources to pci_create_root_bus() so they're correct immediately. This fixes the problem of "early" and "header" quirks seeing incorrect root bus resources. CC: linux-parisc@vger.kernel.org Signed-off-by: Bjorn Helgaas Signed-off-by: Jesse Barnes --- drivers/parisc/lba_pci.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'drivers/parisc') diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index e5dfa25e2fdd..d5f3d753a108 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -653,7 +653,7 @@ lba_fixup_bus(struct pci_bus *bus) } } else { /* Host-PCI Bridge */ - int err, i; + int err; DBG("lba_fixup_bus() %s [%lx/%lx]/%lx\n", ldev->hba.io_space.name, @@ -669,9 +669,6 @@ lba_fixup_bus(struct pci_bus *bus) lba_dump_res(&ioport_resource, 2); BUG(); } - /* advertize Host bridge resources to PCI bus */ - bus->resource[0] = &(ldev->hba.io_space); - i = 1; if (ldev->hba.elmmio_space.start) { err = request_resource(&iomem_resource, @@ -685,8 +682,7 @@ lba_fixup_bus(struct pci_bus *bus) /* lba_dump_res(&iomem_resource, 2); */ /* BUG(); */ - } else - bus->resource[i++] = &(ldev->hba.elmmio_space); + } } if (ldev->hba.lmmio_space.flags) { @@ -696,8 +692,7 @@ lba_fixup_bus(struct pci_bus *bus) "lmmio_space [%lx/%lx]\n", (long)ldev->hba.lmmio_space.start, (long)ldev->hba.lmmio_space.end); - } else - bus->resource[i++] = &(ldev->hba.lmmio_space); + } } #ifdef CONFIG_64BIT @@ -712,7 +707,6 @@ lba_fixup_bus(struct pci_bus *bus) lba_dump_res(&iomem_resource, 2); BUG(); } - bus->resource[i++] = &(ldev->hba.gmmio_space); } #endif @@ -1388,6 +1382,7 @@ static int __init lba_driver_probe(struct parisc_device *dev) { struct lba_device *lba_dev; + LIST_HEAD(resources); struct pci_bus *lba_bus; struct pci_ops *cfg_ops; u32 func_class; @@ -1519,12 +1514,22 @@ lba_driver_probe(struct parisc_device *dev) lba_dev->hba.lmmio_space.flags = 0; } + pci_add_resource(&resources, &lba_dev->hba.io_space); + if (lba_dev->hba.elmmio_space.start) + pci_add_resource(&resources, &lba_dev->hba.elmmio_space); + if (lba_dev->hba.lmmio_space.flags) + pci_add_resource(&resources, &lba_dev->hba.lmmio_space); + if (lba_dev->hba.gmmio_space.flags) + pci_add_resource(&resources, &lba_dev->hba.gmmio_space); + dev->dev.platform_data = lba_dev; lba_bus = lba_dev->hba.hba_bus = - pci_create_bus(&dev->dev, lba_dev->hba.bus_num.start, - cfg_ops, NULL); - if (!lba_bus) + pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start, + cfg_ops, NULL, &resources); + if (!lba_bus) { + pci_free_resource_list(&resources); return 0; + } lba_bus->subordinate = pci_scan_child_bus(lba_bus); -- cgit v1.2.3