blob: e4032b7c3133d85cfc7545b540355b4413bf337d [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * processor_perflib.c - ACPI Processor P-States Library ($Revision: 71 $)
4 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/cpufreq.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090016#include <linux/slab.h>
Lv Zheng8b484632013-12-03 08:49:16 +080017#include <linux/acpi.h>
18#include <acpi/processor.h>
Miao Xie16be87e2008-10-24 17:22:04 +080019#ifdef CONFIG_X86
Thomas Renninger910dfae2008-09-01 14:27:04 +020020#include <asm/cpufeature.h>
Miao Xie16be87e2008-10-24 17:22:04 +080021#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Len Browna192a952009-07-28 16:45:54 -040023#define PREFIX "ACPI: "
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Arjan van de Ven65c19bb2006-04-27 05:25:00 -040027static DEFINE_MUTEX(performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29/*
30 * _PPC support is implemented as a CPUfreq policy notifier:
31 * This means each time a CPUfreq driver registered also with
32 * the ACPI core is asked to change the speed policy, the maximum
33 * value is adjusted so that it is within the platform limit.
34 *
35 * Also, when a new platform limit value is detected, the CPUfreq
36 * policy is adjusted accordingly.
37 */
38
Thomas Renningera1531ac2008-07-29 22:32:58 -070039/* ignore_ppc:
40 * -1 -> cpufreq low level drivers not initialized -> _PSS, etc. not called yet
41 * ignore _PPC
42 * 0 -> cpufreq low level drivers initialized -> consider _PPC values
43 * 1 -> ignore _PPC totally -> forced by user through boot param
44 */
Milan Broz9f497bc2008-08-12 17:48:27 +020045static int ignore_ppc = -1;
Milan Broz613e5f32008-08-16 02:11:28 +020046module_param(ignore_ppc, int, 0644);
Thomas Renninger623b78c2007-05-18 21:59:28 -050047MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \
48 "limited by BIOS, this should help");
49
Viresh Kumard15ce412019-08-28 14:20:13 +053050static bool acpi_processor_ppc_in_use;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Len Brown4be44fc2005-08-05 00:44:28 -040052static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
Len Brown4be44fc2005-08-05 00:44:28 -040054 acpi_status status = 0;
Matthew Wilcox27663c52008-10-10 02:22:59 -040055 unsigned long long ppc = 0;
Viresh Kumard15ce412019-08-28 14:20:13 +053056 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -040059 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 /*
62 * _PPC indicates the maximum state currently supported by the platform
63 * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
64 */
65 status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
66
67 if (status != AE_NOT_FOUND)
Viresh Kumard15ce412019-08-28 14:20:13 +053068 acpi_processor_ppc_in_use = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Len Brown4be44fc2005-08-05 00:44:28 -040070 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +010071 acpi_handle_warn(pr->handle, "_PPC evaluation failed: %s\n",
72 acpi_format_exception(status));
Patrick Mocheld550d982006-06-27 00:41:40 -040073 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75
Dominik Brodowski2d06d8c2011-03-27 15:04:46 +020076 pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
Thomas Renninger919158d2007-10-31 15:41:42 +010077 (int)ppc, ppc ? "" : "not");
78
Len Brown4be44fc2005-08-05 00:44:28 -040079 pr->performance_platform_limit = (int)ppc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Viresh Kumard15ce412019-08-28 14:20:13 +053081 if (ppc >= pr->performance->state_count ||
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +020082 unlikely(!freq_qos_request_active(&pr->perflib_req)))
Viresh Kumard15ce412019-08-28 14:20:13 +053083 return 0;
84
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +020085 ret = freq_qos_update_request(&pr->perflib_req,
Viresh Kumard15ce412019-08-28 14:20:13 +053086 pr->performance->states[ppc].core_frequency * 1000);
87 if (ret < 0) {
88 pr_warn("Failed to update perflib freq constraint: CPU%d (%d)\n",
89 pr->id, ret);
90 }
91
Patrick Mocheld550d982006-06-27 00:41:40 -040092 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Zhao Yakuid81c45e12009-10-16 09:20:41 +080095#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
96/*
97 * acpi_processor_ppc_ost: Notify firmware the _PPC evaluation status
98 * @handle: ACPI processor handle
99 * @status: the status code of _PPC evaluation
100 * 0: success. OSPM is now using the performance state specificed.
101 * 1: failure. OSPM has not changed the number of P-states in use
102 */
103static void acpi_processor_ppc_ost(acpi_handle handle, int status)
104{
Jiang Liu4a6172a2014-02-19 14:02:18 +0800105 if (acpi_has_method(handle, "_OST"))
106 acpi_evaluate_ost(handle, ACPI_PROCESSOR_NOTIFY_PERFORMANCE,
107 status, NULL);
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800108}
109
Rafael J. Wysockibca5f552016-11-18 13:57:54 +0100110void acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
Thomas Renninger623b78c2007-05-18 21:59:28 -0500112 int ret;
113
Chen Yuba1edb92018-01-29 10:26:46 +0800114 if (ignore_ppc || !pr->performance) {
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800115 /*
116 * Only when it is notification event, the _OST object
117 * will be evaluated. Otherwise it is skipped.
118 */
119 if (event_flag)
120 acpi_processor_ppc_ost(pr->handle, 1);
Rafael J. Wysockibca5f552016-11-18 13:57:54 +0100121 return;
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800122 }
Thomas Renninger623b78c2007-05-18 21:59:28 -0500123
124 ret = acpi_processor_get_platform_limit(pr);
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800125 /*
126 * Only when it is notification event, the _OST object
127 * will be evaluated. Otherwise it is skipped.
128 */
129 if (event_flag) {
130 if (ret < 0)
131 acpi_processor_ppc_ost(pr->handle, 1);
132 else
133 acpi_processor_ppc_ost(pr->handle, 0);
134 }
Rafael J. Wysockibca5f552016-11-18 13:57:54 +0100135 if (ret >= 0)
Rafael J. Wysocki5a25e3f2019-03-26 12:15:13 +0100136 cpufreq_update_limits(pr->id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137}
138
Thomas Renningere2f74f32009-11-19 12:31:01 +0100139int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
140{
141 struct acpi_processor *pr;
142
143 pr = per_cpu(processors, cpu);
144 if (!pr || !pr->performance || !pr->performance->state_count)
145 return -ENODEV;
146 *limit = pr->performance->states[pr->performance_platform_limit].
147 core_frequency * 1000;
148 return 0;
149}
150EXPORT_SYMBOL(acpi_processor_get_bios_limit);
151
Viresh Kumard15ce412019-08-28 14:20:13 +0530152void acpi_processor_ignore_ppc_init(void)
Len Brown4be44fc2005-08-05 00:44:28 -0400153{
Viresh Kumard15ce412019-08-28 14:20:13 +0530154 if (ignore_ppc < 0)
155 ignore_ppc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156}
157
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +0200158void acpi_processor_ppc_init(struct cpufreq_policy *policy)
Len Brown4be44fc2005-08-05 00:44:28 -0400159{
Rafael J. Wysockia1bb46c2019-10-25 02:41:40 +0200160 unsigned int cpu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Rafael J. Wysockia1bb46c2019-10-25 02:41:40 +0200162 for_each_cpu(cpu, policy->related_cpus) {
163 struct acpi_processor *pr = per_cpu(processors, cpu);
164 int ret;
Rafael J. Wysocki2d8b39a2019-10-15 19:35:20 +0200165
Rafael J. Wysockia1bb46c2019-10-25 02:41:40 +0200166 if (!pr)
167 continue;
168
169 ret = freq_qos_add_request(&policy->constraints,
170 &pr->perflib_req,
171 FREQ_QOS_MAX, INT_MAX);
172 if (ret < 0)
173 pr_err("Failed to add freq constraint for CPU%d (%d)\n",
174 cpu, ret);
175 }
Viresh Kumard15ce412019-08-28 14:20:13 +0530176}
177
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +0200178void acpi_processor_ppc_exit(struct cpufreq_policy *policy)
Viresh Kumard15ce412019-08-28 14:20:13 +0530179{
Rafael J. Wysockia1bb46c2019-10-25 02:41:40 +0200180 unsigned int cpu;
Viresh Kumard15ce412019-08-28 14:20:13 +0530181
Rafael J. Wysockia1bb46c2019-10-25 02:41:40 +0200182 for_each_cpu(cpu, policy->related_cpus) {
183 struct acpi_processor *pr = per_cpu(processors, cpu);
184
185 if (pr)
186 freq_qos_remove_request(&pr->perflib_req);
187 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188}
189
Len Brown4be44fc2005-08-05 00:44:28 -0400190static int acpi_processor_get_performance_control(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191{
Len Brown4be44fc2005-08-05 00:44:28 -0400192 int result = 0;
193 acpi_status status = 0;
194 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
195 union acpi_object *pct = NULL;
196 union acpi_object obj = { 0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
Len Brown4be44fc2005-08-05 00:44:28 -0400200 if (ACPI_FAILURE(status)) {
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100201 acpi_handle_warn(pr->handle, "_PCT evaluation failed: %s\n",
202 acpi_format_exception(status));
Patrick Mocheld550d982006-06-27 00:41:40 -0400203 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 }
205
Len Brown4be44fc2005-08-05 00:44:28 -0400206 pct = (union acpi_object *)buffer.pointer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
Len Brown4be44fc2005-08-05 00:44:28 -0400208 || (pct->package.count != 2)) {
Len Brown64684632006-06-26 23:41:38 -0400209 printk(KERN_ERR PREFIX "Invalid _PCT data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 result = -EFAULT;
211 goto end;
212 }
213
214 /*
215 * control_register
216 */
217
218 obj = pct->package.elements[0];
219
220 if ((obj.type != ACPI_TYPE_BUFFER)
Len Brown4be44fc2005-08-05 00:44:28 -0400221 || (obj.buffer.length < sizeof(struct acpi_pct_register))
222 || (obj.buffer.pointer == NULL)) {
Len Brown64684632006-06-26 23:41:38 -0400223 printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 result = -EFAULT;
225 goto end;
226 }
Len Brown4be44fc2005-08-05 00:44:28 -0400227 memcpy(&pr->performance->control_register, obj.buffer.pointer,
228 sizeof(struct acpi_pct_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
230 /*
231 * status_register
232 */
233
234 obj = pct->package.elements[1];
235
236 if ((obj.type != ACPI_TYPE_BUFFER)
Len Brown4be44fc2005-08-05 00:44:28 -0400237 || (obj.buffer.length < sizeof(struct acpi_pct_register))
238 || (obj.buffer.pointer == NULL)) {
Len Brown64684632006-06-26 23:41:38 -0400239 printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 result = -EFAULT;
241 goto end;
242 }
243
Len Brown4be44fc2005-08-05 00:44:28 -0400244 memcpy(&pr->performance->status_register, obj.buffer.pointer,
245 sizeof(struct acpi_pct_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Len Brown4be44fc2005-08-05 00:44:28 -0400247 end:
Len Brown02438d82006-06-30 03:19:10 -0400248 kfree(buffer.pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Patrick Mocheld550d982006-06-27 00:41:40 -0400250 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251}
252
Matthew Garrettf5940652012-09-04 08:28:06 +0000253#ifdef CONFIG_X86
254/*
255 * Some AMDs have 50MHz frequency multiples, but only provide 100MHz rounding
256 * in their ACPI data. Calculate the real values and fix up the _PSS data.
257 */
258static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
259{
260 u32 hi, lo, fid, did;
261 int index = px->control & 0x00000007;
262
263 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
264 return;
265
266 if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
267 || boot_cpu_data.x86 == 0x11) {
268 rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);
Stefan Bader9855d8c2013-01-22 13:37:21 +0100269 /*
270 * MSR C001_0064+:
271 * Bit 63: PstateEn. Read-write. If set, the P-state is valid.
272 */
273 if (!(hi & BIT(31)))
274 return;
275
Matthew Garrettf5940652012-09-04 08:28:06 +0000276 fid = lo & 0x3f;
277 did = (lo >> 6) & 7;
278 if (boot_cpu_data.x86 == 0x10)
279 px->core_frequency = (100 * (fid + 0x10)) >> did;
280 else
281 px->core_frequency = (100 * (fid + 8)) >> did;
282 }
283}
284#else
285static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
286#endif
287
Len Brown4be44fc2005-08-05 00:44:28 -0400288static int acpi_processor_get_performance_states(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289{
Len Brown4be44fc2005-08-05 00:44:28 -0400290 int result = 0;
291 acpi_status status = AE_OK;
292 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
293 struct acpi_buffer format = { sizeof("NNNNNN"), "NNNNNN" };
294 struct acpi_buffer state = { 0, NULL };
295 union acpi_object *pss = NULL;
296 int i;
Marco Aurelio da Costad8e725f2012-05-04 18:53:44 +0200297 int last_invalid = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
300 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
Len Brown4be44fc2005-08-05 00:44:28 -0400301 if (ACPI_FAILURE(status)) {
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100302 acpi_handle_warn(pr->handle, "_PSS evaluation failed: %s\n",
303 acpi_format_exception(status));
Patrick Mocheld550d982006-06-27 00:41:40 -0400304 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 }
306
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200307 pss = buffer.pointer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
Len Brown64684632006-06-26 23:41:38 -0400309 printk(KERN_ERR PREFIX "Invalid _PSS data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 result = -EFAULT;
311 goto end;
312 }
313
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100314 acpi_handle_debug(pr->handle, "Found %d performance states\n",
315 pss->package.count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
317 pr->performance->state_count = pss->package.count;
Len Brown4be44fc2005-08-05 00:44:28 -0400318 pr->performance->states =
Kees Cook6da2ec52018-06-12 13:55:00 -0700319 kmalloc_array(pss->package.count,
320 sizeof(struct acpi_processor_px),
321 GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 if (!pr->performance->states) {
323 result = -ENOMEM;
324 goto end;
325 }
326
327 for (i = 0; i < pr->performance->state_count; i++) {
328
329 struct acpi_processor_px *px = &(pr->performance->states[i]);
330
331 state.length = sizeof(struct acpi_processor_px);
332 state.pointer = px;
333
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100334 acpi_handle_debug(pr->handle, "Extracting state %d\n", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336 status = acpi_extract_package(&(pss->package.elements[i]),
Len Brown4be44fc2005-08-05 00:44:28 -0400337 &format, &state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 if (ACPI_FAILURE(status)) {
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100339 acpi_handle_warn(pr->handle, "Invalid _PSS data: %s\n",
340 acpi_format_exception(status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 result = -EFAULT;
342 kfree(pr->performance->states);
343 goto end;
344 }
345
Matthew Garrettf5940652012-09-04 08:28:06 +0000346 amd_fixup_frequency(px, i);
347
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100348 acpi_handle_debug(pr->handle,
Len Brown4be44fc2005-08-05 00:44:28 -0400349 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
350 i,
351 (u32) px->core_frequency,
352 (u32) px->power,
353 (u32) px->transition_latency,
354 (u32) px->bus_master_latency,
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100355 (u32) px->control, (u32) px->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
Len Brown34d531e2009-05-26 15:11:06 -0400357 /*
Maximilian Luzc6237b22020-11-05 03:06:00 +0100358 * Check that ACPI's u64 MHz will be valid as u32 KHz in cpufreq
Len Brown34d531e2009-05-26 15:11:06 -0400359 */
360 if (!px->core_frequency ||
361 ((u32)(px->core_frequency * 1000) !=
362 (px->core_frequency * 1000))) {
363 printk(KERN_ERR FW_BUG PREFIX
Marco Aurelio da Costad8e725f2012-05-04 18:53:44 +0200364 "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
365 pr->id, px->core_frequency);
366 if (last_invalid == -1)
367 last_invalid = i;
368 } else {
369 if (last_invalid != -1) {
370 /*
371 * Copy this valid entry over last_invalid entry
372 */
373 memcpy(&(pr->performance->states[last_invalid]),
374 px, sizeof(struct acpi_processor_px));
375 ++last_invalid;
376 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 }
378 }
379
Marco Aurelio da Costad8e725f2012-05-04 18:53:44 +0200380 if (last_invalid == 0) {
381 printk(KERN_ERR FW_BUG PREFIX
382 "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
383 result = -EFAULT;
384 kfree(pr->performance->states);
385 pr->performance->states = NULL;
386 }
387
388 if (last_invalid > 0)
389 pr->performance->state_count = last_invalid;
390
Len Brown4be44fc2005-08-05 00:44:28 -0400391 end:
Len Brown02438d82006-06-30 03:19:10 -0400392 kfree(buffer.pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
Patrick Mocheld550d982006-06-27 00:41:40 -0400394 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395}
396
Konrad Rzeszutek Wilkc705c782013-03-05 13:42:54 -0500397int acpi_processor_get_performance_info(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398{
Len Brown4be44fc2005-08-05 00:44:28 -0400399 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 if (!pr || !pr->performance || !pr->handle)
Patrick Mocheld550d982006-06-27 00:41:40 -0400402 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
Jiang Liu952c63e2013-06-29 00:24:38 +0800404 if (!acpi_has_method(pr->handle, "_PCT")) {
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100405 acpi_handle_debug(pr->handle,
406 "ACPI-based processor performance control unavailable\n");
Patrick Mocheld550d982006-06-27 00:41:40 -0400407 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 }
409
410 result = acpi_processor_get_performance_control(pr);
411 if (result)
Thomas Renninger910dfae2008-09-01 14:27:04 +0200412 goto update_bios;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
414 result = acpi_processor_get_performance_states(pr);
415 if (result)
Thomas Renninger910dfae2008-09-01 14:27:04 +0200416 goto update_bios;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
Darrick J. Wong455c0d72010-02-18 10:28:20 -0800418 /* We need to call _PPC once when cpufreq starts */
419 if (ignore_ppc != 1)
420 result = acpi_processor_get_platform_limit(pr);
421
422 return result;
Thomas Renninger910dfae2008-09-01 14:27:04 +0200423
424 /*
425 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
426 * the BIOS is older than the CPU and does not know its frequencies
427 */
428 update_bios:
Miao Xie16be87e2008-10-24 17:22:04 +0800429#ifdef CONFIG_X86
Jiang Liu952c63e2013-06-29 00:24:38 +0800430 if (acpi_has_method(pr->handle, "_PPC")) {
Thomas Renninger910dfae2008-09-01 14:27:04 +0200431 if(boot_cpu_has(X86_FEATURE_EST))
432 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
433 "frequency support\n");
434 }
Miao Xie16be87e2008-10-24 17:22:04 +0800435#endif
Thomas Renninger910dfae2008-09-01 14:27:04 +0200436 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437}
Konrad Rzeszutek Wilkc705c782013-03-05 13:42:54 -0500438EXPORT_SYMBOL_GPL(acpi_processor_get_performance_info);
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100439
440int acpi_processor_pstate_control(void)
Len Brown4be44fc2005-08-05 00:44:28 -0400441{
442 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100444 if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)
445 return 0;
446
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100447 pr_debug("Writing pstate_control [0x%x] to smi_command [0x%x]\n",
448 acpi_gbl_FADT.pstate_control, acpi_gbl_FADT.smi_command);
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100449
450 status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
451 (u32)acpi_gbl_FADT.pstate_control, 8);
452 if (ACPI_SUCCESS(status))
453 return 1;
454
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100455 pr_warn("Failed to write pstate_control [0x%x] to smi_command [0x%x]: %s\n",
456 acpi_gbl_FADT.pstate_control, acpi_gbl_FADT.smi_command,
457 acpi_format_exception(status));
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100458 return -EIO;
459}
460
461int acpi_processor_notify_smm(struct module *calling_module)
462{
Tian Tao41103b32021-02-23 08:56:29 +0800463 static int is_done;
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100464 int result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
Viresh Kumard15ce412019-08-28 14:20:13 +0530466 if (!acpi_processor_cpufreq_init)
Patrick Mocheld550d982006-06-27 00:41:40 -0400467 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
469 if (!try_module_get(calling_module))
Patrick Mocheld550d982006-06-27 00:41:40 -0400470 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Lucas De Marchi58f87ed2010-09-07 12:49:45 -0400472 /* is_done is set to negative if an error occurred,
473 * and to postitive if _no_ error occurred, but SMM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 * was already notified. This avoids double notification
475 * which might lead to unexpected results...
476 */
477 if (is_done > 0) {
478 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400479 return 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400480 } else if (is_done < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400482 return is_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 }
484
485 is_done = -EIO;
486
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100487 result = acpi_processor_pstate_control();
488 if (!result) {
Rafael J. Wysocki52af99c2021-02-22 19:59:13 +0100489 pr_debug("No SMI port or pstate_control\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400491 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 }
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100493 if (result < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 module_put(calling_module);
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100495 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 }
497
498 /* Success. If there's no _PPC, we need to fear nothing, so
499 * we can allow the cpufreq driver to be rmmod'ed. */
500 is_done = 1;
501
Viresh Kumard15ce412019-08-28 14:20:13 +0530502 if (!acpi_processor_ppc_in_use)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 module_put(calling_module);
504
Patrick Mocheld550d982006-06-27 00:41:40 -0400505 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
Len Brown4be44fc2005-08-05 00:44:28 -0400508EXPORT_SYMBOL(acpi_processor_notify_smm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000510int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500511{
512 int result = 0;
513 acpi_status status = AE_OK;
514 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
515 struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
516 struct acpi_buffer state = {0, NULL};
517 union acpi_object *psd = NULL;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500518
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000519 status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500520 if (ACPI_FAILURE(status)) {
Len Brown9011bff42006-05-11 00:28:12 -0400521 return -ENODEV;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500522 }
523
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200524 psd = buffer.pointer;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500525 if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800526 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500527 result = -EFAULT;
528 goto end;
529 }
530
531 if (psd->package.count != 1) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800532 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500533 result = -EFAULT;
534 goto end;
535 }
536
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500537 state.length = sizeof(struct acpi_psd_package);
538 state.pointer = pdomain;
539
540 status = acpi_extract_package(&(psd->package.elements[0]),
541 &format, &state);
542 if (ACPI_FAILURE(status)) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800543 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500544 result = -EFAULT;
545 goto end;
546 }
547
548 if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800549 printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500550 result = -EFAULT;
551 goto end;
552 }
553
554 if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800555 printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500556 result = -EFAULT;
557 goto end;
558 }
559
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100560 if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL &&
561 pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ANY &&
562 pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) {
563 printk(KERN_ERR PREFIX "Invalid _PSD:coord_type\n");
564 result = -EFAULT;
565 goto end;
566 }
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500567end:
Len Brown02438d82006-06-30 03:19:10 -0400568 kfree(buffer.pointer);
Len Brown9011bff42006-05-11 00:28:12 -0400569 return result;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500570}
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000571EXPORT_SYMBOL(acpi_processor_get_psd);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500572
573int acpi_processor_preregister_performance(
Tejun Heoa29d8b82010-02-02 14:39:15 +0900574 struct acpi_processor_performance __percpu *performance)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500575{
Lan Tianyu09d5ca82013-06-25 10:06:45 +0800576 int count_target;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500577 int retval = 0;
578 unsigned int i, j;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800579 cpumask_var_t covered_cpus;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500580 struct acpi_processor *pr;
581 struct acpi_psd_package *pdomain;
582 struct acpi_processor *match_pr;
583 struct acpi_psd_package *match_pdomain;
584
Li Zefan79f55992009-06-15 14:58:26 +0800585 if (!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800586 return -ENOMEM;
587
Len Brown785fccc2006-06-15 22:19:31 -0400588 mutex_lock(&performance_mutex);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500589
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100590 /*
591 * Check if another driver has already registered, and abort before
592 * changing pr->performance if it has. Check input data as well.
593 */
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400594 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700595 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500596 if (!pr) {
597 /* Look only at processors in ACPI namespace */
598 continue;
599 }
600
601 if (pr->performance) {
602 retval = -EBUSY;
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100603 goto err_out;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500604 }
605
Rusty Russellb36128c2009-02-20 16:29:08 +0900606 if (!performance || !per_cpu_ptr(performance, i)) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500607 retval = -EINVAL;
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100608 goto err_out;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500609 }
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100610 }
611
612 /* Call _PSD for all CPUs */
613 for_each_possible_cpu(i) {
614 pr = per_cpu(processors, i);
615 if (!pr)
616 continue;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500617
Rusty Russellb36128c2009-02-20 16:29:08 +0900618 pr->performance = per_cpu_ptr(performance, i);
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000619 pdomain = &(pr->performance->domain_info);
620 if (acpi_processor_get_psd(pr->handle, pdomain)) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500621 retval = -EINVAL;
622 continue;
623 }
624 }
625 if (retval)
626 goto err_ret;
627
628 /*
Maximilian Luzc6237b22020-11-05 03:06:00 +0100629 * Now that we have _PSD data from all CPUs, lets setup P-state
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500630 * domain info.
631 */
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400632 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700633 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500634 if (!pr)
635 continue;
636
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800637 if (cpumask_test_cpu(i, covered_cpus))
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500638 continue;
639
640 pdomain = &(pr->performance->domain_info);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800641 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
642 cpumask_set_cpu(i, covered_cpus);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500643 if (pdomain->num_processors <= 1)
644 continue;
645
646 /* Validate the Domain info */
647 count_target = pdomain->num_processors;
Venkatesh Pallipadi46f18e32006-06-26 00:34:43 -0400648 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500649 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
Venkatesh Pallipadi46f18e32006-06-26 00:34:43 -0400650 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
651 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW;
652 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500653 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500654
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400655 for_each_possible_cpu(j) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500656 if (i == j)
657 continue;
658
Mike Travis706546d2008-06-09 16:22:23 -0700659 match_pr = per_cpu(processors, j);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500660 if (!match_pr)
661 continue;
662
663 match_pdomain = &(match_pr->performance->domain_info);
664 if (match_pdomain->domain != pdomain->domain)
665 continue;
666
667 /* Here i and j are in the same domain */
668
669 if (match_pdomain->num_processors != count_target) {
670 retval = -EINVAL;
671 goto err_ret;
672 }
673
674 if (pdomain->coord_type != match_pdomain->coord_type) {
675 retval = -EINVAL;
676 goto err_ret;
677 }
678
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800679 cpumask_set_cpu(j, covered_cpus);
680 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500681 }
682
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400683 for_each_possible_cpu(j) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500684 if (i == j)
685 continue;
686
Mike Travis706546d2008-06-09 16:22:23 -0700687 match_pr = per_cpu(processors, j);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500688 if (!match_pr)
689 continue;
690
691 match_pdomain = &(match_pr->performance->domain_info);
692 if (match_pdomain->domain != pdomain->domain)
693 continue;
694
Maximilian Luzc6237b22020-11-05 03:06:00 +0100695 match_pr->performance->shared_type =
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500696 pr->performance->shared_type;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800697 cpumask_copy(match_pr->performance->shared_cpu_map,
698 pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500699 }
700 }
701
702err_ret:
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400703 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700704 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500705 if (!pr || !pr->performance)
706 continue;
707
708 /* Assume no coordination on any error parsing domain info */
709 if (retval) {
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800710 cpumask_clear(pr->performance->shared_cpu_map);
711 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
Ionela Voinescubca3e432020-12-14 12:07:40 +0000712 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_NONE;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500713 }
714 pr->performance = NULL; /* Will be set for real in register */
715 }
716
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100717err_out:
Len Brown785fccc2006-06-15 22:19:31 -0400718 mutex_unlock(&performance_mutex);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800719 free_cpumask_var(covered_cpus);
Len Brown9011bff42006-05-11 00:28:12 -0400720 return retval;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500721}
722EXPORT_SYMBOL(acpi_processor_preregister_performance);
723
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724int
Len Brown4be44fc2005-08-05 00:44:28 -0400725acpi_processor_register_performance(struct acpi_processor_performance
726 *performance, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727{
728 struct acpi_processor *pr;
729
Viresh Kumard15ce412019-08-28 14:20:13 +0530730 if (!acpi_processor_cpufreq_init)
Patrick Mocheld550d982006-06-27 00:41:40 -0400731 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400733 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734
Mike Travis706546d2008-06-09 16:22:23 -0700735 pr = per_cpu(processors, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 if (!pr) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400737 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400738 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 }
740
741 if (pr->performance) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400742 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400743 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 }
745
Andrew Mortona913f502006-06-10 09:54:13 -0700746 WARN_ON(!performance);
747
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 pr->performance = performance;
749
750 if (acpi_processor_get_performance_info(pr)) {
751 pr->performance = NULL;
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400752 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400753 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 }
755
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400756 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400757 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758}
Len Brown4be44fc2005-08-05 00:44:28 -0400759
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760EXPORT_SYMBOL(acpi_processor_register_performance);
761
Rafael J. Wysockib2f8dc42015-07-22 22:11:16 +0200762void acpi_processor_unregister_performance(unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763{
764 struct acpi_processor *pr;
765
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400766 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767
Mike Travis706546d2008-06-09 16:22:23 -0700768 pr = per_cpu(processors, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 if (!pr) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400770 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400771 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 }
773
Andrew Mortona913f502006-06-10 09:54:13 -0700774 if (pr->performance)
775 kfree(pr->performance->states);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 pr->performance = NULL;
777
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400778 mutex_unlock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779
Patrick Mocheld550d982006-06-27 00:41:40 -0400780 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781}
Len Brown4be44fc2005-08-05 00:44:28 -0400782
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783EXPORT_SYMBOL(acpi_processor_unregister_performance);