Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: power: convert docs to ReST and rename to *.rst

Convert the PM documents to ReST, in order to allow them to
build with Sphinx.

The conversion is actually:
- add blank lines and indentation in order to identify paragraphs;
- fix tables markups;
- add some lists markups;
- mark literal blocks;
- adjust title markups.

At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Srivatsa S. Bhat (VMware) <srivatsa@csail.mit.edu>

authored by

Mauro Carvalho Chehab and committed by
Bjorn Helgaas
151f4e2b 9595aee2

+2127 -1706
+1 -1
Documentation/ABI/testing/sysfs-class-powercap
··· 5 5 Description: 6 6 The powercap/ class sub directory belongs to the power cap 7 7 subsystem. Refer to 8 - Documentation/power/powercap/powercap.txt for details. 8 + Documentation/power/powercap/powercap.rst for details. 9 9 10 10 What: /sys/class/powercap/<control type> 11 11 Date: September 2013
+3 -3
Documentation/admin-guide/kernel-parameters.txt
··· 13 13 For ARM64, ONLY "acpi=off", "acpi=on" or "acpi=force" 14 14 are available 15 15 16 - See also Documentation/power/runtime_pm.txt, pci=noacpi 16 + See also Documentation/power/runtime_pm.rst, pci=noacpi 17 17 18 18 acpi_apic_instance= [ACPI, IOAPIC] 19 19 Format: <int> ··· 223 223 acpi_sleep= [HW,ACPI] Sleep options 224 224 Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig, 225 225 old_ordering, nonvs, sci_force_enable, nobl } 226 - See Documentation/power/video.txt for information on 226 + See Documentation/power/video.rst for information on 227 227 s3_bios and s3_mode. 228 228 s3_beep is for debugging; it makes the PC's speaker beep 229 229 as soon as the kernel's real-mode entry point is called. ··· 4108 4108 Specify the offset from the beginning of the partition 4109 4109 given by "resume=" at which the swap header is located, 4110 4110 in <PAGE_SIZE> units (needed only for swap files). 4111 - See Documentation/power/swsusp-and-swap-files.txt 4111 + See Documentation/power/swsusp-and-swap-files.rst 4112 4112 4113 4113 resumedelay= [HIBERNATION] Delay (in seconds) to pause before attempting to 4114 4114 read the resume files
+1 -1
Documentation/cpu-freq/core.txt
··· 95 95 96 96 3. CPUFreq Table Generation with Operating Performance Point (OPP) 97 97 ================================================================== 98 - For details about OPP, see Documentation/power/opp.txt 98 + For details about OPP, see Documentation/power/opp.rst 99 99 100 100 dev_pm_opp_init_cpufreq_table - 101 101 This function provides a ready to use conversion routine to translate
+3 -3
Documentation/driver-api/pm/devices.rst
··· 225 225 flag is clear. 226 226 227 227 For more information about the runtime power management framework, refer to 228 - :file:`Documentation/power/runtime_pm.txt`. 228 + :file:`Documentation/power/runtime_pm.rst`. 229 229 230 230 231 231 Calling Drivers to Enter and Leave System Sleep States ··· 728 728 729 729 Devices may be defined as IRQ-safe which indicates to the PM core that their 730 730 runtime PM callbacks may be invoked with disabled interrupts (see 731 - :file:`Documentation/power/runtime_pm.txt` for more information). If an 731 + :file:`Documentation/power/runtime_pm.rst` for more information). If an 732 732 IRQ-safe device belongs to a PM domain, the runtime PM of the domain will be 733 733 disallowed, unless the domain itself is defined as IRQ-safe. However, it 734 734 makes sense to define a PM domain as IRQ-safe only if all the devices in it ··· 795 795 status in that case. 796 796 797 797 During system-wide resume from a sleep state it's easiest to put devices into 798 - the full-power state, as explained in :file:`Documentation/power/runtime_pm.txt`. 798 + the full-power state, as explained in :file:`Documentation/power/runtime_pm.rst`. 799 799 [Refer to that document for more information regarding this particular issue as 800 800 well as for information on the device runtime power management framework in 801 801 general.]
+1 -1
Documentation/driver-api/usb/power-management.rst
··· 46 46 call it a "dynamic suspend" (also known as a "runtime suspend" or 47 47 "selective suspend"). This document concentrates mostly on how 48 48 dynamic PM is implemented in the USB subsystem, although system PM is 49 - covered to some extent (see ``Documentation/power/*.txt`` for more 49 + covered to some extent (see ``Documentation/power/*.rst`` for more 50 50 information about system PM). 51 51 52 52 System PM support is present only if the kernel was built with
+7 -3
Documentation/power/apm-acpi.txt Documentation/power/apm-acpi.rst
··· 1 + ============ 1 2 APM or ACPI? 2 - ------------ 3 + ============ 4 + 3 5 If you have a relatively recent x86 mobile, desktop, or server system, 4 6 odds are it supports either Advanced Power Management (APM) or 5 7 Advanced Configuration and Power Interface (ACPI). ACPI is the newer ··· 30 28 Go ahead and start both. If ACPI or APM is not available on your 31 29 system the associated daemon will exit gracefully. 32 30 33 - apmd: http://ftp.debian.org/pool/main/a/apmd/ 34 - acpid: http://acpid.sf.net/ 31 + ===== ======================================= 32 + apmd http://ftp.debian.org/pool/main/a/apmd/ 33 + acpid http://acpid.sf.net/ 34 + ===== =======================================
+47 -32
Documentation/power/basic-pm-debugging.txt Documentation/power/basic-pm-debugging.rst
··· 1 + ================================= 1 2 Debugging hibernation and suspend 3 + ================================= 4 + 2 5 (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL 3 6 4 7 1. Testing hibernation (aka suspend to disk or STD) 8 + =================================================== 5 9 6 - To check if hibernation works, you can try to hibernate in the "reboot" mode: 10 + To check if hibernation works, you can try to hibernate in the "reboot" mode:: 7 11 8 - # echo reboot > /sys/power/disk 9 - # echo disk > /sys/power/state 12 + # echo reboot > /sys/power/disk 13 + # echo disk > /sys/power/state 10 14 11 15 and the system should create a hibernation image, reboot, resume and get back to 12 16 the command prompt where you have started the transition. If that happens, ··· 19 15 because some problems only show up on a second attempt at suspending and 20 16 resuming the system.] Moreover, hibernating in the "reboot" and "shutdown" 21 17 modes causes the PM core to skip some platform-related callbacks which on ACPI 22 - systems might be necessary to make hibernation work. Thus, if your machine fails 23 - to hibernate or resume in the "reboot" mode, you should try the "platform" mode: 18 + systems might be necessary to make hibernation work. Thus, if your machine 19 + fails to hibernate or resume in the "reboot" mode, you should try the 20 + "platform" mode:: 24 21 25 - # echo platform > /sys/power/disk 26 - # echo disk > /sys/power/state 22 + # echo platform > /sys/power/disk 23 + # echo disk > /sys/power/state 27 24 28 25 which is the default and recommended mode of hibernation. 29 26 30 27 Unfortunately, the "platform" mode of hibernation does not work on some systems 31 28 with broken BIOSes. In such cases the "shutdown" mode of hibernation might 32 - work: 29 + work:: 33 30 34 - # echo shutdown > /sys/power/disk 35 - # echo disk > /sys/power/state 31 + # echo shutdown > /sys/power/disk 32 + # echo disk > /sys/power/state 36 33 37 34 (it is similar to the "reboot" mode, but it requires you to press the power 38 35 button to make the system resume). ··· 42 37 identify what goes wrong. 43 38 44 39 a) Test modes of hibernation 40 + ---------------------------- 45 41 46 42 To find out why hibernation fails on your system, you can use a special testing 47 43 facility available if the kernel is compiled with CONFIG_PM_DEBUG set. Then, ··· 50 44 core run in a test mode. There are 5 test modes available: 51 45 52 46 freezer 53 - - test the freezing of processes 47 + - test the freezing of processes 54 48 55 49 devices 56 - - test the freezing of processes and suspending of devices 50 + - test the freezing of processes and suspending of devices 57 51 58 52 platform 59 - - test the freezing of processes, suspending of devices and platform 60 - global control methods(*) 53 + - test the freezing of processes, suspending of devices and platform 54 + global control methods [1]_ 61 55 62 56 processors 63 - - test the freezing of processes, suspending of devices, platform 64 - global control methods(*) and the disabling of nonboot CPUs 57 + - test the freezing of processes, suspending of devices, platform 58 + global control methods [1]_ and the disabling of nonboot CPUs 65 59 66 60 core 67 - - test the freezing of processes, suspending of devices, platform global 68 - control methods(*), the disabling of nonboot CPUs and suspending of 69 - platform/system devices 61 + - test the freezing of processes, suspending of devices, platform global 62 + control methods\ [1]_, the disabling of nonboot CPUs and suspending 63 + of platform/system devices 70 64 71 - (*) the platform global control methods are only available on ACPI systems 65 + .. [1] 66 + 67 + the platform global control methods are only available on ACPI systems 72 68 and are only tested if the hibernation mode is set to "platform" 73 69 74 70 To use one of them it is necessary to write the corresponding string to 75 71 /sys/power/pm_test (eg. "devices" to test the freezing of processes and 76 72 suspending devices) and issue the standard hibernation commands. For example, 77 73 to use the "devices" test mode along with the "platform" mode of hibernation, 78 - you should do the following: 74 + you should do the following:: 79 75 80 - # echo devices > /sys/power/pm_test 81 - # echo platform > /sys/power/disk 82 - # echo disk > /sys/power/state 76 + # echo devices > /sys/power/pm_test 77 + # echo platform > /sys/power/disk 78 + # echo disk > /sys/power/state 83 79 84 80 Then, the kernel will try to freeze processes, suspend devices, wait a few 85 81 seconds (5 by default, but configurable by the suspend.pm_test_delay module ··· 116 108 or resume its device (in the latter case the system may hang or become unstable 117 109 after the test, so please take that into consideration). To find this driver, 118 110 you can carry out a binary search according to the rules: 111 + 119 112 - if the test fails, unload a half of the drivers currently loaded and repeat 120 - (that would probably involve rebooting the system, so always note what drivers 121 - have been loaded before the test), 113 + (that would probably involve rebooting the system, so always note what drivers 114 + have been loaded before the test), 122 115 - if the test succeeds, load a half of the drivers you have unloaded most 123 - recently and repeat. 116 + recently and repeat. 124 117 125 118 Once you have found the failing driver (there can be more than just one of 126 119 them), you have to unload it every time before hibernation. In that case please ··· 155 146 please report it anyway. 156 147 157 148 b) Testing minimal configuration 149 + -------------------------------- 158 150 159 151 If all of the hibernation test modes work, you can boot the system with the 160 152 "init=/bin/bash" command line parameter and attempt to hibernate in the ··· 175 165 before hibernation, and please report the problem with it(them). 176 166 177 167 c) Using the "test_resume" hibernation option 168 + --------------------------------------------- 178 169 179 170 /sys/power/disk generally tells the kernel what to do after creating a 180 171 hibernation image. One of the available options is "test_resume" which 181 172 causes the just created image to be used for immediate restoration. Namely, 182 - after doing: 173 + after doing:: 183 174 184 - # echo test_resume > /sys/power/disk 185 - # echo disk > /sys/power/state 175 + # echo test_resume > /sys/power/disk 176 + # echo disk > /sys/power/state 186 177 187 178 a hibernation image will be created and a resume from it will be triggered 188 179 immediately without involving the platform firmware in any way. ··· 201 190 kernels. 202 191 203 192 d) Advanced debugging 193 + --------------------- 204 194 205 195 In case that hibernation does not work on your system even in the minimal 206 196 configuration and compiling more drivers as modules is not practical or some ··· 212 200 information about the reasons of the suspend (resume) failure. Alternatively, 213 201 it may be possible to use a FireWire port for debugging with firescope 214 202 (http://v3.sk/~lkundrak/firescope/). On x86 it is also possible to 215 - use the PM_TRACE mechanism documented in Documentation/power/s2ram.txt . 203 + use the PM_TRACE mechanism documented in Documentation/power/s2ram.rst . 216 204 217 205 2. Testing suspend to RAM (STR) 206 + =============================== 218 207 219 208 To verify that the STR works, it is generally more convenient to use the s2ram 220 209 tool available from http://suspend.sf.net and documented at ··· 243 230 you run s2ram), and please report the problems with them. 244 231 245 232 There is a debugfs entry which shows the suspend to RAM statistics. Here is an 246 - example of its output. 233 + example of its output:: 234 + 247 235 # mount -t debugfs none /sys/kernel/debug 248 236 # cat /sys/kernel/debug/suspend_stats 249 237 success: 20 ··· 262 248 -16 263 249 last_failed_step: suspend 264 250 suspend 251 + 265 252 Field success means the success number of suspend to RAM, and field fail means 266 253 the failure number. Others are the failure number of different steps of suspend 267 254 to RAM. suspend_stats just lists the last 2 failed devices, error number and
+53 -48
Documentation/power/charger-manager.txt Documentation/power/charger-manager.rst
··· 1 + =============== 1 2 Charger Manager 3 + =============== 4 + 2 5 (C) 2011 MyungJoo Ham <myungjoo.ham@samsung.com>, GPL 3 6 4 7 Charger Manager provides in-kernel battery charger management that ··· 58 55 notification to users with UEVENT. 59 56 60 57 2. Global Charger-Manager Data related with suspend_again 61 - ======================================================== 58 + ========================================================= 62 59 In order to setup Charger Manager with suspend-again feature 63 60 (in-suspend monitoring), the user should provide charger_global_desc 64 - with setup_charger_manager(struct charger_global_desc *). 61 + with setup_charger_manager(`struct charger_global_desc *`). 65 62 This charger_global_desc data for in-suspend monitoring is global 66 63 as the name suggests. Thus, the user needs to provide only once even 67 64 if there are multiple batteries. If there are multiple batteries, the 68 65 multiple instances of Charger Manager share the same charger_global_desc 69 66 and it will manage in-suspend monitoring for all instances of Charger Manager. 70 67 71 - The user needs to provide all the three entries properly in order to activate 72 - in-suspend monitoring: 68 + The user needs to provide all the three entries to `struct charger_global_desc` 69 + properly in order to activate in-suspend monitoring: 73 70 74 - struct charger_global_desc { 75 - 76 - char *rtc_name; 77 - : The name of rtc (e.g., "rtc0") used to wakeup the system from 71 + `char *rtc_name;` 72 + The name of rtc (e.g., "rtc0") used to wakeup the system from 78 73 suspend for Charger Manager. The alarm interrupt (AIE) of the rtc 79 74 should be able to wake up the system from suspend. Charger Manager 80 75 saves and restores the alarm value and use the previously-defined 81 76 alarm if it is going to go off earlier than Charger Manager so that 82 77 Charger Manager does not interfere with previously-defined alarms. 83 78 84 - bool (*rtc_only_wakeup)(void); 85 - : This callback should let CM know whether 79 + `bool (*rtc_only_wakeup)(void);` 80 + This callback should let CM know whether 86 81 the wakeup-from-suspend is caused only by the alarm of "rtc" in the 87 82 same struct. If there is any other wakeup source triggered the 88 83 wakeup, it should return false. If the "rtc" is the only wakeup 89 84 reason, it should return true. 90 85 91 - bool assume_timer_stops_in_suspend; 92 - : if true, Charger Manager assumes that 86 + `bool assume_timer_stops_in_suspend;` 87 + if true, Charger Manager assumes that 93 88 the timer (CM uses jiffies as timer) stops during suspend. Then, CM 94 89 assumes that the suspend-duration is same as the alarm length. 95 - }; 90 + 96 91 97 92 3. How to setup suspend_again 98 93 ============================= ··· 110 109 ============================================= 111 110 For each battery charged independently from other batteries (if a series of 112 111 batteries are charged by a single charger, they are counted as one independent 113 - battery), an instance of Charger Manager is attached to it. 112 + battery), an instance of Charger Manager is attached to it. The following 114 113 115 - struct charger_desc { 114 + struct charger_desc elements: 116 115 117 - char *psy_name; 118 - : The power-supply-class name of the battery. Default is 116 + `char *psy_name;` 117 + The power-supply-class name of the battery. Default is 119 118 "battery" if psy_name is NULL. Users can access the psy entries 120 119 at "/sys/class/power_supply/[psy_name]/". 121 120 122 - enum polling_modes polling_mode; 123 - : CM_POLL_DISABLE: do not poll this battery. 124 - CM_POLL_ALWAYS: always poll this battery. 125 - CM_POLL_EXTERNAL_POWER_ONLY: poll this battery if and only if 126 - an external power source is attached. 127 - CM_POLL_CHARGING_ONLY: poll this battery if and only if the 128 - battery is being charged. 121 + `enum polling_modes polling_mode;` 122 + CM_POLL_DISABLE: 123 + do not poll this battery. 124 + CM_POLL_ALWAYS: 125 + always poll this battery. 126 + CM_POLL_EXTERNAL_POWER_ONLY: 127 + poll this battery if and only if an external power 128 + source is attached. 129 + CM_POLL_CHARGING_ONLY: 130 + poll this battery if and only if the battery is being charged. 129 131 130 - unsigned int fullbatt_vchkdrop_ms; 131 - unsigned int fullbatt_vchkdrop_uV; 132 - : If both have non-zero values, Charger Manager will check the 132 + `unsigned int fullbatt_vchkdrop_ms; / unsigned int fullbatt_vchkdrop_uV;` 133 + If both have non-zero values, Charger Manager will check the 133 134 battery voltage drop fullbatt_vchkdrop_ms after the battery is fully 134 135 charged. If the voltage drop is over fullbatt_vchkdrop_uV, Charger 135 136 Manager will try to recharge the battery by disabling and enabling ··· 139 136 condition) is needed to be implemented with hardware interrupts from 140 137 fuel gauges or charger devices/chips. 141 138 142 - unsigned int fullbatt_uV; 143 - : If specified with a non-zero value, Charger Manager assumes 139 + `unsigned int fullbatt_uV;` 140 + If specified with a non-zero value, Charger Manager assumes 144 141 that the battery is full (capacity = 100) if the battery is not being 145 142 charged and the battery voltage is equal to or greater than 146 143 fullbatt_uV. 147 144 148 - unsigned int polling_interval_ms; 149 - : Required polling interval in ms. Charger Manager will poll 145 + `unsigned int polling_interval_ms;` 146 + Required polling interval in ms. Charger Manager will poll 150 147 this battery every polling_interval_ms or more frequently. 151 148 152 - enum data_source battery_present; 153 - : CM_BATTERY_PRESENT: assume that the battery exists. 154 - CM_NO_BATTERY: assume that the battery does not exists. 155 - CM_FUEL_GAUGE: get battery presence information from fuel gauge. 156 - CM_CHARGER_STAT: get battery presence from chargers. 149 + `enum data_source battery_present;` 150 + CM_BATTERY_PRESENT: 151 + assume that the battery exists. 152 + CM_NO_BATTERY: 153 + assume that the battery does not exists. 154 + CM_FUEL_GAUGE: 155 + get battery presence information from fuel gauge. 156 + CM_CHARGER_STAT: 157 + get battery presence from chargers. 157 158 158 - char **psy_charger_stat; 159 - : An array ending with NULL that has power-supply-class names of 159 + `char **psy_charger_stat;` 160 + An array ending with NULL that has power-supply-class names of 160 161 chargers. Each power-supply-class should provide "PRESENT" (if 161 162 battery_present is "CM_CHARGER_STAT"), "ONLINE" (shows whether an 162 163 external power source is attached or not), and "STATUS" (shows whether 163 164 the battery is {"FULL" or not FULL} or {"FULL", "Charging", 164 165 "Discharging", "NotCharging"}). 165 166 166 - int num_charger_regulators; 167 - struct regulator_bulk_data *charger_regulators; 168 - : Regulators representing the chargers in the form for 167 + `int num_charger_regulators; / struct regulator_bulk_data *charger_regulators;` 168 + Regulators representing the chargers in the form for 169 169 regulator framework's bulk functions. 170 170 171 - char *psy_fuel_gauge; 172 - : Power-supply-class name of the fuel gauge. 171 + `char *psy_fuel_gauge;` 172 + Power-supply-class name of the fuel gauge. 173 173 174 - int (*temperature_out_of_range)(int *mC); 175 - bool measure_battery_temp; 176 - : This callback returns 0 if the temperature is safe for charging, 174 + `int (*temperature_out_of_range)(int *mC); / bool measure_battery_temp;` 175 + This callback returns 0 if the temperature is safe for charging, 177 176 a positive number if it is too hot to charge, and a negative number 178 177 if it is too cold to charge. With the variable mC, the callback returns 179 178 the temperature in 1/1000 of centigrade. 180 179 The source of temperature can be battery or ambient one according to 181 180 the value of measure_battery_temp. 182 - }; 181 + 183 182 184 183 5. Notify Charger-Manager of charger events: cm_notify_event() 185 - ========================================================= 184 + ============================================================== 186 185 If there is an charger event is required to notify 187 186 Charger Manager, a charger device driver that triggers the event can call 188 187 cm_notify_event(psy, type, msg) to notify the corresponding Charger Manager.
+10 -5
Documentation/power/drivers-testing.txt Documentation/power/drivers-testing.rst
··· 1 + ==================================================== 1 2 Testing suspend and resume support in device drivers 3 + ==================================================== 4 + 2 5 (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL 3 6 4 7 1. Preparing the test system 8 + ============================ 5 9 6 10 Unfortunately, to effectively test the support for the system-wide suspend and 7 11 resume transitions in a driver, it is necessary to suspend and resume a fully ··· 18 14 Of course, for this purpose the test system has to be known to suspend and 19 15 resume without the driver being tested. Thus, if possible, you should first 20 16 resolve all suspend/resume-related problems in the test system before you start 21 - testing the new driver. Please see Documentation/power/basic-pm-debugging.txt 17 + testing the new driver. Please see Documentation/power/basic-pm-debugging.rst 22 18 for more information about the debugging of suspend/resume functionality. 23 19 24 20 2. Testing the driver 21 + ===================== 25 22 26 23 Once you have resolved the suspend/resume-related problems with your test system 27 24 without the new driver, you are ready to test it: 28 25 29 26 a) Build the driver as a module, load it and try the test modes of hibernation 30 - (see: Documentation/power/basic-pm-debugging.txt, 1). 27 + (see: Documentation/power/basic-pm-debugging.rst, 1). 31 28 32 29 b) Load the driver and attempt to hibernate in the "reboot", "shutdown" and 33 - "platform" modes (see: Documentation/power/basic-pm-debugging.txt, 1). 30 + "platform" modes (see: Documentation/power/basic-pm-debugging.rst, 1). 34 31 35 32 c) Compile the driver directly into the kernel and try the test modes of 36 33 hibernation. ··· 39 34 d) Attempt to hibernate with the driver compiled directly into the kernel 40 35 in the "reboot", "shutdown" and "platform" modes. 41 36 42 - e) Try the test modes of suspend (see: Documentation/power/basic-pm-debugging.txt, 37 + e) Try the test modes of suspend (see: Documentation/power/basic-pm-debugging.rst, 43 38 2). [As far as the STR tests are concerned, it should not matter whether or 44 39 not the driver is built as a module.] 45 40 46 41 f) Attempt to suspend to RAM using the s2ram tool with the driver loaded 47 - (see: Documentation/power/basic-pm-debugging.txt, 2). 42 + (see: Documentation/power/basic-pm-debugging.rst, 2). 48 43 49 44 Each of the above tests should be repeated several times and the STD tests 50 45 should be mixed with the STR tests. If any of them fails, the driver cannot be
+52 -49
Documentation/power/energy-model.txt Documentation/power/energy-model.rst
··· 1 - ==================== 2 - Energy Model of CPUs 3 - ==================== 1 + ==================== 2 + Energy Model of CPUs 3 + ==================== 4 4 5 5 1. Overview 6 6 ----------- ··· 20 20 21 21 The figure below depicts an example of drivers (Arm-specific here, but the 22 22 approach is applicable to any architecture) providing power costs to the EM 23 - framework, and interested clients reading the data from it. 23 + framework, and interested clients reading the data from it:: 24 24 25 25 +---------------+ +-----------------+ +---------------+ 26 26 | Thermal (IPA) | | Scheduler (EAS) | | Other | ··· 58 58 2. Core APIs 59 59 ------------ 60 60 61 - 2.1 Config options 61 + 2.1 Config options 62 + ^^^^^^^^^^^^^^^^^^ 62 63 63 64 CONFIG_ENERGY_MODEL must be enabled to use the EM framework. 64 65 65 66 66 - 2.2 Registration of performance domains 67 + 2.2 Registration of performance domains 68 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 69 68 70 Drivers are expected to register performance domains into the EM framework by 69 - calling the following API: 71 + calling the following API:: 70 72 71 73 int em_register_perf_domain(cpumask_t *span, unsigned int nr_states, 72 74 struct em_data_callback *cb); ··· 82 80 API. 83 81 84 82 85 - 2.3 Accessing performance domains 83 + 2.3 Accessing performance domains 84 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 86 85 87 86 Subsystems interested in the energy model of a CPU can retrieve it using the 88 87 em_cpu_get() API. The energy model tables are allocated once upon creation of ··· 102 99 This section provides a simple example of a CPUFreq driver registering a 103 100 performance domain in the Energy Model framework using the (fake) 'foo' 104 101 protocol. The driver implements an est_power() function to be provided to the 105 - EM framework. 102 + EM framework:: 106 103 107 - -> drivers/cpufreq/foo_cpufreq.c 104 + -> drivers/cpufreq/foo_cpufreq.c 108 105 109 - 01 static int est_power(unsigned long *mW, unsigned long *KHz, int cpu) 110 - 02 { 111 - 03 long freq, power; 112 - 04 113 - 05 /* Use the 'foo' protocol to ceil the frequency */ 114 - 06 freq = foo_get_freq_ceil(cpu, *KHz); 115 - 07 if (freq < 0); 116 - 08 return freq; 117 - 09 118 - 10 /* Estimate the power cost for the CPU at the relevant freq. */ 119 - 11 power = foo_estimate_power(cpu, freq); 120 - 12 if (power < 0); 121 - 13 return power; 122 - 14 123 - 15 /* Return the values to the EM framework */ 124 - 16 *mW = power; 125 - 17 *KHz = freq; 126 - 18 127 - 19 return 0; 128 - 20 } 129 - 21 130 - 22 static int foo_cpufreq_init(struct cpufreq_policy *policy) 131 - 23 { 132 - 24 struct em_data_callback em_cb = EM_DATA_CB(est_power); 133 - 25 int nr_opp, ret; 134 - 26 135 - 27 /* Do the actual CPUFreq init work ... */ 136 - 28 ret = do_foo_cpufreq_init(policy); 137 - 29 if (ret) 138 - 30 return ret; 139 - 31 140 - 32 /* Find the number of OPPs for this policy */ 141 - 33 nr_opp = foo_get_nr_opp(policy); 142 - 34 143 - 35 /* And register the new performance domain */ 144 - 36 em_register_perf_domain(policy->cpus, nr_opp, &em_cb); 145 - 37 146 - 38 return 0; 147 - 39 } 106 + 01 static int est_power(unsigned long *mW, unsigned long *KHz, int cpu) 107 + 02 { 108 + 03 long freq, power; 109 + 04 110 + 05 /* Use the 'foo' protocol to ceil the frequency */ 111 + 06 freq = foo_get_freq_ceil(cpu, *KHz); 112 + 07 if (freq < 0); 113 + 08 return freq; 114 + 09 115 + 10 /* Estimate the power cost for the CPU at the relevant freq. */ 116 + 11 power = foo_estimate_power(cpu, freq); 117 + 12 if (power < 0); 118 + 13 return power; 119 + 14 120 + 15 /* Return the values to the EM framework */ 121 + 16 *mW = power; 122 + 17 *KHz = freq; 123 + 18 124 + 19 return 0; 125 + 20 } 126 + 21 127 + 22 static int foo_cpufreq_init(struct cpufreq_policy *policy) 128 + 23 { 129 + 24 struct em_data_callback em_cb = EM_DATA_CB(est_power); 130 + 25 int nr_opp, ret; 131 + 26 132 + 27 /* Do the actual CPUFreq init work ... */ 133 + 28 ret = do_foo_cpufreq_init(policy); 134 + 29 if (ret) 135 + 30 return ret; 136 + 31 137 + 32 /* Find the number of OPPs for this policy */ 138 + 33 nr_opp = foo_get_nr_opp(policy); 139 + 34 140 + 35 /* And register the new performance domain */ 141 + 36 em_register_perf_domain(policy->cpus, nr_opp, &em_cb); 142 + 37 143 + 38 return 0; 144 + 39 }
+52 -39
Documentation/power/freezing-of-tasks.txt Documentation/power/freezing-of-tasks.rst
··· 1 + ================= 1 2 Freezing of tasks 2 - (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL 3 + ================= 4 + 5 + (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL 3 6 4 7 I. What is the freezing of tasks? 8 + ================================= 5 9 6 10 The freezing of tasks is a mechanism by which user space processes and some 7 11 kernel threads are controlled during hibernation or system-wide suspend (on some 8 12 architectures). 9 13 10 14 II. How does it work? 15 + ===================== 11 16 12 17 There are three per-task flags used for that, PF_NOFREEZE, PF_FROZEN 13 18 and PF_FREEZER_SKIP (the last one is auxiliary). The tasks that have ··· 46 41 wait_event_freezable_timeout() macros (defined in include/linux/freezer.h) 47 42 that combine interruptible sleep with checking if the task is to be frozen and 48 43 calling try_to_freeze(). The main loop of a freezable kernel thread may look 49 - like the following one: 44 + like the following one:: 50 45 51 46 set_freezable(); 52 47 do { ··· 70 65 have been frozen leave __refrigerator() and continue running. 71 66 72 67 73 - Rationale behind the functions dealing with freezing and thawing of tasks: 68 + Rationale behind the functions dealing with freezing and thawing of tasks 74 69 ------------------------------------------------------------------------- 75 70 76 71 freeze_processes(): ··· 91 86 92 87 93 88 III. Which kernel threads are freezable? 89 + ======================================== 94 90 95 91 Kernel threads are not freezable by default. However, a kernel thread may clear 96 92 PF_NOFREEZE for itself by calling set_freezable() (the resetting of PF_NOFREEZE ··· 99 93 and must call try_to_freeze() in a suitable place. 100 94 101 95 IV. Why do we do that? 96 + ====================== 102 97 103 98 Generally speaking, there is a couple of reasons to use the freezing of tasks: 104 99 105 100 1. The principal reason is to prevent filesystems from being damaged after 106 - hibernation. At the moment we have no simple means of checkpointing 107 - filesystems, so if there are any modifications made to filesystem data and/or 108 - metadata on disks, we cannot bring them back to the state from before the 109 - modifications. At the same time each hibernation image contains some 110 - filesystem-related information that must be consistent with the state of the 111 - on-disk data and metadata after the system memory state has been restored from 112 - the image (otherwise the filesystems will be damaged in a nasty way, usually 113 - making them almost impossible to repair). We therefore freeze tasks that might 114 - cause the on-disk filesystems' data and metadata to be modified after the 115 - hibernation image has been created and before the system is finally powered off. 116 - The majority of these are user space processes, but if any of the kernel threads 117 - may cause something like this to happen, they have to be freezable. 101 + hibernation. At the moment we have no simple means of checkpointing 102 + filesystems, so if there are any modifications made to filesystem data and/or 103 + metadata on disks, we cannot bring them back to the state from before the 104 + modifications. At the same time each hibernation image contains some 105 + filesystem-related information that must be consistent with the state of the 106 + on-disk data and metadata after the system memory state has been restored 107 + from the image (otherwise the filesystems will be damaged in a nasty way, 108 + usually making them almost impossible to repair). We therefore freeze 109 + tasks that might cause the on-disk filesystems' data and metadata to be 110 + modified after the hibernation image has been created and before the 111 + system is finally powered off. The majority of these are user space 112 + processes, but if any of the kernel threads may cause something like this 113 + to happen, they have to be freezable. 118 114 119 115 2. Next, to create the hibernation image we need to free a sufficient amount of 120 - memory (approximately 50% of available RAM) and we need to do that before 121 - devices are deactivated, because we generally need them for swapping out. Then, 122 - after the memory for the image has been freed, we don't want tasks to allocate 123 - additional memory and we prevent them from doing that by freezing them earlier. 124 - [Of course, this also means that device drivers should not allocate substantial 125 - amounts of memory from their .suspend() callbacks before hibernation, but this 126 - is a separate issue.] 116 + memory (approximately 50% of available RAM) and we need to do that before 117 + devices are deactivated, because we generally need them for swapping out. 118 + Then, after the memory for the image has been freed, we don't want tasks 119 + to allocate additional memory and we prevent them from doing that by 120 + freezing them earlier. [Of course, this also means that device drivers 121 + should not allocate substantial amounts of memory from their .suspend() 122 + callbacks before hibernation, but this is a separate issue.] 127 123 128 124 3. The third reason is to prevent user space processes and some kernel threads 129 - from interfering with the suspending and resuming of devices. A user space 130 - process running on a second CPU while we are suspending devices may, for 131 - example, be troublesome and without the freezing of tasks we would need some 132 - safeguards against race conditions that might occur in such a case. 125 + from interfering with the suspending and resuming of devices. A user space 126 + process running on a second CPU while we are suspending devices may, for 127 + example, be troublesome and without the freezing of tasks we would need some 128 + safeguards against race conditions that might occur in such a case. 133 129 134 130 Although Linus Torvalds doesn't like the freezing of tasks, he said this in one 135 131 of the discussions on LKML (http://lkml.org/lkml/2007/4/27/608): ··· 140 132 141 133 Linus: In many ways, 'at all'. 142 134 143 - I _do_ realize the IO request queue issues, and that we cannot actually do 135 + I **do** realize the IO request queue issues, and that we cannot actually do 144 136 s2ram with some devices in the middle of a DMA. So we want to be able to 145 137 avoid *that*, there's no question about that. And I suspect that stopping 146 138 user threads and then waiting for a sync is practically one of the easier ··· 158 150 the device while it's suspended. 159 151 160 152 4. Another reason for freezing tasks is to prevent user space processes from 161 - realizing that hibernation (or suspend) operation takes place. Ideally, user 162 - space processes should not notice that such a system-wide operation has occurred 163 - and should continue running without any problems after the restore (or resume 164 - from suspend). Unfortunately, in the most general case this is quite difficult 165 - to achieve without the freezing of tasks. Consider, for example, a process 166 - that depends on all CPUs being online while it's running. Since we need to 167 - disable nonboot CPUs during the hibernation, if this process is not frozen, it 168 - may notice that the number of CPUs has changed and may start to work incorrectly 169 - because of that. 153 + realizing that hibernation (or suspend) operation takes place. Ideally, user 154 + space processes should not notice that such a system-wide operation has 155 + occurred and should continue running without any problems after the restore 156 + (or resume from suspend). Unfortunately, in the most general case this 157 + is quite difficult to achieve without the freezing of tasks. Consider, 158 + for example, a process that depends on all CPUs being online while it's 159 + running. Since we need to disable nonboot CPUs during the hibernation, 160 + if this process is not frozen, it may notice that the number of CPUs has 161 + changed and may start to work incorrectly because of that. 170 162 171 163 V. Are there any problems related to the freezing of tasks? 164 + =========================================================== 172 165 173 166 Yes, there are. 174 167 ··· 181 172 182 173 Second, there are the following two problems related to the freezing of user 183 174 space processes: 175 + 184 176 1. Putting processes into an uninterruptible sleep distorts the load average. 185 177 2. Now that we have FUSE, plus the framework for doing device drivers in 186 - userspace, it gets even more complicated because some userspace processes are 187 - now doing the sorts of things that kernel threads do 188 - (https://lists.linux-foundation.org/pipermail/linux-pm/2007-May/012309.html). 178 + userspace, it gets even more complicated because some userspace processes are 179 + now doing the sorts of things that kernel threads do 180 + (https://lists.linux-foundation.org/pipermail/linux-pm/2007-May/012309.html). 189 181 190 182 The problem 1. seems to be fixable, although it hasn't been fixed so far. The 191 183 other one is more serious, but it seems that we can work around it by using ··· 211 201 Documentation/driver-api/pm/notifiers.rst. 212 202 213 203 VI. Are there any precautions to be taken to prevent freezing failures? 204 + ======================================================================= 214 205 215 206 Yes, there are. 216 207 ··· 237 226 mutex_[un]lock(&system_transition_mutex). That would prevent freezing failures. 238 227 239 228 V. Miscellaneous 229 + ================ 230 + 240 231 /sys/power/pm_freeze_timeout controls how long it will cost at most to freeze 241 232 all user space processes or all freezable kernel threads, in unit of millisecond. 242 233 The default value is 20000, with range of unsigned integer.
+46
Documentation/power/index.rst
··· 1 + :orphan: 2 + 3 + ================ 4 + Power Management 5 + ================ 6 + 7 + .. toctree:: 8 + :maxdepth: 1 9 + 10 + apm-acpi 11 + basic-pm-debugging 12 + charger-manager 13 + drivers-testing 14 + energy-model 15 + freezing-of-tasks 16 + interface 17 + opp 18 + pci 19 + pm_qos_interface 20 + power_supply_class 21 + runtime_pm 22 + s2ram 23 + suspend-and-cpuhotplug 24 + suspend-and-interrupts 25 + swsusp-and-swap-files 26 + swsusp-dmcrypt 27 + swsusp 28 + video 29 + tricks 30 + 31 + userland-swsusp 32 + 33 + powercap/powercap 34 + 35 + regulator/consumer 36 + regulator/design 37 + regulator/machine 38 + regulator/overview 39 + regulator/regulator 40 + 41 + .. only:: subproject and html 42 + 43 + Indices 44 + ======= 45 + 46 + * :ref:`genindex`
+13 -11
Documentation/power/interface.txt Documentation/power/interface.rst
··· 1 + =========================================== 1 2 Power Management Interface for System Sleep 3 + =========================================== 2 4 3 5 Copyright (c) 2016 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> 4 6 ··· 13 11 14 12 Reading from it returns a list of supported sleep states, encoded as: 15 13 16 - 'freeze' (Suspend-to-Idle) 17 - 'standby' (Power-On Suspend) 18 - 'mem' (Suspend-to-RAM) 19 - 'disk' (Suspend-to-Disk) 14 + - 'freeze' (Suspend-to-Idle) 15 + - 'standby' (Power-On Suspend) 16 + - 'mem' (Suspend-to-RAM) 17 + - 'disk' (Suspend-to-Disk) 20 18 21 19 Suspend-to-Idle is always supported. Suspend-to-Disk is always supported 22 20 too as long the kernel has been configured to support hibernation at all ··· 34 32 35 33 Reading from it returns a list of supported options encoded as: 36 34 37 - 'platform' (put the system into sleep using a platform-provided method) 38 - 'shutdown' (shut the system down) 39 - 'reboot' (reboot the system) 40 - 'suspend' (trigger a Suspend-to-RAM transition) 41 - 'test_resume' (resume-after-hibernation test mode) 35 + - 'platform' (put the system into sleep using a platform-provided method) 36 + - 'shutdown' (shut the system down) 37 + - 'reboot' (reboot the system) 38 + - 'suspend' (trigger a Suspend-to-RAM transition) 39 + - 'test_resume' (resume-after-hibernation test mode) 42 40 43 41 The currently selected option is printed in square brackets. 44 42 45 43 The 'platform' option is only available if the platform provides a special 46 44 mechanism to put the system to sleep after creating a hibernation image (ACPI 47 45 does that, for example). The 'suspend' option is available if Suspend-to-RAM 48 - is supported. Refer to Documentation/power/basic-pm-debugging.txt for the 46 + is supported. Refer to Documentation/power/basic-pm-debugging.rst for the 49 47 description of the 'test_resume' option. 50 48 51 49 To select an option, write the string representing it to /sys/power/disk. ··· 73 71 event point in turn will be stored in the RTC memory (overwriting the actual 74 72 RTC information), so it will survive a system crash if one occurs right after 75 73 storing it and it can be used later to identify the driver that caused the crash 76 - to happen (see Documentation/power/s2ram.txt for more information). 74 + to happen (see Documentation/power/s2ram.rst for more information). 77 75 78 76 Initially it contains '0' which may be changed to '1' by writing a string 79 77 representing a nonzero integer into it.
+106 -69
Documentation/power/opp.txt Documentation/power/opp.rst
··· 1 + ========================================== 1 2 Operating Performance Points (OPP) Library 2 3 ========================================== 3 4 4 5 (C) 2009-2010 Nishanth Menon <nm@ti.com>, Texas Instruments Incorporated 5 6 6 - Contents 7 - -------- 8 - 1. Introduction 9 - 2. Initial OPP List Registration 10 - 3. OPP Search Functions 11 - 4. OPP Availability Control Functions 12 - 5. OPP Data Retrieval Functions 13 - 6. Data Structures 7 + .. Contents 8 + 9 + 1. Introduction 10 + 2. Initial OPP List Registration 11 + 3. OPP Search Functions 12 + 4. OPP Availability Control Functions 13 + 5. OPP Data Retrieval Functions 14 + 6. Data Structures 14 15 15 16 1. Introduction 16 17 =============== 18 + 17 19 1.1 What is an Operating Performance Point (OPP)? 20 + ------------------------------------------------- 18 21 19 22 Complex SoCs of today consists of a multiple sub-modules working in conjunction. 20 23 In an operational system executing varied use cases, not all modules in the SoC ··· 31 28 OPPs. 32 29 33 30 As an example: 31 + 34 32 Let us consider an MPU device which supports the following: 35 33 {300MHz at minimum voltage of 1V}, {800MHz at minimum voltage of 1.2V}, 36 34 {1GHz at minimum voltage of 1.3V} 37 35 38 36 We can represent these as three OPPs as the following {Hz, uV} tuples: 39 - {300000000, 1000000} 40 - {800000000, 1200000} 41 - {1000000000, 1300000} 37 + 38 + - {300000000, 1000000} 39 + - {800000000, 1200000} 40 + - {1000000000, 1300000} 42 41 43 42 1.2 Operating Performance Points Library 43 + ---------------------------------------- 44 44 45 45 OPP library provides a set of helper functions to organize and query the OPP 46 46 information. The library is located in drivers/base/power/opp.c and the header ··· 52 46 CONFIG_PM as certain SoCs such as Texas Instrument's OMAP framework allows to 53 47 optionally boot at a certain OPP without needing cpufreq. 54 48 55 - Typical usage of the OPP library is as follows: 56 - (users) -> registers a set of default OPPs -> (library) 57 - SoC framework -> modifies on required cases certain OPPs -> OPP layer 49 + Typical usage of the OPP library is as follows:: 50 + 51 + (users) -> registers a set of default OPPs -> (library) 52 + SoC framework -> modifies on required cases certain OPPs -> OPP layer 58 53 -> queries to search/retrieve information -> 59 54 60 55 OPP layer expects each domain to be represented by a unique device pointer. SoC ··· 64 57 This initial list contains a set of OPPs that the framework expects to be safely 65 58 enabled by default in the system. 66 59 67 - Note on OPP Availability: 68 - ------------------------ 60 + Note on OPP Availability 61 + ^^^^^^^^^^^^^^^^^^^^^^^^ 62 + 69 63 As the system proceeds to operate, SoC framework may choose to make certain 70 64 OPPs available or not available on each device based on various external 71 65 factors. Example usage: Thermal management or other exceptional situations where ··· 96 88 operation. The SoC framework can subsequently control the availability of the 97 89 OPPs dynamically using the dev_pm_opp_enable / disable functions. 98 90 99 - dev_pm_opp_add - Add a new OPP for a specific domain represented by the device pointer. 91 + dev_pm_opp_add 92 + Add a new OPP for a specific domain represented by the device pointer. 100 93 The OPP is defined using the frequency and voltage. Once added, the OPP 101 94 is assumed to be available and control of it's availability can be done 102 95 with the dev_pm_opp_enable/disable functions. OPP library internally stores ··· 105 96 used by SoC framework to define a optimal list as per the demands of 106 97 SoC usage environment. 107 98 108 - WARNING: Do not use this function in interrupt context. 99 + WARNING: 100 + Do not use this function in interrupt context. 109 101 110 - Example: 102 + Example:: 103 + 111 104 soc_pm_init() 112 105 { 113 106 /* Do things */ ··· 136 125 OPP. Otherwise the memory for the OPP will never get freed and result in 137 126 memleak. 138 127 139 - dev_pm_opp_find_freq_exact - Search for an OPP based on an *exact* frequency and 128 + dev_pm_opp_find_freq_exact 129 + Search for an OPP based on an *exact* frequency and 140 130 availability. This function is especially useful to enable an OPP which 141 131 is not available by default. 142 132 Example: In a case when SoC framework detects a situation where a 143 133 higher frequency could be made available, it can use this function to 144 - find the OPP prior to call the dev_pm_opp_enable to actually make it available. 134 + find the OPP prior to call the dev_pm_opp_enable to actually make 135 + it available:: 136 + 145 137 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false); 146 138 dev_pm_opp_put(opp); 147 139 /* dont operate on the pointer.. just do a sanity check.. */ ··· 155 141 dev_pm_opp_enable(dev,1000000000); 156 142 } 157 143 158 - NOTE: This is the only search function that operates on OPPs which are 159 - not available. 144 + NOTE: 145 + This is the only search function that operates on OPPs which are 146 + not available. 160 147 161 - dev_pm_opp_find_freq_floor - Search for an available OPP which is *at most* the 148 + dev_pm_opp_find_freq_floor 149 + Search for an available OPP which is *at most* the 162 150 provided frequency. This function is useful while searching for a lesser 163 151 match OR operating on OPP information in the order of decreasing 164 152 frequency. 165 - Example: To find the highest opp for a device: 153 + Example: To find the highest opp for a device:: 154 + 166 155 freq = ULONG_MAX; 167 156 opp = dev_pm_opp_find_freq_floor(dev, &freq); 168 157 dev_pm_opp_put(opp); 169 158 170 - dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the 159 + dev_pm_opp_find_freq_ceil 160 + Search for an available OPP which is *at least* the 171 161 provided frequency. This function is useful while searching for a 172 162 higher match OR operating on OPP information in the order of increasing 173 163 frequency. 174 - Example 1: To find the lowest opp for a device: 164 + Example 1: To find the lowest opp for a device:: 165 + 175 166 freq = 0; 176 167 opp = dev_pm_opp_find_freq_ceil(dev, &freq); 177 168 dev_pm_opp_put(opp); 178 - Example 2: A simplified implementation of a SoC cpufreq_driver->target: 169 + 170 + Example 2: A simplified implementation of a SoC cpufreq_driver->target:: 171 + 179 172 soc_cpufreq_target(..) 180 173 { 181 174 /* Do stuff like policy checks etc. */ ··· 205 184 These functions are intended to *temporarily* remove an OPP in conditions such 206 185 as thermal considerations (e.g. don't use OPPx until the temperature drops). 207 186 208 - WARNING: Do not use these functions in interrupt context. 187 + WARNING: 188 + Do not use these functions in interrupt context. 209 189 210 - dev_pm_opp_enable - Make a OPP available for operation. 190 + dev_pm_opp_enable 191 + Make a OPP available for operation. 211 192 Example: Lets say that 1GHz OPP is to be made available only if the 212 193 SoC temperature is lower than a certain threshold. The SoC framework 213 - implementation might choose to do something as follows: 194 + implementation might choose to do something as follows:: 195 + 214 196 if (cur_temp < temp_low_thresh) { 215 197 /* Enable 1GHz if it was disabled */ 216 198 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false); ··· 225 201 goto try_something_else; 226 202 } 227 203 228 - dev_pm_opp_disable - Make an OPP to be not available for operation 204 + dev_pm_opp_disable 205 + Make an OPP to be not available for operation 229 206 Example: Lets say that 1GHz OPP is to be disabled if the temperature 230 207 exceeds a threshold value. The SoC framework implementation might 231 - choose to do something as follows: 208 + choose to do something as follows:: 209 + 232 210 if (cur_temp > temp_high_thresh) { 233 211 /* Disable 1GHz if it was enabled */ 234 212 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, true); ··· 249 223 retrieved using the search functions, the following functions can be used by SoC 250 224 framework to retrieve the information represented inside the OPP layer. 251 225 252 - dev_pm_opp_get_voltage - Retrieve the voltage represented by the opp pointer. 226 + dev_pm_opp_get_voltage 227 + Retrieve the voltage represented by the opp pointer. 253 228 Example: At a cpufreq transition to a different frequency, SoC 254 229 framework requires to set the voltage represented by the OPP using 255 230 the regulator framework to the Power Management chip providing the 256 - voltage. 231 + voltage:: 232 + 257 233 soc_switch_to_freq_voltage(freq) 258 234 { 259 235 /* do things */ ··· 267 239 /* do other things */ 268 240 } 269 241 270 - dev_pm_opp_get_freq - Retrieve the freq represented by the opp pointer. 242 + dev_pm_opp_get_freq 243 + Retrieve the freq represented by the opp pointer. 271 244 Example: Lets say the SoC framework uses a couple of helper functions 272 245 we could pass opp pointers instead of doing additional parameters to 273 - handle quiet a bit of data parameters. 246 + handle quiet a bit of data parameters:: 247 + 274 248 soc_cpufreq_target(..) 275 249 { 276 250 /* do things.. */ ··· 294 264 /* do things.. */ 295 265 } 296 266 297 - dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device 267 + dev_pm_opp_get_opp_count 268 + Retrieve the number of available opps for a device 298 269 Example: Lets say a co-processor in the SoC needs to know the available 299 - frequencies in a table, the main processor can notify as following: 270 + frequencies in a table, the main processor can notify as following:: 271 + 300 272 soc_notify_coproc_available_frequencies() 301 273 { 302 274 /* Do things */ ··· 321 289 ================== 322 290 Typically an SoC contains multiple voltage domains which are variable. Each 323 291 domain is represented by a device pointer. The relationship to OPP can be 324 - represented as follows: 325 - SoC 326 - |- device 1 327 - | |- opp 1 (availability, freq, voltage) 328 - | |- opp 2 .. 329 - ... ... 330 - | `- opp n .. 331 - |- device 2 332 - ... 333 - `- device m 292 + represented as follows:: 293 + 294 + SoC 295 + |- device 1 296 + | |- opp 1 (availability, freq, voltage) 297 + | |- opp 2 .. 298 + ... ... 299 + | `- opp n .. 300 + |- device 2 301 + ... 302 + `- device m 334 303 335 304 OPP library maintains a internal list that the SoC framework populates and 336 305 accessed by various functions as described above. However, the structures 337 306 representing the actual OPPs and domains are internal to the OPP library itself 338 307 to allow for suitable abstraction reusable across systems. 339 308 340 - struct dev_pm_opp - The internal data structure of OPP library which is used to 309 + struct dev_pm_opp 310 + The internal data structure of OPP library which is used to 341 311 represent an OPP. In addition to the freq, voltage, availability 342 312 information, it also contains internal book keeping information required 343 313 for the OPP library to operate on. Pointer to this structure is 344 314 provided back to the users such as SoC framework to be used as a 345 315 identifier for OPP in the interactions with OPP layer. 346 316 347 - WARNING: The struct dev_pm_opp pointer should not be parsed or modified by the 348 - users. The defaults of for an instance is populated by dev_pm_opp_add, but the 349 - availability of the OPP can be modified by dev_pm_opp_enable/disable functions. 317 + WARNING: 318 + The struct dev_pm_opp pointer should not be parsed or modified by the 319 + users. The defaults of for an instance is populated by 320 + dev_pm_opp_add, but the availability of the OPP can be modified 321 + by dev_pm_opp_enable/disable functions. 350 322 351 - struct device - This is used to identify a domain to the OPP layer. The 323 + struct device 324 + This is used to identify a domain to the OPP layer. The 352 325 nature of the device and it's implementation is left to the user of 353 326 OPP library such as the SoC framework. 354 327 355 328 Overall, in a simplistic view, the data structure operations is represented as 356 - following: 329 + following:: 357 330 358 - Initialization / modification: 359 - +-----+ /- dev_pm_opp_enable 360 - dev_pm_opp_add --> | opp | <------- 361 - | +-----+ \- dev_pm_opp_disable 362 - \-------> domain_info(device) 331 + Initialization / modification: 332 + +-----+ /- dev_pm_opp_enable 333 + dev_pm_opp_add --> | opp | <------- 334 + | +-----+ \- dev_pm_opp_disable 335 + \-------> domain_info(device) 363 336 364 - Search functions: 365 - /-- dev_pm_opp_find_freq_ceil ---\ +-----+ 366 - domain_info<---- dev_pm_opp_find_freq_exact -----> | opp | 367 - \-- dev_pm_opp_find_freq_floor ---/ +-----+ 337 + Search functions: 338 + /-- dev_pm_opp_find_freq_ceil ---\ +-----+ 339 + domain_info<---- dev_pm_opp_find_freq_exact -----> | opp | 340 + \-- dev_pm_opp_find_freq_floor ---/ +-----+ 368 341 369 - Retrieval functions: 370 - +-----+ /- dev_pm_opp_get_voltage 371 - | opp | <--- 372 - +-----+ \- dev_pm_opp_get_freq 342 + Retrieval functions: 343 + +-----+ /- dev_pm_opp_get_voltage 344 + | opp | <--- 345 + +-----+ \- dev_pm_opp_get_freq 373 346 374 - domain_info <- dev_pm_opp_get_opp_count 347 + domain_info <- dev_pm_opp_get_opp_count
+64 -23
Documentation/power/pci.txt Documentation/power/pci.rst
··· 1 + ==================== 1 2 PCI Power Management 3 + ==================== 2 4 3 5 Copyright (c) 2010 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. 4 6 ··· 11 9 This document only covers the aspects of power management specific to PCI 12 10 devices. For general description of the kernel's interfaces related to device 13 11 power management refer to Documentation/driver-api/pm/devices.rst and 14 - Documentation/power/runtime_pm.txt. 12 + Documentation/power/runtime_pm.rst. 15 13 16 - --------------------------------------------------------------------------- 14 + .. contents: 17 15 18 - 1. Hardware and Platform Support for PCI Power Management 19 - 2. PCI Subsystem and Device Power Management 20 - 3. PCI Device Drivers and Power Management 21 - 4. Resources 16 + 1. Hardware and Platform Support for PCI Power Management 17 + 2. PCI Subsystem and Device Power Management 18 + 3. PCI Device Drivers and Power Management 19 + 4. Resources 22 20 23 21 24 22 1. Hardware and Platform Support for PCI Power Management ··· 26 24 27 25 1.1. Native and Platform-Based Power Management 28 26 ----------------------------------------------- 27 + 29 28 In general, power management is a feature allowing one to save energy by putting 30 29 devices into states in which they draw less power (low-power states) at the 31 30 price of reduced functionality or performance. ··· 70 67 71 68 1.2. Native PCI Power Management 72 69 -------------------------------- 70 + 73 71 The PCI Bus Power Management Interface Specification (PCI PM Spec) was 74 72 introduced between the PCI 2.1 and PCI 2.2 Specifications. It defined a 75 73 standard interface for performing various operations related to power ··· 138 134 139 135 1.3. ACPI Device Power Management 140 136 --------------------------------- 137 + 141 138 The platform firmware support for the power management of PCI devices is 142 139 system-specific. However, if the system in question is compliant with the 143 140 Advanced Configuration and Power Interface (ACPI) Specification, like the ··· 199 194 200 195 1.4. Wakeup Signaling 201 196 --------------------- 197 + 202 198 Wakeup signals generated by PCI devices, either as native PCI PMEs, or as 203 199 a result of the execution of the _DSW (or _PSW) ACPI control method before 204 200 putting the device into a low-power state, have to be caught and handled as ··· 271 265 272 266 2.1. Device Power Management Callbacks 273 267 -------------------------------------- 268 + 274 269 The PCI Subsystem participates in the power management of PCI devices in a 275 270 number of ways. First of all, it provides an intermediate code layer between 276 271 the device power management core (PM core) and PCI device drivers. 277 272 Specifically, the pm field of the PCI subsystem's struct bus_type object, 278 273 pci_bus_type, points to a struct dev_pm_ops object, pci_dev_pm_ops, containing 279 - pointers to several device power management callbacks: 274 + pointers to several device power management callbacks:: 280 275 281 - const struct dev_pm_ops pci_dev_pm_ops = { 276 + const struct dev_pm_ops pci_dev_pm_ops = { 282 277 .prepare = pci_pm_prepare, 283 278 .complete = pci_pm_complete, 284 279 .suspend = pci_pm_suspend, ··· 297 290 .runtime_suspend = pci_pm_runtime_suspend, 298 291 .runtime_resume = pci_pm_runtime_resume, 299 292 .runtime_idle = pci_pm_runtime_idle, 300 - }; 293 + }; 301 294 302 295 These callbacks are executed by the PM core in various situations related to 303 296 device power management and they, in turn, execute power management callbacks ··· 306 299 drivers need not know or care about. 307 300 308 301 The structure representing a PCI device, struct pci_dev, contains several fields 309 - that these callbacks operate on: 302 + that these callbacks operate on:: 310 303 311 - struct pci_dev { 304 + struct pci_dev { 312 305 ... 313 306 pci_power_t current_state; /* Current operating state. */ 314 307 int pm_cap; /* PM capability offset in the ··· 322 315 unsigned int wakeup_prepared:1; /* Device prepared for wake up */ 323 316 unsigned int d3_delay; /* D3->D0 transition time in ms */ 324 317 ... 325 - }; 318 + }; 326 319 327 320 They also indirectly use some fields of the struct device that is embedded in 328 321 struct pci_dev. 329 322 330 323 2.2. Device Initialization 331 324 -------------------------- 325 + 332 326 The PCI subsystem's first task related to device power management is to 333 327 prepare the device for power management and initialize the fields of struct 334 328 pci_dev used for this purpose. This happens in two functions defined in ··· 356 348 357 349 2.3. Runtime Device Power Management 358 350 ------------------------------------ 351 + 359 352 The PCI subsystem plays a vital role in the runtime power management of PCI 360 353 devices. For this purpose it uses the general runtime power management 361 - (runtime PM) framework described in Documentation/power/runtime_pm.txt. 362 - Namely, it provides subsystem-level callbacks: 354 + (runtime PM) framework described in Documentation/power/runtime_pm.rst. 355 + Namely, it provides subsystem-level callbacks:: 363 356 364 357 pci_pm_runtime_suspend() 365 358 pci_pm_runtime_resume() ··· 434 425 after tasks have been frozen. 435 426 436 427 2.4.1. System Suspend 428 + ^^^^^^^^^^^^^^^^^^^^^ 437 429 438 430 When the system is going into a sleep state in which the contents of memory will 439 431 be preserved, such as one of the ACPI sleep states S1-S3, the phases are: 440 432 441 433 prepare, suspend, suspend_noirq. 442 434 443 - The following PCI bus type's callbacks, respectively, are used in these phases: 435 + The following PCI bus type's callbacks, respectively, are used in these phases:: 444 436 445 437 pci_pm_prepare() 446 438 pci_pm_suspend() ··· 502 492 rare cases doing that in the driver may be the optimum approach. 503 493 504 494 2.4.2. System Resume 495 + ^^^^^^^^^^^^^^^^^^^^ 505 496 506 497 When the system is undergoing a transition from a sleep state in which the 507 498 contents of memory have been preserved, such as one of the ACPI sleep states ··· 511 500 resume_noirq, resume, complete. 512 501 513 502 The following PCI bus type's callbacks, respectively, are executed in these 514 - phases: 503 + phases:: 515 504 516 505 pci_pm_resume_noirq() 517 506 pci_pm_resume() ··· 550 539 callback, if defined. 551 540 552 541 2.4.3. System Hibernation 542 + ^^^^^^^^^^^^^^^^^^^^^^^^^ 553 543 554 544 System hibernation is more complicated than system suspend, because it requires 555 545 a system image to be created and written into a persistent storage medium. The ··· 563 551 564 552 prepare, freeze, freeze_noirq 565 553 566 - that correspond to the PCI bus type's callbacks: 554 + that correspond to the PCI bus type's callbacks:: 567 555 568 556 pci_pm_prepare() 569 557 pci_pm_freeze() ··· 592 580 593 581 thaw_noirq, thaw, complete 594 582 595 - using the following PCI bus type's callbacks: 583 + using the following PCI bus type's callbacks:: 596 584 597 585 pci_pm_thaw_noirq() 598 586 pci_pm_thaw() ··· 620 608 621 609 where the prepare phase is exactly the same as for system suspend. The other 622 610 two phases are analogous to the suspend and suspend_noirq phases, respectively. 623 - The PCI subsystem-level callbacks they correspond to 611 + The PCI subsystem-level callbacks they correspond to:: 624 612 625 613 pci_pm_poweroff() 626 614 pci_pm_poweroff_noirq() ··· 630 618 registers. 631 619 632 620 2.4.4. System Restore 621 + ^^^^^^^^^^^^^^^^^^^^^ 633 622 634 623 System restore requires a hibernation image to be loaded into memory and the 635 624 pre-hibernation memory contents to be restored before the pre-hibernation system ··· 666 653 667 654 The first two of these are analogous to the resume_noirq and resume phases 668 655 described above, respectively, and correspond to the following PCI subsystem 669 - callbacks: 656 + callbacks:: 670 657 671 658 pci_pm_restore_noirq() 672 659 pci_pm_restore() ··· 684 671 685 672 3.1. Power Management Callbacks 686 673 ------------------------------- 674 + 687 675 PCI device drivers participate in power management by providing callbacks to be 688 676 executed by the PCI subsystem's power management routines described above and by 689 677 controlling the runtime power management of their devices. ··· 712 698 subsections. 713 699 714 700 3.1.1. prepare() 701 + ^^^^^^^^^^^^^^^^ 715 702 716 703 The prepare() callback is executed during system suspend, during hibernation 717 704 (when a hibernation image is about to be created), during power-off after ··· 731 716 in Documentation/driver-api/pm/notifiers.rst). 732 717 733 718 3.1.2. suspend() 719 + ^^^^^^^^^^^^^^^^ 734 720 735 721 The suspend() callback is only executed during system suspend, after prepare() 736 722 callbacks have been executed for all devices in the system. ··· 758 742 carried out in this callback. 759 743 760 744 3.1.3. suspend_noirq() 745 + ^^^^^^^^^^^^^^^^^^^^^^ 761 746 762 747 The suspend_noirq() callback is only executed during system suspend, after 763 748 suspend() callbacks have been executed for all devices in the system and ··· 770 753 arise if they were performed in suspend(). 771 754 772 755 3.1.4. freeze() 756 + ^^^^^^^^^^^^^^^ 773 757 774 758 The freeze() callback is hibernation-specific and is executed in two situations, 775 759 during hibernation, after prepare() callbacks have been executed for all devices ··· 788 770 save the device's standard configuration registers using pci_save_state(). 789 771 790 772 3.1.5. freeze_noirq() 773 + ^^^^^^^^^^^^^^^^^^^^^ 791 774 792 775 The freeze_noirq() callback is hibernation-specific. It is executed during 793 776 hibernation, after prepare() and freeze() callbacks have been executed for all ··· 805 786 difference between suspend_noirq() and suspend(). 806 787 807 788 3.1.6. poweroff() 789 + ^^^^^^^^^^^^^^^^^ 808 790 809 791 The poweroff() callback is hibernation-specific. It is executed when the system 810 792 is about to be powered off after saving a hibernation image to a persistent ··· 822 802 configuration registers. 823 803 824 804 3.1.7. poweroff_noirq() 805 + ^^^^^^^^^^^^^^^^^^^^^^^ 825 806 826 807 The poweroff_noirq() callback is hibernation-specific. It is executed after 827 808 poweroff() callbacks have been executed for all devices in the system. ··· 835 814 difference between suspend_noirq() and suspend(). 836 815 837 816 3.1.8. resume_noirq() 817 + ^^^^^^^^^^^^^^^^^^^^^ 838 818 839 819 The resume_noirq() callback is only executed during system resume, after the 840 820 PM core has enabled the non-boot CPUs. The driver's interrupt handler will not ··· 849 827 conditions if carried out by resume(). 850 828 851 829 3.1.9. resume() 830 + ^^^^^^^^^^^^^^^ 852 831 853 832 The resume() callback is only executed during system resume, after 854 833 resume_noirq() callbacks have been executed for all devices in the system and ··· 860 837 able to process I/O in a usual way after resume() has returned. 861 838 862 839 3.1.10. thaw_noirq() 840 + ^^^^^^^^^^^^^^^^^^^^ 863 841 864 842 The thaw_noirq() callback is hibernation-specific. It is executed after a 865 843 system image has been created and the non-boot CPUs have been enabled by the PM ··· 875 851 contents of the device's registers. 876 852 877 853 3.1.11. thaw() 854 + ^^^^^^^^^^^^^^ 878 855 879 856 The thaw() callback is hibernation-specific. It is executed after thaw_noirq() 880 857 callbacks have been executed for all devices in the system and after device ··· 885 860 the device, so that it will work in a usual way after thaw() has returned. 886 861 887 862 3.1.12. restore_noirq() 863 + ^^^^^^^^^^^^^^^^^^^^^^^ 888 864 889 865 The restore_noirq() callback is hibernation-specific. It is executed in the 890 866 restore_noirq phase of hibernation, when the boot kernel has passed control to ··· 901 875 resume_noirq() and restore_noirq(). 902 876 903 877 3.1.13. restore() 878 + ^^^^^^^^^^^^^^^^^ 904 879 905 880 The restore() callback is hibernation-specific. It is executed after 906 881 restore_noirq() callbacks have been executed for all devices in the system and ··· 915 888 resume() and restore(). 916 889 917 890 3.1.14. complete() 891 + ^^^^^^^^^^^^^^^^^^ 918 892 919 893 The complete() callback is executed in the following situations: 894 + 920 895 - during system resume, after resume() callbacks have been executed for all 921 896 devices, 922 897 - during hibernation, before saving the system image, after thaw() callbacks 923 898 have been executed for all devices, 924 899 - during system restore, when the system is going back to its pre-hibernation 925 900 state, after restore() callbacks have been executed for all devices. 901 + 926 902 It also may be executed if the loading of a hibernation image into memory fails 927 903 (in that case it is run after thaw() callbacks have been executed for all 928 904 devices that have drivers in the boot kernel). ··· 934 904 prepare() callback performs operations that need to be reversed. 935 905 936 906 3.1.15. runtime_suspend() 907 + ^^^^^^^^^^^^^^^^^^^^^^^^^ 937 908 938 909 The runtime_suspend() callback is specific to device runtime power management 939 910 (runtime PM). It is executed by the PM core's runtime PM framework when the ··· 946 915 of the PCI-specific actions necessary for suspending the device. 947 916 948 917 3.1.16. runtime_resume() 918 + ^^^^^^^^^^^^^^^^^^^^^^^^ 949 919 950 920 The runtime_resume() callback is specific to device runtime PM. It is executed 951 921 by the PM core's runtime PM framework when the device is about to be resumed ··· 959 927 runtime_resume() has returned. 960 928 961 929 3.1.17. runtime_idle() 930 + ^^^^^^^^^^^^^^^^^^^^^^ 962 931 963 932 The runtime_idle() callback is specific to device runtime PM. It is executed 964 933 by the PM core's runtime PM framework whenever it may be desirable to suspend ··· 972 939 cause the driver's runtime_suspend() callback to be executed. 973 940 974 941 3.1.18. Pointing Multiple Callback Pointers to One Routine 942 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 975 943 976 944 Although in principle each of the callbacks described in the previous 977 945 subsections can be defined as a separate function, it often is convenient to ··· 996 962 be pointed to by the .resume(), .thaw(), and .restore() members. 997 963 998 964 3.1.19. Driver Flags for Power Management 965 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 999 966 1000 967 The PM core allows device drivers to set flags that influence the handling of 1001 968 power management for the devices by the core itself and by middle layer code ··· 1042 1007 1043 1008 3.2. Device Runtime Power Management 1044 1009 ------------------------------------ 1010 + 1045 1011 In addition to providing device power management callbacks PCI device drivers 1046 1012 are responsible for controlling the runtime power management (runtime PM) of 1047 1013 their devices. ··· 1109 1073 idle), device drivers are generally responsible for queuing power management 1110 1074 requests for their devices. For this purpose they should use the runtime PM 1111 1075 helper functions provided by the PM core, discussed in 1112 - Documentation/power/runtime_pm.txt. 1076 + Documentation/power/runtime_pm.rst. 1113 1077 1114 1078 Devices can also be suspended and resumed synchronously, without placing a 1115 1079 request into pm_wq. In the majority of cases this also is done by their 1116 1080 drivers that use helper functions provided by the PM core for this purpose. 1117 1081 1118 1082 For more information on the runtime PM of devices refer to 1119 - Documentation/power/runtime_pm.txt. 1083 + Documentation/power/runtime_pm.rst. 1120 1084 1121 1085 1122 1086 4. Resources 1123 1087 ============ 1124 1088 1125 1089 PCI Local Bus Specification, Rev. 3.0 1090 + 1126 1091 PCI Bus Power Management Interface Specification, Rev. 1.2 1092 + 1127 1093 Advanced Configuration and Power Interface (ACPI) Specification, Rev. 3.0b 1094 + 1128 1095 PCI Express Base Specification, Rev. 2.0 1096 + 1129 1097 Documentation/driver-api/pm/devices.rst 1130 - Documentation/power/runtime_pm.txt 1098 + 1099 + Documentation/power/runtime_pm.rst
+70 -57
Documentation/power/pm_qos_interface.txt Documentation/power/pm_qos_interface.rst
··· 1 - PM Quality Of Service Interface. 1 + =============================== 2 + PM Quality Of Service Interface 3 + =============================== 2 4 3 5 This interface provides a kernel and user mode interface for registering 4 6 performance expectations by drivers, subsystems and user space applications on ··· 13 11 constraints and PM QoS flags. 14 12 15 13 Each parameters have defined units: 14 + 16 15 * latency: usec 17 16 * timeout: usec 18 17 * throughput: kbs (kilo bit / sec) ··· 21 18 22 19 23 20 1. PM QoS framework 21 + =================== 24 22 25 23 The infrastructure exposes multiple misc device nodes one per implemented 26 24 parameter. The set of parameters implement is defined by pm_qos_power_init() ··· 41 37 From kernel mode the use of this interface is simple: 42 38 43 39 void pm_qos_add_request(handle, param_class, target_value): 44 - Will insert an element into the list for that identified PM QoS class with the 45 - target value. Upon change to this list the new target is recomputed and any 46 - registered notifiers are called only if the target value is now different. 47 - Clients of pm_qos need to save the returned handle for future use in other 48 - pm_qos API functions. 40 + Will insert an element into the list for that identified PM QoS class with the 41 + target value. Upon change to this list the new target is recomputed and any 42 + registered notifiers are called only if the target value is now different. 43 + Clients of pm_qos need to save the returned handle for future use in other 44 + pm_qos API functions. 49 45 50 46 void pm_qos_update_request(handle, new_target_value): 51 - Will update the list element pointed to by the handle with the new target value 52 - and recompute the new aggregated target, calling the notification tree if the 53 - target is changed. 47 + Will update the list element pointed to by the handle with the new target value 48 + and recompute the new aggregated target, calling the notification tree if the 49 + target is changed. 54 50 55 51 void pm_qos_remove_request(handle): 56 - Will remove the element. After removal it will update the aggregate target and 57 - call the notification tree if the target was changed as a result of removing 58 - the request. 52 + Will remove the element. After removal it will update the aggregate target and 53 + call the notification tree if the target was changed as a result of removing 54 + the request. 59 55 60 56 int pm_qos_request(param_class): 61 - Returns the aggregated value for a given PM QoS class. 57 + Returns the aggregated value for a given PM QoS class. 62 58 63 59 int pm_qos_request_active(handle): 64 - Returns if the request is still active, i.e. it has not been removed from a 65 - PM QoS class constraints list. 60 + Returns if the request is still active, i.e. it has not been removed from a 61 + PM QoS class constraints list. 66 62 67 63 int pm_qos_add_notifier(param_class, notifier): 68 - Adds a notification callback function to the PM QoS class. The callback is 69 - called when the aggregated value for the PM QoS class is changed. 64 + Adds a notification callback function to the PM QoS class. The callback is 65 + called when the aggregated value for the PM QoS class is changed. 70 66 71 67 int pm_qos_remove_notifier(int param_class, notifier): 72 - Removes the notification callback function for the PM QoS class. 68 + Removes the notification callback function for the PM QoS class. 73 69 74 70 75 71 From user mode: 72 + 76 73 Only processes can register a pm_qos request. To provide for automatic 77 74 cleanup of a process, the interface requires the process to register its 78 75 parameter requests in the following way: ··· 94 89 95 90 96 91 2. PM QoS per-device latency and flags framework 92 + ================================================ 97 93 98 94 For each device, there are three lists of PM QoS requests. Two of them are 99 95 maintained along with the aggregated targets of resume latency and active ··· 113 107 From kernel mode the use of this interface is the following: 114 108 115 109 int dev_pm_qos_add_request(device, handle, type, value): 116 - Will insert an element into the list for that identified device with the 117 - target value. Upon change to this list the new target is recomputed and any 118 - registered notifiers are called only if the target value is now different. 119 - Clients of dev_pm_qos need to save the handle for future use in other 120 - dev_pm_qos API functions. 110 + Will insert an element into the list for that identified device with the 111 + target value. Upon change to this list the new target is recomputed and any 112 + registered notifiers are called only if the target value is now different. 113 + Clients of dev_pm_qos need to save the handle for future use in other 114 + dev_pm_qos API functions. 121 115 122 116 int dev_pm_qos_update_request(handle, new_value): 123 - Will update the list element pointed to by the handle with the new target value 124 - and recompute the new aggregated target, calling the notification trees if the 125 - target is changed. 117 + Will update the list element pointed to by the handle with the new target 118 + value and recompute the new aggregated target, calling the notification 119 + trees if the target is changed. 126 120 127 121 int dev_pm_qos_remove_request(handle): 128 - Will remove the element. After removal it will update the aggregate target and 129 - call the notification trees if the target was changed as a result of removing 130 - the request. 122 + Will remove the element. After removal it will update the aggregate target 123 + and call the notification trees if the target was changed as a result of 124 + removing the request. 131 125 132 126 s32 dev_pm_qos_read_value(device): 133 - Returns the aggregated value for a given device's constraints list. 127 + Returns the aggregated value for a given device's constraints list. 134 128 135 129 enum pm_qos_flags_status dev_pm_qos_flags(device, mask) 136 - Check PM QoS flags of the given device against the given mask of flags. 137 - The meaning of the return values is as follows: 138 - PM_QOS_FLAGS_ALL: All flags from the mask are set 139 - PM_QOS_FLAGS_SOME: Some flags from the mask are set 140 - PM_QOS_FLAGS_NONE: No flags from the mask are set 141 - PM_QOS_FLAGS_UNDEFINED: The device's PM QoS structure has not been 142 - initialized or the list of requests is empty. 130 + Check PM QoS flags of the given device against the given mask of flags. 131 + The meaning of the return values is as follows: 132 + 133 + PM_QOS_FLAGS_ALL: 134 + All flags from the mask are set 135 + PM_QOS_FLAGS_SOME: 136 + Some flags from the mask are set 137 + PM_QOS_FLAGS_NONE: 138 + No flags from the mask are set 139 + PM_QOS_FLAGS_UNDEFINED: 140 + The device's PM QoS structure has not been initialized 141 + or the list of requests is empty. 143 142 144 143 int dev_pm_qos_add_ancestor_request(dev, handle, type, value) 145 - Add a PM QoS request for the first direct ancestor of the given device whose 146 - power.ignore_children flag is unset (for DEV_PM_QOS_RESUME_LATENCY requests) 147 - or whose power.set_latency_tolerance callback pointer is not NULL (for 148 - DEV_PM_QOS_LATENCY_TOLERANCE requests). 144 + Add a PM QoS request for the first direct ancestor of the given device whose 145 + power.ignore_children flag is unset (for DEV_PM_QOS_RESUME_LATENCY requests) 146 + or whose power.set_latency_tolerance callback pointer is not NULL (for 147 + DEV_PM_QOS_LATENCY_TOLERANCE requests). 149 148 150 149 int dev_pm_qos_expose_latency_limit(device, value) 151 - Add a request to the device's PM QoS list of resume latency constraints and 152 - create a sysfs attribute pm_qos_resume_latency_us under the device's power 153 - directory allowing user space to manipulate that request. 150 + Add a request to the device's PM QoS list of resume latency constraints and 151 + create a sysfs attribute pm_qos_resume_latency_us under the device's power 152 + directory allowing user space to manipulate that request. 154 153 155 154 void dev_pm_qos_hide_latency_limit(device) 156 - Drop the request added by dev_pm_qos_expose_latency_limit() from the device's 157 - PM QoS list of resume latency constraints and remove sysfs attribute 158 - pm_qos_resume_latency_us from the device's power directory. 155 + Drop the request added by dev_pm_qos_expose_latency_limit() from the device's 156 + PM QoS list of resume latency constraints and remove sysfs attribute 157 + pm_qos_resume_latency_us from the device's power directory. 159 158 160 159 int dev_pm_qos_expose_flags(device, value) 161 - Add a request to the device's PM QoS list of flags and create sysfs attribute 162 - pm_qos_no_power_off under the device's power directory allowing user space to 163 - change the value of the PM_QOS_FLAG_NO_POWER_OFF flag. 160 + Add a request to the device's PM QoS list of flags and create sysfs attribute 161 + pm_qos_no_power_off under the device's power directory allowing user space to 162 + change the value of the PM_QOS_FLAG_NO_POWER_OFF flag. 164 163 165 164 void dev_pm_qos_hide_flags(device) 166 - Drop the request added by dev_pm_qos_expose_flags() from the device's PM QoS list 167 - of flags and remove sysfs attribute pm_qos_no_power_off from the device's power 168 - directory. 165 + Drop the request added by dev_pm_qos_expose_flags() from the device's PM QoS list 166 + of flags and remove sysfs attribute pm_qos_no_power_off from the device's power 167 + directory. 169 168 170 169 Notification mechanisms: 170 + 171 171 The per-device PM QoS framework has a per-device notification tree. 172 172 173 173 int dev_pm_qos_add_notifier(device, notifier): 174 - Adds a notification callback function for the device. 175 - The callback is called when the aggregated value of the device constraints list 176 - is changed (for resume latency device PM QoS only). 174 + Adds a notification callback function for the device. 175 + The callback is called when the aggregated value of the device constraints list 176 + is changed (for resume latency device PM QoS only). 177 177 178 178 int dev_pm_qos_remove_notifier(device, notifier): 179 - Removes the notification callback function for the device. 179 + Removes the notification callback function for the device. 180 180 181 181 182 182 Active state latency tolerance 183 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 183 184 184 185 This device PM QoS type is used to support systems in which hardware may switch 185 186 to energy-saving operation modes on the fly. In those systems, if the operation
+282
Documentation/power/power_supply_class.rst
··· 1 + ======================== 2 + Linux power supply class 3 + ======================== 4 + 5 + Synopsis 6 + ~~~~~~~~ 7 + Power supply class used to represent battery, UPS, AC or DC power supply 8 + properties to user-space. 9 + 10 + It defines core set of attributes, which should be applicable to (almost) 11 + every power supply out there. Attributes are available via sysfs and uevent 12 + interfaces. 13 + 14 + Each attribute has well defined meaning, up to unit of measure used. While 15 + the attributes provided are believed to be universally applicable to any 16 + power supply, specific monitoring hardware may not be able to provide them 17 + all, so any of them may be skipped. 18 + 19 + Power supply class is extensible, and allows to define drivers own attributes. 20 + The core attribute set is subject to the standard Linux evolution (i.e. 21 + if it will be found that some attribute is applicable to many power supply 22 + types or their drivers, it can be added to the core set). 23 + 24 + It also integrates with LED framework, for the purpose of providing 25 + typically expected feedback of battery charging/fully charged status and 26 + AC/USB power supply online status. (Note that specific details of the 27 + indication (including whether to use it at all) are fully controllable by 28 + user and/or specific machine defaults, per design principles of LED 29 + framework). 30 + 31 + 32 + Attributes/properties 33 + ~~~~~~~~~~~~~~~~~~~~~ 34 + Power supply class has predefined set of attributes, this eliminates code 35 + duplication across drivers. Power supply class insist on reusing its 36 + predefined attributes *and* their units. 37 + 38 + So, userspace gets predictable set of attributes and their units for any 39 + kind of power supply, and can process/present them to a user in consistent 40 + manner. Results for different power supplies and machines are also directly 41 + comparable. 42 + 43 + See drivers/power/supply/ds2760_battery.c and drivers/power/supply/pda_power.c 44 + for the example how to declare and handle attributes. 45 + 46 + 47 + Units 48 + ~~~~~ 49 + Quoting include/linux/power_supply.h: 50 + 51 + All voltages, currents, charges, energies, time and temperatures in µV, 52 + µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise 53 + stated. It's driver's job to convert its raw values to units in which 54 + this class operates. 55 + 56 + 57 + Attributes/properties detailed 58 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 59 + 60 + +--------------------------------------------------------------------------+ 61 + | **Charge/Energy/Capacity - how to not confuse** | 62 + +--------------------------------------------------------------------------+ 63 + | **Because both "charge" (µAh) and "energy" (µWh) represents "capacity" | 64 + | of battery, this class distinguish these terms. Don't mix them!** | 65 + | | 66 + | - `CHARGE_*` | 67 + | attributes represents capacity in µAh only. | 68 + | - `ENERGY_*` | 69 + | attributes represents capacity in µWh only. | 70 + | - `CAPACITY` | 71 + | attribute represents capacity in *percents*, from 0 to 100. | 72 + +--------------------------------------------------------------------------+ 73 + 74 + Postfixes: 75 + 76 + _AVG 77 + *hardware* averaged value, use it if your hardware is really able to 78 + report averaged values. 79 + _NOW 80 + momentary/instantaneous values. 81 + 82 + STATUS 83 + this attribute represents operating status (charging, full, 84 + discharging (i.e. powering a load), etc.). This corresponds to 85 + `BATTERY_STATUS_*` values, as defined in battery.h. 86 + 87 + CHARGE_TYPE 88 + batteries can typically charge at different rates. 89 + This defines trickle and fast charges. For batteries that 90 + are already charged or discharging, 'n/a' can be displayed (or 91 + 'unknown', if the status is not known). 92 + 93 + AUTHENTIC 94 + indicates the power supply (battery or charger) connected 95 + to the platform is authentic(1) or non authentic(0). 96 + 97 + HEALTH 98 + represents health of the battery, values corresponds to 99 + POWER_SUPPLY_HEALTH_*, defined in battery.h. 100 + 101 + VOLTAGE_OCV 102 + open circuit voltage of the battery. 103 + 104 + VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN 105 + design values for maximal and minimal power supply voltages. 106 + Maximal/minimal means values of voltages when battery considered 107 + "full"/"empty" at normal conditions. Yes, there is no direct relation 108 + between voltage and battery capacity, but some dumb 109 + batteries use voltage for very approximated calculation of capacity. 110 + Battery driver also can use this attribute just to inform userspace 111 + about maximal and minimal voltage thresholds of a given battery. 112 + 113 + VOLTAGE_MAX, VOLTAGE_MIN 114 + same as _DESIGN voltage values except that these ones should be used 115 + if hardware could only guess (measure and retain) the thresholds of a 116 + given power supply. 117 + 118 + VOLTAGE_BOOT 119 + Reports the voltage measured during boot 120 + 121 + CURRENT_BOOT 122 + Reports the current measured during boot 123 + 124 + CHARGE_FULL_DESIGN, CHARGE_EMPTY_DESIGN 125 + design charge values, when battery considered full/empty. 126 + 127 + ENERGY_FULL_DESIGN, ENERGY_EMPTY_DESIGN 128 + same as above but for energy. 129 + 130 + CHARGE_FULL, CHARGE_EMPTY 131 + These attributes means "last remembered value of charge when battery 132 + became full/empty". It also could mean "value of charge when battery 133 + considered full/empty at given conditions (temperature, age)". 134 + I.e. these attributes represents real thresholds, not design values. 135 + 136 + ENERGY_FULL, ENERGY_EMPTY 137 + same as above but for energy. 138 + 139 + CHARGE_COUNTER 140 + the current charge counter (in µAh). This could easily 141 + be negative; there is no empty or full value. It is only useful for 142 + relative, time-based measurements. 143 + 144 + PRECHARGE_CURRENT 145 + the maximum charge current during precharge phase of charge cycle 146 + (typically 20% of battery capacity). 147 + 148 + CHARGE_TERM_CURRENT 149 + Charge termination current. The charge cycle terminates when battery 150 + voltage is above recharge threshold, and charge current is below 151 + this setting (typically 10% of battery capacity). 152 + 153 + CONSTANT_CHARGE_CURRENT 154 + constant charge current programmed by charger. 155 + 156 + 157 + CONSTANT_CHARGE_CURRENT_MAX 158 + maximum charge current supported by the power supply object. 159 + 160 + CONSTANT_CHARGE_VOLTAGE 161 + constant charge voltage programmed by charger. 162 + CONSTANT_CHARGE_VOLTAGE_MAX 163 + maximum charge voltage supported by the power supply object. 164 + 165 + INPUT_CURRENT_LIMIT 166 + input current limit programmed by charger. Indicates 167 + the current drawn from a charging source. 168 + 169 + CHARGE_CONTROL_LIMIT 170 + current charge control limit setting 171 + CHARGE_CONTROL_LIMIT_MAX 172 + maximum charge control limit setting 173 + 174 + CALIBRATE 175 + battery or coulomb counter calibration status 176 + 177 + CAPACITY 178 + capacity in percents. 179 + CAPACITY_ALERT_MIN 180 + minimum capacity alert value in percents. 181 + CAPACITY_ALERT_MAX 182 + maximum capacity alert value in percents. 183 + CAPACITY_LEVEL 184 + capacity level. This corresponds to POWER_SUPPLY_CAPACITY_LEVEL_*. 185 + 186 + TEMP 187 + temperature of the power supply. 188 + TEMP_ALERT_MIN 189 + minimum battery temperature alert. 190 + TEMP_ALERT_MAX 191 + maximum battery temperature alert. 192 + TEMP_AMBIENT 193 + ambient temperature. 194 + TEMP_AMBIENT_ALERT_MIN 195 + minimum ambient temperature alert. 196 + TEMP_AMBIENT_ALERT_MAX 197 + maximum ambient temperature alert. 198 + TEMP_MIN 199 + minimum operatable temperature 200 + TEMP_MAX 201 + maximum operatable temperature 202 + 203 + TIME_TO_EMPTY 204 + seconds left for battery to be considered empty 205 + (i.e. while battery powers a load) 206 + TIME_TO_FULL 207 + seconds left for battery to be considered full 208 + (i.e. while battery is charging) 209 + 210 + 211 + Battery <-> external power supply interaction 212 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 213 + Often power supplies are acting as supplies and supplicants at the same 214 + time. Batteries are good example. So, batteries usually care if they're 215 + externally powered or not. 216 + 217 + For that case, power supply class implements notification mechanism for 218 + batteries. 219 + 220 + External power supply (AC) lists supplicants (batteries) names in 221 + "supplied_to" struct member, and each power_supply_changed() call 222 + issued by external power supply will notify supplicants via 223 + external_power_changed callback. 224 + 225 + 226 + Devicetree battery characteristics 227 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 228 + Drivers should call power_supply_get_battery_info() to obtain battery 229 + characteristics from a devicetree battery node, defined in 230 + Documentation/devicetree/bindings/power/supply/battery.txt. This is 231 + implemented in drivers/power/supply/bq27xxx_battery.c. 232 + 233 + Properties in struct power_supply_battery_info and their counterparts in the 234 + battery node have names corresponding to elements in enum power_supply_property, 235 + for naming consistency between sysfs attributes and battery node properties. 236 + 237 + 238 + QA 239 + ~~ 240 + 241 + Q: 242 + Where is POWER_SUPPLY_PROP_XYZ attribute? 243 + A: 244 + If you cannot find attribute suitable for your driver needs, feel free 245 + to add it and send patch along with your driver. 246 + 247 + The attributes available currently are the ones currently provided by the 248 + drivers written. 249 + 250 + Good candidates to add in future: model/part#, cycle_time, manufacturer, 251 + etc. 252 + 253 + 254 + Q: 255 + I have some very specific attribute (e.g. battery color), should I add 256 + this attribute to standard ones? 257 + A: 258 + Most likely, no. Such attribute can be placed in the driver itself, if 259 + it is useful. Of course, if the attribute in question applicable to 260 + large set of batteries, provided by many drivers, and/or comes from 261 + some general battery specification/standard, it may be a candidate to 262 + be added to the core attribute set. 263 + 264 + 265 + Q: 266 + Suppose, my battery monitoring chip/firmware does not provides capacity 267 + in percents, but provides charge_{now,full,empty}. Should I calculate 268 + percentage capacity manually, inside the driver, and register CAPACITY 269 + attribute? The same question about time_to_empty/time_to_full. 270 + A: 271 + Most likely, no. This class is designed to export properties which are 272 + directly measurable by the specific hardware available. 273 + 274 + Inferring not available properties using some heuristics or mathematical 275 + model is not subject of work for a battery driver. Such functionality 276 + should be factored out, and in fact, apm_power, the driver to serve 277 + legacy APM API on top of power supply class, uses a simple heuristic of 278 + approximating remaining battery capacity based on its charge, current, 279 + voltage and so on. But full-fledged battery model is likely not subject 280 + for kernel at all, as it would require floating point calculation to deal 281 + with things like differential equations and Kalman filters. This is 282 + better be handled by batteryd/libbattery, yet to be written.
-231
Documentation/power/power_supply_class.txt
··· 1 - Linux power supply class 2 - ======================== 3 - 4 - Synopsis 5 - ~~~~~~~~ 6 - Power supply class used to represent battery, UPS, AC or DC power supply 7 - properties to user-space. 8 - 9 - It defines core set of attributes, which should be applicable to (almost) 10 - every power supply out there. Attributes are available via sysfs and uevent 11 - interfaces. 12 - 13 - Each attribute has well defined meaning, up to unit of measure used. While 14 - the attributes provided are believed to be universally applicable to any 15 - power supply, specific monitoring hardware may not be able to provide them 16 - all, so any of them may be skipped. 17 - 18 - Power supply class is extensible, and allows to define drivers own attributes. 19 - The core attribute set is subject to the standard Linux evolution (i.e. 20 - if it will be found that some attribute is applicable to many power supply 21 - types or their drivers, it can be added to the core set). 22 - 23 - It also integrates with LED framework, for the purpose of providing 24 - typically expected feedback of battery charging/fully charged status and 25 - AC/USB power supply online status. (Note that specific details of the 26 - indication (including whether to use it at all) are fully controllable by 27 - user and/or specific machine defaults, per design principles of LED 28 - framework). 29 - 30 - 31 - Attributes/properties 32 - ~~~~~~~~~~~~~~~~~~~~~ 33 - Power supply class has predefined set of attributes, this eliminates code 34 - duplication across drivers. Power supply class insist on reusing its 35 - predefined attributes *and* their units. 36 - 37 - So, userspace gets predictable set of attributes and their units for any 38 - kind of power supply, and can process/present them to a user in consistent 39 - manner. Results for different power supplies and machines are also directly 40 - comparable. 41 - 42 - See drivers/power/supply/ds2760_battery.c and drivers/power/supply/pda_power.c 43 - for the example how to declare and handle attributes. 44 - 45 - 46 - Units 47 - ~~~~~ 48 - Quoting include/linux/power_supply.h: 49 - 50 - All voltages, currents, charges, energies, time and temperatures in µV, 51 - µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise 52 - stated. It's driver's job to convert its raw values to units in which 53 - this class operates. 54 - 55 - 56 - Attributes/properties detailed 57 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 58 - 59 - ~ ~ ~ ~ ~ ~ ~ Charge/Energy/Capacity - how to not confuse ~ ~ ~ ~ ~ ~ ~ 60 - ~ ~ 61 - ~ Because both "charge" (µAh) and "energy" (µWh) represents "capacity" ~ 62 - ~ of battery, this class distinguish these terms. Don't mix them! ~ 63 - ~ ~ 64 - ~ CHARGE_* attributes represents capacity in µAh only. ~ 65 - ~ ENERGY_* attributes represents capacity in µWh only. ~ 66 - ~ CAPACITY attribute represents capacity in *percents*, from 0 to 100. ~ 67 - ~ ~ 68 - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 69 - 70 - Postfixes: 71 - _AVG - *hardware* averaged value, use it if your hardware is really able to 72 - report averaged values. 73 - _NOW - momentary/instantaneous values. 74 - 75 - STATUS - this attribute represents operating status (charging, full, 76 - discharging (i.e. powering a load), etc.). This corresponds to 77 - BATTERY_STATUS_* values, as defined in battery.h. 78 - 79 - CHARGE_TYPE - batteries can typically charge at different rates. 80 - This defines trickle and fast charges. For batteries that 81 - are already charged or discharging, 'n/a' can be displayed (or 82 - 'unknown', if the status is not known). 83 - 84 - AUTHENTIC - indicates the power supply (battery or charger) connected 85 - to the platform is authentic(1) or non authentic(0). 86 - 87 - HEALTH - represents health of the battery, values corresponds to 88 - POWER_SUPPLY_HEALTH_*, defined in battery.h. 89 - 90 - VOLTAGE_OCV - open circuit voltage of the battery. 91 - 92 - VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN - design values for maximal and 93 - minimal power supply voltages. Maximal/minimal means values of voltages 94 - when battery considered "full"/"empty" at normal conditions. Yes, there is 95 - no direct relation between voltage and battery capacity, but some dumb 96 - batteries use voltage for very approximated calculation of capacity. 97 - Battery driver also can use this attribute just to inform userspace 98 - about maximal and minimal voltage thresholds of a given battery. 99 - 100 - VOLTAGE_MAX, VOLTAGE_MIN - same as _DESIGN voltage values except that 101 - these ones should be used if hardware could only guess (measure and 102 - retain) the thresholds of a given power supply. 103 - 104 - VOLTAGE_BOOT - Reports the voltage measured during boot 105 - 106 - CURRENT_BOOT - Reports the current measured during boot 107 - 108 - CHARGE_FULL_DESIGN, CHARGE_EMPTY_DESIGN - design charge values, when 109 - battery considered full/empty. 110 - 111 - ENERGY_FULL_DESIGN, ENERGY_EMPTY_DESIGN - same as above but for energy. 112 - 113 - CHARGE_FULL, CHARGE_EMPTY - These attributes means "last remembered value 114 - of charge when battery became full/empty". It also could mean "value of 115 - charge when battery considered full/empty at given conditions (temperature, 116 - age)". I.e. these attributes represents real thresholds, not design values. 117 - 118 - ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. 119 - 120 - CHARGE_COUNTER - the current charge counter (in µAh). This could easily 121 - be negative; there is no empty or full value. It is only useful for 122 - relative, time-based measurements. 123 - 124 - PRECHARGE_CURRENT - the maximum charge current during precharge phase 125 - of charge cycle (typically 20% of battery capacity). 126 - CHARGE_TERM_CURRENT - Charge termination current. The charge cycle 127 - terminates when battery voltage is above recharge threshold, and charge 128 - current is below this setting (typically 10% of battery capacity). 129 - 130 - CONSTANT_CHARGE_CURRENT - constant charge current programmed by charger. 131 - CONSTANT_CHARGE_CURRENT_MAX - maximum charge current supported by the 132 - power supply object. 133 - 134 - CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger. 135 - CONSTANT_CHARGE_VOLTAGE_MAX - maximum charge voltage supported by the 136 - power supply object. 137 - 138 - INPUT_CURRENT_LIMIT - input current limit programmed by charger. Indicates 139 - the current drawn from a charging source. 140 - 141 - CHARGE_CONTROL_LIMIT - current charge control limit setting 142 - CHARGE_CONTROL_LIMIT_MAX - maximum charge control limit setting 143 - 144 - CALIBRATE - battery or coulomb counter calibration status 145 - 146 - CAPACITY - capacity in percents. 147 - CAPACITY_ALERT_MIN - minimum capacity alert value in percents. 148 - CAPACITY_ALERT_MAX - maximum capacity alert value in percents. 149 - CAPACITY_LEVEL - capacity level. This corresponds to 150 - POWER_SUPPLY_CAPACITY_LEVEL_*. 151 - 152 - TEMP - temperature of the power supply. 153 - TEMP_ALERT_MIN - minimum battery temperature alert. 154 - TEMP_ALERT_MAX - maximum battery temperature alert. 155 - TEMP_AMBIENT - ambient temperature. 156 - TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert. 157 - TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert. 158 - TEMP_MIN - minimum operatable temperature 159 - TEMP_MAX - maximum operatable temperature 160 - 161 - TIME_TO_EMPTY - seconds left for battery to be considered empty (i.e. 162 - while battery powers a load) 163 - TIME_TO_FULL - seconds left for battery to be considered full (i.e. 164 - while battery is charging) 165 - 166 - 167 - Battery <-> external power supply interaction 168 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 169 - Often power supplies are acting as supplies and supplicants at the same 170 - time. Batteries are good example. So, batteries usually care if they're 171 - externally powered or not. 172 - 173 - For that case, power supply class implements notification mechanism for 174 - batteries. 175 - 176 - External power supply (AC) lists supplicants (batteries) names in 177 - "supplied_to" struct member, and each power_supply_changed() call 178 - issued by external power supply will notify supplicants via 179 - external_power_changed callback. 180 - 181 - 182 - Devicetree battery characteristics 183 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 184 - Drivers should call power_supply_get_battery_info() to obtain battery 185 - characteristics from a devicetree battery node, defined in 186 - Documentation/devicetree/bindings/power/supply/battery.txt. This is 187 - implemented in drivers/power/supply/bq27xxx_battery.c. 188 - 189 - Properties in struct power_supply_battery_info and their counterparts in the 190 - battery node have names corresponding to elements in enum power_supply_property, 191 - for naming consistency between sysfs attributes and battery node properties. 192 - 193 - 194 - QA 195 - ~~ 196 - Q: Where is POWER_SUPPLY_PROP_XYZ attribute? 197 - A: If you cannot find attribute suitable for your driver needs, feel free 198 - to add it and send patch along with your driver. 199 - 200 - The attributes available currently are the ones currently provided by the 201 - drivers written. 202 - 203 - Good candidates to add in future: model/part#, cycle_time, manufacturer, 204 - etc. 205 - 206 - 207 - Q: I have some very specific attribute (e.g. battery color), should I add 208 - this attribute to standard ones? 209 - A: Most likely, no. Such attribute can be placed in the driver itself, if 210 - it is useful. Of course, if the attribute in question applicable to 211 - large set of batteries, provided by many drivers, and/or comes from 212 - some general battery specification/standard, it may be a candidate to 213 - be added to the core attribute set. 214 - 215 - 216 - Q: Suppose, my battery monitoring chip/firmware does not provides capacity 217 - in percents, but provides charge_{now,full,empty}. Should I calculate 218 - percentage capacity manually, inside the driver, and register CAPACITY 219 - attribute? The same question about time_to_empty/time_to_full. 220 - A: Most likely, no. This class is designed to export properties which are 221 - directly measurable by the specific hardware available. 222 - 223 - Inferring not available properties using some heuristics or mathematical 224 - model is not subject of work for a battery driver. Such functionality 225 - should be factored out, and in fact, apm_power, the driver to serve 226 - legacy APM API on top of power supply class, uses a simple heuristic of 227 - approximating remaining battery capacity based on its charge, current, 228 - voltage and so on. But full-fledged battery model is likely not subject 229 - for kernel at all, as it would require floating point calculation to deal 230 - with things like differential equations and Kalman filters. This is 231 - better be handled by batteryd/libbattery, yet to be written.
+257
Documentation/power/powercap/powercap.rst
··· 1 + ======================= 2 + Power Capping Framework 3 + ======================= 4 + 5 + The power capping framework provides a consistent interface between the kernel 6 + and the user space that allows power capping drivers to expose the settings to 7 + user space in a uniform way. 8 + 9 + Terminology 10 + =========== 11 + 12 + The framework exposes power capping devices to user space via sysfs in the 13 + form of a tree of objects. The objects at the root level of the tree represent 14 + 'control types', which correspond to different methods of power capping. For 15 + example, the intel-rapl control type represents the Intel "Running Average 16 + Power Limit" (RAPL) technology, whereas the 'idle-injection' control type 17 + corresponds to the use of idle injection for controlling power. 18 + 19 + Power zones represent different parts of the system, which can be controlled and 20 + monitored using the power capping method determined by the control type the 21 + given zone belongs to. They each contain attributes for monitoring power, as 22 + well as controls represented in the form of power constraints. If the parts of 23 + the system represented by different power zones are hierarchical (that is, one 24 + bigger part consists of multiple smaller parts that each have their own power 25 + controls), those power zones may also be organized in a hierarchy with one 26 + parent power zone containing multiple subzones and so on to reflect the power 27 + control topology of the system. In that case, it is possible to apply power 28 + capping to a set of devices together using the parent power zone and if more 29 + fine grained control is required, it can be applied through the subzones. 30 + 31 + 32 + Example sysfs interface tree:: 33 + 34 + /sys/devices/virtual/powercap 35 + └──intel-rapl 36 + ├──intel-rapl:0 37 + │   ├──constraint_0_name 38 + │   ├──constraint_0_power_limit_uw 39 + │   ├──constraint_0_time_window_us 40 + │   ├──constraint_1_name 41 + │   ├──constraint_1_power_limit_uw 42 + │   ├──constraint_1_time_window_us 43 + │   ├──device -> ../../intel-rapl 44 + │   ├──energy_uj 45 + │   ├──intel-rapl:0:0 46 + │   │   ├──constraint_0_name 47 + │   │   ├──constraint_0_power_limit_uw 48 + │   │   ├──constraint_0_time_window_us 49 + │   │   ├──constraint_1_name 50 + │   │   ├──constraint_1_power_limit_uw 51 + │   │   ├──constraint_1_time_window_us 52 + │   │   ├──device -> ../../intel-rapl:0 53 + │   │   ├──energy_uj 54 + │   │   ├──max_energy_range_uj 55 + │   │   ├──name 56 + │   │   ├──enabled 57 + │   │   ├──power 58 + │   │   │   ├──async 59 + │   │   │   [] 60 + │   │   ├──subsystem -> ../../../../../../class/power_cap 61 + │   │   └──uevent 62 + │   ├──intel-rapl:0:1 63 + │   │   ├──constraint_0_name 64 + │   │   ├──constraint_0_power_limit_uw 65 + │   │   ├──constraint_0_time_window_us 66 + │   │   ├──constraint_1_name 67 + │   │   ├──constraint_1_power_limit_uw 68 + │   │   ├──constraint_1_time_window_us 69 + │   │   ├──device -> ../../intel-rapl:0 70 + │   │   ├──energy_uj 71 + │   │   ├──max_energy_range_uj 72 + │   │   ├──name 73 + │   │   ├──enabled 74 + │   │   ├──power 75 + │   │   │   ├──async 76 + │   │   │   [] 77 + │   │   ├──subsystem -> ../../../../../../class/power_cap 78 + │   │   └──uevent 79 + │   ├──max_energy_range_uj 80 + │   ├──max_power_range_uw 81 + │   ├──name 82 + │   ├──enabled 83 + │   ├──power 84 + │   │   ├──async 85 + │   │   [] 86 + │   ├──subsystem -> ../../../../../class/power_cap 87 + │   ├──enabled 88 + │   ├──uevent 89 + ├──intel-rapl:1 90 + │   ├──constraint_0_name 91 + │   ├──constraint_0_power_limit_uw 92 + │   ├──constraint_0_time_window_us 93 + │   ├──constraint_1_name 94 + │   ├──constraint_1_power_limit_uw 95 + │   ├──constraint_1_time_window_us 96 + │   ├──device -> ../../intel-rapl 97 + │   ├──energy_uj 98 + │   ├──intel-rapl:1:0 99 + │   │   ├──constraint_0_name 100 + │   │   ├──constraint_0_power_limit_uw 101 + │   │   ├──constraint_0_time_window_us 102 + │   │   ├──constraint_1_name 103 + │   │   ├──constraint_1_power_limit_uw 104 + │   │   ├──constraint_1_time_window_us 105 + │   │   ├──device -> ../../intel-rapl:1 106 + │   │   ├──energy_uj 107 + │   │   ├──max_energy_range_uj 108 + │   │   ├──name 109 + │   │   ├──enabled 110 + │   │   ├──power 111 + │   │   │   ├──async 112 + │   │   │   [] 113 + │   │   ├──subsystem -> ../../../../../../class/power_cap 114 + │   │   └──uevent 115 + │   ├──intel-rapl:1:1 116 + │   │   ├──constraint_0_name 117 + │   │   ├──constraint_0_power_limit_uw 118 + │   │   ├──constraint_0_time_window_us 119 + │   │   ├──constraint_1_name 120 + │   │   ├──constraint_1_power_limit_uw 121 + │   │   ├──constraint_1_time_window_us 122 + │   │   ├──device -> ../../intel-rapl:1 123 + │   │   ├──energy_uj 124 + │   │   ├──max_energy_range_uj 125 + │   │   ├──name 126 + │   │   ├──enabled 127 + │   │   ├──power 128 + │   │   │   ├──async 129 + │   │   │   [] 130 + │   │   ├──subsystem -> ../../../../../../class/power_cap 131 + │   │   └──uevent 132 + │   ├──max_energy_range_uj 133 + │   ├──max_power_range_uw 134 + │   ├──name 135 + │   ├──enabled 136 + │   ├──power 137 + │   │   ├──async 138 + │   │   [] 139 + │   ├──subsystem -> ../../../../../class/power_cap 140 + │   ├──uevent 141 + ├──power 142 + │   ├──async 143 + │   [] 144 + ├──subsystem -> ../../../../class/power_cap 145 + ├──enabled 146 + └──uevent 147 + 148 + The above example illustrates a case in which the Intel RAPL technology, 149 + available in Intel® IA-64 and IA-32 Processor Architectures, is used. There is one 150 + control type called intel-rapl which contains two power zones, intel-rapl:0 and 151 + intel-rapl:1, representing CPU packages. Each of these power zones contains 152 + two subzones, intel-rapl:j:0 and intel-rapl:j:1 (j = 0, 1), representing the 153 + "core" and the "uncore" parts of the given CPU package, respectively. All of 154 + the zones and subzones contain energy monitoring attributes (energy_uj, 155 + max_energy_range_uj) and constraint attributes (constraint_*) allowing controls 156 + to be applied (the constraints in the 'package' power zones apply to the whole 157 + CPU packages and the subzone constraints only apply to the respective parts of 158 + the given package individually). Since Intel RAPL doesn't provide instantaneous 159 + power value, there is no power_uw attribute. 160 + 161 + In addition to that, each power zone contains a name attribute, allowing the 162 + part of the system represented by that zone to be identified. 163 + For example:: 164 + 165 + cat /sys/class/power_cap/intel-rapl/intel-rapl:0/name 166 + 167 + package-0 168 + --------- 169 + 170 + The Intel RAPL technology allows two constraints, short term and long term, 171 + with two different time windows to be applied to each power zone. Thus for 172 + each zone there are 2 attributes representing the constraint names, 2 power 173 + limits and 2 attributes representing the sizes of the time windows. Such that, 174 + constraint_j_* attributes correspond to the jth constraint (j = 0,1). 175 + 176 + For example:: 177 + 178 + constraint_0_name 179 + constraint_0_power_limit_uw 180 + constraint_0_time_window_us 181 + constraint_1_name 182 + constraint_1_power_limit_uw 183 + constraint_1_time_window_us 184 + 185 + Power Zone Attributes 186 + ===================== 187 + 188 + Monitoring attributes 189 + --------------------- 190 + 191 + energy_uj (rw) 192 + Current energy counter in micro joules. Write "0" to reset. 193 + If the counter can not be reset, then this attribute is read only. 194 + 195 + max_energy_range_uj (ro) 196 + Range of the above energy counter in micro-joules. 197 + 198 + power_uw (ro) 199 + Current power in micro watts. 200 + 201 + max_power_range_uw (ro) 202 + Range of the above power value in micro-watts. 203 + 204 + name (ro) 205 + Name of this power zone. 206 + 207 + It is possible that some domains have both power ranges and energy counter ranges; 208 + however, only one is mandatory. 209 + 210 + Constraints 211 + ----------- 212 + 213 + constraint_X_power_limit_uw (rw) 214 + Power limit in micro watts, which should be applicable for the 215 + time window specified by "constraint_X_time_window_us". 216 + 217 + constraint_X_time_window_us (rw) 218 + Time window in micro seconds. 219 + 220 + constraint_X_name (ro) 221 + An optional name of the constraint 222 + 223 + constraint_X_max_power_uw(ro) 224 + Maximum allowed power in micro watts. 225 + 226 + constraint_X_min_power_uw(ro) 227 + Minimum allowed power in micro watts. 228 + 229 + constraint_X_max_time_window_us(ro) 230 + Maximum allowed time window in micro seconds. 231 + 232 + constraint_X_min_time_window_us(ro) 233 + Minimum allowed time window in micro seconds. 234 + 235 + Except power_limit_uw and time_window_us other fields are optional. 236 + 237 + Common zone and control type attributes 238 + --------------------------------------- 239 + 240 + enabled (rw): Enable/Disable controls at zone level or for all zones using 241 + a control type. 242 + 243 + Power Cap Client Driver Interface 244 + ================================= 245 + 246 + The API summary: 247 + 248 + Call powercap_register_control_type() to register control type object. 249 + Call powercap_register_zone() to register a power zone (under a given 250 + control type), either as a top-level power zone or as a subzone of another 251 + power zone registered earlier. 252 + The number of constraints in a power zone and the corresponding callbacks have 253 + to be defined prior to calling powercap_register_zone() to register that zone. 254 + 255 + To Free a power zone call powercap_unregister_zone(). 256 + To free a control type object call powercap_unregister_control_type(). 257 + Detailed API can be generated using kernel-doc on include/linux/powercap.h.
-236
Documentation/power/powercap/powercap.txt
··· 1 - Power Capping Framework 2 - ================================== 3 - 4 - The power capping framework provides a consistent interface between the kernel 5 - and the user space that allows power capping drivers to expose the settings to 6 - user space in a uniform way. 7 - 8 - Terminology 9 - ========================= 10 - The framework exposes power capping devices to user space via sysfs in the 11 - form of a tree of objects. The objects at the root level of the tree represent 12 - 'control types', which correspond to different methods of power capping. For 13 - example, the intel-rapl control type represents the Intel "Running Average 14 - Power Limit" (RAPL) technology, whereas the 'idle-injection' control type 15 - corresponds to the use of idle injection for controlling power. 16 - 17 - Power zones represent different parts of the system, which can be controlled and 18 - monitored using the power capping method determined by the control type the 19 - given zone belongs to. They each contain attributes for monitoring power, as 20 - well as controls represented in the form of power constraints. If the parts of 21 - the system represented by different power zones are hierarchical (that is, one 22 - bigger part consists of multiple smaller parts that each have their own power 23 - controls), those power zones may also be organized in a hierarchy with one 24 - parent power zone containing multiple subzones and so on to reflect the power 25 - control topology of the system. In that case, it is possible to apply power 26 - capping to a set of devices together using the parent power zone and if more 27 - fine grained control is required, it can be applied through the subzones. 28 - 29 - 30 - Example sysfs interface tree: 31 - 32 - /sys/devices/virtual/powercap 33 - ??? intel-rapl 34 - ??? intel-rapl:0 35 - ?   ??? constraint_0_name 36 - ?   ??? constraint_0_power_limit_uw 37 - ?   ??? constraint_0_time_window_us 38 - ?   ??? constraint_1_name 39 - ?   ??? constraint_1_power_limit_uw 40 - ?   ??? constraint_1_time_window_us 41 - ?   ??? device -> ../../intel-rapl 42 - ?   ??? energy_uj 43 - ?   ??? intel-rapl:0:0 44 - ?   ?   ??? constraint_0_name 45 - ?   ?   ??? constraint_0_power_limit_uw 46 - ?   ?   ??? constraint_0_time_window_us 47 - ?   ?   ??? constraint_1_name 48 - ?   ?   ??? constraint_1_power_limit_uw 49 - ?   ?   ??? constraint_1_time_window_us 50 - ?   ?   ??? device -> ../../intel-rapl:0 51 - ?   ?   ??? energy_uj 52 - ?   ?   ??? max_energy_range_uj 53 - ?   ?   ??? name 54 - ?   ?   ??? enabled 55 - ?   ?   ??? power 56 - ?   ?   ?   ??? async 57 - ?   ?   ?   [] 58 - ?   ?   ??? subsystem -> ../../../../../../class/power_cap 59 - ?   ?   ??? uevent 60 - ?   ??? intel-rapl:0:1 61 - ?   ?   ??? constraint_0_name 62 - ?   ?   ??? constraint_0_power_limit_uw 63 - ?   ?   ??? constraint_0_time_window_us 64 - ?   ?   ??? constraint_1_name 65 - ?   ?   ??? constraint_1_power_limit_uw 66 - ?   ?   ??? constraint_1_time_window_us 67 - ?   ?   ??? device -> ../../intel-rapl:0 68 - ?   ?   ??? energy_uj 69 - ?   ?   ??? max_energy_range_uj 70 - ?   ?   ??? name 71 - ?   ?   ??? enabled 72 - ?   ?   ??? power 73 - ?   ?   ?   ??? async 74 - ?   ?   ?   [] 75 - ?   ?   ??? subsystem -> ../../../../../../class/power_cap 76 - ?   ?   ??? uevent 77 - ?   ??? max_energy_range_uj 78 - ?   ??? max_power_range_uw 79 - ?   ??? name 80 - ?   ??? enabled 81 - ?   ??? power 82 - ?   ?   ??? async 83 - ?   ?   [] 84 - ?   ??? subsystem -> ../../../../../class/power_cap 85 - ?   ??? enabled 86 - ?   ??? uevent 87 - ??? intel-rapl:1 88 - ?   ??? constraint_0_name 89 - ?   ??? constraint_0_power_limit_uw 90 - ?   ??? constraint_0_time_window_us 91 - ?   ??? constraint_1_name 92 - ?   ??? constraint_1_power_limit_uw 93 - ?   ??? constraint_1_time_window_us 94 - ?   ??? device -> ../../intel-rapl 95 - ?   ??? energy_uj 96 - ?   ??? intel-rapl:1:0 97 - ?   ?   ??? constraint_0_name 98 - ?   ?   ??? constraint_0_power_limit_uw 99 - ?   ?   ??? constraint_0_time_window_us 100 - ?   ?   ??? constraint_1_name 101 - ?   ?   ??? constraint_1_power_limit_uw 102 - ?   ?   ??? constraint_1_time_window_us 103 - ?   ?   ??? device -> ../../intel-rapl:1 104 - ?   ?   ??? energy_uj 105 - ?   ?   ??? max_energy_range_uj 106 - ?   ?   ??? name 107 - ?   ?   ??? enabled 108 - ?   ?   ??? power 109 - ?   ?   ?   ??? async 110 - ?   ?   ?   [] 111 - ?   ?   ??? subsystem -> ../../../../../../class/power_cap 112 - ?   ?   ??? uevent 113 - ?   ??? intel-rapl:1:1 114 - ?   ?   ??? constraint_0_name 115 - ?   ?   ??? constraint_0_power_limit_uw 116 - ?   ?   ??? constraint_0_time_window_us 117 - ?   ?   ??? constraint_1_name 118 - ?   ?   ??? constraint_1_power_limit_uw 119 - ?   ?   ??? constraint_1_time_window_us 120 - ?   ?   ??? device -> ../../intel-rapl:1 121 - ?   ?   ??? energy_uj 122 - ?   ?   ??? max_energy_range_uj 123 - ?   ?   ??? name 124 - ?   ?   ??? enabled 125 - ?   ?   ??? power 126 - ?   ?   ?   ??? async 127 - ?   ?   ?   [] 128 - ?   ?   ??? subsystem -> ../../../../../../class/power_cap 129 - ?   ?   ??? uevent 130 - ?   ??? max_energy_range_uj 131 - ?   ??? max_power_range_uw 132 - ?   ??? name 133 - ?   ??? enabled 134 - ?   ??? power 135 - ?   ?   ??? async 136 - ?   ?   [] 137 - ?   ??? subsystem -> ../../../../../class/power_cap 138 - ?   ??? uevent 139 - ??? power 140 - ?   ??? async 141 - ?   [] 142 - ??? subsystem -> ../../../../class/power_cap 143 - ??? enabled 144 - ??? uevent 145 - 146 - The above example illustrates a case in which the Intel RAPL technology, 147 - available in Intel® IA-64 and IA-32 Processor Architectures, is used. There is one 148 - control type called intel-rapl which contains two power zones, intel-rapl:0 and 149 - intel-rapl:1, representing CPU packages. Each of these power zones contains 150 - two subzones, intel-rapl:j:0 and intel-rapl:j:1 (j = 0, 1), representing the 151 - "core" and the "uncore" parts of the given CPU package, respectively. All of 152 - the zones and subzones contain energy monitoring attributes (energy_uj, 153 - max_energy_range_uj) and constraint attributes (constraint_*) allowing controls 154 - to be applied (the constraints in the 'package' power zones apply to the whole 155 - CPU packages and the subzone constraints only apply to the respective parts of 156 - the given package individually). Since Intel RAPL doesn't provide instantaneous 157 - power value, there is no power_uw attribute. 158 - 159 - In addition to that, each power zone contains a name attribute, allowing the 160 - part of the system represented by that zone to be identified. 161 - For example: 162 - 163 - cat /sys/class/power_cap/intel-rapl/intel-rapl:0/name 164 - package-0 165 - 166 - The Intel RAPL technology allows two constraints, short term and long term, 167 - with two different time windows to be applied to each power zone. Thus for 168 - each zone there are 2 attributes representing the constraint names, 2 power 169 - limits and 2 attributes representing the sizes of the time windows. Such that, 170 - constraint_j_* attributes correspond to the jth constraint (j = 0,1). 171 - 172 - For example: 173 - constraint_0_name 174 - constraint_0_power_limit_uw 175 - constraint_0_time_window_us 176 - constraint_1_name 177 - constraint_1_power_limit_uw 178 - constraint_1_time_window_us 179 - 180 - Power Zone Attributes 181 - ================================= 182 - Monitoring attributes 183 - ---------------------- 184 - 185 - energy_uj (rw): Current energy counter in micro joules. Write "0" to reset. 186 - If the counter can not be reset, then this attribute is read only. 187 - 188 - max_energy_range_uj (ro): Range of the above energy counter in micro-joules. 189 - 190 - power_uw (ro): Current power in micro watts. 191 - 192 - max_power_range_uw (ro): Range of the above power value in micro-watts. 193 - 194 - name (ro): Name of this power zone. 195 - 196 - It is possible that some domains have both power ranges and energy counter ranges; 197 - however, only one is mandatory. 198 - 199 - Constraints 200 - ---------------- 201 - constraint_X_power_limit_uw (rw): Power limit in micro watts, which should be 202 - applicable for the time window specified by "constraint_X_time_window_us". 203 - 204 - constraint_X_time_window_us (rw): Time window in micro seconds. 205 - 206 - constraint_X_name (ro): An optional name of the constraint 207 - 208 - constraint_X_max_power_uw(ro): Maximum allowed power in micro watts. 209 - 210 - constraint_X_min_power_uw(ro): Minimum allowed power in micro watts. 211 - 212 - constraint_X_max_time_window_us(ro): Maximum allowed time window in micro seconds. 213 - 214 - constraint_X_min_time_window_us(ro): Minimum allowed time window in micro seconds. 215 - 216 - Except power_limit_uw and time_window_us other fields are optional. 217 - 218 - Common zone and control type attributes 219 - ---------------------------------------- 220 - enabled (rw): Enable/Disable controls at zone level or for all zones using 221 - a control type. 222 - 223 - Power Cap Client Driver Interface 224 - ================================== 225 - The API summary: 226 - 227 - Call powercap_register_control_type() to register control type object. 228 - Call powercap_register_zone() to register a power zone (under a given 229 - control type), either as a top-level power zone or as a subzone of another 230 - power zone registered earlier. 231 - The number of constraints in a power zone and the corresponding callbacks have 232 - to be defined prior to calling powercap_register_zone() to register that zone. 233 - 234 - To Free a power zone call powercap_unregister_zone(). 235 - To free a control type object call powercap_unregister_control_type(). 236 - Detailed API can be generated using kernel-doc on include/linux/powercap.h.
+76 -65
Documentation/power/regulator/consumer.txt Documentation/power/regulator/consumer.rst
··· 1 + =================================== 1 2 Regulator Consumer Driver Interface 2 3 =================================== 3 4 ··· 9 8 1. Consumer Regulator Access (static & dynamic drivers) 10 9 ======================================================= 11 10 12 - A consumer driver can get access to its supply regulator by calling :- 11 + A consumer driver can get access to its supply regulator by calling :: 13 12 14 - regulator = regulator_get(dev, "Vcc"); 13 + regulator = regulator_get(dev, "Vcc"); 15 14 16 15 The consumer passes in its struct device pointer and power supply ID. The core 17 16 then finds the correct regulator by consulting a machine specific lookup table. 18 17 If the lookup is successful then this call will return a pointer to the struct 19 18 regulator that supplies this consumer. 20 19 21 - To release the regulator the consumer driver should call :- 20 + To release the regulator the consumer driver should call :: 22 21 23 - regulator_put(regulator); 22 + regulator_put(regulator); 24 23 25 24 Consumers can be supplied by more than one regulator e.g. codec consumer with 26 - analog and digital supplies :- 25 + analog and digital supplies :: 27 26 28 - digital = regulator_get(dev, "Vcc"); /* digital core */ 29 - analog = regulator_get(dev, "Avdd"); /* analog */ 27 + digital = regulator_get(dev, "Vcc"); /* digital core */ 28 + analog = regulator_get(dev, "Avdd"); /* analog */ 30 29 31 30 The regulator access functions regulator_get() and regulator_put() will 32 31 usually be called in your device drivers probe() and remove() respectively. 33 32 34 33 35 34 2. Regulator Output Enable & Disable (static & dynamic drivers) 36 - ==================================================================== 35 + =============================================================== 37 36 38 - A consumer can enable its power supply by calling:- 39 37 40 - int regulator_enable(regulator); 38 + A consumer can enable its power supply by calling:: 41 39 42 - NOTE: The supply may already be enabled before regulator_enabled() is called. 43 - This may happen if the consumer shares the regulator or the regulator has been 44 - previously enabled by bootloader or kernel board initialization code. 40 + int regulator_enable(regulator); 45 41 46 - A consumer can determine if a regulator is enabled by calling :- 42 + NOTE: 43 + The supply may already be enabled before regulator_enabled() is called. 44 + This may happen if the consumer shares the regulator or the regulator has been 45 + previously enabled by bootloader or kernel board initialization code. 47 46 48 - int regulator_is_enabled(regulator); 47 + A consumer can determine if a regulator is enabled by calling:: 48 + 49 + int regulator_is_enabled(regulator); 49 50 50 51 This will return > zero when the regulator is enabled. 51 52 52 53 53 - A consumer can disable its supply when no longer needed by calling :- 54 + A consumer can disable its supply when no longer needed by calling:: 54 55 55 - int regulator_disable(regulator); 56 + int regulator_disable(regulator); 56 57 57 - NOTE: This may not disable the supply if it's shared with other consumers. The 58 - regulator will only be disabled when the enabled reference count is zero. 58 + NOTE: 59 + This may not disable the supply if it's shared with other consumers. The 60 + regulator will only be disabled when the enabled reference count is zero. 59 61 60 - Finally, a regulator can be forcefully disabled in the case of an emergency :- 62 + Finally, a regulator can be forcefully disabled in the case of an emergency:: 61 63 62 - int regulator_force_disable(regulator); 64 + int regulator_force_disable(regulator); 63 65 64 - NOTE: this will immediately and forcefully shutdown the regulator output. All 65 - consumers will be powered off. 66 + NOTE: 67 + this will immediately and forcefully shutdown the regulator output. All 68 + consumers will be powered off. 66 69 67 70 68 71 3. Regulator Voltage Control & Status (dynamic drivers) 69 - ====================================================== 72 + ======================================================= 70 73 71 74 Some consumer drivers need to be able to dynamically change their supply 72 75 voltage to match system operating points. e.g. CPUfreq drivers can scale 73 76 voltage along with frequency to save power, SD drivers may need to select the 74 77 correct card voltage, etc. 75 78 76 - Consumers can control their supply voltage by calling :- 79 + Consumers can control their supply voltage by calling:: 77 80 78 - int regulator_set_voltage(regulator, min_uV, max_uV); 81 + int regulator_set_voltage(regulator, min_uV, max_uV); 79 82 80 83 Where min_uV and max_uV are the minimum and maximum acceptable voltages in 81 84 microvolts. ··· 89 84 configuration changes and the voltage is physically set when the regulator is 90 85 next enabled. 91 86 92 - The regulators configured voltage output can be found by calling :- 87 + The regulators configured voltage output can be found by calling:: 93 88 94 - int regulator_get_voltage(regulator); 89 + int regulator_get_voltage(regulator); 95 90 96 - NOTE: get_voltage() will return the configured output voltage whether the 97 - regulator is enabled or disabled and should NOT be used to determine regulator 98 - output state. However this can be used in conjunction with is_enabled() to 99 - determine the regulator physical output voltage. 91 + NOTE: 92 + get_voltage() will return the configured output voltage whether the 93 + regulator is enabled or disabled and should NOT be used to determine regulator 94 + output state. However this can be used in conjunction with is_enabled() to 95 + determine the regulator physical output voltage. 100 96 101 97 102 98 4. Regulator Current Limit Control & Status (dynamic drivers) 103 - =========================================================== 99 + ============================================================= 104 100 105 101 Some consumer drivers need to be able to dynamically change their supply 106 102 current limit to match system operating points. e.g. LCD backlight driver can 107 103 change the current limit to vary the backlight brightness, USB drivers may want 108 104 to set the limit to 500mA when supplying power. 109 105 110 - Consumers can control their supply current limit by calling :- 106 + Consumers can control their supply current limit by calling:: 111 107 112 - int regulator_set_current_limit(regulator, min_uA, max_uA); 108 + int regulator_set_current_limit(regulator, min_uA, max_uA); 113 109 114 110 Where min_uA and max_uA are the minimum and maximum acceptable current limit in 115 111 microamps. 116 112 117 - NOTE: this can be called when the regulator is enabled or disabled. If called 118 - when enabled, then the current limit changes instantly, otherwise the current 119 - limit configuration changes and the current limit is physically set when the 120 - regulator is next enabled. 113 + NOTE: 114 + this can be called when the regulator is enabled or disabled. If called 115 + when enabled, then the current limit changes instantly, otherwise the current 116 + limit configuration changes and the current limit is physically set when the 117 + regulator is next enabled. 121 118 122 - A regulators current limit can be found by calling :- 119 + A regulators current limit can be found by calling:: 123 120 124 - int regulator_get_current_limit(regulator); 121 + int regulator_get_current_limit(regulator); 125 122 126 - NOTE: get_current_limit() will return the current limit whether the regulator 127 - is enabled or disabled and should not be used to determine regulator current 128 - load. 123 + NOTE: 124 + get_current_limit() will return the current limit whether the regulator 125 + is enabled or disabled and should not be used to determine regulator current 126 + load. 129 127 130 128 131 129 5. Regulator Operating Mode Control & Status (dynamic drivers) 132 - ============================================================= 130 + ============================================================== 133 131 134 132 Some consumers can further save system power by changing the operating mode of 135 133 their supply regulator to be more efficient when the consumers operating state ··· 143 135 Indirect operating mode control. 144 136 -------------------------------- 145 137 Consumer drivers can request a change in their supply regulator operating mode 146 - by calling :- 138 + by calling:: 147 139 148 - int regulator_set_load(struct regulator *regulator, int load_uA); 140 + int regulator_set_load(struct regulator *regulator, int load_uA); 149 141 150 142 This will cause the core to recalculate the total load on the regulator (based 151 143 on all its consumers) and change operating mode (if necessary and permitted) ··· 161 153 162 154 Direct operating mode control. 163 155 ------------------------------ 156 + 164 157 Bespoke or tightly coupled drivers may want to directly control regulator 165 158 operating mode depending on their operating point. This can be achieved by 166 - calling :- 159 + calling:: 167 160 168 - int regulator_set_mode(struct regulator *regulator, unsigned int mode); 169 - unsigned int regulator_get_mode(struct regulator *regulator); 161 + int regulator_set_mode(struct regulator *regulator, unsigned int mode); 162 + unsigned int regulator_get_mode(struct regulator *regulator); 170 163 171 164 Direct mode will only be used by consumers that *know* about the regulator and 172 165 are not sharing the regulator with other consumers. ··· 175 166 176 167 6. Regulator Events 177 168 =================== 169 + 178 170 Regulators can notify consumers of external events. Events could be received by 179 171 consumers under regulator stress or failure conditions. 180 172 181 - Consumers can register interest in regulator events by calling :- 173 + Consumers can register interest in regulator events by calling:: 182 174 183 - int regulator_register_notifier(struct regulator *regulator, 184 - struct notifier_block *nb); 175 + int regulator_register_notifier(struct regulator *regulator, 176 + struct notifier_block *nb); 185 177 186 - Consumers can unregister interest by calling :- 178 + Consumers can unregister interest by calling:: 187 179 188 - int regulator_unregister_notifier(struct regulator *regulator, 189 - struct notifier_block *nb); 180 + int regulator_unregister_notifier(struct regulator *regulator, 181 + struct notifier_block *nb); 190 182 191 183 Regulators use the kernel notifier framework to send event to their interested 192 184 consumers. 193 185 194 186 7. Regulator Direct Register Access 195 187 =================================== 188 + 196 189 Some kinds of power management hardware or firmware are designed such that 197 190 they need to do low-level hardware access to regulators, with no involvement 198 191 from the kernel. Examples of such devices are: ··· 210 199 these details. 211 200 212 201 Bus-specific details, like I2C addresses or transfer rates are handled by the 213 - regmap framework. To get the regulator's regmap (if supported), use :- 202 + regmap framework. To get the regulator's regmap (if supported), use:: 214 203 215 - struct regmap *regulator_get_regmap(struct regulator *regulator); 204 + struct regmap *regulator_get_regmap(struct regulator *regulator); 216 205 217 206 To obtain the hardware register offset and bitmask for the regulator's voltage 218 - selector register, use :- 207 + selector register, use:: 219 208 220 - int regulator_get_hardware_vsel_register(struct regulator *regulator, 221 - unsigned *vsel_reg, 222 - unsigned *vsel_mask); 209 + int regulator_get_hardware_vsel_register(struct regulator *regulator, 210 + unsigned *vsel_reg, 211 + unsigned *vsel_mask); 223 212 224 213 To convert a regulator framework voltage selector code (used by 225 214 regulator_list_voltage) to a hardware-specific voltage selector that can be 226 - directly written to the voltage selector register, use :- 215 + directly written to the voltage selector register, use:: 227 216 228 - int regulator_list_hardware_vsel(struct regulator *regulator, 229 - unsigned selector); 217 + int regulator_list_hardware_vsel(struct regulator *regulator, 218 + unsigned selector);
+7 -2
Documentation/power/regulator/design.txt Documentation/power/regulator/design.rst
··· 1 + ========================== 1 2 Regulator API design notes 2 3 ========================== 3 4 ··· 15 14 have different power requirements, and not all components with power 16 15 requirements are visible to software. 17 16 18 - => The API should make no changes to the hardware state unless it has 17 + .. note:: 18 + 19 + The API should make no changes to the hardware state unless it has 19 20 specific knowledge that these changes are safe to perform on this 20 21 particular system. 21 22 ··· 31 28 - Many of the power supplies in the system will be shared between many 32 29 different consumers. 33 30 34 - => The consumer API should be structured so that these use cases are 31 + .. note:: 32 + 33 + The consumer API should be structured so that these use cases are 35 34 very easy to handle and so that consumers will work with shared 36 35 supplies without any additional effort.
+24 -23
Documentation/power/regulator/machine.txt Documentation/power/regulator/machine.rst
··· 1 + ================================== 1 2 Regulator Machine Driver Interface 2 - =================================== 3 + ================================== 3 4 4 5 The regulator machine driver interface is intended for board/machine specific 5 6 initialisation code to configure the regulator subsystem. 6 7 7 - Consider the following machine :- 8 + Consider the following machine:: 8 9 9 10 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V] 10 11 | ··· 14 13 The drivers for consumers A & B must be mapped to the correct regulator in 15 14 order to control their power supplies. This mapping can be achieved in machine 16 15 initialisation code by creating a struct regulator_consumer_supply for 17 - each regulator. 16 + each regulator:: 18 17 19 - struct regulator_consumer_supply { 18 + struct regulator_consumer_supply { 20 19 const char *dev_name; /* consumer dev_name() */ 21 20 const char *supply; /* consumer supply - e.g. "vcc" */ 22 - }; 21 + }; 23 22 24 - e.g. for the machine above 23 + e.g. for the machine above:: 25 24 26 - static struct regulator_consumer_supply regulator1_consumers[] = { 25 + static struct regulator_consumer_supply regulator1_consumers[] = { 27 26 REGULATOR_SUPPLY("Vcc", "consumer B"), 28 - }; 27 + }; 29 28 30 - static struct regulator_consumer_supply regulator2_consumers[] = { 29 + static struct regulator_consumer_supply regulator2_consumers[] = { 31 30 REGULATOR_SUPPLY("Vcc", "consumer A"), 32 - }; 31 + }; 33 32 34 33 This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2 35 34 to the 'Vcc' supply for Consumer A. 36 35 37 36 Constraints can now be registered by defining a struct regulator_init_data 38 37 for each regulator power domain. This structure also maps the consumers 39 - to their supply regulators :- 38 + to their supply regulators:: 40 39 41 - static struct regulator_init_data regulator1_data = { 40 + static struct regulator_init_data regulator1_data = { 42 41 .constraints = { 43 42 .name = "Regulator-1", 44 43 .min_uV = 3300000, ··· 47 46 }, 48 47 .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers), 49 48 .consumer_supplies = regulator1_consumers, 50 - }; 49 + }; 51 50 52 51 The name field should be set to something that is usefully descriptive 53 52 for the board for configuration of supplies for other regulators and ··· 58 57 Regulator-1 supplies power to Regulator-2. This relationship must be registered 59 58 with the core so that Regulator-1 is also enabled when Consumer A enables its 60 59 supply (Regulator-2). The supply regulator is set by the supply_regulator 61 - field below and co:- 60 + field below and co:: 62 61 63 - static struct regulator_init_data regulator2_data = { 62 + static struct regulator_init_data regulator2_data = { 64 63 .supply_regulator = "Regulator-1", 65 64 .constraints = { 66 65 .min_uV = 1800000, ··· 70 69 }, 71 70 .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers), 72 71 .consumer_supplies = regulator2_consumers, 73 - }; 72 + }; 74 73 75 - Finally the regulator devices must be registered in the usual manner. 74 + Finally the regulator devices must be registered in the usual manner:: 76 75 77 - static struct platform_device regulator_devices[] = { 76 + static struct platform_device regulator_devices[] = { 78 77 { 79 78 .name = "regulator", 80 79 .id = DCDC_1, ··· 89 88 .platform_data = &regulator2_data, 90 89 }, 91 90 }, 92 - }; 93 - /* register regulator 1 device */ 94 - platform_device_register(&regulator_devices[0]); 91 + }; 92 + /* register regulator 1 device */ 93 + platform_device_register(&regulator_devices[0]); 95 94 96 - /* register regulator 2 device */ 97 - platform_device_register(&regulator_devices[1]); 95 + /* register regulator 2 device */ 96 + platform_device_register(&regulator_devices[1]);
+32 -25
Documentation/power/regulator/overview.txt Documentation/power/regulator/overview.rst
··· 1 + ============================================= 1 2 Linux voltage and current regulator framework 2 3 ============================================= 3 4 ··· 14 13 current limit is controllable). 15 14 16 15 (C) 2008 Wolfson Microelectronics PLC. 16 + 17 17 Author: Liam Girdwood <lrg@slimlogic.co.uk> 18 18 19 19 20 20 Nomenclature 21 21 ============ 22 22 23 - Some terms used in this document:- 23 + Some terms used in this document: 24 24 25 - o Regulator - Electronic device that supplies power to other devices. 25 + - Regulator 26 + - Electronic device that supplies power to other devices. 26 27 Most regulators can enable and disable their output while 27 28 some can control their output voltage and or current. 28 29 29 30 Input Voltage -> Regulator -> Output Voltage 30 31 31 32 32 - o PMIC - Power Management IC. An IC that contains numerous regulators 33 - and often contains other subsystems. 33 + - PMIC 34 + - Power Management IC. An IC that contains numerous 35 + regulators and often contains other subsystems. 34 36 35 37 36 - o Consumer - Electronic device that is supplied power by a regulator. 38 + - Consumer 39 + - Electronic device that is supplied power by a regulator. 37 40 Consumers can be classified into two types:- 38 41 39 42 Static: consumer does not change its supply voltage or ··· 49 44 current limit to meet operation demands. 50 45 51 46 52 - o Power Domain - Electronic circuit that is supplied its input power by the 47 + - Power Domain 48 + - Electronic circuit that is supplied its input power by the 53 49 output power of a regulator, switch or by another power 54 50 domain. 55 51 56 - The supply regulator may be behind a switch(s). i.e. 52 + The supply regulator may be behind a switch(s). i.e.:: 57 53 58 - Regulator -+-> Switch-1 -+-> Switch-2 --> [Consumer A] 59 - | | 60 - | +-> [Consumer B], [Consumer C] 61 - | 62 - +-> [Consumer D], [Consumer E] 54 + Regulator -+-> Switch-1 -+-> Switch-2 --> [Consumer A] 55 + | | 56 + | +-> [Consumer B], [Consumer C] 57 + | 58 + +-> [Consumer D], [Consumer E] 63 59 64 60 That is one regulator and three power domains: 65 61 66 - Domain 1: Switch-1, Consumers D & E. 67 - Domain 2: Switch-2, Consumers B & C. 68 - Domain 3: Consumer A. 62 + - Domain 1: Switch-1, Consumers D & E. 63 + - Domain 2: Switch-2, Consumers B & C. 64 + - Domain 3: Consumer A. 69 65 70 66 and this represents a "supplies" relationship: 71 67 72 68 Domain-1 --> Domain-2 --> Domain-3. 73 69 74 70 A power domain may have regulators that are supplied power 75 - by other regulators. i.e. 71 + by other regulators. i.e.:: 76 72 77 - Regulator-1 -+-> Regulator-2 -+-> [Consumer A] 78 - | 79 - +-> [Consumer B] 73 + Regulator-1 -+-> Regulator-2 -+-> [Consumer A] 74 + | 75 + +-> [Consumer B] 80 76 81 77 This gives us two regulators and two power domains: 82 78 83 - Domain 1: Regulator-2, Consumer B. 84 - Domain 2: Consumer A. 79 + - Domain 1: Regulator-2, Consumer B. 80 + - Domain 2: Consumer A. 85 81 86 82 and a "supplies" relationship: 87 83 88 84 Domain-1 --> Domain-2 89 85 90 86 91 - o Constraints - Constraints are used to define power levels for performance 87 + - Constraints 88 + - Constraints are used to define power levels for performance 92 89 and hardware protection. Constraints exist at three levels: 93 90 94 91 Regulator Level: This is defined by the regulator hardware ··· 148 141 limit. This also compiles out if not in use so drivers can be reused in 149 142 systems with no regulator based power control. 150 143 151 - See Documentation/power/regulator/consumer.txt 144 + See Documentation/power/regulator/consumer.rst 152 145 153 146 2. Regulator driver interface. 154 147 ··· 156 149 operations to the core. It also has a notifier call chain for propagating 157 150 regulator events to clients. 158 151 159 - See Documentation/power/regulator/regulator.txt 152 + See Documentation/power/regulator/regulator.rst 160 153 161 154 3. Machine interface. 162 155 ··· 167 160 allows the creation of a regulator tree whereby some regulators are 168 161 supplied by others (similar to a clock tree). 169 162 170 - See Documentation/power/regulator/machine.txt 163 + See Documentation/power/regulator/machine.rst 171 164 172 165 4. Userspace ABI. 173 166
+32
Documentation/power/regulator/regulator.rst
··· 1 + ========================== 2 + Regulator Driver Interface 3 + ========================== 4 + 5 + The regulator driver interface is relatively simple and designed to allow 6 + regulator drivers to register their services with the core framework. 7 + 8 + 9 + Registration 10 + ============ 11 + 12 + Drivers can register a regulator by calling:: 13 + 14 + struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, 15 + const struct regulator_config *config); 16 + 17 + This will register the regulator's capabilities and operations to the regulator 18 + core. 19 + 20 + Regulators can be unregistered by calling:: 21 + 22 + void regulator_unregister(struct regulator_dev *rdev); 23 + 24 + 25 + Regulator Events 26 + ================ 27 + 28 + Regulators can send events (e.g. overtemperature, undervoltage, etc) to 29 + consumer drivers by calling:: 30 + 31 + int regulator_notifier_call_chain(struct regulator_dev *rdev, 32 + unsigned long event, void *data);
-30
Documentation/power/regulator/regulator.txt
··· 1 - Regulator Driver Interface 2 - ========================== 3 - 4 - The regulator driver interface is relatively simple and designed to allow 5 - regulator drivers to register their services with the core framework. 6 - 7 - 8 - Registration 9 - ============ 10 - 11 - Drivers can register a regulator by calling :- 12 - 13 - struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, 14 - const struct regulator_config *config); 15 - 16 - This will register the regulator's capabilities and operations to the regulator 17 - core. 18 - 19 - Regulators can be unregistered by calling :- 20 - 21 - void regulator_unregister(struct regulator_dev *rdev); 22 - 23 - 24 - Regulator Events 25 - ================ 26 - Regulators can send events (e.g. overtemperature, undervoltage, etc) to 27 - consumer drivers by calling :- 28 - 29 - int regulator_notifier_call_chain(struct regulator_dev *rdev, 30 - unsigned long event, void *data);
+123 -111
Documentation/power/runtime_pm.txt Documentation/power/runtime_pm.rst
··· 1 + ================================================== 1 2 Runtime Power Management Framework for I/O Devices 3 + ================================================== 2 4 3 5 (C) 2009-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. 6 + 4 7 (C) 2010 Alan Stern <stern@rowland.harvard.edu> 8 + 5 9 (C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> 6 10 7 11 1. Introduction 12 + =============== 8 13 9 14 Support for runtime power management (runtime PM) of I/O devices is provided 10 15 at the power management core (PM core) level by means of: ··· 38 33 runtime PM are described below. 39 34 40 35 2. Device Runtime PM Callbacks 36 + ============================== 41 37 42 - There are three device runtime PM callbacks defined in 'struct dev_pm_ops': 38 + There are three device runtime PM callbacks defined in 'struct dev_pm_ops':: 43 39 44 - struct dev_pm_ops { 40 + struct dev_pm_ops { 45 41 ... 46 42 int (*runtime_suspend)(struct device *dev); 47 43 int (*runtime_resume)(struct device *dev); 48 44 int (*runtime_idle)(struct device *dev); 49 45 ... 50 - }; 46 + }; 51 47 52 48 The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks 53 49 are executed by the PM core for the device's subsystem that may be either of ··· 118 112 that remote wakeup will be enabled for the device. Generally, remote wakeup 119 113 should be enabled for all input devices put into low-power states at run time. 120 114 121 - The subsystem-level resume callback, if present, is _entirely_ _responsible_ for 115 + The subsystem-level resume callback, if present, is **entirely responsible** for 122 116 handling the resume of the device as appropriate, which may, but need not 123 117 include executing the device driver's own ->runtime_resume() callback (from the 124 118 PM core's point of view it is not necessary to implement a ->runtime_resume() ··· 203 197 except for scheduled autosuspends. 204 198 205 199 3. Runtime PM Device Fields 200 + =========================== 206 201 207 202 The following device runtime PM fields are present in 'struct dev_pm_info', as 208 203 defined in include/linux/pm.h: 209 204 210 - struct timer_list suspend_timer; 205 + `struct timer_list suspend_timer;` 211 206 - timer used for scheduling (delayed) suspend and autosuspend requests 212 207 213 - unsigned long timer_expires; 208 + `unsigned long timer_expires;` 214 209 - timer expiration time, in jiffies (if this is different from zero, the 215 210 timer is running and will expire at that time, otherwise the timer is not 216 211 running) 217 212 218 - struct work_struct work; 213 + `struct work_struct work;` 219 214 - work structure used for queuing up requests (i.e. work items in pm_wq) 220 215 221 - wait_queue_head_t wait_queue; 216 + `wait_queue_head_t wait_queue;` 222 217 - wait queue used if any of the helper functions needs to wait for another 223 218 one to complete 224 219 225 - spinlock_t lock; 220 + `spinlock_t lock;` 226 221 - lock used for synchronization 227 222 228 - atomic_t usage_count; 223 + `atomic_t usage_count;` 229 224 - the usage counter of the device 230 225 231 - atomic_t child_count; 226 + `atomic_t child_count;` 232 227 - the count of 'active' children of the device 233 228 234 - unsigned int ignore_children; 229 + `unsigned int ignore_children;` 235 230 - if set, the value of child_count is ignored (but still updated) 236 231 237 - unsigned int disable_depth; 232 + `unsigned int disable_depth;` 238 233 - used for disabling the helper functions (they work normally if this is 239 234 equal to zero); the initial value of it is 1 (i.e. runtime PM is 240 235 initially disabled for all devices) 241 236 242 - int runtime_error; 237 + `int runtime_error;` 243 238 - if set, there was a fatal error (one of the callbacks returned error code 244 239 as described in Section 2), so the helper functions will not work until 245 240 this flag is cleared; this is the error code returned by the failing 246 241 callback 247 242 248 - unsigned int idle_notification; 243 + `unsigned int idle_notification;` 249 244 - if set, ->runtime_idle() is being executed 250 245 251 - unsigned int request_pending; 246 + `unsigned int request_pending;` 252 247 - if set, there's a pending request (i.e. a work item queued up into pm_wq) 253 248 254 - enum rpm_request request; 249 + `enum rpm_request request;` 255 250 - type of request that's pending (valid if request_pending is set) 256 251 257 - unsigned int deferred_resume; 252 + `unsigned int deferred_resume;` 258 253 - set if ->runtime_resume() is about to be run while ->runtime_suspend() is 259 254 being executed for that device and it is not practical to wait for the 260 255 suspend to complete; means "start a resume as soon as you've suspended" 261 256 262 - enum rpm_status runtime_status; 257 + `enum rpm_status runtime_status;` 263 258 - the runtime PM status of the device; this field's initial value is 264 259 RPM_SUSPENDED, which means that each device is initially regarded by the 265 260 PM core as 'suspended', regardless of its real hardware status 266 261 267 - unsigned int runtime_auto; 262 + `unsigned int runtime_auto;` 268 263 - if set, indicates that the user space has allowed the device driver to 269 264 power manage the device at run time via the /sys/devices/.../power/control 270 - interface; it may only be modified with the help of the pm_runtime_allow() 265 + `interface;` it may only be modified with the help of the pm_runtime_allow() 271 266 and pm_runtime_forbid() helper functions 272 267 273 - unsigned int no_callbacks; 268 + `unsigned int no_callbacks;` 274 269 - indicates that the device does not use the runtime PM callbacks (see 275 270 Section 8); it may be modified only by the pm_runtime_no_callbacks() 276 271 helper function 277 272 278 - unsigned int irq_safe; 273 + `unsigned int irq_safe;` 279 274 - indicates that the ->runtime_suspend() and ->runtime_resume() callbacks 280 275 will be invoked with the spinlock held and interrupts disabled 281 276 282 - unsigned int use_autosuspend; 277 + `unsigned int use_autosuspend;` 283 278 - indicates that the device's driver supports delayed autosuspend (see 284 279 Section 9); it may be modified only by the 285 280 pm_runtime{_dont}_use_autosuspend() helper functions 286 281 287 - unsigned int timer_autosuspends; 282 + `unsigned int timer_autosuspends;` 288 283 - indicates that the PM core should attempt to carry out an autosuspend 289 284 when the timer expires rather than a normal suspend 290 285 291 - int autosuspend_delay; 286 + `int autosuspend_delay;` 292 287 - the delay time (in milliseconds) to be used for autosuspend 293 288 294 - unsigned long last_busy; 289 + `unsigned long last_busy;` 295 290 - the time (in jiffies) when the pm_runtime_mark_last_busy() helper 296 291 function was last called for this device; used in calculating inactivity 297 292 periods for autosuspend ··· 300 293 All of the above fields are members of the 'power' member of 'struct device'. 301 294 302 295 4. Runtime PM Device Helper Functions 296 + ===================================== 303 297 304 298 The following runtime PM helper functions are defined in 305 299 drivers/base/power/runtime.c and include/linux/pm_runtime.h: 306 300 307 - void pm_runtime_init(struct device *dev); 301 + `void pm_runtime_init(struct device *dev);` 308 302 - initialize the device runtime PM fields in 'struct dev_pm_info' 309 303 310 - void pm_runtime_remove(struct device *dev); 304 + `void pm_runtime_remove(struct device *dev);` 311 305 - make sure that the runtime PM of the device will be disabled after 312 306 removing the device from device hierarchy 313 307 314 - int pm_runtime_idle(struct device *dev); 308 + `int pm_runtime_idle(struct device *dev);` 315 309 - execute the subsystem-level idle callback for the device; returns an 316 310 error code on failure, where -EINPROGRESS means that ->runtime_idle() is 317 311 already being executed; if there is no callback or the callback returns 0 318 312 then run pm_runtime_autosuspend(dev) and return its result 319 313 320 - int pm_runtime_suspend(struct device *dev); 314 + `int pm_runtime_suspend(struct device *dev);` 321 315 - execute the subsystem-level suspend callback for the device; returns 0 on 322 316 success, 1 if the device's runtime PM status was already 'suspended', or 323 317 error code on failure, where -EAGAIN or -EBUSY means it is safe to attempt 324 318 to suspend the device again in future and -EACCES means that 325 319 'power.disable_depth' is different from 0 326 320 327 - int pm_runtime_autosuspend(struct device *dev); 321 + `int pm_runtime_autosuspend(struct device *dev);` 328 322 - same as pm_runtime_suspend() except that the autosuspend delay is taken 329 - into account; if pm_runtime_autosuspend_expiration() says the delay has 323 + `into account;` if pm_runtime_autosuspend_expiration() says the delay has 330 324 not yet expired then an autosuspend is scheduled for the appropriate time 331 325 and 0 is returned 332 326 333 - int pm_runtime_resume(struct device *dev); 327 + `int pm_runtime_resume(struct device *dev);` 334 328 - execute the subsystem-level resume callback for the device; returns 0 on 335 329 success, 1 if the device's runtime PM status was already 'active' or 336 330 error code on failure, where -EAGAIN means it may be safe to attempt to ··· 339 331 checked additionally, and -EACCES means that 'power.disable_depth' is 340 332 different from 0 341 333 342 - int pm_request_idle(struct device *dev); 334 + `int pm_request_idle(struct device *dev);` 343 335 - submit a request to execute the subsystem-level idle callback for the 344 336 device (the request is represented by a work item in pm_wq); returns 0 on 345 337 success or error code if the request has not been queued up 346 338 347 - int pm_request_autosuspend(struct device *dev); 339 + `int pm_request_autosuspend(struct device *dev);` 348 340 - schedule the execution of the subsystem-level suspend callback for the 349 341 device when the autosuspend delay has expired; if the delay has already 350 342 expired then the work item is queued up immediately 351 343 352 - int pm_schedule_suspend(struct device *dev, unsigned int delay); 344 + `int pm_schedule_suspend(struct device *dev, unsigned int delay);` 353 345 - schedule the execution of the subsystem-level suspend callback for the 354 346 device in future, where 'delay' is the time to wait before queuing up a 355 347 suspend work item in pm_wq, in milliseconds (if 'delay' is zero, the work ··· 359 351 ->runtime_suspend() is already scheduled and not yet expired, the new 360 352 value of 'delay' will be used as the time to wait 361 353 362 - int pm_request_resume(struct device *dev); 354 + `int pm_request_resume(struct device *dev);` 363 355 - submit a request to execute the subsystem-level resume callback for the 364 356 device (the request is represented by a work item in pm_wq); returns 0 on 365 357 success, 1 if the device's runtime PM status was already 'active', or 366 358 error code if the request hasn't been queued up 367 359 368 - void pm_runtime_get_noresume(struct device *dev); 360 + `void pm_runtime_get_noresume(struct device *dev);` 369 361 - increment the device's usage counter 370 362 371 - int pm_runtime_get(struct device *dev); 363 + `int pm_runtime_get(struct device *dev);` 372 364 - increment the device's usage counter, run pm_request_resume(dev) and 373 365 return its result 374 366 375 - int pm_runtime_get_sync(struct device *dev); 367 + `int pm_runtime_get_sync(struct device *dev);` 376 368 - increment the device's usage counter, run pm_runtime_resume(dev) and 377 369 return its result 378 370 379 - int pm_runtime_get_if_in_use(struct device *dev); 371 + `int pm_runtime_get_if_in_use(struct device *dev);` 380 372 - return -EINVAL if 'power.disable_depth' is nonzero; otherwise, if the 381 373 runtime PM status is RPM_ACTIVE and the runtime PM usage counter is 382 374 nonzero, increment the counter and return 1; otherwise return 0 without 383 375 changing the counter 384 376 385 - void pm_runtime_put_noidle(struct device *dev); 377 + `void pm_runtime_put_noidle(struct device *dev);` 386 378 - decrement the device's usage counter 387 379 388 - int pm_runtime_put(struct device *dev); 380 + `int pm_runtime_put(struct device *dev);` 389 381 - decrement the device's usage counter; if the result is 0 then run 390 382 pm_request_idle(dev) and return its result 391 383 392 - int pm_runtime_put_autosuspend(struct device *dev); 384 + `int pm_runtime_put_autosuspend(struct device *dev);` 393 385 - decrement the device's usage counter; if the result is 0 then run 394 386 pm_request_autosuspend(dev) and return its result 395 387 396 - int pm_runtime_put_sync(struct device *dev); 388 + `int pm_runtime_put_sync(struct device *dev);` 397 389 - decrement the device's usage counter; if the result is 0 then run 398 390 pm_runtime_idle(dev) and return its result 399 391 400 - int pm_runtime_put_sync_suspend(struct device *dev); 392 + `int pm_runtime_put_sync_suspend(struct device *dev);` 401 393 - decrement the device's usage counter; if the result is 0 then run 402 394 pm_runtime_suspend(dev) and return its result 403 395 404 - int pm_runtime_put_sync_autosuspend(struct device *dev); 396 + `int pm_runtime_put_sync_autosuspend(struct device *dev);` 405 397 - decrement the device's usage counter; if the result is 0 then run 406 398 pm_runtime_autosuspend(dev) and return its result 407 399 408 - void pm_runtime_enable(struct device *dev); 400 + `void pm_runtime_enable(struct device *dev);` 409 401 - decrement the device's 'power.disable_depth' field; if that field is equal 410 402 to zero, the runtime PM helper functions can execute subsystem-level 411 403 callbacks described in Section 2 for the device 412 404 413 - int pm_runtime_disable(struct device *dev); 405 + `int pm_runtime_disable(struct device *dev);` 414 406 - increment the device's 'power.disable_depth' field (if the value of that 415 407 field was previously zero, this prevents subsystem-level runtime PM 416 408 callbacks from being run for the device), make sure that all of the ··· 419 411 necessary to execute the subsystem-level resume callback for the device 420 412 to satisfy that request, otherwise 0 is returned 421 413 422 - int pm_runtime_barrier(struct device *dev); 414 + `int pm_runtime_barrier(struct device *dev);` 423 415 - check if there's a resume request pending for the device and resume it 424 416 (synchronously) in that case, cancel any other pending runtime PM requests 425 417 regarding it and wait for all runtime PM operations on it in progress to ··· 427 419 necessary to execute the subsystem-level resume callback for the device to 428 420 satisfy that request, otherwise 0 is returned 429 421 430 - void pm_suspend_ignore_children(struct device *dev, bool enable); 422 + `void pm_suspend_ignore_children(struct device *dev, bool enable);` 431 423 - set/unset the power.ignore_children flag of the device 432 424 433 - int pm_runtime_set_active(struct device *dev); 425 + `int pm_runtime_set_active(struct device *dev);` 434 426 - clear the device's 'power.runtime_error' flag, set the device's runtime 435 427 PM status to 'active' and update its parent's counter of 'active' 436 428 children as appropriate (it is only valid to use this function if ··· 438 430 zero); it will fail and return error code if the device has a parent 439 431 which is not active and the 'power.ignore_children' flag of which is unset 440 432 441 - void pm_runtime_set_suspended(struct device *dev); 433 + `void pm_runtime_set_suspended(struct device *dev);` 442 434 - clear the device's 'power.runtime_error' flag, set the device's runtime 443 435 PM status to 'suspended' and update its parent's counter of 'active' 444 436 children as appropriate (it is only valid to use this function if 445 437 'power.runtime_error' is set or 'power.disable_depth' is greater than 446 438 zero) 447 439 448 - bool pm_runtime_active(struct device *dev); 440 + `bool pm_runtime_active(struct device *dev);` 449 441 - return true if the device's runtime PM status is 'active' or its 450 442 'power.disable_depth' field is not equal to zero, or false otherwise 451 443 452 - bool pm_runtime_suspended(struct device *dev); 444 + `bool pm_runtime_suspended(struct device *dev);` 453 445 - return true if the device's runtime PM status is 'suspended' and its 454 446 'power.disable_depth' field is equal to zero, or false otherwise 455 447 456 - bool pm_runtime_status_suspended(struct device *dev); 448 + `bool pm_runtime_status_suspended(struct device *dev);` 457 449 - return true if the device's runtime PM status is 'suspended' 458 450 459 - void pm_runtime_allow(struct device *dev); 451 + `void pm_runtime_allow(struct device *dev);` 460 452 - set the power.runtime_auto flag for the device and decrease its usage 461 453 counter (used by the /sys/devices/.../power/control interface to 462 454 effectively allow the device to be power managed at run time) 463 455 464 - void pm_runtime_forbid(struct device *dev); 456 + `void pm_runtime_forbid(struct device *dev);` 465 457 - unset the power.runtime_auto flag for the device and increase its usage 466 458 counter (used by the /sys/devices/.../power/control interface to 467 459 effectively prevent the device from being power managed at run time) 468 460 469 - void pm_runtime_no_callbacks(struct device *dev); 461 + `void pm_runtime_no_callbacks(struct device *dev);` 470 462 - set the power.no_callbacks flag for the device and remove the runtime 471 463 PM attributes from /sys/devices/.../power (or prevent them from being 472 464 added when the device is registered) 473 465 474 - void pm_runtime_irq_safe(struct device *dev); 466 + `void pm_runtime_irq_safe(struct device *dev);` 475 467 - set the power.irq_safe flag for the device, causing the runtime-PM 476 468 callbacks to be invoked with interrupts off 477 469 478 - bool pm_runtime_is_irq_safe(struct device *dev); 470 + `bool pm_runtime_is_irq_safe(struct device *dev);` 479 471 - return true if power.irq_safe flag was set for the device, causing 480 472 the runtime-PM callbacks to be invoked with interrupts off 481 473 482 - void pm_runtime_mark_last_busy(struct device *dev); 474 + `void pm_runtime_mark_last_busy(struct device *dev);` 483 475 - set the power.last_busy field to the current time 484 476 485 - void pm_runtime_use_autosuspend(struct device *dev); 477 + `void pm_runtime_use_autosuspend(struct device *dev);` 486 478 - set the power.use_autosuspend flag, enabling autosuspend delays; call 487 479 pm_runtime_get_sync if the flag was previously cleared and 488 480 power.autosuspend_delay is negative 489 481 490 - void pm_runtime_dont_use_autosuspend(struct device *dev); 482 + `void pm_runtime_dont_use_autosuspend(struct device *dev);` 491 483 - clear the power.use_autosuspend flag, disabling autosuspend delays; 492 484 decrement the device's usage counter if the flag was previously set and 493 485 power.autosuspend_delay is negative; call pm_runtime_idle 494 486 495 - void pm_runtime_set_autosuspend_delay(struct device *dev, int delay); 487 + `void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);` 496 488 - set the power.autosuspend_delay value to 'delay' (expressed in 497 489 milliseconds); if 'delay' is negative then runtime suspends are 498 490 prevented; if power.use_autosuspend is set, pm_runtime_get_sync may be ··· 501 493 changed to or from a negative value; if power.use_autosuspend is clear, 502 494 pm_runtime_idle is called 503 495 504 - unsigned long pm_runtime_autosuspend_expiration(struct device *dev); 496 + `unsigned long pm_runtime_autosuspend_expiration(struct device *dev);` 505 497 - calculate the time when the current autosuspend delay period will expire, 506 498 based on power.last_busy and power.autosuspend_delay; if the delay time 507 499 is 1000 ms or larger then the expiration time is rounded up to the ··· 511 503 512 504 It is safe to execute the following helper functions from interrupt context: 513 505 514 - pm_request_idle() 515 - pm_request_autosuspend() 516 - pm_schedule_suspend() 517 - pm_request_resume() 518 - pm_runtime_get_noresume() 519 - pm_runtime_get() 520 - pm_runtime_put_noidle() 521 - pm_runtime_put() 522 - pm_runtime_put_autosuspend() 523 - pm_runtime_enable() 524 - pm_suspend_ignore_children() 525 - pm_runtime_set_active() 526 - pm_runtime_set_suspended() 527 - pm_runtime_suspended() 528 - pm_runtime_mark_last_busy() 529 - pm_runtime_autosuspend_expiration() 506 + - pm_request_idle() 507 + - pm_request_autosuspend() 508 + - pm_schedule_suspend() 509 + - pm_request_resume() 510 + - pm_runtime_get_noresume() 511 + - pm_runtime_get() 512 + - pm_runtime_put_noidle() 513 + - pm_runtime_put() 514 + - pm_runtime_put_autosuspend() 515 + - pm_runtime_enable() 516 + - pm_suspend_ignore_children() 517 + - pm_runtime_set_active() 518 + - pm_runtime_set_suspended() 519 + - pm_runtime_suspended() 520 + - pm_runtime_mark_last_busy() 521 + - pm_runtime_autosuspend_expiration() 530 522 531 523 If pm_runtime_irq_safe() has been called for a device then the following helper 532 524 functions may also be used in interrupt context: 533 525 534 - pm_runtime_idle() 535 - pm_runtime_suspend() 536 - pm_runtime_autosuspend() 537 - pm_runtime_resume() 538 - pm_runtime_get_sync() 539 - pm_runtime_put_sync() 540 - pm_runtime_put_sync_suspend() 541 - pm_runtime_put_sync_autosuspend() 526 + - pm_runtime_idle() 527 + - pm_runtime_suspend() 528 + - pm_runtime_autosuspend() 529 + - pm_runtime_resume() 530 + - pm_runtime_get_sync() 531 + - pm_runtime_put_sync() 532 + - pm_runtime_put_sync_suspend() 533 + - pm_runtime_put_sync_autosuspend() 542 534 543 535 5. Runtime PM Initialization, Device Probing and Removal 536 + ======================================================== 544 537 545 538 Initially, the runtime PM is disabled for all devices, which means that the 546 539 majority of the runtime PM helper functions described in Section 4 will return ··· 617 608 pm_runtime_forbid() this way. 618 609 619 610 6. Runtime PM and System Sleep 611 + ============================== 620 612 621 613 Runtime PM and system sleep (i.e., system suspend and hibernation, also known 622 614 as suspend-to-RAM and suspend-to-disk) interact with each other in a couple of ··· 657 647 to be updated to reflect the actual post-system sleep status. The way to do 658 648 this is: 659 649 660 - pm_runtime_disable(dev); 661 - pm_runtime_set_active(dev); 662 - pm_runtime_enable(dev); 650 + - pm_runtime_disable(dev); 651 + - pm_runtime_set_active(dev); 652 + - pm_runtime_enable(dev); 663 653 664 654 The PM core always increments the runtime usage counter before calling the 665 655 ->suspend() callback and decrements it after calling the ->resume() callback. ··· 715 705 management callbacks provided by the PM core, defined in 716 706 driver/base/power/generic_ops.c: 717 707 718 - int pm_generic_runtime_suspend(struct device *dev); 708 + `int pm_generic_runtime_suspend(struct device *dev);` 719 709 - invoke the ->runtime_suspend() callback provided by the driver of this 720 710 device and return its result, or return 0 if not defined 721 711 722 - int pm_generic_runtime_resume(struct device *dev); 712 + `int pm_generic_runtime_resume(struct device *dev);` 723 713 - invoke the ->runtime_resume() callback provided by the driver of this 724 714 device and return its result, or return 0 if not defined 725 715 726 - int pm_generic_suspend(struct device *dev); 716 + `int pm_generic_suspend(struct device *dev);` 727 717 - if the device has not been suspended at run time, invoke the ->suspend() 728 718 callback provided by its driver and return its result, or return 0 if not 729 719 defined 730 720 731 - int pm_generic_suspend_noirq(struct device *dev); 721 + `int pm_generic_suspend_noirq(struct device *dev);` 732 722 - if pm_runtime_suspended(dev) returns "false", invoke the ->suspend_noirq() 733 723 callback provided by the device's driver and return its result, or return 734 724 0 if not defined 735 725 736 - int pm_generic_resume(struct device *dev); 726 + `int pm_generic_resume(struct device *dev);` 737 727 - invoke the ->resume() callback provided by the driver of this device and, 738 728 if successful, change the device's runtime PM status to 'active' 739 729 740 - int pm_generic_resume_noirq(struct device *dev); 730 + `int pm_generic_resume_noirq(struct device *dev);` 741 731 - invoke the ->resume_noirq() callback provided by the driver of this device 742 732 743 - int pm_generic_freeze(struct device *dev); 733 + `int pm_generic_freeze(struct device *dev);` 744 734 - if the device has not been suspended at run time, invoke the ->freeze() 745 735 callback provided by its driver and return its result, or return 0 if not 746 736 defined 747 737 748 - int pm_generic_freeze_noirq(struct device *dev); 738 + `int pm_generic_freeze_noirq(struct device *dev);` 749 739 - if pm_runtime_suspended(dev) returns "false", invoke the ->freeze_noirq() 750 740 callback provided by the device's driver and return its result, or return 751 741 0 if not defined 752 742 753 - int pm_generic_thaw(struct device *dev); 743 + `int pm_generic_thaw(struct device *dev);` 754 744 - if the device has not been suspended at run time, invoke the ->thaw() 755 745 callback provided by its driver and return its result, or return 0 if not 756 746 defined 757 747 758 - int pm_generic_thaw_noirq(struct device *dev); 748 + `int pm_generic_thaw_noirq(struct device *dev);` 759 749 - if pm_runtime_suspended(dev) returns "false", invoke the ->thaw_noirq() 760 750 callback provided by the device's driver and return its result, or return 761 751 0 if not defined 762 752 763 - int pm_generic_poweroff(struct device *dev); 753 + `int pm_generic_poweroff(struct device *dev);` 764 754 - if the device has not been suspended at run time, invoke the ->poweroff() 765 755 callback provided by its driver and return its result, or return 0 if not 766 756 defined 767 757 768 - int pm_generic_poweroff_noirq(struct device *dev); 758 + `int pm_generic_poweroff_noirq(struct device *dev);` 769 759 - if pm_runtime_suspended(dev) returns "false", run the ->poweroff_noirq() 770 760 callback provided by the device's driver and return its result, or return 771 761 0 if not defined 772 762 773 - int pm_generic_restore(struct device *dev); 763 + `int pm_generic_restore(struct device *dev);` 774 764 - invoke the ->restore() callback provided by the driver of this device and, 775 765 if successful, change the device's runtime PM status to 'active' 776 766 777 - int pm_generic_restore_noirq(struct device *dev); 767 + `int pm_generic_restore_noirq(struct device *dev);` 778 768 - invoke the ->restore_noirq() callback provided by the device's driver 779 769 780 770 These functions are the defaults used by the PM core, if a subsystem doesn't ··· 791 781 last argument to NULL). 792 782 793 783 8. "No-Callback" Devices 784 + ======================== 794 785 795 786 Some "devices" are only logical sub-devices of their parent and cannot be 796 787 power-managed on their own. (The prototype example is a USB interface. Entire ··· 818 807 parent's power state changes. 819 808 820 809 9. Autosuspend, or automatically-delayed suspends 810 + ================================================= 821 811 822 812 Changing a device's power state isn't free; it requires both time and energy. 823 813 A device should be put in a low-power state only when there's some reason to ··· 844 832 845 833 In order to use autosuspend, subsystems or drivers must call 846 834 pm_runtime_use_autosuspend() (preferably before registering the device), and 847 - thereafter they should use the various *_autosuspend() helper functions instead 848 - of the non-autosuspend counterparts: 835 + thereafter they should use the various `*_autosuspend()` helper functions 836 + instead of the non-autosuspend counterparts:: 849 837 850 838 Instead of: pm_runtime_suspend use: pm_runtime_autosuspend; 851 839 Instead of: pm_schedule_suspend use: pm_request_autosuspend; ··· 870 858 However such use inevitably involves races, because the PM core can't 871 859 synchronize ->runtime_suspend() callbacks with the arrival of I/O requests. 872 860 This synchronization must be handled by the driver, using its private lock. 873 - Here is a schematic pseudo-code example: 861 + Here is a schematic pseudo-code example:: 874 862 875 863 foo_read_or_write(struct foo_priv *foo, void *data) 876 864 {
+11 -9
Documentation/power/s2ram.txt Documentation/power/s2ram.rst
··· 1 - How to get s2ram working 2 - ~~~~~~~~~~~~~~~~~~~~~~~~ 3 - 2006 Linus Torvalds 4 - 2006 Pavel Machek 1 + ======================== 2 + How to get s2ram working 3 + ======================== 4 + 5 + 2006 Linus Torvalds 6 + 2006 Pavel Machek 5 7 6 8 1) Check suspend.sf.net, program s2ram there has long whitelist of 7 9 "known ok" machines, along with tricks to use on each one. ··· 14 12 15 13 3) You can use Linus' TRACE_RESUME infrastructure, described below. 16 14 17 - Using TRACE_RESUME 18 - ~~~~~~~~~~~~~~~~~~ 15 + Using TRACE_RESUME 16 + ~~~~~~~~~~~~~~~~~~ 19 17 20 18 I've been working at making the machines I have able to STR, and almost 21 19 always it's a driver that is buggy. Thank God for the suspend/resume ··· 29 27 30 28 - enable PM_DEBUG, and PM_TRACE 31 29 32 - - use a script like this: 30 + - use a script like this:: 33 31 34 32 #!/bin/sh 35 33 sync ··· 40 38 41 39 - if it doesn't come back up (which is usually the problem), reboot by 42 40 holding the power button down, and look at the dmesg output for things 43 - like 41 + like:: 44 42 45 43 Magic number: 4:156:725 46 44 hash matches drivers/base/power/resume.c:28 ··· 54 52 If no device matches the hash (or any matches appear to be false positives), 55 53 the culprit may be a device from a loadable kernel module that is not loaded 56 54 until after the hash is checked. You can check the hash against the current 57 - devices again after more modules are loaded using sysfs: 55 + devices again after more modules are loaded using sysfs:: 58 56 59 57 cat /sys/power/pm_trace_dev_match 60 58
+27 -15
Documentation/power/suspend-and-cpuhotplug.txt Documentation/power/suspend-and-cpuhotplug.rst
··· 1 + ==================================================================== 1 2 Interaction of Suspend code (S3) with the CPU hotplug infrastructure 3 + ==================================================================== 2 4 3 - (C) 2011 - 2014 Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> 5 + (C) 2011 - 2014 Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> 4 6 5 7 6 - I. How does the regular CPU hotplug code differ from how the Suspend-to-RAM 7 - infrastructure uses it internally? And where do they share common code? 8 + I. Differences between CPU hotplug and Suspend-to-RAM 9 + ====================================================== 10 + 11 + How does the regular CPU hotplug code differ from how the Suspend-to-RAM 12 + infrastructure uses it internally? And where do they share common code? 8 13 9 14 Well, a picture is worth a thousand words... So ASCII art follows :-) 10 15 ··· 21 16 What happens when regular CPU hotplug and Suspend-to-RAM race with each other 22 17 is not depicted here.] 23 18 24 - On a high level, the suspend-resume cycle goes like this: 19 + On a high level, the suspend-resume cycle goes like this:: 25 20 26 - |Freeze| -> |Disable nonboot| -> |Do suspend| -> |Enable nonboot| -> |Thaw | 27 - |tasks | | cpus | | | | cpus | |tasks| 21 + |Freeze| -> |Disable nonboot| -> |Do suspend| -> |Enable nonboot| -> |Thaw | 22 + |tasks | | cpus | | | | cpus | |tasks| 28 23 29 24 30 - More details follow: 25 + More details follow:: 31 26 32 27 Suspend call path 33 28 ----------------- ··· 92 87 93 88 Resuming back is likewise, with the counterparts being (in the order of 94 89 execution during resume): 95 - * enable_nonboot_cpus() which involves: 90 + 91 + * enable_nonboot_cpus() which involves:: 92 + 96 93 | Acquire cpu_add_remove_lock 97 94 | Decrease cpu_hotplug_disabled, thereby enabling regular cpu hotplug 98 95 | Call _cpu_up() [for all those cpus in the frozen_cpus mask, in a loop] ··· 109 102 It is to be noted here that the system_transition_mutex lock is acquired at the very 110 103 beginning, when we are just starting out to suspend, and then released only 111 104 after the entire cycle is complete (i.e., suspend + resume). 105 + 106 + :: 112 107 113 108 114 109 ··· 161 152 162 153 163 154 Important files and functions/entry points: 164 - ------------------------------------------ 155 + ------------------------------------------- 165 156 166 - kernel/power/process.c : freeze_processes(), thaw_processes() 167 - kernel/power/suspend.c : suspend_prepare(), suspend_enter(), suspend_finish() 168 - kernel/cpu.c: cpu_[up|down](), _cpu_[up|down](), [disable|enable]_nonboot_cpus() 157 + - kernel/power/process.c : freeze_processes(), thaw_processes() 158 + - kernel/power/suspend.c : suspend_prepare(), suspend_enter(), suspend_finish() 159 + - kernel/cpu.c: cpu_[up|down](), _cpu_[up|down](), [disable|enable]_nonboot_cpus() 169 160 170 161 171 162 172 163 II. What are the issues involved in CPU hotplug? 173 - ------------------------------------------- 164 + ------------------------------------------------ 174 165 175 166 There are some interesting situations involving CPU hotplug and microcode 176 167 update on the CPUs, as discussed below: ··· 252 243 cycles). 253 244 254 245 255 - III. Are there any known problems when regular CPU hotplug and suspend race 256 - with each other? 246 + III. Known problems 247 + =================== 248 + 249 + Are there any known problems when regular CPU hotplug and suspend race 250 + with each other? 257 251 258 252 Yes, they are listed below: 259 253
+2
Documentation/power/suspend-and-interrupts.txt Documentation/power/suspend-and-interrupts.rst
··· 1 + ==================================== 1 2 System Suspend and Device Interrupts 3 + ==================================== 2 4 3 5 Copyright (C) 2014 Intel Corp. 4 6 Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+10 -7
Documentation/power/swsusp-and-swap-files.txt Documentation/power/swsusp-and-swap-files.rst
··· 1 + =============================================== 1 2 Using swap files with software suspend (swsusp) 3 + =============================================== 4 + 2 5 (C) 2006 Rafael J. Wysocki <rjw@sisk.pl> 3 6 4 7 The Linux kernel handles swap files almost in the same way as it handles swap ··· 24 21 25 22 In order to use a swap file with swsusp, you need to: 26 23 27 - 1) Create the swap file and make it active, eg. 24 + 1) Create the swap file and make it active, eg.:: 28 25 29 - # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k> 30 - # mkswap <swap_file_path> 31 - # swapon <swap_file_path> 26 + # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k> 27 + # mkswap <swap_file_path> 28 + # swapon <swap_file_path> 32 29 33 30 2) Use an application that will bmap the swap file with the help of the 34 31 FIBMAP ioctl and determine the location of the file's swap header, as the 35 32 offset, in <PAGE_SIZE> units, from the beginning of the partition which 36 33 holds the swap file. 37 34 38 - 3) Add the following parameters to the kernel command line: 35 + 3) Add the following parameters to the kernel command line:: 39 36 40 - resume=<swap_file_partition> resume_offset=<swap_file_offset> 37 + resume=<swap_file_partition> resume_offset=<swap_file_offset> 41 38 42 39 where <swap_file_partition> is the partition on which the swap file is located 43 40 and <swap_file_offset> is the offset of the swap header determined by the ··· 49 46 50 47 Use a userland suspend application that will set the partition and offset 51 48 with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in 52 - Documentation/power/userland-swsusp.txt (this is the only method to suspend 49 + Documentation/power/userland-swsusp.rst (this is the only method to suspend 53 50 to a swap file allowing the resume to be initiated from an initrd or initramfs 54 51 image). 55 52
+61 -59
Documentation/power/swsusp-dmcrypt.txt Documentation/power/swsusp-dmcrypt.rst
··· 1 + ======================================= 2 + How to use dm-crypt and swsusp together 3 + ======================================= 4 + 1 5 Author: Andreas Steinmetz <ast@domdv.de> 2 6 3 7 4 - How to use dm-crypt and swsusp together: 5 - ======================================== 6 8 7 9 Some prerequisites: 8 10 You know how dm-crypt works. If not, visit the following web page: 9 11 http://www.saout.de/misc/dm-crypt/ 10 - You have read Documentation/power/swsusp.txt and understand it. 12 + You have read Documentation/power/swsusp.rst and understand it. 11 13 You did read Documentation/admin-guide/initrd.rst and know how an initrd works. 12 14 You know how to create or how to modify an initrd. 13 15 ··· 31 29 always the same major/minor within the initrd as well as 32 30 within your running system. The easiest way to achieve this is 33 31 to always set up this swap device first with dmsetup, so that 34 - it will always look like the following: 32 + it will always look like the following:: 35 33 36 - brw------- 1 root root 254, 0 Jul 28 13:37 /dev/mapper/swap0 34 + brw------- 1 root root 254, 0 Jul 28 13:37 /dev/mapper/swap0 37 35 38 36 Now set up your kernel to use /dev/mapper/swap0 as the default 39 - resume partition, so your kernel .config contains: 37 + resume partition, so your kernel .config contains:: 40 38 41 - CONFIG_PM_STD_PARTITION="/dev/mapper/swap0" 39 + CONFIG_PM_STD_PARTITION="/dev/mapper/swap0" 42 40 43 41 Prepare your boot loader to use the initrd you will create or 44 42 modify. For lilo the simplest setup looks like the following 45 - lines: 43 + lines:: 46 44 47 - image=/boot/vmlinuz 48 - initrd=/boot/initrd.gz 49 - label=linux 50 - append="root=/dev/ram0 init=/linuxrc rw" 45 + image=/boot/vmlinuz 46 + initrd=/boot/initrd.gz 47 + label=linux 48 + append="root=/dev/ram0 init=/linuxrc rw" 51 49 52 50 Finally you need to create or modify your initrd. Lets assume 53 51 you create an initrd that reads the required dm-crypt setup ··· 55 53 fs which resides on /dev/hde1 when the card is inserted. The 56 54 card contains at least the encrypted swap setup in a file 57 55 named "swapkey". /etc/fstab of your initrd contains something 58 - like the following: 56 + like the following:: 59 57 60 - /dev/hda1 /mnt ext3 ro 0 0 61 - none /proc proc defaults,noatime,nodiratime 0 0 62 - none /sys sysfs defaults,noatime,nodiratime 0 0 58 + /dev/hda1 /mnt ext3 ro 0 0 59 + none /proc proc defaults,noatime,nodiratime 0 0 60 + none /sys sysfs defaults,noatime,nodiratime 0 0 63 61 64 62 /dev/hda1 contains an unencrypted mini system that sets up all 65 63 of your crypto devices, again by reading the setup from the 66 64 pcmcia flash disk. What follows now is a /linuxrc for your 67 65 initrd that allows you to resume from encrypted swap and that 68 66 continues boot with your mini system on /dev/hda1 if resume 69 - does not happen: 67 + does not happen:: 70 68 71 - #!/bin/sh 72 - PATH=/sbin:/bin:/usr/sbin:/usr/bin 73 - mount /proc 74 - mount /sys 75 - mapped=0 76 - noresume=`grep -c noresume /proc/cmdline` 77 - if [ "$*" != "" ] 78 - then 79 - noresume=1 80 - fi 81 - dmesg -n 1 82 - /sbin/cardmgr -q 83 - for i in 1 2 3 4 5 6 7 8 9 0 84 - do 85 - if [ -f /proc/ide/hde/media ] 69 + #!/bin/sh 70 + PATH=/sbin:/bin:/usr/sbin:/usr/bin 71 + mount /proc 72 + mount /sys 73 + mapped=0 74 + noresume=`grep -c noresume /proc/cmdline` 75 + if [ "$*" != "" ] 86 76 then 87 - usleep 500000 88 - mount -t ext2 -o ro /dev/hde1 /mnt 89 - if [ -f /mnt/swapkey ] 77 + noresume=1 78 + fi 79 + dmesg -n 1 80 + /sbin/cardmgr -q 81 + for i in 1 2 3 4 5 6 7 8 9 0 82 + do 83 + if [ -f /proc/ide/hde/media ] 90 84 then 91 - dmsetup create swap0 /mnt/swapkey > /dev/null 2>&1 && mapped=1 85 + usleep 500000 86 + mount -t ext2 -o ro /dev/hde1 /mnt 87 + if [ -f /mnt/swapkey ] 88 + then 89 + dmsetup create swap0 /mnt/swapkey > /dev/null 2>&1 && mapped=1 90 + fi 91 + umount /mnt 92 + break 92 93 fi 93 - umount /mnt 94 - break 95 - fi 96 - usleep 500000 97 - done 98 - killproc /sbin/cardmgr 99 - dmesg -n 6 100 - if [ $mapped = 1 ] 101 - then 102 - if [ $noresume != 0 ] 94 + usleep 500000 95 + done 96 + killproc /sbin/cardmgr 97 + dmesg -n 6 98 + if [ $mapped = 1 ] 103 99 then 104 - mkswap /dev/mapper/swap0 > /dev/null 2>&1 100 + if [ $noresume != 0 ] 101 + then 102 + mkswap /dev/mapper/swap0 > /dev/null 2>&1 103 + fi 104 + echo 254:0 > /sys/power/resume 105 + dmsetup remove swap0 105 106 fi 106 - echo 254:0 > /sys/power/resume 107 - dmsetup remove swap0 108 - fi 109 - umount /sys 110 - mount /mnt 111 - umount /proc 112 - cd /mnt 113 - pivot_root . mnt 114 - mount /proc 115 - umount -l /mnt 116 - umount /proc 117 - exec chroot . /sbin/init $* < dev/console > dev/console 2>&1 107 + umount /sys 108 + mount /mnt 109 + umount /proc 110 + cd /mnt 111 + pivot_root . mnt 112 + mount /proc 113 + umount -l /mnt 114 + umount /proc 115 + exec chroot . /sbin/init $* < dev/console > dev/console 2>&1 118 116 119 117 Please don't mind the weird loop above, busybox's msh doesn't know 120 118 the let statement. Now, what is happening in the script?
+501
Documentation/power/swsusp.rst
··· 1 + ============ 2 + Swap suspend 3 + ============ 4 + 5 + Some warnings, first. 6 + 7 + .. warning:: 8 + 9 + **BIG FAT WARNING** 10 + 11 + If you touch anything on disk between suspend and resume... 12 + ...kiss your data goodbye. 13 + 14 + If you do resume from initrd after your filesystems are mounted... 15 + ...bye bye root partition. 16 + 17 + [this is actually same case as above] 18 + 19 + If you have unsupported ( ) devices using DMA, you may have some 20 + problems. If your disk driver does not support suspend... (IDE does), 21 + it may cause some problems, too. If you change kernel command line 22 + between suspend and resume, it may do something wrong. If you change 23 + your hardware while system is suspended... well, it was not good idea; 24 + but it will probably only crash. 25 + 26 + ( ) suspend/resume support is needed to make it safe. 27 + 28 + If you have any filesystems on USB devices mounted before software suspend, 29 + they won't be accessible after resume and you may lose data, as though 30 + you have unplugged the USB devices with mounted filesystems on them; 31 + see the FAQ below for details. (This is not true for more traditional 32 + power states like "standby", which normally don't turn USB off.) 33 + 34 + Swap partition: 35 + You need to append resume=/dev/your_swap_partition to kernel command 36 + line or specify it using /sys/power/resume. 37 + 38 + Swap file: 39 + If using a swapfile you can also specify a resume offset using 40 + resume_offset=<number> on the kernel command line or specify it 41 + in /sys/power/resume_offset. 42 + 43 + After preparing then you suspend by:: 44 + 45 + echo shutdown > /sys/power/disk; echo disk > /sys/power/state 46 + 47 + - If you feel ACPI works pretty well on your system, you might try:: 48 + 49 + echo platform > /sys/power/disk; echo disk > /sys/power/state 50 + 51 + - If you would like to write hibernation image to swap and then suspend 52 + to RAM (provided your platform supports it), you can try:: 53 + 54 + echo suspend > /sys/power/disk; echo disk > /sys/power/state 55 + 56 + - If you have SATA disks, you'll need recent kernels with SATA suspend 57 + support. For suspend and resume to work, make sure your disk drivers 58 + are built into kernel -- not modules. [There's way to make 59 + suspend/resume with modular disk drivers, see FAQ, but you probably 60 + should not do that.] 61 + 62 + If you want to limit the suspend image size to N bytes, do:: 63 + 64 + echo N > /sys/power/image_size 65 + 66 + before suspend (it is limited to around 2/5 of available RAM by default). 67 + 68 + - The resume process checks for the presence of the resume device, 69 + if found, it then checks the contents for the hibernation image signature. 70 + If both are found, it resumes the hibernation image. 71 + 72 + - The resume process may be triggered in two ways: 73 + 74 + 1) During lateinit: If resume=/dev/your_swap_partition is specified on 75 + the kernel command line, lateinit runs the resume process. If the 76 + resume device has not been probed yet, the resume process fails and 77 + bootup continues. 78 + 2) Manually from an initrd or initramfs: May be run from 79 + the init script by using the /sys/power/resume file. It is vital 80 + that this be done prior to remounting any filesystems (even as 81 + read-only) otherwise data may be corrupted. 82 + 83 + Article about goals and implementation of Software Suspend for Linux 84 + ==================================================================== 85 + 86 + Author: Gábor Kuti 87 + Last revised: 2003-10-20 by Pavel Machek 88 + 89 + Idea and goals to achieve 90 + ------------------------- 91 + 92 + Nowadays it is common in several laptops that they have a suspend button. It 93 + saves the state of the machine to a filesystem or to a partition and switches 94 + to standby mode. Later resuming the machine the saved state is loaded back to 95 + ram and the machine can continue its work. It has two real benefits. First we 96 + save ourselves the time machine goes down and later boots up, energy costs 97 + are real high when running from batteries. The other gain is that we don't have 98 + to interrupt our programs so processes that are calculating something for a long 99 + time shouldn't need to be written interruptible. 100 + 101 + swsusp saves the state of the machine into active swaps and then reboots or 102 + powerdowns. You must explicitly specify the swap partition to resume from with 103 + `resume=` kernel option. If signature is found it loads and restores saved 104 + state. If the option `noresume` is specified as a boot parameter, it skips 105 + the resuming. If the option `hibernate=nocompress` is specified as a boot 106 + parameter, it saves hibernation image without compression. 107 + 108 + In the meantime while the system is suspended you should not add/remove any 109 + of the hardware, write to the filesystems, etc. 110 + 111 + Sleep states summary 112 + ==================== 113 + 114 + There are three different interfaces you can use, /proc/acpi should 115 + work like this: 116 + 117 + In a really perfect world:: 118 + 119 + echo 1 > /proc/acpi/sleep # for standby 120 + echo 2 > /proc/acpi/sleep # for suspend to ram 121 + echo 3 > /proc/acpi/sleep # for suspend to ram, but with more power conservative 122 + echo 4 > /proc/acpi/sleep # for suspend to disk 123 + echo 5 > /proc/acpi/sleep # for shutdown unfriendly the system 124 + 125 + and perhaps:: 126 + 127 + echo 4b > /proc/acpi/sleep # for suspend to disk via s4bios 128 + 129 + Frequently Asked Questions 130 + ========================== 131 + 132 + Q: 133 + well, suspending a server is IMHO a really stupid thing, 134 + but... (Diego Zuccato): 135 + 136 + A: 137 + You bought new UPS for your server. How do you install it without 138 + bringing machine down? Suspend to disk, rearrange power cables, 139 + resume. 140 + 141 + You have your server on UPS. Power died, and UPS is indicating 30 142 + seconds to failure. What do you do? Suspend to disk. 143 + 144 + 145 + Q: 146 + Maybe I'm missing something, but why don't the regular I/O paths work? 147 + 148 + A: 149 + We do use the regular I/O paths. However we cannot restore the data 150 + to its original location as we load it. That would create an 151 + inconsistent kernel state which would certainly result in an oops. 152 + Instead, we load the image into unused memory and then atomically copy 153 + it back to it original location. This implies, of course, a maximum 154 + image size of half the amount of memory. 155 + 156 + There are two solutions to this: 157 + 158 + * require half of memory to be free during suspend. That way you can 159 + read "new" data onto free spots, then cli and copy 160 + 161 + * assume we had special "polling" ide driver that only uses memory 162 + between 0-640KB. That way, I'd have to make sure that 0-640KB is free 163 + during suspending, but otherwise it would work... 164 + 165 + suspend2 shares this fundamental limitation, but does not include user 166 + data and disk caches into "used memory" by saving them in 167 + advance. That means that the limitation goes away in practice. 168 + 169 + Q: 170 + Does linux support ACPI S4? 171 + 172 + A: 173 + Yes. That's what echo platform > /sys/power/disk does. 174 + 175 + Q: 176 + What is 'suspend2'? 177 + 178 + A: 179 + suspend2 is 'Software Suspend 2', a forked implementation of 180 + suspend-to-disk which is available as separate patches for 2.4 and 2.6 181 + kernels from swsusp.sourceforge.net. It includes support for SMP, 4GB 182 + highmem and preemption. It also has a extensible architecture that 183 + allows for arbitrary transformations on the image (compression, 184 + encryption) and arbitrary backends for writing the image (eg to swap 185 + or an NFS share[Work In Progress]). Questions regarding suspend2 186 + should be sent to the mailing list available through the suspend2 187 + website, and not to the Linux Kernel Mailing List. We are working 188 + toward merging suspend2 into the mainline kernel. 189 + 190 + Q: 191 + What is the freezing of tasks and why are we using it? 192 + 193 + A: 194 + The freezing of tasks is a mechanism by which user space processes and some 195 + kernel threads are controlled during hibernation or system-wide suspend (on some 196 + architectures). See freezing-of-tasks.txt for details. 197 + 198 + Q: 199 + What is the difference between "platform" and "shutdown"? 200 + 201 + A: 202 + shutdown: 203 + save state in linux, then tell bios to powerdown 204 + 205 + platform: 206 + save state in linux, then tell bios to powerdown and blink 207 + "suspended led" 208 + 209 + "platform" is actually right thing to do where supported, but 210 + "shutdown" is most reliable (except on ACPI systems). 211 + 212 + Q: 213 + I do not understand why you have such strong objections to idea of 214 + selective suspend. 215 + 216 + A: 217 + Do selective suspend during runtime power management, that's okay. But 218 + it's useless for suspend-to-disk. (And I do not see how you could use 219 + it for suspend-to-ram, I hope you do not want that). 220 + 221 + Lets see, so you suggest to 222 + 223 + * SUSPEND all but swap device and parents 224 + * Snapshot 225 + * Write image to disk 226 + * SUSPEND swap device and parents 227 + * Powerdown 228 + 229 + Oh no, that does not work, if swap device or its parents uses DMA, 230 + you've corrupted data. You'd have to do 231 + 232 + * SUSPEND all but swap device and parents 233 + * FREEZE swap device and parents 234 + * Snapshot 235 + * UNFREEZE swap device and parents 236 + * Write 237 + * SUSPEND swap device and parents 238 + 239 + Which means that you still need that FREEZE state, and you get more 240 + complicated code. (And I have not yet introduce details like system 241 + devices). 242 + 243 + Q: 244 + There don't seem to be any generally useful behavioral 245 + distinctions between SUSPEND and FREEZE. 246 + 247 + A: 248 + Doing SUSPEND when you are asked to do FREEZE is always correct, 249 + but it may be unnecessarily slow. If you want your driver to stay simple, 250 + slowness may not matter to you. It can always be fixed later. 251 + 252 + For devices like disk it does matter, you do not want to spindown for 253 + FREEZE. 254 + 255 + Q: 256 + After resuming, system is paging heavily, leading to very bad interactivity. 257 + 258 + A: 259 + Try running:: 260 + 261 + cat /proc/[0-9]*/maps | grep / | sed 's:.* /:/:' | sort -u | while read file 262 + do 263 + test -f "$file" && cat "$file" > /dev/null 264 + done 265 + 266 + after resume. swapoff -a; swapon -a may also be useful. 267 + 268 + Q: 269 + What happens to devices during swsusp? They seem to be resumed 270 + during system suspend? 271 + 272 + A: 273 + That's correct. We need to resume them if we want to write image to 274 + disk. Whole sequence goes like 275 + 276 + **Suspend part** 277 + 278 + running system, user asks for suspend-to-disk 279 + 280 + user processes are stopped 281 + 282 + suspend(PMSG_FREEZE): devices are frozen so that they don't interfere 283 + with state snapshot 284 + 285 + state snapshot: copy of whole used memory is taken with interrupts disabled 286 + 287 + resume(): devices are woken up so that we can write image to swap 288 + 289 + write image to swap 290 + 291 + suspend(PMSG_SUSPEND): suspend devices so that we can power off 292 + 293 + turn the power off 294 + 295 + **Resume part** 296 + 297 + (is actually pretty similar) 298 + 299 + running system, user asks for suspend-to-disk 300 + 301 + user processes are stopped (in common case there are none, 302 + but with resume-from-initrd, no one knows) 303 + 304 + read image from disk 305 + 306 + suspend(PMSG_FREEZE): devices are frozen so that they don't interfere 307 + with image restoration 308 + 309 + image restoration: rewrite memory with image 310 + 311 + resume(): devices are woken up so that system can continue 312 + 313 + thaw all user processes 314 + 315 + Q: 316 + What is this 'Encrypt suspend image' for? 317 + 318 + A: 319 + First of all: it is not a replacement for dm-crypt encrypted swap. 320 + It cannot protect your computer while it is suspended. Instead it does 321 + protect from leaking sensitive data after resume from suspend. 322 + 323 + Think of the following: you suspend while an application is running 324 + that keeps sensitive data in memory. The application itself prevents 325 + the data from being swapped out. Suspend, however, must write these 326 + data to swap to be able to resume later on. Without suspend encryption 327 + your sensitive data are then stored in plaintext on disk. This means 328 + that after resume your sensitive data are accessible to all 329 + applications having direct access to the swap device which was used 330 + for suspend. If you don't need swap after resume these data can remain 331 + on disk virtually forever. Thus it can happen that your system gets 332 + broken in weeks later and sensitive data which you thought were 333 + encrypted and protected are retrieved and stolen from the swap device. 334 + To prevent this situation you should use 'Encrypt suspend image'. 335 + 336 + During suspend a temporary key is created and this key is used to 337 + encrypt the data written to disk. When, during resume, the data was 338 + read back into memory the temporary key is destroyed which simply 339 + means that all data written to disk during suspend are then 340 + inaccessible so they can't be stolen later on. The only thing that 341 + you must then take care of is that you call 'mkswap' for the swap 342 + partition used for suspend as early as possible during regular 343 + boot. This asserts that any temporary key from an oopsed suspend or 344 + from a failed or aborted resume is erased from the swap device. 345 + 346 + As a rule of thumb use encrypted swap to protect your data while your 347 + system is shut down or suspended. Additionally use the encrypted 348 + suspend image to prevent sensitive data from being stolen after 349 + resume. 350 + 351 + Q: 352 + Can I suspend to a swap file? 353 + 354 + A: 355 + Generally, yes, you can. However, it requires you to use the "resume=" and 356 + "resume_offset=" kernel command line parameters, so the resume from a swap file 357 + cannot be initiated from an initrd or initramfs image. See 358 + swsusp-and-swap-files.txt for details. 359 + 360 + Q: 361 + Is there a maximum system RAM size that is supported by swsusp? 362 + 363 + A: 364 + It should work okay with highmem. 365 + 366 + Q: 367 + Does swsusp (to disk) use only one swap partition or can it use 368 + multiple swap partitions (aggregate them into one logical space)? 369 + 370 + A: 371 + Only one swap partition, sorry. 372 + 373 + Q: 374 + If my application(s) causes lots of memory & swap space to be used 375 + (over half of the total system RAM), is it correct that it is likely 376 + to be useless to try to suspend to disk while that app is running? 377 + 378 + A: 379 + No, it should work okay, as long as your app does not mlock() 380 + it. Just prepare big enough swap partition. 381 + 382 + Q: 383 + What information is useful for debugging suspend-to-disk problems? 384 + 385 + A: 386 + Well, last messages on the screen are always useful. If something 387 + is broken, it is usually some kernel driver, therefore trying with as 388 + little as possible modules loaded helps a lot. I also prefer people to 389 + suspend from console, preferably without X running. Booting with 390 + init=/bin/bash, then swapon and starting suspend sequence manually 391 + usually does the trick. Then it is good idea to try with latest 392 + vanilla kernel. 393 + 394 + Q: 395 + How can distributions ship a swsusp-supporting kernel with modular 396 + disk drivers (especially SATA)? 397 + 398 + A: 399 + Well, it can be done, load the drivers, then do echo into 400 + /sys/power/resume file from initrd. Be sure not to mount 401 + anything, not even read-only mount, or you are going to lose your 402 + data. 403 + 404 + Q: 405 + How do I make suspend more verbose? 406 + 407 + A: 408 + If you want to see any non-error kernel messages on the virtual 409 + terminal the kernel switches to during suspend, you have to set the 410 + kernel console loglevel to at least 4 (KERN_WARNING), for example by 411 + doing:: 412 + 413 + # save the old loglevel 414 + read LOGLEVEL DUMMY < /proc/sys/kernel/printk 415 + # set the loglevel so we see the progress bar. 416 + # if the level is higher than needed, we leave it alone. 417 + if [ $LOGLEVEL -lt 5 ]; then 418 + echo 5 > /proc/sys/kernel/printk 419 + fi 420 + 421 + IMG_SZ=0 422 + read IMG_SZ < /sys/power/image_size 423 + echo -n disk > /sys/power/state 424 + RET=$? 425 + # 426 + # the logic here is: 427 + # if image_size > 0 (without kernel support, IMG_SZ will be zero), 428 + # then try again with image_size set to zero. 429 + if [ $RET -ne 0 -a $IMG_SZ -ne 0 ]; then # try again with minimal image size 430 + echo 0 > /sys/power/image_size 431 + echo -n disk > /sys/power/state 432 + RET=$? 433 + fi 434 + 435 + # restore previous loglevel 436 + echo $LOGLEVEL > /proc/sys/kernel/printk 437 + exit $RET 438 + 439 + Q: 440 + Is this true that if I have a mounted filesystem on a USB device and 441 + I suspend to disk, I can lose data unless the filesystem has been mounted 442 + with "sync"? 443 + 444 + A: 445 + That's right ... if you disconnect that device, you may lose data. 446 + In fact, even with "-o sync" you can lose data if your programs have 447 + information in buffers they haven't written out to a disk you disconnect, 448 + or if you disconnect before the device finished saving data you wrote. 449 + 450 + Software suspend normally powers down USB controllers, which is equivalent 451 + to disconnecting all USB devices attached to your system. 452 + 453 + Your system might well support low-power modes for its USB controllers 454 + while the system is asleep, maintaining the connection, using true sleep 455 + modes like "suspend-to-RAM" or "standby". (Don't write "disk" to the 456 + /sys/power/state file; write "standby" or "mem".) We've not seen any 457 + hardware that can use these modes through software suspend, although in 458 + theory some systems might support "platform" modes that won't break the 459 + USB connections. 460 + 461 + Remember that it's always a bad idea to unplug a disk drive containing a 462 + mounted filesystem. That's true even when your system is asleep! The 463 + safest thing is to unmount all filesystems on removable media (such USB, 464 + Firewire, CompactFlash, MMC, external SATA, or even IDE hotplug bays) 465 + before suspending; then remount them after resuming. 466 + 467 + There is a work-around for this problem. For more information, see 468 + Documentation/driver-api/usb/persist.rst. 469 + 470 + Q: 471 + Can I suspend-to-disk using a swap partition under LVM? 472 + 473 + A: 474 + Yes and No. You can suspend successfully, but the kernel will not be able 475 + to resume on its own. You need an initramfs that can recognize the resume 476 + situation, activate the logical volume containing the swap volume (but not 477 + touch any filesystems!), and eventually call:: 478 + 479 + echo -n "$major:$minor" > /sys/power/resume 480 + 481 + where $major and $minor are the respective major and minor device numbers of 482 + the swap volume. 483 + 484 + uswsusp works with LVM, too. See http://suspend.sourceforge.net/ 485 + 486 + Q: 487 + I upgraded the kernel from 2.6.15 to 2.6.16. Both kernels were 488 + compiled with the similar configuration files. Anyway I found that 489 + suspend to disk (and resume) is much slower on 2.6.16 compared to 490 + 2.6.15. Any idea for why that might happen or how can I speed it up? 491 + 492 + A: 493 + This is because the size of the suspend image is now greater than 494 + for 2.6.15 (by saving more data we can get more responsive system 495 + after resume). 496 + 497 + There's the /sys/power/image_size knob that controls the size of the 498 + image. If you set it to 0 (eg. by echo 0 > /sys/power/image_size as 499 + root), the 2.6.15 behavior should be restored. If it is still too 500 + slow, take a look at suspend.sf.net -- userland suspend is faster and 501 + supports LZF compression to speed it up further.
-446
Documentation/power/swsusp.txt
··· 1 - Some warnings, first. 2 - 3 - * BIG FAT WARNING ********************************************************* 4 - * 5 - * If you touch anything on disk between suspend and resume... 6 - * ...kiss your data goodbye. 7 - * 8 - * If you do resume from initrd after your filesystems are mounted... 9 - * ...bye bye root partition. 10 - * [this is actually same case as above] 11 - * 12 - * If you have unsupported (*) devices using DMA, you may have some 13 - * problems. If your disk driver does not support suspend... (IDE does), 14 - * it may cause some problems, too. If you change kernel command line 15 - * between suspend and resume, it may do something wrong. If you change 16 - * your hardware while system is suspended... well, it was not good idea; 17 - * but it will probably only crash. 18 - * 19 - * (*) suspend/resume support is needed to make it safe. 20 - * 21 - * If you have any filesystems on USB devices mounted before software suspend, 22 - * they won't be accessible after resume and you may lose data, as though 23 - * you have unplugged the USB devices with mounted filesystems on them; 24 - * see the FAQ below for details. (This is not true for more traditional 25 - * power states like "standby", which normally don't turn USB off.) 26 - 27 - Swap partition: 28 - You need to append resume=/dev/your_swap_partition to kernel command 29 - line or specify it using /sys/power/resume. 30 - 31 - Swap file: 32 - If using a swapfile you can also specify a resume offset using 33 - resume_offset=<number> on the kernel command line or specify it 34 - in /sys/power/resume_offset. 35 - 36 - After preparing then you suspend by 37 - 38 - echo shutdown > /sys/power/disk; echo disk > /sys/power/state 39 - 40 - . If you feel ACPI works pretty well on your system, you might try 41 - 42 - echo platform > /sys/power/disk; echo disk > /sys/power/state 43 - 44 - . If you would like to write hibernation image to swap and then suspend 45 - to RAM (provided your platform supports it), you can try 46 - 47 - echo suspend > /sys/power/disk; echo disk > /sys/power/state 48 - 49 - . If you have SATA disks, you'll need recent kernels with SATA suspend 50 - support. For suspend and resume to work, make sure your disk drivers 51 - are built into kernel -- not modules. [There's way to make 52 - suspend/resume with modular disk drivers, see FAQ, but you probably 53 - should not do that.] 54 - 55 - If you want to limit the suspend image size to N bytes, do 56 - 57 - echo N > /sys/power/image_size 58 - 59 - before suspend (it is limited to around 2/5 of available RAM by default). 60 - 61 - . The resume process checks for the presence of the resume device, 62 - if found, it then checks the contents for the hibernation image signature. 63 - If both are found, it resumes the hibernation image. 64 - 65 - . The resume process may be triggered in two ways: 66 - 1) During lateinit: If resume=/dev/your_swap_partition is specified on 67 - the kernel command line, lateinit runs the resume process. If the 68 - resume device has not been probed yet, the resume process fails and 69 - bootup continues. 70 - 2) Manually from an initrd or initramfs: May be run from 71 - the init script by using the /sys/power/resume file. It is vital 72 - that this be done prior to remounting any filesystems (even as 73 - read-only) otherwise data may be corrupted. 74 - 75 - Article about goals and implementation of Software Suspend for Linux 76 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 77 - Author: Gábor Kuti 78 - Last revised: 2003-10-20 by Pavel Machek 79 - 80 - Idea and goals to achieve 81 - 82 - Nowadays it is common in several laptops that they have a suspend button. It 83 - saves the state of the machine to a filesystem or to a partition and switches 84 - to standby mode. Later resuming the machine the saved state is loaded back to 85 - ram and the machine can continue its work. It has two real benefits. First we 86 - save ourselves the time machine goes down and later boots up, energy costs 87 - are real high when running from batteries. The other gain is that we don't have to 88 - interrupt our programs so processes that are calculating something for a long 89 - time shouldn't need to be written interruptible. 90 - 91 - swsusp saves the state of the machine into active swaps and then reboots or 92 - powerdowns. You must explicitly specify the swap partition to resume from with 93 - ``resume='' kernel option. If signature is found it loads and restores saved 94 - state. If the option ``noresume'' is specified as a boot parameter, it skips 95 - the resuming. If the option ``hibernate=nocompress'' is specified as a boot 96 - parameter, it saves hibernation image without compression. 97 - 98 - In the meantime while the system is suspended you should not add/remove any 99 - of the hardware, write to the filesystems, etc. 100 - 101 - Sleep states summary 102 - ==================== 103 - 104 - There are three different interfaces you can use, /proc/acpi should 105 - work like this: 106 - 107 - In a really perfect world: 108 - echo 1 > /proc/acpi/sleep # for standby 109 - echo 2 > /proc/acpi/sleep # for suspend to ram 110 - echo 3 > /proc/acpi/sleep # for suspend to ram, but with more power conservative 111 - echo 4 > /proc/acpi/sleep # for suspend to disk 112 - echo 5 > /proc/acpi/sleep # for shutdown unfriendly the system 113 - 114 - and perhaps 115 - echo 4b > /proc/acpi/sleep # for suspend to disk via s4bios 116 - 117 - Frequently Asked Questions 118 - ========================== 119 - 120 - Q: well, suspending a server is IMHO a really stupid thing, 121 - but... (Diego Zuccato): 122 - 123 - A: You bought new UPS for your server. How do you install it without 124 - bringing machine down? Suspend to disk, rearrange power cables, 125 - resume. 126 - 127 - You have your server on UPS. Power died, and UPS is indicating 30 128 - seconds to failure. What do you do? Suspend to disk. 129 - 130 - 131 - Q: Maybe I'm missing something, but why don't the regular I/O paths work? 132 - 133 - A: We do use the regular I/O paths. However we cannot restore the data 134 - to its original location as we load it. That would create an 135 - inconsistent kernel state which would certainly result in an oops. 136 - Instead, we load the image into unused memory and then atomically copy 137 - it back to it original location. This implies, of course, a maximum 138 - image size of half the amount of memory. 139 - 140 - There are two solutions to this: 141 - 142 - * require half of memory to be free during suspend. That way you can 143 - read "new" data onto free spots, then cli and copy 144 - 145 - * assume we had special "polling" ide driver that only uses memory 146 - between 0-640KB. That way, I'd have to make sure that 0-640KB is free 147 - during suspending, but otherwise it would work... 148 - 149 - suspend2 shares this fundamental limitation, but does not include user 150 - data and disk caches into "used memory" by saving them in 151 - advance. That means that the limitation goes away in practice. 152 - 153 - Q: Does linux support ACPI S4? 154 - 155 - A: Yes. That's what echo platform > /sys/power/disk does. 156 - 157 - Q: What is 'suspend2'? 158 - 159 - A: suspend2 is 'Software Suspend 2', a forked implementation of 160 - suspend-to-disk which is available as separate patches for 2.4 and 2.6 161 - kernels from swsusp.sourceforge.net. It includes support for SMP, 4GB 162 - highmem and preemption. It also has a extensible architecture that 163 - allows for arbitrary transformations on the image (compression, 164 - encryption) and arbitrary backends for writing the image (eg to swap 165 - or an NFS share[Work In Progress]). Questions regarding suspend2 166 - should be sent to the mailing list available through the suspend2 167 - website, and not to the Linux Kernel Mailing List. We are working 168 - toward merging suspend2 into the mainline kernel. 169 - 170 - Q: What is the freezing of tasks and why are we using it? 171 - 172 - A: The freezing of tasks is a mechanism by which user space processes and some 173 - kernel threads are controlled during hibernation or system-wide suspend (on some 174 - architectures). See freezing-of-tasks.txt for details. 175 - 176 - Q: What is the difference between "platform" and "shutdown"? 177 - 178 - A: 179 - 180 - shutdown: save state in linux, then tell bios to powerdown 181 - 182 - platform: save state in linux, then tell bios to powerdown and blink 183 - "suspended led" 184 - 185 - "platform" is actually right thing to do where supported, but 186 - "shutdown" is most reliable (except on ACPI systems). 187 - 188 - Q: I do not understand why you have such strong objections to idea of 189 - selective suspend. 190 - 191 - A: Do selective suspend during runtime power management, that's okay. But 192 - it's useless for suspend-to-disk. (And I do not see how you could use 193 - it for suspend-to-ram, I hope you do not want that). 194 - 195 - Lets see, so you suggest to 196 - 197 - * SUSPEND all but swap device and parents 198 - * Snapshot 199 - * Write image to disk 200 - * SUSPEND swap device and parents 201 - * Powerdown 202 - 203 - Oh no, that does not work, if swap device or its parents uses DMA, 204 - you've corrupted data. You'd have to do 205 - 206 - * SUSPEND all but swap device and parents 207 - * FREEZE swap device and parents 208 - * Snapshot 209 - * UNFREEZE swap device and parents 210 - * Write 211 - * SUSPEND swap device and parents 212 - 213 - Which means that you still need that FREEZE state, and you get more 214 - complicated code. (And I have not yet introduce details like system 215 - devices). 216 - 217 - Q: There don't seem to be any generally useful behavioral 218 - distinctions between SUSPEND and FREEZE. 219 - 220 - A: Doing SUSPEND when you are asked to do FREEZE is always correct, 221 - but it may be unnecessarily slow. If you want your driver to stay simple, 222 - slowness may not matter to you. It can always be fixed later. 223 - 224 - For devices like disk it does matter, you do not want to spindown for 225 - FREEZE. 226 - 227 - Q: After resuming, system is paging heavily, leading to very bad interactivity. 228 - 229 - A: Try running 230 - 231 - cat /proc/[0-9]*/maps | grep / | sed 's:.* /:/:' | sort -u | while read file 232 - do 233 - test -f "$file" && cat "$file" > /dev/null 234 - done 235 - 236 - after resume. swapoff -a; swapon -a may also be useful. 237 - 238 - Q: What happens to devices during swsusp? They seem to be resumed 239 - during system suspend? 240 - 241 - A: That's correct. We need to resume them if we want to write image to 242 - disk. Whole sequence goes like 243 - 244 - Suspend part 245 - ~~~~~~~~~~~~ 246 - running system, user asks for suspend-to-disk 247 - 248 - user processes are stopped 249 - 250 - suspend(PMSG_FREEZE): devices are frozen so that they don't interfere 251 - with state snapshot 252 - 253 - state snapshot: copy of whole used memory is taken with interrupts disabled 254 - 255 - resume(): devices are woken up so that we can write image to swap 256 - 257 - write image to swap 258 - 259 - suspend(PMSG_SUSPEND): suspend devices so that we can power off 260 - 261 - turn the power off 262 - 263 - Resume part 264 - ~~~~~~~~~~~ 265 - (is actually pretty similar) 266 - 267 - running system, user asks for suspend-to-disk 268 - 269 - user processes are stopped (in common case there are none, but with resume-from-initrd, no one knows) 270 - 271 - read image from disk 272 - 273 - suspend(PMSG_FREEZE): devices are frozen so that they don't interfere 274 - with image restoration 275 - 276 - image restoration: rewrite memory with image 277 - 278 - resume(): devices are woken up so that system can continue 279 - 280 - thaw all user processes 281 - 282 - Q: What is this 'Encrypt suspend image' for? 283 - 284 - A: First of all: it is not a replacement for dm-crypt encrypted swap. 285 - It cannot protect your computer while it is suspended. Instead it does 286 - protect from leaking sensitive data after resume from suspend. 287 - 288 - Think of the following: you suspend while an application is running 289 - that keeps sensitive data in memory. The application itself prevents 290 - the data from being swapped out. Suspend, however, must write these 291 - data to swap to be able to resume later on. Without suspend encryption 292 - your sensitive data are then stored in plaintext on disk. This means 293 - that after resume your sensitive data are accessible to all 294 - applications having direct access to the swap device which was used 295 - for suspend. If you don't need swap after resume these data can remain 296 - on disk virtually forever. Thus it can happen that your system gets 297 - broken in weeks later and sensitive data which you thought were 298 - encrypted and protected are retrieved and stolen from the swap device. 299 - To prevent this situation you should use 'Encrypt suspend image'. 300 - 301 - During suspend a temporary key is created and this key is used to 302 - encrypt the data written to disk. When, during resume, the data was 303 - read back into memory the temporary key is destroyed which simply 304 - means that all data written to disk during suspend are then 305 - inaccessible so they can't be stolen later on. The only thing that 306 - you must then take care of is that you call 'mkswap' for the swap 307 - partition used for suspend as early as possible during regular 308 - boot. This asserts that any temporary key from an oopsed suspend or 309 - from a failed or aborted resume is erased from the swap device. 310 - 311 - As a rule of thumb use encrypted swap to protect your data while your 312 - system is shut down or suspended. Additionally use the encrypted 313 - suspend image to prevent sensitive data from being stolen after 314 - resume. 315 - 316 - Q: Can I suspend to a swap file? 317 - 318 - A: Generally, yes, you can. However, it requires you to use the "resume=" and 319 - "resume_offset=" kernel command line parameters, so the resume from a swap file 320 - cannot be initiated from an initrd or initramfs image. See 321 - swsusp-and-swap-files.txt for details. 322 - 323 - Q: Is there a maximum system RAM size that is supported by swsusp? 324 - 325 - A: It should work okay with highmem. 326 - 327 - Q: Does swsusp (to disk) use only one swap partition or can it use 328 - multiple swap partitions (aggregate them into one logical space)? 329 - 330 - A: Only one swap partition, sorry. 331 - 332 - Q: If my application(s) causes lots of memory & swap space to be used 333 - (over half of the total system RAM), is it correct that it is likely 334 - to be useless to try to suspend to disk while that app is running? 335 - 336 - A: No, it should work okay, as long as your app does not mlock() 337 - it. Just prepare big enough swap partition. 338 - 339 - Q: What information is useful for debugging suspend-to-disk problems? 340 - 341 - A: Well, last messages on the screen are always useful. If something 342 - is broken, it is usually some kernel driver, therefore trying with as 343 - little as possible modules loaded helps a lot. I also prefer people to 344 - suspend from console, preferably without X running. Booting with 345 - init=/bin/bash, then swapon and starting suspend sequence manually 346 - usually does the trick. Then it is good idea to try with latest 347 - vanilla kernel. 348 - 349 - Q: How can distributions ship a swsusp-supporting kernel with modular 350 - disk drivers (especially SATA)? 351 - 352 - A: Well, it can be done, load the drivers, then do echo into 353 - /sys/power/resume file from initrd. Be sure not to mount 354 - anything, not even read-only mount, or you are going to lose your 355 - data. 356 - 357 - Q: How do I make suspend more verbose? 358 - 359 - A: If you want to see any non-error kernel messages on the virtual 360 - terminal the kernel switches to during suspend, you have to set the 361 - kernel console loglevel to at least 4 (KERN_WARNING), for example by 362 - doing 363 - 364 - # save the old loglevel 365 - read LOGLEVEL DUMMY < /proc/sys/kernel/printk 366 - # set the loglevel so we see the progress bar. 367 - # if the level is higher than needed, we leave it alone. 368 - if [ $LOGLEVEL -lt 5 ]; then 369 - echo 5 > /proc/sys/kernel/printk 370 - fi 371 - 372 - IMG_SZ=0 373 - read IMG_SZ < /sys/power/image_size 374 - echo -n disk > /sys/power/state 375 - RET=$? 376 - # 377 - # the logic here is: 378 - # if image_size > 0 (without kernel support, IMG_SZ will be zero), 379 - # then try again with image_size set to zero. 380 - if [ $RET -ne 0 -a $IMG_SZ -ne 0 ]; then # try again with minimal image size 381 - echo 0 > /sys/power/image_size 382 - echo -n disk > /sys/power/state 383 - RET=$? 384 - fi 385 - 386 - # restore previous loglevel 387 - echo $LOGLEVEL > /proc/sys/kernel/printk 388 - exit $RET 389 - 390 - Q: Is this true that if I have a mounted filesystem on a USB device and 391 - I suspend to disk, I can lose data unless the filesystem has been mounted 392 - with "sync"? 393 - 394 - A: That's right ... if you disconnect that device, you may lose data. 395 - In fact, even with "-o sync" you can lose data if your programs have 396 - information in buffers they haven't written out to a disk you disconnect, 397 - or if you disconnect before the device finished saving data you wrote. 398 - 399 - Software suspend normally powers down USB controllers, which is equivalent 400 - to disconnecting all USB devices attached to your system. 401 - 402 - Your system might well support low-power modes for its USB controllers 403 - while the system is asleep, maintaining the connection, using true sleep 404 - modes like "suspend-to-RAM" or "standby". (Don't write "disk" to the 405 - /sys/power/state file; write "standby" or "mem".) We've not seen any 406 - hardware that can use these modes through software suspend, although in 407 - theory some systems might support "platform" modes that won't break the 408 - USB connections. 409 - 410 - Remember that it's always a bad idea to unplug a disk drive containing a 411 - mounted filesystem. That's true even when your system is asleep! The 412 - safest thing is to unmount all filesystems on removable media (such USB, 413 - Firewire, CompactFlash, MMC, external SATA, or even IDE hotplug bays) 414 - before suspending; then remount them after resuming. 415 - 416 - There is a work-around for this problem. For more information, see 417 - Documentation/driver-api/usb/persist.rst. 418 - 419 - Q: Can I suspend-to-disk using a swap partition under LVM? 420 - 421 - A: Yes and No. You can suspend successfully, but the kernel will not be able 422 - to resume on its own. You need an initramfs that can recognize the resume 423 - situation, activate the logical volume containing the swap volume (but not 424 - touch any filesystems!), and eventually call 425 - 426 - echo -n "$major:$minor" > /sys/power/resume 427 - 428 - where $major and $minor are the respective major and minor device numbers of 429 - the swap volume. 430 - 431 - uswsusp works with LVM, too. See http://suspend.sourceforge.net/ 432 - 433 - Q: I upgraded the kernel from 2.6.15 to 2.6.16. Both kernels were 434 - compiled with the similar configuration files. Anyway I found that 435 - suspend to disk (and resume) is much slower on 2.6.16 compared to 436 - 2.6.15. Any idea for why that might happen or how can I speed it up? 437 - 438 - A: This is because the size of the suspend image is now greater than 439 - for 2.6.15 (by saving more data we can get more responsive system 440 - after resume). 441 - 442 - There's the /sys/power/image_size knob that controls the size of the 443 - image. If you set it to 0 (eg. by echo 0 > /sys/power/image_size as 444 - root), the 2.6.15 behavior should be restored. If it is still too 445 - slow, take a look at suspend.sf.net -- userland suspend is faster and 446 - supports LZF compression to speed it up further.
+4 -2
Documentation/power/tricks.txt Documentation/power/tricks.rst
··· 1 - swsusp/S3 tricks 2 - ~~~~~~~~~~~~~~~~ 1 + ================ 2 + swsusp/S3 tricks 3 + ================ 4 + 3 5 Pavel Machek <pavel@ucw.cz> 4 6 5 7 If you want to trick swsusp/S3 into working, you might want to try:
+38 -17
Documentation/power/userland-swsusp.txt Documentation/power/userland-swsusp.rst
··· 1 + ===================================================== 1 2 Documentation for userland software suspend interface 3 + ===================================================== 4 + 2 5 (C) 2006 Rafael J. Wysocki <rjw@sisk.pl> 3 6 4 7 First, the warnings at the beginning of swsusp.txt still apply. ··· 33 30 34 31 The ioctl() commands recognized by the device are: 35 32 36 - SNAPSHOT_FREEZE - freeze user space processes (the current process is 33 + SNAPSHOT_FREEZE 34 + freeze user space processes (the current process is 37 35 not frozen); this is required for SNAPSHOT_CREATE_IMAGE 38 36 and SNAPSHOT_ATOMIC_RESTORE to succeed 39 37 40 - SNAPSHOT_UNFREEZE - thaw user space processes frozen by SNAPSHOT_FREEZE 38 + SNAPSHOT_UNFREEZE 39 + thaw user space processes frozen by SNAPSHOT_FREEZE 41 40 42 - SNAPSHOT_CREATE_IMAGE - create a snapshot of the system memory; the 41 + SNAPSHOT_CREATE_IMAGE 42 + create a snapshot of the system memory; the 43 43 last argument of ioctl() should be a pointer to an int variable, 44 44 the value of which will indicate whether the call returned after 45 45 creating the snapshot (1) or after restoring the system memory state ··· 51 45 has been created the read() operation can be used to transfer 52 46 it out of the kernel 53 47 54 - SNAPSHOT_ATOMIC_RESTORE - restore the system memory state from the 48 + SNAPSHOT_ATOMIC_RESTORE 49 + restore the system memory state from the 55 50 uploaded snapshot image; before calling it you should transfer 56 51 the system memory snapshot back to the kernel using the write() 57 52 operation; this call will not succeed if the snapshot 58 53 image is not available to the kernel 59 54 60 - SNAPSHOT_FREE - free memory allocated for the snapshot image 55 + SNAPSHOT_FREE 56 + free memory allocated for the snapshot image 61 57 62 - SNAPSHOT_PREF_IMAGE_SIZE - set the preferred maximum size of the image 58 + SNAPSHOT_PREF_IMAGE_SIZE 59 + set the preferred maximum size of the image 63 60 (the kernel will do its best to ensure the image size will not exceed 64 61 this number, but if it turns out to be impossible, the kernel will 65 62 create the smallest image possible) 66 63 67 - SNAPSHOT_GET_IMAGE_SIZE - return the actual size of the hibernation image 64 + SNAPSHOT_GET_IMAGE_SIZE 65 + return the actual size of the hibernation image 68 66 69 - SNAPSHOT_AVAIL_SWAP_SIZE - return the amount of available swap in bytes (the 67 + SNAPSHOT_AVAIL_SWAP_SIZE 68 + return the amount of available swap in bytes (the 70 69 last argument should be a pointer to an unsigned int variable that will 71 70 contain the result if the call is successful). 72 71 73 - SNAPSHOT_ALLOC_SWAP_PAGE - allocate a swap page from the resume partition 72 + SNAPSHOT_ALLOC_SWAP_PAGE 73 + allocate a swap page from the resume partition 74 74 (the last argument should be a pointer to a loff_t variable that 75 75 will contain the swap page offset if the call is successful) 76 76 77 - SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated by 77 + SNAPSHOT_FREE_SWAP_PAGES 78 + free all swap pages allocated by 78 79 SNAPSHOT_ALLOC_SWAP_PAGE 79 80 80 - SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in <PAGE_SIZE> 81 + SNAPSHOT_SET_SWAP_AREA 82 + set the resume partition and the offset (in <PAGE_SIZE> 81 83 units) from the beginning of the partition at which the swap header is 82 84 located (the last ioctl() argument should point to a struct 83 85 resume_swap_area, as defined in kernel/power/suspend_ioctls.h, 84 86 containing the resume device specification and the offset); for swap 85 87 partitions the offset is always 0, but it is different from zero for 86 - swap files (see Documentation/power/swsusp-and-swap-files.txt for 88 + swap files (see Documentation/power/swsusp-and-swap-files.rst for 87 89 details). 88 90 89 - SNAPSHOT_PLATFORM_SUPPORT - enable/disable the hibernation platform support, 91 + SNAPSHOT_PLATFORM_SUPPORT 92 + enable/disable the hibernation platform support, 90 93 depending on the argument value (enable, if the argument is nonzero) 91 94 92 - SNAPSHOT_POWER_OFF - make the kernel transition the system to the hibernation 95 + SNAPSHOT_POWER_OFF 96 + make the kernel transition the system to the hibernation 93 97 state (eg. ACPI S4) using the platform (eg. ACPI) driver 94 98 95 - SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to 99 + SNAPSHOT_S2RAM 100 + suspend to RAM; using this call causes the kernel to 96 101 immediately enter the suspend-to-RAM state, so this call must always 97 102 be preceded by the SNAPSHOT_FREEZE call and it is also necessary 98 103 to use the SNAPSHOT_UNFREEZE call after the system wakes up. This call ··· 115 98 116 99 The device's read() operation can be used to transfer the snapshot image from 117 100 the kernel. It has the following limitations: 101 + 118 102 - you cannot read() more than one virtual memory page at a time 119 103 - read()s across page boundaries are impossible (ie. if you read() 1/2 of 120 - a page in the previous call, you will only be able to read() 121 - _at_ _most_ 1/2 of the page in the next call) 104 + a page in the previous call, you will only be able to read() 105 + **at most** 1/2 of the page in the next call) 122 106 123 107 The device's write() operation is used for uploading the system memory snapshot 124 108 into the kernel. It has the same limitations as the read() operation. ··· 161 143 The suspending utility MUST check the value stored by SNAPSHOT_CREATE_IMAGE 162 144 in the memory location pointed to by the last argument of ioctl() and proceed 163 145 in accordance with it: 146 + 164 147 1. If the value is 1 (ie. the system memory snapshot has just been 165 148 created and the system is ready for saving it): 149 + 166 150 (a) The suspending utility MUST NOT close the snapshot device 167 151 _unless_ the whole suspend procedure is to be cancelled, in 168 152 which case, if the snapshot image has already been saved, the ··· 178 158 called. However, it MAY mount a file system that was not 179 159 mounted at that time and perform some operations on it (eg. 180 160 use it for saving the image). 161 + 181 162 2. If the value is 0 (ie. the system state has just been restored from 182 163 the snapshot image), the suspending utility MUST close the snapshot 183 164 device. Afterwards it will be treated as a regular userland process,
+92 -64
Documentation/power/video.txt Documentation/power/video.rst
··· 1 + =========================== 2 + Video issues with S3 resume 3 + =========================== 1 4 2 - Video issues with S3 resume 3 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 - 2003-2006, Pavel Machek 5 + 2003-2006, Pavel Machek 5 6 6 7 During S3 resume, hardware needs to be reinitialized. For most 7 8 devices, this is easy, and kernel driver knows how to do ··· 42 41 (1) systems where video state is preserved over S3. 43 42 44 43 (2) systems where it is possible to call the video BIOS during S3 45 - resume. Unfortunately, it is not correct to call the video BIOS at 46 - that point, but it happens to work on some machines. Use 47 - acpi_sleep=s3_bios. 44 + resume. Unfortunately, it is not correct to call the video BIOS at 45 + that point, but it happens to work on some machines. Use 46 + acpi_sleep=s3_bios. 48 47 49 48 (3) systems that initialize video card into vga text mode and where 50 - the BIOS works well enough to be able to set video mode. Use 51 - acpi_sleep=s3_mode on these. 49 + the BIOS works well enough to be able to set video mode. Use 50 + acpi_sleep=s3_mode on these. 52 51 53 52 (4) on some systems s3_bios kicks video into text mode, and 54 - acpi_sleep=s3_bios,s3_mode is needed. 53 + acpi_sleep=s3_bios,s3_mode is needed. 55 54 56 55 (5) radeon systems, where X can soft-boot your video card. You'll need 57 - a new enough X, and a plain text console (no vesafb or radeonfb). See 58 - http://www.doesi.gmxhome.de/linux/tm800s3/s3.html for more information. 59 - Alternatively, you should use vbetool (6) instead. 56 + a new enough X, and a plain text console (no vesafb or radeonfb). See 57 + http://www.doesi.gmxhome.de/linux/tm800s3/s3.html for more information. 58 + Alternatively, you should use vbetool (6) instead. 60 59 61 60 (6) other radeon systems, where vbetool is enough to bring system back 62 - to life. It needs text console to be working. Do vbetool vbestate 63 - save > /tmp/delme; echo 3 > /proc/acpi/sleep; vbetool post; vbetool 64 - vbestate restore < /tmp/delme; setfont <whatever>, and your video 65 - should work. 61 + to life. It needs text console to be working. Do vbetool vbestate 62 + save > /tmp/delme; echo 3 > /proc/acpi/sleep; vbetool post; vbetool 63 + vbestate restore < /tmp/delme; setfont <whatever>, and your video 64 + should work. 66 65 67 66 (7) on some systems, it is possible to boot most of kernel, and then 68 - POSTing bios works. Ole Rohne has patch to do just that at 69 - http://dev.gentoo.org/~marineam/patch-radeonfb-2.6.11-rc2-mm2. 67 + POSTing bios works. Ole Rohne has patch to do just that at 68 + http://dev.gentoo.org/~marineam/patch-radeonfb-2.6.11-rc2-mm2. 70 69 71 - (8) on some systems, you can use the video_post utility and or 72 - do echo 3 > /sys/power/state && /usr/sbin/video_post - which will 73 - initialize the display in console mode. If you are in X, you can switch 74 - to a virtual terminal and back to X using CTRL+ALT+F1 - CTRL+ALT+F7 to get 75 - the display working in graphical mode again. 70 + (8) on some systems, you can use the video_post utility and or 71 + do echo 3 > /sys/power/state && /usr/sbin/video_post - which will 72 + initialize the display in console mode. If you are in X, you can switch 73 + to a virtual terminal and back to X using CTRL+ALT+F1 - CTRL+ALT+F7 to get 74 + the display working in graphical mode again. 76 75 77 76 Now, if you pass acpi_sleep=something, and it does not work with your 78 77 bios, you'll get a hard crash during resume. Be careful. Also it is ··· 88 87 89 88 Table of known working notebooks: 90 89 90 + 91 + =============================== =============================================== 91 92 Model hack (or "how to do it") 92 - ------------------------------------------------------------------------------ 93 + =============================== =============================================== 93 94 Acer Aspire 1406LC ole's late BIOS init (7), turn off DRI 94 95 Acer TM 230 s3_bios (2) 95 96 Acer TM 242FX vbetool (6) 96 97 Acer TM C110 video_post (8) 97 - Acer TM C300 vga=normal (only suspend on console, not in X), vbetool (6) or video_post (8) 98 + Acer TM C300 vga=normal (only suspend on console, not in X), 99 + vbetool (6) or video_post (8) 98 100 Acer TM 4052LCi s3_bios (2) 99 101 Acer TM 636Lci s3_bios,s3_mode (4) 100 - Acer TM 650 (Radeon M7) vga=normal plus boot-radeon (5) gets text console back 101 - Acer TM 660 ??? (*) 102 - Acer TM 800 vga=normal, X patches, see webpage (5) or vbetool (6) 103 - Acer TM 803 vga=normal, X patches, see webpage (5) or vbetool (6) 102 + Acer TM 650 (Radeon M7) vga=normal plus boot-radeon (5) gets text 103 + console back 104 + Acer TM 660 ??? [#f1]_ 105 + Acer TM 800 vga=normal, X patches, see webpage (5) 106 + or vbetool (6) 107 + Acer TM 803 vga=normal, X patches, see webpage (5) 108 + or vbetool (6) 104 109 Acer TM 803LCi vga=normal, vbetool (6) 105 110 Arima W730a vbetool needed (6) 106 - Asus L2400D s3_mode (3)(***) (S1 also works OK) 111 + Asus L2400D s3_mode (3) [#f2]_ (S1 also works OK) 107 112 Asus L3350M (SiS 740) (6) 108 113 Asus L3800C (Radeon M7) s3_bios (2) (S1 also works OK) 109 - Asus M6887Ne vga=normal, s3_bios (2), use radeon driver instead of fglrx in x.org 114 + Asus M6887Ne vga=normal, s3_bios (2), use radeon driver 115 + instead of fglrx in x.org 110 116 Athlon64 desktop prototype s3_bios (2) 111 - Compal CL-50 ??? (*) 117 + Compal CL-50 ??? [#f1]_ 112 118 Compaq Armada E500 - P3-700 none (1) (S1 also works OK) 113 119 Compaq Evo N620c vga=normal, s3_bios (2) 114 120 Dell 600m, ATI R250 Lf none (1), but needs xorg-x11-6.8.1.902-1 115 121 Dell D600, ATI RV250 vga=normal and X, or try vbestate (6) 116 - Dell D610 vga=normal and X (possibly vbestate (6) too, but not tested) 117 - Dell Inspiron 4000 ??? (*) 118 - Dell Inspiron 500m ??? (*) 122 + Dell D610 vga=normal and X (possibly vbestate (6) too, 123 + but not tested) 124 + Dell Inspiron 4000 ??? [#f1]_ 125 + Dell Inspiron 500m ??? [#f1]_ 119 126 Dell Inspiron 510m ??? 120 127 Dell Inspiron 5150 vbetool needed (6) 121 - Dell Inspiron 600m ??? (*) 122 - Dell Inspiron 8200 ??? (*) 123 - Dell Inspiron 8500 ??? (*) 124 - Dell Inspiron 8600 ??? (*) 125 - eMachines athlon64 machines vbetool needed (6) (someone please get me model #s) 126 - HP NC6000 s3_bios, may not use radeonfb (2); or vbetool (6) 127 - HP NX7000 ??? (*) 128 - HP Pavilion ZD7000 vbetool post needed, need open-source nv driver for X 128 + Dell Inspiron 600m ??? [#f1]_ 129 + Dell Inspiron 8200 ??? [#f1]_ 130 + Dell Inspiron 8500 ??? [#f1]_ 131 + Dell Inspiron 8600 ??? [#f1]_ 132 + eMachines athlon64 machines vbetool needed (6) (someone please get 133 + me model #s) 134 + HP NC6000 s3_bios, may not use radeonfb (2); 135 + or vbetool (6) 136 + HP NX7000 ??? [#f1]_ 137 + HP Pavilion ZD7000 vbetool post needed, need open-source nv 138 + driver for X 129 139 HP Omnibook XE3 athlon version none (1) 130 140 HP Omnibook XE3GC none (1), video is S3 Savage/IX-MV 131 141 HP Omnibook XE3L-GF vbetool (6) 132 142 HP Omnibook 5150 none (1), (S1 also works OK) 133 - IBM TP T20, model 2647-44G none (1), video is S3 Inc. 86C270-294 Savage/IX-MV, vesafb gets "interesting" but X work. 134 - IBM TP A31 / Type 2652-M5G s3_mode (3) [works ok with BIOS 1.04 2002-08-23, but not at all with BIOS 1.11 2004-11-05 :-(] 143 + IBM TP T20, model 2647-44G none (1), video is S3 Inc. 86C270-294 144 + Savage/IX-MV, vesafb gets "interesting" 145 + but X work. 146 + IBM TP A31 / Type 2652-M5G s3_mode (3) [works ok with 147 + BIOS 1.04 2002-08-23, but not at all with 148 + BIOS 1.11 2004-11-05 :-(] 135 149 IBM TP R32 / Type 2658-MMG none (1) 136 - IBM TP R40 2722B3G ??? (*) 150 + IBM TP R40 2722B3G ??? [#f1]_ 137 151 IBM TP R50p / Type 1832-22U s3_bios (2) 138 152 IBM TP R51 none (1) 139 - IBM TP T30 236681A ??? (*) 153 + IBM TP T30 236681A ??? [#f1]_ 140 154 IBM TP T40 / Type 2373-MU4 none (1) 141 155 IBM TP T40p none (1) 142 156 IBM TP R40p s3_bios (2) 143 157 IBM TP T41p s3_bios (2), switch to X after resume 144 158 IBM TP T42 s3_bios (2) 145 159 IBM ThinkPad T42p (2373-GTG) s3_bios (2) 146 - IBM TP X20 ??? (*) 160 + IBM TP X20 ??? [#f1]_ 147 161 IBM TP X30 s3_bios, s3_mode (4) 148 - IBM TP X31 / Type 2672-XXH none (1), use radeontool (http://fdd.com/software/radeon/) to turn off backlight. 149 - IBM TP X32 none (1), but backlight is on and video is trashed after long suspend. s3_bios,s3_mode (4) works too. Perhaps that gets better results? 162 + IBM TP X31 / Type 2672-XXH none (1), use radeontool 163 + (http://fdd.com/software/radeon/) to 164 + turn off backlight. 165 + IBM TP X32 none (1), but backlight is on and video is 166 + trashed after long suspend. s3_bios, 167 + s3_mode (4) works too. Perhaps that gets 168 + better results? 150 169 IBM Thinkpad X40 Type 2371-7JG s3_bios,s3_mode (4) 151 - IBM TP 600e none(1), but a switch to console and back to X is needed 152 - Medion MD4220 ??? (*) 170 + IBM TP 600e none(1), but a switch to console and 171 + back to X is needed 172 + Medion MD4220 ??? [#f1]_ 153 173 Samsung P35 vbetool needed (6) 154 174 Sharp PC-AR10 (ATI rage) none (1), backlight does not switch off 155 175 Sony Vaio PCG-C1VRX/K s3_bios (2) 156 - Sony Vaio PCG-F403 ??? (*) 176 + Sony Vaio PCG-F403 ??? [#f1]_ 157 177 Sony Vaio PCG-GRT995MP none (1), works with 'nv' X driver 158 - Sony Vaio PCG-GR7/K none (1), but needs radeonfb, use radeontool (http://fdd.com/software/radeon/) to turn off backlight. 159 - Sony Vaio PCG-N505SN ??? (*) 178 + Sony Vaio PCG-GR7/K none (1), but needs radeonfb, use 179 + radeontool (http://fdd.com/software/radeon/) 180 + to turn off backlight. 181 + Sony Vaio PCG-N505SN ??? [#f1]_ 160 182 Sony Vaio vgn-s260 X or boot-radeon can init it (5) 161 - Sony Vaio vgn-S580BH vga=normal, but suspend from X. Console will be blank unless you return to X. 183 + Sony Vaio vgn-S580BH vga=normal, but suspend from X. Console will 184 + be blank unless you return to X. 162 185 Sony Vaio vgn-FS115B s3_bios (2),s3_mode (4) 163 186 Toshiba Libretto L5 none (1) 164 187 Toshiba Libretto 100CT/110CT vbetool (6) 165 188 Toshiba Portege 3020CT s3_mode (3) 166 189 Toshiba Satellite 4030CDT s3_mode (3) (S1 also works OK) 167 190 Toshiba Satellite 4080XCDT s3_mode (3) (S1 also works OK) 168 - Toshiba Satellite 4090XCDT ??? (*) 169 - Toshiba Satellite P10-554 s3_bios,s3_mode (4)(****) 191 + Toshiba Satellite 4090XCDT ??? [#f1]_ 192 + Toshiba Satellite P10-554 s3_bios,s3_mode (4)[#f3]_ 170 193 Toshiba M30 (2) xor X with nvidia driver using internal AGP 171 - Uniwill 244IIO ??? (*) 194 + Uniwill 244IIO ??? [#f1]_ 195 + =============================== =============================================== 172 196 173 197 Known working desktop systems 174 198 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 175 199 200 + =================== ============================= ======================== 176 201 Mainboard Graphics card hack (or "how to do it") 177 - ------------------------------------------------------------------------------ 202 + =================== ============================= ======================== 178 203 Asus A7V8X nVidia RIVA TNT2 model 64 s3_bios,s3_mode (4) 204 + =================== ============================= ======================== 179 205 180 206 181 - (*) from https://wiki.ubuntu.com/HoaryPMResults, not sure 182 - which options to use. If you know, please tell me. 207 + .. [#f1] from https://wiki.ubuntu.com/HoaryPMResults, not sure 208 + which options to use. If you know, please tell me. 183 209 184 - (***) To be tested with a newer kernel. 210 + .. [#f2] To be tested with a newer kernel. 185 211 186 - (****) Not with SMP kernel, UP only. 212 + .. [#f3] Not with SMP kernel, UP only.
+1 -1
Documentation/process/submitting-drivers.rst
··· 117 117 implemented") error. You should also try to make sure that your 118 118 driver uses as little power as possible when it's not doing 119 119 anything. For the driver testing instructions see 120 - Documentation/power/drivers-testing.txt and for a relatively 120 + Documentation/power/drivers-testing.rst and for a relatively 121 121 complete overview of the power management issues related to 122 122 drivers see :ref:`Documentation/driver-api/pm/devices.rst <driverapi_pm_devices>`. 123 123
+3 -3
Documentation/scheduler/sched-energy.txt
··· 22 22 23 23 The actual EM used by EAS is _not_ maintained by the scheduler, but by a 24 24 dedicated framework. For details about this framework and what it provides, 25 - please refer to its documentation (see Documentation/power/energy-model.txt). 25 + please refer to its documentation (see Documentation/power/energy-model.rst). 26 26 27 27 28 28 2. Background and Terminology ··· 81 81 82 82 The rest of platform knowledge used by EAS is directly read from the Energy 83 83 Model (EM) framework. The EM of a platform is composed of a power cost table 84 - per 'performance domain' in the system (see Documentation/power/energy-model.txt 84 + per 'performance domain' in the system (see Documentation/power/energy-model.rst 85 85 for futher details about performance domains). 86 86 87 87 The scheduler manages references to the EM objects in the topology code when the ··· 352 352 EAS uses the EM of a platform to estimate the impact of scheduling decisions on 353 353 energy. So, your platform must provide power cost tables to the EM framework in 354 354 order to make EAS start. To do so, please refer to documentation of the 355 - independent EM framework in Documentation/power/energy-model.txt. 355 + independent EM framework in Documentation/power/energy-model.rst. 356 356 357 357 Please also note that the scheduling domains need to be re-built after the 358 358 EM has been registered in order to start EAS.
+1 -1
Documentation/trace/coresight-cpu-debug.txt
··· 151 151 152 152 It is possible to disable CPU idle states by way of the PM QoS 153 153 subsystem, more specifically by using the "/dev/cpu_dma_latency" 154 - interface (see Documentation/power/pm_qos_interface.txt for more 154 + interface (see Documentation/power/pm_qos_interface.rst for more 155 155 details). As specified in the PM QoS documentation the requested 156 156 parameter will stay in effect until the file descriptor is released. 157 157 For example:
+1 -1
Documentation/translations/zh_CN/process/submitting-drivers.rst
··· 97 97 函数定义成返回 -ENOSYS(功能未实现)错误。你还应该尝试确 98 98 保你的驱动在什么都不干的情况下将耗电降到最低。要获得驱动 99 99 程序测试的指导,请参阅 100 - Documentation/power/drivers-testing.txt。有关驱动程序电 100 + Documentation/power/drivers-testing.rst。有关驱动程序电 101 101 源管理问题相对全面的概述,请参阅 102 102 Documentation/driver-api/pm/devices.rst。 103 103
+2 -2
MAINTAINERS
··· 6446 6446 M: Pavel Machek <pavel@ucw.cz> 6447 6447 L: linux-pm@vger.kernel.org 6448 6448 S: Supported 6449 - F: Documentation/power/freezing-of-tasks.txt 6449 + F: Documentation/power/freezing-of-tasks.rst 6450 6450 F: include/linux/freezer.h 6451 6451 F: kernel/freezer.c 6452 6452 ··· 11764 11764 T: git git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git 11765 11765 F: drivers/opp/ 11766 11766 F: include/linux/pm_opp.h 11767 - F: Documentation/power/opp.txt 11767 + F: Documentation/power/opp.rst 11768 11768 F: Documentation/devicetree/bindings/opp/ 11769 11769 11770 11770 OPL4 DRIVER
+1 -1
arch/x86/Kconfig
··· 2447 2447 machines with more than one CPU. 2448 2448 2449 2449 In order to use APM, you will need supporting software. For location 2450 - and more information, read <file:Documentation/power/apm-acpi.txt> 2450 + and more information, read <file:Documentation/power/apm-acpi.rst> 2451 2451 and the Battery Powered Linux mini-HOWTO, available from 2452 2452 <http://www.tldp.org/docs.html#howto>. 2453 2453
+1 -1
drivers/gpu/drm/i915/i915_drv.h
··· 1175 1175 * to be disabled. This shouldn't happen and we'll print some error messages in 1176 1176 * case it happens. 1177 1177 * 1178 - * For more, read the Documentation/power/runtime_pm.txt. 1178 + * For more, read the Documentation/power/runtime_pm.rst. 1179 1179 */ 1180 1180 struct i915_runtime_pm { 1181 1181 atomic_t wakeref_count;
+1 -1
drivers/opp/Kconfig
··· 10 10 OPP layer organizes the data internally using device pointers 11 11 representing individual voltage domains and provides SOC 12 12 implementations a ready to use framework to manage OPPs. 13 - For more information, read <file:Documentation/power/opp.txt> 13 + For more information, read <file:Documentation/power/opp.rst>
+1 -1
drivers/power/supply/power_supply_core.c
··· 607 607 608 608 /* The property and field names below must correspond to elements 609 609 * in enum power_supply_property. For reasoning, see 610 - * Documentation/power/power_supply_class.txt. 610 + * Documentation/power/power_supply_class.rst. 611 611 */ 612 612 613 613 of_property_read_u32(battery_np, "energy-full-design-microwatt-hours",
+1 -1
include/linux/interrupt.h
··· 52 52 * irq line disabled until the threaded handler has been run. 53 53 * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend. Does not guarantee 54 54 * that this interrupt will wake the system from a suspended 55 - * state. See Documentation/power/suspend-and-interrupts.txt 55 + * state. See Documentation/power/suspend-and-interrupts.rst 56 56 * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set 57 57 * IRQF_NO_THREAD - Interrupt cannot be threaded 58 58 * IRQF_EARLY_RESUME - Resume IRQ early during syscore instead of at device
+1 -1
include/linux/pci.h
··· 807 807 * @suspend_late: Put device into low power state. 808 808 * @resume_early: Wake device from low power state. 809 809 * @resume: Wake device from low power state. 810 - * (Please see Documentation/power/pci.txt for descriptions 810 + * (Please see Documentation/power/pci.rst for descriptions 811 811 * of PCI Power Management and the related functions.) 812 812 * @shutdown: Hook into reboot_notifier_list (kernel/sys.c). 813 813 * Intended to stop any idling DMA operations.
+1 -1
include/linux/pm.h
··· 284 284 * actions to be performed by a device driver's callbacks generally depend on 285 285 * the platform and subsystem the device belongs to. 286 286 * 287 - * Refer to Documentation/power/runtime_pm.txt for more information about the 287 + * Refer to Documentation/power/runtime_pm.rst for more information about the 288 288 * role of the @runtime_suspend(), @runtime_resume() and @runtime_idle() 289 289 * callbacks in device runtime power management. 290 290 */
+3 -3
kernel/power/Kconfig
··· 65 65 need to run mkswap against the swap partition used for the suspend. 66 66 67 67 It also works with swap files to a limited extent (for details see 68 - <file:Documentation/power/swsusp-and-swap-files.txt>). 68 + <file:Documentation/power/swsusp-and-swap-files.rst>). 69 69 70 70 Right now you may boot without resuming and resume later but in the 71 71 meantime you cannot use the swap partition(s)/file(s) involved in ··· 74 74 MOUNT any journaled filesystems mounted before the suspend or they 75 75 will get corrupted in a nasty way. 76 76 77 - For more information take a look at <file:Documentation/power/swsusp.txt>. 77 + For more information take a look at <file:Documentation/power/swsusp.rst>. 78 78 79 79 config ARCH_SAVE_PAGE_KEYS 80 80 bool ··· 255 255 notification of APM "events" (e.g. battery status change). 256 256 257 257 In order to use APM, you will need supporting software. For location 258 - and more information, read <file:Documentation/power/apm-acpi.txt> 258 + and more information, read <file:Documentation/power/apm-acpi.rst> 259 259 and the Battery Powered Linux mini-HOWTO, available from 260 260 <http://www.tldp.org/docs.html#howto>. 261 261
+1 -1
net/wireless/Kconfig
··· 165 165 166 166 If this causes your applications to misbehave you should fix your 167 167 applications instead -- they need to register their network 168 - latency requirement, see Documentation/power/pm_qos_interface.txt. 168 + latency requirement, see Documentation/power/pm_qos_interface.rst. 169 169 170 170 config CFG80211_DEBUGFS 171 171 bool "cfg80211 DebugFS entries"