TuxMobil: Linux with Laptops, PDAs, Mobile Phones and Portable Computers
PRINT version of "Power Management on Linux Laptops and Notebooks - APM, ACPI, PMU"
    <= Back to SCREEN version <=



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(http://acpi.sourceforge.net). 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(http://www.columbia.edu/~ariel/acpi/acpi_howto.txt) 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.

APM

Linux Compatibility Check

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.

Introduction

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.

Kernel Land

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):

User Land

The utilities for userland support may be found at APMD(http://worldvisions.ca/~apenwarr/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(http://www.hanno.de/) 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:

Richard Gooch wrote: I'have had a look at the beta version of apmd, and I still don't like it, because:

Though this topic was discussed controversly Richard Gooch has put together a package suspendd at his page(http://www.atnf.csiro.au/~rgooch/linux/) .

Also, have a look at apmcd (apm based crontab) at apmcd(ftp://ftp.binary9.net/pub/linux/) . A tool made by Nicolas J. Leon <nicholas_at_binary9.net> apmcd(http://mrnick.binary9.net/).

Note: I didn't check whether this features are merged into one package (apmd eventually) already.

Caveats

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 - utility for preparing a hibernation partition for APM Suspend-To-Disk

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(http://www.procyon.com/~pda/lphdisk/).

Troubleshooting

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(ftp://metalab.unc.edu/pub/Linux/system/daemons/init/).

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(http://www.canb.auug.org.au/~sfr/) 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:

  1. make sure that you have enough swap space and that it is enabled.
  2. pass the no-hlt option to the kernel.
  3. switch on floating point emulation in the kernel and pass the no387 option to the kernel.
  4. pass the floppy=nodma option to the kernel.
  5. pass the mem=4M option to the kernel (thereby disabling all but the first 4 MB of RAM).
  6. make sure that the CPU is not over clocked.
  7. read the sig11 FAQ(http://www.bitwizard.nl/sig11/) .
  8. disable the cache from your BIOS settings.
  9. install a fan for the video card or exchange video RAM.
  10. install a better fan for the CPU.
  11. exchange RAM chips.
  12. exchange the motherboard.

PCMCIA Card Services and Advanced Power Management

(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."

X-Windows and APM

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(http://www.linuxlaptops.com/ll/xresume.html) has created a fix for this problem.

APM Resume Options

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.

APM and Sound

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.

apmsleep

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

Software Suspend(http://falcon.sch.bme.hu/~seasons/linux/swsusp.html) 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(http://swsusp.sourceforge.net) project.

ACPI

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(http://acpi.sourceforge.net/).

Linux ACPI-HOWTO(http://www.columbia.edu/~ariel/acpi/acpi_howto.txt) by Ariel Glenn. This document describes how to compile, install, and use the ACPI driver for Linux and its associated applications.

The E-AcpiPower(http://www.netego.de/hpc?p=acpipower&l=en) 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(http://sourceforge.net/projects/acpi) 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(http://rffr.de/acpi) which allows setting the ACPI CPU performance state using a graphical interface under Linux.

ACPI Info(http://www.acpi.info/) provides the ACPI specification.

PMU

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

Apmiser(http://www.sifry.com/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.

Resources

Credits

Thanks to


        /* Adv.    Xtops.DE - Laptops and PDAs with pre-installed Linux   Adv. */        

http://tuxmobil.org/apm_linux.html, copyright © Werner Heuser, 1997-2008