ACPICA commit 
7e823714911480be47e310fb1b3590d289b9fd99
Segmentation fault can be seen for executing the "terminate" command. This
is because acpi_ut_subsystem_shutdown() is errnously called multiple times.
This patch cleans up acpi_ut_subsystem_shutdown() logics to fix this
issue. Lv Zheng.
Link: https://github.com/acpica/acpica/commit/7e823714
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>
                 * re-creating the semaphores!
                 */
 
+               acpi_gbl_db_terminate_loop = TRUE;
                /*  acpi_initialize (NULL); */
                break;
 
        acpi_status status = AE_OK;
        acpi_status Mstatus;
 
-       while (status != AE_CTRL_TERMINATE) {
+       while (status != AE_CTRL_TERMINATE && !acpi_gbl_db_terminate_loop) {
                acpi_gbl_method_executing = FALSE;
                acpi_gbl_step_to_next_call = FALSE;
 
 
 {
        ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
 
+       /* Just exit if subsystem is already shutdown */
+
+       if (acpi_gbl_shutdown) {
+               ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
+               return_VOID;
+       }
+
+       /* Subsystem appears active, go ahead and shut it down */
+
+       acpi_gbl_shutdown = TRUE;
+       acpi_gbl_startup_flags = 0;
+       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
+
 #ifndef ACPI_ASL_COMPILER
 
        /* Close the acpi_event Handling */
 
 
        ACPI_FUNCTION_TRACE(acpi_terminate);
 
-       /* Just exit if subsystem is already shutdown */
-
-       if (acpi_gbl_shutdown) {
-               ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
-               return_ACPI_STATUS(AE_OK);
-       }
-
-       /* Subsystem appears active, go ahead and shut it down */
-
-       acpi_gbl_shutdown = TRUE;
-       acpi_gbl_startup_flags = 0;
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
-
        /* Shutdown and free all resources */
 
        acpi_ut_subsystem_shutdown();