2 * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $)
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
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
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.
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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>
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>
49 #include <asm/system.h>
51 #include <asm/delay.h>
52 #include <asm/uaccess.h>
53 #include <asm/processor.h>
57 #include <acpi/acpi_bus.h>
58 #include <acpi/acpi_drivers.h>
59 #include <acpi/processor.h>
61 #define ACPI_PROCESSOR_COMPONENT 0x01000000
62 #define ACPI_PROCESSOR_CLASS "processor"
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
70 #define ACPI_PROCESSOR_LIMIT_USER 0
71 #define ACPI_PROCESSOR_LIMIT_THERMAL 1
73 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
74 ACPI_MODULE_NAME("processor_core");
76 MODULE_AUTHOR("Paul Diefenbaugh");
77 MODULE_DESCRIPTION("ACPI Processor Driver");
78 MODULE_LICENSE("GPL");
80 static int acpi_processor_add(struct acpi_device
*device
);
81 static int acpi_processor_start(struct acpi_device
*device
);
82 static int acpi_processor_remove(struct acpi_device
*device
, int type
);
83 static int acpi_processor_info_open_fs(struct inode
*inode
, struct file
*file
);
84 static void acpi_processor_notify(acpi_handle handle
, u32 event
, void *data
);
85 static acpi_status
acpi_processor_hotadd_init(acpi_handle handle
, int *p_cpu
);
86 static int acpi_processor_handle_eject(struct acpi_processor
*pr
);
88 static struct acpi_driver acpi_processor_driver
= {
90 .class = ACPI_PROCESSOR_CLASS
,
91 .ids
= ACPI_PROCESSOR_HID
,
93 .add
= acpi_processor_add
,
94 .remove
= acpi_processor_remove
,
95 .start
= acpi_processor_start
,
99 #define INSTALL_NOTIFY_HANDLER 1
100 #define UNINSTALL_NOTIFY_HANDLER 2
102 static const struct file_operations acpi_processor_info_fops
= {
103 .open
= acpi_processor_info_open_fs
,
106 .release
= single_release
,
109 struct acpi_processor
*processors
[NR_CPUS
];
110 struct acpi_processor_errata errata __read_mostly
;
112 /* --------------------------------------------------------------------------
114 -------------------------------------------------------------------------- */
116 static int acpi_processor_errata_piix4(struct pci_dev
*dev
)
126 * Note that 'dev' references the PIIX4 ACPI Controller.
129 switch (dev
->revision
) {
131 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found PIIX4 A-step\n"));
134 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found PIIX4 B-step\n"));
137 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found PIIX4E\n"));
140 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found PIIX4M\n"));
143 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found unknown PIIX4\n"));
147 switch (dev
->revision
) {
149 case 0: /* PIIX4 A-step */
150 case 1: /* PIIX4 B-step */
152 * See specification changes #13 ("Manual Throttle Duty Cycle")
153 * and #14 ("Enabling and Disabling Manual Throttle"), plus
154 * erratum #5 ("STPCLK# Deassertion Time") from the January
155 * 2002 PIIX4 specification update. Applies to only older
158 errata
.piix4
.throttle
= 1;
163 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
164 * Livelock") from the January 2002 PIIX4 specification update.
165 * Applies to all PIIX4 models.
171 * Find the PIIX4 IDE Controller and get the Bus Master IDE
172 * Status register address. We'll use this later to read
173 * each IDE controller's DMA status to make sure we catch all
176 dev
= pci_get_subsys(PCI_VENDOR_ID_INTEL
,
177 PCI_DEVICE_ID_INTEL_82371AB
,
178 PCI_ANY_ID
, PCI_ANY_ID
, NULL
);
180 errata
.piix4
.bmisx
= pci_resource_start(dev
, 4);
187 * Find the PIIX4 ISA Controller and read the Motherboard
188 * DMA controller's status to see if Type-F (Fast) DMA mode
189 * is enabled (bit 7) on either channel. Note that we'll
190 * disable C3 support if this is enabled, as some legacy
191 * devices won't operate well if fast DMA is disabled.
193 dev
= pci_get_subsys(PCI_VENDOR_ID_INTEL
,
194 PCI_DEVICE_ID_INTEL_82371AB_0
,
195 PCI_ANY_ID
, PCI_ANY_ID
, NULL
);
197 pci_read_config_byte(dev
, 0x76, &value1
);
198 pci_read_config_byte(dev
, 0x77, &value2
);
199 if ((value1
& 0x80) || (value2
& 0x80))
200 errata
.piix4
.fdma
= 1;
207 if (errata
.piix4
.bmisx
)
208 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
209 "Bus master activity detection (BM-IDE) erratum enabled\n"));
210 if (errata
.piix4
.fdma
)
211 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
212 "Type-F DMA livelock erratum (C3 disabled)\n"));
217 static int acpi_processor_errata(struct acpi_processor
*pr
)
220 struct pci_dev
*dev
= NULL
;
229 dev
= pci_get_subsys(PCI_VENDOR_ID_INTEL
,
230 PCI_DEVICE_ID_INTEL_82371AB_3
, PCI_ANY_ID
,
233 result
= acpi_processor_errata_piix4(dev
);
240 /* --------------------------------------------------------------------------
241 Common ACPI processor functions
242 -------------------------------------------------------------------------- */
245 * _PDC is required for a BIOS-OS handshake for most of the newer
246 * ACPI processor features.
248 static int acpi_processor_set_pdc(struct acpi_processor
*pr
)
250 struct acpi_object_list
*pdc_in
= pr
->pdc
;
251 acpi_status status
= AE_OK
;
257 status
= acpi_evaluate_object(pr
->handle
, "_PDC", pdc_in
, NULL
);
259 if (ACPI_FAILURE(status
))
260 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
261 "Could not evaluate _PDC, using legacy perf. control...\n"));
266 /* --------------------------------------------------------------------------
268 -------------------------------------------------------------------------- */
270 static struct proc_dir_entry
*acpi_processor_dir
= NULL
;
272 static int acpi_processor_info_seq_show(struct seq_file
*seq
, void *offset
)
274 struct acpi_processor
*pr
= seq
->private;
280 seq_printf(seq
, "processor id: %d\n"
282 "bus mastering control: %s\n"
283 "power management: %s\n"
284 "throttling control: %s\n"
285 "limit interface: %s\n",
288 pr
->flags
.bm_control
? "yes" : "no",
289 pr
->flags
.power
? "yes" : "no",
290 pr
->flags
.throttling
? "yes" : "no",
291 pr
->flags
.limit
? "yes" : "no");
297 static int acpi_processor_info_open_fs(struct inode
*inode
, struct file
*file
)
299 return single_open(file
, acpi_processor_info_seq_show
,
303 static int acpi_processor_add_fs(struct acpi_device
*device
)
305 struct proc_dir_entry
*entry
= NULL
;
308 if (!acpi_device_dir(device
)) {
309 acpi_device_dir(device
) = proc_mkdir(acpi_device_bid(device
),
311 if (!acpi_device_dir(device
))
314 acpi_device_dir(device
)->owner
= THIS_MODULE
;
317 entry
= create_proc_entry(ACPI_PROCESSOR_FILE_INFO
,
318 S_IRUGO
, acpi_device_dir(device
));
322 entry
->proc_fops
= &acpi_processor_info_fops
;
323 entry
->data
= acpi_driver_data(device
);
324 entry
->owner
= THIS_MODULE
;
327 /* 'throttling' [R/W] */
328 entry
= create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING
,
329 S_IFREG
| S_IRUGO
| S_IWUSR
,
330 acpi_device_dir(device
));
334 entry
->proc_fops
= &acpi_processor_throttling_fops
;
335 entry
->data
= acpi_driver_data(device
);
336 entry
->owner
= THIS_MODULE
;
340 entry
= create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT
,
341 S_IFREG
| S_IRUGO
| S_IWUSR
,
342 acpi_device_dir(device
));
346 entry
->proc_fops
= &acpi_processor_limit_fops
;
347 entry
->data
= acpi_driver_data(device
);
348 entry
->owner
= THIS_MODULE
;
354 static int acpi_processor_remove_fs(struct acpi_device
*device
)
357 if (acpi_device_dir(device
)) {
358 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO
,
359 acpi_device_dir(device
));
360 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING
,
361 acpi_device_dir(device
));
362 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT
,
363 acpi_device_dir(device
));
364 remove_proc_entry(acpi_device_bid(device
), acpi_processor_dir
);
365 acpi_device_dir(device
) = NULL
;
371 /* Use the acpiid in MADT to map cpus in case of SMP */
374 static int get_cpu_id(acpi_handle handle
, u32 acpi_id
) {return -1;}
377 static struct acpi_table_madt
*madt
;
379 static int map_lapic_id(struct acpi_subtable_header
*entry
,
380 u32 acpi_id
, int *apic_id
)
382 struct acpi_madt_local_apic
*lapic
=
383 (struct acpi_madt_local_apic
*)entry
;
384 if ((lapic
->lapic_flags
& ACPI_MADT_ENABLED
) &&
385 lapic
->processor_id
== acpi_id
) {
386 *apic_id
= lapic
->id
;
392 static int map_lsapic_id(struct acpi_subtable_header
*entry
,
393 u32 acpi_id
, int *apic_id
)
395 struct acpi_madt_local_sapic
*lsapic
=
396 (struct acpi_madt_local_sapic
*)entry
;
397 /* Only check enabled APICs*/
398 if (lsapic
->lapic_flags
& ACPI_MADT_ENABLED
) {
399 /* First check against id */
400 if (lsapic
->processor_id
== acpi_id
) {
401 *apic_id
= (lsapic
->id
<< 8) | lsapic
->eid
;
403 /* Check against optional uid */
404 } else if (entry
->length
>= 16 &&
405 lsapic
->uid
== acpi_id
) {
406 *apic_id
= lsapic
->uid
;
414 #define arch_cpu_to_apicid ia64_cpu_to_sapicid
416 #define arch_cpu_to_apicid x86_cpu_to_apicid
419 static int map_madt_entry(u32 acpi_id
)
421 unsigned long madt_end
, entry
;
427 entry
= (unsigned long)madt
;
428 madt_end
= entry
+ madt
->header
.length
;
430 /* Parse all entries looking for a match. */
432 entry
+= sizeof(struct acpi_table_madt
);
433 while (entry
+ sizeof(struct acpi_subtable_header
) < madt_end
) {
434 struct acpi_subtable_header
*header
=
435 (struct acpi_subtable_header
*)entry
;
436 if (header
->type
== ACPI_MADT_TYPE_LOCAL_APIC
) {
437 if (map_lapic_id(header
, acpi_id
, &apic_id
))
439 } else if (header
->type
== ACPI_MADT_TYPE_LOCAL_SAPIC
) {
440 if (map_lsapic_id(header
, acpi_id
, &apic_id
))
443 entry
+= header
->length
;
448 static int map_mat_entry(acpi_handle handle
, u32 acpi_id
)
450 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
451 union acpi_object
*obj
;
452 struct acpi_subtable_header
*header
;
455 if (ACPI_FAILURE(acpi_evaluate_object(handle
, "_MAT", NULL
, &buffer
)))
458 if (!buffer
.length
|| !buffer
.pointer
)
461 obj
= buffer
.pointer
;
462 if (obj
->type
!= ACPI_TYPE_BUFFER
||
463 obj
->buffer
.length
< sizeof(struct acpi_subtable_header
)) {
467 header
= (struct acpi_subtable_header
*)obj
->buffer
.pointer
;
468 if (header
->type
== ACPI_MADT_TYPE_LOCAL_APIC
) {
469 map_lapic_id(header
, acpi_id
, &apic_id
);
470 } else if (header
->type
== ACPI_MADT_TYPE_LOCAL_SAPIC
) {
471 map_lsapic_id(header
, acpi_id
, &apic_id
);
476 kfree(buffer
.pointer
);
480 static int get_cpu_id(acpi_handle handle
, u32 acpi_id
)
485 apic_id
= map_mat_entry(handle
, acpi_id
);
487 apic_id
= map_madt_entry(acpi_id
);
491 for (i
= 0; i
< NR_CPUS
; ++i
) {
492 if (arch_cpu_to_apicid
[i
] == apic_id
)
499 /* --------------------------------------------------------------------------
501 -------------------------------------------------------------------------- */
503 static int acpi_processor_get_info(struct acpi_processor
*pr
, unsigned has_uid
)
505 acpi_status status
= 0;
506 union acpi_object object
= { 0 };
507 struct acpi_buffer buffer
= { sizeof(union acpi_object
), &object
};
509 static int cpu0_initialized
;
515 if (num_online_cpus() > 1)
518 acpi_processor_errata(pr
);
521 * Check to see if we have bus mastering arbitration control. This
522 * is required for proper C3 usage (to maintain cache coherency).
524 if (acpi_gbl_FADT
.pm2_control_block
&& acpi_gbl_FADT
.pm2_control_length
) {
525 pr
->flags
.bm_control
= 1;
526 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
527 "Bus mastering arbitration control present\n"));
529 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
530 "No bus mastering arbitration control\n"));
532 /* Check if it is a Device with HID and UID */
535 status
= acpi_evaluate_integer(pr
->handle
, METHOD_NAME__UID
,
537 if (ACPI_FAILURE(status
)) {
538 printk(KERN_ERR PREFIX
"Evaluating processor _UID\n");
544 * Evalute the processor object. Note that it is common on SMP to
545 * have the first (boot) processor with a valid PBLK address while
546 * all others have a NULL address.
548 status
= acpi_evaluate_object(pr
->handle
, NULL
, NULL
, &buffer
);
549 if (ACPI_FAILURE(status
)) {
550 printk(KERN_ERR PREFIX
"Evaluating processor object\n");
555 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
556 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c
558 pr
->acpi_id
= object
.processor
.proc_id
;
560 cpu_index
= get_cpu_id(pr
->handle
, pr
->acpi_id
);
562 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
563 if (!cpu0_initialized
&& (cpu_index
== -1) &&
564 (num_online_cpus() == 1)) {
568 cpu0_initialized
= 1;
573 * Extra Processor objects may be enumerated on MP systems with
574 * less than the max # of CPUs. They should be ignored _iff
575 * they are physically not present.
579 (acpi_processor_hotadd_init(pr
->handle
, &pr
->id
))) {
584 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Processor [%d:%d]\n", pr
->id
,
587 if (!object
.processor
.pblk_address
)
588 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No PBLK (NULL address)\n"));
589 else if (object
.processor
.pblk_length
!= 6)
590 printk(KERN_ERR PREFIX
"Invalid PBLK length [%d]\n",
591 object
.processor
.pblk_length
);
593 pr
->throttling
.address
= object
.processor
.pblk_address
;
594 pr
->throttling
.duty_offset
= acpi_gbl_FADT
.duty_offset
;
595 pr
->throttling
.duty_width
= acpi_gbl_FADT
.duty_width
;
597 pr
->pblk
= object
.processor
.pblk_address
;
600 * We don't care about error returns - we just try to mark
601 * these reserved so that nobody else is confused into thinking
602 * that this region might be unused..
604 * (In particular, allocating the IO range for Cardbus)
606 request_region(pr
->throttling
.address
, 6, "ACPI CPU throttle");
609 #ifdef CONFIG_CPU_FREQ
610 acpi_processor_ppc_has_changed(pr
);
612 acpi_processor_get_throttling_info(pr
);
613 acpi_processor_get_limit_info(pr
);
618 static void *processor_device_array
[NR_CPUS
];
620 static int __cpuinit
acpi_processor_start(struct acpi_device
*device
)
623 acpi_status status
= AE_OK
;
624 struct acpi_processor
*pr
;
627 pr
= acpi_driver_data(device
);
629 result
= acpi_processor_get_info(pr
, device
->flags
.unique_id
);
631 /* Processor is physically not present */
635 BUG_ON((pr
->id
>= NR_CPUS
) || (pr
->id
< 0));
639 * ACPI id of processors can be reported wrongly by the BIOS.
640 * Don't trust it blindly
642 if (processor_device_array
[pr
->id
] != NULL
&&
643 processor_device_array
[pr
->id
] != device
) {
644 printk(KERN_WARNING
"BIOS reported wrong ACPI id"
645 "for the processor\n");
648 processor_device_array
[pr
->id
] = device
;
650 processors
[pr
->id
] = pr
;
652 result
= acpi_processor_add_fs(device
);
656 status
= acpi_install_notify_handler(pr
->handle
, ACPI_DEVICE_NOTIFY
,
657 acpi_processor_notify
, pr
);
659 /* _PDC call should be done before doing anything else (if reqd.). */
660 arch_acpi_processor_init_pdc(pr
);
661 acpi_processor_set_pdc(pr
);
663 acpi_processor_power_init(pr
, device
);
665 if (pr
->flags
.throttling
) {
666 printk(KERN_INFO PREFIX
"%s [%s] (supports",
667 acpi_device_name(device
), acpi_device_bid(device
));
668 printk(" %d throttling states", pr
->throttling
.state_count
);
677 static void acpi_processor_notify(acpi_handle handle
, u32 event
, void *data
)
679 struct acpi_processor
*pr
= data
;
680 struct acpi_device
*device
= NULL
;
686 if (acpi_bus_get_device(pr
->handle
, &device
))
690 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE
:
691 acpi_processor_ppc_has_changed(pr
);
692 acpi_bus_generate_event(device
, event
,
693 pr
->performance_platform_limit
);
695 case ACPI_PROCESSOR_NOTIFY_POWER
:
696 acpi_processor_cst_has_changed(pr
);
697 acpi_bus_generate_event(device
, event
, 0);
700 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
701 "Unsupported event [0x%x]\n", event
));
708 static int acpi_processor_add(struct acpi_device
*device
)
710 struct acpi_processor
*pr
= NULL
;
716 pr
= kzalloc(sizeof(struct acpi_processor
), GFP_KERNEL
);
720 pr
->handle
= device
->handle
;
721 strcpy(acpi_device_name(device
), ACPI_PROCESSOR_DEVICE_NAME
);
722 strcpy(acpi_device_class(device
), ACPI_PROCESSOR_CLASS
);
723 acpi_driver_data(device
) = pr
;
728 static int acpi_processor_remove(struct acpi_device
*device
, int type
)
730 acpi_status status
= AE_OK
;
731 struct acpi_processor
*pr
= NULL
;
734 if (!device
|| !acpi_driver_data(device
))
737 pr
= acpi_driver_data(device
);
739 if (pr
->id
>= NR_CPUS
) {
744 if (type
== ACPI_BUS_REMOVAL_EJECT
) {
745 if (acpi_processor_handle_eject(pr
))
749 acpi_processor_power_exit(pr
, device
);
751 status
= acpi_remove_notify_handler(pr
->handle
, ACPI_DEVICE_NOTIFY
,
752 acpi_processor_notify
);
754 acpi_processor_remove_fs(device
);
756 processors
[pr
->id
] = NULL
;
763 #ifdef CONFIG_ACPI_HOTPLUG_CPU
764 /****************************************************************************
765 * Acpi processor hotplug support *
766 ****************************************************************************/
768 static int is_processor_present(acpi_handle handle
);
770 static int is_processor_present(acpi_handle handle
)
773 unsigned long sta
= 0;
776 status
= acpi_evaluate_integer(handle
, "_STA", NULL
, &sta
);
777 if (ACPI_FAILURE(status
) || !(sta
& ACPI_STA_DEVICE_PRESENT
)) {
778 ACPI_EXCEPTION((AE_INFO
, status
, "Processor Device is not present"));
785 int acpi_processor_device_add(acpi_handle handle
, struct acpi_device
**device
)
788 struct acpi_device
*pdev
;
789 struct acpi_processor
*pr
;
792 if (acpi_get_parent(handle
, &phandle
)) {
796 if (acpi_bus_get_device(phandle
, &pdev
)) {
800 if (acpi_bus_add(device
, pdev
, handle
, ACPI_BUS_TYPE_PROCESSOR
)) {
804 acpi_bus_start(*device
);
806 pr
= acpi_driver_data(*device
);
810 if ((pr
->id
>= 0) && (pr
->id
< NR_CPUS
)) {
811 kobject_uevent(&(*device
)->dev
.kobj
, KOBJ_ONLINE
);
817 acpi_processor_hotplug_notify(acpi_handle handle
, u32 event
, void *data
)
819 struct acpi_processor
*pr
;
820 struct acpi_device
*device
= NULL
;
825 case ACPI_NOTIFY_BUS_CHECK
:
826 case ACPI_NOTIFY_DEVICE_CHECK
:
827 printk("Processor driver received %s event\n",
828 (event
== ACPI_NOTIFY_BUS_CHECK
) ?
829 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
831 if (!is_processor_present(handle
))
834 if (acpi_bus_get_device(handle
, &device
)) {
835 result
= acpi_processor_device_add(handle
, &device
);
837 printk(KERN_ERR PREFIX
838 "Unable to add the device\n");
842 pr
= acpi_driver_data(device
);
844 printk(KERN_ERR PREFIX
"Driver data is NULL\n");
848 if (pr
->id
>= 0 && (pr
->id
< NR_CPUS
)) {
849 kobject_uevent(&device
->dev
.kobj
, KOBJ_OFFLINE
);
853 result
= acpi_processor_start(device
);
854 if ((!result
) && ((pr
->id
>= 0) && (pr
->id
< NR_CPUS
))) {
855 kobject_uevent(&device
->dev
.kobj
, KOBJ_ONLINE
);
857 printk(KERN_ERR PREFIX
"Device [%s] failed to start\n",
858 acpi_device_bid(device
));
861 case ACPI_NOTIFY_EJECT_REQUEST
:
862 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
863 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
865 if (acpi_bus_get_device(handle
, &device
)) {
866 printk(KERN_ERR PREFIX
867 "Device don't exist, dropping EJECT\n");
870 pr
= acpi_driver_data(device
);
872 printk(KERN_ERR PREFIX
873 "Driver data is NULL, dropping EJECT\n");
877 if ((pr
->id
< NR_CPUS
) && (cpu_present(pr
->id
)))
878 kobject_uevent(&device
->dev
.kobj
, KOBJ_OFFLINE
);
881 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
882 "Unsupported event [0x%x]\n", event
));
890 processor_walk_namespace_cb(acpi_handle handle
,
891 u32 lvl
, void *context
, void **rv
)
894 int *action
= context
;
895 acpi_object_type type
= 0;
897 status
= acpi_get_type(handle
, &type
);
898 if (ACPI_FAILURE(status
))
901 if (type
!= ACPI_TYPE_PROCESSOR
)
905 case INSTALL_NOTIFY_HANDLER
:
906 acpi_install_notify_handler(handle
,
908 acpi_processor_hotplug_notify
,
911 case UNINSTALL_NOTIFY_HANDLER
:
912 acpi_remove_notify_handler(handle
,
914 acpi_processor_hotplug_notify
);
923 static acpi_status
acpi_processor_hotadd_init(acpi_handle handle
, int *p_cpu
)
926 if (!is_processor_present(handle
)) {
930 if (acpi_map_lsapic(handle
, p_cpu
))
933 if (arch_register_cpu(*p_cpu
)) {
934 acpi_unmap_lsapic(*p_cpu
);
941 static int acpi_processor_handle_eject(struct acpi_processor
*pr
)
943 if (cpu_online(pr
->id
)) {
946 arch_unregister_cpu(pr
->id
);
947 acpi_unmap_lsapic(pr
->id
);
951 static acpi_status
acpi_processor_hotadd_init(acpi_handle handle
, int *p_cpu
)
955 static int acpi_processor_handle_eject(struct acpi_processor
*pr
)
962 void acpi_processor_install_hotplug_notify(void)
964 #ifdef CONFIG_ACPI_HOTPLUG_CPU
965 int action
= INSTALL_NOTIFY_HANDLER
;
966 acpi_walk_namespace(ACPI_TYPE_PROCESSOR
,
969 processor_walk_namespace_cb
, &action
, NULL
);
974 void acpi_processor_uninstall_hotplug_notify(void)
976 #ifdef CONFIG_ACPI_HOTPLUG_CPU
977 int action
= UNINSTALL_NOTIFY_HANDLER
;
978 acpi_walk_namespace(ACPI_TYPE_PROCESSOR
,
981 processor_walk_namespace_cb
, &action
, NULL
);
986 * We keep the driver loaded even when ACPI is not running.
987 * This is needed for the powernow-k8 driver, that works even without
988 * ACPI, but needs symbols from this driver
991 static int __init
acpi_processor_init(void)
996 memset(&processors
, 0, sizeof(processors
));
997 memset(&errata
, 0, sizeof(errata
));
1000 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT
, 0,
1001 (struct acpi_table_header
**)&madt
)))
1005 acpi_processor_dir
= proc_mkdir(ACPI_PROCESSOR_CLASS
, acpi_root_dir
);
1006 if (!acpi_processor_dir
)
1008 acpi_processor_dir
->owner
= THIS_MODULE
;
1010 result
= acpi_bus_register_driver(&acpi_processor_driver
);
1012 remove_proc_entry(ACPI_PROCESSOR_CLASS
, acpi_root_dir
);
1016 acpi_processor_install_hotplug_notify();
1018 acpi_thermal_cpufreq_init();
1020 acpi_processor_ppc_init();
1025 static void __exit
acpi_processor_exit(void)
1028 acpi_processor_ppc_exit();
1030 acpi_thermal_cpufreq_exit();
1032 acpi_processor_uninstall_hotplug_notify();
1034 acpi_bus_unregister_driver(&acpi_processor_driver
);
1036 remove_proc_entry(ACPI_PROCESSOR_CLASS
, acpi_root_dir
);
1041 module_init(acpi_processor_init
);
1042 module_exit(acpi_processor_exit
);
1044 EXPORT_SYMBOL(acpi_processor_set_thermal_limit
);
1046 MODULE_ALIAS("processor");