ACPI Fan Problem After Suspend to Ram on Ubuntu 10.10

This is just a summary of my trials in solving this problem on my new laptop running Ubuntu 10.10

Description of problem: When I would close the laptop which would put it into suspend mode, and then open it up later to resume the fan would run at a high and annoyingly loud speed for no apparent reason. I know very little of ACPI but I hacked my system based on the helpful dialog on an Ubuntu bug post #77370 @ https://bugs.launchpad.net/ubuntu/+source/acpi/+bug/77370 , thanks guys.

So here’s what I did:

If you run:  cat /proc/acpi/fan/FAN*/state you will get a list of on/off states for the fan based on set points that can be seen with: cat /proc/acpi/thermal_zone/CPUZ/trip_points
What I had to do in essence is change the states to turn the fans to low speed or off and then for reasons I don’t have any idea about the proper functioning seems to take over and work fine. I used this little snippet of code to create the echo statements needed to set the states. The output ends up in /tmp/fanstate0 and /tmp/fanstate3 . If I then run the command sh /tmp/fanstate3 than the fan will slow way down.

for x in /proc/acpi/fan/*; do
if [ -f "$x/state" ] && [ "`grep off $x/state`" ]; then
echo "echo -n 0 > $x/state;" >> /tmp/fanstate0;
echo "echo -n 3 > $x/state;" >> /tmp/fanstate3;
fi;
done

In order to automate the process I had to create the file /etc/pm/sleep.d/99fanfix and put in the following code:

#!/bin/sh
#
# 99funguj: sprav co se da
case "$1" in
hibernate|suspend)
# Stopping is not required.
;;
thaw|resume)
# sprav to
for x in /proc/acpi/fan/*; do
if [ -f "$x/state" ] && [ "`grep on $x/state`" ]; then
echo -n 3 > $x/state;
echo -n 0 > $x/state;
fi
done
for x in /proc/acpi/fan/*; do
if [ -f "$x/state" ] && [ "`grep off $x/state`" ]; then
echo "echo -n 0 > $x/state;" >> /tmp/fanstate0
echo "echo -n 3 > $x/state;" >> /tmp/fanstate3
fi
done
sh /tmp/fanstate0
sleep 1
sh /tmp/fanstate3
rm /tmp/fanstate0
rm /tmp/fanstate3
;;
*) exit $NA
;;
esac

So far it seems to have solved the problem for now.

Other useful commands discovered in the process:

dmidecode   — outputs info about memory banks, battery, cpu etc.

lspci   — ouputs info about the devices connected to the pci buss.

cat /proc/acpi/thermal_zone/CPUZ/temperature

cat /proc/acpi/thermal_zone/CPUZ/trip_points

acpi -V   — acpi info.

sensors  — temp sensor outputs