diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 12:03:55 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 12:03:55 -0400 |
| commit | 46ee9645094ad1eb5b4888882ecaa1fb87dcd2a3 (patch) | |
| tree | d0a48e993568b6a2415cfc21fc06eaa2fd886429 | |
| parent | fa5312d9e87e7222c6c384c4e930dc149bc1178d (diff) | |
| parent | 25f3a5a2854dce8b8413fd24cc9d5b9e3632be54 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
PM: PM QOS update fix
Freezer / cgroup freezer: Update stale locking comments
PM / platform_bus: Allow runtime PM by default
i2c: Fix bus-level power management callbacks
PM QOS update
PM / Hibernate: Fix block_io.c printk warning
PM / Hibernate: Group swap ops
PM / Hibernate: Move the first_sector out of swsusp_write
PM / Hibernate: Separate block_io
PM / Hibernate: Snapshot cleanup
FS / libfs: Implement simple_write_to_buffer
PM / Hibernate: document open(/dev/snapshot) side effects
PM / Runtime: Add sysfs debug files
PM: Improve device power management document
PM: Update device power management document
PM: Allow runtime_suspend methods to call pm_schedule_suspend()
PM: pm_wakeup - switch to using bool
31 files changed, 1251 insertions, 949 deletions
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt index c9abbd86bc18..57080cd74575 100644 --- a/Documentation/power/devices.txt +++ b/Documentation/power/devices.txt | |||
| @@ -1,7 +1,13 @@ | |||
| 1 | Device Power Management | ||
| 2 | |||
| 3 | Copyright (c) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. | ||
| 4 | Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu> | ||
| 5 | |||
| 6 | |||
| 1 | Most of the code in Linux is device drivers, so most of the Linux power | 7 | Most of the code in Linux is device drivers, so most of the Linux power |
| 2 | management code is also driver-specific. Most drivers will do very little; | 8 | management (PM) code is also driver-specific. Most drivers will do very |
| 3 | others, especially for platforms with small batteries (like cell phones), | 9 | little; others, especially for platforms with small batteries (like cell |
| 4 | will do a lot. | 10 | phones), will do a lot. |
| 5 | 11 | ||
| 6 | This writeup gives an overview of how drivers interact with system-wide | 12 | This writeup gives an overview of how drivers interact with system-wide |
| 7 | power management goals, emphasizing the models and interfaces that are | 13 | power management goals, emphasizing the models and interfaces that are |
| @@ -15,9 +21,10 @@ Drivers will use one or both of these models to put devices into low-power | |||
| 15 | states: | 21 | states: |
| 16 | 22 | ||
| 17 | System Sleep model: | 23 | System Sleep model: |
| 18 | Drivers can enter low power states as part of entering system-wide | 24 | Drivers can enter low-power states as part of entering system-wide |
| 19 | low-power states like "suspend-to-ram", or (mostly for systems with | 25 | low-power states like "suspend" (also known as "suspend-to-RAM"), or |
| 20 | disks) "hibernate" (suspend-to-disk). | 26 | (mostly for systems with disks) "hibernation" (also known as |
| 27 | "suspend-to-disk"). | ||
| 21 | 28 | ||
| 22 | This is something that device, bus, and class drivers collaborate on | 29 | This is something that device, bus, and class drivers collaborate on |
| 23 | by implementing various role-specific suspend and resume methods to | 30 | by implementing various role-specific suspend and resume methods to |
| @@ -25,33 +32,41 @@ states: | |||
| 25 | them without loss of data. | 32 | them without loss of data. |
| 26 | 33 | ||
| 27 | Some drivers can manage hardware wakeup events, which make the system | 34 | Some drivers can manage hardware wakeup events, which make the system |
| 28 | leave that low-power state. This feature may be disabled using the | 35 | leave the low-power state. This feature may be enabled or disabled |
| 29 | relevant /sys/devices/.../power/wakeup file; enabling it may cost some | 36 | using the relevant /sys/devices/.../power/wakeup file (for Ethernet |
| 30 | power usage, but let the whole system enter low power states more often. | 37 | drivers the ioctl interface used by ethtool may also be used for this |
| 38 | purpose); enabling it may cost some power usage, but let the whole | ||
| 39 | system enter low-power states more often. | ||
| 31 | 40 | ||
| 32 | Runtime Power Management model: | 41 | Runtime Power Management model: |
| 33 | Drivers may also enter low power states while the system is running, | 42 | Devices may also be put into low-power states while the system is |
| 34 | independently of other power management activity. Upstream drivers | 43 | running, independently of other power management activity in principle. |
| 35 | will normally not know (or care) if the device is in some low power | 44 | However, devices are not generally independent of each other (for |
| 36 | state when issuing requests; the driver will auto-resume anything | 45 | example, a parent device cannot be suspended unless all of its child |
| 37 | that's needed when it gets a request. | 46 | devices have been suspended). Moreover, depending on the bus type the |
| 38 | 47 | device is on, it may be necessary to carry out some bus-specific | |
| 39 | This doesn't have, or need much infrastructure; it's just something you | 48 | operations on the device for this purpose. Devices put into low power |
| 40 | should do when writing your drivers. For example, clk_disable() unused | 49 | states at run time may require special handling during system-wide power |
| 41 | clocks as part of minimizing power drain for currently-unused hardware. | 50 | transitions (suspend or hibernation). |
| 42 | Of course, sometimes clusters of drivers will collaborate with each | 51 | |
| 43 | other, which could involve task-specific power management. | 52 | For these reasons not only the device driver itself, but also the |
| 44 | 53 | appropriate subsystem (bus type, device type or device class) driver and | |
| 45 | There's not a lot to be said about those low power states except that they | 54 | the PM core are involved in runtime power management. As in the system |
| 46 | are very system-specific, and often device-specific. Also, that if enough | 55 | sleep power management case, they need to collaborate by implementing |
| 47 | drivers put themselves into low power states (at "runtime"), the effect may be | 56 | various role-specific suspend and resume methods, so that the hardware |
| 48 | the same as entering some system-wide low-power state (system sleep) ... and | 57 | is cleanly powered down and reactivated without data or service loss. |
| 49 | that synergies exist, so that several drivers using runtime pm might put the | 58 | |
| 50 | system into a state where even deeper power saving options are available. | 59 | There's not a lot to be said about those low-power states except that they are |
| 51 | 60 | very system-specific, and often device-specific. Also, that if enough devices | |
| 52 | Most suspended devices will have quiesced all I/O: no more DMA or irqs, no | 61 | have been put into low-power states (at runtime), the effect may be very similar |
| 53 | more data read or written, and requests from upstream drivers are no longer | 62 | to entering some system-wide low-power state (system sleep) ... and that |
| 54 | accepted. A given bus or platform may have different requirements though. | 63 | synergies exist, so that several drivers using runtime PM might put the system |
| 64 | into a state where even deeper power saving options are available. | ||
| 65 | |||
| 66 | Most suspended devices will have quiesced all I/O: no more DMA or IRQs (except | ||
| 67 | for wakeup events), no more data read or written, and requests from upstream | ||
| 68 | drivers are no longer accepted. A given bus or platform may have different | ||
| 69 | requirements though. | ||
| 55 | 70 | ||
| 56 | Examples of hardware wakeup events include an alarm from a real time clock, | 71 | Examples of hardware wakeup events include an alarm from a real time clock, |
| 57 | network wake-on-LAN packets, keyboard or mouse activity, and media insertion | 72 | network wake-on-LAN packets, keyboard or mouse activity, and media insertion |
| @@ -60,129 +75,152 @@ or removal (for PCMCIA, MMC/SD, USB, and so on). | |||
| 60 | 75 | ||
| 61 | Interfaces for Entering System Sleep States | 76 | Interfaces for Entering System Sleep States |
| 62 | =========================================== | 77 | =========================================== |
| 63 | Most of the programming interfaces a device driver needs to know about | 78 | There are programming interfaces provided for subsystems (bus type, device type, |
| 64 | relate to that first model: entering a system-wide low power state, | 79 | device class) and device drivers to allow them to participate in the power |
| 65 | rather than just minimizing power consumption by one device. | 80 | management of devices they are concerned with. These interfaces cover both |
| 66 | 81 | system sleep and runtime power management. | |
| 67 | 82 | ||
| 68 | Bus Driver Methods | 83 | |
| 69 | ------------------ | 84 | Device Power Management Operations |
| 70 | The core methods to suspend and resume devices reside in struct bus_type. | 85 | ---------------------------------- |
| 71 | These are mostly of interest to people writing infrastructure for busses | 86 | Device power management operations, at the subsystem level as well as at the |
| 72 | like PCI or USB, or because they define the primitives that device drivers | 87 | device driver level, are implemented by defining and populating objects of type |
| 73 | may need to apply in domain-specific ways to their devices: | 88 | struct dev_pm_ops: |
| 74 | 89 | ||
| 75 | struct bus_type { | 90 | struct dev_pm_ops { |
| 76 | ... | 91 | int (*prepare)(struct device *dev); |
| 77 | int (*suspend)(struct device *dev, pm_message_t state); | 92 | void (*complete)(struct device *dev); |
| 78 | int (*resume)(struct device *dev); | 93 | int (*suspend)(struct device *dev); |
| 94 | int (*resume)(struct device *dev); | ||
| 95 | int (*freeze)(struct device *dev); | ||
| 96 | int (*thaw)(struct device *dev); | ||
| 97 | int (*poweroff)(struct device *dev); | ||
| 98 | int (*restore)(struct device *dev); | ||
| 99 | int (*suspend_noirq)(struct device *dev); | ||
| 100 | int (*resume_noirq)(struct device *dev); | ||
