]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
PCI: don't shrink bridge resources
authorYinghai Lu <yinghai@kernel.org>
Fri, 22 Jan 2010 09:02:23 +0000 (01:02 -0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 23 Feb 2010 00:17:21 +0000 (16:17 -0800)
When clearing leaf bridge resources, trying to get a big enough one, we
could shrink the bridge if there is no resource under it.  Confirm
against the old resource side to make sure we're increasing the
allocation.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/setup-bus.c

index 7e87ea8f320006cd39e8be30c8fc71aa5ccc3728..f560814c557c6e04696d65288e05eca7f4289dbc 100644 (file)
@@ -382,7 +382,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size)
 {
        struct pci_dev *dev;
        struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
-       unsigned long size = 0, size1 = 0;
+       unsigned long size = 0, size1 = 0, old_size;
 
        if (!b_res)
                return;
@@ -407,12 +407,17 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size)
        }
        if (size < min_size)
                size = min_size;
+       old_size = resource_size(b_res);
+       if (old_size == 1)
+               old_size = 0;
 /* To be fixed in 2.5: we should have sort of HAVE_ISA
    flag in the struct pci_bus. */
 #if defined(CONFIG_ISA) || defined(CONFIG_EISA)
        size = (size & 0xff) + ((size & ~0xffUL) << 2);
 #endif
        size = ALIGN(size + size1, 4096);
+       if (size < old_size)
+               size = old_size;
        if (!size) {
                if (b_res->start || b_res->end)
                        dev_info(&bus->self->dev, "disabling bridge window "
@@ -433,7 +438,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
                         unsigned long type, resource_size_t min_size)
 {
        struct pci_dev *dev;
-       resource_size_t min_align, align, size;
+       resource_size_t min_align, align, size, old_size;
        resource_size_t aligns[12];     /* Alignments from 1Mb to 2Gb */
        int order, max_order;
        struct resource *b_res = find_free_bus_resource(bus, type);
@@ -483,6 +488,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
        }
        if (size < min_size)
                size = min_size;
+       old_size = resource_size(b_res);
+       if (old_size == 1)
+               old_size = 0;
+       if (size < old_size)
+               size = old_size;
 
        align = 0;
        min_align = 0;