Skip to content

Commit 7a63296

Browse files
committed
ACPI: PM: Turn off unused wakeup power resources
If an ACPI power resource is found to be "on" during the initialization of the list of wakeup power resources of a device, it is reference counted and its wakeup_enabled flag is set, which is problematic if the deivce in question is the only user of the given power resource, it is never runtime-suspended and it is not allowed to wake up the system from sleep, because in that case the given power resource will stay "on" until the system reboots and energy will be wasted. It is better to simply turn off wakeup power resources that are "on" during the initialization unless their reference counters are not zero, because that may be the only opportunity to prevent them from staying in the "on" state all the time. Fixes: b5d667e ("ACPI / PM: Take unusual configurations of power resources into account") Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a1224f3 commit 7a63296

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

drivers/acpi/power.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -615,20 +615,19 @@ int acpi_power_wakeup_list_init(struct list_head *list, int *system_level_p)
615615

616616
list_for_each_entry(entry, list, node) {
617617
struct acpi_power_resource *resource = entry->resource;
618-
int result;
619618
u8 state;
620619

621620
mutex_lock(&resource->resource_lock);
622621

623-
result = acpi_power_get_state(resource, &state);
624-
if (result) {
625-
mutex_unlock(&resource->resource_lock);
626-
return result;
627-
}
628-
if (state == ACPI_POWER_RESOURCE_STATE_ON) {
629-
resource->ref_count++;
630-
resource->wakeup_enabled = true;
631-
}
622+
/*
623+
* Make sure that the power resource state and its reference
624+
* counter value are consistent with each other.
625+
*/
626+
if (!resource->ref_count &&
627+
!acpi_power_get_state(resource, &state) &&
628+
state == ACPI_POWER_RESOURCE_STATE_ON)
629+
__acpi_power_off(resource);
630+
632631
if (system_level > resource->system_level)
633632
system_level = resource->system_level;
634633

0 commit comments

Comments
 (0)