aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2007-05-09 23:01:59 -0400
committerLen Brown <len.brown@intel.com>2007-05-09 23:01:59 -0400
commit262a7a28de060f3a63cae20035876d6f22fd7670 (patch)
tree80c687704cb57fafe11a2e40fbc9e6b2f095b604
parent40d07080e585396dc58bc64befa1de0695318b3b (diff)
Revert "ACPICA: fix AML mutex re-entrancy"
This reverts commit c0d127b56937c3e72c2b1819161d2f6718eee877. These changes to AML locking were made to allow Notify handlers to be called on the stack and not deadlock. However, that scheme turns out to be flawed and was reverted by the previous commit, so this commit restores the locking to it previous design. Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c12
-rw-r--r--drivers/acpi/executer/exdump.c2
-rw-r--r--drivers/acpi/executer/exmutex.c36
-rw-r--r--drivers/acpi/utilities/utdelete.c1
-rw-r--r--include/acpi/acinterp.h3
-rw-r--r--include/acpi/acobject.h2
6 files changed, 31 insertions, 25 deletions
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 1683e5c5b94c..1cbe61905824 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -231,8 +231,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
231 * Obtain the method mutex if necessary. Do not acquire mutex for a 231 * Obtain the method mutex if necessary. Do not acquire mutex for a
232 * recursive call. 232 * recursive call.
233 */ 233 */
234 if (acpi_os_get_thread_id() != 234 if (!walk_state ||
235 obj_desc->method.mutex->mutex.owner_thread_id) { 235 !obj_desc->method.mutex->mutex.owner_thread ||
236 (walk_state->thread !=
237 obj_desc->method.mutex->mutex.owner_thread)) {
236 /* 238 /*
237 * Acquire the method mutex. This releases the interpreter if we 239 * Acquire the method mutex. This releases the interpreter if we
238 * block (and reacquires it before it returns) 240 * block (and reacquires it before it returns)
@@ -246,14 +248,14 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
246 } 248 }
247 249
248 /* Update the mutex and walk info and save the original sync_level */ 250 /* Update the mutex and walk info and save the original sync_level */
249 obj_desc->method.mutex->mutex.owner_thread_id =
250 acpi_os_get_thread_id();
251 251
252 if (walk_state) { 252 if (walk_state) {
253 obj_desc->method.mutex->mutex. 253 obj_desc->method.mutex->mutex.
254 original_sync_level = 254 original_sync_level =
255 walk_state->thread->current_sync_level; 255 walk_state->thread->current_sync_level;
256 256
257 obj_desc->method.mutex->mutex.owner_thread =
258 walk_state->thread;
257 walk_state->thread->current_sync_level = 259 walk_state->thread->current_sync_level =
258 obj_desc->method.sync_level; 260 obj_desc->method.sync_level;
259 } else { 261 } else {
@@ -567,7 +569,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
567 569
568 acpi_os_release_mutex(method_desc->method.mutex->mutex. 570 acpi_os_release_mutex(method_desc->method.mutex->mutex.
569 os_mutex); 571 os_mutex);
570 method_desc->method.mutex->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; 572 method_desc->method.mutex->mutex.owner_thread = NULL;
571 } 573 }
572 } 574 }
573 575
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 1a73c14df2c5..68d283fd60e7 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -134,7 +134,7 @@ static struct acpi_exdump_info acpi_ex_dump_method[8] = {
134static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { 134static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
135 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, 135 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
136 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, 136 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
137 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread_id), "Owner Thread"}, 137 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
138 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), 138 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
139 "Acquire Depth"}, 139 "Acquire Depth"},
140 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} 140 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index 4eb883bda6ae..5101bad5baf8 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -66,9 +66,10 @@ acpi_ex_link_mutex(union acpi_operand_object *obj_desc,
66 * 66 *
67 ******************************************************************************/ 67 ******************************************************************************/
68 68
69void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc, 69void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc)
70 struct acpi_thread_state *thread)
71{ 70{
71 struct acpi_thread_state *thread = obj_desc->mutex.owner_thread;
72
72 if (!thread) { 73 if (!thread) {
73 return; 74 return;
74 } 75 }
@@ -173,13 +174,16 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
173 174
174 /* Support for multiple acquires by the owning thread */ 175 /* Support for multiple acquires by the owning thread */
175 176
176 if (obj_desc->mutex.owner_thread_id == acpi_os_get_thread_id()) { 177 if (obj_desc->mutex.owner_thread) {
177 /* 178 if (obj_desc->mutex.owner_thread->thread_id ==
178 * The mutex is already owned by this thread, just increment the 179 walk_state->thread->thread_id) {
179 * acquisition depth 180 /*
180 */ 181 * The mutex is already owned by this thread, just increment the
181 obj_desc->mutex.acquisition_depth++; 182 * acquisition depth
182 return_ACPI_STATUS(AE_OK); 183 */
184 obj_desc->mutex.acquisition_depth++;
185 return_ACPI_STATUS(AE_OK);
186 }
183 } 187 }
184 188
185 /* Acquire the mutex, wait if necessary. Special case for Global Lock */ 189 /* Acquire the mutex, wait if necessary. Special case for Global Lock */
@@ -202,7 +206,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
202 206
203 /* Have the mutex: update mutex and walk info and save the sync_level */ 207 /* Have the mutex: update mutex and walk info and save the sync_level */
204 208
205 obj_desc->mutex.owner_thread_id = acpi_os_get_thread_id(); 209 obj_desc->mutex.owner_thread = walk_state->thread;
206 obj_desc->mutex.acquisition_depth = 1; 210 obj_desc->mutex.acquisition_depth = 1;
207 obj_desc->mutex.original_sync_level = 211 obj_desc->mutex.original_sync_level =
208 walk_state->thread->current_sync_level; 212 walk_state->thread->current_sync_level;
@@ -242,7 +246,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
242 246
243 /* The mutex must have been previously acquired in order to release it */ 247 /* The mutex must have been previously acquired in order to release it */
244 248
245 if (!obj_desc->mutex.owner_thread_id) { 249 if (!obj_desc->mutex.owner_thread) {
246 ACPI_ERROR((AE_INFO, 250 ACPI_ERROR((AE_INFO,
247 "Cannot release Mutex [%4.4s], not acquired", 251 "Cannot release Mutex [%4.4s], not acquired",
248 acpi_ut_get_node_name(obj_desc->mutex.node))); 252 acpi_ut_get_node_name(obj_desc->mutex.node)));
@@ -262,14 +266,14 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
262 * The Mutex is owned, but this thread must be the owner. 266 * The Mutex is owned, but this thread must be the owner.
263 * Special case for Global Lock, any thread can release 267 * Special case for Global Lock, any thread can release
264 */ 268 */
265 if ((obj_desc->mutex.owner_thread_id != 269 if ((obj_desc->mutex.owner_thread->thread_id !=
266 walk_state->thread->thread_id) 270 walk_state->thread->thread_id)
267 && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) { 271 && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) {
268 ACPI_ERROR((AE_INFO, 272 ACPI_ERROR((AE_INFO,
269 "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", 273 "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX",
270 (unsigned long)walk_state->thread->thread_id, 274 (unsigned long)walk_state->thread->thread_id,
271 acpi_ut_get_node_name(obj_desc->mutex.node), 275 acpi_ut_get_node_name(obj_desc->mutex.node),
272 (unsigned long)obj_desc->mutex.owner_thread_id)); 276 (unsigned long)obj_desc->mutex.owner_thread->thread_id));
273 return_ACPI_STATUS(AE_AML_NOT_OWNER); 277 return_ACPI_STATUS(AE_AML_NOT_OWNER);
274 } 278 }
275 279
@@ -296,7 +300,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
296 300
297 /* Unlink the mutex from the owner's list */ 301 /* Unlink the mutex from the owner's list */
298 302
299 acpi_ex_unlink_mutex(obj_desc, walk_state->thread); 303 acpi_ex_unlink_mutex(obj_desc);
300 304
301 /* Release the mutex, special case for Global Lock */ 305 /* Release the mutex, special case for Global Lock */
302 306
@@ -308,7 +312,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
308 312
309 /* Update the mutex and restore sync_level */ 313 /* Update the mutex and restore sync_level */
310 314
311 obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; 315 obj_desc->mutex.owner_thread = NULL;
312 walk_state->thread->current_sync_level = 316 walk_state->thread->current_sync_level =
313 obj_desc->mutex.original_sync_level; 317 obj_desc->mutex.original_sync_level;
314 318
@@ -363,7 +367,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
363 367
364 /* Mark mutex unowned */ 368 /* Mark mutex unowned */
365 369
366 obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; 370 obj_desc->mutex.owner_thread = NULL;
367 371
368 /* Update Thread sync_level (Last mutex is the important one) */ 372 /* Update Thread sync_level (Last mutex is the important one) */
369 373
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 673a0caa4073..f777cebdc46d 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -170,6 +170,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
170 acpi_os_delete_mutex(object->mutex.os_mutex); 170 acpi_os_delete_mutex(object->mutex.os_mutex);
171 acpi_gbl_global_lock_mutex = NULL; 171 acpi_gbl_global_lock_mutex = NULL;
172 } else { 172 } else {
173 acpi_ex_unlink_mutex(object);
173 acpi_os_delete_mutex(object->mutex.os_mutex); 174 acpi_os_delete_mutex(object->mutex.os_mutex);
174 } 175 }
175 break; 176 break;
diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h
index 73967c8152d3..ce7c9d653910 100644
--- a/include/acpi/acinterp.h
+++ b/include/acpi/acinterp.h
@@ -253,8 +253,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
253 253
254void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread); 254void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
255 255
256void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc, 256void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
257 struct acpi_thread_state *thread);
258 257
259/* 258/*
260 * exprep - ACPI AML execution - prep utilities 259 * exprep - ACPI AML execution - prep utilities
diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h
index 5206d61d74a6..04e9735a6742 100644
--- a/include/acpi/acobject.h
+++ b/include/acpi/acobject.h
@@ -155,7 +155,7 @@ struct acpi_object_event {
155struct acpi_object_mutex { 155struct acpi_object_mutex {
156 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */ 156 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */
157 u16 acquisition_depth; /* Allow multiple Acquires, same thread */ 157 u16 acquisition_depth; /* Allow multiple Acquires, same thread */
158 acpi_thread_id owner_thread_id; /* Current owner of the mutex */ 158 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
159 acpi_mutex os_mutex; /* Actual OS synchronization object */ 159 acpi_mutex os_mutex; /* Actual OS synchronization object */
160 union acpi_operand_object *prev; /* Link for list of acquired mutexes */ 160 union acpi_operand_object *prev; /* Link for list of acquired mutexes */
161 union acpi_operand_object *next; /* Link for list of acquired mutexes */ 161 union acpi_operand_object *next; /* Link for list of acquired mutexes */