xref: /onnv-gate/usr/src/uts/intel/io/acpica/utilities/utmutex.c (revision 9980:13d7f3eec672)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: utmutex - local mutex support
43446Smrj  *
53446Smrj  ******************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj 
1173446Smrj #define __UTMUTEX_C__
1183446Smrj 
1193446Smrj #include "acpi.h"
120*9980SDana.Myers@Sun.COM #include "accommon.h"
1213446Smrj 
1223446Smrj #define _COMPONENT          ACPI_UTILITIES
1233446Smrj         ACPI_MODULE_NAME    ("utmutex")
1243446Smrj 
1253446Smrj /* Local prototypes */
1263446Smrj 
1273446Smrj static ACPI_STATUS
1283446Smrj AcpiUtCreateMutex (
1293446Smrj     ACPI_MUTEX_HANDLE       MutexId);
1303446Smrj 
1313446Smrj static ACPI_STATUS
1323446Smrj AcpiUtDeleteMutex (
1333446Smrj     ACPI_MUTEX_HANDLE       MutexId);
1343446Smrj 
1353446Smrj 
1363446Smrj /*******************************************************************************
1373446Smrj  *
1383446Smrj  * FUNCTION:    AcpiUtMutexInitialize
1393446Smrj  *
1403446Smrj  * PARAMETERS:  None.
1413446Smrj  *
1423446Smrj  * RETURN:      Status
1433446Smrj  *
144*9980SDana.Myers@Sun.COM  * DESCRIPTION: Create the system mutex objects. This includes mutexes,
145*9980SDana.Myers@Sun.COM  *              spin locks, and reader/writer locks.
1463446Smrj  *
1473446Smrj  ******************************************************************************/
1483446Smrj 
1493446Smrj ACPI_STATUS
AcpiUtMutexInitialize(void)1503446Smrj AcpiUtMutexInitialize (
1513446Smrj     void)
1523446Smrj {
1533446Smrj     UINT32                  i;
1543446Smrj     ACPI_STATUS             Status;
1553446Smrj 
1563446Smrj 
1573446Smrj     ACPI_FUNCTION_TRACE (UtMutexInitialize);
1583446Smrj 
1593446Smrj 
160*9980SDana.Myers@Sun.COM     /* Create each of the predefined mutex objects */
161*9980SDana.Myers@Sun.COM 
1623446Smrj     for (i = 0; i < ACPI_NUM_MUTEX; i++)
1633446Smrj     {
1643446Smrj         Status = AcpiUtCreateMutex (i);
1653446Smrj         if (ACPI_FAILURE (Status))
1663446Smrj         {
1673446Smrj             return_ACPI_STATUS (Status);
1683446Smrj         }
1693446Smrj     }
1703446Smrj 
1713446Smrj     /* Create the spinlocks for use at interrupt level */
1723446Smrj 
1733446Smrj     Status = AcpiOsCreateLock (&AcpiGbl_GpeLock);
1743446Smrj     if (ACPI_FAILURE (Status))
1753446Smrj     {
1763446Smrj         return_ACPI_STATUS (Status);
1773446Smrj     }
1783446Smrj 
1793446Smrj     Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock);
180*9980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
181*9980SDana.Myers@Sun.COM     {
182*9980SDana.Myers@Sun.COM         return_ACPI_STATUS (Status);
183*9980SDana.Myers@Sun.COM     }
184*9980SDana.Myers@Sun.COM 
185*9980SDana.Myers@Sun.COM     /* Create the reader/writer lock for namespace access */
186*9980SDana.Myers@Sun.COM 
187*9980SDana.Myers@Sun.COM     Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock);
1883446Smrj     return_ACPI_STATUS (Status);
1893446Smrj }
1903446Smrj 
1913446Smrj 
1923446Smrj /*******************************************************************************
1933446Smrj  *
1943446Smrj  * FUNCTION:    AcpiUtMutexTerminate
1953446Smrj  *
1963446Smrj  * PARAMETERS:  None.
1973446Smrj  *
1983446Smrj  * RETURN:      None.
1993446Smrj  *
200*9980SDana.Myers@Sun.COM  * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes,
201*9980SDana.Myers@Sun.COM  *              spin locks, and reader/writer locks.
2023446Smrj  *
2033446Smrj  ******************************************************************************/
2043446Smrj 
2053446Smrj void
AcpiUtMutexTerminate(void)2063446Smrj AcpiUtMutexTerminate (
2073446Smrj     void)
2083446Smrj {
2093446Smrj     UINT32                  i;
2103446Smrj 
2113446Smrj 
2123446Smrj     ACPI_FUNCTION_TRACE (UtMutexTerminate);
2133446Smrj 
2143446Smrj 
215*9980SDana.Myers@Sun.COM     /* Delete each predefined mutex object */
216*9980SDana.Myers@Sun.COM 
2173446Smrj     for (i = 0; i < ACPI_NUM_MUTEX; i++)
2183446Smrj     {
2193446Smrj         (void) AcpiUtDeleteMutex (i);
2203446Smrj     }
2213446Smrj 
2223446Smrj     /* Delete the spinlocks */
2233446Smrj 
2243446Smrj     AcpiOsDeleteLock (AcpiGbl_GpeLock);
2253446Smrj     AcpiOsDeleteLock (AcpiGbl_HardwareLock);
226*9980SDana.Myers@Sun.COM 
227*9980SDana.Myers@Sun.COM     /* Delete the reader/writer lock */
228*9980SDana.Myers@Sun.COM 
229*9980SDana.Myers@Sun.COM     AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
2303446Smrj     return_VOID;
2313446Smrj }
2323446Smrj 
2333446Smrj 
2343446Smrj /*******************************************************************************
2353446Smrj  *
2363446Smrj  * FUNCTION:    AcpiUtCreateMutex
2373446Smrj  *
2383446Smrj  * PARAMETERS:  MutexID         - ID of the mutex to be created
2393446Smrj  *
2403446Smrj  * RETURN:      Status
2413446Smrj  *
2423446Smrj  * DESCRIPTION: Create a mutex object.
2433446Smrj  *
2443446Smrj  ******************************************************************************/
2453446Smrj 
2463446Smrj static ACPI_STATUS
AcpiUtCreateMutex(ACPI_MUTEX_HANDLE MutexId)2473446Smrj AcpiUtCreateMutex (
2483446Smrj     ACPI_MUTEX_HANDLE       MutexId)
2493446Smrj {
2503446Smrj     ACPI_STATUS             Status = AE_OK;
2513446Smrj 
2523446Smrj 
2533446Smrj     ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId);
2543446Smrj 
2553446Smrj 
2563446Smrj     if (MutexId > ACPI_MAX_MUTEX)
2573446Smrj     {
2583446Smrj         return_ACPI_STATUS (AE_BAD_PARAMETER);
2593446Smrj     }
2603446Smrj 
2613446Smrj     if (!AcpiGbl_MutexInfo[MutexId].Mutex)
2623446Smrj     {
2633446Smrj         Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex);
2643446Smrj         AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
2653446Smrj         AcpiGbl_MutexInfo[MutexId].UseCount = 0;
2663446Smrj     }
2673446Smrj 
2683446Smrj     return_ACPI_STATUS (Status);
2693446Smrj }
2703446Smrj 
2713446Smrj 
2723446Smrj /*******************************************************************************
2733446Smrj  *
2743446Smrj  * FUNCTION:    AcpiUtDeleteMutex
2753446Smrj  *
2763446Smrj  * PARAMETERS:  MutexID         - ID of the mutex to be deleted
2773446Smrj  *
2783446Smrj  * RETURN:      Status
2793446Smrj  *
2803446Smrj  * DESCRIPTION: Delete a mutex object.
2813446Smrj  *
2823446Smrj  ******************************************************************************/
2833446Smrj 
2843446Smrj static ACPI_STATUS
AcpiUtDeleteMutex(ACPI_MUTEX_HANDLE MutexId)2853446Smrj AcpiUtDeleteMutex (
2863446Smrj     ACPI_MUTEX_HANDLE       MutexId)
2873446Smrj {
2883446Smrj 
2893446Smrj     ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId);
2903446Smrj 
2913446Smrj 
2923446Smrj     if (MutexId > ACPI_MAX_MUTEX)
2933446Smrj     {
2943446Smrj         return_ACPI_STATUS (AE_BAD_PARAMETER);
2953446Smrj     }
2963446Smrj 
2973446Smrj     AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
2983446Smrj 
2993446Smrj     AcpiGbl_MutexInfo[MutexId].Mutex = NULL;
3003446Smrj     AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
3013446Smrj 
3023446Smrj     return_ACPI_STATUS (AE_OK);
3033446Smrj }
3043446Smrj 
3053446Smrj 
3063446Smrj /*******************************************************************************
3073446Smrj  *
3083446Smrj  * FUNCTION:    AcpiUtAcquireMutex
3093446Smrj  *
3103446Smrj  * PARAMETERS:  MutexID         - ID of the mutex to be acquired
3113446Smrj  *
3123446Smrj  * RETURN:      Status
3133446Smrj  *
3143446Smrj  * DESCRIPTION: Acquire a mutex object.
3153446Smrj  *
3163446Smrj  ******************************************************************************/
3173446Smrj 
3183446Smrj ACPI_STATUS
AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)3193446Smrj AcpiUtAcquireMutex (
3203446Smrj     ACPI_MUTEX_HANDLE       MutexId)
3213446Smrj {
3223446Smrj     ACPI_STATUS             Status;
3233446Smrj     ACPI_THREAD_ID          ThisThreadId;
3243446Smrj 
3253446Smrj 
3263446Smrj     ACPI_FUNCTION_NAME (UtAcquireMutex);
3273446Smrj 
3283446Smrj 
3293446Smrj     if (MutexId > ACPI_MAX_MUTEX)
3303446Smrj     {
3313446Smrj         return (AE_BAD_PARAMETER);
3323446Smrj     }
3333446Smrj 
3343446Smrj     ThisThreadId = AcpiOsGetThreadId ();
3353446Smrj 
3363446Smrj #ifdef ACPI_MUTEX_DEBUG
3373446Smrj     {
3383446Smrj         UINT32                  i;
3393446Smrj         /*
3403446Smrj          * Mutex debug code, for internal debugging only.
3413446Smrj          *
3423446Smrj          * Deadlock prevention.  Check if this thread owns any mutexes of value
3433446Smrj          * greater than or equal to this one.  If so, the thread has violated
3443446Smrj          * the mutex ordering rule.  This indicates a coding error somewhere in
3453446Smrj          * the ACPI subsystem code.
3463446Smrj          */
3477851SDana.Myers@Sun.COM         for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
3483446Smrj         {
3493446Smrj             if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
3503446Smrj             {
3513446Smrj                 if (i == MutexId)
3523446Smrj                 {
3533446Smrj                     ACPI_ERROR ((AE_INFO,
354*9980SDana.Myers@Sun.COM                         "Mutex [%s] already acquired by this thread [%p]",
355*9980SDana.Myers@Sun.COM                         AcpiUtGetMutexName (MutexId),
356*9980SDana.Myers@Sun.COM                         ACPI_CAST_PTR (void, ThisThreadId)));
3573446Smrj 
3583446Smrj                     return (AE_ALREADY_ACQUIRED);
3593446Smrj                 }
3603446Smrj 
3613446Smrj                 ACPI_ERROR ((AE_INFO,
362*9980SDana.Myers@Sun.COM                     "Invalid acquire order: Thread %p owns [%s], wants [%s]",
363*9980SDana.Myers@Sun.COM                     ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i),
3643446Smrj                     AcpiUtGetMutexName (MutexId)));
3653446Smrj 
3663446Smrj                 return (AE_ACQUIRE_DEADLOCK);
3673446Smrj             }
3683446Smrj         }
3693446Smrj     }
3703446Smrj #endif
3713446Smrj 
3723446Smrj     ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
373*9980SDana.Myers@Sun.COM         "Thread %p attempting to acquire Mutex [%s]\n",
374*9980SDana.Myers@Sun.COM         ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId)));
3753446Smrj 
3763446Smrj     Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex,
3773446Smrj                 ACPI_WAIT_FOREVER);
3783446Smrj     if (ACPI_SUCCESS (Status))
3793446Smrj     {
380*9980SDana.Myers@Sun.COM         ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n",
381*9980SDana.Myers@Sun.COM             ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId)));
3823446Smrj 
3833446Smrj         AcpiGbl_MutexInfo[MutexId].UseCount++;
3843446Smrj         AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId;
3853446Smrj     }
3863446Smrj     else
3873446Smrj     {
3883446Smrj         ACPI_EXCEPTION ((AE_INFO, Status,
389*9980SDana.Myers@Sun.COM             "Thread %p could not acquire Mutex [%X]",
390*9980SDana.Myers@Sun.COM             ACPI_CAST_PTR (void, ThisThreadId), MutexId));
3913446Smrj     }
3923446Smrj 
3933446Smrj     return (Status);
3943446Smrj }
3953446Smrj 
3963446Smrj 
3973446Smrj /*******************************************************************************
3983446Smrj  *
3993446Smrj  * FUNCTION:    AcpiUtReleaseMutex
4003446Smrj  *
4013446Smrj  * PARAMETERS:  MutexID         - ID of the mutex to be released
4023446Smrj  *
4033446Smrj  * RETURN:      Status
4043446Smrj  *
4053446Smrj  * DESCRIPTION: Release a mutex object.
4063446Smrj  *
4073446Smrj  ******************************************************************************/
4083446Smrj 
4093446Smrj ACPI_STATUS
AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)4103446Smrj AcpiUtReleaseMutex (
4113446Smrj     ACPI_MUTEX_HANDLE       MutexId)
4123446Smrj {
4133446Smrj     ACPI_THREAD_ID          ThisThreadId;
4143446Smrj 
4153446Smrj 
4163446Smrj     ACPI_FUNCTION_NAME (UtReleaseMutex);
4173446Smrj 
4183446Smrj 
4193446Smrj     ThisThreadId = AcpiOsGetThreadId ();
420*9980SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n",
421*9980SDana.Myers@Sun.COM         ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId)));
4223446Smrj 
4233446Smrj     if (MutexId > ACPI_MAX_MUTEX)
4243446Smrj     {
4253446Smrj         return (AE_BAD_PARAMETER);
4263446Smrj     }
4273446Smrj 
4283446Smrj     /*
4293446Smrj      * Mutex must be acquired in order to release it!
4303446Smrj      */
4313446Smrj     if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED)
4323446Smrj     {
4333446Smrj         ACPI_ERROR ((AE_INFO,
4343446Smrj             "Mutex [%X] is not acquired, cannot release", MutexId));
4353446Smrj 
4363446Smrj         return (AE_NOT_ACQUIRED);
4373446Smrj     }
4383446Smrj 
4393446Smrj #ifdef ACPI_MUTEX_DEBUG
4403446Smrj     {
4413446Smrj         UINT32                  i;
4423446Smrj         /*
4433446Smrj          * Mutex debug code, for internal debugging only.
4443446Smrj          *
4453446Smrj          * Deadlock prevention.  Check if this thread owns any mutexes of value
4463446Smrj          * greater than this one.  If so, the thread has violated the mutex
4473446Smrj          * ordering rule.  This indicates a coding error somewhere in
4483446Smrj          * the ACPI subsystem code.
4493446Smrj          */
4507851SDana.Myers@Sun.COM         for (i = MutexId; i < ACPI_NUM_MUTEX; i++)
4513446Smrj         {
4523446Smrj             if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId)
4533446Smrj             {
4543446Smrj                 if (i == MutexId)
4553446Smrj                 {
4563446Smrj                     continue;
4573446Smrj                 }
4583446Smrj 
4593446Smrj                 ACPI_ERROR ((AE_INFO,
4603446Smrj                     "Invalid release order: owns [%s], releasing [%s]",
4613446Smrj                     AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId)));
4623446Smrj 
4633446Smrj                 return (AE_RELEASE_DEADLOCK);
4643446Smrj             }
4653446Smrj         }
4663446Smrj     }
4673446Smrj #endif
4683446Smrj 
4693446Smrj     /* Mark unlocked FIRST */
4703446Smrj 
4713446Smrj     AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
4723446Smrj 
4733446Smrj     AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex);
4743446Smrj     return (AE_OK);
4753446Smrj }
4763446Smrj 
4773446Smrj 
478