All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Apply default governor for setpolicy drivers
@ 2013-12-18 20:31 Jason Baron
  2013-12-18 21:38 ` Rafael J. Wysocki
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Baron @ 2013-12-18 20:31 UTC (permalink / raw)
  To: rjw, viresh.kumar; +Cc: cpufreq, linux-pm

When configuring a default governor (via CONFIG_CPU_FREQ_DEFAULT_*) with the
'intel_pstate' driver, I found that the default is not honored. For example,
configure 'CONFIG_CPU_FREQ_GOV_PERFORMANCE', and then do:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
powersave

However, I can do:

echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

and it takes properly.

Fix by setting the default governor, if its either 'powersave' or 'performance'.
Otherwise, fall back to what the driver originally set via its 'init' routine.

Signed-off-by: Jason Baron <jbaron@akamai.com>
---
 drivers/cpufreq/cpufreq.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 02d534d..931fa67 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -826,8 +826,19 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy)
 {
 	struct cpufreq_policy new_policy;
 	int ret = 0;
+	int init_policy;
 
 	memcpy(&new_policy, policy, sizeof(*policy));
+
+	/* honor the default governor policy, unless its invalid */
+	if (cpufreq_driver->setpolicy) {
+		init_policy = new_policy.policy;
+		if (cpufreq_parse_governor(policy->governor->name,
+				&new_policy.policy, &new_policy.governor)) {
+			new_policy.policy = init_policy;
+		}
+	}
+
 	/* assure that the starting sequence is run in cpufreq_set_policy */
 	policy->governor = NULL;
 
-- 
1.8.2.rc2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-12-19 13:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 20:31 [PATCH] cpufreq: Apply default governor for setpolicy drivers Jason Baron
2013-12-18 21:38 ` Rafael J. Wysocki
2013-12-18 21:35   ` Jason Baron
2013-12-18 23:33     ` Rafael J. Wysocki
2013-12-19  3:51       ` Jason Baron
2013-12-19 13:18         ` Rafael J. Wysocki
2013-12-19 13:18           ` Rafael J. Wysocki
2013-12-19  5:27       ` Viresh Kumar
2013-12-19 13:16         ` Rafael J. Wysocki

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.