aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_perflib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/processor_perflib.c')
-rw-r--r--drivers/acpi/processor_perflib.c87
1 files changed, 38 insertions, 49 deletions
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 5c24ac45717c..14a00e5a8f6a 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -108,10 +108,9 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
108 acpi_status status = 0; 108 acpi_status status = 0;
109 unsigned long ppc = 0; 109 unsigned long ppc = 0;
110 110
111 ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
112 111
113 if (!pr) 112 if (!pr)
114 return_VALUE(-EINVAL); 113 return -EINVAL;
115 114
116 /* 115 /*
117 * _PPC indicates the maximum state currently supported by the platform 116 * _PPC indicates the maximum state currently supported by the platform
@@ -124,12 +123,12 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
124 123
125 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 124 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
126 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC")); 125 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
127 return_VALUE(-ENODEV); 126 return -ENODEV;
128 } 127 }
129 128
130 pr->performance_platform_limit = (int)ppc; 129 pr->performance_platform_limit = (int)ppc;
131 130
132 return_VALUE(0); 131 return 0;
133} 132}
134 133
135int acpi_processor_ppc_has_changed(struct acpi_processor *pr) 134int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
@@ -168,12 +167,11 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
168 union acpi_object *pct = NULL; 167 union acpi_object *pct = NULL;
169 union acpi_object obj = { 0 }; 168 union acpi_object obj = { 0 };
170 169
171 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
172 170
173 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); 171 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
174 if (ACPI_FAILURE(status)) { 172 if (ACPI_FAILURE(status)) {
175 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT")); 173 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
176 return_VALUE(-ENODEV); 174 return -ENODEV;
177 } 175 }
178 176
179 pct = (union acpi_object *)buffer.pointer; 177 pct = (union acpi_object *)buffer.pointer;
@@ -220,7 +218,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
220 end: 218 end:
221 acpi_os_free(buffer.pointer); 219 acpi_os_free(buffer.pointer);
222 220
223 return_VALUE(result); 221 return result;
224} 222}
225 223
226static int acpi_processor_get_performance_states(struct acpi_processor *pr) 224static int acpi_processor_get_performance_states(struct acpi_processor *pr)
@@ -233,12 +231,11 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
233 union acpi_object *pss = NULL; 231 union acpi_object *pss = NULL;
234 int i; 232 int i;
235 233
236 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
237 234
238 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); 235 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
239 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
240 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS")); 237 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
241 return_VALUE(-ENODEV); 238 return -ENODEV;
242 } 239 }
243 240
244 pss = (union acpi_object *)buffer.pointer; 241 pss = (union acpi_object *)buffer.pointer;
@@ -299,7 +296,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
299 end: 296 end:
300 acpi_os_free(buffer.pointer); 297 acpi_os_free(buffer.pointer);
301 298
302 return_VALUE(result); 299 return result;
303} 300}
304 301
305static int acpi_processor_get_performance_info(struct acpi_processor *pr) 302static int acpi_processor_get_performance_info(struct acpi_processor *pr)
@@ -308,31 +305,30 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
308 acpi_status status = AE_OK; 305 acpi_status status = AE_OK;
309 acpi_handle handle = NULL; 306 acpi_handle handle = NULL;
310 307
311 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
312 308
313 if (!pr || !pr->performance || !pr->handle) 309 if (!pr || !pr->performance || !pr->handle)
314 return_VALUE(-EINVAL); 310 return -EINVAL;
315 311
316 status = acpi_get_handle(pr->handle, "_PCT", &handle); 312 status = acpi_get_handle(pr->handle, "_PCT", &handle);
317 if (ACPI_FAILURE(status)) { 313 if (ACPI_FAILURE(status)) {
318 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 314 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
319 "ACPI-based processor performance control unavailable\n")); 315 "ACPI-based processor performance control unavailable\n"));
320 return_VALUE(-ENODEV); 316 return -ENODEV;
321 } 317 }
322 318
323 result = acpi_processor_get_performance_control(pr); 319 result = acpi_processor_get_performance_control(pr);
324 if (result) 320 if (result)
325 return_VALUE(result); 321 return result;
326 322
327 result = acpi_processor_get_performance_states(pr); 323 result = acpi_processor_get_performance_states(pr);
328 if (result) 324 if (result)
329 return_VALUE(result); 325 return result;
330 326
331 result = acpi_processor_get_platform_limit(pr); 327 result = acpi_processor_get_platform_limit(pr);
332 if (result) 328 if (result)
333 return_VALUE(result); 329 return result;
334 330
335 return_VALUE(0); 331 return 0;
336} 332}
337 333
338int acpi_processor_notify_smm(struct module *calling_module) 334int acpi_processor_notify_smm(struct module *calling_module)
@@ -340,13 +336,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
340 acpi_status status; 336 acpi_status status;
341 static int is_done = 0; 337 static int is_done = 0;
342 338
343 ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
344 339
345 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 340 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
346 return_VALUE(-EBUSY); 341 return -EBUSY;
347 342
348 if (!try_module_get(calling_module)) 343 if (!try_module_get(calling_module))
349 return_VALUE(-EINVAL); 344 return -EINVAL;
350 345
351 /* is_done is set to negative if an error occured, 346 /* is_done is set to negative if an error occured,
352 * and to postitive if _no_ error occured, but SMM 347 * and to postitive if _no_ error occured, but SMM
@@ -355,10 +350,10 @@ int acpi_processor_notify_smm(struct module *calling_module)
355 */ 350 */
356 if (is_done > 0) { 351 if (is_done > 0) {
357 module_put(calling_module); 352 module_put(calling_module);
358 return_VALUE(0); 353 return 0;
359 } else if (is_done < 0) { 354 } else if (is_done < 0) {
360 module_put(calling_module); 355 module_put(calling_module);
361 return_VALUE(is_done); 356 return is_done;
362 } 357 }
363 358
364 is_done = -EIO; 359 is_done = -EIO;
@@ -367,7 +362,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
367 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) { 362 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) {
368 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n")); 363 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n"));
369 module_put(calling_module); 364 module_put(calling_module);
370 return_VALUE(0); 365 return 0;
371 } 366 }
372 367
373 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 368 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -389,7 +384,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
389 "smi_cmd [0x%x]", acpi_fadt.pstate_cnt, 384 "smi_cmd [0x%x]", acpi_fadt.pstate_cnt,
390 acpi_fadt.smi_cmd)); 385 acpi_fadt.smi_cmd));
391 module_put(calling_module); 386 module_put(calling_module);
392 return_VALUE(status); 387 return status;
393 } 388 }
394 389
395 /* Success. If there's no _PPC, we need to fear nothing, so 390 /* Success. If there's no _PPC, we need to fear nothing, so
@@ -399,7 +394,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
399 if (!(acpi_processor_ppc_status & PPC_IN_USE)) 394 if (!(acpi_processor_ppc_status & PPC_IN_USE))
400 module_put(calling_module); 395 module_put(calling_module);
401 396
402 return_VALUE(0); 397 return 0;
403} 398}
404 399
405EXPORT_SYMBOL(acpi_processor_notify_smm); 400EXPORT_SYMBOL(acpi_processor_notify_smm);
@@ -420,7 +415,6 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
420 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 415 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
421 int i; 416 int i;
422 417
423 ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
424 418
425 if (!pr) 419 if (!pr)
426 goto end; 420 goto end;
@@ -444,7 +438,7 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
444 (u32) pr->performance->states[i].transition_latency); 438 (u32) pr->performance->states[i].transition_latency);
445 439
446 end: 440 end:
447 return_VALUE(0); 441 return 0;
448} 442}
449 443
450static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) 444static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
@@ -466,23 +460,22 @@ acpi_processor_write_performance(struct file *file,
466 unsigned int new_state = 0; 460 unsigned int new_state = 0;
467 struct cpufreq_policy policy; 461 struct cpufreq_policy policy;
468 462
469 ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
470 463
471 if (!pr || (count > sizeof(state_string) - 1)) 464 if (!pr || (count > sizeof(state_string) - 1))
472 return_VALUE(-EINVAL); 465 return -EINVAL;
473 466
474 perf = pr->performance; 467 perf = pr->performance;
475 if (!perf) 468 if (!perf)
476 return_VALUE(-EINVAL); 469 return -EINVAL;
477 470
478 if (copy_from_user(state_string, buffer, count)) 471 if (copy_from_user(state_string, buffer, count))
479 return_VALUE(-EFAULT); 472 return -EFAULT;
480 473
481 state_string[count] = '\0'; 474 state_string[count] = '\0';
482 new_state = simple_strtoul(state_string, NULL, 0); 475 new_state = simple_strtoul(state_string, NULL, 0);
483 476
484 if (new_state >= perf->state_count) 477 if (new_state >= perf->state_count)
485 return_VALUE(-EINVAL); 478 return -EINVAL;
486 479
487 cpufreq_get_policy(&policy, pr->id); 480 cpufreq_get_policy(&policy, pr->id);
488 481
@@ -492,9 +485,9 @@ acpi_processor_write_performance(struct file *file,
492 485
493 result = cpufreq_set_policy(&policy); 486 result = cpufreq_set_policy(&policy);
494 if (result) 487 if (result)
495 return_VALUE(result); 488 return result;
496 489
497 return_VALUE(count); 490 return count;
498} 491}
499 492
500static void acpi_cpufreq_add_file(struct acpi_processor *pr) 493static void acpi_cpufreq_add_file(struct acpi_processor *pr)
@@ -502,10 +495,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
502 struct proc_dir_entry *entry = NULL; 495 struct proc_dir_entry *entry = NULL;
503 struct acpi_device *device = NULL; 496 struct acpi_device *device = NULL;
504 497
505 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
506 498
507 if (acpi_bus_get_device(pr->handle, &device)) 499 if (acpi_bus_get_device(pr->handle, &device))
508 return_VOID; 500 return;
509 501
510 /* add file 'performance' [R/W] */ 502 /* add file 'performance' [R/W] */
511 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 503 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
@@ -517,23 +509,22 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
517 entry->data = acpi_driver_data(device); 509 entry->data = acpi_driver_data(device);
518 entry->owner = THIS_MODULE; 510 entry->owner = THIS_MODULE;
519 } 511 }
520 return_VOID; 512 return;
521} 513}
522 514
523static void acpi_cpufreq_remove_file(struct acpi_processor *pr) 515static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
524{ 516{
525 struct acpi_device *device = NULL; 517 struct acpi_device *device = NULL;
526 518
527 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
528 519
529 if (acpi_bus_get_device(pr->handle, &device)) 520 if (acpi_bus_get_device(pr->handle, &device))
530 return_VOID; 521 return;
531 522
532 /* remove file 'performance' */ 523 /* remove file 'performance' */
533 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 524 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
534 acpi_device_dir(device)); 525 acpi_device_dir(device));
535 526
536 return_VOID; 527 return;
537} 528}
538 529
539#else 530#else
@@ -777,22 +768,21 @@ acpi_processor_register_performance(struct acpi_processor_performance
777{ 768{
778 struct acpi_processor *pr; 769 struct acpi_processor *pr;
779 770
780 ACPI_FUNCTION_TRACE("acpi_processor_register_performance");
781 771
782 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 772 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
783 return_VALUE(-EINVAL); 773 return -EINVAL;
784 774
785 mutex_lock(&performance_mutex); 775 mutex_lock(&performance_mutex);
786 776
787 pr = processors[cpu]; 777 pr = processors[cpu];
788 if (!pr) { 778 if (!pr) {
789 mutex_unlock(&performance_mutex); 779 mutex_unlock(&performance_mutex);
790 return_VALUE(-ENODEV); 780 return -ENODEV;
791 } 781 }
792 782
793 if (pr->performance) { 783 if (pr->performance) {
794 mutex_unlock(&performance_mutex); 784 mutex_unlock(&performance_mutex);
795 return_VALUE(-EBUSY); 785 return -EBUSY;
796 } 786 }
797 787
798 WARN_ON(!performance); 788 WARN_ON(!performance);
@@ -802,13 +792,13 @@ acpi_processor_register_performance(struct acpi_processor_performance
802 if (acpi_processor_get_performance_info(pr)) { 792 if (acpi_processor_get_performance_info(pr)) {
803 pr->performance = NULL; 793 pr->performance = NULL;
804 mutex_unlock(&performance_mutex); 794 mutex_unlock(&performance_mutex);
805 return_VALUE(-EIO); 795 return -EIO;
806 } 796 }
807 797
808 acpi_cpufreq_add_file(pr); 798 acpi_cpufreq_add_file(pr);
809 799
810 mutex_unlock(&performance_mutex); 800 mutex_unlock(&performance_mutex);
811 return_VALUE(0); 801 return 0;
812} 802}
813 803
814EXPORT_SYMBOL(acpi_processor_register_performance); 804EXPORT_SYMBOL(acpi_processor_register_performance);
@@ -819,14 +809,13 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
819{ 809{
820 struct acpi_processor *pr; 810 struct acpi_processor *pr;
821 811
822 ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
823 812
824 mutex_lock(&performance_mutex); 813 mutex_lock(&performance_mutex);
825 814
826 pr = processors[cpu]; 815 pr = processors[cpu];
827 if (!pr) { 816 if (!pr) {
828 mutex_unlock(&performance_mutex); 817 mutex_unlock(&performance_mutex);
829 return_VOID; 818 return;
830 } 819 }
831 820
832 if (pr->performance) 821 if (pr->performance)
@@ -837,7 +826,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
837 826
838 mutex_unlock(&performance_mutex); 827 mutex_unlock(&performance_mutex);
839 828
840 return_VOID; 829 return;
841} 830}
842 831
843EXPORT_SYMBOL(acpi_processor_unregister_performance); 832EXPORT_SYMBOL(acpi_processor_unregister_performance);