How to make use of Power Management features

From ThinkWiki
Revision as of 17:16, 4 December 2004 by 83.134.198.145 (Talk) (DynamicClocks in the Radeon Xorg driver)
Jump to: navigation, search

APM

general

You need to enable the APM Power Management support in the kernel and install the apmd to handle the events triggered by the kernel driver. The configuration for what to do at the different events is done in the proxy script which is usually found in /etc/apmd_proxy. See man apmd for further information on this.

Screen blanking (Standby)

Todo...

Suspend to RAM (Sleep)

Todo...

Suspend to disk (Hibernate)

The Phoenix BIOS allows you two ways to hibernate with APM: using a special partition or using a hibernation file on a dos type partition.

using a hibernation partition

The partition to be used for hibernation must be a primary partition that is at least as big as your laptop's memory including its video ram. First set the partition type of this partition to a0 (IBM Thinkpad hibernation) with fdisk, and then use tphdisk to write a hibernation file directly to this partition.

Only follow these instructions, if you understand them. You will overwrite a partition on your hard disk and might loose valuable data - consider yourself warned. For example, assume that /dev/hda2 is the partition that is to be converted to a hibernation partition. Become root and type /sbin/fdisk /dev/hda. At the fdisk prompt type t to change the partition type, then type 2 to indicate that you want to change the type of partition 2, and then enter the partition type: a0. Now type w to write the partition table back to disk and exit. After that use tphdisk to initialize the hibernation partition. First estimate the size of your laptop's memory (main and video). For the sake of this example, let us assume that the main memory is 1024 MB and the video card has 128 MB of memory. Then the command tphdisk 1152 > /dev/hda2 will initialize the hibernation partition. Note that this will only work if the partition is big enough. After a reboot, Fn+F12 will work as expected.

I have successfully used this method on a T41 (2373GEU) that runs Fedora Core 3.

using a hibernation file on a dos partition

The partition to put the file on must be a dos or vfat partition. Fat32 formatted partitions have been reported successful as well as Fat16 formatted ones. The file is either created with phdisk.exe, if you happen to have a floppy drive and a bootable dos floppy disk that you can start it from. Under Linux tphdisk will do this job for you.

Todo... (how to create the file, partition size)

ACPI

general

Todo...

Screen blanking (Standby)

Make sure you have

  • Option "DPMS"

in you XF86Config/xorg.conf.

Running "xset +dpms" and then "xset xdpms force off" will turn off the backlight on a laptop screen. To force a screen off that is using a radeon chipset, install the package "radeontools."

Todo...

Suspend to RAM (Sleep)

ACPI Sleep and suspend-to-ram with recent 2.6.x kernels usually works fine, too.

Todo...

Suspend to disk (Hibernate)

There are two drivers for this available:

  • swsusp, which is in the kernel and
  • SoftwareSuspend2 which is more feature rich, but not yet in the kernel, so you have to patch it in yourself

Both are reported to work fine as long as you use open-source graphic drivers. A comparison of the features can be found on this page.

Just in case you are in doubt...yes, it is safe in both cases to use the same swap partition as active swap and as suspend partition.

using swsusp

Software Suspend (swsusp) is included in the 2.6 kernel series. It seems like no patches for 2.4 kernels are available.

To enable it, go to Power management options and enable Power management support and Software Suspend in the kernel config menu. You'll also want to give the swap partition to suspend to in Default resume partition.

In case you prefer to edit your config file directly, you should have the following three entries look like here...

CONFIG_PM=y
CONFIG_SOFTWARE_SUSPEND=y
CONFIG_PM_STD_PARTITION="/dev/resume_partition"

...where /dev/resume_partition needs to be replaced by the swap partition you want to use for suspending. (Use fdisk -l /dev/hda if unsure.)

You can override the default resume partition anytime by giving resume=/dev/resume_partition as kernel boot parameter. Also, ihn case you suspended, but want to boot up normally (without resuming from the saved image - loosing all data that was unsaved at suspend time), you can give the noresume kernel boot parameter.

To suspend you can either do a simple echo -n 4 > /proc/acpi/sleep (recommended) or use the patched SysVInit and call swsusp or shutdown -z now.

Ideally you would do this from a script like /etc/acpi/actions/hibernate.sh. It has proven to be a good idea to shutdown the following processes/drivers within the script before you do the actual suspend.

  • any running mysql server
  • the madwifi driver, if you happen to use it

Afterwards you might want to enable them again, as well as run a script that does necessary configurations according to the ac power state. It has furthermore turned out that the system clock is not readjusted automatically, so you will probably also want the do that from that script (i.e. by restarting your systemclock bootup script).

Finally you should take note that swsusp does not set the ACPI S4 state. Instead it goes to S5. This means that the machine itself doesn't know that it was suspend rather than shutdown. Hence you can i.e. boot a parallel installed other operating system and resume your linux session later, as long as you don't touch the swap partition the image was saved to.

using SoftwareSuspend2

Todo...

Dynamic Frequency Scaling (SpeedStep)

configuring the kernel

2.4 kernels

Todo...

2.6 kernels

Todo...

If you have a Coppermine-piix-smi based Thinkpads like from the A2x, X2x and T2x series you might want to look at this page.

configuring SpeedStep daemons

Harddisk Power Management

Todo...

enabling the harddisks power management features

#!/bin/sh
# I' using this on FC2 and FC3
# cpu throttling off as FC does thisout-of-the-box
# turning swap off is only for those that feel comfortable
# doing something this nasty.
#
# pcfe, 2004-11-15
                                                                                                                                     
# cpu throttling
# cat /proc/acpi/processor/CPU0/throttling for more info
ACAD_THR=0
BATT_THR=2
                                                                                                                                    
# spindown time for HD (man hdparm for valid values)
# I prefer 2 hours for acad and 2 min for batt
ACAD_HD=244
BATT_HD=24
                                                                                                                                    
# Power management level
# 255 (off) on AC
# 128 (medium) on batt
# lowered to 32, pcfe, 2004-06-23
# upped to 64, pcfe, 2004-07-14
# upped to 96, pcfe, 2004-10-20
ACAD_PM=255
BATT_PM=96
                                                                                                                                    
# ac/battery event handler
                                                                                                                                    
status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/AC/state`
                                                                                                                                     
case $status in
       "on-line")
               logger "Running /sbin/laptop_mode stop"
               /sbin/laptop_mode stop
               logger "Setting HD spindown for AC mode with hdparm -S $ACAD_HD /dev/hda."
               /sbin/hdparm -S $ACAD_HD /dev/hda > /dev/null 2>&1
               logger "Setting HD powersaving for AC mode with hdparm -B $ACAD_PM /dev/hda."
               /sbin/hdparm -B $ACAD_PM /dev/hda > /dev/null 2>&1
               #logger "Turning on swap."
               #/sbin/swapon -a
               #echo -n $ACAD_CPU:$ACAD_THR > /proc/acpi/processor/CPU0/limit
               exit 0
       ;;
       "off-line")
               #logger "Turning off swap."
               #/sbin/swapoff -a
               logger "Running /sbin/laptop_mode start"
               /sbin/laptop_mode start
               logger "Setting HD spindown for battery mode with hdparm -S $BATT_HD /dev/hda."
               /sbin/hdparm -S $BATT_HD /dev/hda > /dev/null 2>&1
               logger "Setting HD powersaving for battery mode with hdparm -B $BATT_PM /dev/hda."
               /sbin/hdparm -B $BATT_PM /dev/hda > /dev/null 2>&1
               #echo -n $BATT_CPU:$BATT_THR > /proc/acpi/processor/CPU0/limit
               exit 0
       ;;
esac

Laptop-mode

To actually enable the harddrive to shutdown for a longer time and not get started again because of filesystem syncs every few seconds, you'll need to activate Laptop-mode.

DynamicClocks in the Radeon Xorg driver

The xorg X server has support for a power saving feature from ATI called PowerPlay. Xorg calls this feature DynamicClocks. It can be enabled in the server by adding Option "DynamicClocks" "on" in the Device section in /etc/X11/xorg.conf

Section "Device"
       Identifier  "Videocard0"
       Driver      "radeon"
       VendorName  "IBM Thinkpad"
       BoardName   "ATI Radeon Mobility M9"
       Option      "DynamicClocks" "on"
EndSection


With this option enabled, the X11 server should print (/var/log/Xorg.0.log):

(**) RADEON(0): Option "DynamicClocks" "on"
(II) RADEON(0): Dynamic Clock Scaling Enabled

http://www.ati.com/products/pdf/powerplaywp2.pdf

other Hardware

Todo...(if any - other ways of saving power and such)