diff --git a/source/components/events/evxface.c b/source/components/events/evxface.c index 26caed93a..fb995b295 100644 --- a/source/components/events/evxface.c +++ b/source/components/events/evxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * $Revision: 1.164 $ + * $Revision: 1.165 $ * *****************************************************************************/ @@ -961,7 +961,7 @@ AcpiReleaseGlobalLock ( ACPI_STATUS Status; - if (Handle != AcpiGbl_GlobalLockHandle) + if (!Handle || (Handle != AcpiGbl_GlobalLockHandle)) { return (AE_NOT_ACQUIRED); } diff --git a/source/components/executer/exfield.c b/source/components/executer/exfield.c index b3452f435..75dc4f948 100644 --- a/source/components/executer/exfield.c +++ b/source/components/executer/exfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 1.130 $ + * $Revision: 1.131 $ * *****************************************************************************/ @@ -206,7 +206,7 @@ AcpiExReadDataFromField ( Status = AcpiExAccessRegion (ObjDesc, 0, ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), ACPI_READ | (ObjDesc->Field.Attribute << 16)); - AcpiExReleaseGlobalLock (); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); goto Exit; } @@ -263,7 +263,7 @@ AcpiExReadDataFromField ( /* Read from the field */ Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length); - AcpiExReleaseGlobalLock (); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); Exit: @@ -381,7 +381,7 @@ AcpiExWriteDataToField ( Status = AcpiExAccessRegion (ObjDesc, 0, (ACPI_INTEGER *) Buffer, ACPI_WRITE | (ObjDesc->Field.Attribute << 16)); - AcpiExReleaseGlobalLock (); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); *ResultDesc = BufferDesc; return_ACPI_STATUS (Status); @@ -460,7 +460,7 @@ AcpiExWriteDataToField ( /* Write to the field */ Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); - AcpiExReleaseGlobalLock (); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); /* Free temporary buffer if we used one */ diff --git a/source/components/executer/exmutex.c b/source/components/executer/exmutex.c index 52e5faa95..729b173a5 100644 --- a/source/components/executer/exmutex.c +++ b/source/components/executer/exmutex.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * $Revision: 1.39 $ + * $Revision: 1.40 $ * *****************************************************************************/ @@ -250,6 +250,11 @@ AcpiExAcquireMutexObject ( ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + /* Support for multiple acquires by the owning thread */ if (ObjDesc->Mutex.ThreadId == ThreadId) @@ -396,6 +401,11 @@ AcpiExReleaseMutexObject ( ACPI_FUNCTION_TRACE (ExReleaseMutexObject); + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + return (AE_NOT_ACQUIRED); + } + /* Match multiple Acquires with multiple Releases */ ObjDesc->Mutex.AcquisitionDepth--; @@ -501,16 +511,20 @@ AcpiExReleaseMutex ( if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) { ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], incorrect SyncLevel", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } Status = AcpiExReleaseMutexObject (ObjDesc); - /* Restore the original SyncLevel */ + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + /* Restore the original SyncLevel */ - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + } return_ACPI_STATUS (Status); } diff --git a/source/components/executer/exutils.c b/source/components/executer/exutils.c index 7a0593c19..510a3ad01 100644 --- a/source/components/executer/exutils.c +++ b/source/components/executer/exutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * $Revision: 1.128 $ + * $Revision: 1.129 $ * *****************************************************************************/ @@ -390,7 +390,8 @@ AcpiExAcquireGlobalLock ( * * FUNCTION: AcpiExReleaseGlobalLock * - * PARAMETERS: None + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock * * RETURN: None * @@ -400,7 +401,7 @@ AcpiExAcquireGlobalLock ( void AcpiExReleaseGlobalLock ( - void) + UINT32 FieldFlags) { ACPI_STATUS Status; @@ -408,6 +409,13 @@ AcpiExReleaseGlobalLock ( ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + /* Release the global lock */ Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); diff --git a/source/include/acinterp.h b/source/include/acinterp.h index 64a429b83..367266c53 100644 --- a/source/include/acinterp.h +++ b/source/include/acinterp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 1.170 $ + * $Revision: 1.171 $ * *****************************************************************************/ @@ -701,7 +701,7 @@ AcpiExAcquireGlobalLock ( void AcpiExReleaseGlobalLock ( - void); + UINT32 Rule); void AcpiExEisaIdToString (