linux CPU dominant frequency setting

Posted by merrydown on Mon, 31 Jan 2022 02:23:57 +0100

CPU dominant frequency related information

root@am335x-evm:/sys/devices/system/cpu/cpu0/cpufreq# ls
affected_cpus                  scaling_cur_freq
cpuinfo_cur_freq               scaling_driver
cpuinfo_max_freq               scaling_governor
cpuinfo_min_freq               scaling_max_freq
cpuinfo_transition_latency     scaling_min_freq
related_cpus                   scaling_setspeed
scaling_available_frequencies  stats
scaling_available_governors
  • cpuinfo_cur_freq: current CPU working frequency, the working frequency read from the CPU register.
    cpuinfo_max_freq: the highest operating frequency that the processor can run (unit: KHz).
    cpuinfo_min_freq: the lowest operating frequency that the processor can run (unit: KHz).
    cpuinfo_transition_latency: the time required for the processor to switch frequency (unit: ns).
    scaling_available_frequencies: list of main frequencies supported by the processor (unit: KHz).
    scaling_available_governors: all types of Governors supported in the current kernel.
    scaling_cur_freq: saves the current CPU frequency cached by the cpufreq module and does not load the CPU hardware register
    Line check.
    scaling_driver: this file saves the FM driver used by the current CPU.
    scaling_governor:governor (frequency modulation) strategy, the Linux kernel has a total of 5 medium frequency strategy:
    ① , Performance, the highest Performance, directly using the highest frequency, regardless of power consumption.
    ② Interactive, first directly use the highest frequency, and then slowly reduce it according to the CPU load.
    ③ Powersave, a power-saving mode, usually operates at the lowest frequency, which will affect the system performance. Generally, this mode is not used!
    ④ Userspace, which can manually adjust the frequency in the user space.
    ⑤ , Ondemand, check the load regularly, and then adjust the frequency according to the load. When the load is low, reduce the CPU frequency to save power. When the load is high, increase the CPU frequency and increase performance
root@ATK-IMX6U:~# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
792000
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
198000 396000 528000 792000
root@ATK-IMX6U:~# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 12.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

Hardware        : Freescale i.MX6 Ultralite (Device Tree)
Revision        : 0000
Serial          : 0000000000000000

The higher the bogops is, the higher the MIPs is.

View the main frequency attribute settings in the kernel

CPU Power Management
	-> CPU Frequency scaling
		-> CPU Frequency scaling
			-> Default CPUFreq governor


However, in the future actual product development, from the perspective of power saving, it is recommended to use ondemand mode, which can save power and reduce heating.

Modify the mode to ondemand

After compiling zImage, check the parameters after startup

root@ATK-IMX6U:~# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
528000

The current frequency is reduced to 528M

root@ATK-IMX6U:~# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 6.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

Hardware        : Freescale i.MX6 Ultralite (Device Tree)
Revision        : 0000
Serial          : 0000000000000000

BogoMIPS values are getting smaller

Add new frequency 696MHz

Modify the device tree file arch / arm / boot / DTS / imx6ull dtsi

        cpus {
                #address-cells = <1>;
                #size-cells = <0>;

                cpu0: cpu@0 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        reg = <0>;
                        clock-latency = <61036>; /* two CLK32 periods */
                        operating-points = <
                                /* kHz  uV */
                                996000  1275000
                                792000  1225000
                                528000  1175000
                                396000  1025000
                                198000  950000
                        >;
                        fsl,soc-operating-points = <
                                /* KHz  uV */
                                996000  1175000
                                792000  1175000
                                528000  1175000
                                396000  1175000
                                198000  1175000
                        >;

Add support for 696MHz

        cpus {
                #address-cells = <1>;
                #size-cells = <0>;

                cpu0: cpu@0 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        reg = <0>;
                        clock-latency = <61036>; /* two CLK32 periods */
                        operating-points = <
                                /* kHz  uV */
                                996000  1275000
                                792000  1225000
                                696000 1175000
                                528000  1175000
                                396000  1025000
                                198000  950000
                        >;
                        fsl,soc-operating-points = <
                                /* KHz  uV */
                                996000  1175000
                                792000  1175000
                                696000 1175000
                                528000  1175000
                                396000  1175000
                                198000  1175000
                        >;

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  dtbs

After compilation, use the new device tree file imx6ull alientek_ emmc. DTB boot Linux

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
198000 396000 528000 696000 792000

696M frequency in options