Commit 212967c6 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Len Brown

ACPI / PM: Check device state before refcounting power resources

Commit 3e384ee6 (ACPI / PM: Fix
reference counting of power resources) introduced a regression by
causing fan power resources to be turned on and reference counted
unnecessarily during resume, so on some boxes fans are always on
after resume.

Fix the problem by checking if the current device state is different
from the new state before reference counting and turning on power
resources in acpi_power_transition().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=22932 .
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: default avatarMaciej Rutecki <maciej.rutecki@gmail.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent e8a7e48b
...@@ -465,10 +465,12 @@ int acpi_power_transition(struct acpi_device *device, int state) ...@@ -465,10 +465,12 @@ int acpi_power_transition(struct acpi_device *device, int state)
struct acpi_handle_list *tl = NULL; /* Target Resources */ struct acpi_handle_list *tl = NULL; /* Target Resources */
int i = 0; int i = 0;
if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
return -EINVAL; return -EINVAL;
if (device->power.state == state)
return 0;
if ((device->power.state < ACPI_STATE_D0) if ((device->power.state < ACPI_STATE_D0)
|| (device->power.state > ACPI_STATE_D3)) || (device->power.state > ACPI_STATE_D3))
return -ENODEV; return -ENODEV;
...@@ -488,10 +490,6 @@ int acpi_power_transition(struct acpi_device *device, int state) ...@@ -488,10 +490,6 @@ int acpi_power_transition(struct acpi_device *device, int state)
goto end; goto end;
} }
if (device->power.state == state) {
goto end;
}
/* /*
* Then we dereference all power resources used in the current list. * Then we dereference all power resources used in the current list.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment