blob: 0cc2fd31e3765f7c9b945460345533dfebf1424b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * acpi_processor.c - ACPI Processor Driver ($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 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 * TBD:
28 * 1. Make # power states dynamic.
29 * 2. Support duty_cycle values that span bit 4.
30 * 3. Optimize by having scheduler determine business instead of
31 * having us try to calculate it here.
32 * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this.
33 */
34
35#include <linux/kernel.h>
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/types.h>
39#include <linux/pci.h>
40#include <linux/pm.h>
41#include <linux/cpufreq.h>
42#include <linux/cpu.h>
43#include <linux/proc_fs.h>
44#include <linux/seq_file.h>
45#include <linux/dmi.h>
46#include <linux/moduleparam.h>
Len Brown4f86d3a2007-10-03 18:58:00 -040047#include <linux/cpuidle.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#include <asm/io.h>
50#include <asm/system.h>
51#include <asm/cpu.h>
52#include <asm/delay.h>
53#include <asm/uaccess.h>
54#include <asm/processor.h>
55#include <asm/smp.h>
56#include <asm/acpi.h>
57
58#include <acpi/acpi_bus.h>
59#include <acpi/acpi_drivers.h>
60#include <acpi/processor.h>
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#define ACPI_PROCESSOR_CLASS "processor"
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define ACPI_PROCESSOR_DEVICE_NAME "Processor"
64#define ACPI_PROCESSOR_FILE_INFO "info"
65#define ACPI_PROCESSOR_FILE_THROTTLING "throttling"
66#define ACPI_PROCESSOR_FILE_LIMIT "limit"
67#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
68#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
Luming Yu01854e62007-05-26 22:49:58 +080069#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#define ACPI_PROCESSOR_LIMIT_USER 0
72#define ACPI_PROCESSOR_LIMIT_THERMAL 1
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#define _COMPONENT ACPI_PROCESSOR_COMPONENT
Len Brownf52fd662007-02-12 22:42:12 -050075ACPI_MODULE_NAME("processor_core");
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Len Brownf52fd662007-02-12 22:42:12 -050077MODULE_AUTHOR("Paul Diefenbaugh");
Len Brown7cda93e2007-02-12 23:50:02 -050078MODULE_DESCRIPTION("ACPI Processor Driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -070079MODULE_LICENSE("GPL");
80
Len Brown4be44fc2005-08-05 00:44:28 -040081static int acpi_processor_add(struct acpi_device *device);
82static int acpi_processor_start(struct acpi_device *device);
83static int acpi_processor_remove(struct acpi_device *device, int type);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
Len Brown4be44fc2005-08-05 00:44:28 -040085static void acpi_processor_notify(acpi_handle handle, u32 event, void *data);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
87static int acpi_processor_handle_eject(struct acpi_processor *pr);
Luming Yu01854e62007-05-26 22:49:58 +080088
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Thomas Renninger1ba90e32007-07-23 14:44:41 +020090static const struct acpi_device_id processor_device_ids[] = {
Myron Stowead93a762008-11-04 14:52:55 -070091 {ACPI_PROCESSOR_OBJECT_HID, 0},
Thomas Renninger1ba90e32007-07-23 14:44:41 +020092 {ACPI_PROCESSOR_HID, 0},
93 {"", 0},
94};
95MODULE_DEVICE_TABLE(acpi, processor_device_ids);
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097static struct acpi_driver acpi_processor_driver = {
Len Brownc2b67052007-02-12 23:33:40 -050098 .name = "processor",
Len Brown4be44fc2005-08-05 00:44:28 -040099 .class = ACPI_PROCESSOR_CLASS,
Thomas Renninger1ba90e32007-07-23 14:44:41 +0200100 .ids = processor_device_ids,
Len Brown4be44fc2005-08-05 00:44:28 -0400101 .ops = {
102 .add = acpi_processor_add,
103 .remove = acpi_processor_remove,
104 .start = acpi_processor_start,
Thomas Gleixnerb04e7bd2007-09-22 22:29:05 +0000105 .suspend = acpi_processor_suspend,
106 .resume = acpi_processor_resume,
Len Brown4be44fc2005-08-05 00:44:28 -0400107 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108};
109
110#define INSTALL_NOTIFY_HANDLER 1
111#define UNINSTALL_NOTIFY_HANDLER 2
112
Arjan van de Vend7508032006-07-04 13:06:00 -0400113static const struct file_operations acpi_processor_info_fops = {
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700114 .owner = THIS_MODULE,
Len Brown4be44fc2005-08-05 00:44:28 -0400115 .open = acpi_processor_info_open_fs,
116 .read = seq_read,
117 .llseek = seq_lseek,
118 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119};
120
Mike Travis706546d2008-06-09 16:22:23 -0700121DEFINE_PER_CPU(struct acpi_processor *, processors);
Andreas Mohr9f222712006-06-23 02:04:27 -0700122struct acpi_processor_errata errata __read_mostly;
Zhao Yakui2a2a6472008-06-24 18:02:57 +0800123static int set_no_mwait(const struct dmi_system_id *id)
124{
125 printk(KERN_NOTICE PREFIX "%s detected - "
Pavel Machekd0057412008-08-12 12:24:34 +0200126 "disabling mwait for CPU C-states\n", id->ident);
Zhao Yakui2a2a6472008-06-24 18:02:57 +0800127 idle_nomwait = 1;
128 return 0;
129}
130
131static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
132 {
133 set_no_mwait, "IFL91 board", {
134 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
135 DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
136 DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
137 DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
138 {
139 set_no_mwait, "Extensa 5220", {
140 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
Dennis Jansen3df8a902008-08-15 01:28:57 +0200141 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
Zhao Yakui2a2a6472008-06-24 18:02:57 +0800142 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
143 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
144 {},
145};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147/* --------------------------------------------------------------------------
148 Errata Handling
149 -------------------------------------------------------------------------- */
150
Len Brown4be44fc2005-08-05 00:44:28 -0400151static int acpi_processor_errata_piix4(struct pci_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152{
Len Brown4be44fc2005-08-05 00:44:28 -0400153 u8 value1 = 0;
154 u8 value2 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
157 if (!dev)
Patrick Mocheld550d982006-06-27 00:41:40 -0400158 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160 /*
161 * Note that 'dev' references the PIIX4 ACPI Controller.
162 */
163
Auke Kok44c10132007-06-08 15:46:36 -0700164 switch (dev->revision) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 case 0:
166 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n"));
167 break;
168 case 1:
169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n"));
170 break;
171 case 2:
172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n"));
173 break;
174 case 3:
175 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n"));
176 break;
177 default:
178 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n"));
179 break;
180 }
181
Auke Kok44c10132007-06-08 15:46:36 -0700182 switch (dev->revision) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184 case 0: /* PIIX4 A-step */
185 case 1: /* PIIX4 B-step */
186 /*
187 * See specification changes #13 ("Manual Throttle Duty Cycle")
188 * and #14 ("Enabling and Disabling Manual Throttle"), plus
189 * erratum #5 ("STPCLK# Deassertion Time") from the January
190 * 2002 PIIX4 specification update. Applies to only older
191 * PIIX4 models.
192 */
193 errata.piix4.throttle = 1;
194
195 case 2: /* PIIX4E */
196 case 3: /* PIIX4M */
197 /*
198 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
199 * Livelock") from the January 2002 PIIX4 specification update.
200 * Applies to all PIIX4 models.
201 */
202
203 /*
204 * BM-IDE
205 * ------
206 * Find the PIIX4 IDE Controller and get the Bus Master IDE
207 * Status register address. We'll use this later to read
208 * each IDE controller's DMA status to make sure we catch all
209 * DMA activity.
210 */
211 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
Len Brown4be44fc2005-08-05 00:44:28 -0400212 PCI_DEVICE_ID_INTEL_82371AB,
213 PCI_ANY_ID, PCI_ANY_ID, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 if (dev) {
215 errata.piix4.bmisx = pci_resource_start(dev, 4);
216 pci_dev_put(dev);
217 }
218
219 /*
220 * Type-F DMA
221 * ----------
222 * Find the PIIX4 ISA Controller and read the Motherboard
223 * DMA controller's status to see if Type-F (Fast) DMA mode
224 * is enabled (bit 7) on either channel. Note that we'll
225 * disable C3 support if this is enabled, as some legacy
226 * devices won't operate well if fast DMA is disabled.
227 */
228 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
Len Brown4be44fc2005-08-05 00:44:28 -0400229 PCI_DEVICE_ID_INTEL_82371AB_0,
230 PCI_ANY_ID, PCI_ANY_ID, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 if (dev) {
232 pci_read_config_byte(dev, 0x76, &value1);
233 pci_read_config_byte(dev, 0x77, &value2);
234 if ((value1 & 0x80) || (value2 & 0x80))
235 errata.piix4.fdma = 1;
236 pci_dev_put(dev);
237 }
238
239 break;
240 }
241
242 if (errata.piix4.bmisx)
243 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400244 "Bus master activity detection (BM-IDE) erratum enabled\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 if (errata.piix4.fdma)
246 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400247 "Type-F DMA livelock erratum (C3 disabled)\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Patrick Mocheld550d982006-06-27 00:41:40 -0400249 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250}
251
Adrian Bunk8713cbe2005-09-02 17:16:48 -0400252static int acpi_processor_errata(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253{
Len Brown4be44fc2005-08-05 00:44:28 -0400254 int result = 0;
255 struct pci_dev *dev = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
258 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400259 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 /*
262 * PIIX4
263 */
264 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
Len Brown4be44fc2005-08-05 00:44:28 -0400265 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
266 PCI_ANY_ID, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 if (dev) {
268 result = acpi_processor_errata_piix4(dev);
269 pci_dev_put(dev);
270 }
271
Patrick Mocheld550d982006-06-27 00:41:40 -0400272 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273}
274
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275/* --------------------------------------------------------------------------
Akinobu Mita0b280022006-03-26 01:38:58 -0800276 Common ACPI processor functions
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400277 -------------------------------------------------------------------------- */
278
279/*
280 * _PDC is required for a BIOS-OS handshake for most of the newer
281 * ACPI processor features.
282 */
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400283static int acpi_processor_set_pdc(struct acpi_processor *pr)
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400284{
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400285 struct acpi_object_list *pdc_in = pr->pdc;
Len Brown4be44fc2005-08-05 00:44:28 -0400286 acpi_status status = AE_OK;
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400287
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400288
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400289 if (!pdc_in)
Patrick Mocheld550d982006-06-27 00:41:40 -0400290 return status;
Zhao Yakuida5e09a2008-06-24 18:01:09 +0800291 if (idle_nomwait) {
292 /*
293 * If mwait is disabled for CPU C-states, the C2C3_FFH access
294 * mode will be disabled in the parameter of _PDC object.
295 * Of course C1_FFH access mode will also be disabled.
296 */
297 union acpi_object *obj;
298 u32 *buffer = NULL;
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400299
Zhao Yakuida5e09a2008-06-24 18:01:09 +0800300 obj = pdc_in->pointer;
301 buffer = (u32 *)(obj->buffer.pointer);
302 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
303
304 }
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400305 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400306
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400307 if (ACPI_FAILURE(status))
Len Brown4be44fc2005-08-05 00:44:28 -0400308 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400309 "Could not evaluate _PDC, using legacy perf. control...\n"));
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400310
Patrick Mocheld550d982006-06-27 00:41:40 -0400311 return status;
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400312}
313
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400314/* --------------------------------------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 FS Interface (/proc)
316 -------------------------------------------------------------------------- */
317
Len Brown4be44fc2005-08-05 00:44:28 -0400318static struct proc_dir_entry *acpi_processor_dir = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
321{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200322 struct acpi_processor *pr = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325 if (!pr)
326 goto end;
327
328 seq_printf(seq, "processor id: %d\n"
Len Brown4be44fc2005-08-05 00:44:28 -0400329 "acpi id: %d\n"
330 "bus mastering control: %s\n"
331 "power management: %s\n"
332 "throttling control: %s\n"
333 "limit interface: %s\n",
334 pr->id,
335 pr->acpi_id,
336 pr->flags.bm_control ? "yes" : "no",
337 pr->flags.power ? "yes" : "no",
338 pr->flags.throttling ? "yes" : "no",
339 pr->flags.limit ? "yes" : "no");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Len Brown4be44fc2005-08-05 00:44:28 -0400341 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400342 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343}
344
345static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
346{
347 return single_open(file, acpi_processor_info_seq_show,
Len Brown4be44fc2005-08-05 00:44:28 -0400348 PDE(inode)->data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349}
350
Len Brown4be44fc2005-08-05 00:44:28 -0400351static int acpi_processor_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352{
Len Brown4be44fc2005-08-05 00:44:28 -0400353 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356 if (!acpi_device_dir(device)) {
357 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown4be44fc2005-08-05 00:44:28 -0400358 acpi_processor_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400360 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 }
362 acpi_device_dir(device)->owner = THIS_MODULE;
363
364 /* 'info' [R] */
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700365 entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
366 S_IRUGO, acpi_device_dir(device),
367 &acpi_processor_info_fops,
368 acpi_driver_data(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400370 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 /* 'throttling' [R/W] */
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700373 entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING,
374 S_IFREG | S_IRUGO | S_IWUSR,
375 acpi_device_dir(device),
376 &acpi_processor_throttling_fops,
377 acpi_driver_data(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400379 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381 /* 'limit' [R/W] */
Denis V. Lunevcf7acfa2008-04-29 01:02:27 -0700382 entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT,
383 S_IFREG | S_IRUGO | S_IWUSR,
384 acpi_device_dir(device),
385 &acpi_processor_limit_fops,
386 acpi_driver_data(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400388 return -EIO;
Patrick Mocheld550d982006-06-27 00:41:40 -0400389 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
391
Len Brown4be44fc2005-08-05 00:44:28 -0400392static int acpi_processor_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395 if (acpi_device_dir(device)) {
Len Brown4be44fc2005-08-05 00:44:28 -0400396 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
397 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
Len Brown4be44fc2005-08-05 00:44:28 -0400399 acpi_device_dir(device));
400 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
401 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
403 acpi_device_dir(device) = NULL;
404 }
405
Patrick Mocheld550d982006-06-27 00:41:40 -0400406 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407}
408
409/* Use the acpiid in MADT to map cpus in case of SMP */
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300410
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411#ifndef CONFIG_SMP
Myron Stoweb26e9282008-11-04 14:53:00 -0700412static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413#else
414
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300415static struct acpi_table_madt *madt;
416
417static int map_lapic_id(struct acpi_subtable_header *entry,
418 u32 acpi_id, int *apic_id)
419{
420 struct acpi_madt_local_apic *lapic =
421 (struct acpi_madt_local_apic *)entry;
422 if ((lapic->lapic_flags & ACPI_MADT_ENABLED) &&
423 lapic->processor_id == acpi_id) {
424 *apic_id = lapic->id;
425 return 1;
426 }
427 return 0;
428}
429
430static int map_lsapic_id(struct acpi_subtable_header *entry,
Myron Stoweb26e9282008-11-04 14:53:00 -0700431 int device_declaration, u32 acpi_id, int *apic_id)
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300432{
433 struct acpi_madt_local_sapic *lsapic =
434 (struct acpi_madt_local_sapic *)entry;
Myron Stoweb26e9282008-11-04 14:53:00 -0700435 u32 tmp = (lsapic->id << 8) | lsapic->eid;
436
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300437 /* Only check enabled APICs*/
Myron Stoweb26e9282008-11-04 14:53:00 -0700438 if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
439 return 0;
440
441 /* Device statement declaration type */
442 if (device_declaration) {
443 if (entry->length < 16)
444 printk(KERN_ERR PREFIX
445 "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n",
446 tmp);
447 else if (lsapic->uid == acpi_id)
448 goto found;
449 /* Processor statement declaration type */
450 } else if (lsapic->processor_id == acpi_id)
451 goto found;
452
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300453 return 0;
Myron Stoweb26e9282008-11-04 14:53:00 -0700454found:
455 *apic_id = tmp;
456 return 1;
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300457}
458
Myron Stoweb26e9282008-11-04 14:53:00 -0700459static int map_madt_entry(int type, u32 acpi_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300461 unsigned long madt_end, entry;
462 int apic_id = -1;
463
464 if (!madt)
465 return apic_id;
466
467 entry = (unsigned long)madt;
468 madt_end = entry + madt->header.length;
469
470 /* Parse all entries looking for a match. */
471
472 entry += sizeof(struct acpi_table_madt);
473 while (entry + sizeof(struct acpi_subtable_header) < madt_end) {
474 struct acpi_subtable_header *header =
475 (struct acpi_subtable_header *)entry;
476 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
477 if (map_lapic_id(header, acpi_id, &apic_id))
478 break;
479 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
Myron Stoweb26e9282008-11-04 14:53:00 -0700480 if (map_lsapic_id(header, type, acpi_id, &apic_id))
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300481 break;
482 }
483 entry += header->length;
484 }
485 return apic_id;
486}
487
Myron Stoweb26e9282008-11-04 14:53:00 -0700488static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300489{
490 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
491 union acpi_object *obj;
492 struct acpi_subtable_header *header;
493 int apic_id = -1;
494
495 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
496 goto exit;
497
498 if (!buffer.length || !buffer.pointer)
499 goto exit;
500
501 obj = buffer.pointer;
502 if (obj->type != ACPI_TYPE_BUFFER ||
503 obj->buffer.length < sizeof(struct acpi_subtable_header)) {
504 goto exit;
505 }
506
507 header = (struct acpi_subtable_header *)obj->buffer.pointer;
508 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
509 map_lapic_id(header, acpi_id, &apic_id);
510 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
Myron Stoweb26e9282008-11-04 14:53:00 -0700511 map_lsapic_id(header, type, acpi_id, &apic_id);
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300512 }
513
514exit:
515 if (buffer.pointer)
516 kfree(buffer.pointer);
517 return apic_id;
518}
519
Myron Stoweb26e9282008-11-04 14:53:00 -0700520static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id)
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300521{
Len Brown4a35a462005-09-03 12:40:06 -0400522 int i;
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300523 int apic_id = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524
Myron Stoweb26e9282008-11-04 14:53:00 -0700525 apic_id = map_mat_entry(handle, type, acpi_id);
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300526 if (apic_id == -1)
Myron Stoweb26e9282008-11-04 14:53:00 -0700527 apic_id = map_madt_entry(type, acpi_id);
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300528 if (apic_id == -1)
529 return apic_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Christoph Lameterfbb43ab2007-11-28 16:22:08 -0800531 for_each_possible_cpu(i) {
Mike Travis71b31232007-10-19 20:35:03 +0200532 if (cpu_physical_id(i) == apic_id)
Len Brown4a35a462005-09-03 12:40:06 -0400533 return i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 }
535 return -1;
536}
537#endif
538
539/* --------------------------------------------------------------------------
540 Driver Interface
541 -------------------------------------------------------------------------- */
542
Myron Stoweb26e9282008-11-04 14:53:00 -0700543static int acpi_processor_get_info(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544{
Len Brown4be44fc2005-08-05 00:44:28 -0400545 acpi_status status = 0;
546 union acpi_object object = { 0 };
547 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
Myron Stoweb26e9282008-11-04 14:53:00 -0700548 struct acpi_processor *pr;
549 int cpu_index, device_declaration = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400550 static int cpu0_initialized;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551
Myron Stoweb26e9282008-11-04 14:53:00 -0700552 pr = acpi_driver_data(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400554 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555
556 if (num_online_cpus() > 1)
557 errata.smp = TRUE;
558
559 acpi_processor_errata(pr);
560
561 /*
562 * Check to see if we have bus mastering arbitration control. This
563 * is required for proper C3 usage (to maintain cache coherency).
564 */
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300565 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 pr->flags.bm_control = 1;
567 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400568 "Bus mastering arbitration control present\n"));
569 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400571 "No bus mastering arbitration control\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572
Myron Stoweb26e9282008-11-04 14:53:00 -0700573 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_HID)) {
574 /*
575 * Declared with "Device" statement; match _UID.
576 * Note that we don't handle string _UIDs yet.
577 */
Matthew Wilcox27663c52008-10-10 02:22:59 -0400578 unsigned long long value;
Alexey Starikovskiy11bf04c2007-02-02 19:48:23 +0300579 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
580 NULL, &value);
581 if (ACPI_FAILURE(status)) {
Myron Stoweb26e9282008-11-04 14:53:00 -0700582 printk(KERN_ERR PREFIX
583 "Evaluating processor _UID [%#x]\n", status);
Alexey Starikovskiy11bf04c2007-02-02 19:48:23 +0300584 return -ENODEV;
585 }
Myron Stoweb26e9282008-11-04 14:53:00 -0700586 device_declaration = 1;
Alexey Starikovskiy11bf04c2007-02-02 19:48:23 +0300587 pr->acpi_id = value;
588 } else {
Myron Stoweb26e9282008-11-04 14:53:00 -0700589 /* Declared with "Processor" statement; match ProcessorID */
Alexey Starikovskiy11bf04c2007-02-02 19:48:23 +0300590 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
591 if (ACPI_FAILURE(status)) {
592 printk(KERN_ERR PREFIX "Evaluating processor object\n");
593 return -ENODEV;
594 }
595
596 /*
Myron Stowe5b53ed62008-11-04 14:53:05 -0700597 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
598 * >>> 'acpi_get_processor_id(acpi_id, &id)' in
599 * arch/xxx/acpi.c
600 */
Alexey Starikovskiy11bf04c2007-02-02 19:48:23 +0300601 pr->acpi_id = object.processor.proc_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 }
Myron Stoweb26e9282008-11-04 14:53:00 -0700603 cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
Len Brown4be44fc2005-08-05 00:44:28 -0400605 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
Ashok Rajdf42baa2006-03-28 17:04:00 -0500606 if (!cpu0_initialized && (cpu_index == -1) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400607 (num_online_cpus() == 1)) {
608 cpu_index = 0;
609 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
Len Brown4be44fc2005-08-05 00:44:28 -0400611 cpu0_initialized = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612
Len Brown4be44fc2005-08-05 00:44:28 -0400613 pr->id = cpu_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614
Len Brown4be44fc2005-08-05 00:44:28 -0400615 /*
616 * Extra Processor objects may be enumerated on MP systems with
617 * less than the max # of CPUs. They should be ignored _iff
618 * they are physically not present.
619 */
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +0300620 if (pr->id == -1) {
Len Brown4be44fc2005-08-05 00:44:28 -0400621 if (ACPI_FAILURE
622 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400623 return -ENODEV;
Len Brown4be44fc2005-08-05 00:44:28 -0400624 }
625 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
627 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
Len Brown4be44fc2005-08-05 00:44:28 -0400628 pr->acpi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
630 if (!object.processor.pblk_address)
631 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
632 else if (object.processor.pblk_length != 6)
Len Brown64684632006-06-26 23:41:38 -0400633 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
634 object.processor.pblk_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 else {
636 pr->throttling.address = object.processor.pblk_address;
Alexey Starikovskiycee324b2007-02-02 19:48:22 +0300637 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
638 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
640 pr->pblk = object.processor.pblk_address;
641
642 /*
643 * We don't care about error returns - we just try to mark
644 * these reserved so that nobody else is confused into thinking
645 * that this region might be unused..
646 *
647 * (In particular, allocating the IO range for Cardbus)
648 */
649 request_region(pr->throttling.address, 6, "ACPI CPU throttle");
650 }
651
Alex Chiangfe086a72008-04-29 15:05:29 -0700652 /*
653 * If ACPI describes a slot number for this CPU, we can use it
654 * ensure we get the right value in the "physical id" field
655 * of /proc/cpuinfo
656 */
657 status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer);
658 if (ACPI_SUCCESS(status))
659 arch_fix_phys_package_id(pr->id, object.integer.value);
660
Patrick Mocheld550d982006-06-27 00:41:40 -0400661 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662}
663
Mike Travis706546d2008-06-09 16:22:23 -0700664static DEFINE_PER_CPU(void *, processor_device_array);
Venkatesh Pallipadicd8e2b42005-10-21 19:22:00 -0400665
Pierre Ossman7af8b662006-10-10 14:20:31 -0700666static int __cpuinit acpi_processor_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667{
Len Brown4be44fc2005-08-05 00:44:28 -0400668 int result = 0;
669 acpi_status status = AE_OK;
670 struct acpi_processor *pr;
Zhang Rui9f1eb992008-04-29 02:36:07 -0400671 struct sys_device *sysdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672
673 pr = acpi_driver_data(device);
674
Myron Stoweb26e9282008-11-04 14:53:00 -0700675 result = acpi_processor_get_info(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 if (result) {
677 /* Processor is physically not present */
Patrick Mocheld550d982006-06-27 00:41:40 -0400678 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 }
680
Christoph Lameterfbb43ab2007-11-28 16:22:08 -0800681 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
Venkatesh Pallipadicd8e2b42005-10-21 19:22:00 -0400683 /*
684 * Buggy BIOS check
685 * ACPI id of processors can be reported wrongly by the BIOS.
686 * Don't trust it blindly
687 */
Mike Travis706546d2008-06-09 16:22:23 -0700688 if (per_cpu(processor_device_array, pr->id) != NULL &&
689 per_cpu(processor_device_array, pr->id) != device) {
Joe Perches4fdb2a02007-11-19 17:48:02 -0800690 printk(KERN_WARNING "BIOS reported wrong ACPI id "
Len Brown0eacee52006-03-31 00:37:23 -0500691 "for the processor\n");
Patrick Mocheld550d982006-06-27 00:41:40 -0400692 return -ENODEV;
Venkatesh Pallipadicd8e2b42005-10-21 19:22:00 -0400693 }
Mike Travis706546d2008-06-09 16:22:23 -0700694 per_cpu(processor_device_array, pr->id) = device;
Venkatesh Pallipadicd8e2b42005-10-21 19:22:00 -0400695
Mike Travis706546d2008-06-09 16:22:23 -0700696 per_cpu(processors, pr->id) = pr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697
698 result = acpi_processor_add_fs(device);
699 if (result)
700 goto end;
701
Zhang Rui9f1eb992008-04-29 02:36:07 -0400702 sysdev = get_cpu_sysdev(pr->id);
703 if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev"))
704 return -EFAULT;
705
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
Len Brown4be44fc2005-08-05 00:44:28 -0400707 acpi_processor_notify, pr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400709 /* _PDC call should be done before doing anything else (if reqd.). */
710 arch_acpi_processor_init_pdc(pr);
711 acpi_processor_set_pdc(pr);
Zhao Yakui0ac3c572007-11-15 17:05:46 +0800712#ifdef CONFIG_CPU_FREQ
713 acpi_processor_ppc_has_changed(pr);
714#endif
715 acpi_processor_get_throttling_info(pr);
716 acpi_processor_get_limit_info(pr);
717
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400718
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 acpi_processor_power_init(pr, device);
720
Zhang Ruid9460fd222008-01-17 15:51:23 +0800721 pr->cdev = thermal_cooling_device_register("Processor", device,
722 &processor_cooling_ops);
Thomas Sujithd76628c2008-02-15 18:26:54 -0500723 if (IS_ERR(pr->cdev)) {
724 result = PTR_ERR(pr->cdev);
725 goto end;
726 }
Zhang Ruid9460fd222008-01-17 15:51:23 +0800727
Greg Kroah-Hartmanfc3a8822008-05-02 06:02:41 +0200728 dev_info(&device->dev, "registered as cooling_device%d\n",
729 pr->cdev->id);
Julia Lawall90300622008-04-11 10:09:24 +0800730
731 result = sysfs_create_link(&device->dev.kobj,
732 &pr->cdev->device.kobj,
733 "thermal_cooling");
734 if (result)
735 printk(KERN_ERR PREFIX "Create sysfs link\n");
736 result = sysfs_create_link(&pr->cdev->device.kobj,
737 &device->dev.kobj,
738 "device");
739 if (result)
740 printk(KERN_ERR PREFIX "Create sysfs link\n");
Zhang Ruid9460fd222008-01-17 15:51:23 +0800741
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 if (pr->flags.throttling) {
743 printk(KERN_INFO PREFIX "%s [%s] (supports",
Len Brown4be44fc2005-08-05 00:44:28 -0400744 acpi_device_name(device), acpi_device_bid(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 printk(" %d throttling states", pr->throttling.state_count);
746 printk(")\n");
747 }
748
Len Brown4be44fc2005-08-05 00:44:28 -0400749 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750
Patrick Mocheld550d982006-06-27 00:41:40 -0400751 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752}
753
Len Brown4be44fc2005-08-05 00:44:28 -0400754static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200756 struct acpi_processor *pr = data;
Len Brown4be44fc2005-08-05 00:44:28 -0400757 struct acpi_device *device = NULL;
Alexey Starikovskiye790cc82007-11-21 03:23:32 +0300758 int saved;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759
760 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400761 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762
763 if (acpi_bus_get_device(pr->handle, &device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400764 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765
766 switch (event) {
767 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
Alexey Starikovskiye790cc82007-11-21 03:23:32 +0300768 saved = pr->performance_platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 acpi_processor_ppc_has_changed(pr);
Alexey Starikovskiye790cc82007-11-21 03:23:32 +0300770 if (saved == pr->performance_platform_limit)
771 break;
Len Brown14e04fb2007-08-23 15:20:26 -0400772 acpi_bus_generate_proc_event(device, event,
Len Brown4be44fc2005-08-05 00:44:28 -0400773 pr->performance_platform_limit);
Zhang Rui962ce8c2007-08-23 01:24:31 +0800774 acpi_bus_generate_netlink_event(device->pnp.device_class,
Kay Sievers07944692008-10-30 01:18:59 +0100775 dev_name(&device->dev), event,
Zhang Rui962ce8c2007-08-23 01:24:31 +0800776 pr->performance_platform_limit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 break;
778 case ACPI_PROCESSOR_NOTIFY_POWER:
779 acpi_processor_cst_has_changed(pr);
Len Brown14e04fb2007-08-23 15:20:26 -0400780 acpi_bus_generate_proc_event(device, event, 0);
Zhang Rui962ce8c2007-08-23 01:24:31 +0800781 acpi_bus_generate_netlink_event(device->pnp.device_class,
Kay Sievers07944692008-10-30 01:18:59 +0100782 dev_name(&device->dev), event, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 break;
Luming Yu01854e62007-05-26 22:49:58 +0800784 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
785 acpi_processor_tstate_has_changed(pr);
Len Brown14e04fb2007-08-23 15:20:26 -0400786 acpi_bus_generate_proc_event(device, event, 0);
Zhang Rui962ce8c2007-08-23 01:24:31 +0800787 acpi_bus_generate_netlink_event(device->pnp.device_class,
Kay Sievers07944692008-10-30 01:18:59 +0100788 dev_name(&device->dev), event, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 default:
790 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400791 "Unsupported event [0x%x]\n", event));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 break;
793 }
794
Patrick Mocheld550d982006-06-27 00:41:40 -0400795 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796}
797
Venkatesh Pallipadi729c6ba2007-09-16 15:36:43 +0200798static int acpi_cpu_soft_notify(struct notifier_block *nfb,
799 unsigned long action, void *hcpu)
800{
801 unsigned int cpu = (unsigned long)hcpu;
Mike Travis706546d2008-06-09 16:22:23 -0700802 struct acpi_processor *pr = per_cpu(processors, cpu);
Venkatesh Pallipadi729c6ba2007-09-16 15:36:43 +0200803
804 if (action == CPU_ONLINE && pr) {
805 acpi_processor_ppc_has_changed(pr);
806 acpi_processor_cst_has_changed(pr);
807 acpi_processor_tstate_has_changed(pr);
808 }
809 return NOTIFY_OK;
810}
811
812static struct notifier_block acpi_cpu_notifier =
813{
814 .notifier_call = acpi_cpu_soft_notify,
815};
816
Len Brown4be44fc2005-08-05 00:44:28 -0400817static int acpi_processor_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818{
Len Brown4be44fc2005-08-05 00:44:28 -0400819 struct acpi_processor *pr = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821
822 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400823 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824
Burman Yan36bcbec2006-12-19 12:56:11 -0800825 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400827 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800829 if (!alloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
830 kfree(pr);
831 return -ENOMEM;
832 }
833
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 pr->handle = device->handle;
835 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
836 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
Pavel Machekdb89b4f2008-09-22 14:37:34 -0700837 device->driver_data = pr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838
Patrick Mocheld550d982006-06-27 00:41:40 -0400839 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840}
841
Len Brown4be44fc2005-08-05 00:44:28 -0400842static int acpi_processor_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843{
Len Brown4be44fc2005-08-05 00:44:28 -0400844 acpi_status status = AE_OK;
845 struct acpi_processor *pr = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
848 if (!device || !acpi_driver_data(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400849 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200851 pr = acpi_driver_data(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800853 if (pr->id >= nr_cpu_ids)
854 goto free;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855
856 if (type == ACPI_BUS_REMOVAL_EJECT) {
857 if (acpi_processor_handle_eject(pr))
Patrick Mocheld550d982006-06-27 00:41:40 -0400858 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 }
860
861 acpi_processor_power_exit(pr, device);
862
863 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
Len Brown4be44fc2005-08-05 00:44:28 -0400864 acpi_processor_notify);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865
Zhang Rui9f1eb992008-04-29 02:36:07 -0400866 sysfs_remove_link(&device->dev.kobj, "sysdev");
867
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 acpi_processor_remove_fs(device);
869
Zhao Yakuif28bb452008-02-15 08:34:37 +0800870 if (pr->cdev) {
871 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
872 sysfs_remove_link(&pr->cdev->device.kobj, "device");
873 thermal_cooling_device_unregister(pr->cdev);
874 pr->cdev = NULL;
875 }
Zhang Ruid9460fd222008-01-17 15:51:23 +0800876
Mike Travis706546d2008-06-09 16:22:23 -0700877 per_cpu(processors, pr->id) = NULL;
878 per_cpu(processor_device_array, pr->id) = NULL;
Rusty Russell2fdf66b2008-12-31 18:08:47 -0800879
880free:
881 free_cpumask_var(pr->throttling.shared_cpu_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 kfree(pr);
883
Patrick Mocheld550d982006-06-27 00:41:40 -0400884 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885}
886
887#ifdef CONFIG_ACPI_HOTPLUG_CPU
888/****************************************************************************
889 * Acpi processor hotplug support *
890 ****************************************************************************/
891
Len Brown4be44fc2005-08-05 00:44:28 -0400892static int is_processor_present(acpi_handle handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893{
Len Brown4be44fc2005-08-05 00:44:28 -0400894 acpi_status status;
Matthew Wilcox27663c52008-10-10 02:22:59 -0400895 unsigned long long sta = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897
898 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
Zhang Ruicfaf3742008-01-09 02:17:47 -0500899
900 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT))
901 return 1;
902
Zhang Ruid0ce46f2008-02-23 01:53:09 -0500903 /*
904 * _STA is mandatory for a processor that supports hot plug
905 */
906 if (status == AE_NOT_FOUND)
907 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
908 "Processor does not support hot plug\n"));
909 else
910 ACPI_EXCEPTION((AE_INFO, status,
911 "Processor Device is not present"));
Zhang Ruicfaf3742008-01-09 02:17:47 -0500912 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913}
914
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915static
Len Brown4be44fc2005-08-05 00:44:28 -0400916int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917{
Len Brown4be44fc2005-08-05 00:44:28 -0400918 acpi_handle phandle;
919 struct acpi_device *pdev;
920 struct acpi_processor *pr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922
923 if (acpi_get_parent(handle, &phandle)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400924 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 }
926
927 if (acpi_bus_get_device(phandle, &pdev)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400928 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 }
930
931 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400932 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 }
934
Rajesh Shah3fb02732005-04-28 00:25:52 -0700935 acpi_bus_start(*device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936
937 pr = acpi_driver_data(*device);
938 if (!pr)
Patrick Mocheld550d982006-06-27 00:41:40 -0400939 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940
Christoph Lameterfbb43ab2007-11-28 16:22:08 -0800941 if ((pr->id >= 0) && (pr->id < nr_cpu_ids)) {
Patrick Mochelf883d9d2006-12-07 20:56:38 +0800942 kobject_uevent(&(*device)->dev.kobj, KOBJ_ONLINE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 }
Patrick Mocheld550d982006-06-27 00:41:40 -0400944 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945}
946
Sam Ravnborgb95e9e82008-02-17 13:22:48 +0100947static void __ref acpi_processor_hotplug_notify(acpi_handle handle,
948 u32 event, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949{
Len Brown4be44fc2005-08-05 00:44:28 -0400950 struct acpi_processor *pr;
951 struct acpi_device *device = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 int result;
953
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954
955 switch (event) {
956 case ACPI_NOTIFY_BUS_CHECK:
957 case ACPI_NOTIFY_DEVICE_CHECK:
Glauber Costad6f882e2008-03-04 15:06:36 -0800958 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
959 "Processor driver received %s event\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400960 (event == ACPI_NOTIFY_BUS_CHECK) ?
Glauber Costad6f882e2008-03-04 15:06:36 -0800961 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962
963 if (!is_processor_present(handle))
964 break;
965
966 if (acpi_bus_get_device(handle, &device)) {
967 result = acpi_processor_device_add(handle, &device);
968 if (result)
Len Brown64684632006-06-26 23:41:38 -0400969 printk(KERN_ERR PREFIX
970 "Unable to add the device\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 break;
972 }
973
974 pr = acpi_driver_data(device);
975 if (!pr) {
Len Brown64684632006-06-26 23:41:38 -0400976 printk(KERN_ERR PREFIX "Driver data is NULL\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 break;
978 }
979
Christoph Lameterfbb43ab2007-11-28 16:22:08 -0800980 if (pr->id >= 0 && (pr->id < nr_cpu_ids)) {
Patrick Mochelf883d9d2006-12-07 20:56:38 +0800981 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982 break;
983 }
984
985 result = acpi_processor_start(device);
Christoph Lameterfbb43ab2007-11-28 16:22:08 -0800986 if ((!result) && ((pr->id >= 0) && (pr->id < nr_cpu_ids))) {
Patrick Mochelf883d9d2006-12-07 20:56:38 +0800987 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 } else {
Len Brown64684632006-06-26 23:41:38 -0400989 printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
990 acpi_device_bid(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 }
Len Brown4be44fc2005-08-05 00:44:28 -0400992 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 case ACPI_NOTIFY_EJECT_REQUEST:
Len Brown4be44fc2005-08-05 00:44:28 -0400994 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
995 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996
997 if (acpi_bus_get_device(handle, &device)) {
Len Brown64684632006-06-26 23:41:38 -0400998 printk(KERN_ERR PREFIX
999 "Device don't exist, dropping EJECT\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 break;
1001 }
1002 pr = acpi_driver_data(device);
1003 if (!pr) {
Len Brown64684632006-06-26 23:41:38 -04001004 printk(KERN_ERR PREFIX
1005 "Driver data is NULL, dropping EJECT\n");
Patrick Mocheld550d982006-06-27 00:41:40 -04001006 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 }
1008
Christoph Lameterfbb43ab2007-11-28 16:22:08 -08001009 if ((pr->id < nr_cpu_ids) && (cpu_present(pr->id)))
Patrick Mochelf883d9d2006-12-07 20:56:38 +08001010 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 break;
1012 default:
1013 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -04001014 "Unsupported event [0x%x]\n", event));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 break;
1016 }
1017
Patrick Mocheld550d982006-06-27 00:41:40 -04001018 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019}
1020
1021static acpi_status
1022processor_walk_namespace_cb(acpi_handle handle,
Len Brown4be44fc2005-08-05 00:44:28 -04001023 u32 lvl, void *context, void **rv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024{
Len Brown4be44fc2005-08-05 00:44:28 -04001025 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 int *action = context;
Len Brown4be44fc2005-08-05 00:44:28 -04001027 acpi_object_type type = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028
1029 status = acpi_get_type(handle, &type);
1030 if (ACPI_FAILURE(status))
Len Brown4be44fc2005-08-05 00:44:28 -04001031 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032
1033 if (type != ACPI_TYPE_PROCESSOR)
Len Brown4be44fc2005-08-05 00:44:28 -04001034 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035
Len Brown4be44fc2005-08-05 00:44:28 -04001036 switch (*action) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 case INSTALL_NOTIFY_HANDLER:
1038 acpi_install_notify_handler(handle,
Len Brown4be44fc2005-08-05 00:44:28 -04001039 ACPI_SYSTEM_NOTIFY,
1040 acpi_processor_hotplug_notify,
1041 NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 break;
1043 case UNINSTALL_NOTIFY_HANDLER:
1044 acpi_remove_notify_handler(handle,
Len Brown4be44fc2005-08-05 00:44:28 -04001045 ACPI_SYSTEM_NOTIFY,
1046 acpi_processor_hotplug_notify);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 break;
1048 default:
1049 break;
1050 }
1051
Len Brown4be44fc2005-08-05 00:44:28 -04001052 return (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053}
1054
Len Brown4be44fc2005-08-05 00:44:28 -04001055static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057
1058 if (!is_processor_present(handle)) {
Patrick Mocheld550d982006-06-27 00:41:40 -04001059 return AE_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 }
1061
1062 if (acpi_map_lsapic(handle, p_cpu))
Patrick Mocheld550d982006-06-27 00:41:40 -04001063 return AE_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064
1065 if (arch_register_cpu(*p_cpu)) {
1066 acpi_unmap_lsapic(*p_cpu);
Patrick Mocheld550d982006-06-27 00:41:40 -04001067 return AE_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 }
1069
Patrick Mocheld550d982006-06-27 00:41:40 -04001070 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071}
1072
Len Brown4be44fc2005-08-05 00:44:28 -04001073static int acpi_processor_handle_eject(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074{
Zhang Ruib62b8ef2008-04-29 02:35:56 -04001075 if (cpu_online(pr->id))
1076 cpu_down(pr->id);
1077
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 arch_unregister_cpu(pr->id);
1079 acpi_unmap_lsapic(pr->id);
Len Brown4be44fc2005-08-05 00:44:28 -04001080 return (0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081}
1082#else
Len Brown4be44fc2005-08-05 00:44:28 -04001083static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084{
1085 return AE_ERROR;
1086}
Len Brown4be44fc2005-08-05 00:44:28 -04001087static int acpi_processor_handle_eject(struct acpi_processor *pr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088{
Len Brown4be44fc2005-08-05 00:44:28 -04001089 return (-EINVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090}
1091#endif
1092
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093static
1094void acpi_processor_install_hotplug_notify(void)
1095{
1096#ifdef CONFIG_ACPI_HOTPLUG_CPU
1097 int action = INSTALL_NOTIFY_HANDLER;
1098 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
Len Brown4be44fc2005-08-05 00:44:28 -04001099 ACPI_ROOT_OBJECT,
1100 ACPI_UINT32_MAX,
1101 processor_walk_namespace_cb, &action, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102#endif
Venkatesh Pallipadi729c6ba2007-09-16 15:36:43 +02001103 register_hotcpu_notifier(&acpi_cpu_notifier);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104}
1105
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106static
1107void acpi_processor_uninstall_hotplug_notify(void)
1108{
1109#ifdef CONFIG_ACPI_HOTPLUG_CPU
1110 int action = UNINSTALL_NOTIFY_HANDLER;
1111 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
Len Brown4be44fc2005-08-05 00:44:28 -04001112 ACPI_ROOT_OBJECT,
1113 ACPI_UINT32_MAX,
1114 processor_walk_namespace_cb, &action, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115#endif
Venkatesh Pallipadi729c6ba2007-09-16 15:36:43 +02001116 unregister_hotcpu_notifier(&acpi_cpu_notifier);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117}
1118
1119/*
1120 * We keep the driver loaded even when ACPI is not running.
1121 * This is needed for the powernow-k8 driver, that works even without
1122 * ACPI, but needs symbols from this driver
1123 */
1124
Len Brown4be44fc2005-08-05 00:44:28 -04001125static int __init acpi_processor_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126{
Len Brown4be44fc2005-08-05 00:44:28 -04001127 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 memset(&errata, 0, sizeof(errata));
1130
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +03001131#ifdef CONFIG_SMP
1132 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0,
1133 (struct acpi_table_header **)&madt)))
Randy Dunlap70c08462007-02-13 16:11:36 -08001134 madt = NULL;
Alexey Starikovskiyf18c5a02007-02-02 19:48:23 +03001135#endif
1136
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1138 if (!acpi_processor_dir)
Akinobu Mita83822fc2006-12-19 12:56:10 -08001139 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 acpi_processor_dir->owner = THIS_MODULE;
1141
Zhao Yakui2a2a6472008-06-24 18:02:57 +08001142 /*
1143 * Check whether the system is DMI table. If yes, OSPM
1144 * should not use mwait for CPU-states.
1145 */
1146 dmi_check_system(processor_idle_dmi_table);
Len Brown4f86d3a2007-10-03 18:58:00 -04001147 result = cpuidle_register_driver(&acpi_idle_driver);
1148 if (result < 0)
1149 goto out_proc;
1150
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 result = acpi_bus_register_driver(&acpi_processor_driver);
Len Brown4f86d3a2007-10-03 18:58:00 -04001152 if (result < 0)
1153 goto out_cpuidle;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154
1155 acpi_processor_install_hotplug_notify();
1156
1157 acpi_thermal_cpufreq_init();
1158
1159 acpi_processor_ppc_init();
1160
Zhao Yakui11805092008-01-28 13:53:42 +08001161 acpi_processor_throttling_init();
1162
Patrick Mocheld550d982006-06-27 00:41:40 -04001163 return 0;
Len Brown4f86d3a2007-10-03 18:58:00 -04001164
1165out_cpuidle:
1166 cpuidle_unregister_driver(&acpi_idle_driver);
1167
1168out_proc:
1169 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1170
1171 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172}
1173
Len Brown4be44fc2005-08-05 00:44:28 -04001174static void __exit acpi_processor_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 acpi_processor_ppc_exit();
1177
1178 acpi_thermal_cpufreq_exit();
1179
1180 acpi_processor_uninstall_hotplug_notify();
1181
1182 acpi_bus_unregister_driver(&acpi_processor_driver);
1183
Len Brown4f86d3a2007-10-03 18:58:00 -04001184 cpuidle_unregister_driver(&acpi_idle_driver);
1185
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1187
Patrick Mocheld550d982006-06-27 00:41:40 -04001188 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189}
1190
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191module_init(acpi_processor_init);
1192module_exit(acpi_processor_exit);
1193
1194EXPORT_SYMBOL(acpi_processor_set_thermal_limit);
1195
1196MODULE_ALIAS("processor");