• Bjorn Helgaas's avatar
    PCI: Remove pci_find_parent_resource() use for allocation · f44116ae
    Bjorn Helgaas authored
    If the resource hasn't been allocated yet, pci_find_parent_resource() is
    documented as returning the region "where it should be allocated from."
    This is impossible in general because there may be several candidates: a
    prefetchable BAR can be put in either a prefetchable or non-prefetchable
    window, a transparent bridge may have overlapping positively- and
    subtractively-decoded windows, and a root bus may have several windows of
    the same type.
    
    Allocation should be done by pci_bus_alloc_resource(), which iterates
    through all bus resources and looks for the best match, e.g., one with the
    desired prefetchability attributes, and falls back to less-desired
    possibilities.
    
    The only valid use of pci_find_parent_resource() is to find the parent of
    an already-allocated resource so we can claim it via request_resource(),
    and all we need for that is a bus region of the correct type that contains
    the resource.
    
    Note that like 8c8def26 ("PCI: allow matching of prefetchable resources
    to non-prefetchable windows"), this depends on pci_bus_for_each_resource()
    iterating through positively-decoded regions before subtractively-decoded
    ones.  We prefer not to return a subtractively-decoded region because
    requesting from it will likely conflict with the overlapping positively-
    decoded window (see Launchpad report below).
    
    Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/424142Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    CC: Linus Torvalds <torvalds@linux-foundation.org>
    f44116ae
pci.c 113 KB