Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3869954ybz; Mon, 4 May 2020 11:13:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKtq6C6ScJle9GLuZ300ukz/pLf6Jst/3XiaWp1kDo1CSG3eRYe87edG3ZNwV/zuWU/pD+j X-Received: by 2002:a17:906:1751:: with SMTP id d17mr15698890eje.314.1588615980117; Mon, 04 May 2020 11:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588615980; cv=none; d=google.com; s=arc-20160816; b=nC2wxcrFpAHwsj9xXTdwpBnKPvsaLEnNNTMzUNjzSIUNfyKpCjZRrDEdRumBNimzyc TuTXZ8BelU3QQhZmBhx2D64W0uap7MeJ6KH6D3hGsmGOGhr5p0nVh5k0YQ8M8BWexFKf C35fSxswOj3ddLU9yWnhHIfE7INHzPCA/i5qaBqZSVvHigXKnVYWK6hZuywBnKCFovge 8xLT5nKXX/KZLgdG1plcsct4EK+Og36eEI/Koj5AFJ6s/FBzNsDFOrI5GXr6/GxPvNQX YW54EVH0V1xvqGqDVr6JEpA58D42lJ4a3bJp2VoqXEJ0hmxxMzxfwx5dxXdi5pwSjxZW oRtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+h7jhRxDYl98M4iQsIOzbWBq2ueTPWY80jdEbtUllUk=; b=zCcoWPZ/qrB/q8l0Aht+MPLtvXIMwZNl/ciBQ3KE3tzXANDNw2raVJNiYyy3WO49iZ EfANsxwOnZvykgqs7pqg+aJriDNksZSzrVJlYnKiT3WnriHbUPRthgIyWHkw+KTgFMO7 wXHgOI9qDAVk0tAU8rZuw/+rA4MO6IiqqukBUaJrivUEVqfHlaZrSA+5l3ZryWfp/1rZ K0yQd/7VKCl42C1MNXjUq0uoELCQScHntlN6hcIExt2n7YTkIGo38htmY2bYW3vIXgQ5 1FkiqDBnlrVDqeUCaLpLaHRgoaBbDQbkUtnmTMyI6CqOXKFADAix28xSjkwliKAKSeNq Uc6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UZJaOsin; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si7370127edn.210.2020.05.04.11.12.37; Mon, 04 May 2020 11:13:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UZJaOsin; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731979AbgEDSJ7 (ORCPT + 99 others); Mon, 4 May 2020 14:09:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730810AbgEDSGD (ORCPT ); Mon, 4 May 2020 14:06:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5651A205ED; Mon, 4 May 2020 18:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588615562; bh=Mua+sMQzr3POhYCOn5RPotb5tnVTDlzYZE2WaBFwzFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZJaOsinusU20Ac3/LkXHY6DMULo9YO8bFqnDkpFQABRZPgFEttdaK5Z5C0m2OQew 5992MSaNVK4cKAdUeYIcHAzhSkE5s4sZx1gBT7To4SkfmH6V23SPJ4dDlEA6By8k03 WJSyxSb0BMdtUMmh623girSzoNUQp3EtWB2TT/u8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Dexuan Cui , Wei Liu Subject: [PATCH 5.6 30/73] Drivers: hv: vmbus: Fix Suspend-to-Idle for Generation-2 VM Date: Mon, 4 May 2020 19:57:33 +0200 Message-Id: <20200504165507.267516405@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200504165501.781878940@linuxfoundation.org> References: <20200504165501.781878940@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dexuan Cui commit 1a06d017fb3f388734ffbe5dedee6f8c3af5f2db upstream. 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") Cc: stable@vger.kernel.org Reviewed-by: Michael Kelley Signed-off-by: Dexuan Cui Link: https://lore.kernel.org/r/1586663435-36243-1-git-send-email-decui@microsoft.com Signed-off-by: Wei Liu Signed-off-by: Greg Kroah-Hartman --- drivers/hv/vmbus_drv.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -978,6 +978,9 @@ static int vmbus_resume(struct device *c return drv->resume(dev); } +#else +#define vmbus_suspend NULL +#define vmbus_resume NULL #endif /* CONFIG_PM_SLEEP */ /* @@ -997,11 +1000,22 @@ static void vmbus_device_release(struct } /* - * 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 */ @@ -2281,6 +2295,9 @@ static int vmbus_bus_resume(struct devic return 0; } +#else +#define vmbus_bus_suspend NULL +#define vmbus_bus_resume NULL #endif /* CONFIG_PM_SLEEP */ static const struct acpi_device_id vmbus_acpi_device_ids[] = { @@ -2291,16 +2308,24 @@ static const struct acpi_device_id vmbus 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 this 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 = {