Skip to content

Commit 25ccd24

Browse files
zetalografaeljw
authored andcommitted
ACPICA: Dispatcher: Fix order issue of method termination
The last step of the method termination should be the end of the method serialization. Otherwise, the steps happening after it will face the race issues that cannot be protected by the method serialization mechanism. This patch fixes this issue by moving the per-method-object deletion code prior than the end of the method serialization. Otherwise, the possible race issues may result in AE_ALREADY_EXISTS error in a parallel environment. Fixes: 74f51b8 (ACPICA: Namespace: Fix dynamic table loading issues) Reported-and-tested-by: Imre Deak <imre.deak@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 07d9a38 commit 25ccd24

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

drivers/acpi/acpica/dsmethod.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -730,26 +730,6 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
730730

731731
acpi_ds_method_data_delete_all(walk_state);
732732

733-
/*
734-
* If method is serialized, release the mutex and restore the
735-
* current sync level for this thread
736-
*/
737-
if (method_desc->method.mutex) {
738-
739-
/* Acquisition Depth handles recursive calls */
740-
741-
method_desc->method.mutex->mutex.acquisition_depth--;
742-
if (!method_desc->method.mutex->mutex.acquisition_depth) {
743-
walk_state->thread->current_sync_level =
744-
method_desc->method.mutex->mutex.
745-
original_sync_level;
746-
747-
acpi_os_release_mutex(method_desc->method.
748-
mutex->mutex.os_mutex);
749-
method_desc->method.mutex->mutex.thread_id = 0;
750-
}
751-
}
752-
753733
/*
754734
* Delete any namespace objects created anywhere within the
755735
* namespace by the execution of this method. Unless:
@@ -786,6 +766,26 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
786766
~ACPI_METHOD_MODIFIED_NAMESPACE;
787767
}
788768
}
769+
770+
/*
771+
* If method is serialized, release the mutex and restore the
772+
* current sync level for this thread
773+
*/
774+
if (method_desc->method.mutex) {
775+
776+
/* Acquisition Depth handles recursive calls */
777+
778+
method_desc->method.mutex->mutex.acquisition_depth--;
779+
if (!method_desc->method.mutex->mutex.acquisition_depth) {
780+
walk_state->thread->current_sync_level =
781+
method_desc->method.mutex->mutex.
782+
original_sync_level;
783+
784+
acpi_os_release_mutex(method_desc->method.
785+
mutex->mutex.os_mutex);
786+
method_desc->method.mutex->mutex.thread_id = 0;
787+
}
788+
}
789789
}
790790

791791
/* Decrement the thread count on the method */

0 commit comments

Comments
 (0)