dsmethod.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /******************************************************************************
  2. *
  3. * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2013, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acdispat.h"
  45. #include "acinterp.h"
  46. #include "acnamesp.h"
  47. #ifdef ACPI_DISASSEMBLER
  48. #include "acdisasm.h"
  49. #endif
  50. #define _COMPONENT ACPI_DISPATCHER
  51. ACPI_MODULE_NAME("dsmethod")
  52. /* Local prototypes */
  53. static acpi_status
  54. acpi_ds_create_method_mutex(union acpi_operand_object *method_desc);
  55. /*******************************************************************************
  56. *
  57. * FUNCTION: acpi_ds_method_error
  58. *
  59. * PARAMETERS: status - Execution status
  60. * walk_state - Current state
  61. *
  62. * RETURN: Status
  63. *
  64. * DESCRIPTION: Called on method error. Invoke the global exception handler if
  65. * present, dump the method data if the disassembler is configured
  66. *
  67. * Note: Allows the exception handler to change the status code
  68. *
  69. ******************************************************************************/
  70. acpi_status
  71. acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
  72. {
  73. ACPI_FUNCTION_ENTRY();
  74. /* Ignore AE_OK and control exception codes */
  75. if (ACPI_SUCCESS(status) || (status & AE_CODE_CONTROL)) {
  76. return (status);
  77. }
  78. /* Invoke the global exception handler */
  79. if (acpi_gbl_exception_handler) {
  80. /* Exit the interpreter, allow handler to execute methods */
  81. acpi_ex_exit_interpreter();
  82. /*
  83. * Handler can map the exception code to anything it wants, including
  84. * AE_OK, in which case the executing method will not be aborted.
  85. */
  86. status = acpi_gbl_exception_handler(status,
  87. walk_state->method_node ?
  88. walk_state->method_node->
  89. name.integer : 0,
  90. walk_state->opcode,
  91. walk_state->aml_offset,
  92. NULL);
  93. acpi_ex_enter_interpreter();
  94. }
  95. acpi_ds_clear_implicit_return(walk_state);
  96. #ifdef ACPI_DISASSEMBLER
  97. if (ACPI_FAILURE(status)) {
  98. /* Display method locals/args if disassembler is present */
  99. acpi_dm_dump_method_info(status, walk_state, walk_state->op);
  100. }
  101. #endif
  102. return (status);
  103. }
  104. /*******************************************************************************
  105. *
  106. * FUNCTION: acpi_ds_create_method_mutex
  107. *
  108. * PARAMETERS: obj_desc - The method object
  109. *
  110. * RETURN: Status
  111. *
  112. * DESCRIPTION: Create a mutex object for a serialized control method
  113. *
  114. ******************************************************************************/
  115. static acpi_status
  116. acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
  117. {
  118. union acpi_operand_object *mutex_desc;
  119. acpi_status status;
  120. ACPI_FUNCTION_TRACE(ds_create_method_mutex);
  121. /* Create the new mutex object */
  122. mutex_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
  123. if (!mutex_desc) {
  124. return_ACPI_STATUS(AE_NO_MEMORY);
  125. }
  126. /* Create the actual OS Mutex */
  127. status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);
  128. if (ACPI_FAILURE(status)) {
  129. acpi_ut_delete_object_desc(mutex_desc);
  130. return_ACPI_STATUS(status);
  131. }
  132. mutex_desc->mutex.sync_level = method_desc->method.sync_level;
  133. method_desc->method.mutex = mutex_desc;
  134. return_ACPI_STATUS(AE_OK);
  135. }
  136. /*******************************************************************************
  137. *
  138. * FUNCTION: acpi_ds_begin_method_execution
  139. *
  140. * PARAMETERS: method_node - Node of the method
  141. * obj_desc - The method object
  142. * walk_state - current state, NULL if not yet executing
  143. * a method.
  144. *
  145. * RETURN: Status
  146. *
  147. * DESCRIPTION: Prepare a method for execution. Parses the method if necessary,
  148. * increments the thread count, and waits at the method semaphore
  149. * for clearance to execute.
  150. *
  151. ******************************************************************************/
  152. acpi_status
  153. acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
  154. union acpi_operand_object *obj_desc,
  155. struct acpi_walk_state *walk_state)
  156. {
  157. acpi_status status = AE_OK;
  158. ACPI_FUNCTION_TRACE_PTR(ds_begin_method_execution, method_node);
  159. if (!method_node) {
  160. return_ACPI_STATUS(AE_NULL_ENTRY);
  161. }
  162. /* Prevent wraparound of thread count */
  163. if (obj_desc->method.thread_count == ACPI_UINT8_MAX) {
  164. ACPI_ERROR((AE_INFO,
  165. "Method reached maximum reentrancy limit (255)"));
  166. return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
  167. }
  168. /*
  169. * If this method is serialized, we need to acquire the method mutex.
  170. */
  171. if (obj_desc->method.info_flags & ACPI_METHOD_SERIALIZED) {
  172. /*
  173. * Create a mutex for the method if it is defined to be Serialized
  174. * and a mutex has not already been created. We defer the mutex creation
  175. * until a method is actually executed, to minimize the object count
  176. */
  177. if (!obj_desc->method.mutex) {
  178. status = acpi_ds_create_method_mutex(obj_desc);
  179. if (ACPI_FAILURE(status)) {
  180. return_ACPI_STATUS(status);
  181. }
  182. }
  183. /*
  184. * The current_sync_level (per-thread) must be less than or equal to
  185. * the sync level of the method. This mechanism provides some
  186. * deadlock prevention
  187. *
  188. * Top-level method invocation has no walk state at this point
  189. */
  190. if (walk_state &&
  191. (walk_state->thread->current_sync_level >
  192. obj_desc->method.mutex->mutex.sync_level)) {
  193. ACPI_ERROR((AE_INFO,
  194. "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)",
  195. acpi_ut_get_node_name(method_node),
  196. walk_state->thread->current_sync_level));
  197. return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
  198. }
  199. /*
  200. * Obtain the method mutex if necessary. Do not acquire mutex for a
  201. * recursive call.
  202. */
  203. if (!walk_state ||
  204. !obj_desc->method.mutex->mutex.thread_id ||
  205. (walk_state->thread->thread_id !=
  206. obj_desc->method.mutex->mutex.thread_id)) {
  207. /*
  208. * Acquire the method mutex. This releases the interpreter if we
  209. * block (and reacquires it before it returns)
  210. */
  211. status =
  212. acpi_ex_system_wait_mutex(obj_desc->method.mutex->
  213. mutex.os_mutex,
  214. ACPI_WAIT_FOREVER);
  215. if (ACPI_FAILURE(status)) {
  216. return_ACPI_STATUS(status);
  217. }
  218. /* Update the mutex and walk info and save the original sync_level */
  219. if (walk_state) {
  220. obj_desc->method.mutex->mutex.
  221. original_sync_level =
  222. walk_state->thread->current_sync_level;
  223. obj_desc->method.mutex->mutex.thread_id =
  224. walk_state->thread->thread_id;
  225. walk_state->thread->current_sync_level =
  226. obj_desc->method.sync_level;
  227. } else {
  228. obj_desc->method.mutex->mutex.
  229. original_sync_level =
  230. obj_desc->method.mutex->mutex.sync_level;
  231. }
  232. }
  233. /* Always increase acquisition depth */
  234. obj_desc->method.mutex->mutex.acquisition_depth++;
  235. }
  236. /*
  237. * Allocate an Owner ID for this method, only if this is the first thread
  238. * to begin concurrent execution. We only need one owner_id, even if the
  239. * method is invoked recursively.
  240. */
  241. if (!obj_desc->method.owner_id) {
  242. status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
  243. if (ACPI_FAILURE(status)) {
  244. goto cleanup;
  245. }
  246. }
  247. /*
  248. * Increment the method parse tree thread count since it has been
  249. * reentered one more time (even if it is the same thread)
  250. */
  251. obj_desc->method.thread_count++;
  252. return_ACPI_STATUS(status);
  253. cleanup:
  254. /* On error, must release the method mutex (if present) */
  255. if (obj_desc->method.mutex) {
  256. acpi_os_release_mutex(obj_desc->method.mutex->mutex.os_mutex);
  257. }
  258. return_ACPI_STATUS(status);
  259. }
  260. /*******************************************************************************
  261. *
  262. * FUNCTION: acpi_ds_call_control_method
  263. *
  264. * PARAMETERS: thread - Info for this thread
  265. * this_walk_state - Current walk state
  266. * op - Current Op to be walked
  267. *
  268. * RETURN: Status
  269. *
  270. * DESCRIPTION: Transfer execution to a called control method
  271. *
  272. ******************************************************************************/
  273. acpi_status
  274. acpi_ds_call_control_method(struct acpi_thread_state *thread,
  275. struct acpi_walk_state *this_walk_state,
  276. union acpi_parse_object *op)
  277. {
  278. acpi_status status;
  279. struct acpi_namespace_node *method_node;
  280. struct acpi_walk_state *next_walk_state = NULL;
  281. union acpi_operand_object *obj_desc;
  282. struct acpi_evaluate_info *info;
  283. u32 i;
  284. ACPI_FUNCTION_TRACE_PTR(ds_call_control_method, this_walk_state);
  285. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  286. "Calling method %p, currentstate=%p\n",
  287. this_walk_state->prev_op, this_walk_state));
  288. /*
  289. * Get the namespace entry for the control method we are about to call
  290. */
  291. method_node = this_walk_state->method_call_node;
  292. if (!method_node) {
  293. return_ACPI_STATUS(AE_NULL_ENTRY);
  294. }
  295. obj_desc = acpi_ns_get_attached_object(method_node);
  296. if (!obj_desc) {
  297. return_ACPI_STATUS(AE_NULL_OBJECT);
  298. }
  299. /* Init for new method, possibly wait on method mutex */
  300. status = acpi_ds_begin_method_execution(method_node, obj_desc,
  301. this_walk_state);
  302. if (ACPI_FAILURE(status)) {
  303. return_ACPI_STATUS(status);
  304. }
  305. /* Begin method parse/execution. Create a new walk state */
  306. next_walk_state = acpi_ds_create_walk_state(obj_desc->method.owner_id,
  307. NULL, obj_desc, thread);
  308. if (!next_walk_state) {
  309. status = AE_NO_MEMORY;
  310. goto cleanup;
  311. }
  312. /*
  313. * The resolved arguments were put on the previous walk state's operand
  314. * stack. Operands on the previous walk state stack always
  315. * start at index 0. Also, null terminate the list of arguments
  316. */
  317. this_walk_state->operands[this_walk_state->num_operands] = NULL;
  318. /*
  319. * Allocate and initialize the evaluation information block
  320. * TBD: this is somewhat inefficient, should change interface to
  321. * ds_init_aml_walk. For now, keeps this struct off the CPU stack
  322. */
  323. info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
  324. if (!info) {
  325. status = AE_NO_MEMORY;
  326. goto cleanup;
  327. }
  328. info->parameters = &this_walk_state->operands[0];
  329. status = acpi_ds_init_aml_walk(next_walk_state, NULL, method_node,
  330. obj_desc->method.aml_start,
  331. obj_desc->method.aml_length, info,
  332. ACPI_IMODE_EXECUTE);
  333. ACPI_FREE(info);
  334. if (ACPI_FAILURE(status)) {
  335. goto cleanup;
  336. }
  337. /*
  338. * Delete the operands on the previous walkstate operand stack
  339. * (they were copied to new objects)
  340. */
  341. for (i = 0; i < obj_desc->method.param_count; i++) {
  342. acpi_ut_remove_reference(this_walk_state->operands[i]);
  343. this_walk_state->operands[i] = NULL;
  344. }
  345. /* Clear the operand stack */
  346. this_walk_state->num_operands = 0;
  347. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  348. "**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
  349. method_node->name.ascii, next_walk_state));
  350. /* Invoke an internal method if necessary */
  351. if (obj_desc->method.info_flags & ACPI_METHOD_INTERNAL_ONLY) {
  352. status =
  353. obj_desc->method.dispatch.implementation(next_walk_state);
  354. if (status == AE_OK) {
  355. status = AE_CTRL_TERMINATE;
  356. }
  357. }
  358. return_ACPI_STATUS(status);
  359. cleanup:
  360. /* On error, we must terminate the method properly */
  361. acpi_ds_terminate_control_method(obj_desc, next_walk_state);
  362. if (next_walk_state) {
  363. acpi_ds_delete_walk_state(next_walk_state);
  364. }
  365. return_ACPI_STATUS(status);
  366. }
  367. /*******************************************************************************
  368. *
  369. * FUNCTION: acpi_ds_restart_control_method
  370. *
  371. * PARAMETERS: walk_state - State for preempted method (caller)
  372. * return_desc - Return value from the called method
  373. *
  374. * RETURN: Status
  375. *
  376. * DESCRIPTION: Restart a method that was preempted by another (nested) method
  377. * invocation. Handle the return value (if any) from the callee.
  378. *
  379. ******************************************************************************/
  380. acpi_status
  381. acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
  382. union acpi_operand_object *return_desc)
  383. {
  384. acpi_status status;
  385. int same_as_implicit_return;
  386. ACPI_FUNCTION_TRACE_PTR(ds_restart_control_method, walk_state);
  387. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  388. "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
  389. acpi_ut_get_node_name(walk_state->method_node),
  390. walk_state->method_call_op, return_desc));
  391. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  392. " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n",
  393. walk_state->return_used,
  394. walk_state->results, walk_state));
  395. /* Did the called method return a value? */
  396. if (return_desc) {
  397. /* Is the implicit return object the same as the return desc? */
  398. same_as_implicit_return =
  399. (walk_state->implicit_return_obj == return_desc);
  400. /* Are we actually going to use the return value? */
  401. if (walk_state->return_used) {
  402. /* Save the return value from the previous method */
  403. status = acpi_ds_result_push(return_desc, walk_state);
  404. if (ACPI_FAILURE(status)) {
  405. acpi_ut_remove_reference(return_desc);
  406. return_ACPI_STATUS(status);
  407. }
  408. /*
  409. * Save as THIS method's return value in case it is returned
  410. * immediately to yet another method
  411. */
  412. walk_state->return_desc = return_desc;
  413. }
  414. /*
  415. * The following code is the optional support for the so-called
  416. * "implicit return". Some AML code assumes that the last value of the
  417. * method is "implicitly" returned to the caller, in the absence of an
  418. * explicit return value.
  419. *
  420. * Just save the last result of the method as the return value.
  421. *
  422. * NOTE: this is optional because the ASL language does not actually
  423. * support this behavior.
  424. */
  425. else if (!acpi_ds_do_implicit_return
  426. (return_desc, walk_state, FALSE)
  427. || same_as_implicit_return) {
  428. /*
  429. * Delete the return value if it will not be used by the
  430. * calling method or remove one reference if the explicit return
  431. * is the same as the implicit return value.
  432. */
  433. acpi_ut_remove_reference(return_desc);
  434. }
  435. }
  436. return_ACPI_STATUS(AE_OK);
  437. }
  438. /*******************************************************************************
  439. *
  440. * FUNCTION: acpi_ds_terminate_control_method
  441. *
  442. * PARAMETERS: method_desc - Method object
  443. * walk_state - State associated with the method
  444. *
  445. * RETURN: None
  446. *
  447. * DESCRIPTION: Terminate a control method. Delete everything that the method
  448. * created, delete all locals and arguments, and delete the parse
  449. * tree if requested.
  450. *
  451. * MUTEX: Interpreter is locked
  452. *
  453. ******************************************************************************/
  454. void
  455. acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
  456. struct acpi_walk_state *walk_state)
  457. {
  458. ACPI_FUNCTION_TRACE_PTR(ds_terminate_control_method, walk_state);
  459. /* method_desc is required, walk_state is optional */
  460. if (!method_desc) {
  461. return_VOID;
  462. }
  463. if (walk_state) {
  464. /* Delete all arguments and locals */
  465. acpi_ds_method_data_delete_all(walk_state);
  466. /*
  467. * If method is serialized, release the mutex and restore the
  468. * current sync level for this thread
  469. */
  470. if (method_desc->method.mutex) {
  471. /* Acquisition Depth handles recursive calls */
  472. method_desc->method.mutex->mutex.acquisition_depth--;
  473. if (!method_desc->method.mutex->mutex.acquisition_depth) {
  474. walk_state->thread->current_sync_level =
  475. method_desc->method.mutex->mutex.
  476. original_sync_level;
  477. acpi_os_release_mutex(method_desc->method.
  478. mutex->mutex.os_mutex);
  479. method_desc->method.mutex->mutex.thread_id = 0;
  480. }
  481. }
  482. /*
  483. * Delete any namespace objects created anywhere within the
  484. * namespace by the execution of this method. Unless:
  485. * 1) This method is a module-level executable code method, in which
  486. * case we want make the objects permanent.
  487. * 2) There are other threads executing the method, in which case we
  488. * will wait until the last thread has completed.
  489. */
  490. if (!(method_desc->method.info_flags & ACPI_METHOD_MODULE_LEVEL)
  491. && (method_desc->method.thread_count == 1)) {
  492. /* Delete any direct children of (created by) this method */
  493. acpi_ns_delete_namespace_subtree(walk_state->
  494. method_node);
  495. /*
  496. * Delete any objects that were created by this method
  497. * elsewhere in the namespace (if any were created).
  498. * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
  499. * deletion such that we don't have to perform an entire
  500. * namespace walk for every control method execution.
  501. */
  502. if (method_desc->method.
  503. info_flags & ACPI_METHOD_MODIFIED_NAMESPACE) {
  504. acpi_ns_delete_namespace_by_owner(method_desc->
  505. method.
  506. owner_id);
  507. method_desc->method.info_flags &=
  508. ~ACPI_METHOD_MODIFIED_NAMESPACE;
  509. }
  510. }
  511. }
  512. /* Decrement the thread count on the method */
  513. if (method_desc->method.thread_count) {
  514. method_desc->method.thread_count--;
  515. } else {
  516. ACPI_ERROR((AE_INFO, "Invalid zero thread count in method"));
  517. }
  518. /* Are there any other threads currently executing this method? */
  519. if (method_desc->method.thread_count) {
  520. /*
  521. * Additional threads. Do not release the owner_id in this case,
  522. * we immediately reuse it for the next thread executing this method
  523. */
  524. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  525. "*** Completed execution of one thread, %u threads remaining\n",
  526. method_desc->method.thread_count));
  527. } else {
  528. /* This is the only executing thread for this method */
  529. /*
  530. * Support to dynamically change a method from not_serialized to
  531. * Serialized if it appears that the method is incorrectly written and
  532. * does not support multiple thread execution. The best example of this
  533. * is if such a method creates namespace objects and blocks. A second
  534. * thread will fail with an AE_ALREADY_EXISTS exception.
  535. *
  536. * This code is here because we must wait until the last thread exits
  537. * before marking the method as serialized.
  538. */
  539. if (method_desc->method.
  540. info_flags & ACPI_METHOD_SERIALIZED_PENDING) {
  541. if (walk_state) {
  542. ACPI_INFO((AE_INFO,
  543. "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
  544. walk_state->method_node->name.
  545. ascii));
  546. }
  547. /*
  548. * Method tried to create an object twice and was marked as
  549. * "pending serialized". The probable cause is that the method
  550. * cannot handle reentrancy.
  551. *
  552. * The method was created as not_serialized, but it tried to create
  553. * a named object and then blocked, causing the second thread
  554. * entrance to begin and then fail. Workaround this problem by
  555. * marking the method permanently as Serialized when the last
  556. * thread exits here.
  557. */
  558. method_desc->method.info_flags &=
  559. ~ACPI_METHOD_SERIALIZED_PENDING;
  560. method_desc->method.info_flags |=
  561. ACPI_METHOD_SERIALIZED;
  562. method_desc->method.sync_level = 0;
  563. }
  564. /* No more threads, we can free the owner_id */
  565. if (!
  566. (method_desc->method.
  567. info_flags & ACPI_METHOD_MODULE_LEVEL)) {
  568. acpi_ut_release_owner_id(&method_desc->method.owner_id);
  569. }
  570. }
  571. return_VOID;
  572. }