Skip to content
  • Christian König's avatar
    PCI: Add pci_resize_resource() for resizing BARs · 8bb705e3
    Christian König authored
    
    
    Add a pci_resize_resource() interface to allow device drivers to resize
    BARs of their devices.
    
    This is useful for devices with large local storage, e.g., graphics
    devices.  These devices often only expose 256MB BARs initially to be
    compatible with 32-bit systems.
    
    This function only tries to reprogram the windows of the bridge directly
    above the requesting device and only the BAR of the same type (usually mem,
    64bit, prefetchable).  This is done to avoid disturbing other drivers by
    changing the BARs of their devices.
    
    Drivers should use the following sequence to resize their BARs:
    1. Disable memory decoding of the device using the PCI cfg dword.
    2. Use pci_release_resource() to release all BARs which can move during the
       resize, including the one you want to resize.
    3. Call pci_resize_resource() for each BAR you want to resize.
    4. Call pci_assign_unassigned_bus_resources() to reassign new locations
       for all BARs which are not resized, but could move.
    5. If everything worked as expected, enable memory decoding in the device
       again using the PCI cfg dword.
    
    Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    8bb705e3