diff options
Diffstat (limited to 'drivers/cpufreq/intel_pstate.c')
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 131 |
1 files changed, 53 insertions, 78 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 86631cb6f7de..c5eac949760d 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #define BYT_TURBO_RATIOS 0x66c | 37 | #define BYT_TURBO_RATIOS 0x66c |
38 | #define BYT_TURBO_VIDS 0x66d | 38 | #define BYT_TURBO_VIDS 0x66d |
39 | 39 | ||
40 | |||
41 | #define FRAC_BITS 8 | 40 | #define FRAC_BITS 8 |
42 | #define int_tofp(X) ((int64_t)(X) << FRAC_BITS) | 41 | #define int_tofp(X) ((int64_t)(X) << FRAC_BITS) |
43 | #define fp_toint(X) ((X) >> FRAC_BITS) | 42 | #define fp_toint(X) ((X) >> FRAC_BITS) |
@@ -50,7 +49,7 @@ static inline int32_t mul_fp(int32_t x, int32_t y) | |||
50 | 49 | ||
51 | static inline int32_t div_fp(int32_t x, int32_t y) | 50 | static inline int32_t div_fp(int32_t x, int32_t y) |
52 | { | 51 | { |
53 | return div_s64((int64_t)x << FRAC_BITS, (int64_t)y); | 52 | return div_s64((int64_t)x << FRAC_BITS, y); |
54 | } | 53 | } |
55 | 54 | ||
56 | struct sample { | 55 | struct sample { |
@@ -148,7 +147,7 @@ static struct perf_limits limits = { | |||
148 | }; | 147 | }; |
149 | 148 | ||
150 | static inline void pid_reset(struct _pid *pid, int setpoint, int busy, | 149 | static inline void pid_reset(struct _pid *pid, int setpoint, int busy, |
151 | int deadband, int integral) { | 150 | int deadband, int integral) { |
152 | pid->setpoint = setpoint; | 151 | pid->setpoint = setpoint; |
153 | pid->deadband = deadband; | 152 | pid->deadband = deadband; |
154 | pid->integral = int_tofp(integral); | 153 | pid->integral = int_tofp(integral); |
@@ -167,7 +166,6 @@ static inline void pid_i_gain_set(struct _pid *pid, int percent) | |||
167 | 166 | ||
168 | static inline void pid_d_gain_set(struct _pid *pid, int percent) | 167 | static inline void pid_d_gain_set(struct _pid *pid, int percent) |
169 | { | 168 | { |
170 | |||
171 | pid->d_gain = div_fp(int_tofp(percent), int_tofp(100)); | 169 | pid->d_gain = div_fp(int_tofp(percent), int_tofp(100)); |
172 | } | 170 | } |
173 | 171 | ||
@@ -207,16 +205,13 @@ static inline void intel_pstate_busy_pid_reset(struct cpudata *cpu) | |||
207 | pid_d_gain_set(&cpu->pid, pid_params.d_gain_pct); | 205 | pid_d_gain_set(&cpu->pid, pid_params.d_gain_pct); |
208 | pid_i_gain_set(&cpu->pid, pid_params.i_gain_pct); | 206 | pid_i_gain_set(&cpu->pid, pid_params.i_gain_pct); |
209 | 207 | ||
210 | pid_reset(&cpu->pid, | 208 | pid_reset(&cpu->pid, pid_params.setpoint, 100, pid_params.deadband, 0); |
211 | pid_params.setpoint, | ||
212 | 100, | ||
213 | pid_params.deadband, | ||
214 | 0); | ||
215 | } | 209 | } |
216 | 210 | ||
217 | static inline void intel_pstate_reset_all_pid(void) | 211 | static inline void intel_pstate_reset_all_pid(void) |
218 | { | 212 | { |
219 | unsigned int cpu; | 213 | unsigned int cpu; |
214 | |||
220 | for_each_online_cpu(cpu) { | 215 | for_each_online_cpu(cpu) { |
221 | if (all_cpu_data[cpu]) | 216 | if (all_cpu_data[cpu]) |
222 | intel_pstate_busy_pid_reset(all_cpu_data[cpu]); | 217 | intel_pstate_busy_pid_reset(all_cpu_data[cpu]); |
@@ -230,13 +225,13 @@ static int pid_param_set(void *data, u64 val) | |||
230 | intel_pstate_reset_all_pid(); | 225 | intel_pstate_reset_all_pid(); |
231 | return 0; | 226 | return 0; |
232 | } | 227 | } |
228 | |||
233 | static int pid_param_get(void *data, u64 *val) | 229 | static int pid_param_get(void *data, u64 *val) |
234 | { | 230 | { |
235 | *val = *(u32 *)data; | 231 | *val = *(u32 *)data; |
236 | return 0; | 232 | return 0; |
237 | } | 233 | } |
238 | DEFINE_SIMPLE_ATTRIBUTE(fops_pid_param, pid_param_get, | 234 | DEFINE_SIMPLE_ATTRIBUTE(fops_pid_param, pid_param_get, pid_param_set, "%llu\n"); |
239 | pid_param_set, "%llu\n"); | ||
240 | 235 | ||
241 | struct pid_param { | 236 | struct pid_param { |
242 | char *name; | 237 | char *name; |
@@ -253,9 +248,9 @@ static struct pid_param pid_files[] = { | |||
253 | {NULL, NULL} | 248 | {NULL, NULL} |
254 | }; | 249 | }; |
255 | 250 | ||
256 | static struct dentry *debugfs_parent; | 251 | static void __init intel_pstate_debug_expose_params(void) |
257 | static void intel_pstate_debug_expose_params(void) | ||
258 | { | 252 | { |
253 | struct dentry *debugfs_parent; | ||
259 | int i = 0; | 254 | int i = 0; |
260 | 255 | ||
261 | debugfs_parent = debugfs_create_dir("pstate_snb", NULL); | 256 | debugfs_parent = debugfs_create_dir("pstate_snb", NULL); |
@@ -263,8 +258,8 @@ static void intel_pstate_debug_expose_params(void) | |||
263 | return; | 258 | return; |
264 | while (pid_files[i].name) { | 259 | while (pid_files[i].name) { |
265 | debugfs_create_file(pid_files[i].name, 0660, | 260 | debugfs_create_file(pid_files[i].name, 0660, |
266 | debugfs_parent, pid_files[i].value, | 261 | debugfs_parent, pid_files[i].value, |
267 | &fops_pid_param); | 262 | &fops_pid_param); |
268 | i++; | 263 | i++; |
269 | } | 264 | } |
270 | } | 265 | } |
@@ -280,10 +275,11 @@ static void intel_pstate_debug_expose_params(void) | |||
280 | } | 275 | } |
281 | 276 | ||
282 | static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, | 277 | static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, |
283 | const char *buf, size_t count) | 278 | const char *buf, size_t count) |
284 | { | 279 | { |
285 | unsigned int input; | 280 | unsigned int input; |
286 | int ret; | 281 | int ret; |
282 | |||
287 | ret = sscanf(buf, "%u", &input); | 283 | ret = sscanf(buf, "%u", &input); |
288 | if (ret != 1) | 284 | if (ret != 1) |
289 | return -EINVAL; | 285 | return -EINVAL; |
@@ -296,10 +292,11 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, | |||
296 | } | 292 | } |
297 | 293 | ||
298 | static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, | 294 | static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, |
299 | const char *buf, size_t count) | 295 | const char *buf, size_t count) |
300 | { | 296 | { |
301 | unsigned int input; | 297 | unsigned int input; |
302 | int ret; | 298 | int ret; |
299 | |||
303 | ret = sscanf(buf, "%u", &input); | 300 | ret = sscanf(buf, "%u", &input); |
304 | if (ret != 1) | 301 | if (ret != 1) |
305 | return -EINVAL; | 302 | return -EINVAL; |
@@ -307,14 +304,16 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, | |||
307 | limits.max_sysfs_pct = clamp_t(int, input, 0 , 100); | 304 | limits.max_sysfs_pct = clamp_t(int, input, 0 , 100); |
308 | limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); | 305 | limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); |
309 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); | 306 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); |
307 | |||
310 | return count; | 308 | return count; |
311 | } | 309 | } |
312 | 310 | ||
313 | static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, | 311 | static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, |
314 | const char *buf, size_t count) | 312 | const char *buf, size_t count) |
315 | { | 313 | { |
316 | unsigned int input; | 314 | unsigned int input; |
317 | int ret; | 315 | int ret; |
316 | |||
318 | ret = sscanf(buf, "%u", &input); | 317 | ret = sscanf(buf, "%u", &input); |
319 | if (ret != 1) | 318 | if (ret != 1) |
320 | return -EINVAL; | 319 | return -EINVAL; |
@@ -342,17 +341,16 @@ static struct attribute *intel_pstate_attributes[] = { | |||
342 | static struct attribute_group intel_pstate_attr_group = { | 341 | static struct attribute_group intel_pstate_attr_group = { |
343 | .attrs = intel_pstate_attributes, | 342 | .attrs = intel_pstate_attributes, |
344 | }; | 343 | }; |
345 | static struct kobject *intel_pstate_kobject; | ||
346 | 344 | ||
347 | static void intel_pstate_sysfs_expose_params(void) | 345 | static void __init intel_pstate_sysfs_expose_params(void) |
348 | { | 346 | { |
347 | struct kobject *intel_pstate_kobject; | ||
349 | int rc; | 348 | int rc; |
350 | 349 | ||
351 | intel_pstate_kobject = kobject_create_and_add("intel_pstate", | 350 | intel_pstate_kobject = kobject_create_and_add("intel_pstate", |
352 | &cpu_subsys.dev_root->kobj); | 351 | &cpu_subsys.dev_root->kobj); |
353 | BUG_ON(!intel_pstate_kobject); | 352 | BUG_ON(!intel_pstate_kobject); |
354 | rc = sysfs_create_group(intel_pstate_kobject, | 353 | rc = sysfs_create_group(intel_pstate_kobject, &intel_pstate_attr_group); |
355 | &intel_pstate_attr_group); | ||
356 | BUG_ON(rc); | 354 | BUG_ON(rc); |
357 | } | 355 | } |
358 | 356 | ||
@@ -360,6 +358,7 @@ static void intel_pstate_sysfs_expose_params(void) | |||
360 | static int byt_get_min_pstate(void) | 358 | static int byt_get_min_pstate(void) |
361 | { | 359 | { |
362 | u64 value; | 360 | u64 value; |
361 | |||
363 | rdmsrl(BYT_RATIOS, value); | 362 | rdmsrl(BYT_RATIOS, value); |
364 | return (value >> 8) & 0x7F; | 363 | return (value >> 8) & 0x7F; |
365 | } | 364 | } |
@@ -367,6 +366,7 @@ static int byt_get_min_pstate(void) | |||
367 | static int byt_get_max_pstate(void) | 366 | static int byt_get_max_pstate(void) |
368 | { | 367 | { |
369 | u64 value; | 368 | u64 value; |
369 | |||
370 | rdmsrl(BYT_RATIOS, value); | 370 | rdmsrl(BYT_RATIOS, value); |
371 | return (value >> 16) & 0x7F; | 371 | return (value >> 16) & 0x7F; |
372 | } | 372 | } |
@@ -374,6 +374,7 @@ static int byt_get_max_pstate(void) | |||
374 | static int byt_get_turbo_pstate(void) | 374 | static int byt_get_turbo_pstate(void) |
375 | { | 375 | { |
376 | u64 value; | 376 | u64 value; |
377 | |||
377 | rdmsrl(BYT_TURBO_RATIOS, value); | 378 | rdmsrl(BYT_TURBO_RATIOS, value); |
378 | return value & 0x7F; | 379 | return value & 0x7F; |
379 | } | 380 | } |
@@ -407,7 +408,6 @@ static void byt_get_vid(struct cpudata *cpudata) | |||
407 | { | 408 | { |
408 | u64 value; | 409 | u64 value; |
409 | 410 | ||
410 | |||
411 | rdmsrl(BYT_VIDS, value); | 411 | rdmsrl(BYT_VIDS, value); |
412 | cpudata->vid.min = int_tofp((value >> 8) & 0x7f); | 412 | cpudata->vid.min = int_tofp((value >> 8) & 0x7f); |
413 | cpudata->vid.max = int_tofp((value >> 16) & 0x7f); | 413 | cpudata->vid.max = int_tofp((value >> 16) & 0x7f); |
@@ -420,10 +420,10 @@ static void byt_get_vid(struct cpudata *cpudata) | |||
420 | cpudata->vid.turbo = value & 0x7f; | 420 | cpudata->vid.turbo = value & 0x7f; |
421 | } | 421 | } |
422 | 422 | ||
423 | |||
424 | static int core_get_min_pstate(void) | 423 | static int core_get_min_pstate(void) |
425 | { | 424 | { |
426 | u64 value; | 425 | u64 value; |
426 | |||
427 | rdmsrl(MSR_PLATFORM_INFO, value); | 427 | rdmsrl(MSR_PLATFORM_INFO, value); |
428 | return (value >> 40) & 0xFF; | 428 | return (value >> 40) & 0xFF; |
429 | } | 429 | } |
@@ -431,6 +431,7 @@ static int core_get_min_pstate(void) | |||
431 | static int core_get_max_pstate(void) | 431 | static int core_get_max_pstate(void) |
432 | { | 432 | { |
433 | u64 value; | 433 | u64 value; |
434 | |||
434 | rdmsrl(MSR_PLATFORM_INFO, value); | 435 | rdmsrl(MSR_PLATFORM_INFO, value); |
435 | return (value >> 8) & 0xFF; | 436 | return (value >> 8) & 0xFF; |
436 | } | 437 | } |
@@ -439,9 +440,10 @@ static int core_get_turbo_pstate(void) | |||
439 | { | 440 | { |
440 | u64 value; | 441 | u64 value; |
441 | int nont, ret; | 442 | int nont, ret; |
443 | |||
442 | rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value); | 444 | rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value); |
443 | nont = core_get_max_pstate(); | 445 | nont = core_get_max_pstate(); |
444 | ret = ((value) & 255); | 446 | ret = (value) & 255; |
445 | if (ret <= nont) | 447 | if (ret <= nont) |
446 | ret = nont; | 448 | ret = nont; |
447 | return ret; | 449 | return ret; |
@@ -493,12 +495,12 @@ static struct cpu_defaults byt_params = { | |||
493 | }, | 495 | }, |
494 | }; | 496 | }; |
495 | 497 | ||
496 | |||
497 | static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | 498 | static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) |
498 | { | 499 | { |
499 | int max_perf = cpu->pstate.turbo_pstate; | 500 | int max_perf = cpu->pstate.turbo_pstate; |
500 | int max_perf_adj; | 501 | int max_perf_adj; |
501 | int min_perf; | 502 | int min_perf; |
503 | |||
502 | if (limits.no_turbo) | 504 | if (limits.no_turbo) |
503 | max_perf = cpu->pstate.max_pstate; | 505 | max_perf = cpu->pstate.max_pstate; |
504 | 506 | ||
@@ -507,8 +509,7 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | |||
507 | cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); | 509 | cpu->pstate.min_pstate, cpu->pstate.turbo_pstate); |
508 | 510 | ||
509 | min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.min_perf)); | 511 | min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.min_perf)); |
510 | *min = clamp_t(int, min_perf, | 512 | *min = clamp_t(int, min_perf, cpu->pstate.min_pstate, max_perf); |
511 | cpu->pstate.min_pstate, max_perf); | ||
512 | } | 513 | } |
513 | 514 | ||
514 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | 515 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) |
@@ -529,21 +530,6 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | |||
529 | pstate_funcs.set(cpu, pstate); | 530 | pstate_funcs.set(cpu, pstate); |
530 | } | 531 | } |
531 | 532 | ||
532 | static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps) | ||
533 | { | ||
534 | int target; | ||
535 | target = cpu->pstate.current_pstate + steps; | ||
536 | |||
537 | intel_pstate_set_pstate(cpu, target); | ||
538 | } | ||
539 | |||
540 | static inline void intel_pstate_pstate_decrease(struct cpudata *cpu, int steps) | ||
541 | { | ||
542 | int target; | ||
543 | target = cpu->pstate.current_pstate - steps; | ||
544 | intel_pstate_set_pstate(cpu, target); | ||
545 | } | ||
546 | |||
547 | static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) | 533 | static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) |
548 | { | 534 | { |
549 | cpu->pstate.min_pstate = pstate_funcs.get_min(); | 535 | cpu->pstate.min_pstate = pstate_funcs.get_min(); |
@@ -559,13 +545,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) | |||
559 | { | 545 | { |
560 | struct sample *sample = &cpu->sample; | 546 | struct sample *sample = &cpu->sample; |
561 | int64_t core_pct; | 547 | int64_t core_pct; |
562 | int32_t rem; | ||
563 | 548 | ||
564 | core_pct = int_tofp(sample->aperf) * int_tofp(100); | 549 | core_pct = int_tofp(sample->aperf) * int_tofp(100); |
565 | core_pct = div_u64_rem(core_pct, int_tofp(sample->mperf), &rem); | 550 | core_pct = div64_u64(core_pct, int_tofp(sample->mperf)); |
566 | |||
567 | if ((rem << 1) >= int_tofp(sample->mperf)) | ||
568 | core_pct += 1; | ||
569 | 551 | ||
570 | sample->freq = fp_toint( | 552 | sample->freq = fp_toint( |
571 | mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); | 553 | mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); |
@@ -576,12 +558,12 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) | |||
576 | static inline void intel_pstate_sample(struct cpudata *cpu) | 558 | static inline void intel_pstate_sample(struct cpudata *cpu) |
577 | { | 559 | { |
578 | u64 aperf, mperf; | 560 | u64 aperf, mperf; |
561 | unsigned long flags; | ||
579 | 562 | ||
563 | local_irq_save(flags); | ||
580 | rdmsrl(MSR_IA32_APERF, aperf); | 564 | rdmsrl(MSR_IA32_APERF, aperf); |
581 | rdmsrl(MSR_IA32_MPERF, mperf); | 565 | rdmsrl(MSR_IA32_MPERF, mperf); |
582 | 566 | local_irq_restore(flags); | |
583 | aperf = aperf >> FRAC_BITS; | ||
584 | mperf = mperf >> FRAC_BITS; | ||
585 | 567 | ||
586 | cpu->last_sample_time = cpu->sample.time; | 568 | cpu->last_sample_time = cpu->sample.time; |
587 | cpu->sample.time = ktime_get(); | 569 | cpu->sample.time = ktime_get(); |
@@ -598,10 +580,9 @@ static inline void intel_pstate_sample(struct cpudata *cpu) | |||
598 | 580 | ||
599 | static inline void intel_pstate_set_sample_time(struct cpudata *cpu) | 581 | static inline void intel_pstate_set_sample_time(struct cpudata *cpu) |
600 | { | 582 | { |
601 | int sample_time, delay; | 583 | int delay; |
602 | 584 | ||
603 | sample_time = pid_params.sample_rate_ms; | 585 | delay = msecs_to_jiffies(pid_params.sample_rate_ms); |
604 | delay = msecs_to_jiffies(sample_time); | ||
605 | mod_timer_pinned(&cpu->timer, jiffies + delay); | 586 | mod_timer_pinned(&cpu->timer, jiffies + delay); |
606 | } | 587 | } |
607 | 588 | ||
@@ -616,12 +597,12 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu) | |||
616 | current_pstate = int_tofp(cpu->pstate.current_pstate); | 597 | current_pstate = int_tofp(cpu->pstate.current_pstate); |
617 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); | 598 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); |
618 | 599 | ||
619 | sample_time = (pid_params.sample_rate_ms * USEC_PER_MSEC); | 600 | sample_time = pid_params.sample_rate_ms * USEC_PER_MSEC; |
620 | duration_us = (u32) ktime_us_delta(cpu->sample.time, | 601 | duration_us = (u32) ktime_us_delta(cpu->sample.time, |
621 | cpu->last_sample_time); | 602 | cpu->last_sample_time); |
622 | if (duration_us > sample_time * 3) { | 603 | if (duration_us > sample_time * 3) { |
623 | sample_ratio = div_fp(int_tofp(sample_time), | 604 | sample_ratio = div_fp(int_tofp(sample_time), |
624 | int_tofp(duration_us)); | 605 | int_tofp(duration_us)); |
625 | core_busy = mul_fp(core_busy, sample_ratio); | 606 | core_busy = mul_fp(core_busy, sample_ratio); |
626 | } | 607 | } |
627 | 608 | ||
@@ -632,20 +613,15 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu) | |||
632 | { | 613 | { |
633 | int32_t busy_scaled; | 614 | int32_t busy_scaled; |
634 | struct _pid *pid; | 615 | struct _pid *pid; |
635 | signed int ctl = 0; | 616 | signed int ctl; |
636 | int steps; | ||
637 | 617 | ||
638 | pid = &cpu->pid; | 618 | pid = &cpu->pid; |
639 | busy_scaled = intel_pstate_get_scaled_busy(cpu); | 619 | busy_scaled = intel_pstate_get_scaled_busy(cpu); |
640 | 620 | ||
641 | ctl = pid_calc(pid, busy_scaled); | 621 | ctl = pid_calc(pid, busy_scaled); |
642 | 622 | ||
643 | steps = abs(ctl); | 623 | /* Negative values of ctl increase the pstate and vice versa */ |
644 | 624 | intel_pstate_set_pstate(cpu, cpu->pstate.current_pstate - ctl); | |
645 | if (ctl < 0) | ||
646 | intel_pstate_pstate_increase(cpu, steps); | ||
647 | else | ||
648 | intel_pstate_pstate_decrease(cpu, steps); | ||
649 | } | 625 | } |
650 | 626 | ||
651 | static void intel_pstate_timer_func(unsigned long __data) | 627 | static void intel_pstate_timer_func(unsigned long __data) |
@@ -705,8 +681,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum) | |||
705 | 681 | ||
706 | init_timer_deferrable(&cpu->timer); | 682 | init_timer_deferrable(&cpu->timer); |
707 | cpu->timer.function = intel_pstate_timer_func; | 683 | cpu->timer.function = intel_pstate_timer_func; |
708 | cpu->timer.data = | 684 | cpu->timer.data = (unsigned long)cpu; |
709 | (unsigned long)cpu; | ||
710 | cpu->timer.expires = jiffies + HZ/100; | 685 | cpu->timer.expires = jiffies + HZ/100; |
711 | intel_pstate_busy_pid_reset(cpu); | 686 | intel_pstate_busy_pid_reset(cpu); |
712 | intel_pstate_sample(cpu); | 687 | intel_pstate_sample(cpu); |
@@ -751,7 +726,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) | |||
751 | limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); | 726 | limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); |
752 | limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); | 727 | limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); |
753 | 728 | ||
754 | limits.max_policy_pct = policy->max * 100 / policy->cpuinfo.max_freq; | 729 | limits.max_policy_pct = (policy->max * 100) / policy->cpuinfo.max_freq; |
755 | limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100); | 730 | limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100); |
756 | limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); | 731 | limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); |
757 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); | 732 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); |
@@ -763,8 +738,8 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) | |||
763 | { | 738 | { |
764 | cpufreq_verify_within_cpu_limits(policy); | 739 | cpufreq_verify_within_cpu_limits(policy); |
765 | 740 | ||
766 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && | 741 | if (policy->policy != CPUFREQ_POLICY_POWERSAVE && |
767 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) | 742 | policy->policy != CPUFREQ_POLICY_PERFORMANCE) |
768 | return -EINVAL; | 743 | return -EINVAL; |
769 | 744 | ||
770 | return 0; | 745 | return 0; |
@@ -797,7 +772,7 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
797 | 772 | ||
798 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); | 773 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); |
799 | if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || | 774 | if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || |
800 | cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { | 775 | cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { |
801 | limits.turbo_disabled = 1; | 776 | limits.turbo_disabled = 1; |
802 | limits.no_turbo = 1; | 777 | limits.no_turbo = 1; |
803 | } | 778 | } |
@@ -839,8 +814,8 @@ static int intel_pstate_msrs_not_valid(void) | |||
839 | rdmsrl(MSR_IA32_MPERF, mperf); | 814 | rdmsrl(MSR_IA32_MPERF, mperf); |
840 | 815 | ||
841 | if (!pstate_funcs.get_max() || | 816 | if (!pstate_funcs.get_max() || |
842 | !pstate_funcs.get_min() || | 817 | !pstate_funcs.get_min() || |
843 | !pstate_funcs.get_turbo()) | 818 | !pstate_funcs.get_turbo()) |
844 | return -ENODEV; | 819 | return -ENODEV; |
845 | 820 | ||
846 | rdmsrl(MSR_IA32_APERF, tmp); | 821 | rdmsrl(MSR_IA32_APERF, tmp); |
@@ -922,14 +897,14 @@ static bool intel_pstate_platform_pwr_mgmt_exists(void) | |||
922 | struct acpi_table_header hdr; | 897 | struct acpi_table_header hdr; |
923 | struct hw_vendor_info *v_info; | 898 | struct hw_vendor_info *v_info; |
924 | 899 | ||
925 | if (acpi_disabled | 900 | if (acpi_disabled || |
926 | || ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr))) | 901 | ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr))) |
927 | return false; | 902 | return false; |
928 | 903 | ||
929 | for (v_info = vendor_info; v_info->valid; v_info++) { | 904 | for (v_info = vendor_info; v_info->valid; v_info++) { |
930 | if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) | 905 | if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) && |
931 | && !strncmp(hdr.oem_table_id, v_info->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) | 906 | !strncmp(hdr.oem_table_id, v_info->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && |
932 | && intel_pstate_no_acpi_pss()) | 907 | intel_pstate_no_acpi_pss()) |
933 | return true; | 908 | return true; |
934 | } | 909 | } |
935 | 910 | ||