1. 13 Jul, 2011 2 commits
  2. 11 Jul, 2011 7 commits
    • Rafael J. Wysocki's avatar
      PM / Domains: Queue up power off work only if it is not pending · 56375fd4
      Rafael J. Wysocki authored
      In theory it is possible that pm_genpd_poweroff() for two different
      subdomains of the same parent domain will attempt to queue up the
      execution of pm_genpd_poweroff() for the parent twice in a row.  This
      would lead to unpleasant consequences, so prevent it from happening
      by checking if genpd->power_off_work is pending before attempting to
      queue it up.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      56375fd4
    • Rafael J. Wysocki's avatar
      PM / Domains: Improve handling of wakeup devices during system suspend · 4ecd6e65
      Rafael J. Wysocki authored
      Kevin points out that if there's a device that can wake up the system
      from sleep states, but it doesn't generate wakeup signals by itself
      (they are generated on its behalf by other parts of the system) and
      it currently is not enabled to wake up the system (that is,
      device_may_wakeup() returns "false" for it), we may need to change
      its wakeup settings during system suspend (for example, the device
      might have been configured to signal remote wakeup from the system's
      working state, as needed by runtime PM).  Therefore the generic PM
      domains code should invoke the system suspend callbacks provided by
      the device's driver, which it doesn't do if the PM domain is powered
      off during the system suspend's "prepare" stage.  This is a valid
      point.  Moreover, this code also should make sure that system wakeup
      devices that are enabled to wake up the system from sleep states and
      have to remain active for this purpose are not suspended while the
      system is in a sleep state.
      
      To avoid the above issues, make the generic PM domains' .prepare()
      routine, pm_genpd_prepare(), force runtime resume of devices whose
      system wakeup settings may need to be changed during system suspend
      or that should remain active while the system is in a sleep state to
      be able to wake it up from that state.
      Reported-by: default avatarKevin Hilman <khilman@ti.com>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      4ecd6e65
    • Rafael J. Wysocki's avatar
      PM / Domains: Do not restore all devices on power off error · 697a7f37
      Rafael J. Wysocki authored
      Since every device in a PM domain has its own need_restore
      flag, which is set by __pm_genpd_save_device(), there's no need to
      walk the domain's device list and restore all devices on an error
      from one of the drivers' .runtime_suspend() callbacks.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      697a7f37
    • Rafael J. Wysocki's avatar
      PM / Domains: Allow callbacks to execute all runtime PM helpers · c6d22b37
      Rafael J. Wysocki authored
      A deadlock may occur if one of the PM domains' .start_device() or
      .stop_device() callbacks or a device driver's .runtime_suspend() or
      .runtime_resume() callback executed by the core generic PM domain
      code uses a "wrong" runtime PM helper function.  This happens, for
      example, if .runtime_resume() from one device's driver calls
      pm_runtime_resume() for another device in the same PM domain.
      A similar situation may take place if a device's parent is in the
      same PM domain, in which case the runtime PM framework may execute
      pm_genpd_runtime_resume() automatically for the parent (if it is
      suspended at the moment).  This, of course, is undesirable, so
      the generic PM domains code should be modified to prevent it from
      happening.
      
      The runtime PM framework guarantees that pm_genpd_runtime_suspend()
      and pm_genpd_runtime_resume() won't be executed in parallel for
      the same device, so the generic PM domains code need not worry
      about those cases.  Still, it needs to prevent the other possible
      race conditions between pm_genpd_runtime_suspend(),
      pm_genpd_runtime_resume(), pm_genpd_poweron() and pm_genpd_poweroff()
      from happening and it needs to avoid deadlocks at the same time.
      To this end, modify the generic PM domains code to relax
      synchronization rules so that:
      
      * pm_genpd_poweron() doesn't wait for the PM domain status to
        change from GPD_STATE_BUSY.  If it finds that the status is
        not GPD_STATE_POWER_OFF, it returns without powering the domain on
        (it may modify the status depending on the circumstances).
      
      * pm_genpd_poweroff() returns as soon as it finds that the PM
        domain's status changed from GPD_STATE_BUSY after it's released
        the PM domain's lock.
      
      * pm_genpd_runtime_suspend() doesn't wait for the PM domain status
        to change from GPD_STATE_BUSY after executing the domain's
        .stop_device() callback and executes pm_genpd_poweroff() only
        if pm_genpd_runtime_resume() is not executed in parallel.
      
      * pm_genpd_runtime_resume() doesn't wait for the PM domain status
        to change from GPD_STATE_BUSY after executing pm_genpd_poweron()
        and sets the domain's status to GPD_STATE_BUSY and increments its
        counter of resuming devices (introduced by this change) immediately
        after acquiring the lock.  The counter of resuming devices is then
        decremented after executing __pm_genpd_runtime_resume() for the
        device and the domain's status is reset to GPD_STATE_ACTIVE (unless
        there are more resuming devices in the domain, in which case the
        status remains GPD_STATE_BUSY).
      
      This way, for example, if a device driver's .runtime_resume()
      callback executes pm_runtime_resume() for another device in the same
      PM domain, pm_genpd_poweron() called by pm_genpd_runtime_resume()
      invoked by the runtime PM framework will not block and it will see
      that there's nothing to do for it.  Next, the PM domain's lock will
      be acquired without waiting for its status to change from
      GPD_STATE_BUSY and the device driver's .runtime_resume() callback
      will be executed.  In turn, if pm_runtime_suspend() is executed by
      one device driver's .runtime_resume() callback for another device in
      the same PM domain, pm_genpd_poweroff() executed by
      pm_genpd_runtime_suspend() invoked by the runtime PM framework as a
      result will notice that one of the devices in the domain is being
      resumed, so it will return immediately.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      c6d22b37
    • Rafael J. Wysocki's avatar
      PM / Domains: Do not execute device callbacks under locks · 17b75eca
      Rafael J. Wysocki authored
      Currently, the .start_device() and .stop_device() callbacks from
      struct generic_pm_domain() as well as the device drivers' runtime PM
      callbacks used by the generic PM domains code are executed under
      the generic PM domain lock.  This, unfortunately, is prone to
      deadlocks, for example if a device and its parent are boths members
      of the same PM domain.  For this reason, it would be better if the
      PM domains code didn't execute device callbacks under the lock.
      
      Rework the locking in the generic PM domains code so that the lock
      is dropped for the execution of device callbacks.  To this end,
      introduce PM domains states reflecting the current status of a PM
      domain and such that the PM domain lock cannot be acquired if the
      status is GPD_STATE_BUSY.  Make threads attempting to acquire a PM
      domain's lock wait until the status changes to either
      GPD_STATE_ACTIVE or GPD_STATE_POWER_OFF.
      
      This change by itself doesn't fix the deadlock problem mentioned
      above, but the mechanism introduced by it will be used for for this
      purpose by a subsequent patch.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      17b75eca
    • Rafael J. Wysocki's avatar
      PM / Domains: Make failing pm_genpd_prepare() clean up properly · b6c10c84
      Rafael J. Wysocki authored
      If pm_generic_prepare() in pm_genpd_prepare() returns error code,
      the PM domains counter of "prepared" devices should be decremented
      and its suspend_power_off flag should be reset if this counter drops
      down to zero.  Otherwise, the PM domain runtime PM code will not
      handle the domain correctly (it will permanently think that system
      suspend is in progress).
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      b6c10c84
    • Rafael J. Wysocki's avatar
      PM / Domains: Set device state to "active" during system resume · 6f00ff78
      Rafael J. Wysocki authored
      The runtime PM status of devices in a power domain that is not
      powered off in pm_genpd_complete() should be set to "active", because
      those devices are operational at this point.  Some of them may not be
      in use, though, so make pm_genpd_complete() call pm_runtime_idle()
      in addition to pm_runtime_set_active() for each of them.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      6f00ff78
  3. 10 Jul, 2011 7 commits
  4. 02 Jul, 2011 16 commits
    • Magnus Damm's avatar
      ARM: mach-shmobile: sh7372 A3SG support · c47586b6
      Magnus Damm authored
      Add support for the sh7372 A3SG power domain. This domain contains
      the SGX hardware block, but there is no open source driver available.
      Signed-off-by: default avatarMagnus Damm <damm@opensource.se>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      c47586b6
    • Magnus Damm's avatar
      ARM: mach-shmobile: sh7372 A3RI support · 082517aa
      Magnus Damm authored
      Add support for the sh7372 A3RI power domain. This domain contains
      the ISP hardware block, but there is no driver available.
      Signed-off-by: default avatarMagnus Damm <damm@opensource.se>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      082517aa
    • Magnus Damm's avatar
      ARM: mach-shmobile: sh7372 A3RV support · 33afebf3
      Magnus Damm authored
      Add support for the sh7372 A3RV power domain and hook
      up the VPU device.
      Signed-off-by: default avatarMagnus Damm <damm@opensource.se>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      33afebf3
    • Magnus Damm's avatar
      ARM: mach-shmobile: sh7372 A4LC support for AP4EVB · 96f7934e
      Magnus Damm authored
      The AP4EVB board is also using a sh7372 SoC, so tie in
      A4LC support on that board as well.
      Signed-off-by: default avatarMagnus Damm <damm@opensource.se>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      96f7934e
    • Rafael J. Wysocki's avatar
      ARM / shmobile: Support for I/O power domains for SH7372 (v9) · e3e01091
      Rafael J. Wysocki authored
      Use the generic power domains support introduced by the previous
      patch to implement support for power domains on SH7372.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
      e3e01091
    • Rafael J. Wysocki's avatar
      PM: Rename clock management functions · 3d5c3036
      Rafael J. Wysocki authored
      The common PM clock management functions may be used for system
      suspend/resume as well as for runtime PM, so rename them
      accordingly.  Modify kerneldoc comments describing these functions
      and kernel messages printed by them, so that they refer to power
      management in general rather that to runtime PM.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
      3d5c3036
    • Rafael J. Wysocki's avatar
      PM: Allow the clocks management code to be used during system suspend · b7b95920
      Rafael J. Wysocki authored
      The common clocks management code in drivers/base/power/clock_ops.c
      is going to be used during system-wide power transitions as well as
      for runtime PM, so it shouldn't depend on CONFIG_PM_RUNTIME.
      However, the suspend/resume functions provided by it for
      CONFIG_PM_RUNTIME unset, to be used during system-wide power
      transitions, should not behave in the same way as their counterparts
      defined for CONFIG_PM_RUNTIME set, because in that case the clocks
      are managed differently at run time.
      
      The names of the functions still contain the word "runtime" after
      this change, but that is going to be modified by a separate patch
      later.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
      b7b95920
    • Rafael J. Wysocki's avatar
      PM / Domains: Wakeup devices support for system sleep transitions · d4f2d87a
      Rafael J. Wysocki authored
      There is the problem how to handle devices set up to wake up the
      system from sleep states during system-wide power transitions.
      In some cases, those devices can be turned off entirely, because the
      wakeup signals will be generated on their behalf anyway.  In some
      other cases, they will generate wakeup signals if their clocks are
      stopped, but only if power is not removed from them.  Finally, in
      some cases, they can only generate wakeup signals if power is not
      removed from them and their clocks are enabled.
      
      To allow platform-specific code to decide whether or not to put
      wakeup devices (and their PM domains) into low-power state during
      system-wide transitions, such as system suspend, introduce a new
      generic PM domain callback, .active_wakeup(), that will be used
      during the "noirq" phase of system suspend and hibernation (after
      image creation) to decide what to do with wakeup devices.
      Specifically, if this callback is present and returns "true", the
      generic PM domain code will not execute .stop_device() for the
      given wakeup device and its PM domain won't be powered off.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarKevin Hilman <khilman@ti.com>
      d4f2d87a
    • Rafael J. Wysocki's avatar
      PM / Domains: System-wide transitions support for generic domains (v5) · 596ba34b
      Rafael J. Wysocki authored
      Make generic PM domains support system-wide power transitions
      (system suspend and hibernation).  Add suspend, resume, freeze, thaw,
      poweroff and restore callbacks to be associated with struct
      generic_pm_domain objects and make pm_genpd_init() use them as
      appropriate.
      
      The new callbacks do nothing for devices belonging to power domains
      that were powered down at run time (before the transition).  For the
      other devices the action carried out depends on the type of the
      transition.  During system suspend the power domain .suspend()
      callback executes pm_generic_suspend() for the device, while the
      PM domain .suspend_noirq() callback runs pm_generic_suspend_noirq()
      for it, stops it and eventually removes power from the PM domain it
      belongs to (after all devices in the domain have been stopped and its
      subdomains have been powered off).
      
      During system resume the PM domain .resume_noirq() callback
      restores power to the PM domain (when executed for it first time),
      starts the device and executes pm_generic_resume_noirq() for it,
      while the .resume() callback executes pm_generic_resume() for the
      device.  Finally, the .complete() callback executes pm_runtime_idle()
      for the device which should put it back into the suspended state if
      its runtime PM usage count is equal to zero at that time.
      
      The actions carried out during hibernation and resume from it are
      analogous to the ones described above.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
      596ba34b
    • Rafael J. Wysocki's avatar
      PM / Domains: Move code from under #ifdef CONFIG_PM_RUNTIME (v2) · 5248051b
      Rafael J. Wysocki authored
      There is some code in drivers/base/power/domain.c that will be useful
      for both runtime PM and system-wide power transitions, so make it
      depend on CONFIG_PM instead of CONFIG_PM_RUNTIME.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
      5248051b
    • Rafael J. Wysocki's avatar
      PM: Introduce generic "noirq" callback routines for subsystems (v2) · e5291928
      Rafael J. Wysocki authored
      Introduce generic "noirq" power management callback routines for
      subsystems in addition to the "regular" generic PM callback routines.
      
      The new routines will be used, among other things, for implementing
      system-wide PM transitions support for generic PM domains.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      e5291928
    • Rafael J. Wysocki's avatar
      PM / Domains: Support for generic I/O PM domains (v8) · f721889f
      Rafael J. Wysocki authored
      Introduce common headers, helper functions and callbacks allowing
      platforms to use simple generic power domains for runtime power
      management.
      
      Introduce struct generic_pm_domain to be used for representing
      power domains that each contain a number of devices and may be
      parent domains or subdomains with respect to other power domains.
      Among other things, this structure includes callbacks to be
      provided by platforms for performing specific tasks related to
      power management (i.e. ->stop_device() may disable a device's
      clocks, while ->start_device() may enable them, ->power_off() is
      supposed to remove power from the entire power domain
      and ->power_on() is supposed to restore it).
      
      Introduce functions that can be used as power domain runtime PM
      callbacks, pm_genpd_runtime_suspend() and pm_genpd_runtime_resume(),
      as well as helper functions for the initialization of a power
      domain represented by a struct generic_power_domain object,
      adding a device to or removing a device from it and adding or
      removing subdomains.
      
      Introduce configuration option CONFIG_PM_GENERIC_DOMAINS to be
      selected by the platforms that want to use the new code.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
      f721889f
    • Rafael J. Wysocki's avatar
      PM: subsys_data in struct dev_pm_info need not depend on RM_RUNTIME · dc6e4e56
      Rafael J. Wysocki authored
      The subsys_data field of struct dev_pm_info, introduced by commit
      1d2b71f6 (PM / Runtime: Add subsystem
      data field to struct dev_pm_info), is going to be used even if
      CONFIG_PM_RUNTIME is not set, so move it from under the #ifdef.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      dc6e4e56
    • Rafael J. Wysocki's avatar
      PM / Domains: Rename struct dev_power_domain to struct dev_pm_domain · 564b905a
      Rafael J. Wysocki authored
      The naming convention used by commit 7538e3db6e015e890825fbd9f86599b
      (PM: Add support for device power domains), which introduced the
      struct dev_power_domain type for representing device power domains,
      evidently confuses some developers who tend to think that objects
      of this type must correspond to "power domains" as defined by
      hardware, which is not the case.  Namely, at the kernel level, a
      struct dev_power_domain object can represent arbitrary set of devices
      that are mutually dependent power management-wise and need not belong
      to one hardware power domain.  To avoid that confusion, rename struct
      dev_power_domain to struct dev_pm_domain and rename the related
      pointers in struct device and struct pm_clk_notifier_block from
      pwr_domain to pm_domain.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: default avatarKevin Hilman <khilman@ti.com>
      564b905a
    • Rafael J. Wysocki's avatar
      PM / Runtime: Update documentation regarding driver removal · f5da24db
      Rafael J. Wysocki authored
      Commit e1866b33 (PM / Runtime: Rework
      runtime PM handling during driver removal) forgot to update the
      documentation in Documentation/power/runtime_pm.txt to match the new
      code in drivers/base/dd.c.  Update that documentation to match the
      code it describes.
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
      f5da24db
    • Kevin Hilman's avatar
      PM: Documentation: fix typo: pm_runtime_idle_sync() doesn't exist. · 5efb54cc
      Kevin Hilman authored
      Replace reference to pm_runtime_idle_sync() in the driver core with
      pm_runtime_put_sync() which is used in the code.
      Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      5efb54cc
  5. 01 Jul, 2011 4 commits
  6. 30 Jun, 2011 4 commits