Skip to contentSkip to conversation

Drivers: hv: vmbus: Fix Suspend-to-Idle for Generation-2 VM

PATCH Superseded Dexuan Cui 2 participants 2 messages Apr 10, 2020 – Apr 11, 2020

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH 1/1 Drivers: hv: vmbus: Fix Suspend-to-Idle for Generation-2 VM

Before the hibernation patchset (e.g. f53335e3289f), in a Generation-2 Linux VM on Hyper-V, the user can run "echo freeze > /sys/power/state" to freeze the system, i.e. Suspend-to-Idle. The user can press the keyboard or move the mouse to wake up the VM.

With the hibernation patchset, Linux VM on Hyper-V can hibernate to disk, but Suspend-to-Idle is broken: when the synthetic keyboard/mouse are suspended, there is no way to wake up the VM.

Fix the issue by not suspending and resuming the vmbus devices upon Suspend-to-Idle.

Fixes f53335e3289f ("Drivers: hv: vmbus: Suspend/resume the vmbus itself for hibernation")
---
 drivers/hv/vmbus_drv.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)
drivers/hv/vmbus_drv.c +28 -9
index 029378c27421..821185d20cbd 100644
@@ -969,11 +969,22 @@ static void vmbus_device_release(struct device *device)
 }
 
 /*
- * Note: we must use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS rather than
- * SET_SYSTEM_SLEEP_PM_OPS: see the comment before vmbus_bus_pm.
+ * Note: we must use the "noirq" ops: see the comment before vmbus_bus_pm.
+ *
+ * suspend_noirq/resume_noirq are set to NULL to support Suspend-to-Idle: we
+ * shouldn't suspend the vmbus devices upon Suspend-to-Idle, otherwise there
+ * is no way to wake up a Generation-2 VM.
+ *
+ * The other 4 ops are for hibernation.
  */
+
 static const struct dev_pm_ops vmbus_pm = {
-	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(vmbus_suspend, vmbus_resume)
+	.suspend_noirq	= NULL,
+	.resume_noirq	= NULL,
+	.freeze_noirq	= vmbus_suspend,
+	.thaw_noirq	= vmbus_resume,
+	.poweroff_noirq	= vmbus_suspend,
+	.restore_noirq	= vmbus_resume,
 };
 
 /* The one and only one */
@@ -2263,16 +2274,24 @@ static const struct acpi_device_id vmbus_acpi_device_ids[] = {
 MODULE_DEVICE_TABLE(acpi, vmbus_acpi_device_ids);
 
 /*
- * Note: we must use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS rather than
- * SET_SYSTEM_SLEEP_PM_OPS, otherwise NIC SR-IOV can not work, because the
- * "pci_dev_pm_ops" uses the "noirq" callbacks: in the resume path, the
- * pci "noirq" restore callback runs before "non-noirq" callbacks (see
+ * Note: we must use the "no_irq" ops, otherwise hibernation can not work with
+ * PCI device assignment, because "pci_dev_pm_ops" uses the "noirq" ops: in
+ * the resume path, the pci "noirq" restore op runs before "non-noirq" op (see
  * resume_target_kernel() -> dpm_resume_start(), and hibernation_restore() ->
  * dpm_resume_end()). This means vmbus_bus_resume() and the pci-hyperv's
- * resume callback must also run via the "noirq" callbacks.
+ * resume callback must also run via the "noirq" ops.
+ *
+ * Set suspend_noirq/resume_noirq to NULL for Suspend-to-Idle: see the comment
+ * earlier in thie file before vmbus_pm.
  */
+
 static const struct dev_pm_ops vmbus_bus_pm = {
-	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(vmbus_bus_suspend, vmbus_bus_resume)
+	.suspend_noirq	= NULL,
+	.resume_noirq	= NULL,
+	.freeze_noirq	= vmbus_bus_suspend,
+	.thaw_noirq	= vmbus_bus_resume,
+	.poweroff_noirq	= vmbus_bus_suspend,
+	.restore_noirq	= vmbus_bus_resume
 };
 
 static struct acpi_driver vmbus_acpi_driver = {
Signature · 1 line
2.19.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Dexuan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.6 next-20200410]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dexuan-Cui/Drivers-hv-vmbus-Fix-Suspend-to-Idle-for-Generation-2-VM/20200411-061907
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git c0cc271173b2e1c2d8d0ceaef14e4dfa79eefc0d
config: x86_64-randconfig-h003-20200410 (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> drivers/hv/vmbus_drv.c:984:18: error: 'vmbus_suspend' undeclared here (not in a function); did you mean 'vmbus_uevent'?
     .freeze_noirq = vmbus_suspend,
                     ^~~~~~~~~~~~~
                     vmbus_uevent
>> drivers/hv/vmbus_drv.c:985:16: error: 'vmbus_resume' undeclared here (not in a function); did you mean 'vmbus_remove'?
     .thaw_noirq = vmbus_resume,
                   ^~~~~~~~~~~~
                   vmbus_remove
>> drivers/hv/vmbus_drv.c:2291:18: error: 'vmbus_bus_suspend' undeclared here (not in a function); did you mean 'vmbus_suspend'?
     .freeze_noirq = vmbus_bus_suspend,
                     ^~~~~~~~~~~~~~~~~
                     vmbus_suspend
>> drivers/hv/vmbus_drv.c:2292:16: error: 'vmbus_bus_resume' undeclared here (not in a function); did you mean 'vmbus_resume'?

.thaw_noirq = vmbus_bus_resume,
^~~~~~~~~~~~~~~~
vmbus_resume

vim +984 drivers/hv/vmbus_drv.c

970
971 /*
972 * Note: we must use the "noirq" ops: see the comment before vmbus_bus_pm.
973 *
974 * suspend_noirq/resume_noirq are set to NULL to support Suspend-to-Idle: we
975 * shouldn't suspend the vmbus devices upon Suspend-to-Idle, otherwise there
976 * is no way to wake up a Generation-2 VM.
977 *
978 * The other 4 ops are for hibernation.
979 */
980
981 static const struct dev_pm_ops vmbus_pm = {
982 .suspend_noirq = NULL,
983 .resume_noirq = NULL,

 > 984		.freeze_noirq	= vmbus_suspend,
 > 985		.thaw_noirq	= vmbus_resume,

986 .poweroff_noirq = vmbus_suspend,
987 .restore_noirq = vmbus_resume,
988 };
989

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org