]> Pileus Git - ~andy/linux/commit
PCI: Enforce bus address limits in resource allocation
authorYinghai Lu <yinghai@kernel.org>
Fri, 20 Dec 2013 16:57:37 +0000 (09:57 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 7 Jan 2014 23:24:33 +0000 (16:24 -0700)
commitf75b99d5a77d63f20e07bd276d5a427808ac8ef6
treed95860eb9124958ce6cda8cc927403c97ff3d358
parent36e097a8a29761e0e2c951c0390f1057df248a87
PCI: Enforce bus address limits in resource allocation

When allocating space for 32-bit BARs, we previously limited RESOURCE
addresses so they would fit in 32 bits.  However, the BUS address need not
be the same as the resource address, and it's the bus address that must fit
in the 32-bit BAR.

This patch adds:

  - pci_clip_resource_to_region(), which clips a resource so it contains
    only the range that maps to the specified bus address region, e.g., to
    clip a resource to 32-bit bus addresses, and

  - pci_bus_alloc_from_region(), which allocates space for a resource from
    the specified bus address region,

and changes pci_bus_alloc_resource() to allocate space for 64-bit BARs from
the entire bus address region, and space for 32-bit BARs from only the bus
address region below 4GB.

If we had this window:

  pci_root HWP0002:0a: host bridge window [mem 0xf0180000000-0xf01fedfffff] (bus address [0x80000000-0xfedfffff])

we previously could not put a 32-bit BAR there, because the CPU addresses
don't fit in 32 bits.  This patch fixes this, so we can use this space for
32-bit BARs.

It's also possible (though unlikely) to have resources with 32-bit CPU
addresses but bus addresses above 4GB.  In this case the previous code
would allocate space that a 32-bit BAR could not map.

Remove PCIBIOS_MAX_MEM_32, which is no longer used.

[bhelgaas: reworked starting from http://lkml.kernel.org/r/1386658484-15774-3-git-send-email-yinghai@kernel.org]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
arch/x86/include/asm/pci.h
drivers/pci/bus.c
include/linux/pci.h