/[gentoo]/xml/htdocs/doc/en/power-management-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/power-management-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.7 Revision 1.41
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.7 2004/10/11 00:51:36 vapier Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.41 2009/08/12 02:24:57 nightmorph Exp $ -->
4<guide link="power-management-guide.xml"> 4<guide link="/doc/en/power-management-guide.xml">
5<title>Power Management Guide</title> 5<title>Power Management Guide</title>
6 6
7<author title="Author"> 7<author title="Author">
8 <mail link="fragfred@gmx.de">Dennis Nienh&#252;ser</mail> 8 <mail link="earthwings@gentoo.org">Dennis Nienhüser</mail>
9</author>
10<author title="Editor">
11 <mail link="chriswhite@gentoo.org">Chris White</mail>
12</author>
13<author title="Editor">
14 <mail link="nightmorph@gentoo.org">Joshua Saddler</mail>
9</author> 15</author>
10 16
11<abstract> 17<abstract>
12Power Management is the key to extend battery run time on mobile systems like 18Power Management is the key to extend battery run time on mobile systems like
13laptops. This guide assists you setting it up on your laptop. 19laptops. This guide assists you setting it up on your laptop.
14</abstract> 20</abstract>
15 21
16<!-- The content of this document is licensed under the CC-BY-SA license --> 22<!-- The content of this document is licensed under the CC-BY-SA license -->
17<!-- See http://creativecommons.org/licenses/by-sa/2.0 --> 23<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
18<license/> 24<license/>
19 25
20<version>1.17</version> 26<version>1.44</version>
21<date>October 10, 2004</date> 27<date>2009-08-11</date>
22 28
23<chapter> 29<chapter>
24<title>Introduction</title> 30<title>Introduction</title>
25
26<section> 31<section>
27<title>Why Power Management?</title>
28
29<body> 32<body>
30 33
31<p> 34<p>
32Capacity and lifetime of laptop batteries has improved much in the last years. 35Capacity and lifetime of laptop batteries have improved much in the last years.
33Nevertheless modern processors consume much more energy than older ones and 36Nevertheless modern processors consume much more energy than older ones and
34each laptop generation introduces more devices hungry for energy. That's why 37each laptop generation introduces more devices hungry for energy. That's why
35Power Management is more important than ever. Increasing battery run time 38Power Management is more important than ever. Increasing battery run time
36doesn't necessarily mean buying another battery. Much can be achieved applying 39doesn't necessarily mean buying another battery. Much can be achieved applying
37intelligent Power Management policies. 40intelligent Power Management policies.
38</p> 41</p>
39 42
40</body> 43</body>
41</section> 44</section>
42
43<section> 45<section>
44<title>A quick overview</title> 46<title>A Quick Overview</title>
45<body> 47<body>
46 48
47<p> 49<p>
48Please notice that this guide describes Power Management for <e>laptops</e>. 50Please notice that this guide describes Power Management for <e>laptops</e>.
49While some sections might also suite for <e>servers</e>, others do not and may 51While some sections might also suite for <e>servers</e>, others do not and may
55As this guide has become rather long, here's a short overview helping you to 57As this guide has become rather long, here's a short overview helping you to
56find your way through it. 58find your way through it.
57</p> 59</p>
58 60
59<p> 61<p>
60The <e>Prerequisites</e> chapter talks about some requirements that should be 62The <uri link="#doc_chap2">Prerequisites</uri> chapter talks about some
61met before any of the following device individual sections will work. This 63requirements that should be met before any of the following device individual
62includes BIOS settings, kernel configuration and some simplifications in user 64sections will work. This includes BIOS settings, kernel configuration and some
63land. The following three chapters focus on devices that typically consume most 65simplifications in user land. The following three chapters focus on devices
64energy - processor, display and hard drive. Each can be configured seperately. 66that typically consume most energy - processor, display and hard drive. Each
65<e>CPU Power Management</e> shows how to adjust the processor's frequency to 67can be configured seperately. <uri link="#doc_chap3">CPU Power Management</uri>
66save a maximum of energy whithout losing too much performance. A few different 68shows how to adjust the processor's frequency to save a maximum of energy
67tricks prevent your hard drive from working unnecessarily often in <e>Disk Power 69without losing too much performance. A few different tricks prevent your hard
70drive from working unnecessarily often in <uri link="#doc_chap5">Disk Power
68Management</e> (decreasing noise level as a nice side effect). Some notes on 71Management</uri> (decreasing noise level as a nice side effect). Some notes on
69Wireless LAN and USB finish the device section in <e>Power Management for other 72graphics cards, Wireless LAN and USB finish the device section in <uri
70devices</e> while another chapter is dedicated to the (rather experimental) 73link="#doc_chap6">Power Management For Other Devices</uri> while another
71<e>sleep states</e>. Last not least <e>Troubleshooting</e> lists common 74chapter is dedicated to the (rather experimental) <uri link="#doc_chap7">sleep
72pitfalls. 75states</uri>. Last not least <uri link="#doc_chap8">Troubleshooting</uri> lists
76common pitfalls.
73</p> 77</p>
74 78
75</body> 79</body>
76</section>
77
78<section> 80</section>
81<section>
79<title>Power Budget for each component</title> 82<title>Power Budget For Each Component</title>
80<body> 83<body>
81 84
82<figure link="/images/energy-budget.png" short="Which component consumes how 85<figure link="/images/energy-budget.png" short="Which component consumes how
83much energy?" caption="Power budget for each component"/> 86much energy?" caption="Power budget for each component"/>
84 87
95</chapter> 98</chapter>
96 99
97<chapter> 100<chapter>
98<title>Prerequisites</title> 101<title>Prerequisites</title>
99<section> 102<section>
100<title>What has to be done first</title>
101<body>
102
103<p>
104Before going into the details on making individual devices Power Management
105aware, make sure certain requirements are met. After controlling the BIOS
106settings, some kernel options want to be enabled - these are in short ACPI,
107sleep states and CPU frequency scaling. As power saving most of the time comes
108along with performance loss or increased latency, it should only be enabled
109when running on batteries. That's where a new runlevel <e>battery</e> comes in
110handy.
111</p>
112
113</body> 103<body>
114</section> 104
105<p>
106Before discussing the details of making individual devices Power Management
107aware, make sure certain requirements are met. After controlling BIOS settings,
108some kernel options want to be enabled - these are in short ACPI, sleep states
109and CPU frequency scaling. As power saving most of the time comes along with
110performance loss or increased latency, it should only be enabled when running
111on batteries. That's where a new runlevel <e>battery</e> comes in handy.
112</p>
113
114</body>
115<section> 115</section>
116<section>
116<title>The BIOS part</title> 117<title>The BIOS Part</title>
117<body> 118<body>
118 119
119<p> 120<p>
120First have a look into your BIOS Power Management settings. The best way is to 121First have a look into your BIOS Power Management settings. The best way is to
121combine BIOS and operating system policies, but for the moment it's better to 122combine BIOS and operating system policies, but for the moment it's better to
125</p> 126</p>
126 127
127</body> 128</body>
128</section> 129</section>
129<section> 130<section>
131<title>Setting USE Flags</title>
132<body>
133
134<p>
135Please check that the <c>acpi</c> USE flag is set in
136<path>/etc/make.conf</path>. Other USE flags that might be interesting for your
137system are <c>apm</c>, <c>lm_sensors</c>, <c>nforce2</c>, <c>nvidia</c>,
138<c>pmu</c>. See <path>/usr/portage/profiles/use*.desc</path> for details. If
139you forgot to set one of these flags, you can recompile affected packages using
140the <c>--newuse</c> flag in <c>emerge</c>, see <c>man emerge</c>.
141</p>
142
143</body>
144</section>
145<section>
130<title>Configuring the kernel</title> 146<title>Configuring The Kernel</title>
131<body> 147<body>
132 148
133<p> 149<p>
134ACPI (Advanced Configuration and Power Interface) support in the kernel is 150ACPI (Advanced Configuration and Power Interface) support in the kernel is
135still work in progress. Using a recent kernel will make sure you'll get the 151still work in progress. Using a recent kernel will make sure you'll get the
136most out of it. 152most out of it.
137</p> 153</p>
138 154
139<p> 155<p>
140In kernel config, activate at least these options: 156There are different kernel sources in Portage. I'd recommend using
157<c>gentoo-sources</c> or <c>tuxonice-sources</c>. The latter contains patches
158for TuxOnIce, see the chapter about <uri link="#doc_chap7">sleep states</uri>
159for more details. When configuring the kernel, activate at least these options:
141</p> 160</p>
142 161
143<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)"> 162<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
144Power Management Options ---&gt; 163Power management and ACPI options ---&gt;
145 [*] Power Management Support 164[*] Power Management support
146 [ ] Software Suspend 165 [ ] Software Suspend
147 [ ] Suspend-to-Disk Support
148 166
149 ACPI( Advanced Configuration and Power Interface ) Support ---&gt; 167 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
150 [*] ACPI Support 168 [ ] Deprecated /proc/acpi/ files
151 [ ] Sleep States 169 [*] AC Adapter
152 &lt;M&gt; AC Adapter 170 [*] Battery
153 &lt;M&gt; Battery
154 &lt;M&gt; Button 171 &lt;M&gt; Button
172 &lt;M&gt; Video
173 [ ] Generic Hotkey
155 &lt;M&gt; Fan 174 &lt;M&gt; Fan
156 &lt;M&gt; Processor 175 &lt;M&gt; Processor
157 &lt;M&gt; Thermal Zone 176 &lt;M&gt; Thermal Zone
158 &lt; &gt; ASUS/Medion Laptop Extras 177 &lt; &gt; ASUS/Medion Laptop Extras
178 &lt; &gt; IBM ThinkPad Laptop Extras
159 &lt; &gt; Toshiba Laptop Extras 179 &lt; &gt; Toshiba Laptop Extras
180 (0) Disable ACPI for systems before Jan 1st this year
160 [ ] Debug Statements 181 [ ] Debug Statements
161 182 [*] Power Management Timer Support
183 &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)
184
162 CPU Frequency Scaling ---&gt; 185 CPU Frequency Scaling ---&gt;
163 [*] CPU Frequency scaling 186 [*] CPU Frequency scaling
187 [ ] Enable CPUfreq debugging
188 &lt; &gt; CPU frequency translation statistics
189 [ ] CPU frequency translation statistics details
164 Default CPUFreq governor (userspace) 190 Default CPUFreq governor (userspace)
165 &lt;*&gt; 'performance' governor 191 &lt;*&gt; 'performance' governor
166 &lt;*&gt; 'powersave' governor 192 &lt;*&gt; 'powersave' governor
193 &lt;*&gt; 'ondemand' cpufreq policy governor
194 &lt;*&gt; 'conservative' cpufreq governor
167 &lt;*&gt; CPU frequency table helpers 195 &lt;*&gt; CPU frequency table helpers
168 &lt;M&gt; ACPI Processor P-States driver 196 &lt;M&gt; ACPI Processor P-States driver
169 &lt;*&gt; <i>CPUFreq driver for your processor</i> 197 &lt;*&gt; <i>CPUFreq driver for your processor</i>
170</pre> 198</pre>
171 199
172<p> 200<p>
173Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk 201Decide yourself whether you want to enable Software Suspend, and Sleep States
174and Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, 202(see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable
175enable the appropriate section. 203the appropriate section.
204</p>
205
206<p>
207The kernel has to know how to enable CPU frequency scaling on your processor.
208As each type of CPU has a different interface, you've got to choose the right
209driver for your processor. Be careful here - enabling <c>Intel Pentium 4 clock
210modulation</c> on a Pentium M system will lead to strange results for example.
211Consult the kernel documentation if you're unsure which one to take.
176</p> 212</p>
177 213
178<p> 214<p>
179Compile your kernel, make sure the right modules get loaded at startup and boot 215Compile your kernel, make sure the right modules get loaded at startup and boot
180into your new ACPI-enabled kernel. Next run <c>emerge sys-apps/acpid</c> to get 216into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to
181the acpi daemon. This one informs you about events like switching from AC to 217get the acpi daemon. This one informs you about events like switching from AC
182battery or closing the lid. Make sure the module <e>button</e> is loaded if you 218to battery or closing the lid. Make sure the modules are loaded if you didn't
183didn't compile it into the kernel and start acpid with <c>/etc/init.d/acpid 219compile them into the kernel and start acpid by executing <c>/etc/init.d/acpid
184start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll 220start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
185soon see how to use it. 221soon see how to use it.
186</p> 222</p>
187 223
188<pre caption="Installing acpid"> 224<pre caption="Installing acpid">
189# <i>emerge sys-apps/acpid</i> 225# <i>emerge sys-power/acpid</i>
190# <i>modprobe button</i>
191# <i>/etc/init.d/acpid start</i> 226# <i>/etc/init.d/acpid start</i>
192# <i>rc-update add acpid default</i> 227# <i>rc-update add acpid default</i>
193</pre> 228</pre>
194 229
195</body> 230</body>
196</section> 231</section>
197<section> 232<section>
198<title>Creating a "battery" runlevel</title> 233<title>Creating A "battery" Runlevel</title>
199<body> 234<body>
200 235
201<p> 236<p>
202The default policy will be to enable Power Management only when needed - 237The default policy will be to enable Power Management only when needed -
203running on batteries. To make the switch between AC and battery convenient, 238running on batteries. To make the switch between AC and battery convenient,
204create a runlevel <e>battery</e> that holds all the scripts starting and 239create a runlevel <c>battery</c> that holds all the scripts starting and
205stopping Power Management. 240stopping Power Management.
206</p> 241</p>
207 242
208<note> 243<note>
209You can safely skip this section if you don't like the idea of having another 244You can safely skip this section if you don't like the idea of having another
210runlevel. However, skipping this step will make the rest a bit trickier to set 245runlevel. However, skipping this step will make the rest a bit trickier to set
211up. The next sections assume a runlevel <e>battery</e> exists. 246up. The next sections assume a runlevel <c>battery</c> exists.
212</note> 247</note>
213 248
214<pre caption="Creating a battery runlevel"> 249<pre caption="Creating a battery runlevel">
215# <i>cd /etc/runlevels</i> 250# <i>cd /etc/runlevels</i>
216# <i>cp -a default battery</i> 251# <i>cp -a default battery</i>
217</pre> 252</pre>
218 253
219<p> 254<p>
220Finished. Your new runlevel <e>battery</e> contains everything like 255Finished. Your new runlevel <c>battery</c> contains everything like
221<e>default</e>, but there is no automatic switch between both yet. Time to 256<c>default</c>, but there is no automatic switch between both yet. Time to
222change it. 257change it.
223</p> 258</p>
224 259
225</body> 260</body>
226</section> 261</section>
227<section> 262<section>
228<title>Reacting on ACPI events</title> 263<title>Reacting On ACPI Events</title>
229<body> 264<body>
230 265
231<p> 266<p>
232Typical ACPI events are closing the lid, changing the power source or pressing 267Typical ACPI events are closing the lid, changing the power source or pressing
233the sleep button. Every acpi event recognized by the kernel is catched by acpid 268the sleep button. An important event is changing the power source, which should
234which calls <path>/etc/acpi/default.sh</path>. Here is a basic modification 269cause a runlevel switch. A small script will take care of it.
235supporting runlevel switching: 270</p>
271
236</p> 272<p>
273First you need a script which changes the runlevel to <c>default</c>
274respectively <c>battery</c> depending on the power source. The script uses the
275<c>on_ac_power</c> command from <c>sys-power/powermgmt-base</c> - make sure the
276package is installed on your system.
277</p>
237 278
238<pre caption="Event driven runlevel switching with acpid"> 279<pre caption="Installing powermgt-base">
280# <i>emerge powermgmt-base</i>
281</pre>
282
283<p>
284You are now able to determine the power source by executing <c>on_ac_power
285&amp;&amp; echo AC available || echo Running on batteries</c> in a shell. The
286script below is responsible for changing runlevels. Save it as
287<path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>.
288</p>
289
290<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
239#!/bin/sh 291#!/bin/bash
240 292
241set $* 293<comment># BEGIN configuration</comment>
242
243group=${1/\/*/}
244action=${1/*\//}
245
246<comment># runlevel to use in AC mode</comment>
247RLVL_AC="default" 294RUNLEVEL_AC="default"
248<comment># runlevel to use in battery mode</comment>
249RLVL_BATTERY="battery" 295RUNLEVEL_BATTERY="battery"
296<comment># END configuration</comment>
250 297
251<comment># file indicating the AC state. Verify the filename before using</comment>
252AC_STATE="/proc/acpi/ac_adapter/AC/state"
253<comment># this string means running on AC</comment>
254AC_ON="on-line"
255<comment># this string means running on batteries</comment>
256AC_OFF="off-line"
257 298
258function SwitchRunlevel() { 299if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
259 if [[ "$(grep ${AC_OFF} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_BATTERY}" ]] 300then
301 logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
302 exit 1
303fi
304
305if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
306then
307 logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
308 exit 1
309fi
310
311if on_ac_power
312then
313 if [[ "$(&lt;/var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
260 then 314 then
315 logger "Switching to ${RUNLEVEL_AC} runlevel"
316 /sbin/rc ${RUNLEVEL_AC}
317 fi
318elif [[ "$(&lt;/var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
319then
261 logger "Switching to ${RLVL_BATTERY} runlevel" 320 logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
262 /sbin/rc ${RLVL_BATTERY} 321 /sbin/rc ${RUNLEVEL_BATTERY}
263 elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]] 322fi
264 then 323</pre>
265 logger "Switching to ${RLVL_AC} runlevel"
266 /sbin/rc ${RLVL_AC}
267 fi
268}
269 324
325<p>
326Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to
327make the script executable. The last thing that needs to be done is calling the
328script whenever the power source changes. That's done by catching ACPI events
329with the help of <c>acpid</c>. First you need to know which events are
330generated when the power source changes. The events are called
331<c>ac_adapter</c> and <c>battery</c> on most laptops, but it might be different
332on yours.
333</p>
270 334
271case "$group" in 335<pre caption="Determining ACPI events for changing the power source">
272 battery) 336# <i>tail -f /var/log/messages | grep "received event"</i>
273 case "$action" in 337</pre>
274 battery)
275 SwitchRunlevel
276 ;;
277 *)
278 logger "ACPI group battery / action $action is not defined"
279 ;;
280 esac
281 ;;
282 338
283 ac_adapter) 339<p>
284 case "$action" in 340Run the command above and pull the power cable. You should see something like
285 ac_adapter) 341this:
286 SwitchRunlevel 342</p>
287 ;; 343
288 *) 344<pre caption="Sample output for power source changes">
289 logger "ACPI group ac_adapter / action $action is not defined" 345[Tue Sep 20 17:39:06 2005] received event "ac_adapter AC 00000080 00000000"
290 ;; 346[Tue Sep 20 17:39:06 2005] received event "battery BAT0 00000080 00000001"
291 esac 347</pre>
292 ;; 348
293 *) 349<p>
294 logger "ACPI group $group / action $action is not defined" 350The interesting part is the quoted string after <c>received event</c>. It will
295 ;; 351be matched by the event line in the files you are going to create below. Don't
296esac 352worry if your system generates multiple events or always the same. As long as
353any event is generated, runlevel changing will work.
354</p>
355
356<pre caption="/etc/acpi/events/pmg_ac_adapter">
357<comment># replace "ac_adapter" below with the event generated on your laptop</comment>
358<comment># For example, ac_adapter.* will match ac_adapter AC 00000080 00000000</comment>
359event=ac_adapter.*
360action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
361</pre>
362
363<pre caption="/etc/acpi/events/pmg_battery">
364<comment># replace "battery" below with the event generated on your laptop</comment>
365<comment># For example, battery.* will match battery BAT0 00000080 00000001</comment>
366event=battery.*
367action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
368</pre>
369
370<p>
371Finally acpid has to be restarted to recognize the changes.
372</p>
373
374<pre caption="Finishing runlevel switching with acpid">
375# <i>/etc/init.d/acpid restart</i>
297</pre> 376</pre>
298 377
299<p> 378<p>
300Give it a try: Plug AC in and out and watch syslog for the "Switching to AC 379Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
301mode" or "Switching to battery mode" messages. 380mode" or "Switching to battery mode" messages. See the <uri
381link="#doc_chap8">Troubleshooting section</uri> if the script is not able to
382detect the power source correctly.
302</p> 383</p>
303 384
304<p> 385<p>
305Due to the nature of the event mechanism, your laptop will boot into runlevel 386Due to the nature of the event mechanism, your laptop will boot into runlevel
306<e>default</e> regardless of the AC/battery state. You can add another entry 387<c>default</c> regardless of the AC/battery state. This is fine when running
307to the boot loader with <c>softlevel=boot</c>, but it's likely to forget 388from AC, but we'd like to boot into the battery runlevel otherwise. One
308choosing it. A better way is faking an ACPI event in the end of the boot 389solution would be to add another entry to the boot loader with the parameter
309process and let the <path>/etc/acpi/default.sh</path> script decide whether a 390<c>softlevel=battery</c>, but it's likely to forget choosing it. A better way
391is faking an ACPI event in the end of the boot process and letting
392<path>pmg_switch_runlevel.sh</path> script decide whether a runlevel change is
310runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your 393necessary. Open <path>/etc/conf.d/local.start</path> in your favourite editor
311favourite editor and add these lines: 394and add these lines:
312</p> 395</p>
313 396
314<pre caption="Runlevel switch at boot time by editing local.start"> 397<pre caption="Runlevel adjustment at boot time by editing local.start">
315<comment># Fake acpi event to switch runlevel if running on batteries</comment> 398<comment># Fake acpi event to switch runlevel if running on batteries</comment>
316/etc/acpi/default.sh "battery/battery" 399/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
317</pre> 400</pre>
318 401
319<p> 402<p>
320Prepared like this you can activate Power Management policies for individual 403Prepared like this you can activate Power Management policies for individual
321devices. 404devices.
322</p> 405</p>
323 406
324</body> 407</body>
325</section> 408</section>
326</chapter> 409</chapter>
327 410
328<chapter> 411<chapter>
329<title>CPU Power Management</title> 412<title>CPU Power Management</title>
330<section> 413<section>
414<body>
415
416<p>
417Mobile processors can operate at different frequencies. Some allow changing
418voltage as well. Most of the time your CPU doesn't need to run at full speed
419and scaling it down will save much energy - often without any performance
420decrease.
421</p>
422
423</body>
424</section>
425<section>
426<title>Some Technical Terms</title>
427<body>
428
429<p>
430CPU frequency scaling brings up some technical terms that might be unknown to
431you. Here's a quick introduction.
432</p>
433
434<p>
435First of all, the kernel has to be able to change the processor's frequency.
436The <b>CPUfreq processor driver</b> knows the commands to do it on your CPU.
437Thus it's important to choose the right one in your kernel. You should already
438have done it above. Once the kernel knows how to change frequencies, it has to
439know which frequency it should set. This is done according to the <b>policy</b>
440which consists of a <b>CPUfreq policy</b> and a <b>governor</b>. A CPUfreq
441policy are just two numbers which define a range the frequency has to stay
442between - minimal and maximal frequency. The governor now decides which of the
443available frequencies in between minimal and maximal frequency to choose. For
444example, the <b>powersave governor</b> always chooses the lowest frequency
445available, the <b>performance governor</b> the highest one. The <b>userspace
446governor</b> makes no decision but chooses whatever the user (or a program in
447userspace) wants - which means it reads the frequency from
448<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
449</p>
450
451<p>
452This doesn't sound like dynamic frequency changes yet and in fact it isn't.
453Dynamics however can be accomplished with various approaches. For example, the
454<b>ondemand governor</b> makes its decisions depending on the current CPU load.
455The same is done by various userland tools like <c>cpudyn</c>, <c>cpufreqd</c>,
456<c>powernowd</c> and many more. ACPI events can be used to enable or disable
457dynamic frequency changes depending on power source.
458</p>
459
460</body>
461</section>
462<section>
331<title>Setting the frequency manually</title> 463<title>Setting The Frequency</title>
332<body> 464<body>
333 465
334<p> 466<p>
335Decreasing CPU speed and voltage has two advantages: On the one hand less 467Decreasing CPU speed and voltage has two advantages: On the one hand less
336energy is consumed, on the other hand there is thermal improvement as your 468energy is consumed, on the other hand there is thermal improvement as your
339between performance loss and energy saving. 471between performance loss and energy saving.
340</p> 472</p>
341 473
342<note> 474<note>
343Not every laptop supports frequency scaling. If unsure, have a look at the list 475Not every laptop supports frequency scaling. If unsure, have a look at the list
344of supported processors in the <e>Troubleshooting</e> section to verify your's 476of supported processors in the <uri link="#doc_chap8">Troubleshooting</uri>
345is supported. 477section to verify yours is supported.
346</note> 478</note>
347 479
348<p> 480<p>
349It's time to test whether CPU frequency changing works. To get comfortable with 481It's time to test whether CPU frequency changing works. Let's install another
350the interface to the kernel, first do some manual speed modifications. To set 482tool: <c>sys-power/cpufrequtils</c>.
351another CPU speed, use:
352</p>
353
354<pre caption="Manual CPU speed modifications">
355<comment>(Get current frequency)</comment>
356# <i>grep "cpu MHz" /proc/cpuinfo</i>
357
358<comment>(Lists supported frequencies. This might fail.)</comment>
359# <i>cd /sys/devices/system/cpu/cpu0/cpufreq/</i>
360# <i>cat scaling_available_frequencies</i>
361
362<comment>(Change frequency to 1 GHz (1000000 KHz)
363Replace with a frequency your laptop supports.)</comment>
364# <i>echo -n userspace > scaling_governor</i>
365# <i>echo -n 1000000 > scaling_setspeed</i>
366
367<comment>(Verify frequency was changed)</comment>
368# <i>grep "cpu MHz" /proc/cpuinfo</i>
369</pre>
370
371<p> 483</p>
372If you are getting error messages, please refer to the <e>Troubleshooting</e> 484
373chapter in the end of this guide. 485<pre caption="Checking CPU frequency">
486# <i>emerge cpufrequtils</i>
487# <i>cpufreq-info</i>
488</pre>
489
374</p> 490<p>
375 491Here is an example output:
376<p> 492</p>
377You can also write to <path>scaling_max_freq</path> and 493
378<path>scaling_min_freq</path> to set boundaries the frequency should stay in 494<pre caption="Sample output from cpufreq-info">
379between. 495cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004
496Report errors and bugs to linux@brodo.de, please.
497analyzing CPU 0:
498 driver: centrino
499 CPUs which need to switch frequency at the same time: 0
500 hardware limits: 600 MHz - 1.40 GHz
501 available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
502 available cpufreq governors: conservative, ondemand, powersave, userspace, performance
503 current policy: frequency should be within 924 MHz and 1.40 GHz.
504 The governor "performance" may decide which speed to use
505 within this range.
506 current CPU frequency is 1.40 GHz.
507</pre>
508
380</p> 509<p>
510Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
511Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
512governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as
513expected, you might find help in the <uri link="#doc_chap8">Troubleshooting
514section</uri> in the end of this guide.
515</p>
381 516
382<note> 517<p>
383Some kernel seem to be buggy about updating <path>/proc/cpuinfo</path>. If you 518<c>cpufrequtils</c> can operate in an automatic mode (when you use the
384don't see any change there, this doesn't neccessarily mean the CPU frequency 519<b>ondemand</b> governor), you can also switch to the <b>userspace</b> governor
385wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your 520if you want to manually set a specific speed. You can also statically set your
386kernel as asked and check the current frequency with <c>x86info -mhz</c>. 521CPU to its highest or lowest frequency by using the <b>performance</b>
387</note> 522and <b>powersave</b> governors, respectively.
523</p>
388 524
525<pre caption="Changing CPU speeds">
526<comment>(Set the highest available frequency)</comment>
527# <i>cpufreq-set -g performance</i>
528<comment>(Set the lowest available frequency)</comment>
529# <i>cpufreq-set -g powersave</i>
530<comment>(Set a specific frequency)</comment>
531# <i>cpufreq-set -g userspace</i>
532# <i>cpufreq-set -f 2.00ghz</i>
533</pre>
534
389</body> 535</body>
390</section>
391<section> 536</section>
392<title>Automated frequency adaption</title> 537<section>
538<title>Other CPU Speed Utilities</title>
393<body> 539<body>
394 540
395<p> 541<p>
396The above is quite nice, but not doable in daily life. Better let your system 542While <c>cpufrequtils</c> may be the best all-around program, there are some
397set the appropriate frequency automatically. A couple of user space programs 543other choices available in Portage. The following table gives a quick overview
398like to do it for you. The following table gives a quick overview to help you 544of available CPU speed utilities. It's roughly separated in three categories
399decide on one of them. 545<b>kernel</b> for approaches that only need kernel support, <b>daemon</b> for
546programs that run in the background and <b>graphical</b> for programs that
547provide a GUI for easy configuration and changes.
400</p> 548</p>
401 549
402<table> 550<table>
403<tr> 551<tr>
404 <th>Name</th> 552 <th>Name</th>
405 <th>Pro</th> 553 <th>Category</th>
554 <th>Switch decision</th>
555 <th>Kernel governors</th>
556 <th>Further governors</th>
406 <th>Con</th> 557 <th>Comments</th>
558</tr>
559<tr>
560 <ti>'ondemand' governor</ti>
561 <ti>Kernel</ti>
562 <ti>CPU load</ti>
563 <ti>N.A.</ti>
564 <ti>N.A.</ti>
565 <ti>
566 Chooses maximal frequency on CPU load and slowly steps down when the CPU is
567 idle. Further tuning through files in
568 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
569 userland tools (programs, scripts) if governor switching or similar is
570 desired.
571 </ti>
572</tr>
573<tr>
574 <ti>'conservative' governor</ti>
575 <ti>Kernel</ti>
576 <ti>CPU load</ti>
577 <ti>N.A.</ti>
578 <ti>N.A.</ti>
579 <ti>
580 Unlike the ondemand governor, conversative doesn't jump to maximum
581 frequency when CPU load is high, but increases the frequency step by step.
582 Further tuning through files in
583 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
584 userland tools (programs, scripts) if governor switching or similar is
585 desired.
586 </ti>
407</tr> 587</tr>
408<tr> 588<tr>
409 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti> 589 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
410 <ti>Also supports disk standby</ti>
411 <ti></ti> 590 <ti>Daemon</ti>
591 <ti>CPU load</ti>
592 <ti>Performance, powersave</ti>
593 <ti>Dynamic</ti>
594 <ti>
595 Also supports disk standby - notice however that <e>laptop mode</e> in most
596 cases will do a better job.
597 </ti>
412</tr> 598</tr>
413<tr> 599<tr>
414 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreq</uri></ti> 600 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
415 <ti>Sophisticated setup possible</ti> 601 <ti>Daemon</ti>
416 <ti>Complicated setup</ti> 602 <ti>Battery state, CPU load, temperature, running programs and more</ti>
603 <ti>All available</ti>
604 <ti>None</ti>
605 <ti>
606 Sophisticated (but somewhat complicated) setup. Extendible through plugins
607 like sensor monitoring (lm_sensors) or coordinating some NVidia based
608 graphics card memory and core. Cpufreqd is SMP aware and can optionally be
609 controlled manually at runtime.
610 </ti>
611</tr>
612<tr>
613 <ti>
614 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
615 </ti>
616 <ti>Daemon</ti>
617 <ti>CPU load</ti>
618 <ti>None</ti>
619 <ti>Passive, sine, aggressive</ti>
620 <ti>
621 Supports SMP.
622 </ti>
623</tr>
624<tr>
625 <ti>
626 <uri
627 link="http://projects.simpledesigns.com.pl/project/ncpufreqd/">ncpufreqd</uri>
628 </ti>
629 <ti>Daemon</ti>
630 <ti>Temperature</ti>
631 <ti>None</ti>
632 <ti>Powersave, performance</ti>
633 <ti>
634 Toggles the used governor between performance and powersave depending on
635 system temperature. Very useful on laptops with notorious heat problems.
636 </ti>
417</tr> 637</tr>
418<tr> 638<tr>
419 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti> 639 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
640 <ti>Daemon</ti>
641 <ti>CPU load</ti>
642 <ti>None</ti>
643 <ti>Dynamic, powersave, performance, fixed speed</ti>
420 <ti> 644 <ti>
421 Small yet powerful<br /> 645 Easy to configure with a nice client/server interface. Requires a 2.6
422 Useful client/server interface 646 kernel. Unmaintained, broken and thus removed from Portage. Please switch
647 to cpufreqd if you're still using it.
423 </ti> 648 </ti>
424 <ti>Kernel 2.6 series only</ti>
425</tr> 649</tr>
426<tr> 650<tr>
427 <ti><uri link="http://www.deater.net/john/powernowd.html">powernowd</uri></ti> 651 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
428 <ti>Supports SMP</ti> 652 <ti>Graphical</ti>
429 <ti></ti> 653 <ti>None</ti>
654 <ti>None</ti>
655 <ti>None</ti>
656 <ti>
657 Gnome application, a graphical tool to set CPU frequency manually. It does
658 not offer any automation.
659 </ti>
660</tr>
661<tr>
662 <ti>klaptopdaemon</ti>
663 <ti>Graphical</ti>
664 <ti>Battery state</ti>
665 <ti>All available</ti>
666 <ti>None</ti>
667 <ti>
668 KDE only, 'ondemand' governor required for dynamic frequency scaling.
669 </ti>
430</tr> 670</tr>
431</table> 671</table>
432 672
433<p> 673<p>
434While adjusting the frequency to the current load looks simple on the first 674While adjusting the frequency to the current load looks simple at a first
435view, it's not such a trivial task. A bad algorithm can cause switching between 675glance, it's not such a trivial task. A bad algorithm can cause switching
436two frequencies all the time or wasting energy when setting frequency to an 676between two frequencies all the time or wasting energy when setting frequency
437unnecessary high level. 677to an unnecessary high level.
438</p>
439
440<p> 678</p>
679
680<p>
441Which one to choose? If you have no idea about it, first try <c>speedfreq</c>: 681Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
442</p> 682</p>
443 683
444<pre caption="Installing speedfreq"> 684<pre caption="Installing cpufreqd">
445# <i>emerge speedfreq</i> 685# <i>emerge cpufreqd</i>
446# <i>rc-update add speedfreq battery</i>
447</pre> 686</pre>
448 687
449<p>
450<c>speedfreq</c> can be configured by editing
451<path>/etc/conf.d/speedfreq</path>. For example, if you like users to be able
452to change the policy, modify <c>SPEEDFREQ_OPTS=""</c> to
453<c>SPEEDFREQ_OPTS="-u"</c>. Having done your changes, start the daemon.
454</p> 688<p>
689<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>.
690The default one that ships with cpufreqd may look a bit confusing. I recommend
691replacing it with the one from former Gentoo developer Henrik Brix Andersen
692(see below). Please notice that you need cpufreqd-2.0.0 or later. Earlier
693versions have a different syntax for the config file.
694</p>
455 695
696<pre caption="/etc/cpufreqd.conf (cpufreqd-2.0.0 and later)">
697[General]
698pidfile=/var/run/cpufreqd.pid
699poll_interval=3
700enable_plugins=acpi_ac, acpi_battery
701enable_remote=1
702remote_group=wheel
703verbosity=5
704[/General]
705
706[Profile]
707name=ondemand
708minfreq=0%
709maxfreq=100%
710policy=ondemand
711[/Profile]
712
713[Profile]
714name=conservative
715minfreq=0%
716maxfreq=100%
717policy=conservative
718[/Profile]
719
720[Profile]
721name=powersave
722minfreq=0%
723maxfreq=100%
724policy=powersave
725[/Profile]
726
727[Profile]
728name=performance
729minfreq=0%
730maxfreq=100%
731policy=performance
732[/Profile]
733
734[Rule]
735name=battery
736ac=off
737profile=conservative
738[/Rule]
739
740[Rule]
741name=battery_low
742ac=off
743battery_interval=0-10
744profile=powersave
745[/Rule]
746
747[Rule]
748name=ac
749ac=on
750profile=ondemand
751[/Rule]
752</pre>
753
754<p>
755Now you can start the cpufreqd daemon. Add it to the <c>default</c> and
756<c>battery</c> runlevel as well.
757</p>
758
456<pre caption="Starting speedfreq"> 759<pre caption="Starting cpufreqd">
760# <i>rc-update add cpufreqd default battery</i>
457# <i>/etc/init.d/speedfreq start</i> 761# <i>/etc/init.d/cpufreqd start</i>
458</pre> 762</pre>
459 763
460<p> 764<p>
461Setting up cpufreq is a little bit more complicated. 765Sometimes it can be desirable to select another policy than the daemon chooses,
766for example when battery power is low, but you know that AC will be available
767soon. In that case you can turn on cpufreqd's manual mode with <c>cpufreqd-set
768manual</c> and select one of your configured policies (as listed by
769<c>cpufreqd-get</c>). You can leave manual mode by executing <c>cpufreqd-set
770dynamic</c>.
462</p> 771</p>
463 772
464<warn> 773<warn>
465Do not run more than one of the above programs at the same time. It may cause 774Do not run more than one of the above programs at the same time. It may cause
466confusion like switching between two frequencies all the time. If you just 775confusion like switching between two frequencies all the time.
467installed speedfreq, skip cpufreq now.
468</warn> 776</warn>
469 777
470<pre caption="Installing cpufreqd"> 778</body>
471# <i>emerge cpufreqd</i> 779</section>
472# <i>rc-update add cpufreqd battery</i> 780<section>
473</pre> 781<title>Verifying the result</title>
474 782<body>
475<p>
476<c>cpufreqd</c> comes with a default configuration in
477<path>/etc/cpufreqd.conf</path>.
478Change the config file to fit your needs. The following will save more energy
479than the default one - at the cost of less performance, of course.
480</p>
481
482<pre caption="A sample cpufreqd config file">
483[General]
484pidfile=/var/run/cpufreqd.pid
485poll_interval=2
486pm_type=acpi
487<comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5))
488# acpi_workaround=1</comment>
489verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment>
490
491<comment># Full performance</comment>
492[Profile]
493name=ac
494minfreq=600000
495maxfreq=1400000
496policy=performance
497
498<comment># Maximum power saving</comment>
499[Profile]
500name=battery
501minfreq=600000
502maxfreq=900000
503policy=powersave
504
505<comment># Constant frequency</comment>
506[Profile]
507name=dvd
508minfreq=900000
509maxfreq=1100000
510policy=powersave
511
512<comment># Full performance when running on AC</comment>
513[Rule]
514name=ac_on
515ac=on
516profile=ac
517
518<comment># Compiling should be fast if battery state is ok</comment>
519[Rule]
520name=compiling
521ac=off
522battery_interval=30-100
523programs=emerge,make,gcc,cpp
524cpu_interval=0-100
525profile=ac
526
527<comment># watching DVD's gets sluggish with slow CPU frequency
528# Can also be used for games etc.</comment>
529[Rule]
530name=dvd_watching
531ac=off
532battery_interval=15-100
533programs=xine,mplayer,avidemux,kaffeine,kmplayer
534cpu_interval=0-100
535profile=dvd
536
537<comment># If above doesn't apply, maximise power saving</comment>
538[Rule]
539name=battery_on
540ac=off
541battery_interval=0-100
542cpu_interval=0-100
543profile=battery
544</pre>
545
546<p>
547<c>cpudyn</c> and <c>powernowd</c> are installed in the same way as
548<c>speedfreq</c>.
549</p>
550 783
551<p> 784<p>
552The last thing to check is that your new policies do a good job. An easy way to 785The last thing to check is that your new policies do a good job. An easy way to
553do so is monitoring the CPU speed while working with your laptop: 786do so is monitoring CPU speed while working with your laptop:
554</p> 787</p>
555 788
556<pre caption="Monitoring CPU speed"> 789<pre caption="Monitoring CPU speed">
557# <i>watch -n 1 grep "cpu MHz" /proc/cpuinfo</i> 790# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
558</pre> 791</pre>
559 792
560<p> 793<p>
561If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU 794If <path>/proc/cpuinfo</path> doesn't get updated (see <uri
562frequency with: 795link="#doc_chap8">Troubleshooting</uri>), monitor the CPU frequency with
796<c>sys-apps/x86info</c>:
563</p> 797</p>
564 798
565<pre caption="Alternative CPU speed monitoring"> 799<pre caption="Alternative CPU speed monitoring">
566# <i>watch -n 1 x86info -mhz</i> 800# <i>watch x86info -mhz</i>
567</pre> 801</pre>
568 802
569<p> 803<p>
570Depending on your setup, CPU speed should increase on heavy load, decrease on 804Depending on your setup, CPU speed should increase on heavy load, decrease on
571no activity or just stay at the same level. 805no activity or just stay at the same level. When using <c>cpufreqd</c> and
806verbosity set to 5 or higher in <path>cpufreqd.conf</path> you'll get
807additional information about what's happening reported to <c>syslog</c>.
572</p> 808</p>
573 809
574</body> 810</body>
575</section> 811</section>
576</chapter> 812</chapter>
577 813
578<chapter> 814<chapter>
579<title>LCD Power Management</title> 815<title>LCD Power Management</title>
580<section> 816<section>
581<title>Energy consumer no. 1</title>
582<body> 817<body>
583 818
584<p> 819<p>
585As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD display 820As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD
586consumes the biggest part of energy (might not be the case for non-mobile 821display consumes the biggest part of energy (might not be the case for
587CPU's). Thus it's quite important not only to shut the display off when not 822non-mobile CPU's). Thus it's quite important not only to shut the display off
588needed, but also to reduce it's backlight if possible. Most laptops offer the 823when not needed, but also to reduce it's backlight if possible. Most laptops
589possibility to control the backlight dimming. 824offer the possibility to control the backlight dimming.
590</p>
591
592<p> 825</p>
826
827</body>
828</section>
829<section>
830<title>Standby settings</title>
831<body>
832
833<p>
593First thing to check is the standby/suspend/off timings of the display. As this 834The first thing to check is the standby/suspend/off timings of the display. As
594depends heavily on your windowmanager, I'll let you figure it out yourself. 835this depends heavily on your windowmanager, I'll let you figure it out
595Just two common places: Blanking the terminal can be done with <c>setterm 836yourself. Just two common places: Blanking the terminal can be done with
596-blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c> and 837<c>setterm -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c>
597<c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. 838and <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. For X.org, modify
598For Xorg, modify <path>/etc/X11/xorg.conf</path> similar to this: 839<path>/etc/X11/xorg.conf</path> similar to this:
599</p> 840</p>
600 841
601<pre caption="LCD suspend settings in Xorg and XFree86"> 842<pre caption="LCD suspend settings in X.org">
602Section "ServerLayout" 843Section "ServerFlags"
603 Identifier [...]
604 [...]
605 Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment> 844 Option "blank time" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
606 Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment> 845 Option "standby time" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
607 Option "SuspendTime" "20" <comment># Full suspend after 20 minutes</comment> 846 Option "suspend time" "20" <comment># Full suspend after 20 minutes</comment>
608 Option "OffTime" "30" <comment># Turn off after half an hour</comment> 847 Option "off time" "30" <comment># Turn off after half an hour</comment>
609 [...] 848 [...]
610EndSection 849EndSection
611 850
612[...] 851[...]
613 852
614Section "Monitor" 853Section "Monitor"
615 Identifier [...] 854 Identifier [...]
616 Option "DPMS" "true" 855 Option "DPMS"
617 [...] 856 [...]
618EndSection 857EndSection
619</pre> 858</pre>
620 859
621<p> 860</body>
622This is the same for XFree86 and <path>/etc/X11/XF86Config</path>. 861</section>
623</p> 862<section>
863<title>Backlight dimming</title>
864<body>
624 865
625<p> 866<p>
626Probably more important is the backlight dimming. If you have access to the 867Probably more important is the backlight dimming. If you have access to the
627dimming settings via a tool, write a small script that dims the backlight in 868dimming settings via a tool, write a small script that dims the backlight in
628battery mode and place it in your <e>battery</e> runlevel. 869battery mode and place it in your <c>battery</c> runlevel. The following script
870should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the
871appropriate option in your kernel (IBM Thinkpads only). For Toshiba laptops,
872install <c>sys-power/acpitool</c> and skip configuration of <c>thinkpad_acpi</c>
873(formerly called <c>ibm_acpi</c>) as described below.
874</p>
875
876<warn>
877Support for setting brightness is marked experimental in thinkpad_acpi. It
878accesses hardware directly and may cause severe harm to your system. Please
879read the <uri link="http://ibm-acpi.sourceforge.net/">thinkpad_acpi
880website</uri>
881</warn>
882
629</p> 883<p>
884To be able to set the brightness level, the thinkpad_acpi module has to be
885loaded with the experimental parameter.
886</p>
887
888<pre caption="automatically loading the thinkpad_acpi module">
889<comment>(Please read the warnings above before doing this!)</comment>
890# <i>echo "options thinkpad_acpi experimental=1" >> /etc/modprobe.d/thinkpad_acpi</i>
891# <i>update-modules</i>
892# <i>echo thinkpad_acpi >> /etc/modules.autoload.d/kernel-2.6</i>
893# <i>modprobe thinkpad_acpi</i>
894</pre>
895
896<p>
897This should work without error messages and a file
898<path>/proc/acpi/ibm/brightness</path> should be created after loading the
899module. An init script will take care of choosing the brightness according to
900the power source.
901</p>
902
903<pre caption="/etc/conf.d/lcd-brightness">
904<comment># See /proc/acpi/ibm/brightness for available values</comment>
905<comment># Please read /usr/src/linux/Documentation/thinkpad-acpi.txt</comment>
906
907<comment># brightness level in ac mode. Default is 7.</comment>
908BRIGHTNESS_AC=7
909
910<comment># brightness level in battery mode. Default is 4.</comment>
911BRIGHTNESS_BATTERY=4
912</pre>
913
914<pre caption="/etc/init.d/lcd-brightness">
915#!/sbin/runscript
916
917set_brightness() {
918 if on_ac_power
919 then
920 LEVEL=${BRIGHTNESS_AC:-7}
921 else
922 LEVEL=${BRIGHTNESS_BATTERY:-4}
923 fi
924
925 if [ -f /proc/acpi/ibm/brightness ]
926 then
927 ebegin "Setting LCD brightness"
928 echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
929 eend $?
930 elif [[ -e /usr/bin/acpitool &amp;&amp; -n $(acpitool -T | grep "LCD brightness") ]]
931 then
932 ebegin "Setting LCD brightness"
933 acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
934 eend $?
935 else
936 ewarn "Setting LCD brightness is not supported."
937 ewarn "For IBM Thinkpads, check that thinkpad_acpi is loaded into the kernel"
938 ewarn "For Toshiba laptops, you've got to install sys-power/acpitool"
939 fi
940}
941
942start() {
943 set_brightness
944}
945
946stop () {
947 set_brightness
948}
949</pre>
950
951<p>
952When done, make sure brightness is adjusted automatically by adding it to the
953battery runlevel.
954</p>
955
956<pre caption="Enabling automatic brightness adjustment">
957# <i>chmod +x /etc/init.d/lcd-brightness</i>
958# <i>rc-update add lcd-brightness battery</i>
959# <i>rc</i>
960</pre>
630 961
631</body> 962</body>
632</section> 963</section>
633</chapter> 964</chapter>
634 965
635<chapter> 966<chapter>
636<title>Disk Power Management</title> 967<title>Disk Power Management</title>
637<section> 968<section>
638<title>Sleep when idle</title> 969<body>
970
971<p>
972Hard disks consume less energy in sleep mode. Therefore it makes sense to
973activate power saving features whenever the hard disk is not used for a certain
974amount of time. I'll show you two alternative possibilities to do it. First,
975laptop-mode will save most energy due to several measures which prevent or at
976least delay write accesses. The drawback is that due to the delayed write
977accesses a power outage or kernel crash will be more dangerous for data loss.
978If you don't like this, you have to make sure that there are no processes which
979write to your hard disk frequently. Afterwards you can enable power saving
980features of your hard disk with <c>hdparm</c> as the second alternative.
981</p>
982
639<body> 983</body>
984</section>
985<section>
986<title>Increasing idle time - laptop-mode</title>
987<body>
640 988
641<p>
642Let's bring the hard disk to sleep as early as possible whenever it is not
643needed. I'll show you two possibilities to do it. First <c>cpudyn</c> supports
644Disk Power Management. Uncomment the lines in the "Disk Options" section in
645<path>/etc/conf.d/cpudyn</path>. To put your first disk to sleep after 60
646seconds of no activity, you would modify it like this:
647</p> 989<p>
648 990Recent 2.6 kernels include the so-called <c>laptop-mode</c>. When activated,
649<pre caption="Using cpudyn for disk standby"> 991dirty buffers are written to disk on read calls or after 10 minutes (instead of
650<comment>################################################ 99230 seconds). This minimizes the time the hard disk needs to be spun up.
651# DISK OPTIONS
652# (disabled by default)
653################################################
654
655#
656# Timeout to put the disk in standby mode if there was no
657# io during that period (in seconds)
658#
659</comment>
660TIMEOUT=60
661<comment>
662#
663# Specified disks to spindown (comma separated devices)
664#
665</comment>
666DISKS=/dev/hda
667</pre>
668
669<p> 993</p>
670The second possibility is using a small script and hdparm. Create 994
671<path>/etc/init.d/pm.hda</path> like this: 995<pre caption="Automated start of laptop-mode">
996# <i>emerge laptop-mode-tools</i>
997</pre>
998
672</p> 999<p>
1000<c>laptop-mode-tools</c> has its configuration file in
1001<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
1002it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
1003automatically.
1004</p>
673 1005
1006<p>
1007Recent versions (1.11 and later) of laptop-mode-tools include a new tool
1008<c>lm-profiler</c>. It will monitor your system's disk usage and running
1009network services and suggests to disable unneeded ones. You can either disable
1010them through laptop-mode-tools builtin runlevel support (which will be reverted
1011by Gentoo's <c>/sbin/rc</c>) or use your <c>default</c>/<c>battery</c>
1012runlevels (recommended).
1013</p>
1014
1015<pre caption="Sample output from running lm-profiler">
1016# <i>lm-profiler</i>
1017Profiling session started.
1018Time remaining: 600 seconds
1019[4296896.602000] amarokapp
1020Time remaining: 599 seconds
1021[4296897.714000] sort
1022[4296897.970000] mv
1023Time remaining: 598 seconds
1024Time remaining: 597 seconds
1025[4296900.482000] reiserfs/0
1026</pre>
1027
1028<p>
1029After profiling your system for ten minutes, lm-profiler will present a list of
1030services which might have caused disk accesses during that time.
1031</p>
1032
1033<pre caption="lm-profiler suggests to disable some services">
1034Program: "atd"
1035Reason: standard recommendation (program may not be running)
1036Init script: /etc/init.d/atd (GUESSED)
1037
1038Do you want to disable this service in battery mode? [y/N]: <i>n</i>
1039</pre>
1040
1041<p>
1042To disable atd as suggested in the example above, you would run <c>rc-update
1043del atd battery</c>. Be careful not to disable services that are needed for
1044your system to run properly - <c>lm-profiler</c> is likely to generate some
1045false positives. Do not disable a service if you are unsure whether it's
1046needed.
1047</p>
1048
1049</body>
1050</section>
1051<section>
1052<title>Limiting Write Accesses</title>
1053<body>
1054
1055<p>
1056If you don't want to use laptop-mode, you must take special care to disable
1057services that write to your disk frequently - <c>syslogd</c> is a good
1058candidate, for example. You probably don't want to shut it down completely, but
1059it's possible to modify the config file so that "unnecessary" things don't get
1060logged and thus don't create disk traffic. <c>Cups</c> writes to disk
1061periodically, so consider shutting it down and only enable it manually when
1062needed.
1063</p>
1064
1065<pre caption="Disabling cups in battery mode">
1066# <i>rc-update del cupsd battery</i>
1067</pre>
1068
1069<p>
1070You can also use <c>lm-profiler</c> from laptop-mode-tools (see above) to find
1071services to disable. Once you eliminated all of them, go on with configuring
1072hdparm.
1073</p>
1074
1075</body>
1076</section>
1077<section>
1078<title>hdparm</title>
1079<body>
1080
1081<p>
1082The second possibility is using <c>hdparm</c>. Skip this if
1083you are using laptop-mode. Otherwise, edit <path>/etc/conf.d/hdparm</path> and
1084add the following values to your drive entries. This example assumes your hard
1085drive is called <b>hda</b>:
1086</p>
1087
674<pre caption="Using hdparm for disk standby"> 1088<pre caption="Using /etc/conf.d/hdparm for disk standby">
675#!/sbin/runscript 1089hda_args="-q -S12"
676start() {
677 ebegin "Activating Power Management for Hard Drives"
678 hdparm -q -S12 /dev/hda
679 eend $?
680}
681
682stop () {
683 ebegin "Deactivating Power Management for Hard Drives"
684 hdparm -q -S253 /dev/hda
685 eend $?
686}
687</pre> 1090</pre>
688 1091
1092<p>
1093This will activate power management for your hard drive. If you ever want to
1094deactivate power management, you can edit <path>/etc/conf.d/hdparm</path> and
1095change the values to <c>-q -S0</c>, or just run <c>hdparm -q -S0 /dev/hda</c>.
689<p> 1096</p>
690See <c>man hdparm</c> for the options. If your script is ready, add it to the 1097
691battery runlevel. 1098<p>
1099See <c>man hdparm</c> for the options. Though you can always start <c>hdparm</c>
1100manually when you are on battery power by running <c>/etc/init.d/hdparm
1101start</c>, it's much easier to automate its startup and shutdown. To do so, add
1102<c>hdparm</c> to the battery runlevel so that it will automatically enable power
1103management.
692</p> 1104</p>
693 1105
694<pre caption="Automate disk standby settings"> 1106<pre caption="Automate disk standby settings">
695# <i>/sbin/depscan.sh</i>
696# <i>rc-update add pm.hda battery</i> 1107# <i>rc-update add hdparm battery</i>
697</pre> 1108</pre>
698 1109
699<impo> 1110<impo>
700Be careful with sleep/spin down settings of your hard drive. Setting it to 1111Be careful with sleep/spin down settings of your hard drive. Setting it to
701small values might wear out your drive and lose warranty. 1112small values might wear out your drive and lose warranty.
702</impo> 1113</impo>
703 1114
704</body> 1115</body>
705</section> 1116</section>
706<section> 1117<section>
707<title>Increasing idle time - laptop-mode</title>
708<body>
709
710<p>
711Recent kernels (2.6.6 and greater, recent 2.4 ones and others with patches)
712include the so-called <e>laptop-mode</e>. When activated, dirty buffers are
713written to disk on read calls or after 10 minutes (instead of 30 seconds). This
714minimizes the time the hard disk needs to be spun up.
715</p>
716
717<p>
718<!-- FIXME: bug #45593 -->
719To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can
720take the one included in
721<path>/usr/src/linux/Documentation/laptop-mode.txt</path>. Onces it's ready,
722make sure it gets called.
723</p>
724
725<pre caption="Automatic start of laptop-mode">
726# <i>rc-update add laptop-mode battery</i>
727</pre>
728
729<warn>
730Once again: Be careful with sleep/spin down settings of your hard drive.
731Setting it to small values might wear out your drive and lose warranty. Be sure
732to read the documentation in laptop-mode.txt. Make sure to stop laptop-mode
733before your battery runs out of power and data gets written to disk - otherwise
734you will at least lose the last 10 minutes of your work.
735</warn>
736
737</body>
738</section>
739<section>
740<title>Other tricks</title> 1118<title>Other tricks</title>
741<body> 1119<body>
742
743<p>
744Besides putting your disk to sleep state as early as possible, it is a good
745idea to minimize disk accesses. Have a look at processes that write to your
746disk frequently - the syslogd is a good candidate. You probably don't want to
747shut it down completely, but it's possible to modify the config file so that
748"unnecessary" things don't get logged and thus don't create disk traffic. Cups
749writes to disk periodically, so consider shutting it down and only enable it
750manually when needed.
751</p>
752
753<pre caption="Disabling cups in battery mode">
754# <i>rc-update del cupsd battery</i>
755</pre>
756 1120
757<p> 1121<p>
758Another possibility is to deactivate swap in battery mode. Before writing a 1122Another possibility is to deactivate swap in battery mode. Before writing a
759swapon/swapoff switcher, make sure there is enough RAM and swap isn't used 1123swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
760heavily, otherwise you'll be in big problems. 1124heavily, otherwise you'll be in big problems.
761</p> 1125</p>
762 1126
763<p> 1127<p>
764If you don't want to use laptop-mode, it's still possible to minimize disk 1128If you don't want to use laptop-mode, it's still possible to minimize disk
765access by mounting certain directories as <e>tmpfs</e> - write accesses are not 1129access by mounting certain directories as <c>tmpfs</c> - write accesses are not
766stored on a disk, but in main memory and get lost with unmounting. Often it's 1130stored on a disk, but in main memory and get lost with unmounting. Often it's
767useful to mount <path>/tmp</path> like this - you don't have to pay special 1131useful to mount <path>/tmp</path> like this - you don't have to pay special
768attention as it gets cleared on every reboot regardless whether it was mounted 1132attention as it gets cleared on every reboot regardless whether it was mounted
769on disk or in RAM. Just make sure you have enough RAM and no program (like a 1133on disk or in RAM. Just make sure you have enough RAM and no program (like a
770download client or compress utility) needs extraordinary much space in 1134download client or compress utility) needs extraordinary much space in
776none /tmp tmpfs size=32m 0 0 1140none /tmp tmpfs size=32m 0 0
777</pre> 1141</pre>
778 1142
779<warn> 1143<warn>
780Pay attention to the size parameter and modify it for your system. If you're 1144Pay attention to the size parameter and modify it for your system. If you're
781unsure, don't try this at all, it can become a perfomance bottleneck easily. In 1145unsure, don't try this at all, it can become a performance bottleneck easily. In
782case you want to mount <path>/var/log</path> like this, make sure to merge the 1146case you want to mount <path>/var/log</path> like this, make sure to merge the
783log files to disk before unmounting. They are essential. Don't attempt to mount 1147log files to disk before unmounting. They are essential. Don't attempt to mount
784/var/tmp like this. Portage uses it for compiling... 1148<path>/var/tmp</path> like this. Portage uses it for compiling...
785</warn> 1149</warn>
786 1150
787</body> 1151</body>
788</section> 1152</section>
789</chapter> 1153</chapter>
790 1154
791<chapter> 1155<chapter>
792<title>Power Management for other devices</title> 1156<title>Power Management For Other Devices</title>
1157<section>
1158<title>Graphics Cards</title>
1159<body>
1160
1161<p>
1162In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1163scaling for the graphics processing unit GPU), you can activate this
1164feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable) the
1165<c>DynamicClocks</c> option in the Device section. Please notice that this
1166feature will lead to crashes on some systems.
1167</p>
1168
1169<pre caption="Enabling ATI PowerPlay support in X.org">
1170Section "Device"
1171[...]
1172Option "DynamicClocks" "on"
1173EndSection
1174</pre>
1175
1176</body>
1177</section>
793<section> 1178<section>
794<title>Wireless Power Management</title> 1179<title>Wireless Power Management</title>
795<body> 1180<body>
796 1181
797<p> 1182<p>
798Wireless LAN cards consume quite a few energy. Put them in Power Management 1183Wireless LAN cards consume quite a bit of energy. Put them in Power Management
799mode in analogy to the pm.hda script. 1184mode just like your hard drives.
800</p>
801
802<pre caption="WLAN Power Management automated">
803#!/sbin/runscript
804start() {
805 ebegin "Activating Power Management for Wireless LAN"
806 iwconfig wlan0 power on power max period 3
807 eend $?
808}
809
810stop () {
811 ebegin "Deactivating Power Management for Wireless LAN"
812 iwconfig wlan0 power off
813 eend $?
814}
815</pre>
816
817<p> 1185</p>
818Starting this script will put wlan0 in Power Management mode, going to sleep at 1186
819the latest three seconds after no traffic. 1187<note>
820Save it as <path>/etc/init.d/pm.wlan0</path> and add it to the battery runlevel 1188This script assumes your wireless interface is called <c>wlan0</c>; replace
821like the disk script above. See <c>man iwconfig</c> for details and more 1189this with the actual name of your interface.
822options. If your driver and access point support changing the beacon time, this 1190</note>
1191
1192<p>
1193Add the following option to <path>/etc/conf.d/net</path> to automatically enable
1194power management for your wireless card:
1195</p>
1196
1197<pre caption="Automated WLAN Power Management">
1198iwconfig_wlan0="power on"
1199</pre>
1200
1201<p>
1202See <c>man iwconfig</c> for details and more options like the period between
1203wakeups or timeout settings. If your driver and access point support changing
823is a good starting point to save even more energy. 1204the beacon time, this is a good starting point to save even more energy.
824</p> 1205</p>
825 1206
826</body> 1207</body>
827</section> 1208</section>
828<section> 1209<section>
833There are two problems with USB devices regarding energy consumption: First, 1214There are two problems with USB devices regarding energy consumption: First,
834devices like USB mice, digital cameras or USB sticks consume energy while 1215devices like USB mice, digital cameras or USB sticks consume energy while
835plugged in. You cannot avoid this (nevertheless remove them in case they're not 1216plugged in. You cannot avoid this (nevertheless remove them in case they're not
836needed). Second, when there are USB devices plugged in, the USB host controller 1217needed). Second, when there are USB devices plugged in, the USB host controller
837periodically accesses the bus which in turn prevents the CPU from going into 1218periodically accesses the bus which in turn prevents the CPU from going into
838C3/4 sleep mode. The OS answer to this problem is the so called "USB selective 1219sleep mode. The kernel offers an experimental option to enable suspension of
839suspend", which has not yet been implemented in the kernel. USB selective 1220USB devices through driver calls or one of the <path>power/state</path> files
840suspend only allows bus accesses in case the device is in use. The cruel 1221in <path>/sys</path>.
841workaround until it's implemented is as following: Compile USB support and 1222</p>
842devices as modules and remove them via a script while they are not in use (e.g. 1223
843when closing the lid). 1224<pre caption="Enabling USB suspend support in the kernel">
1225Device Drivers
1226 USB support
1227 [*] Support for Host-side USB
1228 [*] USB suspend/resume (EXPERIMENTAL)
844</p> 1229</pre>
845 1230
846</body> 1231</body>
847</section> 1232</section>
848</chapter> 1233</chapter>
849 1234
850<chapter> 1235<chapter>
851<title>Sleep states: sleep, standby, suspend to disk</title> 1236<title>Sleep States: sleep, standby, and suspend to disk</title>
852<section> 1237<section>
853<title>Overview</title>
854<body> 1238<body>
855 1239
856<p> 1240<p>
857ACPI defines different sleep states. The more important ones are 1241ACPI defines different sleep states. The more important ones are
858</p> 1242</p>
859 1243
860<ul> 1244<ul>
861 <li>S1 aka Standby</li> 1245 <li>S1 aka Standby</li>
862 <li>S3 aka Suspend to RAM aka Sleep</li> 1246 <li>S3 aka Suspend to RAM aka Sleep</li>
863 <li>S4 aka Suspend to Disk aka Hibernate</li> 1247 <li>S4 aka Suspend to Disk aka Hibernate</li>
864</ul> 1248</ul>
865 1249
869</p> 1253</p>
870 1254
871</body> 1255</body>
872</section> 1256</section>
873<section> 1257<section>
874<title>Sleep, Standby &amp; Hibernate</title> 1258<title>Sleep (S3)</title>
875<body> 1259<body>
876 1260
877<p> 1261<p>
878The ACPI support for these sleep states is marked as experimental for good 1262The ACPI support for these sleep states is marked experimental for good reason.
879reason. APM sleep states seem to be more stable, however you can't use APM and 1263APM sleep states seem to be more stable, however you can't use APM and ACPI
880ACPI together. 1264together.
1265</p>
1266
1267<pre caption="Kernel configuration for the various suspend types">
1268 Power Management Options ---&gt;
1269 [*] Power Management support
1270 [*] Suspend to RAM and standby
1271</pre>
1272
1273<p>
1274Once your kernel is properly configured, you can use the
1275<c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1276first.
1277</p>
1278
1279<pre caption="Installing the hibernate-script">
1280# <i>emerge hibernate-script</i>
1281</pre>
1282
1283<p>
1284Some configuration has to be done in <path>/etc/hibernate</path>. The default
1285package introduces a few configuration files for each sleep state. Options that
1286are common to all suspend methods are placed in <path>common.conf</path>; make
1287sure this file is properly set up for your system.
1288</p>
1289
1290<p>
1291To configure sleep, edit <path>sysfs-ram.conf</path> in
1292<path>/etc/hibernate</path>. <c>UseSysfsPowerState mem</c> is already setup
1293correctly, but if you need to make further changes to this particular sleep
1294state (or any other sleep state) you should add them to
1295<path>/etc/hibernate/hibernate.conf</path>. The comments and option names will
1296guide you. If you use nfs or samba shares over the network, make sure to
1297shutdown the appropriate init scripts to avoid timeouts.
1298</p>
1299
1300<note>
1301For more information on setting up sleep states, read <c>man
1302hibernate.conf</c>.
1303</note>
1304
1305<p>
1306Ready? Now is the last chance to backup any data you want to keep after
1307executing the next command. Notice that you probably have to hit a special key
1308like <c>Fn</c> to resume from sleep.
1309</p>
1310
1311<pre caption="Calling sleep">
1312# <i>hibernate-ram</i>
1313</pre>
1314
1315<p>
1316If you're still reading, it seems to work. You can also setup standby (S1) in a
1317similar way by editing <path>sysfs-ram.conf</path> and changing
1318"UseSysfsPowerState mem" to "UseSysfsPowerState standby". S3 and S4 are the more
1319interesting sleep states due to greater energy savings however.
1320</p>
1321
1322</body>
1323</section>
1324<section>
1325<title>Hibernate (S4)</title>
1326<body>
1327
1328<p>
1329This section introduces hibernation, where a snapshot of the running system is
1330written to disk before powering off. On resume, the snapshot is loaded and you
1331can go on working at exactly the point you called hibernate before.
881</p> 1332</p>
882 1333
883<warn> 1334<warn>
884Altough sleep state support is improving much, it's still rather experimental. 1335Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load
885At last I got swsusp2 and suspend to RAM to work, but be warned: This will very 1336a snapshot with a different kernel image than the one it was created with.
886likely not work but damage your data/system. 1337Shutdown any NFS or samba server/client before hibernating.
887</warn> 1338</warn>
888 1339
889<p> 1340<p>
890There are currently three implementations for S4. The original one is swsusp, 1341There are two different implementations for S4. The original one is swsusp,
891then there is swsusp2 which has the nicest interface (including bootsplash 1342then there is the newer tuxonice (formerly suspend2) with a nicer interface
892support), but requires manual kernel patching. Last not least we have 1343(including fbsplash support). A <uri
893Suspend-to-Disk, a fork of swsusp. 1344link="http://tuxonice.net/features.html#compare">feature comparison</uri> is
894</p> 1345available at the <uri link="http://www.tuxonice.net">tuxonice homepage</uri>.
895 1346There used to be Suspend-to-Disk (pmdisk), a fork of swsusp, but it has been
1347merged back.
896<p> 1348</p>
897If this confused you, have a look at a <uri 1349
898link="http://softwaresuspend.berlios.de/features.html#compare">feature
899comparison</uri>. If you still are confused and don't know which one to choose,
900first give swsusp2 a try, it looks most promising.
901</p> 1350<p>
902 1351TuxOnIce is not included in the mainline kernel yet, therefore you either have
1352to patch your kernel sources with the patches provided by <uri
1353link="http://www.tuxonice.net">tuxonice.net</uri> or use
1354<c>sys-kernel/tuxonice-sources</c>.
903<p> 1355</p>
904The kernel part for this is as following: 1356
1357<p>
1358The kernel part for both swusp and TuxOnIce is as follows:
905</p> 1359</p>
906 1360
907<pre caption="Kernel configuration for the various suspend types"> 1361<pre caption="Kernel configuration for the various suspend types">
908Power Management Options ---&gt; 1362Power Management support ---&gt;
909
910 <comment>(sleep and standby)</comment>
911 ACPI( Advanced Configuration and Power Interface ) Support --->
912 [*] ACPI Support
913 [*] Sleep States
914
915 <comment>(hibernate with swsusp)</comment> 1363 <comment>(hibernate with swsusp)</comment>
916 [*] Software Suspend (EXPERIMENTAL) 1364 [*] Hibernation (aka 'suspend to disk')
917 1365 <comment>(replace /dev/SWAP with your swap partition)</comment>
1366 (/dev/SWAP) Default resume partition
1367
918 <comment>(hibernate with swsusp2)</comment> 1368 <comment>(hibernate with TuxOnIce)</comment>
919 Software Suspend 2 1369 Enhanced Hibernation (TuxOnIce)
920 --- Image Storage (you need at least one writer) 1370 --- Image Storage (you need at least one allocator)
921 [*] Swap Writer 1371 [*] File Allocator
922 --- Page Transformers 1372 [*] Swap Allocator
923 [*] LZF image compression 1373 --- General Options
924 (/dev/"your-swap-here") Default resume device name 1374 [*] Compression support
925 1375 [ ] Allow Keep Image Mode
926 <comment>(hibernate with Suspend-to-Disk)</comment> 1376 [*] Replace swsusp by default
927 [*] Suspend-to-Disk Suport
928 (/dev/"your-swap-here") Default resume partition
929</pre> 1377</pre>
930 1378
931<p>
932Compile your kernel with the appropriate options enabled and issue <c>cat
933/proc/acpi/sleep</c> for 2.4 series respectively <c>cat /sys/power/state</c>
934for 2.6 to find out what is supported. The latter gives me <c>standby mem
935disk</c>. For swsusp, the kernel parameter <c>resume=/dev/"your-swap-here"</c>
936has to be appended. If booting is not possible due to a broken image, use
937<c>noresume</c> for swsusp, <c>pmdisk=off</c> for Suspend-to-Disk and
938<c>noresume2</c> for swsusp2.
939</p> 1379<p>
940 1380The configuration for swsusp is rather easy. If you didn't store the location
1381of your swap partition in the kernel config, you can also pass it as a
1382parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1383possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1384<c>hibernate-cleanup</c> init script invalidates swsusp images during the boot
1385process.
941<p> 1386</p>
942To put your system in one of the sleep states, use 1387
1388<pre caption="Invalidating swsusp images during the boot process">
1389# <i>rc-update add hibernate-cleanup boot</i>
1390</pre>
1391
943</p> 1392<p>
944 1393To activate hibernate with swsusp, use the hibernate script and set
945<pre caption="Activating sleep states"> 1394<c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/sysfs-disk</path>.
946<comment>(kernel 2.4 series)</comment>
947# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment>
948# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment>
949
950<comment>(kernel 2.6 series)</comment>
951# <i>echo -n standby &gt; /sys/power/state</i> <comment>standby</comment>
952# <i>echo -n mem &gt; /sys/power/state</i> <comment>sleep</comment>
953
954<comment>(swsusp)</comment>
955# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>hibernate</comment>
956
957<comment>(Suspend-to-Disk)</comment>
958# <i>echo -n disk &gt; /sys/power/state</i> <comment>hibernate</comment>
959
960<comment>(swsusp2)</comment>
961# <i>echo &gt; /proc/swsusp/activate</i>
962</pre> 1395</p>
963 1396
964<warn> 1397<warn>
965Backup your data before doing this. Run <c>sync</c> before executing one of the 1398Backup your data before doing this. Run <c>sync</c> before executing one of the
966commands to have cached data written to disk. First try it outside of X, then 1399commands to have cached data written to disk. First try it outside of X, then
967with X running, but not logged in. 1400with X running, but not logged in.
968</warn> 1401</warn>
969 1402
970<p> 1403<p>
971If you experience kernel panics due to uhci or similar, try to compile USB 1404If you experience kernel panics due to uhci or similar, try to compile USB
972support as module and unload the modules before sending your laptop to sleep 1405support as module and unload the modules before sending your laptop to sleep
973mode. 1406mode. There are configuration options for this in <path>common.conf</path>
974</p>
975
976<p> 1407</p>
977While the above should be sufficient to get swsusp and Suspend-to-Disk running 1408
978(I didn't say working), swsusp2 needs special care. 1409<pre caption="Hibernating with swsusp">
979The first thing to do is to patch the kernel with the patches provided at <uri 1410# <i>nano -w /etc/hibernate/common.conf</i>
980link="http://softwaresuspend.berlios.de/"> 1411<comment>(Make sure you have a backup of your data)</comment>
981http://softwaresuspend.berlios.de/</uri>. Afterwards, install the hibernate 1412# <i>hibernate</i>
982script from the same page. 1413</pre>
1414
1415<p>
1416The following section discusses the setup of TuxOnIce including fbsplash support
1417for a nice graphical progress bar during suspend and resume.
1418</p>
1419
1420<p>
1421The first part of the configuration is similar to the configuration of swsusp.
1422In case you didn't store the location of your swap partition in the kernel
1423config, you have to pass it as a kernel parameter with the
1424<c>resume=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1425broken image, append the <c>noresume</c> parameter. Additionally, the
1426<c>hibernate-cleanup</c> init script invalidates TuxOnIce images during the boot
1427process.
1428</p>
1429
1430<pre caption="Invalidating TuxOnIce images during the boot process">
1431# <i>rc-update add hibernate-cleanup boot</i>
1432</pre>
1433
1434<p>
1435Now edit <path>/etc/hibernate/tuxonice.conf</path>, enable the <c>TuxOnIce</c>
1436options you need. Do not enable the <c>fbsplash</c> options in
1437<c>common.conf</c> just yet.
1438</p>
1439
1440<pre caption="Hibernating with TuxOnIce">
1441# <i>nano -w /etc/hibernate/tuxonice.conf</i>
1442<comment>(Make sure you have a backup of your data)</comment>
1443# <i>hibernate</i>
1444</pre>
1445
1446<p>
1447Please configure <c>fbsplash</c> now if you didn't do already. To enable
1448fbsplash support during hibernation, the <c>sys-apps/tuxonice-userui</c> package
1449is needed. Additionally, you've got to enable the <c>fbsplash</c> USE flag.
1450</p>
1451
1452<pre caption="Installing tuxonice-userui">
1453# <i>echo "sys-apps/tuxonice-userui fbsplash" >> /etc/portage/package.use</i>
1454<comment>(It may be marked ~arch, so first it must be keyworded)</comment>
1455# <i>echo "sys-apps/tuxonice-userui" >> /etc/portage/package.keywords</i>
1456# <i>emerge tuxonice-userui</i>
1457</pre>
1458
1459<p>
1460The ebuild tells you to make a symlink to the theme you want to use. For
1461example, to use the <c>livecd-2005.1</c> theme, run the following command:
1462</p>
1463
1464<pre caption="Using the livecd-2005.1 theme during hibernation">
1465# <i>ln -sfn /etc/splash/livecd-2005.1 /etc/splash/tuxonice</i>
1466</pre>
1467
1468<p>
1469If you don't want a black screen in the first part of the resume process, you
1470have to add the <c>tuxoniceui_fbsplash</c> tool to your initrd image. Assuming
1471you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1472<path>/boot/fbsplash-emergence-1024x768</path>, here's how to do that.
1473</p>
1474
1475<pre caption="Adding tuxoniceui_fbsplash to an initrd image">
1476# <i>mount /boot</i>
1477# <i>mkdir ~/initrd.d</i>
1478# <i>cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1479# <i>cd ~/initrd.d</i>
1480# <i>gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1481# <i>rm fbsplash-emergence-1024x768</i>
1482# <i>cp /usr/sbin/tuxoniceui_fbsplash sbin/</i>
1483# <i>find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-tuxonice-emergence-1024x768</i>
1484</pre>
1485
1486<p>
1487Afterwards adjust <path>grub.conf</path> (or <path>lilo.conf</path>) so that
1488your TuxOnIce kernel uses
1489<path>/boot/fbsplash-tuxonice-emergence-1024x768</path> as initrd image. You can
1490now test a dry run to see if everything is setup correctly.
1491</p>
1492
1493<pre caption="Test run for fbsplash hibernation">
1494# <i>tuxoniceui_fbsplash -t</i>
1495</pre>
1496
1497<p>
1498Afterwards open <path>/etc/hibernate/common.conf</path> and activate the
1499fbsplash options. Execute <c>hibernate</c> and enjoy.
983</p> 1500</p>
984 1501
985</body> 1502</body>
986</section> 1503</section>
987</chapter> 1504</chapter>
988 1505
989<chapter> 1506<chapter>
990<title>Troubleshooting</title> 1507<title>Troubleshooting</title>
991<section> 1508<section>
992<title>If things go wrong...</title>
993<body> 1509<body>
994 1510
995<p> 1511<p>
996<e>Q:</e> I'm trying to change the CPU frequency, but 1512<e>Q:</e> I'm trying to change the CPU frequency, but
997<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not 1513<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not
999</p> 1515</p>
1000 1516
1001<p> 1517<p>
1002<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose 1518<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1003the right CPUFreq driver for your processor. Here is a list of processors that 1519the right CPUFreq driver for your processor. Here is a list of processors that
1004are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, 1520are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110,
1005ARM-SA1110, AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD 1521AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron,
1006mobile Duron, AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, 1522AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile
1007Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, 1523PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon,
1008Intel Xeon, Intel Pentium M (Centrino), National Semiconductors Geode GX, 1524Intel Pentium M (Centrino), National Semiconductors Geode GX, Transmeta Crusoe,
1009Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several 1525VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several "PowerBook" and
1010"PowerBook" and "iBook2" and various processors on some ACPI 2.0-compatible 1526"iBook2" and various processors on some ACPI 2.0-compatible systems (only if
1011systems (only if "ACPI Processor Performance States" are available to the 1527"ACPI Processor Performance States" are available to the ACPI/BIOS interface).
1012ACPI/BIOS interface).
1013</p> 1528</p>
1014 1529
1015<p> 1530<p>
1016<e>Q:</e> My laptop supports frequency scaling, but 1531<e>Q:</e> My laptop supports frequency scaling, but
1017<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty. 1532<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1022Try to update the BIOS, especially if a broken DSDT is reported. You can also 1537Try to update the BIOS, especially if a broken DSDT is reported. You can also
1023try to fix it yourself (which is beyond the scope of this guide). 1538try to fix it yourself (which is beyond the scope of this guide).
1024</p> 1539</p>
1025 1540
1026<p> 1541<p>
1027<e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo 1542<e>Q:</e> My laptop supports frequency scaling, but according to
1028the speed never changes. 1543<path>/proc/cpuinfo</path> the speed never changes.
1029</p>
1030
1031<p> 1544</p>
1032<e>A:</e> This seems to be a kernel bug. Run <c>emerge x86info</c>, update your 1545
1546<p>
1547<e>A:</e> Probably you have activated symmetric multiprocessing support
1548(CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
1549kernels had a bug causing this. In that case, run <c>emerge x86info</c>, update
1033kernel as asked and check the current frequency with <c>x86info -mhz</c>. 1550your kernel as asked and check the current frequency with <c>x86info -mhz</c>.
1034</p> 1551</p>
1035 1552
1036<p> 1553<p>
1037<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in 1554<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1038another OS. 1555another OS.
1039</p> 1556</p>
1040 1557
1041<p> 1558<p>
1042<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower 1559<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
1043minimum frequency. Notice that throttling doesn't save much energy and is 1560minimum frequency. Notice that throttling doesn't save much energy and is mainly
1044mainly used for thermal management (keeping your laptop cool and quiet). You 1561used for thermal management (keeping your laptop cool and quiet). You can read
1045can read the current throttling state with <c>cat 1562the current throttling state with <c>cat /proc/acpi/processor/CPU/throttling</c>
1046/proc/acpi/processor/CPU/throttling</c> and change it with <c>echo -n "0:x" > 1563and change it with <c>echo -n "0:x" > /proc/acpi/processor/CPU/limit</c>, where
1047/proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in 1564x is one of the Tx states listed in
1048<path>/proc/acpi/processor/CPU/throttling</path>. 1565<path>/proc/acpi/processor/CPU/throttling</path>.
1566</p>
1567
1568<p>
1569<e>Q:</e> When configuring the kernel, powersave, performance and userspace
1570governors show up, but that ondemand thing is missing. Where do I get it?
1571</p>
1572
1573<p>
1574<e>A:</e> The ondemand governor is only included in recent kernel sources. Try
1575updating them.
1049</p> 1576</p>
1050 1577
1051<p> 1578<p>
1052<e>Q:</e> Battery life time seems to be worse than before. 1579<e>Q:</e> Battery life time seems to be worse than before.
1053</p> 1580</p>
1066<e>A:</e> Check that battery support is compiled into your kernel. If you use 1593<e>A:</e> Check that battery support is compiled into your kernel. If you use
1067it as a module, make sure the module is loaded. 1594it as a module, make sure the module is loaded.
1068</p> 1595</p>
1069 1596
1070<p> 1597<p>
1598<e>Q:</e> My system logger reports things like "logger: ACPI group battery /
1599action battery is not defined".
1600</p>
1601
1602<p>
1603<e>A:</e> This message is generated by the <path>/etc/acpi/default.sh</path>
1604script that is shipped with acpid. You can safely ignore it. If you like to get
1605rid of it, you can comment the appropriate line in
1606<path>/etc/acpi/default.sh</path> as shown below:
1607</p>
1608
1609<pre caption="Disabling warnings about unknown acpi events">
1610 *) # logger "ACPI action $action is not defined"
1611</pre>
1612
1613<p>
1071<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events. 1614<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
1072</p> 1615</p>
1073 1616
1074<p> 1617<p>
1075<e>A:</e> This seems to be a kernel bug. Read on <uri 1618<e>A:</e> This seems to be a kernel bug. Read on <uri
1076link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>. 1619link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1077</p> 1620</p>
1078 1621
1079<p> 1622<p>
1623<e>Q:</e> I activated the <c>DynamicClocks</c> option in <path>xorg.conf</path>
1624and now X.org crashes / the screen stays black / my laptop doesn't shutdown
1625properly.
1626</p>
1627
1628<p>
1629<e>A:</e> This happens on some systems. You have to disable
1630<c>DynamicClocks</c>.
1631</p>
1632
1633<p>
1634<e>Q:</e> I want to use TuxOnIce, but it tells me my swap partition is too
1635small. Resizing is not an option.
1636</p>
1637
1638<p>
1639<e>A:</e> If there is enough free space on your system, you can use the
1640filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it as
1641well. More information can be found in
1642<path>/usr/src/linux/Documentation/power/tuxonice.txt</path>.
1643</p>
1644
1645<p>
1080<e>Q:</e> I just bought a brand new battery, but it only lasts for some 1646<e>Q:</e> I just bought a brand new battery, but it only lasts for some
1081minutes! What am I doing wrong? 1647minutes! What am I doing wrong?
1082</p> 1648</p>
1083 1649
1084<p> 1650<p>
1085<e>A:</e> First follow your manufacturer's advice on how to charge the battery 1651<e>A:</e> First follow your manufacturer's advice on how to charge the battery
1086correctly. 1652correctly.
1087</p> 1653</p>
1088 1654
1089<p> 1655<p>
1090<e>Q:</e> The above didn't help. What should I do then? 1656<e>Q:</e> The above didn't help. What should I do then?
1091</p> 1657</p>
1103<p> 1669<p>
1104If the "last full capacity" differs significantly from the design capacity, 1670If the "last full capacity" differs significantly from the design capacity,
1105your battery is probably broken. Try to claim your warranty. 1671your battery is probably broken. Try to claim your warranty.
1106</p> 1672</p>
1107 1673
1674<p>
1675<e>Q:</e> My problem is not listed above. Where should I go next?
1676</p>
1677
1678<p>
1679<e>A:</e> Don't fear to contact me, <mail link="earthwings@gentoo.org">Dennis
1680Nienhüser</mail>, directly. The <uri link="http://forums.gentoo.org">Gentoo
1681Forums</uri> are a good place to get help as well. If you prefer IRC, try the
1682<c>#gentoo-laptop</c> <uri link="irc://irc.gentoo.org">channel</uri>.
1683</p>
1684
1108</body> 1685</body>
1109</section> 1686</section>
1110</chapter> 1687</chapter>
1111</guide> 1688</guide>

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.41

  ViewVC Help
Powered by ViewVC 1.1.20