• Ross Lagerwall's avatar
    PCI: Release resource invalidated by coalescing · e5422327
    Ross Lagerwall authored
    When contiguous windows are coalesced by pci_register_host_bridge(), the
    second resource is expanded to include the first, and the first is
    invalidated and consequently not added to the bus. However, it remains in
    the resource hierarchy.  For example, these windows:
    
      fec00000-fec7ffff : PCI Bus 0000:00
      fec80000-fecbffff : PCI Bus 0000:00
    
    are coalesced into this, where the first resource remains in the tree with
    start/end zeroed out:
    
      00000000-00000000 : PCI Bus 0000:00
      fec00000-fecbffff : PCI Bus 0000:00
    
    In some cases (e.g. the Xen scratch region), this causes future calls to
    allocate_resource() to choose an inappropriate location which the caller
    cannot handle.
    
    Fix by releasing the zeroed-out resource and removing it from the resource
    hierarchy.
    
    [bhelgaas: commit log]
    Fixes: 7c3855c4 ("PCI: Coalesce host bridge contiguous apertures")
    Link: https://lore.kernel.org/r/20230525153248.712779-1-ross.lagerwall@citrix.comSigned-off-by: default avatarRoss Lagerwall <ross.lagerwall@citrix.com>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org	# v5.16+
    e5422327
probe.c 86.1 KB