diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-09-17 22:24:28 -0700 |
---|---|---|
committer | Yinghai Lu <yinghai@kernel.org> | 2012-09-17 22:24:28 -0700 |
commit | 71ed3575c9baa3989072e2fb2af01f72da28108c (patch) | |
tree | 7d754507fd575ff524f084a835a529da1b35c905 | |
parent | 41a1d23d5f8daf38dba2b76634036beb47743b23 (diff) | |
download | linux-yinghai-71ed3575c9baa3989072e2fb2af01f72da28108c.tar.gz |
PCI: Probe safe range that we can use for unassigned bridge.
Try to allocate from parent bus busn_res. If we can not find any big enough,
will try to extend parent bus top. even the extending is through allocating,
after allocating will pad the range to parent buses top.
When extending happens, We will record the parent_res, so could use it as
stopper for really extend/shrink top later.
-v4: Use generic probe_resource()
-v5: Use updated probe_resource() that will not decrease needed_size
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
-rw-r--r-- | drivers/pci/probe.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 471f7a331c840..84a307e27197f 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -892,6 +892,39 @@ static void __devinit pci_bus_shrink_top(struct pci_bus *parent, pci_bus_extend_top(parent, -size, parent_res); } +static int __devinit pci_bridge_probe_busn_res(struct pci_bus *bus, + struct pci_dev *dev, struct resource *busn_res, + resource_size_t needed_size, struct resource **p) +{ + int ret = -ENOMEM; + int old_size = resource_size(&bus->busn_res); + int skip_nr = 1; + int stop_flags = IORESOURCE_PCI_FIXED; + int i; + + for (i = needed_size; i > 0; i--) { + ret = probe_resource(&bus->busn_res, busn_res, i, + p, skip_nr, stop_flags); + + if (!ret) + break; + } + + if (!i) + return ret; + + busn_res->flags = IORESOURCE_BUS; + + if (*p) { + /* extend parent bus top*/ + int new_size = resource_size(&bus->busn_res); + + pci_bus_extend_top(bus, new_size - old_size, *p); + } + + return ret; +} + /* * If it's a bridge, configure it and scan the bus behind it. * For CardBus bridges, we don't scan behind as the devices will |