From patchwork Tue Aug 29 14:56:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111219 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457390qge; Tue, 29 Aug 2017 07:57:02 -0700 (PDT) X-Received: by 10.46.68.80 with SMTP id r77mr266999lja.34.1504018622100; Tue, 29 Aug 2017 07:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018622; cv=none; d=google.com; s=arc-20160816; b=veSPfwwFnuyKdrLm2ynKE3FU3p7lHMs3T8h8gcYHRxwyeo4h0AT8OHBL9UoFZm068O VUCohyka6fkfgDtFLTCYERSrjeH2aVTtmRzj7NScQysGljkHw7m3HMaYriysXzClierO wP3IR8+F914lZTFsKZiJO+46ZdPQNTAyVow8wzFyFMw7wyFKI3wHQwaezcbGcNLHhqCe P1y4bbtIwW+cujVuxPanoOIaEWoiaqg0qqQveW0xPQr6NUjqiEz+COObsQfPsho9YI90 RnhM33RJloEYr2ytZdFhdlauUh/1Z+KUcY1VOBCShyn3g5hq6vpiNIqy5QGLUChhrz9l OLoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Fo+NtBKyToNny54nckr1MxS5d4RhjFqGF0/5CAXxONY=; b=0+VUONmP2J9k3a/s02Ub7MlSHPuVOaQvWbpqDCTAPDOLCvu9PWw8gq2uIlHPc7ABtR 4d3jp0Xbd24V0qfULEepNiRQXCQWNg7eq+QbUso8KCkcBChDZKM1+tehZeNitDTJRz5T Org3PMb2qruuHDvxOxX+PS9TlqevzsaUZl7g5zi8NgOUuc6KoDwbRbv9/UVZZCtCwun5 MsJPRhkzr3OaAOp65IwCa95csJ9LwXljkMNbpxsvViIg3CLXYu9pRlL7l2AtDPJAr2Td fW2HKBK0dmyZ7EDKJBT+zUO+C17XTA6JFu+1P/wg4Ld9xUUl+ld6z/YbPTUROWNn14qF tcrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jjn6j+ha; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22c as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22c.google.com (mail-lf0-x22c.google.com. [2a00:1450:4010:c07::22c]) by mx.google.com with ESMTPS id 7si1467470lje.56.2017.08.29.07.57.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22c as permitted sender) client-ip=2a00:1450:4010:c07::22c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jjn6j+ha; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22c as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22c.google.com with SMTP id d17so14395186lfe.1 for ; Tue, 29 Aug 2017 07:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fo+NtBKyToNny54nckr1MxS5d4RhjFqGF0/5CAXxONY=; b=jjn6j+haoh360x0zIcu37UQ/R4YZ5h9hpLAiPzt5S5ZUUw3GF6tEjDpViBrP3E8G8G cuHL8iAzAu/7OsTXIIPcWoA1Ytha8LevSZLDUUP6uHZpWrVtQ2xo2nyYB3bxHipntjdX G5A2LS/Bn2lR8pcLIOpc6wxtrhlwZYopqXXI0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Fo+NtBKyToNny54nckr1MxS5d4RhjFqGF0/5CAXxONY=; b=BekpTGB1KvuVgAN872WGU1VYj0dgnkLxWv9Qhh5dtrwZ2LyxSM09rVbbvxq7khBoKd q97t7lHQ5/kN2uDzwDvSNwOoSwWz3QLcgieo/ERH1P9uukpbQJiMHtvVAiQ4fUq00OPe Uf4fXHehO+cuXULgHqA+24wVghYvmk9iffV50m71876EsTUsC9Spbqq5N+JET3mfVPZ5 7ptsE51T12D25VCOSAUpjckztHivcsC2dDoa7imwAHFI/nKMpee7t68sHn7sgwUobRvK e4Tf+X6CEjM43wEKMH32ldH+BzjVm9rNaTggUPnO+iisEvxK1j/kwnxT0JlIaWPSIcbg OBmQ== X-Gm-Message-State: AHYfb5iU5szt3PMHeqn5HYmRJBIRdyShtqOH3X/ZVVWwfk8jCoD7XLuS NnFE6VxxrdJqV4k+NSY= X-Received: by 10.46.33.151 with SMTP id h23mr298552lji.92.1504018621596; Tue, 29 Aug 2017 07:57:01 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.56.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:00 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path known to the PM core Date: Tue, 29 Aug 2017 16:56:43 +0200 Message-Id: <1504018610-10822-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> The main principle behind the runtime PM centric path, is to re-use the runtime PM callbacks to implement system sleep - and while doing that also achieve a fully optimized behaviour from PM point of view. More precisely, avoid to wake up a device from its low power state during system sleep, unless the device is really needed to be operational. That does not only mean avoiding to waste power, but may also decrease system suspend/resume time for a device. However, using the runtime PM centric path for a device, does put some requirements on the behaviour of the PM core and a potential PM domain that may be attached to the device. So far, these requirements are not being specially considered, except by the generic PM domain. To move forward and to make it possible to deploy the runtime PM centric path for cross SoC drivers, which may have different PM domains attached to its devices depending on the SoC, we must address how to deal with these requirements. This change starts by making some adoptions to the PM core, while other parts, such as the ACPI PM domain needs to be taken care of separately. In the runtime PM centric path, the driver is expected to make use of the pm_runtime_force_suspend|resume() helpers, to deploy system sleep support. More precisely it may assign the system sleep callbacks to these helpers or may call them from its own callbacks, in case it needs to perform additional actions during system sleep. In other words, the PM core must always invoke the system sleep callbacks for the device when they are present, to allow the driver to deal with the system sleep operations. In case the PM core decides to run the direct_complete path for the device, it skips invoking most of the system sleep callbacks, besides ->prepare|complete(). Therefore using the direct_complete path in combination with the runtime PM centric patch for a device, does not play well. To deal with this issue, let's add a flag 'is_rpm_sleep', to the struct dev_pm_info. The driver that deploys the runtime PM centric path, shall set the flag for the device during ->probe(), to inform the PM core about that it must not use the direct_complete path for the device. Note, not allowing the direct_complete path for a device, doesn't implicit need to propagate to the device's parent/suppliers. Therefore make the PM core check this condition in device_suspend(), before it decides to abandon the direct_complete path for parent/suppliers. To make the is_rpm_sleep flag internal to the PM core, let's add two APIs. - dev_pm_use_rpm_sleep(): It sets the flag and should be called by the driver during ->probe(). - dev_pm_is_rpm_sleep(): Makes it possible for users of the device, like a PM domain, to fetch the state of the flag. Signed-off-by: Ulf Hansson --- Changes in v3: - New patch. - This replaces the earlier method of adding the no_direct_complete to the ACPI structures, according to comments from Rafael. - This change also address the consern Rafael had around that direct_complete should not have to be disabled for parent/suppliers, in case a device use the runtime PM centric path for system sleep. --- drivers/base/power/main.c | 49 +++++++++++++++++++++++++++++++++++++++----- drivers/base/power/runtime.c | 1 + include/linux/pm.h | 7 +++++++ 3 files changed, 52 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ea1732e..865737a 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1549,14 +1549,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) if (parent) { spin_lock_irq(&parent->power.lock); - dev->parent->power.direct_complete = false; + if (!dev->power.is_rpm_sleep) + dev->parent->power.direct_complete = false; if (dev->power.wakeup_path && !dev->parent->power.ignore_children) dev->parent->power.wakeup_path = true; spin_unlock_irq(&parent->power.lock); } - dpm_clear_suppliers_direct_complete(dev); + if (!dev->power.is_rpm_sleep) + dpm_clear_suppliers_direct_complete(dev); } device_unlock(dev); @@ -1709,11 +1711,14 @@ static int device_prepare(struct device *dev, pm_message_t state) * A positive return value from ->prepare() means "this device appears * to be runtime-suspended and its state is fine, so if it really is * runtime-suspended, you can leave it in that state provided that you - * will do the same thing with all of its descendants". This only - * applies to suspend transitions, however. + * will do the same thing with all of its descendants". To allow this, + * the is_rpm_sleep flag must not be set, which is default false, but + * may have been changed by a driver. This only applies to suspend + * transitions, however. */ spin_lock_irq(&dev->power.lock); - dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND; + dev->power.direct_complete = ret > 0 && !dev->power.is_rpm_sleep && + state.event == PM_EVENT_SUSPEND; spin_unlock_irq(&dev->power.lock); return 0; } @@ -1841,6 +1846,40 @@ void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *)) } EXPORT_SYMBOL_GPL(dpm_for_each_dev); +/** + * dev_pm_use_rpm_sleep - use the runtime PM centric sleep path. + * @dev: the device to use the path for. + * + * The runtime PM centric path requires the system sleep callbacks for the + * driver of the device to be invoked. This function sets the is_rpm_sleep flag + * to enable this path to be used, which makes the PM core to adopt to this + * behaviour. More precisely the PM core makes sure to not run the + * direct_complete path for the chosen device during system sleep, when the + * is_rpm_sleep flag is set. A driver using the runtime PM centric path, shall + * use the pm_runtime_force_suspend|resume() helpers, to deploy system sleep + * support and call this function during ->probe(). + * The is_rpm_sleep flag is cleared when unbinding/bind-failure of the driver. + */ +void dev_pm_use_rpm_sleep(struct device *dev) +{ + dev->power.is_rpm_sleep = true; +} +EXPORT_SYMBOL_GPL(dev_pm_use_rpm_sleep); + +/** + * dev_pm_is_rpm_sleep - Returns the value of the is_rpm_sleep flag. + * @dev: the device to return the flag for. + * + * The caller of this function is typically a subsystem or a PM domain that + * needs to know if the runtime PM centric path is used for the device. It may + * be invoked during any of the system sleep phases. + */ +bool dev_pm_is_rpm_sleep(struct device *dev) +{ + return dev->power.is_rpm_sleep; +} +EXPORT_SYMBOL_GPL(dev_pm_is_rpm_sleep); + static bool pm_ops_is_empty(const struct dev_pm_ops *ops) { if (!ops) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 7bcf80f..b2ab22c 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1522,6 +1522,7 @@ void pm_runtime_reinit(struct device *dev) pm_runtime_put(dev->parent); } } + dev->power.is_rpm_sleep = false; } /** diff --git a/include/linux/pm.h b/include/linux/pm.h index 47ded8a..5bf96d2 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -559,6 +559,7 @@ struct dev_pm_info { bool is_suspended:1; /* Ditto */ bool is_noirq_suspended:1; bool is_late_suspended:1; + bool is_rpm_sleep:1; /* Owned by the PM core */ bool early_init:1; /* Owned by the PM core */ bool direct_complete:1; /* Owned by the PM core */ spinlock_t lock; @@ -716,6 +717,9 @@ extern void __suspend_report_result(const char *function, void *fn, int ret); extern int device_pm_wait_for_dev(struct device *sub, struct device *dev); extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *)); +extern void dev_pm_use_rpm_sleep(struct device *dev); +extern bool dev_pm_is_rpm_sleep(struct device *dev); + extern int pm_generic_prepare(struct device *dev); extern int pm_generic_suspend_late(struct device *dev); extern int pm_generic_suspend_noirq(struct device *dev); @@ -759,6 +763,9 @@ static inline void dpm_for_each_dev(void *data, void (*fn)(struct device *, void { } +static inline void dev_pm_use_rpm_sleep(struct device *dev) {} +static inline bool dev_pm_is_rpm_sleep(struct device *dev) { return false; } + #define pm_generic_prepare NULL #define pm_generic_suspend_late NULL #define pm_generic_suspend_noirq NULL From patchwork Tue Aug 29 14:56:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111220 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457434qge; Tue, 29 Aug 2017 07:57:03 -0700 (PDT) X-Received: by 10.25.87.7 with SMTP id l7mr192268lfb.128.1504018623888; Tue, 29 Aug 2017 07:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018623; cv=none; d=google.com; s=arc-20160816; b=sd1bZPXJQHMuXmk+6OvpWb7t5/Somv8HhYpRItcyWRDwchG0FDW/AvIObLhHEpajFi xIY2d9W5LmrhYdT7vgDZmEZIcIcXi7TtR7QdpDAbTVmOcl/evW0zIf2VQ3L5NWYU9W9x DWSWO8E4wTGpUCd0J9eKixoyluP6HRpluH0TjpZ3ywo6Eq7jsInnPfO1EgW/1W3DcdSj 0PdIPSRMxAHKcx1iLMNc/GmOwFxrY0L49sqCGtJljJqOndjwp5jAFkjPNU80jbTtjbHJ mNgq18wz5yi3P18u7fIN9LeqLyrNKRnC60/dC/ojIUgcqRxk68dt4keVedS7rhnFIZSZ lTLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=t/0EnNFHSFSy+bWjKQA9j4SLg6VF07in38lNTG8qPK0=; b=gVFxZSbPPR2WtQyi6cTJA7qJKcQkK2Yaz9Z0zQAf17W3caw7dBUut6zCBlmt0JoGae kwg7qzK4yrnb7iUpLtF/GBIZpHjHMZybQFnwnonGVqBVm/yBvwRgfxdxOTz+N7TwEqkW RKu8PAr4YsN/sWOVIwjZyZsWp32fHRwEfvvTswhF43ZETxdahfznsZCFuJ1189wxTVy2 U1PUGPcwFp2pjrcYNRS7K/blsnYCEWs1EGJeYyTgF2B5LxJqDr0P0v/TENF2TQ+s6yeV udiQCwACNv5wHfpLL6Yrte6jOP05gw4ty5J0X1/HdjqRWOaHLGiHMdoz9HL0cKZlZ+JR DL4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ctbr+X1o; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x235.google.com (mail-lf0-x235.google.com. [2a00:1450:4010:c07::235]) by mx.google.com with ESMTPS id i200si1251061lfg.451.2017.08.29.07.57.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) client-ip=2a00:1450:4010:c07::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ctbr+X1o; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x235.google.com with SMTP id d17so14395520lfe.1 for ; Tue, 29 Aug 2017 07:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t/0EnNFHSFSy+bWjKQA9j4SLg6VF07in38lNTG8qPK0=; b=ctbr+X1oWC+TdTvFCeKHnk0j901D9J4dyc5jODfHaAmx8gbH0u3xs34PzB7J9IaUE+ QkSCJeH5EwAUaXn0u+gaET6QLa328XmEmayBeapeuuA4SCn0CNogituvdqEAbO+1bZQ+ mcBOSq1oMOmQ6odQWoA/QWi1lIVQ5zLtX1hC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t/0EnNFHSFSy+bWjKQA9j4SLg6VF07in38lNTG8qPK0=; b=RFsAkHuu0ezoXRWD+o8ieCyQOnVF6ABAhO+lAzPfYqwtN2RryxpBTs1L4O3b3J6McC CSW9kQXl4pC4DpFN4Pc/1/rCHpuhfKSA6j3JqzQVNnTRrC1tRPx+6UD5n7UGEZMMaBhg lttjmJCeqaUDoJ2aRAZkSPg3VLYI6BNKJ1ixlcPgl2YJ1TKwiKX6OrOhf/uNg7P2Zrd9 BY7H6JEksgwWSAgYMqZjWFQ4GKzk11BuH5jV4y8ePF19bbvqikE/MQHRWCnNPTVUqViS 0UJ0TItEiA6BQnsNGFLdUqavhjuYnoaifjBrbt0Bha6kvY/9r18gNurb1YDqZhwuz/W+ CJUw== X-Gm-Message-State: AHYfb5giKUAuKVgaZhwIXGSlqqK7AZ8NsiyjVwkHZSK89SqOxw7D8I78 vVgf/6yaLuAArIob5IQ= X-Received: by 10.46.88.90 with SMTP id x26mr256631ljd.53.1504018623456; Tue, 29 Aug 2017 07:57:03 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:02 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 2/8] PM / ACPI: Restore acpi_subsys_complete() Date: Tue, 29 Aug 2017 16:56:44 +0200 Message-Id: <1504018610-10822-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> The commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware"), made PCI's and ACPI's ->complete() callbacks to be assigned to a new API called pm_complete_with_resume_check(), which was introduced in the same change. Later it turned out that using pm_complete_with_resume_check() isn't good enough for PCI, as it needs additional PCI specific checks, before deciding whether runtime resuming the device is needed when running the ->complete() callback. This leaves ACPI being the only user of pm_complete_with_resume_check(). Therefore let's restore ACPI's acpi_subsys_complete(), which was dropped in commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware"). This enables us to remove the pm_complete_with_resume_check() API in a following change, but it also enables ACPI to add more ACPI specific checks in acpi_subsys_complete() if it turns out that is needed. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/acpi/acpi_lpss.c | 2 +- drivers/acpi/device_pm.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 032ae44..0c84d15 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -894,7 +894,7 @@ static struct dev_pm_domain acpi_lpss_pm_domain = { #ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP .prepare = acpi_subsys_prepare, - .complete = pm_complete_with_resume_check, + .complete = acpi_subsys_complete, .suspend = acpi_subsys_suspend, .suspend_late = acpi_lpss_suspend_late, .resume_early = acpi_lpss_resume_early, diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index fbcc73f..632f214 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1020,6 +1020,23 @@ int acpi_subsys_prepare(struct device *dev) EXPORT_SYMBOL_GPL(acpi_subsys_prepare); /** + * acpi_subsys_complete - Finalize device's resume during system resume. + * @dev: Device to handle. + */ +void acpi_subsys_complete(struct device *dev) +{ + pm_generic_complete(dev); + /* + * If the device had been runtime-suspended before the system went into + * the sleep state it is going out of and it has never been resumed till + * now, resume it in case the firmware powered it up. + */ + if (dev->power.direct_complete && pm_resume_via_firmware()) + pm_request_resume(dev); +} +EXPORT_SYMBOL_GPL(acpi_subsys_complete); + +/** * acpi_subsys_suspend - Run the device driver's suspend callback. * @dev: Device to handle. * @@ -1087,7 +1104,7 @@ static struct dev_pm_domain acpi_general_pm_domain = { .runtime_resume = acpi_subsys_runtime_resume, #ifdef CONFIG_PM_SLEEP .prepare = acpi_subsys_prepare, - .complete = pm_complete_with_resume_check, + .complete = acpi_subsys_complete, .suspend = acpi_subsys_suspend, .suspend_late = acpi_subsys_suspend_late, .resume_early = acpi_subsys_resume_early, From patchwork Tue Aug 29 14:56:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111221 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457500qge; Tue, 29 Aug 2017 07:57:05 -0700 (PDT) X-Received: by 10.46.9.215 with SMTP id 206mr251909ljj.1.1504018625737; Tue, 29 Aug 2017 07:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018625; cv=none; d=google.com; s=arc-20160816; b=HDGEkha8jPbrw/sZVp55Fc3wG2Sqx4mvT5WiGW2TC5eJLRj/iwxqH6a9cfiN2Rpf24 jeKw1N7GlhlmKhP0rC46IL/bzRzIaTG/axuD4ZSGQP5jeXEgs1ofsOBmJTg7YhRpc1vx N8GxY5YHYCIL6wETqgIj1NbHKdN6Rt9WreHEEToz02nbatEMmSA69I1Jug7w5JU5ySMT q7UsVI/1sVsu/kXtbhqivjWxaLyqwJ534oGXof5RRXESCctt/mlNr3Cg9JyNZ9ACKQd9 6b59qGjqB+SwB+NKhK3x5ianEc7hflGW62qq/ZSa9PGurr5+TeKbmFoKKzDJpjzOeFQr LJ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GKSuDwhuhr3gj47CQ8afU3lKajk4Zvq/lQbvP7ebE8g=; b=j8nE7SIYMvMJO6mzGiNWJVmSXgtHjvrGEZwpkS0Acvb+tMldknmRkkE/hx3Hia+4jA RcVBcTSlM+ZhPG3QWK/wE5eG0foVHfZmdycqXTBSjpgD8xEC/VDmnQVL/WkeHtRutlAt lnqmYwTaB55i9xc3PPNhMVbtpU2iJtVQh6+N8JbJPfATuXEQs1T9lbZcwAyZvjM0SY4/ QXGFwHRFd9opeuLFEN0366nl4LDyqDoRWFJw/AP+nQ7s0x6KRW7C2xmffowOpdnLUdZW p2cPs4uG6ol8W5GSrmEMNGnphk3LKBWbbymwy53Ymp8EhEoi+fwdFvb+tesVLH488dkW eDvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mf1VaJ10; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id u20si1482115lja.128.2017.08.29.07.57.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mf1VaJ10; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x229.google.com with SMTP id z12so14369751lfd.3 for ; Tue, 29 Aug 2017 07:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GKSuDwhuhr3gj47CQ8afU3lKajk4Zvq/lQbvP7ebE8g=; b=Mf1VaJ10LpRyqiP/LfbzBD0DYbUJj9DtY5feHcQn9oZb5OSCt9Im2xui29VISIDLvj 42v7YWiXtzV8AAlyQ/CgI8+29xSZVxiX4sFhsQqDa28W/BDN6VTaKEO2r5K7Xv1HCGsL C7l4ckbqTO1xqKXDN9YZS56trBL4k3qx289Z0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GKSuDwhuhr3gj47CQ8afU3lKajk4Zvq/lQbvP7ebE8g=; b=V+4turnJ+ScE/ghg5cxnztp7A6RaOZ8aPpc2RFsm6dI5A3CXtG/rdk41nvnFcBcAqT KRvN/HxM8xzY6fox6JfAw/7qCfpa+Uztp1mmkCPiKkf3flcL7lOlgum0So9ZXZB1rgJs d05YmsS0Y/bACY/O5xwn2QkElrK2fNd4CxtBu3d/Q+Sh1MFyrJeN6osG6KSFiZft91ov FMWecYYhEq0TSbfkVz3U117R5K31d99XdUhD4RFxE7H5nT2aSqt0FSyX8HV4BEQYbAA2 dCfb8gbhR8x6dG05LLcTXJ+GFrQS2XFcuf/eComlXy+9Whm7RC+XeZbF7xnu/tlpABMe 06Og== X-Gm-Message-State: AHYfb5h3J7pK4XRMqHNJ+51blXfe8xVpH7CoMjLQ6IRmHxIVuDoqFWL1 YjVETm/ErYxgi8uuM0Q= X-Received: by 10.46.5.19 with SMTP id 19mr272268ljf.155.1504018625301; Tue, 29 Aug 2017 07:57:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:04 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 3/8] PM / Sleep: Remove pm_complete_with_resume_check() Date: Tue, 29 Aug 2017 16:56:45 +0200 Message-Id: <1504018610-10822-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> According to recent changes for ACPI, the are longer any users of pm_complete_with_resume_check(), thus let's drop it. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/base/power/generic_ops.c | 23 ----------------------- include/linux/pm.h | 1 - 2 files changed, 24 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index 07c3c4a..b2ed606 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c @@ -9,7 +9,6 @@ #include #include #include -#include #ifdef CONFIG_PM /** @@ -298,26 +297,4 @@ void pm_generic_complete(struct device *dev) if (drv && drv->pm && drv->pm->complete) drv->pm->complete(dev); } - -/** - * pm_complete_with_resume_check - Complete a device power transition. - * @dev: Device to handle. - * - * Complete a device power transition during a system-wide power transition and - * optionally schedule a runtime resume of the device if the system resume in - * progress has been initated by the platform firmware and the device had its - * power.direct_complete flag set. - */ -void pm_complete_with_resume_check(struct device *dev) -{ - pm_generic_complete(dev); - /* - * If the device had been runtime-suspended before the system went into - * the sleep state it is going out of and it has never been resumed till - * now, resume it in case the firmware powered it up. - */ - if (dev->power.direct_complete && pm_resume_via_firmware()) - pm_request_resume(dev); -} -EXPORT_SYMBOL_GPL(pm_complete_with_resume_check); #endif /* CONFIG_PM_SLEEP */ diff --git a/include/linux/pm.h b/include/linux/pm.h index 5bf96d2..c88a4ef 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -740,7 +740,6 @@ extern int pm_generic_poweroff_noirq(struct device *dev); extern int pm_generic_poweroff_late(struct device *dev); extern int pm_generic_poweroff(struct device *dev); extern void pm_generic_complete(struct device *dev); -extern void pm_complete_with_resume_check(struct device *dev); #else /* !CONFIG_PM_SLEEP */ From patchwork Tue Aug 29 14:56:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111222 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457535qge; Tue, 29 Aug 2017 07:57:07 -0700 (PDT) X-Received: by 10.25.1.214 with SMTP id 205mr169977lfb.68.1504018627681; Tue, 29 Aug 2017 07:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018627; cv=none; d=google.com; s=arc-20160816; b=NsyoeQAK9ri9rPvyIsuXJMy9Z1ted4i5pQDaN+GQesqbvFmZn3hkkFmLYopBzZgKZZ DvwaXvqA/VC/DEp1YAcqRI9TYyTfrbuEwKfgRtHm3PJVw0YpnG41OAZ+fQUKI2H2ye/5 eRRrcBLLnYemBQ1FJCi0vlR18zj8V/POAglfMdGm0xKAjjhXo8Oeyws0b8uLoA6U2zl8 vDF/oEvQO6zUeoLNQUMLTI2/FSA++hRgAzJMpvwDEuGflTs+n03OPguEn+V1UylYyFGy BIti5tCcWZmlKmU+a3li0fAHTDxl6BU42OMF+ok4OXuUnYkrEAbU31W+1q0ECOgYyCTW rlCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Lg9EEQT3YuyzWd/JOg75Y85U4sVeV31PRz0DxI/aF3w=; b=Rq6XIIxY+yivRNSZLQLrTJrXvHzUOBBvJTFgkbFBvWg801SjI/09Mv9Ohp6Ni46xgE NDfpr7cMZCe/lFR6GZzbA/d/aZt0N8RxP1JSNlu8sNygxDb57wwopTHZITt9aWuPpNu+ HPobkcT4D1JEZSNm0SFJVqXqUou/se07RcZq6YRAj5KQwqQC1XY/6cgLQu4DC97H5jPs 3fPR4+ord435kGK4BdVXtmaLO+f68/wE/UCcqfAvkVFJ8dFv/uEkRMnLnlbZyU5KA8i9 XbGByQ2mTj7eMj+2mbATJUAz0gpEcRmqdMUloiV/eRLd3mRumkEmWdHKmGpHMw5MSaUq GFxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJTTGHek; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com. [2a00:1450:4010:c07::22a]) by mx.google.com with ESMTPS id o15si1410121lfg.530.2017.08.29.07.57.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) client-ip=2a00:1450:4010:c07::22a; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJTTGHek; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22a.google.com with SMTP id d202so14330830lfd.5 for ; Tue, 29 Aug 2017 07:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lg9EEQT3YuyzWd/JOg75Y85U4sVeV31PRz0DxI/aF3w=; b=AJTTGHekrPYMkim+F9nNl6TaM1vVhP+VaGH0EV/+XkIXeGFZZ5kaw567JrdyVQNW3Y X9aL0t6bnXx+tLpf9vjSRh6NkkMhpuK98xF3rrgTg4y2CrpfKCmJ9ANwr7KFTYGWbOnT 7UzlVLL+nsELDhMNLztjatNIdrCDzFBBEvpvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Lg9EEQT3YuyzWd/JOg75Y85U4sVeV31PRz0DxI/aF3w=; b=ct/QR2fYfxO6OJxKkKXhY7xNWSy8dFFbjKmkOu4lXHrsJK+BSLGfKvfM+Tnt6XtzJK Ej02WgNusby1Iy86Sn0t3GwMeUqT5Lnw/O1DFsXcakOL0CeBNzZePpXvulaRHe5qyH0h k6jaNNjRVNiNjXhzjMF8f3qr9AI5yyHdA+wUBMlxsnPSzbJh8hTkhVDeyWSsXZn/ohyQ nZBOlkUhDCbJi76xGKopxrmRg2JLHadtUl7rp6zLcBocgF2M7YxzUjRUV6Y4+wWZAe7M JIdepzx+9vL7Mi9VMlh0dUYLTnvUHTlUhAMnTykIxzIh+26MeLQOg2SFUXNjAroRv24u PVjA== X-Gm-Message-State: AHYfb5g+kTM2/MdNf8O6kozKUcLdxvd/dyJgP+ssJnSxr/vWvXa8TU53 ZmY0kw9r2F0e5XRczkI= X-Received: by 10.25.84.136 with SMTP id b8mr191048lfl.9.1504018627031; Tue, 29 Aug 2017 07:57:07 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:06 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 4/8] PM / ACPI: Split code validating need for runtime resume in ->prepare() Date: Tue, 29 Aug 2017 16:56:46 +0200 Message-Id: <1504018610-10822-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> Move the code dealing with validation of whether runtime resuming the device is needed during system suspend. In this way it becomes more clear for what circumstances ACPI is prevented from trying the direct_complete path. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/acpi/device_pm.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 632f214..5181057 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -989,6 +989,27 @@ int acpi_dev_resume_early(struct device *dev) } EXPORT_SYMBOL_GPL(acpi_dev_resume_early); +static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev) +{ + u32 sys_target = acpi_target_system_state(); + int ret, state; + + if (device_may_wakeup(dev) != !!adev->wakeup.prepare_count) + return true; + + if (sys_target == ACPI_STATE_S0) + return false; + + if (adev->power.flags.dsw_present) + return true; + + ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); + if (ret) + return true; + + return state != adev->power.state; +} + /** * acpi_subsys_prepare - Prepare device for system transition to a sleep state. * @dev: Device to prepare. @@ -996,26 +1017,16 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume_early); int acpi_subsys_prepare(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); - u32 sys_target; - int ret, state; + int ret; ret = pm_generic_prepare(dev); if (ret < 0) return ret; - if (!adev || !pm_runtime_suspended(dev) - || device_may_wakeup(dev) != !!adev->wakeup.prepare_count) - return 0; - - sys_target = acpi_target_system_state(); - if (sys_target == ACPI_STATE_S0) - return 1; - - if (adev->power.flags.dsw_present) + if (!adev || !pm_runtime_suspended(dev)) return 0; - ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); - return !ret && state == adev->power.state; + return !acpi_dev_needs_resume(dev, adev); } EXPORT_SYMBOL_GPL(acpi_subsys_prepare); From patchwork Tue Aug 29 14:56:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111223 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457567qge; Tue, 29 Aug 2017 07:57:09 -0700 (PDT) X-Received: by 10.46.77.84 with SMTP id a81mr267325ljb.134.1504018629294; Tue, 29 Aug 2017 07:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018629; cv=none; d=google.com; s=arc-20160816; b=oczARWjlJVdrKxYzYfRqZIfcz0iJjf9isXzSRmXY2Njt2NWPWuBXVAOEBnM2s9AfYL HEUTnXxVnWS778MdYhGsD4GLyGz1XJ4ykHAZb+qhk4hMhWGttH6+R/IcmOmqhPfmUxlQ Tlo+sI96HSvrkNzud5NFUEL/OCi7I4fJiZ/6hilHpiQTau5TLjwbznt2w5T3NHvsS6r3 bLYbpHKtGtKt0VviFPS6XdXFrZwSUdDnoKYhri5xL1+8GliQkMxyJoyIveGyKITTDb/i /8ylLbzqhJ0nVjhu6JXMV40MWxU6gsfqdhQ8y7mXTAsvbKcBdtI9lTY810nx1yT/77Pt bW0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=f36S30elag1XUSQJ2xs8/bYVZoa7ATy6lX0aBxlSVbM=; b=AKq4nX75ktgI+1ry7dMH561if40DW3Pf60b9aBqXWskva7IIvkRhPuYFnkNBpB+1tx CRATXWRb3I04UZkkfaij63stNXPaa2zB6LV6DSwhvXcdG2+AVe29Ts7Y6bUZVMMF5ljs n8+Cby1xMh2WSYR7zbK55AEP64XgS2Lb+tDFa8Dvyp3koTWbikUGdYllyp5/ZT+76T7P zwDaa1AvjRSuwD/2trWFrvwD2v2LIOxai/0KoHmSLZpM6AHlv2gqggRIYPavYJYIRlWy BiEfK3FbvMa1r01apk4K9wBMuRMke8H5KpNynQhGn8zt3KoqI5WM02toM/SK1AxBhdiL nfUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gUg8qNZd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x230.google.com (mail-lf0-x230.google.com. [2a00:1450:4010:c07::230]) by mx.google.com with ESMTPS id n1si1412468lje.479.2017.08.29.07.57.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) client-ip=2a00:1450:4010:c07::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gUg8qNZd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x230.google.com with SMTP id z12so14370508lfd.3 for ; Tue, 29 Aug 2017 07:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f36S30elag1XUSQJ2xs8/bYVZoa7ATy6lX0aBxlSVbM=; b=gUg8qNZdgTFXYBikNQpTwlNrIoJ1Rqbkn8/MrtmNa4CdqTegSsIx0mLvBr3RLROVvD Kc/plvnQ2oDlQuxWCyDykDw35gFxLyjzHikJvFDopc65ihv9EvDxYrJDAynZlAiw7KAG 6He1UHzicDQavqHgg7qPfGNiGZjF//vGPM7Kc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f36S30elag1XUSQJ2xs8/bYVZoa7ATy6lX0aBxlSVbM=; b=jQJ85Gv05E5IaV0voQcAW1NGWM/4YbgPGuq7r4DShKosw5JE5diXfZS/Vw67L5plVL nGUb456FfioddGYShUJ/t7Y9CsnQOh2J/kiswe9m1j+9/TgCcDBJvs5Txj1GUg9YTG/f PSujgqGv1ROyd68/p9miwLCCXYDIeUzWI3+TW6Vk4NlohzbmftZXyhbLVCpwR1U9wOSF zeqbJueKLtWCVaCk5qABoX8KMeZUySMwgIe+X9LPBOtjcUqvcH+c6AdWve5+STj2IQ9z A6nBYMByeOPtIKnDqq1fSjXHQr+qybYxQuk5wURbwxTqRRGo6GSepXsgsrhUFQT069Af zHfQ== X-Gm-Message-State: AHYfb5icqTyWmiidOgCh3Smt0CI4r8OEWEYAFjRqVM4wI9+LVXPDfmXP zkRo05SgK1D0YNXS2rY= X-Received: by 10.25.31.136 with SMTP id f130mr156330lff.135.1504018628870; Tue, 29 Aug 2017 07:57:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:08 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 5/8] PM / ACPI: Split acpi_lpss_suspend_late|resume_early() Date: Tue, 29 Aug 2017 16:56:47 +0200 Message-Id: <1504018610-10822-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> Move the code which is special to ACPI LPSS into separate functions. This may clarify the code a bit, but the main purpose of this change, is instead to prepare for additional changes on top. Ideally the following changes should then become easier to review. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/acpi/acpi_lpss.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 0c84d15..e726173 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -717,22 +717,28 @@ static void acpi_lpss_dismiss(struct device *dev) } #ifdef CONFIG_PM_SLEEP -static int acpi_lpss_suspend_late(struct device *dev) +static int lpss_suspend_late(struct device *dev) { struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); + + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) + acpi_lpss_save_ctx(dev, pdata); + + return acpi_dev_suspend_late(dev); +} + +static int acpi_lpss_suspend_late(struct device *dev) +{ int ret; ret = pm_generic_suspend_late(dev); if (ret) return ret; - if (pdata->dev_desc->flags & LPSS_SAVE_CTX) - acpi_lpss_save_ctx(dev, pdata); - - return acpi_dev_suspend_late(dev); + return lpss_suspend_late(dev); } -static int acpi_lpss_resume_early(struct device *dev) +static int lpss_resume_early(struct device *dev) { struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); int ret; @@ -746,6 +752,17 @@ static int acpi_lpss_resume_early(struct device *dev) if (pdata->dev_desc->flags & LPSS_SAVE_CTX) acpi_lpss_restore_ctx(dev, pdata); + return 0; +} + +static int acpi_lpss_resume_early(struct device *dev) +{ + int ret; + + ret = lpss_resume_early(dev); + if (ret) + return ret; + return pm_generic_resume_early(dev); } #endif /* CONFIG_PM_SLEEP */ From patchwork Tue Aug 29 14:56:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111224 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457616qge; Tue, 29 Aug 2017 07:57:11 -0700 (PDT) X-Received: by 10.46.9.80 with SMTP id 77mr245864ljj.143.1504018631405; Tue, 29 Aug 2017 07:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018631; cv=none; d=google.com; s=arc-20160816; b=wO9wA15Qn4etE56/NZayG8FK5QXNX5lweX4dL6CWezbxmwTgZ8wcEDPUFWqOXxzMqu YKROznExcJhVXTTlAHtAwtFjDXKJoIG5yuOI2r876Pzzsyz5xKPqapMijg/j/AdO5Bvo It7NR706jXDUWN3h8fqNYG2KMajma/xGP61LwHkq1HITPws8H++6MnnwHYjtn3T2/hv8 lL6W7IDUsQns/CE+PtLNa83JYLY275KO94UNnAzgghvBRFusU+5RZi3B5sELQNGf5PJd uSKC6pasj6BrOIBFU2pRxwGSr+6W6mD1FK0JmrJ4bBBMJ5k+yHCHi310frJgdkY404at cYHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=8jrgc/IfGCMNNVG6RujufZsFpV26gsYCNTzrZZAH2L4=; b=Il0LW0PIdSAzyvi4dZPLfjkFRNrrZbD6U83tw5VbESnatTdaqc6vBnGZCyTkB7Ml8l gYVIC6nrMA1YA+vCYfnle3iu1CFGjCRE88VoJ15NWth3dDD7C6TJw6O6nk8P+Dfby+8H POa2eJf1BdQ627AGEdTfTn8H/iUD2ccm0mF3JdILDX+J0KTzH4iEj4q7Prq5ZaCHb6RE Nkie2zmDvXl0uVjFa0/JYMmGSyLlkCflQLiNtd1uRXI+dT9CtQUZz3LS6984nnpeg0hm /wOofmef0VFVhPnhG9b52j4dij17cot6bT57OJRY21rf+LG+HiBEMOicaRectNjvt3Bx qzvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KLZcXQUM; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com. [2a00:1450:4010:c07::22a]) by mx.google.com with ESMTPS id i15si1367604ljd.177.2017.08.29.07.57.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) client-ip=2a00:1450:4010:c07::22a; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KLZcXQUM; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22a.google.com with SMTP id z12so14370895lfd.3 for ; Tue, 29 Aug 2017 07:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8jrgc/IfGCMNNVG6RujufZsFpV26gsYCNTzrZZAH2L4=; b=KLZcXQUMH0ZdlLmvFgQYyCQ49ecr9blyUkiwvpKM8mjDpHCY2GoUOOVO3+Yu0oeZlz muu5dasMhdfkbWYTrFo2YJISL5zr9i+WYX5ODcesC14QMHB9wOMA33N75LdPRM7JOSM0 4nuIpPyKO/aWaiZM3IvRxWPm8ot5n0TOXvhzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8jrgc/IfGCMNNVG6RujufZsFpV26gsYCNTzrZZAH2L4=; b=tjQqZ74Enqya4VKb7SGfTkEnzdqqWs9JQzwiMaOFQT6APwoJ2rfnufKSfVg1G1idqU zbWKmFqahPxX0+TOAuV6g2Fx9b6xHTqCbKRE+VzADJQkMLv9TqPQlDMc5hRtmLpwCruy WhkuVKgpS8DiRlUGH7oy8sEOQGS6cnhBz6vnz10oJDyJBa5Coy4G3ZJo/TceDJp29ecN 8Vnr9ouW+l2rRhB6p5u4UQDKfAVtz8UoYDa162hk9ZkYUuDNJ+qjRrPo/QMGBwBiE3RN 6OSQyyp9amMHXJnVi+H7sayWppqQYGpfnCKXrLBlSp6W+hyKDRUer1HtNhXX8HmzG1HW bjHg== X-Gm-Message-State: AHYfb5iwcc/ZNPVc7IpGTx3MzBiXfnO4LX5eOytbpB/9laUkfnBf71P/ CW1o9ydLBTUTQ8FWHfg= X-Received: by 10.25.216.89 with SMTP id p86mr208017lfg.27.1504018630869; Tue, 29 Aug 2017 07:57:10 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:10 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach for system sleep Date: Tue, 29 Aug 2017 16:56:48 +0200 Message-Id: <1504018610-10822-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> This change enables the ACPI PM domain to cope with drivers that deploys the runtime PM centric path for system sleep. Currently the ACPI PM domain supports the direct_complete path, which offers some nice optimizations from PM point of view during system sleep. However, the runtime PM centric path have some additional optimizations that this change enables for the ACPI PM domain. Let's walk through them. *) The runtime PM centric path, doesn't require the device to be runtime suspended during system suspend, when later during system resume trying to avoid to bring it back into full power. That is the case for the direct_complete path. This further avoids wasting power during system resume, but should also decrease the time it takes to resume the device. **) When the runtime PM centric path is used, the PM core does not skip calling any system sleep callbacks for the device, which is the case in the direct_complete path. Based on that knowledge and relying on the driver to do the right thing, the ACPI PM domain may avoid to always runtime resume the device in the device_suspend() phase. ***) In the runtime PM centric path, the device may remain runtime PM enabled until the device_suspend_late() phase, instead of as in the direct_complete path, in the device_suspend() phase. This is convenient if the device needs to be runtime resumed sometime during the device_suspend() phase. To deploy the runtime PM centric approach for the ACPI PM domain, and make it benefit from the above optimizations, the follow changes are made. First, the ACPI PM domain's runtime PM callbacks may be called when runtime PM has been disabled for the device. This serves as an indication to understand when they are running in the system sleep sequence, instead of in the regular runtime PM path. For these cases, make the ACPI PM domain to execute the same operations as normally being run, when the ->suspend_late() and the ->resume_early() callbacks are invoked. Second, the ACPI PM domain's ->suspend_late() callback, shall not execute the regular operations to put the device into low power state, when the runtime PM centric path is used. Calling pm_generic_suspend_late() is sufficient. Vice verse applies to the ACPI PM domain's ->resume_early() callback. Third, in the ACPI PM domain's ->suspend|freeze() callbacks, let's avoid runtime resuming the device in case the runtime PM centric path is used, unless there are ACPI PM domain specific reasons to not. Signed-off-by: Ulf Hansson --- Changes in v3: - Convert to use the PM core flag, is_rpm_sleep flag. - Fold in changes from patch v2 7/9, which means avoiding to runtime resume the device in the ACPI PM domain's ->suspend|freeze() callbacks. - Updated changelog to reflect new changes. --- drivers/acpi/acpi_lpss.c | 56 ++++++++++++++++++++++++++++++--------------- drivers/acpi/device_pm.c | 59 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 87 insertions(+), 28 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index e726173..2e34f69 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -732,7 +732,7 @@ static int acpi_lpss_suspend_late(struct device *dev) int ret; ret = pm_generic_suspend_late(dev); - if (ret) + if (ret || dev_pm_is_rpm_sleep(dev)) return ret; return lpss_suspend_late(dev); @@ -757,13 +757,22 @@ static int lpss_resume_early(struct device *dev) static int acpi_lpss_resume_early(struct device *dev) { - int ret; + int ret = 0; - ret = lpss_resume_early(dev); - if (ret) - return ret; + if (!dev_pm_is_rpm_sleep(dev)) + ret = lpss_resume_early(dev); - return pm_generic_resume_early(dev); + return ret ? ret : pm_generic_resume_early(dev); +} +#else +static inline int lpss_suspend_late(struct device *dev) +{ + return 0; +} + +static inline int lpss_resume_early(struct device *dev) +{ + return 0; } #endif /* CONFIG_PM_SLEEP */ @@ -861,6 +870,9 @@ static int acpi_lpss_runtime_suspend(struct device *dev) if (ret) return ret; + if (!pm_runtime_enabled(dev)) + return lpss_suspend_late(dev); + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) acpi_lpss_save_ctx(dev, pdata); @@ -882,21 +894,29 @@ static int acpi_lpss_runtime_resume(struct device *dev) struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); int ret; - /* - * This call is kept first to be in symmetry with - * acpi_lpss_runtime_suspend() one. - */ - if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available()) - lpss_iosf_exit_d3_state(); + if (pm_runtime_enabled(dev)) { + /* + * This call is kept first to be in symmetry with + * acpi_lpss_runtime_suspend() one. + */ + if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && + iosf_mbi_available()) + lpss_iosf_exit_d3_state(); - ret = acpi_dev_runtime_resume(dev); - if (ret) - return ret; + ret = acpi_dev_runtime_resume(dev); + if (ret) + return ret; - acpi_lpss_d3_to_d0_delay(pdata); + acpi_lpss_d3_to_d0_delay(pdata); - if (pdata->dev_desc->flags & LPSS_SAVE_CTX) - acpi_lpss_restore_ctx(dev, pdata); + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) + acpi_lpss_restore_ctx(dev, pdata); + + } else { + ret = lpss_resume_early(dev); + if (ret) + return ret; + } return pm_generic_runtime_resume(dev); } diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 5181057..f5c4d0e 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -913,7 +913,14 @@ EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); int acpi_subsys_runtime_suspend(struct device *dev) { int ret = pm_generic_runtime_suspend(dev); - return ret ? ret : acpi_dev_runtime_suspend(dev); + + if (ret) + return ret; + + if (!pm_runtime_enabled(dev)) + return acpi_dev_suspend_late(dev); + + return acpi_dev_runtime_suspend(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); @@ -926,7 +933,13 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); */ int acpi_subsys_runtime_resume(struct device *dev) { - int ret = acpi_dev_runtime_resume(dev); + int ret = 0; + + if (!pm_runtime_enabled(dev)) + ret = acpi_dev_resume_early(dev); + else + ret = acpi_dev_runtime_resume(dev); + return ret ? ret : pm_generic_runtime_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); @@ -1023,7 +1036,7 @@ int acpi_subsys_prepare(struct device *dev) if (ret < 0) return ret; - if (!adev || !pm_runtime_suspended(dev)) + if (!adev || dev_pm_is_rpm_sleep(dev) || !pm_runtime_suspended(dev)) return 0; return !acpi_dev_needs_resume(dev, adev); @@ -1042,7 +1055,8 @@ void acpi_subsys_complete(struct device *dev) * the sleep state it is going out of and it has never been resumed till * now, resume it in case the firmware powered it up. */ - if (dev->power.direct_complete && pm_resume_via_firmware()) + if ((dev->power.direct_complete || dev_pm_is_rpm_sleep(dev)) && + pm_resume_via_firmware()) pm_request_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_complete); @@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete); * @dev: Device to handle. * * Follow PCI and resume devices suspended at run time before running their - * system suspend callbacks. + * system suspend callbacks. However, try to avoid it in case the runtime PM + * centric path is used for the device and then trust the driver to do the + * right thing. */ int acpi_subsys_suspend(struct device *dev) { - pm_runtime_resume(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + + if (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev)) + pm_runtime_resume(dev); + return pm_generic_suspend(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_suspend); @@ -1071,7 +1094,11 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend); int acpi_subsys_suspend_late(struct device *dev) { int ret = pm_generic_suspend_late(dev); - return ret ? ret : acpi_dev_suspend_late(dev); + + if (ret || dev_pm_is_rpm_sleep(dev)) + return ret; + + return acpi_dev_suspend_late(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); @@ -1085,7 +1112,11 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); */ int acpi_subsys_resume_early(struct device *dev) { - int ret = acpi_dev_resume_early(dev); + int ret = 0; + + if (!dev_pm_is_rpm_sleep(dev)) + ret = acpi_dev_resume_early(dev); + return ret ? ret : pm_generic_resume_early(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); @@ -1096,13 +1127,21 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); */ int acpi_subsys_freeze(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + /* * 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. + * transitions. In case the runtime PM centric path is used, let's try + * to avoid it. */ - pm_runtime_resume(dev); + if (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev)) + pm_runtime_resume(dev); + return pm_generic_freeze(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_freeze); From patchwork Tue Aug 29 14:56:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111225 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457658qge; Tue, 29 Aug 2017 07:57:13 -0700 (PDT) X-Received: by 10.25.56.22 with SMTP id f22mr174273lfa.92.1504018633060; Tue, 29 Aug 2017 07:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018633; cv=none; d=google.com; s=arc-20160816; b=w5fIrqNX0OrXwDAR0ELd7ldFNwfPPSGdSW9BoGnhcworZJ3e28qMfi6N0WsTI8bPWL 0hWVJqcjFAR6kuYHU6RfMNaKNS8HHGRL56uiIojDJki6fxvPKtEZMnLMUAeSy2ss7dgw lJdbSdH7j07aOSR57Vjk7TJtfArnvxs5eE0zo8B/8ALKyS+NNoBOmArSCtDPIXaaMvOy QQ3TIqaGj8xeVcY0mfEY+omyGSnUTFgrLHWvI8czQkzHVtvhqs4Sy/qFmCmipJe0nSy2 rispulRZoCYqnCX1QnMQAG+2vA3sK0soSK4p3/52dDXt8B2P/HFu2eW1uRMfOAGLEwlc h71g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=fMV4lip5F1xWDoteHgqSSVCG4o5V6Vtcqr29AzWTpyQ=; b=BkyXtEa9rmXwxilWjpzz1TVZAq/1T+nyAtY70/B/S8au8i5r16noOS3YWU8E2GH+lL Wzwtl4J5GJIalUh6q6XJYAi1yhK0jEGnzLZCYx42o+wYR4vBtnXUa/NKK04cgvZUmbPz 4nurItGhxitGR98MB/Y3sQmwiaczH6hmAT6xEIOH+tZFVU1aQkCcUV8HxmSjNBMaErwK Ou9nd/frUW3KWMYpPymtJv7L9weEP9IYbvT5KLMMm/f6gM1ZRLSTkSBgX3GPWJEN3eRh Om8/tsiOigh7lUY4TqETk35Omur3oLkXdAZNmdDFCx2FyBprmPdL+uS7eFSJ6R4s1Ngp bZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EPbaCeiX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x234.google.com (mail-lf0-x234.google.com. [2a00:1450:4010:c07::234]) by mx.google.com with ESMTPS id n9si1287298lfg.413.2017.08.29.07.57.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) client-ip=2a00:1450:4010:c07::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EPbaCeiX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x234.google.com with SMTP id z12so14371227lfd.3 for ; Tue, 29 Aug 2017 07:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fMV4lip5F1xWDoteHgqSSVCG4o5V6Vtcqr29AzWTpyQ=; b=EPbaCeiXzQeazS8pSBCnrk4aSeNE3XXcTr8KkNsLGxH79pYpHk0fZEFbihDu9Vnz7O cTjSl453zDO+Q0Zn3+q4Dkmhqligq1/7ytZLaprMxowRBzfspE4hMzOYNv2KIZ7dni8E fmFdJqgvzkFO733LwDZCsHHs7rvGT0iI+ZlrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fMV4lip5F1xWDoteHgqSSVCG4o5V6Vtcqr29AzWTpyQ=; b=nM/vXjRfLMKlgljOxkycKDGgN9zRL7tYIWRw/Qqs3YoVC1flxmetbEn+abVgxwsOXf PWudyXf5u7zPdlZuLhuXBKnEnXa+UBQ8fvlN830UgWFecIo45KgSySQl9Icb+AWeq6Iy 9XjEVsxH4wjXKhRuB+iAfE601+f3JvJW+uSaUfSOt/+0526z7IAamLJ7tMzTPGcB8QEa 8qbkUnkyZlDvTGAfKkQPjodHcWZpSZCEDCICfYe/7qPNG1yNK/LwfIcN7OI69+raOPzn f8xbFbLH0BO8GpXQ2KTk0bB4TGPQH5Lp1hGIiwnbhRgQ7Rqqj4G0SpEbhK/evYoNNtGH PrAg== X-Gm-Message-State: AHYfb5gCM3ueskFDsFXlmZNHE0ljC2fOy+7PftD7EnNJsModYHjG2Fj9 cmF3P0hqpDCPZnZvCYc= X-Received: by 10.25.145.70 with SMTP id y6mr120016lfj.99.1504018632653; Tue, 29 Aug 2017 07:57:12 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:11 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 7/8] i2c: designware: Don't resume device in the ->complete() callback Date: Tue, 29 Aug 2017 16:56:49 +0200 Message-Id: <1504018610-10822-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> In case the PM core is able to use the direct_complete path during system sleep for the i2c device, the device is runtime resumed in the ->complete() callback. For ACPI platforms this is needed to synchronize the power state of the device, while for non-ACPI platforms this is a waste. To better deal with this, let's drop the ->complete() callback from the i2c-dw-plat driver altogether, thus avoiding the runtime resume of the device. This change still plays well for the ACPI case, because the ACPI PM domain's ->complete() callback, assigned to acpi_subsys_complete(), already deals with runtime resuming the device in case it's needed. Signed-off-by: Ulf Hansson --- Changes in v3: - None. --- drivers/i2c/busses/i2c-designware-platdrv.c | 8 -------- 1 file changed, 8 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 57248bc..38121c9 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -417,15 +417,8 @@ static int dw_i2c_plat_prepare(struct device *dev) { return pm_runtime_suspended(dev); } - -static void dw_i2c_plat_complete(struct device *dev) -{ - if (dev->power.direct_complete) - pm_request_resume(dev); -} #else #define dw_i2c_plat_prepare NULL -#define dw_i2c_plat_complete NULL #endif #ifdef CONFIG_PM @@ -461,7 +454,6 @@ static int dw_i2c_plat_suspend(struct device *dev) static const struct dev_pm_ops dw_i2c_dev_pm_ops = { .prepare = dw_i2c_plat_prepare, - .complete = dw_i2c_plat_complete, SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_resume, From patchwork Tue Aug 29 14:56:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 111226 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457708qge; Tue, 29 Aug 2017 07:57:15 -0700 (PDT) X-Received: by 10.46.64.149 with SMTP id r21mr249315lje.61.1504018634965; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018634; cv=none; d=google.com; s=arc-20160816; b=PpqMRJX0QsBSYEBJeicS78WCYrh98uPoLx5d1D+9nxpbypRQlWJ5qA5dwKjJ5PxIow yeYi+HS/iAak8LEXWxgbzyx+jMY2KNe+EiJ2HLC2Y9IwT1Hi05nL7jxwm8UgD6WMx/zx rDArJlKr/mfJ1iPa8Q/KNMynw6fa3E+NkakfMNMav2ZdbGlIzp0Myc9lThqZaYYEdB7y 0dJenieUdEdulQ5YOi4YMGDO4aDaZ8iROnPdD4gaF0cHJfGQvoxcC3XgiLhOshzFs/gT VAsqVAGDU7O41SeHjgyvMFujiTxGuKYPJ42mbz+chHI9K0lkkmSIQz7UquMiJrDgOvXJ 5SSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dKHCfwk+yvoTIcSdGw1fMF7sumRlyzDWX+dmJ6xv8nA=; b=gVDPEiqo96gn0fR6oQhgFhWuGpTYrakkj9A0fOFK143siR6Z1aGL29KVCPccEHRkgA UyuMQYuBPxvnocth9MY9RKWl7N7yup1+u+S7+2xFJIBMUer1h+Td6Cem42Xz8XpkX1oW qdBsF/EoBOTfmeXtKIdFPoBt0PAAHxzi8UjDyQkOJy4HEKIB/fkLXiTFtIi/+zmnE5ib H4QP3/ytVEllnXHJfin1F6YfDdI7AdjBuA/v4SVinarS1EDijWisZnzDN0NIMqdJpJK3 sNXDuAAcR+L16+PoGPKwCQYXHMAsgTzrb3WpMTQ1iToVtVG/do1YElmT3SV+EjJ03bNr bIWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iT6aTupl; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x234.google.com (mail-lf0-x234.google.com. [2a00:1450:4010:c07::234]) by mx.google.com with ESMTPS id h21si1275964lfe.309.2017.08.29.07.57.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) client-ip=2a00:1450:4010:c07::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iT6aTupl; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x234.google.com with SMTP id z12so14371541lfd.3 for ; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dKHCfwk+yvoTIcSdGw1fMF7sumRlyzDWX+dmJ6xv8nA=; b=iT6aTuplL2iyRlieazBXchlzF+X1ufa0/cR1CShpk74PHUEZLeauzU3UF95h1RJmhR ZtbpBzKyOTSGtMVoen/DSCi9fp8kGRaTfnjSitk3CLQGTKAEoEjM+qqUsCoGciOmSbK0 NMF0BK7i19eb6kxvrENllvheVL3n7BENOsp/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dKHCfwk+yvoTIcSdGw1fMF7sumRlyzDWX+dmJ6xv8nA=; b=ueaKGbRmGbF3m0C418EcxlKeNqItPHOM55NW38P7+kIBjy9SkAifdnO2FKYcBi7zOU N6B7pEGiGCLeQPZvwXpiNXTiRM4SbiTCWuPz4lKFzwm9L9VxqeG1VEjGBgkWKMsH1jGf GRBa2EJbHK33AN1eLEnYoQv+04NT4BHTQZ//w+xOHSZd91OVGi649zOuGF0+ZpAe1zv5 kjpNTpXswkAnR4NN+TuQFnyzOdbW9/2Wkv0csal1mZOv6LWFgJGON7f6n3tRE6r0U4tj Zrhc2bzqo96zGO3J97Hoal8bQ/rXpY7FOG8+TFhXLUsr9yAoHtrypcLK3HsFzHWifHTz +fGw== X-Gm-Message-State: AHYfb5iewzT0/yWkxXpLzAfrPTmfLZ4JKLwcRyaHHZElvr+1FPX3fmsR mIymXcp+z9899/uMvh4= X-Received: by 10.25.21.94 with SMTP id l91mr170588lfi.160.1504018634452; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:13 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 8/8] i2c: designware: Deploy the runtime PM centric path for system sleep Date: Tue, 29 Aug 2017 16:56:50 +0200 Message-Id: <1504018610-10822-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> Currently the device is runtime resumed in the i2c-dw-plat driver's ->suspend() callback, which is needed to manage system sleep properly. The particular reason for the runtime resume is because the PM core may unset the direct_complete flag for a parent device, in case its child device are being system suspended before. This leads to that the i2c-dw-plat driver's ->suspend() callback can be invoked when the device is runtime suspended. Runtime resuming the device in this scenario may be unnecessary, in case when the device is already in its proper lower power state for system sleep. This behaviour increases the time it takes to put the device into low power state, but means also a waste of power. Let's fix the behaviour by deploying the runtime PM centric path for system sleep, via assigning the pm_runtime_force_suspend|resume() helpers as the system sleep callbacks for the i2c-dw-plat driver. We must also inform the PM core and the ACPI PM domain that we are now using the runtime PM centric path, therefore we call dev_pm_use_rpm_sleep() during ->probe(). While deploying the runtime PM centric path, the ->prepare() callback becomes redundant, so let's drop it. Along with these improvements, of course we also get the other regular benefits one get when deploying the runtime PM centric path. Signed-off-by: Ulf Hansson --- Changes in v3: - Use dev_pm_use_rpm_sleep() instead of the earlier acpi_disable_direct_complete() from v2. - Updated changelog. --- drivers/i2c/busses/i2c-designware-platdrv.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 38121c9..20db3c2 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -371,6 +371,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) if (ret) goto exit_probe; + dev_pm_use_rpm_sleep(&pdev->dev); return ret; exit_probe: @@ -412,15 +413,6 @@ static const struct of_device_id dw_i2c_of_match[] = { MODULE_DEVICE_TABLE(of, dw_i2c_of_match); #endif -#ifdef CONFIG_PM_SLEEP -static int dw_i2c_plat_prepare(struct device *dev) -{ - return pm_runtime_suspended(dev); -} -#else -#define dw_i2c_plat_prepare NULL -#endif - #ifdef CONFIG_PM static int dw_i2c_plat_runtime_suspend(struct device *dev) { @@ -433,7 +425,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev) return 0; } -static int dw_i2c_plat_resume(struct device *dev) +static int dw_i2c_plat_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); @@ -444,19 +436,11 @@ static int dw_i2c_plat_resume(struct device *dev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int dw_i2c_plat_suspend(struct device *dev) -{ - pm_runtime_resume(dev); - return dw_i2c_plat_runtime_suspend(dev); -} -#endif - static const struct dev_pm_ops dw_i2c_dev_pm_ops = { - .prepare = dw_i2c_plat_prepare, - SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) + SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, - dw_i2c_plat_resume, + dw_i2c_plat_runtime_resume, NULL) };