@@ -68,7 +68,6 @@ struct acpi_cpufreq_data {
68
68
unsigned int max_freq ;
69
69
unsigned int resume ;
70
70
unsigned int cpu_feature ;
71
- u64 saved_aperf , saved_mperf ;
72
71
};
73
72
74
73
static DEFINE_PER_CPU (struct acpi_cpufreq_data * , drv_data );
@@ -242,23 +241,26 @@ static u32 get_cur_val(const struct cpumask *mask)
242
241
return cmd .val ;
243
242
}
244
243
245
- struct perf_pair {
244
+ struct perf_cur {
246
245
union {
247
246
struct {
248
247
u32 lo ;
249
248
u32 hi ;
250
249
} split ;
251
250
u64 whole ;
252
- } aperf , mperf ;
251
+ } aperf_cur , mperf_cur ;
253
252
};
254
253
255
254
256
255
static long read_measured_perf_ctrs (void * _cur )
257
256
{
258
- struct perf_pair * cur = _cur ;
257
+ struct perf_cur * cur = _cur ;
259
258
260
- rdmsr (MSR_IA32_APERF , cur -> aperf .split .lo , cur -> aperf .split .hi );
261
- rdmsr (MSR_IA32_MPERF , cur -> mperf .split .lo , cur -> mperf .split .hi );
259
+ rdmsr (MSR_IA32_APERF , cur -> aperf_cur .split .lo , cur -> aperf_cur .split .hi );
260
+ rdmsr (MSR_IA32_MPERF , cur -> mperf_cur .split .lo , cur -> mperf_cur .split .hi );
261
+
262
+ wrmsr (MSR_IA32_APERF , 0 , 0 );
263
+ wrmsr (MSR_IA32_MPERF , 0 , 0 );
262
264
263
265
return 0 ;
264
266
}
@@ -279,57 +281,52 @@ static long read_measured_perf_ctrs(void *_cur)
279
281
static unsigned int get_measured_perf (struct cpufreq_policy * policy ,
280
282
unsigned int cpu )
281
283
{
282
- struct perf_pair readin , cur ;
284
+ struct perf_cur cur ;
283
285
unsigned int perf_percent ;
284
286
unsigned int retval ;
285
287
286
- if (!work_on_cpu (cpu , read_measured_perf_ctrs , & readin ))
288
+ if (!work_on_cpu (cpu , read_measured_perf_ctrs , & cur ))
287
289
return 0 ;
288
290
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
-
296
291
#ifdef __i386__
297
292
/*
298
293
* We dont want to do 64 bit divide with 32 bit kernel
299
294
* Get an approximate value. Return failure in case we cannot get
300
295
* an approximate value.
301
296
*/
302
- if (unlikely (cur .aperf .split .hi || cur .mperf .split .hi )) {
297
+ if (unlikely (cur .aperf_cur .split .hi || cur .mperf_cur .split .hi )) {
303
298
int shift_count ;
304
299
u32 h ;
305
300
306
- h = max_t (u32 , cur .aperf .split .hi , cur .mperf .split .hi );
301
+ h = max_t (u32 , cur .aperf_cur .split .hi , cur .mperf_cur .split .hi );
307
302
shift_count = fls (h );
308
303
309
- cur .aperf .whole >>= shift_count ;
310
- cur .mperf .whole >>= shift_count ;
304
+ cur .aperf_cur .whole >>= shift_count ;
305
+ cur .mperf_cur .whole >>= shift_count ;
311
306
}
312
307
313
- if (((unsigned long )(-1 ) / 100 ) < cur .aperf .split .lo ) {
308
+ if (((unsigned long )(-1 ) / 100 ) < cur .aperf_cur .split .lo ) {
314
309
int shift_count = 7 ;
315
- cur .aperf .split .lo >>= shift_count ;
316
- cur .mperf .split .lo >>= shift_count ;
310
+ cur .aperf_cur .split .lo >>= shift_count ;
311
+ cur .mperf_cur .split .lo >>= shift_count ;
317
312
}
318
313
319
- if (cur .aperf .split .lo && cur .mperf .split .lo )
320
- perf_percent = (cur .aperf .split .lo * 100 ) / cur .mperf .split .lo ;
314
+ if (cur .aperf_cur .split .lo && cur .mperf_cur .split .lo )
315
+ perf_percent = (cur .aperf_cur .split .lo * 100 ) /
316
+ cur .mperf_cur .split .lo ;
321
317
else
322
318
perf_percent = 0 ;
323
319
324
320
#else
325
- if (unlikely (((unsigned long )(-1 ) / 100 ) < cur .aperf .whole )) {
321
+ if (unlikely (((unsigned long )(-1 ) / 100 ) < cur .aperf_cur .whole )) {
326
322
int shift_count = 7 ;
327
- cur .aperf .whole >>= shift_count ;
328
- cur .mperf .whole >>= shift_count ;
323
+ cur .aperf_cur .whole >>= shift_count ;
324
+ cur .mperf_cur .whole >>= shift_count ;
329
325
}
330
326
331
- if (cur .aperf .whole && cur .mperf .whole )
332
- perf_percent = (cur .aperf .whole * 100 ) / cur .mperf .whole ;
327
+ if (cur .aperf_cur .whole && cur .mperf_cur .whole )
328
+ perf_percent = (cur .aperf_cur .whole * 100 ) /
329
+ cur .mperf_cur .whole ;
333
330
else
334
331
perf_percent = 0 ;
335
332
0 commit comments