Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "ACPICA: revert "acpi_serialize" changes"

This reverts commit a8f4af6dc6600980885c594f52eecd60edd62013.
Thus restoring ACPICA's new acpi_serialize code.

This commit by itself may cause a regression, but
it is reverted in this order so that subsequent
reverts reverts under this one can be made
without conflict.

Signed-off-by: Len Brown <len.brown@intel.com>

Len Brown 4d2acd9e b5f0adbc

+113 -90
+2 -6
drivers/acpi/events/evmisc.c
··· 196 196 notify_info->notify.value = (u16) notify_value; 197 197 notify_info->notify.handler_obj = handler_obj; 198 198 199 - acpi_ex_exit_interpreter(); 199 + acpi_ex_relinquish_interpreter(); 200 200 201 201 acpi_ev_notify_dispatch(notify_info); 202 202 203 - status = acpi_ex_enter_interpreter(); 204 - if (ACPI_FAILURE(status)) { 205 - return_ACPI_STATUS(status); 206 - } 207 - 203 + acpi_ex_reacquire_interpreter(); 208 204 } 209 205 210 206 if (!handler_obj) {
+4 -11
drivers/acpi/events/evregion.c
··· 291 291 u32 bit_width, acpi_integer * value) 292 292 { 293 293 acpi_status status; 294 - acpi_status status2; 295 294 acpi_adr_space_handler handler; 296 295 acpi_adr_space_setup region_setup; 297 296 union acpi_operand_object *handler_desc; ··· 344 345 * setup will potentially execute control methods 345 346 * (e.g., _REG method for this region) 346 347 */ 347 - acpi_ex_exit_interpreter(); 348 + acpi_ex_relinquish_interpreter(); 348 349 349 350 status = region_setup(region_obj, ACPI_REGION_ACTIVATE, 350 351 handler_desc->address_space.context, ··· 352 353 353 354 /* Re-enter the interpreter */ 354 355 355 - status2 = acpi_ex_enter_interpreter(); 356 - if (ACPI_FAILURE(status2)) { 357 - return_ACPI_STATUS(status2); 358 - } 356 + acpi_ex_reacquire_interpreter(); 359 357 360 358 /* Check for failure of the Region Setup */ 361 359 ··· 405 409 * exit the interpreter because the handler *might* block -- we don't 406 410 * know what it will do, so we can't hold the lock on the intepreter. 407 411 */ 408 - acpi_ex_exit_interpreter(); 412 + acpi_ex_relinquish_interpreter(); 409 413 } 410 414 411 415 /* Call the handler */ ··· 426 430 * We just returned from a non-default handler, we must re-enter the 427 431 * interpreter 428 432 */ 429 - status2 = acpi_ex_enter_interpreter(); 430 - if (ACPI_FAILURE(status2)) { 431 - return_ACPI_STATUS(status2); 432 - } 433 + acpi_ex_reacquire_interpreter(); 433 434 } 434 435 435 436 return_ACPI_STATUS(status);
+2 -4
drivers/acpi/events/evxface.c
··· 768 768 return (AE_BAD_PARAMETER); 769 769 } 770 770 771 - status = acpi_ex_enter_interpreter(); 772 - if (ACPI_FAILURE(status)) { 773 - return (status); 774 - } 771 + /* Must lock interpreter to prevent race conditions */ 775 772 773 + acpi_ex_enter_interpreter(); 776 774 status = acpi_ev_acquire_global_lock(timeout); 777 775 acpi_ex_exit_interpreter(); 778 776
+1 -4
drivers/acpi/executer/excreate.c
··· 583 583 * Get the sync_level. If method is serialized, a mutex will be 584 584 * created for this method when it is parsed. 585 585 */ 586 - if (acpi_gbl_all_methods_serialized) { 587 - obj_desc->method.sync_level = 0; 588 - obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; 589 - } else if (method_flags & AML_METHOD_SERIALIZED) { 586 + if (method_flags & AML_METHOD_SERIALIZED) { 590 587 /* 591 588 * ACPI 1.0: sync_level = 0 592 589 * ACPI 2.0: sync_level = sync_level in method declaration
+7 -23
drivers/acpi/executer/exsystem.c
··· 66 66 acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout) 67 67 { 68 68 acpi_status status; 69 - acpi_status status2; 70 69 71 70 ACPI_FUNCTION_TRACE(ex_system_wait_semaphore); 72 71 ··· 78 79 79 80 /* We must wait, so unlock the interpreter */ 80 81 81 - acpi_ex_exit_interpreter(); 82 + acpi_ex_relinquish_interpreter(); 82 83 83 84 status = acpi_os_wait_semaphore(semaphore, 1, timeout); 84 85 ··· 88 89 89 90 /* Reacquire the interpreter */ 90 91 91 - status2 = acpi_ex_enter_interpreter(); 92 - if (ACPI_FAILURE(status2)) { 93 - 94 - /* Report fatal error, could not acquire interpreter */ 95 - 96 - return_ACPI_STATUS(status2); 97 - } 92 + acpi_ex_reacquire_interpreter(); 98 93 } 99 94 100 95 return_ACPI_STATUS(status); ··· 112 119 acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout) 113 120 { 114 121 acpi_status status; 115 - acpi_status status2; 116 122 117 123 ACPI_FUNCTION_TRACE(ex_system_wait_mutex); 118 124 ··· 124 132 125 133 /* We must wait, so unlock the interpreter */ 126 134 127 - acpi_ex_exit_interpreter(); 135 + acpi_ex_relinquish_interpreter(); 128 136 129 137 status = acpi_os_acquire_mutex(mutex, timeout); 130 138 ··· 134 142 135 143 /* Reacquire the interpreter */ 136 144 137 - status2 = acpi_ex_enter_interpreter(); 138 - if (ACPI_FAILURE(status2)) { 139 - 140 - /* Report fatal error, could not acquire interpreter */ 141 - 142 - return_ACPI_STATUS(status2); 143 - } 145 + acpi_ex_reacquire_interpreter(); 144 146 } 145 147 146 148 return_ACPI_STATUS(status); ··· 195 209 196 210 acpi_status acpi_ex_system_do_suspend(acpi_integer how_long) 197 211 { 198 - acpi_status status; 199 - 200 212 ACPI_FUNCTION_ENTRY(); 201 213 202 214 /* Since this thread will sleep, we must release the interpreter */ 203 215 204 - acpi_ex_exit_interpreter(); 216 + acpi_ex_relinquish_interpreter(); 205 217 206 218 acpi_os_sleep(how_long); 207 219 208 220 /* And now we must get the interpreter again */ 209 221 210 - status = acpi_ex_enter_interpreter(); 211 - return (status); 222 + acpi_ex_reacquire_interpreter(); 223 + return (AE_OK); 212 224 } 213 225 214 226 /*******************************************************************************
+84 -20
drivers/acpi/executer/exutils.c
··· 76 76 * 77 77 * PARAMETERS: None 78 78 * 79 - * RETURN: Status 79 + * RETURN: None 80 80 * 81 - * DESCRIPTION: Enter the interpreter execution region. Failure to enter 82 - * the interpreter region is a fatal system error 81 + * DESCRIPTION: Enter the interpreter execution region. Failure to enter 82 + * the interpreter region is a fatal system error. Used in 83 + * conjunction with exit_interpreter. 83 84 * 84 85 ******************************************************************************/ 85 86 86 - acpi_status acpi_ex_enter_interpreter(void) 87 + void acpi_ex_enter_interpreter(void) 87 88 { 88 89 acpi_status status; 89 90 ··· 92 91 93 92 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); 94 93 if (ACPI_FAILURE(status)) { 95 - ACPI_ERROR((AE_INFO, "Could not acquire interpreter mutex")); 94 + ACPI_ERROR((AE_INFO, 95 + "Could not acquire AML Interpreter mutex")); 96 96 } 97 97 98 - return_ACPI_STATUS(status); 98 + return_VOID; 99 + } 100 + 101 + /******************************************************************************* 102 + * 103 + * FUNCTION: acpi_ex_reacquire_interpreter 104 + * 105 + * PARAMETERS: None 106 + * 107 + * RETURN: None 108 + * 109 + * DESCRIPTION: Reacquire the interpreter execution region from within the 110 + * interpreter code. Failure to enter the interpreter region is a 111 + * fatal system error. Used in conjuction with 112 + * relinquish_interpreter 113 + * 114 + ******************************************************************************/ 115 + 116 + void acpi_ex_reacquire_interpreter(void) 117 + { 118 + ACPI_FUNCTION_TRACE(ex_reacquire_interpreter); 119 + 120 + /* 121 + * If the global serialized flag is set, do not release the interpreter, 122 + * since it was not actually released by acpi_ex_relinquish_interpreter. 123 + * This forces the interpreter to be single threaded. 124 + */ 125 + if (!acpi_gbl_all_methods_serialized) { 126 + acpi_ex_enter_interpreter(); 127 + } 128 + 129 + return_VOID; 99 130 } 100 131 101 132 /******************************************************************************* ··· 138 105 * 139 106 * RETURN: None 140 107 * 141 - * DESCRIPTION: Exit the interpreter execution region 142 - * 143 - * Cases where the interpreter is unlocked: 144 - * 1) Completion of the execution of a control method 145 - * 2) Method blocked on a Sleep() AML opcode 146 - * 3) Method blocked on an Acquire() AML opcode 147 - * 4) Method blocked on a Wait() AML opcode 148 - * 5) Method blocked to acquire the global lock 149 - * 6) Method blocked to execute a serialized control method that is 150 - * already executing 151 - * 7) About to invoke a user-installed opregion handler 108 + * DESCRIPTION: Exit the interpreter execution region. This is the top level 109 + * routine used to exit the interpreter when all processing has 110 + * been completed. 152 111 * 153 112 ******************************************************************************/ 154 113 ··· 152 127 153 128 status = acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); 154 129 if (ACPI_FAILURE(status)) { 155 - ACPI_ERROR((AE_INFO, "Could not release interpreter mutex")); 130 + ACPI_ERROR((AE_INFO, 131 + "Could not release AML Interpreter mutex")); 132 + } 133 + 134 + return_VOID; 135 + } 136 + 137 + /******************************************************************************* 138 + * 139 + * FUNCTION: acpi_ex_relinquish_interpreter 140 + * 141 + * PARAMETERS: None 142 + * 143 + * RETURN: None 144 + * 145 + * DESCRIPTION: Exit the interpreter execution region, from within the 146 + * interpreter - before attempting an operation that will possibly 147 + * block the running thread. 148 + * 149 + * Cases where the interpreter is unlocked internally 150 + * 1) Method to be blocked on a Sleep() AML opcode 151 + * 2) Method to be blocked on an Acquire() AML opcode 152 + * 3) Method to be blocked on a Wait() AML opcode 153 + * 4) Method to be blocked to acquire the global lock 154 + * 5) Method to be blocked waiting to execute a serialized control method 155 + * that is currently executing 156 + * 6) About to invoke a user-installed opregion handler 157 + * 158 + ******************************************************************************/ 159 + 160 + void acpi_ex_relinquish_interpreter(void) 161 + { 162 + ACPI_FUNCTION_TRACE(ex_relinquish_interpreter); 163 + 164 + /* 165 + * If the global serialized flag is set, do not release the interpreter. 166 + * This forces the interpreter to be single threaded. 167 + */ 168 + if (!acpi_gbl_all_methods_serialized) { 169 + acpi_ex_exit_interpreter(); 156 170 } 157 171 158 172 return_VOID; ··· 205 141 * 206 142 * RETURN: none 207 143 * 208 - * DESCRIPTION: Truncate a number to 32-bits if the currently executing method 209 - * belongs to a 32-bit ACPI table. 144 + * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is 145 + * 32-bit, as determined by the revision of the DSDT. 210 146 * 211 147 ******************************************************************************/ 212 148
+2 -9
drivers/acpi/namespace/nseval.c
··· 154 154 * Execute the method via the interpreter. The interpreter is locked 155 155 * here before calling into the AML parser 156 156 */ 157 - status = acpi_ex_enter_interpreter(); 158 - if (ACPI_FAILURE(status)) { 159 - return_ACPI_STATUS(status); 160 - } 161 - 157 + acpi_ex_enter_interpreter(); 162 158 status = acpi_ps_execute_method(info); 163 159 acpi_ex_exit_interpreter(); 164 160 } else { ··· 178 182 * resolution, we must lock it because we could access an opregion. 179 183 * The opregion access code assumes that the interpreter is locked. 180 184 */ 181 - status = acpi_ex_enter_interpreter(); 182 - if (ACPI_FAILURE(status)) { 183 - return_ACPI_STATUS(status); 184 - } 185 + acpi_ex_enter_interpreter(); 185 186 186 187 /* Function has a strange interface */ 187 188
+2 -5
drivers/acpi/namespace/nsinit.c
··· 214 214 u32 level, void *context, void **return_value) 215 215 { 216 216 acpi_object_type type; 217 - acpi_status status; 217 + acpi_status status = AE_OK; 218 218 struct acpi_init_walk_info *info = 219 219 (struct acpi_init_walk_info *)context; 220 220 struct acpi_namespace_node *node = ··· 268 268 /* 269 269 * Must lock the interpreter before executing AML code 270 270 */ 271 - status = acpi_ex_enter_interpreter(); 272 - if (ACPI_FAILURE(status)) { 273 - return (status); 274 - } 271 + acpi_ex_enter_interpreter(); 275 272 276 273 /* 277 274 * Each of these types can contain executable AML code within the
+4 -7
drivers/acpi/namespace/nsxfeval.c
··· 170 170 struct acpi_buffer *return_buffer) 171 171 { 172 172 acpi_status status; 173 - acpi_status status2; 174 173 struct acpi_evaluate_info *info; 175 174 acpi_size buffer_space_needed; 176 175 u32 i; ··· 328 329 * Delete the internal return object. NOTE: Interpreter must be 329 330 * locked to avoid race condition. 330 331 */ 331 - status2 = acpi_ex_enter_interpreter(); 332 - if (ACPI_SUCCESS(status2)) { 332 + acpi_ex_enter_interpreter(); 333 333 334 - /* Remove one reference on the return object (should delete it) */ 334 + /* Remove one reference on the return object (should delete it) */ 335 335 336 - acpi_ut_remove_reference(info->return_object); 337 - acpi_ex_exit_interpreter(); 338 - } 336 + acpi_ut_remove_reference(info->return_object); 337 + acpi_ex_exit_interpreter(); 339 338 } 340 339 341 340 cleanup:
+5 -1
include/acpi/acinterp.h
··· 446 446 /* 447 447 * exutils - interpreter/scanner utilities 448 448 */ 449 - acpi_status acpi_ex_enter_interpreter(void); 449 + void acpi_ex_enter_interpreter(void); 450 450 451 451 void acpi_ex_exit_interpreter(void); 452 + 453 + void acpi_ex_reacquire_interpreter(void); 454 + 455 + void acpi_ex_relinquish_interpreter(void); 452 456 453 457 void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc); 454 458