1. 13 7月, 2011 2 次提交
  2. 12 7月, 2011 7 次提交
    • R
      PM / Domains: Queue up power off work only if it is not pending · 56375fd4
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      56375fd4
    • R
      PM / Domains: Improve handling of wakeup devices during system suspend · 4ecd6e65
      Rafael J. Wysocki 提交于
      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: NKevin Hilman <khilman@ti.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4ecd6e65
    • R
      PM / Domains: Do not restore all devices on power off error · 697a7f37
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      697a7f37
    • R
      PM / Domains: Allow callbacks to execute all runtime PM helpers · c6d22b37
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      c6d22b37
    • R
      PM / Domains: Do not execute device callbacks under locks · 17b75eca
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      17b75eca
    • R
      PM / Domains: Make failing pm_genpd_prepare() clean up properly · b6c10c84
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      b6c10c84
    • R
      PM / Domains: Set device state to "active" during system resume · 6f00ff78
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      6f00ff78
  3. 10 7月, 2011 7 次提交
  4. 02 7月, 2011 20 次提交
  5. 01 7月, 2011 4 次提交