35 #include <linux/kernel.h>
36 #include <linux/module.h>
38 #include <linux/types.h>
39 #include <linux/pci.h>
46 #include <linux/slab.h>
50 #include <asm/delay.h>
51 #include <asm/uaccess.h>
52 #include <asm/processor.h>
60 #define PREFIX "ACPI: "
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
69 #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
70 #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007"
72 #define ACPI_PROCESSOR_LIMIT_USER 0
73 #define ACPI_PROCESSOR_LIMIT_THERMAL 1
75 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
82 static int acpi_processor_add(
struct acpi_device *
device);
83 static int acpi_processor_remove(
struct acpi_device *
device,
int type);
84 static void acpi_processor_notify(
struct acpi_device *
device,
u32 event);
99 static struct acpi_driver acpi_processor_driver = {
102 .ids = processor_device_ids,
104 .add = acpi_processor_add,
105 .remove = acpi_processor_remove,
106 .notify = acpi_processor_notify,
108 .drv.pm = &acpi_processor_pm,
111 #define INSTALL_NOTIFY_HANDLER 1
112 #define UNINSTALL_NOTIFY_HANDLER 2
123 static int acpi_processor_errata_piix4(
struct pci_dev *
dev)
165 errata.piix4.throttle = 1;
204 pci_read_config_byte(dev, 0x76, &value1);
205 pci_read_config_byte(dev, 0x77, &value2);
206 if ((value1 & 0x80) || (value2 & 0x80))
216 "Bus master activity detection (BM-IDE) erratum enabled\n"));
219 "Type-F DMA livelock erratum (C3 disabled)\n"));
240 result = acpi_processor_errata_piix4(dev);
251 static int acpi_processor_get_info(
struct acpi_device *
device)
258 static int cpu0_initialized;
260 pr = acpi_driver_data(device);
274 pr->
flags.bm_control = 1;
276 "Bus mastering arbitration control present\n"));
279 "No bus mastering arbitration control\n"));
294 pr->
acpi_id =
object.processor.proc_id;
300 unsigned long long value;
305 "Evaluating processor _UID [%#x]\n", status);
308 device_declaration = 1;
314 if (!cpu0_initialized && (cpu_index == -1) &&
319 cpu0_initialized = 1;
341 sprintf(acpi_device_bid(device),
"CPU%X", pr->
id);
347 else if (
object.
processor.pblk_length != 6)
351 pr->
throttling.address =
object.processor.pblk_address;
355 pr->
pblk =
object.processor.pblk_address;
381 static void acpi_processor_notify(
struct acpi_device *device,
u32 event)
395 acpi_bus_generate_proc_event(device, event,
398 dev_name(&device->dev), event,
403 acpi_bus_generate_proc_event(device, event, 0);
405 dev_name(&device->dev), event, 0);
409 acpi_bus_generate_proc_event(device, event, 0);
411 dev_name(&device->dev), event, 0);
415 "Unsupported event [0x%x]\n", event));
423 unsigned long action,
void *hcpu)
425 unsigned int cpu = (
unsigned long)hcpu;
432 if (pr->
flags.need_hotplug_init) {
434 "CPU: %d\n", pr->
id);
435 WARN(acpi_processor_start(pr),
"Failed to start CPU:"
437 pr->
flags.need_hotplug_init = 0;
455 .notifier_call = acpi_cpu_soft_notify,
468 struct acpi_device *device =
per_cpu(processor_device_array, pr->
id);
471 #ifdef CONFIG_CPU_FREQ
483 if (IS_ERR(pr->
cdev)) {
484 result = PTR_ERR(pr->
cdev);
488 dev_dbg(&device->dev,
"registered as cooling_device%d\n",
492 &pr->
cdev->device.kobj,
496 goto err_thermal_unregister;
503 goto err_remove_sysfs_thermal;
508 err_remove_sysfs_thermal:
510 err_thermal_unregister:
524 static int __cpuinit acpi_processor_add(
struct acpi_device *device)
539 pr->
handle = device->handle;
542 device->driver_data =
pr;
544 result = acpi_processor_get_info(device);
555 BUG_ON((pr->
id >= nr_cpu_ids) || (pr->
id < 0));
563 per_cpu(processor_device_array, pr->
id) != device) {
565 "for the processor\n");
567 goto err_free_cpumask;
569 per_cpu(processor_device_array, pr->
id) = device;
576 goto err_clear_processor;
583 if (pr->
flags.need_hotplug_init)
586 result = acpi_processor_start(pr);
588 goto err_remove_sysfs;
600 free_cpumask_var(pr->
throttling.shared_cpu_map);
606 static int acpi_processor_remove(
struct acpi_device *device,
int type)
611 if (!device || !acpi_driver_data(device))
614 pr = acpi_driver_data(device);
616 if (pr->
id >= nr_cpu_ids)
619 if (type == ACPI_BUS_REMOVAL_EJECT) {
620 if (acpi_processor_handle_eject(pr))
639 free_cpumask_var(pr->
throttling.shared_cpu_map);
645 #ifdef CONFIG_ACPI_HOTPLUG_CPU
653 unsigned long long sta = 0;
666 "Processor does not support hot plug\n"));
669 "Processor Device is not present"));
674 int acpi_processor_device_add(
acpi_handle handle,
struct acpi_device **device)
677 struct acpi_device *
pdev;
688 if (
acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
695 static void acpi_processor_hotplug_notify(
acpi_handle handle,
699 struct acpi_device *device =
NULL;
700 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
707 "Processor driver received %s event\n",
709 "ACPI_NOTIFY_BUS_CHECK" :
"ACPI_NOTIFY_DEVICE_CHECK"));
711 if (!is_processor_present(handle))
717 result = acpi_processor_device_add(handle, &device);
723 ost_code = ACPI_OST_SC_SUCCESS;
728 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
732 "Device don't exist, dropping EJECT\n");
735 pr = acpi_driver_data(device);
738 "Driver data is NULL, dropping EJECT\n");
743 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
748 "Unsupported event [0x%x]\n", event));
796 status = is_processor_device(handle);
804 acpi_processor_hotplug_notify,
810 acpi_processor_hotplug_notify);
824 if (!is_processor_present(handle)) {
828 if (acpi_map_lsapic(handle, &pr->
id))
831 if (arch_register_cpu(pr->
id)) {
832 acpi_unmap_lsapic(pr->
id);
845 pr->
flags.need_hotplug_init = 1;
855 arch_unregister_cpu(pr->
id);
856 acpi_unmap_lsapic(pr->
id);
871 void acpi_processor_install_hotplug_notify(
void)
873 #ifdef CONFIG_ACPI_HOTPLUG_CPU
878 processor_walk_namespace_cb,
NULL, &action,
NULL);
884 void acpi_processor_uninstall_hotplug_notify(
void)
886 #ifdef CONFIG_ACPI_HOTPLUG_CPU
891 processor_walk_namespace_cb,
NULL, &action,
NULL);
902 static int __init acpi_processor_init(
void)
913 acpi_processor_install_hotplug_notify();
915 acpi_thermal_cpufreq_init();
924 static void __exit acpi_processor_exit(
void)
931 acpi_thermal_cpufreq_exit();
933 acpi_processor_uninstall_hotplug_notify();