1. 05 4月, 2019 1 次提交
  2. 07 3月, 2019 1 次提交
  3. 19 2月, 2019 1 次提交
    • S
      PM / core: Add support to skip power management in device/driver model · 85945c28
      Sudeep Holla 提交于
      All device objects in the driver model contain fields that control the
      handling of various power management activities. However, it's not
      always useful. There are few instances where pseudo devices are added
      to the model just to take advantage of many other features like
      kobjects, udev events, and so on. One such example is cpu devices and
      their caches.
      
      The sysfs for the cpu caches are managed by adding devices with cpu
      as the parent in cpu_device_create() when secondary cpu is brought
      online. Generally when the secondary CPUs are hotplugged back in as part
      of resume from suspend-to-ram, we call cpu_device_create() from the cpu
      hotplug state machine while the cpu device associated with that CPU is
      not yet ready to be resumed as the device_resume() call happens bit
      later. It's not really needed to set the flag is_prepared for cpu
      devices as they are mostly pseudo device and hotplug framework deals
      with state machine and not managed through the cpu device.
      
      This often results in annoying warning when resuming:
      Enabling non-boot CPUs ...
      CPU1: Booted secondary processor
       cache: parent cpu1 should not be sleeping
      CPU1 is up
      CPU2: Booted secondary processor
       cache: parent cpu2 should not be sleeping
      CPU2 is up
      .... and so on.
      
      So in order to fix these kind of errors, we could just completely avoid
      doing any power management related initialisations and operations if
      they are not used by these devices.
      
      Add no_pm flags to indicate that the device doesn't require any sort of
      PM activities and all of them can be completely skipped. We can use the
      same flag to also avoid adding not used *power* sysfs entries for these
      devices. For now, lets use this for cpu cache devices.
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      Tested-by: NEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      85945c28
  4. 14 2月, 2019 1 次提交
  5. 31 1月, 2019 1 次提交
  6. 03 1月, 2019 1 次提交
  7. 05 10月, 2018 1 次提交
  8. 22 5月, 2018 1 次提交
  9. 10 5月, 2018 3 次提交
  10. 10 1月, 2018 2 次提交
  11. 09 1月, 2018 1 次提交
    • U
      PM / core: Assign the wakeup_path status flag in __device_prepare() · 8512220c
      Ulf Hansson 提交于
      The PM core in the device_prepare() phase, resets the wakeup_path status
      flag to the value of device_may_wakeup(). This means if a ->prepare() or a
      ->suspend() callback for the device would update the device's wakeup
      setting, this doesn't become reflected in the wakeup_path status flag.
      
      In general this isn't a problem, because wakeup settings are not supposed
      to be changed (via for example calling device_set_wakeup_enable()) during
      any system wide suspend/resume phase.  Nevertheless there are some users,
      which can be considered as legacy, that don't conform to this behaviour.
      
      These legacy cases should be corrected, however until that is done, let's
      address the issue from the PM core, by moving the assignment of the
      wakeup_path status flag to the __device_suspend() phase and after the
      ->suspend() callback has been invoked.
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8512220c
  12. 03 1月, 2018 3 次提交
    • R
      PM / core: Direct DPM_FLAG_LEAVE_SUSPENDED handling · 32bfa56a
      Rafael J. Wysocki 提交于
      Make the PM core handle DPM_FLAG_LEAVE_SUSPENDED directly for
      devices whose "noirq", "late" and "early" driver callbacks are
      invoked directly by it.
      
      Namely, make it skip all of the system-wide resume callbacks for
      such devices with DPM_FLAG_LEAVE_SUSPENDED set if they are in
      runtime suspend during the "noirq" phase of system-wide suspend
      (or analogous) transitions or the system transition under way is
      a proper suspend (rather than anything related to hibernation) and
      the device's wakeup settings are compatible with runtime PM (that
      is, the device cannot generate wakeup signals at all or it is
      allowed to wake up the system from sleep).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      32bfa56a
    • R
      PM / core: Direct DPM_FLAG_SMART_SUSPEND optimization · 75e94645
      Rafael J. Wysocki 提交于
      Make the PM core avoid invoking the "late" and "noirq" system-wide
      suspend (or analogous) callbacks provided by device drivers directly
      for devices with DPM_FLAG_SMART_SUSPEND set that are in runtime
      suspend during the "late" and "noirq" phases of system-wide suspend
      (or analogous) transitions.  That is only done for devices without
      any middle-layer "late" and "noirq" suspend callbacks (to avoid
      confusing the middle layer if there is one).
      
      The underlying observation is that runtime PM is disabled for devices
      during the "late" and "noirq" system-wide suspend phases, so if they
      remain in runtime suspend from the "late" phase forward, it doesn't
      make sense to invoke the "late" and "noirq" callbacks provided by
      the drivers for them (arguably, the device is already suspended and
      in the right state).  Thus, if the remaining driver suspend callbacks
      are to be invoked directly by the core, they can be skipped.
      
      This change really makes it possible for, say, platform device
      drivers to re-use runtime PM suspend and resume callbacks by
      pointing ->suspend_late and ->resume_early, respectively (and
      possibly the analogous hibernation-related callback pointers too),
      to them without adding any extra "is the device already suspended?"
      type of checks to the callback routines, as long as they will be
      invoked directly by the core.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      75e94645
    • R
      PM / core: Add helpers for subsystem callback selection · 4fa3061a
      Rafael J. Wysocki 提交于
      Add helper routines to find and return a suitable subsystem callback
      during the "noirq" phases of system suspend/resume (or analogous)
      transitions as well as during the "late" phase of system suspend and
      the "early" phase of system resume (or analogous) transitions.
      
      The helpers will be called from additional sites going forward.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      4fa3061a
  13. 13 12月, 2017 2 次提交
  14. 11 12月, 2017 1 次提交
    • R
      PM / sleep: Avoid excess pm_runtime_enable() calls in device_resume() · 3487972d
      Rafael J. Wysocki 提交于
      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: c4b65157 (PCI / PM: Take SMART_SUSPEND driver flag into account)
      Fixes: 05087360 (ACPI / PM: Take SMART_SUSPEND driver flag into account)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      3487972d
  15. 05 12月, 2017 1 次提交
  16. 27 11月, 2017 1 次提交
    • R
      PM / core: Add LEAVE_SUSPENDED driver flag · 0d4b54c6
      Rafael J. Wysocki 提交于
      Define and document a new driver flag, DPM_FLAG_LEAVE_SUSPENDED, to
      instruct the PM core and middle-layer (bus type, PM domain, etc.)
      code that it is desirable to leave the device in runtime suspend
      after system-wide transitions to the working state (for example,
      the device may be slow to resume and it may be better to avoid
      resuming it right away).
      
      Generally, the middle-layer code involved in the handling of the
      device is expected to indicate to the PM core whether or not the
      device may be left in suspend with the help of the device's
      power.may_skip_resume status bit.  That has to happen in the "noirq"
      phase of the preceding system suspend (or analogous) transition.
      The middle layer is then responsible for handling the device as
      appropriate in its "noirq" resume callback which is executed
      regardless of whether or not the device may be left suspended, but
      the other resume callbacks (except for ->complete) will be skipped
      automatically by the core if the device really can be left in
      suspend.
      
      The additional power.must_resume status bit introduced for the
      implementation of this mechanisn is used internally by the PM core
      to track the requirement to resume the device (which may depend on
      its children etc).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      0d4b54c6
  17. 06 11月, 2017 3 次提交
    • R
      PCI / PM: Take SMART_SUSPEND driver flag into account · c4b65157
      Rafael J. Wysocki 提交于
      Make the PCI bus type take DPM_FLAG_SMART_SUSPEND into account in its
      system-wide PM callbacks and make sure that all code that should not
      run in parallel with pci_pm_runtime_resume() is executed in the "late"
      phases of system suspend, freeze and poweroff transitions.
      
      [Note that the pm_runtime_suspended() check in pci_dev_keep_suspended()
      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 pci_pm_suspend_late/noirq(), pci_pm_freeze_late/noirq()
      and pci_pm_poweroff_late/noirq().
      
      Moreover, if pci_pm_resume_noirq() or pci_pm_restore_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, so add checks for that too to these
      functions.
      
      In turn, if pci_pm_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.
      
      In addition to the above add a core helper for checking if
      DPM_FLAG_SMART_SUSPEND is set and the device runtime PM status is
      "suspended" at the same time, which is done quite often in the new
      code (and will be done elsewhere going forward too).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      c4b65157
    • R
      PM / core: Add SMART_SUSPEND driver flag · 0eab11c9
      Rafael J. Wysocki 提交于
      Define and document a SMART_SUSPEND flag to instruct bus types and PM
      domains that the system suspend callbacks provided by the driver can
      cope with runtime-suspended devices, so from the driver's perspective
      it should be safe to leave devices in runtime suspend during system
      suspend.
      
      Setting that flag may also cause middle-layer code (bus types,
      PM domains etc.) to skip invocations of the ->suspend_late and
      ->suspend_noirq callbacks provided by the driver if the device
      is in runtime suspend at the beginning of the "late" phase of
      the system-wide suspend transition, in which case the driver's
      system-wide resume callbacks may be invoked back-to-back with
      its ->runtime_suspend callback, so the driver has to be able to
      cope with that too.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      0eab11c9
    • R
      PM / core: Add NEVER_SKIP and SMART_PREPARE driver flags · 08810a41
      Rafael J. Wysocki 提交于
      The motivation for this change is to provide a way to work around
      a problem with the direct-complete mechanism used for avoiding
      system suspend/resume handling for devices in runtime suspend.
      
      The problem is that some middle layer code (the PCI bus type and
      the ACPI PM domain in particular) returns positive values from its
      system suspend ->prepare callbacks regardless of whether the driver's
      ->prepare returns a positive value or 0, which effectively prevents
      drivers from being able to control the direct-complete feature.
      Some drivers need that control, however, and the PCI bus type has
      grown its own flag to deal with this issue, but since it is not
      limited to PCI, it is better to address it by adding driver flags at
      the core level.
      
      To that end, add a driver_flags field to struct dev_pm_info for flags
      that can be set by device drivers at the probe time to inform the PM
      core and/or bus types, PM domains and so on on the capabilities and/or
      preferences of device drivers.  Also add two static inline helpers
      for setting that field and testing it against a given set of flags
      and make the driver core clear it automatically on driver remove
      and probe failures.
      
      Define and document two PM driver flags related to the direct-
      complete feature: NEVER_SKIP and SMART_PREPARE that can be used,
      respectively, to indicate to the PM core that the direct-complete
      mechanism should never be used for the device and to inform the
      middle layer code (bus types, PM domains etc) that it can only
      request the PM core to use the direct-complete mechanism for
      the device (by returning a positive value from its ->prepare
      callback) if it also has been requested by the driver.
      
      While at it, make the core check pm_runtime_suspended() when
      setting power.direct_complete so that it doesn't need to be
      checked by ->prepare callbacks.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      08810a41
  18. 21 10月, 2017 1 次提交
  19. 05 10月, 2017 1 次提交
    • K
      timer: Remove init_timer_on_stack() in favor of timer_setup_on_stack() · 9c6c273a
      Kees Cook 提交于
      Remove uses of init_timer_on_stack() with open-coded function and data
      assignments that could be expressed using timer_setup_on_stack(). Several
      were removed from the stack entirely since there was a one-to-one mapping
      of parent structure to timer, those are switched to using timer_setup()
      instead. All related callbacks were adjusted to use from_timer().
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: linux-mips@linux-mips.org
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Kalle Valo <kvalo@qca.qualcomm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Wim Van Sebroeck <wim@iguana.be>
      Cc: linux1394-devel@lists.sourceforge.net
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: linux-s390@vger.kernel.org
      Cc: linux-wireless@vger.kernel.org
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: linux-scsi@vger.kernel.org
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ursula Braun <ubraun@linux.vnet.ibm.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Harish Patil <harish.patil@cavium.com>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: Michael Reed <mdr@sgi.com>
      Cc: Manish Chopra <manish.chopra@cavium.com>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-pm@vger.kernel.org
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Julian Wiedmann <jwi@linux.vnet.ibm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Mark Gross <mark.gross@intel.com>
      Cc: linux-watchdog@vger.kernel.org
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: netdev@vger.kernel.org
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Link: https://lkml.kernel.org/r/1507159627-127660-4-git-send-email-keescook@chromium.org
      9c6c273a
  20. 26 9月, 2017 1 次提交
  21. 20 9月, 2017 1 次提交
    • R
      PM: core: Fix device_pm_check_callbacks() · 157c460e
      Rafael J. Wysocki 提交于
      The device_pm_check_callbacks() function doesn't check legacy
      ->suspend and ->resume callback pointers under the device's
      bus type, class and driver, so in some cases it may set the
      no_pm_callbacks flag for the device incorrectly and then the
      callbacks may be skipped during system suspend/resume, which
      shouldn't happen.
      
      Fixes: aa8e54b5 (PM / sleep: Go direct_complete if driver has no callbacks)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: 4.5+ <stable@vger.kernel.org> # 4.5+
      157c460e
  22. 25 7月, 2017 3 次提交
  23. 22 7月, 2017 1 次提交
    • R
      PM / sleep: Do not print debug messages by default · 8d8b2441
      Rafael J. Wysocki 提交于
      Debug messages from the system suspend/hibernation infrastructure can
      fill up the entire kernel log buffer in some cases and anyway they
      are only useful for debugging.  They depend on CONFIG_PM_DEBUG, but
      that is set as a rule as some generally useful diagnostic facilities
      depend on it too.
      
      For this reason, avoid printing those messages by default, but make
      it possible to turn them on as needed with the help of a new sysfs
      attribute under /sys/power/.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8d8b2441
  24. 28 6月, 2017 2 次提交
  25. 15 6月, 2017 2 次提交
    • R
      ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle · 33e4f80e
      Rafael J. Wysocki 提交于
      The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
      during suspend-to-idle transitions and, consequently, any events
      signaled through it wake up the system from that state.  However,
      on some systems some of the events signaled via the ACPI SCI while
      suspended to idle should not cause the system to wake up.  In fact,
      quite often they should just be discarded.
      
      Arguably, systems should not resume entirely on such events, but in
      order to decide which events really should cause the system to resume
      and which are spurious, it is necessary to resume up to the point
      when ACPI SCIs are actually handled and processed, which is after
      executing dpm_resume_noirq() in the system resume path.
      
      For this reasons, add a loop around freeze_enter() in which the
      platforms can process events signaled via multiplexed IRQ lines
      like the ACPI SCI and add suspend-to-idle hooks that can be
      used for this purpose to struct platform_freeze_ops.
      
      In the ACPI case, the ->wake hook is used for checking if the SCI
      has triggered while suspended and deferring the interrupt-induced
      system wakeup until the events signaled through it are actually
      processed sufficiently to decide whether or not the system should
      resume.  In turn, the ->sync hook allows all of the relevant event
      queues to be flushed so as to prevent events from being missed due
      to race conditions.
      
      In addition to that, some ACPI code processing wakeup events needs
      to be modified to use the "hard" version of wakeup triggers, so that
      it will cause a system resume to happen on device-induced wakeup
      events even if the "soft" mechanism to prevent the system from
      suspending is not enabled.  However, to preserve the existing
      behavior with respect to suspend-to-RAM, this only is done in
      the suspend-to-idle case and only if an SCI has occurred while
      suspended.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      33e4f80e
    • R
      PM / sleep: Print timing information if debug is enabled · 604d8958
      Rafael J. Wysocki 提交于
      Avoid printing the device suspend/resume timing information if
      CONFIG_PM_DEBUG is not set to reduce the log noise level.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      604d8958
  26. 07 6月, 2017 1 次提交
  27. 06 5月, 2017 1 次提交
    • R
      ACPI / sleep: Ignore spurious SCI wakeups from suspend-to-idle · eed4d47e
      Rafael J. Wysocki 提交于
      The ACPI SCI (System Control Interrupt) is set up as a wakeup IRQ
      during suspend-to-idle transitions and, consequently, any events
      signaled through it wake up the system from that state.  However,
      on some systems some of the events signaled via the ACPI SCI while
      suspended to idle should not cause the system to wake up.  In fact,
      quite often they should just be discarded.
      
      Arguably, systems should not resume entirely on such events, but in
      order to decide which events really should cause the system to resume
      and which are spurious, it is necessary to resume up to the point
      when ACPI SCIs are actually handled and processed, which is after
      executing dpm_resume_noirq() in the system resume path.
      
      For this reasons, add a loop around freeze_enter() in which the
      platforms can process events signaled via multiplexed IRQ lines
      like the ACPI SCI and add suspend-to-idle hooks that can be
      used for this purpose to struct platform_freeze_ops.
      
      In the ACPI case, the ->wake hook is used for checking if the SCI
      has triggered while suspended and deferring the interrupt-induced
      system wakeup until the events signaled through it are actually
      processed sufficiently to decide whether or not the system should
      resume.  In turn, the ->sync hook allows all of the relevant event
      queues to be flushed so as to prevent events from being missed due
      to race conditions.
      
      In addition to that, some ACPI code processing wakeup events needs
      to be modified to use the "hard" version of wakeup triggers, so that
      it will cause a system resume to happen on device-induced wakeup
      events even if the "soft" mechanism to prevent the system from
      suspending is not enabled (that also helps to catch device-induced
      wakeup events occurring during suspend transitions in progress).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      eed4d47e
  28. 02 3月, 2017 1 次提交