Difference between revisions of "How to make use of Power Management features"

From ThinkWiki
Jump to: navigation, search
(Suspend to RAM (Sleep))
(See also)
 
(24 intermediate revisions by 16 users not shown)
Line 1: Line 1:
==APM==
+
==General Information about Power Management features==
 +
This page should give you all the information you need to make use of your ThinkPads [[Power Management]] features under [[:Category:Distributions|Linux]] and hence effectively enhance your battery life.
  
===general===
+
Note that different distributions and kernels have different results.  ThinkPad-365 and 365X used to perform
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.
+
blank, sleep and hibernation well using HW with W95,OS/2,and Linux installed (1998).  Later ThinkPads such as 240X,600E,T20 with recent Debian 2.4 kernels and ACPI=off will sleep, (also MDK-2.6 kernels).  
The configuration for what to do at the different events is done in the proxy script which is usually found in /etc/apmd_proxy.
+
However, blank and hibernation to disk do not work.  Better results are expected with 2.6.11+.
See <tt>man apmd</tt> for further information on this.
 
  
===Screen blanking (Standby)===
+
===APM vs. ACPI===
apm -S will standby the machine. Fn+F3 should result in the same thing.
+
All IBM ThinkPads support APM, and a lot support ACPI as well. Newer Lenovo ThinkPads support only ACPI.  Quality of ACPI implementation varies from model to model.  Both technologies cannot be used simultaneously; you'll have to make a choice.  Which to use depends on the model as well as on the state of ACPI support in the kernel.
  
===Suspend to RAM (Sleep)===
+
On older models you are surely better off with APM, if they feature ACPI at all.
apm -s will suspend the machine. Fn+F4 should do the same thing.
 
  
===Suspend to disk (Hibernate)===
+
It seems that at least in recent models from the A, G, R, T and X series ACPI generally works fine and is a lot more flexible than APM, but with a lot of them also a [[Problem with high power drain in ACPI sleep]] has been experienced.
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====
+
Please check our [[APM vs. ACPI | APM vs. ACPI success table]] to find out about APM and ACPI support in specific models.
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.
+
On the other hand simply switching from APM to ACPI extended my X31 battery runtime from about 3.5h to 4h. This had
 +
nothing to do with Dynamic Frequency Scaling which was active in both configurations.
  
I have successfully used this method on a T41 (2373GEU) that runs Fedora Core 3.
+
{{Todo|more precise and extended info should be provided here}}
  
====using a hibernation file on a dos partition====
+
==How to enable certain features==
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.
+
The following links will take you to separate pages dealing with the various topics.
Under Linux [[tphdisk]] will do this job for you.
+
*[[How to make APM work]] <tt>(Screen Blanking, Suspend to RAM, Suspend to Disk)</tt>
 +
*[[How to make ACPI work]] <tt>(Screen Blanking, Suspend to RAM, Suspend to Disk)</tt>
 +
*[[How to make use of Dynamic Frequency Scaling]] <tt>(Speedstep, Throttling, etc.)</tt>
 +
*[[How to make use of Harddisk Power Management features]] <tt>(Laptop-mode, Spindown, etc.)</tt>
 +
*[[How to make use of Graphics Chips Power Management features]] <tt>(save even more battery power)</tt>
 +
*[[How to use UltraBay batteries]] <tt>(advanced control for a secondary battery)</tt>
  
There have been varying reports of success or lack thereof using [[tphdisk]]; see [[APM setup on a type 2379 Thinkpad T40]] for workarounds if [[tphdisk]] doesn't do the trick.
+
==See also==
 +
*[[How to reduce power consumption]]
 +
*[[Idle_consumptions]]
  
==ACPI==
+
Suspend Resume
 
+
For users of Lenovo T series Thinkpads who have suspend resume problems related to the Nvidia display card see this page at IBM's Thinkpad support site:
===general===
+
http://www-307.ibm.com/pc/support/site.wss/document.do?sitestyle=lenovo&lndocid=MIGR-69135
Todo...
+
The driver referenced there (for the Quadro NVS 140M card) works with my T60p and suspends and resumes perfectly to disk.  I'll experiment with RAM some day...
 
+
wcn
===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.
 
 
 
But after a suspend-to-ram (using Linux 2.6.9) the display of the T42p (and probably of other Thinkpads, too) remains black. This can be fixed by adding
 
"acpi_sleep=s3_bios" to the kernel boot parameter. However I experience some problems with the serial port of the port replicator
 
after the wake up from ram.
 
 
 
There is a interesting discussion taking place in the [http://bugme.osdl.org/show_bug.cgi?id=3022 OSDL Bugzilla].
 
 
 
===Suspend to disk (Hibernate)===
 
There are two drivers for this available:
 
* swsusp, which is in the kernel and
 
* [http://developer.berlios.de/projects/softwaresuspend/ 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 [http://softwaresuspend.berlios.de/features.html 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 <tt>Power management options</tt> and enable <tt>Power management support</tt> and <tt>Software Suspend</tt> in the kernel config menu. You'll also want to give the swap partition to suspend to in <tt>Default resume partition</tt>.
 
 
 
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 <tt>/dev/resume_partition</tt> needs to be replaced by the swap partition you want to use for suspending. (Use <tt>fdisk -l /dev/hda</tt> if unsure.)
 
 
 
You can override the default resume partition anytime by giving <tt>resume=/dev/resume_partition</tt> 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 <tt>noresume</tt> kernel boot parameter.
 
 
 
To suspend you can either do a simple <tt>echo -n 4 > /proc/acpi/sleep</tt> (recommended) or use the [http://softwaresuspend.berlios.de/old-site/swsusp/sysvinit-2.76-v2-for_swsusp-v5.tar.gz patched SysVInit] and call <tt>swsusp</tt> or <tt>shutdown -z now</tt>.
 
 
 
Ideally you would do this from a script like <tt>/etc/acpi/actions/hibernate.sh</tt>. 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 [[How to get SpeedStep working on Coppermine-piix4-smi based Thinkpads | this page]].
 
 
 
===configuring SpeedStep daemons===
 
*[[How to configure cpufreqd | cpufreqd]]
 
*[[Hot to configure powersaved | powersaved]]
 
 
 
==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)
 

Latest revision as of 17:22, 19 April 2008

General Information about Power Management features

This page should give you all the information you need to make use of your ThinkPads Power Management features under Linux and hence effectively enhance your battery life.

Note that different distributions and kernels have different results. ThinkPad-365 and 365X used to perform blank, sleep and hibernation well using HW with W95,OS/2,and Linux installed (1998). Later ThinkPads such as 240X,600E,T20 with recent Debian 2.4 kernels and ACPI=off will sleep, (also MDK-2.6 kernels). However, blank and hibernation to disk do not work. Better results are expected with 2.6.11+.

APM vs. ACPI

All IBM ThinkPads support APM, and a lot support ACPI as well. Newer Lenovo ThinkPads support only ACPI. Quality of ACPI implementation varies from model to model. Both technologies cannot be used simultaneously; you'll have to make a choice. Which to use depends on the model as well as on the state of ACPI support in the kernel.

On older models you are surely better off with APM, if they feature ACPI at all.

It seems that at least in recent models from the A, G, R, T and X series ACPI generally works fine and is a lot more flexible than APM, but with a lot of them also a Problem with high power drain in ACPI sleep has been experienced.

Please check our APM vs. ACPI success table to find out about APM and ACPI support in specific models.

On the other hand simply switching from APM to ACPI extended my X31 battery runtime from about 3.5h to 4h. This had nothing to do with Dynamic Frequency Scaling which was active in both configurations.

TODO
more precise and extended info should be provided here

How to enable certain features

The following links will take you to separate pages dealing with the various topics.

See also

Suspend Resume For users of Lenovo T series Thinkpads who have suspend resume problems related to the Nvidia display card see this page at IBM's Thinkpad support site: http://www-307.ibm.com/pc/support/site.wss/document.do?sitestyle=lenovo&lndocid=MIGR-69135 The driver referenced there (for the Quadro NVS 140M card) works with my T60p and suspends and resumes perfectly to disk. I'll experiment with RAM some day... wcn