DVFS User Guide

From Texas Instruments Wiki
Jump to: navigation, search

What is DVFS?

Dynamic Voltage and Frequency scaling is a framework to change the frequency and/or operating voltage of a processor(s) based on system performance requirements at the given point of time.

Frequency Scaling

Frequency scaling is achieved using CPUFreq framework.

What is CPUFreq?

CPUfreq is a linux kernel framework that monitors the performance requirements of a processor(s) and takes decisions to increase or decrease operating frequency in order to save power and/or reduce leakage power.

CpuFreq Architecture

CPUFreq consists two elements

  • The Governor - that makes decisions
  • The Driver - acts based on the decisions made by the governor

Policy and Governor


Policy is set of rules the system is bound by such as min and max frequency for each cpu, availabilty of a frequency. Policy for a cpu is created during the CPUFreq framework initialization based on the frequency table.

Frequency Table

Frequency table consists of available frequencies for all cpus in the system. Frequency table is generated/populated based on the Operating Performance Point(OPP) list for each cpu.

OPP List

Operating performance Point(OPP) is a tuple consisting a frequency value and voltage required to run at the frequency. OPP table contains OPPs with a cpu/device name they are applicable to and an availabilty flag. OPP information of each device is added to OPP list.


Governor continuosly monitors the system perfomance requirements and when the requirement to change the frequency arises it checks the current cpu policy for frequency limits and requests the driver to change the frequency.


Multiple drivers can exist in the kernel but there will be only one scaling driver which performs actions based on governors decision.When the govenor request the driver to change the frequency to a target value, driver checks the frequency availability in the OPP list. If its found it scales the device to new frequency.

Governors provided by CPUFreq

The following governors are available in CPUFreq frame work

  • Performance
  • Powersave
  • Ondemand
  • Userspace
  • Conservative

'NOTE: For more information each governor refer to Linux kernel documentation @ <kernel>/Documentation/cpu-freq/governors.txt

Default Governor

Default governor is "performance". The default governor can be changed through 'menuconfig':

Chose the governor you want to use as default governor by selecting it from the list at:
 CPU Power management options --->
  [*] CPU frequency scaling
    Default CPUFreq governor (performance)  --->
      (x) performance
      () userspace
      () ondemand
      () conservative

Build Multiple governors

Multiple governors can be built and exist in the kernel by selecting them through "menuconfig".

Select the governors you want to build in to kernel.
 CPU Power management options --->
  [*] CPU frequency scaling
    Default CPUFreq governor (performance)  --->
  [*] performance
  [*] userspace
  [*] ondemand
  [] conservative

Governors can be switched at any time through the 'sysfs' interface.

  • To list all available governors:
   cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
  • To see current active governor
   cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  • To switch to a different governor
    echo -n "<governor_name>" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

e.g. to switch to 'userspace' governor

    echo -n "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  • To see current

CPUFreq Frequency transition notification

CPUFreq driver supports notifications of frequency changes

CPUFreq User Interface

CPUFreq exports a lot of information to user through sysfs interface To see information pertaining to a cpu(say cpu0):

  • current frequency of a cpu:
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
  • Available frequencies:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
  • Available governors
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
  • Current governor/ governor in use
cat /sys/devices/ system/cpu/cpu0/cpufreq/scaling_governor

Voltage Scaling

Voltage scaling is achieved using voltage layer and regulator framework(driver). When the CPUFreq driver scales the device frequency, voltage corresponding to the frequency(target_voltage) is looked-up in the opp list. The device scale function requests the voltage layer to scale the device voltage to the target_voltage.

Voltage Layer

The voltage layer consists of the information of all voltage domains in the system and configures all vdds during voltage layer initialization. When a vdd is configured a regulator supply handle is acquired and stored in the corresponding vdd structure.The regulators scale/set voltage function is plugged in to the vdd's voltage scale function pointer. Thus when a voltage change is requested forwarded to a vdd. The voltage layer requests the regulator framework to change the device voltage to the target voltage. Regluator driver verifies if the target voltage is in with in the limits of the voltage domain and regulator supply constraints. If all the checks go through then regulator changes the voltage of the requested device to the target voltage.

Transitioning to a different Power state(OPPs)

Userspace governor

Using "userspace" governor one can change the current OPP:

  • Select userspace governor
echo -n "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  • When using "userspace" governor to change to a low/high power state/OPP, first check the available frequencies:
$cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

Select a frequency and to change current cpu frequency do:

$echo -n "<new_frequency> > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

when the frequency is changed, system voltage is also changed to meet the new requirements as part of scaling: This is done in two ways:

* when new frequency is higher (moving to high power state/opp)
 * Voltage is increased first then the frequency,
* when new frequency is lower (moving to low power state/opp)
 * Frequency is reduced first then the voltage.

All other governors

For all other governors user does not need to give input in order to move to a low power/high power state.
The governor takes the decision to transit based on system requirements and does the scaling of frequency and voltage.
Each governors provides some configuration options which can be set/modified through sysfs. For detailed configuration options available for each governor refer to kernel documentation on governors @<kernel>/Documentation/cpu-freq/governors.txt


For more information on CPUFreq framework refer to the documentation available in Linux Kernel source @ <Kernel>/Documentation/cpu-freq.