From patchwork Thu Dec 23 06:23:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Youquan Song X-Patchwork-Id: 429131 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBNJ5f3b026223 for ; Thu, 23 Dec 2010 19:05:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249Ab0LWGVY (ORCPT ); Thu, 23 Dec 2010 01:21:24 -0500 Received: from mga02.intel.com ([134.134.136.20]:9769 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752218Ab0LWGVW (ORCPT ); Thu, 23 Dec 2010 01:21:22 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 22 Dec 2010 22:21:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,217,1291622400"; d="scan'208";a="690075349" Received: from linux-otc0903.bj.intel.com (HELO localhost.localdomain) ([10.238.154.141]) by orsmga001.jf.intel.com with ESMTP; 22 Dec 2010 22:21:19 -0800 From: Youquan Song To: davej@redhat.com, cpufreq@vger.kernel.org Cc: venki@google.com, arjan@linux.intel.com, lenb@kernel.org, suresh.b.siddha@intel.com, kent.liu@intel.com, chaohong.guo@intel.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Youquan Song , Youquan Song Subject: [PATCH 6/6] cpufreq: Evaluate P1 before enter turbo mode Date: Thu, 23 Dec 2010 14:23:44 +0800 Message-Id: <1293085424-18212-7-git-send-email-youquan.song@intel.com> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <1293085424-18212-6-git-send-email-youquan.song@intel.com> References: <1293085424-18212-1-git-send-email-youquan.song@intel.com> <1293085424-18212-2-git-send-email-youquan.song@intel.com> <1293085424-18212-3-git-send-email-youquan.song@intel.com> <1293085424-18212-4-git-send-email-youquan.song@intel.com> <1293085424-18212-5-git-send-email-youquan.song@intel.com> <1293085424-18212-6-git-send-email-youquan.song@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Dec 2010 19:05:52 +0000 (UTC) diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 85ca136..682b2ea 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -797,7 +797,12 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) if (policy->cur < policy->max) this_dbs_info->rate_mult = dbs_tuners_ins.sampling_down_factor; - dbs_freq_increase(policy, policy->max); + /* Before go to turbo, try P1 first */ + if ((policy->max > policy->sec_max) && + (policy->cur == policy->sec_max)) + dbs_freq_increase(policy, policy->max); + else + dbs_freq_increase(policy, policy->sec_max); return; } diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 0543221..d7dc010 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -26,6 +26,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, { unsigned int min_freq = ~0; unsigned int max_freq = 0; + unsigned int sec_max_freq = 0; unsigned int i; for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { @@ -41,10 +42,18 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, min_freq = freq; if (freq > max_freq) max_freq = freq; + /* Find the second largest frequency */ + if ((freq < max_freq) && (freq > sec_max_freq)) + sec_max_freq = freq; } policy->min = policy->cpuinfo.min_freq = min_freq; policy->max = policy->cpuinfo.max_freq = max_freq; + /* Check CPU turbo mode enabled */ + if (max_freq - sec_max_freq == 1000) + policy->sec_max = sec_max_freq; + else + policy->sec_max = max_freq; if (policy->min == ~0) return -EINVAL; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index c3e9de8..0087e56 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -92,6 +92,7 @@ struct cpufreq_policy { unsigned int min; /* in kHz */ unsigned int max; /* in kHz */ + unsigned int sec_max; /* in kHz*/ unsigned int cur; /* in kHz, only needed if cpufreq * governors are used */ unsigned int policy; /* see above */