Subject: est driver adjustment
To: None <tech-kern@NetBSD.org>
From: Juraj Hercek <nbsd@hck.sk>
List: tech-kern
Date: 06/10/2006 18:19:05
Hi,

I've adjusted est (enhanced speedstep) driver so it is possible to 
undervolt intel CPU's with the enhanced speedstep feature. The patch 
gives me about 40+ minutes more time on batteries (Dothan 755 CPU).

The adjusted driver adds new entries under machdep.est:

machdep.est.voltage.undervolt - integer (0 | 1) (RW)[enables or disables 
undervolting feature]
machdep.est.voltage.current - integer (700 - max) (RW)[sets the voltage 
for currently set frequency]
machdep.est.voltage.available - string of values separated by space 
(RW)[sets the voltages for all frequencies]

The max voltage for given frequency is given by default voltage value. 
There is a check which prevents setting higher voltage. Minimal voltage 
is 700. Warning: If you set the voltage too low for given frequency, 
your system will freeze. Write or google for script that finds optimal 
voltage ramp for your CPU.

Before using this patch, please read the very beginning of the source 
file (see bottom of this email for download link), especially the 
section about warranties on lines 18-27. You have been warned.

Example usage (hw.model = Intel Pentium M (Dothan) (686-class); Dothan 
755 CPU):

$ sysctl machdep.est
machdep.est.frequency.target = 600
machdep.est.frequency.current = 600
machdep.est.frequency.available = 2000 1800 1600 1400 1200 1000 800 600
machdep.est.voltage.undervolt = 0
machdep.est.voltage.current = 988
machdep.est.voltage.available = 1340 1292 1244 1196 1148 1100 1052 988
$ sudo sysctl -w machdep.est.voltage.undervolt=1
machdep.est.voltage.undervolt: 0 -> 1
$ sysctl machdep.est                            
machdep.est.frequency.target = 600
machdep.est.frequency.current = 600
machdep.est.frequency.available = 2000 1800 1600 1400 1200 1000 800 600
machdep.est.voltage.undervolt = 1
machdep.est.voltage.current = 988
machdep.est.voltage.available = 1340 1292 1244 1196 1148 1100 1052 988
$ sudo sysctl -w machdep.est.voltage.current=716
machdep.est.voltage.current: 988 -> 716
$ sysctl machdep.est                            
machdep.est.frequency.target = 600
machdep.est.frequency.current = 600
machdep.est.frequency.available = 2000 1800 1600 1400 1200 1000 800 600
machdep.est.voltage.undervolt = 1
machdep.est.voltage.current = 716
machdep.est.voltage.available = 1340 1292 1244 1196 1148 1100 1052 716
$ sudo sysctl -w machdep.est.voltage.available="1164 1100 1036 972 908 
844 780 700"
machdep.est.voltage.available: 1340 1292 1244 1196 1148 1100 1052 988 -> 
1164 1100 1036 972 908 844 780 700
$ sysctl 
machdep.est                                                               
machdep.est.frequency.target = 600
machdep.est.frequency.current = 600
machdep.est.frequency.available = 2000 1800 1600 1400 1200 1000 800 600
machdep.est.voltage.undervolt = 1
machdep.est.voltage.current = 700
machdep.est.voltage.available = 1164 1100 1036 972 908 844 780 700

The diff file (against est-original.c which is the same as the est.c 
from stock NetBSD 3.0 sources) and patched file est-adjusted.c can be 
downloaded from link below. Before you download and apply/use, make sure 
you understand that this feature can freeze (and maybe damage) your CPU.

Link: https://www.hck.sk/netbsd/est

I don't ask to put it into official kernel sources (CVS). I don't even 
know if it would make sense. However, I'll leave this decision on 
others. I just want to share something that could be used also by others 
using NetBSD on notebooks with Intel Centrino CPUs.

Note: I'm NetBSD kernel programmer newbie. This fact most probably 
influences the quality of code written by me. Take it into account...

-- Juraj