Preferred way to save and restore entirety of device config space

I have an PCI device that following a flash update the BARs and other programmable portions of config space need to be restored. Are there any convenience functions for traversing/saving config space? It’s somewhat tedious (and error prone) to restore the BAR addresses, then enable memory access, then walk the capability registers and restore them.

No. It’s always going to be a hack. If your hardware supports PCI hotplug (few do), then you can drop off the bus and reappear, and the operating system will reallocate the BARs. I have seen systems where this works, but you can’t rely on it in the wild.

The only reliable solution is to force a reboot.

Hmmm… Sorry, it’s not clear to me what you need to happen, Mr. @Shane_Corbin… Mr. Roberts clearly understands, so I must be a bit slow today.

You can make your device disappear off the bus and re-appear, using GUID_DEVICE_RESET_INTERFACE_STANDARD . But I admit: I haven’t actually DONE this myself, so I don’t know what devices on the PCI Bus Driver do with this by default. But it LOOKS to me like a power-off reset??

Peter