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: 807143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jjn6j+ha"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvX0w9Mz9sR9 for ; Wed, 30 Aug 2017 00:57:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754669AbdH2O5H (ORCPT ); Tue, 29 Aug 2017 10:57:07 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:36079 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754658AbdH2O5D (ORCPT ); Tue, 29 Aug 2017 10:57:03 -0400 Received: by mail-lf0-f52.google.com with SMTP id z12so14368994lfd.3 for ; Tue, 29 Aug 2017 07:57:02 -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=O3Dc2yz6mJNuToqGcBEdRlL65tZXQzG9lr1kg4eeyIw2go8uvQEptLspeuWtH2l6t7 l7IC4KhxMaQoeE04Cn01ZqsyfCm/4l61kGki7aqg5aPmUDL20/z4eRZ65fVxVbh4AUM3 ak40UEkDlU+SltAQwAfhoNLyYnf5b3RoQoJvJDpxsEC9FIvhfIpbh/wuj8KCAUOaaAK4 Y5xeW/hrOprlZbkbaN+VdJ5QSQ+fgVZoxwJbjv1b2YVEcIjXD+P/OsOmZpZEy3mXJEH0 4xgH/VztWjoOe5hrbSHX9NJBHBVxaEInejXSkcXvj+FovLhFbSkwZLYhatQLgwj/I5Y2 EN8Q== X-Gm-Message-State: AHYfb5hpUu1ozXLAyUKrZnKeSrXn2z13CdJCFEQWLzfiSPbn5IscjlJ6 QuYZKmI2hK0+CDeO X-Received: by 10.46.33.151 with SMTP id h23mr298552lji.92.1504018621596; Tue, 29 Aug 2017 07:57:01 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ctbr+X1o"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvC3sLnz9sR9 for ; Wed, 30 Aug 2017 00:57:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754673AbdH2O5I (ORCPT ); Tue, 29 Aug 2017 10:57:08 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:37905 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754611AbdH2O5F (ORCPT ); Tue, 29 Aug 2017 10:57:05 -0400 Received: by mail-lf0-f50.google.com with SMTP id d202so14330127lfd.5 for ; Tue, 29 Aug 2017 07:57:04 -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=KmLcW+A7mzfuxlHLlBywPoO8jbXe31iBCe/FdBBcDERsORgw2cbIRpGxYhzgG4Am1U cqnd4vx3Grd9TlRNUw8sM2iWy/Ffp2uctlEx77yxe444ZeqPA9hftQQAaL5YHG+Q8GRm gfLBrBtBzGE5MK+TccYmjVgufvmgdx7D995dAZ2oj2GJLpIipjlo8/znlz85gNyZ44pP 39jU3Nb0LzOrOkQu1PcMGVIRPhHXE/TvMXvOo2aKSy8O9k7eg/f6Lw708SNIcYJCQ+29 SIOKI2jdXaK4YOIt+JIiZZU9UVbdl0rHaSwyLLSKAIy7Cfso5AGObHKhHAHkAFfdcRs1 foZw== X-Gm-Message-State: AHYfb5hwRrIQ+iwVWS7s6gl6sf33mizArlXC+LhazILMVkajDSyvYLwV ImYWkIy4/BKDtOMU X-Received: by 10.46.88.90 with SMTP id x26mr256631ljd.53.1504018623456; Tue, 29 Aug 2017 07:57:03 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Mf1VaJ10"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvf0pTlz9sR9 for ; Wed, 30 Aug 2017 00:57:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754664AbdH2O53 (ORCPT ); Tue, 29 Aug 2017 10:57:29 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:34258 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754663AbdH2O5G (ORCPT ); Tue, 29 Aug 2017 10:57:06 -0400 Received: by mail-lf0-f54.google.com with SMTP id d17so14395882lfe.1 for ; Tue, 29 Aug 2017 07:57:06 -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=rqtnV4Mws1pu7XO/0jDlTVbHTXCwdoGpkI0QRaxByCnHlzrmFTGy8X9Jzt5NaEx1MZ pkPWWSXHWHuS0TPdhpmNV6dHtK32otGM2+HcJSePgz5OsGwD6bZED3bXH1XWcw0T5MDc 0GdURbwECFQIAnau8gdOP0kJbwVbzjjGZYKFTHkGgzfNbcuVWM9XhYRnUUA4hyYsNDbQ lECGUXNpcYraLswVQqV301U14+NL1JSa/l9UpQISWwvKPHOkRAQePZ7dw/pmtxzIKbam o3pbn+V/ybwQzekRiB6Rkx3vVJ3bfYOJfsV3NeuC3AS3y0HvCZkjiXtnSnWyvQlmfUDN aVWg== X-Gm-Message-State: AHYfb5iLm1L+sPxS5DUaah2zHXBoWiPRFBJInu1crAfT+sNEDglszn/o GKQHVXS4/XtE7BPB X-Received: by 10.46.5.19 with SMTP id 19mr272268ljf.155.1504018625301; Tue, 29 Aug 2017 07:57:05 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807139 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="AJTTGHek"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvN5Dh0z9t38 for ; Wed, 30 Aug 2017 00:57:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754681AbdH2O5N (ORCPT ); Tue, 29 Aug 2017 10:57:13 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:35488 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754583AbdH2O5I (ORCPT ); Tue, 29 Aug 2017 10:57:08 -0400 Received: by mail-lf0-f54.google.com with SMTP id k186so14377301lfe.2 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=E1xHWXoYbBg1Fp1Kk1DEIf/e/HGSmYRwBJjZThTFvzISfRV5gcGnmPuAQDyNfaWLfR EhJVRqy7+48yRsmv5dq52YW5Iz16fce9lzNN4Kr0vfEb4qMHDwH7GrG/J/DVCnLpoWPW mvNf9O1RPl13gwdaIe7+BEsYIxhKmOmxWqmoCSqOaEQM+uL/hQ7hmTB8xDxFW0ruV2yy iGcqRiM5RWG8fmHAPwm6k2BIqazjV1FYQaCMKTvtTBd55/ndYJ+b4M1n5mUVKnUQ2AsI sH1Bt1Ek7b6I0tu2ItTlDmqd7Fhgd7Qc1kaCHS4RlUKEfk4TMrC37cfFmQPbrreHSxi3 u0PA== X-Gm-Message-State: AHYfb5gOlPVE8kgNus8U4TIi/bSYKTYzGyWyJ6hp4FIJvhslcttNEMEL YCklKQmsqB0ufuAz X-Received: by 10.25.84.136 with SMTP id b8mr191048lfl.9.1504018627031; Tue, 29 Aug 2017 07:57:07 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gUg8qNZd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvV447Sz9sR9 for ; Wed, 30 Aug 2017 00:57:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754678AbdH2O5M (ORCPT ); Tue, 29 Aug 2017 10:57:12 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:35501 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754611AbdH2O5K (ORCPT ); Tue, 29 Aug 2017 10:57:10 -0400 Received: by mail-lf0-f42.google.com with SMTP id k186so14377668lfe.2 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=eeNBSwg80rxI92Q0h3hI1ADVMLC4XhVKOCR4JBvKX+UKm+fIJ7YG5UO2VM6LZQpAt5 saUrNPgezS5oRoecwJBDyvfspINB5g6yZzP+eAxZlv5/WGTRybstffyiWbPptVmROR1S lGM2slId7D2kLgrXzu7lusGR18mGNTUxtTkRWIOdnapvrRjJkfI2PJ8IKRFfSkISNlAI /E2CMc07xIDisX4Ad4Ugv/3t45S/RdqKjMhkdyTCzJmruVFaI7p6LiIY8X/dzMxMRx9K pK6qg0+1bdx8RcVfFcVgliIjD+UCYtOY1j+mvTVE1aRXYXIhhtItXbNWvsokwhX2cl+7 RsjA== X-Gm-Message-State: AHYfb5gJQE/LocDnIM36+hPFjvJYZSWVlrlDRYvTX7C6W1LkdBuHXquL n7ehbbgnIiHC6LTN X-Received: by 10.25.31.136 with SMTP id f130mr156330lff.135.1504018628870; Tue, 29 Aug 2017 07:57:08 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="KLZcXQUM"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvW1YXlz9t38 for ; Wed, 30 Aug 2017 00:57:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751664AbdH2O5Y (ORCPT ); Tue, 29 Aug 2017 10:57:24 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:37950 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754674AbdH2O5M (ORCPT ); Tue, 29 Aug 2017 10:57:12 -0400 Received: by mail-lf0-f44.google.com with SMTP id d202so14331628lfd.5 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=KSuZw3FS9Ys1kJTKxs1/HJXMdMQ/RXg4LF47yonsk8rVtyukrLNACkMs/1PHDhaZAX BN3fJxw0M46Bd0EbFaePEG+f7u4sdHklgz/K73+gWzSQiW5/4Y+Df/RXEzgCm9CmT1Kb GnKEcr6VWeOv+KSAtXcLpE5r50mdABWgNT8bdVMdZS4XGvRricG2YBRXun2CX8lXKD3m iakuV8HKI8v4wPR/TIRgChtEmJVX/veKwDC4U9xtAIfcquvuUc3lCD/dyCD/H7qbsNvS 8fpfwBeqaH3u/tv0E+2vNlnvIhopCUGijuKqq6vMJ+sJIvGGhP3dNP4exmpvxySeE9Jb gi0g== X-Gm-Message-State: AHYfb5iIY2QB4UtqRU1NJ0IbZ1ByVvW4+Dt6zZEmLQmhebivkMzrlsF0 2+rwOBYsPOGB2dPI X-Received: by 10.25.216.89 with SMTP id p86mr208017lfg.27.1504018630869; Tue, 29 Aug 2017 07:57:10 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807138 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EPbaCeiX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvL2LYnz9sR9 for ; Wed, 30 Aug 2017 00:57:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754685AbdH2O5P (ORCPT ); Tue, 29 Aug 2017 10:57:15 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:37832 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754656AbdH2O5O (ORCPT ); Tue, 29 Aug 2017 10:57:14 -0400 Received: by mail-lf0-f53.google.com with SMTP id y128so8738659lfd.4 for ; Tue, 29 Aug 2017 07:57:13 -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=bxaK60jyAME4kviqy28uq+24kdXNs+mJacm4T+P6xNljTeGALIz28Dl6xmbKQiCekc EP0IrAgPYqYVlUzPYdpVcZVsJVQheLIqlqS/fNMfSOvtMepdLGHRoOmV/By9GEH4YxPX ugZltg5g87ZZJ3SSH3TA9hok9MM31/NaO5KS00Mg94CEsn96VlWcbLDL9JvexiV8W8nU CG4D71eChFpnrU1d4iUPslOxLYM3xHZ2/80uhxdkz168Gc1TP47OYDjhVFoPBK3vTM3a Foow4teMag3k3e7VAlc4omCvUYbkM8vD8CBEW/hgdfDGBM2FylD210QE91to8quEbLhG JYoQ== X-Gm-Message-State: AHYfb5hwSo1ZNMsP6bwqI6+SL0eBx10d180GWJ9/RK4J77vGdAvJKNZ6 5cdQTcJlQ3dryhAW X-Received: by 10.25.145.70 with SMTP id y6mr120016lfj.99.1504018632653; Tue, 29 Aug 2017 07:57:12 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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: 807140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iT6aTupl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xhWvP4z1bz9t3F for ; Wed, 30 Aug 2017 00:57:21 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754679AbdH2O5U (ORCPT ); Tue, 29 Aug 2017 10:57:20 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34312 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754682AbdH2O5Q (ORCPT ); Tue, 29 Aug 2017 10:57:16 -0400 Received: by mail-lf0-f50.google.com with SMTP id d17so14397523lfe.1 for ; Tue, 29 Aug 2017 07:57:15 -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=NOQqsQyj5C9NGKNen8QCGn/OBQ6ghv3VsamyL0AXwCRD4ZAYXX3CRPyKI/31lKi965 a4X9IIWOtW0TyVTp8Hc/pSWrrH7TzaSc9/tkFWeY5UrsvTYfr8IKThgm82zfgOQuTZp8 vCFHSCB3iuE3f1cDfpSMo2bR9YRfI/BxW68xsMirVks+zOZy/yno8wDCzyKSgBtcS/NE i7G49dK8W4PEZHotNz3MY/YLo6Z6h8RR1IO3nFMaURowpE4ZOsF9LJlIlWo64gRsZRdN sKOhY57x1tCI/MlgJG17hb+aJUAMDreRdvKpe+4PWohZ7zyvhW1NtLXNs2iuzQX7gjWY pLIg== X-Gm-Message-State: AHYfb5gE0yXxiIuwnvXpRwZYHdNe2sEvFaZFXB95inHoZvYMlaj+dr7X 5NSzKqF8FEE+p6XY X-Received: by 10.25.21.94 with SMTP id l91mr170588lfi.160.1504018634452; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) 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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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(-) 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) };