Commit 5f8902acf87aa206ee4b3f633104456d82747ca6

Authored by Lin Ming
Committed by Len Brown
1 parent a8357b0c95

ACPICA: AcpiGetDevices: Eliminate unnecessary _STA calls

In the case where a specific _HID is requested, do not run _STA
until a _HID match is found. This eliminates potentially dozens
of _STA calls during a search for a particular device/HID.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>

Showing 1 changed file with 33 additions and 19 deletions Side-by-side Diff

drivers/acpi/acpica/nsxfeval.c
... ... @@ -562,25 +562,20 @@
562 562 return (AE_BAD_PARAMETER);
563 563 }
564 564  
565   - /* Run _STA to determine if device is present */
566   -
567   - status = acpi_ut_execute_STA(node, &flags);
568   - if (ACPI_FAILURE(status)) {
569   - return (AE_CTRL_DEPTH);
570   - }
571   -
572   - if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
573   - !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
574   - /*
575   - * Don't examine the children of the device only when the
576   - * device is neither present nor functional. See ACPI spec,
577   - * description of _STA for more information.
578   - */
579   - return (AE_CTRL_DEPTH);
580   - }
581   -
582   - /* Filter based on device HID & CID */
583   -
  565 + /*
  566 + * First, filter based on the device HID and CID.
  567 + *
  568 + * 01/2010: For this case where a specific HID is requested, we don't
  569 + * want to run _STA until we have an actual HID match. Thus, we will
  570 + * not unnecessarily execute _STA on devices for which the caller
  571 + * doesn't care about. Previously, _STA was executed unconditionally
  572 + * on all devices found here.
  573 + *
  574 + * A side-effect of this change is that now we will continue to search
  575 + * for a matching HID even under device trees where the parent device
  576 + * would have returned a _STA that indicates it is not present or
  577 + * not functioning (thus aborting the search on that branch).
  578 + */
584 579 if (info->hid != NULL) {
585 580 status = acpi_ut_execute_HID(node, &hid);
586 581 if (status == AE_NOT_FOUND) {
... ... @@ -619,6 +614,25 @@
619 614 return (AE_OK);
620 615 }
621 616 }
  617 +
  618 + /* Run _STA to determine if device is present */
  619 +
  620 + status = acpi_ut_execute_STA(node, &flags);
  621 + if (ACPI_FAILURE(status)) {
  622 + return (AE_CTRL_DEPTH);
  623 + }
  624 +
  625 + if (!(flags & ACPI_STA_DEVICE_PRESENT) &&
  626 + !(flags & ACPI_STA_DEVICE_FUNCTIONING)) {
  627 + /*
  628 + * Don't examine the children of the device only when the
  629 + * device is neither present nor functional. See ACPI spec,
  630 + * description of _STA for more information.
  631 + */
  632 + return (AE_CTRL_DEPTH);
  633 + }
  634 +
  635 + /* We have a valid device, invoke the user function */
622 636  
623 637 status = info->user_function(obj_handle, nesting_level, info->context,
624 638 return_value);