xref: /titanic_50/usr/src/uts/intel/io/acpica/events/evglock.c (revision 385cc6b4ad1792caef3f84eb61eed3f27085801f)
126f3cdf0SGordon Ross /******************************************************************************
226f3cdf0SGordon Ross  *
326f3cdf0SGordon Ross  * Module Name: evglock - Global Lock support
426f3cdf0SGordon Ross  *
526f3cdf0SGordon Ross  *****************************************************************************/
626f3cdf0SGordon Ross 
726f3cdf0SGordon Ross /*
8*385cc6b4SJerry Jelinek  * Copyright (C) 2000 - 2016, Intel Corp.
926f3cdf0SGordon Ross  * All rights reserved.
1026f3cdf0SGordon Ross  *
1126f3cdf0SGordon Ross  * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross  * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross  * are met:
1426f3cdf0SGordon Ross  * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross  *    notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross  *    without modification.
1726f3cdf0SGordon Ross  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross  *    substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross  *    ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross  *    including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross  *    binary redistribution.
2226f3cdf0SGordon Ross  * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross  *    of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross  *    from this software without specific prior written permission.
2526f3cdf0SGordon Ross  *
2626f3cdf0SGordon Ross  * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross  * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross  * Software Foundation.
2926f3cdf0SGordon Ross  *
3026f3cdf0SGordon Ross  * NO WARRANTY
3126f3cdf0SGordon Ross  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross  * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross  */
4326f3cdf0SGordon Ross 
4426f3cdf0SGordon Ross #include "acpi.h"
4526f3cdf0SGordon Ross #include "accommon.h"
4626f3cdf0SGordon Ross #include "acevents.h"
4726f3cdf0SGordon Ross #include "acinterp.h"
4826f3cdf0SGordon Ross 
4926f3cdf0SGordon Ross #define _COMPONENT          ACPI_EVENTS
5026f3cdf0SGordon Ross         ACPI_MODULE_NAME    ("evglock")
5126f3cdf0SGordon Ross 
52*385cc6b4SJerry Jelinek #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
5326f3cdf0SGordon Ross 
5426f3cdf0SGordon Ross /* Local prototypes */
5526f3cdf0SGordon Ross 
5626f3cdf0SGordon Ross static UINT32
5726f3cdf0SGordon Ross AcpiEvGlobalLockHandler (
5826f3cdf0SGordon Ross     void                    *Context);
5926f3cdf0SGordon Ross 
6026f3cdf0SGordon Ross 
6126f3cdf0SGordon Ross /*******************************************************************************
6226f3cdf0SGordon Ross  *
6326f3cdf0SGordon Ross  * FUNCTION:    AcpiEvInitGlobalLockHandler
6426f3cdf0SGordon Ross  *
6526f3cdf0SGordon Ross  * PARAMETERS:  None
6626f3cdf0SGordon Ross  *
6726f3cdf0SGordon Ross  * RETURN:      Status
6826f3cdf0SGordon Ross  *
6926f3cdf0SGordon Ross  * DESCRIPTION: Install a handler for the global lock release event
7026f3cdf0SGordon Ross  *
7126f3cdf0SGordon Ross  ******************************************************************************/
7226f3cdf0SGordon Ross 
7326f3cdf0SGordon Ross ACPI_STATUS
AcpiEvInitGlobalLockHandler(void)7426f3cdf0SGordon Ross AcpiEvInitGlobalLockHandler (
7526f3cdf0SGordon Ross     void)
7626f3cdf0SGordon Ross {
7726f3cdf0SGordon Ross     ACPI_STATUS             Status;
7826f3cdf0SGordon Ross 
7926f3cdf0SGordon Ross 
8026f3cdf0SGordon Ross     ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler);
8126f3cdf0SGordon Ross 
8226f3cdf0SGordon Ross 
83*385cc6b4SJerry Jelinek     /* If Hardware Reduced flag is set, there is no global lock */
84*385cc6b4SJerry Jelinek 
85*385cc6b4SJerry Jelinek     if (AcpiGbl_ReducedHardware)
86*385cc6b4SJerry Jelinek     {
87*385cc6b4SJerry Jelinek         return_ACPI_STATUS (AE_OK);
88*385cc6b4SJerry Jelinek     }
89*385cc6b4SJerry Jelinek 
9026f3cdf0SGordon Ross     /* Attempt installation of the global lock handler */
9126f3cdf0SGordon Ross 
9226f3cdf0SGordon Ross     Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL,
9326f3cdf0SGordon Ross         AcpiEvGlobalLockHandler, NULL);
9426f3cdf0SGordon Ross 
9526f3cdf0SGordon Ross     /*
9626f3cdf0SGordon Ross      * If the global lock does not exist on this platform, the attempt to
9726f3cdf0SGordon Ross      * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick).
9826f3cdf0SGordon Ross      * Map to AE_OK, but mark global lock as not present. Any attempt to
9926f3cdf0SGordon Ross      * actually use the global lock will be flagged with an error.
10026f3cdf0SGordon Ross      */
10126f3cdf0SGordon Ross     AcpiGbl_GlobalLockPresent = FALSE;
10226f3cdf0SGordon Ross     if (Status == AE_NO_HARDWARE_RESPONSE)
10326f3cdf0SGordon Ross     {
10426f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO,
10526f3cdf0SGordon Ross             "No response from Global Lock hardware, disabling lock"));
10626f3cdf0SGordon Ross 
10726f3cdf0SGordon Ross         return_ACPI_STATUS (AE_OK);
10826f3cdf0SGordon Ross     }
10926f3cdf0SGordon Ross 
11026f3cdf0SGordon Ross     Status = AcpiOsCreateLock (&AcpiGbl_GlobalLockPendingLock);
11126f3cdf0SGordon Ross     if (ACPI_FAILURE (Status))
11226f3cdf0SGordon Ross     {
11326f3cdf0SGordon Ross         return_ACPI_STATUS (Status);
11426f3cdf0SGordon Ross     }
11526f3cdf0SGordon Ross 
11626f3cdf0SGordon Ross     AcpiGbl_GlobalLockPending = FALSE;
11726f3cdf0SGordon Ross     AcpiGbl_GlobalLockPresent = TRUE;
11826f3cdf0SGordon Ross     return_ACPI_STATUS (Status);
11926f3cdf0SGordon Ross }
12026f3cdf0SGordon Ross 
12126f3cdf0SGordon Ross 
12226f3cdf0SGordon Ross /*******************************************************************************
12326f3cdf0SGordon Ross  *
12426f3cdf0SGordon Ross  * FUNCTION:    AcpiEvRemoveGlobalLockHandler
12526f3cdf0SGordon Ross  *
12626f3cdf0SGordon Ross  * PARAMETERS:  None
12726f3cdf0SGordon Ross  *
12826f3cdf0SGordon Ross  * RETURN:      Status
12926f3cdf0SGordon Ross  *
13026f3cdf0SGordon Ross  * DESCRIPTION: Remove the handler for the Global Lock
13126f3cdf0SGordon Ross  *
13226f3cdf0SGordon Ross  ******************************************************************************/
13326f3cdf0SGordon Ross 
13426f3cdf0SGordon Ross ACPI_STATUS
AcpiEvRemoveGlobalLockHandler(void)13526f3cdf0SGordon Ross AcpiEvRemoveGlobalLockHandler (
13626f3cdf0SGordon Ross     void)
13726f3cdf0SGordon Ross {
13826f3cdf0SGordon Ross     ACPI_STATUS             Status;
13926f3cdf0SGordon Ross 
14026f3cdf0SGordon Ross 
14126f3cdf0SGordon Ross     ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler);
14226f3cdf0SGordon Ross 
143*385cc6b4SJerry Jelinek 
14426f3cdf0SGordon Ross     AcpiGbl_GlobalLockPresent = FALSE;
14526f3cdf0SGordon Ross     Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL,
14626f3cdf0SGordon Ross         AcpiEvGlobalLockHandler);
14726f3cdf0SGordon Ross 
148*385cc6b4SJerry Jelinek     AcpiOsDeleteLock (AcpiGbl_GlobalLockPendingLock);
14926f3cdf0SGordon Ross     return_ACPI_STATUS (Status);
15026f3cdf0SGordon Ross }
15126f3cdf0SGordon Ross 
15226f3cdf0SGordon Ross 
15326f3cdf0SGordon Ross /*******************************************************************************
15426f3cdf0SGordon Ross  *
15526f3cdf0SGordon Ross  * FUNCTION:    AcpiEvGlobalLockHandler
15626f3cdf0SGordon Ross  *
15726f3cdf0SGordon Ross  * PARAMETERS:  Context         - From thread interface, not used
15826f3cdf0SGordon Ross  *
15926f3cdf0SGordon Ross  * RETURN:      ACPI_INTERRUPT_HANDLED
16026f3cdf0SGordon Ross  *
16126f3cdf0SGordon Ross  * DESCRIPTION: Invoked directly from the SCI handler when a global lock
16226f3cdf0SGordon Ross  *              release interrupt occurs. If there is actually a pending
16326f3cdf0SGordon Ross  *              request for the lock, signal the waiting thread.
16426f3cdf0SGordon Ross  *
16526f3cdf0SGordon Ross  ******************************************************************************/
16626f3cdf0SGordon Ross 
16726f3cdf0SGordon Ross static UINT32
AcpiEvGlobalLockHandler(void * Context)16826f3cdf0SGordon Ross AcpiEvGlobalLockHandler (
16926f3cdf0SGordon Ross     void                    *Context)
17026f3cdf0SGordon Ross {
17126f3cdf0SGordon Ross     ACPI_STATUS             Status;
17226f3cdf0SGordon Ross     ACPI_CPU_FLAGS          Flags;
17326f3cdf0SGordon Ross 
17426f3cdf0SGordon Ross 
17526f3cdf0SGordon Ross     Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock);
17626f3cdf0SGordon Ross 
17726f3cdf0SGordon Ross     /*
17826f3cdf0SGordon Ross      * If a request for the global lock is not actually pending,
17926f3cdf0SGordon Ross      * we are done. This handles "spurious" global lock interrupts
18026f3cdf0SGordon Ross      * which are possible (and have been seen) with bad BIOSs.
18126f3cdf0SGordon Ross      */
18226f3cdf0SGordon Ross     if (!AcpiGbl_GlobalLockPending)
18326f3cdf0SGordon Ross     {
18426f3cdf0SGordon Ross         goto CleanupAndExit;
18526f3cdf0SGordon Ross     }
18626f3cdf0SGordon Ross 
18726f3cdf0SGordon Ross     /*
18826f3cdf0SGordon Ross      * Send a unit to the global lock semaphore. The actual acquisition
18926f3cdf0SGordon Ross      * of the global lock will be performed by the waiting thread.
19026f3cdf0SGordon Ross      */
19126f3cdf0SGordon Ross     Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, 1);
19226f3cdf0SGordon Ross     if (ACPI_FAILURE (Status))
19326f3cdf0SGordon Ross     {
19426f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore"));
19526f3cdf0SGordon Ross     }
19626f3cdf0SGordon Ross 
19726f3cdf0SGordon Ross     AcpiGbl_GlobalLockPending = FALSE;
19826f3cdf0SGordon Ross 
19926f3cdf0SGordon Ross 
20026f3cdf0SGordon Ross CleanupAndExit:
20126f3cdf0SGordon Ross 
20226f3cdf0SGordon Ross     AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags);
20326f3cdf0SGordon Ross     return (ACPI_INTERRUPT_HANDLED);
20426f3cdf0SGordon Ross }
20526f3cdf0SGordon Ross 
20626f3cdf0SGordon Ross 
20726f3cdf0SGordon Ross /******************************************************************************
20826f3cdf0SGordon Ross  *
20926f3cdf0SGordon Ross  * FUNCTION:    AcpiEvAcquireGlobalLock
21026f3cdf0SGordon Ross  *
21126f3cdf0SGordon Ross  * PARAMETERS:  Timeout         - Max time to wait for the lock, in millisec.
21226f3cdf0SGordon Ross  *
21326f3cdf0SGordon Ross  * RETURN:      Status
21426f3cdf0SGordon Ross  *
21526f3cdf0SGordon Ross  * DESCRIPTION: Attempt to gain ownership of the Global Lock.
21626f3cdf0SGordon Ross  *
21726f3cdf0SGordon Ross  * MUTEX:       Interpreter must be locked
21826f3cdf0SGordon Ross  *
21926f3cdf0SGordon Ross  * Note: The original implementation allowed multiple threads to "acquire" the
22026f3cdf0SGordon Ross  * Global Lock, and the OS would hold the lock until the last thread had
22126f3cdf0SGordon Ross  * released it. However, this could potentially starve the BIOS out of the
22226f3cdf0SGordon Ross  * lock, especially in the case where there is a tight handshake between the
22326f3cdf0SGordon Ross  * Embedded Controller driver and the BIOS. Therefore, this implementation
22426f3cdf0SGordon Ross  * allows only one thread to acquire the HW Global Lock at a time, and makes
22526f3cdf0SGordon Ross  * the global lock appear as a standard mutex on the OS side.
22626f3cdf0SGordon Ross  *
22726f3cdf0SGordon Ross  *****************************************************************************/
22826f3cdf0SGordon Ross 
22926f3cdf0SGordon Ross ACPI_STATUS
AcpiEvAcquireGlobalLock(UINT16 Timeout)23026f3cdf0SGordon Ross AcpiEvAcquireGlobalLock (
23126f3cdf0SGordon Ross     UINT16                  Timeout)
23226f3cdf0SGordon Ross {
23326f3cdf0SGordon Ross     ACPI_CPU_FLAGS          Flags;
23426f3cdf0SGordon Ross     ACPI_STATUS             Status;
23526f3cdf0SGordon Ross     BOOLEAN                 Acquired = FALSE;
23626f3cdf0SGordon Ross 
23726f3cdf0SGordon Ross 
23826f3cdf0SGordon Ross     ACPI_FUNCTION_TRACE (EvAcquireGlobalLock);
23926f3cdf0SGordon Ross 
24026f3cdf0SGordon Ross 
24126f3cdf0SGordon Ross     /*
24226f3cdf0SGordon Ross      * Only one thread can acquire the GL at a time, the GlobalLockMutex
24326f3cdf0SGordon Ross      * enforces this. This interface releases the interpreter if we must wait.
24426f3cdf0SGordon Ross      */
24526f3cdf0SGordon Ross     Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex,
24626f3cdf0SGordon Ross                 Timeout);
24726f3cdf0SGordon Ross     if (ACPI_FAILURE (Status))
24826f3cdf0SGordon Ross     {
24926f3cdf0SGordon Ross         return_ACPI_STATUS (Status);
25026f3cdf0SGordon Ross     }
25126f3cdf0SGordon Ross 
25226f3cdf0SGordon Ross     /*
25326f3cdf0SGordon Ross      * Update the global lock handle and check for wraparound. The handle is
25426f3cdf0SGordon Ross      * only used for the external global lock interfaces, but it is updated
25526f3cdf0SGordon Ross      * here to properly handle the case where a single thread may acquire the
25626f3cdf0SGordon Ross      * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The
25726f3cdf0SGordon Ross      * handle is therefore updated on the first acquire from a given thread
25826f3cdf0SGordon Ross      * regardless of where the acquisition request originated.
25926f3cdf0SGordon Ross      */
26026f3cdf0SGordon Ross     AcpiGbl_GlobalLockHandle++;
26126f3cdf0SGordon Ross     if (AcpiGbl_GlobalLockHandle == 0)
26226f3cdf0SGordon Ross     {
26326f3cdf0SGordon Ross         AcpiGbl_GlobalLockHandle = 1;
26426f3cdf0SGordon Ross     }
26526f3cdf0SGordon Ross 
26626f3cdf0SGordon Ross     /*
26726f3cdf0SGordon Ross      * Make sure that a global lock actually exists. If not, just
26826f3cdf0SGordon Ross      * treat the lock as a standard mutex.
26926f3cdf0SGordon Ross      */
27026f3cdf0SGordon Ross     if (!AcpiGbl_GlobalLockPresent)
27126f3cdf0SGordon Ross     {
27226f3cdf0SGordon Ross         AcpiGbl_GlobalLockAcquired = TRUE;
27326f3cdf0SGordon Ross         return_ACPI_STATUS (AE_OK);
27426f3cdf0SGordon Ross     }
27526f3cdf0SGordon Ross 
27626f3cdf0SGordon Ross     Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock);
27726f3cdf0SGordon Ross 
27826f3cdf0SGordon Ross     do
27926f3cdf0SGordon Ross     {
28026f3cdf0SGordon Ross         /* Attempt to acquire the actual hardware lock */
28126f3cdf0SGordon Ross 
28226f3cdf0SGordon Ross         ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired);
28326f3cdf0SGordon Ross         if (Acquired)
28426f3cdf0SGordon Ross         {
28526f3cdf0SGordon Ross             AcpiGbl_GlobalLockAcquired = TRUE;
28626f3cdf0SGordon Ross             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
28726f3cdf0SGordon Ross                 "Acquired hardware Global Lock\n"));
28826f3cdf0SGordon Ross             break;
28926f3cdf0SGordon Ross         }
29026f3cdf0SGordon Ross 
29126f3cdf0SGordon Ross         /*
29226f3cdf0SGordon Ross          * Did not get the lock. The pending bit was set above, and
29326f3cdf0SGordon Ross          * we must now wait until we receive the global lock
29426f3cdf0SGordon Ross          * released interrupt.
29526f3cdf0SGordon Ross          */
29626f3cdf0SGordon Ross         AcpiGbl_GlobalLockPending = TRUE;
29726f3cdf0SGordon Ross         AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags);
29826f3cdf0SGordon Ross 
29926f3cdf0SGordon Ross         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
30026f3cdf0SGordon Ross             "Waiting for hardware Global Lock\n"));
30126f3cdf0SGordon Ross 
30226f3cdf0SGordon Ross         /*
30326f3cdf0SGordon Ross          * Wait for handshake with the global lock interrupt handler.
30426f3cdf0SGordon Ross          * This interface releases the interpreter if we must wait.
30526f3cdf0SGordon Ross          */
306*385cc6b4SJerry Jelinek         Status = AcpiExSystemWaitSemaphore (
307*385cc6b4SJerry Jelinek             AcpiGbl_GlobalLockSemaphore, ACPI_WAIT_FOREVER);
30826f3cdf0SGordon Ross 
30926f3cdf0SGordon Ross         Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock);
31026f3cdf0SGordon Ross 
31126f3cdf0SGordon Ross     } while (ACPI_SUCCESS (Status));
31226f3cdf0SGordon Ross 
31326f3cdf0SGordon Ross     AcpiGbl_GlobalLockPending = FALSE;
31426f3cdf0SGordon Ross     AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags);
31526f3cdf0SGordon Ross 
31626f3cdf0SGordon Ross     return_ACPI_STATUS (Status);
31726f3cdf0SGordon Ross }
31826f3cdf0SGordon Ross 
31926f3cdf0SGordon Ross 
32026f3cdf0SGordon Ross /*******************************************************************************
32126f3cdf0SGordon Ross  *
32226f3cdf0SGordon Ross  * FUNCTION:    AcpiEvReleaseGlobalLock
32326f3cdf0SGordon Ross  *
32426f3cdf0SGordon Ross  * PARAMETERS:  None
32526f3cdf0SGordon Ross  *
32626f3cdf0SGordon Ross  * RETURN:      Status
32726f3cdf0SGordon Ross  *
32826f3cdf0SGordon Ross  * DESCRIPTION: Releases ownership of the Global Lock.
32926f3cdf0SGordon Ross  *
33026f3cdf0SGordon Ross  ******************************************************************************/
33126f3cdf0SGordon Ross 
33226f3cdf0SGordon Ross ACPI_STATUS
AcpiEvReleaseGlobalLock(void)33326f3cdf0SGordon Ross AcpiEvReleaseGlobalLock (
33426f3cdf0SGordon Ross     void)
33526f3cdf0SGordon Ross {
33626f3cdf0SGordon Ross     BOOLEAN                 Pending = FALSE;
33726f3cdf0SGordon Ross     ACPI_STATUS             Status = AE_OK;
33826f3cdf0SGordon Ross 
33926f3cdf0SGordon Ross 
34026f3cdf0SGordon Ross     ACPI_FUNCTION_TRACE (EvReleaseGlobalLock);
34126f3cdf0SGordon Ross 
34226f3cdf0SGordon Ross 
34326f3cdf0SGordon Ross     /* Lock must be already acquired */
34426f3cdf0SGordon Ross 
34526f3cdf0SGordon Ross     if (!AcpiGbl_GlobalLockAcquired)
34626f3cdf0SGordon Ross     {
34726f3cdf0SGordon Ross         ACPI_WARNING ((AE_INFO,
34826f3cdf0SGordon Ross             "Cannot release the ACPI Global Lock, it has not been acquired"));
34926f3cdf0SGordon Ross         return_ACPI_STATUS (AE_NOT_ACQUIRED);
35026f3cdf0SGordon Ross     }
35126f3cdf0SGordon Ross 
35226f3cdf0SGordon Ross     if (AcpiGbl_GlobalLockPresent)
35326f3cdf0SGordon Ross     {
35426f3cdf0SGordon Ross         /* Allow any thread to release the lock */
35526f3cdf0SGordon Ross 
35626f3cdf0SGordon Ross         ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_FACS, Pending);
35726f3cdf0SGordon Ross 
35826f3cdf0SGordon Ross         /*
35926f3cdf0SGordon Ross          * If the pending bit was set, we must write GBL_RLS to the control
36026f3cdf0SGordon Ross          * register
36126f3cdf0SGordon Ross          */
36226f3cdf0SGordon Ross         if (Pending)
36326f3cdf0SGordon Ross         {
36426f3cdf0SGordon Ross             Status = AcpiWriteBitRegister (
36526f3cdf0SGordon Ross                 ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT);
36626f3cdf0SGordon Ross         }
36726f3cdf0SGordon Ross 
36826f3cdf0SGordon Ross         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n"));
36926f3cdf0SGordon Ross     }
37026f3cdf0SGordon Ross 
37126f3cdf0SGordon Ross     AcpiGbl_GlobalLockAcquired = FALSE;
37226f3cdf0SGordon Ross 
37326f3cdf0SGordon Ross     /* Release the local GL mutex */
37426f3cdf0SGordon Ross 
37526f3cdf0SGordon Ross     AcpiOsReleaseMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex);
37626f3cdf0SGordon Ross     return_ACPI_STATUS (Status);
37726f3cdf0SGordon Ross }
378*385cc6b4SJerry Jelinek 
379*385cc6b4SJerry Jelinek #endif /* !ACPI_REDUCED_HARDWARE */
380