linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>,
	ulf.hansson@linaro.org, Kevin Hilman <khilman@linaro.org>,
	Kevin Hilman <khilman@kernel.org>, Pavel Machek <pavel@ucw.cz>,
	Len Brown <len.brown@intel.com>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Stephen Boyd <sboyd@codeaurora.org>, Nishanth Menon <nm@ti.com>,
	robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH V4 9/9] PM / Domain: Add support to parse domain's OPP table
Date: Mon, 20 Mar 2017 15:02:21 +0530	[thread overview]
Message-ID: <4816e672e5f3495d87c85cda353e29df3885a0b1.1490001099.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1490001099.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1490001099.git.viresh.kumar@linaro.org>

Parse the OPP table from of_genpd_add_provider_simple() by calling
dev_pm_opp_of_add_table(), if the power domain supports changing of
performance states.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/base/power/domain.c | 46 +++++++++++++++++++++++++++++++++++++--------
 include/linux/pm_domain.h   |  1 +
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 51d3afc0476d..8155f95b0db2 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/pm_opp.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_qos.h>
@@ -1806,15 +1807,37 @@ int of_genpd_add_provider_simple(struct device_node *np,
 
 	mutex_lock(&gpd_list_lock);
 
-	if (pm_genpd_present(genpd)) {
-		ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
-		if (!ret) {
-			genpd->provider = &np->fwnode;
-			genpd->has_provider = true;
-			genpd->dev->of_node = np;
+	if (!pm_genpd_present(genpd))
+		goto unlock;
+
+	genpd->dev.of_node = np;
+
+	/* Parse genpd OPP table */
+	if (genpd->set_performance_state) {
+		ret = dev_pm_opp_of_add_table(&genpd->dev);
+		if (ret) {
+			dev_err(&genpd->dev, "Failed to add OPP table: %d\n",
+				ret);
+			goto unlock;
+		}
+
+		genpd->has_opp_table = true;
+	}
+
+	ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
+	if (ret) {
+		if (genpd->has_opp_table) {
+			genpd->has_opp_table = false;
+			dev_pm_opp_of_remove_table(&genpd->dev);
 		}
+
+		goto unlock;
 	}
 
+	genpd->provider = &np->fwnode;
+	genpd->has_provider = true;
+
+unlock:
 	mutex_unlock(&gpd_list_lock);
 
 	return ret;
@@ -1887,10 +1910,17 @@ void of_genpd_del_provider(struct device_node *np)
 			 * provider, set the 'has_provider' to false
 			 * so that the PM domain can be safely removed.
 			 */
-			list_for_each_entry(gpd, &gpd_list, gpd_list_node)
-				if (gpd->provider == &np->fwnode)
+			list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
+				if (gpd->provider == &np->fwnode) {
 					gpd->has_provider = false;
 
+					if (!gpd->has_opp_table)
+						continue;
+
+					dev_pm_opp_of_remove_table(&gpd->dev);
+				}
+			}
+
 			list_del(&cp->link);
 			of_node_put(cp->node);
 			kfree(cp);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index d55c0112dcde..821d7cf5974b 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -57,6 +57,7 @@ struct generic_pm_domain {
 	struct work_struct power_off_work;
 	struct fwnode_handle *provider;	/* Identity of the domain provider */
 	bool has_provider;
+	bool has_opp_table;
 	const char *name;
 	atomic_t sd_count;	/* Number of subdomains with power "on" */
 	enum gpd_status status;	/* Current state of the domain */
-- 
2.12.0.432.g71c3a4f4ba37

  parent reply	other threads:[~2017-03-20  9:33 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20  9:32 [PATCH V4 0/9] PM / Domains: Implement domain performance states Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 1/9] PM / OPP: Allow OPP table to be used for power-domains Viresh Kumar
2017-03-24 15:44   ` Rob Herring
2017-04-10  9:25     ` Viresh Kumar
2017-04-10  9:50       ` Viresh Kumar
2017-04-12 16:49   ` Sudeep Holla
2017-04-13  5:37     ` Viresh Kumar
2017-04-13 13:42       ` Sudeep Holla
2017-04-17  5:27         ` Viresh Kumar
2017-04-18 16:01           ` Sudeep Holla
2017-04-19 10:11             ` Viresh Kumar
2017-04-19 11:47             ` Viresh Kumar
2017-04-19 13:58               ` Sudeep Holla
2017-04-20  5:25                 ` Viresh Kumar
2017-04-20  8:23                   ` Ulf Hansson
2017-04-20  9:33                     ` Viresh Kumar
2017-04-20  9:51                     ` Sudeep Holla
2017-04-20  9:43                   ` Sudeep Holla
2017-04-20  9:52                     ` Viresh Kumar
2017-04-23 22:07                       ` Kevin Hilman
2017-04-26  4:32             ` Rajendra Nayak
2017-04-26 13:55               ` Mark Brown
2017-04-27  9:42                 ` Sudeep Holla
2017-04-27 10:50                   ` Rajendra Nayak
2017-04-28  5:00                     ` Viresh Kumar
2017-04-28  9:44                       ` Sudeep Holla
2017-04-28 11:12                         ` Viresh Kumar
2017-04-30 12:49                   ` Mark Brown
2017-05-03 11:21                     ` Sudeep Holla
2017-05-14  9:55                       ` Mark Brown
2017-04-12 17:05   ` Sudeep Holla
2017-04-13  5:50     ` Viresh Kumar
2017-04-13 13:43       ` Sudeep Holla
2017-04-17  5:33         ` Viresh Kumar
2017-04-18 16:03           ` Sudeep Holla
2017-04-19 10:12             ` Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 2/9] PM / Domains: Use OPP tables " Viresh Kumar
2017-04-12 16:58   ` Sudeep Holla
2017-04-13  6:03     ` Viresh Kumar
2017-04-13 13:45       ` Sudeep Holla
2017-03-20  9:32 ` [PATCH V4 3/9] PM / QOS: Keep common notifier list for genpd constraints Viresh Kumar
2017-04-19 14:06   ` Ulf Hansson
2017-04-20  4:45   ` [PATCH V5 " Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 4/9] PM / QOS: Add DEV_PM_QOS_PERFORMANCE request Viresh Kumar
2017-04-19 14:07   ` Ulf Hansson
2017-04-20  4:34     ` Viresh Kumar
2017-04-20  4:46   ` [PATCH V5 " Viresh Kumar
2017-04-20  6:53     ` Ulf Hansson
2017-03-20  9:32 ` [PATCH V4 5/9] PM / OPP: Add support to parse OPP table for power-domains Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 6/9] PM / OPP: Add dev_pm_opp_find_dps() helper Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 7/9] PM / domain: Register for PM QOS performance notifier Viresh Kumar
2017-04-20  4:46   ` [PATCH V5 " Viresh Kumar
2017-03-20  9:32 ` [PATCH V4 8/9] PM / Domain: Add struct device to genpd Viresh Kumar
2017-03-20  9:32 ` Viresh Kumar [this message]
2017-04-12 14:24 ` [PATCH V4 0/9] PM / Domains: Implement domain performance states Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4816e672e5f3495d87c85cda353e29df3885a0b1.1490001099.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=khilman@kernel.org \
    --cc=khilman@linaro.org \
    --cc=len.brown@intel.com \
    --cc=lina.iyer@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).