]> asedeno.scripts.mit.edu Git - linux.git/commit
vfio/pci: Restore device state on PM transition
authorAlex Williamson <alex.williamson@redhat.com>
Sat, 9 Feb 2019 20:43:30 +0000 (13:43 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 18 Feb 2019 21:55:53 +0000 (14:55 -0700)
commit51ef3a004b1eb6241e56b3aa8495769a092a4dc2
treeefbec861a722c7ab01af18d246e286e45f4bb0a8
parenta3906855890d94736d240f0f637585c1470d8d02
vfio/pci: Restore device state on PM transition

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: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/vfio_pci.c
drivers/vfio/pci/vfio_pci_config.c
drivers/vfio/pci/vfio_pci_private.h