aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c55
-rw-r--r--arch/x86/kernel/cpu/cpufreq/longhaul.c1
2 files changed, 29 insertions, 27 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index 19f6b9d27e83..9d3af380c6bd 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -68,6 +68,7 @@ struct acpi_cpufreq_data {
68 unsigned int max_freq; 68 unsigned int max_freq;
69 unsigned int resume; 69 unsigned int resume;
70 unsigned int cpu_feature; 70 unsigned int cpu_feature;
71 u64 saved_aperf, saved_mperf;
71}; 72};
72 73
73static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data); 74static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data);
@@ -241,26 +242,23 @@ static u32 get_cur_val(const struct cpumask *mask)
241 return cmd.val; 242 return cmd.val;
242} 243}
243 244
244struct perf_cur { 245struct perf_pair {
245 union { 246 union {
246 struct { 247 struct {
247 u32 lo; 248 u32 lo;
248 u32 hi; 249 u32 hi;
249 } split; 250 } split;
250 u64 whole; 251 u64 whole;
251 } aperf_cur, mperf_cur; 252 } aperf, mperf;
252}; 253};
253 254
254 255
255static long read_measured_perf_ctrs(void *_cur) 256static long read_measured_perf_ctrs(void *_cur)
256{ 257{
257 struct perf_cur *cur = _cur; 258 struct perf_pair *cur = _cur;
258 259
259 rdmsr(MSR_IA32_APERF, cur->aperf_cur.split.lo, cur->aperf_cur.split.hi); 260 rdmsr(MSR_IA32_APERF, cur->aperf.split.lo, cur->aperf.split.hi);
260 rdmsr(MSR_IA32_MPERF, cur->mperf_cur.split.lo, cur->mperf_cur.split.hi); 261 rdmsr(MSR_IA32_MPERF, cur->mperf.split.lo, cur->mperf.split.hi);
261
262 wrmsr(MSR_IA32_APERF, 0, 0);
263 wrmsr(MSR_IA32_MPERF, 0, 0);
264 262
265 return 0; 263 return 0;
266} 264}
@@ -281,52 +279,57 @@ static long read_measured_perf_ctrs(void *_cur)
281static unsigned int get_measured_perf(struct cpufreq_policy *policy, 279static unsigned int get_measured_perf(struct cpufreq_policy *policy,
282 unsigned int cpu) 280 unsigned int cpu)
283{ 281{
284 struct perf_cur cur; 282 struct perf_pair readin, cur;
285 unsigned int perf_percent; 283 unsigned int perf_percent;
286 unsigned int retval; 284 unsigned int retval;
287 285
288 if (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur)) 286 if (!work_on_cpu(cpu, read_measured_perf_ctrs, &readin))
289 return 0; 287 return 0;
290 288
289 cur.aperf.whole = readin.aperf.whole -
290 per_cpu(drv_data, cpu)->saved_aperf;
291 cur.mperf.whole = readin.mperf.whole -
292 per_cpu(drv_data, cpu)->saved_mperf;
293 per_cpu(drv_data, cpu)->saved_aperf = readin.aperf.whole;
294 per_cpu(drv_data, cpu)->saved_mperf = readin.mperf.whole;
295
291#ifdef __i386__ 296#ifdef __i386__
292 /* 297 /*
293 * We dont want to do 64 bit divide with 32 bit kernel 298 * We dont want to do 64 bit divide with 32 bit kernel
294 * Get an approximate value. Return failure in case we cannot get 299 * Get an approximate value. Return failure in case we cannot get
295 * an approximate value. 300 * an approximate value.
296 */ 301 */
297 if (unlikely(cur.aperf_cur.split.hi || cur.mperf_cur.split.hi)) { 302 if (unlikely(cur.aperf.split.hi || cur.mperf.split.hi)) {
298 int shift_count; 303 int shift_count;
299 u32 h; 304 u32 h;
300 305
301 h = max_t(u32, cur.aperf_cur.split.hi, cur.mperf_cur.split.hi); 306 h = max_t(u32, cur.aperf.split.hi, cur.mperf.split.hi);
302 shift_count = fls(h); 307 shift_count = fls(h);
303 308
304 cur.aperf_cur.whole >>= shift_count; 309 cur.aperf.whole >>= shift_count;
305 cur.mperf_cur.whole >>= shift_count; 310 cur.mperf.whole >>= shift_count;
306 } 311 }
307 312
308 if (((unsigned long)(-1) / 100) < cur.aperf_cur.split.lo) { 313 if (((unsigned long)(-1) / 100) < cur.aperf.split.lo) {
309 int shift_count = 7; 314 int shift_count = 7;
310 cur.aperf_cur.split.lo >>= shift_count; 315 cur.aperf.split.lo >>= shift_count;
311 cur.mperf_cur.split.lo >>= shift_count; 316 cur.mperf.split.lo >>= shift_count;
312 } 317 }
313 318
314 if (cur.aperf_cur.split.lo && cur.mperf_cur.split.lo) 319 if (cur.aperf.split.lo && cur.mperf.split.lo)
315 perf_percent = (cur.aperf_cur.split.lo * 100) / 320 perf_percent = (cur.aperf.split.lo * 100) / cur.mperf.split.lo;
316 cur.mperf_cur.split.lo;
317 else 321 else
318 perf_percent = 0; 322 perf_percent = 0;
319 323
320#else 324#else
321 if (unlikely(((unsigned long)(-1) / 100) < cur.aperf_cur.whole)) { 325 if (unlikely(((unsigned long)(-1) / 100) < cur.aperf.whole)) {
322 int shift_count = 7; 326 int shift_count = 7;
323 cur.aperf_cur.whole >>= shift_count; 327 cur.aperf.whole >>= shift_count;
324 cur.mperf_cur.whole >>= shift_count; 328 cur.mperf.whole >>= shift_count;
325 } 329 }
326 330
327 if (cur.aperf_cur.whole && cur.mperf_cur.whole) 331 if (cur.aperf.whole && cur.mperf.whole)
328 perf_percent = (cur.aperf_cur.whole * 100) / 332 perf_percent = (cur.aperf.whole * 100) / cur.mperf.whole;
329 cur.mperf_cur.whole;
330 else 333 else
331 perf_percent = 0; 334 perf_percent = 0;
332 335
diff --git a/arch/x86/kernel/cpu/cpufreq/longhaul.c b/arch/x86/kernel/cpu/cpufreq/longhaul.c
index 0bd48e65a0ca..ce2ed3e4aad9 100644
--- a/arch/x86/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/x86/kernel/cpu/cpufreq/longhaul.c
@@ -33,7 +33,6 @@
33#include <linux/timex.h> 33#include <linux/timex.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/acpi.h> 35#include <linux/acpi.h>
36#include <linux/kernel.h>
37 36
38#include <asm/msr.h> 37#include <asm/msr.h>
39#include <acpi/processor.h> 38#include <acpi/processor.h>