diff options
Diffstat (limited to 'drivers/acpi/executer/exmutex.c')
-rw-r--r-- | drivers/acpi/executer/exmutex.c | 86 |
1 files changed, 52 insertions, 34 deletions
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index bf90f04f2c60..5101bad5baf8 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c | |||
@@ -6,7 +6,7 @@ | |||
6 | *****************************************************************************/ | 6 | *****************************************************************************/ |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Copyright (C) 2000 - 2006, R. Byron Moore | 9 | * Copyright (C) 2000 - 2007, R. Byron Moore |
10 | * All rights reserved. | 10 | * All rights reserved. |
11 | * | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without |
@@ -44,6 +44,7 @@ | |||
44 | 44 | ||
45 | #include <acpi/acpi.h> | 45 | #include <acpi/acpi.h> |
46 | #include <acpi/acinterp.h> | 46 | #include <acpi/acinterp.h> |
47 | #include <acpi/acevents.h> | ||
47 | 48 | ||
48 | #define _COMPONENT ACPI_EXECUTER | 49 | #define _COMPONENT ACPI_EXECUTER |
49 | ACPI_MODULE_NAME("exmutex") | 50 | ACPI_MODULE_NAME("exmutex") |
@@ -150,7 +151,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
150 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 151 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
151 | } | 152 | } |
152 | 153 | ||
153 | /* Sanity check -- we must have a valid thread ID */ | 154 | /* Sanity check: we must have a valid thread ID */ |
154 | 155 | ||
155 | if (!walk_state->thread) { | 156 | if (!walk_state->thread) { |
156 | ACPI_ERROR((AE_INFO, | 157 | ACPI_ERROR((AE_INFO, |
@@ -174,24 +175,28 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
174 | /* Support for multiple acquires by the owning thread */ | 175 | /* Support for multiple acquires by the owning thread */ |
175 | 176 | ||
176 | if (obj_desc->mutex.owner_thread) { | 177 | if (obj_desc->mutex.owner_thread) { |
177 | 178 | if (obj_desc->mutex.owner_thread->thread_id == | |
178 | /* Special case for Global Lock, allow all threads */ | 179 | walk_state->thread->thread_id) { |
179 | |||
180 | if ((obj_desc->mutex.owner_thread->thread_id == | ||
181 | walk_state->thread->thread_id) || | ||
182 | (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK)) { | ||
183 | /* | 180 | /* |
184 | * The mutex is already owned by this thread, | 181 | * The mutex is already owned by this thread, just increment the |
185 | * just increment the acquisition depth | 182 | * acquisition depth |
186 | */ | 183 | */ |
187 | obj_desc->mutex.acquisition_depth++; | 184 | obj_desc->mutex.acquisition_depth++; |
188 | return_ACPI_STATUS(AE_OK); | 185 | return_ACPI_STATUS(AE_OK); |
189 | } | 186 | } |
190 | } | 187 | } |
191 | 188 | ||
192 | /* Acquire the mutex, wait if necessary */ | 189 | /* Acquire the mutex, wait if necessary. Special case for Global Lock */ |
190 | |||
191 | if (obj_desc->mutex.os_mutex == acpi_gbl_global_lock_mutex) { | ||
192 | status = | ||
193 | acpi_ev_acquire_global_lock((u16) time_desc->integer.value); | ||
194 | } else { | ||
195 | status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex, | ||
196 | (u16) time_desc->integer. | ||
197 | value); | ||
198 | } | ||
193 | 199 | ||
194 | status = acpi_ex_system_acquire_mutex(time_desc, obj_desc); | ||
195 | if (ACPI_FAILURE(status)) { | 200 | if (ACPI_FAILURE(status)) { |
196 | 201 | ||
197 | /* Includes failure from a timeout on time_desc */ | 202 | /* Includes failure from a timeout on time_desc */ |
@@ -211,7 +216,6 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
211 | /* Link the mutex to the current thread for force-unlock at method exit */ | 216 | /* Link the mutex to the current thread for force-unlock at method exit */ |
212 | 217 | ||
213 | acpi_ex_link_mutex(obj_desc, walk_state->thread); | 218 | acpi_ex_link_mutex(obj_desc, walk_state->thread); |
214 | |||
215 | return_ACPI_STATUS(AE_OK); | 219 | return_ACPI_STATUS(AE_OK); |
216 | } | 220 | } |
217 | 221 | ||
@@ -232,7 +236,7 @@ acpi_status | |||
232 | acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | 236 | acpi_ex_release_mutex(union acpi_operand_object *obj_desc, |
233 | struct acpi_walk_state *walk_state) | 237 | struct acpi_walk_state *walk_state) |
234 | { | 238 | { |
235 | acpi_status status; | 239 | acpi_status status = AE_OK; |
236 | 240 | ||
237 | ACPI_FUNCTION_TRACE(ex_release_mutex); | 241 | ACPI_FUNCTION_TRACE(ex_release_mutex); |
238 | 242 | ||
@@ -249,7 +253,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
249 | return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); | 253 | return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); |
250 | } | 254 | } |
251 | 255 | ||
252 | /* Sanity check -- we must have a valid thread ID */ | 256 | /* Sanity check: we must have a valid thread ID */ |
253 | 257 | ||
254 | if (!walk_state->thread) { | 258 | if (!walk_state->thread) { |
255 | ACPI_ERROR((AE_INFO, | 259 | ACPI_ERROR((AE_INFO, |
@@ -264,7 +268,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
264 | */ | 268 | */ |
265 | if ((obj_desc->mutex.owner_thread->thread_id != | 269 | if ((obj_desc->mutex.owner_thread->thread_id != |
266 | walk_state->thread->thread_id) | 270 | walk_state->thread->thread_id) |
267 | && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) { | 271 | && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) { |
268 | ACPI_ERROR((AE_INFO, | 272 | ACPI_ERROR((AE_INFO, |
269 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", | 273 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", |
270 | (unsigned long)walk_state->thread->thread_id, | 274 | (unsigned long)walk_state->thread->thread_id, |
@@ -274,8 +278,8 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
274 | } | 278 | } |
275 | 279 | ||
276 | /* | 280 | /* |
277 | * The sync level of the mutex must be less than or | 281 | * The sync level of the mutex must be less than or equal to the current |
278 | * equal to the current sync level | 282 | * sync level |
279 | */ | 283 | */ |
280 | if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { | 284 | if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { |
281 | ACPI_ERROR((AE_INFO, | 285 | ACPI_ERROR((AE_INFO, |
@@ -298,11 +302,15 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
298 | 302 | ||
299 | acpi_ex_unlink_mutex(obj_desc); | 303 | acpi_ex_unlink_mutex(obj_desc); |
300 | 304 | ||
301 | /* Release the mutex */ | 305 | /* Release the mutex, special case for Global Lock */ |
302 | 306 | ||
303 | status = acpi_ex_system_release_mutex(obj_desc); | 307 | if (obj_desc->mutex.os_mutex == acpi_gbl_global_lock_mutex) { |
308 | status = acpi_ev_release_global_lock(); | ||
309 | } else { | ||
310 | acpi_os_release_mutex(obj_desc->mutex.os_mutex); | ||
311 | } | ||
304 | 312 | ||
305 | /* Update the mutex and walk state, restore sync_level before acquire */ | 313 | /* Update the mutex and restore sync_level */ |
306 | 314 | ||
307 | obj_desc->mutex.owner_thread = NULL; | 315 | obj_desc->mutex.owner_thread = NULL; |
308 | walk_state->thread->current_sync_level = | 316 | walk_state->thread->current_sync_level = |
@@ -321,39 +329,49 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
321 | * | 329 | * |
322 | * DESCRIPTION: Release all mutexes held by this thread | 330 | * DESCRIPTION: Release all mutexes held by this thread |
323 | * | 331 | * |
332 | * NOTE: This function is called as the thread is exiting the interpreter. | ||
333 | * Mutexes are not released when an individual control method is exited, but | ||
334 | * only when the parent thread actually exits the interpreter. This allows one | ||
335 | * method to acquire a mutex, and a different method to release it, as long as | ||
336 | * this is performed underneath a single parent control method. | ||
337 | * | ||
324 | ******************************************************************************/ | 338 | ******************************************************************************/ |
325 | 339 | ||
326 | void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) | 340 | void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) |
327 | { | 341 | { |
328 | union acpi_operand_object *next = thread->acquired_mutex_list; | 342 | union acpi_operand_object *next = thread->acquired_mutex_list; |
329 | union acpi_operand_object *this; | 343 | union acpi_operand_object *obj_desc; |
330 | acpi_status status; | ||
331 | 344 | ||
332 | ACPI_FUNCTION_ENTRY(); | 345 | ACPI_FUNCTION_ENTRY(); |
333 | 346 | ||
334 | /* Traverse the list of owned mutexes, releasing each one */ | 347 | /* Traverse the list of owned mutexes, releasing each one */ |
335 | 348 | ||
336 | while (next) { | 349 | while (next) { |
337 | this = next; | 350 | obj_desc = next; |
338 | next = this->mutex.next; | 351 | next = obj_desc->mutex.next; |
352 | |||
353 | obj_desc->mutex.prev = NULL; | ||
354 | obj_desc->mutex.next = NULL; | ||
355 | obj_desc->mutex.acquisition_depth = 0; | ||
356 | |||
357 | /* Release the mutex, special case for Global Lock */ | ||
339 | 358 | ||
340 | this->mutex.acquisition_depth = 1; | 359 | if (obj_desc->mutex.os_mutex == acpi_gbl_global_lock_mutex) { |
341 | this->mutex.prev = NULL; | ||
342 | this->mutex.next = NULL; | ||
343 | 360 | ||
344 | /* Release the mutex */ | 361 | /* Ignore errors */ |
345 | 362 | ||
346 | status = acpi_ex_system_release_mutex(this); | 363 | (void)acpi_ev_release_global_lock(); |
347 | if (ACPI_FAILURE(status)) { | 364 | } else { |
348 | continue; | 365 | acpi_os_release_mutex(obj_desc->mutex.os_mutex); |
349 | } | 366 | } |
350 | 367 | ||
351 | /* Mark mutex unowned */ | 368 | /* Mark mutex unowned */ |
352 | 369 | ||
353 | this->mutex.owner_thread = NULL; | 370 | obj_desc->mutex.owner_thread = NULL; |
354 | 371 | ||
355 | /* Update Thread sync_level (Last mutex is the important one) */ | 372 | /* Update Thread sync_level (Last mutex is the important one) */ |
356 | 373 | ||
357 | thread->current_sync_level = this->mutex.original_sync_level; | 374 | thread->current_sync_level = |
375 | obj_desc->mutex.original_sync_level; | ||
358 | } | 376 | } |
359 | } | 377 | } |