Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2047378ybi; Mon, 1 Jul 2019 05:17:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtWydD1q1HKvAWX1POFTMru1IqZf2E512SuoXNuNSo26eLHnqeBUeUOCPsjvkv9xolk9py X-Received: by 2002:a63:610e:: with SMTP id v14mr24560957pgb.221.1561983429864; Mon, 01 Jul 2019 05:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561983429; cv=none; d=google.com; s=arc-20160816; b=Xf3VSV5zUibrgc1j2YKUz/Jh4OMh8ZZ9u9sBlPwY+69aJVsHzDEF8UTkd88muDuCun K5m/nJ5ktPFtfTvyaFJGHX/pyUtP88rRt7W3ViU2ReWZGpAbg1hgC6FsamUSMYaYiN1e OdzeIraxb4s/scPhs9MpSaGH6qRnLktCX2kyR+qB8ToyTrkf3beWwEPnQ/1iUHyEu+ve YTQslXNhX19PvCcdU+0JFRrzbw60ld55qbEoqEQQ87T6pkTp8yuB2KobgqznApSd94lA hsv3cqaehh/kpHBfdcU/N0pV4Edh5gVtcSY13hBjKBAD4FulZUnZC7S8uBzcCH8fI4PQ vMtQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Y8DSbfaV4i5SZYobkoM22DXzBkW3H+ox3H4nI0U+e/A=; b=NbKQGRI0ZEaq+Vq6WFIM7NaJU1jD5ApASkQ2tlGp/B0jvwZgboc1xZa/WoBJH7B/Q6 UGL1eFwDoTruRBx9YvzVTLZmFutLbuu3/Cwm2YY1cFPZ88J6fGPc+0mVckz3AlqV8rqY 8ZF5iA16XrRirLZAayONP4ojwZBedrAw3nY4EpT84rDlFjeR0DOHQc7DHt+eGZ6yGP4S gJFi8javPoDlmbivT/XLXW3clwUa4KLA5glNUEcQme/KxnqVZz0xUP5PBURIIDd9hnvY MCEeioGOetBkYtnI+P6XaHW0SSsZCP3RmLoP4Zb0YJ8IybZv9S7EBrtSkKCGk9SLU9I5 jlpg== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h61si10237825plb.256.2019.07.01.05.16.54; Mon, 01 Jul 2019 05:17:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbfGAK6Y (ORCPT + 99 others); Mon, 1 Jul 2019 06:58:24 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:55366 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727662AbfGAK6W (ORCPT ); Mon, 1 Jul 2019 06:58:22 -0400 Received: from 79.184.254.216.ipv4.supernova.orange.pl (79.184.254.216) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.267) id a425eeee5911cf67; Mon, 1 Jul 2019 12:58:19 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: Linux PCI , Linux ACPI , LKML , Bjorn Helgaas , Andy Shevchenko , Mika Westerberg , Hans De Goede , "Robert R. Howell" Subject: [PATCH v2 1/5] PM: ACPI/PCI: Resume all devices during hibernation Date: Mon, 01 Jul 2019 12:44:25 +0200 Message-ID: <6191578.xJk2HsE5MX@kreacher> In-Reply-To: <4976412.ihyb9sT5jY@kreacher> References: <4976412.ihyb9sT5jY@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Both the PCI bus type and the ACPI PM domain avoid resuming runtime-suspended devices with DPM_FLAG_SMART_SUSPEND set during hibernation (before creating the snapshot image of system memory), but that turns out to be a mistake. It leads to functional issues and adds complexity that's hard to justify. For this reason, resume all runtime-suspended PCI devices and all devices in the ACPI PM domains before creating a snapshot image of system memory during hibernation. Fixes: 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account) Fixes: c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account) Link: https://lore.kernel.org/linux-acpi/917d4399-2e22-67b1-9d54-808561f9083f@uwyo.edu/T/#maf065fe6e4974f2a9d79f332ab99dfaba635f64c Reported-by: Robert R. Howell Tested-by: Robert R. Howell Signed-off-by: Rafael J. Wysocki --- -> v2: No changes. --- drivers/acpi/device_pm.c | 13 +++++++------ drivers/pci/pci-driver.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) Index: linux-pm/drivers/acpi/device_pm.c =================================================================== --- linux-pm.orig/drivers/acpi/device_pm.c +++ linux-pm/drivers/acpi/device_pm.c @@ -1155,13 +1155,14 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_ear int acpi_subsys_freeze(struct device *dev) { /* - * This used to be done in acpi_subsys_prepare() for all devices and - * some drivers may depend on it, so do it here. Ideally, however, - * runtime-suspended devices should not be touched during freeze/thaw - * transitions. + * Resume all runtime-suspended devices before creating a snapshot + * image of system memory, because the restore kernel generally cannot + * be expected to always handle them consistently and they need to be + * put into the runtime-active metastate during system resume anyway, + * so it is better to ensure that the state saved in the image will be + * alwyas consistent with that. */ - if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND)) - pm_runtime_resume(dev); + pm_runtime_resume(dev); return pm_generic_freeze(dev); } Index: linux-pm/drivers/pci/pci-driver.c =================================================================== --- linux-pm.orig/drivers/pci/pci-driver.c +++ linux-pm/drivers/pci/pci-driver.c @@ -1012,15 +1012,15 @@ static int pci_pm_freeze(struct device * } /* - * This used to be done in pci_pm_prepare() for all devices and some - * drivers may depend on it, so do it here. Ideally, runtime-suspended - * devices should not be touched during freeze/thaw transitions, - * however. + * Resume all runtime-suspended devices before creating a snapshot + * image of system memory, because the restore kernel generally cannot + * be expected to always handle them consistently and they need to be + * put into the runtime-active metastate during system resume anyway, + * so it is better to ensure that the state saved in the image will be + * alwyas consistent with that. */ - if (!dev_pm_smart_suspend_and_suspended(dev)) { - pm_runtime_resume(dev); - pci_dev->state_saved = false; - } + pm_runtime_resume(dev); + pci_dev->state_saved = false; if (pm->freeze) { int error;