···423 * the global lock appear as a standard mutex on the OS side.424 *425 *****************************************************************************/00426427acpi_status acpi_ev_acquire_global_lock(u16 timeout)428{···437 * Only one thread can acquire the GL at a time, the global_lock_mutex438 * enforces this. This interface releases the interpreter if we must wait.439 */440- status = acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, timeout);0000000000441 if (ACPI_FAILURE(status)) {442 return_ACPI_STATUS(status);443 }000444445 /*446 * Make sure that a global lock actually exists. If not, just treat···521 return_ACPI_STATUS(AE_NOT_ACQUIRED);522 }52300000524 if (acpi_gbl_global_lock_present) {525526 /* Allow any thread to release the lock */···549 acpi_gbl_global_lock_acquired = FALSE;550551 /* Release the local GL mutex */552-0553 acpi_os_release_mutex(acpi_gbl_global_lock_mutex);554 return_ACPI_STATUS(status);555}
···423 * the global lock appear as a standard mutex on the OS side.424 *425 *****************************************************************************/426+static acpi_thread_id acpi_ev_global_lock_thread_id;427+static int acpi_ev_global_lock_acquired;428429acpi_status acpi_ev_acquire_global_lock(u16 timeout)430{···435 * Only one thread can acquire the GL at a time, the global_lock_mutex436 * enforces this. This interface releases the interpreter if we must wait.437 */438+ status = acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, 0);439+ if (status == AE_TIME) {440+ if (acpi_ev_global_lock_thread_id == acpi_os_get_thread_id()) {441+ acpi_ev_global_lock_acquired++;442+ return AE_OK;443+ }444+ }445+446+ if (ACPI_FAILURE(status)) {447+ status = acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex, timeout);448+ }449 if (ACPI_FAILURE(status)) {450 return_ACPI_STATUS(status);451 }452+453+ acpi_ev_global_lock_thread_id = acpi_os_get_thread_id();454+ acpi_ev_global_lock_acquired++;455456 /*457 * Make sure that a global lock actually exists. If not, just treat···506 return_ACPI_STATUS(AE_NOT_ACQUIRED);507 }508509+ acpi_ev_global_lock_acquired--;510+ if (acpi_ev_global_lock_acquired > 0) {511+ return AE_OK;512+ }513+514 if (acpi_gbl_global_lock_present) {515516 /* Allow any thread to release the lock */···529 acpi_gbl_global_lock_acquired = FALSE;530531 /* Release the local GL mutex */532+ acpi_ev_global_lock_thread_id = 0;533+ acpi_ev_global_lock_acquired = 0;534 acpi_os_release_mutex(acpi_gbl_global_lock_mutex);535 return_ACPI_STATUS(status);536}