Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/dispatcher/dsmethod.c
+++ new/usr/src/common/acpica/components/dispatcher/dsmethod.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __DSMETHOD_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acdispat.h"
49 49 #include "acinterp.h"
50 50 #include "acnamesp.h"
51 51 #include "acdisasm.h"
52 52
53 53
54 54 #define _COMPONENT ACPI_DISPATCHER
55 55 ACPI_MODULE_NAME ("dsmethod")
56 56
57 57 /* Local prototypes */
58 58
59 59 static ACPI_STATUS
60 60 AcpiDsCreateMethodMutex (
61 61 ACPI_OPERAND_OBJECT *MethodDesc);
62 62
63 63
64 64 /*******************************************************************************
65 65 *
66 66 * FUNCTION: AcpiDsMethodError
67 67 *
68 68 * PARAMETERS: Status - Execution status
69 69 * WalkState - Current state
70 70 *
71 71 * RETURN: Status
72 72 *
73 73 * DESCRIPTION: Called on method error. Invoke the global exception handler if
74 74 * present, dump the method data if the disassembler is configured
75 75 *
76 76 * Note: Allows the exception handler to change the status code
77 77 *
78 78 ******************************************************************************/
79 79
80 80 ACPI_STATUS
81 81 AcpiDsMethodError (
82 82 ACPI_STATUS Status,
83 83 ACPI_WALK_STATE *WalkState)
84 84 {
85 85 ACPI_FUNCTION_ENTRY ();
86 86
87 87
88 88 /* Ignore AE_OK and control exception codes */
89 89
90 90 if (ACPI_SUCCESS (Status) ||
91 91 (Status & AE_CODE_CONTROL))
92 92 {
93 93 return (Status);
94 94 }
95 95
96 96 /* Invoke the global exception handler */
97 97
98 98 if (AcpiGbl_ExceptionHandler)
99 99 {
100 100 /* Exit the interpreter, allow handler to execute methods */
101 101
102 102 AcpiExExitInterpreter ();
103 103
104 104 /*
105 105 * Handler can map the exception code to anything it wants, including
106 106 * AE_OK, in which case the executing method will not be aborted.
107 107 */
108 108 Status = AcpiGbl_ExceptionHandler (Status,
109 109 WalkState->MethodNode ?
110 110 WalkState->MethodNode->Name.Integer : 0,
111 111 WalkState->Opcode, WalkState->AmlOffset, NULL);
112 112 AcpiExEnterInterpreter ();
113 113 }
114 114
115 115 AcpiDsClearImplicitReturn (WalkState);
116 116
117 117 #ifdef ACPI_DISASSEMBLER
118 118 if (ACPI_FAILURE (Status))
119 119 {
120 120 /* Display method locals/args if disassembler is present */
121 121
122 122 AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op);
123 123 }
124 124 #endif
125 125
126 126 return (Status);
127 127 }
128 128
129 129
130 130 /*******************************************************************************
131 131 *
132 132 * FUNCTION: AcpiDsCreateMethodMutex
133 133 *
134 134 * PARAMETERS: ObjDesc - The method object
135 135 *
136 136 * RETURN: Status
137 137 *
138 138 * DESCRIPTION: Create a mutex object for a serialized control method
139 139 *
140 140 ******************************************************************************/
141 141
142 142 static ACPI_STATUS
143 143 AcpiDsCreateMethodMutex (
144 144 ACPI_OPERAND_OBJECT *MethodDesc)
145 145 {
146 146 ACPI_OPERAND_OBJECT *MutexDesc;
147 147 ACPI_STATUS Status;
148 148
149 149
150 150 ACPI_FUNCTION_TRACE (DsCreateMethodMutex);
151 151
152 152
153 153 /* Create the new mutex object */
154 154
155 155 MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
↓ open down ↓ |
137 lines elided |
↑ open up ↑ |
156 156 if (!MutexDesc)
157 157 {
158 158 return_ACPI_STATUS (AE_NO_MEMORY);
159 159 }
160 160
161 161 /* Create the actual OS Mutex */
162 162
163 163 Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex);
164 164 if (ACPI_FAILURE (Status))
165 165 {
166 + AcpiUtDeleteObjectDesc (MutexDesc);
166 167 return_ACPI_STATUS (Status);
167 168 }
168 169
169 170 MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel;
170 171 MethodDesc->Method.Mutex = MutexDesc;
171 172 return_ACPI_STATUS (AE_OK);
172 173 }
173 174
174 175
175 176 /*******************************************************************************
176 177 *
177 178 * FUNCTION: AcpiDsBeginMethodExecution
178 179 *
179 180 * PARAMETERS: MethodNode - Node of the method
180 181 * ObjDesc - The method object
181 182 * WalkState - current state, NULL if not yet executing
182 183 * a method.
183 184 *
184 185 * RETURN: Status
185 186 *
186 - * DESCRIPTION: Prepare a method for execution. Parses the method if necessary,
187 + * DESCRIPTION: Prepare a method for execution. Parses the method if necessary,
187 188 * increments the thread count, and waits at the method semaphore
188 189 * for clearance to execute.
189 190 *
190 191 ******************************************************************************/
191 192
192 193 ACPI_STATUS
193 194 AcpiDsBeginMethodExecution (
194 195 ACPI_NAMESPACE_NODE *MethodNode,
195 196 ACPI_OPERAND_OBJECT *ObjDesc,
196 197 ACPI_WALK_STATE *WalkState)
197 198 {
198 199 ACPI_STATUS Status = AE_OK;
199 200
200 201
201 202 ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode);
202 203
203 204
204 205 if (!MethodNode)
205 206 {
206 207 return_ACPI_STATUS (AE_NULL_ENTRY);
207 208 }
208 209
209 210 /* Prevent wraparound of thread count */
210 211
211 212 if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX)
212 213 {
213 214 ACPI_ERROR ((AE_INFO,
214 215 "Method reached maximum reentrancy limit (255)"));
215 216 return_ACPI_STATUS (AE_AML_METHOD_LIMIT);
216 217 }
217 218
218 219 /*
219 220 * If this method is serialized, we need to acquire the method mutex.
220 221 */
221 222 if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)
222 223 {
223 224 /*
224 225 * Create a mutex for the method if it is defined to be Serialized
225 226 * and a mutex has not already been created. We defer the mutex creation
226 227 * until a method is actually executed, to minimize the object count
227 228 */
228 229 if (!ObjDesc->Method.Mutex)
229 230 {
230 231 Status = AcpiDsCreateMethodMutex (ObjDesc);
231 232 if (ACPI_FAILURE (Status))
232 233 {
233 234 return_ACPI_STATUS (Status);
234 235 }
235 236 }
236 237
237 238 /*
238 239 * The CurrentSyncLevel (per-thread) must be less than or equal to
239 240 * the sync level of the method. This mechanism provides some
240 241 * deadlock prevention
241 242 *
242 243 * Top-level method invocation has no walk state at this point
243 244 */
244 245 if (WalkState &&
245 246 (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel))
246 247 {
247 248 ACPI_ERROR ((AE_INFO,
248 249 "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)",
249 250 AcpiUtGetNodeName (MethodNode),
250 251 WalkState->Thread->CurrentSyncLevel));
251 252
252 253 return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
253 254 }
254 255
255 256 /*
256 257 * Obtain the method mutex if necessary. Do not acquire mutex for a
257 258 * recursive call.
258 259 */
259 260 if (!WalkState ||
260 261 !ObjDesc->Method.Mutex->Mutex.ThreadId ||
261 262 (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId))
262 263 {
263 264 /*
264 265 * Acquire the method mutex. This releases the interpreter if we
265 266 * block (and reacquires it before it returns)
266 267 */
267 268 Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex,
268 269 ACPI_WAIT_FOREVER);
269 270 if (ACPI_FAILURE (Status))
270 271 {
271 272 return_ACPI_STATUS (Status);
272 273 }
273 274
274 275 /* Update the mutex and walk info and save the original SyncLevel */
275 276
276 277 if (WalkState)
277 278 {
278 279 ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
279 280 WalkState->Thread->CurrentSyncLevel;
280 281
281 282 ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId;
282 283 WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel;
283 284 }
284 285 else
285 286 {
286 287 ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
287 288 ObjDesc->Method.Mutex->Mutex.SyncLevel;
288 289 }
289 290 }
290 291
291 292 /* Always increase acquisition depth */
292 293
293 294 ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++;
294 295 }
295 296
296 297 /*
297 298 * Allocate an Owner ID for this method, only if this is the first thread
298 299 * to begin concurrent execution. We only need one OwnerId, even if the
299 300 * method is invoked recursively.
300 301 */
301 302 if (!ObjDesc->Method.OwnerId)
302 303 {
303 304 Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
304 305 if (ACPI_FAILURE (Status))
305 306 {
306 307 goto Cleanup;
307 308 }
308 309 }
309 310
310 311 /*
311 312 * Increment the method parse tree thread count since it has been
312 313 * reentered one more time (even if it is the same thread)
313 314 */
314 315 ObjDesc->Method.ThreadCount++;
315 316 AcpiMethodCount++;
316 317 return_ACPI_STATUS (Status);
317 318
318 319
319 320 Cleanup:
320 321 /* On error, must release the method mutex (if present) */
321 322
322 323 if (ObjDesc->Method.Mutex)
323 324 {
324 325 AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex);
325 326 }
326 327 return_ACPI_STATUS (Status);
327 328 }
328 329
329 330
330 331 /*******************************************************************************
331 332 *
332 333 * FUNCTION: AcpiDsCallControlMethod
333 334 *
334 335 * PARAMETERS: Thread - Info for this thread
335 336 * ThisWalkState - Current walk state
336 337 * Op - Current Op to be walked
337 338 *
338 339 * RETURN: Status
339 340 *
340 341 * DESCRIPTION: Transfer execution to a called control method
341 342 *
342 343 ******************************************************************************/
343 344
344 345 ACPI_STATUS
345 346 AcpiDsCallControlMethod (
346 347 ACPI_THREAD_STATE *Thread,
347 348 ACPI_WALK_STATE *ThisWalkState,
348 349 ACPI_PARSE_OBJECT *Op)
349 350 {
350 351 ACPI_STATUS Status;
351 352 ACPI_NAMESPACE_NODE *MethodNode;
352 353 ACPI_WALK_STATE *NextWalkState = NULL;
353 354 ACPI_OPERAND_OBJECT *ObjDesc;
354 355 ACPI_EVALUATE_INFO *Info;
355 356 UINT32 i;
356 357
357 358
358 359 ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState);
359 360
360 361 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n",
361 362 ThisWalkState->PrevOp, ThisWalkState));
362 363
363 364 /*
364 365 * Get the namespace entry for the control method we are about to call
365 366 */
366 367 MethodNode = ThisWalkState->MethodCallNode;
367 368 if (!MethodNode)
368 369 {
369 370 return_ACPI_STATUS (AE_NULL_ENTRY);
370 371 }
371 372
372 373 ObjDesc = AcpiNsGetAttachedObject (MethodNode);
373 374 if (!ObjDesc)
374 375 {
375 376 return_ACPI_STATUS (AE_NULL_OBJECT);
376 377 }
377 378
378 379 /* Init for new method, possibly wait on method mutex */
379 380
380 381 Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc,
381 382 ThisWalkState);
382 383 if (ACPI_FAILURE (Status))
383 384 {
384 385 return_ACPI_STATUS (Status);
385 386 }
386 387
387 388 /* Begin method parse/execution. Create a new walk state */
388 389
389 390 NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId,
390 391 NULL, ObjDesc, Thread);
391 392 if (!NextWalkState)
392 393 {
393 394 Status = AE_NO_MEMORY;
394 395 goto Cleanup;
395 396 }
396 397
397 398 /*
398 399 * The resolved arguments were put on the previous walk state's operand
399 400 * stack. Operands on the previous walk state stack always
400 401 * start at index 0. Also, null terminate the list of arguments
401 402 */
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
402 403 ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;
403 404
404 405 /*
405 406 * Allocate and initialize the evaluation information block
406 407 * TBD: this is somewhat inefficient, should change interface to
407 408 * DsInitAmlWalk. For now, keeps this struct off the CPU stack
408 409 */
409 410 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
410 411 if (!Info)
411 412 {
412 - return_ACPI_STATUS (AE_NO_MEMORY);
413 + Status = AE_NO_MEMORY;
414 + goto Cleanup;
413 415 }
414 416
415 417 Info->Parameters = &ThisWalkState->Operands[0];
416 418
417 419 Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
418 420 ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
419 421 Info, ACPI_IMODE_EXECUTE);
420 422
421 423 ACPI_FREE (Info);
422 424 if (ACPI_FAILURE (Status))
423 425 {
424 426 goto Cleanup;
425 427 }
426 428
427 429 /*
428 430 * Delete the operands on the previous walkstate operand stack
429 431 * (they were copied to new objects)
430 432 */
431 433 for (i = 0; i < ObjDesc->Method.ParamCount; i++)
432 434 {
433 435 AcpiUtRemoveReference (ThisWalkState->Operands [i]);
434 436 ThisWalkState->Operands [i] = NULL;
435 437 }
436 438
437 439 /* Clear the operand stack */
438 440
439 441 ThisWalkState->NumOperands = 0;
440 442
441 443 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
442 444 "**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
443 445 MethodNode->Name.Ascii, NextWalkState));
444 446
445 447 /* Invoke an internal method if necessary */
446 448
447 449 if (ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
448 450 {
449 451 Status = ObjDesc->Method.Dispatch.Implementation (NextWalkState);
450 452 if (Status == AE_OK)
451 453 {
452 454 Status = AE_CTRL_TERMINATE;
453 455 }
454 456 }
455 457
456 458 return_ACPI_STATUS (Status);
457 459
458 460
459 461 Cleanup:
460 462
461 463 /* On error, we must terminate the method properly */
462 464
463 465 AcpiDsTerminateControlMethod (ObjDesc, NextWalkState);
464 466 if (NextWalkState)
465 467 {
466 468 AcpiDsDeleteWalkState (NextWalkState);
467 469 }
468 470
469 471 return_ACPI_STATUS (Status);
470 472 }
471 473
472 474
↓ open down ↓ |
50 lines elided |
↑ open up ↑ |
473 475 /*******************************************************************************
474 476 *
475 477 * FUNCTION: AcpiDsRestartControlMethod
476 478 *
477 479 * PARAMETERS: WalkState - State for preempted method (caller)
478 480 * ReturnDesc - Return value from the called method
479 481 *
480 482 * RETURN: Status
481 483 *
482 484 * DESCRIPTION: Restart a method that was preempted by another (nested) method
483 - * invocation. Handle the return value (if any) from the callee.
485 + * invocation. Handle the return value (if any) from the callee.
484 486 *
485 487 ******************************************************************************/
486 488
487 489 ACPI_STATUS
488 490 AcpiDsRestartControlMethod (
489 491 ACPI_WALK_STATE *WalkState,
490 492 ACPI_OPERAND_OBJECT *ReturnDesc)
491 493 {
492 494 ACPI_STATUS Status;
493 495 int SameAsImplicitReturn;
494 496
495 497
496 498 ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState);
497 499
498 500
499 501 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
500 502 "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
501 503 AcpiUtGetNodeName (WalkState->MethodNode),
502 504 WalkState->MethodCallOp, ReturnDesc));
503 505
504 506 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
505 507 " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n",
506 508 WalkState->ReturnUsed,
507 509 WalkState->Results, WalkState));
508 510
509 511 /* Did the called method return a value? */
510 512
511 513 if (ReturnDesc)
512 514 {
513 515 /* Is the implicit return object the same as the return desc? */
514 516
515 517 SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc);
516 518
517 519 /* Are we actually going to use the return value? */
518 520
519 521 if (WalkState->ReturnUsed)
520 522 {
521 523 /* Save the return value from the previous method */
522 524
523 525 Status = AcpiDsResultPush (ReturnDesc, WalkState);
524 526 if (ACPI_FAILURE (Status))
525 527 {
526 528 AcpiUtRemoveReference (ReturnDesc);
527 529 return_ACPI_STATUS (Status);
528 530 }
529 531
530 532 /*
531 533 * Save as THIS method's return value in case it is returned
532 534 * immediately to yet another method
533 535 */
534 536 WalkState->ReturnDesc = ReturnDesc;
535 537 }
536 538
537 539 /*
538 540 * The following code is the optional support for the so-called
539 541 * "implicit return". Some AML code assumes that the last value of the
540 542 * method is "implicitly" returned to the caller, in the absence of an
541 543 * explicit return value.
542 544 *
543 545 * Just save the last result of the method as the return value.
544 546 *
545 547 * NOTE: this is optional because the ASL language does not actually
546 548 * support this behavior.
547 549 */
548 550 else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) ||
549 551 SameAsImplicitReturn)
550 552 {
551 553 /*
552 554 * Delete the return value if it will not be used by the
553 555 * calling method or remove one reference if the explicit return
554 556 * is the same as the implicit return value.
555 557 */
556 558 AcpiUtRemoveReference (ReturnDesc);
557 559 }
558 560 }
559 561
560 562 return_ACPI_STATUS (AE_OK);
561 563 }
562 564
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
563 565
564 566 /*******************************************************************************
565 567 *
566 568 * FUNCTION: AcpiDsTerminateControlMethod
567 569 *
568 570 * PARAMETERS: MethodDesc - Method object
569 571 * WalkState - State associated with the method
570 572 *
571 573 * RETURN: None
572 574 *
573 - * DESCRIPTION: Terminate a control method. Delete everything that the method
575 + * DESCRIPTION: Terminate a control method. Delete everything that the method
574 576 * created, delete all locals and arguments, and delete the parse
575 577 * tree if requested.
576 578 *
577 579 * MUTEX: Interpreter is locked
578 580 *
579 581 ******************************************************************************/
580 582
581 583 void
582 584 AcpiDsTerminateControlMethod (
583 585 ACPI_OPERAND_OBJECT *MethodDesc,
584 586 ACPI_WALK_STATE *WalkState)
585 587 {
586 588
587 589 ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState);
588 590
589 591
590 592 /* MethodDesc is required, WalkState is optional */
591 593
592 594 if (!MethodDesc)
593 595 {
594 596 return_VOID;
595 597 }
596 598
597 599 if (WalkState)
598 600 {
599 601 /* Delete all arguments and locals */
600 602
601 603 AcpiDsMethodDataDeleteAll (WalkState);
602 604
603 605 /*
604 606 * If method is serialized, release the mutex and restore the
605 607 * current sync level for this thread
606 608 */
607 609 if (MethodDesc->Method.Mutex)
608 610 {
609 611 /* Acquisition Depth handles recursive calls */
610 612
611 613 MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--;
612 614 if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth)
613 615 {
614 616 WalkState->Thread->CurrentSyncLevel =
615 617 MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel;
616 618
617 619 AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex);
618 620 MethodDesc->Method.Mutex->Mutex.ThreadId = 0;
619 621 }
620 622 }
621 623
622 624 /*
623 625 * Delete any namespace objects created anywhere within the
624 626 * namespace by the execution of this method. Unless:
625 627 * 1) This method is a module-level executable code method, in which
626 628 * case we want make the objects permanent.
627 629 * 2) There are other threads executing the method, in which case we
628 630 * will wait until the last thread has completed.
629 631 */
630 632 if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) &&
631 633 (MethodDesc->Method.ThreadCount == 1))
632 634 {
633 635 /* Delete any direct children of (created by) this method */
634 636
635 637 AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode);
636 638
637 639 /*
638 640 * Delete any objects that were created by this method
639 641 * elsewhere in the namespace (if any were created).
640 642 * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
641 643 * deletion such that we don't have to perform an entire
642 644 * namespace walk for every control method execution.
643 645 */
644 646 if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE)
645 647 {
646 648 AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId);
647 649 MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_MODIFIED_NAMESPACE;
648 650 }
649 651 }
650 652 }
651 653
652 654 /* Decrement the thread count on the method */
653 655
654 656 if (MethodDesc->Method.ThreadCount)
655 657 {
656 658 MethodDesc->Method.ThreadCount--;
657 659 }
658 660 else
659 661 {
660 662 ACPI_ERROR ((AE_INFO,
661 663 "Invalid zero thread count in method"));
662 664 }
663 665
664 666 /* Are there any other threads currently executing this method? */
665 667
666 668 if (MethodDesc->Method.ThreadCount)
667 669 {
668 670 /*
669 671 * Additional threads. Do not release the OwnerId in this case,
670 672 * we immediately reuse it for the next thread executing this method
671 673 */
672 674 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
673 675 "*** Completed execution of one thread, %u threads remaining\n",
674 676 MethodDesc->Method.ThreadCount));
675 677 }
676 678 else
677 679 {
678 680 /* This is the only executing thread for this method */
679 681
680 682 /*
681 683 * Support to dynamically change a method from NotSerialized to
682 684 * Serialized if it appears that the method is incorrectly written and
683 685 * does not support multiple thread execution. The best example of this
684 686 * is if such a method creates namespace objects and blocks. A second
685 687 * thread will fail with an AE_ALREADY_EXISTS exception.
686 688 *
687 689 * This code is here because we must wait until the last thread exits
688 690 * before marking the method as serialized.
689 691 */
690 692 if (MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED_PENDING)
691 693 {
692 694 if (WalkState)
693 695 {
694 696 ACPI_INFO ((AE_INFO,
695 697 "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
696 698 WalkState->MethodNode->Name.Ascii));
697 699 }
698 700
699 701 /*
700 702 * Method tried to create an object twice and was marked as
701 703 * "pending serialized". The probable cause is that the method
702 704 * cannot handle reentrancy.
703 705 *
704 706 * The method was created as NotSerialized, but it tried to create
705 707 * a named object and then blocked, causing the second thread
706 708 * entrance to begin and then fail. Workaround this problem by
707 709 * marking the method permanently as Serialized when the last
708 710 * thread exits here.
709 711 */
710 712 MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_SERIALIZED_PENDING;
711 713 MethodDesc->Method.InfoFlags |= ACPI_METHOD_SERIALIZED;
712 714 MethodDesc->Method.SyncLevel = 0;
713 715 }
714 716
↓ open down ↓ |
131 lines elided |
↑ open up ↑ |
715 717 /* No more threads, we can free the OwnerId */
716 718
717 719 if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL))
718 720 {
719 721 AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId);
720 722 }
721 723 }
722 724
723 725 return_VOID;
724 726 }
725 -
726 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX