aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/exmutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpica/exmutex.c')
-rw-r--r--drivers/acpi/acpica/exmutex.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 3c456bd575d0..6af14e43f839 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
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
@@ -85,10 +85,10 @@ void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
85 (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next; 85 (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
86 86
87 /* 87 /*
88 * Migrate the previous sync level associated with this mutex to the 88 * Migrate the previous sync level associated with this mutex to
89 * previous mutex on the list so that it may be preserved. This handles 89 * the previous mutex on the list so that it may be preserved.
90 * the case where several mutexes have been acquired at the same level, 90 * This handles the case where several mutexes have been acquired
91 * but are not released in opposite order. 91 * at the same level, but are not released in opposite order.
92 */ 92 */
93 (obj_desc->mutex.prev)->mutex.original_sync_level = 93 (obj_desc->mutex.prev)->mutex.original_sync_level =
94 obj_desc->mutex.original_sync_level; 94 obj_desc->mutex.original_sync_level;
@@ -101,8 +101,8 @@ void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
101 * 101 *
102 * FUNCTION: acpi_ex_link_mutex 102 * FUNCTION: acpi_ex_link_mutex
103 * 103 *
104 * PARAMETERS: obj_desc - The mutex to be linked 104 * PARAMETERS: obj_desc - The mutex to be linked
105 * Thread - Current executing thread object 105 * Thread - Current executing thread object
106 * 106 *
107 * RETURN: None 107 * RETURN: None
108 * 108 *
@@ -138,9 +138,9 @@ acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
138 * 138 *
139 * FUNCTION: acpi_ex_acquire_mutex_object 139 * FUNCTION: acpi_ex_acquire_mutex_object
140 * 140 *
141 * PARAMETERS: time_desc - Timeout in milliseconds 141 * PARAMETERS: Timeout - Timeout in milliseconds
142 * obj_desc - Mutex object 142 * obj_desc - Mutex object
143 * Thread - Current thread state 143 * thread_id - Current thread state
144 * 144 *
145 * RETURN: Status 145 * RETURN: Status
146 * 146 *
@@ -234,7 +234,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
234 return_ACPI_STATUS(AE_BAD_PARAMETER); 234 return_ACPI_STATUS(AE_BAD_PARAMETER);
235 } 235 }
236 236
237 /* Must have a valid thread ID */ 237 /* Must have a valid thread state struct */
238 238
239 if (!walk_state->thread) { 239 if (!walk_state->thread) {
240 ACPI_ERROR((AE_INFO, 240 ACPI_ERROR((AE_INFO,
@@ -249,7 +249,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
249 */ 249 */
250 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 250 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
251 ACPI_ERROR((AE_INFO, 251 ACPI_ERROR((AE_INFO,
252 "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)", 252 "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%u)",
253 acpi_ut_get_node_name(obj_desc->mutex.node), 253 acpi_ut_get_node_name(obj_desc->mutex.node),
254 walk_state->thread->current_sync_level)); 254 walk_state->thread->current_sync_level));
255 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 255 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
@@ -336,7 +336,7 @@ acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc)
336 336
337 /* Clear mutex info */ 337 /* Clear mutex info */
338 338
339 obj_desc->mutex.thread_id = NULL; 339 obj_desc->mutex.thread_id = 0;
340 return_ACPI_STATUS(status); 340 return_ACPI_STATUS(status);
341} 341}
342 342
@@ -359,6 +359,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
359{ 359{
360 acpi_status status = AE_OK; 360 acpi_status status = AE_OK;
361 u8 previous_sync_level; 361 u8 previous_sync_level;
362 struct acpi_thread_state *owner_thread;
362 363
363 ACPI_FUNCTION_TRACE(ex_release_mutex); 364 ACPI_FUNCTION_TRACE(ex_release_mutex);
364 365
@@ -366,17 +367,18 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
366 return_ACPI_STATUS(AE_BAD_PARAMETER); 367 return_ACPI_STATUS(AE_BAD_PARAMETER);
367 } 368 }
368 369
370 owner_thread = obj_desc->mutex.owner_thread;
371
369 /* The mutex must have been previously acquired in order to release it */ 372 /* The mutex must have been previously acquired in order to release it */
370 373
371 if (!obj_desc->mutex.owner_thread) { 374 if (!owner_thread) {
372 ACPI_ERROR((AE_INFO, 375 ACPI_ERROR((AE_INFO,
373 "Cannot release Mutex [%4.4s], not acquired", 376 "Cannot release Mutex [%4.4s], not acquired",
374 acpi_ut_get_node_name(obj_desc->mutex.node))); 377 acpi_ut_get_node_name(obj_desc->mutex.node)));
375 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); 378 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
376 } 379 }
377 380
378 /* Must have a valid thread ID */ 381 /* Must have a valid thread. */
379
380 if (!walk_state->thread) { 382 if (!walk_state->thread) {
381 ACPI_ERROR((AE_INFO, 383 ACPI_ERROR((AE_INFO,
382 "Cannot release Mutex [%4.4s], null thread info", 384 "Cannot release Mutex [%4.4s], null thread info",
@@ -388,16 +390,13 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
388 * The Mutex is owned, but this thread must be the owner. 390 * The Mutex is owned, but this thread must be the owner.
389 * Special case for Global Lock, any thread can release 391 * Special case for Global Lock, any thread can release
390 */ 392 */
391 if ((obj_desc->mutex.owner_thread->thread_id != 393 if ((owner_thread->thread_id != walk_state->thread->thread_id) &&
392 walk_state->thread->thread_id) 394 (obj_desc != acpi_gbl_global_lock_mutex)) {
393 && (obj_desc != acpi_gbl_global_lock_mutex)) {
394 ACPI_ERROR((AE_INFO, 395 ACPI_ERROR((AE_INFO,
395 "Thread %p cannot release Mutex [%4.4s] acquired by thread %p", 396 "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
396 ACPI_CAST_PTR(void, walk_state->thread->thread_id), 397 (u32)walk_state->thread->thread_id,
397 acpi_ut_get_node_name(obj_desc->mutex.node), 398 acpi_ut_get_node_name(obj_desc->mutex.node),
398 ACPI_CAST_PTR(void, 399 (u32)owner_thread->thread_id));
399 obj_desc->mutex.owner_thread->
400 thread_id)));
401 return_ACPI_STATUS(AE_AML_NOT_OWNER); 400 return_ACPI_STATUS(AE_AML_NOT_OWNER);
402 } 401 }
403 402
@@ -408,10 +407,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
408 * different level can only mean that the mutex ordering rule is being 407 * different level can only mean that the mutex ordering rule is being
409 * violated. This behavior is clarified in ACPI 4.0 specification. 408 * violated. This behavior is clarified in ACPI 4.0 specification.
410 */ 409 */
411 if (obj_desc->mutex.sync_level != 410 if (obj_desc->mutex.sync_level != owner_thread->current_sync_level) {
412 walk_state->thread->current_sync_level) {
413 ACPI_ERROR((AE_INFO, 411 ACPI_ERROR((AE_INFO,
414 "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", 412 "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u",
415 acpi_ut_get_node_name(obj_desc->mutex.node), 413 acpi_ut_get_node_name(obj_desc->mutex.node),
416 obj_desc->mutex.sync_level, 414 obj_desc->mutex.sync_level,
417 walk_state->thread->current_sync_level)); 415 walk_state->thread->current_sync_level));
@@ -424,7 +422,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
424 * acquired, but are not released in reverse order. 422 * acquired, but are not released in reverse order.
425 */ 423 */
426 previous_sync_level = 424 previous_sync_level =
427 walk_state->thread->acquired_mutex_list->mutex.original_sync_level; 425 owner_thread->acquired_mutex_list->mutex.original_sync_level;
428 426
429 status = acpi_ex_release_mutex_object(obj_desc); 427 status = acpi_ex_release_mutex_object(obj_desc);
430 if (ACPI_FAILURE(status)) { 428 if (ACPI_FAILURE(status)) {
@@ -435,8 +433,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
435 433
436 /* Restore the previous sync_level */ 434 /* Restore the previous sync_level */
437 435
438 walk_state->thread->current_sync_level = previous_sync_level; 436 owner_thread->current_sync_level = previous_sync_level;
439 } 437 }
438
440 return_ACPI_STATUS(status); 439 return_ACPI_STATUS(status);
441} 440}
442 441
@@ -444,7 +443,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
444 * 443 *
445 * FUNCTION: acpi_ex_release_all_mutexes 444 * FUNCTION: acpi_ex_release_all_mutexes
446 * 445 *
447 * PARAMETERS: Thread - Current executing thread object 446 * PARAMETERS: Thread - Current executing thread object
448 * 447 *
449 * RETURN: Status 448 * RETURN: Status
450 * 449 *
@@ -489,7 +488,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
489 /* Mark mutex unowned */ 488 /* Mark mutex unowned */
490 489
491 obj_desc->mutex.owner_thread = NULL; 490 obj_desc->mutex.owner_thread = NULL;
492 obj_desc->mutex.thread_id = NULL; 491 obj_desc->mutex.thread_id = 0;
493 492
494 /* Update Thread sync_level (Last mutex is the important one) */ 493 /* Update Thread sync_level (Last mutex is the important one) */
495 494