lkdtm: Add Control Flow Integrity test
[linux/fpc-iii.git] / drivers / acpi / processor_perflib.c
blobee87cb6f6e5944f2cc843d1b9b56600d7edde6e6
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * processor_perflib.c - ACPI Processor P-States Library ($Revision: 71 $)
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
8 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
9 * - Added processor hotplug support
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/cpufreq.h>
16 #include <linux/slab.h>
17 #include <linux/acpi.h>
18 #include <acpi/processor.h>
19 #ifdef CONFIG_X86
20 #include <asm/cpufeature.h>
21 #endif
23 #define PREFIX "ACPI: "
25 #define ACPI_PROCESSOR_CLASS "processor"
26 #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
27 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
28 ACPI_MODULE_NAME("processor_perflib");
30 static DEFINE_MUTEX(performance_mutex);
33 * _PPC support is implemented as a CPUfreq policy notifier:
34 * This means each time a CPUfreq driver registered also with
35 * the ACPI core is asked to change the speed policy, the maximum
36 * value is adjusted so that it is within the platform limit.
38 * Also, when a new platform limit value is detected, the CPUfreq
39 * policy is adjusted accordingly.
42 /* ignore_ppc:
43 * -1 -> cpufreq low level drivers not initialized -> _PSS, etc. not called yet
44 * ignore _PPC
45 * 0 -> cpufreq low level drivers initialized -> consider _PPC values
46 * 1 -> ignore _PPC totally -> forced by user through boot param
48 static int ignore_ppc = -1;
49 module_param(ignore_ppc, int, 0644);
50 MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \
51 "limited by BIOS, this should help");
53 #define PPC_REGISTERED 1
54 #define PPC_IN_USE 2
56 static int acpi_processor_ppc_status;
58 static int acpi_processor_ppc_notifier(struct notifier_block *nb,
59 unsigned long event, void *data)
61 struct cpufreq_policy *policy = data;
62 struct acpi_processor *pr;
63 unsigned int ppc = 0;
65 if (ignore_ppc < 0)
66 ignore_ppc = 0;
68 if (ignore_ppc)
69 return 0;
71 if (event != CPUFREQ_ADJUST)
72 return 0;
74 mutex_lock(&performance_mutex);
76 pr = per_cpu(processors, policy->cpu);
77 if (!pr || !pr->performance)
78 goto out;
80 ppc = (unsigned int)pr->performance_platform_limit;
82 if (ppc >= pr->performance->state_count)
83 goto out;
85 cpufreq_verify_within_limits(policy, 0,
86 pr->performance->states[ppc].
87 core_frequency * 1000);
89 out:
90 mutex_unlock(&performance_mutex);
92 return 0;
95 static struct notifier_block acpi_ppc_notifier_block = {
96 .notifier_call = acpi_processor_ppc_notifier,
99 static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
101 acpi_status status = 0;
102 unsigned long long ppc = 0;
105 if (!pr)
106 return -EINVAL;
109 * _PPC indicates the maximum state currently supported by the platform
110 * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
112 status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
114 if (status != AE_NOT_FOUND)
115 acpi_processor_ppc_status |= PPC_IN_USE;
117 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
118 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
119 return -ENODEV;
122 pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
123 (int)ppc, ppc ? "" : "not");
125 pr->performance_platform_limit = (int)ppc;
127 return 0;
130 #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
132 * acpi_processor_ppc_ost: Notify firmware the _PPC evaluation status
133 * @handle: ACPI processor handle
134 * @status: the status code of _PPC evaluation
135 * 0: success. OSPM is now using the performance state specificed.
136 * 1: failure. OSPM has not changed the number of P-states in use
138 static void acpi_processor_ppc_ost(acpi_handle handle, int status)
140 if (acpi_has_method(handle, "_OST"))
141 acpi_evaluate_ost(handle, ACPI_PROCESSOR_NOTIFY_PERFORMANCE,
142 status, NULL);
145 void acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
147 int ret;
149 if (ignore_ppc || !pr->performance) {
151 * Only when it is notification event, the _OST object
152 * will be evaluated. Otherwise it is skipped.
154 if (event_flag)
155 acpi_processor_ppc_ost(pr->handle, 1);
156 return;
159 ret = acpi_processor_get_platform_limit(pr);
161 * Only when it is notification event, the _OST object
162 * will be evaluated. Otherwise it is skipped.
164 if (event_flag) {
165 if (ret < 0)
166 acpi_processor_ppc_ost(pr->handle, 1);
167 else
168 acpi_processor_ppc_ost(pr->handle, 0);
170 if (ret >= 0)
171 cpufreq_update_limits(pr->id);
174 int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
176 struct acpi_processor *pr;
178 pr = per_cpu(processors, cpu);
179 if (!pr || !pr->performance || !pr->performance->state_count)
180 return -ENODEV;
181 *limit = pr->performance->states[pr->performance_platform_limit].
182 core_frequency * 1000;
183 return 0;
185 EXPORT_SYMBOL(acpi_processor_get_bios_limit);
187 void acpi_processor_ppc_init(void)
189 if (!cpufreq_register_notifier
190 (&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER))
191 acpi_processor_ppc_status |= PPC_REGISTERED;
192 else
193 printk(KERN_DEBUG
194 "Warning: Processor Platform Limit not supported.\n");
197 void acpi_processor_ppc_exit(void)
199 if (acpi_processor_ppc_status & PPC_REGISTERED)
200 cpufreq_unregister_notifier(&acpi_ppc_notifier_block,
201 CPUFREQ_POLICY_NOTIFIER);
203 acpi_processor_ppc_status &= ~PPC_REGISTERED;
206 static int acpi_processor_get_performance_control(struct acpi_processor *pr)
208 int result = 0;
209 acpi_status status = 0;
210 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
211 union acpi_object *pct = NULL;
212 union acpi_object obj = { 0 };
215 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
216 if (ACPI_FAILURE(status)) {
217 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
218 return -ENODEV;
221 pct = (union acpi_object *)buffer.pointer;
222 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
223 || (pct->package.count != 2)) {
224 printk(KERN_ERR PREFIX "Invalid _PCT data\n");
225 result = -EFAULT;
226 goto end;
230 * control_register
233 obj = pct->package.elements[0];
235 if ((obj.type != ACPI_TYPE_BUFFER)
236 || (obj.buffer.length < sizeof(struct acpi_pct_register))
237 || (obj.buffer.pointer == NULL)) {
238 printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
239 result = -EFAULT;
240 goto end;
242 memcpy(&pr->performance->control_register, obj.buffer.pointer,
243 sizeof(struct acpi_pct_register));
246 * status_register
249 obj = pct->package.elements[1];
251 if ((obj.type != ACPI_TYPE_BUFFER)
252 || (obj.buffer.length < sizeof(struct acpi_pct_register))
253 || (obj.buffer.pointer == NULL)) {
254 printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
255 result = -EFAULT;
256 goto end;
259 memcpy(&pr->performance->status_register, obj.buffer.pointer,
260 sizeof(struct acpi_pct_register));
262 end:
263 kfree(buffer.pointer);
265 return result;
268 #ifdef CONFIG_X86
270 * Some AMDs have 50MHz frequency multiples, but only provide 100MHz rounding
271 * in their ACPI data. Calculate the real values and fix up the _PSS data.
273 static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
275 u32 hi, lo, fid, did;
276 int index = px->control & 0x00000007;
278 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
279 return;
281 if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
282 || boot_cpu_data.x86 == 0x11) {
283 rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);
285 * MSR C001_0064+:
286 * Bit 63: PstateEn. Read-write. If set, the P-state is valid.
288 if (!(hi & BIT(31)))
289 return;
291 fid = lo & 0x3f;
292 did = (lo >> 6) & 7;
293 if (boot_cpu_data.x86 == 0x10)
294 px->core_frequency = (100 * (fid + 0x10)) >> did;
295 else
296 px->core_frequency = (100 * (fid + 8)) >> did;
299 #else
300 static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
301 #endif
303 static int acpi_processor_get_performance_states(struct acpi_processor *pr)
305 int result = 0;
306 acpi_status status = AE_OK;
307 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
308 struct acpi_buffer format = { sizeof("NNNNNN"), "NNNNNN" };
309 struct acpi_buffer state = { 0, NULL };
310 union acpi_object *pss = NULL;
311 int i;
312 int last_invalid = -1;
315 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
316 if (ACPI_FAILURE(status)) {
317 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
318 return -ENODEV;
321 pss = buffer.pointer;
322 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
323 printk(KERN_ERR PREFIX "Invalid _PSS data\n");
324 result = -EFAULT;
325 goto end;
328 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n",
329 pss->package.count));
331 pr->performance->state_count = pss->package.count;
332 pr->performance->states =
333 kmalloc_array(pss->package.count,
334 sizeof(struct acpi_processor_px),
335 GFP_KERNEL);
336 if (!pr->performance->states) {
337 result = -ENOMEM;
338 goto end;
341 for (i = 0; i < pr->performance->state_count; i++) {
343 struct acpi_processor_px *px = &(pr->performance->states[i]);
345 state.length = sizeof(struct acpi_processor_px);
346 state.pointer = px;
348 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
350 status = acpi_extract_package(&(pss->package.elements[i]),
351 &format, &state);
352 if (ACPI_FAILURE(status)) {
353 ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
354 result = -EFAULT;
355 kfree(pr->performance->states);
356 goto end;
359 amd_fixup_frequency(px, i);
361 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
362 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
364 (u32) px->core_frequency,
365 (u32) px->power,
366 (u32) px->transition_latency,
367 (u32) px->bus_master_latency,
368 (u32) px->control, (u32) px->status));
371 * Check that ACPI's u64 MHz will be valid as u32 KHz in cpufreq
373 if (!px->core_frequency ||
374 ((u32)(px->core_frequency * 1000) !=
375 (px->core_frequency * 1000))) {
376 printk(KERN_ERR FW_BUG PREFIX
377 "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
378 pr->id, px->core_frequency);
379 if (last_invalid == -1)
380 last_invalid = i;
381 } else {
382 if (last_invalid != -1) {
384 * Copy this valid entry over last_invalid entry
386 memcpy(&(pr->performance->states[last_invalid]),
387 px, sizeof(struct acpi_processor_px));
388 ++last_invalid;
393 if (last_invalid == 0) {
394 printk(KERN_ERR FW_BUG PREFIX
395 "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
396 result = -EFAULT;
397 kfree(pr->performance->states);
398 pr->performance->states = NULL;
401 if (last_invalid > 0)
402 pr->performance->state_count = last_invalid;
404 end:
405 kfree(buffer.pointer);
407 return result;
410 int acpi_processor_get_performance_info(struct acpi_processor *pr)
412 int result = 0;
414 if (!pr || !pr->performance || !pr->handle)
415 return -EINVAL;
417 if (!acpi_has_method(pr->handle, "_PCT")) {
418 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
419 "ACPI-based processor performance control unavailable\n"));
420 return -ENODEV;
423 result = acpi_processor_get_performance_control(pr);
424 if (result)
425 goto update_bios;
427 result = acpi_processor_get_performance_states(pr);
428 if (result)
429 goto update_bios;
431 /* We need to call _PPC once when cpufreq starts */
432 if (ignore_ppc != 1)
433 result = acpi_processor_get_platform_limit(pr);
435 return result;
438 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
439 * the BIOS is older than the CPU and does not know its frequencies
441 update_bios:
442 #ifdef CONFIG_X86
443 if (acpi_has_method(pr->handle, "_PPC")) {
444 if(boot_cpu_has(X86_FEATURE_EST))
445 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
446 "frequency support\n");
448 #endif
449 return result;
451 EXPORT_SYMBOL_GPL(acpi_processor_get_performance_info);
453 int acpi_processor_pstate_control(void)
455 acpi_status status;
457 if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)
458 return 0;
460 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
461 "Writing pstate_control [0x%x] to smi_command [0x%x]\n",
462 acpi_gbl_FADT.pstate_control, acpi_gbl_FADT.smi_command));
464 status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
465 (u32)acpi_gbl_FADT.pstate_control, 8);
466 if (ACPI_SUCCESS(status))
467 return 1;
469 ACPI_EXCEPTION((AE_INFO, status,
470 "Failed to write pstate_control [0x%x] to smi_command [0x%x]",
471 acpi_gbl_FADT.pstate_control, acpi_gbl_FADT.smi_command));
472 return -EIO;
475 int acpi_processor_notify_smm(struct module *calling_module)
477 static int is_done = 0;
478 int result;
480 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
481 return -EBUSY;
483 if (!try_module_get(calling_module))
484 return -EINVAL;
486 /* is_done is set to negative if an error occurred,
487 * and to postitive if _no_ error occurred, but SMM
488 * was already notified. This avoids double notification
489 * which might lead to unexpected results...
491 if (is_done > 0) {
492 module_put(calling_module);
493 return 0;
494 } else if (is_done < 0) {
495 module_put(calling_module);
496 return is_done;
499 is_done = -EIO;
501 result = acpi_processor_pstate_control();
502 if (!result) {
503 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_control\n"));
504 module_put(calling_module);
505 return 0;
507 if (result < 0) {
508 module_put(calling_module);
509 return result;
512 /* Success. If there's no _PPC, we need to fear nothing, so
513 * we can allow the cpufreq driver to be rmmod'ed. */
514 is_done = 1;
516 if (!(acpi_processor_ppc_status & PPC_IN_USE))
517 module_put(calling_module);
519 return 0;
522 EXPORT_SYMBOL(acpi_processor_notify_smm);
524 int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain)
526 int result = 0;
527 acpi_status status = AE_OK;
528 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
529 struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
530 struct acpi_buffer state = {0, NULL};
531 union acpi_object *psd = NULL;
533 status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer);
534 if (ACPI_FAILURE(status)) {
535 return -ENODEV;
538 psd = buffer.pointer;
539 if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
540 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
541 result = -EFAULT;
542 goto end;
545 if (psd->package.count != 1) {
546 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
547 result = -EFAULT;
548 goto end;
551 state.length = sizeof(struct acpi_psd_package);
552 state.pointer = pdomain;
554 status = acpi_extract_package(&(psd->package.elements[0]),
555 &format, &state);
556 if (ACPI_FAILURE(status)) {
557 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
558 result = -EFAULT;
559 goto end;
562 if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
563 printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
564 result = -EFAULT;
565 goto end;
568 if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
569 printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
570 result = -EFAULT;
571 goto end;
574 if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL &&
575 pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ANY &&
576 pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) {
577 printk(KERN_ERR PREFIX "Invalid _PSD:coord_type\n");
578 result = -EFAULT;
579 goto end;
581 end:
582 kfree(buffer.pointer);
583 return result;
585 EXPORT_SYMBOL(acpi_processor_get_psd);
587 int acpi_processor_preregister_performance(
588 struct acpi_processor_performance __percpu *performance)
590 int count_target;
591 int retval = 0;
592 unsigned int i, j;
593 cpumask_var_t covered_cpus;
594 struct acpi_processor *pr;
595 struct acpi_psd_package *pdomain;
596 struct acpi_processor *match_pr;
597 struct acpi_psd_package *match_pdomain;
599 if (!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))
600 return -ENOMEM;
602 mutex_lock(&performance_mutex);
605 * Check if another driver has already registered, and abort before
606 * changing pr->performance if it has. Check input data as well.
608 for_each_possible_cpu(i) {
609 pr = per_cpu(processors, i);
610 if (!pr) {
611 /* Look only at processors in ACPI namespace */
612 continue;
615 if (pr->performance) {
616 retval = -EBUSY;
617 goto err_out;
620 if (!performance || !per_cpu_ptr(performance, i)) {
621 retval = -EINVAL;
622 goto err_out;
626 /* Call _PSD for all CPUs */
627 for_each_possible_cpu(i) {
628 pr = per_cpu(processors, i);
629 if (!pr)
630 continue;
632 pr->performance = per_cpu_ptr(performance, i);
633 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
634 pdomain = &(pr->performance->domain_info);
635 if (acpi_processor_get_psd(pr->handle, pdomain)) {
636 retval = -EINVAL;
637 continue;
640 if (retval)
641 goto err_ret;
644 * Now that we have _PSD data from all CPUs, lets setup P-state
645 * domain info.
647 for_each_possible_cpu(i) {
648 pr = per_cpu(processors, i);
649 if (!pr)
650 continue;
652 if (cpumask_test_cpu(i, covered_cpus))
653 continue;
655 pdomain = &(pr->performance->domain_info);
656 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
657 cpumask_set_cpu(i, covered_cpus);
658 if (pdomain->num_processors <= 1)
659 continue;
661 /* Validate the Domain info */
662 count_target = pdomain->num_processors;
663 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
664 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
665 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
666 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW;
667 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
668 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
670 for_each_possible_cpu(j) {
671 if (i == j)
672 continue;
674 match_pr = per_cpu(processors, j);
675 if (!match_pr)
676 continue;
678 match_pdomain = &(match_pr->performance->domain_info);
679 if (match_pdomain->domain != pdomain->domain)
680 continue;
682 /* Here i and j are in the same domain */
684 if (match_pdomain->num_processors != count_target) {
685 retval = -EINVAL;
686 goto err_ret;
689 if (pdomain->coord_type != match_pdomain->coord_type) {
690 retval = -EINVAL;
691 goto err_ret;
694 cpumask_set_cpu(j, covered_cpus);
695 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
698 for_each_possible_cpu(j) {
699 if (i == j)
700 continue;
702 match_pr = per_cpu(processors, j);
703 if (!match_pr)
704 continue;
706 match_pdomain = &(match_pr->performance->domain_info);
707 if (match_pdomain->domain != pdomain->domain)
708 continue;
710 match_pr->performance->shared_type =
711 pr->performance->shared_type;
712 cpumask_copy(match_pr->performance->shared_cpu_map,
713 pr->performance->shared_cpu_map);
717 err_ret:
718 for_each_possible_cpu(i) {
719 pr = per_cpu(processors, i);
720 if (!pr || !pr->performance)
721 continue;
723 /* Assume no coordination on any error parsing domain info */
724 if (retval) {
725 cpumask_clear(pr->performance->shared_cpu_map);
726 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
727 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
729 pr->performance = NULL; /* Will be set for real in register */
732 err_out:
733 mutex_unlock(&performance_mutex);
734 free_cpumask_var(covered_cpus);
735 return retval;
737 EXPORT_SYMBOL(acpi_processor_preregister_performance);
740 acpi_processor_register_performance(struct acpi_processor_performance
741 *performance, unsigned int cpu)
743 struct acpi_processor *pr;
745 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
746 return -EINVAL;
748 mutex_lock(&performance_mutex);
750 pr = per_cpu(processors, cpu);
751 if (!pr) {
752 mutex_unlock(&performance_mutex);
753 return -ENODEV;
756 if (pr->performance) {
757 mutex_unlock(&performance_mutex);
758 return -EBUSY;
761 WARN_ON(!performance);
763 pr->performance = performance;
765 if (acpi_processor_get_performance_info(pr)) {
766 pr->performance = NULL;
767 mutex_unlock(&performance_mutex);
768 return -EIO;
771 mutex_unlock(&performance_mutex);
772 return 0;
775 EXPORT_SYMBOL(acpi_processor_register_performance);
777 void acpi_processor_unregister_performance(unsigned int cpu)
779 struct acpi_processor *pr;
781 mutex_lock(&performance_mutex);
783 pr = per_cpu(processors, cpu);
784 if (!pr) {
785 mutex_unlock(&performance_mutex);
786 return;
789 if (pr->performance)
790 kfree(pr->performance->states);
791 pr->performance = NULL;
793 mutex_unlock(&performance_mutex);
795 return;
798 EXPORT_SYMBOL(acpi_processor_unregister_performance);