Acer Aspire One fan control
Peter Feuerer
maintainerHi list,
I own such an Acer Aspire One netbook and the noisy fan annoyed me. (The default hardware controlled fan is on all the time). So I wrote a small kernel module which monitors the temperature of the cpu and turns the fan on and off. After testing it a while on my and some of my friends netbooks, it seems to be stable and I thought about submitting this functionality to the mainline kernel. As this is my first time, I've got some questions and would really appreciate any help.
Do you think it makes sense to add it as seperate kernelmodule or should I patch another module, e.g. the drivers/misc/acer-wmi.c module?
Should I try also to add the functionality of the /proc/acpi/thermal_zone/THRM/* things in my first patch? Or just submit the general functionality for controlling the fan and add additional things step by step?
kind regards, and many thanks for your answers.
--peter
* Peter Feuerer <[email protected]>:
Quoted 9 lines
Hi list,
I own such an Acer Aspire One netbook and the noisy fan annoyed me. (The default hardware controlled fan is on all the time). So I wrote a small kernel module which monitors the temperature of the cpu and turns the fan on and off. After testing it a while on my and some of my friends netbooks, it seems to be stable and I thought about submitting this functionality to the mainline kernel. As this is my first time, I've got some questions and would really appreciate any help.
There's a userspace program for that. So why add a kernel module?
Peter Feuerer
maintainerQuoted 1 line · Ralf Hildebrandt
There's a userspace program for that. So why add a kernel module?
Because you must write to and read from io-ports and I think this should be done in the kernel. I guess the userspace program you are talking about is acer_ec.pl? A perl script which needs very much cpu time for a functionality which can be handled in kernelspace without causing any big troubles.
Quoted 9 lines · Peter Feuerer
Quoted 1 line · Ralf Hildebrandt
There's a userspace program for that. So why add a kernel module?
Because you must write to and read from io-ports and I think this should be done in the kernel. I guess the userspace program you are talking about is acer_ec.pl? A perl script which needs very much cpu time for a functionality which can be handled in kernelspace without causing any big troubles.
Not just that.
While on acer one it seems that if I kill userspace script, fan restores to its original state (eg: running), I would also like such driver on my main notebook, which is also acer.
It fan is also controlled via EC, but 'control' is done via hack in acpi thermal code, every time it is updated, it sends new temperature to EC, so I can just unload acpi thermal driver, and use own script/driver do do same job, but I afraid that usespace driver can hung/be killed/etc leaving me without fan at all, so this why kernel driver is better - it is more reliable.
Best regards,
Maxim Levitsky
Quoted 11 lines · Peter Feuerer <peter <at> piie.net> writes:
Hi list,
I own such an Acer Aspire One netbook and the noisy fan annoyed me. (The default hardware controlled fan is on all the time). So I wrote a small kernel module which monitors the temperature of the cpu and turns the fan on and off. After testing it a while on my and some of my friends netbooks, it seems to be stable and I thought about submitting this functionality to the mainline kernel. As this is my first time, I've got some questions and would really appreciate any help.
Quoted 6 lines
Do you think it makes sense to add it as seperate kernelmodule or should I patch another module, e.g. the
drivers/misc/acer-wmi.cmodule? Should I try also to add the functionality of the/proc/acpi/thermal_zone/THRM/*things in my first patch? Or just submit the general functionality for controlling the fan and add additional things step by step?
Does it help if you do:
echo 10 >/proc/acpi/thermal_zone/*/polling_frequency
If the fan is controlled via thermal ACPI trip points, maybe latest kernel versions do help? There were several commits lately in this area, e.g.:676962dac6e267ce7c13f73962208f9124a084bb f5adfaa372c76423b6e8e4727a9701330374f364
The latter adds a boot param you could give a try if you think it's worth it:
ACPI: Add "acpi.power_nocheck=1" to disable power state check in power transition
Peter Feuerer
maintainerQuoted 3 lines · Thomas Renninger
Does it help if you do:
echo 10 >/proc/acpi/thermal_zone/*/polling_frequency
Actually there is nothing in /proc/acpi/thermal_zone/. So it seems for me, that there is no driver which handles the temperature and the fan of the Acer Aspire One yet. A search on google didn't disprove it. That's why I started to write my own kernel module. But I tested it only with 2.6.28.4. Maybe there's already something in 2.6.29, not sure about it.
Quoted 4 lines
If the fan is controlled via thermal ACPI trip points, maybe latest kernel versions do help? There were several commits lately in this area, e.g.:
676962dac6e267ce7c13f73962208f9124a084bbf5adfaa372c76423b6e8e4727a9701330374f364
Those patches have been applied to 2.6.28.
Quoted 3 lines
The latter adds a boot param you could give a try if you think it's worth it:
ACPI: Add "acpi.power_nocheck=1" to disable power state check in power transition
I will try the acpi.power_nocheck option, but google results on that don't sound very promising.
--peter
Quoted 6 lines · Peter Feuerer
Do you think it makes sense to add it as seperate kernelmodule or should I patch another module, e.g. the
drivers/misc/acer-wmi.cmodule? Should I try also to add the functionality of the/proc/acpi/thermal_zone/THRM/*things in my first patch? Or just submit the general functionality for controlling the fan and add additional things step by step?
That depends on how you're doing it. Is the code available somewhere? If these io ports are also used by the firmware then you'll need to find ACPI methods to call to perform the fan control. If there aren't any then it's not safe to have a driver to do this.
Signature · 1 line
Matthew Garrett | [email protected]
Peter Feuerer
maintainerQuoted 1 line · Matthew Garrett
That depends on how you're doing it. Is the code available somewhere?
Just cleaned up the code and released it on my homepage, you can download it from: http://piie.net/files/acerhdf_kmod-0.2.tar.gz
Quoted 1 line
If these io ports are also used by the firmware then you'll need to find ACPI methods to call to perform the fan control.
I get the temperature by calling ec_read(0x58) and can read/write the state of the fan by ec_write to / ec_read from 0x55. Actually I don't know if those embedded controller registers are used by the firmware. How can I find it out?
Quoted 1 line
If there aren't any then it's not safe to have a driver to do this.
I think there should not be a problem when calling ec_write and ec_read from my kernel module, as those functions are atomic. Or am I wrong?
--peter
Quoted 9 lines · Peter Feuerer
Quoted 3 lines · Matthew Garrett
If
these io ports are also used by the firmware then you'll need to find ACPI methods to call to perform the fan control.I get the temperature by calling
ec_read(0x58)and can read/write the state of the fan byec_writeto /ec_readfrom0x55. Actually I don't know if those embedded controller registers are used by the firmware. How can I find it out?
Ok, yup, that should be safe. It might be nice to implement this as an hwmon driver, potentially tying it into the thermal layer.
Signature · 1 line
Matthew Garrett | [email protected]
Peter Feuerer
maintainerQuoted 3 lines · Matthew Garrett
Quoted 1 line
I get the temperature by calling
ec_read(0x58)and can read/write the state of the fan byec_writeto /ec_readfrom0x55. Actually I don't know if those embedded controller registers are used by the firmware. How can I find it out?Ok, yup, that should be safe. It might be nice to implement this as an hwmon driver, potentially tying it into the thermal layer.
Thank you very much, I will have a deeper look into hwmon and the thermal layer.
--peter
Peter Feuerer
maintainerPATCH 1/1 acerhdf: Acer Aspire One fan control
In reply to Matthew GarrettQuoted 1 line · Matthew Garrett
Ok, yup, that should be safe. It might be nice to implement this as an hwmon driver, potentially tying it into the thermal layer.
Here is a patch which adds the "acerhdf" module to the kernel. It is now tied into the thermal layer.
The module creates a cooling device and a thermal zone. Both can be accessed through /sys/class/thermal/*. The module can be ran either in "kernel mode" in which a kernelthread to monitor the temperature and control the fan is started. Or it can be ran in "user mode" in which an userspace application can handle the fan control.
What do you think about this piece of code?
kind regards and thanks for all your comments!
--peter
drivers/misc/Kconfig +0 -0
@@ -158,6 +158,18 @@
If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M here.
+config ACERHDF
+ tristate "Acer Aspire One Fan Control (EXPERIMENTAL)"
+ depends on X86
+ depends on EXPERIMENTAL
+ depends on ACPI
+ depends on THERMAL
+ ---help---
+ This is the driver for monitoring the temperature and controlling + the fan of Acer Aspire One netbooks. + The temperature can be read from + /sys/class/thermal/thermal_zone0/temp
+
config ASUS_LAPTOP
tristate "Asus Laptop Extras (EXPERIMENTAL)" depends on X86
drivers/misc/Makefile +0 -0
@@ -10,6 +10,7 @@
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
obj-$(CONFIG_ACER_WMI) += acer-wmi.o
+obj-$(CONFIG_ACERHDF) += acerhdf.o
obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
drivers/misc/acerhdf.c +540 -0
540 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): 1235763653.24506.6.camel@localhost
Peter Feuerer
maintainerRe: [PATCH] acerhdf: Acer Aspire One fan control
Hi Joe, Hi List,
thank you very much for your tips!
Quoted 4 lines · Joe Perches
Quoted 1 line · Peter Feuerer
What do you think about this piece of code?
I think you should run it through lindent/checkpatch.
I let the checkpatch.pl script ran over the code and corrected every single warning and error. The resulting code is at the end of this email.
Do you (or anyobdy else on this list) have any further tips, suggestions or advices? If everybody is fine with the code, what will be the next steps?
kind regards,
--peter
drivers/misc/Kconfig +0 -0
@@ -158,6 +158,18 @@
If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M here.
+config ACERHDF
+ tristate "Acer Aspire One Fan Control (EXPERIMENTAL)"
+ depends on X86
+ depends on EXPERIMENTAL
+ depends on ACPI
+ depends on THERMAL
+ ---help---
+ This is the driver for monitoring the temperature and controlling + the fan of Acer Aspire One netbooks. + The temperature can be read from + /sys/class/thermal/thermal_zone0/temp
+
config ASUS_LAPTOP
tristate "Asus Laptop Extras (EXPERIMENTAL)" depends on X86
drivers/misc/Makefile +0 -0
@@ -10,6 +10,7 @@
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
obj-$(CONFIG_ACER_WMI) += acer-wmi.o
+obj-$(CONFIG_ACERHDF) += acerhdf.o
obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
drivers/misc/acerhdf.c +527 -0
527 lines not on this page · raw message
Re: [PATCH] acerhdf: Acer Aspire One fan control
Small number of things:
*) It looks like the patch has ended up linewrapped - it probably won't apply as a result.
*) x86 specific drivers are mostly moving from drivers/misc to drivers/platform/x86.
*) It should probably have a DMI modalias to allow it to autoload on appropriate hardware.
*) You have user and kernel modes - it should probably also have a bios mode that just leaves fan control in the same state it would be if the driver had never been loaded, and this should be the default.
*) The thermal code has been moved from ACPI into the generic thermal layer for 2.6.30. If you register thermal trip points and indicate that you require polling you should be able to get rid of the kernel thread in your driver and leave that up to the kernel.
Once that's all dealt with you should submit the patch to linux-kernel and Cc: Len Brown who maintains drivers/platform/x86. Include a description and a signed-off-by: line (and an entry in the MAINTAINERS file) and it should get merged.
Signature · 1 line
Matthew Garrett | [email protected]
Peter Feuerer
maintainerRe: [PATCH] acerhdf: Acer Aspire One fan control
Hi Matthew, Hi Len,
I've been improving and testing the acerhdf module the last few days and here's a new patch. Thank you Matthew for your hints!
Quoted 1 line · Matthew Garrett
*) It looks like the patch has ended up linewrapped - it probably won't apply as a result.
Hope this is fixed now, as I'm now using git diff to create the patch.
Quoted 1 line
*) x86 specific drivers are mostly moving from
drivers/misctodrivers/platform/x86.
Done.
Quoted 1 line
*) It should probably have a DMI modalias to allow it to autoload on appropriate hardware.
Done.
Quoted 1 line
*) You have user and kernel modes - it should probably also have a bios mode that just leaves fan control in the same state it would be if the driver had never been loaded, and this should be the default.
It's now started in user mode by default. The bios cares in usermode about the fan unless a userspace program does.
Quoted 1 line
*) The thermal code has been moved from ACPI into the generic thermal layer for 2.6.30. If you register thermal trip points and indicate that you require polling you should be able to get rid of the kernel thread in your driver and leave that up to the kernel.
Didn't find anything about polling in the drivers/thermal/ yet, but I'll keep on looking for that.
Quoted 1 line
Once that's all dealt with you should submit the patch to linux-kernel and Cc: Len Brown who maintains
drivers/platform/x86. Include a description and a signed-off-by: line (and an entry in theMAINTAINERSfile) and it should get merged.
Here we go:
Acerhdf is a driver for Acer Aspire One netbooks. It allows to access the temperature sensor and to control the fan.
MAINTAINERS +0 -0
@@ -189,6 +189,12 @@ M: [email protected]
L: [email protected]
S: Maintained
+ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER
+P: Peter Feuerer
+M: [email protected]
+W: http://piie.net/?section=acerhdf
+S: Maintained
+
ACER WMI LAPTOP EXTRAS
P: Carlos Corbacho
M: [email protected]
drivers/platform/x86/Kconfig +0 -0
@@ -34,6 +34,25 @@ config ACER_WMI
If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M here.
+config ACERHDF
+ tristate "Acer Aspire One temperature and fan driver"
+ depends on THERMAL
+ depends on THERMAL_HWMON
+ ---help---
+ This is a driver for Acer Aspire One netbooks. It allows to access + the temperature sensor and to control the fan. + + The driver is started in "user" mode where the Bios takes care about + controlling the fan, unless a userspace program controls it. + To let the kernelmodule handle the fan, do: + echo kernel > /sys/class/thermal/thermal_zone0/mode
+
+ For more information about this driver see
+ <http://piie.net/files/acerhdf_README.txt>
+
+ If you have an Acer Aspire One netbook, say Y or M
+ here.
+
config ASUS_LAPTOP
tristate "Asus Laptop Extras (EXPERIMENTAL)" depends on ACPI
drivers/platform/x86/Makefile +0 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
obj-$(CONFIG_ACER_WMI) += acer-wmi.o
+obj-$(CONFIG_ACERHDF) += acerhdf.o
obj-$(CONFIG_HP_WMI) += hp-wmi.o
obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
drivers/platform/x86/acerhdf.c new file +646 -0
646 lines not on this page · raw message
Peter Feuerer
maintainerRe: [PATCH] acerhdf: Acer Aspire One fan control
Hi Len,
have you already had a look at the patch? Is there anything what should be done in another way before you're going to apply it? Just for information, the kernelmodule has been downloaded from my homepage about 2200 times in march. So there are a lot of people already using it.
kind regards,
--peter
Peter Feuerer
maintainerRe: [PATCH] acerhdf: Acer Aspire One fan control
Hi len,
could you please write at least a short reply to one of my mails? It feels like you are ignoring me. I mean, if you don't have time to investigate the kernelmodule or if you don't want to have it in the kernel, I'm fine with it. But please reply. Being ignored makes me feel sad...
regards and looking forward to reading a reply,
--peter
Peter Feuerer
maintainerRe: [PATCH] acerhdf: Acer Aspire One fan control
In reply to Peter FeuererHi Matthew,
Len didn't respond to my email with my patch yet. Did I do anything wrong? Or is it just normal that it takes some weeks until he replies?
thank you very much,
kind regards,
--peter
Re: [PATCH] acerhdf: Acer Aspire One fan control
In reply to Peter FeuererQuoted 10 lines · On Saturday 28 February 2009 13:58:28 Peter Feuerer wrote:
Hi Joe, Hi List,
thank you very much for your tips!
Quoted 4 lines · Joe Perches
Quoted 1 line · Peter Feuerer
What do you think about this piece of code?
I think you should run it through lindent/checkpatch.
Quoted 8 lines
I let the checkpatch.pl script ran over the code and corrected every single warning and error. The resulting code is at the end of this email.
Do you (or anyobdy else on this list) have any further tips, suggestions or advices? If everybody is fine with the code, what will be the next steps?
kind regards,
--peter
It this now in a state that it makes sense to put it in linux next? or should mm be the target?
I would like to see this in the kernel. It is being used. My wife's acer is runing a version it. I suspect she is far from alone.
TIA
Ed Tomlinson