8. CPU Frequency Control

The VIA CPUs include the ability to change CPU clock speed during operation. This feature used to be called longhaul but recently Centaur has changed the name to Powersaver. CPU clock speed is determined by two settings: the front side bus (FSB) clock speed and the CPU multiplier. For instance, the EPIA ME6000 includes a 600MHz Eden ESP CPU which has an FSB of 133 MHz and a CPU mult of 4.5. 133 x 4.5 = 598.5, and the manufacturers always round up to 600. The minimum and maximum clock multipliers are different for each CPU core. Between the minimum and maximum values, the clock multipliers increase by increments of .5. The table below summarizes the CPU clock speeds for each CPU core.

Table 9. VIA CPU Core Clock Speeds

CoreFSBMin CPU MultMax CPU Mult
Samuel66/100/13338
Samuel 266/100/133 fixed312
Ezra66/100/133 fixed312
Ezra T66/100/133312
Nehemiah66(?)/100/133516

The maximum values shown in the preceding table represent the maximum values supported by the longhaul/powersaver feature. In fact, each CPU has a factory default clock multiplier specified in its MSR_EBL_CR_POWERON register. This factory default multiplier should be considered the maximum clock multiplier for the CPU. In fact, some VIA CPUs may be overclocked by setting the longhaul clock multiplier higher than the factory default. Overclocking your CPU is usually a bad idea because the extra heat generated by the higher clock might damage or destroy the CPU.

So if you can't make the CPU go faster, why bother? Well, lower clock speed means less power dissipation, which means cooler and quieter. For instance, many people leave their computers on all the time. Consider a screensaver that will automatically reduce the CPU speed when the computer is not being used. It also means that batteries will last longer. Consider a daemon running in the background that saves battery life by automatically reducing the clock speed when the CPU is running at less than full load.

That's the idea. But how do you actually use the feature? You need two tools to control the CPU frequency: a longhaul driver and a governor. The longhaul driver directly accesses the CPU, changing the clock speed. The governor monitors some system parameter (for instance cpu usage) and instructs the kernel module to increase or decrease the CPU speed when the system parameter changes.

8.1. Linux 2.6 CPU Frequency Control

The linux 2.6 kernel includes a CPU Frequency Control system called cpufreq. cpufreq includes a longhaul driver. The cpufreq longhaul driver supports Samuel, Samuel 2, Ezra and Ezra-T microprocessors, but not Nehemiah processors. If your EPIA runs at 1 GHz or more, odds are it has a Nehemiah processor. In order to implement the powersaver function on the Nehemiah under linux you will need to patch the kernel. Here are two methods, first the newer and better method, and second the older buggy method.

Ken Staton has fixed the longhaul driver and submitted a patch to the cpufreq tree. Unfortunately it might take a while for the patch to reach the official linux kernel. In the meantime, we will have to patch the kernel and recompile. Here is the patch. This patch should apply cleanly to the 2.6.10 and 2.6.11 kernels, and maybe even 2.4.27.

Here is the older, buggy method. First read the Building Linux 2.6-epia section and download and patch the source tree. But after you apply the 2.6.6-epia1 patch download the 2.6.6-epia1-longhaul patch and apply it also.

bash# gzip -dc ../patch-2.6.6-epia1-longhaul.gz | patch -p1

Now you can go continue with the Building Linux 2.6-epia instructions, but when you configure the kernel be sure to enable frequency scaling. You will find it in the Power Management section under CPU Frequency Scaling. Enable CPU Frequency Scaling. Go into the Default CPUFreq Governor menu and select the userspace governor as the default. Go back to the previous menu and build the performance and powersave governors as modules. Build the CPU Frequency Table Helpers and build the VIA Cyrix III Longhaul support as a module.

Once the kernel is built and installed you must load the module into the kernel:

bash# modprobe longhaul

8.2. Userspace Governor

The userspace governor gives you direct control of the cpu speed using simple cat and echo commands. If you didn't set the userspace governor as the default governor then you must load the module. The 2.6 CPU Frequency Scaling code uses the new sysfs interface, so you must create a /sys directory and mount the sysfs filesystem there. Now change into the cpufreq directory and you can control the cpu speed as illustrated below:

bash# modprobe userspace
bash# mount -t sysfs sysfs /sys
bash# cd /sys/devices/system/cpu/cpu0/cpufreq
bash# cat scaling_governor
userspace
bash# cat /proc/cpuinfo
processor       : 0
vendor_id       : CentaurHauls
cpu family      : 6
model           : 9
model name      : VIA Nehemiah
stepping        : 1
cpu MHz         : 999.914
cache size      : 64 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu de tsc msr mtrr pge cmov mmx fxsr sse rng
bogomips        : 1974.27

bash# cat scaling_available_frequencies
731000 798000 931000 665000 864000 997000
bash# echo 731000 > scaling_setspeed
bash# cat /proc/cpuinfo
processor       : 0
vendor_id       : CentaurHauls
cpu family      : 6
model           : 9
model name      : VIA Nehemiah
stepping        : 1
cpu MHz         : 733.136
cache size      : 64 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu de tsc msr mtrr pge cmov mmx fxsr sse rng
bogomips        : 1447.53