]> Pileus Git - ~andy/linux/commitdiff
PCI: Split out bridge window override of minimum allocation address
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 18 Dec 2013 23:31:39 +0000 (16:31 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 7 Jan 2014 23:24:33 +0000 (16:24 -0700)
pci_bus_alloc_resource() avoids allocating space below the "min" supplied
by the caller (usually PCIBIOS_MIN_IO or PCIBIOS_MIN_MEM).  This is to
protect badly documented motherboard resources.  But if we're allocating
space inside an already-configured PCI-PCI bridge window, we ignore "min".

See 688d191821de ("pci: make bus resource start address override minimum IO
address").

This patch moves the check to make it more visible and simplify future
patches.  No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/bus.c

index fc1b740137430b703a348b03d1c9420d19d21d7a..6f2f47a7b6c60b557df2f26b57dddeaf0b2f4be3 100644 (file)
@@ -147,11 +147,18 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
                    !(res->flags & IORESOURCE_PREFETCH))
                        continue;
 
+               /*
+                * "min" is typically PCIBIOS_MIN_IO or PCIBIOS_MIN_MEM to
+                * protect badly documented motherboard resources, but if
+                * this is an already-configured bridge window, its start
+                * overrides "min".
+                */
+               if (r->start)
+                       min = r->start;
+
                /* Ok, try it out.. */
-               ret = allocate_resource(r, res, size,
-                                       r->start ? : min,
-                                       max, align,
-                                       alignf, alignf_data);
+               ret = allocate_resource(r, res, size, min, max,
+                                       align, alignf, alignf_data);
                if (ret == 0)
                        break;
        }