diff options
| -rw-r--r-- | drivers/cpufreq/intel_pstate.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index eab8ccfe6beb..e5735446c7ed 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -59,7 +59,6 @@ struct sample { | |||
| 59 | int32_t core_pct_busy; | 59 | int32_t core_pct_busy; |
| 60 | u64 aperf; | 60 | u64 aperf; |
| 61 | u64 mperf; | 61 | u64 mperf; |
| 62 | unsigned long long tsc; | ||
| 63 | int freq; | 62 | int freq; |
| 64 | }; | 63 | }; |
| 65 | 64 | ||
| @@ -100,7 +99,6 @@ struct cpudata { | |||
| 100 | 99 | ||
| 101 | u64 prev_aperf; | 100 | u64 prev_aperf; |
| 102 | u64 prev_mperf; | 101 | u64 prev_mperf; |
| 103 | unsigned long long prev_tsc; | ||
| 104 | struct sample sample; | 102 | struct sample sample; |
| 105 | }; | 103 | }; |
| 106 | 104 | ||
| @@ -561,46 +559,37 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu, | |||
| 561 | struct sample *sample) | 559 | struct sample *sample) |
| 562 | { | 560 | { |
| 563 | int32_t core_pct; | 561 | int32_t core_pct; |
| 564 | int32_t c0_pct; | ||
| 565 | 562 | ||
| 566 | core_pct = div_fp(int_tofp((sample->aperf)), | 563 | core_pct = div_fp(int_tofp((sample->aperf)), |
| 567 | int_tofp((sample->mperf))); | 564 | int_tofp((sample->mperf))); |
| 568 | core_pct = mul_fp(core_pct, int_tofp(100)); | 565 | core_pct = mul_fp(core_pct, int_tofp(100)); |
| 569 | FP_ROUNDUP(core_pct); | 566 | FP_ROUNDUP(core_pct); |
| 570 | 567 | ||
| 571 | c0_pct = div_fp(int_tofp(sample->mperf), int_tofp(sample->tsc)); | ||
| 572 | |||
| 573 | sample->freq = fp_toint( | 568 | sample->freq = fp_toint( |
| 574 | mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); | 569 | mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); |
| 575 | 570 | ||
| 576 | sample->core_pct_busy = mul_fp(core_pct, c0_pct); | 571 | sample->core_pct_busy = core_pct; |
| 577 | } | 572 | } |
| 578 | 573 | ||
| 579 | static inline void intel_pstate_sample(struct cpudata *cpu) | 574 | static inline void intel_pstate_sample(struct cpudata *cpu) |
| 580 | { | 575 | { |
| 581 | u64 aperf, mperf; | 576 | u64 aperf, mperf; |
| 582 | unsigned long long tsc; | ||
| 583 | 577 | ||
| 584 | rdmsrl(MSR_IA32_APERF, aperf); | 578 | rdmsrl(MSR_IA32_APERF, aperf); |
| 585 | rdmsrl(MSR_IA32_MPERF, mperf); | 579 | rdmsrl(MSR_IA32_MPERF, mperf); |
| 586 | tsc = native_read_tsc(); | ||
| 587 | 580 | ||
| 588 | aperf = aperf >> FRAC_BITS; | 581 | aperf = aperf >> FRAC_BITS; |
| 589 | mperf = mperf >> FRAC_BITS; | 582 | mperf = mperf >> FRAC_BITS; |
| 590 | tsc = tsc >> FRAC_BITS; | ||
| 591 | 583 | ||
| 592 | cpu->sample.aperf = aperf; | 584 | cpu->sample.aperf = aperf; |
| 593 | cpu->sample.mperf = mperf; | 585 | cpu->sample.mperf = mperf; |
| 594 | cpu->sample.tsc = tsc; | ||
| 595 | cpu->sample.aperf -= cpu->prev_aperf; | 586 | cpu->sample.aperf -= cpu->prev_aperf; |
| 596 | cpu->sample.mperf -= cpu->prev_mperf; | 587 | cpu->sample.mperf -= cpu->prev_mperf; |
| 597 | cpu->sample.tsc -= cpu->prev_tsc; | ||
| 598 | 588 | ||
| 599 | intel_pstate_calc_busy(cpu, &cpu->sample); | 589 | intel_pstate_calc_busy(cpu, &cpu->sample); |
| 600 | 590 | ||
| 601 | cpu->prev_aperf = aperf; | 591 | cpu->prev_aperf = aperf; |
| 602 | cpu->prev_mperf = mperf; | 592 | cpu->prev_mperf = mperf; |
| 603 | cpu->prev_tsc = tsc; | ||
| 604 | } | 593 | } |
| 605 | 594 | ||
| 606 | static inline void intel_pstate_set_sample_time(struct cpudata *cpu) | 595 | static inline void intel_pstate_set_sample_time(struct cpudata *cpu) |
