diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2019-06-18 14:49:04 +1000 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2019-06-29 09:31:24 +1000 |
commit | d0c7ce60372867480393694eb6b2a9b3e7bc80dd (patch) | |
tree | f916f29bab3abc734a8c8a30977a0eeffe827bd5 | |
parent | d15418b88d08e48ddaf7bb518eb82936938f1ef4 (diff) | |
download | pci-d0c7ce60372867480393694eb6b2a9b3e7bc80dd.tar.gz |
parisc: lba_pci: Use pci_host_resource_survey()
This replaces a whole bunch of custom resource claiming code that was
done at pcibios_fixup_bus() time. We now do a single call to
pci_host_resource_survey() to perform all the standard claiming.
Hopefully I didn't miss some subtle difference and things will still
work fine...
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | drivers/parisc/lba_pci.c | 100 |
1 files changed, 25 insertions, 75 deletions
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index a99e385c68bd6c..224ad254528b55 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -664,41 +664,6 @@ extend_lmmio_len(unsigned long start, unsigned long end, unsigned long lba_len) #define truncate_pat_collision(r,n) (0) #endif -static void pcibios_allocate_bridge_resources(struct pci_dev *dev) -{ - int idx; - struct resource *r; - - for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { - r = &dev->resource[idx]; - if (!r->flags) - continue; - if (r->parent) /* Already allocated */ - continue; - if (!r->start || pci_claim_bridge_resource(dev, idx) < 0) { - /* - * Something is wrong with the region. - * Invalidate the resource to prevent - * child resource allocations in this - * range. - */ - r->start = r->end = 0; - r->flags = 0; - } - } -} - -static void pcibios_allocate_bus_resources(struct pci_bus *bus) -{ - struct pci_bus *child; - - /* Depth-First Search on bus tree */ - if (bus->self) - pcibios_allocate_bridge_resources(bus->self); - list_for_each_entry(child, &bus->children, node) - pcibios_allocate_bus_resources(child); -} - /* ** The algorithm is generic code. @@ -725,13 +690,7 @@ lba_fixup_bus(struct pci_bus *bus) ** Properly Setup MMIO resources for this bus. ** pci_alloc_primary_bus() mangles this. */ - if (bus->parent) { - /* PCI-PCI Bridge */ - pci_read_bridge_bases(bus); - - /* check and allocate bridge resources */ - pcibios_allocate_bus_resources(bus); - } else { + if (!bus->parent) { /* Host-PCI Bridge */ int err; @@ -744,6 +703,10 @@ lba_fixup_bus(struct pci_bus *bus) ldev->hba.lmmio_space.start, ldev->hba.lmmio_space.end, ldev->hba.lmmio_space.flags); + /* + * This should probably be done elsewhere, such as in + * lba_driver_probe()... + */ err = request_resource(&ioport_resource, &(ldev->hba.io_space)); if (err < 0) { lba_dump_res(&ioport_resource, 2); @@ -793,26 +756,8 @@ lba_fixup_bus(struct pci_bus *bus) } list_for_each_entry(dev, &bus->devices, bus_list) { - int i; - DBG("lba_fixup_bus() %s\n", pci_name(dev)); - /* Virtualize Device/Bridge Resources. */ - for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { - struct resource *res = &dev->resource[i]; - - /* If resource not allocated - skip it */ - if (!res->start) - continue; - - /* - ** FIXME: this will result in whinging for devices - ** that share expansion ROMs (think quad tulip), but - ** isn't harmful. - */ - pci_claim_resource(dev, i); - } - #ifdef FBB_SUPPORT /* ** If one device does not support FBB transfers, @@ -1628,25 +1573,30 @@ lba_driver_probe(struct parisc_device *dev) return 0; } + /* + * The previous code would claim bus and device resources from + * pcibios_fixup_bus(). I've removed that code, in favor of + * doing things here via the generic pci_host_resource_survey(). + */ + if (!is_pdc_pat()) { + /* Override the policy to "claim only" on non-PAT */ + struct pci_host_bridge *host = pci_find_host_bridge(lba_bus); + host->rsrc_policy = pci_rsrc_claim_only; + } max = pci_scan_child_bus(lba_bus); - - /* This is in lieu of calling pci_assign_unassigned_resources() */ - if (is_pdc_pat()) { - /* assign resources to un-initialized devices */ - - DBG_PAT("LBA pci_bus_size_bridges()\n"); - pci_bus_size_bridges(lba_bus); - - DBG_PAT("LBA pci_bus_assign_resources()\n"); - pci_bus_assign_resources(lba_bus); + pci_host_resource_survey(lba_bus); #ifdef DEBUG_LBA_PAT - DBG_PAT("\nLBA PIOP resource tree\n"); - lba_dump_res(&lba_dev->hba.io_space, 2); - DBG_PAT("\nLBA LMMIO resource tree\n"); - lba_dump_res(&lba_dev->hba.lmmio_space, 2); + /* + * This debug code used to be only in is_pdc_pat(), but with the + * changes to use generic code, making it unconditional might help + * diagnose issues + */ + DBG_PAT("\nLBA PIOP resource tree\n"); + lba_dump_res(&lba_dev->hba.io_space, 2); + DBG_PAT("\nLBA LMMIO resource tree\n"); + lba_dump_res(&lba_dev->hba.lmmio_space, 2); #endif - } /* ** Once PCI register ops has walked the bus, access to config |