]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
powerpc/pci: Save P2P bridge resource if possible
authorGavin Shan <shangw@linux.vnet.ibm.com>
Sun, 3 Jun 2012 22:15:25 +0000 (22:15 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 7 Sep 2012 00:45:30 +0000 (10:45 +1000)
When PCI probe flag PCI_REASSIGN_ALL_RSRC has been passed into PCI
core, it's hoped that all resources to be reassigned by PCI core.
As to particular P2P (PCI-to-PCI) bridge, the size of the corresponding
BAR (I/O, MMIO, prefetchable MMIO) is calculated by the resources
required by the PCI devices behind the P2P bridge. That means that
the information like start/end address retrieved from the hardware
registers of the P2P bridge is meainingless in the case. However,
we still count that in and the BARs might have been configured by
firmware with non-zero size. That leads to space waste.

The patch explicitly sets the size of P2P bridge BARs to zero in
case that resource reassignment is expected with PCI probe flag
PCI_REASSIGN_ALL_RSRC. In the result, it will save overall resource
required by the system without waste.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/pci-common.c

index 2aa04f29e1de95d89f295c190bb56754ba84efd7..4cb714792bea52ad4ebfac8112c32bcfb3fb2eb4 100644 (file)
@@ -960,13 +960,14 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
                if (i >= 3 && bus->self->transparent)
                        continue;
 
-               /* If we are going to re-assign everything, mark the resource
-                * as unset and move it down to 0
+               /* If we're going to reassign everything, we can
+                * shrink the P2P resource to have size as being
+                * of 0 in order to save space.
                 */
                if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
                        res->flags |= IORESOURCE_UNSET;
-                       res->end -= res->start;
                        res->start = 0;
+                       res->end = -1;
                        continue;
                }
 
@@ -1228,7 +1229,14 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
                pr_warning("PCI: Cannot allocate resource region "
                           "%d of PCI bridge %d, will remap\n", i, bus->number);
        clear_resource:
-               res->start = res->end = 0;
+               /* The resource might be figured out when doing
+                * reassignment based on the resources required
+                * by the downstream PCI devices. Here we set
+                * the size of the resource to be 0 in order to
+                * save more space.
+                */
+               res->start = 0;
+               res->end = -1;
                res->flags = 0;
        }