Difference between revisions of "How to control fan speed"

From ThinkWiki
Jump to: navigation, search
(tested disengaged mode via the ecdump and works)
(new packages)
Line 74: Line 74:
 
There is an distro independent daemon (http://projekte.f4.fhtw-berlin.de/trac/s0332819-linuxtools/wiki/), written in python. Packages are available for debian based linux systems.
 
There is an distro independent daemon (http://projekte.f4.fhtw-berlin.de/trac/s0332819-linuxtools/wiki/), written in python. Packages are available for debian based linux systems.
  
[http://www.gambitchess.org/moin.py/ThinkPad_Fan_Control A GTK GUI program (packaged for Ubuntu Gutsy Gibbon 7.10)] may also help.
+
[http://www.gambitchess.org/moin.py/ThinkPad_Fan_Control A GTK GUI program (packaged for Ubuntu 7.10 and 8.04)] may also help.
  
 
==For Windows==
 
==For Windows==

Revision as of 16:34, 4 April 2008

This page discusses methods for controlling the system fan.

For Linux

Using a patched kernel

NOTE!
The ibm-acpi driver is part of the Linux kernel 2.6.10 and later (option CONFIG_ACPI_IBM), so patching is not needed anymore.
ATTENTION!
This patch is superceded by the patches in ibm-acpi Git repository or ibm-acpi.sf.net releases
NOTE!
Advanced fan control through ibm-acpi has been merged in Linux 2.6.20-rc2 mainline, so users of 2.6.20 won't need to patch their kernels to get the fan level functionality anymore

The Patch for controlling fan speed provides a convenient interface via /proc/acpi/ibm/fan.

Manual speed control can be done through the patch for controlling fan speed:

#cat /proc/acpi/ibm/fan
status:         enabled
level:          auto
speed:          4219
commands:       enable, disable, level <level>
                (<level> is 0-7, auto or disengaged)

#echo level 2 > /proc/acpi/ibm/fan

#cat /proc/acpi/ibm/fan
status:         enabled
level:          2
speed:          3142
commands:       enable, disable, level <level>
                (<level> is 0-7, auto or disengaged)

Using a stock kernel

If you have the ibm-acpi module loaded with experimental=1, you can control the fan without patching the kernel by directly writing to the relevant embedded controller register using /proc/acpi/ibm/ecdump.

For example:

# echo 0x2F 0x00 > /proc/acpi/ibm/ecdump (fan off)

# echo 0x2F 0x02 > /proc/acpi/ibm/ecdump (low speed)

# echo 0x2F 0x04 > /proc/acpi/ibm/ecdump (medium speed)

# echo 0x2F 0x07 > /proc/acpi/ibm/ecdump (maximum speed)

# echo 0x2F 0x80 > /proc/acpi/ibm/ecdump (automatic - default)

# echo 0x2F 0x40 > /proc/acpi/ibm/ecdump (disengaged)

See the specifications below for the meaning of these modes.

On/off control using stock kernel

If you only wish to turn the fan on and off (with automatic control when it's on), you can use the following.

When loading ibm-acpi v0.11 with experimental switch (# modprobe ibm_acpi experimental=1), it is possible to read and write the status of fan:

#cat /proc/acpi/ibm/fan
status:         enabled
speed:          3580
commands:       enable, disable

#echo disable > /proc/acpi/ibm/fan

cat /proc/acpi/ibm/fan
status:         disabled
speed:          0
commands:       enable, disable

When off, the fan will then never wake up. It is advised to use an automated control script to reduce the chance of hardware damage.

Automated control scripts

An ACPI fan control script can be used to override the firmware's fan algorithm with gentler, quieter version. It monitors the laptop's thermal sensors and sets the fan speed accordingly, according to customizable thresholds. For the default behavior, simply save tp-fancontrol (download) as tp-fancontrol, make sure you've loaded thinkpad-acpi with the "fan_control=1" parameter, and run:
# ./tp-fancontrol

There is an distro independent daemon (http://projekte.f4.fhtw-berlin.de/trac/s0332819-linuxtools/wiki/), written in python. Packages are available for debian based linux systems.

A GTK GUI program (packaged for Ubuntu 7.10 and 8.04) may also help.

For Windows

Shimodax's ThinkPad fan control tool offers similar functionality (see forum discussion at thinkpads.com). Source and binaries are available through the "Tp4xFanControl" project on SourceForge.

Hardware specs

The following hardware behavior was discovered experimentally by Thinker and neither provided by nor confirmed by IBM/Lenovo. The following description may be inaccurate and may vary by model (see list of models above). The terminology probably does not match the one used by IBM/Lenovo engineers.

NOTE!
Information on other models is included in the ibm-acpi Git version.

ACPI DSDT register HFSP (8 bits, offset 0x2F in the EmbeddedController address space, accessed through the standard EC interface at IO ports 0x62 and 0x66) is read/writable and has the following meaning:

Bits   7 6 5 4 3 2 1 0
       ---------------
Value  1 0 * * * * * *  - automatic
       * 1 * * * * * *  - disengaged
       0 0 N N N N N N  - manual (0..63; 0=disable fan, 1=min, ..., 7=max)

Changing modes may not be immediate on all ThinkPads. Later ThinkPad models seem to take at least 5s to start responding to a fan mode change, for example.

After boot, the HFSP register may not reflect the true state of the EC (on some models it reads 0x07 even though the EC is actually in automatic mode).

Fan Tachometer

The embedded controller registers 0x84 (LSB), 0x85 (MSB) are the main fan tachometer, and report fan speed in RPM in everything since the A31 and maybe a little earlier. Not much is know about the tachometer in earlier models, or even whether they had one or not.

Automatic mode

In automatic mode, the embedded controller sets the fan speed automatically according to system temperatures and some unknown algorithm.

Note that the ACPI DSDT may supplement this in some models. The X40, for example, changes the profile of speeds the automatic mode should use depending on battery status.

Manual mode

In manual mode, the fan level is forced to the given value and the EC will auto-regulate the fan to maintain at a (roughly) constant RPM, which is model-dependent. Manual speed levels 8-63 yield the same behavior as level 7, and the the ACPI DSDT uses level 7 for the emergency mode it enters upon critical CPU/GPU temperature, so apparently 7 is the real maximum level.

Disengaged (full-speed) mode

In disengaged mode, the embedded controller does not monitor the fan speed. It "disengages" the closed-loop control function that keeps track of fan speed, and uses an open-loop control function that ramps up the fan to its maximum speed (100% duty-cycle). The end speed is not stable, but it is often much faster than the maximum speed manual and automatic modes would set the fan to.

Most newer ThinkPads take quite a while (in excess of one minute) to fully enter disengaged mode. Exiting it is much faster. The A31 acts differently, and switches to disengaged mode as fast as it switches to other modes.

For some reason, the embedded controller may stop updating the tachometer registers while entering or exiting disengaged mode in some ThinkPad firmware versions (hence the EC tachometer registers will not be updated on these models while entering/exiting disengaged mode). Once it arrives at maximum speed, or once it gets back at closed-loop cruise speed, the embedded controller starts updating the tachometer registers again. Later T models such as the T43 have this problem, while the A31 does not.

Hint:
Apparently the pulsing fan noise experienced by some users can be cured by repeatedly running 2-4 seconds of manual control followed by 0.5-1 seconds of disengaged mode. The pulse occurs when the the embedded controller computes the fan speed and adjusts the fan voltage adaptively every few seconds (~4.8sec for the ThinkPad T43); the aforementioned mode switching doesn't give it a chance to do so. One of the ACPI fan control scripts implements this solution.

Supported models

The above was successfully tested on the following models:

  • ThinkPad A31 (fan levels RPM: 0 = off, 1-2 = ~3280-3380 (!), 3-5 = ~3200, 6-7 = ~3380, "disengaged" = ~4000 (see NOTE above))
  • ThinkPad R50 (highest manual level is 3; disengage mode works and reaches much higher RPM)
  • ThinkPad R50p (fan levels RPM: 0 = off, 1-2 = ~3200, 3-5 = ~3500-3600, 6-7 = ~3700-3800, disengaged = ~5300)
  • ThinkPad R51 (fan levels RPM: 0 = off, 1-2 = ~3150, 3-5 = ~3350, 6 = ~3750, disengaged = ~5100)
  • ThinkPad R51e (fan levels RPM: 0 = off, 1-2 = ~3300, 3-5 = ~3800, 6 = ~4150, disengaged = ~5100)
  • ThinkPad R52 (fan levels RPM: 0 = off, 1-2 = ~3350, 3-5 = ~3650, 6 = ~4250, disengaged = ~5245)
  • ThinkPad R60 (fan levels RPM: 0 = off, 1-1 = ~2650, 3-5 = ~3300, 6-7 = ~3950, disengaged = ~4800)
  • ThinkPad R60e
  • ThinkPad T22
  • ThinkPad T23 (low speed = ~2200, medium and maximum speed = ~4800; disengaged mode works at ~5800)
  • ThinkPad T30
  • ThinkPad T40 (fan levels RPM: 1-2 = ~2950, 3-5 = ~3600, 6-7 = ~4050; disengaged = ~5400)
  • ThinkPad T41, T41p (fan levels RPM: 1-2 = ~2980, 3-5 = ~3500, 6-7 = ~4050; disengaged mode works at ~5100)
  • ThinkPad T42, T42p (fan levels RPM: 1-2 = ~2900, 3-5 = ~3700, 6-7 = ~4700; disengaged mode works at ~5200)
  • ThinkPad T43, T43p (fan levels RPM: 1-2 = ~3300, 3-5 = ~4100, 6-7 = ~4700; disengaged mode works at ~6450)
  • ThinkPad T60 (fan levels RPM: 1-2 = 3000-3100, 3-5 = ~3600, 6-7 = ~4500; disengaged mode works at ~5500)
  • ThinkPad T61 (fan levels RPM: 0 = off, 1-2 = ~2980, 3-5 = ~3330, 6-7 = ~3760; disengaged mode works at ~4500)
  • ThinkPad X30 (level 0 = off, low = ~3900, medium = ~4200, maximum = ~4650, disengaged = ~5900)
  • ThinkPad X31 (fan levels RPM: 0 = off, 1-2 = ~2850, 3-5 = ~3450, 6 = ~4050, 7 = ~4150; disengaged mode works at ~4975)
  • ThinkPad X40
  • ThinkPad X41
  • ThinkPad X41 Tablet
  • ThinkPad X60
  • ThinkPad X61s
  • ThinkPad Z60t, Z60m (fan levels RPM: 1-2 = ~1700, 3-5 = ~2800, 6-7 = ~3500)
  • ThinkPad Z61m
  • Thinkpad Z61p (fan levels 0-7, auto, disengaged; enable, disable; watchdog (untested))

Probably other models are supported too (please update this page if you confirm this; maintain some ordering too).

Models using a different interface

The following models also work, use a different access method which supported (only) via the /proc/acpi/ibm/fan of ibm-acpi. No need for patching.

Unsupported models

  • ThinkPad 560 (these models don't have a fan)