All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>, juri.lelli@arm.com
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	skannan@codeaurora.org, peterz@infradead.org,
	mturquette@baylibre.com, steve.muckle@linaro.org,
	vincent.guittot@linaro.org, morten.rasmussen@arm.com,
	dietmar.eggemann@arm.com, shilpa.bhat@linux.vnet.ibm.com,
	linux-kernel@vger.kernel.org,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH V3 10/13] cpufreq: governor: No need to manage state machine now
Date: Mon,  8 Feb 2016 17:09:24 +0530	[thread overview]
Message-ID: <20ec06049bffdf0a41c89bbe9679a181f8def4cf.1454931189.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1454931188.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1454931188.git.viresh.kumar@linaro.org>

cpufreq core now guarantees that policy->rwsem wouldn't get dropped
while calling CPUFREQ_GOV_POLICY_EXIT governor event and will be kept
acquired until the complete sequence of governor state changes has
finished.

And so we can remove the state machine checks that were put in place
earlier.

This also means that policy_dbs->policy can be initialized while
policy_dbs is allocated, to move all initialization together.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_governor.c | 27 +++++----------------------
 drivers/cpufreq/cpufreq_ondemand.c |  6 +++---
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 5403f863b14d..ee3c2d92da53 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -332,8 +332,10 @@ static inline void gov_clear_update_util(struct cpufreq_policy *policy)
 	synchronize_rcu();
 }
 
-static void gov_cancel_work(struct policy_dbs_info *policy_dbs)
+static void gov_cancel_work(struct cpufreq_policy *policy)
 {
+	struct policy_dbs_info *policy_dbs = policy->governor_data;
+
 	/* Tell dbs_update_util_handler() to skip queuing up work items. */
 	atomic_inc(&policy_dbs->skip_work);
 	/*
@@ -429,6 +431,7 @@ static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *poli
 	if (!policy_dbs)
 		return NULL;
 
+	policy_dbs->policy = policy;
 	mutex_init(&policy_dbs->timer_mutex);
 	atomic_set(&policy_dbs->skip_work, 0);
 	init_irq_work(&policy_dbs->irq_work, dbs_irq_work);
@@ -551,10 +554,6 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy)
 	struct policy_dbs_info *policy_dbs = policy->governor_data;
 	struct dbs_data *dbs_data = policy_dbs->dbs_data;
 
-	/* State should be equivalent to INIT */
-	if (policy_dbs->policy)
-		return -EBUSY;
-
 	if (!--dbs_data->usage_count) {
 		kobject_put(&dbs_data->kobj);
 
@@ -585,10 +584,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)
 	if (!policy->cur)
 		return -EINVAL;
 
-	/* State should be equivalent to INIT */
-	if (policy_dbs->policy)
-		return -EBUSY;
-
 	sampling_rate = dbs_data->sampling_rate;
 	ignore_nice = dbs_data->ignore_nice_load;
 
@@ -613,7 +608,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)
 		if (ignore_nice)
 			j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE];
 	}
-	policy_dbs->policy = policy;
 
 	if (gov->governor == GOV_CONSERVATIVE) {
 		struct cs_cpu_dbs_info_s *cs_dbs_info =
@@ -636,14 +630,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)
 
 static int cpufreq_governor_stop(struct cpufreq_policy *policy)
 {
-	struct policy_dbs_info *policy_dbs = policy->governor_data;
-
-	/* State should be equivalent to START */
-	if (!policy_dbs->policy)
-		return -EBUSY;
-
-	gov_cancel_work(policy_dbs);
-	policy_dbs->policy = NULL;
+	gov_cancel_work(policy);
 
 	return 0;
 }
@@ -652,10 +639,6 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy)
 {
 	struct policy_dbs_info *policy_dbs = policy->governor_data;
 
-	/* State should be equivalent to START */
-	if (!policy_dbs->policy)
-		return -EBUSY;
-
 	mutex_lock(&policy_dbs->timer_mutex);
 	if (policy->max < policy->cur)
 		__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index ccc3419d43f3..745290d7f6a2 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -258,10 +258,10 @@ static void update_sampling_rate(struct dbs_data *dbs_data)
 		policy_dbs = cdbs->policy_dbs;
 
 		/*
-		 * A valid policy_dbs and policy_dbs->policy means governor
-		 * hasn't stopped or exited yet.
+		 * A valid policy_dbs means governor hasn't stopped or exited
+		 * yet.
 		 */
-		if (!policy_dbs || !policy_dbs->policy)
+		if (!policy_dbs)
 			continue;
 
 		policy = policy_dbs->policy;
-- 
2.7.1.370.gb2aa7f8

  parent reply	other threads:[~2016-02-08 11:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 11:39 [PATCH V3 00/13] cpufreq: governors: Fix ABBA lockups Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 01/13] cpufreq: governor: Create generic macro for global tuners Viresh Kumar
2016-02-08 16:33   ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 02/13] cpufreq: governor: Move common tunables to 'struct dbs_data' Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 03/13] cpufreq: governor: New sysfs show/store callbacks for governor tunables Viresh Kumar
2016-02-08 17:07   ` Viresh Kumar
2016-02-08 21:28     ` Rafael J. Wysocki
2016-02-08 21:36   ` Rafael J. Wysocki
2016-02-09  3:21     ` Viresh Kumar
2016-02-09 20:20       ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 04/13] cpufreq: governor: Drop unused macros for creating governor tunable attributes Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 05/13] Revert "cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT" Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 06/13] cpufreq: Merge cpufreq_offline_prepare/finish routines Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 07/13] cpufreq: Call __cpufreq_governor() with policy->rwsem held Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 08/13] cpufreq: Remove cpufreq_governor_lock Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 09/13] cpufreq: governor: Move common sysfs tunables to cpufreq_governor.c Viresh Kumar
2016-02-08 12:58   ` Rafael J. Wysocki
2016-02-08 13:03     ` Viresh Kumar
2016-02-08 13:24       ` Rafael J. Wysocki
2016-02-08 11:39 ` Viresh Kumar [this message]
2016-02-08 11:39 ` [PATCH V3 11/13] cpufreq: governor: Keep list of policy_dbs within dbs_data Viresh Kumar
2016-02-08 13:21   ` Rafael J. Wysocki
2016-02-08 13:30     ` Viresh Kumar
2016-02-08 13:35       ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 12/13] cpufreq: ondemand: Traverse list of policy_dbs in update_sampling_rate() Viresh Kumar
2016-02-08 13:32   ` Rafael J. Wysocki
2016-02-08 13:34     ` Viresh Kumar
2016-02-08 13:34       ` Viresh Kumar
2016-02-08 13:37       ` Rafael J. Wysocki
2016-02-08 17:20     ` Viresh Kumar
2016-02-08 22:05       ` Rafael J. Wysocki
2016-02-08 22:08         ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 13/13] cpufreq: conservative: Update sample_delay_ns immediately Viresh Kumar
2016-02-08 12:51 ` [PATCH V3 00/13] cpufreq: governors: Fix ABBA lockups Shilpasri G Bhat
2016-02-08 12:54   ` Viresh Kumar
2016-02-08 16:39     ` Juri Lelli
2016-02-08 16:55       ` Viresh Kumar
2016-02-08 21:43 ` Rafael J. Wysocki

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=20ec06049bffdf0a41c89bbe9679a181f8def4cf.1454931189.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@arm.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=morten.rasmussen@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=shilpa.bhat@linux.vnet.ibm.com \
    --cc=skannan@codeaurora.org \
    --cc=steve.muckle@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.