aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Brandewie <dirk.j.brandewie@intel.com>2014-06-20 10:27:59 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-06 19:22:19 -0400
commitdd5fbf70f96dbfd7ee432096a1f979b2b3267856 (patch)
tree7829e15ad3cd4dbdbdd1121f4d7649bf008f6481
parentc16ed06024a6e699c332831dd50d8276744e3de8 (diff)
intel_pstate: don't touch turbo bit if turbo disabled or unavailable.
If turbo is disabled in the BIOS bit 38 should be set in MSR_IA32_MISC_ENABLE register per section 14.3.2.1 of the SDM Vol 3 document 325384-050US Feb 2014. If this bit is set do *not* attempt to disable trubo via the MSR_IA32_PERF_CTL register. On some systems trying to disable turbo via MSR_IA32_PERF_CTL will cause subsequent writes to MSR_IA32_PERF_CTL not take affect, in fact reading MSR_IA32_PERF_CTL will not show the IDA/Turbo DISENGAGE bit(32) as set. A write of bit 32 to zero returns to normal operation. Also deal with the case where the processor does not support turbo and the BIOS does not report the fact in MSR_IA32_MISC_ENABLE but does report the max and turbo P states as the same value. Link: https://bugzilla.kernel.org/show_bug.cgi?id=64251 Cc: 3.13+ <stable@vger.kernel.org> # 3.13+ Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/intel_pstate.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 74376d615eca..127ead814619 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -128,6 +128,7 @@ static struct pstate_funcs pstate_funcs;
128 128
129struct perf_limits { 129struct perf_limits {
130 int no_turbo; 130 int no_turbo;
131 int turbo_disabled;
131 int max_perf_pct; 132 int max_perf_pct;
132 int min_perf_pct; 133 int min_perf_pct;
133 int32_t max_perf; 134 int32_t max_perf;
@@ -287,7 +288,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
287 if (ret != 1) 288 if (ret != 1)
288 return -EINVAL; 289 return -EINVAL;
289 limits.no_turbo = clamp_t(int, input, 0 , 1); 290 limits.no_turbo = clamp_t(int, input, 0 , 1);
290 291 if (limits.turbo_disabled) {
292 pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
293 limits.no_turbo = limits.turbo_disabled;
294 }
291 return count; 295 return count;
292} 296}
293 297
@@ -381,7 +385,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate)
381 u32 vid; 385 u32 vid;
382 386
383 val = pstate << 8; 387 val = pstate << 8;
384 if (limits.no_turbo) 388 if (limits.no_turbo && !limits.turbo_disabled)
385 val |= (u64)1 << 32; 389 val |= (u64)1 << 32;
386 390
387 vid_fp = cpudata->vid.min + mul_fp( 391 vid_fp = cpudata->vid.min + mul_fp(
@@ -448,7 +452,7 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate)
448 u64 val; 452 u64 val;
449 453
450 val = pstate << 8; 454 val = pstate << 8;
451 if (limits.no_turbo) 455 if (limits.no_turbo && !limits.turbo_disabled)
452 val |= (u64)1 << 32; 456 val |= (u64)1 << 32;
453 457
454 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); 458 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val);
@@ -741,7 +745,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
741 limits.min_perf = int_tofp(1); 745 limits.min_perf = int_tofp(1);
742 limits.max_perf_pct = 100; 746 limits.max_perf_pct = 100;
743 limits.max_perf = int_tofp(1); 747 limits.max_perf = int_tofp(1);
744 limits.no_turbo = 0; 748 limits.no_turbo = limits.turbo_disabled;
745 return 0; 749 return 0;
746 } 750 }
747 limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; 751 limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
@@ -784,6 +788,7 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
784{ 788{
785 struct cpudata *cpu; 789 struct cpudata *cpu;
786 int rc; 790 int rc;
791 u64 misc_en;
787 792
788 rc = intel_pstate_init_cpu(policy->cpu); 793 rc = intel_pstate_init_cpu(policy->cpu);
789 if (rc) 794 if (rc)
@@ -791,8 +796,13 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
791 796
792 cpu = all_cpu_data[policy->cpu]; 797 cpu = all_cpu_data[policy->cpu];
793 798
794 if (!limits.no_turbo && 799 rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
795 limits.min_perf_pct == 100 && limits.max_perf_pct == 100) 800 if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
801 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) {
802 limits.turbo_disabled = 1;
803 limits.no_turbo = 1;
804 }
805 if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
796 policy->policy = CPUFREQ_POLICY_PERFORMANCE; 806 policy->policy = CPUFREQ_POLICY_PERFORMANCE;
797 else 807 else
798 policy->policy = CPUFREQ_POLICY_POWERSAVE; 808 policy->policy = CPUFREQ_POLICY_POWERSAVE;