[ltp] Re: [PATCH] In-kernel automatic fan control

Shem Multinymous linux-thinkpad@linux-thinkpad.org
Wed, 30 Nov 2005 21:25:18 +0200


------=_Part_24276_24842419.1133378718986
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

A few comments about Yury's patch and the ensuing discussion:

Looking only at the maximum temperature is dangerous. Each sensor monitors =
a
different component, and each component has a different spec and different
cooling system. For example, the CPU is rated to 97 degrees Celsius, the
2200BG mini-PCI card is rated at 80 degrees and the battery will die out
quite quickly at 50 degrees. The embedded controller uses different
thresholds for each sensor, for a good reason.

Yury's patch only monitors the 8 temperature sensors recognized by ibm-acpi
(embedded controller offsets 0x78-0x7F). There are at least 3 more sensors,
at EC offsets 0xC0 to 0xC3 (and 0xC4-0xC7 look like they're reserved for
more sensors). It has been observed by several people that the BIOS often
steps up the fan speed because of these extra sensors. You mustn't ignored
them, and you mustn't apply the too-generous CPU thresholds to them either.
See this discussion:

http://www.thinkwiki.org/wiki/Talk:Problem_with_fan_noise#Secret_sensor_and=
_the_cause_of_fan_always_on

As Paul said, it's much better to keep a stable low fan speed than to have
bursts of high speed - due to fan wear, thermal expansion and (subjectively=
)
annoyance effect.

Several people here referred to the 2nd and 3rd sensors (0x79 and 0x7A) as
"MiniPCI" and "HDD respectively". This is NOT generally true. On the T43,
sensor 0x79 seems to be in the HDAPS accelerometer chip (which sits between
the Mini-PCI and the well-ventilated PCMCIA slots, so it doesn't reflect
Mini-PCI temperature well), and sensor 0x7A gives values that are completel=
y
uncorrelated with the HDD temperature reported by the HDD's SMART interface=
.
For the best available guess about the location of the sensors and the
appropriate temperatures, see the top of the script mentioned earlier:

http://www.thinkwiki.org/wiki/ACPI_fan_control_script#Variable_speed_contro=
l_scripts

Anyway, fan control can be done in kernel despite this complication -  the
core algorithm used by the above script, stripped of comments and support
code, is just a dozen lines of code. Performance-wise, a kernelspace
governer is unnecessary (it wakes up only every few seconds anyway, just
like the embedded controller). Yes, it could prevent things like ungraceful
death by OOM (graceful death is fine - the above script restore the default
fan behavior when it's killed). But if you care only about ungraceful death
then it suffices to have a tiny kernel patch that kicks the fan to default
speed if it didn't get a keep-alive signal (say, a write to
/etc/acpi/ibm/fan) for N seconds.

For userspace control of fan speed, there's this patch:
  http://www.thinkwiki.org/wiki/Patch_for_controlling_fan_speed
At the bottom of that page you can find the relevant hardware specs
(including a surprise). But if you don't care about a bit of ugliness, you
don't even need this patch - just force a certain speed this way:

echo 0x2F 0x00 > /proc/acpi/ibm/ecdump   # fan off
echo 0x2F 0x01 > /proc/acpi/ibm/ecdump   # fan at low speed
echo 0x2F 0x04 > /proc/acpi/ibm/ecdump   # fan at medium speed
echo 0x2F 0x07 > /proc/acpi/ibm/ecdump   # fan at high speed
echo 0x2F 0x80 > /proc/acpi/ibm/ecdump   # back to automatic speed

Have fun and don't fry your laptop! If it works for you, please report your
ThinkPad model on the Wiki.

  Shem

P.S. there's also a ThinkPad fan control tool for Windows based on the abov=
e
specs:
  http://forum.thinkpads.com/viewtopic.php?t=3D17715
  http://forum.thinkpads.com/viewtopic.php?t=3D17733

------=_Part_24276_24842419.1133378718986
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,<br>
<br>
A few comments about Yury's patch and the ensuing discussion:<br>
<br>
Looking only at the maximum temperature is dangerous. Each sensor
monitors a different component, and each component has a different spec
and different cooling system. For example, the CPU is rated to 97
degrees Celsius, the 2200BG mini-PCI card is rated at 80 degrees and
the battery will die out quite quickly at 50 degrees. The embedded
controller uses different thresholds for each sensor, for a good reason.<br=
>
<br>
Yury's patch only monitors the 8 temperature sensors recognized by
ibm-acpi (embedded controller offsets 0x78-0x7F). There are at least 3
more sensors, at EC offsets 0xC0 to 0xC3 (and 0xC4-0xC7 look like
they're reserved for more sensors). It has been observed by several
people that the BIOS often steps up the fan speed because of these
extra sensors. You mustn't ignored them, and you mustn't apply the
too-generous CPU thresholds to them either. See this discussion:<br>
&nbsp; <a href=3D"http://www.thinkwiki.org/wiki/Talk:Problem_with_fan_noise=
#Secret_sensor_and_the_cause_of_fan_always_on">http://www.thinkwiki.org/wik=
i/Talk:Problem_with_fan_noise#Secret_sensor_and_the_cause_of_fan_always_on<=
/a>
<br>
<br>
As Paul said, it's much better to keep a stable low fan speed than to
have bursts of high speed - due to fan wear, thermal expansion
and (subjectively) annoyance effect.<br>
<br>
Several people here referred to the 2nd and 3rd sensors (0x79 and 0x7A)
as &quot;MiniPCI&quot; and &quot;HDD respectively&quot;. This is NOT genera=
lly true. On the
T43, sensor 0x79 seems to be in the HDAPS accelerometer chip (which
sits between the Mini-PCI and the well-ventilated PCMCIA slots, so it
doesn't reflect Mini-PCI temperature well), and sensor 0x7A gives
values that are completely uncorrelated with the HDD temperature
reported by the HDD's SMART interface. For the best available guess
about the location of the sensors and the appropriate temperatures, see
the top of the script mentioned earlier:<br>
&nbsp; <a href=3D"http://www.thinkwiki.org/wiki/ACPI_fan_control_script#Var=
iable_speed_control_scripts">http://www.thinkwiki.org/wiki/ACPI_fan_control=
_script#Variable_speed_control_scripts</a> <br>
<br>
Anyway, fan control can be done in kernel despite this complication
-&nbsp; the core algorithm used by the above script, stripped of
comments and support code, is just a dozen lines of code.
Performance-wise, a kernelspace governer is unnecessary (it wakes up
only every few seconds anyway, just like the embedded controller). Yes,
it could prevent things like ungraceful death by OOM (graceful death is
fine - the above script restore the default fan behavior when it's
killed). But if you care only about ungraceful death then it suffices
to have a tiny kernel patch that kicks the fan to default speed if it
didn't get a keep-alive signal (say, a write to /etc/acpi/ibm/fan) for
N seconds.<br>
<br>
For userspace control of fan speed, there's this patch:<br>
&nbsp; <a href=3D"http://www.thinkwiki.org/wiki/Patch_for_controlling_fan_s=
peed">http://www.thinkwiki.org/wiki/Patch_for_controlling_fan_speed</a><br>
At the bottom of that page you can find the relevant hardware specs
(including a surprise). But if you don't care about a bit of ugliness,
you don't even need this patch - just force a certain speed this way:<br>
<br>
<code style=3D"white-space: nowrap; color: rgb(73, 89, 136); background-col=
or: white;">echo 0x2F 0x00 &gt; /proc/acpi/ibm/ecdump&nbsp;&nbsp; # fan off=
</code><br>
<code style=3D"white-space: nowrap; color: rgb(73, 89, 136); background-col=
or: white;">echo 0x2F 0x01 &gt; /proc/acpi/ibm/ecdump&nbsp;&nbsp; # fan at =
low speed</code><br>

<code style=3D"white-space: nowrap; color: rgb(73, 89, 136); background-col=
or: white;">echo 0x2F 0x04 &gt; /proc/acpi/ibm/ecdump&nbsp;&nbsp; # fan at =
medium speed</code><br>

<code style=3D"white-space: nowrap; color: rgb(73, 89, 136); background-col=
or: white;"></code><code style=3D"white-space: nowrap; color: rgb(73, 89, 1=
36); background-color: white;">echo 0x2F 0x07 &gt; /proc/acpi/ibm/ecdump&nb=
sp;&nbsp; # fan at high speed
</code><br>
<code style=3D"white-space: nowrap; color: rgb(73, 89, 136); background-col=
or: white;">echo 0x2F 0x80 &gt; /proc/acpi/ibm/ecdump&nbsp;&nbsp; # back to=
 automatic speed</code><br>
<br>
Have fun and don't fry your laptop! If it works for you, please report your=
 ThinkPad model on the Wiki.<br>
<br>
&nbsp; Shem<br>
<br>
P.S. there's also a ThinkPad fan control tool for Windows based on the abov=
e specs:<br>

&nbsp; <a href=3D"http://forum.thinkpads.com/viewtopic.php?t=3D17715">http:=
//forum.thinkpads.com/viewtopic.php?t=3D17715</a><br>

&nbsp; <a href=3D"http://forum.thinkpads.com/viewtopic.php?t=3D17733">http:=
//forum.thinkpads.com/viewtopic.php?t=3D17733</a><br>
<br>

------=_Part_24276_24842419.1133378718986--