diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-10-18 22:25:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-10-21 20:05:05 -0400 |
commit | af08f9cc5073eee875016d28730c99ec86da4198 (patch) | |
tree | 8d63bdda3a08515e28bf74b6fc8a9979c807348b | |
parent | 9957510255724c1c746c9a6264c849e9fdd4cd24 (diff) |
ACPICA: Debugger: Fix "quit/exit" command by cleaning up user commands termination logic
ACPICA commit 0dd68e16274cd38224aa4781eddc57dc2cbaa108
The quit/exit commands shouldn't invoke acpi_terminate_debugger() and
acpi_terminate() right in the user command loop, because when the debugger
exits, the kernel ACPI subsystem shouldn't be terminated (acpi_terminate())
and the debugger should only be terminated by its users
(acpi_terminate_debugger()) rather than being terminated itself. Leaving such
invocations causes kernel panic when the debugger is shipped in the Linux
kernel.
This patch fixes this issue. Lv Zheng.
Link: https://github.com/acpica/acpica/commit/0dd68e16
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/acglobal.h | 3 | ||||
-rw-r--r-- | drivers/acpi/acpica/dbinput.c | 16 | ||||
-rw-r--r-- | drivers/acpi/acpica/dbxface.c | 20 | ||||
-rw-r--r-- | drivers/acpi/acpica/utinit.c | 2 | ||||
-rw-r--r-- | drivers/acpi/acpica/utxface.c | 4 |
5 files changed, 26 insertions, 19 deletions
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 71a3c40dbf20..e57686533f6d 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -325,7 +325,6 @@ ACPI_GLOBAL(struct acpi_external_file *, acpi_gbl_external_file_list); | |||
325 | 325 | ||
326 | #ifdef ACPI_DEBUGGER | 326 | #ifdef ACPI_DEBUGGER |
327 | 327 | ||
328 | ACPI_INIT_GLOBAL(u8, acpi_gbl_db_terminate_threads, FALSE); | ||
329 | ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE); | 328 | ACPI_INIT_GLOBAL(u8, acpi_gbl_abort_method, FALSE); |
330 | ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE); | 329 | ACPI_INIT_GLOBAL(u8, acpi_gbl_method_executing, FALSE); |
331 | 330 | ||
@@ -337,6 +336,8 @@ ACPI_GLOBAL(char *, acpi_gbl_db_filename); | |||
337 | ACPI_GLOBAL(u32, acpi_gbl_db_debug_level); | 336 | ACPI_GLOBAL(u32, acpi_gbl_db_debug_level); |
338 | ACPI_GLOBAL(u32, acpi_gbl_db_console_debug_level); | 337 | ACPI_GLOBAL(u32, acpi_gbl_db_console_debug_level); |
339 | ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_db_scope_node); | 338 | ACPI_GLOBAL(struct acpi_namespace_node *, acpi_gbl_db_scope_node); |
339 | ACPI_GLOBAL(u8, acpi_gbl_db_terminate_loop); | ||
340 | ACPI_GLOBAL(u8, acpi_gbl_db_threads_terminated); | ||
340 | 341 | ||
341 | ACPI_GLOBAL(char *, acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]); | 342 | ACPI_GLOBAL(char *, acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]); |
342 | ACPI_GLOBAL(acpi_object_type, acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]); | 343 | ACPI_GLOBAL(acpi_object_type, acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]); |
diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c index 7f1b6ec62668..f8cddd682af2 100644 --- a/drivers/acpi/acpica/dbinput.c +++ b/drivers/acpi/acpica/dbinput.c | |||
@@ -694,7 +694,7 @@ acpi_db_command_dispatch(char *input_buffer, | |||
694 | 694 | ||
695 | /* If acpi_terminate has been called, terminate this thread */ | 695 | /* If acpi_terminate has been called, terminate this thread */ |
696 | 696 | ||
697 | if (acpi_gbl_db_terminate_threads) { | 697 | if (acpi_gbl_db_terminate_loop) { |
698 | return (AE_CTRL_TERMINATE); | 698 | return (AE_CTRL_TERMINATE); |
699 | } | 699 | } |
700 | 700 | ||
@@ -1116,7 +1116,7 @@ acpi_db_command_dispatch(char *input_buffer, | |||
1116 | #ifdef ACPI_APPLICATION | 1116 | #ifdef ACPI_APPLICATION |
1117 | acpi_db_close_debug_file(); | 1117 | acpi_db_close_debug_file(); |
1118 | #endif | 1118 | #endif |
1119 | acpi_gbl_db_terminate_threads = TRUE; | 1119 | acpi_gbl_db_terminate_loop = TRUE; |
1120 | return (AE_CTRL_TERMINATE); | 1120 | return (AE_CTRL_TERMINATE); |
1121 | 1121 | ||
1122 | case CMD_NOT_FOUND: | 1122 | case CMD_NOT_FOUND: |
@@ -1166,6 +1166,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context) | |||
1166 | 1166 | ||
1167 | acpi_os_release_mutex(acpi_gbl_db_command_complete); | 1167 | acpi_os_release_mutex(acpi_gbl_db_command_complete); |
1168 | } | 1168 | } |
1169 | acpi_gbl_db_threads_terminated = TRUE; | ||
1169 | } | 1170 | } |
1170 | 1171 | ||
1171 | /******************************************************************************* | 1172 | /******************************************************************************* |
@@ -1212,7 +1213,7 @@ acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op) | |||
1212 | 1213 | ||
1213 | /* TBD: [Restructure] Need a separate command line buffer for step mode */ | 1214 | /* TBD: [Restructure] Need a separate command line buffer for step mode */ |
1214 | 1215 | ||
1215 | while (!acpi_gbl_db_terminate_threads) { | 1216 | while (!acpi_gbl_db_terminate_loop) { |
1216 | 1217 | ||
1217 | /* Force output to console until a command is entered */ | 1218 | /* Force output to console until a command is entered */ |
1218 | 1219 | ||
@@ -1261,14 +1262,5 @@ acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op) | |||
1261 | } | 1262 | } |
1262 | } | 1263 | } |
1263 | 1264 | ||
1264 | /* Shut down the debugger */ | ||
1265 | |||
1266 | acpi_terminate_debugger(); | ||
1267 | |||
1268 | /* | ||
1269 | * Only this thread (the original thread) should actually terminate the | ||
1270 | * subsystem, because all the semaphores are deleted during termination | ||
1271 | */ | ||
1272 | status = acpi_terminate(); | ||
1273 | return (status); | 1265 | return (status); |
1274 | } | 1266 | } |
diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c index 26023bd95f56..bef5f4ed22a0 100644 --- a/drivers/acpi/acpica/dbxface.c +++ b/drivers/acpi/acpica/dbxface.c | |||
@@ -401,6 +401,10 @@ acpi_status acpi_initialize_debugger(void) | |||
401 | acpi_gbl_db_scope_buf[1] = 0; | 401 | acpi_gbl_db_scope_buf[1] = 0; |
402 | acpi_gbl_db_scope_node = acpi_gbl_root_node; | 402 | acpi_gbl_db_scope_node = acpi_gbl_root_node; |
403 | 403 | ||
404 | /* Initialize user commands loop */ | ||
405 | |||
406 | acpi_gbl_db_terminate_loop = FALSE; | ||
407 | |||
404 | /* | 408 | /* |
405 | * If configured for multi-thread support, the debug executor runs in | 409 | * If configured for multi-thread support, the debug executor runs in |
406 | * a separate thread so that the front end can be in another address | 410 | * a separate thread so that the front end can be in another address |
@@ -426,11 +430,13 @@ acpi_status acpi_initialize_debugger(void) | |||
426 | 430 | ||
427 | /* Create the debug execution thread to execute commands */ | 431 | /* Create the debug execution thread to execute commands */ |
428 | 432 | ||
433 | acpi_gbl_db_threads_terminated = FALSE; | ||
429 | status = acpi_os_execute(OSL_DEBUGGER_THREAD, | 434 | status = acpi_os_execute(OSL_DEBUGGER_THREAD, |
430 | acpi_db_execute_thread, NULL); | 435 | acpi_db_execute_thread, NULL); |
431 | if (ACPI_FAILURE(status)) { | 436 | if (ACPI_FAILURE(status)) { |
432 | ACPI_EXCEPTION((AE_INFO, status, | 437 | ACPI_EXCEPTION((AE_INFO, status, |
433 | "Could not start debugger thread")); | 438 | "Could not start debugger thread")); |
439 | acpi_gbl_db_threads_terminated = TRUE; | ||
434 | return_ACPI_STATUS(status); | 440 | return_ACPI_STATUS(status); |
435 | } | 441 | } |
436 | } | 442 | } |
@@ -454,6 +460,20 @@ ACPI_EXPORT_SYMBOL(acpi_initialize_debugger) | |||
454 | void acpi_terminate_debugger(void) | 460 | void acpi_terminate_debugger(void) |
455 | { | 461 | { |
456 | 462 | ||
463 | /* Terminate the AML Debugger */ | ||
464 | |||
465 | acpi_gbl_db_terminate_loop = TRUE; | ||
466 | |||
467 | if (acpi_gbl_debugger_configuration & DEBUGGER_MULTI_THREADED) { | ||
468 | acpi_os_release_mutex(acpi_gbl_db_command_ready); | ||
469 | |||
470 | /* Wait the AML Debugger threads */ | ||
471 | |||
472 | while (!acpi_gbl_db_threads_terminated) { | ||
473 | acpi_os_sleep(100); | ||
474 | } | ||
475 | } | ||
476 | |||
457 | if (acpi_gbl_db_buffer) { | 477 | if (acpi_gbl_db_buffer) { |
458 | acpi_os_free(acpi_gbl_db_buffer); | 478 | acpi_os_free(acpi_gbl_db_buffer); |
459 | acpi_gbl_db_buffer = NULL; | 479 | acpi_gbl_db_buffer = NULL; |
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c index 28ab3a1d5ec1..d8699df8914c 100644 --- a/drivers/acpi/acpica/utinit.c +++ b/drivers/acpi/acpica/utinit.c | |||
@@ -241,8 +241,6 @@ acpi_status acpi_ut_init_globals(void) | |||
241 | acpi_gbl_disable_mem_tracking = FALSE; | 241 | acpi_gbl_disable_mem_tracking = FALSE; |
242 | #endif | 242 | #endif |
243 | 243 | ||
244 | ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE); | ||
245 | |||
246 | return_ACPI_STATUS(AE_OK); | 244 | return_ACPI_STATUS(AE_OK); |
247 | } | 245 | } |
248 | 246 | ||
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c index 4f332815db00..f183daf938b7 100644 --- a/drivers/acpi/acpica/utxface.c +++ b/drivers/acpi/acpica/utxface.c | |||
@@ -80,10 +80,6 @@ acpi_status __init acpi_terminate(void) | |||
80 | acpi_gbl_startup_flags = 0; | 80 | acpi_gbl_startup_flags = 0; |
81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); | 81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); |
82 | 82 | ||
83 | /* Terminate the AML Debugger if present */ | ||
84 | |||
85 | ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE); | ||
86 | |||
87 | /* Shutdown and free all resources */ | 83 | /* Shutdown and free all resources */ |
88 | 84 | ||
89 | acpi_ut_subsystem_shutdown(); | 85 | acpi_ut_subsystem_shutdown(); |