Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/rafael/suspend-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
  spi / PM: Support dev_pm_ops
  PM: Prototype the pm_generic_ operations
  PM / Runtime: Generic resume shouldn't set RPM_ACTIVE unconditionally
  PM: Use dev_name() in core device suspend and resume routines
  PM: Permit registration of parentless devices during system suspend
  PM: Replace the device power.status field with a bit field
  PM: Remove redundant checks from core device resume routines
  PM: Use a different list of devices for each stage of device suspend
  PM: Avoid compiler warning in pm_noirq_op()
  PM: Use pm_wakeup_pending() in __device_suspend()
  PM / Wakeup: Replace pm_check_wakeup_events() with pm_wakeup_pending()
  PM: Prevent dpm_prepare() from returning errors unnecessarily
  PM: Fix references to basic-pm-debugging.txt in drivers-testing.txt
  PM / Runtime: Add synchronous runtime interface for interrupt handlers (v3)
  PM / Hibernate: When failed, in_suspend should be reset
  PM / Hibernate: hibernation_ops->leave should be checked too
  Freezer: Fix a race during freezing of TASK_STOPPED tasks
  PM: Use proper ccflag flag in kernel/power/Makefile
  PM / Runtime: Fix comments to match runtime callback code
  • Loading branch information
torvalds committed Jan 10, 2011
2 parents 78c92a9 + 3ae22e8 commit c8940ec
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 206 deletions.
8 changes: 4 additions & 4 deletions Documentation/power/drivers-testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ Once you have resolved the suspend/resume-related problems with your test system
without the new driver, you are ready to test it:

a) Build the driver as a module, load it and try the test modes of hibernation
(see: Documents/power/basic-pm-debugging.txt, 1).
(see: Documentation/power/basic-pm-debugging.txt, 1).

b) Load the driver and attempt to hibernate in the "reboot", "shutdown" and
"platform" modes (see: Documents/power/basic-pm-debugging.txt, 1).
"platform" modes (see: Documentation/power/basic-pm-debugging.txt, 1).

c) Compile the driver directly into the kernel and try the test modes of
hibernation.

d) Attempt to hibernate with the driver compiled directly into the kernel
in the "reboot", "shutdown" and "platform" modes.

e) Try the test modes of suspend (see: Documents/power/basic-pm-debugging.txt,
e) Try the test modes of suspend (see: Documentation/power/basic-pm-debugging.txt,
2). [As far as the STR tests are concerned, it should not matter whether or
not the driver is built as a module.]

f) Attempt to suspend to RAM using the s2ram tool with the driver loaded
(see: Documents/power/basic-pm-debugging.txt, 2).
(see: Documentation/power/basic-pm-debugging.txt, 2).

Each of the above tests should be repeated several times and the STD tests
should be mixed with the STR tests. If any of them fails, the driver cannot be
Expand Down
31 changes: 31 additions & 0 deletions Documentation/power/runtime_pm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ type's callbacks are not defined) of given device. The bus type, device type
and device class callbacks are referred to as subsystem-level callbacks in what
follows.

By default, the callbacks are always invoked in process context with interrupts
enabled. However, subsystems can use the pm_runtime_irq_safe() helper function
to tell the PM core that a device's ->runtime_suspend() and ->runtime_resume()
callbacks should be invoked in atomic context with interrupts disabled
(->runtime_idle() is still invoked the default way). This implies that these
callback routines must not block or sleep, but it also means that the
synchronous helper functions listed at the end of Section 4 can be used within
an interrupt handler or in an atomic context.

The subsystem-level suspend callback is _entirely_ _responsible_ for handling
the suspend of the device as appropriate, which may, but need not include
executing the device driver's own ->runtime_suspend() callback (from the
Expand Down Expand Up @@ -237,6 +246,10 @@ defined in include/linux/pm.h:
Section 8); it may be modified only by the pm_runtime_no_callbacks()
helper function

unsigned int irq_safe;
- indicates that the ->runtime_suspend() and ->runtime_resume() callbacks
will be invoked with the spinlock held and interrupts disabled

unsigned int use_autosuspend;
- indicates that the device's driver supports delayed autosuspend (see
Section 9); it may be modified only by the
Expand Down Expand Up @@ -344,6 +357,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
- decrement the device's usage counter; if the result is 0 then run
pm_runtime_idle(dev) and return its result

int pm_runtime_put_sync_suspend(struct device *dev);
- decrement the device's usage counter; if the result is 0 then run
pm_runtime_suspend(dev) and return its result

int pm_runtime_put_sync_autosuspend(struct device *dev);
- decrement the device's usage counter; if the result is 0 then run
pm_runtime_autosuspend(dev) and return its result
Expand Down Expand Up @@ -397,6 +414,11 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
PM attributes from /sys/devices/.../power (or prevent them from being
added when the device is registered)

void pm_runtime_irq_safe(struct device *dev);
- set the power.irq_safe flag for the device, causing the runtime-PM
suspend and resume callbacks (but not the idle callback) to be invoked
with interrupts disabled

void pm_runtime_mark_last_busy(struct device *dev);
- set the power.last_busy field to the current time

Expand Down Expand Up @@ -438,6 +460,15 @@ pm_runtime_suspended()
pm_runtime_mark_last_busy()
pm_runtime_autosuspend_expiration()

If pm_runtime_irq_safe() has been called for a device then the following helper
functions may also be used in interrupt context:

pm_runtime_suspend()
pm_runtime_autosuspend()
pm_runtime_resume()
pm_runtime_get_sync()
pm_runtime_put_sync_suspend()

5. Run-time PM Initialization, Device Probing and Removal

Initially, the run-time PM is disabled for all devices, which means that the
Expand Down
6 changes: 3 additions & 3 deletions drivers/base/power/generic_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EXPORT_SYMBOL_GPL(pm_generic_runtime_idle);
*
* If PM operations are defined for the @dev's driver and they include
* ->runtime_suspend(), execute it and return its error code. Otherwise,
* return -EINVAL.
* return 0.
*/
int pm_generic_runtime_suspend(struct device *dev)
{
Expand All @@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pm_generic_runtime_suspend);
*
* If PM operations are defined for the @dev's driver and they include
* ->runtime_resume(), execute it and return its error code. Otherwise,
* return -EINVAL.
* return 0.
*/
int pm_generic_runtime_resume(struct device *dev)
{
Expand Down Expand Up @@ -185,7 +185,7 @@ static int __pm_generic_resume(struct device *dev, int event)
return 0;

ret = callback(dev);
if (!ret) {
if (!ret && pm_runtime_enabled(dev)) {
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
Expand Down
Loading

0 comments on commit c8940ec

Please sign in to comment.