Power Management on Linux Laptops and Notebooks - APM, ACPI, PMU
Since 2002 laptop and notebook manufacturers have started to switch Power Management from
Advanced Power Management - APM to Advanced Configuration and Power Interface - ACPI for x86
hardware. ACPI support for Linux Linux Kernel is now sometimes even required
to boot. And for some devices e.g. WLAN chipsets it may also be necessary to be compiled into
the kernel. On the other hand Linux support for ACPI is still a work in
progress. You should always use the current stable Kernel, together with the
ACPI patch . APM
and ACPI are mutually exclusive. But you can build them as modules and
use a boot option like
append="apm=off acpi=on"
or vice versa, to check both.
For more details see
Linux ACPI-HOWTO
and the Kernel docs in ../linux/Documentation.
For hibernation and suspend to disk with recent Kernels see the
software suspend section below.
For Apple notebooks see the Power Management Unit - PMU section below.
From the Battery-Powered-mini-HOWTO " .. for
Advanced Power Management - APM to work on any notebook or energy-conscious desktop, the system BIOS ROM in the machine must support the APM standard. Furthermore, for APM to work with the Linux operating system, the system BIOS ROM must support either the 1.0 or 1.1 version of the APM standard, and it must also support 32-bit protected mode connections. A system that supports APM 1.1 is preferred, as it provides more features that the device driver and supporting utilities can take advantage of."
You may get information about the APM version with the dmesg command and in the /proc/apm file.
Features of APM according to Documentation/Configure.help: "The system time will be reset after a USER RESUME operation, the /proc/apm device will provide battery status information, and user-space programs will receive notification of APM events (e.g., battery status change). "
APM support consists of two parts: kernel support and user-land support.
For kernel support, enable the parameters in the corresponding kernel section. Some features
need special tweaking with certain machines (e.g. IBM ThinkPad) or even don't work,
("TI 4000M TravelMate and the ACER 486/DX4/75 because they don't have compliant BIOSes").
Currently all distributions I know don't provide a kernel with APM support enabled.
So you usually have to compile your custom kernel. Please see Kernel-HOWTO or distribution manual for details.
The available APM options are (please see Documentation/Configure.help in the kernel source tree for more details):
CONFIG_APM_IGNORE_USER_SUSPEND Just a workaround for some NEC Versa M series laptops.
CONFIG_APM_DO_ENABLE Enable APM features at boot time.
CONFIG_APM_CPU_IDLE. Puts CPU in power save mode, if there is nothing to do for the kernel.
CONFIG_APM_DISPLAY_BLANK Some laptops can use this to turn off the LCD backlight when the screen blanker of the Linux virtual console blanks the screen. Note that this is only used by the virtual console screen blanker, and won't turn off the backlight when using the X Window system.
CONFIG_APM_POWER_OFF Turns the machine completely down, when using halt. This feature works with most laptops without problems.
CONFIG_APM_IGNORE_MULTIPLE_SUSPEND Just a workaround for IBM ThinkPad 560.
CONFIG_APM_IGNORE_SUSPEND_BOUNCE Just a workaround for Dell Inspiron 3200 and other notebooks.
CONFIG_APM_RTC_IS_GMT Stores time in Greenwich Mean Time format. It is in fact recommended to store GMT in your real time clock (RTC) in the BIOS.
CONFIG_APM_ALLOW_INTS Resolves some problems with Suspend to Disk for some laptops, for instance many newer IBM ThinkPads.
The utilities for userland support may be found at
APMD . APMD is a set of programs that control the Advanced Power Management system found in most modern laptop computers. If you run a 2.2.x kernel and want to experiment, Gabor Kuti <seasons_at_falcon.sch.bme.hu> has made a kernel patch that allows you to hibernate any Linux system to disk, even if your computers APM BIOS doesn't support it directly. IMHO you don't need this features if your laptop provides a function key to invoke suspend mode directly.
When you first install Linux, you will probably have to recompile the kernel. The kernel that came with your distribution probably does not have APM enabled.
Please see the Battery Powered Linux Mini-HOWTO by <hanno_at_lava.de>
Hanno Mueller
for detailed information.
README apmd?:On laptop computers, the APM support provides access to battery status
information and may help you to conserve battery power, depending on your
laptop and the APM implementation.
Rik Faith <faith_at_acm.org> has transferred maintenance of the Linux apmd
package over to me, Avery Pennarun <apenwarr_at_worldvisions.ca> and I'm
finally getting around to making a release with the many updates we've
collected since the last release back in 1996.
Here's what apmd can do:
- apmd(8): logs the battery status to syslog every now and then and handles background power management tasks;
- apm(1): a command-line tool to print the current battery status or suspend the computer;
- xapm(1x): provides a battery meter for X;
- libapm.a: a library for writing similar APM applications.
Richard Gooch wrote: I'have had a look at the beta version of apmd, and I still don't like it, because:
- Only supports one command to run at suspend time.
- Doesn't distinguish between user and system suspends.
- doesn't provide a way to disable policy (the
sync(); sleep(0) ; sync(); sleep(1); sequence)
- Does not document extra features.
- And I'm not sure that what we want is a single super daemon. A collection of smaller daemons might be better, since it allows people to pick and choose. A super daemon is bloat for those who only want one small feature.
Though this topic was discussed controversly Richard Gooch has put together a package suspendd at
his page .
Also, have a look at apmcd (apm based crontab) at
apmcd . A tool made by Nicolas J. Leon <nicholas_at_binary9.net>
apmcd .
Note: I didn't check whether this features are merged into one package (apmd eventually) already.
If you have another operating system preinstalled or use another operating
system at the same disk, make sure there is no
"hibernation" or "suspend" tool installed, which could severely interfere with Linux, e.g. it might use disk space which is occupied by Linux or vice versa.
lphdisk is a Linux replacement for Phoenix's buggy DOS-only PHDISK.EXE
utility, which creates and prepares hibernation partitions for use with
laptops running Phoenix's NoteBIOS. Until now, Linux users had to boot to
DOS to repair/create these partitions, and then it was painful and
dangerous. (PHDISK.EXE tends to nuke existing data if one is not careful.)
The tool is
available from Patrick D. Ashmore .
If your machine worked with 2.0.x kernels but not with the 2.2.x series, take this advice from Klaus Franken
<kfr_at_klaus.franken.de> : "The default changed in 2.2. Search in the init-scripts for halt
and change it to halt -p or poweroff. See man halt ,
if you don't have this option you need a newer version of halt."
You may find it in the SysVinit (
package .
On some new machines (for instance HP Omnibook 4150 - 366 MHz model) when accessing /proc/apm, you may get a
kernel fault general protection fault: f000.
Stephen Rothwell
explaines: "
This is your APM BIOS attempting to use a real mode segment while in protected mode, i.e. it is a bug in your BIOS. ..
We have seen a few of these recently, except all the others are in the power off code in the BIOS wher we can work
around it by returning to real mode before attempting to power off. Here we cannot do this."
apmd-rhcn-2.4phil-1 by
RedHat contains an unofficial patch
for shutting down the PCMCIA sockets before a suspend and patches for multiple batteries.
According to Documentation/Configure.help: "Some other things you should try when experiencing
seemingly random, weird problems:
- make sure that you have enough swap space and that it is enabled.
- pass the
no-hlt option to the kernel.
- switch on floating point emulation in the kernel and pass the
no387 option to the kernel.
- pass the
floppy=nodma option to the kernel.
- pass the
mem=4M option to the kernel (thereby disabling all but the first 4 MB of RAM).
- make sure that the CPU is not over clocked.
- read the sig11 FAQ
.
- disable the cache from your BIOS settings.
- install a fan for the video card or exchange video RAM.
- install a better fan for the CPU.
- exchange RAM chips.
- exchange the motherboard.
(from the PCMCIA-HOWTO):
"Card Services can be compiled with support for APM (Advanced Power Management) if you've configured your kernel with APM support. ... The PCMCIA modules will automatically be configured for APM if a compatible version is detected on your system. Whether or not APM is configured, you can use cardctl suspend before suspending your laptop, and cardctl resume after resuming, to cleanly shut down and restart your PCMCIA cards.
This will not work with a modem that is in use, because the serial
driver isn't able to save and restore the modem operating parameters. APM seems to be unstable on some systems. If you experience trouble with APM and PCMCIA on your system, try to narrow down the problem to one package or the other before reporting a bug. Some drivers, notably the PCMCIA SCSI drivers, cannot recover from a suspend/resume cycle. When using a PCMCIA SCSI card, always use cardctl eject prior to suspending the system."
Sometimes X windows and APM don't work smoothly together, the machine might even hang.
A recommendation from Steve Rader: Some linux systems have their X server hang when doing apm -s.
Folks with this affliction might want switch to the console virtual terminal then suspend chvt 1; apm -s
as root, or, more appropiately.sudo chvt 1; sudo apm -s.
I have these commands in a script, say, my-suspend and then
do xapmload --click-command my-suspend .
"Many (most?) BIOSes fail to save and restore display
controller chip registers, and X has no protocol to
be notified of resume events, so on many systems
suspend/resume is more-or-less incompatible with X."
Linux Laptops
has created a fix for this problem.
The new 3.0beta versions add a new feature to apmd: it can run arbitrary
commands (like cardctl suspend) when you suspend or resume your system.
It also supports BIOS clocks that are set to UTC time.
Lots of BIOSes fail to restore sound chip registers, so you may get
a squeal of feedback when you wake up the machine. A script in
/etc/apm/event.d can use aumix to save and restore sound mixer
settings.
From the man page:
Some computers, especially laptops, can wake-up from a
low-power suspend to DRAM mode using the Real-time-clock
(RTC) chip. Apmsleep can be used to set the alarm time in
the RTC and to go into suspend or standby mode. An interrupt from the RTC causes the computer to wake-up. The
program detects this event, by waiting for a leap in the
kernel time and terminates successfully. If no time leap
occurs within one minute, or something goes wrong, the
exit value will be non-zero.
Software Suspend enables the possibilty of suspending a machine. It doesn't need APM. You may suspend your machine by either pressing Sysrq-d
or with 'swsusp' or 'shutdown -z (patch for sysvinit needed). It creates an image which is saved in your active swaps. By the
next booting the kernel detects the saved image, restores the memory from it and then it continues to run as before you've
suspended. If you don't want the previous state to continue use the 'noresume' kernel option.
In recent 2.5.x kernels SoftWareSuspend is part of the kernel. You may find it in the last section (Kernel Hacking).
Patches for 2.4.x series and user space tools are provided by the
SWSUSPEND project.
ACPI stands for Advanced Configuration and Power Interface. This is a specification by Toshiba, Intel and Microsoft. Besides many other things it also defines power management. This is why it is often compared to APM.
The ACPI4Linux project has started at the beginning of 1999. The ACPI4Linux project is a kernel driver project aimed at implementing full ACPI support for Linux, including fan control, dock/undock detection and a WindowMaker dockable temperature meter. You may reach it at
ACPI4Linux .
Linux ACPI-HOWTO
by Ariel Glenn.
This document describes how to compile, install, and use the ACPI
driver for Linux and its associated applications.
The
E-AcpiPower
epplet is based on E-Power. It is modified to read
battery status information using the new acpi kernel module, making it much
more accurate and reliable than the old APM method.
The
Linux ACPI Project
is committed to the development of fundamental ACPI (Advanced Configuration and Power
Interface) components for Linux. This includes a generic ACPI table parser, AML
interpreter, bus and device drivers, policy, user interface, and support tools.
TCL/TK script
which allows setting the ACPI CPU performance
state using a graphical interface under Linux.
ACPI Info provides the
ACPI specification.
Apple Computer Inc. PowerBooks do not support the APM specification, but they have a
separate protocol for their PMU (Power Management Unit). There is a
free (GPL) daemon called pmud that handles power management;
it can monitor the battery level, put the machine to sleep, and set
different levels of power consumption. It was written by
Stephan Leemburg <stephan_at_jvc.nl>, and is available from PPC
distribution FTP sites#
There is also an older utility called snooze available from the
same sites that just puts the PowerBook to sleep.
Apmiser
is a daemon that monitors the CPU usage patterns of your laptop
and automatically switches between power-saving mode (in which the CPU
is underclocked) and normal mode, depending on whether it thinks you
will need the extra CPU speed. This lets you leave your laptop in it's
power-saving state without having to suffer from poor performance when
you need to perform a CPU-intensive task. Apmiser currently only
supports IBM Thinkpads via tpctl, but support can be easily added for
any laptop that supports switching power-saving modes programmatically.
Thanks to
- Nathan Myers <ncm_at_linuxlaptops.com> from Linux Laptops

- Steven G. Johnson <stevenj_at_alum.mit.edu> provided the PowerBook related information.
- Jan Lambert <snapdrgn_at_cruzio.com<
|