• Rafael J. Wysocki's avatar
    ACPI / PM: Fix reference counting of power resources · 3e384ee6
    Rafael J. Wysocki authored
    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: default avatarMatthew Garrett <mjg@redhat.com>
    Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
    Signed-off-by: default avatarLen Brown <len.brown@intel.com>
    3e384ee6
power.c 15.7 KB