Skip to content

Commit

Permalink
ACPI: acpi_os_get_thread_id() returns current
Browse files Browse the repository at this point in the history
Linux mutexes and the debug code that that reference
acpi_os_get_thread_id() are happy with 0.
But the AML mutexes in exmutex.c expect a unique non-zero
number for each thread - as they track this thread_id
to permit the mutex re-entrancy defined by the ACPI spec.

http://bugzilla.kernel.org/show_bug.cgi?id=6687

Signed-off-by: Len Brown <[email protected]>
  • Loading branch information
lenb committed Jul 9, 2006
1 parent 120bda2 commit ab8aa06
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions drivers/acpi/executer/exmutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
&& (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) {
ACPI_ERROR((AE_INFO,
"Thread %X cannot release Mutex [%4.4s] acquired by thread %X",
walk_state->thread->thread_id,
(u32) walk_state->thread->thread_id,
acpi_ut_get_node_name(obj_desc->mutex.node),
obj_desc->mutex.owner_thread->thread_id));
(u32) obj_desc->mutex.owner_thread->thread_id));
return_ACPI_STATUS(AE_AML_NOT_OWNER);
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/utilities/utdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
ACPI_MODULE_NAME("utdebug")

#ifdef ACPI_DEBUG_OUTPUT
static u32 acpi_gbl_prev_thread_id = 0xFFFFFFFF;
static acpi_thread_id acpi_gbl_prev_thread_id;
static char *acpi_gbl_fn_entry_str = "----Entry";
static char *acpi_gbl_fn_exit_str = "----Exit-";

Expand Down Expand Up @@ -181,7 +181,7 @@ acpi_ut_debug_print(u32 requested_debug_level,
if (ACPI_LV_THREADS & acpi_dbg_level) {
acpi_os_printf
("\n**** Context Switch from TID %X to TID %X ****\n\n",
acpi_gbl_prev_thread_id, thread_id);
(u32) acpi_gbl_prev_thread_id, (u32) thread_id);
}

acpi_gbl_prev_thread_id = thread_id;
Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/utilities/utmutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,22 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)

ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Thread %X attempting to acquire Mutex [%s]\n",
this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
(u32) this_thread_id, acpi_ut_get_mutex_name(mutex_id)));

status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Thread %X acquired Mutex [%s]\n",
this_thread_id,
(u32) this_thread_id,
acpi_ut_get_mutex_name(mutex_id)));

acpi_gbl_mutex_info[mutex_id].use_count++;
acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
} else {
ACPI_EXCEPTION((AE_INFO, status,
"Thread %X could not acquire Mutex [%X]",
this_thread_id, mutex_id));
(u32) this_thread_id, mutex_id));
}

return (status);
Expand All @@ -285,7 +285,7 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)

this_thread_id = acpi_os_get_thread_id();
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Thread %X releasing Mutex [%s]\n", this_thread_id,
"Thread %X releasing Mutex [%s]\n", (u32) this_thread_id,
acpi_ut_get_mutex_name(mutex_id)));

if (mutex_id > ACPI_MAX_MUTEX) {
Expand Down
2 changes: 1 addition & 1 deletion include/acpi/aclocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ typedef u8 acpi_owner_id;

/* This Thread ID means that the mutex is not in use (unlocked) */

#define ACPI_MUTEX_NOT_ACQUIRED (u32) -1
#define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0

/* Table for the global mutexes */

Expand Down
5 changes: 3 additions & 2 deletions include/acpi/platform/aclinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <asm/acpi.h>
#include <linux/slab.h>
#include <linux/spinlock_types.h>
#include <asm/current.h>

/* Host-dependent types and defines */

Expand Down Expand Up @@ -100,8 +101,8 @@

#define acpi_cpu_flags unsigned long

#define acpi_thread_id u32
#define acpi_thread_id struct task_struct *

static inline acpi_thread_id acpi_os_get_thread_id(void) { return 0; }
static inline acpi_thread_id acpi_os_get_thread_id(void) { return current; }

#endif /* __ACLINUX_H__ */

0 comments on commit ab8aa06

Please sign in to comment.