• Rafael J. Wysocki's avatar
    ACPI: PM: Avoid using power resources if there are none for D0 · 956ad9d9
    Rafael J. Wysocki authored
    As recently reported, some platforms provide a list of power
    resources for device power state D3hot, through the _PR3 object,
    but they do not provide a list of power resources for device power
    state D0.
    
    Among other things, this causes acpi_device_get_power() to return
    D3hot as the current state of the device in question if all of the
    D3hot power resources are "on", because it sees the power_resources
    flag set and calls acpi_power_get_inferred_state() which finds that
    D3hot is the shallowest power state with all of the associated power
    resources turned "on", so that's what it returns.  Moreover, that
    value takes precedence over the acpi_dev_pm_explicit_get() return
    value, because it means a deeper power state.  The device may very
    well be in D0 physically at that point, however.
    
    Moreover, the presence of _PR3 without _PR0 for a given device
    means that only one D3-level power state can be supported by it.
    Namely, because there are no power resources to turn "off" when
    transitioning the device from D0 into D3cold (which should be
    supported since _PR3 is present), the evaluation of _PS3 should
    be sufficient to put it straight into D3cold, but this means that
    the effect of turning "on" the _PR3 power resources is unclear,
    so it is better to avoid doing that altogether.  Consequently,
    there is no practical way do distinguish D3cold from D3hot for
    the device in question and the power states of it can be labeled
    so that D3hot is the deepest supported one (and Linux assumes
    that putting a device into D3hot via ACPI may cause power to be
    removed from it anyway, for legacy reasons).
    
    To work around the problem described above modify the ACPI
    enumeration of devices so that power resources are only used
    for device power management if the list of D0 power resources
    is not empty and make it mart D3cold as supported only if that
    is the case and the D3hot list of power resources is not empty
    too.
    
    Fixes: ef85bdbe ("ACPI / scan: Consolidate extraction of power resources lists")
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=205057
    Link: https://lore.kernel.org/linux-acpi/20200603194659.185757-1-hdegoede@redhat.com/Reported-by: default avatarHans de Goede <hdegoede@redhat.com>
    Tested-by: default avatarHans de Goede <hdegoede@redhat.com>
    Tested-by: youling257@gmail.com
    Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    956ad9d9
scan.c 58.6 KB