x86: use cpumask_var_t in acpi/boot.c
[deliverable/linux.git] / drivers / acpi / processor_core.c
CommitLineData
1da177e4
LT
1/*
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>
4f86d3a8 47#include <linux/cpuidle.h>
1da177e4
LT
48
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
1da177e4 62#define ACPI_PROCESSOR_CLASS "processor"
1da177e4
LT
63#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
01854e69 69#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
1da177e4
LT
70
71#define ACPI_PROCESSOR_LIMIT_USER 0
72#define ACPI_PROCESSOR_LIMIT_THERMAL 1
73
1da177e4 74#define _COMPONENT ACPI_PROCESSOR_COMPONENT
f52fd66d 75ACPI_MODULE_NAME("processor_core");
1da177e4 76
f52fd66d 77MODULE_AUTHOR("Paul Diefenbaugh");
7cda93e0 78MODULE_DESCRIPTION("ACPI Processor Driver");
1da177e4
LT
79MODULE_LICENSE("GPL");
80
4be44fcd
LB
81static 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);
1da177e4 84static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
4be44fcd 85static void acpi_processor_notify(acpi_handle handle, u32 event, void *data);
1da177e4
LT
86static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
87static int acpi_processor_handle_eject(struct acpi_processor *pr);
01854e69 88
1da177e4 89
1ba90e3a 90static const struct acpi_device_id processor_device_ids[] = {
ad93a765 91 {ACPI_PROCESSOR_OBJECT_HID, 0},
1ba90e3a
TR
92 {ACPI_PROCESSOR_HID, 0},
93 {"", 0},
94};
95MODULE_DEVICE_TABLE(acpi, processor_device_ids);
96
1da177e4 97static struct acpi_driver acpi_processor_driver = {
c2b6705b 98 .name = "processor",
4be44fcd 99 .class = ACPI_PROCESSOR_CLASS,
1ba90e3a 100 .ids = processor_device_ids,
4be44fcd
LB
101 .ops = {
102 .add = acpi_processor_add,
103 .remove = acpi_processor_remove,
104 .start = acpi_processor_start,
b04e7bdb
TG
105 .suspend = acpi_processor_suspend,
106 .resume = acpi_processor_resume,
4be44fcd 107 },
1da177e4
LT
108};
109
110#define INSTALL_NOTIFY_HANDLER 1
111#define UNINSTALL_NOTIFY_HANDLER 2
112
d7508032 113static const struct file_operations acpi_processor_info_fops = {
cf7acfab 114 .owner = THIS_MODULE,
4be44fcd
LB
115 .open = acpi_processor_info_open_fs,
116 .read = seq_read,
117 .llseek = seq_lseek,
118 .release = single_release,
1da177e4
LT
119};
120
706546d0 121DEFINE_PER_CPU(struct acpi_processor *, processors);
9f222718 122struct acpi_processor_errata errata __read_mostly;
2a2a6471
ZY
123static int set_no_mwait(const struct dmi_system_id *id)
124{
125 printk(KERN_NOTICE PREFIX "%s detected - "
d0057413 126 "disabling mwait for CPU C-states\n", id->ident);
2a2a6471
ZY
127 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"),
3df8a905 141 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
2a2a6471
ZY
142 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
143 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
144 {},
145};
1da177e4 146
1da177e4
LT
147/* --------------------------------------------------------------------------
148 Errata Handling
149 -------------------------------------------------------------------------- */
150
4be44fcd 151static int acpi_processor_errata_piix4(struct pci_dev *dev)
1da177e4 152{
4be44fcd
LB
153 u8 value1 = 0;
154 u8 value2 = 0;
1da177e4 155
1da177e4
LT
156
157 if (!dev)
d550d98d 158 return -EINVAL;
1da177e4
LT
159
160 /*
161 * Note that 'dev' references the PIIX4 ACPI Controller.
162 */
163
44c10138 164 switch (dev->revision) {
1da177e4
LT
165 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
44c10138 182 switch (dev->revision) {
1da177e4
LT
183
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,
4be44fcd
LB
212 PCI_DEVICE_ID_INTEL_82371AB,
213 PCI_ANY_ID, PCI_ANY_ID, NULL);
1da177e4
LT
214 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,
4be44fcd
LB
229 PCI_DEVICE_ID_INTEL_82371AB_0,
230 PCI_ANY_ID, PCI_ANY_ID, NULL);
1da177e4
LT
231 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,
4be44fcd 244 "Bus master activity detection (BM-IDE) erratum enabled\n"));
1da177e4
LT
245 if (errata.piix4.fdma)
246 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
4be44fcd 247 "Type-F DMA livelock erratum (C3 disabled)\n"));
1da177e4 248
d550d98d 249 return 0;
1da177e4
LT
250}
251
8713cbef 252static int acpi_processor_errata(struct acpi_processor *pr)
1da177e4 253{
4be44fcd
LB
254 int result = 0;
255 struct pci_dev *dev = NULL;
1da177e4 256
1da177e4
LT
257
258 if (!pr)
d550d98d 259 return -EINVAL;
1da177e4
LT
260
261 /*
262 * PIIX4
263 */
264 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
4be44fcd
LB
265 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
266 PCI_ANY_ID, NULL);
1da177e4
LT
267 if (dev) {
268 result = acpi_processor_errata_piix4(dev);
269 pci_dev_put(dev);
270 }
271
d550d98d 272 return result;
1da177e4
LT
273}
274
02df8b93 275/* --------------------------------------------------------------------------
0b28002f 276 Common ACPI processor functions
02df8b93
VP
277 -------------------------------------------------------------------------- */
278
279/*
280 * _PDC is required for a BIOS-OS handshake for most of the newer
281 * ACPI processor features.
282 */
05131ecc 283static int acpi_processor_set_pdc(struct acpi_processor *pr)
02df8b93 284{
05131ecc 285 struct acpi_object_list *pdc_in = pr->pdc;
4be44fcd 286 acpi_status status = AE_OK;
02df8b93 287
02df8b93 288
05131ecc 289 if (!pdc_in)
d550d98d 290 return status;
da5e09a1
ZY
291 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;
02df8b93 299
da5e09a1
ZY
300 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 }
05131ecc 305 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
02df8b93 306
05131ecc 307 if (ACPI_FAILURE(status))
4be44fcd 308 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
05131ecc 309 "Could not evaluate _PDC, using legacy perf. control...\n"));
02df8b93 310
d550d98d 311 return status;
02df8b93
VP
312}
313
1da177e4
LT
314/* --------------------------------------------------------------------------
315 FS Interface (/proc)
316 -------------------------------------------------------------------------- */
317
4be44fcd 318static struct proc_dir_entry *acpi_processor_dir = NULL;
1da177e4
LT
319
320static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
321{
50dd0969 322 struct acpi_processor *pr = seq->private;
1da177e4 323
1da177e4
LT
324
325 if (!pr)
326 goto end;
327
328 seq_printf(seq, "processor id: %d\n"
4be44fcd
LB
329 "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");
340
341 end:
d550d98d 342 return 0;
1da177e4
LT
343}
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,
4be44fcd 348 PDE(inode)->data);
1da177e4
LT
349}
350
4be44fcd 351static int acpi_processor_add_fs(struct acpi_device *device)
1da177e4 352{
4be44fcd 353 struct proc_dir_entry *entry = NULL;
1da177e4 354
1da177e4
LT
355
356 if (!acpi_device_dir(device)) {
357 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
4be44fcd 358 acpi_processor_dir);
1da177e4 359 if (!acpi_device_dir(device))
d550d98d 360 return -ENODEV;
1da177e4
LT
361 }
362 acpi_device_dir(device)->owner = THIS_MODULE;
363
364 /* 'info' [R] */
cf7acfab
DL
365 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));
1da177e4 369 if (!entry)
d550d98d 370 return -EIO;
1da177e4
LT
371
372 /* 'throttling' [R/W] */
cf7acfab
DL
373 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));
1da177e4 378 if (!entry)
d550d98d 379 return -EIO;
1da177e4
LT
380
381 /* 'limit' [R/W] */
cf7acfab
DL
382 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));
1da177e4 387 if (!entry)
d550d98d 388 return -EIO;
d550d98d 389 return 0;
1da177e4
LT
390}
391
4be44fcd 392static int acpi_processor_remove_fs(struct acpi_device *device)
1da177e4 393{
1da177e4
LT
394
395 if (acpi_device_dir(device)) {
4be44fcd
LB
396 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
397 acpi_device_dir(device));
1da177e4 398 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
4be44fcd
LB
399 acpi_device_dir(device));
400 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
401 acpi_device_dir(device));
1da177e4
LT
402 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
403 acpi_device_dir(device) = NULL;
404 }
405
d550d98d 406 return 0;
1da177e4
LT
407}
408
409/* Use the acpiid in MADT to map cpus in case of SMP */
f18c5a08 410
1da177e4 411#ifndef CONFIG_SMP
b26e9286 412static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; }
1da177e4
LT
413#else
414
f18c5a08
AS
415static 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,
b26e9286 431 int device_declaration, u32 acpi_id, int *apic_id)
f18c5a08
AS
432{
433 struct acpi_madt_local_sapic *lsapic =
434 (struct acpi_madt_local_sapic *)entry;
b26e9286
MS
435 u32 tmp = (lsapic->id << 8) | lsapic->eid;
436
f18c5a08 437 /* Only check enabled APICs*/
b26e9286
MS
438 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
f18c5a08 453 return 0;
b26e9286
MS
454found:
455 *apic_id = tmp;
456 return 1;
f18c5a08
AS
457}
458
b26e9286 459static int map_madt_entry(int type, u32 acpi_id)
f18c5a08
AS
460{
461 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) {
b26e9286 480 if (map_lsapic_id(header, type, acpi_id, &apic_id))
f18c5a08
AS
481 break;
482 }
483 entry += header->length;
484 }
485 return apic_id;
486}
487
b26e9286 488static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
f18c5a08
AS
489{
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) {
b26e9286 511 map_lsapic_id(header, type, acpi_id, &apic_id);
f18c5a08
AS
512 }
513
514exit:
515 if (buffer.pointer)
516 kfree(buffer.pointer);
517 return apic_id;
518}
519
b26e9286 520static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id)
1da177e4 521{
4a35a46b 522 int i;
f18c5a08 523 int apic_id = -1;
1da177e4 524
b26e9286 525 apic_id = map_mat_entry(handle, type, acpi_id);
f18c5a08 526 if (apic_id == -1)
b26e9286 527 apic_id = map_madt_entry(type, acpi_id);
f18c5a08
AS
528 if (apic_id == -1)
529 return apic_id;
1da177e4 530
fbb43ab0 531 for_each_possible_cpu(i) {
71b31233 532 if (cpu_physical_id(i) == apic_id)
4a35a46b 533 return i;
1da177e4
LT
534 }
535 return -1;
536}
537#endif
538
539/* --------------------------------------------------------------------------
540 Driver Interface
541 -------------------------------------------------------------------------- */
542
b26e9286 543static int acpi_processor_get_info(struct acpi_device *device)
1da177e4 544{
4be44fcd
LB
545 acpi_status status = 0;
546 union acpi_object object = { 0 };
547 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
b26e9286
MS
548 struct acpi_processor *pr;
549 int cpu_index, device_declaration = 0;
4be44fcd 550 static int cpu0_initialized;
1da177e4 551
b26e9286 552 pr = acpi_driver_data(device);
1da177e4 553 if (!pr)
d550d98d 554 return -EINVAL;
1da177e4
LT
555
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 */
cee324b1 565 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
1da177e4
LT
566 pr->flags.bm_control = 1;
567 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
4be44fcd
LB
568 "Bus mastering arbitration control present\n"));
569 } else
1da177e4 570 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
4be44fcd 571 "No bus mastering arbitration control\n"));
1da177e4 572
b26e9286
MS
573 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 */
27663c58 578 unsigned long long value;
11bf04c4
AS
579 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
580 NULL, &value);
581 if (ACPI_FAILURE(status)) {
b26e9286
MS
582 printk(KERN_ERR PREFIX
583 "Evaluating processor _UID [%#x]\n", status);
11bf04c4
AS
584 return -ENODEV;
585 }
b26e9286 586 device_declaration = 1;
11bf04c4
AS
587 pr->acpi_id = value;
588 } else {
b26e9286 589 /* Declared with "Processor" statement; match ProcessorID */
11bf04c4
AS
590 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 }
1da177e4 595
11bf04c4 596 /*
5b53ed69
MS
597 * 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 */
11bf04c4
AS
601 pr->acpi_id = object.processor.proc_id;
602 }
b26e9286 603 cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id);
1da177e4 604
4be44fcd 605 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
df42baa0 606 if (!cpu0_initialized && (cpu_index == -1) &&
4be44fcd
LB
607 (num_online_cpus() == 1)) {
608 cpu_index = 0;
609 }
610
611 cpu0_initialized = 1;
612
613 pr->id = cpu_index;
614
615 /*
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 */
f18c5a08 620 if (pr->id == -1) {
4be44fcd
LB
621 if (ACPI_FAILURE
622 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
d550d98d 623 return -ENODEV;
4be44fcd
LB
624 }
625 }
1da177e4
LT
626
627 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
4be44fcd 628 pr->acpi_id));
1da177e4
LT
629
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)
6468463a
LB
633 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
634 object.processor.pblk_length);
1da177e4
LT
635 else {
636 pr->throttling.address = object.processor.pblk_address;
cee324b1
AS
637 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
638 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
1da177e4
LT
639
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
fe086a7b
AC
652 /*
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
d550d98d 661 return 0;
1da177e4
LT
662}
663
706546d0 664static DEFINE_PER_CPU(void *, processor_device_array);
cd8e2b48 665
7af8b660 666static int __cpuinit acpi_processor_start(struct acpi_device *device)
1da177e4 667{
4be44fcd
LB
668 int result = 0;
669 acpi_status status = AE_OK;
670 struct acpi_processor *pr;
9f1eb99c 671 struct sys_device *sysdev;
1da177e4
LT
672
673 pr = acpi_driver_data(device);
674
b26e9286 675 result = acpi_processor_get_info(device);
1da177e4
LT
676 if (result) {
677 /* Processor is physically not present */
d550d98d 678 return 0;
1da177e4
LT
679 }
680
fbb43ab0 681 BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
1da177e4 682
cd8e2b48
VP
683 /*
684 * Buggy BIOS check
685 * ACPI id of processors can be reported wrongly by the BIOS.
686 * Don't trust it blindly
687 */
706546d0
MT
688 if (per_cpu(processor_device_array, pr->id) != NULL &&
689 per_cpu(processor_device_array, pr->id) != device) {
4fdb2a05 690 printk(KERN_WARNING "BIOS reported wrong ACPI id "
0eacee58 691 "for the processor\n");
d550d98d 692 return -ENODEV;
cd8e2b48 693 }
706546d0 694 per_cpu(processor_device_array, pr->id) = device;
cd8e2b48 695
706546d0 696 per_cpu(processors, pr->id) = pr;
1da177e4
LT
697
698 result = acpi_processor_add_fs(device);
699 if (result)
700 goto end;
701
9f1eb99c
ZR
702 sysdev = get_cpu_sysdev(pr->id);
703 if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev"))
704 return -EFAULT;
705
1da177e4 706 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
4be44fcd 707 acpi_processor_notify, pr);
1da177e4 708
05131ecc
VP
709 /* _PDC call should be done before doing anything else (if reqd.). */
710 arch_acpi_processor_init_pdc(pr);
711 acpi_processor_set_pdc(pr);
0ac3c571
ZY
712#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
05131ecc 718
1da177e4
LT
719 acpi_processor_power_init(pr, device);
720
d9460fd2
ZR
721 pr->cdev = thermal_cooling_device_register("Processor", device,
722 &processor_cooling_ops);
d76628c6
TS
723 if (IS_ERR(pr->cdev)) {
724 result = PTR_ERR(pr->cdev);
725 goto end;
726 }
9030062f 727
fc3a8828
GKH
728 dev_info(&device->dev, "registered as cooling_device%d\n",
729 pr->cdev->id);
9030062f
JL
730
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");
d9460fd2 741
1da177e4
LT
742 if (pr->flags.throttling) {
743 printk(KERN_INFO PREFIX "%s [%s] (supports",
4be44fcd 744 acpi_device_name(device), acpi_device_bid(device));
1da177e4
LT
745 printk(" %d throttling states", pr->throttling.state_count);
746 printk(")\n");
747 }
748
4be44fcd 749 end:
1da177e4 750
d550d98d 751 return result;
1da177e4
LT
752}
753
4be44fcd 754static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
1da177e4 755{
50dd0969 756 struct acpi_processor *pr = data;
4be44fcd 757 struct acpi_device *device = NULL;
e790cc8b 758 int saved;
1da177e4
LT
759
760 if (!pr)
d550d98d 761 return;
1da177e4
LT
762
763 if (acpi_bus_get_device(pr->handle, &device))
d550d98d 764 return;
1da177e4
LT
765
766 switch (event) {
767 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
e790cc8b 768 saved = pr->performance_platform_limit;
1da177e4 769 acpi_processor_ppc_has_changed(pr);
e790cc8b
AS
770 if (saved == pr->performance_platform_limit)
771 break;
14e04fb3 772 acpi_bus_generate_proc_event(device, event,
4be44fcd 773 pr->performance_platform_limit);
962ce8ca 774 acpi_bus_generate_netlink_event(device->pnp.device_class,
0794469d 775 dev_name(&device->dev), event,
962ce8ca 776 pr->performance_platform_limit);
1da177e4
LT
777 break;
778 case ACPI_PROCESSOR_NOTIFY_POWER:
779 acpi_processor_cst_has_changed(pr);
14e04fb3 780 acpi_bus_generate_proc_event(device, event, 0);
962ce8ca 781 acpi_bus_generate_netlink_event(device->pnp.device_class,
0794469d 782 dev_name(&device->dev), event, 0);
1da177e4 783 break;
01854e69
LY
784 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
785 acpi_processor_tstate_has_changed(pr);
14e04fb3 786 acpi_bus_generate_proc_event(device, event, 0);
962ce8ca 787 acpi_bus_generate_netlink_event(device->pnp.device_class,
0794469d 788 dev_name(&device->dev), event, 0);
1da177e4
LT
789 default:
790 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
4be44fcd 791 "Unsupported event [0x%x]\n", event));
1da177e4
LT
792 break;
793 }
794
d550d98d 795 return;
1da177e4
LT
796}
797
729c6ba3
VP
798static int acpi_cpu_soft_notify(struct notifier_block *nfb,
799 unsigned long action, void *hcpu)
800{
801 unsigned int cpu = (unsigned long)hcpu;
706546d0 802 struct acpi_processor *pr = per_cpu(processors, cpu);
729c6ba3
VP
803
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
4be44fcd 817static int acpi_processor_add(struct acpi_device *device)
1da177e4 818{
4be44fcd 819 struct acpi_processor *pr = NULL;
1da177e4 820
1da177e4
LT
821
822 if (!device)
d550d98d 823 return -EINVAL;
1da177e4 824
36bcbec7 825 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
1da177e4 826 if (!pr)
d550d98d 827 return -ENOMEM;
1da177e4
LT
828
829 pr->handle = device->handle;
830 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
831 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
db89b4f0 832 device->driver_data = pr;
1da177e4 833
d550d98d 834 return 0;
1da177e4
LT
835}
836
4be44fcd 837static int acpi_processor_remove(struct acpi_device *device, int type)
1da177e4 838{
4be44fcd
LB
839 acpi_status status = AE_OK;
840 struct acpi_processor *pr = NULL;
1da177e4 841
1da177e4
LT
842
843 if (!device || !acpi_driver_data(device))
d550d98d 844 return -EINVAL;
1da177e4 845
50dd0969 846 pr = acpi_driver_data(device);
1da177e4 847
fbb43ab0 848 if (pr->id >= nr_cpu_ids) {
1da177e4 849 kfree(pr);
d550d98d 850 return 0;
1da177e4
LT
851 }
852
853 if (type == ACPI_BUS_REMOVAL_EJECT) {
854 if (acpi_processor_handle_eject(pr))
d550d98d 855 return -EINVAL;
1da177e4
LT
856 }
857
858 acpi_processor_power_exit(pr, device);
859
860 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
4be44fcd 861 acpi_processor_notify);
1da177e4 862
9f1eb99c
ZR
863 sysfs_remove_link(&device->dev.kobj, "sysdev");
864
1da177e4
LT
865 acpi_processor_remove_fs(device);
866
f28bb45e
ZY
867 if (pr->cdev) {
868 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
869 sysfs_remove_link(&pr->cdev->device.kobj, "device");
870 thermal_cooling_device_unregister(pr->cdev);
871 pr->cdev = NULL;
872 }
d9460fd2 873
706546d0
MT
874 per_cpu(processors, pr->id) = NULL;
875 per_cpu(processor_device_array, pr->id) = NULL;
1da177e4
LT
876 kfree(pr);
877
d550d98d 878 return 0;
1da177e4
LT
879}
880
881#ifdef CONFIG_ACPI_HOTPLUG_CPU
882/****************************************************************************
883 * Acpi processor hotplug support *
884 ****************************************************************************/
885
4be44fcd 886static int is_processor_present(acpi_handle handle)
1da177e4 887{
4be44fcd 888 acpi_status status;
27663c58 889 unsigned long long sta = 0;
1da177e4 890
1da177e4
LT
891
892 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
cfaf3747
ZR
893
894 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT))
895 return 1;
896
d0ce46f5
ZR
897 /*
898 * _STA is mandatory for a processor that supports hot plug
899 */
900 if (status == AE_NOT_FOUND)
901 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
902 "Processor does not support hot plug\n"));
903 else
904 ACPI_EXCEPTION((AE_INFO, status,
905 "Processor Device is not present"));
cfaf3747 906 return 0;
1da177e4
LT
907}
908
1da177e4 909static
4be44fcd 910int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
1da177e4 911{
4be44fcd
LB
912 acpi_handle phandle;
913 struct acpi_device *pdev;
914 struct acpi_processor *pr;
1da177e4 915
1da177e4
LT
916
917 if (acpi_get_parent(handle, &phandle)) {
d550d98d 918 return -ENODEV;
1da177e4
LT
919 }
920
921 if (acpi_bus_get_device(phandle, &pdev)) {
d550d98d 922 return -ENODEV;
1da177e4
LT
923 }
924
925 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
d550d98d 926 return -ENODEV;
1da177e4
LT
927 }
928
3fb02738 929 acpi_bus_start(*device);
1da177e4
LT
930
931 pr = acpi_driver_data(*device);
932 if (!pr)
d550d98d 933 return -ENODEV;
1da177e4 934
fbb43ab0 935 if ((pr->id >= 0) && (pr->id < nr_cpu_ids)) {
f883d9db 936 kobject_uevent(&(*device)->dev.kobj, KOBJ_ONLINE);
1da177e4 937 }
d550d98d 938 return 0;
1da177e4
LT
939}
940
b95e9e8d
SR
941static void __ref acpi_processor_hotplug_notify(acpi_handle handle,
942 u32 event, void *data)
1da177e4 943{
4be44fcd
LB
944 struct acpi_processor *pr;
945 struct acpi_device *device = NULL;
1da177e4
LT
946 int result;
947
1da177e4
LT
948
949 switch (event) {
950 case ACPI_NOTIFY_BUS_CHECK:
951 case ACPI_NOTIFY_DEVICE_CHECK:
d6f882e1
GC
952 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
953 "Processor driver received %s event\n",
4be44fcd 954 (event == ACPI_NOTIFY_BUS_CHECK) ?
d6f882e1 955 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"));
1da177e4
LT
956
957 if (!is_processor_present(handle))
958 break;
959
960 if (acpi_bus_get_device(handle, &device)) {
961 result = acpi_processor_device_add(handle, &device);
962 if (result)
6468463a
LB
963 printk(KERN_ERR PREFIX
964 "Unable to add the device\n");
1da177e4
LT
965 break;
966 }
967
968 pr = acpi_driver_data(device);
969 if (!pr) {
6468463a 970 printk(KERN_ERR PREFIX "Driver data is NULL\n");
1da177e4
LT
971 break;
972 }
973
fbb43ab0 974 if (pr->id >= 0 && (pr->id < nr_cpu_ids)) {
f883d9db 975 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
1da177e4
LT
976 break;
977 }
978
979 result = acpi_processor_start(device);
fbb43ab0 980 if ((!result) && ((pr->id >= 0) && (pr->id < nr_cpu_ids))) {
f883d9db 981 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
1da177e4 982 } else {
6468463a
LB
983 printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
984 acpi_device_bid(device));
1da177e4 985 }
4be44fcd 986 break;
1da177e4 987 case ACPI_NOTIFY_EJECT_REQUEST:
4be44fcd
LB
988 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
989 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
1da177e4
LT
990
991 if (acpi_bus_get_device(handle, &device)) {
6468463a
LB
992 printk(KERN_ERR PREFIX
993 "Device don't exist, dropping EJECT\n");
1da177e4
LT
994 break;
995 }
996 pr = acpi_driver_data(device);
997 if (!pr) {
6468463a
LB
998 printk(KERN_ERR PREFIX
999 "Driver data is NULL, dropping EJECT\n");
d550d98d 1000 return;
1da177e4
LT
1001 }
1002
fbb43ab0 1003 if ((pr->id < nr_cpu_ids) && (cpu_present(pr->id)))
f883d9db 1004 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
1da177e4
LT
1005 break;
1006 default:
1007 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
4be44fcd 1008 "Unsupported event [0x%x]\n", event));
1da177e4
LT
1009 break;
1010 }
1011
d550d98d 1012 return;
1da177e4
LT
1013}
1014
1015static acpi_status
1016processor_walk_namespace_cb(acpi_handle handle,
4be44fcd 1017 u32 lvl, void *context, void **rv)
1da177e4 1018{
4be44fcd 1019 acpi_status status;
1da177e4 1020 int *action = context;
4be44fcd 1021 acpi_object_type type = 0;
1da177e4
LT
1022
1023 status = acpi_get_type(handle, &type);
1024 if (ACPI_FAILURE(status))
4be44fcd 1025 return (AE_OK);
1da177e4
LT
1026
1027 if (type != ACPI_TYPE_PROCESSOR)
4be44fcd 1028 return (AE_OK);
1da177e4 1029
4be44fcd 1030 switch (*action) {
1da177e4
LT
1031 case INSTALL_NOTIFY_HANDLER:
1032 acpi_install_notify_handler(handle,
4be44fcd
LB
1033 ACPI_SYSTEM_NOTIFY,
1034 acpi_processor_hotplug_notify,
1035 NULL);
1da177e4
LT
1036 break;
1037 case UNINSTALL_NOTIFY_HANDLER:
1038 acpi_remove_notify_handler(handle,
4be44fcd
LB
1039 ACPI_SYSTEM_NOTIFY,
1040 acpi_processor_hotplug_notify);
1da177e4
LT
1041 break;
1042 default:
1043 break;
1044 }
1045
4be44fcd 1046 return (AE_OK);
1da177e4
LT
1047}
1048
4be44fcd 1049static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
1da177e4 1050{
1da177e4
LT
1051
1052 if (!is_processor_present(handle)) {
d550d98d 1053 return AE_ERROR;
1da177e4
LT
1054 }
1055
1056 if (acpi_map_lsapic(handle, p_cpu))
d550d98d 1057 return AE_ERROR;
1da177e4
LT
1058
1059 if (arch_register_cpu(*p_cpu)) {
1060 acpi_unmap_lsapic(*p_cpu);
d550d98d 1061 return AE_ERROR;
1da177e4
LT
1062 }
1063
d550d98d 1064 return AE_OK;
1da177e4
LT
1065}
1066
4be44fcd 1067static int acpi_processor_handle_eject(struct acpi_processor *pr)
1da177e4 1068{
b62b8ef9
ZR
1069 if (cpu_online(pr->id))
1070 cpu_down(pr->id);
1071
1da177e4
LT
1072 arch_unregister_cpu(pr->id);
1073 acpi_unmap_lsapic(pr->id);
4be44fcd 1074 return (0);
1da177e4
LT
1075}
1076#else
4be44fcd 1077static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
1da177e4
LT
1078{
1079 return AE_ERROR;
1080}
4be44fcd 1081static int acpi_processor_handle_eject(struct acpi_processor *pr)
1da177e4 1082{
4be44fcd 1083 return (-EINVAL);
1da177e4
LT
1084}
1085#endif
1086
1da177e4
LT
1087static
1088void acpi_processor_install_hotplug_notify(void)
1089{
1090#ifdef CONFIG_ACPI_HOTPLUG_CPU
1091 int action = INSTALL_NOTIFY_HANDLER;
1092 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
4be44fcd
LB
1093 ACPI_ROOT_OBJECT,
1094 ACPI_UINT32_MAX,
1095 processor_walk_namespace_cb, &action, NULL);
1da177e4 1096#endif
729c6ba3 1097 register_hotcpu_notifier(&acpi_cpu_notifier);
1da177e4
LT
1098}
1099
1da177e4
LT
1100static
1101void acpi_processor_uninstall_hotplug_notify(void)
1102{
1103#ifdef CONFIG_ACPI_HOTPLUG_CPU
1104 int action = UNINSTALL_NOTIFY_HANDLER;
1105 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
4be44fcd
LB
1106 ACPI_ROOT_OBJECT,
1107 ACPI_UINT32_MAX,
1108 processor_walk_namespace_cb, &action, NULL);
1da177e4 1109#endif
729c6ba3 1110 unregister_hotcpu_notifier(&acpi_cpu_notifier);
1da177e4
LT
1111}
1112
1113/*
1114 * We keep the driver loaded even when ACPI is not running.
1115 * This is needed for the powernow-k8 driver, that works even without
1116 * ACPI, but needs symbols from this driver
1117 */
1118
4be44fcd 1119static int __init acpi_processor_init(void)
1da177e4 1120{
4be44fcd 1121 int result = 0;
1da177e4 1122
1da177e4
LT
1123 memset(&errata, 0, sizeof(errata));
1124
f18c5a08
AS
1125#ifdef CONFIG_SMP
1126 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0,
1127 (struct acpi_table_header **)&madt)))
70c0846e 1128 madt = NULL;
f18c5a08
AS
1129#endif
1130
1da177e4
LT
1131 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1132 if (!acpi_processor_dir)
83822fc9 1133 return -ENOMEM;
1da177e4
LT
1134 acpi_processor_dir->owner = THIS_MODULE;
1135
2a2a6471
ZY
1136 /*
1137 * Check whether the system is DMI table. If yes, OSPM
1138 * should not use mwait for CPU-states.
1139 */
1140 dmi_check_system(processor_idle_dmi_table);
4f86d3a8
LB
1141 result = cpuidle_register_driver(&acpi_idle_driver);
1142 if (result < 0)
1143 goto out_proc;
1144
1da177e4 1145 result = acpi_bus_register_driver(&acpi_processor_driver);
4f86d3a8
LB
1146 if (result < 0)
1147 goto out_cpuidle;
1da177e4
LT
1148
1149 acpi_processor_install_hotplug_notify();
1150
1151 acpi_thermal_cpufreq_init();
1152
1153 acpi_processor_ppc_init();
1154
1180509f
ZY
1155 acpi_processor_throttling_init();
1156
d550d98d 1157 return 0;
4f86d3a8
LB
1158
1159out_cpuidle:
1160 cpuidle_unregister_driver(&acpi_idle_driver);
1161
1162out_proc:
1163 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1164
1165 return result;
1da177e4
LT
1166}
1167
4be44fcd 1168static void __exit acpi_processor_exit(void)
1da177e4 1169{
1da177e4
LT
1170 acpi_processor_ppc_exit();
1171
1172 acpi_thermal_cpufreq_exit();
1173
1174 acpi_processor_uninstall_hotplug_notify();
1175
1176 acpi_bus_unregister_driver(&acpi_processor_driver);
1177
4f86d3a8
LB
1178 cpuidle_unregister_driver(&acpi_idle_driver);
1179
1da177e4
LT
1180 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1181
d550d98d 1182 return;
1da177e4
LT
1183}
1184
1da177e4
LT
1185module_init(acpi_processor_init);
1186module_exit(acpi_processor_exit);
1187
1188EXPORT_SYMBOL(acpi_processor_set_thermal_limit);
1189
1190MODULE_ALIAS("processor");
This page took 0.802861 seconds and 5 git commands to generate.