Skip to content

Commit

Permalink
Pull bugzilla-8385 into release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Len Brown committed May 10, 2007
2 parents f697b67 + 88db5e1 commit 3dd6786
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 126 deletions.
12 changes: 7 additions & 5 deletions drivers/acpi/dispatcher/dsmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
* Obtain the method mutex if necessary. Do not acquire mutex for a
* recursive call.
*/
if (acpi_os_get_thread_id() !=
obj_desc->method.mutex->mutex.owner_thread_id) {
if (!walk_state ||
!obj_desc->method.mutex->mutex.owner_thread ||
(walk_state->thread !=
obj_desc->method.mutex->mutex.owner_thread)) {
/*
* Acquire the method mutex. This releases the interpreter if we
* block (and reacquires it before it returns)
Expand All @@ -246,14 +248,14 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
}

/* Update the mutex and walk info and save the original sync_level */
obj_desc->method.mutex->mutex.owner_thread_id =
acpi_os_get_thread_id();

if (walk_state) {
obj_desc->method.mutex->mutex.
original_sync_level =
walk_state->thread->current_sync_level;

obj_desc->method.mutex->mutex.owner_thread =
walk_state->thread;
walk_state->thread->current_sync_level =
obj_desc->method.sync_level;
} else {
Expand Down Expand Up @@ -567,7 +569,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,

acpi_os_release_mutex(method_desc->method.mutex->mutex.
os_mutex);
method_desc->method.mutex->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED;
method_desc->method.mutex->mutex.owner_thread = NULL;
}
}

Expand Down
11 changes: 4 additions & 7 deletions drivers/acpi/events/evmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,12 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
notify_info->notify.value = (u16) notify_value;
notify_info->notify.handler_obj = handler_obj;

acpi_ex_exit_interpreter();

acpi_ev_notify_dispatch(notify_info);

status = acpi_ex_enter_interpreter();
status =
acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch,
notify_info);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
acpi_ut_delete_generic_state(notify_info);
}

}

if (!handler_obj) {
Expand Down
15 changes: 4 additions & 11 deletions drivers/acpi/events/evregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
u32 bit_width, acpi_integer * value)
{
acpi_status status;
acpi_status status2;
acpi_adr_space_handler handler;
acpi_adr_space_setup region_setup;
union acpi_operand_object *handler_desc;
Expand Down Expand Up @@ -345,18 +344,15 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
* setup will potentially execute control methods
* (e.g., _REG method for this region)
*/
acpi_ex_exit_interpreter();
acpi_ex_relinquish_interpreter();

status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
handler_desc->address_space.context,
&region_context);

/* Re-enter the interpreter */

status2 = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
acpi_ex_reacquire_interpreter();

/* Check for failure of the Region Setup */

Expand Down Expand Up @@ -409,7 +405,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
* exit the interpreter because the handler *might* block -- we don't
* know what it will do, so we can't hold the lock on the intepreter.
*/
acpi_ex_exit_interpreter();
acpi_ex_relinquish_interpreter();
}

/* Call the handler */
Expand All @@ -430,10 +426,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
* We just returned from a non-default handler, we must re-enter the
* interpreter
*/
status2 = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
acpi_ex_reacquire_interpreter();
}

return_ACPI_STATUS(status);
Expand Down
6 changes: 2 additions & 4 deletions drivers/acpi/events/evxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,9 @@ acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle)
return (AE_BAD_PARAMETER);
}

status = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status)) {
return (status);
}
/* Must lock interpreter to prevent race conditions */

acpi_ex_enter_interpreter();
status = acpi_ev_acquire_global_lock(timeout);
acpi_ex_exit_interpreter();

Expand Down
5 changes: 1 addition & 4 deletions drivers/acpi/executer/excreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,7 @@ acpi_ex_create_method(u8 * aml_start,
* Get the sync_level. If method is serialized, a mutex will be
* created for this method when it is parsed.
*/
if (acpi_gbl_all_methods_serialized) {
obj_desc->method.sync_level = 0;
obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
} else if (method_flags & AML_METHOD_SERIALIZED) {
if (method_flags & AML_METHOD_SERIALIZED) {
/*
* ACPI 1.0: sync_level = 0
* ACPI 2.0: sync_level = sync_level in method declaration
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/executer/exdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static struct acpi_exdump_info acpi_ex_dump_method[8] = {
static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread_id), "Owner Thread"},
{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
{ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
"Acquire Depth"},
{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
Expand Down
36 changes: 20 additions & 16 deletions drivers/acpi/executer/exmutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
*
******************************************************************************/

void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc,
struct acpi_thread_state *thread)
void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
{
struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;

if (!thread) {
return;
}
Expand Down Expand Up @@ -173,13 +174,16 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,

/* Support for multiple acquires by the owning thread */

if (obj_desc->mutex.owner_thread_id == acpi_os_get_thread_id()) {
/*
* The mutex is already owned by this thread, just increment the
* acquisition depth
*/
obj_desc->mutex.acquisition_depth++;
return_ACPI_STATUS(AE_OK);
if (obj_desc->mutex.owner_thread) {
if (obj_desc->mutex.owner_thread->thread_id ==
walk_state->thread->thread_id) {
/*
* The mutex is already owned by this thread, just increment the
* acquisition depth
*/
obj_desc->mutex.acquisition_depth++;
return_ACPI_STATUS(AE_OK);
}
}

/* Acquire the mutex, wait if necessary. Special case for Global Lock */
Expand All @@ -202,7 +206,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,

/* Have the mutex: update mutex and walk info and save the sync_level */

obj_desc->mutex.owner_thread_id = acpi_os_get_thread_id();
obj_desc->mutex.owner_thread = walk_state->thread;
obj_desc->mutex.acquisition_depth = 1;
obj_desc->mutex.original_sync_level =
walk_state->thread->current_sync_level;
Expand Down Expand Up @@ -242,7 +246,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,

/* The mutex must have been previously acquired in order to release it */

if (!obj_desc->mutex.owner_thread_id) {
if (!obj_desc->mutex.owner_thread) {
ACPI_ERROR((AE_INFO,
"Cannot release Mutex [%4.4s], not acquired",
acpi_ut_get_node_name(obj_desc->mutex.node)));
Expand All @@ -262,14 +266,14 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
* The Mutex is owned, but this thread must be the owner.
* Special case for Global Lock, any thread can release
*/
if ((obj_desc->mutex.owner_thread_id !=
if ((obj_desc->mutex.owner_thread->thread_id !=
walk_state->thread->thread_id)
&& (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) {
ACPI_ERROR((AE_INFO,
"Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX",
(unsigned long)walk_state->thread->thread_id,
acpi_ut_get_node_name(obj_desc->mutex.node),
(unsigned long)obj_desc->mutex.owner_thread_id));
(unsigned long)obj_desc->mutex.owner_thread->thread_id));
return_ACPI_STATUS(AE_AML_NOT_OWNER);
}

Expand All @@ -296,7 +300,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,

/* Unlink the mutex from the owner's list */

acpi_ex_unlink_mutex(obj_desc, walk_state->thread);
acpi_ex_unlink_mutex(obj_desc);

/* Release the mutex, special case for Global Lock */

Expand All @@ -308,7 +312,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,

/* Update the mutex and restore sync_level */

obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED;
obj_desc->mutex.owner_thread = NULL;
walk_state->thread->current_sync_level =
obj_desc->mutex.original_sync_level;

Expand Down Expand Up @@ -363,7 +367,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)

/* Mark mutex unowned */

obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED;
obj_desc->mutex.owner_thread = NULL;

/* Update Thread sync_level (Last mutex is the important one) */

Expand Down
30 changes: 7 additions & 23 deletions drivers/acpi/executer/exsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ ACPI_MODULE_NAME("exsystem")
acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
{
acpi_status status;
acpi_status status2;

ACPI_FUNCTION_TRACE(ex_system_wait_semaphore);

Expand All @@ -79,7 +78,7 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)

/* We must wait, so unlock the interpreter */

acpi_ex_exit_interpreter();
acpi_ex_relinquish_interpreter();

status = acpi_os_wait_semaphore(semaphore, 1, timeout);

Expand All @@ -89,13 +88,7 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)

/* Reacquire the interpreter */

status2 = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status2)) {

/* Report fatal error, could not acquire interpreter */

return_ACPI_STATUS(status2);
}
acpi_ex_reacquire_interpreter();
}

return_ACPI_STATUS(status);
Expand All @@ -119,7 +112,6 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)
{
acpi_status status;
acpi_status status2;

ACPI_FUNCTION_TRACE(ex_system_wait_mutex);

Expand All @@ -132,7 +124,7 @@ acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)

/* We must wait, so unlock the interpreter */

acpi_ex_exit_interpreter();
acpi_ex_relinquish_interpreter();

status = acpi_os_acquire_mutex(mutex, timeout);

Expand All @@ -142,13 +134,7 @@ acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)

/* Reacquire the interpreter */

status2 = acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status2)) {

/* Report fatal error, could not acquire interpreter */

return_ACPI_STATUS(status2);
}
acpi_ex_reacquire_interpreter();
}

return_ACPI_STATUS(status);
Expand Down Expand Up @@ -209,20 +195,18 @@ acpi_status acpi_ex_system_do_stall(u32 how_long)

acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
{
acpi_status status;

ACPI_FUNCTION_ENTRY();

/* Since this thread will sleep, we must release the interpreter */

acpi_ex_exit_interpreter();
acpi_ex_relinquish_interpreter();

acpi_os_sleep(how_long);

/* And now we must get the interpreter again */

status = acpi_ex_enter_interpreter();
return (status);
acpi_ex_reacquire_interpreter();
return (AE_OK);
}

/*******************************************************************************
Expand Down
Loading

0 comments on commit 3dd6786

Please sign in to comment.