1. 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
  2. 16 12月, 2009 1 次提交
  3. 06 12月, 2009 1 次提交
  4. 15 9月, 2009 1 次提交
  5. 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
  6. 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
  7. 25 3月, 2009 1 次提交
  8. 23 2月, 2009 1 次提交
  9. 07 1月, 2009 2 次提交
  10. 17 10月, 2008 1 次提交
  11. 25 7月, 2008 4 次提交
  12. 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
  13. 30 4月, 2008 1 次提交
  14. 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
  15. 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
  16. 03 2月, 2008 1 次提交
  17. 12 1月, 2008 1 次提交
  18. 19 10月, 2007 1 次提交
    • R
      PM: Move definition of struct pm_ops to suspend.h · 95d9ffbe
      Rafael J. Wysocki 提交于
      Move the definition of 'struct pm_ops' and related functions from <linux/pm.h>
      to <linux/suspend.h> .
      
      There are, at least, the following reasons to do that:
      * 'struct pm_ops' is specifically related to suspend and not to the power
        management in general.
      * As long as 'struct pm_ops' is defined in <linux/pm.h>, any modification of it
        causes the entire kernel to be recompiled, which is unnecessary and annoying.
      * Some suspend-related features are already defined in <linux/suspend.h>, so it
        is logical to move the definition of 'struct pm_ops' into there.
      * 'struct hibernation_ops', being the hibernation-related counterpart of
        'struct pm_ops', is defined in <linux/suspend.h> .
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      95d9ffbe
  19. 31 7月, 2007 1 次提交
  20. 30 7月, 2007 1 次提交
    • R
      Introduce CONFIG_SUSPEND for suspend-to-Ram and standby · 296699de
      Rafael J. Wysocki 提交于
      Introduce CONFIG_SUSPEND representing the ability to enter system sleep
      states, such as the ACPI S3 state, and allow the user to choose SUSPEND
      and HIBERNATION independently of each other.
      
      Make HOTPLUG_CPU be selected automatically if SUSPEND or HIBERNATION has
      been chosen and the kernel is intended for SMP systems.
      
      Also, introduce CONFIG_PM_SLEEP which is automatically selected if
      CONFIG_SUSPEND or CONFIG_HIBERNATION is set and use it to select the
      code needed for both suspend and hibernation.
      
      The top-level power management headers and the ACPI code related to
      suspend and hibernation are modified to use the new definitions (the
      changes in drivers/acpi/sleep/main.c are, mostly, moving code to reduce
      the number of ifdefs).
      
      There are many other files in which CONFIG_PM can be replaced with
      CONFIG_PM_SLEEP or even with CONFIG_SUSPEND, but they can be updated in
      the future.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      296699de
  21. 20 7月, 2007 1 次提交
  22. 19 7月, 2007 1 次提交
  23. 12 7月, 2007 3 次提交
  24. 02 7月, 2007 1 次提交
    • R
      PM: introduce set_target method in pm_ops · 2391dae3
      Rafael J. Wysocki 提交于
      Commit 52ade9b3 changed the suspend code
      ordering to execute pm_ops->prepare() after the device model per-device
      .suspend() calls in order to fix some ACPI-related issues.  Unfortunately, it
      broke the at91 platform which assumed that pm_ops->prepare() would be called
      before suspending devices.
      
      at91 used pm_ops->prepare() to get notified of the target system sleep state,
      so that it could use this information while suspending devices.  However, with
      the current suspend code ordering pm_ops->prepare() is called too late for
      this purpose.  Thus, at91 needs an additional method in 'struct pm_ops' that
      will be used for notifying the platform of the target system sleep state.
      Moreover, in the future such a method will also be needed by ACPI.
      
      This patch adds the .set_target() method to 'struct pm_ops' and makes the
      suspend code call it, if implemented, before executing the device model
      per-device .suspend() calls.  It also modifies the at91 code to use
      pm_ops->set_target() instead of pm_ops->prepare().
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2391dae3
  25. 10 5月, 2007 1 次提交
    • R
      PM: Separate hibernation code from suspend code · a3d25c27
      Rafael J. Wysocki 提交于
      [ With Johannes Berg <johannes@sipsolutions.net> ]
      
      Separate the hibernation (aka suspend to disk code) from the other suspend
      code.  In particular:
      
       * Remove the definitions related to hibernation from include/linux/pm.h
       * Introduce struct hibernation_ops and a new hibernate() function to hibernate
         the system, defined in include/linux/suspend.h
       * Separate suspend code in kernel/power/main.c from hibernation-related code
         in kernel/power/disk.c and kernel/power/user.c (with the help of
         hibernation_ops)
       * Switch ACPI (the only user of pm_ops.pm_disk_mode) to hibernation_ops
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Greg KH <greg@kroah.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Nigel Cunningham <nigel@nigel.suspend2.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a3d25c27
  26. 01 5月, 2007 4 次提交