30 Dec, 2020

1 commit

  • commit 7482c5cb90e5a7f9e9e12dd154d405e0219656e3 upstream.

    The idea behind acpi_pm_set_bridge_wakeup() was to allow bridges to
    be reference counted for wakeup enabling, because they may be enabled
    to signal wakeup on behalf of their subordinate devices and that
    may happen for multiple times in a row, whereas for the other devices
    it only makes sense to enable wakeup signaling once.

    However, this becomes problematic if the bridge itself is suspended,
    because it is treated as a "regular" device in that case and the
    reference counting doesn't work.

    For instance, suppose that there are two devices below a bridge and
    they both can signal wakeup. Every time one of them is suspended,
    wakeup signaling is enabled for the bridge, so when they both have
    been suspended, the bridge's wakeup reference counter value is 2.

    Say that the bridge is suspended subsequently and acpi_pci_wakeup()
    is called for it. Because the bridge can signal wakeup, that
    function will invoke acpi_pm_set_device_wakeup() to configure it
    and __acpi_pm_set_device_wakeup() will be called with the last
    argument equal to 1. This causes __acpi_device_wakeup_enable()
    invoked by it to omit the reference counting, because the reference
    counter of the target device (the bridge) is 2 at that time.

    Now say that the bridge resumes and one of the device below it
    resumes too, so the bridge's reference counter becomes 0 and
    wakeup signaling is disabled for it, but there is still the other
    suspended device which may need the bridge to signal wakeup on its
    behalf and that is not going to work.

    To address this scenario, use wakeup enable reference counting for
    all devices, not just for bridges, so drop the last argument from
    __acpi_device_wakeup_enable() and __acpi_pm_set_device_wakeup(),
    which causes acpi_pm_set_device_wakeup() and
    acpi_pm_set_bridge_wakeup() to become identical, so drop the latter
    and use the former instead of it everywhere.

    Fixes: 1ba51a7c1496 ("ACPI / PCI / PM: Rework acpi_pci_propagate_wakeup()")
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg
    Acked-by: Bjorn Helgaas
    Cc: 4.14+ # 4.14+
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

10 Jun, 2020

1 commit


08 Jun, 2020

1 commit

  • 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: ef85bdbec444 ("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: Hans de Goede
    Tested-by: Hans de Goede
    Tested-by: youling257@gmail.com
    Cc: 3.10+ # 3.10+
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Hans de Goede

    Rafael J. Wysocki
     

01 Jun, 2020

1 commit

  • * pm-core:
    PM: runtime: Replace pm_runtime_callbacks_present()
    PM: runtime: clk: Fix clk_pm_runtime_get() error path
    PM: runtime: Make clear what we do when conditions are wrong in rpm_suspend()

    * pm-sleep:
    PM: hibernate: Restrict writes to the resume device
    PM: hibernate: Split off snapshot dev option
    PM: hibernate: Incorporate concurrency handling
    PM: sleep: Helpful edits for devices.rst documentation
    Documentation: PM: sleep: Update driver flags documentation
    PM: sleep: core: Rename DPM_FLAG_LEAVE_SUSPENDED
    PM: sleep: core: Rename DPM_FLAG_NEVER_SKIP
    PM: sleep: core: Rename dev_pm_smart_suspend_and_suspended()
    PM: sleep: core: Rename dev_pm_may_skip_resume()
    PM: sleep: core: Rework the power.may_skip_resume handling
    PM: sleep: core: Do not skip callbacks in the resume phase
    PM: sleep: core: Fold functions into their callers
    PM: sleep: core: Simplify the SMART_SUSPEND flag handling

    Rafael J. Wysocki
     

27 Apr, 2020

1 commit


25 Apr, 2020

4 commits

  • Because all callers of dev_pm_smart_suspend_and_suspended use it only
    for checking whether or not to skip driver suspend callbacks for a
    device, rename it to dev_pm_skip_suspend() in analogy with
    dev_pm_skip_resume().

    No functional impact.

    Suggested-by: Alan Stern
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Alan Stern
    Acked-by: Bjorn Helgaas

    Rafael J. Wysocki
     
  • The name of dev_pm_may_skip_resume() may be easily confused with the
    power.may_skip_resume flag which is not checked by that function, so
    rename the former as dev_pm_skip_resume().

    No functional impact.

    Suggested-by: Alan Stern
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Alan Stern
    Acked-by: Bjorn Helgaas

    Rafael J. Wysocki
     
  • Because the power.may_skip_resume device status bit is taken
    into account in combination with the DPM_FLAG_LEAVE_SUSPENDED
    driver flag, it can be set to 'true' for all devices in the
    "suspend" phase of a suspend-resume cycle, so do that.

    Then, neither the PM core nor the middle-layer (sybsystem) code
    handling it needs to set it to 'true' any more and it just has
    to be cleared if there is a reason to avoid skipping the "noirq"
    and "early" resume callbacks provided by the driver, so update
    the code in question accordingly.

    Suggested-by: Alan Stern
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Alan Stern
    Acked-by: Bjorn Helgaas

    Rafael J. Wysocki
     
  • The current code in device_resume_noirq() causes the entire early
    resume and resume phases of device suspend to be skipped for
    devices for which the noirq resume phase have been skipped (due
    to the LEAVE_SUSPENDED flag being set) on the premise that those
    devices should stay in runtime-suspend after system-wide resume.

    However, that may not be correct in two situations. First, the
    middle layer (subsystem) noirq resume callback may be missing for
    a given device, but its early resume callback may be present and it
    may need to do something even if it decides to skip the driver
    callback. Second, if the device's wakeup settings were adjusted
    in the suspend phase without resuming the device (that was in
    runtime suspend at that time), they most likely need to be
    adjusted again in the resume phase and so the driver callback
    in that phase needs to be run.

    For the above reason, modify the core to allow the middle layer
    ->resume_late callback to run even if its ->resume_noirq callback
    is missing (and the core has skipped the driver-level callback
    in that phase) and to allow all device callbacks to run in the
    resume phase. Also make the core set the PM-runtime status of
    devices with SMART_SUSPEND set whose resume callbacks are not
    skipped to "active" in the "noirq" resume phase and update the
    affected subsystems (PCI and ACPI) accordingly.

    After this change, middle-layer (subsystem) callbacks will always
    be invoked in all phases of system suspend and resume and driver
    callbacks will always run in the prepare, suspend, resume, and
    complete phases for all devices.

    For devices with SMART_SUSPEND set, driver callbacks will be
    skipped in the late and noirq phases of system suspend if those
    devices remain in runtime suspend in __device_suspend_late().
    Driver callbacks will also be skipped for them during the
    noirq and early phases of the "thaw" transition related to
    hibernation in that case.

    Setting LEAVE_SUSPENDED means that the driver allows its callbacks
    to be skipped in the noirq and early phases of system resume, but
    some additional conditions need to be met for that to happen (among
    other things, the power.may_skip_resume flag needs to be set for the
    device during system suspend for the driver callbacks to be skipped
    during the subsequent resume transition).

    For all devices with SMART_SUSPEND set whose driver callbacks are
    invoked during system resume, the PM-runtime status will be set to
    "active" (by the core).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Alan Stern
    Acked-by: Bjorn Helgaas

    Rafael J. Wysocki
     

01 Apr, 2020

1 commit

  • Tiger Lake's new unique ACPI device IDs for DPTF and fan drivers are not
    valid as the IDs are missing 'C'. Fix the IDs by updating them.

    After the update, the new IDs should now look like
    INT1047 --> INTC1047
    INT1040 --> INTC1040
    INT1043 --> INTC1043
    INT1044 --> INTC1044

    Fixes: 55cfe6a5c582 ("ACPI: DPTF: Add Tiger Lake ACPI device IDs")
    Fixes: c248dfe7e0ca ("ACPI: fan: Add Tiger Lake ACPI device ID")
    Suggested-by: Srinivas Pandruvada
    Signed-off-by: Gayatri Kammela
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Rafael J. Wysocki

    Gayatri Kammela
     

20 Dec, 2019

1 commit

  • Tiger Lake has a new unique ACPI device ID for the ACPI fan that
    needs to be added to the fan driver and to the blacklist in
    acpi_dev_pm_attach() to support it.

    Signed-off-by: Gayatri Kammela
    [ rjw: Subject & changelog, fold in another patch ]
    Signed-off-by: Rafael J. Wysocki

    Gayatri Kammela
     

10 Dec, 2019

1 commit

  • Certain ACPI-enumerated devices represented as platform devices in
    Linux, like fans, require special low-level power management handling
    implemented by their drivers that is not in agreement with the ACPI
    PM domain behavior. That leads to problems with managing ACPI fans
    during system-wide suspend and resume.

    For this reason, make acpi_dev_pm_attach() skip the affected devices
    by adding a list of device IDs to avoid to it and putting the IDs of
    the affected devices into that list.

    Fixes: e5cc8ef31267 (ACPI / PM: Provide ACPI PM callback routines for subsystems)
    Reported-by: Zhang Rui
    Tested-by: Todd Brandt
    Cc: 3.10+ # 3.10+
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

17 Sep, 2019

1 commit

  • * pm-opp:
    PM / OPP: Correct Documentation about library location
    opp: of: Support multiple suspend OPPs defined in DT
    dt-bindings: opp: Support multiple opp-suspend properties
    opp: core: add regulators enable and disable
    opp: Don't decrement uninitialized list_kref

    * pm-qos:
    PM: QoS: Get rid of unused flags

    * acpi-pm:
    ACPI: PM: Print debug messages on device power state changes

    * pm-domains:
    PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state()
    PM / Domains: Simplify genpd_lookup_dev()
    PM / Domains: Align in-parameter names for some genpd functions

    * pm-tools:
    pm-graph: make setVal unbuffered again for python2 and python3
    cpupower: update German translation
    tools/power/cpupower: fix 64bit detection when cross-compiling
    cpupower: Add missing newline at end of file
    pm-graph v5.5

    Rafael J. Wysocki
     

21 Aug, 2019

1 commit

  • Add an ID and a device pointer to 'struct wakeup_source'. Use them to to
    expose wakeup sources statistics in sysfs under
    /sys/class/wakeup/wakeup/*.

    Co-developed-by: Greg Kroah-Hartman
    Signed-off-by: Greg Kroah-Hartman
    Co-developed-by: Stephen Boyd
    Signed-off-by: Stephen Boyd
    Signed-off-by: Tri Vo
    Tested-by: Kalesh Singh
    Signed-off-by: Rafael J. Wysocki

    Tri Vo
     

08 Aug, 2019

1 commit


02 Aug, 2019

1 commit

  • Commit f850a48a0799 ("ACPI: PM: Allow transitions to D0 to occur in
    special cases") overlooked the fact that acpi_power_transition() may
    change the power.state value for the target device and if that
    happens, it may confuse acpi_device_set_power() and cause it to
    omit the _PS0 evaluation which on some systems is necessary to
    change power states of devices from low-power to D0.

    Fix that by saving the current value of power.state for the
    target device before passing it to acpi_power_transition() and
    using the saved value in a subsequent check.

    Fixes: f850a48a0799 ("ACPI: PM: Allow transitions to D0 to occur in special cases")
    Reported-by: Kai-Heng Feng
    Reported-by: Mario Limonciello
    Signed-off-by: Rafael J. Wysocki
    Tested-by: Kai-Heng Feng
    Tested-by: Mario Limonciello

    Rafael J. Wysocki
     

08 Jul, 2019

2 commits

  • * pm-sleep:
    PM: sleep: Drop dev_pm_skip_next_resume_phases()
    ACPI: PM: Drop unused function and function header
    ACPI: PM: Introduce "poweroff" callbacks for ACPI PM domain and LPSS
    ACPI: PM: Simplify and fix PM domain hibernation callbacks
    PCI: PM: Simplify bus-level hibernation callbacks
    PM: ACPI/PCI: Resume all devices during hibernation
    kernel: power: swap: use kzalloc() instead of kmalloc() followed by memset()
    PM: sleep: Update struct wakeup_source documentation
    drivers: base: power: remove wakeup_sources_stats_dentry variable
    PM: suspend: Rename pm_suspend_via_s2idle()
    PM: sleep: Show how long dpm_suspend_start() and dpm_suspend_end() take
    PM: hibernate: powerpc: Expose pfn_is_nosave() prototype

    Rafael J. Wysocki
     
  • * acpi-pm:
    ACPI: PM: Make acpi_sleep_state_supported() non-static
    ACPI: PM: Allow transitions to D0 to occur in special cases
    ACPI: PM: Avoid evaluating _PS3 on transitions from D3hot to D3cold
    ACPI / sleep: Switch to use acpi_dev_get_first_match_dev()
    ACPI / LPIT: Correct LPIT end address for lpit_process()

    * pm-pci:
    ACPI: PM: Unexport acpi_device_get_power()
    PCI: PM/ACPI: Refresh all stale power state data in pci_pm_complete()
    PCI / ACPI: Add _PR0 dependent devices
    ACPI / PM: Introduce concept of a _PR0 dependent device
    PCI / ACPI: Use cached ACPI device state to get PCI device power state
    PCI: Do not poll for PME if the device is in D3cold
    PCI: Add missing link delays required by the PCIe spec
    PCI: PM: Replace pci_dev_keep_suspended() with two functions
    PCI: PM: Avoid resuming devices in D3hot during system suspend

    Rafael J. Wysocki
     

04 Jul, 2019

1 commit

  • Using acpi_device_get_power() outside of ACPI device initialization
    and ACPI sysfs is problematic due to the way in which power resources
    are handled by it, so unexport it and add a paragraph explaining the
    pitfalls to its kerneldoc comment.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg

    Rafael J. Wysocki
     

03 Jul, 2019

3 commits

  • In general, it is not correct to call pm_generic_suspend(),
    pm_generic_suspend_late() and pm_generic_suspend_noirq() during the
    hibernation's "poweroff" transition, because device drivers may
    provide special callbacks to be invoked then and the wrappers in
    question cause system suspend callbacks to be run. Unfortunately,
    that happens in the ACPI PM domain and ACPI LPSS.

    To address this potential issue, introduce "poweroff" callbacks
    for the ACPI PM and LPSS that will use pm_generic_poweroff(),
    pm_generic_poweroff_late() and pm_generic_poweroff_noirq() as
    appropriate.

    Fixes: 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg
    Reviewed-by: Hans de Goede

    Rafael J. Wysocki
     
  • First, after a previous change causing all runtime-suspended devices
    in the ACPI PM domain (and ACPI LPSS devices) to be resumed before
    creating a snapshot image of memory during hibernation, it is not
    necessary to worry about the case in which them might be left in
    runtime-suspend any more, so get rid of the code related to that from
    ACPI PM domain and ACPI LPSS hibernation callbacks.

    Second, it is not correct to use pm_generic_resume_early() and
    acpi_subsys_resume_noirq() in hibernation "restore" callbacks (which
    currently happens in the ACPI PM domain and ACPI LPSS), so introduce
    proper _restore_late and _restore_noirq callbacks for the ACPI PM
    domain and ACPI LPSS.

    Fixes: 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg
    Reviewed-by: Hans de Goede

    Rafael J. Wysocki
     
  • Both the PCI bus type and the ACPI PM domain avoid resuming
    runtime-suspended devices with DPM_FLAG_SMART_SUSPEND set during
    hibernation (before creating the snapshot image of system memory),
    but that turns out to be a mistake. It leads to functional issues
    and adds complexity that's hard to justify.

    For this reason, resume all runtime-suspended PCI devices and all
    devices in the ACPI PM domains before creating a snapshot image of
    system memory during hibernation.

    Fixes: 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)
    Fixes: c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account)
    Link: https://lore.kernel.org/linux-acpi/917d4399-2e22-67b1-9d54-808561f9083f@uwyo.edu/T/#maf065fe6e4974f2a9d79f332ab99dfaba635f64c
    Reported-by: Robert R. Howell
    Tested-by: Robert R. Howell
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg
    Reviewed-by: Hans de Goede

    Rafael J. Wysocki
     

27 Jun, 2019

2 commits

  • If a device with ACPI PM is left in D0 during a system-wide
    transition to the S3 (suspend-to-RAM) or S4 (hibernation) sleep
    state, the actual state of the device need not be D0 during resume
    from it, although its power.state value will still reflect D0 (that
    is, the power state from before the system-wide transition).

    In that case, the acpi_device_set_power() call made to ensure that
    the power state of the device will be D0 going forward has no effect,
    because the new state (D0) is equal to the one reflected by the
    device's power.state value. That does not affect power resources,
    which are taken care of by acpi_resume_power_resources() called from
    acpi_pm_finish() during resume from system-wide sleep states, but it
    still may be necessary to invoke _PS0 for the device on top of that
    in order to finalize its transition to D0.

    For this reason, modify acpi_device_set_power() to allow transitions
    to D0 to occur even if D0 is the current power state of the device
    according to its power.state value.

    That will not affect power resources, which are assumed to be in
    the right configuration already (as reflected by the current values
    of their reference counters), but it may cause _PS0 to be evaluated
    for the device. However, evaluating _PS0 for a device already in D0
    may lead to confusion in general, so invoke _PSC (if present) to
    check the device's current power state upfront and only evaluate
    _PS0 for it if _PSC has returned a power state different from D0.
    [If _PSC is not present or the evaluation of it fails, the power
    state of the device is assumed to be D0 at this point.]

    Fixes: 20dacb71ad28 (ACPI / PM: Rework device power management to follow ACPI 6)
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg

    Rafael J. Wysocki
     
  • If the power state of a device with ACPI PM is changed from D3hot to
    D3cold, it merely is a matter of dropping references to additional
    power resources (specifically, those in the list returned by _PR3),
    and the _PS3 method should not be invoked for the device then (as
    it has already been evaluated during the previous transition to
    D3hot).

    Fixes: 20dacb71ad28 (ACPI / PM: Rework device power management to follow ACPI 6)
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg

    Rafael J. Wysocki
     

01 Jun, 2019

1 commit

  • Pull power management fixes from Rafael Wysocki:
    "These fix three issues in the system-wide suspend and hibernation area
    related to PCI device PM handling by suspend-to-idle, device wakeup
    optimizations and arbitrary differences between suspend and
    hiberantion.

    Specifics:

    - Modify the PCI bus type's PM code to avoid putting devices left by
    their drivers in D0 on purpose during suspend to idle into
    low-power states as doing that may confuse the system resume
    callbacks of the drivers in question (Rafael Wysocki).

    - Avoid checking ACPI wakeup configuration during system-wide suspend
    for suspended devices that do not use ACPI-based wakeup to allow
    them to stay in suspend more often (Rafael Wysocki).

    - The last phase of hibernation is analogous to system-wide suspend
    also because on platforms with ACPI it passes control to the
    platform firmware to complete the transision, so make it indicate
    that by calling pm_set_suspend_via_firmware() to allow the drivers
    that care about this to do the right thing (Rafael Wysocki)"

    * tag 'pm-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
    PCI: PM: Avoid possible suspend-to-idle issue
    ACPI: PM: Call pm_set_suspend_via_firmware() during hibernation
    ACPI/PCI: PM: Add missing wakeup.flags.valid checks

    Linus Torvalds
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 655 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

27 May, 2019

1 commit

  • Both acpi_pci_need_resume() and acpi_dev_needs_resume() check if the
    current ACPI wakeup configuration of the device matches what is
    expected as far as system wakeup from sleep states is concerned, as
    reflected by the device_may_wakeup() return value for the device.

    However, they only should do that if wakeup.flags.valid is set for
    the device's ACPI companion, because otherwise the wakeup.prepare_count
    value for it is meaningless.

    Add the missing wakeup.flags.valid checks to these functions.

    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Mika Westerberg

    Rafael J. Wysocki
     

08 May, 2019

1 commit

  • Pull printk updates from Petr Mladek:

    - Allow state reset of printk_once() calls.

    - Prevent crashes when dereferencing invalid pointers in vsprintf().
    Only the first byte is checked for simplicity.

    - Make vsprintf warnings consistent and inlined.

    - Treewide conversion of obsolete %pf, %pF to %ps, %pF printf
    modifiers.

    - Some clean up of vsprintf and test_printf code.

    * tag 'printk-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk:
    lib/vsprintf: Make function pointer_string static
    vsprintf: Limit the length of inlined error messages
    vsprintf: Avoid confusion between invalid address and value
    vsprintf: Prevent crash when dereferencing invalid pointers
    vsprintf: Consolidate handling of unknown pointer specifiers
    vsprintf: Factor out %pO handler as kobject_string()
    vsprintf: Factor out %pV handler as va_format()
    vsprintf: Factor out %p[iI] handler as ip_addr_string()
    vsprintf: Do not check address of well-known strings
    vsprintf: Consistent %pK handling for kptr_restrict == 0
    vsprintf: Shuffle restricted_pointer()
    printk: Tie printk_once / printk_deferred_once into .data.once for reset
    treewide: Switch printk users from %pf and %pF to %ps and %pS, respectively
    lib/test_printf: Switch to bitmap_zalloc()

    Linus Torvalds
     

09 Apr, 2019

1 commit

  • %pF and %pf are functionally equivalent to %pS and %ps conversion
    specifiers. The former are deprecated, therefore switch the current users
    to use the preferred variant.

    The changes have been produced by the following command:

    git grep -l '%p[fF]' | grep -v '^\(tools\|Documentation\)/' | \
    while read i; do perl -i -pe 's/%pf/%ps/g; s/%pF/%pS/g;' $i; done

    And verifying the result.

    Link: http://lkml.kernel.org/r/20190325193229.23390-1-sakari.ailus@linux.intel.com
    Cc: Andy Shevchenko
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: sparclinux@vger.kernel.org
    Cc: linux-um@lists.infradead.org
    Cc: xen-devel@lists.xenproject.org
    Cc: linux-acpi@vger.kernel.org
    Cc: linux-pm@vger.kernel.org
    Cc: drbd-dev@lists.linbit.com
    Cc: linux-block@vger.kernel.org
    Cc: linux-mmc@vger.kernel.org
    Cc: linux-nvdimm@lists.01.org
    Cc: linux-pci@vger.kernel.org
    Cc: linux-scsi@vger.kernel.org
    Cc: linux-btrfs@vger.kernel.org
    Cc: linux-f2fs-devel@lists.sourceforge.net
    Cc: linux-mm@kvack.org
    Cc: ceph-devel@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Signed-off-by: Sakari Ailus
    Acked-by: David Sterba (for btrfs)
    Acked-by: Mike Rapoport (for mm/memblock.c)
    Acked-by: Bjorn Helgaas (for drivers/pci)
    Acked-by: Rafael J. Wysocki
    Signed-off-by: Petr Mladek

    Sakari Ailus
     

08 Apr, 2019

1 commit


12 Oct, 2018

1 commit


15 May, 2018

2 commits

  • The callers of dev_pm_domain_attach() currently checks the returned error
    code for -EPROBE_DEFER and needs to ignore other error codes. This is an
    unnecessary limitation, which also leads to a rather strange behaviour in
    the error path.

    Address this limitation, by changing the return codes from
    acpi_dev_pm_attach() and genpd_dev_pm_attach(). More precisely, let them
    return 0, when no PM domain is needed for the device and then return 1, in
    case the device was successfully attached to its PM domain. In this way,
    dev_pm_domain_attach(), gets a better understanding of what happens in the
    attach attempts and also allowing its caller to better act on real errors
    codes.

    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     
  • Instead of checking if an existing PM domain pointer has been assigned in
    genpd_dev_pm_attach() and acpi_dev_pm_attach(), move the check to the
    common path in dev_pm_domain_attach(), thus potentially avoid one
    unnecessary check.

    Signed-off-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki

    Ulf Hansson
     

20 Mar, 2018

1 commit

  • acpi_dev_pm_get_state() is used to determine the range of allowable
    device power states when going into S3 suspend. This is implemented
    by executing the _S3D and _S3W ACPI methods.

    Linux follows the ACPI spec behaviour in that when _S3D is implemented
    and _S3W is not, Linux will not go into a power state deeper than the one
    returned by _S3D for a wakeup-enabled device.

    However, this same logic is being applied to the case when neither
    _S3D nor _S3W are present, and the result is that this function
    decides that the device must stay in D0 (fully on) state.

    This is breaking USB wakeups on Asus V222GA and Acer XC-830. _S3D and
    _S3W are not present, so the USB controller is left in the D0 running
    state during S3, and hence it is unable to generate a PME# wake event.

    The ACPI spec is unclear on which power states are permissable for
    wakeup-enabled devices when both _S3D and _S3W are missing.
    However, USB wakeups work fine on these platforms under Windows, where
    device manager shows that they are using D3 device state for the USB
    controller in S3.

    I assume that the "max = min" clamping done by the code here is
    specifically written for the _S3D but no _S3W case. By making the
    code true to those conditions, avoiding them on these platforms,
    the controller will be put into D3 state and USB wakeups start working.

    Additionally I feel that this change makes the code more directly
    mirror the wording of the ACPI spec and it's associated lack of clarity.

    Thanks to Mathias Nyman for pointing us in the right direction.

    Signed-off-by: Daniel Drake
    Link: http://lkml.kernel.org/r/CAB4CAwf_k-WsF3zL4epm9TKAOu0h=Bv1XhXV_gY3bziOo_NPKA@mail.gmail.com

    https://phabricator.endlessm.com/T21410
    Signed-off-by: Rafael J. Wysocki

    Daniel Drake
     

16 Dec, 2017

1 commit


11 Dec, 2017

1 commit

  • Middle-layer code doing suspend-time optimizations for devices with
    the DPM_FLAG_SMART_SUSPEND flag set (currently, the PCI bus type and
    the ACPI PM domain) needs to make the core skip ->thaw_early and
    ->thaw callbacks for those devices in some cases and it sets the
    power.direct_complete flag for them for this purpose.

    However, it turns out that setting power.direct_complete outside of
    the PM core is a bad idea as it triggers an excess invocation of
    pm_runtime_enable() in device_resume().

    For this reason, provide a helper to clear power.is_late_suspended
    and power.is_suspended to be invoked by the middle-layer code in
    question instead of setting power.direct_complete and make that code
    call the new helper.

    Fixes: c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account)
    Fixes: 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)
    Signed-off-by: Rafael J. Wysocki
    Reviewed-by: Ulf Hansson
    Acked-by: Bjorn Helgaas

    Rafael J. Wysocki
     

27 Nov, 2017

1 commit

  • Add support for DPM_FLAG_LEAVE_SUSPENDED to the ACPI PM domain by
    making it (a) set the power.may_skip_resume status bit for devices
    that, from its perspective, may be left in suspend after system
    wakeup from sleep and (b) return early from acpi_subsys_resume_noirq()
    for devices whose remaining resume callbacks during the transition
    under way are going to be skipped by the PM core.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

13 Nov, 2017

1 commit

  • * pm-core:
    ACPI / PM: Take SMART_SUSPEND driver flag into account
    PCI / PM: Take SMART_SUSPEND driver flag into account
    PCI / PM: Drop unnecessary invocations of pcibios_pm_ops callbacks
    PM / core: Add SMART_SUSPEND driver flag
    PCI / PM: Use the NEVER_SKIP driver flag
    PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags
    PM / core: Convert timers to use timer_setup()
    PM / core: Fix kerneldoc comments of four functions
    PM / core: Drop legacy class suspend/resume operations

    Rafael J. Wysocki
     

09 Nov, 2017

1 commit

  • acpi_remove_pm_notifier() ends up calling flush_workqueue() while
    holding acpi_pm_notifier_lock, and that same lock is taken by
    by the work via acpi_pm_notify_handler(). This can deadlock.

    To fix the problem let's split the single lock into two: one to
    protect the dev->wakeup between the work vs. add/remove, and
    another one to handle notifier installation vs. removal.

    After commit a1d14934ea4b "workqueue/lockdep: 'Fix' flush_work()
    annotation" I was able to kill the machine (Intel Braswell)
    very easily with 'powertop --auto-tune', runtime suspending i915,
    and trying to wake it up via the USB keyboard. The cases when
    it didn't die are presumably explained by lockdep getting disabled
    by something else (cpu hotplug locking issues usually).

    Fortunately I still got a lockdep report over netconsole
    (trickling in very slowly), even though the machine was
    otherwise practically dead:

    [ 112.179806] ======================================================
    [ 114.670858] WARNING: possible circular locking dependency detected
    [ 117.155663] 4.13.0-rc6-bsw-bisect-00169-ga1d14934ea4b #119 Not tainted
    [ 119.658101] ------------------------------------------------------
    [ 121.310242] xhci_hcd 0000:00:14.0: xHCI host not responding to stop endpoint command.
    [ 121.313294] xhci_hcd 0000:00:14.0: xHCI host controller not responding, assume dead
    [ 121.313346] xhci_hcd 0000:00:14.0: HC died; cleaning up
    [ 121.313485] usb 1-6: USB disconnect, device number 3
    [ 121.313501] usb 1-6.2: USB disconnect, device number 4
    [ 134.747383] kworker/0:2/47 is trying to acquire lock:
    [ 137.220790] (acpi_pm_notifier_lock){+.+.}, at: [] acpi_pm_notify_handler+0x2f/0x80
    [ 139.721524]
    [ 139.721524] but task is already holding lock:
    [ 144.672922] ((&dpc->work)){+.+.}, at: [] process_one_work+0x160/0x720
    [ 147.184450]
    [ 147.184450] which lock already depends on the new lock.
    [ 147.184450]
    [ 154.604711]
    [ 154.604711] the existing dependency chain (in reverse order) is:
    [ 159.447888]
    [ 159.447888] -> #2 ((&dpc->work)){+.+.}:
    [ 164.183486] __lock_acquire+0x1255/0x13f0
    [ 166.504313] lock_acquire+0xb5/0x210
    [ 168.778973] process_one_work+0x1b9/0x720
    [ 171.030316] worker_thread+0x4c/0x440
    [ 173.257184] kthread+0x154/0x190
    [ 175.456143] ret_from_fork+0x27/0x40
    [ 177.624348]
    [ 177.624348] -> #1 ("kacpi_notify"){+.+.}:
    [ 181.850351] __lock_acquire+0x1255/0x13f0
    [ 183.941695] lock_acquire+0xb5/0x210
    [ 186.046115] flush_workqueue+0xdd/0x510
    [ 190.408153] acpi_os_wait_events_complete+0x31/0x40
    [ 192.625303] acpi_remove_notify_handler+0x133/0x188
    [ 194.820829] acpi_remove_pm_notifier+0x56/0x90
    [ 196.989068] acpi_dev_pm_detach+0x5f/0xa0
    [ 199.145866] dev_pm_domain_detach+0x27/0x30
    [ 201.285614] i2c_device_probe+0x100/0x210
    [ 203.411118] driver_probe_device+0x23e/0x310
    [ 205.522425] __driver_attach+0xa3/0xb0
    [ 207.634268] bus_for_each_dev+0x69/0xa0
    [ 209.714797] driver_attach+0x1e/0x20
    [ 211.778258] bus_add_driver+0x1bc/0x230
    [ 213.837162] driver_register+0x60/0xe0
    [ 215.868162] i2c_register_driver+0x42/0x70
    [ 217.869551] 0xffffffffa0172017
    [ 219.863009] do_one_initcall+0x45/0x170
    [ 221.843863] do_init_module+0x5f/0x204
    [ 223.817915] load_module+0x225b/0x29b0
    [ 225.757234] SyS_finit_module+0xc6/0xd0
    [ 227.661851] do_syscall_64+0x5c/0x120
    [ 229.536819] return_from_SYSCALL_64+0x0/0x7a
    [ 231.392444]
    [ 231.392444] -> #0 (acpi_pm_notifier_lock){+.+.}:
    [ 235.124914] check_prev_add+0x44e/0x8a0
    [ 237.024795] __lock_acquire+0x1255/0x13f0
    [ 238.937351] lock_acquire+0xb5/0x210
    [ 240.840799] __mutex_lock+0x75/0x940
    [ 242.709517] mutex_lock_nested+0x1c/0x20
    [ 244.551478] acpi_pm_notify_handler+0x2f/0x80
    [ 246.382052] acpi_ev_notify_dispatch+0x44/0x5c
    [ 248.194412] acpi_os_execute_deferred+0x14/0x30
    [ 250.003925] process_one_work+0x1ec/0x720
    [ 251.803191] worker_thread+0x4c/0x440
    [ 253.605307] kthread+0x154/0x190
    [ 255.387498] ret_from_fork+0x27/0x40
    [ 257.153175]
    [ 257.153175] other info that might help us debug this:
    [ 257.153175]
    [ 262.324392] Chain exists of:
    [ 262.324392] acpi_pm_notifier_lock --> "kacpi_notify" --> (&dpc->work)
    [ 262.324392]
    [ 267.391997] Possible unsafe locking scenario:
    [ 267.391997]
    [ 270.758262] CPU0 CPU1
    [ 272.431713] ---- ----
    [ 274.060756] lock((&dpc->work));
    [ 275.646532] lock("kacpi_notify");
    [ 277.260772] lock((&dpc->work));
    [ 278.839146] lock(acpi_pm_notifier_lock);
    [ 280.391902]
    [ 280.391902] *** DEADLOCK ***
    [ 280.391902]
    [ 284.986385] 2 locks held by kworker/0:2/47:
    [ 286.524895] #0: ("kacpi_notify"){+.+.}, at: [] process_one_work+0x160/0x720
    [ 288.112927] #1: ((&dpc->work)){+.+.}, at: [] process_one_work+0x160/0x720
    [ 289.727725]

    Fixes: c072530f391e (ACPI / PM: Revork the handling of ACPI device wakeup notifications)
    Signed-off-by: Ville Syrjälä
    Cc: 3.17+ # 3.17+
    Signed-off-by: Rafael J. Wysocki

    Ville Syrjälä
     

06 Nov, 2017

1 commit

  • Make the ACPI PM domain take DPM_FLAG_SMART_SUSPEND into account in
    its system suspend callbacks.

    [Note that the pm_runtime_suspended() check in acpi_dev_needs_resume()
    is an optimization, because if is not passed, all of the subsequent
    checks may be skipped and some of them are much more overhead in
    general.]

    Also use the observation that if the device is in runtime suspend
    at the beginning of the "late" phase of a system-wide suspend-like
    transition, its state cannot change going forward (runtime PM is
    disabled for it at that time) until the transition is over and the
    subsequent system-wide PM callbacks should be skipped for it (as
    they generally assume the device to not be suspended), so add
    checks for that in acpi_subsys_suspend_late/noirq() and
    acpi_subsys_freeze_late/noirq().

    Moreover, if acpi_subsys_resume_noirq() is called during the
    subsequent system-wide resume transition and if the device was left
    in runtime suspend previously, its runtime PM status needs to be
    changed to "active" as it is going to be put into the full-power
    state going forward, so add a check for that too in there.

    In turn, if acpi_subsys_thaw_noirq() runs after the device has been
    left in runtime suspend, the subsequent "thaw" callbacks need
    to be skipped for it (as they may not work correctly with a
    suspended device), so set the power.direct_complete flag for the
    device then to make the PM core skip those callbacks.

    On top of the above, make the analogous changes in the acpi_lpss
    driver that uses the ACPI PM domain callbacks.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki