View | Details | Raw Unified | Return to bug 83151 | Differences between
and this patch

Collapse All | Expand All

(-)a/drivers/cpufreq/intel_pstate.c (-14 / +37 lines)
Lines 138-143 struct perf_limits { Link Here
138
138
139
static struct perf_limits limits = {
139
static struct perf_limits limits = {
140
	.no_turbo = 0,
140
	.no_turbo = 0,
141
	.turbo_disabled = 0,
141
	.max_perf_pct = 100,
142
	.max_perf_pct = 100,
142
	.max_perf = int_tofp(1),
143
	.max_perf = int_tofp(1),
143
	.min_perf_pct = 0,
144
	.min_perf_pct = 0,
Lines 218-223 static inline void intel_pstate_reset_all_pid(void) Link Here
218
	}
219
	}
219
}
220
}
220
221
222
static inline void update_turbo_state(void)
223
{
224
	u64 misc_en;
225
	struct cpudata *cpu;
226
227
	cpu = all_cpu_data[0];
228
	rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
229
	limits.turbo_disabled =
230
		(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
231
		 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate);
232
}
233
221
/************************** debugfs begin ************************/
234
/************************** debugfs begin ************************/
222
static int pid_param_set(void *data, u64 val)
235
static int pid_param_set(void *data, u64 val)
223
{
236
{
Lines 274-279 static void __init intel_pstate_debug_expose_params(void) Link Here
274
		return sprintf(buf, "%u\n", limits.object);		\
287
		return sprintf(buf, "%u\n", limits.object);		\
275
	}
288
	}
276
289
290
static ssize_t show_no_turbo(struct kobject *kobj,
291
			     struct attribute *attr, char *buf)
292
{
293
	ssize_t ret;
294
295
	update_turbo_state();
296
	if (limits.turbo_disabled)
297
		ret = sprintf(buf, "%u\n", limits.turbo_disabled);
298
	else
299
		ret = sprintf(buf, "%u\n", limits.no_turbo);
300
301
	return ret;
302
}
303
277
static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
304
static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
278
			      const char *buf, size_t count)
305
			      const char *buf, size_t count)
279
{
306
{
Lines 283-293 static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, Link Here
283
	ret = sscanf(buf, "%u", &input);
310
	ret = sscanf(buf, "%u", &input);
284
	if (ret != 1)
311
	if (ret != 1)
285
		return -EINVAL;
312
		return -EINVAL;
286
	limits.no_turbo = clamp_t(int, input, 0 , 1);
313
314
	update_turbo_state();
287
	if (limits.turbo_disabled) {
315
	if (limits.turbo_disabled) {
288
		pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
316
		pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
289
		limits.no_turbo = limits.turbo_disabled;
317
		return -EPERM;
290
	}
318
	} else
319
		limits.no_turbo = clamp_t(int, input, 0, 1);
320
291
	return count;
321
	return count;
292
}
322
}
293
323
Lines 323-329 static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, Link Here
323
	return count;
353
	return count;
324
}
354
}
325
355
326
show_one(no_turbo, no_turbo);
327
show_one(max_perf_pct, max_perf_pct);
356
show_one(max_perf_pct, max_perf_pct);
328
show_one(min_perf_pct, min_perf_pct);
357
show_one(min_perf_pct, min_perf_pct);
329
358
Lines 501-507 static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) Link Here
501
	int max_perf_adj;
530
	int max_perf_adj;
502
	int min_perf;
531
	int min_perf;
503
532
504
	if (limits.no_turbo)
533
	if (limits.no_turbo || limits.turbo_disabled)
505
		max_perf = cpu->pstate.max_pstate;
534
		max_perf = cpu->pstate.max_pstate;
506
535
507
	max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf));
536
	max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf));
Lines 516-521 static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) Link Here
516
{
545
{
517
	int max_perf, min_perf;
546
	int max_perf, min_perf;
518
547
548
	update_turbo_state();
549
519
	intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
550
	intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
520
551
521
	pstate = clamp_t(int, pstate, min_perf, max_perf);
552
	pstate = clamp_t(int, pstate, min_perf, max_perf);
Lines 716-722 static int intel_pstate_set_policy(struct cpufreq_policy *policy) Link Here
716
		limits.min_perf = int_tofp(1);
747
		limits.min_perf = int_tofp(1);
717
		limits.max_perf_pct = 100;
748
		limits.max_perf_pct = 100;
718
		limits.max_perf = int_tofp(1);
749
		limits.max_perf = int_tofp(1);
719
		limits.no_turbo = limits.turbo_disabled;
750
		limits.no_turbo = 0;
720
		return 0;
751
		return 0;
721
	}
752
	}
722
	limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
753
	limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
Lines 759-765 static int intel_pstate_cpu_init(struct cpufreq_policy *policy) Link Here
759
{
790
{
760
	struct cpudata *cpu;
791
	struct cpudata *cpu;
761
	int rc;
792
	int rc;
762
	u64 misc_en;
763
793
764
	rc = intel_pstate_init_cpu(policy->cpu);
794
	rc = intel_pstate_init_cpu(policy->cpu);
765
	if (rc)
795
	if (rc)
Lines 767-778 static int intel_pstate_cpu_init(struct cpufreq_policy *policy) Link Here
767
797
768
	cpu = all_cpu_data[policy->cpu];
798
	cpu = all_cpu_data[policy->cpu];
769
799
770
	rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
771
	if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
772
	    cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) {
773
		limits.turbo_disabled = 1;
774
		limits.no_turbo = 1;
775
	}
776
	if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
800
	if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
777
		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
801
		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
778
	else
802
	else
779
- 

Return to bug 83151