diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-07 20:08:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-07 20:08:30 -0400 |
commit | 9e50ab91d025afc17ca14a1764be2e1d0c24245d (patch) | |
tree | 2647ef3fed12810ef88eb77e05bb7c3b2ea49d56 /drivers/acpi/acpica/evgpeinit.c | |
parent | 3cc08fc35db75b059118626c30b60b0f56583802 (diff) | |
parent | a0d468718b9049f7396d101075a129a2d683ad66 (diff) |
Merge branch 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (27 commits)
ACPI / ACPICA: Simplify acpi_ev_initialize_gpe_block()
ACPI / ACPICA: Fail acpi_gpe_wakeup() if ACPI_GPE_CAN_WAKE is unset
ACPI / ACPICA: Do not execute _PRW methods during initialization
ACPI: Fix bogus GPE test in acpi_bus_set_run_wake_flags()
ACPICA: Update version to 20100702
ACPICA: Fix for Alias references within Package objects
ACPICA: Fix lint warning for 64-bit constant
ACPICA: Remove obsolete GPE function
ACPICA: Update debug output components
ACPICA: Add support for WDDT - Watchdog Descriptor Table
ACPICA: Drop acpi_set_gpe
ACPICA: Use low-level GPE enable during GPE block initialization
ACPI / EC: Do not use acpi_set_gpe
ACPI / EC: Drop suspend and resume routines
ACPICA: Remove wakeup GPE reference counting which is not used
ACPICA: Introduce acpi_gpe_wakeup()
ACPICA: Rename acpi_hw_gpe_register_bit
ACPICA: Update version to 20100528
ACPICA: Add signatures for undefined tables: ATKG, GSCI, IEIT
ACPICA: Optimization: Reduce the number of namespace walks
...
Diffstat (limited to 'drivers/acpi/acpica/evgpeinit.c')
-rw-r--r-- | drivers/acpi/acpica/evgpeinit.c | 236 |
1 files changed, 17 insertions, 219 deletions
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c index 3f6c2d26410d..3084c5de1bba 100644 --- a/drivers/acpi/acpica/evgpeinit.c +++ b/drivers/acpi/acpica/evgpeinit.c | |||
@@ -211,9 +211,7 @@ acpi_status acpi_ev_gpe_initialize(void) | |||
211 | * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a | 211 | * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a |
212 | * result of a Load() or load_table() operation. If new GPE | 212 | * result of a Load() or load_table() operation. If new GPE |
213 | * methods have been installed, register the new methods and | 213 | * methods have been installed, register the new methods and |
214 | * enable and runtime GPEs that are associated with them. Also, | 214 | * enable and runtime GPEs that are associated with them. |
215 | * run any newly loaded _PRW methods in order to discover any | ||
216 | * new CAN_WAKE GPEs. | ||
217 | * | 215 | * |
218 | ******************************************************************************/ | 216 | ******************************************************************************/ |
219 | 217 | ||
@@ -223,49 +221,12 @@ void acpi_ev_update_gpes(acpi_owner_id table_owner_id) | |||
223 | struct acpi_gpe_block_info *gpe_block; | 221 | struct acpi_gpe_block_info *gpe_block; |
224 | struct acpi_gpe_walk_info walk_info; | 222 | struct acpi_gpe_walk_info walk_info; |
225 | acpi_status status = AE_OK; | 223 | acpi_status status = AE_OK; |
226 | u32 new_wake_gpe_count = 0; | ||
227 | |||
228 | /* We will examine only _PRW/_Lxx/_Exx methods owned by this table */ | ||
229 | |||
230 | walk_info.owner_id = table_owner_id; | ||
231 | walk_info.execute_by_owner_id = TRUE; | ||
232 | walk_info.count = 0; | ||
233 | |||
234 | if (acpi_gbl_leave_wake_gpes_disabled) { | ||
235 | /* | ||
236 | * 1) Run any newly-loaded _PRW methods to find any GPEs that | ||
237 | * can now be marked as CAN_WAKE GPEs. Note: We must run the | ||
238 | * _PRW methods before we process the _Lxx/_Exx methods because | ||
239 | * we will enable all runtime GPEs associated with the new | ||
240 | * _Lxx/_Exx methods at the time we process those methods. | ||
241 | * | ||
242 | * Unlock interpreter so that we can run the _PRW methods. | ||
243 | */ | ||
244 | walk_info.gpe_block = NULL; | ||
245 | walk_info.gpe_device = NULL; | ||
246 | |||
247 | acpi_ex_exit_interpreter(); | ||
248 | |||
249 | status = | ||
250 | acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
251 | ACPI_UINT32_MAX, | ||
252 | ACPI_NS_WALK_NO_UNLOCK, | ||
253 | acpi_ev_match_prw_and_gpe, NULL, | ||
254 | &walk_info, NULL); | ||
255 | if (ACPI_FAILURE(status)) { | ||
256 | ACPI_EXCEPTION((AE_INFO, status, | ||
257 | "While executing _PRW methods")); | ||
258 | } | ||
259 | |||
260 | acpi_ex_enter_interpreter(); | ||
261 | new_wake_gpe_count = walk_info.count; | ||
262 | } | ||
263 | 224 | ||
264 | /* | 225 | /* |
265 | * 2) Find any _Lxx/_Exx GPE methods that have just been loaded. | 226 | * 2) Find any _Lxx/_Exx GPE methods that have just been loaded. |
266 | * | 227 | * |
267 | * Any GPEs that correspond to new _Lxx/_Exx methods and are not | 228 | * Any GPEs that correspond to new _Lxx/_Exx methods are immediately |
268 | * marked as CAN_WAKE are immediately enabled. | 229 | * enabled. |
269 | * | 230 | * |
270 | * Examine the namespace underneath each gpe_device within the | 231 | * Examine the namespace underneath each gpe_device within the |
271 | * gpe_block lists. | 232 | * gpe_block lists. |
@@ -275,6 +236,8 @@ void acpi_ev_update_gpes(acpi_owner_id table_owner_id) | |||
275 | return; | 236 | return; |
276 | } | 237 | } |
277 | 238 | ||
239 | walk_info.owner_id = table_owner_id; | ||
240 | walk_info.execute_by_owner_id = TRUE; | ||
278 | walk_info.count = 0; | 241 | walk_info.count = 0; |
279 | walk_info.enable_this_gpe = TRUE; | 242 | walk_info.enable_this_gpe = TRUE; |
280 | 243 | ||
@@ -307,10 +270,8 @@ void acpi_ev_update_gpes(acpi_owner_id table_owner_id) | |||
307 | gpe_xrupt_info = gpe_xrupt_info->next; | 270 | gpe_xrupt_info = gpe_xrupt_info->next; |
308 | } | 271 | } |
309 | 272 | ||
310 | if (walk_info.count || new_wake_gpe_count) { | 273 | if (walk_info.count) { |
311 | ACPI_INFO((AE_INFO, | 274 | ACPI_INFO((AE_INFO, "Enabled %u new GPEs", walk_info.count)); |
312 | "Enabled %u new runtime GPEs, added %u new wakeup GPEs", | ||
313 | walk_info.count, new_wake_gpe_count)); | ||
314 | } | 275 | } |
315 | 276 | ||
316 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 277 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
@@ -386,9 +347,6 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
386 | /* | 347 | /* |
387 | * 3) Edge/Level determination is based on the 2nd character | 348 | * 3) Edge/Level determination is based on the 2nd character |
388 | * of the method name | 349 | * of the method name |
389 | * | ||
390 | * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is | ||
391 | * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set. | ||
392 | */ | 350 | */ |
393 | switch (name[1]) { | 351 | switch (name[1]) { |
394 | case 'L': | 352 | case 'L': |
@@ -471,24 +429,18 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
471 | */ | 429 | */ |
472 | if (walk_info->enable_this_gpe) { | 430 | if (walk_info->enable_this_gpe) { |
473 | 431 | ||
474 | /* Ignore GPEs that can wake the system */ | 432 | walk_info->count++; |
433 | gpe_device = walk_info->gpe_device; | ||
475 | 434 | ||
476 | if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE) || | 435 | if (gpe_device == acpi_gbl_fadt_gpe_device) { |
477 | !acpi_gbl_leave_wake_gpes_disabled) { | 436 | gpe_device = NULL; |
478 | walk_info->count++; | 437 | } |
479 | gpe_device = walk_info->gpe_device; | ||
480 | |||
481 | if (gpe_device == acpi_gbl_fadt_gpe_device) { | ||
482 | gpe_device = NULL; | ||
483 | } | ||
484 | 438 | ||
485 | status = acpi_enable_gpe(gpe_device, gpe_number, | 439 | status = acpi_enable_gpe(gpe_device, gpe_number); |
486 | ACPI_GPE_TYPE_RUNTIME); | 440 | if (ACPI_FAILURE(status)) { |
487 | if (ACPI_FAILURE(status)) { | 441 | ACPI_EXCEPTION((AE_INFO, status, |
488 | ACPI_EXCEPTION((AE_INFO, status, | 442 | "Could not enable GPE 0x%02X", |
489 | "Could not enable GPE 0x%02X", | 443 | gpe_number)); |
490 | gpe_number)); | ||
491 | } | ||
492 | } | 444 | } |
493 | } | 445 | } |
494 | 446 | ||
@@ -497,157 +449,3 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
497 | name, gpe_number)); | 449 | name, gpe_number)); |
498 | return_ACPI_STATUS(AE_OK); | 450 | return_ACPI_STATUS(AE_OK); |
499 | } | 451 | } |
500 | |||
501 | /******************************************************************************* | ||
502 | * | ||
503 | * FUNCTION: acpi_ev_match_prw_and_gpe | ||
504 | * | ||
505 | * PARAMETERS: Callback from walk_namespace | ||
506 | * | ||
507 | * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is | ||
508 | * not aborted on a single _PRW failure. | ||
509 | * | ||
510 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
511 | * Device. Run the _PRW method. If present, extract the GPE | ||
512 | * number and mark the GPE as a CAN_WAKE GPE. Allows a | ||
513 | * per-owner_id execution if execute_by_owner_id is TRUE in the | ||
514 | * walk_info parameter block. | ||
515 | * | ||
516 | * If walk_info->execute_by_owner_id is TRUE, we only execute _PRWs with that | ||
517 | * owner. | ||
518 | * If walk_info->gpe_device is NULL, we execute every _PRW found. Otherwise, | ||
519 | * we only execute _PRWs that refer to the input gpe_device. | ||
520 | * | ||
521 | ******************************************************************************/ | ||
522 | |||
523 | acpi_status | ||
524 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
525 | u32 level, void *context, void **return_value) | ||
526 | { | ||
527 | struct acpi_gpe_walk_info *walk_info = | ||
528 | ACPI_CAST_PTR(struct acpi_gpe_walk_info, context); | ||
529 | struct acpi_namespace_node *gpe_device; | ||
530 | struct acpi_gpe_block_info *gpe_block; | ||
531 | struct acpi_namespace_node *target_gpe_device; | ||
532 | struct acpi_namespace_node *prw_node; | ||
533 | struct acpi_gpe_event_info *gpe_event_info; | ||
534 | union acpi_operand_object *pkg_desc; | ||
535 | union acpi_operand_object *obj_desc; | ||
536 | u32 gpe_number; | ||
537 | acpi_status status; | ||
538 | |||
539 | ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe); | ||
540 | |||
541 | /* Check for a _PRW method under this device */ | ||
542 | |||
543 | status = acpi_ns_get_node(obj_handle, METHOD_NAME__PRW, | ||
544 | ACPI_NS_NO_UPSEARCH, &prw_node); | ||
545 | if (ACPI_FAILURE(status)) { | ||
546 | return_ACPI_STATUS(AE_OK); | ||
547 | } | ||
548 | |||
549 | /* Check if requested owner_id matches this owner_id */ | ||
550 | |||
551 | if ((walk_info->execute_by_owner_id) && | ||
552 | (prw_node->owner_id != walk_info->owner_id)) { | ||
553 | return_ACPI_STATUS(AE_OK); | ||
554 | } | ||
555 | |||
556 | /* Execute the _PRW */ | ||
557 | |||
558 | status = acpi_ut_evaluate_object(prw_node, NULL, | ||
559 | ACPI_BTYPE_PACKAGE, &pkg_desc); | ||
560 | if (ACPI_FAILURE(status)) { | ||
561 | return_ACPI_STATUS(AE_OK); | ||
562 | } | ||
563 | |||
564 | /* The returned _PRW package must have at least two elements */ | ||
565 | |||
566 | if (pkg_desc->package.count < 2) { | ||
567 | goto cleanup; | ||
568 | } | ||
569 | |||
570 | /* Extract pointers from the input context */ | ||
571 | |||
572 | gpe_device = walk_info->gpe_device; | ||
573 | gpe_block = walk_info->gpe_block; | ||
574 | |||
575 | /* | ||
576 | * The _PRW object must return a package, we are only interested | ||
577 | * in the first element | ||
578 | */ | ||
579 | obj_desc = pkg_desc->package.elements[0]; | ||
580 | |||
581 | if (obj_desc->common.type == ACPI_TYPE_INTEGER) { | ||
582 | |||
583 | /* Use FADT-defined GPE device (from definition of _PRW) */ | ||
584 | |||
585 | target_gpe_device = NULL; | ||
586 | if (gpe_device) { | ||
587 | target_gpe_device = acpi_gbl_fadt_gpe_device; | ||
588 | } | ||
589 | |||
590 | /* Integer is the GPE number in the FADT described GPE blocks */ | ||
591 | |||
592 | gpe_number = (u32)obj_desc->integer.value; | ||
593 | } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { | ||
594 | |||
595 | /* Package contains a GPE reference and GPE number within a GPE block */ | ||
596 | |||
597 | if ((obj_desc->package.count < 2) || | ||
598 | ((obj_desc->package.elements[0])->common.type != | ||
599 | ACPI_TYPE_LOCAL_REFERENCE) || | ||
600 | ((obj_desc->package.elements[1])->common.type != | ||
601 | ACPI_TYPE_INTEGER)) { | ||
602 | goto cleanup; | ||
603 | } | ||
604 | |||
605 | /* Get GPE block reference and decode */ | ||
606 | |||
607 | target_gpe_device = | ||
608 | obj_desc->package.elements[0]->reference.node; | ||
609 | gpe_number = (u32)obj_desc->package.elements[1]->integer.value; | ||
610 | } else { | ||
611 | /* Unknown type, just ignore it */ | ||
612 | |||
613 | goto cleanup; | ||
614 | } | ||
615 | |||
616 | /* Get the gpe_event_info for this GPE */ | ||
617 | |||
618 | if (gpe_device) { | ||
619 | /* | ||
620 | * Is this GPE within this block? | ||
621 | * | ||
622 | * TRUE if and only if these conditions are true: | ||
623 | * 1) The GPE devices match. | ||
624 | * 2) The GPE index(number) is within the range of the Gpe Block | ||
625 | * associated with the GPE device. | ||
626 | */ | ||
627 | if (gpe_device != target_gpe_device) { | ||
628 | goto cleanup; | ||
629 | } | ||
630 | |||
631 | gpe_event_info = | ||
632 | acpi_ev_low_get_gpe_info(gpe_number, gpe_block); | ||
633 | } else { | ||
634 | /* gpe_device is NULL, just match the target_device and gpe_number */ | ||
635 | |||
636 | gpe_event_info = | ||
637 | acpi_ev_get_gpe_event_info(target_gpe_device, gpe_number); | ||
638 | } | ||
639 | |||
640 | if (gpe_event_info) { | ||
641 | if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { | ||
642 | |||
643 | /* This GPE can wake the system */ | ||
644 | |||
645 | gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; | ||
646 | walk_info->count++; | ||
647 | } | ||
648 | } | ||
649 | |||
650 | cleanup: | ||
651 | acpi_ut_remove_reference(pkg_desc); | ||
652 | return_ACPI_STATUS(AE_OK); | ||
653 | } | ||