diff options
Diffstat (limited to 'drivers/cpufreq/intel_pstate.c')
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 2cd36b9297f3..bcb9a6d0ae11 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -99,8 +99,7 @@ struct cpudata { | |||
99 | u64 prev_aperf; | 99 | u64 prev_aperf; |
100 | u64 prev_mperf; | 100 | u64 prev_mperf; |
101 | unsigned long long prev_tsc; | 101 | unsigned long long prev_tsc; |
102 | int sample_ptr; | 102 | struct sample sample; |
103 | struct sample samples[SAMPLE_COUNT]; | ||
104 | }; | 103 | }; |
105 | 104 | ||
106 | static struct cpudata **all_cpu_data; | 105 | static struct cpudata **all_cpu_data; |
@@ -154,7 +153,7 @@ static inline void pid_reset(struct _pid *pid, int setpoint, int busy, | |||
154 | pid->setpoint = setpoint; | 153 | pid->setpoint = setpoint; |
155 | pid->deadband = deadband; | 154 | pid->deadband = deadband; |
156 | pid->integral = int_tofp(integral); | 155 | pid->integral = int_tofp(integral); |
157 | pid->last_err = setpoint - busy; | 156 | pid->last_err = int_tofp(setpoint) - int_tofp(busy); |
158 | } | 157 | } |
159 | 158 | ||
160 | static inline void pid_p_gain_set(struct _pid *pid, int percent) | 159 | static inline void pid_p_gain_set(struct _pid *pid, int percent) |
@@ -447,7 +446,7 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate) | |||
447 | if (limits.no_turbo) | 446 | if (limits.no_turbo) |
448 | val |= (u64)1 << 32; | 447 | val |= (u64)1 << 32; |
449 | 448 | ||
450 | wrmsrl(MSR_IA32_PERF_CTL, val); | 449 | wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); |
451 | } | 450 | } |
452 | 451 | ||
453 | static struct cpu_defaults core_params = { | 452 | static struct cpu_defaults core_params = { |
@@ -586,15 +585,14 @@ static inline void intel_pstate_sample(struct cpudata *cpu) | |||
586 | mperf = mperf >> FRAC_BITS; | 585 | mperf = mperf >> FRAC_BITS; |
587 | tsc = tsc >> FRAC_BITS; | 586 | tsc = tsc >> FRAC_BITS; |
588 | 587 | ||
589 | cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; | 588 | cpu->sample.aperf = aperf; |
590 | cpu->samples[cpu->sample_ptr].aperf = aperf; | 589 | cpu->sample.mperf = mperf; |
591 | cpu->samples[cpu->sample_ptr].mperf = mperf; | 590 | cpu->sample.tsc = tsc; |
592 | cpu->samples[cpu->sample_ptr].tsc = tsc; | 591 | cpu->sample.aperf -= cpu->prev_aperf; |
593 | cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; | 592 | cpu->sample.mperf -= cpu->prev_mperf; |
594 | cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; | 593 | cpu->sample.tsc -= cpu->prev_tsc; |
595 | cpu->samples[cpu->sample_ptr].tsc -= cpu->prev_tsc; | ||
596 | 594 | ||
597 | intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); | 595 | intel_pstate_calc_busy(cpu, &cpu->sample); |
598 | 596 | ||
599 | cpu->prev_aperf = aperf; | 597 | cpu->prev_aperf = aperf; |
600 | cpu->prev_mperf = mperf; | 598 | cpu->prev_mperf = mperf; |
@@ -614,7 +612,7 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu) | |||
614 | { | 612 | { |
615 | int32_t core_busy, max_pstate, current_pstate; | 613 | int32_t core_busy, max_pstate, current_pstate; |
616 | 614 | ||
617 | core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy; | 615 | core_busy = cpu->sample.core_pct_busy; |
618 | max_pstate = int_tofp(cpu->pstate.max_pstate); | 616 | max_pstate = int_tofp(cpu->pstate.max_pstate); |
619 | current_pstate = int_tofp(cpu->pstate.current_pstate); | 617 | current_pstate = int_tofp(cpu->pstate.current_pstate); |
620 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); | 618 | core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate)); |
@@ -648,7 +646,7 @@ static void intel_pstate_timer_func(unsigned long __data) | |||
648 | 646 | ||
649 | intel_pstate_sample(cpu); | 647 | intel_pstate_sample(cpu); |
650 | 648 | ||
651 | sample = &cpu->samples[cpu->sample_ptr]; | 649 | sample = &cpu->sample; |
652 | 650 | ||
653 | intel_pstate_adjust_busy_pstate(cpu); | 651 | intel_pstate_adjust_busy_pstate(cpu); |
654 | 652 | ||
@@ -729,7 +727,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num) | |||
729 | cpu = all_cpu_data[cpu_num]; | 727 | cpu = all_cpu_data[cpu_num]; |
730 | if (!cpu) | 728 | if (!cpu) |
731 | return 0; | 729 | return 0; |
732 | sample = &cpu->samples[cpu->sample_ptr]; | 730 | sample = &cpu->sample; |
733 | return sample->freq; | 731 | return sample->freq; |
734 | } | 732 | } |
735 | 733 | ||
@@ -773,14 +771,17 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) | |||
773 | return 0; | 771 | return 0; |
774 | } | 772 | } |
775 | 773 | ||
776 | static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) | 774 | static void intel_pstate_stop_cpu(struct cpufreq_policy *policy) |
777 | { | 775 | { |
778 | int cpu = policy->cpu; | 776 | int cpu_num = policy->cpu; |
777 | struct cpudata *cpu = all_cpu_data[cpu_num]; | ||
779 | 778 | ||
780 | del_timer(&all_cpu_data[cpu]->timer); | 779 | pr_info("intel_pstate CPU %d exiting\n", cpu_num); |
781 | kfree(all_cpu_data[cpu]); | 780 | |
782 | all_cpu_data[cpu] = NULL; | 781 | del_timer(&all_cpu_data[cpu_num]->timer); |
783 | return 0; | 782 | intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); |
783 | kfree(all_cpu_data[cpu_num]); | ||
784 | all_cpu_data[cpu_num] = NULL; | ||
784 | } | 785 | } |
785 | 786 | ||
786 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | 787 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) |
@@ -818,7 +819,7 @@ static struct cpufreq_driver intel_pstate_driver = { | |||
818 | .setpolicy = intel_pstate_set_policy, | 819 | .setpolicy = intel_pstate_set_policy, |
819 | .get = intel_pstate_get, | 820 | .get = intel_pstate_get, |
820 | .init = intel_pstate_cpu_init, | 821 | .init = intel_pstate_cpu_init, |
821 | .exit = intel_pstate_cpu_exit, | 822 | .stop_cpu = intel_pstate_stop_cpu, |
822 | .name = "intel_pstate", | 823 | .name = "intel_pstate", |
823 | }; | 824 | }; |
824 | 825 | ||