1. 15 3月, 2011 3 次提交
    • 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 15 次提交
    • 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
    • K
      PM: Fix signed/unsigned warning in dpm_show_time() · 0702d9ee
      Kevin Cernekee 提交于
      Seen on MIPS32, gcc 4.4.3, 2.6.36-rc4:
      
      drivers/base/power/main.c: In function 'dpm_show_time':
      drivers/base/power/main.c:415: warning: comparison of distinct pointer types lacks a cast
      
      do_div() takes unsigned parameters:
      
      uint32_t do_div(uint64_t *n, uint32_t base);
      
      Using an unsigned variable for usecs64 should not cause any problems,
      because calltime >= starttime .
      Signed-off-by: NKevin Cernekee <cernekee@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0702d9ee
    • O
      PM / Runtime: Lenient generic runtime pm callbacks · 05aa55dd
      Ohad Ben-Cohen 提交于
      Allow drivers, that belong to subsystems which use the generic
      runtime pm callbacks, not to define runtime pm suspend/resume handlers,
      by implicitly assuming success in such cases.
      
      This is needed to eliminate nop handlers that would otherwise be
      necessary by drivers which enable runtime pm, but don't need
      to do anything when their devices are runtime-suspended/resumed.
      Signed-off-by: NOhad Ben-Cohen <ohad@wizery.com>
      Acked-by: NKevin Hilman <khilman@deeprootsystems.com>
      Acked-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      05aa55dd
  10. 09 9月, 2010 1 次提交
    • C
      PM: Prevent waiting forever on asynchronous resume after failing suspend · 152e1d59
      Colin Cross 提交于
      During suspend, the power.completion is expected to be set when a
      device has not yet started suspending.  Set it on init to fix a
      corner case where a device is resumed when its parent has never
      suspended.
      
      Consider three drivers, A, B, and C.  The parent of A is C, and C
      has async_suspend set.  On boot, C->power.completion is initialized
      to 0.
      
      During the first suspend:
      suspend_devices_and_enter(...)
       dpm_resume(...)
        device_suspend(A)
        device_suspend(B) returns error, aborts suspend
       dpm_resume_end(...)
         dpm_resume(...)
          device_resume(A)
           dpm_wait(A->parent == C)
            wait_for_completion(C->power.completion)
      
      The wait_for_completion will never complete, because
      complete_all(C->power.completion) will only be called from
      device_suspend(C) or device_resume(C), neither of which is called
      if suspend is aborted before C.
      
      After a successful suspend->resume cycle, where B doesn't abort
      suspend, C->power.completion is left in the completed state by the
      call to device_resume(C), and the same call path will work if B
      aborts suspend.
      Signed-off-by: NColin Cross <ccross@android.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      152e1d59
  11. 19 7月, 2010 3 次提交
    • 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
    • A
      PM / Runtime: Make runtime_status attribute not debug-only (v. 2) · 0fcb4eef
      Alan Stern 提交于
      This patch (as1404b) makes the runtime_status sysfs attribute available
      even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
      routine to display "unsupported" when runtime PM is disabled for a
      device.  Although not strictly 100% accurate, this will almost always
      be correct.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      0fcb4eef
    • R
      PM: Do not use dynamically allocated objects in pm_wakeup_event() · 4eb241e5
      Rafael J. Wysocki 提交于
      Originally, pm_wakeup_event() uses struct delayed_work objects,
      allocated with GFP_ATOMIC, to schedule the execution of pm_relax()
      in future.  However, as noted by Alan Stern, it is not necessary to
      do that, because all pm_wakeup_event() calls can use one static timer
      that will always be set to expire at the latest time passed to
      pm_wakeup_event().
      
      The modifications are based on the example code posted by Alan.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      4eb241e5