On Sat, Mar 28, 2015 at 3:02 AM, Yijing Wang <wangyijing@xxxxxxxxxx> wrote: > ... > > I compared above log and found after we did remove and rescan, the bridge requested resource size extended to 0x06000000, > and when system boot up, it requested only 0x4800000. > > In hotplug(remove and rescan) path, we would call calculate_mem_align() function which would align the resource at 0x2000000. Looks like we align the size too early. Please check if attach patch could fix the problem. Thanks Yinghai
Subject: [RFT PATCH] PCI: Align resource size later in bus mem sizing TEST only. We only need to align the size on bridge up one level later. --- drivers/pci/setup-bus.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) Index: linux-2.6/drivers/pci/setup-bus.c =================================================================== --- linux-2.6.orig/drivers/pci/setup-bus.c +++ linux-2.6/drivers/pci/setup-bus.c @@ -783,8 +783,7 @@ static resource_size_t calculate_iosize( static resource_size_t calculate_memsize(resource_size_t size, resource_size_t min_size, resource_size_t size1, - resource_size_t old_size, - resource_size_t align) + resource_size_t old_size) { if (size < min_size) size = min_size; @@ -792,8 +791,8 @@ static resource_size_t calculate_memsize old_size = 0; if (size < old_size) size = old_size; - size = ALIGN(size + size1, align); - return size; + + return size + size1; } resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus, @@ -1008,10 +1007,10 @@ static int pbus_size_mem(struct pci_bus r->flags = 0; continue; } - size += r_size; + size += ALIGN(r_size, align); /* Exclude ranges with size > align from calculation of the alignment. */ - if (r_size == align) + if (r_size <= align) aligns[order] += align; if (order > max_order) max_order = order; @@ -1023,12 +1022,12 @@ static int pbus_size_mem(struct pci_bus min_align = calculate_mem_align(aligns, max_order); min_align = max(min_align, window_alignment(bus, b_res->flags)); - size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); + size0 = calculate_memsize(size, min_size, 0, resource_size(b_res)); if (children_add_size > add_size) add_size = children_add_size; size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : calculate_memsize(size, min_size, add_size, - resource_size(b_res), min_align); + resource_size(b_res)); if (!size0 && !size1) { if (b_res->start || b_res->end) dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n",