diff options
author | Bob Moore <robert.moore@intel.com> | 2011-04-12 23:33:17 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2011-05-09 22:16:11 -0400 |
commit | 0f6896f195df014064014493c8287a8e2d18f938 (patch) | |
tree | eda07d3fa557d5ac398e4e0cc217e82da5e7a351 /drivers/acpi/acpica/evmisc.c | |
parent | 749c27639b95c5c4a8185e02a4efb189034944ed (diff) |
ACPICA: Split all internal Global Lock functions to new file - evglock
These functions were moved from evmisc.c
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/evmisc.c')
-rw-r--r-- | drivers/acpi/acpica/evmisc.c | 309 |
1 files changed, 0 insertions, 309 deletions
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index 69a3b4aa862b..d0b331844427 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include "accommon.h" | 45 | #include "accommon.h" |
46 | #include "acevents.h" | 46 | #include "acevents.h" |
47 | #include "acnamesp.h" | 47 | #include "acnamesp.h" |
48 | #include "acinterp.h" | ||
49 | 48 | ||
50 | #define _COMPONENT ACPI_EVENTS | 49 | #define _COMPONENT ACPI_EVENTS |
51 | ACPI_MODULE_NAME("evmisc") | 50 | ACPI_MODULE_NAME("evmisc") |
@@ -53,10 +52,6 @@ ACPI_MODULE_NAME("evmisc") | |||
53 | /* Local prototypes */ | 52 | /* Local prototypes */ |
54 | static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); | 53 | static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); |
55 | 54 | ||
56 | static u32 acpi_ev_global_lock_handler(void *context); | ||
57 | |||
58 | static acpi_status acpi_ev_remove_global_lock_handler(void); | ||
59 | |||
60 | /******************************************************************************* | 55 | /******************************************************************************* |
61 | * | 56 | * |
62 | * FUNCTION: acpi_ev_is_notify_object | 57 | * FUNCTION: acpi_ev_is_notify_object |
@@ -275,310 +270,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context) | |||
275 | acpi_ut_delete_generic_state(notify_info); | 270 | acpi_ut_delete_generic_state(notify_info); |
276 | } | 271 | } |
277 | 272 | ||
278 | /******************************************************************************* | ||
279 | * | ||
280 | * FUNCTION: acpi_ev_global_lock_handler | ||
281 | * | ||
282 | * PARAMETERS: Context - From thread interface, not used | ||
283 | * | ||
284 | * RETURN: ACPI_INTERRUPT_HANDLED | ||
285 | * | ||
286 | * DESCRIPTION: Invoked directly from the SCI handler when a global lock | ||
287 | * release interrupt occurs. If there is actually a pending | ||
288 | * request for the lock, signal the waiting thread. | ||
289 | * | ||
290 | ******************************************************************************/ | ||
291 | |||
292 | static u32 acpi_ev_global_lock_handler(void *context) | ||
293 | { | ||
294 | acpi_status status; | ||
295 | acpi_cpu_flags flags; | ||
296 | |||
297 | flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); | ||
298 | |||
299 | /* | ||
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 | } | ||
307 | |||
308 | /* | ||
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 | */ | ||
312 | status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1); | ||
313 | if (ACPI_FAILURE(status)) { | ||
314 | ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore")); | ||
315 | } | ||
316 | |||
317 | acpi_gbl_global_lock_pending = FALSE; | ||
318 | |||
319 | cleanup_and_exit: | ||
320 | |||
321 | acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); | ||
322 | return (ACPI_INTERRUPT_HANDLED); | ||
323 | } | ||
324 | |||
325 | /******************************************************************************* | ||
326 | * | ||
327 | * FUNCTION: acpi_ev_init_global_lock_handler | ||
328 | * | ||
329 | * PARAMETERS: None | ||
330 | * | ||
331 | * RETURN: Status | ||
332 | * | ||
333 | * DESCRIPTION: Install a handler for the global lock release event | ||
334 | * | ||
335 | ******************************************************************************/ | ||
336 | |||
337 | acpi_status acpi_ev_init_global_lock_handler(void) | ||
338 | { | ||
339 | acpi_status status; | ||
340 | |||
341 | ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); | ||
342 | |||
343 | /* Attempt installation of the global lock handler */ | ||
344 | |||
345 | status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, | ||
346 | acpi_ev_global_lock_handler, | ||
347 | NULL); | ||
348 | |||
349 | /* | ||
350 | * If the global lock does not exist on this platform, the attempt to | ||
351 | * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). | ||
352 | * Map to AE_OK, but mark global lock as not present. Any attempt to | ||
353 | * actually use the global lock will be flagged with an error. | ||
354 | */ | ||
355 | acpi_gbl_global_lock_present = FALSE; | ||
356 | if (status == AE_NO_HARDWARE_RESPONSE) { | ||
357 | ACPI_ERROR((AE_INFO, | ||
358 | "No response from Global Lock hardware, disabling lock")); | ||
359 | |||
360 | return_ACPI_STATUS(AE_OK); | ||
361 | } | ||
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; | ||
369 | acpi_gbl_global_lock_present = TRUE; | ||
370 | return_ACPI_STATUS(status); | ||
371 | } | ||
372 | |||
373 | /******************************************************************************* | ||
374 | * | ||
375 | * FUNCTION: acpi_ev_remove_global_lock_handler | ||
376 | * | ||
377 | * PARAMETERS: None | ||
378 | * | ||
379 | * RETURN: Status | ||
380 | * | ||
381 | * DESCRIPTION: Remove the handler for the Global Lock | ||
382 | * | ||
383 | ******************************************************************************/ | ||
384 | |||
385 | static acpi_status acpi_ev_remove_global_lock_handler(void) | ||
386 | { | ||
387 | acpi_status status; | ||
388 | |||
389 | ACPI_FUNCTION_TRACE(ev_remove_global_lock_handler); | ||
390 | |||
391 | acpi_gbl_global_lock_present = FALSE; | ||
392 | status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL, | ||
393 | acpi_ev_global_lock_handler); | ||
394 | |||
395 | return_ACPI_STATUS(status); | ||
396 | } | ||
397 | |||
398 | /****************************************************************************** | ||
399 | * | ||
400 | * FUNCTION: acpi_ev_acquire_global_lock | ||
401 | * | ||
402 | * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. | ||
403 | * | ||
404 | * RETURN: Status | ||
405 | * | ||
406 | * DESCRIPTION: Attempt to gain ownership of the Global Lock. | ||
407 | * | ||
408 | * MUTEX: Interpreter must be locked | ||
409 | * | ||
410 | * Note: The original implementation allowed multiple threads to "acquire" the | ||
411 | * Global Lock, and the OS would hold the lock until the last thread had | ||
412 | * released it. However, this could potentially starve the BIOS out of the | ||
413 | * lock, especially in the case where there is a tight handshake between the | ||
414 | * Embedded Controller driver and the BIOS. Therefore, this implementation | ||
415 | * allows only one thread to acquire the HW Global Lock at a time, and makes | ||
416 | * the global lock appear as a standard mutex on the OS side. | ||
417 | * | ||
418 | *****************************************************************************/ | ||
419 | static acpi_thread_id acpi_ev_global_lock_thread_id; | ||
420 | static int acpi_ev_global_lock_acquired; | ||
421 | |||
422 | acpi_status acpi_ev_acquire_global_lock(u16 timeout) | ||
423 | { | ||
424 | acpi_cpu_flags flags; | ||
425 | acpi_status status; | ||
426 | u8 acquired = FALSE; | ||
427 | |||
428 | ACPI_FUNCTION_TRACE(ev_acquire_global_lock); | ||
429 | |||
430 | /* | ||
431 | * Only one thread can acquire the GL at a time, the global_lock_mutex | ||
432 | * enforces this. This interface releases the interpreter if we must wait. | ||
433 | */ | ||
434 | status = acpi_ex_system_wait_mutex( | ||
435 | acpi_gbl_global_lock_mutex->mutex.os_mutex, 0); | ||
436 | if (status == AE_TIME) { | ||
437 | if (acpi_ev_global_lock_thread_id == acpi_os_get_thread_id()) { | ||
438 | acpi_ev_global_lock_acquired++; | ||
439 | return AE_OK; | ||
440 | } | ||
441 | } | ||
442 | |||
443 | if (ACPI_FAILURE(status)) { | ||
444 | status = acpi_ex_system_wait_mutex( | ||
445 | acpi_gbl_global_lock_mutex->mutex.os_mutex, | ||
446 | timeout); | ||
447 | } | ||
448 | if (ACPI_FAILURE(status)) { | ||
449 | return_ACPI_STATUS(status); | ||
450 | } | ||
451 | |||
452 | acpi_ev_global_lock_thread_id = acpi_os_get_thread_id(); | ||
453 | acpi_ev_global_lock_acquired++; | ||
454 | |||
455 | /* | ||
456 | * Update the global lock handle and check for wraparound. The handle is | ||
457 | * only used for the external global lock interfaces, but it is updated | ||
458 | * here to properly handle the case where a single thread may acquire the | ||
459 | * lock via both the AML and the acpi_acquire_global_lock interfaces. The | ||
460 | * handle is therefore updated on the first acquire from a given thread | ||
461 | * regardless of where the acquisition request originated. | ||
462 | */ | ||
463 | acpi_gbl_global_lock_handle++; | ||
464 | if (acpi_gbl_global_lock_handle == 0) { | ||
465 | acpi_gbl_global_lock_handle = 1; | ||
466 | } | ||
467 | |||
468 | /* | ||
469 | * Make sure that a global lock actually exists. If not, just | ||
470 | * treat the lock as a standard mutex. | ||
471 | */ | ||
472 | if (!acpi_gbl_global_lock_present) { | ||
473 | acpi_gbl_global_lock_acquired = TRUE; | ||
474 | return_ACPI_STATUS(AE_OK); | ||
475 | } | ||
476 | |||
477 | flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); | ||
478 | |||
479 | do { | ||
480 | |||
481 | /* Attempt to acquire the actual hardware lock */ | ||
482 | |||
483 | ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired); | ||
484 | if (acquired) { | ||
485 | acpi_gbl_global_lock_acquired = TRUE; | ||
486 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
487 | "Acquired hardware Global Lock\n")); | ||
488 | break; | ||
489 | } | ||
490 | |||
491 | /* | ||
492 | * Did not get the lock. The pending bit was set above, and | ||
493 | * we must now wait until we receive the global lock | ||
494 | * released interrupt. | ||
495 | */ | ||
496 | acpi_gbl_global_lock_pending = TRUE; | ||
497 | acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); | ||
498 | |||
499 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
500 | "Waiting for hardware Global Lock\n")); | ||
501 | |||
502 | /* | ||
503 | * Wait for handshake with the global lock interrupt handler. | ||
504 | * This interface releases the interpreter if we must wait. | ||
505 | */ | ||
506 | status = | ||
507 | acpi_ex_system_wait_semaphore | ||
508 | (acpi_gbl_global_lock_semaphore, ACPI_WAIT_FOREVER); | ||
509 | |||
510 | flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock); | ||
511 | |||
512 | } while (ACPI_SUCCESS(status)); | ||
513 | |||
514 | acpi_gbl_global_lock_pending = FALSE; | ||
515 | acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags); | ||
516 | |||
517 | return_ACPI_STATUS(status); | ||
518 | } | ||
519 | |||
520 | /******************************************************************************* | ||
521 | * | ||
522 | * FUNCTION: acpi_ev_release_global_lock | ||
523 | * | ||
524 | * PARAMETERS: None | ||
525 | * | ||
526 | * RETURN: Status | ||
527 | * | ||
528 | * DESCRIPTION: Releases ownership of the Global Lock. | ||
529 | * | ||
530 | ******************************************************************************/ | ||
531 | |||
532 | acpi_status acpi_ev_release_global_lock(void) | ||
533 | { | ||
534 | u8 pending = FALSE; | ||
535 | acpi_status status = AE_OK; | ||
536 | |||
537 | ACPI_FUNCTION_TRACE(ev_release_global_lock); | ||
538 | |||
539 | /* Lock must be already acquired */ | ||
540 | |||
541 | if (!acpi_gbl_global_lock_acquired) { | ||
542 | ACPI_WARNING((AE_INFO, | ||
543 | "Cannot release the ACPI Global Lock, it has not been acquired")); | ||
544 | return_ACPI_STATUS(AE_NOT_ACQUIRED); | ||
545 | } | ||
546 | |||
547 | acpi_ev_global_lock_acquired--; | ||
548 | if (acpi_ev_global_lock_acquired > 0) { | ||
549 | return AE_OK; | ||
550 | } | ||
551 | |||
552 | if (acpi_gbl_global_lock_present) { | ||
553 | |||
554 | /* Allow any thread to release the lock */ | ||
555 | |||
556 | ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending); | ||
557 | |||
558 | /* | ||
559 | * If the pending bit was set, we must write GBL_RLS to the control | ||
560 | * register | ||
561 | */ | ||
562 | if (pending) { | ||
563 | status = | ||
564 | acpi_write_bit_register | ||
565 | (ACPI_BITREG_GLOBAL_LOCK_RELEASE, | ||
566 | ACPI_ENABLE_EVENT); | ||
567 | } | ||
568 | |||
569 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
570 | "Released hardware Global Lock\n")); | ||
571 | } | ||
572 | |||
573 | acpi_gbl_global_lock_acquired = FALSE; | ||
574 | |||
575 | /* Release the local GL mutex */ | ||
576 | acpi_ev_global_lock_thread_id = 0; | ||
577 | acpi_ev_global_lock_acquired = 0; | ||
578 | acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); | ||
579 | return_ACPI_STATUS(status); | ||
580 | } | ||
581 | |||
582 | /****************************************************************************** | 273 | /****************************************************************************** |
583 | * | 274 | * |
584 | * FUNCTION: acpi_ev_terminate | 275 | * FUNCTION: acpi_ev_terminate |