6
6
*****************************************************************************/
9
* Copyright (C) 2000 - 2008, Intel Corp.
9
* Copyright (C) 2000 - 2011, Intel Corp.
10
10
* All rights reserved.
12
12
* Redistribution and use in source and binary forms, with or without
85
85
(obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
88
* Migrate the previous sync level associated with this mutex to the
89
* previous mutex on the list so that it may be preserved. This handles
90
* the case where several mutexes have been acquired at the same level,
91
* but are not released in opposite order.
88
* Migrate the previous sync level associated with this mutex to
89
* the previous mutex on the list so that it may be preserved.
90
* This handles the case where several mutexes have been acquired
91
* at the same level, but are not released in opposite order.
93
93
(obj_desc->mutex.prev)->mutex.original_sync_level =
94
94
obj_desc->mutex.original_sync_level;
102
102
* FUNCTION: acpi_ex_link_mutex
104
* PARAMETERS: obj_desc - The mutex to be linked
105
* Thread - Current executing thread object
104
* PARAMETERS: obj_desc - The mutex to be linked
105
* Thread - Current executing thread object
139
139
* FUNCTION: acpi_ex_acquire_mutex_object
141
* PARAMETERS: time_desc - Timeout in milliseconds
141
* PARAMETERS: Timeout - Timeout in milliseconds
142
142
* obj_desc - Mutex object
143
* Thread - Current thread state
143
* thread_id - Current thread state
250
250
if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
251
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
253
acpi_ut_get_node_name(obj_desc->mutex.node),
254
254
walk_state->thread->current_sync_level));
255
255
return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
366
367
return_ACPI_STATUS(AE_BAD_PARAMETER);
370
owner_thread = obj_desc->mutex.owner_thread;
369
372
/* The mutex must have been previously acquired in order to release it */
371
if (!obj_desc->mutex.owner_thread) {
372
375
ACPI_ERROR((AE_INFO,
373
376
"Cannot release Mutex [%4.4s], not acquired",
374
377
acpi_ut_get_node_name(obj_desc->mutex.node)));
375
378
return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
381
/* Must have a valid thread. */
382
if (!walk_state->thread) {
384
"Cannot release Mutex [%4.4s], null thread info",
385
acpi_ut_get_node_name(obj_desc->mutex.node)));
386
return_ACPI_STATUS(AE_AML_INTERNAL);
379
390
* The Mutex is owned, but this thread must be the owner.
380
391
* Special case for Global Lock, any thread can release
382
if ((obj_desc->mutex.owner_thread->thread_id !=
383
walk_state->thread->thread_id)
384
&& (obj_desc != acpi_gbl_global_lock_mutex)) {
393
if ((owner_thread->thread_id != walk_state->thread->thread_id) &&
394
(obj_desc != acpi_gbl_global_lock_mutex)) {
385
395
ACPI_ERROR((AE_INFO,
386
"Thread %p cannot release Mutex [%4.4s] acquired by thread %p",
387
ACPI_CAST_PTR(void, walk_state->thread->thread_id),
396
"Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
397
(u32)walk_state->thread->thread_id,
388
398
acpi_ut_get_node_name(obj_desc->mutex.node),
390
obj_desc->mutex.owner_thread->
399
(u32)owner_thread->thread_id));
392
400
return_ACPI_STATUS(AE_AML_NOT_OWNER);
395
/* Must have a valid thread ID */
397
if (!walk_state->thread) {
399
"Cannot release Mutex [%4.4s], null thread info",
400
acpi_ut_get_node_name(obj_desc->mutex.node)));
401
return_ACPI_STATUS(AE_AML_INTERNAL);
405
404
* The sync level of the mutex must be equal to the current sync level. In
406
405
* other words, the current level means that at least one mutex at that
408
407
* different level can only mean that the mutex ordering rule is being
409
408
* violated. This behavior is clarified in ACPI 4.0 specification.
411
if (obj_desc->mutex.sync_level !=
412
walk_state->thread->current_sync_level) {
410
if (obj_desc->mutex.sync_level != owner_thread->current_sync_level) {
413
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
413
acpi_ut_get_node_name(obj_desc->mutex.node),
416
414
obj_desc->mutex.sync_level,
417
415
walk_state->thread->current_sync_level));
424
422
* acquired, but are not released in reverse order.
426
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;
429
427
status = acpi_ex_release_mutex_object(obj_desc);
430
428
if (ACPI_FAILURE(status)) {