• Rafael J. Wysocki's avatar
    ACPI: power: Save the last known state of each power resource · ca84f187
    Rafael J. Wysocki authored
    Currently, there are two ways to check the state of an ACPI power
    resource and they may not be consistent with each other.  The first
    one is to evaluate the power resource's _STA object and the other one
    is to check its reference counter value.  However, on some systems
    the value returned by _STA may not be consistent with the value of
    the power resource's reference counter (for example, on some systems
    it returns the same value every time for certain power resources).
    
    Moreover, evaluating _STA is unnecessary overhead for a power
    resource for which it has been evaluated already or whose state is
    otherwise known, because either the _ON or the _OFF method has been
    executed for it.
    
    For this reason, save the state of each power resource in its
    struct acpi_power_resource object and use the saved value whenever
    its state needs to be checked, except when its stats is unknown, in
    which case the _STA method is evaluated for it and the value
    returned by that method is saved as the last known state of
    the power resource.
    
    Moreover, drop the power resource _STA method evaluation from
    acpi_add_power_resource(), so as to avoid doing that unnecessarily
    for power resources that will never be used.
    Tested-by: default avatarDave Olsthoorn <dave@bewaar.me>
    Tested-by: default avatarShujun Wang <wsj20369@163.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    ca84f187
power.c 26.5 KB