1
2 /******************************************************************************
3 *
4 * Module Name: exmutex - ASL Mutex Acquire/Release functions
5 *
6 *****************************************************************************/
7
8 /*
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
324 * NOTE: This interface is called from three places:
325 * 1) From AcpiExReleaseMutex, via an AML Acquire() operator
326 * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
327 * global lock
328 * 3) From the external interface, AcpiReleaseGlobalLock
329 *
330 ******************************************************************************/
331
332 ACPI_STATUS
333 AcpiExReleaseMutexObject (
334 ACPI_OPERAND_OBJECT *ObjDesc)
335 {
336 ACPI_STATUS Status = AE_OK;
337
338
339 ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
340
341
342 if (ObjDesc->Mutex.AcquisitionDepth == 0)
343 {
344 return (AE_NOT_ACQUIRED);
345 }
346
347 /* Match multiple Acquires with multiple Releases */
348
349 ObjDesc->Mutex.AcquisitionDepth--;
350 if (ObjDesc->Mutex.AcquisitionDepth != 0)
351 {
352 /* Just decrement the depth and return */
353
354 return_ACPI_STATUS (AE_OK);
355 }
356
357 if (ObjDesc->Mutex.OwnerThread)
358 {
359 /* Unlink the mutex from the owner's list */
360
361 AcpiExUnlinkMutex (ObjDesc);
362 ObjDesc->Mutex.OwnerThread = NULL;
363 }
364
498 * RETURN: Status
499 *
500 * DESCRIPTION: Release all mutexes held by this thread
501 *
502 * NOTE: This function is called as the thread is exiting the interpreter.
503 * Mutexes are not released when an individual control method is exited, but
504 * only when the parent thread actually exits the interpreter. This allows one
505 * method to acquire a mutex, and a different method to release it, as long as
506 * this is performed underneath a single parent control method.
507 *
508 ******************************************************************************/
509
510 void
511 AcpiExReleaseAllMutexes (
512 ACPI_THREAD_STATE *Thread)
513 {
514 ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList;
515 ACPI_OPERAND_OBJECT *ObjDesc;
516
517
518 ACPI_FUNCTION_ENTRY ();
519
520
521 /* Traverse the list of owned mutexes, releasing each one */
522
523 while (Next)
524 {
525 ObjDesc = Next;
526 Next = ObjDesc->Mutex.Next;
527
528 ObjDesc->Mutex.Prev = NULL;
529 ObjDesc->Mutex.Next = NULL;
530 ObjDesc->Mutex.AcquisitionDepth = 0;
531
532 /* Release the mutex, special case for Global Lock */
533
534 if (ObjDesc == AcpiGbl_GlobalLockMutex)
535 {
536 /* Ignore errors */
537
538 (void) AcpiEvReleaseGlobalLock ();
539 }
540 else
541 {
542 AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
543 }
544
545 /* Mark mutex unowned */
546
547 ObjDesc->Mutex.OwnerThread = NULL;
548 ObjDesc->Mutex.ThreadId = 0;
549
550 /* Update Thread SyncLevel (Last mutex is the important one) */
551
|
1 /******************************************************************************
2 *
3 * Module Name: exmutex - ASL Mutex Acquire/Release functions
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
323 * NOTE: This interface is called from three places:
324 * 1) From AcpiExReleaseMutex, via an AML Acquire() operator
325 * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the
326 * global lock
327 * 3) From the external interface, AcpiReleaseGlobalLock
328 *
329 ******************************************************************************/
330
331 ACPI_STATUS
332 AcpiExReleaseMutexObject (
333 ACPI_OPERAND_OBJECT *ObjDesc)
334 {
335 ACPI_STATUS Status = AE_OK;
336
337
338 ACPI_FUNCTION_TRACE (ExReleaseMutexObject);
339
340
341 if (ObjDesc->Mutex.AcquisitionDepth == 0)
342 {
343 return_ACPI_STATUS (AE_NOT_ACQUIRED);
344 }
345
346 /* Match multiple Acquires with multiple Releases */
347
348 ObjDesc->Mutex.AcquisitionDepth--;
349 if (ObjDesc->Mutex.AcquisitionDepth != 0)
350 {
351 /* Just decrement the depth and return */
352
353 return_ACPI_STATUS (AE_OK);
354 }
355
356 if (ObjDesc->Mutex.OwnerThread)
357 {
358 /* Unlink the mutex from the owner's list */
359
360 AcpiExUnlinkMutex (ObjDesc);
361 ObjDesc->Mutex.OwnerThread = NULL;
362 }
363
497 * RETURN: Status
498 *
499 * DESCRIPTION: Release all mutexes held by this thread
500 *
501 * NOTE: This function is called as the thread is exiting the interpreter.
502 * Mutexes are not released when an individual control method is exited, but
503 * only when the parent thread actually exits the interpreter. This allows one
504 * method to acquire a mutex, and a different method to release it, as long as
505 * this is performed underneath a single parent control method.
506 *
507 ******************************************************************************/
508
509 void
510 AcpiExReleaseAllMutexes (
511 ACPI_THREAD_STATE *Thread)
512 {
513 ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList;
514 ACPI_OPERAND_OBJECT *ObjDesc;
515
516
517 ACPI_FUNCTION_NAME (ExReleaseAllMutexes);
518
519
520 /* Traverse the list of owned mutexes, releasing each one */
521
522 while (Next)
523 {
524 ObjDesc = Next;
525 Next = ObjDesc->Mutex.Next;
526
527 ObjDesc->Mutex.Prev = NULL;
528 ObjDesc->Mutex.Next = NULL;
529 ObjDesc->Mutex.AcquisitionDepth = 0;
530
531 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
532 "Force-releasing held mutex: %p\n", ObjDesc));
533
534 /* Release the mutex, special case for Global Lock */
535
536 if (ObjDesc == AcpiGbl_GlobalLockMutex)
537 {
538 /* Ignore errors */
539
540 (void) AcpiEvReleaseGlobalLock ();
541 }
542 else
543 {
544 AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
545 }
546
547 /* Mark mutex unowned */
548
549 ObjDesc->Mutex.OwnerThread = NULL;
550 ObjDesc->Mutex.ThreadId = 0;
551
552 /* Update Thread SyncLevel (Last mutex is the important one) */
553
|