From patchwork Thu Feb 9 03:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 93667 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp65781qgi; Wed, 8 Feb 2017 19:48:52 -0800 (PST) X-Received: by 10.84.225.150 with SMTP id u22mr1361104plj.157.1486612132091; Wed, 08 Feb 2017 19:48:52 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h91si8925459pld.68.2017.02.08.19.48.51; Wed, 08 Feb 2017 19:48:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751813AbdBIDso (ORCPT + 13 others); Wed, 8 Feb 2017 22:48:44 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:32850 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbdBIDsm (ORCPT ); Wed, 8 Feb 2017 22:48:42 -0500 Received: by mail-pf0-f180.google.com with SMTP id y143so46722754pfb.0 for ; Wed, 08 Feb 2017 19:48:37 -0800 (PST) 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 :in-reply-to:references; bh=kRlJeBgR5AiIepvZgRTxZ1oFmJ4OTF6okWaOIAvYZEE=; b=ctE6C2XyiXXjWbT/A4yvybE72fEXpuo9Wu568BeBid2fMlbOc2WYYLihhnCXX3H2sH hEhpHolOT9FWnIcJBOSU/ZxlbYSkVYgOqPWDpVeOUAXYJVW8cYI0dzmN98l5DIIH3mng f6mobY0ghRFUKWaPFEHHeizHHdmFssCkIRd8o= 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:in-reply-to:references; bh=kRlJeBgR5AiIepvZgRTxZ1oFmJ4OTF6okWaOIAvYZEE=; b=b1TH2x+BtZrOpVWes0dG1tK2WdV5Lh3a8wSqoZZsUOFQAnZLreaD4tq1sJLcfIwvPF Mw3cTbz2JsoqVLKTtaF5fQkc7MtK4Rc3TrXuPfWARqpgQcstp4bSLfdrICikghs/KIMk wAuOZx0PJgXtuanq3H9mK6PMK8adPa+iwFdMhNHbhq7Ax8LnWi/DP8pGPRBR/aCOsQmw Y5X1aP5jDm7lp7Qs8hqT0qpDvC2G1YY4PTbHH+SsWYs4w/Omu5VEBogKpGlXeHIEw/Qo rNhuHoV3QVj1ZvlKx3XCz1QRTKNerAb8FmH/GqNpFxIAoolthF6XL+QsvNmJm0RbVXV+ RW7Q== X-Gm-Message-State: AMke39nWZZGImTnwjWBitbRrrkhqyxhLVMFwCevdtK81EUEkFmjNOeZMfNfWQ1+5CfuQvnWq X-Received: by 10.84.194.37 with SMTP id g34mr1342922pld.105.1486611739584; Wed, 08 Feb 2017 19:42:19 -0800 (PST) Received: from localhost ([122.172.165.189]) by smtp.gmail.com with ESMTPSA id w123sm15874842pfb.44.2017.02.08.19.42.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 19:42:19 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , khilman@baylibre.com, ulf.hansson@linaro.org, Kevin Hilman , Pavel Machek , Len Brown Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , sboyd@codeaurora.org, nm@ti.com, robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, Viresh Kumar Subject: [PATCH V2 5/6] PM / domain: Save/restore performance state at runtime suspend/resume Date: Thu, 9 Feb 2017 09:11:51 +0530 Message-Id: <21383233a44afe5e5144fadb82867a0a890db46f.1486611268.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org With runtime PM, the devices get suspended while the system is up and running in order to save power. At such times, it is important to re-evaluate the required performance state of the domain, in order to choose a lower state if possible. This patch updates the genpd suspend/resume callbacks to do that. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 19 +++++++++++++++++-- include/linux/pm_domain.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) -- 2.7.1.410.g6faf27b -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1158a07f92de..ce9ab18be243 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -603,7 +603,8 @@ static int genpd_runtime_suspend(struct device *dev) { struct generic_pm_domain *genpd; bool (*suspend_ok)(struct device *__dev); - struct gpd_timing_data *td = &dev_gpd_data(dev)->td; + struct generic_pm_domain_data *pd_data = dev_gpd_data(dev); + struct gpd_timing_data *td = &pd_data->td; bool runtime_pm = pm_runtime_enabled(dev); ktime_t time_start; s64 elapsed_ns; @@ -660,7 +661,14 @@ static int genpd_runtime_suspend(struct device *dev) return 0; genpd_lock(genpd); + + /* Re-evaluate performance state of the domain */ + pd_data->cached_performance_state = pd_data->performance_state; + pd_data->performance_state = 0; + update_domain_performance_state(genpd, 0); + genpd_power_off(genpd, false); + genpd_unlock(genpd); return 0; @@ -677,7 +685,8 @@ static int genpd_runtime_suspend(struct device *dev) static int genpd_runtime_resume(struct device *dev) { struct generic_pm_domain *genpd; - struct gpd_timing_data *td = &dev_gpd_data(dev)->td; + struct generic_pm_domain_data *pd_data = dev_gpd_data(dev); + struct gpd_timing_data *td = &pd_data->td; bool runtime_pm = pm_runtime_enabled(dev); ktime_t time_start; s64 elapsed_ns; @@ -700,7 +709,13 @@ static int genpd_runtime_resume(struct device *dev) } genpd_lock(genpd); + ret = genpd_power_on(genpd, 0); + + /* Re-evaluate performance state of the domain */ + pd_data->performance_state = pd_data->cached_performance_state; + update_domain_performance_state(genpd, 0); + genpd_unlock(genpd); if (ret) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index d994ad5ba1c0..69b453d44adb 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -122,6 +122,7 @@ struct generic_pm_domain_data { struct notifier_block nb; struct notifier_block perf_nb; unsigned int performance_state; + unsigned int cached_performance_state; }; #ifdef CONFIG_PM_GENERIC_DOMAINS