Linux Dynamic Frequency Scaling
Contents
Introduction
Dynamic Frequency Scaling aka DFS is available on APF27, APF51, APF28, APF6 and OPOS6UL based systems. It allows you to control CPU speed according to module activity.
Linux configuration
You need to have a kernel with the CPUfreq drivers built-in (done by default when available):
$ make linux-menuconfig
CPU Power Management ---> [*] CPU Frequency scaling [*] Enable CPUfreq debugging <*> CPU frequency translation statistics [ ] CPU frequency translation statistics details Default CPUFreq governor (performance) ---> -*- 'performance' governor <*> 'powersave' governor <*> 'userspace' governor for userspace frequency scaling <*> 'ondemand' cpufreq policy governor <*> 'conservative' cpufreq governor <*> CPUfreq driver for i.MX CPUs or <*> i.MX27 frequency driver
In old Linux kernels (before device tree), frequency scaling handling is done in arch/arm/plat-mxc/cpufreq.c or arch/arm/mach-mx2/cpufreq_imx27.c
To know whether the driver is working
APF27 / APF28 / APF51 | APF6 / OPOS6UL |
---|---|
# dmesg | grep freq i.MXC CPU frequency driver |
Should be activated/working by default :-) |
Usage (sysfs)
- all is here:
# cd /sys/devices/system/cpu/cpu0/cpufreq/ # ls
Note: APF6 may have up to 4 CPU cores so you may end up with cpu0, cpu1, cpu2, cpu3 in /sys/devices/system/cpu/ |
- identify the current governor:
# cat scaling_governor performance
- list available governors:
# cat scaling_available_governors conservative ondemand userspace powersave interactive performance
- change governor:
# echo powersave > scaling_governor
- To know current CPU frequency (here 160MHz):
# cat cpuinfo_cur_freq 160000
- To know how much time CPU has spent in its different state (here 160MHz and 800MHz):
# cat stats/time_in_state 160000 243595 800000 585
- change frequency manually (here 133MHz). Requires userspace governor ! :
# echo 133000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
Effect on current consumption
When there is little activity, the CPU frequency has nearly no visible effect on the current consumed.
This is caused by the "doze mode" : when all processes are sleeping, the kernel turns off the CPU clock until the next IO or timer event.
When there is a 100% CPU activity, the effect of the CPU frequency can be observed with a ampmeter.
The % CPU activity per process can be checked with the top command, which is supported by Busybox (but it may be necessary to configure and rebuild busybox to have it)
Note: If you make current measurements using a development board like APF27dev or APF51dev, take care of making all the measurement with the same supply voltage.
Unlike linear regulators, the switching regulator of the board reduces the current consumed when the input voltage is increased (to keep the power constant) |
- To Be Continued...