1. 12 5月, 2011 1 次提交
  2. 24 3月, 2011 1 次提交
    • R
      Introduce ARCH_NO_SYSDEV_OPS config option (v2) · d47d81c0
      Rafael J. Wysocki 提交于
      Introduce Kconfig option allowing architectures where sysdev
      operations used during system suspend, resume and shutdown have been
      completely replaced with struct sycore_ops operations to avoid
      building sysdev code that will never be used.
      
      Make callbacks in struct sys_device and struct sysdev_driver depend
      on ARCH_NO_SYSDEV_OPS to allows us to verify if all of the references
      have been actually removed from the code the given architecture
      depends on.
      
      Make x86 select ARCH_NO_SYSDEV_OPS.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d47d81c0
  3. 15 3月, 2011 3 次提交
    • 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: Drop pm_flags that is not necessary · 6831c6ed
      Rafael J. Wysocki 提交于
      The variable pm_flags is used to prevent APM from being enabled
      along with ACPI, which would lead to problems.  However, acpi_init()
      is always called before apm_init() and after acpi_init() has
      returned, it is known whether or not ACPI will be used.  Namely, if
      acpi_disabled is not set after acpi_init() has returned, this means
      that ACPI is enabled.  Thus, it is sufficient to check acpi_disabled
      in apm_init() to prevent APM from being enabled in parallel with
      ACPI.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NLen Brown <len.brown@intel.com>
      6831c6ed
    • 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
  4. 25 2月, 2011 1 次提交
  5. 24 12月, 2010 3 次提交
  6. 17 10月, 2010 4 次提交
    • 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
    • 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
  7. 19 7月, 2010 2 次提交
    • 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
    • R
      PM: Make it possible to avoid races between wakeup and system sleep · c125e96f
      Rafael J. Wysocki 提交于
      One of the arguments during the suspend blockers discussion was that
      the mainline kernel didn't contain any mechanisms making it possible
      to avoid races between wakeup and system suspend.
      
      Generally, there are two problems in that area.  First, if a wakeup
      event occurs exactly when /sys/power/state is being written to, it
      may be delivered to user space right before the freezer kicks in, so
      the user space consumer of the event may not be able to process it
      before the system is suspended.  Second, if a wakeup event occurs
      after user space has been frozen, it is not generally guaranteed that
      the ongoing transition of the system into a sleep state will be
      aborted.
      
      To address these issues introduce a new global sysfs attribute,
      /sys/power/wakeup_count, associated with a running counter of wakeup
      events and three helper functions, pm_stay_awake(), pm_relax(), and
      pm_wakeup_event(), that may be used by kernel subsystems to control
      the behavior of this attribute and to request the PM core to abort
      system transitions into a sleep state already in progress.
      
      The /sys/power/wakeup_count file may be read from or written to by
      user space.  Reads will always succeed (unless interrupted by a
      signal) and return the current value of the wakeup events counter.
      Writes, however, will only succeed if the written number is equal to
      the current value of the wakeup events counter.  If a write is
      successful, it will cause the kernel to save the current value of the
      wakeup events counter and to abort the subsequent system transition
      into a sleep state if any wakeup events are reported after the write
      has returned.
      
      [The assumption is that before writing to /sys/power/state user space
      will first read from /sys/power/wakeup_count.  Next, user space
      consumers of wakeup events will have a chance to acknowledge or
      veto the upcoming system transition to a sleep state.  Finally, if
      the transition is allowed to proceed, /sys/power/wakeup_count will
      be written to and if that succeeds, /sys/power/state will be written
      to as well.  Still, if any wakeup events are reported to the PM core
      by kernel subsystems after that point, the transition will be
      aborted.]
      
      Additionally, put a wakeup events counter into struct dev_pm_info and
      make these per-device wakeup event counters available via sysfs,
      so that it's possible to check the activity of various wakeup event
      sources within the kernel.
      
      To illustrate how subsystems can use pm_wakeup_event(), make the
      low-level PCI runtime PM wakeup-handling code use it.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Acked-by: Nmarkgross <markgross@thegnar.org>
      Reviewed-by: NAlan Stern <stern@rowland.harvard.edu>
      c125e96f
  8. 07 3月, 2010 1 次提交
    • R
      PM: Provide generic subsystem-level callbacks · d690b2cd
      Rafael J. Wysocki 提交于
      There are subsystems whose power management callbacks only need to
      invoke the callbacks provided by device drivers.  Still, their system
      sleep PM callbacks should play well with the runtime PM callbacks,
      so that devices suspended at run time can be left in that state for
      a system sleep transition.
      
      Provide a set of generic PM callbacks for such subsystems and
      define convenience macros for populating dev_pm_ops structures.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d690b2cd
  9. 27 2月, 2010 3 次提交
    • R
      PM: Allow device drivers to use dpm_wait() · f8824cee
      Rafael J. Wysocki 提交于
      There are some dependencies between devices (in particular, between
      EHCI USB controllers and their OHCI/UHCI siblings) which are not
      reflected by the structure of the device tree.  With synchronous
      suspend and resume these dependencies are taken into accout
      automatically, because the devices in question are always registered
      in the right order, but to meet these constraints with asynchronous
      suspend and resume the drivers of these devices will need to use
      dpm_wait() in their suspend/resume routines, so introduce a helper
      function allowing them to do that.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      f8824cee
    • R
      PM: Asynchronous suspend and resume of devices · 5af84b82
      Rafael J. Wysocki 提交于
      Theoretically, the total time of system sleep transitions (suspend
      to RAM, hibernation) can be reduced by running suspend and resume
      callbacks of device drivers in parallel with each other.  However,
      there are dependencies between devices such that we're not allowed
      to suspend the parent of a device before suspending the device
      itself.  Analogously, we're not allowed to resume a device before
      resuming its parent.
      
      The most straightforward way to take these dependencies into accout
      is to start the async threads used for suspending and resuming
      devices at the core level, so that async_schedule() is called for
      each suspend and resume callback supposed to be executed
      asynchronously.
      
      For this purpose, introduce a new device flag, power.async_suspend,
      used to mark the devices whose suspend and resume callbacks are to be
      executed asynchronously (ie. in parallel with the main suspend/resume
      thread and possibly in parallel with each other) and helper function
      device_enable_async_suspend() allowing one to set power.async_suspend
      for given device (power.async_suspend is unset by default for all
      devices).  For each device with the power.async_suspend flag set the
      PM core will use async_schedule() to execute its suspend and resume
      callbacks.
      
      The async threads started for different devices as a result of
      calling async_schedule() are synchronized with each other and with
      the main suspend/resume thread with the help of completions, in the
      following way:
      (1) There is a completion, power.completion, for each device object.
      (2) Each device's completion is reset before calling async_schedule()
          for the device or, in the case of devices with the
          power.async_suspend flags unset, before executing the device's
          suspend and resume callbacks.
      (3) During suspend, right before running the bus type, device type
          and device class suspend callbacks for the device, the PM core
          waits for the completions of all the device's children to be
          completed.
      (4) During resume, right before running the bus type, device type and
          device class resume callbacks for the device, the PM core waits
          for the completion of the device's parent to be completed.
      (5) The PM core completes power.completion for each device right
          after the bus type, device type and device class suspend (or
          resume) callbacks executed for the device have returned.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      5af84b82
    • R
      PM / Runtime: Add sysfs switch for disabling device run-time PM · 53823639
      Rafael J. Wysocki 提交于
      Add new device sysfs attribute, power/control, allowing the user
      space to block the run-time power management of the devices.  If this
      attribute is set to "on", the driver of the device won't be able to power
      manage it at run time (without breaking the rules) and the device will
      always be in the full power state (except when the entire system goes
      into a sleep state).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      53823639
  10. 16 12月, 2009 1 次提交
  11. 06 12月, 2009 1 次提交
  12. 15 9月, 2009 1 次提交
  13. 23 8月, 2009 1 次提交
    • R
      PM: Introduce core framework for run-time PM of I/O devices (rev. 17) · 5e928f77
      Rafael J. Wysocki 提交于
      Introduce a core framework for run-time power management of I/O
      devices.  Add device run-time PM fields to 'struct dev_pm_info'
      and device run-time PM callbacks to 'struct dev_pm_ops'.  Introduce
      a run-time PM workqueue and define some device run-time PM helper
      functions at the core level.  Document all these things.
      
      Special thanks to Alan Stern for his help with the design and
      multiple detailed reviews of the pereceding versions of this patch
      and to Magnus Damm for testing feedback.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NMagnus Damm <damm@igel.co.jp>
      5e928f77
  14. 13 6月, 2009 2 次提交
    • A
      PM core: rename suspend and resume functions · d1616302
      Alan Stern 提交于
      This patch (as1241) renames a bunch of functions in the PM core.
      Rather than go through a boring list of name changes, suffice it to
      say that in the end we have a bunch of pairs of functions:
      
      	device_resume_noirq	dpm_resume_noirq
      	device_resume		dpm_resume
      	device_complete		dpm_complete
      	device_suspend_noirq	dpm_suspend_noirq
      	device_suspend		dpm_suspend
      	device_prepare		dpm_prepare
      
      in which device_X does the X operation on a single device and dpm_X
      invokes device_X for all devices in the dpm_list.
      
      In addition, the old dpm_power_up and device_resume_noirq have been
      combined into a single function (dpm_resume_noirq).
      
      Lastly, dpm_suspend_start and dpm_resume_end are the renamed versions
      of the former top-level device_suspend and device_resume routines.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NMagnus Damm <damm@igel.co.jp>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      d1616302
    • M
      PM: Rename device_power_down/up() · e39a71ef
      Magnus Damm 提交于
      Rename the functions performing "_noirq" dev_pm_ops
      operations from device_power_down() and device_power_up()
      to device_suspend_noirq() and device_resume_noirq().
      
      The new function names are chosen to show that the functions
      are responsible for calling the _noirq() versions to finalize
      the suspend/resume operation. The current function names do
      not perform power down/up anymore so the names may be misleading.
      
      Global function renames:
      - device_power_down() -> device_suspend_noirq()
      - device_power_up() -> device_resume_noirq()
      
      Static function renames:
      - suspend_device_noirq() -> __device_suspend_noirq()
      - resume_device_noirq() -> __device_resume_noirq()
      Signed-off-by: NMagnus Damm <damm@igel.co.jp>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Acked-by: NLen Brown <lenb@kernel.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e39a71ef
  15. 25 3月, 2009 1 次提交
  16. 23 2月, 2009 1 次提交
  17. 07 1月, 2009 2 次提交
  18. 17 10月, 2008 1 次提交
  19. 25 7月, 2008 4 次提交
  20. 11 6月, 2008 1 次提交
    • R
      Introduce new top level suspend and hibernation callbacks · 1eede070
      Rafael J. Wysocki 提交于
      Introduce 'struct pm_ops' and 'struct pm_ext_ops' ('ext' meaning
      'extended') representing suspend and hibernation operations for bus
      types, device classes, device types and device drivers.
      
      Modify the PM core to use 'struct pm_ops' and 'struct pm_ext_ops'
      objects, if defined, instead of the ->suspend(), ->resume(),
      ->suspend_late(), and ->resume_early() callbacks (the old callbacks
      will be considered as legacy and gradually phased out).
      
      The main purpose of doing this is to separate suspend (aka S2RAM and
      standby) callbacks from hibernation callbacks in such a way that the
      new callbacks won't take arguments and the semantics of each of them
      will be clearly specified.  This has been requested for multiple
      times by many people, including Linus himself, and the reason is that
      within the current scheme if ->resume() is called, for example, it's
      difficult to say why it's been called (ie. is it a resume from RAM or
      from hibernation or a suspend/hibernation failure etc.?).
      
      The second purpose is to make the suspend/hibernation callbacks more
      flexible so that device drivers can handle more than they can within
      the current scheme.  For example, some drivers may need to prevent
      new children of the device from being registered before their
      ->suspend() callbacks are executed or they may want to carry out some
      operations requiring the availability of some other devices, not
      directly bound via the parent-child relationship, in order to prepare
      for the execution of ->suspend(), etc.
      
      Ultimately, we'd like to stop using the freezing of tasks for suspend
      and therefore the drivers' suspend/hibernation code will have to take
      care of the handling of the user space during suspend/hibernation.
      That, in turn, would be difficult within the current scheme, without
      the new ->prepare() and ->complete() callbacks.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      1eede070
  21. 30 4月, 2008 1 次提交
  22. 20 4月, 2008 3 次提交
    • A
      PM: Convert wakeup flag accessors to inline functions · 9a3df1f7
      Alan Stern 提交于
      This patch (as1058) improves the wakeup macros in include/linux/pm.h.
      All but the trivial ones are converted to inline routines, which
      requires moving them to a separate header file since they depend on
      the definition of struct device.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9a3df1f7
    • A
      PM: Make wakeup flags available whenever CONFIG_PM is set · d288e47c
      Alan Stern 提交于
      The various wakeup flags and their accessor macros in struct
      dev_pm_info should be available whenever CONFIG_PM is enabled, not
      just when CONFIG_PM_SLEEP is on.  Otherwise remote wakeup won't always
      be configurable for runtime power management.  This patch (as1056b)
      fixes the oversight.
      
      David Brownell adds:
      	More accurately, fixes the "regression" ... as noted sometime
      	last summer, after 296699de
      	introduced CONFIG_SUSPEND.  But that didn't make the regression
      	list for that kernel, ergo the delay in fixing it.
      
      [rjw: rebased]
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d288e47c
    • R
      PM: Handle device registrations during suspend/resume · 58aca232
      Rafael J. Wysocki 提交于
      Modify the PM core to protect its data structures, specifically the
      dpm_active list, from being corrupted if a child of the currently
      suspending device is registered concurrently with its ->suspend()
      callback.  In that case, since the new device (the child) is added
      to dpm_active after its parent, the PM core will attempt to
      suspend it after the parent, which is wrong.
      
      Introduce a new member of struct dev_pm_info, called 'sleeping',
      and use it to check if the parent of the device being added to
      dpm_active has been suspended, in which case the device registration
      fails.  Also, use 'sleeping' for checking if the ordering of devices
      on dpm_active is correct.
      
      Introduce variable 'all_sleeping' that will be set to 'true' once all
      devices have been suspended and make new device registrations fail
      until 'all_sleeping' is reset to 'false', in order to avoid having
      unsuspended devices around while the system is going into a sleep state.
      
      Remove pm_sleep_rwsem which is not necessary any more.
      
      Special thanks to Alan Stern for discussions and suggestions that
      lead to the creation of this patch.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      58aca232
  23. 24 2月, 2008 1 次提交
    • R
      PM: Introduce PM_EVENT_HIBERNATE callback state · 3a2d5b70
      Rafael J. Wysocki 提交于
      During the last step of hibernation in the "platform" mode (with the
      help of ACPI) we use the suspend code, including the devices'
      ->suspend() methods, to prepare the system for entering the ACPI S4
      system sleep state.
      
      But at least for some devices the operations performed by the
      ->suspend() callback in that case must be different from its operations
      during regular suspend.
      
      For this reason, introduce the new PM event type PM_EVENT_HIBERNATE and
      pass it to the device drivers' ->suspend() methods during the last phase
      of hibernation, so that they can distinguish this case and handle it as
      appropriate.  Modify the drivers that handle PM_EVENT_SUSPEND in a
      special way and need to handle PM_EVENT_HIBERNATE in the same way.
      
      These changes are necessary to fix a hibernation regression related
      to the i915 driver (ref. http://lkml.org/lkml/2008/2/22/488).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Tested-by: NJeff Chua <jeff.chua.linux@gmail.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3a2d5b70