• Alex Williamson's avatar
    vfio/pci: Restore device state on PM transition · 51ef3a00
    Alex Williamson authored
    PCI core handles save and restore of device state around reset, but
    when using pci_set_power_state() we can unintentionally trigger a soft
    reset of the device, where PCI core only restores the BAR state.  If
    we're using vfio-pci's idle D3 support to try to put devices into low
    power when unused, this might trigger a reset when the device is woken
    for use.  Also power state management by the user, or within a guest,
    can put the device into D3 power state with potentially limited
    ability to restore the device if it should undergo a reset.  The PCI
    spec does not define the extent of a soft reset and many devices
    reporting soft reset on D3->D0 transition do not undergo a PCI config
    space reset.  It's therefore assumed safe to unconditionally restore
    the remainder of the state if the device indicates soft reset
    support, even on a user initiated wakeup.
    
    Implement a wrapper in vfio-pci to tag devices reporting PM reset
    support, save their state on transitions into D3 and restore on
    transitions back to D0.
    Reported-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
    Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    51ef3a00
vfio_pci_config.c 49.9 KB