xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/executer/exmutex.c (revision 71452e98334eaac603bf542d159e24788a46bebb)
1 /******************************************************************************
2  *
3  * Module Name: exmutex - ASL Mutex Acquire/Release functions
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************/
115 
116 #include "acpi.h"
117 #include "accommon.h"
118 #include "acinterp.h"
119 #include "acevents.h"
120 
121 #define _COMPONENT          ACPI_EXECUTER
122         ACPI_MODULE_NAME    ("exmutex")
123 
124 /* Local prototypes */
125 
126 static void
127 AcpiExLinkMutex (
128     ACPI_OPERAND_OBJECT     *ObjDesc,
129     ACPI_THREAD_STATE       *Thread);
130 
131 
132 /*******************************************************************************
133  *
134  * FUNCTION:    AcpiExUnlinkMutex
135  *
136  * PARAMETERS:  ObjDesc             - The mutex to be unlinked
137  *
138  * RETURN:      None
139  *
140  * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
141  *
142  ******************************************************************************/
143 
144 void
145 AcpiExUnlinkMutex (
146     ACPI_OPERAND_OBJECT     *ObjDesc)
147 {
148     ACPI_THREAD_STATE       *Thread = ObjDesc->Mutex.OwnerThread;
149 
150 
151     if (!Thread)
152     {
153         return;
154     }
155 
156     /* Doubly linked list */
157 
158     if (ObjDesc->Mutex.Next)
159     {
160         (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
161     }
162 
163     if (ObjDesc->Mutex.Prev)
164     {
165         (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next;
166 
167         /*
168          * Migrate the previous sync level associated with this mutex to
169          * the previous mutex on the list so that it may be preserved.
170          * This handles the case where several mutexes have been acquired
171          * at the same level, but are not released in opposite order.
172          */
173         (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel =
174             ObjDesc->Mutex.OriginalSyncLevel;
175     }
176     else
177     {
178         Thread->AcquiredMutexList = ObjDesc->Mutex.Next;
179     }
180 }
181 
182 
183 /*******************************************************************************
184  *
185  * FUNCTION:    AcpiExLinkMutex
186  *
187  * PARAMETERS:  ObjDesc             - The mutex to be linked
188  *              Thread              - Current executing thread object
189  *
190  * RETURN:      None
191  *
192  * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
193  *
194  ******************************************************************************/
195 
196 static void
197 AcpiExLinkMutex (
198     ACPI_OPERAND_OBJECT     *ObjDesc,
199     ACPI_THREAD_STATE       *Thread)
200 {
201     ACPI_OPERAND_OBJECT     *ListHead;
202 
203 
204     ListHead = Thread->AcquiredMutexList;
205 
206     /* This object will be the first object in the list */
207 
208     ObjDesc->Mutex.Prev = NULL;
209     ObjDesc->Mutex.Next = ListHead;
210 
211     /* Update old first object to point back to this object */
212 
213     if (ListHead)
214     {
215         ListHead->Mutex.Prev = ObjDesc;
216     }
217 
218     /* Update list head */
219 
220     Thread->AcquiredMutexList = ObjDesc;
221 }
222 
223 
224 /*******************************************************************************
225  *
226  * FUNCTION:    AcpiExAcquireMutexObject
227  *
228  * PARAMETERS:  Timeout             - Timeout in milliseconds
229  *              ObjDesc             - Mutex object
230  *              ThreadId            - Current thread state
231  *
232  * RETURN:      Status
233  *
234  * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
235  *              path that supports multiple acquires by the same thread.
236  *
237  * MUTEX:       Interpreter must be locked
238  *
239  * NOTE: This interface is called from three places:
240  * 1) From AcpiExAcquireMutex, via an AML Acquire() operator
241  * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the
242  *    global lock
243  * 3) From the external interface, AcpiAcquireGlobalLock
244  *
245  ******************************************************************************/
246 
247 ACPI_STATUS
248 AcpiExAcquireMutexObject (
249     UINT16                  Timeout,
250     ACPI_OPERAND_OBJECT     *ObjDesc,
251     ACPI_THREAD_ID          ThreadId)
252 {
253     ACPI_STATUS             Status;
254 
255 
256     ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc);
257 
258 
259     if (!ObjDesc)
260     {
261         return_ACPI_STATUS (AE_BAD_PARAMETER);
262     }
263 
264     /* Support for multiple acquires by the owning thread */
265 
266     if (ObjDesc->Mutex.ThreadId == ThreadId)
267     {
268         /*
269          * The mutex is already owned by this thread, just increment the
270          * acquisition depth
271          */
272         ObjDesc->Mutex.AcquisitionDepth++;
273         return_ACPI_STATUS (AE_OK);
274     }
275 
276     /* Acquire the mutex, wait if necessary. Special case for Global Lock */
277 
278     if (ObjDesc == AcpiGbl_GlobalLockMutex)
279     {
280         Status = AcpiEvAcquireGlobalLock (Timeout);
281     }
282     else
283     {
284         Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, Timeout);
285     }
286 
287     if (ACPI_FAILURE (Status))
288     {
289         /* Includes failure from a timeout on TimeDesc */
290 
291         return_ACPI_STATUS (Status);
292     }
293 
294     /* Acquired the mutex: update mutex object */
295 
296     ObjDesc->Mutex.ThreadId = ThreadId;
297     ObjDesc->Mutex.AcquisitionDepth = 1;
298     ObjDesc->Mutex.OriginalSyncLevel = 0;
299     ObjDesc->Mutex.OwnerThread = NULL;      /* Used only for AML Acquire() */
300 
301     return_ACPI_STATUS (AE_OK);
302 }
303 
304 
305 /*******************************************************************************
306  *
307  * FUNCTION:    AcpiExAcquireMutex
308  *
309  * PARAMETERS:  TimeDesc            - Timeout integer
310  *              ObjDesc             - Mutex object
311  *              WalkState           - Current method execution state
312  *
313  * RETURN:      Status
314  *
315  * DESCRIPTION: Acquire an AML mutex
316  *
317  ******************************************************************************/
318 
319 ACPI_STATUS
320 AcpiExAcquireMutex (
321     ACPI_OPERAND_OBJECT     *TimeDesc,
322     ACPI_OPERAND_OBJECT     *ObjDesc,
323     ACPI_WALK_STATE         *WalkState)
324 {
325     ACPI_STATUS             Status;
326 
327 
328     ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc);
329 
330 
331     if (!ObjDesc)
332     {
333         return_ACPI_STATUS (AE_BAD_PARAMETER);
334     }
335 
336     /* Must have a valid thread state struct */
337 
338     if (!WalkState->Thread)
339     {
340         ACPI_ERROR ((AE_INFO,
341             "Cannot acquire Mutex [%4.4s], null thread info",
342             AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
343         return_ACPI_STATUS (AE_AML_INTERNAL);
344     }
345 
346     /*
347      * Current sync level must be less than or equal to the sync level
348      * of the mutex. This mechanism provides some deadlock prevention.
349      */
350     if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel)
351     {
352         ACPI_ERROR ((AE_INFO,
353             "Cannot acquire Mutex [%4.4s], "
354             "current SyncLevel is too large (%u)",
355             AcpiUtGetNodeName (ObjDesc->Mutex.Node),
356             WalkState->Thread->CurrentSyncLevel));
357         return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
358     }
359 
360     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
361         "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, "
362         "Depth %u TID %p\n",
363         ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
364         ObjDesc->Mutex.AcquisitionDepth, WalkState->Thread));
365 
366     Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value,
367         ObjDesc, WalkState->Thread->ThreadId);
368 
369     if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1)
370     {
371         /* Save Thread object, original/current sync levels */
372 
373         ObjDesc->Mutex.OwnerThread = WalkState->Thread;
374         ObjDesc->Mutex.OriginalSyncLevel =
375             WalkState->Thread->CurrentSyncLevel;
376         WalkState->Thread->CurrentSyncLevel =
377             ObjDesc->Mutex.SyncLevel;
378 
379         /* Link the mutex to the current thread for force-unlock at method exit */
380 
381         AcpiExLinkMutex (ObjDesc, WalkState->Thread);
382     }
383 
384     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
385         "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n",
386         ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
387         ObjDesc->Mutex.AcquisitionDepth));
388 
389     return_ACPI_STATUS (Status);
390 }
391 
392 
393 /*******************************************************************************
394  *
395  * FUNCTION:    AcpiExReleaseMutexObject
396  *
397  * PARAMETERS:  ObjDesc             - The object descriptor for this op
398  *
399  * RETURN:      Status
400  *
401  * DESCRIPTION: Release a previously acquired Mutex, low level interface.
402  *              Provides a common path that supports multiple releases (after
403  *              previous multiple acquires) by the same thread.
404  *
405  * MUTEX:       Interpreter must be locked
406  *
407  * NOTE: This interface is called from three places:
408  * 1) From AcpiExReleaseMutex, via an AML Acquire() operator
409  * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
410  *    global lock
411  * 3) From the external interface, AcpiReleaseGlobalLock
412  *
413  ******************************************************************************/
414 
415 ACPI_STATUS
416 AcpiExReleaseMutexObject (
417     ACPI_OPERAND_OBJECT     *ObjDesc)
418 {
419     ACPI_STATUS             Status = AE_OK;
420 
421 
422     ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
423 
424 
425     if (ObjDesc->Mutex.AcquisitionDepth == 0)
426     {
427         return_ACPI_STATUS (AE_NOT_ACQUIRED);
428     }
429 
430     /* Match multiple Acquires with multiple Releases */
431 
432     ObjDesc->Mutex.AcquisitionDepth--;
433     if (ObjDesc->Mutex.AcquisitionDepth != 0)
434     {
435         /* Just decrement the depth and return */
436 
437         return_ACPI_STATUS (AE_OK);
438     }
439 
440     if (ObjDesc->Mutex.OwnerThread)
441     {
442         /* Unlink the mutex from the owner's list */
443 
444         AcpiExUnlinkMutex (ObjDesc);
445         ObjDesc->Mutex.OwnerThread = NULL;
446     }
447 
448     /* Release the mutex, special case for Global Lock */
449 
450     if (ObjDesc == AcpiGbl_GlobalLockMutex)
451     {
452         Status = AcpiEvReleaseGlobalLock ();
453     }
454     else
455     {
456         AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
457     }
458 
459     /* Clear mutex info */
460 
461     ObjDesc->Mutex.ThreadId = 0;
462     return_ACPI_STATUS (Status);
463 }
464 
465 
466 /*******************************************************************************
467  *
468  * FUNCTION:    AcpiExReleaseMutex
469  *
470  * PARAMETERS:  ObjDesc             - The object descriptor for this op
471  *              WalkState           - Current method execution state
472  *
473  * RETURN:      Status
474  *
475  * DESCRIPTION: Release a previously acquired Mutex.
476  *
477  ******************************************************************************/
478 
479 ACPI_STATUS
480 AcpiExReleaseMutex (
481     ACPI_OPERAND_OBJECT     *ObjDesc,
482     ACPI_WALK_STATE         *WalkState)
483 {
484     UINT8                   PreviousSyncLevel;
485     ACPI_THREAD_STATE       *OwnerThread;
486     ACPI_STATUS             Status = AE_OK;
487 
488 
489     ACPI_FUNCTION_TRACE (ExReleaseMutex);
490 
491 
492     if (!ObjDesc)
493     {
494         return_ACPI_STATUS (AE_BAD_PARAMETER);
495     }
496 
497     OwnerThread = ObjDesc->Mutex.OwnerThread;
498 
499     /* The mutex must have been previously acquired in order to release it */
500 
501     if (!OwnerThread)
502     {
503         ACPI_ERROR ((AE_INFO,
504             "Cannot release Mutex [%4.4s], not acquired",
505             AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
506         return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED);
507     }
508 
509     /* Must have a valid thread ID */
510 
511     if (!WalkState->Thread)
512     {
513         ACPI_ERROR ((AE_INFO,
514             "Cannot release Mutex [%4.4s], null thread info",
515             AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
516         return_ACPI_STATUS (AE_AML_INTERNAL);
517     }
518 
519     /*
520      * The Mutex is owned, but this thread must be the owner.
521      * Special case for Global Lock, any thread can release
522      */
523     if ((OwnerThread->ThreadId != WalkState->Thread->ThreadId) &&
524         (ObjDesc != AcpiGbl_GlobalLockMutex))
525     {
526         ACPI_ERROR ((AE_INFO,
527             "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
528             (UINT32) WalkState->Thread->ThreadId,
529             AcpiUtGetNodeName (ObjDesc->Mutex.Node),
530             (UINT32) OwnerThread->ThreadId));
531         return_ACPI_STATUS (AE_AML_NOT_OWNER);
532     }
533 
534     /*
535      * The sync level of the mutex must be equal to the current sync level. In
536      * other words, the current level means that at least one mutex at that
537      * level is currently being held. Attempting to release a mutex of a
538      * different level can only mean that the mutex ordering rule is being
539      * violated. This behavior is clarified in ACPI 4.0 specification.
540      */
541     if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel)
542     {
543         ACPI_ERROR ((AE_INFO,
544             "Cannot release Mutex [%4.4s], SyncLevel mismatch: "
545             "mutex %u current %u",
546             AcpiUtGetNodeName (ObjDesc->Mutex.Node),
547             ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel));
548         return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
549     }
550 
551     /*
552      * Get the previous SyncLevel from the head of the acquired mutex list.
553      * This handles the case where several mutexes at the same level have been
554      * acquired, but are not released in reverse order.
555      */
556     PreviousSyncLevel =
557         OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel;
558 
559     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
560         "Releasing: Object SyncLevel %u, Thread SyncLevel %u, "
561         "Prev SyncLevel %u, Depth %u TID %p\n",
562         ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
563         PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth,
564         WalkState->Thread));
565 
566     Status = AcpiExReleaseMutexObject (ObjDesc);
567     if (ACPI_FAILURE (Status))
568     {
569         return_ACPI_STATUS (Status);
570     }
571 
572     if (ObjDesc->Mutex.AcquisitionDepth == 0)
573     {
574         /* Restore the previous SyncLevel */
575 
576         OwnerThread->CurrentSyncLevel = PreviousSyncLevel;
577     }
578 
579     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
580         "Released: Object SyncLevel %u, Thread SyncLevel, %u, "
581         "Prev SyncLevel %u, Depth %u\n",
582         ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
583         PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth));
584 
585     return_ACPI_STATUS (Status);
586 }
587 
588 
589 /*******************************************************************************
590  *
591  * FUNCTION:    AcpiExReleaseAllMutexes
592  *
593  * PARAMETERS:  Thread              - Current executing thread object
594  *
595  * RETURN:      Status
596  *
597  * DESCRIPTION: Release all mutexes held by this thread
598  *
599  * NOTE: This function is called as the thread is exiting the interpreter.
600  * Mutexes are not released when an individual control method is exited, but
601  * only when the parent thread actually exits the interpreter. This allows one
602  * method to acquire a mutex, and a different method to release it, as long as
603  * this is performed underneath a single parent control method.
604  *
605  ******************************************************************************/
606 
607 void
608 AcpiExReleaseAllMutexes (
609     ACPI_THREAD_STATE       *Thread)
610 {
611     ACPI_OPERAND_OBJECT     *Next = Thread->AcquiredMutexList;
612     ACPI_OPERAND_OBJECT     *ObjDesc;
613 
614 
615     ACPI_FUNCTION_TRACE (ExReleaseAllMutexes);
616 
617 
618     /* Traverse the list of owned mutexes, releasing each one */
619 
620     while (Next)
621     {
622         ObjDesc = Next;
623         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
624             "Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n",
625             ObjDesc->Mutex.Node->Name.Ascii, ObjDesc->Mutex.SyncLevel,
626             ObjDesc->Mutex.AcquisitionDepth));
627 
628         /* Release the mutex, special case for Global Lock */
629 
630         if (ObjDesc == AcpiGbl_GlobalLockMutex)
631         {
632             /* Ignore errors */
633 
634             (void) AcpiEvReleaseGlobalLock ();
635         }
636         else
637         {
638             AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
639         }
640 
641         /* Update Thread SyncLevel (Last mutex is the important one) */
642 
643         Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;
644 
645         /* Mark mutex unowned */
646 
647         Next = ObjDesc->Mutex.Next;
648 
649         ObjDesc->Mutex.Prev = NULL;
650         ObjDesc->Mutex.Next = NULL;
651         ObjDesc->Mutex.AcquisitionDepth = 0;
652         ObjDesc->Mutex.OwnerThread = NULL;
653         ObjDesc->Mutex.ThreadId = 0;
654     }
655 
656     return_VOID;
657 }
658