diff options
Diffstat (limited to 'drivers/acpi/events/evmisc.c')
-rw-r--r-- | drivers/acpi/events/evmisc.c | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 21cb749d0c75..2113e58e2221 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c | |||
@@ -5,7 +5,7 @@ | |||
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | * Copyright (C) 2000 - 2007, R. Byron Moore | 8 | * Copyright (C) 2000 - 2008, Intel Corp. |
9 | * All rights reserved. | 9 | * All rights reserved. |
10 | * | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
@@ -49,22 +49,7 @@ | |||
49 | #define _COMPONENT ACPI_EVENTS | 49 | #define _COMPONENT ACPI_EVENTS |
50 | ACPI_MODULE_NAME("evmisc") | 50 | ACPI_MODULE_NAME("evmisc") |
51 | 51 | ||
52 | /* Names for Notify() values, used for debug output */ | ||
53 | #ifdef ACPI_DEBUG_OUTPUT | ||
54 | static const char *acpi_notify_value_names[] = { | ||
55 | "Bus Check", | ||
56 | "Device Check", | ||
57 | "Device Wake", | ||
58 | "Eject Request", | ||
59 | "Device Check Light", | ||
60 | "Frequency Mismatch", | ||
61 | "Bus Mode Mismatch", | ||
62 | "Power Fault" | ||
63 | }; | ||
64 | #endif | ||
65 | |||
66 | /* Pointer to FACS needed for the Global Lock */ | 52 | /* Pointer to FACS needed for the Global Lock */ |
67 | |||
68 | static struct acpi_table_facs *facs = NULL; | 53 | static struct acpi_table_facs *facs = NULL; |
69 | 54 | ||
70 | /* Local prototypes */ | 55 | /* Local prototypes */ |
@@ -94,7 +79,6 @@ u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node) | |||
94 | switch (node->type) { | 79 | switch (node->type) { |
95 | case ACPI_TYPE_DEVICE: | 80 | case ACPI_TYPE_DEVICE: |
96 | case ACPI_TYPE_PROCESSOR: | 81 | case ACPI_TYPE_PROCESSOR: |
97 | case ACPI_TYPE_POWER: | ||
98 | case ACPI_TYPE_THERMAL: | 82 | case ACPI_TYPE_THERMAL: |
99 | /* | 83 | /* |
100 | * These are the ONLY objects that can receive ACPI notifications | 84 | * These are the ONLY objects that can receive ACPI notifications |
@@ -139,17 +123,9 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
139 | * initiate soft-off or sleep operation? | 123 | * initiate soft-off or sleep operation? |
140 | */ | 124 | */ |
141 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 125 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
142 | "Dispatching Notify(%X) on node %p\n", notify_value, | 126 | "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", |
143 | node)); | 127 | acpi_ut_get_node_name(node), node, notify_value, |
144 | 128 | acpi_ut_get_notify_name(notify_value))); | |
145 | if (notify_value <= 7) { | ||
146 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notify value: %s\n", | ||
147 | acpi_notify_value_names[notify_value])); | ||
148 | } else { | ||
149 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
150 | "Notify value: 0x%2.2X **Device Specific**\n", | ||
151 | notify_value)); | ||
152 | } | ||
153 | 129 | ||
154 | /* Get the notify object attached to the NS Node */ | 130 | /* Get the notify object attached to the NS Node */ |
155 | 131 | ||
@@ -159,10 +135,12 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
159 | /* We have the notify object, Get the right handler */ | 135 | /* We have the notify object, Get the right handler */ |
160 | 136 | ||
161 | switch (node->type) { | 137 | switch (node->type) { |
138 | |||
139 | /* Notify allowed only on these types */ | ||
140 | |||
162 | case ACPI_TYPE_DEVICE: | 141 | case ACPI_TYPE_DEVICE: |
163 | case ACPI_TYPE_THERMAL: | 142 | case ACPI_TYPE_THERMAL: |
164 | case ACPI_TYPE_PROCESSOR: | 143 | case ACPI_TYPE_PROCESSOR: |
165 | case ACPI_TYPE_POWER: | ||
166 | 144 | ||
167 | if (notify_value <= ACPI_MAX_SYS_NOTIFY) { | 145 | if (notify_value <= ACPI_MAX_SYS_NOTIFY) { |
168 | handler_obj = | 146 | handler_obj = |
@@ -179,8 +157,13 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
179 | } | 157 | } |
180 | } | 158 | } |
181 | 159 | ||
182 | /* If there is any handler to run, schedule the dispatcher */ | 160 | /* |
183 | 161 | * If there is any handler to run, schedule the dispatcher. | |
162 | * Check for: | ||
163 | * 1) Global system notify handler | ||
164 | * 2) Global device notify handler | ||
165 | * 3) Per-device notify handler | ||
166 | */ | ||
184 | if ((acpi_gbl_system_notify.handler | 167 | if ((acpi_gbl_system_notify.handler |
185 | && (notify_value <= ACPI_MAX_SYS_NOTIFY)) | 168 | && (notify_value <= ACPI_MAX_SYS_NOTIFY)) |
186 | || (acpi_gbl_device_notify.handler | 169 | || (acpi_gbl_device_notify.handler |
@@ -190,6 +173,13 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
190 | return (AE_NO_MEMORY); | 173 | return (AE_NO_MEMORY); |
191 | } | 174 | } |
192 | 175 | ||
176 | if (!handler_obj) { | ||
177 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
178 | "Executing system notify handler for Notify (%4.4s, %X) node %p\n", | ||
179 | acpi_ut_get_node_name(node), | ||
180 | notify_value, node)); | ||
181 | } | ||
182 | |||
193 | notify_info->common.descriptor_type = | 183 | notify_info->common.descriptor_type = |
194 | ACPI_DESC_TYPE_STATE_NOTIFY; | 184 | ACPI_DESC_TYPE_STATE_NOTIFY; |
195 | notify_info->notify.node = node; | 185 | notify_info->notify.node = node; |
@@ -202,15 +192,12 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
202 | if (ACPI_FAILURE(status)) { | 192 | if (ACPI_FAILURE(status)) { |
203 | acpi_ut_delete_generic_state(notify_info); | 193 | acpi_ut_delete_generic_state(notify_info); |
204 | } | 194 | } |
205 | } | 195 | } else { |
206 | |||
207 | if (!handler_obj) { | ||
208 | /* | 196 | /* |
209 | * There is no per-device notify handler for this device. | 197 | * There is no notify handler (per-device or system) for this device. |
210 | * This may or may not be a problem. | ||
211 | */ | 198 | */ |
212 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 199 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
213 | "No notify handler for Notify(%4.4s, %X) node %p\n", | 200 | "No notify handler for Notify (%4.4s, %X) node %p\n", |
214 | acpi_ut_get_node_name(node), notify_value, | 201 | acpi_ut_get_node_name(node), notify_value, |
215 | node)); | 202 | node)); |
216 | } | 203 | } |
@@ -349,9 +336,10 @@ acpi_status acpi_ev_init_global_lock_handler(void) | |||
349 | 336 | ||
350 | ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); | 337 | ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); |
351 | 338 | ||
352 | status = | 339 | status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, |
353 | acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, | 340 | ACPI_CAST_INDIRECT_PTR(struct |
354 | (struct acpi_table_header **)&facs); | 341 | acpi_table_header, |
342 | &facs)); | ||
355 | if (ACPI_FAILURE(status)) { | 343 | if (ACPI_FAILURE(status)) { |
356 | return_ACPI_STATUS(status); | 344 | return_ACPI_STATUS(status); |
357 | } | 345 | } |
@@ -439,7 +427,8 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
439 | * Only one thread can acquire the GL at a time, the global_lock_mutex | 427 | * Only one thread can acquire the GL at a time, the global_lock_mutex |
440 | * enforces this. This interface releases the interpreter if we must wait. | 428 | * enforces this. This interface releases the interpreter if we must wait. |
441 | */ | 429 | */ |
442 | status = acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, 0); | 430 | status = acpi_ex_system_wait_mutex( |
431 | acpi_gbl_global_lock_mutex->mutex.os_mutex, 0); | ||
443 | if (status == AE_TIME) { | 432 | if (status == AE_TIME) { |
444 | if (acpi_ev_global_lock_thread_id == acpi_os_get_thread_id()) { | 433 | if (acpi_ev_global_lock_thread_id == acpi_os_get_thread_id()) { |
445 | acpi_ev_global_lock_acquired++; | 434 | acpi_ev_global_lock_acquired++; |
@@ -448,9 +437,9 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
448 | } | 437 | } |
449 | 438 | ||
450 | if (ACPI_FAILURE(status)) { | 439 | if (ACPI_FAILURE(status)) { |
451 | status = | 440 | status = acpi_ex_system_wait_mutex( |
452 | acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, | 441 | acpi_gbl_global_lock_mutex->mutex.os_mutex, |
453 | timeout); | 442 | timeout); |
454 | } | 443 | } |
455 | if (ACPI_FAILURE(status)) { | 444 | if (ACPI_FAILURE(status)) { |
456 | return_ACPI_STATUS(status); | 445 | return_ACPI_STATUS(status); |
@@ -460,6 +449,19 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
460 | acpi_ev_global_lock_acquired++; | 449 | acpi_ev_global_lock_acquired++; |
461 | 450 | ||
462 | /* | 451 | /* |
452 | * Update the global lock handle and check for wraparound. The handle is | ||
453 | * only used for the external global lock interfaces, but it is updated | ||
454 | * here to properly handle the case where a single thread may acquire the | ||
455 | * lock via both the AML and the acpi_acquire_global_lock interfaces. The | ||
456 | * handle is therefore updated on the first acquire from a given thread | ||
457 | * regardless of where the acquisition request originated. | ||
458 | */ | ||
459 | acpi_gbl_global_lock_handle++; | ||
460 | if (acpi_gbl_global_lock_handle == 0) { | ||
461 | acpi_gbl_global_lock_handle = 1; | ||
462 | } | ||
463 | |||
464 | /* | ||
463 | * Make sure that a global lock actually exists. If not, just treat | 465 | * Make sure that a global lock actually exists. If not, just treat |
464 | * the lock as a standard mutex. | 466 | * the lock as a standard mutex. |
465 | */ | 467 | */ |
@@ -555,7 +557,7 @@ acpi_status acpi_ev_release_global_lock(void) | |||
555 | /* Release the local GL mutex */ | 557 | /* Release the local GL mutex */ |
556 | acpi_ev_global_lock_thread_id = NULL; | 558 | acpi_ev_global_lock_thread_id = NULL; |
557 | acpi_ev_global_lock_acquired = 0; | 559 | acpi_ev_global_lock_acquired = 0; |
558 | acpi_os_release_mutex(acpi_gbl_global_lock_mutex); | 560 | acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); |
559 | return_ACPI_STATUS(status); | 561 | return_ACPI_STATUS(status); |
560 | } | 562 | } |
561 | 563 | ||