From patchwork Tue Jan 3 11:06:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 89631 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7951482qgi; Tue, 3 Jan 2017 03:07:14 -0800 (PST) X-Received: by 10.84.167.2 with SMTP id c2mr131740629plb.56.1483441634712; Tue, 03 Jan 2017 03:07:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si25735369plk.60.2017.01.03.03.07.14; Tue, 03 Jan 2017 03:07:14 -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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934856AbdACLG6 (ORCPT + 13 others); Tue, 3 Jan 2017 06:06:58 -0500 Received: from mail-pg0-f46.google.com ([74.125.83.46]:35198 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934803AbdACLGu (ORCPT ); Tue, 3 Jan 2017 06:06:50 -0500 Received: by mail-pg0-f46.google.com with SMTP id i5so149100341pgh.2 for ; Tue, 03 Jan 2017 03:06:50 -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=i8Gilm3sR4X1ZwTLFdVHEZaqure23Tf9hp0NnPo2JrI=; b=So8yNxy52SC3jFPjp7ceI3+2lKJZESNML1DKrm/RN+xI8Q5a/5+qGJuqHww2G0OinW I/3YYwBWoI9JSisJPYn0HT6q1Az5+MKFnMbQdgAFBqmLLkCKBhaUfMzPyvxiuIsWFUVR qjKkhLcZY6AH+c0NfcAxV4MwWwhPjsl7LV0us= 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=i8Gilm3sR4X1ZwTLFdVHEZaqure23Tf9hp0NnPo2JrI=; b=kNbXmDc+cIp54XvlRX5oZXcmrvFxmD4bRduwTu6hLnsfZBr/W3lEeQpwPVUdGQRxth fWupLKc0siJYZ/X9GqMCExCqTK012aGZJp4+hSwCnwv0U9UxROUl9Ts1RQJ86rFbS+ut e34Yvu8WG933CAbWwkTYkH+XhtWsmifI1TwqjzWOZv8AjVXoW271PjND2BMN4ihIyJUv 7DMGmKMSFvUFCRJ8veyKNpejJh6POcugV8XFBiZ+fYEsnN8fCAdva43pC9U23QXjDOJ3 gkEjppy7aCQmKFGB1GkG+JS390bLkvoZY9X98OYjxDzz3PBXcH2dsZIcilPfA0A3lQ+T 8fBw== X-Gm-Message-State: AIkVDXJZ+LE/pBYJJQrrY5ZXnN0KEhwNDgw7FKVUnssbx7Yq/H3nFZuKBDspGxvFJUULKQhP X-Received: by 10.84.216.17 with SMTP id m17mr132722662pli.82.1483441609497; Tue, 03 Jan 2017 03:06:49 -0800 (PST) Received: from localhost ([122.171.77.55]) by smtp.gmail.com with ESMTPSA id y73sm139098921pfa.68.2017.01.03.03.06.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 03:06:48 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , khilman@baylibre.com, ulf.hansson@linaro.org, Kevin Hilman , Len Brown , Pavel Machek Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd , Nishanth Menon , Vincent Guittot , robh+dt@kernel.org, mark.rutland@arm.com, lina.iyer@linaro.org, rnayak@codeaurora.org, Viresh Kumar Subject: [PATCH 5/6] PM / domain: Save/restore performance state at runtime suspend/resume Date: Tue, 3 Jan 2017 16:36:11 +0530 Message-Id: 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 f460be4ca5f7..ef4062927713 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -576,7 +576,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; @@ -633,7 +634,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); + genpd_poweroff(genpd, false); + genpd_unlock(genpd); return 0; @@ -650,7 +658,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; @@ -673,7 +682,13 @@ static int genpd_runtime_resume(struct device *dev) } genpd_lock(genpd); + ret = genpd_poweron(genpd, 0); + + /* Re-evaluate performance state of the domain */ + pd_data->performance_state = pd_data->cached_performance_state; + update_domain_performance_state(genpd); + 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