]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
PCI: Add pci_resize_resource() for resizing BARs
authorChristian König <christian.koenig@amd.com>
Tue, 24 Oct 2017 19:40:26 +0000 (14:40 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 25 Oct 2017 21:07:31 +0000 (16:07 -0500)
commit8bb705e3e79d84e77edd4499e74483dd96a4626c
tree6e8ec3230481d768d7a5a53e12d6975fb1bd9e9f
parent276b738deb5bf856b9f6049fcd92a967f52643d7
PCI: Add pci_resize_resource() for resizing BARs

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: Christian König <christian.koenig@amd.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/setup-bus.c
drivers/pci/setup-res.c
include/linux/pci.h