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: (21 commits)
  PM / Hibernate: Reduce autotuned default image size
  PM / Core: Introduce struct syscore_ops for core subsystems PM
  PM QoS: Make pm_qos settings readable
  PM / OPP: opp_find_freq_exact() documentation fix
  PM: Documentation/power/states.txt: fix repetition
  PM: Make system-wide PM and runtime PM treat subsystems consistently
  PM: Simplify kernel/power/Kconfig
  PM: Add support for device power domains
  PM: Drop pm_flags that is not necessary
  PM: Allow pm_runtime_suspend() to succeed during system suspend
  PM: Clean up PM_TRACE dependencies and drop unnecessary Kconfig option
  PM: Remove CONFIG_PM_OPS
  PM: Reorder power management Kconfig options
  PM: Make CONFIG_PM depend on (CONFIG_PM_SLEEP || CONFIG_PM_RUNTIME)
  PM / ACPI: Remove references to pm_flags from bus.c
  PM: Do not create wakeup sysfs files for devices that cannot wake up
  USB / Hub: Do not call device_set_wakeup_capable() under spinlock
  PM: Use appropriate printk() priority level in trace.c
  PM / Wakeup: Don't update events_check_enabled in pm_get_wakeup_count()
  PM / Wakeup: Make pm_save_wakeup_count() work as documented
  ...
  • Loading branch information
torvalds committed Mar 16, 2011
2 parents 48d5f67 + bea3864 commit fc82e1d
Show file tree
Hide file tree
Showing 40 changed files with 691 additions and 421 deletions.
20 changes: 10 additions & 10 deletions Documentation/ABI/testing/sysfs-devices-power
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ Description:
"disabled" to it.

For the devices that are not capable of generating system wakeup
events this file contains "\n". In that cases the user space
cannot modify the contents of this file and the device cannot be
enabled to wake up the system.
events this file is not present. In that case the device cannot
be enabled to wake up the system from sleep states.

What: /sys/devices/.../power/control
Date: January 2009
Expand Down Expand Up @@ -85,7 +84,7 @@ Description:
The /sys/devices/.../wakeup_count attribute contains the number
of signaled wakeup events associated with the device. This
attribute is read-only. If the device is not enabled to wake up
the system from sleep states, this attribute is empty.
the system from sleep states, this attribute is not present.

What: /sys/devices/.../power/wakeup_active_count
Date: September 2010
Expand All @@ -95,7 +94,7 @@ Description:
number of times the processing of wakeup events associated with
the device was completed (at the kernel level). This attribute
is read-only. If the device is not enabled to wake up the
system from sleep states, this attribute is empty.
system from sleep states, this attribute is not present.

What: /sys/devices/.../power/wakeup_hit_count
Date: September 2010
Expand All @@ -105,7 +104,8 @@ Description:
number of times the processing of a wakeup event associated with
the device might prevent the system from entering a sleep state.
This attribute is read-only. If the device is not enabled to
wake up the system from sleep states, this attribute is empty.
wake up the system from sleep states, this attribute is not
present.

What: /sys/devices/.../power/wakeup_active
Date: September 2010
Expand All @@ -115,7 +115,7 @@ Description:
or 0, depending on whether or not a wakeup event associated with
the device is being processed (1). This attribute is read-only.
If the device is not enabled to wake up the system from sleep
states, this attribute is empty.
states, this attribute is not present.

What: /sys/devices/.../power/wakeup_total_time_ms
Date: September 2010
Expand All @@ -125,7 +125,7 @@ Description:
the total time of processing wakeup events associated with the
device, in milliseconds. This attribute is read-only. If the
device is not enabled to wake up the system from sleep states,
this attribute is empty.
this attribute is not present.

What: /sys/devices/.../power/wakeup_max_time_ms
Date: September 2010
Expand All @@ -135,7 +135,7 @@ Description:
the maximum time of processing a single wakeup event associated
with the device, in milliseconds. This attribute is read-only.
If the device is not enabled to wake up the system from sleep
states, this attribute is empty.
states, this attribute is not present.

What: /sys/devices/.../power/wakeup_last_time_ms
Date: September 2010
Expand All @@ -146,7 +146,7 @@ Description:
signaling the last wakeup event associated with the device, in
milliseconds. This attribute is read-only. If the device is
not enabled to wake up the system from sleep states, this
attribute is empty.
attribute is not present.

What: /sys/devices/.../power/autosuspend_delay_ms
Date: September 2010
Expand Down
94 changes: 66 additions & 28 deletions Documentation/power/devices.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Device Power Management

Copyright (c) 2010 Rafael J. Wysocki <[email protected]>, Novell Inc.
Copyright (c) 2010-2011 Rafael J. Wysocki <[email protected]>, Novell Inc.
Copyright (c) 2010 Alan Stern <[email protected]>


Expand Down Expand Up @@ -159,18 +159,18 @@ matter, and the kernel is responsible for keeping track of it. By contrast,
whether or not a wakeup-capable device should issue wakeup events is a policy
decision, and it is managed by user space through a sysfs attribute: the
power/wakeup file. User space can write the strings "enabled" or "disabled" to
set or clear the should_wakeup flag, respectively. Reads from the file will
return the corresponding string if can_wakeup is true, but if can_wakeup is
false then reads will return an empty string, to indicate that the device
doesn't support wakeup events. (But even though the file appears empty, writes
will still affect the should_wakeup flag.)
set or clear the "should_wakeup" flag, respectively. This file is only present
for wakeup-capable devices (i.e. devices whose "can_wakeup" flags are set)
and is created (or removed) by device_set_wakeup_capable(). Reads from the
file will return the corresponding string.

The device_may_wakeup() routine returns true only if both flags are set.
Drivers should check this routine when putting devices in a low-power state
during a system sleep transition, to see whether or not to enable the devices'
wakeup mechanisms. However for runtime power management, wakeup events should
be enabled whenever the device and driver both support them, regardless of the
should_wakeup flag.
This information is used by subsystems, like the PCI bus type code, to see
whether or not to enable the devices' wakeup mechanisms. If device wakeup
mechanisms are enabled or disabled directly by drivers, they also should use
device_may_wakeup() to decide what to do during a system sleep transition.
However for runtime power management, wakeup events should be enabled whenever
the device and driver both support them, regardless of the should_wakeup flag.


/sys/devices/.../power/control files
Expand Down Expand Up @@ -249,23 +249,18 @@ various phases always run after tasks have been frozen and before they are
unfrozen. Furthermore, the *_noirq phases run at a time when IRQ handlers have
been disabled (except for those marked with the IRQ_WAKEUP flag).

Most phases use bus, type, and class callbacks (that is, methods defined in
dev->bus->pm, dev->type->pm, and dev->class->pm). The prepare and complete
phases are exceptions; they use only bus callbacks. When multiple callbacks
are used in a phase, they are invoked in the order: <class, type, bus> during
power-down transitions and in the opposite order during power-up transitions.
For example, during the suspend phase the PM core invokes

dev->class->pm.suspend(dev);
dev->type->pm.suspend(dev);
dev->bus->pm.suspend(dev);

before moving on to the next device, whereas during the resume phase the core
invokes

dev->bus->pm.resume(dev);
dev->type->pm.resume(dev);
dev->class->pm.resume(dev);
All phases use bus, type, or class callbacks (that is, methods defined in
dev->bus->pm, dev->type->pm, or dev->class->pm). These callbacks are mutually
exclusive, so if the device type provides a struct dev_pm_ops object pointed to
by its pm field (i.e. both dev->type and dev->type->pm are defined), the
callbacks included in that object (i.e. dev->type->pm) will be used. Otherwise,
if the class provides a struct dev_pm_ops object pointed to by its pm field
(i.e. both dev->class and dev->class->pm are defined), the PM core will use the
callbacks from that object (i.e. dev->class->pm). Finally, if the pm fields of
both the device type and class objects are NULL (or those objects do not exist),
the callbacks provided by the bus (that is, the callbacks from dev->bus->pm)
will be used (this allows device types to override callbacks provided by bus
types or classes if necessary).

These callbacks may in turn invoke device- or driver-specific methods stored in
dev->driver->pm, but they don't have to.
Expand Down Expand Up @@ -507,6 +502,49 @@ routines. Nevertheless, different callback pointers are used in case there is a
situation where it actually matters.


Device Power Domains
--------------------
Sometimes devices share reference clocks or other power resources. In those
cases it generally is not possible to put devices into low-power states
individually. Instead, a set of devices sharing a power resource can be put
into a low-power state together at the same time by turning off the shared
power resource. Of course, they also need to be put into the full-power state
together, by turning the shared power resource on. A set of devices with this
property is often referred to as a power domain.

Support for power domains is provided through the pwr_domain field of struct
device. This field is a pointer to an object of type struct dev_power_domain,
defined in include/linux/pm.h, providing a set of power management callbacks
analogous to the subsystem-level and device driver callbacks that are executed
for the given device during all power transitions, in addition to the respective
subsystem-level callbacks. Specifically, the power domain "suspend" callbacks
(i.e. ->runtime_suspend(), ->suspend(), ->freeze(), ->poweroff(), etc.) are
executed after the analogous subsystem-level callbacks, while the power domain
"resume" callbacks (i.e. ->runtime_resume(), ->resume(), ->thaw(), ->restore,
etc.) are executed before the analogous subsystem-level callbacks. Error codes
returned by the "suspend" and "resume" power domain callbacks are ignored.

Power domain ->runtime_idle() callback is executed before the subsystem-level
->runtime_idle() callback and the result returned by it is not ignored. Namely,
if it returns error code, the subsystem-level ->runtime_idle() callback will not
be called and the helper function rpm_idle() executing it will return error
code. This mechanism is intended to help platforms where saving device state
is a time consuming operation and should only be carried out if all devices
in the power domain are idle, before turning off the shared power resource(s).
Namely, the power domain ->runtime_idle() callback may return error code until
the pm_runtime_idle() helper (or its asychronous version) has been called for
all devices in the power domain (it is recommended that the returned error code
be -EBUSY in those cases), preventing the subsystem-level ->runtime_idle()
callback from being run prematurely.

The support for device power domains is only relevant to platforms needing to
use the same subsystem-level (e.g. platform bus type) and device driver power
management callbacks in many different power domain configurations and wanting
to avoid incorporating the support for power domains into the subsystem-level
callbacks. The other platforms need not implement it or take it into account
in any way.


System Devices
--------------
System devices (sysdevs) follow a slightly different API, which can be found in
Expand Down
13 changes: 7 additions & 6 deletions Documentation/power/runtime_pm.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Run-time Power Management Framework for I/O Devices

(C) 2009 Rafael J. Wysocki <[email protected]>, Novell Inc.
(C) 2009-2011 Rafael J. Wysocki <[email protected]>, Novell Inc.
(C) 2010 Alan Stern <[email protected]>

1. Introduction
Expand Down Expand Up @@ -44,11 +44,12 @@ struct dev_pm_ops {
};

The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks are
executed by the PM core for either the bus type, or device type (if the bus
type's callback is not defined), or device class (if the bus type's and device
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.
executed by the PM core for either the device type, or the class (if the device
type's struct dev_pm_ops object does not exist), or the bus type (if the
device type's and class' struct dev_pm_ops objects do not exist) of the given
device (this allows device types to override callbacks provided by bus types or
classes if necessary). The bus type, device type and 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
Expand Down
12 changes: 6 additions & 6 deletions Documentation/power/states.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ setup via another operating system for it to use. Despite the
inconvenience, this method requires minimal work by the kernel, since
the firmware will also handle restoring memory contents on resume.

For suspend-to-disk, a mechanism called swsusp called 'swsusp' (Swap
Suspend) is used to write memory contents to free swap space.
swsusp has some restrictive requirements, but should work in most
cases. Some, albeit outdated, documentation can be found in
Documentation/power/swsusp.txt. Alternatively, userspace can do most
of the actual suspend to disk work, see userland-swsusp.txt.
For suspend-to-disk, a mechanism called 'swsusp' (Swap Suspend) is used
to write memory contents to free swap space. swsusp has some restrictive
requirements, but should work in most cases. Some, albeit outdated,
documentation can be found in Documentation/power/swsusp.txt.
Alternatively, userspace can do most of the actual suspend to disk work,
see userland-swsusp.txt.

Once memory state is written to disk, the system may either enter a
low-power state (like ACPI S4), or it may simply power down. Powering
Expand Down
5 changes: 2 additions & 3 deletions arch/x86/kernel/apm_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
#include <linux/suspend.h>
#include <linux/kthread.h>
#include <linux/jiffies.h>
#include <linux/acpi.h>

#include <asm/system.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -2331,12 +2332,11 @@ static int __init apm_init(void)
apm_info.disabled = 1;
return -ENODEV;
}
if (pm_flags & PM_ACPI) {
if (!acpi_disabled) {
printk(KERN_NOTICE "apm: overridden by ACPI.\n");
apm_info.disabled = 1;
return -ENODEV;
}
pm_flags |= PM_APM;

/*
* Set up the long jump entry point to the APM BIOS, which is called
Expand Down Expand Up @@ -2428,7 +2428,6 @@ static void __exit apm_exit(void)
kthread_stop(kapmd_task);
kapmd_task = NULL;
}
pm_flags &= ~PM_APM;
}

module_init(apm_init);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/xen/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ config XEN_MAX_DOMAIN_MEMORY

config XEN_SAVE_RESTORE
bool
depends on XEN && PM
depends on XEN
default y

config XEN_DEBUG_FS
Expand Down
1 change: 0 additions & 1 deletion drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ menuconfig ACPI
depends on !IA64_HP_SIM
depends on IA64 || X86
depends on PCI
depends on PM
select PNP
default y
help
Expand Down
23 changes: 6 additions & 17 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <linux/dmi.h>
#include <linux/suspend.h>

#include "internal.h"

Expand Down Expand Up @@ -1006,8 +1007,7 @@ struct kobject *acpi_kobj;

static int __init acpi_init(void)
{
int result = 0;

int result;

if (acpi_disabled) {
printk(KERN_INFO PREFIX "Interpreter disabled.\n");
Expand All @@ -1022,29 +1022,18 @@ static int __init acpi_init(void)

init_acpi_device_notify();
result = acpi_bus_init();

if (!result) {
pci_mmcfg_late_init();
if (!(pm_flags & PM_APM))
pm_flags |= PM_ACPI;
else {
printk(KERN_INFO PREFIX
"APM is already active, exiting\n");
disable_acpi();
result = -ENODEV;
}
} else
if (result) {
disable_acpi();

if (acpi_disabled)
return result;
}

pci_mmcfg_late_init();
acpi_scan_init();
acpi_ec_init();
acpi_debugfs_init();
acpi_sleep_proc_init();
acpi_wakeup_device_init();
return result;
return 0;
}

subsys_initcall(acpi_init);
4 changes: 2 additions & 2 deletions drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ int acpi_suspend(u32 acpi_state)
return -EINVAL;
}

#ifdef CONFIG_PM_OPS
#ifdef CONFIG_PM
/**
* acpi_pm_device_sleep_state - return preferred power state of ACPI device
* in the system sleep state given by %acpi_target_sleep_state
Expand Down Expand Up @@ -671,7 +671,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p)
*d_min_p = d_min;
return d_max;
}
#endif /* CONFIG_PM_OPS */
#endif /* CONFIG_PM */

#ifdef CONFIG_PM_SLEEP
/**
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for the Linux device tree

obj-y := core.o sys.o bus.o dd.o \
obj-y := core.o sys.o bus.o dd.o syscore.o \
driver.o class.o platform.o \
cpu.o firmware.o init.o map.o devres.o \
attribute_container.o transport_class.o
Expand Down
3 changes: 1 addition & 2 deletions drivers/base/power/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
obj-$(CONFIG_PM) += sysfs.o
obj-$(CONFIG_PM) += sysfs.o generic_ops.o
obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
obj-$(CONFIG_PM_RUNTIME) += runtime.o
obj-$(CONFIG_PM_OPS) += generic_ops.o
obj-$(CONFIG_PM_TRACE_RTC) += trace.o
obj-$(CONFIG_PM_OPP) += opp.o

Expand Down
Loading

0 comments on commit fc82e1d

Please sign in to comment.