Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1686259

[RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching"

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching"
Date 2017-07-13 07:50 +0200
Message-ID <u2FaG-1xh-13@gated-at.bofh.it> (permalink)
References <u2FaF-1xh-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


There is no limitation in the ondemand or conservative governors which
disallow the transition_latency to be greater than 10 ms.

The max_transition_latency field is rather used to disallow automatic
dynamic frequency switching for platforms which didn't wanted these
governors to run.

Replace max_transition_latency with a boolean (dynamic_switching) and
check for transition_latency == CPUFREQ_ETERNAL along with that. This
makes it pretty straight forward to read/understand now.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c          | 8 ++++----
 drivers/cpufreq/cpufreq_governor.h | 2 +-
 include/linux/cpufreq.h            | 9 ++-------
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9bf97a366029..dcef293c5e2c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1988,13 +1988,13 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy)
 	if (!policy->governor)
 		return -EINVAL;
 
-	if (policy->governor->max_transition_latency &&
-	    policy->cpuinfo.transition_latency >
-	    policy->governor->max_transition_latency) {
+	/* Platform doesn't want dynamic frequency switching ? */
+	if (policy->governor->dynamic_switching &&
+	    policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL) {
 		struct cpufreq_governor *gov = cpufreq_fallback_governor();
 
 		if (gov) {
-			pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n",
+			pr_warn("Transition latency set to CPUFREQ_ETERNAL, can't use %s governor. Fallback to %s governor\n",
 				policy->governor->name, gov->name);
 			policy->governor = gov;
 		} else {
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index 0236ec2cd654..7b7839c45fba 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -160,7 +160,7 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy);
 #define CPUFREQ_DBS_GOVERNOR_INITIALIZER(_name_)			\
 	{								\
 		.name = _name_,						\
-		.max_transition_latency	= TRANSITION_LATENCY_LIMIT,	\
+		.dynamic_switching = true,				\
 		.owner = THIS_MODULE,					\
 		.init = cpufreq_dbs_governor_init,			\
 		.exit = cpufreq_dbs_governor_exit,			\
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 905117bd5012..3d8c52b3b5df 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -487,14 +487,10 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div,
  * polling frequency is 1000 times the transition latency of the processor. The
  * ondemand governor will work on any processor with transition latency <= 10ms,
  * using appropriate sampling rate.
- *
- * For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL)
- * the ondemand governor will not work. All times here are in us (microseconds).
  */
 #define MIN_SAMPLING_RATE_RATIO		(2)
 #define LATENCY_MULTIPLIER		(1000)
 #define MIN_LATENCY_MULTIPLIER		(20)
-#define TRANSITION_LATENCY_LIMIT	(10 * 1000 * 1000)
 
 struct cpufreq_governor {
 	char	name[CPUFREQ_NAME_LEN];
@@ -507,9 +503,8 @@ struct cpufreq_governor {
 					 char *buf);
 	int	(*store_setspeed)	(struct cpufreq_policy *policy,
 					 unsigned int freq);
-	unsigned int max_transition_latency; /* HW must be able to switch to
-			next freq faster than this value in nano secs or we
-			will fallback to performance governor */
+	/* For governors which change frequency dynamically by themselves */
+	bool			dynamic_switching;
 	struct list_head	governor_list;
 	struct module		*owner;
 };
-- 
2.13.0.71.gd7076ec9c9cb

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-13 07:50 +0200
  Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" "Rafael J. Wysocki" <rafael@kernel.org> - 2017-07-13 18:30 +0200
    Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with  "dynamic_switching" Dominik Brodowski <linux@dominikbrodowski.net> - 2017-07-14 09:10 +0200
      Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" "Rafael J. Wysocki" <rafael@kernel.org> - 2017-07-14 13:20 +0200
        Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-15 00:20 +0200
          Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with  "dynamic_switching" Dominik Brodowski <linux@dominikbrodowski.net> - 2017-07-15 07:20 +0200
            Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-15 14:40 +0200
              Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with  "dynamic_switching" Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-17 14:00 +0200
                Re: [RFC V2 1/6] cpufreq: Replace "max_transition_latency" with "dynamic_switching" "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-17 14:30 +0200

csiph-web