xref: /illumos-gate/usr/src/common/acpica/dispatcher/dsmethod.c (revision 35786f6866ae52207d0f1a25fe7ca5f652f32ce0)
1bc36eafdSMike Gerdts /******************************************************************************
2bc36eafdSMike Gerdts  *
3bc36eafdSMike Gerdts  * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
4bc36eafdSMike Gerdts  *
5bc36eafdSMike Gerdts  *****************************************************************************/
6bc36eafdSMike Gerdts 
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi  *
9*35786f68SRobert Mustacchi  * 1. Copyright Notice
10*35786f68SRobert Mustacchi  *
11*35786f68SRobert Mustacchi  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12bc36eafdSMike Gerdts  * All rights reserved.
13bc36eafdSMike Gerdts  *
14*35786f68SRobert Mustacchi  * 2. License
15*35786f68SRobert Mustacchi  *
16*35786f68SRobert Mustacchi  * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi  * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi  * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi  * property rights.
20*35786f68SRobert Mustacchi  *
21*35786f68SRobert Mustacchi  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi  * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi  * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi  * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi  * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi  *
28*35786f68SRobert Mustacchi  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi  * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi  * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi  * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi  * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi  * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi  * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi  * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi  *
37*35786f68SRobert Mustacchi  * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi  * conditions are met:
39*35786f68SRobert Mustacchi  *
40*35786f68SRobert Mustacchi  * 3. Conditions
41*35786f68SRobert Mustacchi  *
42*35786f68SRobert Mustacchi  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi  * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi  * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi  * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi  * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi  * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi  * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi  * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi  * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi  * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi  *
54*35786f68SRobert Mustacchi  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi  * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi  * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi  * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi  * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi  * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi  * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi  * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi  * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi  * make.
65*35786f68SRobert Mustacchi  *
66*35786f68SRobert Mustacchi  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi  * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi  * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi  * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi  * distribution.
71*35786f68SRobert Mustacchi  *
72*35786f68SRobert Mustacchi  * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi  * Intel Code.
74*35786f68SRobert Mustacchi  *
75*35786f68SRobert Mustacchi  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi  * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi  * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi  * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi  *
80*35786f68SRobert Mustacchi  * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi  *
82*35786f68SRobert Mustacchi  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi  * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi  *
90*35786f68SRobert Mustacchi  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi  * LIMITED REMEDY.
98*35786f68SRobert Mustacchi  *
99*35786f68SRobert Mustacchi  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi  * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi  * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi  * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi  * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi  * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi  * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi  * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi  * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi  * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi  * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi  * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi  * such license, approval or letter.
113*35786f68SRobert Mustacchi  *
114*35786f68SRobert Mustacchi  *****************************************************************************
115*35786f68SRobert Mustacchi  *
116*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi  * following license:
118*35786f68SRobert Mustacchi  *
119bc36eafdSMike Gerdts  * Redistribution and use in source and binary forms, with or without
120bc36eafdSMike Gerdts  * modification, are permitted provided that the following conditions
121bc36eafdSMike Gerdts  * are met:
122bc36eafdSMike Gerdts  * 1. Redistributions of source code must retain the above copyright
123bc36eafdSMike Gerdts  *    notice, this list of conditions, and the following disclaimer,
124bc36eafdSMike Gerdts  *    without modification.
125bc36eafdSMike Gerdts  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126bc36eafdSMike Gerdts  *    substantially similar to the "NO WARRANTY" disclaimer below
127bc36eafdSMike Gerdts  *    ("Disclaimer") and any redistribution must be conditioned upon
128bc36eafdSMike Gerdts  *    including a substantially similar Disclaimer requirement for further
129bc36eafdSMike Gerdts  *    binary redistribution.
130bc36eafdSMike Gerdts  * 3. Neither the names of the above-listed copyright holders nor the names
131bc36eafdSMike Gerdts  *    of any contributors may be used to endorse or promote products derived
132bc36eafdSMike Gerdts  *    from this software without specific prior written permission.
133bc36eafdSMike Gerdts  *
134*35786f68SRobert Mustacchi  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135*35786f68SRobert Mustacchi  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137*35786f68SRobert Mustacchi  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi  *
146*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
147bc36eafdSMike Gerdts  * GNU General Public License ("GPL") version 2 as published by the Free
148bc36eafdSMike Gerdts  * Software Foundation.
149bc36eafdSMike Gerdts  *
150*35786f68SRobert Mustacchi  *****************************************************************************/
151bc36eafdSMike Gerdts 
152bc36eafdSMike Gerdts #include "acpi.h"
153bc36eafdSMike Gerdts #include "accommon.h"
154bc36eafdSMike Gerdts #include "acdispat.h"
155bc36eafdSMike Gerdts #include "acinterp.h"
156bc36eafdSMike Gerdts #include "acnamesp.h"
157bc36eafdSMike Gerdts #include "acparser.h"
158bc36eafdSMike Gerdts #include "amlcode.h"
159bc36eafdSMike Gerdts #include "acdebug.h"
160bc36eafdSMike Gerdts 
161bc36eafdSMike Gerdts 
162bc36eafdSMike Gerdts #define _COMPONENT          ACPI_DISPATCHER
163bc36eafdSMike Gerdts         ACPI_MODULE_NAME    ("dsmethod")
164bc36eafdSMike Gerdts 
165bc36eafdSMike Gerdts /* Local prototypes */
166bc36eafdSMike Gerdts 
167bc36eafdSMike Gerdts static ACPI_STATUS
168bc36eafdSMike Gerdts AcpiDsDetectNamedOpcodes (
169bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState,
170bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       **OutOp);
171bc36eafdSMike Gerdts 
172bc36eafdSMike Gerdts static ACPI_STATUS
173bc36eafdSMike Gerdts AcpiDsCreateMethodMutex (
174bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *MethodDesc);
175bc36eafdSMike Gerdts 
176bc36eafdSMike Gerdts 
177bc36eafdSMike Gerdts /*******************************************************************************
178bc36eafdSMike Gerdts  *
179bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsAutoSerializeMethod
180bc36eafdSMike Gerdts  *
181bc36eafdSMike Gerdts  * PARAMETERS:  Node                        - Namespace Node of the method
182bc36eafdSMike Gerdts  *              ObjDesc                     - Method object attached to node
183bc36eafdSMike Gerdts  *
184bc36eafdSMike Gerdts  * RETURN:      Status
185bc36eafdSMike Gerdts  *
186bc36eafdSMike Gerdts  * DESCRIPTION: Parse a control method AML to scan for control methods that
187bc36eafdSMike Gerdts  *              need serialization due to the creation of named objects.
188bc36eafdSMike Gerdts  *
189bc36eafdSMike Gerdts  * NOTE: It is a bit of overkill to mark all such methods serialized, since
190bc36eafdSMike Gerdts  * there is only a problem if the method actually blocks during execution.
191bc36eafdSMike Gerdts  * A blocking operation is, for example, a Sleep() operation, or any access
192bc36eafdSMike Gerdts  * to an operation region. However, it is probably not possible to easily
193bc36eafdSMike Gerdts  * detect whether a method will block or not, so we simply mark all suspicious
194bc36eafdSMike Gerdts  * methods as serialized.
195bc36eafdSMike Gerdts  *
196bc36eafdSMike Gerdts  * NOTE2: This code is essentially a generic routine for parsing a single
197bc36eafdSMike Gerdts  * control method.
198bc36eafdSMike Gerdts  *
199bc36eafdSMike Gerdts  ******************************************************************************/
200bc36eafdSMike Gerdts 
201bc36eafdSMike Gerdts ACPI_STATUS
AcpiDsAutoSerializeMethod(ACPI_NAMESPACE_NODE * Node,ACPI_OPERAND_OBJECT * ObjDesc)202bc36eafdSMike Gerdts AcpiDsAutoSerializeMethod (
203bc36eafdSMike Gerdts     ACPI_NAMESPACE_NODE     *Node,
204bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc)
205bc36eafdSMike Gerdts {
206bc36eafdSMike Gerdts     ACPI_STATUS             Status;
207bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op = NULL;
208bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState;
209bc36eafdSMike Gerdts 
210bc36eafdSMike Gerdts 
211bc36eafdSMike Gerdts     ACPI_FUNCTION_TRACE_PTR (DsAutoSerializeMethod, Node);
212bc36eafdSMike Gerdts 
213bc36eafdSMike Gerdts 
214bc36eafdSMike Gerdts     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
215bc36eafdSMike Gerdts         "Method auto-serialization parse [%4.4s] %p\n",
216bc36eafdSMike Gerdts         AcpiUtGetNodeName (Node), Node));
217bc36eafdSMike Gerdts 
218bc36eafdSMike Gerdts     /* Create/Init a root op for the method parse tree */
219bc36eafdSMike Gerdts 
220bc36eafdSMike Gerdts     Op = AcpiPsAllocOp (AML_METHOD_OP, ObjDesc->Method.AmlStart);
221bc36eafdSMike Gerdts     if (!Op)
222bc36eafdSMike Gerdts     {
223bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_NO_MEMORY);
224bc36eafdSMike Gerdts     }
225bc36eafdSMike Gerdts 
226bc36eafdSMike Gerdts     AcpiPsSetName (Op, Node->Name.Integer);
227bc36eafdSMike Gerdts     Op->Common.Node = Node;
228bc36eafdSMike Gerdts 
229bc36eafdSMike Gerdts     /* Create and initialize a new walk state */
230bc36eafdSMike Gerdts 
231bc36eafdSMike Gerdts     WalkState = AcpiDsCreateWalkState (Node->OwnerId, NULL, NULL, NULL);
232bc36eafdSMike Gerdts     if (!WalkState)
233bc36eafdSMike Gerdts     {
234bc36eafdSMike Gerdts         AcpiPsFreeOp (Op);
235bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_NO_MEMORY);
236bc36eafdSMike Gerdts     }
237bc36eafdSMike Gerdts 
238bc36eafdSMike Gerdts     Status = AcpiDsInitAmlWalk (WalkState, Op, Node,
239bc36eafdSMike Gerdts         ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, NULL, 0);
240bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
241bc36eafdSMike Gerdts     {
242bc36eafdSMike Gerdts         AcpiDsDeleteWalkState (WalkState);
243bc36eafdSMike Gerdts         AcpiPsFreeOp (Op);
244bc36eafdSMike Gerdts         return_ACPI_STATUS (Status);
245bc36eafdSMike Gerdts     }
246bc36eafdSMike Gerdts 
247bc36eafdSMike Gerdts     WalkState->DescendingCallback = AcpiDsDetectNamedOpcodes;
248bc36eafdSMike Gerdts 
249bc36eafdSMike Gerdts     /* Parse the method, scan for creation of named objects */
250bc36eafdSMike Gerdts 
251bc36eafdSMike Gerdts     Status = AcpiPsParseAml (WalkState);
252bc36eafdSMike Gerdts 
253bc36eafdSMike Gerdts     AcpiPsDeleteParseTree (Op);
254bc36eafdSMike Gerdts     return_ACPI_STATUS (Status);
255bc36eafdSMike Gerdts }
256bc36eafdSMike Gerdts 
257bc36eafdSMike Gerdts 
258bc36eafdSMike Gerdts /*******************************************************************************
259bc36eafdSMike Gerdts  *
260bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsDetectNamedOpcodes
261bc36eafdSMike Gerdts  *
262bc36eafdSMike Gerdts  * PARAMETERS:  WalkState       - Current state of the parse tree walk
263bc36eafdSMike Gerdts  *              OutOp           - Unused, required for parser interface
264bc36eafdSMike Gerdts  *
265bc36eafdSMike Gerdts  * RETURN:      Status
266bc36eafdSMike Gerdts  *
267bc36eafdSMike Gerdts  * DESCRIPTION: Descending callback used during the loading of ACPI tables.
268bc36eafdSMike Gerdts  *              Currently used to detect methods that must be marked serialized
269bc36eafdSMike Gerdts  *              in order to avoid problems with the creation of named objects.
270bc36eafdSMike Gerdts  *
271bc36eafdSMike Gerdts  ******************************************************************************/
272bc36eafdSMike Gerdts 
273bc36eafdSMike Gerdts static ACPI_STATUS
AcpiDsDetectNamedOpcodes(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT ** OutOp)274bc36eafdSMike Gerdts AcpiDsDetectNamedOpcodes (
275bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState,
276bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       **OutOp)
277bc36eafdSMike Gerdts {
278bc36eafdSMike Gerdts 
279bc36eafdSMike Gerdts     ACPI_FUNCTION_NAME (AcpiDsDetectNamedOpcodes);
280bc36eafdSMike Gerdts 
281bc36eafdSMike Gerdts 
282bc36eafdSMike Gerdts     /* We are only interested in opcodes that create a new name */
283bc36eafdSMike Gerdts 
284bc36eafdSMike Gerdts     if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_CREATE | AML_FIELD)))
285bc36eafdSMike Gerdts     {
286bc36eafdSMike Gerdts         return (AE_OK);
287bc36eafdSMike Gerdts     }
288bc36eafdSMike Gerdts 
289bc36eafdSMike Gerdts     /*
290bc36eafdSMike Gerdts      * At this point, we know we have a Named object opcode.
291bc36eafdSMike Gerdts      * Mark the method as serialized. Later code will create a mutex for
292bc36eafdSMike Gerdts      * this method to enforce serialization.
293bc36eafdSMike Gerdts      *
294bc36eafdSMike Gerdts      * Note, ACPI_METHOD_IGNORE_SYNC_LEVEL flag means that we will ignore the
295bc36eafdSMike Gerdts      * Sync Level mechanism for this method, even though it is now serialized.
296bc36eafdSMike Gerdts      * Otherwise, there can be conflicts with existing ASL code that actually
297bc36eafdSMike Gerdts      * uses sync levels.
298bc36eafdSMike Gerdts      */
299bc36eafdSMike Gerdts     WalkState->MethodDesc->Method.SyncLevel = 0;
300bc36eafdSMike Gerdts     WalkState->MethodDesc->Method.InfoFlags |=
301bc36eafdSMike Gerdts         (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL);
302bc36eafdSMike Gerdts 
303bc36eafdSMike Gerdts     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
304bc36eafdSMike Gerdts         "Method serialized [%4.4s] %p - [%s] (%4.4X)\n",
305bc36eafdSMike Gerdts         WalkState->MethodNode->Name.Ascii, WalkState->MethodNode,
306bc36eafdSMike Gerdts         WalkState->OpInfo->Name, WalkState->Opcode));
307bc36eafdSMike Gerdts 
308bc36eafdSMike Gerdts     /* Abort the parse, no need to examine this method any further */
309bc36eafdSMike Gerdts 
310bc36eafdSMike Gerdts     return (AE_CTRL_TERMINATE);
311bc36eafdSMike Gerdts }
312bc36eafdSMike Gerdts 
313bc36eafdSMike Gerdts 
314bc36eafdSMike Gerdts /*******************************************************************************
315bc36eafdSMike Gerdts  *
316bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsMethodError
317bc36eafdSMike Gerdts  *
318bc36eafdSMike Gerdts  * PARAMETERS:  Status          - Execution status
319bc36eafdSMike Gerdts  *              WalkState       - Current state
320bc36eafdSMike Gerdts  *
321bc36eafdSMike Gerdts  * RETURN:      Status
322bc36eafdSMike Gerdts  *
323bc36eafdSMike Gerdts  * DESCRIPTION: Called on method error. Invoke the global exception handler if
324bc36eafdSMike Gerdts  *              present, dump the method data if the debugger is configured
325bc36eafdSMike Gerdts  *
326bc36eafdSMike Gerdts  *              Note: Allows the exception handler to change the status code
327bc36eafdSMike Gerdts  *
328bc36eafdSMike Gerdts  ******************************************************************************/
329bc36eafdSMike Gerdts 
330bc36eafdSMike Gerdts ACPI_STATUS
AcpiDsMethodError(ACPI_STATUS Status,ACPI_WALK_STATE * WalkState)331bc36eafdSMike Gerdts AcpiDsMethodError (
332bc36eafdSMike Gerdts     ACPI_STATUS             Status,
333bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState)
334bc36eafdSMike Gerdts {
335bc36eafdSMike Gerdts     UINT32                  AmlOffset;
336*35786f68SRobert Mustacchi     ACPI_NAME               Name = 0;
337bc36eafdSMike Gerdts 
338bc36eafdSMike Gerdts 
339bc36eafdSMike Gerdts     ACPI_FUNCTION_ENTRY ();
340bc36eafdSMike Gerdts 
341bc36eafdSMike Gerdts 
342bc36eafdSMike Gerdts     /* Ignore AE_OK and control exception codes */
343bc36eafdSMike Gerdts 
344bc36eafdSMike Gerdts     if (ACPI_SUCCESS (Status) ||
345bc36eafdSMike Gerdts         (Status & AE_CODE_CONTROL))
346bc36eafdSMike Gerdts     {
347bc36eafdSMike Gerdts         return (Status);
348bc36eafdSMike Gerdts     }
349bc36eafdSMike Gerdts 
350bc36eafdSMike Gerdts     /* Invoke the global exception handler */
351bc36eafdSMike Gerdts 
352bc36eafdSMike Gerdts     if (AcpiGbl_ExceptionHandler)
353bc36eafdSMike Gerdts     {
354bc36eafdSMike Gerdts         /* Exit the interpreter, allow handler to execute methods */
355bc36eafdSMike Gerdts 
356bc36eafdSMike Gerdts         AcpiExExitInterpreter ();
357bc36eafdSMike Gerdts 
358bc36eafdSMike Gerdts         /*
359bc36eafdSMike Gerdts          * Handler can map the exception code to anything it wants, including
360bc36eafdSMike Gerdts          * AE_OK, in which case the executing method will not be aborted.
361bc36eafdSMike Gerdts          */
362bc36eafdSMike Gerdts         AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
363bc36eafdSMike Gerdts             WalkState->ParserState.AmlStart);
364bc36eafdSMike Gerdts 
365*35786f68SRobert Mustacchi         if (WalkState->MethodNode)
366*35786f68SRobert Mustacchi         {
367*35786f68SRobert Mustacchi             Name = WalkState->MethodNode->Name.Integer;
368*35786f68SRobert Mustacchi         }
369*35786f68SRobert Mustacchi         else if (WalkState->DeferredNode)
370*35786f68SRobert Mustacchi         {
371*35786f68SRobert Mustacchi             Name = WalkState->DeferredNode->Name.Integer;
372*35786f68SRobert Mustacchi         }
373*35786f68SRobert Mustacchi 
374*35786f68SRobert Mustacchi         Status = AcpiGbl_ExceptionHandler (Status, Name,
375bc36eafdSMike Gerdts             WalkState->Opcode, AmlOffset, NULL);
376bc36eafdSMike Gerdts         AcpiExEnterInterpreter ();
377bc36eafdSMike Gerdts     }
378bc36eafdSMike Gerdts 
379bc36eafdSMike Gerdts     AcpiDsClearImplicitReturn (WalkState);
380bc36eafdSMike Gerdts 
381bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
382bc36eafdSMike Gerdts     {
383bc36eafdSMike Gerdts         AcpiDsDumpMethodStack (Status, WalkState, WalkState->Op);
384bc36eafdSMike Gerdts 
385bc36eafdSMike Gerdts         /* Display method locals/args if debugger is present */
386bc36eafdSMike Gerdts 
387bc36eafdSMike Gerdts #ifdef ACPI_DEBUGGER
388bc36eafdSMike Gerdts         AcpiDbDumpMethodInfo (Status, WalkState);
389bc36eafdSMike Gerdts #endif
390bc36eafdSMike Gerdts     }
391bc36eafdSMike Gerdts 
392bc36eafdSMike Gerdts     return (Status);
393bc36eafdSMike Gerdts }
394bc36eafdSMike Gerdts 
395bc36eafdSMike Gerdts 
396bc36eafdSMike Gerdts /*******************************************************************************
397bc36eafdSMike Gerdts  *
398bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsCreateMethodMutex
399bc36eafdSMike Gerdts  *
400bc36eafdSMike Gerdts  * PARAMETERS:  ObjDesc             - The method object
401bc36eafdSMike Gerdts  *
402bc36eafdSMike Gerdts  * RETURN:      Status
403bc36eafdSMike Gerdts  *
404bc36eafdSMike Gerdts  * DESCRIPTION: Create a mutex object for a serialized control method
405bc36eafdSMike Gerdts  *
406bc36eafdSMike Gerdts  ******************************************************************************/
407bc36eafdSMike Gerdts 
408bc36eafdSMike Gerdts static ACPI_STATUS
AcpiDsCreateMethodMutex(ACPI_OPERAND_OBJECT * MethodDesc)409bc36eafdSMike Gerdts AcpiDsCreateMethodMutex (
410bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *MethodDesc)
411bc36eafdSMike Gerdts {
412bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *MutexDesc;
413bc36eafdSMike Gerdts     ACPI_STATUS             Status;
414bc36eafdSMike Gerdts 
415bc36eafdSMike Gerdts 
416bc36eafdSMike Gerdts     ACPI_FUNCTION_TRACE (DsCreateMethodMutex);
417bc36eafdSMike Gerdts 
418bc36eafdSMike Gerdts 
419bc36eafdSMike Gerdts     /* Create the new mutex object */
420bc36eafdSMike Gerdts 
421bc36eafdSMike Gerdts     MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
422bc36eafdSMike Gerdts     if (!MutexDesc)
423bc36eafdSMike Gerdts     {
424bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_NO_MEMORY);
425bc36eafdSMike Gerdts     }
426bc36eafdSMike Gerdts 
427bc36eafdSMike Gerdts     /* Create the actual OS Mutex */
428bc36eafdSMike Gerdts 
429bc36eafdSMike Gerdts     Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex);
430bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
431bc36eafdSMike Gerdts     {
432bc36eafdSMike Gerdts         AcpiUtDeleteObjectDesc (MutexDesc);
433bc36eafdSMike Gerdts         return_ACPI_STATUS (Status);
434bc36eafdSMike Gerdts     }
435bc36eafdSMike Gerdts 
436bc36eafdSMike Gerdts     MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel;
437bc36eafdSMike Gerdts     MethodDesc->Method.Mutex = MutexDesc;
438bc36eafdSMike Gerdts     return_ACPI_STATUS (AE_OK);
439bc36eafdSMike Gerdts }
440bc36eafdSMike Gerdts 
441bc36eafdSMike Gerdts 
442bc36eafdSMike Gerdts /*******************************************************************************
443bc36eafdSMike Gerdts  *
444bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsBeginMethodExecution
445bc36eafdSMike Gerdts  *
446bc36eafdSMike Gerdts  * PARAMETERS:  MethodNode          - Node of the method
447bc36eafdSMike Gerdts  *              ObjDesc             - The method object
448bc36eafdSMike Gerdts  *              WalkState           - current state, NULL if not yet executing
449bc36eafdSMike Gerdts  *                                    a method.
450bc36eafdSMike Gerdts  *
451bc36eafdSMike Gerdts  * RETURN:      Status
452bc36eafdSMike Gerdts  *
453bc36eafdSMike Gerdts  * DESCRIPTION: Prepare a method for execution. Parses the method if necessary,
454bc36eafdSMike Gerdts  *              increments the thread count, and waits at the method semaphore
455bc36eafdSMike Gerdts  *              for clearance to execute.
456bc36eafdSMike Gerdts  *
457bc36eafdSMike Gerdts  ******************************************************************************/
458bc36eafdSMike Gerdts 
459bc36eafdSMike Gerdts ACPI_STATUS
AcpiDsBeginMethodExecution(ACPI_NAMESPACE_NODE * MethodNode,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)460bc36eafdSMike Gerdts AcpiDsBeginMethodExecution (
461bc36eafdSMike Gerdts     ACPI_NAMESPACE_NODE     *MethodNode,
462bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc,
463bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState)
464bc36eafdSMike Gerdts {
465bc36eafdSMike Gerdts     ACPI_STATUS             Status = AE_OK;
466bc36eafdSMike Gerdts 
467bc36eafdSMike Gerdts 
468bc36eafdSMike Gerdts     ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode);
469bc36eafdSMike Gerdts 
470bc36eafdSMike Gerdts 
471bc36eafdSMike Gerdts     if (!MethodNode)
472bc36eafdSMike Gerdts     {
473bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_NULL_ENTRY);
474bc36eafdSMike Gerdts     }
475bc36eafdSMike Gerdts 
476bc36eafdSMike Gerdts     AcpiExStartTraceMethod (MethodNode, ObjDesc, WalkState);
477bc36eafdSMike Gerdts 
478bc36eafdSMike Gerdts     /* Prevent wraparound of thread count */
479bc36eafdSMike Gerdts 
480bc36eafdSMike Gerdts     if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX)
481bc36eafdSMike Gerdts     {
482bc36eafdSMike Gerdts         ACPI_ERROR ((AE_INFO,
483bc36eafdSMike Gerdts             "Method reached maximum reentrancy limit (255)"));
484bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_AML_METHOD_LIMIT);
485bc36eafdSMike Gerdts     }
486bc36eafdSMike Gerdts 
487bc36eafdSMike Gerdts     /*
488bc36eafdSMike Gerdts      * If this method is serialized, we need to acquire the method mutex.
489bc36eafdSMike Gerdts      */
490bc36eafdSMike Gerdts     if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)
491bc36eafdSMike Gerdts     {
492bc36eafdSMike Gerdts         /*
493bc36eafdSMike Gerdts          * Create a mutex for the method if it is defined to be Serialized
494bc36eafdSMike Gerdts          * and a mutex has not already been created. We defer the mutex creation
495bc36eafdSMike Gerdts          * until a method is actually executed, to minimize the object count
496bc36eafdSMike Gerdts          */
497bc36eafdSMike Gerdts         if (!ObjDesc->Method.Mutex)
498bc36eafdSMike Gerdts         {
499bc36eafdSMike Gerdts             Status = AcpiDsCreateMethodMutex (ObjDesc);
500bc36eafdSMike Gerdts             if (ACPI_FAILURE (Status))
501bc36eafdSMike Gerdts             {
502bc36eafdSMike Gerdts                 return_ACPI_STATUS (Status);
503bc36eafdSMike Gerdts             }
504bc36eafdSMike Gerdts         }
505bc36eafdSMike Gerdts 
506bc36eafdSMike Gerdts         /*
507bc36eafdSMike Gerdts          * The CurrentSyncLevel (per-thread) must be less than or equal to
508bc36eafdSMike Gerdts          * the sync level of the method. This mechanism provides some
509bc36eafdSMike Gerdts          * deadlock prevention.
510bc36eafdSMike Gerdts          *
511bc36eafdSMike Gerdts          * If the method was auto-serialized, we just ignore the sync level
512bc36eafdSMike Gerdts          * mechanism, because auto-serialization of methods can interfere
513bc36eafdSMike Gerdts          * with ASL code that actually uses sync levels.
514bc36eafdSMike Gerdts          *
515bc36eafdSMike Gerdts          * Top-level method invocation has no walk state at this point
516bc36eafdSMike Gerdts          */
517bc36eafdSMike Gerdts         if (WalkState &&
518bc36eafdSMike Gerdts             (!(ObjDesc->Method.InfoFlags & ACPI_METHOD_IGNORE_SYNC_LEVEL)) &&
519bc36eafdSMike Gerdts             (WalkState->Thread->CurrentSyncLevel >
520bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.SyncLevel))
521bc36eafdSMike Gerdts         {
522bc36eafdSMike Gerdts             ACPI_ERROR ((AE_INFO,
523bc36eafdSMike Gerdts                 "Cannot acquire Mutex for method [%4.4s]"
524bc36eafdSMike Gerdts                 ", current SyncLevel is too large (%u)",
525bc36eafdSMike Gerdts                 AcpiUtGetNodeName (MethodNode),
526bc36eafdSMike Gerdts                 WalkState->Thread->CurrentSyncLevel));
527bc36eafdSMike Gerdts 
528bc36eafdSMike Gerdts             return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
529bc36eafdSMike Gerdts         }
530bc36eafdSMike Gerdts 
531bc36eafdSMike Gerdts         /*
532bc36eafdSMike Gerdts          * Obtain the method mutex if necessary. Do not acquire mutex for a
533bc36eafdSMike Gerdts          * recursive call.
534bc36eafdSMike Gerdts          */
535bc36eafdSMike Gerdts         if (!WalkState ||
536bc36eafdSMike Gerdts             !ObjDesc->Method.Mutex->Mutex.ThreadId ||
537bc36eafdSMike Gerdts             (WalkState->Thread->ThreadId !=
538bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.ThreadId))
539bc36eafdSMike Gerdts         {
540bc36eafdSMike Gerdts             /*
541bc36eafdSMike Gerdts              * Acquire the method mutex. This releases the interpreter if we
542bc36eafdSMike Gerdts              * block (and reacquires it before it returns)
543bc36eafdSMike Gerdts              */
544bc36eafdSMike Gerdts             Status = AcpiExSystemWaitMutex (
545bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.OsMutex, ACPI_WAIT_FOREVER);
546bc36eafdSMike Gerdts             if (ACPI_FAILURE (Status))
547bc36eafdSMike Gerdts             {
548bc36eafdSMike Gerdts                 return_ACPI_STATUS (Status);
549bc36eafdSMike Gerdts             }
550bc36eafdSMike Gerdts 
551bc36eafdSMike Gerdts             /* Update the mutex and walk info and save the original SyncLevel */
552bc36eafdSMike Gerdts 
553bc36eafdSMike Gerdts             if (WalkState)
554bc36eafdSMike Gerdts             {
555bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
556bc36eafdSMike Gerdts                     WalkState->Thread->CurrentSyncLevel;
557bc36eafdSMike Gerdts 
558bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.ThreadId =
559bc36eafdSMike Gerdts                     WalkState->Thread->ThreadId;
560bc36eafdSMike Gerdts 
561bc36eafdSMike Gerdts                 /*
562bc36eafdSMike Gerdts                  * Update the current SyncLevel only if this is not an auto-
563bc36eafdSMike Gerdts                  * serialized method. In the auto case, we have to ignore
564bc36eafdSMike Gerdts                  * the sync level for the method mutex (created for the
565bc36eafdSMike Gerdts                  * auto-serialization) because we have no idea of what the
566bc36eafdSMike Gerdts                  * sync level should be. Therefore, just ignore it.
567bc36eafdSMike Gerdts                  */
568bc36eafdSMike Gerdts                 if (!(ObjDesc->Method.InfoFlags &
569bc36eafdSMike Gerdts                     ACPI_METHOD_IGNORE_SYNC_LEVEL))
570bc36eafdSMike Gerdts                 {
571bc36eafdSMike Gerdts                     WalkState->Thread->CurrentSyncLevel =
572bc36eafdSMike Gerdts                         ObjDesc->Method.SyncLevel;
573bc36eafdSMike Gerdts                 }
574bc36eafdSMike Gerdts             }
575bc36eafdSMike Gerdts             else
576bc36eafdSMike Gerdts             {
577bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
578bc36eafdSMike Gerdts                     ObjDesc->Method.Mutex->Mutex.SyncLevel;
579bc36eafdSMike Gerdts 
580bc36eafdSMike Gerdts                 ObjDesc->Method.Mutex->Mutex.ThreadId =
581bc36eafdSMike Gerdts                     AcpiOsGetThreadId ();
582bc36eafdSMike Gerdts             }
583bc36eafdSMike Gerdts         }
584bc36eafdSMike Gerdts 
585bc36eafdSMike Gerdts         /* Always increase acquisition depth */
586bc36eafdSMike Gerdts 
587bc36eafdSMike Gerdts         ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++;
588bc36eafdSMike Gerdts     }
589bc36eafdSMike Gerdts 
590bc36eafdSMike Gerdts     /*
591bc36eafdSMike Gerdts      * Allocate an Owner ID for this method, only if this is the first thread
592bc36eafdSMike Gerdts      * to begin concurrent execution. We only need one OwnerId, even if the
593bc36eafdSMike Gerdts      * method is invoked recursively.
594bc36eafdSMike Gerdts      */
595bc36eafdSMike Gerdts     if (!ObjDesc->Method.OwnerId)
596bc36eafdSMike Gerdts     {
597bc36eafdSMike Gerdts         Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
598bc36eafdSMike Gerdts         if (ACPI_FAILURE (Status))
599bc36eafdSMike Gerdts         {
600bc36eafdSMike Gerdts             goto Cleanup;
601bc36eafdSMike Gerdts         }
602bc36eafdSMike Gerdts     }
603bc36eafdSMike Gerdts 
604bc36eafdSMike Gerdts     /*
605bc36eafdSMike Gerdts      * Increment the method parse tree thread count since it has been
606bc36eafdSMike Gerdts      * reentered one more time (even if it is the same thread)
607bc36eafdSMike Gerdts      */
608bc36eafdSMike Gerdts     ObjDesc->Method.ThreadCount++;
609bc36eafdSMike Gerdts     AcpiMethodCount++;
610bc36eafdSMike Gerdts     return_ACPI_STATUS (Status);
611bc36eafdSMike Gerdts 
612bc36eafdSMike Gerdts 
613bc36eafdSMike Gerdts Cleanup:
614bc36eafdSMike Gerdts     /* On error, must release the method mutex (if present) */
615bc36eafdSMike Gerdts 
616bc36eafdSMike Gerdts     if (ObjDesc->Method.Mutex)
617bc36eafdSMike Gerdts     {
618bc36eafdSMike Gerdts         AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex);
619bc36eafdSMike Gerdts     }
620bc36eafdSMike Gerdts     return_ACPI_STATUS (Status);
621bc36eafdSMike Gerdts }
622bc36eafdSMike Gerdts 
623bc36eafdSMike Gerdts 
624bc36eafdSMike Gerdts /*******************************************************************************
625bc36eafdSMike Gerdts  *
626bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsCallControlMethod
627bc36eafdSMike Gerdts  *
628bc36eafdSMike Gerdts  * PARAMETERS:  Thread              - Info for this thread
629bc36eafdSMike Gerdts  *              ThisWalkState       - Current walk state
630bc36eafdSMike Gerdts  *              Op                  - Current Op to be walked
631bc36eafdSMike Gerdts  *
632bc36eafdSMike Gerdts  * RETURN:      Status
633bc36eafdSMike Gerdts  *
634bc36eafdSMike Gerdts  * DESCRIPTION: Transfer execution to a called control method
635bc36eafdSMike Gerdts  *
636bc36eafdSMike Gerdts  ******************************************************************************/
637bc36eafdSMike Gerdts 
638bc36eafdSMike Gerdts ACPI_STATUS
AcpiDsCallControlMethod(ACPI_THREAD_STATE * Thread,ACPI_WALK_STATE * ThisWalkState,ACPI_PARSE_OBJECT * Op)639bc36eafdSMike Gerdts AcpiDsCallControlMethod (
640bc36eafdSMike Gerdts     ACPI_THREAD_STATE       *Thread,
641bc36eafdSMike Gerdts     ACPI_WALK_STATE         *ThisWalkState,
642bc36eafdSMike Gerdts     ACPI_PARSE_OBJECT       *Op)
643bc36eafdSMike Gerdts {
644bc36eafdSMike Gerdts     ACPI_STATUS             Status;
645bc36eafdSMike Gerdts     ACPI_NAMESPACE_NODE     *MethodNode;
646bc36eafdSMike Gerdts     ACPI_WALK_STATE         *NextWalkState = NULL;
647bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ObjDesc;
648bc36eafdSMike Gerdts     ACPI_EVALUATE_INFO      *Info;
649bc36eafdSMike Gerdts     UINT32                  i;
650bc36eafdSMike Gerdts 
651bc36eafdSMike Gerdts 
652bc36eafdSMike Gerdts     ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState);
653bc36eafdSMike Gerdts 
654bc36eafdSMike Gerdts     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
655bc36eafdSMike Gerdts         "Calling method %p, currentstate=%p\n",
656bc36eafdSMike Gerdts         ThisWalkState->PrevOp, ThisWalkState));
657bc36eafdSMike Gerdts 
658bc36eafdSMike Gerdts     /*
659bc36eafdSMike Gerdts      * Get the namespace entry for the control method we are about to call
660bc36eafdSMike Gerdts      */
661bc36eafdSMike Gerdts     MethodNode = ThisWalkState->MethodCallNode;
662bc36eafdSMike Gerdts     if (!MethodNode)
663bc36eafdSMike Gerdts     {
664bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_NULL_ENTRY);
665bc36eafdSMike Gerdts     }
666bc36eafdSMike Gerdts 
667bc36eafdSMike Gerdts     ObjDesc = AcpiNsGetAttachedObject (MethodNode);
668bc36eafdSMike Gerdts     if (!ObjDesc)
669bc36eafdSMike Gerdts     {
670bc36eafdSMike Gerdts         return_ACPI_STATUS (AE_NULL_OBJECT);
671bc36eafdSMike Gerdts     }
672bc36eafdSMike Gerdts 
673bc36eafdSMike Gerdts     /* Init for new method, possibly wait on method mutex */
674bc36eafdSMike Gerdts 
675bc36eafdSMike Gerdts     Status = AcpiDsBeginMethodExecution (
676bc36eafdSMike Gerdts         MethodNode, ObjDesc, ThisWalkState);
677bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
678bc36eafdSMike Gerdts     {
679bc36eafdSMike Gerdts         return_ACPI_STATUS (Status);
680bc36eafdSMike Gerdts     }
681bc36eafdSMike Gerdts 
682bc36eafdSMike Gerdts     /* Begin method parse/execution. Create a new walk state */
683bc36eafdSMike Gerdts 
684bc36eafdSMike Gerdts     NextWalkState = AcpiDsCreateWalkState (
685bc36eafdSMike Gerdts         ObjDesc->Method.OwnerId, NULL, ObjDesc, Thread);
686bc36eafdSMike Gerdts     if (!NextWalkState)
687bc36eafdSMike Gerdts     {
688bc36eafdSMike Gerdts         Status = AE_NO_MEMORY;
689bc36eafdSMike Gerdts         goto Cleanup;
690bc36eafdSMike Gerdts     }
691bc36eafdSMike Gerdts 
692bc36eafdSMike Gerdts     /*
693bc36eafdSMike Gerdts      * The resolved arguments were put on the previous walk state's operand
694bc36eafdSMike Gerdts      * stack. Operands on the previous walk state stack always
695bc36eafdSMike Gerdts      * start at index 0. Also, null terminate the list of arguments
696bc36eafdSMike Gerdts      */
697bc36eafdSMike Gerdts     ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;
698bc36eafdSMike Gerdts 
699bc36eafdSMike Gerdts     /*
700bc36eafdSMike Gerdts      * Allocate and initialize the evaluation information block
701bc36eafdSMike Gerdts      * TBD: this is somewhat inefficient, should change interface to
702bc36eafdSMike Gerdts      * DsInitAmlWalk. For now, keeps this struct off the CPU stack
703bc36eafdSMike Gerdts      */
704bc36eafdSMike Gerdts     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
705bc36eafdSMike Gerdts     if (!Info)
706bc36eafdSMike Gerdts     {
707bc36eafdSMike Gerdts         Status = AE_NO_MEMORY;
708bc36eafdSMike Gerdts         goto Cleanup;
709bc36eafdSMike Gerdts     }
710bc36eafdSMike Gerdts 
711bc36eafdSMike Gerdts     Info->Parameters = &ThisWalkState->Operands[0];
712bc36eafdSMike Gerdts 
713bc36eafdSMike Gerdts     Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
714bc36eafdSMike Gerdts         ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
715bc36eafdSMike Gerdts         Info, ACPI_IMODE_EXECUTE);
716bc36eafdSMike Gerdts 
717bc36eafdSMike Gerdts     ACPI_FREE (Info);
718bc36eafdSMike Gerdts     if (ACPI_FAILURE (Status))
719bc36eafdSMike Gerdts     {
720bc36eafdSMike Gerdts         goto Cleanup;
721bc36eafdSMike Gerdts     }
722bc36eafdSMike Gerdts 
723bc36eafdSMike Gerdts     /*
724bc36eafdSMike Gerdts      * Delete the operands on the previous walkstate operand stack
725bc36eafdSMike Gerdts      * (they were copied to new objects)
726bc36eafdSMike Gerdts      */
727bc36eafdSMike Gerdts     for (i = 0; i < ObjDesc->Method.ParamCount; i++)
728bc36eafdSMike Gerdts     {
729bc36eafdSMike Gerdts         AcpiUtRemoveReference (ThisWalkState->Operands [i]);
730bc36eafdSMike Gerdts         ThisWalkState->Operands [i] = NULL;
731bc36eafdSMike Gerdts     }
732bc36eafdSMike Gerdts 
733bc36eafdSMike Gerdts     /* Clear the operand stack */
734bc36eafdSMike Gerdts 
735bc36eafdSMike Gerdts     ThisWalkState->NumOperands = 0;
736bc36eafdSMike Gerdts 
737bc36eafdSMike Gerdts     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
738bc36eafdSMike Gerdts         "**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
739bc36eafdSMike Gerdts         MethodNode->Name.Ascii, NextWalkState));
740bc36eafdSMike Gerdts 
741bc36eafdSMike Gerdts     /* Invoke an internal method if necessary */
742bc36eafdSMike Gerdts 
743bc36eafdSMike Gerdts     if (ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
744bc36eafdSMike Gerdts     {
745bc36eafdSMike Gerdts         Status = ObjDesc->Method.Dispatch.Implementation (NextWalkState);
746bc36eafdSMike Gerdts         if (Status == AE_OK)
747bc36eafdSMike Gerdts         {
748bc36eafdSMike Gerdts             Status = AE_CTRL_TERMINATE;
749bc36eafdSMike Gerdts         }
750bc36eafdSMike Gerdts     }
751bc36eafdSMike Gerdts 
752bc36eafdSMike Gerdts     return_ACPI_STATUS (Status);
753bc36eafdSMike Gerdts 
754bc36eafdSMike Gerdts 
755bc36eafdSMike Gerdts Cleanup:
756bc36eafdSMike Gerdts 
757bc36eafdSMike Gerdts     /* On error, we must terminate the method properly */
758bc36eafdSMike Gerdts 
759bc36eafdSMike Gerdts     AcpiDsTerminateControlMethod (ObjDesc, NextWalkState);
760bc36eafdSMike Gerdts     AcpiDsDeleteWalkState (NextWalkState);
761bc36eafdSMike Gerdts 
762bc36eafdSMike Gerdts     return_ACPI_STATUS (Status);
763bc36eafdSMike Gerdts }
764bc36eafdSMike Gerdts 
765bc36eafdSMike Gerdts 
766bc36eafdSMike Gerdts /*******************************************************************************
767bc36eafdSMike Gerdts  *
768bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsRestartControlMethod
769bc36eafdSMike Gerdts  *
770bc36eafdSMike Gerdts  * PARAMETERS:  WalkState           - State for preempted method (caller)
771bc36eafdSMike Gerdts  *              ReturnDesc          - Return value from the called method
772bc36eafdSMike Gerdts  *
773bc36eafdSMike Gerdts  * RETURN:      Status
774bc36eafdSMike Gerdts  *
775bc36eafdSMike Gerdts  * DESCRIPTION: Restart a method that was preempted by another (nested) method
776bc36eafdSMike Gerdts  *              invocation. Handle the return value (if any) from the callee.
777bc36eafdSMike Gerdts  *
778bc36eafdSMike Gerdts  ******************************************************************************/
779bc36eafdSMike Gerdts 
780bc36eafdSMike Gerdts ACPI_STATUS
AcpiDsRestartControlMethod(ACPI_WALK_STATE * WalkState,ACPI_OPERAND_OBJECT * ReturnDesc)781bc36eafdSMike Gerdts AcpiDsRestartControlMethod (
782bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState,
783bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *ReturnDesc)
784bc36eafdSMike Gerdts {
785bc36eafdSMike Gerdts     ACPI_STATUS             Status;
786bc36eafdSMike Gerdts     int                     SameAsImplicitReturn;
787bc36eafdSMike Gerdts 
788bc36eafdSMike Gerdts 
789bc36eafdSMike Gerdts     ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState);
790bc36eafdSMike Gerdts 
791bc36eafdSMike Gerdts 
792bc36eafdSMike Gerdts     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
793bc36eafdSMike Gerdts         "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
794bc36eafdSMike Gerdts         AcpiUtGetNodeName (WalkState->MethodNode),
795bc36eafdSMike Gerdts         WalkState->MethodCallOp, ReturnDesc));
796bc36eafdSMike Gerdts 
797bc36eafdSMike Gerdts     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
798bc36eafdSMike Gerdts         "    ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n",
799bc36eafdSMike Gerdts         WalkState->ReturnUsed,
800bc36eafdSMike Gerdts         WalkState->Results, WalkState));
801bc36eafdSMike Gerdts 
802bc36eafdSMike Gerdts     /* Did the called method return a value? */
803bc36eafdSMike Gerdts 
804bc36eafdSMike Gerdts     if (ReturnDesc)
805bc36eafdSMike Gerdts     {
806bc36eafdSMike Gerdts         /* Is the implicit return object the same as the return desc? */
807bc36eafdSMike Gerdts 
808bc36eafdSMike Gerdts         SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc);
809bc36eafdSMike Gerdts 
810bc36eafdSMike Gerdts         /* Are we actually going to use the return value? */
811bc36eafdSMike Gerdts 
812bc36eafdSMike Gerdts         if (WalkState->ReturnUsed)
813bc36eafdSMike Gerdts         {
814bc36eafdSMike Gerdts             /* Save the return value from the previous method */
815bc36eafdSMike Gerdts 
816bc36eafdSMike Gerdts             Status = AcpiDsResultPush (ReturnDesc, WalkState);
817bc36eafdSMike Gerdts             if (ACPI_FAILURE (Status))
818bc36eafdSMike Gerdts             {
819bc36eafdSMike Gerdts                 AcpiUtRemoveReference (ReturnDesc);
820bc36eafdSMike Gerdts                 return_ACPI_STATUS (Status);
821bc36eafdSMike Gerdts             }
822bc36eafdSMike Gerdts 
823bc36eafdSMike Gerdts             /*
824bc36eafdSMike Gerdts              * Save as THIS method's return value in case it is returned
825bc36eafdSMike Gerdts              * immediately to yet another method
826bc36eafdSMike Gerdts              */
827bc36eafdSMike Gerdts             WalkState->ReturnDesc = ReturnDesc;
828bc36eafdSMike Gerdts         }
829bc36eafdSMike Gerdts 
830bc36eafdSMike Gerdts         /*
831bc36eafdSMike Gerdts          * The following code is the optional support for the so-called
832bc36eafdSMike Gerdts          * "implicit return". Some AML code assumes that the last value of the
833bc36eafdSMike Gerdts          * method is "implicitly" returned to the caller, in the absence of an
834bc36eafdSMike Gerdts          * explicit return value.
835bc36eafdSMike Gerdts          *
836bc36eafdSMike Gerdts          * Just save the last result of the method as the return value.
837bc36eafdSMike Gerdts          *
838bc36eafdSMike Gerdts          * NOTE: this is optional because the ASL language does not actually
839bc36eafdSMike Gerdts          * support this behavior.
840bc36eafdSMike Gerdts          */
841bc36eafdSMike Gerdts         else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) ||
842bc36eafdSMike Gerdts                  SameAsImplicitReturn)
843bc36eafdSMike Gerdts         {
844bc36eafdSMike Gerdts             /*
845bc36eafdSMike Gerdts              * Delete the return value if it will not be used by the
846bc36eafdSMike Gerdts              * calling method or remove one reference if the explicit return
847bc36eafdSMike Gerdts              * is the same as the implicit return value.
848bc36eafdSMike Gerdts              */
849bc36eafdSMike Gerdts             AcpiUtRemoveReference (ReturnDesc);
850bc36eafdSMike Gerdts         }
851bc36eafdSMike Gerdts     }
852bc36eafdSMike Gerdts 
853bc36eafdSMike Gerdts     return_ACPI_STATUS (AE_OK);
854bc36eafdSMike Gerdts }
855bc36eafdSMike Gerdts 
856bc36eafdSMike Gerdts 
857bc36eafdSMike Gerdts /*******************************************************************************
858bc36eafdSMike Gerdts  *
859bc36eafdSMike Gerdts  * FUNCTION:    AcpiDsTerminateControlMethod
860bc36eafdSMike Gerdts  *
861bc36eafdSMike Gerdts  * PARAMETERS:  MethodDesc          - Method object
862bc36eafdSMike Gerdts  *              WalkState           - State associated with the method
863bc36eafdSMike Gerdts  *
864bc36eafdSMike Gerdts  * RETURN:      None
865bc36eafdSMike Gerdts  *
866bc36eafdSMike Gerdts  * DESCRIPTION: Terminate a control method. Delete everything that the method
867bc36eafdSMike Gerdts  *              created, delete all locals and arguments, and delete the parse
868bc36eafdSMike Gerdts  *              tree if requested.
869bc36eafdSMike Gerdts  *
870bc36eafdSMike Gerdts  * MUTEX:       Interpreter is locked
871bc36eafdSMike Gerdts  *
872bc36eafdSMike Gerdts  ******************************************************************************/
873bc36eafdSMike Gerdts 
874bc36eafdSMike Gerdts void
AcpiDsTerminateControlMethod(ACPI_OPERAND_OBJECT * MethodDesc,ACPI_WALK_STATE * WalkState)875bc36eafdSMike Gerdts AcpiDsTerminateControlMethod (
876bc36eafdSMike Gerdts     ACPI_OPERAND_OBJECT     *MethodDesc,
877bc36eafdSMike Gerdts     ACPI_WALK_STATE         *WalkState)
878bc36eafdSMike Gerdts {
879bc36eafdSMike Gerdts 
880bc36eafdSMike Gerdts     ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState);
881bc36eafdSMike Gerdts 
882bc36eafdSMike Gerdts 
883bc36eafdSMike Gerdts     /* MethodDesc is required, WalkState is optional */
884bc36eafdSMike Gerdts 
885bc36eafdSMike Gerdts     if (!MethodDesc)
886bc36eafdSMike Gerdts     {
887bc36eafdSMike Gerdts         return_VOID;
888bc36eafdSMike Gerdts     }
889bc36eafdSMike Gerdts 
890bc36eafdSMike Gerdts     if (WalkState)
891bc36eafdSMike Gerdts     {
892bc36eafdSMike Gerdts         /* Delete all arguments and locals */
893bc36eafdSMike Gerdts 
894bc36eafdSMike Gerdts         AcpiDsMethodDataDeleteAll (WalkState);
895bc36eafdSMike Gerdts 
896bc36eafdSMike Gerdts         /*
897*35786f68SRobert Mustacchi          * Delete any namespace objects created anywhere within the
898*35786f68SRobert Mustacchi          * namespace by the execution of this method. Unless:
899*35786f68SRobert Mustacchi          * 1) This method is a module-level executable code method, in which
900*35786f68SRobert Mustacchi          *    case we want make the objects permanent.
901*35786f68SRobert Mustacchi          * 2) There are other threads executing the method, in which case we
902*35786f68SRobert Mustacchi          *    will wait until the last thread has completed.
903*35786f68SRobert Mustacchi          */
904*35786f68SRobert Mustacchi         if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) &&
905*35786f68SRobert Mustacchi              (MethodDesc->Method.ThreadCount == 1))
906*35786f68SRobert Mustacchi         {
907*35786f68SRobert Mustacchi             /* Delete any direct children of (created by) this method */
908*35786f68SRobert Mustacchi 
909*35786f68SRobert Mustacchi             (void) AcpiExExitInterpreter ();
910*35786f68SRobert Mustacchi             AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode);
911*35786f68SRobert Mustacchi             (void) AcpiExEnterInterpreter ();
912*35786f68SRobert Mustacchi 
913*35786f68SRobert Mustacchi             /*
914*35786f68SRobert Mustacchi              * Delete any objects that were created by this method
915*35786f68SRobert Mustacchi              * elsewhere in the namespace (if any were created).
916*35786f68SRobert Mustacchi              * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
917*35786f68SRobert Mustacchi              * deletion such that we don't have to perform an entire
918*35786f68SRobert Mustacchi              * namespace walk for every control method execution.
919*35786f68SRobert Mustacchi              */
920*35786f68SRobert Mustacchi             if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE)
921*35786f68SRobert Mustacchi             {
922*35786f68SRobert Mustacchi                 (void) AcpiExExitInterpreter ();
923*35786f68SRobert Mustacchi                 AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId);
924*35786f68SRobert Mustacchi                 (void) AcpiExEnterInterpreter ();
925*35786f68SRobert Mustacchi                 MethodDesc->Method.InfoFlags &=
926*35786f68SRobert Mustacchi                     ~ACPI_METHOD_MODIFIED_NAMESPACE;
927*35786f68SRobert Mustacchi             }
928*35786f68SRobert Mustacchi         }
929*35786f68SRobert Mustacchi 
930*35786f68SRobert Mustacchi         /*
931bc36eafdSMike Gerdts          * If method is serialized, release the mutex and restore the
932bc36eafdSMike Gerdts          * current sync level for this thread
933bc36eafdSMike Gerdts          */
934bc36eafdSMike Gerdts         if (MethodDesc->Method.Mutex)
935bc36eafdSMike Gerdts         {
936bc36eafdSMike Gerdts             /* Acquisition Depth handles recursive calls */
937bc36eafdSMike Gerdts 
938bc36eafdSMike Gerdts             MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--;
939bc36eafdSMike Gerdts             if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth)
940bc36eafdSMike Gerdts             {
941bc36eafdSMike Gerdts                 WalkState->Thread->CurrentSyncLevel =
942bc36eafdSMike Gerdts                     MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel;
943bc36eafdSMike Gerdts 
944bc36eafdSMike Gerdts                 AcpiOsReleaseMutex (
945bc36eafdSMike Gerdts                     MethodDesc->Method.Mutex->Mutex.OsMutex);
946bc36eafdSMike Gerdts                 MethodDesc->Method.Mutex->Mutex.ThreadId = 0;
947bc36eafdSMike Gerdts             }
948bc36eafdSMike Gerdts         }
949bc36eafdSMike Gerdts     }
950bc36eafdSMike Gerdts 
951bc36eafdSMike Gerdts     /* Decrement the thread count on the method */
952bc36eafdSMike Gerdts 
953bc36eafdSMike Gerdts     if (MethodDesc->Method.ThreadCount)
954bc36eafdSMike Gerdts     {
955bc36eafdSMike Gerdts         MethodDesc->Method.ThreadCount--;
956bc36eafdSMike Gerdts     }
957bc36eafdSMike Gerdts     else
958bc36eafdSMike Gerdts     {
959bc36eafdSMike Gerdts         ACPI_ERROR ((AE_INFO,
960bc36eafdSMike Gerdts             "Invalid zero thread count in method"));
961bc36eafdSMike Gerdts     }
962bc36eafdSMike Gerdts 
963bc36eafdSMike Gerdts     /* Are there any other threads currently executing this method? */
964bc36eafdSMike Gerdts 
965bc36eafdSMike Gerdts     if (MethodDesc->Method.ThreadCount)
966bc36eafdSMike Gerdts     {
967bc36eafdSMike Gerdts         /*
968bc36eafdSMike Gerdts          * Additional threads. Do not release the OwnerId in this case,
969bc36eafdSMike Gerdts          * we immediately reuse it for the next thread executing this method
970bc36eafdSMike Gerdts          */
971bc36eafdSMike Gerdts         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
972bc36eafdSMike Gerdts             "*** Completed execution of one thread, %u threads remaining\n",
973bc36eafdSMike Gerdts             MethodDesc->Method.ThreadCount));
974bc36eafdSMike Gerdts     }
975bc36eafdSMike Gerdts     else
976bc36eafdSMike Gerdts     {
977bc36eafdSMike Gerdts         /* This is the only executing thread for this method */
978bc36eafdSMike Gerdts 
979bc36eafdSMike Gerdts         /*
980bc36eafdSMike Gerdts          * Support to dynamically change a method from NotSerialized to
981bc36eafdSMike Gerdts          * Serialized if it appears that the method is incorrectly written and
982bc36eafdSMike Gerdts          * does not support multiple thread execution. The best example of this
983bc36eafdSMike Gerdts          * is if such a method creates namespace objects and blocks. A second
984bc36eafdSMike Gerdts          * thread will fail with an AE_ALREADY_EXISTS exception.
985bc36eafdSMike Gerdts          *
986bc36eafdSMike Gerdts          * This code is here because we must wait until the last thread exits
987bc36eafdSMike Gerdts          * before marking the method as serialized.
988bc36eafdSMike Gerdts          */
989bc36eafdSMike Gerdts         if (MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED_PENDING)
990bc36eafdSMike Gerdts         {
991bc36eafdSMike Gerdts             if (WalkState)
992bc36eafdSMike Gerdts             {
993bc36eafdSMike Gerdts                 ACPI_INFO ((
994bc36eafdSMike Gerdts                     "Marking method %4.4s as Serialized "
995bc36eafdSMike Gerdts                     "because of AE_ALREADY_EXISTS error",
996bc36eafdSMike Gerdts                     WalkState->MethodNode->Name.Ascii));
997bc36eafdSMike Gerdts             }
998bc36eafdSMike Gerdts 
999bc36eafdSMike Gerdts             /*
1000bc36eafdSMike Gerdts              * Method tried to create an object twice and was marked as
1001bc36eafdSMike Gerdts              * "pending serialized". The probable cause is that the method
1002bc36eafdSMike Gerdts              * cannot handle reentrancy.
1003bc36eafdSMike Gerdts              *
1004bc36eafdSMike Gerdts              * The method was created as NotSerialized, but it tried to create
1005bc36eafdSMike Gerdts              * a named object and then blocked, causing the second thread
1006bc36eafdSMike Gerdts              * entrance to begin and then fail. Workaround this problem by
1007bc36eafdSMike Gerdts              * marking the method permanently as Serialized when the last
1008bc36eafdSMike Gerdts              * thread exits here.
1009bc36eafdSMike Gerdts              */
1010bc36eafdSMike Gerdts             MethodDesc->Method.InfoFlags &=
1011bc36eafdSMike Gerdts                 ~ACPI_METHOD_SERIALIZED_PENDING;
1012bc36eafdSMike Gerdts 
1013bc36eafdSMike Gerdts             MethodDesc->Method.InfoFlags |=
1014bc36eafdSMike Gerdts                 (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL);
1015bc36eafdSMike Gerdts             MethodDesc->Method.SyncLevel = 0;
1016bc36eafdSMike Gerdts         }
1017bc36eafdSMike Gerdts 
1018bc36eafdSMike Gerdts         /* No more threads, we can free the OwnerId */
1019bc36eafdSMike Gerdts 
1020bc36eafdSMike Gerdts         if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL))
1021bc36eafdSMike Gerdts         {
1022bc36eafdSMike Gerdts             AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId);
1023bc36eafdSMike Gerdts         }
1024bc36eafdSMike Gerdts     }
1025bc36eafdSMike Gerdts 
1026bc36eafdSMike Gerdts     AcpiExStopTraceMethod ((ACPI_NAMESPACE_NODE *) MethodDesc->Method.Node,
1027bc36eafdSMike Gerdts         MethodDesc, WalkState);
1028bc36eafdSMike Gerdts 
1029bc36eafdSMike Gerdts     return_VOID;
1030bc36eafdSMike Gerdts }
1031