Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Module Name: exmutex - ASL Mutex Acquire/Release functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define _COMPONENT          ACPI_EXECUTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) ACPI_MODULE_NAME("exmutex")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		   struct acpi_thread_state *thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * FUNCTION:    acpi_ex_unlink_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * PARAMETERS:  obj_desc            - The mutex to be unlinked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	if (!thread) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/* Doubly linked list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (obj_desc->mutex.next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		(obj_desc->mutex.next)->mutex.prev = obj_desc->mutex.prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	if (obj_desc->mutex.prev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		(obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		 * Migrate the previous sync level associated with this mutex to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		 * the previous mutex on the list so that it may be preserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		 * This handles the case where several mutexes have been acquired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		 * at the same level, but are not released in opposite order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		(obj_desc->mutex.prev)->mutex.original_sync_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		    obj_desc->mutex.original_sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		thread->acquired_mutex_list = obj_desc->mutex.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * FUNCTION:    acpi_ex_link_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * PARAMETERS:  obj_desc            - The mutex to be linked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *              thread              - Current executing thread object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		   struct acpi_thread_state *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	union acpi_operand_object *list_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	list_head = thread->acquired_mutex_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* This object will be the first object in the list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	obj_desc->mutex.prev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	obj_desc->mutex.next = list_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* Update old first object to point back to this object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	if (list_head) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		list_head->mutex.prev = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* Update list head */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	thread->acquired_mutex_list = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * FUNCTION:    acpi_ex_acquire_mutex_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * PARAMETERS:  timeout             - Timeout in milliseconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *              obj_desc            - Mutex object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *              thread_id           - Current thread state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *              path that supports multiple acquires by the same thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * MUTEX:       Interpreter must be locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * NOTE: This interface is called from three places:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  * 1) From acpi_ex_acquire_mutex, via an AML Acquire() operator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * 2) From acpi_ex_acquire_global_lock when an AML Field access requires the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *    global lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * 3) From the external interface, acpi_acquire_global_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) acpi_ex_acquire_mutex_object(u16 timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			     union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			     acpi_thread_id thread_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	ACPI_FUNCTION_TRACE_PTR(ex_acquire_mutex_object, obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	/* Support for multiple acquires by the owning thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (obj_desc->mutex.thread_id == thread_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		 * The mutex is already owned by this thread, just increment the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		 * acquisition depth
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		obj_desc->mutex.acquisition_depth++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	/* Acquire the mutex, wait if necessary. Special case for Global Lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (obj_desc == acpi_gbl_global_lock_mutex) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		status = acpi_ev_acquire_global_lock(timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		    acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 					      timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		/* Includes failure from a timeout on time_desc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	/* Acquired the mutex: update mutex object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	obj_desc->mutex.thread_id = thread_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	obj_desc->mutex.acquisition_depth = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	obj_desc->mutex.original_sync_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	obj_desc->mutex.owner_thread = NULL;	/* Used only for AML Acquire() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * FUNCTION:    acpi_ex_acquire_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * PARAMETERS:  time_desc           - Timeout integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *              obj_desc            - Mutex object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *              walk_state          - Current method execution state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * DESCRIPTION: Acquire an AML mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		      union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		      struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	ACPI_FUNCTION_TRACE_PTR(ex_acquire_mutex, obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	/* Must have a valid thread state struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (!walk_state->thread) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			    "Cannot acquire Mutex [%4.4s], null thread info",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			    acpi_ut_get_node_name(obj_desc->mutex.node)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		return_ACPI_STATUS(AE_AML_INTERNAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 * Current sync level must be less than or equal to the sync level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	 * of the mutex. This mechanism provides some deadlock prevention.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			    "Cannot acquire Mutex [%4.4s], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			    "current SyncLevel is too large (%u)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			    acpi_ut_get_node_name(obj_desc->mutex.node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			    walk_state->thread->current_sync_level));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			  "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			  "Depth %u TID %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			  obj_desc->mutex.sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			  walk_state->thread->current_sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			  obj_desc->mutex.acquisition_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 			  walk_state->thread));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	status = acpi_ex_acquire_mutex_object((u16)time_desc->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 					      obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 					      walk_state->thread->thread_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (ACPI_SUCCESS(status) && obj_desc->mutex.acquisition_depth == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		/* Save Thread object, original/current sync levels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		obj_desc->mutex.owner_thread = walk_state->thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		obj_desc->mutex.original_sync_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		    walk_state->thread->current_sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		walk_state->thread->current_sync_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		    obj_desc->mutex.sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		/* Link the mutex to the current thread for force-unlock at method exit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		acpi_ex_link_mutex(obj_desc, walk_state->thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			  "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			  obj_desc->mutex.sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			  walk_state->thread->current_sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			  obj_desc->mutex.acquisition_depth));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  * FUNCTION:    acpi_ex_release_mutex_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  * PARAMETERS:  obj_desc            - The object descriptor for this op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * DESCRIPTION: Release a previously acquired Mutex, low level interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  *              Provides a common path that supports multiple releases (after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  *              previous multiple acquires) by the same thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  * MUTEX:       Interpreter must be locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * NOTE: This interface is called from three places:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  * 1) From acpi_ex_release_mutex, via an AML Acquire() operator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * 2) From acpi_ex_release_global_lock when an AML Field access requires the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  *    global lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * 3) From the external interface, acpi_release_global_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	ACPI_FUNCTION_TRACE(ex_release_mutex_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	if (obj_desc->mutex.acquisition_depth == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		return_ACPI_STATUS(AE_NOT_ACQUIRED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	/* Match multiple Acquires with multiple Releases */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	obj_desc->mutex.acquisition_depth--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	if (obj_desc->mutex.acquisition_depth != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		/* Just decrement the depth and return */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (obj_desc->mutex.owner_thread) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		/* Unlink the mutex from the owner's list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		acpi_ex_unlink_mutex(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		obj_desc->mutex.owner_thread = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	/* Release the mutex, special case for Global Lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	if (obj_desc == acpi_gbl_global_lock_mutex) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		status = acpi_ev_release_global_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		acpi_os_release_mutex(obj_desc->mutex.os_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	/* Clear mutex info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	obj_desc->mutex.thread_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * FUNCTION:    acpi_ex_release_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * PARAMETERS:  obj_desc            - The object descriptor for this op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  *              walk_state          - Current method execution state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  * DESCRIPTION: Release a previously acquired Mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		      struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	u8 previous_sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	struct acpi_thread_state *owner_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	ACPI_FUNCTION_TRACE(ex_release_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	owner_thread = obj_desc->mutex.owner_thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	/* The mutex must have been previously acquired in order to release it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	if (!owner_thread) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 			    "Cannot release Mutex [%4.4s], not acquired",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 			    acpi_ut_get_node_name(obj_desc->mutex.node)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	/* Must have a valid thread ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	if (!walk_state->thread) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			    "Cannot release Mutex [%4.4s], null thread info",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			    acpi_ut_get_node_name(obj_desc->mutex.node)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		return_ACPI_STATUS(AE_AML_INTERNAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	 * The Mutex is owned, but this thread must be the owner.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	 * Special case for Global Lock, any thread can release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	if ((owner_thread->thread_id != walk_state->thread->thread_id) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	    (obj_desc != acpi_gbl_global_lock_mutex)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			    "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 			    (u32)walk_state->thread->thread_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 			    acpi_ut_get_node_name(obj_desc->mutex.node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 			    (u32)owner_thread->thread_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		return_ACPI_STATUS(AE_AML_NOT_OWNER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	 * The sync level of the mutex must be equal to the current sync level. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	 * other words, the current level means that at least one mutex at that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	 * level is currently being held. Attempting to release a mutex of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	 * different level can only mean that the mutex ordering rule is being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	 * violated. This behavior is clarified in ACPI 4.0 specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	if (obj_desc->mutex.sync_level != owner_thread->current_sync_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			    "Cannot release Mutex [%4.4s], SyncLevel mismatch: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			    "mutex %u current %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			    acpi_ut_get_node_name(obj_desc->mutex.node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			    obj_desc->mutex.sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			    walk_state->thread->current_sync_level));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	 * Get the previous sync_level from the head of the acquired mutex list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	 * This handles the case where several mutexes at the same level have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	 * acquired, but are not released in reverse order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	previous_sync_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	    owner_thread->acquired_mutex_list->mutex.original_sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			  "Releasing: Object SyncLevel %u, Thread SyncLevel %u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 			  "Prev SyncLevel %u, Depth %u TID %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 			  obj_desc->mutex.sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			  walk_state->thread->current_sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			  previous_sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			  obj_desc->mutex.acquisition_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 			  walk_state->thread));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	status = acpi_ex_release_mutex_object(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	if (obj_desc->mutex.acquisition_depth == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		/* Restore the previous sync_level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		owner_thread->current_sync_level = previous_sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 			  "Released: Object SyncLevel %u, Thread SyncLevel, %u, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 			  "Prev SyncLevel %u, Depth %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 			  obj_desc->mutex.sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 			  walk_state->thread->current_sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 			  previous_sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 			  obj_desc->mutex.acquisition_depth));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)  * FUNCTION:    acpi_ex_release_all_mutexes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)  * PARAMETERS:  thread              - Current executing thread object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)  * DESCRIPTION: Release all mutexes held by this thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)  * NOTE: This function is called as the thread is exiting the interpreter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)  * Mutexes are not released when an individual control method is exited, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)  * only when the parent thread actually exits the interpreter. This allows one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)  * method to acquire a mutex, and a different method to release it, as long as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)  * this is performed underneath a single parent control method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	union acpi_operand_object *next = thread->acquired_mutex_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	ACPI_FUNCTION_TRACE(ex_release_all_mutexes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	/* Traverse the list of owned mutexes, releasing each one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	while (next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		obj_desc = next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 				  "Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 				  obj_desc->mutex.node->name.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 				  obj_desc->mutex.sync_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 				  obj_desc->mutex.acquisition_depth));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		/* Release the mutex, special case for Global Lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		if (obj_desc == acpi_gbl_global_lock_mutex) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 			/* Ignore errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			(void)acpi_ev_release_global_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 			acpi_os_release_mutex(obj_desc->mutex.os_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 		/* Update Thread sync_level (Last mutex is the important one) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 		thread->current_sync_level =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		    obj_desc->mutex.original_sync_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		/* Mark mutex unowned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		next = obj_desc->mutex.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		obj_desc->mutex.prev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		obj_desc->mutex.next = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		obj_desc->mutex.acquisition_depth = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		obj_desc->mutex.owner_thread = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		obj_desc->mutex.thread_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }