1. 17 3月, 2012 2 次提交
    • R
      PM / Domains: Fix hibernation restore of devices, v2 · 65533bbf
      Rafael J. Wysocki 提交于
      During resume from hibernation pm_genpd_restore_noirq() should only
      power off domains whose suspend_power_off flags are set once and
      not every time it is called for a device in the given domain.
      Moreover, it shouldn't decrement genpd->suspended_count, because
      that field is not touched during device freezing and therefore it is
      always equal to 0 when pm_genpd_restore_noirq() runs for the first
      device in the given domain.
      
      This means pm_genpd_restore_noirq() may use genpd->suspended_count
      to determine whether or not it it has been called for the domain in
      question already in this cycle (it only needs to increment that
      field every time it runs for this purpose) and whether or not it
      should check if the domain needs to be powered off.  For that to
      work, though, pm_genpd_prepare() has to clear genpd->suspended_count
      when it runs for the first device in the given domain (in which case
      that flag need not be cleared during domain initialization).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: stable@vger.kernel.org
      65533bbf
    • R
      PM / Domains: Fix handling of wakeup devices during system resume · cc85b207
      Rafael J. Wysocki 提交于
      During system suspend pm_genpd_suspend_noirq() checks if the given
      device is in a wakeup path (i.e. it appears to be needed for one or
      more wakeup devices to work or is a wakeup device itself) and if it
      needs to be "active" for wakeup to work.  If that is the case, the
      function returns 0 without incrementing the device domain's counter
      of suspended devices and without executing genpd_stop_dev() for the
      device.  In consequence, the device is not stopped (e.g. its clock
      isn't disabled) and power is always supplied to its domain in the
      resulting system sleep state.
      
      However, pm_genpd_resume_noirq() doesn't repeat that check and it
      runs genpd_start_dev() and decrements the domain's counter of
      suspended devices even for the wakeup device that weren't stopped by
      pm_genpd_suspend_noirq().  As a result, the start callback may be run
      unnecessarily for them and their domains' counters of suspended
      devices may become negative.  Both outcomes aren't desirable, so fix
      pm_genpd_resume_noirq() to look for wakeup devices that might not be
      stopped by during system suspend.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Tested-by: NSimon Horman <horms@verge.net.au>
      Cc: stable@vger.kernel.org
      cc85b207
  2. 30 1月, 2012 3 次提交
    • R
      PM / Domains: Run late/early device suspend callbacks at the right time · 0496c8ae
      Rafael J. Wysocki 提交于
      After the introduction of the late/early phases of device
      suspend/resume during system-wide power transitions it is possible
      to make the generic PM domains code execute its default late/early
      device suspend/resume callbacks during those phases instead of the
      corresponding _noirq phases.  The _noirq device suspend/resume
      phases were only used for executing those callbacks, because this
      was the only way it could be done, but now we can do better.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0496c8ae
    • R
      PM / Sleep: Introduce generic callbacks for new device PM phases · e470d066
      Rafael J. Wysocki 提交于
      Introduce generic subsystem callbacks for the new phases of device
      suspend/resume during system power transitions: "late suspend",
      "early resume", "late freeze", "early thaw", "late poweroff",
      "early restore".
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e470d066
    • R
      PM / Sleep: Introduce "late suspend" and "early resume" of devices · cf579dfb
      Rafael J. Wysocki 提交于
      The current device suspend/resume phases during system-wide power
      transitions appear to be insufficient for some platforms that want
      to use the same callback routines for saving device states and
      related operations during runtime suspend/resume as well as during
      system suspend/resume.  In principle, they could point their
      .suspend_noirq() and .resume_noirq() to the same callback routines
      as their .runtime_suspend() and .runtime_resume(), respectively,
      but at least some of them require device interrupts to be enabled
      while the code in those routines is running.
      
      It also makes sense to have device suspend-resume callbacks that will
      be executed with runtime PM disabled and with device interrupts
      enabled in case someone needs to run some special code in that
      context during system-wide power transitions.
      
      Apart from this, .suspend_noirq() and .resume_noirq() were introduced
      as a workaround for drivers using shared interrupts and failing to
      prevent their interrupt handlers from accessing suspended hardware.
      It appears to be better not to use them for other porposes, or we may
      have to deal with some serious confusion (which seems to be happening
      already).
      
      For the above reasons, introduce new device suspend/resume phases,
      "late suspend" and "early resume" (and analogously for hibernation)
      whose callback will be executed with runtime PM disabled and with
      device interrupts enabled and whose callback pointers generally may
      point to runtime suspend/resume routines.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      cf579dfb
  3. 27 1月, 2012 1 次提交
    • T
      PM / Domains: Add OF support · c8aa130b
      Thomas Abraham 提交于
      A device node pointer is added to generic pm domain structure to associate
      the domain with a node in the device tree. The platform code parses the
      device tree to find available nodes representing the generic power domain,
      instantiates the available domains and initializes them by calling
      pm_genpd_init().
      
      Nodes representing the devices include a phandle of the power domain to
      which it belongs. As these devices get instantiated, the driver code
      checkes for availability of a power domain phandle, converts the phandle
      to a device node and uses the new pm_genpd_of_add_device() api to
      associate the device with a power domain.
      
      pm_genpd_of_add_device() runs through its list of registered power domains
      and matches the OF node of the domain with the one specified as the
      parameter. If a match is found, the device is associated with the matched
      domain.
      
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Grant Likely <grant.likely@secretlab.ca>
      Signed-off-by: NThomas Abraham <thomas.abraham@linaro.org>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NKukjin Kim <kgene.kim@samsung.com>
      c8aa130b
  4. 14 1月, 2012 2 次提交
  5. 26 12月, 2011 1 次提交
    • R
      PM / QoS: Introduce dev_pm_qos_add_ancestor_request() · 40a5f8be
      Rafael J. Wysocki 提交于
      Some devices, like the I2C controller on SH7372, are not
      necessary for providing power to their children or forwarding
      wakeup signals (and generally interrupts) from them.  They are
      only needed by their children when there's some data to transfer,
      so they may be suspended for the majority of time and resumed
      on demand, when the children have data to send or receive.  For this
      purpose, however, their power.ignore_children flags have to be set,
      or the PM core wouldn't allow them to be suspended while their
      children were active.
      
      Unfortunately, in some situations it may take too much time to
      resume such devices so that they can assist their children in
      transferring data.  For example, if such a device belongs to a PM
      domain which goes to the "power off" state when that device is
      suspended, it may take too much time to restore power to the
      domain in response to the request from one of the device's
      children.  In that case, if the parent's resume time is critical,
      the domain should stay in the "power on" state, although it still may
      be desirable to power manage the parent itself (e.g. by manipulating
      its clock).
      
      In general, device PM QoS may be used to address this problem.
      Namely, if the device's children added PM QoS latency constraints
      for it, they would be able to prevent it from being put into an
      overly deep low-power state.  However, in some cases the devices
      needing to be serviced are not the immediate children of a
      "children-ignoring" device, but its grandchildren or even less
      direct descendants.  In those cases, the entity wanting to add a
      PM QoS request for a given device's ancestor that ignores its
      children will have to find it in the first place, so introduce a new
      helper function that may be used to achieve that.  This function,
      dev_pm_qos_add_ancestor_request(), will search for the first
      ancestor of the given device whose power.ignore_children flag is
      set and will add a device PM QoS latency request for that ancestor
      on behalf of the caller.  The request added this way may be removed
      with the help of dev_pm_qos_remove_request() in the future, like
      any other device PM QoS latency request.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      40a5f8be
  6. 22 12月, 2011 3 次提交
    • R
      PM: Drop generic_subsys_pm_ops · 90363ddf
      Rafael J. Wysocki 提交于
      Since the PM core is now going to execute driver callbacks directly
      if the corresponding subsystem callbacks are not present,
      forward-only subsystem callbacks (i.e. such that only execute the
      corresponding driver callbacks) are not necessary any more.  Thus
      it is possible to remove generic_subsys_pm_ops, because the only
      callback in there that is not forward-only, .runtime_idle, is not
      really used by the only user of generic_subsys_pm_ops, which is
      vio_bus_type.
      
      However, the generic callback routines themselves cannot be removed
      from generic_ops.c, because they are used individually by a number
      of subsystems.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      90363ddf
    • R
      PM: Run the driver callback directly if the subsystem one is not there · 35cd133c
      Rafael J. Wysocki 提交于
      Make the PM core execute driver PM callbacks directly if the
      corresponding subsystem callbacks are not present.
      
      There are three reasons for doing that.  First, it reflects the
      behavior of drivers/base/dd.c:really_probe() that runs the driver's
      .probe() callback directly if the bus type's one is not defined, so
      this change will remove one arbitrary difference between the PM core
      and the remaining parts of the driver core.  Second, it will allow
      some subsystems, whose PM callbacks don't do anything except for
      executing driver callbacks, to be simplified quite a bit by removing
      those "forward-only" callbacks.  Finally, it will allow us to remove
      one level of indirection in the system suspend and resume code paths
      where it is not necessary, which is going to lead to less debug noise
      with initcall_debug passed in the kernel command line (messages won't
      be printed for driverless devices whose subsystems don't provide
      PM callbacks among other things).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      35cd133c
    • R
      PM / Sleep: Make pm_op() and pm_noirq_op() return callback pointers · 9cf519d1
      Rafael J. Wysocki 提交于
      Make the pm_op() and pm_noirq_op() functions return pointers to
      appropriate callbacks instead of executing those callbacks and
      returning their results.
      
      This change is required for a subsequent modification that will
      execute the corresponding driver callback if the subsystem
      callback returned by either pm_op(), or pm_noirq_op() is NULL.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      9cf519d1
  7. 18 12月, 2011 2 次提交
    • R
      PM / Sleep: Merge internal functions in generic_ops.c · 1eac8111
      Rafael J. Wysocki 提交于
      After the change that removed the code related to runtime PM
      from __pm_generic_call() and __pm_generic_resume() these two
      functions need not be separate any more, so merge them.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      1eac8111
    • R
      PM / Sleep: Simplify generic system suspend callbacks · 8ca6d9bc
      Rafael J. Wysocki 提交于
      The pm_runtime_suspended() check in __pm_generic_call() doesn't
      really help and may cause problems to happen, because in some cases
      the system suspend callbacks need to be called even if the given
      device has been suspended by runtime PM.  For example, if the device
      generally supports remote wakeup and is not enabled to wake up
      the system from sleep, it should be prevented from generating wakeup
      signals during system suspend and that has to be done by the
      suspend callbacks that the pm_runtime_suspended() check prevents from
      being executed.
      
      Similarly, it may not be a good idea to unconditionally change
      the runtime PM status of the device to 'active' in
      __pm_generic_resume(), because the driver may want to leave the
      device in the 'suspended' state, depending on what happened to it
      before the system suspend and whether or not it is enabled to
      wake up the system.
      
      For the above reasons, remove the pm_runtime_suspended()
      check from __pm_generic_call() and remove the code changing the
      device's runtime PM status from __pm_generic_resume().
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      8ca6d9bc
  8. 10 12月, 2011 1 次提交
  9. 09 12月, 2011 1 次提交
  10. 07 12月, 2011 2 次提交
  11. 02 12月, 2011 7 次提交
    • R
      PM / Domains: Automatically update overoptimistic latency information · 0140d8bd
      Rafael J. Wysocki 提交于
      Measure the time of execution of the .stop(), .start(), .save_state()
      and .restore_state() PM domain device callbacks and if the result
      is greater than the corresponding latency value stored in the
      device's struct generic_pm_domain_data object, replace the inaccurate
      value with the measured time.
      
      Do analogously for the PM domains' .power_off() and .power_off()
      callbacks.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0140d8bd
    • R
      PM / Domains: Add default power off governor function (v4) · 221e9b58
      Rafael J. Wysocki 提交于
      Add a function deciding whether or not a given PM domain should
      be powered off on the basis of the PM QoS constraints of devices
      belonging to it and their PM QoS timing data.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      221e9b58
    • R
      PM / Domains: Add device stop governor function (v4) · b02c999a
      Rafael J. Wysocki 提交于
      Add a function deciding whether or not devices should be stopped in
      pm_genpd_runtime_suspend() depending on their PM QoS constraints
      and stop/start timing values.  Make it possible to add information
      used by this function to device objects.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@opensource.se>
      b02c999a
    • R
      PM / Domains: Rework system suspend callback routines (v2) · d23b9b00
      Rafael J. Wysocki 提交于
      The current generic PM domains code attempts to use the generic
      system suspend operations along with the domains' device stop/start
      routines, which requires device drivers to assume that their
      system suspend/resume (and hibernation/restore) callbacks will always
      be used with generic PM domains.  However, in theory, the same
      hardware may be used in devices that don't belong to any PM domain,
      in which case it would be necessary to add "fake" PM domains to
      satisfy the above assumption.  Also, the domain the hardware belongs
      to may not be handled with the help of the generic code.
      
      To allow device drivers that may be used along with the generic PM
      domains code of more flexibility, add new device callbacks,
      .suspend(), .suspend_late(), .resume_early(), .resume(), .freeze(),
      .freeze_late(), .thaw_early(), and .thaw(), that can be supplied by
      the drivers in addition to their "standard" system suspend and
      hibernation callbacks.  These new callbacks, if defined, will be used
      by the generic PM domains code for the handling of system suspend and
      hibernation instead of the "standard" ones.  This will allow drivers
      to be designed to work with generic PM domains as well as without
      them.
      
      For backwards compatibility, introduce default implementations of the
      new callbacks for PM domains that will execute pm_generic_suspend(),
      pm_generic_suspend_noirq(), pm_generic_resume_noirq(),
      pm_generic_resume(), pm_generic_freeze(), pm_generic_freeze_noirq(),
      pm_generic_thaw_noirq(), and pm_generic_thaw(), respectively, for the
      given device if its driver doesn't define those callbacks.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d23b9b00
    • R
      PM / Domains: Introduce "save/restore state" device callbacks · ecf00475
      Rafael J. Wysocki 提交于
      The current PM domains code uses device drivers' .runtime_suspend()
      and .runtime_resume() callbacks as the "save device state" and
      "restore device state" operations, which may not be appropriate in
      general, because it forces drivers to assume that they always will
      be used with generic PM domains.  However, in theory, the same
      hardware may be used in devices that don't belong to any PM
      domain, in which case it would be necessary to add "fake" PM
      domains to satisfy the above assumption.  It also may be located in
      a PM domain that's not handled with the help of the generic code.
      
      To allow device drivers that may be used along with the generic PM
      domains code of more flexibility, introduce new device callbacks,
      .save_state() and .restore_state(), that can be supplied by the
      drivers in addition to their "standard" runtime PM callbacks.  This
      will allow the drivers to be designed to work with generic PM domains
      as well as without them.
      
      For backwards compatibility, introduce default .save_state() and
      .restore_state() callback routines for PM domains that will execute
      a device driver's .runtime_suspend() and .runtime_resume() callbacks,
      respectively, for the given device if the driver doesn't provide its
      own implementations of .save_state() and .restore_state().
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      ecf00475
    • R
      PM / Domains: Make it possible to use per-device domain callbacks · d5e4cbfe
      Rafael J. Wysocki 提交于
      The current generic PM domains code requires that the same .stop(),
      .start() and .active_wakeup() device callback routines be used for
      all devices in the given domain, which is inflexible and may not
      cover some specific use cases.  For this reason, make it possible to
      use device specific .start()/.stop() and .active_wakeup() callback
      routines by adding corresponding callback pointers to struct
      generic_pm_domain_data.  Add a new helper routine,
      pm_genpd_register_callbacks(), that can be used to populate
      the new per-device callback pointers.
      
      Modify the shmobile's power domains code to allow drivers to add
      their own code to be run during the device stop and start operations
      with the help of the new callback pointers.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@opensource.se>
      d5e4cbfe
    • R
      PM / Runtime: Use device PM QoS constraints (v2) · 00dc9ad1
      Rafael J. Wysocki 提交于
      Make the runtime PM core use device PM QoS constraints to check if
      it is allowed to suspend a given device, so that an error code is
      returned if the device's own PM QoS constraint is negative or one of
      its children has already been suspended for too long.  If this is
      not the case, the maximum estimated time the device is allowed to be
      suspended, computed as the minimum of the device's PM QoS constraint
      and the PM QoS constraints of its children (reduced by the difference
      between the current time and their suspend times) is stored in a new
      device's PM field power.max_time_suspended_ns that can be used by
      the device's subsystem or PM domain to decide whether or not to put
      the device into lower-power (and presumably higher-latency) states
      later (if the constraint is 0, which means "no constraint", the
      power.max_time_suspended_ns is set to -1).
      
      Additionally, the time of execution of the subsystem-level
      .runtime_suspend() callback for the device is recorded in the new
      power.suspend_time field for later use by the device's subsystem or
      PM domain along with power.max_time_suspended_ns (it also is used
      by the core code when the device's parent is suspended).
      
      Introduce a new helper function,
      pm_runtime_update_max_time_suspended(), allowing subsystems and PM
      domains (or device drivers) to update the power.max_time_suspended_ns
      field, for example after changing the power state of a suspended
      device.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      00dc9ad1
  12. 24 11月, 2011 2 次提交
  13. 18 11月, 2011 1 次提交
    • R
      PM Sleep: Do not extend wakeup paths to devices with ignore_children set · 8b258cc8
      Rafael J. Wysocki 提交于
      Commit 4ca46ff3 (PM / Sleep: Mark
      devices involved in wakeup signaling during suspend) introduced
      the power.wakeup_path field in struct dev_pm_info to mark devices
      whose children are enabled to wake up the system from sleep states,
      so that power domains containing the parents that provide their
      children with wakeup power and/or relay their wakeup signals are not
      turned off.  Unfortunately, that introduced a PM regression on SH7372
      whose power consumption in the system "memory sleep" state increased
      as a result of it, because it prevented the power domain containing
      the I2C controller from being turned off when some children of that
      controller were enabled to wake up the system, although the
      controller was not necessary for them to signal wakeup.
      
      To fix this issue use the observation that devices whose
      power.ignore_children flag is set for runtime PM should be treated
      analogously during system suspend.  Namely, they shouldn't be
      included in wakeup paths going through their children.  Since the
      SH7372 I2C controller's power.ignore_children flag is set, doing so
      will restore the previous behavior of that SOC.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8b258cc8
  14. 10 11月, 2011 2 次提交
  15. 09 11月, 2011 1 次提交
  16. 05 11月, 2011 2 次提交
  17. 01 11月, 2011 2 次提交
  18. 22 10月, 2011 2 次提交
    • J
      PM / Clocks: Remove redundant NULL checks before kfree() · 0ab1e79b
      Jonghwan Choi 提交于
      Since kfree() checks it its argument is not NULL, it is not necessary
      to duplicate this check in __pm_clk_remove().
      
      [rjw: Added the changelog.]
      Signed-off-by: NJonghwan Choi <jhbird.choi@samsung.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0ab1e79b
    • R
      PM / Sleep: Mark devices involved in wakeup signaling during suspend · 4ca46ff3
      Rafael J. Wysocki 提交于
      The generic PM domains code in drivers/base/power/domain.c has
      to avoid powering off domains that provide power to wakeup devices
      during system suspend.  Currently, however, this only works for
      wakeup devices directly belonging to the given domain and not for
      their children (or the children of their children and so on).
      Thus, if there's a wakeup device whose parent belongs to a power
      domain handled by the generic PM domains code, the domain will be
      powered off during system suspend preventing the device from
      signaling wakeup.
      
      To address this problem introduce a device flag, power.wakeup_path,
      that will be set during system suspend for all wakeup devices,
      their parents, the parents of their parents and so on.  This way,
      all wakeup paths in the device hierarchy will be marked and the
      generic PM domains code will only need to avoid powering off
      domains containing devices whose power.wakeup_path is set.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4ca46ff3
  19. 17 10月, 2011 3 次提交
    • A
      PM: Update the policy on default wakeup settings · 8f88893c
      Alan Stern 提交于
      This patch (as1485) documents a change to the kernel's default wakeup
      policy.  Devices that forward wakeup requests between buses should be
      enabled for wakeup by default.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      8f88893c
    • S
      PM / Suspend: Add statistics debugfs file for suspend to RAM · 2a77c46d
      ShuoX Liu 提交于
      Record S3 failure time about each reason and the latest two failed
      devices' names in S3 progress.
      We can check it through 'suspend_stats' entry in debugfs.
      
      The motivation of the patch:
      
      We are enabling power features on Medfield. Comparing with PC/notebook,
      a mobile enters/exits suspend-2-ram (we call it s3 on Medfield) far
      more frequently. If it can't enter suspend-2-ram in time, the power
      might be used up soon.
      
      We often find sometimes, a device suspend fails. Then, system retries
      s3 over and over again. As display is off, testers and developers
      don't know what happens.
      
      Some testers and developers complain they don't know if system
      tries suspend-2-ram, and what device fails to suspend. They need
      such info for a quick check. The patch adds suspend_stats under
      debugfs for users to check suspend to RAM statistics quickly.
      
      If not using this patch, we have other methods to get info about
      what device fails. One is to turn on  CONFIG_PM_DEBUG, but users
      would get too much info and testers need recompile the system.
      
      In addition, dynamic debug is another good tool to dump debug info.
      But it still doesn't match our utilization scenario closely.
      1) user need write a user space parser to process the syslog output;
      2) Our testing scenario is we leave the mobile for at least hours.
         Then, check its status. No serial console available during the
         testing. One is because console would be suspended, and the other
         is serial console connecting with spi or HSU devices would consume
         power. These devices are powered off at suspend-2-ram.
      Signed-off-by: NShuoX Liu <shuox.liu@intel.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      2a77c46d
    • M
      PM / Runtime: Handle .runtime_suspend() failure correctly · 857b36c7
      Ming Lei 提交于
      If .runtime_suspend() returns -EAGAIN or -EBUSY, the device should
      still be in ACTIVE state, so it is not necessary to send an idle
      notification to its parent.  If .runtime_suspend() returns other
      fatal failure, it doesn't make sense to send idle notification to
      its parent.
      
      Skip parent idle notification when failure is returned from
      .runtime_suspend() and update comments in rpm_suspend() to reflect
      that change.
      
      [rjw: Modified the subject and changelog slightly.]
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      857b36c7