1. 04 9月, 2012 1 次提交
    • R
      PM / Domains: Move syscore flag from subsys data to struct device · dbf37414
      Rafael J. Wysocki 提交于
      The syscore device PM flag is used to mark the devices (belonging to
      a PM domain) that should never be turned off, except for the system
      core (syscore) suspend/hibernation and resume stages.  That flag is
      stored in the device's struct pm_subsys_data object whose address is
      available from struct device.  However, in some situations it may be
      convenient to set that flag before the device is added to a PM
      domain, so it is better to move it directly to the "power" member of
      struct device.  Then, it can be checked by the routines in
      drivers/base/power/runtime.c and drivers/base/power/main.c, which is
      more straightforward.
      
      This also reduces the number of dev_gpd_data() invocations in the
      generic PM domains framework, so the overhead related to the syscore
      flag is slightly smaller.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@opensource.se>
      dbf37414
  2. 18 8月, 2012 3 次提交
    • R
      PM / Runtime: Check device PM QoS setting before "no callbacks" check · 55d7ec45
      Rafael J. Wysocki 提交于
      If __dev_pm_qos_read_value(dev) returns a negative value,
      rpm_suspend() should return -EPERM for dev even if its
      power.no_callbacks flag is set.  For this to happen, the device's
      power.no_callbacks flag has to be checked after the PM QoS check,
      so move the PM QoS check to rpm_check_suspend_allowed() (this will
      make it cover idle notifications as well as runtime suspend too).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      55d7ec45
    • R
      PM / Runtime: Clear power.deferred_resume on success in rpm_suspend() · 58a34de7
      Rafael J. Wysocki 提交于
      The power.deferred_resume can only be set if the runtime PM status
      of device is RPM_SUSPENDING and it should be cleared after its
      status has been changed, regardless of whether or not the runtime
      suspend has been successful.  However, it only is cleared on
      suspend failure, while it may remain set on successful suspend and
      is happily leaked to rpm_resume() executed in that case.
      
      That shouldn't happen, so if power.deferred_resume is set in
      rpm_suspend() after the status has been changed to RPM_SUSPENDED,
      clear it before calling rpm_resume().  Then, it doesn't need to be
      cleared before changing the status to RPM_SUSPENDING any more,
      because it's always cleared after the status has been changed to
      either RPM_SUSPENDED (on success) or RPM_ACTIVE (on failure).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      58a34de7
    • R
      PM / Runtime: Fix rpm_resume() return value for power.no_callbacks set · 7f321c26
      Rafael J. Wysocki 提交于
      For devices whose power.no_callbacks flag is set, rpm_resume()
      should return 1 if the device's parent is already active, so that
      the callers of pm_runtime_get() don't think that they have to wait
      for the device to resume (asynchronously) in that case (the core
      won't queue up an asynchronous resume in that case, so there's
      nothing to wait for anyway).
      
      Modify the code accordingly (and make sure that an idle notification
      will be queued up on success, even if 1 is to be returned).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable@vger.kernel.org
      7f321c26
  3. 02 5月, 2012 1 次提交
  4. 27 3月, 2012 1 次提交
    • A
      PM / Runtime: don't forget to wake up waitqueue on failure · f2791d73
      Alan Stern 提交于
      This patch (as1535) fixes a bug in the runtime PM core.  When a
      runtime suspend attempt completes, whether successfully or not, the
      device's power.wait_queue is supposed to be signalled.  But this
      doesn't happen in the failure pathway of rpm_suspend() when another
      autosuspend attempt is rescheduled.  As a result, a task can get stuck
      indefinitely on the wait queue (I have seen this happen in testing).
      
      The patch fixes the problem by moving the wake_up_all() call up near
      the start of the failure code.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      f2791d73
  5. 22 12月, 2011 1 次提交
    • 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
  6. 02 12月, 2011 1 次提交
    • 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
  7. 05 11月, 2011 2 次提交
  8. 01 11月, 2011 1 次提交
  9. 17 10月, 2011 2 次提交
    • 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
    • M
      PM / Runtime: Fix kerneldoc comment for rpm_suspend() · 47d8f0ba
      Ming Lei 提交于
      This patch fix kerneldoc comments for rpm_suspend():
      
       - 'Cancel a pending idle notification' should be put before, also
         should be changed to 'Cancel a pending idle notification,
         autosuspend or suspend'.
      
       - idle notification for the device after succeeding suspend has
         been removed, so update the comment accordingly.
      
      [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>
      47d8f0ba
  10. 28 9月, 2011 2 次提交
    • M
      PM / Runtime: Replace dev_dbg() with trace_rpm_*() · c3dc2f14
      Ming Lei 提交于
      This patch replaces dev_dbg with trace_rpm_* inside
      the three important functions:
      
      	rpm_idle
      	rpm_suspend
      	rpm_resume
      
      Trace points have the below advantages compared with dev_dbg:
      
      	- trace points include much runtime information(such as
      	running cpu, current task, ...)
      
      	- most of linux distributions may disable "verbose debug"
      	driver debug compile switch, so it is very difficult to
      	report/debug runtime pm related problems from distribution
      	users without this kind of debug information.
      
      	- for upstream kernel users, enableing the debug switch will
      	produce many useless "rpm_resume" output, and it is very noise.
      
      	- dev_dbg inside rpm_suspend/rpm_resume may have some effects
      	on runtime pm behaviour of console devicer
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      c3dc2f14
    • R
      PM / Runtime: Don't run callbacks under lock for power.irq_safe set · ad3c36a5
      Rafael J. Wysocki 提交于
      The rpm_suspend() and rpm_resume() routines execute subsystem or PM
      domain callbacks under power.lock if power.irq_safe is set for the
      given device.  This is inconsistent with that rpm_idle() does after
      commit 02b26774 (PM / Runtime: Allow _put_sync() from
      interrupts-disabled context) and is problematic for subsystems and PM
      domains wanting to use power.lock for synchronization in their
      runtime PM callbacks.
      
      This change requires the code checking if the device's runtime PM
      status is RPM_SUSPENDING or RPM_RESUMING to be modified too, to take
      the power.irq_safe set case into account (that code wasn't reachable
      before with power.irq_safe set, because it's executed with the
      device's power.lock held).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NMing Lei <tom.leiming@gmail.com>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      ad3c36a5
  11. 14 8月, 2011 1 次提交
    • C
      PM / Runtime: Add might_sleep() to runtime PM functions · 311aab73
      Colin Cross 提交于
      Some of the entry points to pm runtime are not safe to
      call in atomic context unless pm_runtime_irq_safe() has
      been called.  Inspecting the code, it is not immediately
      obvious that the functions sleep at all, as they run
      inside a spin_lock_irqsave, but under some conditions
      they can drop the lock and turn on irqs.
      
      If a driver incorrectly calls the pm_runtime apis, it can
      cause sleeping and irq processing when it expects to stay
      in atomic context.
      
      Add might_sleep_if to the majority of the __pm_runtime_* entry points
      to enforce correct usage.
      
      Add pm_runtime_put_sync_autosuspend to the list of
      functions that can be called in atomic context.
      Signed-off-by: NColin Cross <ccross@android.com>
      Reviewed-by: NKevin Hilman <khilman@ti.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      311aab73
  12. 06 8月, 2011 1 次提交
    • K
      PM / Runtime: Allow _put_sync() from interrupts-disabled context · 02b26774
      Kevin Hilman 提交于
      Currently the use of pm_runtime_put_sync() is not safe from
      interrupts-disabled context because rpm_idle() will release the
      spinlock and enable interrupts for the idle callbacks.  This enables
      interrupts during a time where interrupts were expected to be
      disabled, and can have strange side effects on drivers that expected
      interrupts to be disabled.
      
      This is not a bug since the documentation clearly states that only
      _put_sync_suspend() is safe in IRQ-safe mode.
      
      However, pm_runtime_put_sync() could be made safe when in IRQ-safe
      mode by releasing the spinlock but not re-enabling interrupts, which
      is what this patch aims to do.
      
      Problem was found when using some buggy drivers that set
      pm_runtime_irq_safe() and used _put_sync() in interrupts-disabled
      context.
      Reported-by: NColin Cross <ccross@google.com>
      Tested-by: NNishanth Menon <nm@ti.com>
      Signed-off-by: NKevin Hilman <khilman@ti.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      02b26774
  13. 09 7月, 2011 1 次提交
  14. 06 7月, 2011 1 次提交
  15. 02 7月, 2011 2 次提交
    • R
      PM / Runtime: Return special error code if runtime PM is disabled · 632e270e
      Rafael J. Wysocki 提交于
      Some callers of pm_runtime_get_sync() and other runtime PM helper
      functions, scsi_autopm_get_host() and scsi_autopm_get_device() in
      particular, need to distinguish error codes returned when runtime PM
      is disabled (i.e. power.disable_depth is nonzero for the given
      device) from error codes returned in other situations.  For this
      reason, make the runtime PM helper functions return -EACCES when
      power.disable_depth is nonzero and ensure that this error code
      won't be returned by them in any other circumstances.  Modify
      scsi_autopm_get_host() and scsi_autopm_get_device() to check the
      error code returned by pm_runtime_get_sync() and ignore -EACCES.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      632e270e
    • R
      PM / Domains: Rename struct dev_power_domain to struct dev_pm_domain · 564b905a
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NKevin Hilman <khilman@ti.com>
      564b905a
  16. 29 4月, 2011 1 次提交
    • R
      PM: Make power domain callbacks take precedence over subsystem ones · 4d27e9dc
      Rafael J. Wysocki 提交于
      Change the PM core's behavior related to power domains in such a way
      that, if a power domain is defined for a given device, its callbacks
      will be executed instead of and not in addition to the device
      subsystem's PM callbacks.
      
      The idea behind the initial implementation of power domains handling
      by the PM core was that power domain callbacks would be executed in
      addition to subsystem callbacks, so that it would be possible to
      extend the subsystem callbacks by using power domains.  It turns out,
      however, that this wouldn't be really convenient in some important
      situations.
      
      For example, there are systems in which power can only be removed
      from entire power domains.  On those systems it is not desirable to
      execute device drivers' PM callbacks until it is known that power is
      going to be removed from the devices in question, which means that
      they should be executed by power domain callbacks rather then by
      subsystem (e.g. bus type) PM callbacks, because subsystems generally
      have no information about what devices belong to which power domain.
      Thus, for instance, if the bus type in question is the platform bus
      type, its PM callbacks generally should not be called in addition to
      power domain callbacks, because they run device drivers' callbacks
      unconditionally if defined.
      
      While in principle the default subsystem PM callbacks, or a subset of
      them, may be replaced with different functions, it doesn't seem
      correct to do so, because that would change the subsystem's behavior
      with respect to all devices in the system, regardless of whether or
      not they belong to any power domains.  Thus, the only remaining
      option is to make power domain callbacks take precedence over
      subsystem callbacks.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGrant Likely <grant.likely@secretlab.ca>
      Acked-by: NKevin Hilman <khilman@ti.com>
      4d27e9dc
  17. 31 3月, 2011 1 次提交
  18. 15 3月, 2011 2 次提交
    • R
      PM: Make system-wide PM and runtime PM treat subsystems consistently · 9659cc06
      Rafael J. Wysocki 提交于
      The code handling system-wide power transitions (eg. suspend-to-RAM)
      can in theory execute callbacks provided by the device's bus type,
      device type and class in each phase of the power transition.  In
      turn, the runtime PM core code only calls one of those callbacks at
      a time, preferring bus type callbacks to device type or class
      callbacks and device type callbacks to class callbacks.
      
      It seems reasonable to make them both behave in the same way in that
      respect.  Moreover, even though a device may belong to two subsystems
      (eg. bus type and device class) simultaneously, in practice power
      management callbacks for system-wide power transitions are always
      provided by only one of them (ie. if the bus type callbacks are
      defined, the device class ones are not and vice versa).  Thus it is
      possible to modify the code handling system-wide power transitions
      so that it follows the core runtime PM code (ie. treats the
      subsystem callbacks as mutually exclusive).
      
      On the other hand, the core runtime PM code will choose to execute,
      for example, a runtime suspend callback provided by the device type
      even if the bus type's struct dev_pm_ops object exists, but the
      runtime_suspend pointer in it happens to be NULL.  This is confusing,
      because it may lead to the execution of callbacks from different
      subsystems during different operations (eg. the bus type suspend
      callback may be executed during runtime suspend of the device, while
      the device type callback will be executed during system suspend).
      
      Make all of the power management code treat subsystem callbacks in
      a consistent way, such that:
      (1) If the device's type is defined (eg. dev->type is not NULL)
          and its pm pointer is not NULL, the callbacks from dev->type->pm
          will be used.
      (2) If dev->type is NULL or dev->type->pm is NULL, but the device's
          class is defined (eg. dev->class is not NULL) and its pm pointer
          is not NULL, the callbacks from dev->class->pm will be used.
      (3) If dev->type is NULL or dev->type->pm is NULL and dev->class is
          NULL or dev->class->pm is NULL, the callbacks from dev->bus->pm
          will be used provided that both dev->bus and dev->bus->pm are
          not NULL.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NKevin Hilman <khilman@ti.com>
      Reasoning-sounds-sane-to: Grant Likely <grant.likely@secretlab.ca>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9659cc06
    • R
      PM: Add support for device power domains · 7538e3db
      Rafael J. Wysocki 提交于
      The platform bus type is often used to handle Systems-on-a-Chip (SoC)
      where all devices are represented by objects of type struct
      platform_device.  In those cases the same "platform" device driver
      may be used with multiple different system configurations, but the
      actions needed to put the devices it handles into a low-power state
      and back into the full-power state may depend on the design of the
      given SoC.  The driver, however, cannot possibly include all the
      information necessary for the power management of its device on all
      the systems it is used with.  Moreover, the device hierarchy in its
      current form also is not suitable for representing this kind of
      information.
      
      The patch below attempts to address this problem by introducing
      objects of type struct dev_power_domain that can be used for
      representing power domains within a SoC.  Every struct
      dev_power_domain object provides a sets of device power
      management callbacks that can be used to perform what's needed for
      device power management in addition to the operations carried out by
      the device's driver and subsystem.
      
      Namely, if a struct dev_power_domain object is pointed to by the
      pwr_domain field in a struct device, the callbacks provided by its
      ops member will be executed in addition to the corresponding
      callbacks provided by the device's subsystem and driver during all
      power transitions.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Tested-and-acked-by: NKevin Hilman <khilman@ti.com>
      7538e3db
  19. 26 1月, 2011 1 次提交
  20. 24 12月, 2010 1 次提交
    • A
      PM / Runtime: Add synchronous runtime interface for interrupt handlers (v3) · c7b61de5
      Alan Stern 提交于
      This patch (as1431c) makes the synchronous runtime-PM interface
      suitable for use in interrupt handlers.  Subsystems can call the new
      pm_runtime_irq_safe() function to tell the PM core that a device's
      runtime_suspend and runtime_resume callbacks should be invoked with
      interrupts disabled and the spinlock held.  This permits the
      pm_runtime_get_sync() and the new pm_runtime_put_sync_suspend()
      routines to be called from within interrupt handlers.
      
      When a device is declared irq-safe in this way, the PM core increments
      the parent's usage count, so the parent will never be runtime
      suspended.  This prevents difficult situations in which an irq-safe
      device can't resume because it is forced to wait for its non-irq-safe
      parent.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      c7b61de5
  21. 29 10月, 2010 1 次提交
  22. 23 10月, 2010 1 次提交
  23. 17 10月, 2010 9 次提交
    • R
      PM / Runtime: Remove idle notification after failing suspend · f71648d7
      Rafael J. Wysocki 提交于
      If runtime suspend of a device fails returning -EAGAIN or -EBUSY,
      which means that it's safe to try to suspend it again, the PM core
      runs the runtime idle helper function for it.  Unfortunately this may
      lead to problems, for example for PCI devices whose drivers don't
      implement the ->runtime_idle() callback, because in that case the
      PCI bus type's ->runtime_idle() always calls pm_runtime_suspend()
      for the given device.  Then, if there's an automatic idle
      notification after the driver's ->runtime_suspend() returning -EAGAIN
      or -EBUSY, it will make the suspend happen again possibly causing a
      busy loop to appear.  To avoid that, remove the idle notification
      after failing runtime suspend of a device altogether and let the
      callers of pm_runtime_suspend() repeat the operation if need be.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      f71648d7
    • R
      PM / Runtime: Reduce code duplication in core helper functions · 71c63122
      Rafael J. Wysocki 提交于
      Reduce code duplication in rpm_idle(), rpm_suspend() and rpm_resume()
      by using local pointers to store callback addresses and moving some
      duplicated code into a separate function.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reviewed-by: NAlan Stern <stern@rowland.harvard.edu>
      71c63122
    • A
      PM / Runtime: Implement autosuspend support · 15bcb91d
      Alan Stern 提交于
      This patch (as1427) implements the "autosuspend" facility for runtime
      PM.  A few new fields are added to the dev_pm_info structure and
      several new PM helper functions are defined, for telling the PM core
      whether or not a device uses autosuspend, for setting the autosuspend
      delay, and for marking periods of device activity.
      
      Drivers that do not want to use autosuspend can continue using the
      same helper functions as before; their behavior will not change.  In
      addition, drivers supporting autosuspend can also call the old helper
      functions to get the old behavior.
      
      The details are all explained in Documentation/power/runtime_pm.txt
      and Documentation/ABI/testing/sysfs-devices-power.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      15bcb91d
    • A
      PM / Runtime: Add no_callbacks flag · 7490e442
      Alan Stern 提交于
      Some devices, such as USB interfaces, cannot be power-managed
      independently of their parents, i.e., they cannot be put in low power
      while the parent remains at full power.  This patch (as1425) creates a
      new "no_callbacks" flag, which tells the PM core not to invoke the
      runtime-PM callback routines for the such devices but instead to
      assume that the callbacks always succeed.  In addition, the
      non-debugging runtime-PM sysfs attributes for the devices are removed,
      since they are pretty much meaningless.
      
      The advantage of this scheme comes not so much from avoiding the
      callbacks themselves, but rather from the fact that without the need
      for a process context in which to run the callbacks, more work can be
      done in interrupt context.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      7490e442
    • A
      PM / Runtime: Combine runtime PM entry points · 140a6c94
      Alan Stern 提交于
      This patch (as1424) combines the various public entry points for the
      runtime PM routines into three simple functions: one for idle, one for
      suspend, and one for resume.  A new bitflag specifies whether or not
      to increment or decrement the usage_count field.
      
      The new entry points are named __pm_runtime_idle,
      __pm_runtime_suspend, and __pm_runtime_resume, to reflect that they
      are trampolines.  Simultaneously, the corresponding internal routines
      are renamed to rpm_idle, rpm_suspend, and rpm_resume.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      140a6c94
    • A
      PM / Runtime: Merge synchronous and async runtime routines · 1bfee5bc
      Alan Stern 提交于
      This patch (as1423) merges the asynchronous routines
      __pm_request_idle(), __pm_request_suspend(), and __pm_request_resume()
      with their synchronous counterparts.  The RPM_ASYNC bitflag argument
      serves to indicate what sort of operation to perform.
      
      In the course of performing this merger, it became apparent that the
      various functions don't all behave consistenly with regard to error
      reporting and cancellation of outstanding requests.  A new routine,
      rpm_check_suspend_allowed(), was written to centralize much of the
      testing, and the other functions were revised to follow a simple
      algorithm:
      
      	If the operation is disallowed because of the device's
      	settings or current state, return an error.
      
      	Cancel pending or scheduled requests of lower priority.
      
      	Schedule, queue, or perform the desired operation.
      
      A few special cases and exceptions are noted in comments.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      1bfee5bc
    • A
      PM / Runtime: Replace boolean arguments with bitflags · 3f9af051
      Alan Stern 提交于
      The "from_wq" argument in __pm_runtime_suspend() and
      __pm_runtime_resume() supposedly indicates whether or not the function
      was called by the PM workqueue thread, but in fact it isn't always
      used this way.  It really indicates whether or not the function should
      return early if the requested operation is already in progress.
      
      Along with this badly-named boolean argument, later patches in this
      series will add several other boolean arguments to these functions and
      others.  Therefore this patch (as1422) begins the conversion process
      by replacing from_wq with a bitflag argument.  The same bitflags are
      also used in __pm_runtime_get() and __pm_runtime_put(), where they
      indicate whether or not the operation should be asynchronous.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      3f9af051
    • A
      PM / Runtime: Move code in drivers/base/power/runtime.c · 4769373c
      Alan Stern 提交于
      This patch (as1421) moves the PM runtime accounting subroutines up to
      the beginning of runtime.c, taking them out of the middle of the
      functions that do the actual work.  No operational changes.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4769373c
    • R
      PM / Wakeup: Introduce wakeup source objects and event statistics (v3) · 074037ec
      Rafael J. Wysocki 提交于
      Introduce struct wakeup_source for representing system wakeup sources
      within the kernel and for collecting statistics related to them.
      Make the recently introduced helper functions pm_wakeup_event(),
      pm_stay_awake() and pm_relax() use struct wakeup_source objects
      internally, so that wakeup statistics associated with wakeup devices
      can be collected and reported in a consistent way (the definition of
      pm_relax() is changed, which is harmless, because this function is
      not called directly by anyone yet).  Introduce new wakeup-related
      sysfs device attributes in /sys/devices/.../power for reporting the
      device wakeup statistics.
      
      Change the global wakeup events counters event_count and
      events_in_progress into atomic variables, so that it is not necessary
      to acquire a global spinlock in pm_wakeup_event(), pm_stay_awake()
      and pm_relax(), which should allow us to avoid lock contention in
      these functions on SMP systems with many wakeup devices.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      074037ec
  24. 19 7月, 2010 1 次提交
    • A
      PM / Runtime: Add runtime PM statistics (v3) · 8d4b9d1b
      Arjan van de Ven 提交于
      In order for PowerTOP to be able to report how well the new runtime PM is
      working for the various drivers, the kernel needs to export some basic
      statistics in sysfs.
      
      This patch adds two sysfs files in the runtime PM domain that expose the
      total time a device has been active, and the time a device has been
      suspended.
      
      With this PowerTOP can compute the activity percentage
      
      Active %age = 100 * (delta active) / (delta active + delta suspended)
      
      and present the information to the user.
      
      I've written the PowerTOP code (slated for version 1.12) already, and the
      output looks like this:
      
      Runtime Device Power Management statistics
      Active  Device name
       10.0%	06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller
      
      [version 2: fix stat update bugs noticed by Alan Stern]
      [version 3: rebase to -next and move the sysfs declaration]
      Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      8d4b9d1b
  25. 11 5月, 2010 1 次提交
    • A
      PM: Allow runtime_suspend methods to call pm_schedule_suspend() · 240c7337
      Alan Stern 提交于
      This patch (as1361) changes the runtime PM interface slightly; it
      allows suspend requests to be scheduled while the runtime_suspend
      method is running.  If the method succeeds then the scheduled request
      is cancelled, whereas if the method fails then an idle notification is
      sent only if no request was scheduled.
      
      Being able to schedule suspend requests from within a runtime_suspend
      method is useful for drivers that need to test for idleness and
      suspend the device all while holding a single spinlock, or for drivers
      that want to check for idleness by polling.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      240c7337