]> asedeno.scripts.mit.edu Git - linux.git/commit
PCI: hv: Add hibernation support
authorDexuan Cui <decui@microsoft.com>
Mon, 25 Nov 2019 05:33:52 +0000 (21:33 -0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 26 Nov 2019 10:32:33 +0000 (10:32 +0000)
commitac82fc83270884adea31d9dec22db09392058bf7
treee7220c5039d8cd9189ba7c86cc04a06aa4faaf90
parenta8e37506e79a7a08d0ee217f389fa1710e7a2ea4
PCI: hv: Add hibernation support

Add suspend() and resume() functions so that Hyper-V virtual PCI devices
are handled properly when the VM hibernates and resumes from
hibernation.

Note that the suspend() function must make sure there are no pending
work items before calling vmbus_close(), since it runs in a process
context as a callback in dpm_suspend(). When it starts to run, the
channel callback hv_pci_onchannelcallback(), which runs in a tasklet
context, can be still running concurrently and scheduling new work items
onto hbus->wq in hv_pci_devices_present() and hv_pci_eject_device(), and
the work item handlers can access the vmbus channel, which can be being
closed by hv_pci_suspend(), e.g. the work item handler
pci_devices_present_work() -> new_pcichild_device() writes to the vmbus
channel.

To eliminate the race, hv_pci_suspend() disables the channel callback
tasklet, sets hbus->state to hv_pcibus_removing, and re-enables the
tasklet.  This way, when hv_pci_suspend() proceeds, it knows that no new
work item can be scheduled, and then it flushes hbus->wq and safely
closes the vmbus channel.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
drivers/pci/controller/pci-hyperv.c