Description
Qualcomm device CPU uses the cpufreq framework to dynamically adjust the frequency, and the GPU uses the Linux devfreq framework to adjust.
Devfreq has four frequency management strategies (governor actually implements different manufacturers):
- Performance: The GPU will work at the highest frequency it supports in order to pursue the highest performance.
- Powersave: The GPU will work at the lowest frequency it supports in order to pursue the lowest power consumption.
- Userspace: In the early management strategy, the system handed over the decision of the frequency conversion strategy to the user-mode application, and provided the corresponding interface for its use.
- Ondemand: userspace is user-mode detection, which is inefficient, while ondemand is a governor that works entirely in kernel mode and can sample and analyze system load at more fine-grained time intervals.
CPU
Using following codes to set CPU working at max clock frequency.
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor"
adb shell "echo 'performance' > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor"
GPU
Using following codes to set GPU working at max clock frequency.
adb shell "echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on"
adb shell "echo 100000000 > /sys/class/kgsl/kgsl-3d0/idle_timer"
adb shell "echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor"
Query
Using following codes to query CPU’s max clock frequency and working frequency.
CPU7_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu7/cpufreq/cpuinfo_max_freq"`
CPU6_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu6/cpufreq/cpuinfo_max_freq"`
CPU5_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_max_freq"`
CPU4_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_max_freq"`
CPU3_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_max_freq"`
CPU2_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_max_freq"`
CPU1_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq"`
CPU0_MAX_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"`
CPU7_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu7/cpufreq/cpuinfo_cur_freq"`
CPU6_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu6/cpufreq/cpuinfo_cur_freq"`
CPU5_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_cur_freq"`
CPU4_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq"`
CPU3_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq"`
CPU2_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq"`
CPU1_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq"`
CPU0_CUR_FREQ=`adb shell "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq"`
echo "CPU7_MAX_FREQ = ${CPU7_MAX_FREQ} CPU7_CUR_FREQ = ${CPU7_CUR_FREQ}"
echo "CPU6_MAX_FREQ = ${CPU6_MAX_FREQ} CPU6_CUR_FREQ = ${CPU6_CUR_FREQ}"
echo "CPU5_MAX_FREQ = ${CPU5_MAX_FREQ} CPU5_CUR_FREQ = ${CPU5_CUR_FREQ}"
echo "CPU4_MAX_FREQ = ${CPU4_MAX_FREQ} CPU4_CUR_FREQ = ${CPU4_CUR_FREQ}"
echo "CPU3_MAX_FREQ = ${CPU3_MAX_FREQ} CPU3_CUR_FREQ = ${CPU3_CUR_FREQ}"
echo "CPU2_MAX_FREQ = ${CPU2_MAX_FREQ} CPU2_CUR_FREQ = ${CPU2_CUR_FREQ}"
echo "CPU1_MAX_FREQ = ${CPU1_MAX_FREQ} CPU1_CUR_FREQ = ${CPU1_CUR_FREQ}"
echo "CPU0_MAX_FREQ = ${CPU0_MAX_FREQ} CPU0_CUR_FREQ = ${CPU0_CUR_FREQ}"