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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.20