1. 15 3月, 2011 9 次提交
    • 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
    • R
      PM: Allow pm_runtime_suspend() to succeed during system suspend · e8665002
      Rafael J. Wysocki 提交于
      The dpm_prepare() function increments the runtime PM reference
      counters of all devices to prevent pm_runtime_suspend() from
      executing subsystem-level callbacks.  However, this was supposed to
      guard against a specific race condition that cannot happen, because
      the power management workqueue is freezable, so pm_runtime_suspend()
      can only be called synchronously during system suspend and we can
      rely on subsystems and device drivers to avoid doing that
      unnecessarily.
      
      Make dpm_prepare() drop the runtime PM reference to each device
      after making sure that runtime resume is not pending for it.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NKevin Hilman <khilman@ti.com>
      e8665002
    • R
      PM: Remove CONFIG_PM_OPS · aa338601
      Rafael J. Wysocki 提交于
      After redefining CONFIG_PM to depend on (CONFIG_PM_SLEEP ||
      CONFIG_PM_RUNTIME) the CONFIG_PM_OPS option is redundant and can be
      replaced with CONFIG_PM.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      aa338601
    • R
      PM: Do not create wakeup sysfs files for devices that cannot wake up · cb8f51bd
      Rafael J. Wysocki 提交于
      Currently, wakeup sysfs attributes are created for all devices,
      regardless of whether or not they are wakeup-capable.  This is
      excessive and complicates wakeup device identification from user
      space (i.e. to identify wakeup-capable devices user space has to read
      /sys/devices/.../power/wakeup for all devices and see if they are not
      empty).
      
      Fix this issue by avoiding to create wakeup sysfs files for devices
      that cannot wake up the system from sleep states (i.e. whose
      power.can_wakeup flags are unset during registration) and modify
      device_set_wakeup_capable() so that it adds (or removes) the relevant
      sysfs attributes if a device's wakeup capability status is changed.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      cb8f51bd
    • M
      PM: Use appropriate printk() priority level in trace.c · 0295a34d
      Mandeep Singh Baines 提交于
      printk()s without a priority level default to KERN_WARNING. To reduce
      noise at KERN_WARNING, this patch sets the priority level appriopriately
      for unleveled printks()s. This should be useful to folks that look at
      dmesg warnings closely.
      
      Changed these messages to pr_info().
      Signed-off-by: NMandeep Singh Baines <msb@chromium.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0295a34d
    • R
      PM / Wakeup: Don't update events_check_enabled in pm_get_wakeup_count() · 790c7885
      Rafael J. Wysocki 提交于
      Since pm_save_wakeup_count() has just been changed to clear
      events_check_enabled unconditionally before checking if there are
      any new wakeup events registered since the last read from
      /sys/power/wakeup_count, the detection of wakeup events during
      suspend may be disabled, after it's been enabled, by writing a
      "wrong" value back to /sys/power/wakeup_count.  For this reason,
      it is not necessary to update events_check_enabled in
      pm_get_wakeup_count() any more.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      790c7885
    • R
      PM / Wakeup: Make pm_save_wakeup_count() work as documented · 378eef99
      Rafael J. Wysocki 提交于
      According to Documentation/ABI/testing/sysfs-power, the
      /sys/power/wakeup_count interface should only make the kernel react
      to wakeup events during suspend if the last write to it has been
      successful.  However, if /sys/power/wakeup_count is written to two
      times in a row, where the first write is successful and the second
      is not, the kernel will still react to wakeup events during suspend
      due to a bug in pm_save_wakeup_count().
      
      Fix the bug by making pm_save_wakeup_count() clear
      events_check_enabled unconditionally before checking if there are
      any new wakeup events registered since the previous read from
      /sys/power/wakeup_count.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      378eef99
    • R
      PM / Wakeup: Combine atomic counters to avoid reordering issues · 023d3779
      Rafael J. Wysocki 提交于
      The memory barrier in wakeup_source_deactivate() is supposed to
      prevent the callers of pm_wakeup_pending() and pm_get_wakeup_count()
      from seeing the new value of events_in_progress (0, in particular)
      and the old value of event_count at the same time.  However, if
      wakeup_source_deactivate() is executed by CPU0 and, for instance,
      pm_wakeup_pending() is executed by CPU1, where both processors can
      reorder operations, the memory barrier in wakeup_source_deactivate()
      doesn't affect CPU1 which can reorder reads.  In that case CPU1 may
      very well decide to fetch event_count before it's modified and
      events_in_progress after it's been updated, so pm_wakeup_pending()
      may fail to detect a wakeup event.  This issue can be addressed by
      using a single atomic variable to store both events_in_progress
      and event_count, so that they can be updated together in a single
      atomic operation.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      023d3779
  2. 26 1月, 2011 1 次提交
  3. 24 12月, 2010 12 次提交
  4. 11 11月, 2010 1 次提交
    • R
      PM: Allow devices to be removed during late suspend and early resume · d08a5ace
      Rafael J. Wysocki 提交于
      Holding dpm_list_mtx across late suspend and early resume of devices
      is problematic for the PCMCIA subsystem and doesn't allow device
      objects to be removed by late suspend and early resume driver
      callbacks.  This appears to be overly restrictive, as drivers are
      generally allowed to remove device objects in other phases of suspend
      and resume.  Therefore rework dpm_{suspend|resume}_noirq() so that
      they don't have to hold dpm_list_mtx all the time.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d08a5ace
  5. 02 11月, 2010 1 次提交
  6. 29 10月, 2010 1 次提交
  7. 23 10月, 2010 1 次提交
  8. 20 10月, 2010 1 次提交
  9. 17 10月, 2010 13 次提交
    • N
      PM: Introduce library for device-specific OPPs (v7) · e1f60b29
      Nishanth Menon 提交于
      SoCs have a standard set of tuples consisting of frequency and
      voltage pairs that the device will support per voltage domain. These
      are called Operating Performance Points or OPPs. The actual
      definitions of OPP varies over silicon versions. For a specific domain,
      we can have a set of {frequency, voltage} pairs. As the kernel boots
      and more information is available, a default set of these are activated
      based on the precise nature of device. Further on operation, based on
      conditions prevailing in the system (such as temperature), some OPP
      availability may be temporarily controlled by the SoC frameworks.
      
      To implement an OPP, some sort of power management support is necessary
      hence this library depends on CONFIG_PM.
      
      Contributions include:
      Sanjeev Premi for the initial concept:
      	http://patchwork.kernel.org/patch/50998/
      Kevin Hilman for converting original design to device-based.
      Kevin Hilman and Paul Walmsey for cleaning up many of the function
      abstractions, improvements and data structure handling.
      Romit Dasgupta for using enums instead of opp pointers.
      Thara Gopinath, Eduardo Valentin and Vishwanath BS for fixes and
      cleanups.
      Linus Walleij for recommending this layer be made generic for usage
      in other architectures beyond OMAP and ARM.
      Mark Brown, Andrew Morton, Rafael J. Wysocki, Paul E. McKenney for
      valuable improvements.
      
      Discussions and comments from:
      http://marc.info/?l=linux-omap&m=126033945313269&w=2
      http://marc.info/?l=linux-omap&m=125482970102327&w=2
      http://marc.info/?t=125809247500002&r=1&w=2
      http://marc.info/?l=linux-omap&m=126025973426007&w=2
      http://marc.info/?t=128152609200064&r=1&w=2
      http://marc.info/?t=128468723000002&r=1&w=2
      incorporated.
      
      v1: http://marc.info/?t=128468723000002&r=1&w=2Signed-off-by: NNishanth Menon <nm@ti.com>
      Signed-off-by: NKevin Hilman <khilman@deeprootsystems.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e1f60b29
    • J
      PM: Add sysfs attr for rechecking dev hash from PM trace · d33ac60b
      James Hogan 提交于
      If the device which fails to resume is part of a loadable kernel module
      it won't be checked at startup against the magic number stored in the
      RTC.
      
      Add a read-only sysfs attribute /sys/power/pm_trace_dev_match which
      contains a list of newline separated devices (usually just the one)
      which currently match the last magic number. This allows the device
      which is failing to resume to be found after the modules are loaded
      again.
      Signed-off-by: NJames Hogan <james@albanarts.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d33ac60b
    • J
      PM: Lock PM device list mutex in show_dev_hash() · 2ac21c6b
      James Hogan 提交于
      Lock the PM device list mutex using device_pm_lock() and
      device_pm_unlock() around the list iteration in show_dev_hash().
      
      show_dev_hash() was reverse iterating dpm_list without first locking the
      mutex that the functions in drivers/base/power/main.c lock. I assume
      this was unintentional since there is no comment suggesting why the lock
      might not be necessary.
      Signed-off-by: NJames Hogan <james@albanarts.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      2ac21c6b
    • 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: Fix potential issue with failing asynchronous suspend · 098dff73
      Rafael J. Wysocki 提交于
      There is a potential issue with the asynchronous suspend code that
      a device driver suspending asynchronously may not notice that it
      should back off.  There are two failing scenarions, (1) when the
      driver is waiting for a driver suspending synchronously to complete
      and that second driver returns error code, in which case async_error
      won't be set and the waiting driver will continue suspending and (2)
      after the driver has called device_pm_wait_for_dev() and the waited
      for driver returns error code, in which case the caller of
      device_pm_wait_for_dev() will not know that there was an error and
      will continue suspending.
      
      To fix this issue make __device_suspend() set async_error, so
      async_suspend() doesn't need to set it any more, and make
      device_pm_wait_for_dev() return async_error, so that its callers
      can check whether or not they should continue suspending.
      
      No more changes are necessary, since device_pm_wait_for_dev() is
      not used by any drivers' suspend routines.
      Reported-by: NColin Cross <ccross@android.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      098dff73
    • 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