diff options
author | Lin Ming <ming.m.lin@intel.com> | 2011-03-23 05:26:36 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2011-03-25 04:33:15 -0400 |
commit | 749c27639b95c5c4a8185e02a4efb189034944ed (patch) | |
tree | bb20d0d20fbc325f676949a4a240beefb9d53f9a /drivers/acpi | |
parent | 3854c8e32f46ffa6ee0bf2eb01137f5a48b2754f (diff) |
ACPICA: Fix code divergence of global lock handling
Commit 9cd0314(ACPI / ACPICA: Fix global lock acquisition) was backported
into ACPICA code base, and some divergence was introduced.
This patch fixed it,
- rename acpi_ev_global_lock_pending/acpi_ev_global_lock_pending_lock
to acpi_gbl_global_lock_pending/acpi_gbl_global_lock_pending_lock.
- move the initialization of acpi_gbl_global_lock_pending_lock from
acpi_ut_mutex_initialize to acpi_ev_init_global_lock_handler.
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/acpica/acglobal.h | 6 | ||||
-rw-r--r-- | drivers/acpi/acpica/evmisc.c | 74 | ||||
-rw-r--r-- | drivers/acpi/acpica/utmutex.c | 5 |
3 files changed, 44 insertions, 41 deletions
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 6d512fcabdbe..73863d86f022 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -214,13 +214,16 @@ ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX]; | |||
214 | 214 | ||
215 | /* | 215 | /* |
216 | * Global lock mutex is an actual AML mutex object | 216 | * Global lock mutex is an actual AML mutex object |
217 | * Global lock semaphore works in conjunction with the HW global lock | 217 | * Global lock semaphore works in conjunction with the actual global lock |
218 | * Global lock spinlock is used for "pending" handshake | ||
218 | */ | 219 | */ |
219 | ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex; | 220 | ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex; |
220 | ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; | 221 | ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; |
222 | ACPI_EXTERN acpi_spinlock acpi_gbl_global_lock_pending_lock; | ||
221 | ACPI_EXTERN u16 acpi_gbl_global_lock_handle; | 223 | ACPI_EXTERN u16 acpi_gbl_global_lock_handle; |
222 | ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; | 224 | ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; |
223 | ACPI_EXTERN u8 acpi_gbl_global_lock_present; | 225 | ACPI_EXTERN u8 acpi_gbl_global_lock_present; |
226 | ACPI_EXTERN u8 acpi_gbl_global_lock_pending; | ||
224 | 227 | ||
225 | /* | 228 | /* |
226 | * Spinlocks are used for interfaces that can be possibly called at | 229 | * Spinlocks are used for interfaces that can be possibly called at |
@@ -228,7 +231,6 @@ ACPI_EXTERN u8 acpi_gbl_global_lock_present; | |||
228 | */ | 231 | */ |
229 | ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ | 232 | ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ |
230 | ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ | 233 | ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ |
231 | ACPI_EXTERN acpi_spinlock acpi_ev_global_lock_pending_lock; /* For global lock */ | ||
232 | 234 | ||
233 | /***************************************************************************** | 235 | /***************************************************************************** |
234 | * | 236 | * |
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index 7dc80946f7bd..69a3b4aa862b 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c | |||
@@ -284,39 +284,41 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context) | |||
284 | * RETURN: ACPI_INTERRUPT_HANDLED | 284 | * RETURN: ACPI_INTERRUPT_HANDLED |
285 | * | 285 | * |
286 | * DESCRIPTION: Invoked directly from the SCI handler when a global lock | 286 | * DESCRIPTION: Invoked directly from the SCI handler when a global lock |
287 | * release interrupt occurs. If there's a thread waiting for | 287 | * release interrupt occurs. If there is actually a pending |
288 | * the global lock, signal it. | 288 | * request for the lock, signal the waiting thread. |
289 | * | ||
290 | * NOTE: Assumes that the semaphore can be signaled from interrupt level. If | ||
291 | * this is not possible for some reason, a separate thread will have to be | ||
292 | * scheduled to do this. | ||
293 | * | 289 | * |
294 | ******************************************************************************/ | 290 | ******************************************************************************/ |
295 | static u8 acpi_ev_global_lock_pending; | ||
296 | 291 | ||
297 | static u32 acpi_ev_global_lock_handler(void *context) | 292 | static u32 acpi_ev_global_lock_handler(void *context) |
298 | { | 293 | { |
299 | acpi_status status; | 294 | acpi_status status; |
300 | acpi_cpu_flags flags; | 295 | acpi_cpu_flags flags; |
301 | 296 | ||
302 | flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock); | 297 | flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); |
303 | 298 | ||
304 | if (!acpi_ev_global_lock_pending) { | 299 | /* |
305 | goto out; | 300 | * If a request for the global lock is not actually pending, |
301 | * we are done. This handles "spurious" global lock interrupts | ||
302 | * which are possible (and have been seen) with bad BIOSs. | ||
303 | */ | ||
304 | if (!acpi_gbl_global_lock_pending) { | ||
305 | goto cleanup_and_exit; | ||
306 | } | 306 | } |
307 | 307 | ||
308 | /* Send a unit to the semaphore */ | 308 | /* |
309 | 309 | * Send a unit to the global lock semaphore. The actual acquisition | |
310 | * of the global lock will be performed by the waiting thread. | ||
311 | */ | ||
310 | status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1); | 312 | status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1); |
311 | if (ACPI_FAILURE(status)) { | 313 | if (ACPI_FAILURE(status)) { |
312 | ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore")); | 314 | ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore")); |
313 | } | 315 | } |
314 | 316 | ||
315 | acpi_ev_global_lock_pending = FALSE; | 317 | acpi_gbl_global_lock_pending = FALSE; |
316 | 318 | ||
317 | out: | 319 | cleanup_and_exit: |
318 | acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags); | ||
319 | 320 | ||
321 | acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); | ||
320 | return (ACPI_INTERRUPT_HANDLED); | 322 | return (ACPI_INTERRUPT_HANDLED); |
321 | } | 323 | } |
322 | 324 | ||
@@ -350,14 +352,20 @@ acpi_status acpi_ev_init_global_lock_handler(void) | |||
350 | * Map to AE_OK, but mark global lock as not present. Any attempt to | 352 | * Map to AE_OK, but mark global lock as not present. Any attempt to |
351 | * actually use the global lock will be flagged with an error. | 353 | * actually use the global lock will be flagged with an error. |
352 | */ | 354 | */ |
355 | acpi_gbl_global_lock_present = FALSE; | ||
353 | if (status == AE_NO_HARDWARE_RESPONSE) { | 356 | if (status == AE_NO_HARDWARE_RESPONSE) { |
354 | ACPI_ERROR((AE_INFO, | 357 | ACPI_ERROR((AE_INFO, |
355 | "No response from Global Lock hardware, disabling lock")); | 358 | "No response from Global Lock hardware, disabling lock")); |
356 | 359 | ||
357 | acpi_gbl_global_lock_present = FALSE; | ||
358 | return_ACPI_STATUS(AE_OK); | 360 | return_ACPI_STATUS(AE_OK); |
359 | } | 361 | } |
360 | 362 | ||
363 | status = acpi_os_create_lock(&acpi_gbl_global_lock_pending_lock); | ||
364 | if (ACPI_FAILURE(status)) { | ||
365 | return_ACPI_STATUS(status); | ||
366 | } | ||
367 | |||
368 | acpi_gbl_global_lock_pending = FALSE; | ||
361 | acpi_gbl_global_lock_present = TRUE; | 369 | acpi_gbl_global_lock_present = TRUE; |
362 | return_ACPI_STATUS(status); | 370 | return_ACPI_STATUS(status); |
363 | } | 371 | } |
@@ -414,7 +422,7 @@ static int acpi_ev_global_lock_acquired; | |||
414 | acpi_status acpi_ev_acquire_global_lock(u16 timeout) | 422 | acpi_status acpi_ev_acquire_global_lock(u16 timeout) |
415 | { | 423 | { |
416 | acpi_cpu_flags flags; | 424 | acpi_cpu_flags flags; |
417 | acpi_status status = AE_OK; | 425 | acpi_status status; |
418 | u8 acquired = FALSE; | 426 | u8 acquired = FALSE; |
419 | 427 | ||
420 | ACPI_FUNCTION_TRACE(ev_acquire_global_lock); | 428 | ACPI_FUNCTION_TRACE(ev_acquire_global_lock); |
@@ -458,15 +466,15 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
458 | } | 466 | } |
459 | 467 | ||
460 | /* | 468 | /* |
461 | * Make sure that a global lock actually exists. If not, just treat the | 469 | * Make sure that a global lock actually exists. If not, just |
462 | * lock as a standard mutex. | 470 | * treat the lock as a standard mutex. |
463 | */ | 471 | */ |
464 | if (!acpi_gbl_global_lock_present) { | 472 | if (!acpi_gbl_global_lock_present) { |
465 | acpi_gbl_global_lock_acquired = TRUE; | 473 | acpi_gbl_global_lock_acquired = TRUE; |
466 | return_ACPI_STATUS(AE_OK); | 474 | return_ACPI_STATUS(AE_OK); |
467 | } | 475 | } |
468 | 476 | ||
469 | flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock); | 477 | flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); |
470 | 478 | ||
471 | do { | 479 | do { |
472 | 480 | ||
@@ -475,20 +483,19 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
475 | ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired); | 483 | ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired); |
476 | if (acquired) { | 484 | if (acquired) { |
477 | acpi_gbl_global_lock_acquired = TRUE; | 485 | acpi_gbl_global_lock_acquired = TRUE; |
478 | |||
479 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 486 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
480 | "Acquired hardware Global Lock\n")); | 487 | "Acquired hardware Global Lock\n")); |
481 | break; | 488 | break; |
482 | } | 489 | } |
483 | 490 | ||
484 | acpi_ev_global_lock_pending = TRUE; | ||
485 | |||
486 | acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags); | ||
487 | |||
488 | /* | 491 | /* |
489 | * Did not get the lock. The pending bit was set above, and we | 492 | * Did not get the lock. The pending bit was set above, and |
490 | * must wait until we get the global lock released interrupt. | 493 | * we must now wait until we receive the global lock |
494 | * released interrupt. | ||
491 | */ | 495 | */ |
496 | acpi_gbl_global_lock_pending = TRUE; | ||
497 | acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); | ||
498 | |||
492 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 499 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
493 | "Waiting for hardware Global Lock\n")); | 500 | "Waiting for hardware Global Lock\n")); |
494 | 501 | ||
@@ -496,17 +503,16 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout) | |||
496 | * Wait for handshake with the global lock interrupt handler. | 503 | * Wait for handshake with the global lock interrupt handler. |
497 | * This interface releases the interpreter if we must wait. | 504 | * This interface releases the interpreter if we must wait. |
498 | */ | 505 | */ |
499 | status = acpi_ex_system_wait_semaphore( | 506 | status = |
500 | acpi_gbl_global_lock_semaphore, | 507 | acpi_ex_system_wait_semaphore |
501 | ACPI_WAIT_FOREVER); | 508 | (acpi_gbl_global_lock_semaphore, ACPI_WAIT_FOREVER); |
502 | 509 | ||
503 | flags = acpi_os_acquire_lock(acpi_ev_global_lock_pending_lock); | 510 | flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); |
504 | 511 | ||
505 | } while (ACPI_SUCCESS(status)); | 512 | } while (ACPI_SUCCESS(status)); |
506 | 513 | ||
507 | acpi_ev_global_lock_pending = FALSE; | 514 | acpi_gbl_global_lock_pending = FALSE; |
508 | 515 | acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); | |
509 | acpi_os_release_lock(acpi_ev_global_lock_pending_lock, flags); | ||
510 | 516 | ||
511 | return_ACPI_STATUS(status); | 517 | return_ACPI_STATUS(status); |
512 | } | 518 | } |
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c index 519d4ee9b45a..7d797e2baecd 100644 --- a/drivers/acpi/acpica/utmutex.c +++ b/drivers/acpi/acpica/utmutex.c | |||
@@ -93,11 +93,6 @@ acpi_status acpi_ut_mutex_initialize(void) | |||
93 | return_ACPI_STATUS (status); | 93 | return_ACPI_STATUS (status); |
94 | } | 94 | } |
95 | 95 | ||
96 | status = acpi_os_create_lock (&acpi_ev_global_lock_pending_lock); | ||
97 | if (ACPI_FAILURE (status)) { | ||
98 | return_ACPI_STATUS (status); | ||
99 | } | ||
100 | |||
101 | /* Mutex for _OSI support */ | 96 | /* Mutex for _OSI support */ |
102 | status = acpi_os_create_mutex(&acpi_gbl_osi_mutex); | 97 | status = acpi_os_create_mutex(&acpi_gbl_osi_mutex); |
103 | if (ACPI_FAILURE(status)) { | 98 | if (ACPI_FAILURE(status)) { |