From 4169c45f179e285feac6bcf25f4bd0db6b109bab Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Wed, 14 Nov 2007 19:38:40 -0500 Subject: ACPI: add control method tracing support Add debug tracing support during certain AML method execution. Four more module parameters are created under /sys/module/acpi/parameters/: trace_method_name: the AML method name that user wants to trace trace_debug_layer: the temporary debug_layer used when tracing the method. Using 0xffffffff by default if it is 0. trace_debug_level: the temporary debug_level used when tracing the method. Using 0x00ffffff by default if it is 0. trace_state: The status of the tracing feature. "enabled" means this feature is enabled and the AML method is traced every time it's executed. "1" means this feature is enabled and the AML method will only be traced during the next execution. "disabled" means this feature is disabled. Users can enable/disable this debug tracing feature by "echo string > /sys/module/acpi/parameters/trace_state". "string" should be one of "enable", "disable" and "1". http://bugzilla.kernel.org/show_bug.cgi?id=6629 Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/debug.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index bf513e07b77..6df564f4ca6 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c @@ -130,6 +130,63 @@ static int param_get_debug_level(char *buffer, struct kernel_param *kp) { module_param_call(debug_layer, param_set_uint, param_get_debug_layer, &acpi_dbg_layer, 0644); module_param_call(debug_level, param_set_uint, param_get_debug_level, &acpi_dbg_level, 0644); +static char trace_method_name[6]; +module_param_string(trace_method_name, trace_method_name, 6, 0644); +static unsigned int trace_debug_layer; +module_param(trace_debug_layer, uint, 0644); +static unsigned int trace_debug_level; +module_param(trace_debug_level, uint, 0644); + +static int param_set_trace_state(const char *val, struct kernel_param *kp) +{ + int result = 0; + + if (!strncmp(val, "enable", strlen("enable") - 1)) { + result = acpi_debug_trace(trace_method_name, trace_debug_level, + trace_debug_layer, 0); + if (result) + result = -EBUSY; + goto exit; + } + + if (!strncmp(val, "disable", strlen("disable") - 1)) { + int name = 0; + result = acpi_debug_trace((char *)&name, trace_debug_level, + trace_debug_layer, 0); + if (result) + result = -EBUSY; + goto exit; + } + + if (!strncmp(val, "1", 1)) { + result = acpi_debug_trace(trace_method_name, trace_debug_level, + trace_debug_layer, 1); + if (result) + result = -EBUSY; + goto exit; + } + + result = -EINVAL; +exit: + return result; +} + +static int param_get_trace_state(char *buffer, struct kernel_param *kp) +{ + if (!acpi_gbl_trace_method_name) + return sprintf(buffer, "disable"); + else { + if (acpi_gbl_trace_flags & 1) + return sprintf(buffer, "1"); + else + return sprintf(buffer, "enable"); + } + return 0; +} + +module_param_call(trace_state, param_set_trace_state, param_get_trace_state, + NULL, 0644); + /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ -- cgit v1.2.3 From a7f9b1f24974da287771e2d70b30d9ca7bd66684 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Tue, 20 Nov 2007 13:38:59 -0500 Subject: ACPI: disable stray GPE, prevent ACPI interrupt storm GPEs are disabled depending on their type -- WAKE, WAKE_RUN, and RUNTIME. An error is returned if we are asked to disable a GPE that has no type. But at least one system exists that enables a GPE from AML that is not the EC GPE, and has no _Lxx/_Exx AML handler, and is thus never initialized. In this case, when an external CRT is plugged in, the GPE fires, we attempt to disable the GPE, but instead just return an error. So the GPE stays asserted and an ACPI interrupt storm follows. The fix is to disable a firing GPE, even if it comes from outer space. http://bugzilla.kernel.org/show_bug.cgi?id=6217 Signed-off-by: Zhang Rui Acked-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/events/evgpe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index e22f4a973c0..056b7884482 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -270,18 +270,18 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info) case ACPI_GPE_TYPE_WAKE_RUN: ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED); - /*lint -fallthrough */ + /* fallthrough */ case ACPI_GPE_TYPE_RUNTIME: /* Disable the requested runtime GPE */ ACPI_CLEAR_BIT(gpe_event_info->flags, ACPI_GPE_RUN_ENABLED); - status = acpi_hw_write_gpe_enable_reg(gpe_event_info); - break; + + /* fallthrough */ default: - return_ACPI_STATUS(AE_BAD_PARAMETER); + acpi_hw_write_gpe_enable_reg(gpe_event_info); } return_ACPI_STATUS(AE_OK); -- cgit v1.2.3 From 17bc54eef91df29f0a22e8a1562a404cf7a68e74 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Tue, 13 Nov 2007 13:05:45 +0300 Subject: ACPI: Defer enabling of level GPE until all pending notifies done Level GPE should not be enabled until all work caused by it is done, e.g. all Notify() methods are completed. This can be accomplished by appending enable_gpe function to the end of notify queue. Signed-off-by: Alexey Starikovskiy Acked-by: Shaohua Li Signed-off-by: Len Brown --- drivers/acpi/events/evgpe.c | 17 +++++++++++++---- drivers/acpi/osl.c | 42 ++++++++---------------------------------- 2 files changed, 21 insertions(+), 38 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index e22f4a973c0..b4509f93ff8 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -501,6 +501,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) * an interrupt handler. * ******************************************************************************/ +static void acpi_ev_asynch_enable_gpe(void *context); static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) { @@ -576,22 +577,30 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) method_node))); } } + /* Defer enabling of GPE until all notify handlers are done */ + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_asynch_enable_gpe, + gpe_event_info); + return_VOID; +} - if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == +static void acpi_ev_asynch_enable_gpe(void *context) +{ + struct acpi_gpe_event_info *gpe_event_info = context; + acpi_status status; + if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) { /* * GPE is level-triggered, we clear the GPE status bit after * handling the event. */ - status = acpi_hw_clear_gpe(&local_gpe_event_info); + status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { return_VOID; } } /* Enable this GPE */ - - (void)acpi_hw_write_gpe_enable_reg(&local_gpe_event_info); + (void)acpi_hw_write_gpe_enable_reg(gpe_event_info); return_VOID; } diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e3a673a0084..21d34595dba 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -618,25 +618,6 @@ static void acpi_os_execute_deferred(struct work_struct *work) dpc->function(dpc->context); kfree(dpc); - /* Yield cpu to notify thread */ - cond_resched(); - - return; -} - -static void acpi_os_execute_notify(struct work_struct *work) -{ - struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work); - - if (!dpc) { - printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); - return; - } - - dpc->function(dpc->context); - - kfree(dpc); - return; } @@ -660,7 +641,7 @@ acpi_status acpi_os_execute(acpi_execute_type type, { acpi_status status = AE_OK; struct acpi_os_dpc *dpc; - + struct workqueue_struct *queue; ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Scheduling function [%p(%p)] for deferred execution.\n", function, context)); @@ -684,20 +665,13 @@ acpi_status acpi_os_execute(acpi_execute_type type, dpc->function = function; dpc->context = context; - if (type == OSL_NOTIFY_HANDLER) { - INIT_WORK(&dpc->work, acpi_os_execute_notify); - if (!queue_work(kacpi_notify_wq, &dpc->work)) { - status = AE_ERROR; - kfree(dpc); - } - } else { - INIT_WORK(&dpc->work, acpi_os_execute_deferred); - if (!queue_work(kacpid_wq, &dpc->work)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Call to queue_work() failed.\n")); - status = AE_ERROR; - kfree(dpc); - } + INIT_WORK(&dpc->work, acpi_os_execute_deferred); + queue = (type == OSL_NOTIFY_HANDLER) ? kacpi_notify_wq : kacpid_wq; + if (!queue_work(queue, &dpc->work)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Call to queue_work() failed.\n")); + status = AE_ERROR; + kfree(dpc); } return_ACPI_STATUS(status); } -- cgit v1.2.3 From 223630fe3dc564b94e51ff4eb839828c9083f2f6 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 6 Dec 2007 23:36:35 -0500 Subject: export thermal notification to userspace when nocrt is set module parameter is used to prevent the thermal_zone action upon critical trip points. But exporting this notification to userspace is still useful. By setting nocrt with this patch applied, ACPI will take no action but exporting the events to userspace upon critical/hot trip points. http://bugzilla.kernel.org/show_bug.cgi?id=9139 Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/thermal.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 5f79b445121..3a0af9a8cd2 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -492,7 +492,7 @@ static int acpi_thermal_get_devices(struct acpi_thermal *tz) static int acpi_thermal_critical(struct acpi_thermal *tz) { - if (!tz || !tz->trips.critical.flags.valid || nocrt) + if (!tz || !tz->trips.critical.flags.valid) return -EINVAL; if (tz->temperature >= tz->trips.critical.temperature) { @@ -501,9 +501,6 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) } else if (tz->trips.critical.flags.enabled) tz->trips.critical.flags.enabled = 0; - printk(KERN_EMERG - "Critical temperature reached (%ld C), shutting down.\n", - KELVIN_TO_CELSIUS(tz->temperature)); acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); acpi_bus_generate_netlink_event(tz->device->pnp.device_class, @@ -511,14 +508,20 @@ static int acpi_thermal_critical(struct acpi_thermal *tz) ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled); - orderly_poweroff(true); + /* take no action if nocrt is set */ + if(!nocrt) { + printk(KERN_EMERG + "Critical temperature reached (%ld C), shutting down.\n", + KELVIN_TO_CELSIUS(tz->temperature)); + orderly_poweroff(true); + } return 0; } static int acpi_thermal_hot(struct acpi_thermal *tz) { - if (!tz || !tz->trips.hot.flags.valid || nocrt) + if (!tz || !tz->trips.hot.flags.valid) return -EINVAL; if (tz->temperature >= tz->trips.hot.temperature) { @@ -534,7 +537,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz) ACPI_THERMAL_NOTIFY_HOT, tz->trips.hot.flags.enabled); - /* TBD: Call user-mode "sleep(S4)" function */ + /* TBD: Call user-mode "sleep(S4)" function if nocrt is cleared */ return 0; } -- cgit v1.2.3 From 3620f2f2f39e7870cf1a4fb2e34063a142f28716 Mon Sep 17 00:00:00 2001 From: Frank Seidel Date: Fri, 7 Dec 2007 13:20:34 +0100 Subject: ACPI: Fix autloading of dock, video, bay and all linux specific HID drivers References: https://bugzilla.novell.com/show_bug.cgi?id=302482 Due to the new autloading of acpi drivers, the dock driver wasn't loaded anymore as there is no HID to identify it with (dock is needed if ACPI has a _DCK method). This patch is a workaround for this, original by Thomas Renninger, revised first by Kay Sievers and last by Frank Seidel. V2 of this patch fixed problems on systems without a defined _CID for the docking devices. Signed-off-by: Thomas Renninger Signed-off-by: Kay Sievers Signed-off-by: Frank Seidel Signed-off-by: Len Brown --- drivers/acpi/scan.c | 100 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 15 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5b4d462117c..bf079265ce7 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -941,6 +941,15 @@ static int acpi_bay_match(struct acpi_device *device){ return -ENODEV; } +/* + * acpi_dock_match - see if a device has a _DCK method + */ +static int acpi_dock_match(struct acpi_device *device) +{ + acpi_handle tmp; + return acpi_get_handle(device->handle, "_DCK", &tmp); +} + static void acpi_device_set_id(struct acpi_device *device, struct acpi_device *parent, acpi_handle handle, int type) @@ -950,6 +959,7 @@ static void acpi_device_set_id(struct acpi_device *device, char *hid = NULL; char *uid = NULL; struct acpi_compatible_id_list *cid_list = NULL; + const char *cid_add = NULL; acpi_status status; switch (type) { @@ -972,15 +982,18 @@ static void acpi_device_set_id(struct acpi_device *device, device->flags.bus_address = 1; } - if(!(info->valid & (ACPI_VALID_HID | ACPI_VALID_CID))){ - status = acpi_video_bus_match(device); - if(ACPI_SUCCESS(status)) - hid = ACPI_VIDEO_HID; + /* If we have a video/bay/dock device, add our selfdefined + HID to the CID list. Like that the video/bay/dock drivers + will get autoloaded and the device might still match + against another driver. + */ + if (ACPI_SUCCESS(acpi_video_bus_match(device))) + cid_add = ACPI_VIDEO_HID; + else if (ACPI_SUCCESS(acpi_bay_match(device))) + cid_add = ACPI_BAY_HID; + else if (ACPI_SUCCESS(acpi_dock_match(device))) + cid_add = ACPI_DOCK_HID; - status = acpi_bay_match(device); - if (ACPI_SUCCESS(status)) - hid = ACPI_BAY_HID; - } break; case ACPI_BUS_TYPE_POWER: hid = ACPI_POWER_HID; @@ -1021,11 +1034,44 @@ static void acpi_device_set_id(struct acpi_device *device, strcpy(device->pnp.unique_id, uid); device->flags.unique_id = 1; } - if (cid_list) { - device->pnp.cid_list = kmalloc(cid_list->size, GFP_KERNEL); - if (device->pnp.cid_list) - memcpy(device->pnp.cid_list, cid_list, cid_list->size); - else + if (cid_list || cid_add) { + struct acpi_compatible_id_list *list; + int size = 0; + int count = 0; + + if (cid_list) { + size = cid_list->size; + } else if (cid_add) { + size = sizeof(struct acpi_compatible_id_list); + cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size); + if (!cid_list) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(buffer.pointer); + return; + } else { + cid_list->count = 0; + cid_list->size = size; + } + } + if (cid_add) + size += sizeof(struct acpi_compatible_id); + list = kmalloc(size, GFP_KERNEL); + + if (list) { + if (cid_list) { + memcpy(list, cid_list, cid_list->size); + count = cid_list->count; + } + if (cid_add) { + strncpy(list->id[count].value, cid_add, + ACPI_MAX_CID_LENGTH); + count++; + device->flags.compatible_ids = 1; + } + list->size = size; + list->count = count; + device->pnp.cid_list = list; + } else printk(KERN_ERR "Memory allocation error\n"); } @@ -1080,6 +1126,20 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) return 0; } +static int +acpi_is_child_device(struct acpi_device *device, + int (*matcher)(struct acpi_device *)) +{ + int result = -ENODEV; + + do { + if (ACPI_SUCCESS(matcher(device))) + return AE_OK; + } while ((device = device->parent)); + + return result; +} + static int acpi_add_single_object(struct acpi_device **child, struct acpi_device *parent, acpi_handle handle, int type, @@ -1131,10 +1191,20 @@ acpi_add_single_object(struct acpi_device **child, case ACPI_BUS_TYPE_PROCESSOR: case ACPI_BUS_TYPE_DEVICE: result = acpi_bus_get_status(device); - if (ACPI_FAILURE(result) || !device->status.present) { - result = -ENOENT; + if (ACPI_FAILURE(result)) { + result = -ENODEV; goto end; } + if (!device->status.present) { + /* Bay and dock should be handled even if absent */ + if (!ACPI_SUCCESS( + acpi_is_child_device(device, acpi_bay_match)) && + !ACPI_SUCCESS( + acpi_is_child_device(device, acpi_dock_match))) { + result = -ENODEV; + goto end; + } + } break; default: STRUCT_TO_INT(device->status) = -- cgit v1.2.3 From a340af14b4c08a53c5f7d821d8bd910e17403384 Mon Sep 17 00:00:00 2001 From: Frank Seidel Date: Fri, 7 Dec 2007 13:20:42 +0100 Subject: ACPI: Add autoload info to dock driver References: https://bugzilla.novell.com/show_bug.cgi?id=302482 Signed-off-by: Thomas Renninger Signed-off-by: Kay Sievers Signed-off-by: Frank Seidel Signed-off-by: Len Brown --- drivers/acpi/dock.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 1dabdf4c07b..b3dec2101e2 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -51,6 +51,12 @@ static struct atomic_notifier_head dock_notifier_list; static struct platform_device *dock_device; static char dock_device_name[] = "dock"; +static const struct acpi_device_id dock_device_ids[] = { + {"LNXDOCK", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, dock_device_ids); + struct dock_station { acpi_handle handle; unsigned long last_dock_time; -- cgit v1.2.3 From 17196d6e533a5c09ca57bf398099ffa3c13248b1 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Fri, 7 Dec 2007 13:20:43 +0100 Subject: ACPI: Also autoload the bay driver, was forgotten... Signed-off-by: Thomas Renninger Signed-off-by: Len Brown --- drivers/acpi/bay.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c index 6daf6088ac8..477711435b2 100644 --- a/drivers/acpi/bay.c +++ b/drivers/acpi/bay.c @@ -46,6 +46,12 @@ MODULE_LICENSE("GPL"); printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); } static void bay_notify(acpi_handle handle, u32 event, void *data); +static const struct acpi_device_id bay_device_ids[] = { + {"LNXIOBAY", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, bay_device_ids); + struct bay { acpi_handle handle; char *name; -- cgit v1.2.3 From 2fdf07417e57136cf6baedf9508e2169a059ebea Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 13 Dec 2007 08:33:59 +0000 Subject: acpi: make __acpi_map_table() and __init function .. as it it used only during early boot. Signed-off-by: Jan Beulich arch/ia64/kernel/acpi.c | 2 +- arch/x86/kernel/acpi/boot.c | 4 ++-- drivers/acpi/osl.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) Signed-off-by: Len Brown --- drivers/acpi/osl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e3a673a0084..82525d9cccb 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -211,7 +211,8 @@ acpi_physical_address __init acpi_os_get_root_pointer(void) return acpi_find_rsdp(); } -void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size) +void __iomem *__init_refok +acpi_os_map_memory(acpi_physical_address phys, acpi_size size) { if (phys > ULONG_MAX) { printk(KERN_ERR PREFIX "Cannot map memory that high\n"); -- cgit v1.2.3 From 4963f62045b64f93c45fbcb6f8f0baf1e3e7a127 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 13 Dec 2007 23:50:45 -0500 Subject: cpuidle: create processor.latency_factor tunable Start with default value of 6, so by default, there is no functional change in this patch. Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index f996d0e3768..26ade1f3f5c 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -94,6 +94,9 @@ module_param(bm_history, uint, 0644); static int acpi_processor_set_power_policy(struct acpi_processor *pr); +#else /* CONFIG_CPU_IDLE */ +static unsigned int latency_factor __read_mostly = 6; +module_param(latency_factor, uint, 0644); #endif /* @@ -1576,7 +1579,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); state->exit_latency = cx->latency; - state->target_residency = cx->latency * 6; + state->target_residency = cx->latency * latency_factor; state->power_usage = cx->power; state->flags = 0; -- cgit v1.2.3 From 25de5718356e264820625600a9edca1df5ff26f8 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 14 Dec 2007 00:24:15 -0500 Subject: cpuidle: default processor.latency_factor=2 More aggressively request deep C-states. Note that the job of the OS is to minimize latency impact to expected break events such as interrupts. It is not the job of the OS to try to calculate if the C-state will reach energy break-even. The platform doesn't give the OS enough information for it to make that calculation. Thus, it is up to the platform to decide if it is worth it to go as deep as the OS requested it to, or if it should internally demote to a more shallow C-state. But the converse is not true. The platform can not promote into a deeper C-state than the OS requested else it may violate latency constraints. So it is important that the OS be aggressive in giving the platform permission to enter deep C-states. Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 26ade1f3f5c..bc99b7b9094 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -95,7 +95,7 @@ module_param(bm_history, uint, 0644); static int acpi_processor_set_power_policy(struct acpi_processor *pr); #else /* CONFIG_CPU_IDLE */ -static unsigned int latency_factor __read_mostly = 6; +static unsigned int latency_factor __read_mostly = 2; module_param(latency_factor, uint, 0644); #endif -- cgit v1.2.3 From 239665a3bb0a2234980f918913add31bc536cfd1 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 23 Nov 2007 20:08:02 -0500 Subject: ACPI: tables: complete searching upon RSDP w/ bad checksum. ACPI tables follow a tree structure in memory. The root of the tree is the RSDP (Root System Description Pointer). To find the RSDP, the OS searches for the signature "RSD PTR " in well known physical memory locations. Then the OS computes a table checksum to verify that the signature is really part of a valid table header. Some systems have a proper signature but an invalid checksum; followed elsewhere by a proper signature with valid checksum. http://bugzilla.kernel.org/show_bug.cgi?id=9444 The Linux RSDP scanning code bailed out on those systems and as a result they booted with ACPI disabled. Fix this by deleting the Linux RSDP scanning code and plugging in the ACPICA RSDP scanning code. Signed-off-by: Len Brown --- drivers/acpi/osl.c | 8 ++++++-- drivers/acpi/tables/Makefile | 2 +- drivers/acpi/tables/tbxfroot.c | 4 +--- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index aabc6ca4a81..101691ef66c 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -207,8 +207,12 @@ acpi_physical_address __init acpi_os_get_root_pointer(void) "System description tables not found\n"); return 0; } - } else - return acpi_find_rsdp(); + } else { + acpi_physical_address pa = 0; + + acpi_find_root_pointer(&pa); + return pa; + } } void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size) diff --git a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile index 0a7d7afac25..7385efa6162 100644 --- a/drivers/acpi/tables/Makefile +++ b/drivers/acpi/tables/Makefile @@ -2,6 +2,6 @@ # Makefile for all Linux ACPI interpreter subdirectories # -obj-y := tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o +obj-y := tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o EXTRA_CFLAGS += $(ACPI_CFLAGS) diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index cf8fa514189..9ecb4b6c1e7 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -100,7 +100,7 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) /******************************************************************************* * - * FUNCTION: acpi_tb_find_rsdp + * FUNCTION: acpi_find_root_pointer * * PARAMETERS: table_address - Where the table pointer is returned * @@ -219,8 +219,6 @@ acpi_status acpi_find_root_pointer(acpi_native_uint * table_address) return_ACPI_STATUS(AE_NOT_FOUND); } -ACPI_EXPORT_SYMBOL(acpi_find_root_pointer) - /******************************************************************************* * * FUNCTION: acpi_tb_scan_memory_for_rsdp -- cgit v1.2.3 From 087980295082ccaa816330bc69c29a2ff53a244c Mon Sep 17 00:00:00 2001 From: Yi Yang Date: Thu, 27 Dec 2007 22:04:26 -0500 Subject: ACPI: /proc/acpi/alarm parsing: handle large numbers properly In function acpi_system_write_alarm in file drivers/acpi/sleep/proc.c, big sec, min, hr, mo, day and yr are counted twice to get reasonable values, that is very superfluous, we can do that only once. In additon, /proc/acpi/alarm can set a related value which can be specified as YYYY years MM months DD days HH hours MM minutes SS senconds, it isn't a date, so you can specify as +0000-00-00 96:00:00 , that means 3 days later, current code can't handle such a case. This patch removes unnecessary code and does with the aforementioned situation. Before applying this patch: [root@localhost /]# cat /proc/acpi/alarm 2007-12-00 00:00:00 [root@localhost /]# echo "0000-00-00 96:180:180" > /proc/acpi/alarm [root@localhost /]# cat /proc/acpi/alarm 0007-12-02 **:**:** [root@localhost /]# After applying this patch: [root@localhost ~]# echo "2007-12-00 00:00:00" > /proc/acpi/alarm [root@localhost ~]# cat /proc/acpi/alarm 2007-12-00 00:00:00 [root@localhost ~]# echo "0000-00-00 96:180:180" > /proc/acpi/alarm [root@localhost ~]# cat /proc/acpi/alarm 0007-12-04 03:03:00 [root@localhost ~]# Signed-off-by: Yi Yang Signed-off-by: Len Brown --- drivers/acpi/sleep/proc.c | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 1538355c266..e19eb0c25e6 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c @@ -251,27 +251,6 @@ acpi_system_write_alarm(struct file *file, if ((result = get_date_field(&p, &sec))) goto end; - if (sec > 59) { - min += 1; - sec -= 60; - } - if (min > 59) { - hr += 1; - min -= 60; - } - if (hr > 23) { - day += 1; - hr -= 24; - } - if (day > 31) { - mo += 1; - day -= 31; - } - if (mo > 12) { - yr += 1; - mo -= 12; - } - spin_lock_irq(&rtc_lock); rtc_control = CMOS_READ(RTC_CONTROL); @@ -288,24 +267,24 @@ acpi_system_write_alarm(struct file *file, spin_unlock_irq(&rtc_lock); if (sec > 59) { - min++; - sec -= 60; + min += sec/60; + sec = sec%60; } if (min > 59) { - hr++; - min -= 60; + hr += min/60; + min = min%60; } if (hr > 23) { - day++; - hr -= 24; + day += hr/24; + hr = hr%24; } if (day > 31) { - mo++; - day -= 31; + mo += day/32; + day = day%32; } if (mo > 12) { - yr++; - mo -= 12; + yr += mo/13; + mo = mo%13; } spin_lock_irq(&rtc_lock); -- cgit v1.2.3 From 975c30257e75c3d067d4858f60963b80fc6bd0e4 Mon Sep 17 00:00:00 2001 From: Signed-off by Yi Yang Date: Thu, 27 Dec 2007 21:50:42 -0500 Subject: ACPI: detect invalid argument written to /proc/acpi/alarm /proc/acpi/alarm can't be set correctly, here is a sample: [root@localhost /]# echo "2006 09" > /proc/acpi/alarm [root@localhost /]# cat /proc/acpi/alarm 2007-12-09 09:09:09 [root@localhost /]# echo "2006 04" > /proc/acpi/alarm [root@localhost /]# cat /proc/acpi/alarm 2007-12-04 04:04:04 [root@localhost /]# Obviously, it is wrong, it should consider it as an invalid input. after this patch: [root@localhost /]# echo "2008 09" > /proc/acpi/alarm -bash: echo: write error: Invalid argument [root@localhost /]# Signed-off-by: Yi Yang Signed-off-by: Len Brown --- drivers/acpi/sleep/proc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 1538355c266..fce78fbf5f6 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c @@ -178,6 +178,9 @@ static int get_date_field(char **p, u32 * value) * Try to find delimeter, only to insert null. The end of the * string won't have one, but is still valid. */ + if (*p == NULL) + return result; + next = strpbrk(*p, "- :"); if (next) *next++ = '\0'; @@ -190,6 +193,8 @@ static int get_date_field(char **p, u32 * value) if (next) *p = next; + else + *p = NULL; return result; } -- cgit v1.2.3 From 623b78c39c4525731f852072edd742cc4fba6786 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Fri, 18 May 2007 21:59:28 -0500 Subject: ACPI: add "processor.ignore_ppc" hook to workaround BIOS _PPC weirdness There have been fixes using _PPC, which seem to unhide a problem on HP nx6125 (double cpufreq switch freezes the machine for several seconds). This one should provide a workaround for the nx6125 and for possible other machines that show any weird _PPC behaviour. Signed-off-by: Thomas Renninger Signed-off-by: Len Brown --- drivers/acpi/processor_perflib.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 463b0247cbc..f32010bee4d 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -60,6 +60,11 @@ static DEFINE_MUTEX(performance_mutex); * policy is adjusted accordingly. */ +static unsigned int ignore_ppc = 0; +module_param(ignore_ppc, uint, 0644); +MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \ + "limited by BIOS, this should help"); + #define PPC_REGISTERED 1 #define PPC_IN_USE 2 @@ -72,6 +77,9 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb, struct acpi_processor *pr; unsigned int ppc = 0; + if (ignore_ppc) + return 0; + mutex_lock(&performance_mutex); if (event != CPUFREQ_INCOMPATIBLE) @@ -130,7 +138,13 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr) int acpi_processor_ppc_has_changed(struct acpi_processor *pr) { - int ret = acpi_processor_get_platform_limit(pr); + int ret; + + if (ignore_ppc) + return 0; + + ret = acpi_processor_get_platform_limit(pr); + if (ret < 0) return (ret); else -- cgit v1.2.3 From cfaf3747ff3d431fba33f75083b7f50f58ae22ff Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Wed, 9 Jan 2008 02:17:47 -0500 Subject: ACPI: ACPI Exception (): AE_NOT_FOUND, Processor Device is not present ACPI Exception (acpi_processor-0677): AE_NOT_FOUND, Processor Device is not present [20060707] According to the ACPI spec 6.3.7, "If a device object (including the processor object) does not have an _STA object, then OSPM assumes that all of the above bits are set, (in other words, the device is present, enabled, shown in the UI and funtioning)". is_processor_present shoud return 1 if the processor device object exists while it doesn't have an _STA object. http://bugzilla.kernel.org/show_bug.cgi?id=8570 Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/processor_core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e48ee4f8749..c53113e1800 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -812,11 +812,18 @@ static int is_processor_present(acpi_handle handle) status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); - if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) { - ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present")); - return 0; - } - return 1; + /* + * if a processor object does not have an _STA object, + * OSPM assumes that the processor is present. + */ + if (status == AE_NOT_FOUND) + return 1; + + if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT)) + return 1; + + ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present")); + return 0; } static -- cgit v1.2.3 From 3e71a87d03055de0b8c8e42aba758ee6494af083 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Fri, 11 Jan 2008 02:42:51 +0300 Subject: ACPI: EC: Do the byte access with a fast path Specification allows only byte access for EC region, so make it separate from bug-compatible multi-byte access. Also do not allow return of garbage in supplied *value. Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9341 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d411017f8c0..63862dfe347 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -563,7 +563,7 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, void *handler_context, void *region_context) { struct acpi_ec *ec = handler_context; - int result = 0, i = 0; + int result = 0, i; u8 temp = 0; if ((address > 0xFF) || !value || !handler_context) @@ -575,7 +575,16 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, if (bits != 8 && acpi_strict) return AE_BAD_PARAMETER; - while (bits - i > 0) { + if (function == ACPI_READ) { + result = acpi_ec_read(ec, address, &temp); + *value = temp; + } else { + temp = 0xff & (*value); + result = acpi_ec_write(ec, address, temp); + } + + for (i = 8; unlikely(bits - i > 0); i += 8) { + ++address; if (function == ACPI_READ) { result = acpi_ec_read(ec, address, &temp); (*value) |= ((acpi_integer)temp) << i; @@ -583,8 +592,6 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, temp = 0xff & ((*value) >> i); result = acpi_ec_write(ec, address, temp); } - i += 8; - ++address; } switch (result) { -- cgit v1.2.3 From b3b233c7d948a5f55185fb5a1b248157b948a1e5 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Fri, 11 Jan 2008 02:42:57 +0300 Subject: ACPI: EC: Some hardware requires burst mode to operate properly Burst mode temporary (50 ms) locks EC to do only transactions with driver, without it some hardware returns abstract garbage. Reference: http://bugzilla.kernel.org/show_bug.cgi?id=9341 Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/ec.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 63862dfe347..445ecbabbe7 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -575,6 +575,8 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, if (bits != 8 && acpi_strict) return AE_BAD_PARAMETER; + acpi_ec_burst_enable(ec); + if (function == ACPI_READ) { result = acpi_ec_read(ec, address, &temp); *value = temp; @@ -594,6 +596,8 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, } } + acpi_ec_burst_disable(ec); + switch (result) { case -EINVAL: return AE_BAD_PARAMETER; -- cgit v1.2.3 From ad3399c378993152f12c23304ee56d7f9108e758 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 11 Jan 2008 00:10:38 +0100 Subject: ACPI: Fix acpi_pm_device_sleep_state() Fix acpi_pm_device_sleep_state() to return the value returned by _SxD if the device is supposed to wake up the system from given sleep state and the evaluation of _SxW fails (e.g. _SxW is not present). Signed-off-by: Rafael J. Wysocki Signed-off-by: Len Brown --- drivers/acpi/sleep/main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 2c0b6630f8b..99181c8f023 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c @@ -386,11 +386,20 @@ int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p) if (acpi_target_sleep_state == ACPI_STATE_S0 || (wake && adev->wakeup.state.enabled && adev->wakeup.sleep_state <= acpi_target_sleep_state)) { + acpi_status status; + acpi_method[3] = 'W'; - acpi_evaluate_integer(handle, acpi_method, NULL, &d_max); - /* Sanity check */ - if (d_max < d_min) + status = acpi_evaluate_integer(handle, acpi_method, NULL, + &d_max); + if (ACPI_FAILURE(status)) { + d_max = d_min; + } else if (d_max < d_min) { + /* Warn the user of the broken DSDT */ + printk(KERN_WARNING "ACPI: Wrong value from %s\n", + acpi_method); + /* Sanitize it */ d_min = d_max; + } } if (d_min_p) -- cgit v1.2.3 From 37748ebf8888aef6a252016d7c3cdc84514df051 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Wed, 6 Jun 2007 03:34:07 -0400 Subject: ACPI: remove P2B-S from blacklist. According to http://bugzilla.kernel.org/show_bug.cgi?id=6933 The latest BIOS for the P2B-S works fine. Remove it from the blacklist. Signed-off-by: Dave Jones Signed-off-by: Len Brown --- drivers/acpi/blacklist.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 3ec110ce00c..7c24a8dafde 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -67,8 +67,6 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata = { /* IBM 600E - _ADR should return 7, but it returns 1 */ {"IBM ", "TP600E ", 0x00000105, ACPI_SIG_DSDT, less_than_or_equal, "Incorrect _ADR", 1}, - {"ASUS\0\0", "P2B-S ", 0, ACPI_SIG_DSDT, all_versions, - "Bogus PCI routing", 1}, {""} }; -- cgit v1.2.3 From 02f8a8586574350a1f3c2cee79cbc0faf630961d Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Tue, 22 Jan 2008 17:18:22 -0700 Subject: ACPI: Check for any matching CID when walking namespace. The callback function acpi_ns_get_device_callback called from acpi_get_devices() will check CID's if the HID does not match. This code has a bug where it requires that all CIDs match the HID. Changed the code so that any CID match will do. Signed-off-by: Andrew Patterson Signed-off-by: Len Brown --- drivers/acpi/namespace/nsxfeval.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index f39fbc6b923..b92133faf5b 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -443,6 +443,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, struct acpica_device_id hid; struct acpi_compatible_id_list *cid; acpi_native_uint i; + int found; status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { @@ -496,16 +497,19 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, /* Walk the CID list */ + found = 0; for (i = 0; i < cid->count; i++) { if (ACPI_STRNCMP(cid->id[i].value, info->hid, sizeof(struct - acpi_compatible_id)) != + acpi_compatible_id)) == 0) { - ACPI_FREE(cid); - return (AE_OK); + found = 1; + break; } } ACPI_FREE(cid); + if (!found) + return (AE_OK); } } -- cgit v1.2.3 From 38531e6fe51ad5c7dfe72e0e066b5f54bc1921cd Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Wed, 26 Dec 2007 02:03:26 +0000 Subject: ACPI: video: Rationalise ACPI backlight implementation The sysfs backlight class provides no mechanism for querying the acceptable brightness for a backlight. The ACPI spec states that values are only valid if they are reported as available by the firmware. Since we can't provide that information to userspace, instead collapse the range to the number of actual values that can be set. http://bugzilla.kernel.org/show_bug.cgi?id=9277 Signed-off-by: Matthew Garrett Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bd77e81e81c..59639c9c666 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -292,18 +292,26 @@ static int acpi_video_device_set_state(struct acpi_video_device *device, int sta static int acpi_video_get_brightness(struct backlight_device *bd) { unsigned long cur_level; + int i; struct acpi_video_device *vd = (struct acpi_video_device *)bl_get_data(bd); acpi_video_device_lcd_get_level_current(vd, &cur_level); - return (int) cur_level; + for (i = 2; i < vd->brightness->count; i++) { + if (vd->brightness->levels[i] == cur_level) + /* The first two entries are special - see page 575 + of the ACPI spec 3.0 */ + return i-2; + } + return 0; } static int acpi_video_set_brightness(struct backlight_device *bd) { - int request_level = bd->props.brightness; + int request_level = bd->props.brightness+2; struct acpi_video_device *vd = (struct acpi_video_device *)bl_get_data(bd); - acpi_video_device_lcd_set_level(vd, request_level); + acpi_video_device_lcd_set_level(vd, + vd->brightness->levels[request_level]); return 0; } @@ -652,7 +660,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) kfree(obj); if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){ - unsigned long tmp; static int count = 0; char *name; name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); @@ -660,11 +667,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) return; sprintf(name, "acpi_video%d", count++); - acpi_video_device_lcd_get_level_current(device, &tmp); device->backlight = backlight_device_register(name, NULL, device, &acpi_backlight_ops); - device->backlight->props.max_brightness = max_level; - device->backlight->props.brightness = (int)tmp; + device->backlight->props.max_brightness = device->brightness->count-3; + device->backlight->props.brightness = acpi_video_get_brightness(device->backlight); backlight_update_status(device->backlight); kfree(name); -- cgit v1.2.3 From 3f655ef8c439e0775ffb7d1ead5d1d4f060e1f8b Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:11 +0800 Subject: ACPI: register ACPI thermal zone as generic thermal zone devices Register ACPI thermal zone as thermal zone device. the new sys I/F for ACPI thermal zone will be like this: /sys/class/thermal: |thermal_zone1: |-----type: "ACPI thermal zone". RO |-----temp: the current temperature. RO |-----mode: the current working mode. RW. the default value is "kernel" which means thermal management is done by ACPI thermal driver. "echo user > mode" prevents all the ACPI thermal driver actions upon any trip points. |-----trip_point_0_temp: the threshold of trip point 0. RO. |-----trip_point_0_type: "critical". RO. the type of trip point 0 This may be one of critical/hot/passive/active[x] for an ACPI thermal zone. ... |-----trip_point_3_temp: |-----trip_point_3_type: "active[1]" Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 1 + drivers/acpi/thermal.c | 301 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 292 insertions(+), 10 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccf6ea95f68..558372957fd 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -186,6 +186,7 @@ config ACPI_HOTPLUG_CPU config ACPI_THERMAL tristate "Thermal Zone" depends on ACPI_PROCESSOR + select THERMAL default y help This driver adds support for ACPI thermal zones. Most mobile and diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 5f79b445121..c6cfce4c012 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -43,7 +43,7 @@ #include #include #include - +#include #include #include @@ -195,6 +195,8 @@ struct acpi_thermal { struct acpi_thermal_trips trips; struct acpi_handle_list devices; struct timer_list timer; + struct thermal_zone_device *thermal_zone; + int tz_enabled; struct mutex lock; }; @@ -732,6 +734,9 @@ static void acpi_thermal_check(void *data) if (result) goto unlock; + if (!tz->tz_enabled) + goto unlock; + memset(&tz->state, 0, sizeof(tz->state)); /* @@ -825,6 +830,273 @@ static void acpi_thermal_check(void *data) mutex_unlock(&tz->lock); } +/* sys I/F for generic thermal sysfs support */ +static int thermal_get_temp(struct thermal_zone_device *thermal, char *buf) +{ + struct acpi_thermal *tz = thermal->devdata; + + if (!tz) + return -EINVAL; + + return sprintf(buf, "%ld\n", KELVIN_TO_CELSIUS(tz->temperature)); +} + +static const char enabled[] = "kernel"; +static const char disabled[] = "user"; +static int thermal_get_mode(struct thermal_zone_device *thermal, + char *buf) +{ + struct acpi_thermal *tz = thermal->devdata; + + if (!tz) + return -EINVAL; + + return sprintf(buf, "%s\n", tz->tz_enabled ? + enabled : disabled); +} + +static int thermal_set_mode(struct thermal_zone_device *thermal, + const char *buf) +{ + struct acpi_thermal *tz = thermal->devdata; + int enable; + + if (!tz) + return -EINVAL; + + /* + * enable/disable thermal management from ACPI thermal driver + */ + if (!strncmp(buf, enabled, sizeof enabled - 1)) + enable = 1; + else if (!strncmp(buf, disabled, sizeof disabled - 1)) + enable = 0; + else + return -EINVAL; + + if (enable != tz->tz_enabled) { + tz->tz_enabled = enable; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "%s ACPI thermal control\n", + tz->tz_enabled ? enabled : disabled)); + acpi_thermal_check(tz); + } + return 0; +} + +static int thermal_get_trip_type(struct thermal_zone_device *thermal, + int trip, char *buf) +{ + struct acpi_thermal *tz = thermal->devdata; + int i; + + if (!tz || trip < 0) + return -EINVAL; + + if (tz->trips.critical.flags.valid) { + if (!trip) + return sprintf(buf, "critical\n"); + trip--; + } + + if (tz->trips.hot.flags.valid) { + if (!trip) + return sprintf(buf, "hot\n"); + trip--; + } + + if (tz->trips.passive.flags.valid) { + if (!trip) + return sprintf(buf, "passive\n"); + trip--; + } + + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && + tz->trips.active[i].flags.valid; i++) { + if (!trip) + return sprintf(buf, "active%d\n", i); + trip--; + } + + return -EINVAL; +} + +static int thermal_get_trip_temp(struct thermal_zone_device *thermal, + int trip, char *buf) +{ + struct acpi_thermal *tz = thermal->devdata; + int i; + + if (!tz || trip < 0) + return -EINVAL; + + if (tz->trips.critical.flags.valid) { + if (!trip) + return sprintf(buf, "%ld\n", KELVIN_TO_CELSIUS( + tz->trips.critical.temperature)); + trip--; + } + + if (tz->trips.hot.flags.valid) { + if (!trip) + return sprintf(buf, "%ld\n", KELVIN_TO_CELSIUS( + tz->trips.hot.temperature)); + trip--; + } + + if (tz->trips.passive.flags.valid) { + if (!trip) + return sprintf(buf, "%ld\n", KELVIN_TO_CELSIUS( + tz->trips.passive.temperature)); + trip--; + } + + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && + tz->trips.active[i].flags.valid; i++) { + if (!trip) + return sprintf(buf, "%ld\n", KELVIN_TO_CELSIUS( + tz->trips.active[i].temperature)); + trip--; + } + + return -EINVAL; +} + +typedef int (*cb)(struct thermal_zone_device *, int, + struct thermal_cooling_device *); +static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, + struct thermal_cooling_device *cdev, + cb action) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_thermal *tz = thermal->devdata; + acpi_handle handle = device->handle; + int i; + int j; + int trip = -1; + int result = 0; + + if (tz->trips.critical.flags.valid) + trip++; + + if (tz->trips.hot.flags.valid) + trip++; + + if (tz->trips.passive.flags.valid) { + trip++; + for (i = 0; i < tz->trips.passive.devices.count; + i++) { + if (tz->trips.passive.devices.handles[i] != + handle) + continue; + result = action(thermal, trip, cdev); + if (result) + goto failed; + } + } + + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { + if (!tz->trips.active[i].flags.valid) + break; + trip++; + for (j = 0; + j < tz->trips.active[i].devices.count; + j++) { + if (tz->trips.active[i].devices. + handles[j] != handle) + continue; + result = action(thermal, trip, cdev); + if (result) + goto failed; + } + } + + for (i = 0; i < tz->devices.count; i++) { + if (tz->devices.handles[i] != handle) + continue; + result = action(thermal, -1, cdev); + if (result) + goto failed; + } + +failed: + return result; +} + +static int +acpi_thermal_bind_cooling_device(struct thermal_zone_device *thermal, + struct thermal_cooling_device *cdev) +{ + return acpi_thermal_cooling_device_cb(thermal, cdev, + thermal_zone_bind_cooling_device); +} + +static int +acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, + struct thermal_cooling_device *cdev) +{ + return acpi_thermal_cooling_device_cb(thermal, cdev, + thermal_zone_unbind_cooling_device); +} + +static struct thermal_zone_device_ops acpi_thermal_zone_ops = { + .bind = acpi_thermal_bind_cooling_device, + .unbind = acpi_thermal_unbind_cooling_device, + .get_temp = thermal_get_temp, + .get_mode = thermal_get_mode, + .set_mode = thermal_set_mode, + .get_trip_type = thermal_get_trip_type, + .get_trip_temp = thermal_get_trip_temp, +}; + +static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) +{ + int trips = 0; + int result; + int i; + + if (tz->trips.critical.flags.valid) + trips++; + + if (tz->trips.hot.flags.valid) + trips++; + + if (tz->trips.passive.flags.valid) + trips++; + + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && + tz->trips.active[i].flags.valid; i++, trips++); + tz->thermal_zone = thermal_zone_device_register("ACPI thermal zone", + trips, tz, &acpi_thermal_zone_ops); + if (!tz->thermal_zone) + return -ENODEV; + + result = sysfs_create_link(&tz->device->dev.kobj, + &tz->thermal_zone->device.kobj, "thermal_zone"); + if (result) + return result; + + result = sysfs_create_link(&tz->thermal_zone->device.kobj, + &tz->device->dev.kobj, "device"); + if (result) + return result; + + tz->tz_enabled = 1; + + printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n", + tz->device->dev.bus_id, tz->thermal_zone->id); + return 0; +} + +static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) +{ + sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); + sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); + thermal_zone_device_unregister(tz->thermal_zone); + tz->thermal_zone = NULL; +} + + /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ @@ -1260,13 +1532,19 @@ static int acpi_thermal_add(struct acpi_device *device) strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); acpi_driver_data(device) = tz; mutex_init(&tz->lock); + + result = acpi_thermal_get_info(tz); if (result) - goto end; + goto free_memory; + + result = acpi_thermal_register_thermal_zone(tz); + if (result) + goto free_memory; result = acpi_thermal_add_fs(device); if (result) - goto end; + goto unregister_thermal_zone; init_timer(&tz->timer); @@ -1277,19 +1555,21 @@ static int acpi_thermal_add(struct acpi_device *device) acpi_thermal_notify, tz); if (ACPI_FAILURE(status)) { result = -ENODEV; - goto end; + goto remove_fs; } printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); + goto end; - end: - if (result) { - acpi_thermal_remove_fs(device); - kfree(tz); - } - +remove_fs: + acpi_thermal_remove_fs(device); +unregister_thermal_zone: + thermal_zone_device_unregister(tz->thermal_zone); +free_memory: + kfree(tz); +end: return result; } @@ -1329,6 +1609,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) } acpi_thermal_remove_fs(device); + acpi_thermal_unregister_thermal_zone(tz); mutex_destroy(&tz->lock); kfree(tz); return 0; -- cgit v1.2.3 From ce44e19701ac1de004815c225585ff617c5948b4 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:25 +0800 Subject: ACPI: ACPI thermal zone handle notification correctly Change the ACPI thermal action upon notification 0x81 and 0x82. According to the ACPI spec, we should: re-evaluate _PSV and _ACx methods upon notification 0x81 re-evaluate _PSL and _ALx and _TZD upon notificaiton 0x82. But the current code re-evaluates all the trip points for 0x81 while only re-evaluates _TZD for 0x82. Fix this violation of ACPI spec. TODO: devices in _PSL, _ALx and _TZD may change after a notification 0x82. At this time, we need to re-bind the cooling devices with the thermal zone. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/thermal.c | 325 ++++++++++++++++++++++++++++--------------------- 1 file changed, 184 insertions(+), 141 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index c6cfce4c012..d317da5c6e9 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -323,173 +323,221 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) return 0; } -static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) -{ - acpi_status status = AE_OK; - int i = 0; +#define ACPI_TRIPS_CRITICAL 0x01 +#define ACPI_TRIPS_HOT 0x02 +#define ACPI_TRIPS_PASSIVE 0x04 +#define ACPI_TRIPS_ACTIVE 0x08 +#define ACPI_TRIPS_DEVICES 0x10 +#define ACPI_TRIPS_REFRESH_THRESHOLDS (ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE) +#define ACPI_TRIPS_REFRESH_DEVICES ACPI_TRIPS_DEVICES - if (!tz) - return -EINVAL; +#define ACPI_TRIPS_INIT (ACPI_TRIPS_CRITICAL | ACPI_TRIPS_HOT | \ + ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE | \ + ACPI_TRIPS_DEVICES) - /* Critical Shutdown (required) */ - - status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, - &tz->trips.critical.temperature); - if (ACPI_FAILURE(status)) { - tz->trips.critical.flags.valid = 0; - ACPI_EXCEPTION((AE_INFO, status, "No critical threshold")); - return -ENODEV; - } else { - tz->trips.critical.flags.valid = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Found critical threshold [%lu]\n", - tz->trips.critical.temperature)); - } +/* + * This exception is thrown out in two cases: + * 1.An invalid trip point becomes invalid or a valid trip point becomes invalid + * when re-evaluating the AML code. + * 2.TODO: Devices listed in _PSL, _ALx, _TZD may change. + * We need to re-bind the cooling devices of a thermal zone when this occurs. + */ +#define ACPI_THERMAL_TRIPS_EXCEPTION(flags, str) \ +do { \ + if (flags != ACPI_TRIPS_INIT) \ + ACPI_EXCEPTION((AE_INFO, AE_ERROR, \ + "ACPI thermal trip point %s changed\n" \ + "Please send acpidump to linux-acpi@vger.kernel.org\n", str)); \ +} while (0) + +static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) +{ + acpi_status status = AE_OK; + struct acpi_handle_list devices; + int valid = 0; + int i; - if (tz->trips.critical.flags.valid == 1) { - if (crt == -1) { + /* Critical Shutdown (required) */ + if (flag & ACPI_TRIPS_CRITICAL) { + status = acpi_evaluate_integer(tz->device->handle, + "_CRT", NULL, &tz->trips.critical.temperature); + if (ACPI_FAILURE(status)) { tz->trips.critical.flags.valid = 0; - } else if (crt > 0) { - unsigned long crt_k = CELSIUS_TO_KELVIN(crt); - - /* - * Allow override to lower critical threshold - */ - if (crt_k < tz->trips.critical.temperature) - tz->trips.critical.temperature = crt_k; + ACPI_EXCEPTION((AE_INFO, status, + "No critical threshold")); + return -ENODEV; + } else { + tz->trips.critical.flags.valid = 1; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found critical threshold [%lu]\n", + tz->trips.critical.temperature)); + } + if (tz->trips.critical.flags.valid == 1) { + if (crt == -1) { + tz->trips.critical.flags.valid = 0; + } else if (crt > 0) { + unsigned long crt_k = CELSIUS_TO_KELVIN(crt); + /* + * Allow override to lower critical threshold + */ + if (crt_k < tz->trips.critical.temperature) + tz->trips.critical.temperature = crt_k; + } } } /* Critical Sleep (optional) */ - - status = - acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, - &tz->trips.hot.temperature); - if (ACPI_FAILURE(status)) { - tz->trips.hot.flags.valid = 0; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n")); - } else { - tz->trips.hot.flags.valid = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n", - tz->trips.hot.temperature)); - } - - /* Passive: Processors (optional) */ - - if (psv == -1) { - status = AE_SUPPORT; - } else if (psv > 0) { - tz->trips.passive.temperature = CELSIUS_TO_KELVIN(psv); - status = AE_OK; - } else { + if (flag & ACPI_TRIPS_HOT) { status = acpi_evaluate_integer(tz->device->handle, - "_PSV", NULL, &tz->trips.passive.temperature); + "_HOT", NULL, &tz->trips.hot.temperature); + if (ACPI_FAILURE(status)) { + tz->trips.hot.flags.valid = 0; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "No hot threshold\n")); + } else { + tz->trips.hot.flags.valid = 1; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Found hot threshold [%lu]\n", + tz->trips.critical.temperature)); + } } - if (ACPI_FAILURE(status)) { - tz->trips.passive.flags.valid = 0; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n")); - } else { - tz->trips.passive.flags.valid = 1; - - status = - acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, - &tz->trips.passive.tc1); - if (ACPI_FAILURE(status)) - tz->trips.passive.flags.valid = 0; - - status = - acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, - &tz->trips.passive.tc2); - if (ACPI_FAILURE(status)) - tz->trips.passive.flags.valid = 0; + /* Passive (optional) */ + if (flag & ACPI_TRIPS_PASSIVE) { + valid = tz->trips.passive.flags.valid; + if (psv == -1) { + status = AE_SUPPORT; + } else if (psv > 0) { + tz->trips.passive.temperature = CELSIUS_TO_KELVIN(psv); + status = AE_OK; + } else { + status = acpi_evaluate_integer(tz->device->handle, + "_PSV", NULL, &tz->trips.passive.temperature); + } - status = - acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, - &tz->trips.passive.tsp); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; - - status = - acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, - &tz->trips.passive.devices); + else { + tz->trips.passive.flags.valid = 1; + if (flag == ACPI_TRIPS_INIT) { + status = acpi_evaluate_integer( + tz->device->handle, "_TC1", + NULL, &tz->trips.passive.tc1); + if (ACPI_FAILURE(status)) + tz->trips.passive.flags.valid = 0; + status = acpi_evaluate_integer( + tz->device->handle, "_TC2", + NULL, &tz->trips.passive.tc2); + if (ACPI_FAILURE(status)) + tz->trips.passive.flags.valid = 0; + status = acpi_evaluate_integer( + tz->device->handle, "_TSP", + NULL, &tz->trips.passive.tsp); + if (ACPI_FAILURE(status)) + tz->trips.passive.flags.valid = 0; + } + } + } + if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { + memset(&devices, 0, sizeof(struct acpi_handle_list)); + status = acpi_evaluate_reference(tz->device->handle, "_PSL", + NULL, &devices); if (ACPI_FAILURE(status)) tz->trips.passive.flags.valid = 0; - - if (!tz->trips.passive.flags.valid) - printk(KERN_WARNING PREFIX "Invalid passive threshold\n"); else - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Found passive threshold [%lu]\n", - tz->trips.passive.temperature)); - } + tz->trips.passive.flags.valid = 1; - /* Active: Fans, etc. (optional) */ + if (memcmp(&tz->trips.passive.devices, &devices, + sizeof(struct acpi_handle_list))) { + memcpy(&tz->trips.passive.devices, &devices, + sizeof(struct acpi_handle_list)); + ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); + } + } + if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) { + if (valid != tz->trips.passive.flags.valid) + ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state"); + } + /* Active (optional) */ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { - char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; + valid = tz->trips.active[i].flags.valid; if (act == -1) - break; /* disable all active trip points */ - - status = acpi_evaluate_integer(tz->device->handle, - name, NULL, &tz->trips.active[i].temperature); - - if (ACPI_FAILURE(status)) { - if (i == 0) /* no active trip points */ + break; /* disable all active trip points */ + + if (flag & ACPI_TRIPS_ACTIVE) { + status = acpi_evaluate_integer(tz->device->handle, + name, NULL, &tz->trips.active[i].temperature); + if (ACPI_FAILURE(status)) { + tz->trips.active[i].flags.valid = 0; + if (i == 0) + break; + if (act <= 0) + break; + if (i == 1) + tz->trips.active[0].temperature = + CELSIUS_TO_KELVIN(act); + else + /* + * Don't allow override higher than + * the next higher trip point + */ + tz->trips.active[i - 1].temperature = + (tz->trips.active[i - 2].temperature < + CELSIUS_TO_KELVIN(act) ? + tz->trips.active[i - 2].temperature : + CELSIUS_TO_KELVIN(act)); break; - if (act <= 0) /* no override requested */ - break; - if (i == 1) { /* 1 trip point */ - tz->trips.active[0].temperature = - CELSIUS_TO_KELVIN(act); - } else { /* multiple trips */ - /* - * Don't allow override higher than - * the next higher trip point - */ - tz->trips.active[i - 1].temperature = - (tz->trips.active[i - 2].temperature < - CELSIUS_TO_KELVIN(act) ? - tz->trips.active[i - 2].temperature : - CELSIUS_TO_KELVIN(act)); - } - break; + } else + tz->trips.active[i].flags.valid = 1; } name[2] = 'L'; - status = - acpi_evaluate_reference(tz->device->handle, name, NULL, - &tz->trips.active[i].devices); - if (ACPI_SUCCESS(status)) { - tz->trips.active[i].flags.valid = 1; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Found active threshold [%d]:[%lu]\n", - i, tz->trips.active[i].temperature)); - } else - ACPI_EXCEPTION((AE_INFO, status, - "Invalid active threshold [%d]", i)); + if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { + memset(&devices, 0, sizeof(struct acpi_handle_list)); + status = acpi_evaluate_reference(tz->device->handle, + name, NULL, &devices); + if (ACPI_FAILURE(status)) + tz->trips.active[i].flags.valid = 0; + else + tz->trips.active[i].flags.valid = 1; + + if (memcmp(&tz->trips.active[i].devices, &devices, + sizeof(struct acpi_handle_list))) { + memcpy(&tz->trips.active[i].devices, &devices, + sizeof(struct acpi_handle_list)); + ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); + } + } + if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES)) + if (valid != tz->trips.active[i].flags.valid) + ACPI_THERMAL_TRIPS_EXCEPTION(flag, "state"); + + if (!tz->trips.active[i].flags.valid) + break; + } + + if (flag & ACPI_TRIPS_DEVICES) { + memset(&devices, 0, sizeof(struct acpi_handle_list)); + status = acpi_evaluate_reference(tz->device->handle, "_TZD", + NULL, &devices); + if (memcmp(&tz->devices, &devices, + sizeof(struct acpi_handle_list))) { + memcpy(&tz->devices, &devices, + sizeof(struct acpi_handle_list)); + ACPI_THERMAL_TRIPS_EXCEPTION(flag, "device"); + } } return 0; } -static int acpi_thermal_get_devices(struct acpi_thermal *tz) +static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) { - acpi_status status = AE_OK; - - - if (!tz) - return -EINVAL; - - status = - acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &tz->devices); - if (ACPI_FAILURE(status)) - return -ENODEV; - - return 0; + return acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); } static int acpi_thermal_critical(struct acpi_thermal *tz) @@ -1453,15 +1501,15 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) acpi_thermal_check(tz); break; case ACPI_THERMAL_NOTIFY_THRESHOLDS: - acpi_thermal_get_trip_points(tz); + acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); acpi_thermal_check(tz); acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, 0); break; case ACPI_THERMAL_NOTIFY_DEVICES: - if (tz->flags.devices) - acpi_thermal_get_devices(tz); + acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); + acpi_thermal_check(tz); acpi_bus_generate_proc_event(device, event, 0); acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, 0); @@ -1504,11 +1552,6 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz) else acpi_thermal_get_polling_frequency(tz); - /* Get devices in this thermal zone [_TZD] (optional) */ - result = acpi_thermal_get_devices(tz); - if (!result) - tz->flags.devices = 1; - return 0; } -- cgit v1.2.3 From 05a83d972293f39a66bc2aa409a5e7996bba585d Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:24 +0800 Subject: ACPI: register ACPI Fan as generic thermal cooling device Register ACPI Fan as thermal cooling device. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/fan.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 7 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index a6e149d692c..f6e8165c32e 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -30,7 +30,7 @@ #include #include #include - +#include #include #include @@ -68,9 +68,55 @@ static struct acpi_driver acpi_fan_driver = { }, }; +/* thermal cooling device callbacks */ +static int fan_get_max_state(struct thermal_cooling_device *cdev, char *buf) +{ + /* ACPI fan device only support two states: ON/OFF */ + return sprintf(buf, "1\n"); +} + +static int fan_get_cur_state(struct thermal_cooling_device *cdev, char *buf) +{ + struct acpi_device *device = cdev->devdata; + int state; + int result; + + if (!device) + return -EINVAL; + + result = acpi_bus_get_power(device->handle, &state); + if (result) + return result; + + return sprintf(buf, "%s\n", state == ACPI_STATE_D3 ? "0" : + (state == ACPI_STATE_D0 ? "1" : "unknown")); +} + +static int +fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned int state) +{ + struct acpi_device *device = cdev->devdata; + int result; + + if (!device || (state != 0 && state != 1)) + return -EINVAL; + + result = acpi_bus_set_power(device->handle, + state ? ACPI_STATE_D0 : ACPI_STATE_D3); + + return result; +} + +static struct thermal_cooling_device_ops fan_cooling_ops = { + .get_max_state = fan_get_max_state, + .get_cur_state = fan_get_cur_state, + .set_cur_state = fan_set_cur_state, +}; + /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ +#ifdef CONFIG_ACPI_PROCFS static struct proc_dir_entry *acpi_fan_dir; @@ -171,7 +217,17 @@ static int acpi_fan_remove_fs(struct acpi_device *device) return 0; } +#else +static int acpi_fan_add_fs(struct acpi_device *device) +{ + return 0; +} +static int acpi_fan_remove_fs(struct acpi_device *device) +{ + return 0; +} +#endif /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ @@ -179,9 +235,8 @@ static int acpi_fan_remove_fs(struct acpi_device *device) static int acpi_fan_add(struct acpi_device *device) { int result = 0; - struct acpi_fan *fan = NULL; int state = 0; - + struct thermal_cooling_device *cdev; if (!device) return -EINVAL; @@ -199,6 +254,25 @@ static int acpi_fan_add(struct acpi_device *device) acpi_bus_set_power(device->handle, state); device->flags.force_power_state = 0; + cdev = thermal_cooling_device_register("Fan", device, + &fan_cooling_ops); + if (cdev) + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev.bus_id, cdev->id); + else + goto end; + acpi_driver_data(device) = cdev; + result = sysfs_create_link(&device->dev.kobj, &cdev->device.kobj, + "thermal_cooling"); + if (result) + return result; + + result = sysfs_create_link(&cdev->device.kobj, &device->dev.kobj, + "device"); + if (result) + return result; + result = acpi_fan_add_fs(device); if (result) goto end; @@ -208,18 +282,20 @@ static int acpi_fan_add(struct acpi_device *device) !device->power.state ? "on" : "off"); end: - if (result) - kfree(fan); - return result; } static int acpi_fan_remove(struct acpi_device *device, int type) { - if (!device || !acpi_driver_data(device)) + struct thermal_cooling_device *cdev = acpi_driver_data(device); + + if (!device || !cdev) return -EINVAL; acpi_fan_remove_fs(device); + sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); + sysfs_remove_link(&cdev->device.kobj, "device"); + thermal_cooling_device_unregister(cdev); return 0; } -- cgit v1.2.3 From d9460fd227ed2ce52941b6a12ad4de05c195f6aa Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:23 +0800 Subject: ACPI: register ACPI Processor as generic thermal cooling device Register ACPI processor as thermal cooling devices. A combination of processor T-state and P-state are used for thermal throttling. the processor will reduce the frequency first and then set the T-state. we use cpufreq_thermal_reduction_pctg to calculate the cpufreq limit, and call cpufreq_verify_with_limit to set the cpufreq limit. if cpufreq driver is loaded, then we have four cooling state for cpufreq control. cooling state 0: cpufreq limit == max_freq cooling state 1: cpufreq limit == max_freq * 80% cooling state 2: cpufreq limit == max_freq * 60% cooling state 3: cpufreq limit == max_freq * 40% after the cpufreq limit is set to 40 percentage of the max_freq, we use T-state for cooling. eg. a processor has P-state support, and it has 8 T-state (T0-T7), the max_state of the proceesor is 10: state cpufreq-limit T-state 0: max_freq T0 1: max_freq * 80% T0 2: max_freq * 60% T0 3: max_freq * 40% T0 4: max_freq * 40% T1 5: max_freq * 40% T2 6: max_freq * 40% T3 7: max_freq * 40% T4 8: max_freq * 40% T5 9: max_freq * 40% T6 10: max_freq * 40% T7 Signed-off-by: Zhang Rui Signed-off-by: Zhao Yakui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/processor_core.c | 23 +++++++ drivers/acpi/processor_thermal.c | 134 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 152 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e48ee4f8749..5668c5e8ae1 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -668,6 +668,24 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) acpi_processor_power_init(pr, device); + pr->cdev = thermal_cooling_device_register("Processor", device, + &processor_cooling_ops); + if (pr->cdev) + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev.bus_id, pr->cdev->id); + else + goto end; + + result = sysfs_create_link(&device->dev.kobj, &pr->cdev->device.kobj, + "thermal_cooling"); + if (result) + return result; + result = sysfs_create_link(&pr->cdev->device.kobj, &device->dev.kobj, + "device"); + if (result) + return result; + if (pr->flags.throttling) { printk(KERN_INFO PREFIX "%s [%s] (supports", acpi_device_name(device), acpi_device_bid(device)); @@ -791,6 +809,11 @@ static int acpi_processor_remove(struct acpi_device *device, int type) acpi_processor_remove_fs(device); + sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); + sysfs_remove_link(&pr->cdev->device.kobj, "device"); + thermal_cooling_device_unregister(pr->cdev); + pr->cdev = NULL; + processors[pr->id] = NULL; kfree(pr); diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 06e6f3fb882..9cb43f52f7b 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -93,6 +94,9 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr) * _any_ cpufreq driver and not only the acpi-cpufreq driver. */ +#define CPUFREQ_THERMAL_MIN_STEP 0 +#define CPUFREQ_THERMAL_MAX_STEP 3 + static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS]; static unsigned int acpi_thermal_cpufreq_is_init = 0; @@ -109,8 +113,9 @@ static int acpi_thermal_cpufreq_increase(unsigned int cpu) if (!cpu_has_cpufreq(cpu)) return -ENODEV; - if (cpufreq_thermal_reduction_pctg[cpu] < 60) { - cpufreq_thermal_reduction_pctg[cpu] += 20; + if (cpufreq_thermal_reduction_pctg[cpu] < + CPUFREQ_THERMAL_MAX_STEP) { + cpufreq_thermal_reduction_pctg[cpu]++; cpufreq_update_policy(cpu); return 0; } @@ -123,8 +128,9 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu) if (!cpu_has_cpufreq(cpu)) return -ENODEV; - if (cpufreq_thermal_reduction_pctg[cpu] > 20) - cpufreq_thermal_reduction_pctg[cpu] -= 20; + if (cpufreq_thermal_reduction_pctg[cpu] > + (CPUFREQ_THERMAL_MIN_STEP + 1)) + cpufreq_thermal_reduction_pctg[cpu]--; else cpufreq_thermal_reduction_pctg[cpu] = 0; cpufreq_update_policy(cpu); @@ -143,7 +149,7 @@ static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, max_freq = (policy->cpuinfo.max_freq * - (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100; + (100 - cpufreq_thermal_reduction_pctg[policy->cpu] * 20)) / 100; cpufreq_verify_within_limits(policy, 0, max_freq); @@ -155,6 +161,32 @@ static struct notifier_block acpi_thermal_cpufreq_notifier_block = { .notifier_call = acpi_thermal_cpufreq_notifier, }; +static int cpufreq_get_max_state(unsigned int cpu) +{ + if (!cpu_has_cpufreq(cpu)) + return 0; + + return CPUFREQ_THERMAL_MAX_STEP; +} + +static int cpufreq_get_cur_state(unsigned int cpu) +{ + if (!cpu_has_cpufreq(cpu)) + return 0; + + return cpufreq_thermal_reduction_pctg[cpu]; +} + +static int cpufreq_set_cur_state(unsigned int cpu, int state) +{ + if (!cpu_has_cpufreq(cpu)) + return 0; + + cpufreq_thermal_reduction_pctg[cpu] = state; + cpufreq_update_policy(cpu); + return 0; +} + void acpi_thermal_cpufreq_init(void) { int i; @@ -179,6 +211,20 @@ void acpi_thermal_cpufreq_exit(void) } #else /* ! CONFIG_CPU_FREQ */ +static int cpufreq_get_max_state(unsigned int cpu) +{ + return 0; +} + +static int cpufreq_get_cur_state(unsigned int cpu) +{ + return 0; +} + +static int cpufreq_set_cur_state(unsigned int cpu, int state) +{ + return 0; +} static int acpi_thermal_cpufreq_increase(unsigned int cpu) { @@ -310,6 +356,84 @@ int acpi_processor_get_limit_info(struct acpi_processor *pr) return 0; } +/* thermal coolign device callbacks */ +static int acpi_processor_max_state(struct acpi_processor *pr) +{ + int max_state = 0; + + /* + * There exists four states according to + * cpufreq_thermal_reduction_ptg. 0, 1, 2, 3 + */ + max_state += cpufreq_get_max_state(pr->id); + if (pr->flags.throttling) + max_state += (pr->throttling.state_count -1); + + return max_state; +} +static int +processor_get_max_state(struct thermal_cooling_device *cdev, char *buf) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_processor *pr = acpi_driver_data(device); + + if (!device || !pr) + return -EINVAL; + + return sprintf(buf, "%d\n", acpi_processor_max_state(pr)); +} + +static int +processor_get_cur_state(struct thermal_cooling_device *cdev, char *buf) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_processor *pr = acpi_driver_data(device); + int cur_state; + + if (!device || !pr) + return -EINVAL; + + cur_state = cpufreq_get_cur_state(pr->id); + if (pr->flags.throttling) + cur_state += pr->throttling.state; + + return sprintf(buf, "%d\n", cur_state); +} + +static int +processor_set_cur_state(struct thermal_cooling_device *cdev, unsigned int state) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_processor *pr = acpi_driver_data(device); + int result = 0; + int max_pstate; + + if (!device || !pr) + return -EINVAL; + + max_pstate = cpufreq_get_max_state(pr->id); + + if (state > acpi_processor_max_state(pr)) + return -EINVAL; + + if (state <= max_pstate) { + if (pr->flags.throttling && pr->throttling.state) + result = acpi_processor_set_throttling(pr, 0); + cpufreq_set_cur_state(pr->id, state); + } else { + cpufreq_set_cur_state(pr->id, max_pstate); + result = acpi_processor_set_throttling(pr, + state - max_pstate); + } + return result; +} + +struct thermal_cooling_device_ops processor_cooling_ops = { + .get_max_state = processor_get_max_state, + .get_cur_state = processor_get_cur_state, + .set_cur_state = processor_set_cur_state, +}; + /* /proc interface */ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) -- cgit v1.2.3 From 702ed512de9c8a67a69a981c73b7337c2131f198 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:22 +0800 Subject: ACPI: register ACPI Video LCD as generic thermal cooling device Register ACPI video device as thermal cooling devices as they may be listed in _TZD method and the backlight control can be used for throttling. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/video.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bd77e81e81c..eab9c4213b4 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -179,6 +180,7 @@ struct acpi_video_device { struct acpi_device *dev; struct acpi_video_device_brightness *brightness; struct backlight_device *backlight; + struct thermal_cooling_device *cdev; struct output_device *output_dev; }; @@ -334,6 +336,54 @@ static struct output_properties acpi_output_properties = { .set_state = acpi_video_output_set, .get_status = acpi_video_output_get, }; + + +/* thermal cooling device callbacks */ +static int video_get_max_state(struct thermal_cooling_device *cdev, char *buf) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_video_device *video = acpi_driver_data(device); + + return sprintf(buf, "%d\n", video->brightness->count - 3); +} + +static int video_get_cur_state(struct thermal_cooling_device *cdev, char *buf) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_video_device *video = acpi_driver_data(device); + unsigned long level; + int state; + + acpi_video_device_lcd_get_level_current(video, &level); + for (state = 2; state < video->brightness->count; state++) + if (level == video->brightness->levels[state]) + return sprintf(buf, "%d\n", + video->brightness->count - state - 1); + + return -EINVAL; +} + +static int +video_set_cur_state(struct thermal_cooling_device *cdev, unsigned int state) +{ + struct acpi_device *device = cdev->devdata; + struct acpi_video_device *video = acpi_driver_data(device); + int level; + + if ( state >= video->brightness->count - 2) + return -EINVAL; + + state = video->brightness->count - state; + level = video->brightness->levels[state -1]; + return acpi_video_device_lcd_set_level(video, level); +} + +static struct thermal_cooling_device_ops video_cooling_ops = { + .get_max_state = video_get_max_state, + .get_cur_state = video_get_cur_state, + .set_cur_state = video_set_cur_state, +}; + /* -------------------------------------------------------------------------- Video Management -------------------------------------------------------------------------- */ @@ -653,6 +703,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){ unsigned long tmp; + int result; static int count = 0; char *name; name = kzalloc(MAX_NAME_LEN, GFP_KERNEL); @@ -666,8 +717,25 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) device->backlight->props.max_brightness = max_level; device->backlight->props.brightness = (int)tmp; backlight_update_status(device->backlight); - kfree(name); + + device->cdev = thermal_cooling_device_register("LCD", + device->dev, &video_cooling_ops); + if (device->cdev) { + printk(KERN_INFO PREFIX + "%s is registered as cooling_device%d\n", + device->dev->dev.bus_id, device->cdev->id); + result = sysfs_create_link(&device->dev->dev.kobj, + &device->cdev->device.kobj, + "thermal_cooling"); + if (result) + printk(KERN_ERR PREFIX "Create sysfs link\n"); + result = sysfs_create_link(&device->cdev->device.kobj, + &device->dev->dev.kobj, + "device"); + if (result) + printk(KERN_ERR PREFIX "Create sysfs link\n"); + } } if (device->cap._DCS && device->cap._DSS){ static int count = 0; @@ -1729,6 +1797,14 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) ACPI_DEVICE_NOTIFY, acpi_video_device_notify); backlight_device_unregister(device->backlight); + if (device->cdev) { + sysfs_remove_link(&device->dev->dev.kobj, + "thermal_cooling"); + sysfs_remove_link(&device->cdev->device.kobj, + "device"); + thermal_cooling_device_unregister(device->cdev); + device->cdev = NULL; + } video_output_unregister(device->output_dev); return 0; -- cgit v1.2.3 From 207339398ecb0835331c748612898dad2a09fdec Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:21 +0800 Subject: ACPI: attach thermal zone info Intel menlow driver needs to get the pointer of themal_zone_device structure of an ACPI thermal zone. Attach this to each ACPI thermal zone device object. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/bus.c | 25 +++++++++++++++++++++++++ drivers/acpi/thermal.c | 11 +++++++++++ 2 files changed, 36 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 1b4cf984b08..8df325dafe0 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -122,6 +122,31 @@ int acpi_bus_get_status(struct acpi_device *device) EXPORT_SYMBOL(acpi_bus_get_status); +void acpi_bus_private_data_handler(acpi_handle handle, + u32 function, void *context) +{ + return; +} +EXPORT_SYMBOL(acpi_bus_private_data_handler); + +int acpi_bus_get_private_data(acpi_handle handle, void **data) +{ + acpi_status status = AE_OK; + + if (!*data) + return -EINVAL; + + status = acpi_get_data(handle, acpi_bus_private_data_handler, data); + if (ACPI_FAILURE(status) || !*data) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", + handle)); + return -ENODEV; + } + + return 0; +} +EXPORT_SYMBOL(acpi_bus_get_private_data); + /* -------------------------------------------------------------------------- Power Management -------------------------------------------------------------------------- */ diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index d317da5c6e9..74003635572 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -1101,6 +1101,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) { int trips = 0; int result; + acpi_status status; int i; if (tz->trips.critical.flags.valid) @@ -1129,6 +1130,15 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) if (result) return result; + status = acpi_attach_data(tz->device->handle, + acpi_bus_private_data_handler, + tz->thermal_zone); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error attaching device data\n")); + return -ENODEV; + } + tz->tz_enabled = 1; printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n", @@ -1142,6 +1152,7 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); thermal_zone_device_unregister(tz->thermal_zone); tz->thermal_zone = NULL; + acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler); } -- cgit v1.2.3 From 041d4bbf128f645fe53bb22309efb9db14dbf5b5 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:19 +0800 Subject: ACPI: CELSIUS_TO_KELVIN fixup Fix an imprecision in CELSIUS_TO_KELVIN and move these two macroes to a proper place. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/thermal.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 74003635572..aee371f9daf 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -65,9 +65,6 @@ #define ACPI_THERMAL_MAX_ACTIVE 10 #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65 -#define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10) -#define CELSIUS_TO_KELVIN(t) ((t+273)*10) - #define _COMPONENT ACPI_THERMAL_COMPONENT ACPI_MODULE_NAME("thermal"); -- cgit v1.2.3 From 653a00c9662304ef72a3eb4e681c91720960e0b4 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 17 Jan 2008 15:51:18 +0800 Subject: ACPI: thermal fixup The alias name may be used in _PSL, _ALx and _TZD, so we bind the cooling device only if the acpi_device node matches. Signed-off-by: Zhang Rui Signed-off-by: Thomas Sujith Signed-off-by: Len Brown --- drivers/acpi/thermal.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index aee371f9daf..73f276bc6e4 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -1015,7 +1015,9 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, { struct acpi_device *device = cdev->devdata; struct acpi_thermal *tz = thermal->devdata; - acpi_handle handle = device->handle; + struct acpi_device *dev; + acpi_status status; + acpi_handle handle; int i; int j; int trip = -1; @@ -1031,12 +1033,13 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, trip++; for (i = 0; i < tz->trips.passive.devices.count; i++) { - if (tz->trips.passive.devices.handles[i] != - handle) - continue; - result = action(thermal, trip, cdev); - if (result) - goto failed; + handle = tz->trips.passive.devices.handles[i]; + status = acpi_bus_get_device(handle, &dev); + if (ACPI_SUCCESS(status) && (dev == device)) { + result = action(thermal, trip, cdev); + if (result) + goto failed; + } } } @@ -1047,21 +1050,24 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal, for (j = 0; j < tz->trips.active[i].devices.count; j++) { - if (tz->trips.active[i].devices. - handles[j] != handle) - continue; - result = action(thermal, trip, cdev); - if (result) - goto failed; + handle = tz->trips.active[i].devices.handles[j]; + status = acpi_bus_get_device(handle, &dev); + if (ACPI_SUCCESS(status) && (dev == device)) { + result = action(thermal, trip, cdev); + if (result) + goto failed; + } } } for (i = 0; i < tz->devices.count; i++) { - if (tz->devices.handles[i] != handle) - continue; - result = action(thermal, -1, cdev); - if (result) - goto failed; + handle = tz->devices.handles[i]; + status = acpi_bus_get_device(handle, &dev); + if (ACPI_SUCCESS(status) && (dev == device)) { + result = action(thermal, -1, cdev); + if (result) + goto failed; + } } failed: -- cgit v1.2.3 From 0119509c4fbc9adcef1472817fda295334612976 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 17 Jan 2008 03:39:36 +0000 Subject: ACPI: video: Ignore devices that aren't present in hardware Vendors often ship machines with a choice of integrated or discrete graphics, and use the same DSDT for both. As a result, the ACPI video module will locate devices that may not exist on this specific platform. Attempt to determine whether the device exists or not, and abort the device creation if it doesn't. http://bugzilla.kernel.org/show_bug.cgi?id=9614 Signed-off-by: Matthew Garrett Acked-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bd77e81e81c..2270144d728 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1256,8 +1256,37 @@ acpi_video_bus_write_DOS(struct file *file, static int acpi_video_bus_add_fs(struct acpi_device *device) { + long device_id; + int status; struct proc_dir_entry *entry = NULL; struct acpi_video_bus *video; + struct device *dev; + + status = + acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); + + if (!ACPI_SUCCESS(status)) + return -ENODEV; + + /* We need to attempt to determine whether the _ADR refers to a + PCI device or not. There's no terribly good way to do this, + so the best we can hope for is to assume that there'll never + be a video device in the host bridge */ + if (device_id >= 0x10000) { + /* It looks like a PCI device. Does it exist? */ + dev = acpi_get_physical_device(device->handle); + } else { + /* It doesn't look like a PCI device. Does its parent + exist? */ + acpi_handle phandle; + if (acpi_get_parent(device->handle, &phandle)) + return -ENODEV; + dev = acpi_get_physical_device(phandle); + } + if (!dev) + return -ENODEV; + put_device(dev); + video = acpi_driver_data(device); -- cgit v1.2.3 From 87654273ef63213f90c4243913987436495824f0 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Mon, 28 Jan 2008 13:53:30 +0800 Subject: ACPI : Check parameter when calling acpi_processor_get/set_throttling It is necessary to check the parameter when calling the function of acpi_processor_get/set_throttling function so as to avoid the NULL pointer reference in pr or throttling. http://bugzilla.kernel.org/show_bug.cgi?id=9747 Signed-off-by: Zhao Yakui Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 1685b40abda..5d2eae20788 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -589,6 +589,11 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) cpumask_t saved_mask; int ret; + if (!pr) + return -EINVAL; + + if (!pr->flags.throttling) + return -ENODEV; /* * Migrate task to the cpu pointed by pr. */ @@ -743,6 +748,16 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) { cpumask_t saved_mask; int ret; + + if (!pr) + return -EINVAL; + + if (!pr->flags.throttling) + return -ENODEV; + + if ((state < 0) || (state > (pr->throttling.state_count - 1))) + return -EINVAL; + /* * Migrate task to the cpu pointed by pr. */ -- cgit v1.2.3 From 1180509f6b3ec3ac2505375a78ccd72d270f2169 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Mon, 28 Jan 2008 13:53:42 +0800 Subject: ACPI : Update T-state coordination after getting _TSD info Accordint to ACPI spec, the _TSD object provides T-state control cross logical processor dependency information to OSPM. After the _TSD data for all cpus are obtained, OSPM will set up the T-state coordination between CPUs. Of course if the _TSD doesn't exist or _TSD data is incorrect , it is assumed that there is no T-state coordination and T-state is changed independently. Now there is no proper solution to update T-state coordination after one cpu is hotplugged. So this patch won't support hotplugged cpu very well. Signed-off-by: Zhao Yakui Signed-off-by: Len Brown --- drivers/acpi/processor_core.c | 2 + drivers/acpi/processor_throttling.c | 180 +++++++++++++++++++++++++++++++++++- 2 files changed, 181 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e48ee4f8749..b3b53734271 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -1061,6 +1061,8 @@ static int __init acpi_processor_init(void) acpi_processor_ppc_init(); + acpi_processor_throttling_init(); + return 0; out_cpuidle: diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 5d2eae20788..d6780f41d28 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -48,6 +48,154 @@ ACPI_MODULE_NAME("processor_throttling"); static int acpi_processor_get_throttling(struct acpi_processor *pr); int acpi_processor_set_throttling(struct acpi_processor *pr, int state); +static int acpi_processor_update_tsd_coord(void) +{ + int count, count_target; + int retval = 0; + unsigned int i, j; + cpumask_t covered_cpus; + struct acpi_processor *pr, *match_pr; + struct acpi_tsd_package *pdomain, *match_pdomain; + struct acpi_processor_throttling *pthrottling, *match_pthrottling; + + /* + * Now that we have _TSD data from all CPUs, lets setup T-state + * coordination among all CPUs. + */ + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr) + continue; + + /* Basic validity check for domain info */ + pthrottling = &(pr->throttling); + + /* + * If tsd package for one cpu is invalid, the coordination + * among all CPUs is thought as invalid. + * Maybe it is ugly. + */ + if (!pthrottling->tsd_valid_flag) { + retval = -EINVAL; + break; + } + } + if (retval) + goto err_ret; + + cpus_clear(covered_cpus); + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr) + continue; + + if (cpu_isset(i, covered_cpus)) + continue; + pthrottling = &pr->throttling; + + pdomain = &(pthrottling->domain_info); + cpu_set(i, pthrottling->shared_cpu_map); + cpu_set(i, covered_cpus); + /* + * If the number of processor in the TSD domain is 1, it is + * unnecessary to parse the coordination for this CPU. + */ + if (pdomain->num_processors <= 1) + continue; + + /* Validate the Domain info */ + count_target = pdomain->num_processors; + count = 1; + + for_each_possible_cpu(j) { + if (i == j) + continue; + + match_pr = processors[j]; + if (!match_pr) + continue; + + match_pthrottling = &(match_pr->throttling); + match_pdomain = &(match_pthrottling->domain_info); + if (match_pdomain->domain != pdomain->domain) + continue; + + /* Here i and j are in the same domain. + * If two TSD packages have the same domain, they + * should have the same num_porcessors and + * coordination type. Otherwise it will be regarded + * as illegal. + */ + if (match_pdomain->num_processors != count_target) { + retval = -EINVAL; + goto err_ret; + } + + if (pdomain->coord_type != match_pdomain->coord_type) { + retval = -EINVAL; + goto err_ret; + } + + cpu_set(j, covered_cpus); + cpu_set(j, pthrottling->shared_cpu_map); + count++; + } + for_each_possible_cpu(j) { + if (i == j) + continue; + + match_pr = processors[j]; + if (!match_pr) + continue; + + match_pthrottling = &(match_pr->throttling); + match_pdomain = &(match_pthrottling->domain_info); + if (match_pdomain->domain != pdomain->domain) + continue; + + /* + * If some CPUS have the same domain, they + * will have the same shared_cpu_map. + */ + match_pthrottling->shared_cpu_map = + pthrottling->shared_cpu_map; + } + } + +err_ret: + for_each_possible_cpu(i) { + pr = processors[i]; + if (!pr) + continue; + + /* + * Assume no coordination on any error parsing domain info. + * The coordination type will be forced as SW_ALL. + */ + if (retval) { + pthrottling = &(pr->throttling); + cpus_clear(pthrottling->shared_cpu_map); + cpu_set(i, pthrottling->shared_cpu_map); + pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; + } + } + + return retval; +} + +/* + * Update the T-state coordination after the _TSD + * data for all cpus is obtained. + */ +void acpi_processor_throttling_init(void) +{ + if (acpi_processor_update_tsd_coord()) + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Assume no T-state coordination\n")); + + return; +} + /* * _TPC - Throttling Present Capabilities */ @@ -293,6 +441,10 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr) struct acpi_buffer state = { 0, NULL }; union acpi_object *tsd = NULL; struct acpi_tsd_package *pdomain; + struct acpi_processor_throttling *pthrottling; + + pthrottling = &pr->throttling; + pthrottling->tsd_valid_flag = 0; status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer); if (ACPI_FAILURE(status)) { @@ -340,6 +492,22 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr) goto end; } + pthrottling = &pr->throttling; + pthrottling->tsd_valid_flag = 1; + pthrottling->shared_type = pdomain->coord_type; + cpu_set(pr->id, pthrottling->shared_cpu_map); + /* + * If the coordination type is not defined in ACPI spec, + * the tsd_valid_flag will be clear and coordination type + * will be forecd as DOMAIN_COORD_TYPE_SW_ALL. + */ + if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL && + pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ANY && + pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) { + pthrottling->tsd_valid_flag = 0; + pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; + } + end: kfree(buffer.pointer); return result; @@ -772,6 +940,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) int acpi_processor_get_throttling_info(struct acpi_processor *pr) { int result = 0; + struct acpi_processor_throttling *pthrottling; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", @@ -803,7 +972,16 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) &acpi_processor_set_throttling_ptc; } - acpi_processor_get_tsd(pr); + /* + * If TSD package for one CPU can't be parsed successfully, it means + * that this CPU will have no coordination with other CPUs. + */ + if (acpi_processor_get_tsd(pr)) { + pthrottling = &pr->throttling; + pthrottling->tsd_valid_flag = 0; + cpu_set(pr->id, pthrottling->shared_cpu_map); + pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; + } /* * PIIX4 Errata: We don't support throttling on the original PIIX4. -- cgit v1.2.3 From e4aa5cb2138e7423a6edef6a76a3837b94c2f107 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Mon, 28 Jan 2008 13:54:46 +0800 Subject: ACPI : Add T-state event notifier function The t-state coordination should be considered when T-state for one cpu is changed.It means that OSPM should select one proper target T-state for the all affected cpus before updating T-state. So the function of acpi_processor_throttling_notifier is added. Before updating T-state it can be called for all the affected cpus to get the proper target T-state, which can meet the requirement of thermal, user and _TPC. After updating T-state, it can be called to update T-state flag. Signed-off-by: Zhao Yakui Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index d6780f41d28..18a873a5525 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -45,6 +45,14 @@ #define _COMPONENT ACPI_PROCESSOR_COMPONENT ACPI_MODULE_NAME("processor_throttling"); +struct throttling_tstate { + unsigned int cpu; /* cpu nr */ + int target_state; /* target T-state */ +}; + +#define THROTTLING_PRECHANGE (1) +#define THROTTLING_POSTCHANGE (2) + static int acpi_processor_get_throttling(struct acpi_processor *pr); int acpi_processor_set_throttling(struct acpi_processor *pr, int state); @@ -196,6 +204,70 @@ void acpi_processor_throttling_init(void) return; } +static int acpi_processor_throttling_notifier(unsigned long event, void *data) +{ + struct throttling_tstate *p_tstate = data; + struct acpi_processor *pr; + unsigned int cpu ; + int target_state; + struct acpi_processor_limit *p_limit; + struct acpi_processor_throttling *p_throttling; + + cpu = p_tstate->cpu; + pr = processors[cpu]; + if (!pr) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid pr pointer\n")); + return 0; + } + if (!pr->flags.throttling) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Throttling control is " + "unsupported on CPU %d\n", cpu)); + return 0; + } + target_state = p_tstate->target_state; + p_throttling = &(pr->throttling); + switch (event) { + case THROTTLING_PRECHANGE: + /* + * Prechange event is used to choose one proper t-state, + * which meets the limits of thermal, user and _TPC. + */ + p_limit = &pr->limit; + if (p_limit->thermal.tx > target_state) + target_state = p_limit->thermal.tx; + if (p_limit->user.tx > target_state) + target_state = p_limit->user.tx; + if (pr->throttling_platform_limit > target_state) + target_state = pr->throttling_platform_limit; + if (target_state >= p_throttling->state_count) { + printk(KERN_WARNING + "Exceed the limit of T-state \n"); + target_state = p_throttling->state_count - 1; + } + p_tstate->target_state = target_state; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PreChange Event:" + "target T-state of CPU %d is T%d\n", + cpu, target_state)); + break; + case THROTTLING_POSTCHANGE: + /* + * Postchange event is only used to update the + * T-state flag of acpi_processor_throttling. + */ + p_throttling->state = target_state; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PostChange Event:" + "CPU %d is switched to T%d\n", + cpu, target_state)); + break; + default: + printk(KERN_WARNING + "Unsupported Throttling notifier event\n"); + break; + } + + return 0; +} + /* * _TPC - Throttling Present Capabilities */ -- cgit v1.2.3 From 33a2a529f7a2fb481812b99737176628fda457b0 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Mon, 28 Jan 2008 13:55:56 +0800 Subject: ACPI: Update the t-state for every affected cpu when t-state is changed According to ACPI spec, the _TSD object provides T-state control cross logical processor dependency information to OSPM. So the t-state coordination should be considered when T-state for one cpu is changed. According to ACPI spec, three types of coordination are defined. SW_ALL, SW_ANY and HW_ALL. SW_ALL: it means that OSPM needs to initiate T-state transition on all processors in the domain. It is necessary to call throttling set function for all affected cpus. SW_ANY: it means that OSPM may initiate T-state transition on any processor in the domain. HW_ALL: Spec only says that hardware will perform the coordination and doesn't recommend how OSPM coordinate T-state among the affected cpus. So it is treated as the type of SW_ALL. It means that OSPM needs to initiate t-state transition on all the processors in the domain. Signed-off-by: Zhao Yakui Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 79 ++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 18a873a5525..86c790e9f4f 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -68,7 +68,7 @@ static int acpi_processor_update_tsd_coord(void) /* * Now that we have _TSD data from all CPUs, lets setup T-state - * coordination among all CPUs. + * coordination between all CPUs. */ for_each_possible_cpu(i) { pr = processors[i]; @@ -988,6 +988,11 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) { cpumask_t saved_mask; int ret; + unsigned int i; + struct acpi_processor *match_pr; + struct acpi_processor_throttling *p_throttling; + struct throttling_tstate t_state; + cpumask_t online_throttling_cpus; if (!pr) return -EINVAL; @@ -998,12 +1003,76 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) if ((state < 0) || (state > (pr->throttling.state_count - 1))) return -EINVAL; + saved_mask = current->cpus_allowed; + t_state.target_state = state; + p_throttling = &(pr->throttling); + cpus_and(online_throttling_cpus, cpu_online_map, + p_throttling->shared_cpu_map); /* - * Migrate task to the cpu pointed by pr. + * The throttling notifier will be called for every + * affected cpu in order to get one proper T-state. + * The notifier event is THROTTLING_PRECHANGE. */ - saved_mask = current->cpus_allowed; - set_cpus_allowed(current, cpumask_of_cpu(pr->id)); - ret = pr->throttling.acpi_processor_set_throttling(pr, state); + for_each_cpu_mask(i, online_throttling_cpus) { + t_state.cpu = i; + acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, + &t_state); + } + /* + * The function of acpi_processor_set_throttling will be called + * to switch T-state. If the coordination type is SW_ALL or HW_ALL, + * it is necessary to call it for every affected cpu. Otherwise + * it can be called only for the cpu pointed by pr. + */ + if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { + set_cpus_allowed(current, cpumask_of_cpu(pr->id)); + ret = p_throttling->acpi_processor_set_throttling(pr, + t_state.target_state); + } else { + /* + * When the T-state coordination is SW_ALL or HW_ALL, + * it is necessary to set T-state for every affected + * cpus. + */ + for_each_cpu_mask(i, online_throttling_cpus) { + match_pr = processors[i]; + /* + * If the pointer is invalid, we will report the + * error message and continue. + */ + if (!match_pr) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Invalid Pointer for CPU %d\n", i)); + continue; + } + /* + * If the throttling control is unsupported on CPU i, + * we will report the error message and continue. + */ + if (!match_pr->flags.throttling) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Throttling Controll is unsupported " + "on CPU %d\n", i)); + continue; + } + t_state.cpu = i; + set_cpus_allowed(current, cpumask_of_cpu(i)); + ret = match_pr->throttling. + acpi_processor_set_throttling( + match_pr, t_state.target_state); + } + } + /* + * After the set_throttling is called, the + * throttling notifier is called for every + * affected cpu to update the T-states. + * The notifier event is THROTTLING_POSTCHANGE + */ + for_each_cpu_mask(i, online_throttling_cpus) { + t_state.cpu = i; + acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, + &t_state); + } /* restore the previous state */ set_cpus_allowed(current, saved_mask); return ret; -- cgit v1.2.3 From 3391a76f2bbb74e42b9ba44c05a7366ffd388753 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sat, 2 Feb 2008 03:56:18 -0500 Subject: ACPI: throttling: fix build warning Signed-off-by: Len Brown --- drivers/acpi/processor_throttling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 86c790e9f4f..1b8e592a824 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -987,7 +987,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, int acpi_processor_set_throttling(struct acpi_processor *pr, int state) { cpumask_t saved_mask; - int ret; + int ret = 0; unsigned int i; struct acpi_processor *match_pr; struct acpi_processor_throttling *p_throttling; -- cgit v1.2.3 From 3c602840528cf1aa835e6e32d76a0a45936b8e4c Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sat, 2 Feb 2008 04:05:54 -0500 Subject: ACPI: fan: build fix for CONFIG_ACPI_PROCFS=n MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/acpi/fan.c:340: error: ‘acpi_fan_dir’ undeclared (first use in this function) Signed-off-by: Len Brown --- drivers/acpi/fan.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index f6e8165c32e..48cb705b274 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -337,10 +337,12 @@ static int __init acpi_fan_init(void) int result = 0; +#ifdef CONFIG_ACPI_PROCFS acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); if (!acpi_fan_dir) return -ENODEV; acpi_fan_dir->owner = THIS_MODULE; +#endif result = acpi_bus_register_driver(&acpi_fan_driver); if (result < 0) { -- cgit v1.2.3 From 8964ebb8c35533f4084cc667079a0ce620356104 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 25 Jan 2008 15:39:50 -0500 Subject: ACPI: remove redundant Acer blacklist entry dmi_check_system() does sub-string matching using strstr(), rather than exact string compares with !strcmp(). So delete the longer of the Acer blacklist entries, as its function is just a redundant console message. Spotted-by: Carlos Corbacho Signed-off-by: Len Brown --- drivers/acpi/blacklist.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 8809654d6cc..9ace2194f2e 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -214,13 +214,11 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * _OSI(Linux) effect unknown: * DMI_MATCH(DMI_PRODUCT_NAME, "Ferrari 5000"), */ - { - .callback = dmi_disable_osi_linux, - .ident = "Acer, inc.", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Acer, inc."), - }, - }, + /* + * note that dmi_check_system() uses strstr() + * to match sub-strings rather than !strcmp(), + * so "Acer" below matches "Acer, inc." above. + */ /* * Disable OSI(Linux) warnings on all "Acer" * -- cgit v1.2.3 From e6298c6d60838495978cdbe5555dc290785bb961 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Fri, 25 Jan 2008 15:40:02 -0500 Subject: DMI: remove duplicate helper routine Use existing dmi_get_system_info(), Delete duplicate dmi_get_slot() Spotted-by: Wim Van Sebroeck Signed-off-by: Len Brown --- drivers/acpi/osl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e53fb516f9d..347cda21c0e 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1220,17 +1220,17 @@ int acpi_dmi_dump(void) return -1; printk(KERN_NOTICE PREFIX "DMI System Vendor: %s\n", - dmi_get_slot(DMI_SYS_VENDOR)); + dmi_get_system_info(DMI_SYS_VENDOR)); printk(KERN_NOTICE PREFIX "DMI Product Name: %s\n", - dmi_get_slot(DMI_PRODUCT_NAME)); + dmi_get_system_info(DMI_PRODUCT_NAME)); printk(KERN_NOTICE PREFIX "DMI Product Version: %s\n", - dmi_get_slot(DMI_PRODUCT_VERSION)); + dmi_get_system_info(DMI_PRODUCT_VERSION)); printk(KERN_NOTICE PREFIX "DMI Board Name: %s\n", - dmi_get_slot(DMI_BOARD_NAME)); + dmi_get_system_info(DMI_BOARD_NAME)); printk(KERN_NOTICE PREFIX "DMI BIOS Vendor: %s\n", - dmi_get_slot(DMI_BIOS_VENDOR)); + dmi_get_system_info(DMI_BIOS_VENDOR)); printk(KERN_NOTICE PREFIX "DMI BIOS Date: %s\n", - dmi_get_slot(DMI_BIOS_DATE)); + dmi_get_system_info(DMI_BIOS_DATE)); return 0; } -- cgit v1.2.3 From d0280a02f7412f3fdd45fbd2f51f59d7d8a03fe8 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Sun, 3 Feb 2008 17:32:31 -0500 Subject: ACPI: update blacklist comments ...based on additional feedback -- no code change. Signed-off-by: Len Brown --- drivers/acpi/blacklist.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 9ace2194f2e..bd12c8e02c5 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -208,7 +208,9 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * Disable OSI(Linux) warnings on all "Acer, inc." * * _OSI(Linux) disables the latest Windows BIOS code: + * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3100"), * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5050"), + * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"), * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5580"), * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 3010"), * _OSI(Linux) effect unknown: @@ -223,7 +225,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * Disable OSI(Linux) warnings on all "Acer" * * _OSI(Linux) effect unknown: - * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"), + * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"), * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720Z"), * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), @@ -298,7 +300,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), }, }, - { /* OSI(Linux) touches USB, breaks suspend to disk */ + { /* OSI(Linux) touches USB, unknown side-effect */ .callback = dmi_disable_osi_linux, .ident = "Dell Dimension 5150", .matches = { @@ -472,6 +474,11 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * * _OSI(Linux) confirmed to be a NOP: * DMI_MATCH(DMI_PRODUCT_NAME, "P1-J150B"), + * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"), + * + * unknown: + * DMI_MATCH(DMI_PRODUCT_NAME, "S1-MDGDG"), + * with DMI_MATCH(DMI_BOARD_NAME, "ROCKY"), */ { .callback = dmi_disable_osi_linux, -- cgit v1.2.3 From 12d3931c1007a7ad47364a4884e5a6c6e25aa5e1 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 29 Jan 2008 00:10:12 +0200 Subject: ACPI: make acpi_dmi_dump() static Signed-off-by: Adrian Bunk Signed-off-by: Len Brown --- drivers/acpi/osl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 347cda21c0e..71b0c32979f 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1213,7 +1213,7 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) * * Returns 0 on success */ -int acpi_dmi_dump(void) +static int acpi_dmi_dump(void) { if (!dmi_available) -- cgit v1.2.3 From 1d15d84e8b443971cafd885d18f091814ba32cb7 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 29 Jan 2008 00:10:15 +0200 Subject: ACPI: make struct osi_linux static Signed-off-by: Adrian Bunk Signed-off-by: Len Brown --- drivers/acpi/osl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 71b0c32979f..fde7ac82d61 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -120,7 +120,7 @@ static char osi_additional_string[OSI_STRING_LENGTH_MAX]; */ #define OSI_LINUX_ENABLE 0 -struct osi_linux { +static struct osi_linux { unsigned int enable:1; unsigned int dmi:1; unsigned int cmdline:1; -- cgit v1.2.3 From a64217b922e5a06f328e3962ff903ce829aff3d6 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 4 Feb 2008 00:57:33 -0500 Subject: ACPI: blacklist update move some OSI(Linux) to "disable" from "unknown" to reduce dmesg lines that we don't really need. update Acer 5315 comment update Dell entries, add R200 entry update Apple entries Signed-off-by: Len Brown --- drivers/acpi/blacklist.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index bd12c8e02c5..6dbaa2d15fe 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c @@ -70,8 +70,6 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata = { /* IBM 600E - _ADR should return 7, but it returns 1 */ {"IBM ", "TP600E ", 0x00000105, ACPI_SIG_DSDT, less_than_or_equal, "Incorrect _ADR", 1}, - {"ASUS\0\0", "P2B-S ", 0, ACPI_SIG_DSDT, all_versions, - "Bogus PCI routing", 1}, {""} }; @@ -225,16 +223,18 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * Disable OSI(Linux) warnings on all "Acer" * * _OSI(Linux) effect unknown: - * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"), * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720Z"), * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"), * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"), * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"), + * + * _OSI(Linux) is a NOP: + * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), */ { - .callback = dmi_unknown_osi_linux, + .callback = dmi_disable_osi_linux, .ident = "Acer", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Acer"), @@ -242,21 +242,22 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, /* * Disable OSI(Linux) warnings on all "Apple Computer, Inc." + * Disable OSI(Linux) warnings on all "Apple Inc." * * _OSI(Linux) confirmed to be a NOP: * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook1,1"), * DMI_MATCH(DMI_PRODUCT_NAME, "MacBook2,1"), * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2"), + * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"), * _OSI(Linux) effect unknown: * DMI_MATCH(DMI_PRODUCT_NAME, "MacPro2,1"), * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro1,1"), - * DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"), */ { .callback = dmi_disable_osi_linux, .ident = "Apple", .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."), + DMI_MATCH(DMI_SYS_VENDOR, "Apple"), }, }, /* @@ -294,7 +295,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * DMI_MATCH(DMI_BOARD_NAME, "IFL91"), */ { - .callback = dmi_unknown_osi_linux, + .callback = dmi_disable_osi_linux, .ident = "Compal", .matches = { DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), @@ -310,7 +311,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, { /* OSI(Linux) is a NOP */ .callback = dmi_disable_osi_linux, - .ident = "Dell", + .ident = "Dell i1501", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1501"), @@ -318,7 +319,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, { /* OSI(Linux) effect unknown */ .callback = dmi_unknown_osi_linux, - .ident = "Dell", + .ident = "Dell Latitude D830", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D830"), @@ -326,7 +327,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, { /* OSI(Linux) effect unknown */ .callback = dmi_unknown_osi_linux, - .ident = "Dell", + .ident = "Dell OP GX620", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"), @@ -334,15 +335,23 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, { /* OSI(Linux) effect unknown */ .callback = dmi_unknown_osi_linux, - .ident = "Dell", + .ident = "Dell PE 1900", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1900"), }, }, + { /* OSI(Linux) is a NOP */ + .callback = dmi_disable_osi_linux, + .ident = "Dell PE R200", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R200"), + }, + }, { /* OSI(Linux) touches USB */ .callback = dmi_disable_osi_linux, - .ident = "Dell", + .ident = "Dell PR 390", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"), @@ -358,7 +367,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { }, { /* OSI(Linux) effect unknown */ .callback = dmi_unknown_osi_linux, - .ident = "Dell", + .ident = "Dell PE SC440", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge SC440"), @@ -521,7 +530,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = { * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"), */ { - .callback = dmi_unknown_osi_linux, + .callback = dmi_disable_osi_linux, .ident = "Sony", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), -- cgit v1.2.3 From bff431e49ff531a343fbb2b4426e313000844f32 Mon Sep 17 00:00:00 2001 From: Carlos Corbacho Date: Tue, 5 Feb 2008 02:17:04 +0000 Subject: ACPI: WMI: Add ACPI-WMI mapping driver The following is an implementation of the Windows Management Instrumentation (WMI) ACPI interface mapper (PNP0C14). What it does: Parses the _WDG method and exports functions to process WMI method calls, data block query/ set commands (both based on GUID) and does basic event handling. How: WMI presents an in kernel interface here (essentially, a minimal wrapper around ACPI) (const char *guid assume the 36 character ASCII representation of a GUID - e.g. 67C3371D-95A3-4C37-BB61-DD47B491DAAB) wmi_evaluate_method(const char *guid, u8 instance, u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) wmi_query_block(const char *guid, u8 instance, struct acpi_buffer *out) wmi_set_block(const char *guid, u38 instance, const struct acpi_buffer *in) wmi_install_notify_handler(acpi_notify_handler handler); wmi_remove_notify_handler(void); wmi_get_event_data(u32 event, struct acpi_buffer *out) wmi_has_guid(const char guid*) wmi_has_guid() is a helper function to find if a GUID exists or not on the system (a quick and easy way for WMI dependant drivers to see if the the method/ block they want exists, since GUIDs are supposed to be unique). Event handling - allow a WMI based driver to register a notifier handler for each GUID with WMI. When a notification is sent to a GUID in WMI, the handler registered with WMI is then called (it is left to the caller to ask for the WMI event data associated with the GUID, if needed). What it won't do: Unicode - The MS article[1] calls for converting between ASCII and Unicode (or vice versa) if a GUID is marked as "string". This is left up to the calling driver. Handle a MOF[1] - the WMI mapper just exports methods, data and events to userspace. MOF handling is down to userspace. Userspace interface - this will be added later. [1] http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx === ChangeLog == v1 (2007-10-02): * Initial release v2 (2007-10-05): * Cleaned up code - split up super "wmi_evaluate_block" -> each external symbol now handles its own ACPI calls, rather than handing off to a "super" method (and in turn, is a lot simpler to read) * Added a find_guid() symbol - return true if a given GUID exists on the system * wmi_* functions now return type acpi_status (since they are just fancy wrappers around acpi_evaluate_object()) * Removed extra debug code v3 (2007-10-27) * More code clean up - now passes checkpatch.pl * Change data block calls - ref MS spec, method ID is not required for them, so drop it from the function parameters. * Const'ify guid in the function call parameters. * Fix _WDG buffer handling - copy the data to our own private structure. * Change WMI from tristate to bool - otherwise the external functions are not exported in linux/acpi.h if you try to build WMI as a module. * Fix more flag comparisons. * Add a maintainers entry - since I wrote this, I should take the blame for it. v4 (2007-10-30) * Add missing brace from after fixing checkpatch errors. * Rewrote event handling - allow external drivers to register with WMI to handle WMI events * Clean up flags and sanitise flag handling v5 (2007-11-03) * Add sysfs interface for userspace. Export events over netlink again. * Remove module left overs, fully convert to built-in driver. * Tweak in-kernel API to use u8 for instance, since this is what the GUID blocks use (so instance cannot be greater than u8). * Export wmi_get_event_data() for in kernel WMI drivers. v6 (2007-11-07) * Split out userspace into a different patch v7 (2007-11-20) * Fix driver to handle multiple PNP0C14 devices - store all GUIDs using the kernel's built in list functions, and just keep adding to the list every time we handle a PNP0C14 devices - GUIDs will always be unique, and WMI callers do not know or care about different devices. * Change WMI event handler registration to use its' own event handling struct; we should not pass an acpi_handle down to any WMI based drivers - they should be able to function with only the calls provided in WMI. * Update my e-mail address v8 (2007-11-28) * Convert back to a module. * Update Kconfig to default to building as a module. * Remove an erroneous printk. * Simply comments for string flag (since we now leave the handling to the caller). v9 (2007-12-07) * Add back missing MODULE_DEVICE_TABLE for autoloading * Checkpatch fixes v10 (2007-12-12) * Workaround broken GUIDs declared expensive without a WCxx method. * Minor cleanups v11 (2007-12-17) * More fixing for broken GUIDs declared expensive without a WCxx method. * Add basic EmbeddedControl region handling. v12 (2007-12-18) * Changed EC region handling code, as per Alexey's comments. v13 (2007-12-27) * Changed event handling so that we can have one event handler registered per GUID, as per Matthew Garrett's suggestion. v14 (2008-01-12) * Remove ACPI debug statements v15 (2008-02-01) * Replace two remaining 'x == NULL' type tests with '!x' v16 (2008-02-05) * Change MAINTAINERS entry, as I am not, and never have been, paid to work on WMI * Remove 'default' line from Kconfig Signed-off-by: Carlos Corbacho CC: Matthew Garrett CC: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 10 + drivers/acpi/Makefile | 1 + drivers/acpi/wmi.c | 710 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 721 insertions(+) create mode 100644 drivers/acpi/wmi.c (limited to 'drivers/acpi') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccf6ea95f68..f60cf6fea2b 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -199,6 +199,16 @@ config ACPI_NUMA depends on (X86 || IA64) default y if IA64_GENERIC || IA64_SGI_SN2 +config ACPI_WMI + tristate "WMI (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + This driver adds support for the ACPI-WMI mapper device (PNP0C14) + found on some systems. + + NOTE: You will need another driver or userspace application on top of + this to actually use anything defined in the ACPI-WMI mapper. + config ACPI_ASUS tristate "ASUS/Medion Laptop Extras" depends on X86 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 456446f9007..f29812a8653 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -55,6 +55,7 @@ obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o obj-$(CONFIG_ACPI_DEBUG) += debug.o obj-$(CONFIG_ACPI_NUMA) += numa.o +obj-$(CONFIG_ACPI_WMI) += wmi.o obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c new file mode 100644 index 00000000000..36b84ab418d --- /dev/null +++ b/drivers/acpi/wmi.c @@ -0,0 +1,710 @@ +/* + * ACPI-WMI mapping driver + * + * Copyright (C) 2007-2008 Carlos Corbacho + * + * GUID parsing code from ldm.c is: + * Copyright (C) 2001,2002 Richard Russon + * Copyright (c) 2001-2007 Anton Altaparmakov + * Copyright (C) 2001,2002 Jakob Kemi + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include +#include +#include +#include +#include +#include +#include + +ACPI_MODULE_NAME("wmi"); +MODULE_AUTHOR("Carlos Corbacho"); +MODULE_DESCRIPTION("ACPI-WMI Mapping Driver"); +MODULE_LICENSE("GPL"); + +#define ACPI_WMI_CLASS "wmi" + +#undef PREFIX +#define PREFIX "ACPI: WMI: " + +static DEFINE_MUTEX(wmi_data_lock); + +struct guid_block { + char guid[16]; + union { + char object_id[2]; + struct { + unsigned char notify_id; + unsigned char reserved; + }; + }; + u8 instance_count; + u8 flags; +}; + +struct wmi_block { + struct list_head list; + struct guid_block gblock; + acpi_handle handle; + wmi_notify_handler handler; + void *handler_data; +}; + +static struct wmi_block wmi_blocks; + +/* + * If the GUID data block is marked as expensive, we must enable and + * explicitily disable data collection. + */ +#define ACPI_WMI_EXPENSIVE 0x1 +#define ACPI_WMI_METHOD 0x2 /* GUID is a method */ +#define ACPI_WMI_STRING 0x4 /* GUID takes & returns a string */ +#define ACPI_WMI_EVENT 0x8 /* GUID is an event */ + +static int acpi_wmi_remove(struct acpi_device *device, int type); +static int acpi_wmi_add(struct acpi_device *device); + +static const struct acpi_device_id wmi_device_ids[] = { + {"PNP0C14", 0}, + {"pnp0c14", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, wmi_device_ids); + +static struct acpi_driver acpi_wmi_driver = { + .name = "wmi", + .class = ACPI_WMI_CLASS, + .ids = wmi_device_ids, + .ops = { + .add = acpi_wmi_add, + .remove = acpi_wmi_remove, + }, +}; + +/* + * GUID parsing functions + */ + +/** + * wmi_parse_hexbyte - Convert a ASCII hex number to a byte + * @src: Pointer to at least 2 characters to convert. + * + * Convert a two character ASCII hex string to a number. + * + * Return: 0-255 Success, the byte was parsed correctly + * -1 Error, an invalid character was supplied + */ +static int wmi_parse_hexbyte(const u8 *src) +{ + unsigned int x; /* For correct wrapping */ + int h; + + /* high part */ + x = src[0]; + if (x - '0' <= '9' - '0') { + h = x - '0'; + } else if (x - 'a' <= 'f' - 'a') { + h = x - 'a' + 10; + } else if (x - 'A' <= 'F' - 'A') { + h = x - 'A' + 10; + } else { + return -1; + } + h <<= 4; + + /* low part */ + x = src[1]; + if (x - '0' <= '9' - '0') + return h | (x - '0'); + if (x - 'a' <= 'f' - 'a') + return h | (x - 'a' + 10); + if (x - 'A' <= 'F' - 'A') + return h | (x - 'A' + 10); + return -1; +} + +/** + * wmi_swap_bytes - Rearrange GUID bytes to match GUID binary + * @src: Memory block holding binary GUID (16 bytes) + * @dest: Memory block to hold byte swapped binary GUID (16 bytes) + * + * Byte swap a binary GUID to match it's real GUID value + */ +static void wmi_swap_bytes(u8 *src, u8 *dest) +{ + int i; + + for (i = 0; i <= 3; i++) + memcpy(dest + i, src + (3 - i), 1); + + for (i = 0; i <= 1; i++) + memcpy(dest + 4 + i, src + (5 - i), 1); + + for (i = 0; i <= 1; i++) + memcpy(dest + 6 + i, src + (7 - i), 1); + + memcpy(dest + 8, src + 8, 8); +} + +/** + * wmi_parse_guid - Convert GUID from ASCII to binary + * @src: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba + * @dest: Memory block to hold binary GUID (16 bytes) + * + * N.B. The GUID need not be NULL terminated. + * + * Return: 'true' @dest contains binary GUID + * 'false' @dest contents are undefined + */ +static bool wmi_parse_guid(const u8 *src, u8 *dest) +{ + static const int size[] = { 4, 2, 2, 2, 6 }; + int i, j, v; + + if (src[8] != '-' || src[13] != '-' || + src[18] != '-' || src[23] != '-') + return false; + + for (j = 0; j < 5; j++, src++) { + for (i = 0; i < size[j]; i++, src += 2, *dest++ = v) { + v = wmi_parse_hexbyte(src); + if (v < 0) + return false; + } + } + + return true; +} + +static bool find_guid(const char *guid_string, struct wmi_block **out) +{ + char tmp[16], guid_input[16]; + struct wmi_block *wblock; + struct guid_block *block; + struct list_head *p; + + wmi_parse_guid(guid_string, tmp); + wmi_swap_bytes(tmp, guid_input); + + list_for_each(p, &wmi_blocks.list) { + wblock = list_entry(p, struct wmi_block, list); + block = &wblock->gblock; + + if (memcmp(block->guid, guid_input, 16) == 0) { + if (out) + *out = wblock; + return 1; + } + } + return 0; +} + +/* + * Exported WMI functions + */ +/** + * wmi_evaluate_method - Evaluate a WMI method + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba + * @instance: Instance index + * @method_id: Method ID to call + * &in: Buffer containing input for the method call + * &out: Empty buffer to return the method results + * + * Call an ACPI-WMI method + */ +acpi_status wmi_evaluate_method(const char *guid_string, u8 instance, +u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) +{ + struct guid_block *block = NULL; + struct wmi_block *wblock = NULL; + acpi_handle handle; + acpi_status status; + struct acpi_object_list input; + union acpi_object params[3]; + char method[4] = "WM"; + + if (!find_guid(guid_string, &wblock)) + return AE_BAD_ADDRESS; + + block = &wblock->gblock; + handle = wblock->handle; + + if (!block->flags & ACPI_WMI_METHOD) + return AE_BAD_DATA; + + if (block->instance_count < instance) + return AE_BAD_PARAMETER; + + input.count = 2; + input.pointer = params; + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = instance; + params[1].type = ACPI_TYPE_INTEGER; + params[1].integer.value = method_id; + + if (in) { + input.count = 3; + + if (block->flags & ACPI_WMI_STRING) { + params[2].type = ACPI_TYPE_STRING; + } else { + params[2].type = ACPI_TYPE_BUFFER; + } + params[2].buffer.length = in->length; + params[2].buffer.pointer = in->pointer; + } + + strncat(method, block->object_id, 2); + + status = acpi_evaluate_object(handle, method, &input, out); + + return status; +} +EXPORT_SYMBOL_GPL(wmi_evaluate_method); + +/** + * wmi_query_block - Return contents of a WMI block + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba + * @instance: Instance index + * &out: Empty buffer to return the contents of the data block to + * + * Return the contents of an ACPI-WMI data block to a buffer + */ +acpi_status wmi_query_block(const char *guid_string, u8 instance, +struct acpi_buffer *out) +{ + struct guid_block *block = NULL; + struct wmi_block *wblock = NULL; + acpi_handle handle; + acpi_status status, wc_status = AE_ERROR; + struct acpi_object_list input, wc_input; + union acpi_object wc_params[1], wq_params[1]; + char method[4]; + char wc_method[4] = "WC"; + + if (!guid_string || !out) + return AE_BAD_PARAMETER; + + if (!find_guid(guid_string, &wblock)) + return AE_BAD_ADDRESS; + + block = &wblock->gblock; + handle = wblock->handle; + + if (block->instance_count < instance) + return AE_BAD_PARAMETER; + + /* Check GUID is a data block */ + if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) + return AE_BAD_ADDRESS; + + input.count = 1; + input.pointer = wq_params; + wq_params[0].type = ACPI_TYPE_INTEGER; + wq_params[0].integer.value = instance; + + /* + * If ACPI_WMI_EXPENSIVE, call the relevant WCxx method first to + * enable collection. + */ + if (block->flags & ACPI_WMI_EXPENSIVE) { + wc_input.count = 1; + wc_input.pointer = wc_params; + wc_params[0].type = ACPI_TYPE_INTEGER; + wc_params[0].integer.value = 1; + + strncat(wc_method, block->object_id, 2); + + /* + * Some GUIDs break the specification by declaring themselves + * expensive, but have no corresponding WCxx method. So we + * should not fail if this happens. + */ + wc_status = acpi_evaluate_object(handle, wc_method, + &wc_input, NULL); + } + + strcpy(method, "WQ"); + strncat(method, block->object_id, 2); + + status = acpi_evaluate_object(handle, method, NULL, out); + + /* + * If ACPI_WMI_EXPENSIVE, call the relevant WCxx method, even if + * the WQxx method failed - we should disable collection anyway. + */ + if ((block->flags & ACPI_WMI_EXPENSIVE) && wc_status) { + wc_params[0].integer.value = 0; + status = acpi_evaluate_object(handle, + wc_method, &wc_input, NULL); + } + + return status; +} +EXPORT_SYMBOL_GPL(wmi_query_block); + +/** + * wmi_set_block - Write to a WMI block + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba + * @instance: Instance index + * &in: Buffer containing new values for the data block + * + * Write the contents of the input buffer to an ACPI-WMI data block + */ +acpi_status wmi_set_block(const char *guid_string, u8 instance, +const struct acpi_buffer *in) +{ + struct guid_block *block = NULL; + struct wmi_block *wblock = NULL; + acpi_handle handle; + struct acpi_object_list input; + union acpi_object params[2]; + char method[4] = "WS"; + + if (!guid_string || !in) + return AE_BAD_DATA; + + if (!find_guid(guid_string, &wblock)) + return AE_BAD_ADDRESS; + + block = &wblock->gblock; + handle = wblock->handle; + + if (block->instance_count < instance) + return AE_BAD_PARAMETER; + + /* Check GUID is a data block */ + if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) + return AE_BAD_ADDRESS; + + input.count = 2; + input.pointer = params; + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = instance; + + if (block->flags & ACPI_WMI_STRING) { + params[1].type = ACPI_TYPE_STRING; + } else { + params[1].type = ACPI_TYPE_BUFFER; + } + params[1].buffer.length = in->length; + params[1].buffer.pointer = in->pointer; + + strncat(method, block->object_id, 2); + + return acpi_evaluate_object(handle, method, &input, NULL); +} +EXPORT_SYMBOL_GPL(wmi_set_block); + +/** + * wmi_install_notify_handler - Register handler for WMI events + * @handler: Function to handle notifications + * @data: Data to be returned to handler when event is fired + * + * Register a handler for events sent to the ACPI-WMI mapper device. + */ +acpi_status wmi_install_notify_handler(const char *guid, +wmi_notify_handler handler, void *data) +{ + struct wmi_block *block; + + if (!guid || !handler) + return AE_BAD_PARAMETER; + + find_guid(guid, &block); + if (!block) + return AE_NOT_EXIST; + + if (block->handler) + return AE_ALREADY_ACQUIRED; + + block->handler = handler; + block->handler_data = data; + + return AE_OK; +} +EXPORT_SYMBOL_GPL(wmi_install_notify_handler); + +/** + * wmi_uninstall_notify_handler - Unregister handler for WMI events + * + * Unregister handler for events sent to the ACPI-WMI mapper device. + */ +acpi_status wmi_remove_notify_handler(const char *guid) +{ + struct wmi_block *block; + + if (!guid) + return AE_BAD_PARAMETER; + + find_guid(guid, &block); + if (!block) + return AE_NOT_EXIST; + + if (!block->handler) + return AE_NULL_ENTRY; + + block->handler = NULL; + block->handler_data = NULL; + + return AE_OK; +} +EXPORT_SYMBOL_GPL(wmi_remove_notify_handler); + +/** + * wmi_get_event_data - Get WMI data associated with an event + * + * @event - Event to find + * &out - Buffer to hold event data + * + * Returns extra data associated with an event in WMI. + */ +acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) +{ + struct acpi_object_list input; + union acpi_object params[1]; + struct guid_block *gblock; + struct wmi_block *wblock; + struct list_head *p; + + input.count = 1; + input.pointer = params; + params[0].type = ACPI_TYPE_INTEGER; + params[0].integer.value = event; + + list_for_each(p, &wmi_blocks.list) { + wblock = list_entry(p, struct wmi_block, list); + gblock = &wblock->gblock; + + if ((gblock->flags & ACPI_WMI_EVENT) && + (gblock->notify_id == event)) + return acpi_evaluate_object(wblock->handle, "_WED", + &input, out); + } + + return AE_NOT_FOUND; +} +EXPORT_SYMBOL_GPL(wmi_get_event_data); + +/** + * wmi_has_guid - Check if a GUID is available + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba + * + * Check if a given GUID is defined by _WDG + */ +bool wmi_has_guid(const char *guid_string) +{ + return find_guid(guid_string, NULL); +} +EXPORT_SYMBOL_GPL(wmi_has_guid); + +/* + * Parse the _WDG method for the GUID data blocks + */ +static __init acpi_status parse_wdg(acpi_handle handle) +{ + struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; + union acpi_object *obj; + struct guid_block *gblock; + struct wmi_block *wblock; + acpi_status status; + u32 i, total; + + status = acpi_evaluate_object(handle, "_WDG", NULL, &out); + + if (ACPI_FAILURE(status)) + return status; + + obj = (union acpi_object *) out.pointer; + + if (obj->type != ACPI_TYPE_BUFFER) + return AE_ERROR; + + total = obj->buffer.length / sizeof(struct guid_block); + + gblock = kzalloc(obj->buffer.length, GFP_KERNEL); + if (!gblock) + return AE_NO_MEMORY; + + memcpy(gblock, obj->buffer.pointer, obj->buffer.length); + + for (i = 0; i < total; i++) { + wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); + if (!wblock) + return AE_NO_MEMORY; + + wblock->gblock = gblock[i]; + wblock->handle = handle; + list_add_tail(&wblock->list, &wmi_blocks.list); + } + + kfree(out.pointer); + kfree(gblock); + + return status; +} + +/* + * WMI can have EmbeddedControl access regions. In which case, we just want to + * hand these off to the EC driver. + */ +static acpi_status +acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, + u32 bits, acpi_integer * value, + void *handler_context, void *region_context) +{ + int result = 0, i = 0; + u8 temp = 0; + + if ((address > 0xFF) || !value) + return AE_BAD_PARAMETER; + + if (function != ACPI_READ && function != ACPI_WRITE) + return AE_BAD_PARAMETER; + + if (bits != 8) + return AE_BAD_PARAMETER; + + if (function == ACPI_READ) { + result = ec_read(address, &temp); + (*value) |= ((acpi_integer)temp) << i; + } else { + temp = 0xff & ((*value) >> i); + result = ec_write(address, temp); + } + + switch (result) { + case -EINVAL: + return AE_BAD_PARAMETER; + break; + case -ENODEV: + return AE_NOT_FOUND; + break; + case -ETIME: + return AE_TIME; + break; + default: + return AE_OK; + } +} + +static void acpi_wmi_notify(acpi_handle handle, u32 event, void *data) +{ + struct guid_block *block; + struct wmi_block *wblock; + struct list_head *p; + struct acpi_device *device = data; + + list_for_each(p, &wmi_blocks.list) { + wblock = list_entry(p, struct wmi_block, list); + block = &wblock->gblock; + + if ((block->flags & ACPI_WMI_EVENT) && + (block->notify_id == event)) { + if (wblock->handler) + wblock->handler(event, wblock->handler_data); + + acpi_bus_generate_netlink_event( + device->pnp.device_class, device->dev.bus_id, + event, 0); + break; + } + } +} + +static int acpi_wmi_remove(struct acpi_device *device, int type) +{ + acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_wmi_notify); + + acpi_remove_address_space_handler(device->handle, + ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler); + + return 0; +} + +static int __init acpi_wmi_add(struct acpi_device *device) +{ + acpi_status status; + int result = 0; + + status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_wmi_notify, device); + if (ACPI_FAILURE(status)) { + printk(KERN_ERR PREFIX "Error installing notify handler\n"); + return -ENODEV; + } + + status = acpi_install_address_space_handler(device->handle, + ACPI_ADR_SPACE_EC, + &acpi_wmi_ec_space_handler, + NULL, NULL); + if (ACPI_FAILURE(status)) + return -ENODEV; + + status = parse_wdg(device->handle); + if (ACPI_FAILURE(status)) { + printk(KERN_ERR PREFIX "Error installing EC region handler\n"); + return -ENODEV; + } + + return result; +} + +static int __init acpi_wmi_init(void) +{ + acpi_status result; + + if (acpi_disabled) + return -ENODEV; + + INIT_LIST_HEAD(&wmi_blocks.list); + + result = acpi_bus_register_driver(&acpi_wmi_driver); + + if (result < 0) { + printk(KERN_INFO PREFIX "Error loading mapper\n"); + } else { + printk(KERN_INFO PREFIX "Mapper loaded\n"); + } + + return result; +} + +static void __exit acpi_wmi_exit(void) +{ + struct list_head *p, *tmp; + struct wmi_block *wblock; + + acpi_bus_unregister_driver(&acpi_wmi_driver); + + list_for_each_safe(p, tmp, &wmi_blocks.list) { + wblock = list_entry(p, struct wmi_block, list); + + list_del(p); + kfree(wblock); + } + + printk(KERN_INFO PREFIX "Mapper unloaded\n"); +} + +subsys_initcall(acpi_wmi_init); +module_exit(acpi_wmi_exit); -- cgit v1.2.3 From 7c2670bbb53820d0a4fab8d74593eeccd1eef225 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Tue, 22 Jan 2008 18:46:50 +0100 Subject: ACPI: battery: add sysfs serial number egrep serial /proc/acpi/battery/BAT0/info serial number: 32090 serial number can tell you from the imminent danger of beeing set on fire. Signed-off-by: maximilian attems Acked-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/battery.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index c4a769d1ba8..f6215e80980 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -194,6 +194,9 @@ static int acpi_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_MANUFACTURER: val->strval = battery->oem_info; break; + case POWER_SUPPLY_PROP_SERIAL_NUMBER: + val->strval = battery->serial_number; + break; default: return -EINVAL; } @@ -212,6 +215,7 @@ static enum power_supply_property charge_battery_props[] = { POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, + POWER_SUPPLY_PROP_SERIAL_NUMBER, }; static enum power_supply_property energy_battery_props[] = { @@ -226,6 +230,7 @@ static enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_ENERGY_NOW, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, + POWER_SUPPLY_PROP_SERIAL_NUMBER, }; #endif -- cgit v1.2.3 From 71fc47a9adf8ee89e5c96a47222915c5485ac437 Mon Sep 17 00:00:00 2001 From: Markus Gaugusch Date: Tue, 5 Feb 2008 00:04:06 +0100 Subject: ACPI: basic initramfs DSDT override support The basics of DSDT from initramfs. In case this option is selected, populate_rootfs() is called a bit earlier to have the initramfs content available during ACPI initialization. This is a very similar path to the one available at http://gaugusch.at/kernel.shtml but with some update in the documentation, default set to No and the change of populate_rootfs() the "Jeff Mahony way" (which avoids reading the initramfs twice). Signed-off-by: Thomas Renninger Signed-off-by: Eric Piel Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 17 ++++++++++++ drivers/acpi/osl.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 4 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccf6ea95f68..0442ae153a2 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -274,6 +274,23 @@ config ACPI_CUSTOM_DSDT_FILE Enter the full path name to the file which includes the AmlCode declaration. +config ACPI_CUSTOM_DSDT_INITRD + bool "Read Custom DSDT from initramfs" + depends on BLK_DEV_INITRD + default n + help + The DSDT (Differentiated System Description Table) often needs to be + overridden because of broken BIOS implementations. If this feature is + activated you will be able to provide a customized DSDT by adding it + to your initramfs. If your mkinitrd tool does not support this feature + a script is provided in the documentation. For more details see + or . + If there is no table found, it will fall-back to the custom DSDT + in-kernel (if activated) or to the DSDT from the BIOS. + + Even if you do not need a new one at the moment, you may want to use a + better DSDT later. It is safe to say Y here. + config ACPI_BLACKLIST_YEAR int "Disable ACPI for systems before Jan 1st this year" if X86_32 default 0 diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e53fb516f9d..131936e7ff1 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -312,6 +312,66 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, return AE_OK; } +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD +struct acpi_table_header *acpi_find_dsdt_initrd(void) +{ + struct file *firmware_file; + mm_segment_t oldfs; + unsigned long len, len2; + struct acpi_table_header *dsdt_buffer, *ret = NULL; + struct kstat stat; + char *ramfs_dsdt_name = "/DSDT.aml"; + + printk(KERN_INFO PREFIX "Looking for DSDT in initramfs... "); + + /* + * Never do this at home, only the user-space is allowed to open a file. + * The clean way would be to use the firmware loader. But this code must be run + * before there is any userspace available. So we need a static/init firmware + * infrastructure, which doesn't exist yet... + */ + if (vfs_stat(ramfs_dsdt_name, &stat) < 0) { + printk("not found.\n"); + return ret; + } + + len = stat.size; + /* check especially against empty files */ + if (len <= 4) { + printk("error, file is too small: only %lu bytes.\n", len); + return ret; + } + + firmware_file = filp_open(ramfs_dsdt_name, O_RDONLY, 0); + if (IS_ERR(firmware_file)) { + printk("error, could not open file %s.\n", ramfs_dsdt_name); + return ret; + } + + dsdt_buffer = ACPI_ALLOCATE(len); + if (!dsdt_buffer) { + printk("error when allocating %lu bytes of memory.\n", len); + goto err; + } + + oldfs = get_fs(); + set_fs(KERNEL_DS); + len2 = vfs_read(firmware_file, (char __user *)dsdt_buffer, len, &firmware_file->f_pos); + set_fs(oldfs); + if (len2 < len) { + printk("error trying to read %lu bytes from %s.\n", len, ramfs_dsdt_name); + ACPI_FREE(dsdt_buffer); + goto err; + } + + printk("successfully read %lu bytes from %s.\n", len, ramfs_dsdt_name); + ret = dsdt_buffer; +err: + filp_close(firmware_file, NULL); + return ret; +} +#endif + acpi_status acpi_os_table_override(struct acpi_table_header * existing_table, struct acpi_table_header ** new_table) @@ -319,13 +379,18 @@ acpi_os_table_override(struct acpi_table_header * existing_table, if (!existing_table || !new_table) return AE_BAD_PARAMETER; + *new_table = NULL; + #ifdef CONFIG_ACPI_CUSTOM_DSDT if (strncmp(existing_table->signature, "DSDT", 4) == 0) *new_table = (struct acpi_table_header *)AmlCode; - else - *new_table = NULL; -#else - *new_table = NULL; +#endif +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD + if (strncmp(existing_table->signature, "DSDT", 4) == 0) { + struct acpi_table_header *initrd_table = acpi_find_dsdt_initrd(); + if (initrd_table) + *new_table = initrd_table; + } #endif return AE_OK; } -- cgit v1.2.3 From 6ed31e92e94830c138fbd470486383380710069a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Piel?= Date: Tue, 5 Feb 2008 00:04:50 +0100 Subject: ACPI: Taint kernel on ACPI table override (format corrected) When an ACPI table is overridden (for now this can happen only for DSDT) display a big warning and taint the kernel with flag A. Signed-off-by: Eric Piel Signed-off-by: Len Brown --- drivers/acpi/osl.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 131936e7ff1..bbd8360bfb2 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -392,6 +392,13 @@ acpi_os_table_override(struct acpi_table_header * existing_table, *new_table = initrd_table; } #endif + if (*new_table != NULL) { + printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " + "this is unsafe: tainting kernel\n", + existing_table->signature, + existing_table->oem_table_id); + add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); + } return AE_OK; } -- cgit v1.2.3 From 5229e87d59cef33539322948bd8e3b5a537f7c97 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 6 Feb 2008 01:26:55 -0500 Subject: ACPI: create /sys/firmware/acpi/interrupts See Documentation/ABI/testing/sysfs-firmware-acpi Based-on-original-patch-by: Luming Yu Acked-by: Greg Kroah-Hartman Signed-off-by: Len Brown --- drivers/acpi/events/evevent.c | 2 +- drivers/acpi/events/evgpe.c | 2 +- drivers/acpi/osl.c | 12 ++- drivers/acpi/system.c | 208 ++++++++++++++++++++++++++++++++++++++ drivers/acpi/utilities/utglobal.c | 2 - 5 files changed, 221 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index e41287815ea..3048801a37b 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c @@ -259,7 +259,7 @@ u32 acpi_ev_fixed_event_detect(void) enable_bit_mask)) { /* Found an active (signalled) event */ - + acpi_os_fixed_event_count(i); int_status |= acpi_ev_fixed_event_dispatch((u32) i); } } diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index e22f4a973c0..4bd9e2291bd 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -618,7 +618,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) ACPI_FUNCTION_TRACE(ev_gpe_dispatch); - acpi_gpe_count++; + acpi_os_gpe_count(gpe_number); /* * If edge-triggered, clear the GPE status bit now. Note that diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e53fb516f9d..1087efeca9b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -332,7 +332,15 @@ acpi_os_table_override(struct acpi_table_header * existing_table, static irqreturn_t acpi_irq(int irq, void *dev_id) { - return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; + u32 handled; + + handled = (*acpi_irq_handler) (acpi_irq_context); + + if (handled) { + acpi_irq_handled++; + return IRQ_HANDLED; + } else + return IRQ_NONE; } acpi_status @@ -341,6 +349,8 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, { unsigned int irq; + acpi_irq_stats_init(); + /* * Ignore the GSI from the core, and use the value in our copy of the * FADT. It may not be the same if an interrupt source override exists diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 5ffe0ea1896..ce881713f7a 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -40,6 +40,8 @@ ACPI_MODULE_NAME("system"); #define ACPI_SYSTEM_CLASS "system" #define ACPI_SYSTEM_DEVICE_NAME "System" +u32 acpi_irq_handled; + /* * Make ACPICA version work as module param */ @@ -166,6 +168,212 @@ static int acpi_system_sysfs_init(void) return 0; } +/* + * Detailed ACPI IRQ counters in /sys/firmware/acpi/interrupts/ + * See Documentation/ABI/testing/sysfs-firmware-acpi + */ + +#define COUNT_GPE 0 +#define COUNT_SCI 1 /* acpi_irq_handled */ +#define COUNT_ERROR 2 /* other */ +#define NUM_COUNTERS_EXTRA 3 + +static u32 *all_counters; +static u32 num_gpes; +static u32 num_counters; +static struct attribute **all_attrs; +static u32 acpi_gpe_count; + +static struct attribute_group interrupt_stats_attr_group = { + .name = "interrupts", +}; +static struct kobj_attribute *counter_attrs; + +static int count_num_gpes(void) +{ + int count = 0; + struct acpi_gpe_xrupt_info *gpe_xrupt_info; + struct acpi_gpe_block_info *gpe_block; + acpi_cpu_flags flags; + + flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); + + gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; + while (gpe_xrupt_info) { + gpe_block = gpe_xrupt_info->gpe_block_list_head; + while (gpe_block) { + count += gpe_block->register_count * + ACPI_GPE_REGISTER_WIDTH; + gpe_block = gpe_block->next; + } + gpe_xrupt_info = gpe_xrupt_info->next; + } + acpi_os_release_lock(acpi_gbl_gpe_lock, flags); + + return count; +} + +static void delete_gpe_attr_array(void) +{ + u32 *tmp = all_counters; + + all_counters = NULL; + kfree(tmp); + + if (counter_attrs) { + int i; + + for (i = 0; i < num_gpes; i++) + kfree(counter_attrs[i].attr.name); + + kfree(counter_attrs); + } + kfree(all_attrs); + + return; +} + +void acpi_os_gpe_count(u32 gpe_number) +{ + acpi_gpe_count++; + + if (!all_counters) + return; + + if (gpe_number < num_gpes) + all_counters[gpe_number]++; + else + all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR]++; + + return; +} + +void acpi_os_fixed_event_count(u32 event_number) +{ + if (!all_counters) + return; + + if (event_number < ACPI_NUM_FIXED_EVENTS) + all_counters[num_gpes + event_number]++; + else + all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR]++; + + return; +} + +static ssize_t counter_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI] = + acpi_irq_handled; + all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE] = + acpi_gpe_count; + + return sprintf(buf, "%d\n", all_counters[attr - counter_attrs]); +} + +/* + * counter_set() sets the specified counter. + * setting the total "sci" file to any value clears all counters. + */ +static ssize_t counter_set(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t size) +{ + int index = attr - counter_attrs; + + if (index == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) { + int i; + for (i = 0; i < num_counters; ++i) + all_counters[i] = 0; + acpi_gpe_count = 0; + acpi_irq_handled = 0; + + } else + all_counters[index] = strtoul(buf, NULL, 0); + + return size; +} + +void acpi_irq_stats_init(void) +{ + int i; + + if (all_counters) + return; + + num_gpes = count_num_gpes(); + num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; + + all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1), + GFP_KERNEL); + if (all_attrs == NULL) + return; + + all_counters = kzalloc(sizeof(u32) * (num_counters), GFP_KERNEL); + if (all_counters == NULL) + goto fail; + + counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters), + GFP_KERNEL); + if (counter_attrs == NULL) + goto fail; + + for (i = 0; i < num_counters; ++i) { + char buffer[10]; + char *name; + + if (i < num_gpes) + sprintf(buffer, "gpe%02X", i); + else if (i == num_gpes + ACPI_EVENT_PMTIMER) + sprintf(buffer, "ff_pmtimer"); + else if (i == num_gpes + ACPI_EVENT_GLOBAL) + sprintf(buffer, "ff_gbl_lock"); + else if (i == num_gpes + ACPI_EVENT_POWER_BUTTON) + sprintf(buffer, "ff_pwr_btn"); + else if (i == num_gpes + ACPI_EVENT_SLEEP_BUTTON) + sprintf(buffer, "ff_slp_btn"); + else if (i == num_gpes + ACPI_EVENT_RTC) + sprintf(buffer, "ff_rt_clk"); + else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE) + sprintf(buffer, "gpe_all"); + else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) + sprintf(buffer, "sci"); + else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR) + sprintf(buffer, "error"); + else + sprintf(buffer, "bug%02X", i); + + name = kzalloc(strlen(buffer) + 1, GFP_KERNEL); + if (name == NULL) + goto fail; + strncpy(name, buffer, strlen(buffer) + 1); + + counter_attrs[i].attr.name = name; + counter_attrs[i].attr.mode = 0644; + counter_attrs[i].show = counter_show; + counter_attrs[i].store = counter_set; + + all_attrs[i] = &counter_attrs[i].attr; + } + + interrupt_stats_attr_group.attrs = all_attrs; + sysfs_create_group(acpi_kobj, &interrupt_stats_attr_group); + return; + +fail: + delete_gpe_attr_array(); + return; +} + +static void __exit interrupt_stats_exit(void) +{ + sysfs_remove_group(acpi_kobj, &interrupt_stats_attr_group); + + delete_gpe_attr_array(); + + return; +} + /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 93ea8290b4f..630c9a2c5b7 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -671,7 +671,6 @@ void acpi_ut_init_globals(void) /* GPE support */ - acpi_gpe_count = 0; acpi_gbl_gpe_xrupt_list_head = NULL; acpi_gbl_gpe_fadt_blocks[0] = NULL; acpi_gbl_gpe_fadt_blocks[1] = NULL; @@ -735,4 +734,3 @@ void acpi_ut_init_globals(void) ACPI_EXPORT_SYMBOL(acpi_dbg_level) ACPI_EXPORT_SYMBOL(acpi_dbg_layer) - ACPI_EXPORT_SYMBOL(acpi_gpe_count) -- cgit v1.2.3 From 31e0729a85c1e8ffaf4d14b4c201c28b5d1c9585 Mon Sep 17 00:00:00 2001 From: Luca Tettamanti Date: Mon, 4 Feb 2008 23:31:18 -0800 Subject: asus_acpi: add support for F3Sa Add support for ASUS F3Sa notebook. Features: - LCD on/off - Brightness - Wifi kill - Bluetooth kill Signed-off-by: Luca Tettamanti Cc: Corentin Chary Cc: Karol Kozimor Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/asus_acpi.c | 55 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 10 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index d915fec9bf6..d25ef961415 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -142,6 +142,7 @@ struct asus_hotk { xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N A4S, //Z81sp //(Centrino) + F3Sa, END_MODEL } model; //Models currently supported u16 event_count[128]; //count for each event TODO make this better @@ -405,7 +406,20 @@ static struct model_data model_conf[END_MODEL] = { .brightness_get = "GPLV", .mt_bt_switch = "BLED", .mt_wled = "WLED" - } + }, + + { + .name = "F3Sa", + .mt_bt_switch = "BLED", + .mt_wled = "WLED", + .mt_mled = "MLED", + .brightness_get = "GPLV", + .brightness_set = "SPLV", + .mt_lcd_switch = "\\_SB.PCI0.SBRG.EC0._Q10", + .lcd_status = "\\_SB.PCI0.SBRG.EC0.RPIN", + .display_get = "\\ADVG", + .display_set = "SDSP", + }, }; @@ -710,15 +724,8 @@ static int get_lcd_state(void) { int lcd = 0; - if (hotk->model != L3H) { - /* We don't have to check anything if we are here */ - if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd)) - printk(KERN_WARNING - "Asus ACPI: Error reading LCD status\n"); - - if (hotk->model == L2D) - lcd = ~lcd; - } else { /* L3H and the like have to be handled differently */ + if (hotk->model == L3H) { + /* L3H and the like have to be handled differently */ acpi_status status = 0; struct acpi_object_list input; union acpi_object mt_params[2]; @@ -745,6 +752,32 @@ static int get_lcd_state(void) if (out_obj.type == ACPI_TYPE_INTEGER) /* That's what the AML code does */ lcd = out_obj.integer.value >> 8; + } else if (hotk->model == F3Sa) { + unsigned long tmp; + union acpi_object param; + struct acpi_object_list input; + acpi_status status; + + /* Read pin 11 */ + param.type = ACPI_TYPE_INTEGER; + param.integer.value = 0x11; + input.count = 1; + input.pointer = ¶m; + + status = acpi_evaluate_integer(NULL, hotk->methods->lcd_status, + &input, &tmp); + if (status != AE_OK) + return -1; + + lcd = tmp; + } else { + /* We don't have to check anything if we are here */ + if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd)) + printk(KERN_WARNING + "Asus ACPI: Error reading LCD status\n"); + + if (hotk->model == L2D) + lcd = ~lcd; } return (lcd & 1); @@ -1134,6 +1167,8 @@ static int asus_model_match(char *model) return W5A; else if (strncmp(model, "A4S", 3) == 0) return A4S; + else if (strncmp(model, "F3Sa", 4) == 0) + return F3Sa; else return END_MODEL; } -- cgit v1.2.3 From e76d5f7e831a3f33dd6fa8eb94533b0b4cb22b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Bot=C3=B3n?= Date: Mon, 4 Feb 2008 23:31:19 -0800 Subject: ACPI: remove duplicated warning message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove duplicated warning message in acpi_power_transition() ACPI: Transitioning device [%s] to D%d\n This warning message is printed by acpi_bus_set_power() so we don't need to print it again. Signed-off-by: Miguel Botón Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/power.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index af1769a20c7..76bf6d90c70 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -458,11 +458,9 @@ int acpi_power_transition(struct acpi_device *device, int state) } end: - if (result) { + if (result) device->power.state = ACPI_STATE_UNKNOWN; - printk(KERN_WARNING PREFIX "Transitioning device [%s] to D%d\n", - device->pnp.bus_id, state); - } else { + else { /* We shouldn't change the state till all above operations succeed */ device->power.state = state; } -- cgit v1.2.3 From 1a3b77ae60f19fa85f4cdc34b6c09efb1a18372c Mon Sep 17 00:00:00 2001 From: Matthias Kaehlcke Date: Mon, 4 Feb 2008 23:31:20 -0800 Subject: ACPI: acpi_pci_irq_find_prt_entry(): use list_for_each_entry() instead of list_for_each() Signed-off-by: Matthias Kaehlcke Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/pci_irq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 62010c2481b..76d9c669d2d 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -51,10 +51,8 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, int bus, int device, int pin) { - struct list_head *node = NULL; struct acpi_prt_entry *entry = NULL; - if (!acpi_prt.count) return NULL; @@ -64,8 +62,7 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, * */ spin_lock(&acpi_prt_lock); - list_for_each(node, &acpi_prt.entries) { - entry = list_entry(node, struct acpi_prt_entry, node); + list_for_each_entry(entry, &acpi_prt.entries, node) { if ((segment == entry->id.segment) && (bus == entry->id.bus) && (device == entry->id.device) -- cgit v1.2.3 From df92e695998e1bc6e426a840eb86d6d1ee87e2a5 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Mon, 4 Feb 2008 23:31:22 -0800 Subject: ACPI: track opregion names to avoid driver resource conflicts. Small ACPICA extension to be able to store the name of operation regions in osl.c later In ACPI, AML can define accesses to IO ports and System Memory by Operation Regions. Those are not registered as done by PNPACPI using resource templates (and _CRS/_SRS methods). The IO ports and System Memory regions may get accessed by arbitrary AML code. When native drivers are accessing the same resources bad things can happen (e.g. a critical shutdown temperature of 3000 C every 2 months or so). It is not really possible to register the operation regions via request_resource, as they often overlap with pnp or other resources (e.g. statically setup IO resources below 0x100). This approach stores all Operation Region declarations (IO and System Memory only) at ACPI table parse time. It offers a similar functionality like request_region and let drivers which are known to possibly use the same IO ports and Memory which are also often used by ACPI (hwmon and i2c) check for ACPI interference. A boot parameter acpi_enforce_resources=strict/lax/no is provided, which is default set to lax: - strict: let conflicting drivers fail to load with an error message - lax: let conflicting driver work normal with a warning message - no: no functional change at all Depending on the feedback and the kind of interferences we see, this should be set to strict at later time. Goal of this patch set is: - Identify ACPI interferences in bug reports (very hard to reproduce and to identify) - Find BIOSes for that an ACPI driver should exist for specific HW instead of a native one. - stability in general Provide acpi_check_{mem_}region. Drivers can additionally check against possible ACPI interference by also invoking this shortly before they call request_region. If -EBUSY is returned, the driver must not load. Use acpi_enforce_resources=strict/lax/no options to: - strict: let conflicting drivers fail to load with an error message - lax: let conflicting driver work normal with a warning message - no: no functional change at all Cc: "Mark M. Hoffman" Cc: Jean Delvare Cc: Len Brown Cc: Bjorn Helgaas Signed-off-by: Thomas Renninger Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/dispatcher/dsopcode.c | 4 +- drivers/acpi/osl.c | 175 ++++++++++++++++++++++++++++++++++++- 2 files changed, 176 insertions(+), 3 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index fc9da4879cb..f501e083aac 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -359,7 +359,9 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) status = acpi_os_validate_address(obj_desc->region.space_id, obj_desc->region.address, - (acpi_size) obj_desc->region.length); + (acpi_size) obj_desc->region.length, + acpi_ut_get_node_name(node)); + if (ACPI_FAILURE(status)) { /* * Invalid address/length. We will emit an error message and mark diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e53fb516f9d..222f7b1b66f 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -44,6 +44,8 @@ #include #include +#include +#include #define _COMPONENT ACPI_OS_SERVICES ACPI_MODULE_NAME("osl"); @@ -74,6 +76,18 @@ static void *acpi_irq_context; static struct workqueue_struct *kacpid_wq; static struct workqueue_struct *kacpi_notify_wq; +struct acpi_res_list { + resource_size_t start; + resource_size_t end; + acpi_adr_space_type resource_type; /* IO port, System memory, ...*/ + char name[5]; /* only can have a length of 4 chars, make use of this + one instead of res->name, no need to kalloc then */ + struct list_head resource_list; +}; + +static LIST_HEAD(resource_list_head); +static DEFINE_SPINLOCK(acpi_res_lock); + #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ static char osi_additional_string[OSI_STRING_LENGTH_MAX]; @@ -1102,6 +1116,127 @@ static int __init acpi_wake_gpes_always_on_setup(char *str) __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); +/* Check of resource interference between native drivers and ACPI + * OperationRegions (SystemIO and System Memory only). + * IO ports and memory declared in ACPI might be used by the ACPI subsystem + * in arbitrary AML code and can interfere with legacy drivers. + * acpi_enforce_resources= can be set to: + * + * - strict (2) + * -> further driver trying to access the resources will not load + * - lax (default) (1) + * -> further driver trying to access the resources will load, but you + * get a system message that something might go wrong... + * + * - no (0) + * -> ACPI Operation Region resources will not be registered + * + */ +#define ENFORCE_RESOURCES_STRICT 2 +#define ENFORCE_RESOURCES_LAX 1 +#define ENFORCE_RESOURCES_NO 0 + +static unsigned int acpi_enforce_resources = ENFORCE_RESOURCES_LAX; + +static int __init acpi_enforce_resources_setup(char *str) +{ + if (str == NULL || *str == '\0') + return 0; + + if (!strcmp("strict", str)) + acpi_enforce_resources = ENFORCE_RESOURCES_STRICT; + else if (!strcmp("lax", str)) + acpi_enforce_resources = ENFORCE_RESOURCES_LAX; + else if (!strcmp("no", str)) + acpi_enforce_resources = ENFORCE_RESOURCES_NO; + + return 1; +} + +__setup("acpi_enforce_resources=", acpi_enforce_resources_setup); + +/* Check for resource conflicts between ACPI OperationRegions and native + * drivers */ +static int acpi_check_resource_conflict(struct resource *res) +{ + struct acpi_res_list *res_list_elem; + int ioport; + int clash = 0; + + if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) + return 0; + if (!(res->flags & IORESOURCE_IO) && !(res->flags & IORESOURCE_MEM)) + return 0; + + ioport = res->flags & IORESOURCE_IO; + + spin_lock(&acpi_res_lock); + list_for_each_entry(res_list_elem, &resource_list_head, + resource_list) { + if (ioport && (res_list_elem->resource_type + != ACPI_ADR_SPACE_SYSTEM_IO)) + continue; + if (!ioport && (res_list_elem->resource_type + != ACPI_ADR_SPACE_SYSTEM_MEMORY)) + continue; + + if (res->end < res_list_elem->start + || res_list_elem->end < res->start) + continue; + clash = 1; + break; + } + spin_unlock(&acpi_res_lock); + + if (clash) { + if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { + printk(KERN_INFO "%sACPI: %s resource %s [0x%llx-0x%llx]" + " conflicts with ACPI region %s" + " [0x%llx-0x%llx]\n", + acpi_enforce_resources == ENFORCE_RESOURCES_LAX + ? KERN_WARNING : KERN_ERR, + ioport ? "I/O" : "Memory", res->name, + (long long) res->start, (long long) res->end, + res_list_elem->name, + (long long) res_list_elem->start, + (long long) res_list_elem->end); + printk(KERN_INFO "ACPI: Device needs an ACPI driver\n"); + } + if (acpi_enforce_resources == ENFORCE_RESOURCES_STRICT) + return -EBUSY; + } + return 0; +} + +int acpi_check_region(resource_size_t start, resource_size_t n, + const char *name) +{ + struct resource res = { + .start = start, + .end = start + n - 1, + .name = name, + .flags = IORESOURCE_IO, + }; + + return acpi_check_resource_conflict(&res); +} +EXPORT_SYMBOL(acpi_check_region); + +int acpi_check_mem_region(resource_size_t start, resource_size_t n, + const char *name) +{ + struct resource res = { + .start = start, + .end = start + n - 1, + .name = name, + .flags = IORESOURCE_MEM, + }; + + return acpi_check_resource_conflict(&res); + +} +EXPORT_SYMBOL(acpi_check_mem_region); + /* * Acquire a spinlock. * @@ -1303,10 +1438,46 @@ acpi_status acpi_os_validate_address ( u8 space_id, acpi_physical_address address, - acpi_size length) + acpi_size length, + char *name) { + struct acpi_res_list *res; + if (acpi_enforce_resources == ENFORCE_RESOURCES_NO) + return AE_OK; - return AE_OK; + switch (space_id) { + case ACPI_ADR_SPACE_SYSTEM_IO: + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + /* Only interference checks against SystemIO and SytemMemory + are needed */ + res = kzalloc(sizeof(struct acpi_res_list), GFP_KERNEL); + if (!res) + return AE_OK; + /* ACPI names are fixed to 4 bytes, still better use strlcpy */ + strlcpy(res->name, name, 5); + res->start = address; + res->end = address + length - 1; + res->resource_type = space_id; + spin_lock(&acpi_res_lock); + list_add(&res->resource_list, &resource_list_head); + spin_unlock(&acpi_res_lock); + pr_debug("Added %s resource: start: 0x%llx, end: 0x%llx, " + "name: %s\n", (space_id == ACPI_ADR_SPACE_SYSTEM_IO) + ? "SystemIO" : "System Memory", + (unsigned long long)res->start, + (unsigned long long)res->end, + res->name); + break; + case ACPI_ADR_SPACE_PCI_CONFIG: + case ACPI_ADR_SPACE_EC: + case ACPI_ADR_SPACE_SMBUS: + case ACPI_ADR_SPACE_CMOS: + case ACPI_ADR_SPACE_PCI_BAR_TARGET: + case ACPI_ADR_SPACE_DATA_TABLE: + case ACPI_ADR_SPACE_FIXED_HARDWARE: + break; + } + return AE_OK; } #endif -- cgit v1.2.3 From 443dea72d5f428170de6d6e3c4c1a1e2b7632b65 Mon Sep 17 00:00:00 2001 From: Thomas Renninger Date: Mon, 4 Feb 2008 23:31:23 -0800 Subject: ACPI: Export acpi_check_resource_conflict Export acpi_check_resource_conflict(), sometimes drivers already have a struct resource at hand so no need to use the wrappers to build a new one. Signed-off-by: Jean Delvare Cc: "Mark M. Hoffman" Cc: Bjorn Helgaas Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/osl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 222f7b1b66f..bc1604bfa4d 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1157,7 +1157,7 @@ __setup("acpi_enforce_resources=", acpi_enforce_resources_setup); /* Check for resource conflicts between ACPI OperationRegions and native * drivers */ -static int acpi_check_resource_conflict(struct resource *res) +int acpi_check_resource_conflict(struct resource *res) { struct acpi_res_list *res_list_elem; int ioport; @@ -1207,6 +1207,7 @@ static int acpi_check_resource_conflict(struct resource *res) } return 0; } +EXPORT_SYMBOL(acpi_check_resource_conflict); int acpi_check_region(resource_size_t start, resource_size_t n, const char *name) -- cgit v1.2.3 From 23b168d425ca0ca25257ff8205a39f1c2d1b0f27 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Tue, 5 Feb 2008 19:27:12 +0100 Subject: PM: documentation cleanups Signed-off-by: Pavel Machek Acked-by: Rafael J. Wysocki Signed-off-by: Len Brown --- drivers/acpi/hardware/hwsleep.c | 2 +- drivers/acpi/sleep/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index fd1c4ba6336..058d0be5cbe 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c @@ -286,13 +286,13 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) } /* + * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ status = acpi_hw_disable_all_gpes(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - acpi_gbl_system_awake_and_running = FALSE; status = acpi_hw_enable_all_wakeup_gpes(); diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 485de134707..c9a733f36bd 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c @@ -170,7 +170,7 @@ static int acpi_pm_enter(suspend_state_t pm_state) /* Reprogram control registers and execute _BFS */ acpi_leave_sleep_state_prep(acpi_state); - /* ACPI 3.0 specs (P62) says that it's the responsabilty + /* ACPI 3.0 specs (P62) says that it's the responsibility * of the OSPM to clear the status bit [ implying that the * POWER_BUTTON event should not reach userspace ] */ -- cgit v1.2.3 From 2e906655baf1c6f6fccd212fc9e6499dc6928b80 Mon Sep 17 00:00:00 2001 From: "venkatesh.pallipadi@intel.com" Date: Thu, 31 Jan 2008 17:35:03 -0800 Subject: ACPI: idle: Fix acpi_safe_halt usages and interrupt enabling/disabling acpi_safe_halt() needs interrupts to be disabled for atomic need_resched check and safe halt. Otherwise we may miss an interrupt and go into halt. acpi_safe_halt() also does not enable interrupts on all return paths. So the callers should handle enable and disable interrupts around it. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 199ea214615..106a22948aa 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -201,6 +201,10 @@ static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2) return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); } +/* + * Callers should disable interrupts before the call and enable + * interrupts after return. + */ static void acpi_safe_halt(void) { current_thread_info()->status &= ~TS_POLLING; @@ -413,6 +417,8 @@ static void acpi_processor_idle(void) pm_idle_save(); else acpi_safe_halt(); + + local_irq_enable(); return; } @@ -521,6 +527,7 @@ static void acpi_processor_idle(void) * skew otherwise. */ sleep_ticks = 0xFFFFFFFF; + local_irq_enable(); break; case ACPI_STATE_C2: @@ -1403,11 +1410,13 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, if (unlikely(!pr)) return 0; + local_irq_disable(); if (pr->flags.bm_check) acpi_idle_update_bm_rld(pr, cx); acpi_safe_halt(); + local_irq_enable(); cx->usage++; return 0; @@ -1517,7 +1526,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, if (dev->safe_state) { return dev->safe_state->enter(dev, dev->safe_state); } else { + local_irq_disable(); acpi_safe_halt(); + local_irq_enable(); return 0; } } -- cgit v1.2.3 From bc71bec91f9875ef825d12104acf3bf4ca215fa4 Mon Sep 17 00:00:00 2001 From: "venkatesh.pallipadi@intel.com" Date: Thu, 31 Jan 2008 17:35:04 -0800 Subject: ACPI: enable MWAIT for C1 idle Add MWAIT idle for C1 state instead of halt, on platforms that support C1 state with MWAIT. Renames cx->space_id to something more appropriate. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 106a22948aa..4ba3a9a473d 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -265,7 +265,7 @@ static atomic_t c3_cpu_count; /* Common C-state entry for C2, C3, .. */ static void acpi_cstate_enter(struct acpi_processor_cx *cstate) { - if (cstate->space_id == ACPI_CSTATE_FFH) { + if (cstate->entry_method == ACPI_CSTATE_FFH) { /* Call into architectural FFH based C-state */ acpi_processor_ffh_cstate_enter(cstate); } else { @@ -929,20 +929,20 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) cx.address = reg->address; cx.index = current_count + 1; - cx.space_id = ACPI_CSTATE_SYSTEMIO; + cx.entry_method = ACPI_CSTATE_SYSTEMIO; if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) { if (acpi_processor_ffh_cstate_probe (pr->id, &cx, reg) == 0) { - cx.space_id = ACPI_CSTATE_FFH; - } else if (cx.type != ACPI_STATE_C1) { + cx.entry_method = ACPI_CSTATE_FFH; + } else if (cx.type == ACPI_STATE_C1) { /* * C1 is a special case where FIXED_HARDWARE * can be handled in non-MWAIT way as well. * In that case, save this _CST entry info. - * That is, we retain space_id of SYSTEM_IO for - * halt based C1. * Otherwise, ignore this info and continue. */ + cx.entry_method = ACPI_CSTATE_HALT; + } else { continue; } } @@ -1376,12 +1376,16 @@ static inline void acpi_idle_update_bm_rld(struct acpi_processor *pr, /** * acpi_idle_do_entry - a helper function that does C2 and C3 type entry * @cx: cstate data + * + * Caller disables interrupt before call and enables interrupt after return. */ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx) { - if (cx->space_id == ACPI_CSTATE_FFH) { + if (cx->entry_method == ACPI_CSTATE_FFH) { /* Call into architectural FFH based C-state */ acpi_processor_ffh_cstate_enter(cx); + } else if (cx->entry_method == ACPI_CSTATE_HALT) { + acpi_safe_halt(); } else { int unused; /* IO port based C-state */ @@ -1414,7 +1418,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, if (pr->flags.bm_check) acpi_idle_update_bm_rld(pr, cx); - acpi_safe_halt(); + acpi_idle_do_entry(cx); local_irq_enable(); cx->usage++; -- cgit v1.2.3 From 9b12e18cdc1553de62d931e73443c806347cd974 Mon Sep 17 00:00:00 2001 From: "venkatesh.pallipadi@intel.com" Date: Thu, 31 Jan 2008 17:35:05 -0800 Subject: ACPI: cpuidle: Support C1 idle time accounting Show C1 idle time in /sysfs cpuidle interface. C1 idle time may not be entirely accurate in all cases. It includes the time spent in the interrupt handler after wakeup with "hlt" based C1. But, it will be accurate with "mwait" based C1. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 4ba3a9a473d..fea71597b40 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1407,8 +1407,10 @@ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx) static int acpi_idle_enter_c1(struct cpuidle_device *dev, struct cpuidle_state *state) { + u32 t1, t2; struct acpi_processor *pr; struct acpi_processor_cx *cx = cpuidle_get_statedata(state); + pr = processors[smp_processor_id()]; if (unlikely(!pr)) @@ -1418,12 +1420,14 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, if (pr->flags.bm_check) acpi_idle_update_bm_rld(pr, cx); + t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); acpi_idle_do_entry(cx); + t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); local_irq_enable(); cx->usage++; - return 0; + return ticks_elapsed_in_us(t1, t2); } /** @@ -1660,6 +1664,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) switch (cx->type) { case ACPI_STATE_C1: state->flags |= CPUIDLE_FLAG_SHALLOW; + state->flags |= CPUIDLE_FLAG_TIME_VALID; state->enter = acpi_idle_enter_c1; dev->safe_state = state; break; -- cgit v1.2.3 From 9a0b841586c3c6c846effdbe75885c2ebc0031b0 Mon Sep 17 00:00:00 2001 From: "venkatesh.pallipadi@intel.com" Date: Thu, 31 Jan 2008 17:35:06 -0800 Subject: cpuidle: Add a poll_idle method Add a default poll idle state with 0 latency. Provides an option to users to use poll_idle by using 0 as the latency requirement. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index fea71597b40..32488e6f76a 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1628,7 +1628,7 @@ struct cpuidle_driver acpi_idle_driver = { */ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) { - int i, count = 0; + int i, count = CPUIDLE_DRIVER_STATE_START; struct acpi_processor_cx *cx; struct cpuidle_state *state; struct cpuidle_device *dev = &pr->power.dev; @@ -1687,6 +1687,8 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) } count++; + if (count == CPUIDLE_STATE_MAX) + break; } dev->state_count = count; -- cgit v1.2.3 From 8a681a4dee07ea09aedaadc6a2da28d2131dc414 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Fri, 25 Jan 2008 14:47:49 +0800 Subject: ACPI: video: create "brightness_switch_enabled" modparam Introduce new module parameter for brightness control. "brightness_switch_enabled" is set by default which means nothing changes upon brightness switch events. When "brightness_switch_enabled" is cleared via "echo 0 > /sys/module/video/parameters/brightness_switch_enabled", ACPI will not try to change the brightness level any more. Either X will take charge of this or users can change the brightness level by poking /sys/class/backlight/acpi_videoX/... Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bd77e81e81c..b1a56bf682a 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -72,6 +72,9 @@ MODULE_AUTHOR("Bruno Ducrot"); MODULE_DESCRIPTION("ACPI Video Driver"); MODULE_LICENSE("GPL"); +static int brightness_switch_enabled = 1; +module_param(brightness_switch_enabled, bool, 0644); + static int acpi_video_bus_add(struct acpi_device *device); static int acpi_video_bus_remove(struct acpi_device *device, int type); @@ -1850,27 +1853,32 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ - acpi_video_switch_brightness(video_device, event); + if (brightness_switch_enabled) + acpi_video_switch_brightness(video_device, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_BRIGHTNESS_CYCLE; break; case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ - acpi_video_switch_brightness(video_device, event); + if (brightness_switch_enabled) + acpi_video_switch_brightness(video_device, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_BRIGHTNESSUP; break; case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ - acpi_video_switch_brightness(video_device, event); + if (brightness_switch_enabled) + acpi_video_switch_brightness(video_device, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_BRIGHTNESSDOWN; break; case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ - acpi_video_switch_brightness(video_device, event); + if (brightness_switch_enabled) + acpi_video_switch_brightness(video_device, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_BRIGHTNESS_ZERO; break; case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ - acpi_video_switch_brightness(video_device, event); + if (brightness_switch_enabled) + acpi_video_switch_brightness(video_device, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_DISPLAY_OFF; break; -- cgit v1.2.3 From ba5e1223422368fd2f4dbb0745f5fbb5fe9a65f1 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Fri, 25 Jan 2008 14:47:57 +0800 Subject: ACPI: video: delete unused display switch on hotkey event code Display switching via ACPI control methods are not known to work on any platforms. Further, the X community wants to control the display switching all by themselves without BIOS/AML involvement. Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 63 ---------------------------------------------------- 1 file changed, 63 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index b1a56bf682a..d4b4b52facb 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -276,7 +276,6 @@ static void acpi_video_device_rebind(struct acpi_video_bus *video); static void acpi_video_device_bind(struct acpi_video_bus *video, struct acpi_video_device *device); static int acpi_video_device_enumerate(struct acpi_video_bus *video); -static int acpi_video_switch_output(struct acpi_video_bus *video, int event); static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level); static int acpi_video_device_lcd_get_level_current( @@ -1583,64 +1582,6 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) return status; } -/* - * Arg: - * video : video bus device - * event : notify event - * - * Return: - * < 0 : error - * - * 1. Find out the current active output device. - * 2. Identify the next output device to switch to. - * 3. call _DSS to do actual switch. - */ - -static int acpi_video_switch_output(struct acpi_video_bus *video, int event) -{ - struct list_head *node; - struct acpi_video_device *dev = NULL; - struct acpi_video_device *dev_next = NULL; - struct acpi_video_device *dev_prev = NULL; - unsigned long state; - int status = 0; - - mutex_lock(&video->device_list_lock); - - list_for_each(node, &video->video_device_list) { - dev = container_of(node, struct acpi_video_device, entry); - status = acpi_video_device_get_state(dev, &state); - if (state & 0x2) { - dev_next = container_of(node->next, - struct acpi_video_device, entry); - dev_prev = container_of(node->prev, - struct acpi_video_device, entry); - goto out; - } - } - - dev_next = container_of(node->next, struct acpi_video_device, entry); - dev_prev = container_of(node->prev, struct acpi_video_device, entry); - - out: - mutex_unlock(&video->device_list_lock); - - switch (event) { - case ACPI_VIDEO_NOTIFY_CYCLE: - case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: - acpi_video_device_set_state(dev, 0); - acpi_video_device_set_state(dev_next, 0x80000001); - break; - case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: - acpi_video_device_set_state(dev, 0); - acpi_video_device_set_state(dev_prev, 0x80000001); - default: - break; - } - - return status; -} - static int acpi_video_get_next_level(struct acpi_video_device *device, u32 level_current, u32 event) @@ -1800,23 +1741,19 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) * connector. */ acpi_video_device_enumerate(video); acpi_video_device_rebind(video); - acpi_video_switch_output(video, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_SWITCHVIDEOMODE; break; case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */ - acpi_video_switch_output(video, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_SWITCHVIDEOMODE; break; case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ - acpi_video_switch_output(video, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_VIDEO_NEXT; break; case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ - acpi_video_switch_output(video, event); acpi_bus_generate_proc_event(device, event, 0); keycode = KEY_VIDEO_PREV; break; -- cgit v1.2.3 From 9ee85241fdaab358dff1d8647f20a478cfa512a1 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Fri, 25 Jan 2008 14:48:06 +0800 Subject: ACPI: create notifier chain to get hotkey events to graphics driver Kernel mode graphics drivers need this ACPI notifier chaine so that they can get notified upon hotkey events. Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/event.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 5c95863f8fa..5479dc0eeee 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -109,6 +109,34 @@ static const struct file_operations acpi_system_event_ops = { }; #endif /* CONFIG_ACPI_PROC_EVENT */ +/* ACPI notifier chain */ +BLOCKING_NOTIFIER_HEAD(acpi_chain_head); + +int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) +{ + struct acpi_bus_event event; + + strcpy(event.device_class, dev->pnp.device_class); + strcpy(event.bus_id, dev->pnp.bus_id); + event.type = type; + event.data = data; + return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event) + == NOTIFY_BAD) ? -EINVAL : 0; +} +EXPORT_SYMBOL(acpi_notifier_call_chain); + +int register_acpi_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&acpi_chain_head, nb); +} +EXPORT_SYMBOL(register_acpi_notifier); + +int unregister_acpi_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&acpi_chain_head, nb); +} +EXPORT_SYMBOL(unregister_acpi_notifier); + #ifdef CONFIG_NET static unsigned int acpi_event_seqnum; struct acpi_genl_event { -- cgit v1.2.3 From 7761f638f6e0f276fe8612ba306d09c40d1b553c Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Fri, 25 Jan 2008 14:48:12 +0800 Subject: ACPI: video: call ACPI notifier chain for ACPI video notifications Call notifier chain for display/brightness switch events. The kernel mode graphics driver is interested in this. Sign-off-by: Zhang Rui Signed-off-by: Len Brown --- drivers/acpi/video.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index d4b4b52facb..74ff0faeab5 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1765,6 +1765,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) break; } + acpi_notifier_call_chain(device, event, 0); input_report_key(input, keycode, 1); input_sync(input); input_report_key(input, keycode, 0); @@ -1826,6 +1827,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) break; } + acpi_notifier_call_chain(device, event, 0); input_report_key(input, keycode, 1); input_sync(input); input_report_key(input, keycode, 0); -- cgit v1.2.3 From 863c1490e512db40dab61e44b694a493a9e68b3f Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Mon, 4 Feb 2008 23:31:24 -0800 Subject: ACPI: video: reset brightness on resume Some machines seem to need the backlight brightness to be reset on resume. Add support for doing so to the video module. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Matthew Garrett Cc: Zhang Rui Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/video.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 74ff0faeab5..b5e35cd559e 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -77,6 +77,7 @@ module_param(brightness_switch_enabled, bool, 0644); static int acpi_video_bus_add(struct acpi_device *device); static int acpi_video_bus_remove(struct acpi_device *device, int type); +static int acpi_video_resume(struct acpi_device *device); static const struct acpi_device_id video_device_ids[] = { {ACPI_VIDEO_HID, 0}, @@ -91,6 +92,7 @@ static struct acpi_driver acpi_video_bus = { .ops = { .add = acpi_video_bus_add, .remove = acpi_video_bus_remove, + .resume = acpi_video_resume, }, }; @@ -1837,6 +1839,25 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) } static int instance; +static int acpi_video_resume(struct acpi_device *device) +{ + struct acpi_video_bus *video; + struct acpi_video_device *video_device; + int i; + + if (!device || !acpi_driver_data(device)) + return -EINVAL; + + video = acpi_driver_data(device); + + for (i = 0; i < video->attached_count; i++) { + video_device = video->attached_array[i].bind_info; + if (video_device && video_device->backlight) + acpi_video_set_brightness(video_device->backlight); + } + return AE_OK; +} + static int acpi_video_bus_add(struct acpi_device *device) { acpi_status status; -- cgit v1.2.3 From 3fa2cdcc45a0176de15cac9dbf4ed2834ebf8932 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 7 Feb 2008 01:44:06 +0000 Subject: ACPI: video: Ignore ACPI video devices that aren't present in hardware Vendors often ship machines with a choice of integrated or discrete graphics, and use the same DSDT for both. As a result, the ACPI video module will locate devices that may not exist on this specific platform. Attempt to determine whether the device exists or not, and abort the device creation if it do not exist. Signed-off-by: Matthew Garrett Signed-off-by: Len Brown --- drivers/acpi/video.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index b5e35cd559e..970c01a7f8f 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -730,11 +730,40 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video) static int acpi_video_bus_check(struct acpi_video_bus *video) { acpi_status status = -ENOENT; - + long device_id; + struct device *dev; + struct acpi_device *device; if (!video) return -EINVAL; + device = video->device; + + status = + acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); + + if (!ACPI_SUCCESS(status)) + return -ENODEV; + + /* We need to attempt to determine whether the _ADR refers to a + PCI device or not. There's no terribly good way to do this, + so the best we can hope for is to assume that there'll never + be a video device in the host bridge */ + if (device_id >= 0x10000) { + /* It looks like a PCI device. Does it exist? */ + dev = acpi_get_physical_device(device->handle); + } else { + /* It doesn't look like a PCI device. Does its parent + exist? */ + acpi_handle phandle; + if (acpi_get_parent(device->handle, &phandle)) + return -ENODEV; + dev = acpi_get_physical_device(phandle); + } + if (!dev) + return -ENODEV; + put_device(dev); + /* Since there is no HID, CID and so on for VGA driver, we have * to check well known required nodes. */ -- cgit v1.2.3 From 87ecd5cddaa37f057d8d8c2813e1b748b1804423 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Tue, 1 Jan 2008 14:00:00 -0500 Subject: ACPI: add missing prink prefix strings Signed-off-by: Len Brown --- drivers/acpi/scan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index d9d531cce27..78a82b3c7b6 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -59,7 +59,7 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias, count = snprintf(&modalias[len], size, "%s:", cid_list->id[i].value); if (count < 0 || count >= size) { - printk(KERN_ERR "acpi: %s cid[%i] exceeds event buffer size", + printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size", acpi_dev->pnp.device_name, i); break; } @@ -453,7 +453,7 @@ static int acpi_device_register(struct acpi_device *device, device->dev.release = &acpi_device_release; result = device_add(&device->dev); if(result) { - printk("Error adding device %s", device->dev.bus_id); + printk(KERN_ERR PREFIX "Error adding device %s", device->dev.bus_id); goto end; } @@ -956,7 +956,7 @@ static void acpi_device_set_id(struct acpi_device *device, case ACPI_BUS_TYPE_DEVICE: status = acpi_get_object_info(handle, &buffer); if (ACPI_FAILURE(status)) { - printk("%s: Error reading device info\n", __FUNCTION__); + printk(KERN_ERR PREFIX "%s: Error reading device info\n", __FUNCTION__); return; } @@ -1026,7 +1026,7 @@ static void acpi_device_set_id(struct acpi_device *device, if (device->pnp.cid_list) memcpy(device->pnp.cid_list, cid_list, cid_list->size); else - printk(KERN_ERR "Memory allocation error\n"); + printk(KERN_ERR PREFIX "Memory allocation error\n"); } kfree(buffer.pointer); @@ -1050,7 +1050,7 @@ static int acpi_device_set_context(struct acpi_device *device, int type) acpi_bus_data_handler, device); if (ACPI_FAILURE(status)) { - printk("Error attaching device data\n"); + printk(KERN_ERR PREFIX "Error attaching device data\n"); result = -ENODEV; } } -- cgit v1.2.3 From e5685b9d35c2cc0a98425b05df30cb837dd1e632 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 24 Oct 2007 18:24:42 +0200 Subject: ACPI: misc cleanups This patch contains the following possible cleanups: - make the following needlessly global code static: - drivers/acpi/bay.c:dev_attr_eject - drivers/acpi/bay.c:dev_attr_present - drivers/acpi/dock.c:dev_attr_docked - drivers/acpi/dock.c:dev_attr_flags - drivers/acpi/dock.c:dev_attr_uid - drivers/acpi/dock.c:dev_attr_undock - drivers/acpi/pci_bind.c:acpi_pci_unbind() - drivers/acpi/pci_link.c:acpi_link_lock - drivers/acpi/sbs.c:acpi_sbs_callback() - drivers/acpi/sbshc.c:acpi_smbus_transaction() - drivers/acpi/sleep/main.c:acpi_sleep_prepare() - #if 0 the following unused global functions: - drivers/acpi/numa.c:acpi_unmap_pxm_to_node() - remove the following unused EXPORT_SYMBOL's: - acpi_register_gsi - acpi_unregister_gsi - acpi_strict - acpi_bus_receive_event - register_acpi_bus_type - unregister_acpi_bus_type - acpi_os_printf - acpi_os_sleep - acpi_os_stall - acpi_os_read_pci_configuration - acpi_os_create_semaphore - acpi_os_delete_semaphore - acpi_os_wait_semaphore - acpi_os_signal_semaphore - acpi_os_signal - acpi_pci_irq_enable - acpi_get_pxm Signed-off-by: Adrian Bunk Acked-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/bay.c | 4 ++-- drivers/acpi/bus.c | 1 - drivers/acpi/dock.c | 8 ++++---- drivers/acpi/glue.c | 4 ---- drivers/acpi/numa.c | 3 ++- drivers/acpi/osl.c | 18 ------------------ drivers/acpi/pci_bind.c | 4 +++- drivers/acpi/pci_irq.c | 2 -- drivers/acpi/pci_link.c | 2 +- drivers/acpi/sbs.c | 2 +- drivers/acpi/sbshc.c | 4 ++-- 11 files changed, 15 insertions(+), 37 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c index 6daf6088ac8..0c81294ac48 100644 --- a/drivers/acpi/bay.c +++ b/drivers/acpi/bay.c @@ -128,7 +128,7 @@ static ssize_t show_present(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", bay_present(bay)); } -DEVICE_ATTR(present, S_IRUGO, show_present, NULL); +static DEVICE_ATTR(present, S_IRUGO, show_present, NULL); /* * write_eject - write method for "eject" file in sysfs @@ -144,7 +144,7 @@ static ssize_t write_eject(struct device *dev, struct device_attribute *attr, eject_device(bay->handle); return count; } -DEVICE_ATTR(eject, S_IWUSR, NULL, write_eject); +static DEVICE_ATTR(eject, S_IWUSR, NULL, write_eject); /** * is_ata - see if a device is an ata device diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 1b4cf984b08..2994bb2b22e 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -366,7 +366,6 @@ int acpi_bus_receive_event(struct acpi_bus_event *event) return 0; } -EXPORT_SYMBOL(acpi_bus_receive_event); #endif /* CONFIG_ACPI_PROC_EVENT */ /* -------------------------------------------------------------------------- diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 1dabdf4c07b..7e47a981cc2 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -680,7 +680,7 @@ static ssize_t show_docked(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station)); } -DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); +static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); /* * show_flags - read method for flags file in sysfs @@ -691,7 +691,7 @@ static ssize_t show_flags(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); } -DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL); +static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL); /* * write_undock - write method for "undock" file in sysfs @@ -707,7 +707,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr, ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); return ret ? ret: count; } -DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); +static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); /* * show_dock_uid - read method for "uid" file in sysfs @@ -723,7 +723,7 @@ static ssize_t show_dock_uid(struct device *dev, return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf); } -DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); +static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); /** * dock_add - add a new dock station diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 4893e256e39..eda0978b57c 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -36,8 +36,6 @@ int register_acpi_bus_type(struct acpi_bus_type *type) return -ENODEV; } -EXPORT_SYMBOL(register_acpi_bus_type); - int unregister_acpi_bus_type(struct acpi_bus_type *type) { if (acpi_disabled) @@ -53,8 +51,6 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type) return -ENODEV; } -EXPORT_SYMBOL(unregister_acpi_bus_type); - static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) { struct acpi_bus_type *tmp, *ret = NULL; diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 0822d9fc1cb..5d59cb33b1a 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -78,6 +78,7 @@ int acpi_map_pxm_to_node(int pxm) return node; } +#if 0 void __cpuinit acpi_unmap_pxm_to_node(int node) { int pxm = node_to_pxm_map[node]; @@ -85,6 +86,7 @@ void __cpuinit acpi_unmap_pxm_to_node(int node) node_to_pxm_map[node] = PXM_INVAL; node_clear(node, nodes_found_map); } +#endif /* 0 */ static void __init acpi_table_print_srat_entry(struct acpi_subtable_header *header) @@ -247,7 +249,6 @@ int acpi_get_pxm(acpi_handle h) } while (ACPI_SUCCESS(status)); return -1; } -EXPORT_SYMBOL(acpi_get_pxm); int acpi_get_node(acpi_handle *handle) { diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e53fb516f9d..7fcacc5ed82 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -219,8 +219,6 @@ void acpi_os_printf(const char *fmt, ...) va_end(args); } -EXPORT_SYMBOL(acpi_os_printf); - void acpi_os_vprintf(const char *fmt, va_list args) { static char buffer[512]; @@ -384,8 +382,6 @@ void acpi_os_sleep(acpi_integer ms) schedule_timeout_interruptible(msecs_to_jiffies(ms)); } -EXPORT_SYMBOL(acpi_os_sleep); - void acpi_os_stall(u32 us) { while (us) { @@ -399,8 +395,6 @@ void acpi_os_stall(u32 us) } } -EXPORT_SYMBOL(acpi_os_stall); - /* * Support ACPI 3.0 AML Timer operand * Returns 64-bit free-running, monotonically increasing timer @@ -550,8 +544,6 @@ acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, return (result ? AE_ERROR : AE_OK); } -EXPORT_SYMBOL(acpi_os_read_pci_configuration); - acpi_status acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg, acpi_integer value, u32 width) @@ -793,8 +785,6 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) return AE_OK; } -EXPORT_SYMBOL(acpi_os_create_semaphore); - /* * TODO: A better way to delete semaphores? Linux doesn't have a * 'delete_semaphore()' function -- may result in an invalid @@ -818,8 +808,6 @@ acpi_status acpi_os_delete_semaphore(acpi_handle handle) return AE_OK; } -EXPORT_SYMBOL(acpi_os_delete_semaphore); - /* * TODO: The kernel doesn't have a 'down_timeout' function -- had to * improvise. The process is to sleep for one scheduler quantum @@ -912,8 +900,6 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) return status; } -EXPORT_SYMBOL(acpi_os_wait_semaphore); - /* * TODO: Support for units > 1? */ @@ -936,8 +922,6 @@ acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) return AE_OK; } -EXPORT_SYMBOL(acpi_os_signal_semaphore); - #ifdef ACPI_FUTURE_USAGE u32 acpi_os_get_line(char *buffer) { @@ -981,8 +965,6 @@ acpi_status acpi_os_signal(u32 function, void *info) return AE_OK; } -EXPORT_SYMBOL(acpi_os_signal); - static int __init acpi_os_name_setup(char *str) { char *p = acpi_os_name; diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 388300de005..4b252ea0e95 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c @@ -44,6 +44,8 @@ struct acpi_pci_data { struct pci_dev *dev; }; +static int acpi_pci_unbind(struct acpi_device *device); + static void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context) { @@ -267,7 +269,7 @@ int acpi_pci_bind(struct acpi_device *device) return result; } -int acpi_pci_unbind(struct acpi_device *device) +static int acpi_pci_unbind(struct acpi_device *device) { int result = 0; acpi_status status = AE_OK; diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 62010c2481b..822947339df 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -478,8 +478,6 @@ int acpi_pci_irq_enable(struct pci_dev *dev) return 0; } -EXPORT_SYMBOL(acpi_pci_irq_enable); - /* FIXME: implement x86/x86_64 version */ void __attribute__ ((weak)) acpi_unregister_gsi(u32 i) { diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 5400ea173f6..233c40c5168 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -95,7 +95,7 @@ static struct { int count; struct list_head entries; } acpi_link; -DEFINE_MUTEX(acpi_link_lock); +static DEFINE_MUTEX(acpi_link_lock); /* -------------------------------------------------------------------------- PCI Link Device Management diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index f136c7d3b3c..1194105cc3c 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -888,7 +888,7 @@ static void acpi_charger_remove(struct acpi_sbs *sbs) #endif } -void acpi_sbs_callback(void *context) +static void acpi_sbs_callback(void *context) { int id; struct acpi_sbs *sbs = context; diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index fd40b6a1d63..ae9a90438e2 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c @@ -111,8 +111,8 @@ static int wait_transaction_complete(struct acpi_smb_hc *hc, int timeout) return -ETIME; } -int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, u8 address, - u8 command, u8 *data, u8 length) +static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, + u8 address, u8 command, u8 *data, u8 length) { int ret = -EFAULT, i; u8 temp, sz = 0; -- cgit v1.2.3 From 9e52797131e83688f66fbca6d4cd25b83f33c48f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 3 Jan 2008 16:31:42 +0000 Subject: ACPI: its a directory not a folder.... The kernel help consistently uses 'directory' Signed-off-by: Alan Cox Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccf6ea95f68..95588c2a77d 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -68,26 +68,28 @@ config ACPI_PROCFS Say N to delete /proc/acpi/ files that have moved to /sys/ config ACPI_PROCFS_POWER - bool "Deprecated power /proc/acpi folders" + bool "Deprecated power /proc/acpi directories" depends on PROC_FS default y ---help--- For backwards compatibility, this option allows - deprecated power /proc/acpi/ folders to exist, even when + deprecated power /proc/acpi/ directories to exist, even when they have been replaced by functions in /sys. - The deprecated folders (and their replacements) include: + The deprecated directories (and their replacements) include: /proc/acpi/battery/* (/sys/class/power_supply/*) /proc/acpi/ac_adapter/* (sys/class/power_supply/*) - This option has no effect on /proc/acpi/ folders + This option has no effect on /proc/acpi/ directories and functions, which do not yet exist in /sys - Say N to delete power /proc/acpi/ folders that have moved to /sys/ + Say N to delete power /proc/acpi/ directories that have moved to /sys/ + config ACPI_SYSFS_POWER bool "Future power /sys interface" select POWER_SUPPLY default y ---help--- Say N to disable power /sys interface + config ACPI_PROC_EVENT bool "Deprecated /proc/acpi/event support" depends on PROC_FS -- cgit v1.2.3 From 9cbc7960288d28aec95257af59854e1d14ba23b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Piel?= Date: Tue, 5 Feb 2008 00:04:58 +0100 Subject: ACPI: Add "acpi_no_initrd_override" kernel parameter The acpi_no_initrd_override parameter permits to disable the load of an ACPI table from the initramfs. Signed-off-by: Eric Piel Signed-off-by: Len Brown --- drivers/acpi/osl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index bbd8360bfb2..2b41bdddbeb 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -77,6 +77,10 @@ static struct workqueue_struct *kacpi_notify_wq; #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ static char osi_additional_string[OSI_STRING_LENGTH_MAX]; +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD +static int acpi_no_initrd_override; +#endif + /* * "Ode to _OSI(Linux)" * @@ -386,7 +390,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, *new_table = (struct acpi_table_header *)AmlCode; #endif #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD - if (strncmp(existing_table->signature, "DSDT", 4) == 0) { + if ((strncmp(existing_table->signature, "DSDT", 4) == 0) && + !acpi_no_initrd_override) { struct acpi_table_header *initrd_table = acpi_find_dsdt_initrd(); if (initrd_table) *new_table = initrd_table; @@ -402,6 +407,15 @@ acpi_os_table_override(struct acpi_table_header * existing_table, return AE_OK; } +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD +int __init acpi_no_initrd_override_setup(char *s) +{ + acpi_no_initrd_override = 1; + return 1; +} +__setup("acpi_no_initrd_override", acpi_no_initrd_override_setup); +#endif + static irqreturn_t acpi_irq(int irq, void *dev_id) { return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; -- cgit v1.2.3 From d89e9d6b4930c6505ac3ed35f57ab7f4311d6cf6 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 6 Feb 2008 19:28:02 -0500 Subject: ACPI: update DSDT override documentation Signed-off-by: Len Brown --- drivers/acpi/Kconfig | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 0442ae153a2..c8e83204458 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -263,8 +263,10 @@ config ACPI_CUSTOM_DSDT depends on !STANDALONE default n help - This option is to load a custom ACPI DSDT - If you don't know what that is, say N. + This option supports a custom DSDT by linking it into the kernel. + See Documentation/acpi/dsdt-override.txt + + If unsure, say N. config ACPI_CUSTOM_DSDT_FILE string "Custom DSDT Table file to include" @@ -279,17 +281,11 @@ config ACPI_CUSTOM_DSDT_INITRD depends on BLK_DEV_INITRD default n help - The DSDT (Differentiated System Description Table) often needs to be - overridden because of broken BIOS implementations. If this feature is - activated you will be able to provide a customized DSDT by adding it - to your initramfs. If your mkinitrd tool does not support this feature - a script is provided in the documentation. For more details see - or . - If there is no table found, it will fall-back to the custom DSDT - in-kernel (if activated) or to the DSDT from the BIOS. - - Even if you do not need a new one at the moment, you may want to use a - better DSDT later. It is safe to say Y here. + This option supports a custom DSDT by optionally loading it from initrd. + See Documentation/acpi/dsdt-override.txt + + If you are not using this feature now, but may use it later, + it is safe to say Y here. config ACPI_BLACKLIST_YEAR int "Disable ACPI for systems before Jan 1st this year" if X86_32 -- cgit v1.2.3 From 04d94886b47b5133915021dcfb1108a8576f6ea7 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 6 Feb 2008 19:49:54 -0500 Subject: ACPI: update intrd DSDT override console messages also, address some checkpatch.pl violations Signed-off-by: Len Brown --- drivers/acpi/osl.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 2b41bdddbeb..2a400e08e74 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -326,49 +326,50 @@ struct acpi_table_header *acpi_find_dsdt_initrd(void) struct kstat stat; char *ramfs_dsdt_name = "/DSDT.aml"; - printk(KERN_INFO PREFIX "Looking for DSDT in initramfs... "); + printk(KERN_INFO PREFIX "Checking initramfs for custom DSDT"); /* * Never do this at home, only the user-space is allowed to open a file. - * The clean way would be to use the firmware loader. But this code must be run - * before there is any userspace available. So we need a static/init firmware - * infrastructure, which doesn't exist yet... + * The clean way would be to use the firmware loader. + * But this code must be run before there is any userspace available. + * A static/init firmware infrastructure doesn't exist yet... */ - if (vfs_stat(ramfs_dsdt_name, &stat) < 0) { - printk("not found.\n"); + if (vfs_stat(ramfs_dsdt_name, &stat) < 0) return ret; - } len = stat.size; /* check especially against empty files */ if (len <= 4) { - printk("error, file is too small: only %lu bytes.\n", len); + printk(KERN_ERR PREFIX "Failed: DSDT only %lu bytes.\n", len); return ret; } firmware_file = filp_open(ramfs_dsdt_name, O_RDONLY, 0); if (IS_ERR(firmware_file)) { - printk("error, could not open file %s.\n", ramfs_dsdt_name); + printk(KERN_ERR PREFIX "Failed to open %s.\n", ramfs_dsdt_name); return ret; } - dsdt_buffer = ACPI_ALLOCATE(len); + dsdt_buffer = kmalloc(len, GFP_ATOMIC); if (!dsdt_buffer) { - printk("error when allocating %lu bytes of memory.\n", len); + printk(KERN_ERR PREFIX "Failed to allocate %lu bytes.\n", len); goto err; } oldfs = get_fs(); set_fs(KERNEL_DS); - len2 = vfs_read(firmware_file, (char __user *)dsdt_buffer, len, &firmware_file->f_pos); + len2 = vfs_read(firmware_file, (char __user *)dsdt_buffer, len, + &firmware_file->f_pos); set_fs(oldfs); if (len2 < len) { - printk("error trying to read %lu bytes from %s.\n", len, ramfs_dsdt_name); + printk(KERN_ERR PREFIX "Failed to read %lu bytes from %s.\n", + len, ramfs_dsdt_name); ACPI_FREE(dsdt_buffer); goto err; } - printk("successfully read %lu bytes from %s.\n", len, ramfs_dsdt_name); + printk(KERN_INFO PREFIX "Found %lu byte DSDT in %s.\n", + len, ramfs_dsdt_name); ret = dsdt_buffer; err: filp_close(firmware_file, NULL); @@ -392,7 +393,9 @@ acpi_os_table_override(struct acpi_table_header * existing_table, #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD if ((strncmp(existing_table->signature, "DSDT", 4) == 0) && !acpi_no_initrd_override) { - struct acpi_table_header *initrd_table = acpi_find_dsdt_initrd(); + struct acpi_table_header *initrd_table; + + initrd_table = acpi_find_dsdt_initrd(); if (initrd_table) *new_table = initrd_table; } -- cgit v1.2.3 From b7143156c9ceee1a072c57aac8729d2dec5b3bf1 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Thu, 7 Feb 2008 04:24:01 -0500 Subject: ACPI: fix build warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/acpi/system.c:360: warning: ignoring return value of ‘sysfs_create_group’, declared with attribute warn_unused_result Signed-off-by: Len Brown --- drivers/acpi/system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/acpi') diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index ce881713f7a..55cf4c05bb7 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -357,8 +357,8 @@ void acpi_irq_stats_init(void) } interrupt_stats_attr_group.attrs = all_attrs; - sysfs_create_group(acpi_kobj, &interrupt_stats_attr_group); - return; + if (!sysfs_create_group(acpi_kobj, &interrupt_stats_attr_group)) + return; fail: delete_gpe_attr_array(); -- cgit v1.2.3