From: Thomas Renninger Subject: [PATCH 1/2] Fix limited cpufreq when booted on battery Date: Thu, 19 Apr 2007 15:48:34 +0200 Message-ID: <1176990514.1231.392.camel@queen.suse.de> Reply-To: trenn@suse.de Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: cpufreq-bounces@lists.linux.org.uk Errors-To: cpufreq-bounces+glkc-cpufreq=m.gmane.org+glkc-cpufreq=m.gmane.org@lists.linux.org.uk Content-Type: text/plain; charset="us-ascii" To: cpufreq Cc: Dave Jones Hi, References: https://bugzilla.novell.com/show_bug.cgi?id=231107 https://bugzilla.novell.com/show_bug.cgi?id=264077 I already posted this a while ago..., hopefully it's picked up for 2.6.22 now. Thanks, Thomas Fix limited cpufreq when booted on battery If booted on battery: cpufreq_set_policy (evil) is invoked which calls verify_within_limits. max_freq gets lowered and therefore users_policy.max, which is used to restore higher freqs via update_policy later is set to the already limited frequency -> you can never go up again, even BIOS allows higher freqs later. Signed-off-by: Thomas Renninger --- drivers/cpufreq/cpufreq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) Index: linux-2.6.21-rc3/drivers/cpufreq/cpufreq.c =================================================================== --- linux-2.6.21-rc3.orig/drivers/cpufreq/cpufreq.c +++ linux-2.6.21-rc3/drivers/cpufreq/cpufreq.c @@ -768,7 +768,10 @@ static int cpufreq_add_dev (struct sys_d unlock_policy_rwsem_write(cpu); goto err_out; } - + policy->user_policy.min = policy->cpuinfo.min_freq; + policy->user_policy.max = policy->cpuinfo.max_freq; + policy->user_policy.governor = policy->governor; + #ifdef CONFIG_SMP for_each_cpu_mask(j, policy->cpus) { if (cpu == j) @@ -858,10 +861,13 @@ static int cpufreq_add_dev (struct sys_d policy->governor = NULL; /* to assure that the starting sequence is * run in cpufreq_set_policy */ - unlock_policy_rwsem_write(cpu); /* set default policy */ - ret = cpufreq_set_policy(&new_policy); + ret = __cpufreq_set_policy(policy, &new_policy); + policy->user_policy.policy = policy->policy; + + unlock_policy_rwsem_write(cpu); + if (ret) { dprintk("setting policy failed\n"); goto err_out_unregister;