* [PATCH] hysteresis for active cooling
@ 2005-07-23 18:56 Sanjoy Mahajan
[not found] ` <E1DwPAQ-0006Oa-FA-BgpFEFc6EmUvjq1vVebcCXE/jYh+Q74khca9k7ZVKlY@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Sanjoy Mahajan @ 2005-07-23 18:56 UTC (permalink / raw)
To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
My laptop's fan was turning on and off as the temperature crossed the
active trip point. The patch below adds hysteresis: It turns off active
cooling only when the temperature falls, say, 2 C below the trip point.
Maybe the magic difference should be 5 degrees; I'd be curious what
setting suits people best.
Tested and working on my TP 600X (Debian 'etch', kernel 2.6.11.4,
original DSDT with fixes). It patches cleanly against 2.6.13-rc3 and is
conceptually simple, so I'd hope it works there too.
-Sanjoy
`A society of sheep must in time beget a government of wolves.'
- Bertrand de Jouvenal
--- linux/drivers/acpi/thermal.c.old 2005-03-17 16:40:04.000000000 -0500
+++ linux/drivers/acpi/thermal.c 2005-07-23 13:44:35.000000000 -0400
@@ -66,6 +66,8 @@
#define ACPI_THERMAL_MAX_ACTIVE 10
#define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65
+#define AC_HYSTERESIS 2 /* active-cooling hysteresis, in C */
+
#define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
#define CELSIUS_TO_KELVIN(t) ((t+273)*10)
@@ -625,8 +627,14 @@
* ----------------
* Turn OFF all cooling devices associated with this
* threshold.
+ *
+ * With hysteresis: Turn off only when temp is
+ * AC_HYSTERESIS [in C] below threshold. Safer to
+ * adjust fan-off rather than fan-on behavior.
*/
- else if (active->flags.enabled) {
+ else if (active->flags.enabled &&
+ KELVIN_TO_CELSIUS(tz->temperature) <=
+ KELVIN_TO_CELSIUS(active->temperature) - AC_HYSTERESIS) {
for (j = 0; j < active->devices.count; j++) {
result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3);
if (result) {
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <E1DwPAQ-0006Oa-FA-BgpFEFc6EmUvjq1vVebcCXE/jYh+Q74khca9k7ZVKlY@public.gmane.org>]
* Re: [PATCH] hysteresis for active cooling [not found] ` <E1DwPAQ-0006Oa-FA-BgpFEFc6EmUvjq1vVebcCXE/jYh+Q74khca9k7ZVKlY@public.gmane.org> @ 2005-07-24 4:21 ` Francisco Figueiredo Jr. [not found] ` <42E31751.4080802-/E1597aS9LRfJ/NunPodnw@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Francisco Figueiredo Jr. @ 2005-07-24 4:21 UTC (permalink / raw) To: Sanjoy Mahajan; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sanjoy Mahajan wrote: > My laptop's fan was turning on and off as the temperature crossed the > active trip point. The patch below adds hysteresis: It turns off active > cooling only when the temperature falls, say, 2 C below the trip point. > Maybe the magic difference should be 5 degrees; I'd be curious what > setting suits people best. > Hi Sanjoy. How do I know what temperature active cooling will be turned off? Currently as I type that, my system starts active cooling when it reaches 52 C and turns off when it reaches 44. I have the following as my trip_points: cat /proc/acpi/thermal_zone/THRM/trip_points critical (S5): 93 C passive: 90 C: tc1=2 tc2=3 tsp=100 devices=0xdf6de280 active[0]: 70 C: devices=0xc147de20 active[1]: 60 C: devices=0xc147df40 active[2]: 50 C: devices=0xc147d120 In my system, what your patch would do? Will it turn off fan when it reach 42, instead of actual 44? Thanks in advance. And sorry for boring you with these questions. I'm very interested in fan management in my laptop, since I had a challenge of knowing how to turn it on and off manually :) - -- Regards, Francisco Figueiredo Jr. Npgsql Lead Developer http://gborg.postgresql.org/project/npgsql MonoBrasil Project Founder Member http://monobrasil.softwarelivre.org - ------------- "Science without religion is lame; religion without science is blind." ~ Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iQEVAwUBQuMXUf7iFmsNzeXfAQKEMAf+OEVWUHpkgczonoRTn3KX7IOXv3lDjdVz 25DsFSR7lcMQ6t+6AzX1x1eN8IPtd8jPo2n0uE8Q66t/TNY/7ERtqxpqnDiGLPYr p7rXR+BfG3in/ZGdqKOclnfDhEVQLy8LLuyARRwVAlVdbnPeOjLRNkUZ2ElQNKW8 C/IUU7MzkrmtYutfQZRrwOS/rWA+o2GmnNtGQFTgNDhIM4H3ZnT6Kwt74Ramfsd2 mXJM9iq7AlBZxwQUBp3nSwVVYUfUX7NX/lPaOIdi7Fx2F3cYCEa+4ww9kUuW2uhs 9RF29dJf9vAflfrtKzWODU/aAukYTCawqkPxMOcLusodEFPS4k5lbg== =ulkU -----END PGP SIGNATURE----- _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/ ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <42E31751.4080802-/E1597aS9LRfJ/NunPodnw@public.gmane.org>]
* Re: [PATCH] hysteresis for active cooling [not found] ` <42E31751.4080802-/E1597aS9LRfJ/NunPodnw@public.gmane.org> @ 2005-07-25 3:08 ` Sanjoy Mahajan [not found] ` <E1DwtK9-000275-00-KmINTRm7+bkRAIupTkoUWTYRy0cijUJx@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Sanjoy Mahajan @ 2005-07-25 3:08 UTC (permalink / raw) To: Francisco Figueiredo Jr.; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f > Currently as I type that, my system starts active cooling when it > reaches 52 C and turns off when it reaches 44. > In my system, what your patch would do? Will it turn off fan when it > reach 42, instead of actual 44? I don't know for sure, since I don't understand why your system starts active cooling at 52 C (instead of 50 C) -- maybe there's hysteresis in the hardware? And why does it have to get way down to 44 C instead of only 50 C before turning off? >From reading the acpi spec, I understood that the ACPI interpreter is supposed to handle updating the temperature, querying the embedded controller, providing interfaces to turn the fan on and off; but that the OSPM (operating system power management code) is supposed to decide when to turn the fan on and off. In Linux that code is in the thermal module (drivers/acpi/thermal.c), and the only code I found to turn off active cooling was the else clause of if (tz->temperature >= active->temperature) { Would an ACPI guru clear up my lack of clue? -Sanjoy ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <E1DwtK9-000275-00-KmINTRm7+bkRAIupTkoUWTYRy0cijUJx@public.gmane.org>]
* Re: [PATCH] hysteresis for active cooling [not found] ` <E1DwtK9-000275-00-KmINTRm7+bkRAIupTkoUWTYRy0cijUJx@public.gmane.org> @ 2005-07-25 9:07 ` Jamie Lentin 2005-07-26 18:59 ` Sanjoy Mahajan 2005-08-01 1:59 ` Francisco Figueiredo Jr. 0 siblings, 2 replies; 6+ messages in thread From: Jamie Lentin @ 2005-07-25 9:07 UTC (permalink / raw) To: Sanjoy Mahajan Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > I don't know for sure, since I don't understand why your system starts > active cooling at 52 C (instead of 50 C) -- maybe there's hysteresis > in the hardware? And why does it have to get way down to 44 C instead > of only 50 C before turning off? There is probably hysteresis built into the DSDT. The ACPI Spec suggests doing this (don't have a page # handy tho', sorry), it's how hysteresis is implemented on my laptop (as well as yours---atlhough the hysteresis code is probably broken as it was on mine. I'm preparing a page in the DSDT fixes/rewrites I've done on my laptop, if you're interested. Your 600x DSDT code seems pretty much identical to my 770x code). Basically, whenever there is a change in fan state, the DSDT can trigger the OS to re-read the trip-points from the DSDT, and give lower values. Again, once the fan turns off, it can tell the OS to re-read, and give higher trip-point values. The problem with this is I can't really play with my trip-points using /proc, because as soon as the fan changes state, my changes get overwritten by the DSDT. It would be interesting if anyone has any ideas of getting around this. Cheers, ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] hysteresis for active cooling 2005-07-25 9:07 ` Jamie Lentin @ 2005-07-26 18:59 ` Sanjoy Mahajan 2005-08-01 1:59 ` Francisco Figueiredo Jr. 1 sibling, 0 replies; 6+ messages in thread From: Sanjoy Mahajan @ 2005-07-26 18:59 UTC (permalink / raw) To: Jamie Lentin; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > The problem with this is I can't really play with my trip-points > using /proc, because as soon as the fan changes state, my changes > get overwritten by the DSDT. Hmm, I've noticed that overwriting when the laptop wakes up from suspend (S3). The wakeup script sets the THM2 zone's active trip point to 50 C, but after maybe 10 or 15 minutes, it reverts to 34C (the default I think) and the fan turns on -- as it did just a minute ago. I haven't noticed this overwriting except after a wakeup; normally, the setting made using /proc remains constant. Maybe I should reload the thermal module upon wakeup, then set the temperature. > I'm preparing a page in the DSDT fixes/rewrites I've done on my > laptop, if you're interested. Thanks, I'd be interested. The 600X has the best keyboard of any computer I've used, even better than my old 560. With the maximum memory in it, it is plenty fast enough for what I do (TeX/MetaPost, computational physics) so I never want to upgrade to a newer and shoddier piece of hardware, and would like to fix as much as possible with the 600X's power management. -Sanjoy ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] hysteresis for active cooling 2005-07-25 9:07 ` Jamie Lentin 2005-07-26 18:59 ` Sanjoy Mahajan @ 2005-08-01 1:59 ` Francisco Figueiredo Jr. 1 sibling, 0 replies; 6+ messages in thread From: Francisco Figueiredo Jr. @ 2005-08-01 1:59 UTC (permalink / raw) To: Jamie Lentin Cc: Sanjoy Mahajan, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jamie Lentin wrote: >>I don't know for sure, since I don't understand why your system starts >>active cooling at 52 C (instead of 50 C) -- maybe there's hysteresis >>in the hardware? And why does it have to get way down to 44 C instead >>of only 50 C before turning off? > > > There is probably hysteresis built into the DSDT. The ACPI Spec > suggests doing this (don't have a page # handy tho', sorry), it's how > hysteresis is implemented on my laptop (as well as yours---atlhough the > hysteresis code is probably broken as it was on mine. I'm preparing a > page in the DSDT fixes/rewrites I've done on my laptop, if you're > interested. Your 600x DSDT code seems pretty much identical to my 770x > code). > > Basically, whenever there is a change in fan state, the DSDT can trigger > the OS to re-read the trip-points from the DSDT, and give lower values. > Again, once the fan turns off, it can tell the OS to re-read, and give > higher trip-point values. > Ahhhh, nice catch! I never watched my trip points when fan was on. This is what I get: cat /proc/acpi/thermal_zone/THRM/trip_points critical (S5): 93 C passive: 90 C: tc1=2 tc2=3 tsp=100 devices=0xdf6de240 active[0]: 70 C: devices=0xc147fe00 active[1]: 60 C: devices=0xc147ff20 active[2]: 45 C: devices=0xc147ffe0 Indeed, my active[2] was changed to 45 C. As I get my fan turned off when it reaches 42, 41C I think it has the hysteresis already in my dsdt as Jamie said. This would explain why values when fan is on or off changes sometimes. I mean, sometimes my fan starts with 51C, other times with 52C. The same happens when turning off. Thanks guys for this one more information. - -- Regards, Francisco Figueiredo Jr. Npgsql Lead Developer http://gborg.postgresql.org/project/npgsql MonoBrasil Project Founder Member http://monobrasil.softwarelivre.org - ------------- "Science without religion is lame; religion without science is blind." ~ Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iQEVAwUBQu2CFv7iFmsNzeXfAQKm9gf/dtcvDM7ijfryGUd9uJr/A5HBA178AQ9J MLDUzoVZBcF09SHLk4Oa6b0rqmMpfXiQ4n+Smai9zhwpysY66pcR8JFXHDqXow+K xpEAO91aE34VAYObcBS0WTWZd/5AIBDNzztV26Kaykn/Yp8JR618U94kSjU0k/ot fMqMKJq8IkvsJINxqst6fbHya/IuPSEg1XR6IwAR1DQML3dmXAWFeJiuYx4hrUDd yGU0rR+H369KzGU8Fqexo+aWPLw3beKcF15EGpYea9fwNNGqixEjbB19Cs7vr7z2 7UAn4ZTIX/aQn8rbsXrcn30jlbXNHIkk3k9ziLBKE6ve1IQxVreeYA== =VN0U -----END PGP SIGNATURE----- _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/ ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-08-01 1:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-23 18:56 [PATCH] hysteresis for active cooling Sanjoy Mahajan
[not found] ` <E1DwPAQ-0006Oa-FA-BgpFEFc6EmUvjq1vVebcCXE/jYh+Q74khca9k7ZVKlY@public.gmane.org>
2005-07-24 4:21 ` Francisco Figueiredo Jr.
[not found] ` <42E31751.4080802-/E1597aS9LRfJ/NunPodnw@public.gmane.org>
2005-07-25 3:08 ` Sanjoy Mahajan
[not found] ` <E1DwtK9-000275-00-KmINTRm7+bkRAIupTkoUWTYRy0cijUJx@public.gmane.org>
2005-07-25 9:07 ` Jamie Lentin
2005-07-26 18:59 ` Sanjoy Mahajan
2005-08-01 1:59 ` Francisco Figueiredo Jr.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox