]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ACPI / PM: Fix reference counting of power resources
authorRafael J. Wysocki <rjw@sisk.pl>
Fri, 22 Oct 2010 00:35:54 +0000 (02:35 +0200)
committerLen Brown <len.brown@intel.com>
Sat, 23 Oct 2010 05:56:14 +0000 (01:56 -0400)
commit3e384ee6c687cb397581ee8f9440fc8220cfac80
treeb8559d4952bb6d7350eeb5a0bac418a5eacda117
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f
ACPI / PM: Fix reference counting of power resources

The reference counting of ACPI power resources is currently broken
for a few reasons.  First, instead of using a simple reference
counter per power resource it uses a list of objects representing
refereces to the given power resource from devices.  This leads to
the second breakage, because it prevents power resources from
being referenced more than once by one device, which is necessary
if the device is configured to signal wakeup.  Namely, when putting
the device into a low power state we first call
acpi_enable_wakeup_device_power() that should reference count power
resources needed for signaling wakeup and then we call
acpi_power_transition() to power off the device.  The latter call
drops references to the device's power resources, possibly including
the ones added by acpi_enable_wakeup_device_power(), so the device
can't signal wakeup as a result.  Apart from this, the locking
in acpi_power_on() and acpi_power_off_device() doesn't prevent
all possible races from happening, which may be problematic for
runtime PM and asynchronous suspend and resume.

Fix the problem by using a counter for power resources reference
counting and putting the evaluation of ACPI _ON and _OFF methods
under the power resource mutex.

Reported-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/power.c