processor_perflib.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /*
  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. #include <linux/kernel.h>
  29. #include <linux/module.h>
  30. #include <linux/init.h>
  31. #include <linux/cpufreq.h>
  32. #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
  33. #include <linux/proc_fs.h>
  34. #include <linux/seq_file.h>
  35. #include <asm/uaccess.h>
  36. #endif
  37. #include <acpi/acpi_bus.h>
  38. #include <acpi/processor.h>
  39. #define ACPI_PROCESSOR_COMPONENT 0x01000000
  40. #define ACPI_PROCESSOR_CLASS "processor"
  41. #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
  42. #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance"
  43. #define _COMPONENT ACPI_PROCESSOR_COMPONENT
  44. ACPI_MODULE_NAME ("acpi_processor")
  45. static DECLARE_MUTEX(performance_sem);
  46. /*
  47. * _PPC support is implemented as a CPUfreq policy notifier:
  48. * This means each time a CPUfreq driver registered also with
  49. * the ACPI core is asked to change the speed policy, the maximum
  50. * value is adjusted so that it is within the platform limit.
  51. *
  52. * Also, when a new platform limit value is detected, the CPUfreq
  53. * policy is adjusted accordingly.
  54. */
  55. #define PPC_REGISTERED 1
  56. #define PPC_IN_USE 2
  57. static int acpi_processor_ppc_status = 0;
  58. static int acpi_processor_ppc_notifier(struct notifier_block *nb,
  59. unsigned long event,
  60. void *data)
  61. {
  62. struct cpufreq_policy *policy = data;
  63. struct acpi_processor *pr;
  64. unsigned int ppc = 0;
  65. down(&performance_sem);
  66. if (event != CPUFREQ_INCOMPATIBLE)
  67. goto out;
  68. pr = processors[policy->cpu];
  69. if (!pr || !pr->performance)
  70. goto out;
  71. ppc = (unsigned int) pr->performance_platform_limit;
  72. if (!ppc)
  73. goto out;
  74. if (ppc > pr->performance->state_count)
  75. goto out;
  76. cpufreq_verify_within_limits(policy, 0,
  77. pr->performance->states[ppc].core_frequency * 1000);
  78. out:
  79. up(&performance_sem);
  80. return 0;
  81. }
  82. static struct notifier_block acpi_ppc_notifier_block = {
  83. .notifier_call = acpi_processor_ppc_notifier,
  84. };
  85. static int
  86. acpi_processor_get_platform_limit (
  87. struct acpi_processor* pr)
  88. {
  89. acpi_status status = 0;
  90. unsigned long ppc = 0;
  91. ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
  92. if (!pr)
  93. return_VALUE(-EINVAL);
  94. /*
  95. * _PPC indicates the maximum state currently supported by the platform
  96. * (e.g. 0 = states 0..n; 1 = states 1..n; etc.
  97. */
  98. status = acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
  99. if (status != AE_NOT_FOUND)
  100. acpi_processor_ppc_status |= PPC_IN_USE;
  101. if(ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  102. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n"));
  103. return_VALUE(-ENODEV);
  104. }
  105. pr->performance_platform_limit = (int) ppc;
  106. return_VALUE(0);
  107. }
  108. int acpi_processor_ppc_has_changed(
  109. struct acpi_processor *pr)
  110. {
  111. int ret = acpi_processor_get_platform_limit(pr);
  112. if (ret < 0)
  113. return (ret);
  114. else
  115. return cpufreq_update_policy(pr->id);
  116. }
  117. void acpi_processor_ppc_init(void) {
  118. if (!cpufreq_register_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER))
  119. acpi_processor_ppc_status |= PPC_REGISTERED;
  120. else
  121. printk(KERN_DEBUG "Warning: Processor Platform Limit not supported.\n");
  122. }
  123. void acpi_processor_ppc_exit(void) {
  124. if (acpi_processor_ppc_status & PPC_REGISTERED)
  125. cpufreq_unregister_notifier(&acpi_ppc_notifier_block, CPUFREQ_POLICY_NOTIFIER);
  126. acpi_processor_ppc_status &= ~PPC_REGISTERED;
  127. }
  128. /*
  129. * when registering a cpufreq driver with this ACPI processor driver, the
  130. * _PCT and _PSS structures are read out and written into struct
  131. * acpi_processor_performance.
  132. */
  133. static int acpi_processor_set_pdc (struct acpi_processor *pr)
  134. {
  135. acpi_status status = AE_OK;
  136. u32 arg0_buf[3];
  137. union acpi_object arg0 = {ACPI_TYPE_BUFFER};
  138. struct acpi_object_list no_object = {1, &arg0};
  139. struct acpi_object_list *pdc;
  140. ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
  141. arg0.buffer.length = 12;
  142. arg0.buffer.pointer = (u8 *) arg0_buf;
  143. arg0_buf[0] = ACPI_PDC_REVISION_ID;
  144. arg0_buf[1] = 0;
  145. arg0_buf[2] = 0;
  146. pdc = (pr->performance->pdc) ? pr->performance->pdc : &no_object;
  147. status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
  148. if ((ACPI_FAILURE(status)) && (pr->performance->pdc))
  149. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
  150. return_VALUE(status);
  151. }
  152. static int
  153. acpi_processor_get_performance_control (
  154. struct acpi_processor *pr)
  155. {
  156. int result = 0;
  157. acpi_status status = 0;
  158. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  159. union acpi_object *pct = NULL;
  160. union acpi_object obj = {0};
  161. ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
  162. status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
  163. if(ACPI_FAILURE(status)) {
  164. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n"));
  165. return_VALUE(-ENODEV);
  166. }
  167. pct = (union acpi_object *) buffer.pointer;
  168. if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
  169. || (pct->package.count != 2)) {
  170. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n"));
  171. result = -EFAULT;
  172. goto end;
  173. }
  174. /*
  175. * control_register
  176. */
  177. obj = pct->package.elements[0];
  178. if ((obj.type != ACPI_TYPE_BUFFER)
  179. || (obj.buffer.length < sizeof(struct acpi_pct_register))
  180. || (obj.buffer.pointer == NULL)) {
  181. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  182. "Invalid _PCT data (control_register)\n"));
  183. result = -EFAULT;
  184. goto end;
  185. }
  186. memcpy(&pr->performance->control_register, obj.buffer.pointer, sizeof(struct acpi_pct_register));
  187. /*
  188. * status_register
  189. */
  190. obj = pct->package.elements[1];
  191. if ((obj.type != ACPI_TYPE_BUFFER)
  192. || (obj.buffer.length < sizeof(struct acpi_pct_register))
  193. || (obj.buffer.pointer == NULL)) {
  194. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  195. "Invalid _PCT data (status_register)\n"));
  196. result = -EFAULT;
  197. goto end;
  198. }
  199. memcpy(&pr->performance->status_register, obj.buffer.pointer, sizeof(struct acpi_pct_register));
  200. end:
  201. acpi_os_free(buffer.pointer);
  202. return_VALUE(result);
  203. }
  204. static int
  205. acpi_processor_get_performance_states (
  206. struct acpi_processor *pr)
  207. {
  208. int result = 0;
  209. acpi_status status = AE_OK;
  210. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  211. struct acpi_buffer format = {sizeof("NNNNNN"), "NNNNNN"};
  212. struct acpi_buffer state = {0, NULL};
  213. union acpi_object *pss = NULL;
  214. int i;
  215. ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
  216. status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
  217. if(ACPI_FAILURE(status)) {
  218. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n"));
  219. return_VALUE(-ENODEV);
  220. }
  221. pss = (union acpi_object *) buffer.pointer;
  222. if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
  223. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n"));
  224. result = -EFAULT;
  225. goto end;
  226. }
  227. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d performance states\n",
  228. pss->package.count));
  229. pr->performance->state_count = pss->package.count;
  230. pr->performance->states = kmalloc(sizeof(struct acpi_processor_px) * pss->package.count, GFP_KERNEL);
  231. if (!pr->performance->states) {
  232. result = -ENOMEM;
  233. goto end;
  234. }
  235. for (i = 0; i < pr->performance->state_count; i++) {
  236. struct acpi_processor_px *px = &(pr->performance->states[i]);
  237. state.length = sizeof(struct acpi_processor_px);
  238. state.pointer = px;
  239. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
  240. status = acpi_extract_package(&(pss->package.elements[i]),
  241. &format, &state);
  242. if (ACPI_FAILURE(status)) {
  243. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n"));
  244. result = -EFAULT;
  245. kfree(pr->performance->states);
  246. goto end;
  247. }
  248. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  249. "State [%d]: core_frequency[%d] power[%d] transition_latency[%d] bus_master_latency[%d] control[0x%x] status[0x%x]\n",
  250. i,
  251. (u32) px->core_frequency,
  252. (u32) px->power,
  253. (u32) px->transition_latency,
  254. (u32) px->bus_master_latency,
  255. (u32) px->control,
  256. (u32) px->status));
  257. if (!px->core_frequency) {
  258. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data: freq is zero\n"));
  259. result = -EFAULT;
  260. kfree(pr->performance->states);
  261. goto end;
  262. }
  263. }
  264. end:
  265. acpi_os_free(buffer.pointer);
  266. return_VALUE(result);
  267. }
  268. static int
  269. acpi_processor_get_performance_info (
  270. struct acpi_processor *pr)
  271. {
  272. int result = 0;
  273. acpi_status status = AE_OK;
  274. acpi_handle handle = NULL;
  275. ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
  276. if (!pr || !pr->performance || !pr->handle)
  277. return_VALUE(-EINVAL);
  278. acpi_processor_set_pdc(pr);
  279. status = acpi_get_handle(pr->handle, "_PCT", &handle);
  280. if (ACPI_FAILURE(status)) {
  281. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  282. "ACPI-based processor performance control unavailable\n"));
  283. return_VALUE(-ENODEV);
  284. }
  285. result = acpi_processor_get_performance_control(pr);
  286. if (result)
  287. return_VALUE(result);
  288. result = acpi_processor_get_performance_states(pr);
  289. if (result)
  290. return_VALUE(result);
  291. result = acpi_processor_get_platform_limit(pr);
  292. if (result)
  293. return_VALUE(result);
  294. return_VALUE(0);
  295. }
  296. int acpi_processor_notify_smm(struct module *calling_module) {
  297. acpi_status status;
  298. static int is_done = 0;
  299. ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
  300. if (!(acpi_processor_ppc_status & PPC_REGISTERED))
  301. return_VALUE(-EBUSY);
  302. if (!try_module_get(calling_module))
  303. return_VALUE(-EINVAL);
  304. /* is_done is set to negative if an error occured,
  305. * and to postitive if _no_ error occured, but SMM
  306. * was already notified. This avoids double notification
  307. * which might lead to unexpected results...
  308. */
  309. if (is_done > 0) {
  310. module_put(calling_module);
  311. return_VALUE(0);
  312. }
  313. else if (is_done < 0) {
  314. module_put(calling_module);
  315. return_VALUE(is_done);
  316. }
  317. is_done = -EIO;
  318. /* Can't write pstate_cnt to smi_cmd if either value is zero */
  319. if ((!acpi_fadt.smi_cmd) ||
  320. (!acpi_fadt.pstate_cnt)) {
  321. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  322. "No SMI port or pstate_cnt\n"));
  323. module_put(calling_module);
  324. return_VALUE(0);
  325. }
  326. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Writing pstate_cnt [0x%x] to smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd));
  327. /* FADT v1 doesn't support pstate_cnt, many BIOS vendors use
  328. * it anyway, so we need to support it... */
  329. if (acpi_fadt_is_v1) {
  330. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Using v1.0 FADT reserved value for pstate_cnt\n"));
  331. }
  332. status = acpi_os_write_port (acpi_fadt.smi_cmd,
  333. (u32) acpi_fadt.pstate_cnt, 8);
  334. if (ACPI_FAILURE (status)) {
  335. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  336. "Failed to write pstate_cnt [0x%x] to "
  337. "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, acpi_fadt.smi_cmd));
  338. module_put(calling_module);
  339. return_VALUE(status);
  340. }
  341. /* Success. If there's no _PPC, we need to fear nothing, so
  342. * we can allow the cpufreq driver to be rmmod'ed. */
  343. is_done = 1;
  344. if (!(acpi_processor_ppc_status & PPC_IN_USE))
  345. module_put(calling_module);
  346. return_VALUE(0);
  347. }
  348. EXPORT_SYMBOL(acpi_processor_notify_smm);
  349. #ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
  350. /* /proc/acpi/processor/../performance interface (DEPRECATED) */
  351. static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
  352. static struct file_operations acpi_processor_perf_fops = {
  353. .open = acpi_processor_perf_open_fs,
  354. .read = seq_read,
  355. .llseek = seq_lseek,
  356. .release = single_release,
  357. };
  358. static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
  359. {
  360. struct acpi_processor *pr = (struct acpi_processor *)seq->private;
  361. int i;
  362. ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
  363. if (!pr)
  364. goto end;
  365. if (!pr->performance) {
  366. seq_puts(seq, "<not supported>\n");
  367. goto end;
  368. }
  369. seq_printf(seq, "state count: %d\n"
  370. "active state: P%d\n",
  371. pr->performance->state_count,
  372. pr->performance->state);
  373. seq_puts(seq, "states:\n");
  374. for (i = 0; i < pr->performance->state_count; i++)
  375. seq_printf(seq, " %cP%d: %d MHz, %d mW, %d uS\n",
  376. (i == pr->performance->state?'*':' '), i,
  377. (u32) pr->performance->states[i].core_frequency,
  378. (u32) pr->performance->states[i].power,
  379. (u32) pr->performance->states[i].transition_latency);
  380. end:
  381. return_VALUE(0);
  382. }
  383. static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
  384. {
  385. return single_open(file, acpi_processor_perf_seq_show,
  386. PDE(inode)->data);
  387. }
  388. static ssize_t
  389. acpi_processor_write_performance (
  390. struct file *file,
  391. const char __user *buffer,
  392. size_t count,
  393. loff_t *data)
  394. {
  395. int result = 0;
  396. struct seq_file *m = (struct seq_file *) file->private_data;
  397. struct acpi_processor *pr = (struct acpi_processor *) m->private;
  398. struct acpi_processor_performance *perf;
  399. char state_string[12] = {'\0'};
  400. unsigned int new_state = 0;
  401. struct cpufreq_policy policy;
  402. ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
  403. if (!pr || (count > sizeof(state_string) - 1))
  404. return_VALUE(-EINVAL);
  405. perf = pr->performance;
  406. if (!perf)
  407. return_VALUE(-EINVAL);
  408. if (copy_from_user(state_string, buffer, count))
  409. return_VALUE(-EFAULT);
  410. state_string[count] = '\0';
  411. new_state = simple_strtoul(state_string, NULL, 0);
  412. if (new_state >= perf->state_count)
  413. return_VALUE(-EINVAL);
  414. cpufreq_get_policy(&policy, pr->id);
  415. policy.cpu = pr->id;
  416. policy.min = perf->states[new_state].core_frequency * 1000;
  417. policy.max = perf->states[new_state].core_frequency * 1000;
  418. result = cpufreq_set_policy(&policy);
  419. if (result)
  420. return_VALUE(result);
  421. return_VALUE(count);
  422. }
  423. static void
  424. acpi_cpufreq_add_file (
  425. struct acpi_processor *pr)
  426. {
  427. struct proc_dir_entry *entry = NULL;
  428. struct acpi_device *device = NULL;
  429. ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
  430. if (acpi_bus_get_device(pr->handle, &device))
  431. return_VOID;
  432. /* add file 'performance' [R/W] */
  433. entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
  434. S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
  435. if (!entry)
  436. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  437. "Unable to create '%s' fs entry\n",
  438. ACPI_PROCESSOR_FILE_PERFORMANCE));
  439. else {
  440. entry->proc_fops = &acpi_processor_perf_fops;
  441. entry->proc_fops->write = acpi_processor_write_performance;
  442. entry->data = acpi_driver_data(device);
  443. entry->owner = THIS_MODULE;
  444. }
  445. return_VOID;
  446. }
  447. static void
  448. acpi_cpufreq_remove_file (
  449. struct acpi_processor *pr)
  450. {
  451. struct acpi_device *device = NULL;
  452. ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
  453. if (acpi_bus_get_device(pr->handle, &device))
  454. return_VOID;
  455. /* remove file 'performance' */
  456. remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
  457. acpi_device_dir(device));
  458. return_VOID;
  459. }
  460. #else
  461. static void acpi_cpufreq_add_file (struct acpi_processor *pr) { return; }
  462. static void acpi_cpufreq_remove_file (struct acpi_processor *pr) { return; }
  463. #endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
  464. int
  465. acpi_processor_register_performance (
  466. struct acpi_processor_performance * performance,
  467. unsigned int cpu)
  468. {
  469. struct acpi_processor *pr;
  470. ACPI_FUNCTION_TRACE("acpi_processor_register_performance");
  471. if (!(acpi_processor_ppc_status & PPC_REGISTERED))
  472. return_VALUE(-EINVAL);
  473. down(&performance_sem);
  474. pr = processors[cpu];
  475. if (!pr) {
  476. up(&performance_sem);
  477. return_VALUE(-ENODEV);
  478. }
  479. if (pr->performance) {
  480. up(&performance_sem);
  481. return_VALUE(-EBUSY);
  482. }
  483. pr->performance = performance;
  484. if (acpi_processor_get_performance_info(pr)) {
  485. pr->performance = NULL;
  486. up(&performance_sem);
  487. return_VALUE(-EIO);
  488. }
  489. acpi_cpufreq_add_file(pr);
  490. up(&performance_sem);
  491. return_VALUE(0);
  492. }
  493. EXPORT_SYMBOL(acpi_processor_register_performance);
  494. void
  495. acpi_processor_unregister_performance (
  496. struct acpi_processor_performance * performance,
  497. unsigned int cpu)
  498. {
  499. struct acpi_processor *pr;
  500. ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
  501. down(&performance_sem);
  502. pr = processors[cpu];
  503. if (!pr) {
  504. up(&performance_sem);
  505. return_VOID;
  506. }
  507. kfree(pr->performance->states);
  508. pr->performance = NULL;
  509. acpi_cpufreq_remove_file(pr);
  510. up(&performance_sem);
  511. return_VOID;
  512. }
  513. EXPORT_SYMBOL(acpi_processor_unregister_performance);