exmutex.c (127175) | exmutex.c (129684) |
---|---|
1 2/****************************************************************************** 3 * 4 * Module Name: exmutex - ASL Mutex Acquire/Release functions | 1 2/****************************************************************************** 3 * 4 * Module Name: exmutex - ASL Mutex Acquire/Release functions |
5 * $Revision: 21 $ | 5 * $Revision: 24 $ |
6 * 7 *****************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. --- 109 unchanged lines hidden (view full) --- 123#define _COMPONENT ACPI_EXECUTER 124 ACPI_MODULE_NAME ("exmutex") 125 126 127/******************************************************************************* 128 * 129 * FUNCTION: AcpiExUnlinkMutex 130 * | 6 * 7 *****************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. --- 109 unchanged lines hidden (view full) --- 123#define _COMPONENT ACPI_EXECUTER 124 ACPI_MODULE_NAME ("exmutex") 125 126 127/******************************************************************************* 128 * 129 * FUNCTION: AcpiExUnlinkMutex 130 * |
131 * PARAMETERS: *ObjDesc - The mutex to be unlinked | 131 * PARAMETERS: ObjDesc - The mutex to be unlinked |
132 * 133 * RETURN: Status 134 * 135 * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list 136 * 137 ******************************************************************************/ 138 139void 140AcpiExUnlinkMutex ( 141 ACPI_OPERAND_OBJECT *ObjDesc) 142{ 143 ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; 144 145 146 if (!Thread) 147 { 148 return; 149 } 150 | 132 * 133 * RETURN: Status 134 * 135 * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list 136 * 137 ******************************************************************************/ 138 139void 140AcpiExUnlinkMutex ( 141 ACPI_OPERAND_OBJECT *ObjDesc) 142{ 143 ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; 144 145 146 if (!Thread) 147 { 148 return; 149 } 150 |
151 /* Doubly linked list */ 152 |
|
151 if (ObjDesc->Mutex.Next) 152 { 153 (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; 154 } 155 156 if (ObjDesc->Mutex.Prev) 157 { 158 (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; --- 4 unchanged lines hidden (view full) --- 163 } 164} 165 166 167/******************************************************************************* 168 * 169 * FUNCTION: AcpiExLinkMutex 170 * | 153 if (ObjDesc->Mutex.Next) 154 { 155 (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; 156 } 157 158 if (ObjDesc->Mutex.Prev) 159 { 160 (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; --- 4 unchanged lines hidden (view full) --- 165 } 166} 167 168 169/******************************************************************************* 170 * 171 * FUNCTION: AcpiExLinkMutex 172 * |
171 * PARAMETERS: *ObjDesc - The mutex to be linked 172 * *ListHead - head of the "AcquiredMutex" list | 173 * PARAMETERS: ObjDesc - The mutex to be linked 174 * ListHead - head of the "AcquiredMutex" list |
173 * 174 * RETURN: Status 175 * 176 * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk 177 * 178 ******************************************************************************/ 179 180void --- 23 unchanged lines hidden (view full) --- 204 Thread->AcquiredMutexList = ObjDesc; 205} 206 207 208/******************************************************************************* 209 * 210 * FUNCTION: AcpiExAcquireMutex 211 * | 175 * 176 * RETURN: Status 177 * 178 * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk 179 * 180 ******************************************************************************/ 181 182void --- 23 unchanged lines hidden (view full) --- 206 Thread->AcquiredMutexList = ObjDesc; 207} 208 209 210/******************************************************************************* 211 * 212 * FUNCTION: AcpiExAcquireMutex 213 * |
212 * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor 213 * *ObjDesc - The object descriptor for this op | 214 * PARAMETERS: TimeDesc - The 'time to delay' object descriptor 215 * ObjDesc - The object descriptor for this op |
214 * 215 * RETURN: Status 216 * 217 * DESCRIPTION: Acquire an AML mutex 218 * 219 ******************************************************************************/ 220 221ACPI_STATUS --- 28 unchanged lines hidden (view full) --- 250 */ 251 if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) 252 { 253 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", 254 AcpiUtGetNodeName (ObjDesc->Mutex.Node))); 255 return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 256 } 257 | 216 * 217 * RETURN: Status 218 * 219 * DESCRIPTION: Acquire an AML mutex 220 * 221 ******************************************************************************/ 222 223ACPI_STATUS --- 28 unchanged lines hidden (view full) --- 252 */ 253 if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) 254 { 255 ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", 256 AcpiUtGetNodeName (ObjDesc->Mutex.Node))); 257 return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 258 } 259 |
258 /* 259 * Support for multiple acquires by the owning thread 260 */ | 260 /* Support for multiple acquires by the owning thread */ 261 |
261 if (ObjDesc->Mutex.OwnerThread) 262 { 263 /* Special case for Global Lock, allow all threads */ 264 265 if ((ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId) || 266 (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)) 267 { 268 /* --- 10 unchanged lines hidden (view full) --- 279 Status = AcpiExSystemAcquireMutex (TimeDesc, ObjDesc); 280 if (ACPI_FAILURE (Status)) 281 { 282 /* Includes failure from a timeout on TimeDesc */ 283 284 return_ACPI_STATUS (Status); 285 } 286 | 262 if (ObjDesc->Mutex.OwnerThread) 263 { 264 /* Special case for Global Lock, allow all threads */ 265 266 if ((ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId) || 267 (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)) 268 { 269 /* --- 10 unchanged lines hidden (view full) --- 280 Status = AcpiExSystemAcquireMutex (TimeDesc, ObjDesc); 281 if (ACPI_FAILURE (Status)) 282 { 283 /* Includes failure from a timeout on TimeDesc */ 284 285 return_ACPI_STATUS (Status); 286 } 287 |
287 /* Have the mutex, update mutex and walk info */ | 288 /* Have the mutex: update mutex and walk info and save the SyncLevel */ |
288 | 289 |
289 ObjDesc->Mutex.OwnerThread = WalkState->Thread; 290 ObjDesc->Mutex.AcquisitionDepth = 1; | 290 ObjDesc->Mutex.OwnerThread = WalkState->Thread; 291 ObjDesc->Mutex.AcquisitionDepth = 1; 292 ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; |
291 292 WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; 293 294 /* Link the mutex to the current thread for force-unlock at method exit */ 295 296 AcpiExLinkMutex (ObjDesc, WalkState->Thread); 297 298 return_ACPI_STATUS (AE_OK); 299} 300 301 302/******************************************************************************* 303 * 304 * FUNCTION: AcpiExReleaseMutex 305 * | 293 294 WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; 295 296 /* Link the mutex to the current thread for force-unlock at method exit */ 297 298 AcpiExLinkMutex (ObjDesc, WalkState->Thread); 299 300 return_ACPI_STATUS (AE_OK); 301} 302 303 304/******************************************************************************* 305 * 306 * FUNCTION: AcpiExReleaseMutex 307 * |
306 * PARAMETERS: *ObjDesc - The object descriptor for this op | 308 * PARAMETERS: ObjDesc - The object descriptor for this op |
307 * 308 * RETURN: Status 309 * 310 * DESCRIPTION: Release a previously acquired Mutex. 311 * 312 ******************************************************************************/ 313 314ACPI_STATUS --- 25 unchanged lines hidden (view full) --- 340 341 if (!WalkState->Thread) 342 { 343 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n", 344 AcpiUtGetNodeName (ObjDesc->Mutex.Node))); 345 return_ACPI_STATUS (AE_AML_INTERNAL); 346 } 347 | 309 * 310 * RETURN: Status 311 * 312 * DESCRIPTION: Release a previously acquired Mutex. 313 * 314 ******************************************************************************/ 315 316ACPI_STATUS --- 25 unchanged lines hidden (view full) --- 342 343 if (!WalkState->Thread) 344 { 345 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n", 346 AcpiUtGetNodeName (ObjDesc->Mutex.Node))); 347 return_ACPI_STATUS (AE_AML_INTERNAL); 348 } 349 |
348 /* | 350 /* |
349 * The Mutex is owned, but this thread must be the owner. 350 * Special case for Global Lock, any thread can release 351 */ 352 if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && 353 (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore)) | 351 * The Mutex is owned, but this thread must be the owner. 352 * Special case for Global Lock, any thread can release 353 */ 354 if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && 355 (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore)) |
354 | |
355 { 356 ACPI_REPORT_ERROR (( 357 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", 358 WalkState->Thread->ThreadId, 359 AcpiUtGetNodeName (ObjDesc->Mutex.Node), 360 ObjDesc->Mutex.OwnerThread->ThreadId)); 361 return_ACPI_STATUS (AE_AML_NOT_OWNER); 362 } --- 4 unchanged lines hidden (view full) --- 367 */ 368 if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) 369 { 370 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect SyncLevel\n", 371 AcpiUtGetNodeName (ObjDesc->Mutex.Node))); 372 return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 373 } 374 | 356 { 357 ACPI_REPORT_ERROR (( 358 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", 359 WalkState->Thread->ThreadId, 360 AcpiUtGetNodeName (ObjDesc->Mutex.Node), 361 ObjDesc->Mutex.OwnerThread->ThreadId)); 362 return_ACPI_STATUS (AE_AML_NOT_OWNER); 363 } --- 4 unchanged lines hidden (view full) --- 368 */ 369 if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) 370 { 371 ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect SyncLevel\n", 372 AcpiUtGetNodeName (ObjDesc->Mutex.Node))); 373 return_ACPI_STATUS (AE_AML_MUTEX_ORDER); 374 } 375 |
375 /* 376 * Match multiple Acquires with multiple Releases 377 */ | 376 /* Match multiple Acquires with multiple Releases */ 377 |
378 ObjDesc->Mutex.AcquisitionDepth--; 379 if (ObjDesc->Mutex.AcquisitionDepth != 0) 380 { 381 /* Just decrement the depth and return */ 382 383 return_ACPI_STATUS (AE_OK); 384 } 385 386 /* Unlink the mutex from the owner's list */ 387 388 AcpiExUnlinkMutex (ObjDesc); 389 390 /* Release the mutex */ 391 392 Status = AcpiExSystemReleaseMutex (ObjDesc); 393 | 378 ObjDesc->Mutex.AcquisitionDepth--; 379 if (ObjDesc->Mutex.AcquisitionDepth != 0) 380 { 381 /* Just decrement the depth and return */ 382 383 return_ACPI_STATUS (AE_OK); 384 } 385 386 /* Unlink the mutex from the owner's list */ 387 388 AcpiExUnlinkMutex (ObjDesc); 389 390 /* Release the mutex */ 391 392 Status = AcpiExSystemReleaseMutex (ObjDesc); 393 |
394 /* Update the mutex and walk state */ | 394 /* Update the mutex and walk state, restore SyncLevel before acquire */ |
395 396 ObjDesc->Mutex.OwnerThread = NULL; | 395 396 ObjDesc->Mutex.OwnerThread = NULL; |
397 WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; | 397 WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; |
398 399 return_ACPI_STATUS (Status); 400} 401 402 403/******************************************************************************* 404 * 405 * FUNCTION: AcpiExReleaseAllMutexes 406 * | 398 399 return_ACPI_STATUS (Status); 400} 401 402 403/******************************************************************************* 404 * 405 * FUNCTION: AcpiExReleaseAllMutexes 406 * |
407 * PARAMETERS: *MutexList - Head of the mutex list | 407 * PARAMETERS: MutexList - Head of the mutex list |
408 * 409 * RETURN: Status 410 * 411 * DESCRIPTION: Release all mutexes in the list 412 * 413 ******************************************************************************/ 414 415void 416AcpiExReleaseAllMutexes ( 417 ACPI_THREAD_STATE *Thread) 418{ 419 ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; 420 ACPI_OPERAND_OBJECT *This; 421 ACPI_STATUS Status; 422 423 424 ACPI_FUNCTION_ENTRY (); 425 426 | 408 * 409 * RETURN: Status 410 * 411 * DESCRIPTION: Release all mutexes in the list 412 * 413 ******************************************************************************/ 414 415void 416AcpiExReleaseAllMutexes ( 417 ACPI_THREAD_STATE *Thread) 418{ 419 ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; 420 ACPI_OPERAND_OBJECT *This; 421 ACPI_STATUS Status; 422 423 424 ACPI_FUNCTION_ENTRY (); 425 426 |
427 /* 428 * Traverse the list of owned mutexes, releasing each one. 429 */ | 427 /* Traverse the list of owned mutexes, releasing each one */ 428 |
430 while (Next) 431 { 432 This = Next; 433 Next = This->Mutex.Next; 434 435 This->Mutex.AcquisitionDepth = 1; 436 This->Mutex.Prev = NULL; 437 This->Mutex.Next = NULL; 438 439 /* Release the mutex */ 440 441 Status = AcpiExSystemReleaseMutex (This); 442 if (ACPI_FAILURE (Status)) 443 { 444 continue; 445 } 446 447 /* Mark mutex unowned */ 448 | 429 while (Next) 430 { 431 This = Next; 432 Next = This->Mutex.Next; 433 434 This->Mutex.AcquisitionDepth = 1; 435 This->Mutex.Prev = NULL; 436 This->Mutex.Next = NULL; 437 438 /* Release the mutex */ 439 440 Status = AcpiExSystemReleaseMutex (This); 441 if (ACPI_FAILURE (Status)) 442 { 443 continue; 444 } 445 446 /* Mark mutex unowned */ 447 |
449 This->Mutex.OwnerThread = NULL; | 448 This->Mutex.OwnerThread = NULL; 449 450 /* Update Thread SyncLevel (Last mutex is the important one) */ 451 452 Thread->CurrentSyncLevel = This->Mutex.OriginalSyncLevel; |
450 } 451} 452 453 | 453 } 454} 455 456 |