Rescan/resize/reallocate PCI device BAR when it changes?
I have a PCI device which can, at run time, change the size of the BARs it makes visible (e.g. a BAR which was disabled can become enabled, a BAR that was 64kiByte becomes 128kiByte, etc.
I would like to get the kernel to reallocate the resources for that device without having to shut the device down and reload the device driver - the device driver will "know" how to handle this sort of event (actually, the driver will be the one that caused the event).
I've tried various combinations of pci_scan_bus, pci_request_resources, etc. to no avail: I can see the hardware change size, but the kernel data structures for the PCI device steadfastly remain unchanged.
This is a fairly common issue for us embedded programmers: we have things like FPGAs and microprocessors as endpoints that, as the device driver finishes programming them, will suddenly have a need for different sized BARs.
I realize that in some cases, it may not be possible to simply resize things (e.g. not enough resources exist within the space allocated for the bridge the device lives on to resize things), and I am prepared to handle such events.