From ba886cd4ac957608777fbc8d137f6b9f0450e775 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 10 Apr 2008 19:06:37 +0400 Subject: ACPICA: Update for mutiple global lock acquisitions by same thread Allows AcpiAcquireGlobalLock external interface to be called multiple times by the same thread. Allows use of AML fields that require the global lock while the running AML is already holding the global lock. Signed-off-by: Bob Moore Signed-off-by: Alexey Starikovskiy Signed-off-by: Len Brown --- drivers/acpi/events/evxface.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'drivers/acpi/events/evxface.c') diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index 6d866a01f5f..dbf34a5fc1e 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -758,6 +758,12 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_handler) * * DESCRIPTION: Acquire the ACPI Global Lock * + * Note: Allows callers with the same thread ID to acquire the global lock + * multiple times. In other words, externally, the behavior of the global lock + * is identical to an AML mutex. On the first acquire, a new handle is + * returned. On any subsequent calls to acquire by the same thread, the same + * handle is returned. + * ******************************************************************************/ acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle) { @@ -770,14 +776,26 @@ acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle) /* Must lock interpreter to prevent race conditions */ acpi_ex_enter_interpreter(); - status = acpi_ev_acquire_global_lock(timeout); - acpi_ex_exit_interpreter(); + + status = acpi_ex_acquire_mutex_object(timeout, + acpi_gbl_global_lock_mutex, + acpi_os_get_thread_id()); if (ACPI_SUCCESS(status)) { - acpi_gbl_global_lock_handle++; + /* + * If this was the first acquisition of the Global Lock by this thread, + * create a new handle. Otherwise, return the existing handle. + */ + if (acpi_gbl_global_lock_mutex->mutex.acquisition_depth == 1) { + acpi_gbl_global_lock_handle++; + } + + /* Return the global lock handle */ + *handle = acpi_gbl_global_lock_handle; } + acpi_ex_exit_interpreter(); return (status); } @@ -802,7 +820,7 @@ acpi_status acpi_release_global_lock(u32 handle) return (AE_NOT_ACQUIRED); } - status = acpi_ev_release_global_lock(); + status = acpi_ex_release_mutex_object(acpi_gbl_global_lock_mutex); return (status); } -- cgit v1.2.3