blob: ee87cb6f6e5944f2cc843d1b9b56600d7edde6e6 [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_CLASS "processor"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
27#define _COMPONENT ACPI_PROCESSOR_COMPONENT
Len Brownf52fd662007-02-12 22:42:12 -050028ACPI_MODULE_NAME("processor_perflib");
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Arjan van de Ven65c19bb2006-04-27 05:25:00 -040030static DEFINE_MUTEX(performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32/*
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.
37 *
38 * Also, when a new platform limit value is detected, the CPUfreq
39 * policy is adjusted accordingly.
40 */
41
Thomas Renningera1531ac2008-07-29 22:32:58 -070042/* 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
47 */
Milan Broz9f497bc2008-08-12 17:48:27 +020048static int ignore_ppc = -1;
Milan Broz613e5f32008-08-16 02:11:28 +020049module_param(ignore_ppc, int, 0644);
Thomas Renninger623b78c2007-05-18 21:59:28 -050050MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \
51 "limited by BIOS, this should help");
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#define PPC_REGISTERED 1
54#define PPC_IN_USE 2
55
Thomas Renningera1531ac2008-07-29 22:32:58 -070056static int acpi_processor_ppc_status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58static int acpi_processor_ppc_notifier(struct notifier_block *nb,
Len Brown4be44fc2005-08-05 00:44:28 -040059 unsigned long event, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
61 struct cpufreq_policy *policy = data;
62 struct acpi_processor *pr;
63 unsigned int ppc = 0;
64
Viresh Kumarfa29ae52017-01-30 09:59:57 +053065 if (ignore_ppc < 0)
Thomas Renningera1531ac2008-07-29 22:32:58 -070066 ignore_ppc = 0;
Thomas Renningera1531ac2008-07-29 22:32:58 -070067
Thomas Renninger623b78c2007-05-18 21:59:28 -050068 if (ignore_ppc)
69 return 0;
70
Viresh Kumar6bfb7c72015-08-03 08:36:14 +053071 if (event != CPUFREQ_ADJUST)
Thomas Renninger9b67c5d2008-07-29 22:32:59 -070072 return 0;
73
74 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Mike Travis706546d2008-06-09 16:22:23 -070076 pr = per_cpu(processors, policy->cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 if (!pr || !pr->performance)
78 goto out;
79
Len Brown4be44fc2005-08-05 00:44:28 -040080 ppc = (unsigned int)pr->performance_platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Dave Jones0916bd32006-11-22 20:42:01 -050082 if (ppc >= pr->performance->state_count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 goto out;
84
85 cpufreq_verify_within_limits(policy, 0,
Len Brown4be44fc2005-08-05 00:44:28 -040086 pr->performance->states[ppc].
87 core_frequency * 1000);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Len Brown4be44fc2005-08-05 00:44:28 -040089 out:
Arjan van de Ven65c19bb2006-04-27 05:25:00 -040090 mutex_unlock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92 return 0;
93}
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095static struct notifier_block acpi_ppc_notifier_block = {
96 .notifier_call = acpi_processor_ppc_notifier,
97};
98
Len Brown4be44fc2005-08-05 00:44:28 -040099static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Len Brown4be44fc2005-08-05 00:44:28 -0400101 acpi_status status = 0;
Matthew Wilcox27663c52008-10-10 02:22:59 -0400102 unsigned long long ppc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400106 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108 /*
109 * _PPC indicates the maximum state currently supported by the platform
110 * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
111 */
112 status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
113
114 if (status != AE_NOT_FOUND)
115 acpi_processor_ppc_status |= PPC_IN_USE;
116
Len Brown4be44fc2005-08-05 00:44:28 -0400117 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400118 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400119 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 }
121
Dominik Brodowski2d06d8c2011-03-27 15:04:46 +0200122 pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
Thomas Renninger919158d2007-10-31 15:41:42 +0100123 (int)ppc, ppc ? "" : "not");
124
Len Brown4be44fc2005-08-05 00:44:28 -0400125 pr->performance_platform_limit = (int)ppc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Patrick Mocheld550d982006-06-27 00:41:40 -0400127 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800130#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
131/*
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
137 */
138static void acpi_processor_ppc_ost(acpi_handle handle, int status)
139{
Jiang Liu4a6172a2014-02-19 14:02:18 +0800140 if (acpi_has_method(handle, "_OST"))
141 acpi_evaluate_ost(handle, ACPI_PROCESSOR_NOTIFY_PERFORMANCE,
142 status, NULL);
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800143}
144
Rafael J. Wysockibca5f552016-11-18 13:57:54 +0100145void acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146{
Thomas Renninger623b78c2007-05-18 21:59:28 -0500147 int ret;
148
Chen Yuba1edb92018-01-29 10:26:46 +0800149 if (ignore_ppc || !pr->performance) {
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800150 /*
151 * Only when it is notification event, the _OST object
152 * will be evaluated. Otherwise it is skipped.
153 */
154 if (event_flag)
155 acpi_processor_ppc_ost(pr->handle, 1);
Rafael J. Wysockibca5f552016-11-18 13:57:54 +0100156 return;
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800157 }
Thomas Renninger623b78c2007-05-18 21:59:28 -0500158
159 ret = acpi_processor_get_platform_limit(pr);
Zhao Yakuid81c45e12009-10-16 09:20:41 +0800160 /*
161 * Only when it is notification event, the _OST object
162 * will be evaluated. Otherwise it is skipped.
163 */
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);
169 }
Rafael J. Wysockibca5f552016-11-18 13:57:54 +0100170 if (ret >= 0)
Rafael J. Wysocki5a25e3f2019-03-26 12:15:13 +0100171 cpufreq_update_limits(pr->id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172}
173
Thomas Renningere2f74f32009-11-19 12:31:01 +0100174int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
175{
176 struct acpi_processor *pr;
177
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;
184}
185EXPORT_SYMBOL(acpi_processor_get_bios_limit);
186
Len Brown4be44fc2005-08-05 00:44:28 -0400187void acpi_processor_ppc_init(void)
188{
189 if (!cpufreq_register_notifier
190 (&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 acpi_processor_ppc_status |= PPC_REGISTERED;
192 else
Len Brown4be44fc2005-08-05 00:44:28 -0400193 printk(KERN_DEBUG
194 "Warning: Processor Platform Limit not supported.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195}
196
Len Brown4be44fc2005-08-05 00:44:28 -0400197void acpi_processor_ppc_exit(void)
198{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 if (acpi_processor_ppc_status & PPC_REGISTERED)
Len Brown4be44fc2005-08-05 00:44:28 -0400200 cpufreq_unregister_notifier(&acpi_ppc_notifier_block,
201 CPUFREQ_POLICY_NOTIFIER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203 acpi_processor_ppc_status &= ~PPC_REGISTERED;
204}
205
Len Brown4be44fc2005-08-05 00:44:28 -0400206static int acpi_processor_get_performance_control(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207{
Len Brown4be44fc2005-08-05 00:44:28 -0400208 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 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
Len Brown4be44fc2005-08-05 00:44:28 -0400216 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400217 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400218 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 }
220
Len Brown4be44fc2005-08-05 00:44:28 -0400221 pct = (union acpi_object *)buffer.pointer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
Len Brown4be44fc2005-08-05 00:44:28 -0400223 || (pct->package.count != 2)) {
Len Brown64684632006-06-26 23:41:38 -0400224 printk(KERN_ERR PREFIX "Invalid _PCT data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 result = -EFAULT;
226 goto end;
227 }
228
229 /*
230 * control_register
231 */
232
233 obj = pct->package.elements[0];
234
235 if ((obj.type != ACPI_TYPE_BUFFER)
Len Brown4be44fc2005-08-05 00:44:28 -0400236 || (obj.buffer.length < sizeof(struct acpi_pct_register))
237 || (obj.buffer.pointer == NULL)) {
Len Brown64684632006-06-26 23:41:38 -0400238 printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 result = -EFAULT;
240 goto end;
241 }
Len Brown4be44fc2005-08-05 00:44:28 -0400242 memcpy(&pr->performance->control_register, obj.buffer.pointer,
243 sizeof(struct acpi_pct_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
245 /*
246 * status_register
247 */
248
249 obj = pct->package.elements[1];
250
251 if ((obj.type != ACPI_TYPE_BUFFER)
Len Brown4be44fc2005-08-05 00:44:28 -0400252 || (obj.buffer.length < sizeof(struct acpi_pct_register))
253 || (obj.buffer.pointer == NULL)) {
Len Brown64684632006-06-26 23:41:38 -0400254 printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 result = -EFAULT;
256 goto end;
257 }
258
Len Brown4be44fc2005-08-05 00:44:28 -0400259 memcpy(&pr->performance->status_register, obj.buffer.pointer,
260 sizeof(struct acpi_pct_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Len Brown4be44fc2005-08-05 00:44:28 -0400262 end:
Len Brown02438d82006-06-30 03:19:10 -0400263 kfree(buffer.pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
Patrick Mocheld550d982006-06-27 00:41:40 -0400265 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266}
267
Matthew Garrettf5940652012-09-04 08:28:06 +0000268#ifdef CONFIG_X86
269/*
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.
272 */
273static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
274{
275 u32 hi, lo, fid, did;
276 int index = px->control & 0x00000007;
277
278 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
279 return;
280
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);
Stefan Bader9855d8c2013-01-22 13:37:21 +0100284 /*
285 * MSR C001_0064+:
286 * Bit 63: PstateEn. Read-write. If set, the P-state is valid.
287 */
288 if (!(hi & BIT(31)))
289 return;
290
Matthew Garrettf5940652012-09-04 08:28:06 +0000291 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;
297 }
298}
299#else
300static void amd_fixup_frequency(struct acpi_processor_px *px, int i) {};
301#endif
302
Len Brown4be44fc2005-08-05 00:44:28 -0400303static int acpi_processor_get_performance_states(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304{
Len Brown4be44fc2005-08-05 00:44:28 -0400305 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;
Marco Aurelio da Costad8e725f2012-05-04 18:53:44 +0200312 int last_invalid = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
Len Brown4be44fc2005-08-05 00:44:28 -0400316 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400317 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400318 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 }
320
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200321 pss = buffer.pointer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
Len Brown64684632006-06-26 23:41:38 -0400323 printk(KERN_ERR PREFIX "Invalid _PSS data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 result = -EFAULT;
325 goto end;
326 }
327
328 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400329 pss->package.count));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
331 pr->performance->state_count = pss->package.count;
Len Brown4be44fc2005-08-05 00:44:28 -0400332 pr->performance->states =
Kees Cook6da2ec52018-06-12 13:55:00 -0700333 kmalloc_array(pss->package.count,
334 sizeof(struct acpi_processor_px),
335 GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 if (!pr->performance->states) {
337 result = -ENOMEM;
338 goto end;
339 }
340
341 for (i = 0; i < pr->performance->state_count; i++) {
342
343 struct acpi_processor_px *px = &(pr->performance->states[i]);
344
345 state.length = sizeof(struct acpi_processor_px);
346 state.pointer = px;
347
348 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
349
350 status = acpi_extract_package(&(pss->package.elements[i]),
Len Brown4be44fc2005-08-05 00:44:28 -0400351 &format, &state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400353 ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 result = -EFAULT;
355 kfree(pr->performance->states);
356 goto end;
357 }
358
Matthew Garrettf5940652012-09-04 08:28:06 +0000359 amd_fixup_frequency(px, i);
360
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400362 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
363 i,
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));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
Len Brown34d531e2009-05-26 15:11:06 -0400370 /*
371 * Check that ACPI's u64 MHz will be valid as u32 KHz in cpufreq
372 */
373 if (!px->core_frequency ||
374 ((u32)(px->core_frequency * 1000) !=
375 (px->core_frequency * 1000))) {
376 printk(KERN_ERR FW_BUG PREFIX
Marco Aurelio da Costad8e725f2012-05-04 18:53:44 +0200377 "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) {
383 /*
384 * Copy this valid entry over last_invalid entry
385 */
386 memcpy(&(pr->performance->states[last_invalid]),
387 px, sizeof(struct acpi_processor_px));
388 ++last_invalid;
389 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 }
391 }
392
Marco Aurelio da Costad8e725f2012-05-04 18:53:44 +0200393 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;
399 }
400
401 if (last_invalid > 0)
402 pr->performance->state_count = last_invalid;
403
Len Brown4be44fc2005-08-05 00:44:28 -0400404 end:
Len Brown02438d82006-06-30 03:19:10 -0400405 kfree(buffer.pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
Patrick Mocheld550d982006-06-27 00:41:40 -0400407 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408}
409
Konrad Rzeszutek Wilkc705c782013-03-05 13:42:54 -0500410int acpi_processor_get_performance_info(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
Len Brown4be44fc2005-08-05 00:44:28 -0400412 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 if (!pr || !pr->performance || !pr->handle)
Patrick Mocheld550d982006-06-27 00:41:40 -0400415 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Jiang Liu952c63e2013-06-29 00:24:38 +0800417 if (!acpi_has_method(pr->handle, "_PCT")) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400419 "ACPI-based processor performance control unavailable\n"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400420 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 }
422
423 result = acpi_processor_get_performance_control(pr);
424 if (result)
Thomas Renninger910dfae2008-09-01 14:27:04 +0200425 goto update_bios;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
427 result = acpi_processor_get_performance_states(pr);
428 if (result)
Thomas Renninger910dfae2008-09-01 14:27:04 +0200429 goto update_bios;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
Darrick J. Wong455c0d72010-02-18 10:28:20 -0800431 /* We need to call _PPC once when cpufreq starts */
432 if (ignore_ppc != 1)
433 result = acpi_processor_get_platform_limit(pr);
434
435 return result;
Thomas Renninger910dfae2008-09-01 14:27:04 +0200436
437 /*
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
440 */
441 update_bios:
Miao Xie16be87e2008-10-24 17:22:04 +0800442#ifdef CONFIG_X86
Jiang Liu952c63e2013-06-29 00:24:38 +0800443 if (acpi_has_method(pr->handle, "_PPC")) {
Thomas Renninger910dfae2008-09-01 14:27:04 +0200444 if(boot_cpu_has(X86_FEATURE_EST))
445 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
446 "frequency support\n");
447 }
Miao Xie16be87e2008-10-24 17:22:04 +0800448#endif
Thomas Renninger910dfae2008-09-01 14:27:04 +0200449 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450}
Konrad Rzeszutek Wilkc705c782013-03-05 13:42:54 -0500451EXPORT_SYMBOL_GPL(acpi_processor_get_performance_info);
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100452
453int acpi_processor_pstate_control(void)
Len Brown4be44fc2005-08-05 00:44:28 -0400454{
455 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100457 if (!acpi_gbl_FADT.smi_command || !acpi_gbl_FADT.pstate_control)
458 return 0;
459
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));
463
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;
468
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;
473}
474
475int acpi_processor_notify_smm(struct module *calling_module)
476{
477 static int is_done = 0;
478 int result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
Patrick Mocheld550d982006-06-27 00:41:40 -0400481 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
483 if (!try_module_get(calling_module))
Patrick Mocheld550d982006-06-27 00:41:40 -0400484 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Lucas De Marchi58f87ed2010-09-07 12:49:45 -0400486 /* is_done is set to negative if an error occurred,
487 * and to postitive if _no_ error occurred, but SMM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 * was already notified. This avoids double notification
489 * which might lead to unexpected results...
490 */
491 if (is_done > 0) {
492 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400493 return 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400494 } else if (is_done < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400496 return is_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 }
498
499 is_done = -EIO;
500
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100501 result = acpi_processor_pstate_control();
502 if (!result) {
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300503 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_control\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400505 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 }
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100507 if (result < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 module_put(calling_module);
Rafael J. Wysockid0ea59e2016-11-17 22:47:47 +0100509 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 }
511
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;
515
516 if (!(acpi_processor_ppc_status & PPC_IN_USE))
517 module_put(calling_module);
518
Patrick Mocheld550d982006-06-27 00:41:40 -0400519 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Len Brown4be44fc2005-08-05 00:44:28 -0400522EXPORT_SYMBOL(acpi_processor_notify_smm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000524int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500525{
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;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500532
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000533 status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500534 if (ACPI_FAILURE(status)) {
Len Brown9011bff42006-05-11 00:28:12 -0400535 return -ENODEV;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500536 }
537
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200538 psd = buffer.pointer;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500539 if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800540 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500541 result = -EFAULT;
542 goto end;
543 }
544
545 if (psd->package.count != 1) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800546 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500547 result = -EFAULT;
548 goto end;
549 }
550
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500551 state.length = sizeof(struct acpi_psd_package);
552 state.pointer = pdomain;
553
554 status = acpi_extract_package(&(psd->package.elements[0]),
555 &format, &state);
556 if (ACPI_FAILURE(status)) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800557 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500558 result = -EFAULT;
559 goto end;
560 }
561
562 if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800563 printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500564 result = -EFAULT;
565 goto end;
566 }
567
568 if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800569 printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500570 result = -EFAULT;
571 goto end;
572 }
573
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100574 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;
580 }
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500581end:
Len Brown02438d82006-06-30 03:19:10 -0400582 kfree(buffer.pointer);
Len Brown9011bff42006-05-11 00:28:12 -0400583 return result;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500584}
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000585EXPORT_SYMBOL(acpi_processor_get_psd);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500586
587int acpi_processor_preregister_performance(
Tejun Heoa29d8b82010-02-02 14:39:15 +0900588 struct acpi_processor_performance __percpu *performance)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500589{
Lan Tianyu09d5ca82013-06-25 10:06:45 +0800590 int count_target;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500591 int retval = 0;
592 unsigned int i, j;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800593 cpumask_var_t covered_cpus;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500594 struct acpi_processor *pr;
595 struct acpi_psd_package *pdomain;
596 struct acpi_processor *match_pr;
597 struct acpi_psd_package *match_pdomain;
598
Li Zefan79f55992009-06-15 14:58:26 +0800599 if (!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800600 return -ENOMEM;
601
Len Brown785fccc2006-06-15 22:19:31 -0400602 mutex_lock(&performance_mutex);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500603
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100604 /*
605 * Check if another driver has already registered, and abort before
606 * changing pr->performance if it has. Check input data as well.
607 */
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400608 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700609 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500610 if (!pr) {
611 /* Look only at processors in ACPI namespace */
612 continue;
613 }
614
615 if (pr->performance) {
616 retval = -EBUSY;
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100617 goto err_out;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500618 }
619
Rusty Russellb36128c2009-02-20 16:29:08 +0900620 if (!performance || !per_cpu_ptr(performance, i)) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500621 retval = -EINVAL;
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100622 goto err_out;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500623 }
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100624 }
625
626 /* Call _PSD for all CPUs */
627 for_each_possible_cpu(i) {
628 pr = per_cpu(processors, i);
629 if (!pr)
630 continue;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500631
Rusty Russellb36128c2009-02-20 16:29:08 +0900632 pr->performance = per_cpu_ptr(performance, i);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800633 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
Joao Martins4d0f1ce2018-03-15 14:22:05 +0000634 pdomain = &(pr->performance->domain_info);
635 if (acpi_processor_get_psd(pr->handle, pdomain)) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500636 retval = -EINVAL;
637 continue;
638 }
639 }
640 if (retval)
641 goto err_ret;
642
643 /*
644 * Now that we have _PSD data from all CPUs, lets setup P-state
645 * domain info.
646 */
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400647 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700648 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500649 if (!pr)
650 continue;
651
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800652 if (cpumask_test_cpu(i, covered_cpus))
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500653 continue;
654
655 pdomain = &(pr->performance->domain_info);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800656 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
657 cpumask_set_cpu(i, covered_cpus);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500658 if (pdomain->num_processors <= 1)
659 continue;
660
661 /* Validate the Domain info */
662 count_target = pdomain->num_processors;
Venkatesh Pallipadi46f18e32006-06-26 00:34:43 -0400663 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500664 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
Venkatesh Pallipadi46f18e32006-06-26 00:34:43 -0400665 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)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500668 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500669
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400670 for_each_possible_cpu(j) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500671 if (i == j)
672 continue;
673
Mike Travis706546d2008-06-09 16:22:23 -0700674 match_pr = per_cpu(processors, j);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500675 if (!match_pr)
676 continue;
677
678 match_pdomain = &(match_pr->performance->domain_info);
679 if (match_pdomain->domain != pdomain->domain)
680 continue;
681
682 /* Here i and j are in the same domain */
683
684 if (match_pdomain->num_processors != count_target) {
685 retval = -EINVAL;
686 goto err_ret;
687 }
688
689 if (pdomain->coord_type != match_pdomain->coord_type) {
690 retval = -EINVAL;
691 goto err_ret;
692 }
693
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800694 cpumask_set_cpu(j, covered_cpus);
695 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500696 }
697
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400698 for_each_possible_cpu(j) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500699 if (i == j)
700 continue;
701
Mike Travis706546d2008-06-09 16:22:23 -0700702 match_pr = per_cpu(processors, j);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500703 if (!match_pr)
704 continue;
705
706 match_pdomain = &(match_pr->performance->domain_info);
707 if (match_pdomain->domain != pdomain->domain)
708 continue;
709
710 match_pr->performance->shared_type =
711 pr->performance->shared_type;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800712 cpumask_copy(match_pr->performance->shared_cpu_map,
713 pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500714 }
715 }
716
717err_ret:
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400718 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700719 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500720 if (!pr || !pr->performance)
721 continue;
722
723 /* Assume no coordination on any error parsing domain info */
724 if (retval) {
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800725 cpumask_clear(pr->performance->shared_cpu_map);
726 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500727 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
728 }
729 pr->performance = NULL; /* Will be set for real in register */
730 }
731
Stanislaw Gruszkae1eb4772009-03-24 13:41:59 +0100732err_out:
Len Brown785fccc2006-06-15 22:19:31 -0400733 mutex_unlock(&performance_mutex);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800734 free_cpumask_var(covered_cpus);
Len Brown9011bff42006-05-11 00:28:12 -0400735 return retval;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500736}
737EXPORT_SYMBOL(acpi_processor_preregister_performance);
738
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739int
Len Brown4be44fc2005-08-05 00:44:28 -0400740acpi_processor_register_performance(struct acpi_processor_performance
741 *performance, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742{
743 struct acpi_processor *pr;
744
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
Patrick Mocheld550d982006-06-27 00:41:40 -0400746 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400748 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749
Mike Travis706546d2008-06-09 16:22:23 -0700750 pr = per_cpu(processors, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 if (!pr) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400752 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400753 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 }
755
756 if (pr->performance) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400757 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400758 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 }
760
Andrew Mortona913f502006-06-10 09:54:13 -0700761 WARN_ON(!performance);
762
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 pr->performance = performance;
764
765 if (acpi_processor_get_performance_info(pr)) {
766 pr->performance = NULL;
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400767 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400768 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 }
770
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400771 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400772 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773}
Len Brown4be44fc2005-08-05 00:44:28 -0400774
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775EXPORT_SYMBOL(acpi_processor_register_performance);
776
Rafael J. Wysockib2f8dc42015-07-22 22:11:16 +0200777void acpi_processor_unregister_performance(unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778{
779 struct acpi_processor *pr;
780
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400781 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
Mike Travis706546d2008-06-09 16:22:23 -0700783 pr = per_cpu(processors, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 if (!pr) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400785 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400786 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 }
788
Andrew Mortona913f502006-06-10 09:54:13 -0700789 if (pr->performance)
790 kfree(pr->performance->states);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 pr->performance = NULL;
792
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400793 mutex_unlock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794
Patrick Mocheld550d982006-06-27 00:41:40 -0400795 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796}
Len Brown4be44fc2005-08-05 00:44:28 -0400797
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798EXPORT_SYMBOL(acpi_processor_unregister_performance);