blob: 846e227592d48770787672223a4c37c37ec6468c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * processor_perflib.c - ACPI Processor P-States Library ($Revision: 71 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support
9 *
10 *
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or (at
16 * your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 *
27 */
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/cpufreq.h>
33
34#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
35#include <linux/proc_fs.h>
36#include <linux/seq_file.h>
Arjan van de Ven65c19bb2006-04-27 05:25:00 -040037#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#include <asm/uaccess.h>
40#endif
Miao Xie16be87e2008-10-24 17:22:04 +080041
42#ifdef CONFIG_X86
Thomas Renninger910dfae2008-09-01 14:27:04 +020043#include <asm/cpufeature.h>
Miao Xie16be87e2008-10-24 17:22:04 +080044#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46#include <acpi/acpi_bus.h>
Bjorn Helgaas89595b82008-11-07 16:57:45 -070047#include <acpi/acpi_drivers.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <acpi/processor.h>
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#define ACPI_PROCESSOR_CLASS "processor"
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
52#define _COMPONENT ACPI_PROCESSOR_COMPONENT
Len Brownf52fd662007-02-12 22:42:12 -050053ACPI_MODULE_NAME("processor_perflib");
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Arjan van de Ven65c19bb2006-04-27 05:25:00 -040055static DEFINE_MUTEX(performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Thomas Renninger919158d2007-10-31 15:41:42 +010057/* Use cpufreq debug layer for _PPC changes. */
58#define cpufreq_printk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
59 "cpufreq-core", msg)
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061/*
62 * _PPC support is implemented as a CPUfreq policy notifier:
63 * This means each time a CPUfreq driver registered also with
64 * the ACPI core is asked to change the speed policy, the maximum
65 * value is adjusted so that it is within the platform limit.
66 *
67 * Also, when a new platform limit value is detected, the CPUfreq
68 * policy is adjusted accordingly.
69 */
70
Thomas Renningera1531ac2008-07-29 22:32:58 -070071/* ignore_ppc:
72 * -1 -> cpufreq low level drivers not initialized -> _PSS, etc. not called yet
73 * ignore _PPC
74 * 0 -> cpufreq low level drivers initialized -> consider _PPC values
75 * 1 -> ignore _PPC totally -> forced by user through boot param
76 */
Milan Broz9f497bc2008-08-12 17:48:27 +020077static int ignore_ppc = -1;
Milan Broz613e5f32008-08-16 02:11:28 +020078module_param(ignore_ppc, int, 0644);
Thomas Renninger623b78c2007-05-18 21:59:28 -050079MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \
80 "limited by BIOS, this should help");
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#define PPC_REGISTERED 1
83#define PPC_IN_USE 2
84
Thomas Renningera1531ac2008-07-29 22:32:58 -070085static int acpi_processor_ppc_status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87static int acpi_processor_ppc_notifier(struct notifier_block *nb,
Len Brown4be44fc2005-08-05 00:44:28 -040088 unsigned long event, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
90 struct cpufreq_policy *policy = data;
91 struct acpi_processor *pr;
92 unsigned int ppc = 0;
93
Thomas Renningera1531ac2008-07-29 22:32:58 -070094 if (event == CPUFREQ_START && ignore_ppc <= 0) {
95 ignore_ppc = 0;
96 return 0;
97 }
98
Thomas Renninger623b78c2007-05-18 21:59:28 -050099 if (ignore_ppc)
100 return 0;
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 if (event != CPUFREQ_INCOMPATIBLE)
Thomas Renninger9b67c5d2008-07-29 22:32:59 -0700103 return 0;
104
105 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Mike Travis706546d2008-06-09 16:22:23 -0700107 pr = per_cpu(processors, policy->cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 if (!pr || !pr->performance)
109 goto out;
110
Len Brown4be44fc2005-08-05 00:44:28 -0400111 ppc = (unsigned int)pr->performance_platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Dave Jones0916bd32006-11-22 20:42:01 -0500113 if (ppc >= pr->performance->state_count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 goto out;
115
116 cpufreq_verify_within_limits(policy, 0,
Len Brown4be44fc2005-08-05 00:44:28 -0400117 pr->performance->states[ppc].
118 core_frequency * 1000);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Len Brown4be44fc2005-08-05 00:44:28 -0400120 out:
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400121 mutex_unlock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 return 0;
124}
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126static struct notifier_block acpi_ppc_notifier_block = {
127 .notifier_call = acpi_processor_ppc_notifier,
128};
129
Len Brown4be44fc2005-08-05 00:44:28 -0400130static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131{
Len Brown4be44fc2005-08-05 00:44:28 -0400132 acpi_status status = 0;
Matthew Wilcox27663c52008-10-10 02:22:59 -0400133 unsigned long long ppc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
136 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400137 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139 /*
140 * _PPC indicates the maximum state currently supported by the platform
141 * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
142 */
143 status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
144
145 if (status != AE_NOT_FOUND)
146 acpi_processor_ppc_status |= PPC_IN_USE;
147
Len Brown4be44fc2005-08-05 00:44:28 -0400148 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400149 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400150 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 }
152
Thomas Renninger919158d2007-10-31 15:41:42 +0100153 cpufreq_printk("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
154 (int)ppc, ppc ? "" : "not");
155
Len Brown4be44fc2005-08-05 00:44:28 -0400156 pr->performance_platform_limit = (int)ppc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Patrick Mocheld550d982006-06-27 00:41:40 -0400158 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159}
160
Len Brown4be44fc2005-08-05 00:44:28 -0400161int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162{
Thomas Renninger623b78c2007-05-18 21:59:28 -0500163 int ret;
164
165 if (ignore_ppc)
166 return 0;
167
168 ret = acpi_processor_get_platform_limit(pr);
169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 if (ret < 0)
171 return (ret);
172 else
173 return cpufreq_update_policy(pr->id);
174}
175
Len Brown4be44fc2005-08-05 00:44:28 -0400176void acpi_processor_ppc_init(void)
177{
178 if (!cpufreq_register_notifier
179 (&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 acpi_processor_ppc_status |= PPC_REGISTERED;
181 else
Len Brown4be44fc2005-08-05 00:44:28 -0400182 printk(KERN_DEBUG
183 "Warning: Processor Platform Limit not supported.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184}
185
Len Brown4be44fc2005-08-05 00:44:28 -0400186void acpi_processor_ppc_exit(void)
187{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 if (acpi_processor_ppc_status & PPC_REGISTERED)
Len Brown4be44fc2005-08-05 00:44:28 -0400189 cpufreq_unregister_notifier(&acpi_ppc_notifier_block,
190 CPUFREQ_POLICY_NOTIFIER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192 acpi_processor_ppc_status &= ~PPC_REGISTERED;
193}
194
Len Brown4be44fc2005-08-05 00:44:28 -0400195static int acpi_processor_get_performance_control(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196{
Len Brown4be44fc2005-08-05 00:44:28 -0400197 int result = 0;
198 acpi_status status = 0;
199 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
200 union acpi_object *pct = NULL;
201 union acpi_object obj = { 0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
Len Brown4be44fc2005-08-05 00:44:28 -0400205 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400206 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400207 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 }
209
Len Brown4be44fc2005-08-05 00:44:28 -0400210 pct = (union acpi_object *)buffer.pointer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
Len Brown4be44fc2005-08-05 00:44:28 -0400212 || (pct->package.count != 2)) {
Len Brown64684632006-06-26 23:41:38 -0400213 printk(KERN_ERR PREFIX "Invalid _PCT data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 result = -EFAULT;
215 goto end;
216 }
217
218 /*
219 * control_register
220 */
221
222 obj = pct->package.elements[0];
223
224 if ((obj.type != ACPI_TYPE_BUFFER)
Len Brown4be44fc2005-08-05 00:44:28 -0400225 || (obj.buffer.length < sizeof(struct acpi_pct_register))
226 || (obj.buffer.pointer == NULL)) {
Len Brown64684632006-06-26 23:41:38 -0400227 printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 result = -EFAULT;
229 goto end;
230 }
Len Brown4be44fc2005-08-05 00:44:28 -0400231 memcpy(&pr->performance->control_register, obj.buffer.pointer,
232 sizeof(struct acpi_pct_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 /*
235 * status_register
236 */
237
238 obj = pct->package.elements[1];
239
240 if ((obj.type != ACPI_TYPE_BUFFER)
Len Brown4be44fc2005-08-05 00:44:28 -0400241 || (obj.buffer.length < sizeof(struct acpi_pct_register))
242 || (obj.buffer.pointer == NULL)) {
Len Brown64684632006-06-26 23:41:38 -0400243 printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 result = -EFAULT;
245 goto end;
246 }
247
Len Brown4be44fc2005-08-05 00:44:28 -0400248 memcpy(&pr->performance->status_register, obj.buffer.pointer,
249 sizeof(struct acpi_pct_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
Len Brown4be44fc2005-08-05 00:44:28 -0400251 end:
Len Brown02438d82006-06-30 03:19:10 -0400252 kfree(buffer.pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Patrick Mocheld550d982006-06-27 00:41:40 -0400254 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255}
256
Len Brown4be44fc2005-08-05 00:44:28 -0400257static int acpi_processor_get_performance_states(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258{
Len Brown4be44fc2005-08-05 00:44:28 -0400259 int result = 0;
260 acpi_status status = AE_OK;
261 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
262 struct acpi_buffer format = { sizeof("NNNNNN"), "NNNNNN" };
263 struct acpi_buffer state = { 0, NULL };
264 union acpi_object *pss = NULL;
265 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
268 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
Len Brown4be44fc2005-08-05 00:44:28 -0400269 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400270 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400271 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 }
273
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200274 pss = buffer.pointer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
Len Brown64684632006-06-26 23:41:38 -0400276 printk(KERN_ERR PREFIX "Invalid _PSS data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 result = -EFAULT;
278 goto end;
279 }
280
281 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400282 pss->package.count));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
284 pr->performance->state_count = pss->package.count;
Len Brown4be44fc2005-08-05 00:44:28 -0400285 pr->performance->states =
286 kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
287 GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 if (!pr->performance->states) {
289 result = -ENOMEM;
290 goto end;
291 }
292
293 for (i = 0; i < pr->performance->state_count; i++) {
294
295 struct acpi_processor_px *px = &(pr->performance->states[i]);
296
297 state.length = sizeof(struct acpi_processor_px);
298 state.pointer = px;
299
300 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
301
302 status = acpi_extract_package(&(pss->package.elements[i]),
Len Brown4be44fc2005-08-05 00:44:28 -0400303 &format, &state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400305 ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 result = -EFAULT;
307 kfree(pr->performance->states);
308 goto end;
309 }
310
311 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400312 "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
313 i,
314 (u32) px->core_frequency,
315 (u32) px->power,
316 (u32) px->transition_latency,
317 (u32) px->bus_master_latency,
318 (u32) px->control, (u32) px->status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320 if (!px->core_frequency) {
Len Brown64684632006-06-26 23:41:38 -0400321 printk(KERN_ERR PREFIX
322 "Invalid _PSS data: freq is zero\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 result = -EFAULT;
324 kfree(pr->performance->states);
325 goto end;
326 }
327 }
328
Len Brown4be44fc2005-08-05 00:44:28 -0400329 end:
Len Brown02438d82006-06-30 03:19:10 -0400330 kfree(buffer.pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
Patrick Mocheld550d982006-06-27 00:41:40 -0400332 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333}
334
Len Brown4be44fc2005-08-05 00:44:28 -0400335static int acpi_processor_get_performance_info(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336{
Len Brown4be44fc2005-08-05 00:44:28 -0400337 int result = 0;
338 acpi_status status = AE_OK;
339 acpi_handle handle = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 if (!pr || !pr->performance || !pr->handle)
Patrick Mocheld550d982006-06-27 00:41:40 -0400342 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 status = acpi_get_handle(pr->handle, "_PCT", &handle);
345 if (ACPI_FAILURE(status)) {
346 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400347 "ACPI-based processor performance control unavailable\n"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400348 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 }
350
351 result = acpi_processor_get_performance_control(pr);
352 if (result)
Thomas Renninger910dfae2008-09-01 14:27:04 +0200353 goto update_bios;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
355 result = acpi_processor_get_performance_states(pr);
356 if (result)
Thomas Renninger910dfae2008-09-01 14:27:04 +0200357 goto update_bios;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
Patrick Mocheld550d982006-06-27 00:41:40 -0400359 return 0;
Thomas Renninger910dfae2008-09-01 14:27:04 +0200360
361 /*
362 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
363 * the BIOS is older than the CPU and does not know its frequencies
364 */
365 update_bios:
Miao Xie16be87e2008-10-24 17:22:04 +0800366#ifdef CONFIG_X86
Thomas Renninger910dfae2008-09-01 14:27:04 +0200367 if (ACPI_SUCCESS(acpi_get_handle(pr->handle, "_PPC", &handle))){
368 if(boot_cpu_has(X86_FEATURE_EST))
369 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
370 "frequency support\n");
371 }
Miao Xie16be87e2008-10-24 17:22:04 +0800372#endif
Thomas Renninger910dfae2008-09-01 14:27:04 +0200373 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374}
375
Len Brown4be44fc2005-08-05 00:44:28 -0400376int acpi_processor_notify_smm(struct module *calling_module)
377{
378 acpi_status status;
379 static int is_done = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
382 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
Patrick Mocheld550d982006-06-27 00:41:40 -0400383 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385 if (!try_module_get(calling_module))
Patrick Mocheld550d982006-06-27 00:41:40 -0400386 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388 /* is_done is set to negative if an error occured,
389 * and to postitive if _no_ error occured, but SMM
390 * was already notified. This avoids double notification
391 * which might lead to unexpected results...
392 */
393 if (is_done > 0) {
394 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400395 return 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400396 } else if (is_done < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400398 return is_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 }
400
401 is_done = -EIO;
402
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300403 /* Can't write pstate_control to smi_command if either value is zero */
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300404 if ((!acpi_gbl_FADT.smi_command) || (!acpi_gbl_FADT.pstate_control)) {
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300405 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_control\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400407 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 }
409
Len Brown4be44fc2005-08-05 00:44:28 -0400410 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300411 "Writing pstate_control [0x%x] to smi_command [0x%x]\n",
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300412 acpi_gbl_FADT.pstate_control, acpi_gbl_FADT.smi_command));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300414 status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
415 (u32) acpi_gbl_FADT.pstate_control, 8);
Len Brown4be44fc2005-08-05 00:44:28 -0400416 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400417 ACPI_EXCEPTION((AE_INFO, status,
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300418 "Failed to write pstate_control [0x%x] to "
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300419 "smi_command [0x%x]", acpi_gbl_FADT.pstate_control,
420 acpi_gbl_FADT.smi_command));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 module_put(calling_module);
Patrick Mocheld550d982006-06-27 00:41:40 -0400422 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 }
424
425 /* Success. If there's no _PPC, we need to fear nothing, so
426 * we can allow the cpufreq driver to be rmmod'ed. */
427 is_done = 1;
428
429 if (!(acpi_processor_ppc_status & PPC_IN_USE))
430 module_put(calling_module);
431
Patrick Mocheld550d982006-06-27 00:41:40 -0400432 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
Len Brown4be44fc2005-08-05 00:44:28 -0400435EXPORT_SYMBOL(acpi_processor_notify_smm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
437#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
438/* /proc/acpi/processor/../performance interface (DEPRECATED) */
439
440static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
441static struct file_operations acpi_processor_perf_fops = {
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700442 .owner = THIS_MODULE,
Len Brown4be44fc2005-08-05 00:44:28 -0400443 .open = acpi_processor_perf_open_fs,
444 .read = seq_read,
445 .llseek = seq_lseek,
446 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447};
448
449static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
450{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200451 struct acpi_processor *pr = seq->private;
Len Brown4be44fc2005-08-05 00:44:28 -0400452 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
455 if (!pr)
456 goto end;
457
458 if (!pr->performance) {
459 seq_puts(seq, "<not supported>\n");
460 goto end;
461 }
462
463 seq_printf(seq, "state count: %d\n"
Len Brown4be44fc2005-08-05 00:44:28 -0400464 "active state: P%d\n",
465 pr->performance->state_count, pr->performance->state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466
467 seq_puts(seq, "states:\n");
468 for (i = 0; i < pr->performance->state_count; i++)
Len Brown4be44fc2005-08-05 00:44:28 -0400469 seq_printf(seq,
470 " %cP%d: %d MHz, %d mW, %d uS\n",
471 (i == pr->performance->state ? '*' : ' '), i,
472 (u32) pr->performance->states[i].core_frequency,
473 (u32) pr->performance->states[i].power,
474 (u32) pr->performance->states[i].transition_latency);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Len Brown4be44fc2005-08-05 00:44:28 -0400476 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400477 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
480static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
481{
482 return single_open(file, acpi_processor_perf_seq_show,
Len Brown4be44fc2005-08-05 00:44:28 -0400483 PDE(inode)->data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484}
485
Len Brown4be44fc2005-08-05 00:44:28 -0400486static void acpi_cpufreq_add_file(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487{
Len Brown4be44fc2005-08-05 00:44:28 -0400488 struct acpi_device *device = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490
491 if (acpi_bus_get_device(pr->handle, &device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400492 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
494 /* add file 'performance' [R/W] */
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700495 proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO,
496 acpi_device_dir(device),
497 &acpi_processor_perf_fops, acpi_driver_data(device));
Patrick Mocheld550d982006-06-27 00:41:40 -0400498 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499}
500
Len Brown4be44fc2005-08-05 00:44:28 -0400501static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502{
Len Brown4be44fc2005-08-05 00:44:28 -0400503 struct acpi_device *device = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
506 if (acpi_bus_get_device(pr->handle, &device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400507 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508
509 /* remove file 'performance' */
510 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
Len Brown4be44fc2005-08-05 00:44:28 -0400511 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512
Patrick Mocheld550d982006-06-27 00:41:40 -0400513 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514}
515
516#else
Len Brown4be44fc2005-08-05 00:44:28 -0400517static void acpi_cpufreq_add_file(struct acpi_processor *pr)
518{
519 return;
520}
521static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
522{
523 return;
524}
525#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500527static int acpi_processor_get_psd(struct acpi_processor *pr)
528{
529 int result = 0;
530 acpi_status status = AE_OK;
531 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
532 struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
533 struct acpi_buffer state = {0, NULL};
534 union acpi_object *psd = NULL;
535 struct acpi_psd_package *pdomain;
536
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500537 status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer);
538 if (ACPI_FAILURE(status)) {
Len Brown9011bff42006-05-11 00:28:12 -0400539 return -ENODEV;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500540 }
541
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200542 psd = buffer.pointer;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500543 if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800544 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500545 result = -EFAULT;
546 goto end;
547 }
548
549 if (psd->package.count != 1) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800550 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500551 result = -EFAULT;
552 goto end;
553 }
554
555 pdomain = &(pr->performance->domain_info);
556
557 state.length = sizeof(struct acpi_psd_package);
558 state.pointer = pdomain;
559
560 status = acpi_extract_package(&(psd->package.elements[0]),
561 &format, &state);
562 if (ACPI_FAILURE(status)) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800563 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500564 result = -EFAULT;
565 goto end;
566 }
567
568 if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800569 printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500570 result = -EFAULT;
571 goto end;
572 }
573
574 if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
Lin Ming55ac9a02008-09-28 14:51:56 +0800575 printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500576 result = -EFAULT;
577 goto end;
578 }
579
580end:
Len Brown02438d82006-06-30 03:19:10 -0400581 kfree(buffer.pointer);
Len Brown9011bff42006-05-11 00:28:12 -0400582 return result;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500583}
584
585int acpi_processor_preregister_performance(
Fenghua Yu50109292007-08-07 18:40:30 -0400586 struct acpi_processor_performance *performance)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500587{
588 int count, count_target;
589 int retval = 0;
590 unsigned int i, j;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800591 cpumask_var_t covered_cpus;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500592 struct acpi_processor *pr;
593 struct acpi_psd_package *pdomain;
594 struct acpi_processor *match_pr;
595 struct acpi_psd_package *match_pdomain;
596
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800597 if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))
598 return -ENOMEM;
599
Len Brown785fccc2006-06-15 22:19:31 -0400600 mutex_lock(&performance_mutex);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500601
602 retval = 0;
603
604 /* Call _PSD for all CPUs */
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400605 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700606 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500607 if (!pr) {
608 /* Look only at processors in ACPI namespace */
609 continue;
610 }
611
612 if (pr->performance) {
613 retval = -EBUSY;
614 continue;
615 }
616
Fenghua Yu50109292007-08-07 18:40:30 -0400617 if (!performance || !percpu_ptr(performance, i)) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500618 retval = -EINVAL;
619 continue;
620 }
621
Fenghua Yu50109292007-08-07 18:40:30 -0400622 pr->performance = percpu_ptr(performance, i);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800623 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500624 if (acpi_processor_get_psd(pr)) {
625 retval = -EINVAL;
626 continue;
627 }
628 }
629 if (retval)
630 goto err_ret;
631
632 /*
633 * Now that we have _PSD data from all CPUs, lets setup P-state
634 * domain info.
635 */
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400636 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700637 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500638 if (!pr)
639 continue;
640
641 /* Basic validity check for domain info */
642 pdomain = &(pr->performance->domain_info);
643 if ((pdomain->revision != ACPI_PSD_REV0_REVISION) ||
644 (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES)) {
645 retval = -EINVAL;
646 goto err_ret;
647 }
648 if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL &&
649 pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ANY &&
650 pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) {
651 retval = -EINVAL;
652 goto err_ret;
653 }
654 }
655
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800656 cpumask_clear(covered_cpus);
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400657 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700658 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500659 if (!pr)
660 continue;
661
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800662 if (cpumask_test_cpu(i, covered_cpus))
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500663 continue;
664
665 pdomain = &(pr->performance->domain_info);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800666 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
667 cpumask_set_cpu(i, covered_cpus);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500668 if (pdomain->num_processors <= 1)
669 continue;
670
671 /* Validate the Domain info */
672 count_target = pdomain->num_processors;
673 count = 1;
Venkatesh Pallipadi46f18e32006-06-26 00:34:43 -0400674 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500675 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
Venkatesh Pallipadi46f18e32006-06-26 00:34:43 -0400676 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
677 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW;
678 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500679 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500680
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400681 for_each_possible_cpu(j) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500682 if (i == j)
683 continue;
684
Mike Travis706546d2008-06-09 16:22:23 -0700685 match_pr = per_cpu(processors, j);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500686 if (!match_pr)
687 continue;
688
689 match_pdomain = &(match_pr->performance->domain_info);
690 if (match_pdomain->domain != pdomain->domain)
691 continue;
692
693 /* Here i and j are in the same domain */
694
695 if (match_pdomain->num_processors != count_target) {
696 retval = -EINVAL;
697 goto err_ret;
698 }
699
700 if (pdomain->coord_type != match_pdomain->coord_type) {
701 retval = -EINVAL;
702 goto err_ret;
703 }
704
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800705 cpumask_set_cpu(j, covered_cpus);
706 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500707 count++;
708 }
709
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400710 for_each_possible_cpu(j) {
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500711 if (i == j)
712 continue;
713
Mike Travis706546d2008-06-09 16:22:23 -0700714 match_pr = per_cpu(processors, j);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500715 if (!match_pr)
716 continue;
717
718 match_pdomain = &(match_pr->performance->domain_info);
719 if (match_pdomain->domain != pdomain->domain)
720 continue;
721
722 match_pr->performance->shared_type =
723 pr->performance->shared_type;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800724 cpumask_copy(match_pr->performance->shared_cpu_map,
725 pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500726 }
727 }
728
729err_ret:
KAMEZAWA Hiroyuki193de0c2006-04-27 05:25:00 -0400730 for_each_possible_cpu(i) {
Mike Travis706546d2008-06-09 16:22:23 -0700731 pr = per_cpu(processors, i);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500732 if (!pr || !pr->performance)
733 continue;
734
735 /* Assume no coordination on any error parsing domain info */
736 if (retval) {
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800737 cpumask_clear(pr->performance->shared_cpu_map);
738 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500739 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
740 }
741 pr->performance = NULL; /* Will be set for real in register */
742 }
743
Len Brown785fccc2006-06-15 22:19:31 -0400744 mutex_unlock(&performance_mutex);
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800745 free_cpumask_var(covered_cpus);
Len Brown9011bff42006-05-11 00:28:12 -0400746 return retval;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500747}
748EXPORT_SYMBOL(acpi_processor_preregister_performance);
749
750
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751int
Len Brown4be44fc2005-08-05 00:44:28 -0400752acpi_processor_register_performance(struct acpi_processor_performance
753 *performance, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754{
755 struct acpi_processor *pr;
756
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757
758 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
Patrick Mocheld550d982006-06-27 00:41:40 -0400759 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400761 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762
Mike Travis706546d2008-06-09 16:22:23 -0700763 pr = per_cpu(processors, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 if (!pr) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400765 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400766 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 }
768
769 if (pr->performance) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400770 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400771 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 }
773
Andrew Mortona913f502006-06-10 09:54:13 -0700774 WARN_ON(!performance);
775
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 pr->performance = performance;
777
778 if (acpi_processor_get_performance_info(pr)) {
779 pr->performance = NULL;
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400780 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400781 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 }
783
784 acpi_cpufreq_add_file(pr);
785
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400786 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400787 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788}
Len Brown4be44fc2005-08-05 00:44:28 -0400789
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790EXPORT_SYMBOL(acpi_processor_register_performance);
791
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792void
Len Brown4be44fc2005-08-05 00:44:28 -0400793acpi_processor_unregister_performance(struct acpi_processor_performance
794 *performance, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795{
796 struct acpi_processor *pr;
797
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400799 mutex_lock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800
Mike Travis706546d2008-06-09 16:22:23 -0700801 pr = per_cpu(processors, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 if (!pr) {
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400803 mutex_unlock(&performance_mutex);
Patrick Mocheld550d982006-06-27 00:41:40 -0400804 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 }
806
Andrew Mortona913f502006-06-10 09:54:13 -0700807 if (pr->performance)
808 kfree(pr->performance->states);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 pr->performance = NULL;
810
811 acpi_cpufreq_remove_file(pr);
812
Arjan van de Ven65c19bb2006-04-27 05:25:00 -0400813 mutex_unlock(&performance_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
Patrick Mocheld550d982006-06-27 00:41:40 -0400815 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816}
Len Brown4be44fc2005-08-05 00:44:28 -0400817
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818EXPORT_SYMBOL(acpi_processor_unregister_performance);