Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1874144ybz; Sat, 18 Apr 2020 10:13:30 -0700 (PDT) X-Google-Smtp-Source: APiQypLjbvJRbgSsPxtdiczcvdiHObbdSpyjSnxi6dzqlaUIfxmMrZjZ3kcr1nAScbw7UJYSxWUD X-Received: by 2002:aa7:d7d8:: with SMTP id e24mr7934883eds.215.1587230009950; Sat, 18 Apr 2020 10:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587230009; cv=none; d=google.com; s=arc-20160816; b=tOXzYvPmlJYYQ34w7Q03v0Sf1/eaECPafbBpEaaq+tu8RGqo/3zHjVmAE24P8La5T7 LiO87ZXD/KV63XzgNGsnhttEJyzi18IKOUND2xV9BdAoi+YcleZ518JX4R3QziMOnC85 QDbfsHYFioO1rdTiDoAU8feHpOag2Pu3SXyt5VN7Egoaq4K08PAKu7Xw+32RjQXst2lS 2f2mH8sGiNZHCVBGF0QfKtF8MylEITrgwRjrjbR5v5sbvk9tRHQbx7pff+d2oHrklEO8 kOj/ULfRP27Cfwx91Z+lIjo3nE63nusUOIueyXskomI45HPGloUJcyCwtdaG+p6UXAul Qzjw== 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=g+X2c/JEOkvU3gHOA/IDIk0h3jzQtXsZ5LdCzocnPx0=; b=UjmWnWlEYlOl6+gMOnuwdLRQRL31YAMd+tDmXqMSpMRcKvI8dKz7s6B+Ri28Qa0VM+ RD6O+OEeUdQwU1sdcKkQvH/2q5924gDRbqkC66wjGyJ7JvEnPGdKAhXHcDsEHcu+tc+k +VxnOAOdHLh5k/smCHEld10sUjjALFxX6bX6r81URDwN45ZeapGaCknSDa78bvHSqPLB QMnliI3W77LiCzdIp/PVWUI1HhBL3tU3kWKJgkyDVvvXA3iplmODPiEjgMfVtPCsskk+ XZFqZIROezcZaBXlT1lVE2tbOALS+pfo31+bh2gZY/59VhvtS5V//v+/GmiuetllBGbY Zv9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 d7si15738806edj.504.2020.04.18.10.13.06; Sat, 18 Apr 2020 10:13:29 -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; 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 S1727900AbgDRRMB (ORCPT + 99 others); Sat, 18 Apr 2020 13:12:01 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:41913 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbgDRRL6 (ORCPT ); Sat, 18 Apr 2020 13:11:58 -0400 Received: from 185.80.35.16 (185.80.35.16) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.415) id 30cb542102df344c; Sat, 18 Apr 2020 19:11:54 +0200 From: "Rafael J. Wysocki" To: Linux PM , Alan Stern Cc: Linux ACPI , Linux PCI , LKML , Bjorn Helgaas , Greg Kroah-Hartman , Mika Westerberg , Hans De Goede , Ulf Hansson Subject: [PATCH v2 4/9] PM: sleep: core: Rework the power.may_skip_resume handling Date: Sat, 18 Apr 2020 18:52:19 +0200 Message-ID: <4410060.DOjU9hYLuO@kreacher> In-Reply-To: <5673945.BT02kTCndr@kreacher> References: <1888197.j9z7NJ8yPn@kreacher> <5673945.BT02kTCndr@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" Because the power.may_skip_resume device status bit is taken into account in combination with the DPM_FLAG_LEAVE_SUSPENDED driver flag, it can be set to 'true' for all devices in the "suspend" phase of a suspend-resume cycle, so do that. Then, neither the PM core nor the middle-layer (sybsystem) code handling it needs to set it to 'true' any more and it just has to be cleared if there is a reason to avoid skipping the "noirq" and "early" resume callbacks provided by the driver, so update the code in question accordingly. Signed-off-by: Rafael J. Wysocki --- New patch. --- drivers/acpi/device_pm.c | 8 +++----- drivers/base/power/main.c | 10 ++-------- drivers/pci/pci-driver.c | 8 +++----- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 399684085f85..1b02d7dc7d34 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1100,10 +1100,8 @@ int acpi_subsys_suspend_noirq(struct device *dev) { int ret; - if (dev_pm_smart_suspend_and_suspended(dev)) { - dev->power.may_skip_resume = true; + if (dev_pm_smart_suspend_and_suspended(dev)) return 0; - } ret = pm_generic_suspend_noirq(dev); if (ret) @@ -1116,8 +1114,8 @@ int acpi_subsys_suspend_noirq(struct device *dev) * acpi_subsys_complete() to take care of fixing up the device's state * anyway, if need be. */ - dev->power.may_skip_resume = device_may_wakeup(dev) || - !device_can_wakeup(dev); + if (device_can_wakeup(dev) && !device_may_wakeup(dev)) + dev->power.may_skip_resume = false; return 0; } diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 25b0302188d8..5adf0be6aa47 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1415,14 +1415,8 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as if (callback) goto Run; - if (dev_pm_smart_suspend_and_suspended(dev)) { - /* - * In principle, the resume of the device may be skippend if it - * remains in runtime suspend at this point. - */ - dev->power.may_skip_resume = true; + if (dev_pm_smart_suspend_and_suspended(dev)) goto Skip; - } if (dev->driver && dev->driver->pm) { info = "late driver "; @@ -1647,7 +1641,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) dev->power.direct_complete = false; } - dev->power.may_skip_resume = false; + dev->power.may_skip_resume = true; dev->power.must_resume = false; dpm_watchdog_set(&wd, dev); diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 685fbf044911..ce220b1987df 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -789,10 +789,8 @@ static int pci_pm_suspend_noirq(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; - if (dev_pm_smart_suspend_and_suspended(dev)) { - dev->power.may_skip_resume = true; + if (dev_pm_smart_suspend_and_suspended(dev)) return 0; - } if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend_late(dev, PMSG_SUSPEND); @@ -880,8 +878,8 @@ static int pci_pm_suspend_noirq(struct device *dev) * pci_pm_complete() to take care of fixing up the device's state * anyway, if need be. */ - dev->power.may_skip_resume = device_may_wakeup(dev) || - !device_can_wakeup(dev); + if (device_can_wakeup(dev) && !device_may_wakeup(dev)) + dev->power.may_skip_resume = false; return 0; } -- 2.16.4