1 /******************************************************************************
3 * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
54 #define _COMPONENT ACPI_DISPATCHER
55 ACPI_MODULE_NAME ("dsmethod")
57 /* Local prototypes */
60 AcpiDsDetectNamedOpcodes (
61 ACPI_WALK_STATE *WalkState,
62 ACPI_PARSE_OBJECT **OutOp);
65 AcpiDsCreateMethodMutex (
66 ACPI_OPERAND_OBJECT *MethodDesc);
69 /*******************************************************************************
71 * FUNCTION: AcpiDsAutoSerializeMethod
73 * PARAMETERS: Node - Namespace Node of the method
74 * ObjDesc - Method object attached to node
78 * DESCRIPTION: Parse a control method AML to scan for control methods that
79 * need serialization due to the creation of named objects.
81 * NOTE: It is a bit of overkill to mark all such methods serialized, since
82 * there is only a problem if the method actually blocks during execution.
83 * A blocking operation is, for example, a Sleep() operation, or any access
84 * to an operation region. However, it is probably not possible to easily
85 * detect whether a method will block or not, so we simply mark all suspicious
86 * methods as serialized.
88 * NOTE2: This code is essentially a generic routine for parsing a single
91 ******************************************************************************/
94 AcpiDsAutoSerializeMethod (
95 ACPI_NAMESPACE_NODE *Node,
96 ACPI_OPERAND_OBJECT *ObjDesc)
99 ACPI_PARSE_OBJECT *Op = NULL;
100 ACPI_WALK_STATE *WalkState;
103 ACPI_FUNCTION_TRACE_PTR (DsAutoSerializeMethod, Node);
106 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
107 "Method auto-serialization parse [%4.4s] %p\n",
108 AcpiUtGetNodeName (Node), Node));
110 /* Create/Init a root op for the method parse tree */
112 Op = AcpiPsAllocOp (AML_METHOD_OP, ObjDesc->Method.AmlStart);
115 return_ACPI_STATUS (AE_NO_MEMORY);
118 AcpiPsSetName (Op, Node->Name.Integer);
119 Op->Common.Node = Node;
121 /* Create and initialize a new walk state */
123 WalkState = AcpiDsCreateWalkState (Node->OwnerId, NULL, NULL, NULL);
127 return_ACPI_STATUS (AE_NO_MEMORY);
130 Status = AcpiDsInitAmlWalk (WalkState, Op, Node,
131 ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, NULL, 0);
132 if (ACPI_FAILURE (Status))
134 AcpiDsDeleteWalkState (WalkState);
136 return_ACPI_STATUS (Status);
139 WalkState->DescendingCallback = AcpiDsDetectNamedOpcodes;
141 /* Parse the method, scan for creation of named objects */
143 Status = AcpiPsParseAml (WalkState);
145 AcpiPsDeleteParseTree (Op);
146 return_ACPI_STATUS (Status);
150 /*******************************************************************************
152 * FUNCTION: AcpiDsDetectNamedOpcodes
154 * PARAMETERS: WalkState - Current state of the parse tree walk
155 * OutOp - Unused, required for parser interface
159 * DESCRIPTION: Descending callback used during the loading of ACPI tables.
160 * Currently used to detect methods that must be marked serialized
161 * in order to avoid problems with the creation of named objects.
163 ******************************************************************************/
166 AcpiDsDetectNamedOpcodes (
167 ACPI_WALK_STATE *WalkState,
168 ACPI_PARSE_OBJECT **OutOp)
171 ACPI_FUNCTION_NAME (AcpiDsDetectNamedOpcodes);
174 /* We are only interested in opcodes that create a new name */
176 if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_CREATE | AML_FIELD)))
182 * At this point, we know we have a Named object opcode.
183 * Mark the method as serialized. Later code will create a mutex for
184 * this method to enforce serialization.
186 * Note, ACPI_METHOD_IGNORE_SYNC_LEVEL flag means that we will ignore the
187 * Sync Level mechanism for this method, even though it is now serialized.
188 * Otherwise, there can be conflicts with existing ASL code that actually
191 WalkState->MethodDesc->Method.SyncLevel = 0;
192 WalkState->MethodDesc->Method.InfoFlags |=
193 (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL);
195 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
196 "Method serialized [%4.4s] %p - [%s] (%4.4X)\n",
197 WalkState->MethodNode->Name.Ascii, WalkState->MethodNode,
198 WalkState->OpInfo->Name, WalkState->Opcode));
200 /* Abort the parse, no need to examine this method any further */
202 return (AE_CTRL_TERMINATE);
206 /*******************************************************************************
208 * FUNCTION: AcpiDsMethodError
210 * PARAMETERS: Status - Execution status
211 * WalkState - Current state
215 * DESCRIPTION: Called on method error. Invoke the global exception handler if
216 * present, dump the method data if the debugger is configured
218 * Note: Allows the exception handler to change the status code
220 ******************************************************************************/
225 ACPI_WALK_STATE *WalkState)
230 ACPI_FUNCTION_ENTRY ();
233 /* Ignore AE_OK and control exception codes */
235 if (ACPI_SUCCESS (Status) ||
236 (Status & AE_CODE_CONTROL))
241 /* Invoke the global exception handler */
243 if (AcpiGbl_ExceptionHandler)
245 /* Exit the interpreter, allow handler to execute methods */
247 AcpiExExitInterpreter ();
250 * Handler can map the exception code to anything it wants, including
251 * AE_OK, in which case the executing method will not be aborted.
253 AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
254 WalkState->ParserState.AmlStart);
256 Status = AcpiGbl_ExceptionHandler (Status,
257 WalkState->MethodNode ?
258 WalkState->MethodNode->Name.Integer : 0,
259 WalkState->Opcode, AmlOffset, NULL);
260 AcpiExEnterInterpreter ();
263 AcpiDsClearImplicitReturn (WalkState);
265 if (ACPI_FAILURE (Status))
267 AcpiDsDumpMethodStack (Status, WalkState, WalkState->Op);
269 /* Display method locals/args if debugger is present */
272 AcpiDbDumpMethodInfo (Status, WalkState);
280 /*******************************************************************************
282 * FUNCTION: AcpiDsCreateMethodMutex
284 * PARAMETERS: ObjDesc - The method object
288 * DESCRIPTION: Create a mutex object for a serialized control method
290 ******************************************************************************/
293 AcpiDsCreateMethodMutex (
294 ACPI_OPERAND_OBJECT *MethodDesc)
296 ACPI_OPERAND_OBJECT *MutexDesc;
300 ACPI_FUNCTION_TRACE (DsCreateMethodMutex);
303 /* Create the new mutex object */
305 MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
308 return_ACPI_STATUS (AE_NO_MEMORY);
311 /* Create the actual OS Mutex */
313 Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex);
314 if (ACPI_FAILURE (Status))
316 AcpiUtDeleteObjectDesc (MutexDesc);
317 return_ACPI_STATUS (Status);
320 MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel;
321 MethodDesc->Method.Mutex = MutexDesc;
322 return_ACPI_STATUS (AE_OK);
326 /*******************************************************************************
328 * FUNCTION: AcpiDsBeginMethodExecution
330 * PARAMETERS: MethodNode - Node of the method
331 * ObjDesc - The method object
332 * WalkState - current state, NULL if not yet executing
337 * DESCRIPTION: Prepare a method for execution. Parses the method if necessary,
338 * increments the thread count, and waits at the method semaphore
339 * for clearance to execute.
341 ******************************************************************************/
344 AcpiDsBeginMethodExecution (
345 ACPI_NAMESPACE_NODE *MethodNode,
346 ACPI_OPERAND_OBJECT *ObjDesc,
347 ACPI_WALK_STATE *WalkState)
349 ACPI_STATUS Status = AE_OK;
352 ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode);
357 return_ACPI_STATUS (AE_NULL_ENTRY);
360 AcpiExStartTraceMethod (MethodNode, ObjDesc, WalkState);
362 /* Prevent wraparound of thread count */
364 if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX)
366 ACPI_ERROR ((AE_INFO,
367 "Method reached maximum reentrancy limit (255)"));
368 return_ACPI_STATUS (AE_AML_METHOD_LIMIT);
372 * If this method is serialized, we need to acquire the method mutex.
374 if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)
377 * Create a mutex for the method if it is defined to be Serialized
378 * and a mutex has not already been created. We defer the mutex creation
379 * until a method is actually executed, to minimize the object count
381 if (!ObjDesc->Method.Mutex)
383 Status = AcpiDsCreateMethodMutex (ObjDesc);
384 if (ACPI_FAILURE (Status))
386 return_ACPI_STATUS (Status);
391 * The CurrentSyncLevel (per-thread) must be less than or equal to
392 * the sync level of the method. This mechanism provides some
393 * deadlock prevention.
395 * If the method was auto-serialized, we just ignore the sync level
396 * mechanism, because auto-serialization of methods can interfere
397 * with ASL code that actually uses sync levels.
399 * Top-level method invocation has no walk state at this point
402 (!(ObjDesc->Method.InfoFlags & ACPI_METHOD_IGNORE_SYNC_LEVEL)) &&
403 (WalkState->Thread->CurrentSyncLevel >
404 ObjDesc->Method.Mutex->Mutex.SyncLevel))
406 ACPI_ERROR ((AE_INFO,
407 "Cannot acquire Mutex for method [%4.4s]"
408 ", current SyncLevel is too large (%u)",
409 AcpiUtGetNodeName (MethodNode),
410 WalkState->Thread->CurrentSyncLevel));
412 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
416 * Obtain the method mutex if necessary. Do not acquire mutex for a
420 !ObjDesc->Method.Mutex->Mutex.ThreadId ||
421 (WalkState->Thread->ThreadId !=
422 ObjDesc->Method.Mutex->Mutex.ThreadId))
425 * Acquire the method mutex. This releases the interpreter if we
426 * block (and reacquires it before it returns)
428 Status = AcpiExSystemWaitMutex (
429 ObjDesc->Method.Mutex->Mutex.OsMutex, ACPI_WAIT_FOREVER);
430 if (ACPI_FAILURE (Status))
432 return_ACPI_STATUS (Status);
435 /* Update the mutex and walk info and save the original SyncLevel */
439 ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
440 WalkState->Thread->CurrentSyncLevel;
442 ObjDesc->Method.Mutex->Mutex.ThreadId =
443 WalkState->Thread->ThreadId;
446 * Update the current SyncLevel only if this is not an auto-
447 * serialized method. In the auto case, we have to ignore
448 * the sync level for the method mutex (created for the
449 * auto-serialization) because we have no idea of what the
450 * sync level should be. Therefore, just ignore it.
452 if (!(ObjDesc->Method.InfoFlags &
453 ACPI_METHOD_IGNORE_SYNC_LEVEL))
455 WalkState->Thread->CurrentSyncLevel =
456 ObjDesc->Method.SyncLevel;
461 ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
462 ObjDesc->Method.Mutex->Mutex.SyncLevel;
464 ObjDesc->Method.Mutex->Mutex.ThreadId =
465 AcpiOsGetThreadId ();
469 /* Always increase acquisition depth */
471 ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++;
475 * Allocate an Owner ID for this method, only if this is the first thread
476 * to begin concurrent execution. We only need one OwnerId, even if the
477 * method is invoked recursively.
479 if (!ObjDesc->Method.OwnerId)
481 Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
482 if (ACPI_FAILURE (Status))
489 * Increment the method parse tree thread count since it has been
490 * reentered one more time (even if it is the same thread)
492 ObjDesc->Method.ThreadCount++;
494 return_ACPI_STATUS (Status);
498 /* On error, must release the method mutex (if present) */
500 if (ObjDesc->Method.Mutex)
502 AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex);
504 return_ACPI_STATUS (Status);
508 /*******************************************************************************
510 * FUNCTION: AcpiDsCallControlMethod
512 * PARAMETERS: Thread - Info for this thread
513 * ThisWalkState - Current walk state
514 * Op - Current Op to be walked
518 * DESCRIPTION: Transfer execution to a called control method
520 ******************************************************************************/
523 AcpiDsCallControlMethod (
524 ACPI_THREAD_STATE *Thread,
525 ACPI_WALK_STATE *ThisWalkState,
526 ACPI_PARSE_OBJECT *Op)
529 ACPI_NAMESPACE_NODE *MethodNode;
530 ACPI_WALK_STATE *NextWalkState = NULL;
531 ACPI_OPERAND_OBJECT *ObjDesc;
532 ACPI_EVALUATE_INFO *Info;
536 ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState);
538 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
539 "Calling method %p, currentstate=%p\n",
540 ThisWalkState->PrevOp, ThisWalkState));
543 * Get the namespace entry for the control method we are about to call
545 MethodNode = ThisWalkState->MethodCallNode;
548 return_ACPI_STATUS (AE_NULL_ENTRY);
551 ObjDesc = AcpiNsGetAttachedObject (MethodNode);
554 return_ACPI_STATUS (AE_NULL_OBJECT);
557 /* Init for new method, possibly wait on method mutex */
559 Status = AcpiDsBeginMethodExecution (
560 MethodNode, ObjDesc, ThisWalkState);
561 if (ACPI_FAILURE (Status))
563 return_ACPI_STATUS (Status);
566 /* Begin method parse/execution. Create a new walk state */
568 NextWalkState = AcpiDsCreateWalkState (
569 ObjDesc->Method.OwnerId, NULL, ObjDesc, Thread);
572 Status = AE_NO_MEMORY;
577 * The resolved arguments were put on the previous walk state's operand
578 * stack. Operands on the previous walk state stack always
579 * start at index 0. Also, null terminate the list of arguments
581 ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;
584 * Allocate and initialize the evaluation information block
585 * TBD: this is somewhat inefficient, should change interface to
586 * DsInitAmlWalk. For now, keeps this struct off the CPU stack
588 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
591 Status = AE_NO_MEMORY;
595 Info->Parameters = &ThisWalkState->Operands[0];
597 Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
598 ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
599 Info, ACPI_IMODE_EXECUTE);
602 if (ACPI_FAILURE (Status))
608 * Delete the operands on the previous walkstate operand stack
609 * (they were copied to new objects)
611 for (i = 0; i < ObjDesc->Method.ParamCount; i++)
613 AcpiUtRemoveReference (ThisWalkState->Operands [i]);
614 ThisWalkState->Operands [i] = NULL;
617 /* Clear the operand stack */
619 ThisWalkState->NumOperands = 0;
621 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
622 "**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
623 MethodNode->Name.Ascii, NextWalkState));
625 /* Invoke an internal method if necessary */
627 if (ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
629 Status = ObjDesc->Method.Dispatch.Implementation (NextWalkState);
632 Status = AE_CTRL_TERMINATE;
636 return_ACPI_STATUS (Status);
641 /* On error, we must terminate the method properly */
643 AcpiDsTerminateControlMethod (ObjDesc, NextWalkState);
644 AcpiDsDeleteWalkState (NextWalkState);
646 return_ACPI_STATUS (Status);
650 /*******************************************************************************
652 * FUNCTION: AcpiDsRestartControlMethod
654 * PARAMETERS: WalkState - State for preempted method (caller)
655 * ReturnDesc - Return value from the called method
659 * DESCRIPTION: Restart a method that was preempted by another (nested) method
660 * invocation. Handle the return value (if any) from the callee.
662 ******************************************************************************/
665 AcpiDsRestartControlMethod (
666 ACPI_WALK_STATE *WalkState,
667 ACPI_OPERAND_OBJECT *ReturnDesc)
670 int SameAsImplicitReturn;
673 ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState);
676 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
677 "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
678 AcpiUtGetNodeName (WalkState->MethodNode),
679 WalkState->MethodCallOp, ReturnDesc));
681 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
682 " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n",
683 WalkState->ReturnUsed,
684 WalkState->Results, WalkState));
686 /* Did the called method return a value? */
690 /* Is the implicit return object the same as the return desc? */
692 SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc);
694 /* Are we actually going to use the return value? */
696 if (WalkState->ReturnUsed)
698 /* Save the return value from the previous method */
700 Status = AcpiDsResultPush (ReturnDesc, WalkState);
701 if (ACPI_FAILURE (Status))
703 AcpiUtRemoveReference (ReturnDesc);
704 return_ACPI_STATUS (Status);
708 * Save as THIS method's return value in case it is returned
709 * immediately to yet another method
711 WalkState->ReturnDesc = ReturnDesc;
715 * The following code is the optional support for the so-called
716 * "implicit return". Some AML code assumes that the last value of the
717 * method is "implicitly" returned to the caller, in the absence of an
718 * explicit return value.
720 * Just save the last result of the method as the return value.
722 * NOTE: this is optional because the ASL language does not actually
723 * support this behavior.
725 else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) ||
726 SameAsImplicitReturn)
729 * Delete the return value if it will not be used by the
730 * calling method or remove one reference if the explicit return
731 * is the same as the implicit return value.
733 AcpiUtRemoveReference (ReturnDesc);
737 return_ACPI_STATUS (AE_OK);
741 /*******************************************************************************
743 * FUNCTION: AcpiDsTerminateControlMethod
745 * PARAMETERS: MethodDesc - Method object
746 * WalkState - State associated with the method
750 * DESCRIPTION: Terminate a control method. Delete everything that the method
751 * created, delete all locals and arguments, and delete the parse
754 * MUTEX: Interpreter is locked
756 ******************************************************************************/
759 AcpiDsTerminateControlMethod (
760 ACPI_OPERAND_OBJECT *MethodDesc,
761 ACPI_WALK_STATE *WalkState)
764 ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState);
767 /* MethodDesc is required, WalkState is optional */
776 /* Delete all arguments and locals */
778 AcpiDsMethodDataDeleteAll (WalkState);
781 * If method is serialized, release the mutex and restore the
782 * current sync level for this thread
784 if (MethodDesc->Method.Mutex)
786 /* Acquisition Depth handles recursive calls */
788 MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--;
789 if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth)
791 WalkState->Thread->CurrentSyncLevel =
792 MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel;
795 MethodDesc->Method.Mutex->Mutex.OsMutex);
796 MethodDesc->Method.Mutex->Mutex.ThreadId = 0;
801 * Delete any namespace objects created anywhere within the
802 * namespace by the execution of this method. Unless:
803 * 1) This method is a module-level executable code method, in which
804 * case we want make the objects permanent.
805 * 2) There are other threads executing the method, in which case we
806 * will wait until the last thread has completed.
808 if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) &&
809 (MethodDesc->Method.ThreadCount == 1))
811 /* Delete any direct children of (created by) this method */
813 AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode);
816 * Delete any objects that were created by this method
817 * elsewhere in the namespace (if any were created).
818 * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
819 * deletion such that we don't have to perform an entire
820 * namespace walk for every control method execution.
822 if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE)
824 AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId);
825 MethodDesc->Method.InfoFlags &=
826 ~ACPI_METHOD_MODIFIED_NAMESPACE;
831 /* Decrement the thread count on the method */
833 if (MethodDesc->Method.ThreadCount)
835 MethodDesc->Method.ThreadCount--;
839 ACPI_ERROR ((AE_INFO,
840 "Invalid zero thread count in method"));
843 /* Are there any other threads currently executing this method? */
845 if (MethodDesc->Method.ThreadCount)
848 * Additional threads. Do not release the OwnerId in this case,
849 * we immediately reuse it for the next thread executing this method
851 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
852 "*** Completed execution of one thread, %u threads remaining\n",
853 MethodDesc->Method.ThreadCount));
857 /* This is the only executing thread for this method */
860 * Support to dynamically change a method from NotSerialized to
861 * Serialized if it appears that the method is incorrectly written and
862 * does not support multiple thread execution. The best example of this
863 * is if such a method creates namespace objects and blocks. A second
864 * thread will fail with an AE_ALREADY_EXISTS exception.
866 * This code is here because we must wait until the last thread exits
867 * before marking the method as serialized.
869 if (MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED_PENDING)
874 "Marking method %4.4s as Serialized "
875 "because of AE_ALREADY_EXISTS error",
876 WalkState->MethodNode->Name.Ascii));
880 * Method tried to create an object twice and was marked as
881 * "pending serialized". The probable cause is that the method
882 * cannot handle reentrancy.
884 * The method was created as NotSerialized, but it tried to create
885 * a named object and then blocked, causing the second thread
886 * entrance to begin and then fail. Workaround this problem by
887 * marking the method permanently as Serialized when the last
890 MethodDesc->Method.InfoFlags &=
891 ~ACPI_METHOD_SERIALIZED_PENDING;
893 MethodDesc->Method.InfoFlags |=
894 (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL);
895 MethodDesc->Method.SyncLevel = 0;
898 /* No more threads, we can free the OwnerId */
900 if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL))
902 AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId);
906 AcpiExStopTraceMethod ((ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
907 MethodDesc, WalkState);