Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1020316ybb; Fri, 10 Apr 2020 15:18:59 -0700 (PDT) X-Google-Smtp-Source: APiQypJEU6u5n6XI9lxBl7o6nU8E7lgQhCKV0r9EvkLiwO5kIKSd98mQTvUf1D69Kt80kfV6+9bJ X-Received: by 2002:a37:a4c3:: with SMTP id n186mr6146356qke.62.1586557138883; Fri, 10 Apr 2020 15:18:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1586557138; cv=pass; d=google.com; s=arc-20160816; b=PTguoAUmUp+c5/9APnAwWc2A3s6Ab3TQj3NMfzN1D8cyMiFn3cbNAyQQwt2K1/dExO U0T+4uliac6UKl4pAwD9utvbagPhA2R1NiByWQro/f0tvP84H3+ueNiTDoGNVTJGfgmO cMj2PfeKsK/fF6nWhPxVFNfgsjOey4cE1wvcPq/qC1e5lsxOrX8lLh2F9ointwHhQ7t6 8SuFfv7rwBn76/SX366TsO7x5ev/4VKlZ/5u9hkOI2vmYhoVYVQp+jq+bevxIg4qfiih 9zekDz2Z3e4KseaOABZmFxOFhqisN2BYyGrXc5FrN34LmC0LA534xgEi9wnkxGkkXECc hZzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=94oKViTZYfV255bKs841lRpVgakFZ99tR9nmqF+B94s=; b=tCz+kxRo34YAeOaExTVLxRy/j6E7vHUBr5SC4xkaKuaL+kAhtA1BofrPSJAb7Ku71s Shrc7Odok1daG0zt/uHU/vgRv0KJLvscnVFt3BUB0f6/X5lzDBIMaxR0VXPb+9V2a/j2 dFqvsV8CfDWm7UnYbi7fU/uMyrNriMhsKLhFxmeibQaYaCf42jLEQfOGtTrAfU2q1Chw ZELd2xw7Yn9KSqmdLCtGS+hJmScrTw6SmEhYEaAtRiYEYGsn+YtCZpWLkIv/XxeVKSJs 1KU0D7FUX1CBpIUquwP2k5rOnW/kaTKeeAYrXcGkfgE0NJYCvVN6UnLa0wX/3yxcIyid vz0Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=UE0L9XV5; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z29si1810696qtu.170.2020.04.10.15.18.44; Fri, 10 Apr 2020 15:18:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=UE0L9XV5; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgDJWSA (ORCPT + 99 others); Fri, 10 Apr 2020 18:18:00 -0400 Received: from mail-bn8nam11on2111.outbound.protection.outlook.com ([40.107.236.111]:57441 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726594AbgDJWR7 (ORCPT ); Fri, 10 Apr 2020 18:17:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BrvVPiPTobMyjQjuytem5MLLhUefGDnLWDPxtiz9NxHjd7dW12blvyTAcUz0hfO2U+/WISgmyd0Q63sayRsepX+PSCkH98QNo+QraP751WvexPhMouafcO/bXvQGV0ADBrixps9BWOSuExX2Tb/tdKLfDPLQEJNTZJwNg25xmY5jRkEExShR8WIiVPraLp9j/SaQTNwBfslJUentmah6mFAVM1il4/JGkPWZyvF7s45vGRLaMKMG+TtOFIillzjiyhLDVL6ldTq/wVODVefquAxOg6P8Xz/vBpJFWypLRjqNdTeQmThwigLKeM0NdG8Xd57neunPfVPczcvWLFRdaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=94oKViTZYfV255bKs841lRpVgakFZ99tR9nmqF+B94s=; b=OnS1pxZvhRK1OMe4A0kPdvAbg/5H7x5EUwVYANz+003SCzXoipAABU2Oqj9EWdmj2p3t+GXp0kn+9IF9h0IBbkW3mP/6+8CFMahwSPHrm85Ts9Mgu84zi5Wk5d7wMaD96qras6fuomzrgjKWyVf/HFRTSVhBIvVMjxXZaLrX2Vj8+yk3EXVhrH/HzNVHHax/wDV2GnnViQSDxruBkk2eP8T7IG0TmzubgyhjprlEcPPUZ4XD91/FOgBNdyJyiW7fzlyTEgERvGExCB2dggaL7XpKlpy6OdOXGcB4llW0YywfpzX6Gyc3vtozRksYuO85sbwDhJidZla1QQxUG5VFuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=94oKViTZYfV255bKs841lRpVgakFZ99tR9nmqF+B94s=; b=UE0L9XV5wybrs8jxIG/4JPiAtkq4RNg7Pn14PioKz6pTHp7P5pv/PSMwZuZApxeei4HW7AOqqmKcdYVNnX88C8xQM7lv22zjeY76MjBx57dBwEGf4XHHSHJu/yA4+IbPrwud2+WThfATI96K6M+pCROv34o29CfxegJ+q7Ie7hU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; Received: from BN8PR21MB1139.namprd21.prod.outlook.com (2603:10b6:408:72::10) by BN8PR21MB1204.namprd21.prod.outlook.com (2603:10b6:408:76::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.6; Fri, 10 Apr 2020 22:17:57 +0000 Received: from BN8PR21MB1139.namprd21.prod.outlook.com ([fe80::b01b:e85:784d:4581]) by BN8PR21MB1139.namprd21.prod.outlook.com ([fe80::b01b:e85:784d:4581%9]) with mapi id 15.20.2921.009; Fri, 10 Apr 2020 22:17:57 +0000 From: Dexuan Cui To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com, vkuznets@redhat.com Cc: Dexuan Cui , stable@vger.kernel.org Subject: [PATCH] Drivers: hv: vmbus: Fix Suspend-to-Idle for Generation-2 VM Date: Fri, 10 Apr 2020 15:17:35 -0700 Message-Id: <1586557055-13776-1-git-send-email-decui@microsoft.com> X-Mailer: git-send-email 1.8.3.1 Reply-To: decui@microsoft.com Content-Type: text/plain X-ClientProxiedBy: MWHPR1201CA0023.namprd12.prod.outlook.com (2603:10b6:301:4a::33) To BN8PR21MB1139.namprd21.prod.outlook.com (2603:10b6:408:72::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (13.77.154.182) by MWHPR1201CA0023.namprd12.prod.outlook.com (2603:10b6:301:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Fri, 10 Apr 2020 22:17:55 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [13.77.154.182] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f4b8a624-5e37-4764-9453-08d7dd9d0508 X-MS-TrafficTypeDiagnostic: BN8PR21MB1204:|BN8PR21MB1204:|BN8PR21MB1204: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0369E8196C X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR21MB1139.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(4636009)(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(6506007)(316002)(66946007)(16526019)(478600001)(186003)(10290500003)(2616005)(2906002)(66476007)(66556008)(956004)(3450700001)(6666004)(86362001)(4326008)(5660300002)(6486002)(8936002)(6512007)(15650500001)(82960400001)(8676002)(82950400001)(36756003)(81156014)(26005);DIR:OUT;SFP:1102; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QLaYedKGN9rSIMenATmwN0WWnszgVLE3QSR925jQMQj/6hCQTAUipmkAdt6zohjUWaz72qz/fUizoMCN6JIV1ARq9xZ29nxB6L9jNfNZZCzh+dQBD8ZlG9tlsVLtKt2AVCTQlO7G/LzIafzZmnmkVdv5imoMUs2kVNyGQi2pKHiXnlOW8IC4IwkMX5rSxQwZ1WWhq2RSGYv/RkrQ+1TVhtz5vPGXxPGqhCJhXDXs3RjFN4g0EP7Oq1v12mtY7l0lZj8zRPbVGPmHwj4g/TolAFfwE9/YuTqCjsxssrCqD2JjyqQd+SGYOUJwW0Mw98+yAXtyWpeDRoGy25if//ATCuBNqd3evYXzjooPh0mZ++cgRa+ar++S87vBURWLKk2SyQCYldXK5ISEp4SsyB5TZaz3di4lKvVaKI80HmywUip92rSOu2vk8rO4t4vLXVmR X-MS-Exchange-AntiSpam-MessageData: K0qEpyo/SZwQku1rkwNdtO765VruqqyI9gXlcE1LrjX2L3uR2BGCzGlnGJ/Li9WfpjEb4Ce4hUdlLNQRvYvoZvPfzfhpcoKCT5QoMkTMw+Qi6l0zYPwOVLO/xpPzBRxdGTK5IBWe4rOXJVmwo9X8lw== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4b8a624-5e37-4764-9453-08d7dd9d0508 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2020 22:17:56.8492 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yvFbxO1+TJQb/2HeqedsNN2AQt6ATbw6lYDG7OWHvt6mTCV0XXPAP97oKNQxAtdiQctM+KFuBuZGXD7GncCK2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR21MB1204 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Dexuan Cui --- drivers/hv/vmbus_drv.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 029378c27421..821185d20cbd 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -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 = { -- 2.19.1