aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/intel_pstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/intel_pstate.c')
-rw-r--r--drivers/cpufreq/intel_pstate.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 79606f473f48..e90816105921 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -34,8 +34,10 @@
34 34
35#define SAMPLE_COUNT 3 35#define SAMPLE_COUNT 3
36 36
37#define BYT_RATIOS 0x66a 37#define BYT_RATIOS 0x66a
38#define BYT_VIDS 0x66b 38#define BYT_VIDS 0x66b
39#define BYT_TURBO_RATIOS 0x66c
40
39 41
40#define FRAC_BITS 8 42#define FRAC_BITS 8
41#define int_tofp(X) ((int64_t)(X) << FRAC_BITS) 43#define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
@@ -51,8 +53,6 @@ static inline int32_t div_fp(int32_t x, int32_t y)
51 return div_s64((int64_t)x << FRAC_BITS, (int64_t)y); 53 return div_s64((int64_t)x << FRAC_BITS, (int64_t)y);
52} 54}
53 55
54static u64 energy_divisor;
55
56struct sample { 56struct sample {
57 int32_t core_pct_busy; 57 int32_t core_pct_busy;
58 u64 aperf; 58 u64 aperf;
@@ -359,7 +359,7 @@ static int byt_get_min_pstate(void)
359{ 359{
360 u64 value; 360 u64 value;
361 rdmsrl(BYT_RATIOS, value); 361 rdmsrl(BYT_RATIOS, value);
362 return value & 0xFF; 362 return (value >> 8) & 0xFF;
363} 363}
364 364
365static int byt_get_max_pstate(void) 365static int byt_get_max_pstate(void)
@@ -369,6 +369,13 @@ static int byt_get_max_pstate(void)
369 return (value >> 16) & 0xFF; 369 return (value >> 16) & 0xFF;
370} 370}
371 371
372static int byt_get_turbo_pstate(void)
373{
374 u64 value;
375 rdmsrl(BYT_TURBO_RATIOS, value);
376 return value & 0x3F;
377}
378
372static void byt_set_pstate(struct cpudata *cpudata, int pstate) 379static void byt_set_pstate(struct cpudata *cpudata, int pstate)
373{ 380{
374 u64 val; 381 u64 val;
@@ -471,7 +478,7 @@ static struct cpu_defaults byt_params = {
471 .funcs = { 478 .funcs = {
472 .get_max = byt_get_max_pstate, 479 .get_max = byt_get_max_pstate,
473 .get_min = byt_get_min_pstate, 480 .get_min = byt_get_min_pstate,
474 .get_turbo = byt_get_max_pstate, 481 .get_turbo = byt_get_turbo_pstate,
475 .set = byt_set_pstate, 482 .set = byt_set_pstate,
476 .get_vid = byt_get_vid, 483 .get_vid = byt_get_vid,
477 }, 484 },
@@ -630,12 +637,10 @@ static void intel_pstate_timer_func(unsigned long __data)
630{ 637{
631 struct cpudata *cpu = (struct cpudata *) __data; 638 struct cpudata *cpu = (struct cpudata *) __data;
632 struct sample *sample; 639 struct sample *sample;
633 u64 energy;
634 640
635 intel_pstate_sample(cpu); 641 intel_pstate_sample(cpu);
636 642
637 sample = &cpu->samples[cpu->sample_ptr]; 643 sample = &cpu->samples[cpu->sample_ptr];
638 rdmsrl(MSR_PKG_ENERGY_STATUS, energy);
639 644
640 intel_pstate_adjust_busy_pstate(cpu); 645 intel_pstate_adjust_busy_pstate(cpu);
641 646
@@ -644,7 +649,6 @@ static void intel_pstate_timer_func(unsigned long __data)
644 cpu->pstate.current_pstate, 649 cpu->pstate.current_pstate,
645 sample->mperf, 650 sample->mperf,
646 sample->aperf, 651 sample->aperf,
647 div64_u64(energy, energy_divisor),
648 sample->freq); 652 sample->freq);
649 653
650 intel_pstate_set_sample_time(cpu); 654 intel_pstate_set_sample_time(cpu);
@@ -926,7 +930,6 @@ static int __init intel_pstate_init(void)
926 int cpu, rc = 0; 930 int cpu, rc = 0;
927 const struct x86_cpu_id *id; 931 const struct x86_cpu_id *id;
928 struct cpu_defaults *cpu_info; 932 struct cpu_defaults *cpu_info;
929 u64 units;
930 933
931 if (no_load) 934 if (no_load)
932 return -ENODEV; 935 return -ENODEV;
@@ -960,9 +963,6 @@ static int __init intel_pstate_init(void)
960 if (rc) 963 if (rc)
961 goto out; 964 goto out;
962 965
963 rdmsrl(MSR_RAPL_POWER_UNIT, units);
964 energy_divisor = 1 << ((units >> 8) & 0x1f); /* bits{12:8} */
965
966 intel_pstate_debug_expose_params(); 966 intel_pstate_debug_expose_params();
967 intel_pstate_sysfs_expose_params(); 967 intel_pstate_sysfs_expose_params();
968 968