CPUs frequency capped to minimum on AMD

Hello, I just installed diet-pi on an old AMD 5350, but my cpu speed is capped to 800MHz, instead of 2050MHz
Can you help me fix this?

some info:

#cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 
2050000 1850000 1650000 1400000 1200000 1000000 800000

#cpu

─────────────────────────────────────────────────────
 DietPi CPU Info
 Use dietpi-config to change CPU / performance options
 ─────────────────────────────────────────────────────
 Architecture |     x86_64
 Temperature  |     12 °C / 53 °F : Who put me in the freezer!
 Governor     |     schedutil

                 Current Freq    Min Freq   Max Freq
 CPU0         |      799 MHz      800 MHz    800 MHz
 CPU1         |      799 MHz      800 MHz    800 MHz
 CPU2         |      799 MHz      800 MHz    800 MHz
 CPU3         |      799 MHz      800 MHz    800 MHz

[ INFO ] DietPi-CPU_info | CPU current frequency, may be affected by this script, due to the processing required to run it.

#inxi:

CPU: Quad Core AMD Athlon 5350 APU with Radeon R3 (-MCP-) 
speed/max: 800/800 MHz Kernel: 5.10.0-13-amd64 x86_64 Up: 22m 
Mem: 421.8/11406.5 MiB (3.7%) Storage: 521.66 GiB (0.3% used) Procs: 105 
Shell: Bash inxi: 3.3.01

As you can see in scaling_available_frequencies there is 2050MHz available, but other tools don’t recognize it. In fact, the single cpu is slow. Even the dietpi-config tools (the one to adjust conservative vs performance CPU) is just showing 800MHz as option. Finally, when I check in UEFI at boot, it shows correctly 2050MHz as CPU speed.

:thinking:

let me ping the developer MichaIng

Also the temperature doesn’t look correct :smiley:.

Can you check:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq

Does it work with ondemand CPU governor?

echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
cpu

second this

You have the same or similar AMD 5350 system?

And what I recognized just now, does

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

show frequencies also in reversed order, with largest first and smallest last? It should be the other way round.

Please also add the outputs of my last post above.

Sorry for the spam/ping. Here is everything I’ve done yet:

root@DietPi:/home/dietpi# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
800000
1600000

After:

root@DietPi:/home/dietpi# echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
root@DietPi:/home/dietpi# cpu

 ─────────────────────────────────────────────────────
 DietPi CPU Info
 Use dietpi-config to change CPU / performance options
 ─────────────────────────────────────────────────────
 Architecture |     x86_64
 Temperature  |     4 °C / 39 °F : Who put me in the freezer!
 Governor     |     ondemand
 Throttle up  |     50% CPU usage

                 Current Freq    Min Freq   Max Freq
 CPU0         |      800 MHz      800 MHz    800 MHz
 CPU1         |      800 MHz      800 MHz    800 MHz
 CPU2         |      800 MHz      800 MHz    800 MHz
 CPU3         |      800 MHz      800 MHz    800 MHz

[ INFO ] DietPi-CPU_info | The current CPU frequency may be affected by processing this script itself.

Here is my CPU - so at least same architecture

root@DietPi:/home/dietpi# sudo lshw -class processor
  *-cpu                     
       description: CPU
       product: AMD Athlon(tm) 5150 APU with Radeon(tm) R3
       vendor: Advanced Micro Devices [AMD]
       physical id: 16
       bus info: cpu@0
       version: 22.0.1
       slot: CPUSocket
       size: 800MHz
       capacity: 1600MHz
       width: 64 bits
       clock: 100MHz
       capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp x86-64 constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt topoext perfctr_nb bpext perfctr_llc hw_pstate proc_feedback ssbd vmmcall bmi1 xsaveopt arat npt lbrv svm_lock nrip_save tsc_scale flushbyasid decodeassists pausefilter pfthreshold overflow_recov cpufreq
       configuration: cores=4 enabledcores=4 microcode=117440783 threads=4

Also:

root@DietPi:/home/dietpi# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
1600000 1400000 1200000 1000000 800000 

At last:

root@DietPi:/home/dietpi# sensors
fam15h_power-pci-00c4
Adapter: PCI adapter
power1:           N/A  (crit =  24.98 W)

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +4.5°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)

Thanks!

I’ve just found this ( CPU temperature for AMD A10 7700K APU - English / Hardware - openSUSE Forums):

modprobe nct6775
sensors

Which resulted in a few more sensors and an actual CPU temp reading (?):

root@DietPi:/home/dietpi# sensors
nct6776-isa-0290
Adapter: ISA adapter
Vcore:           1.02 V  (min =  +0.00 V, max =  +1.74 V)
in1:             1.85 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:            3.38 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
+3.3V:           3.38 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in4:           712.00 mV (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:             1.71 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in6:           648.00 mV (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:            3.47 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
Vbat:            3.30 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
fan1:             0 RPM  (min =    0 RPM)
fan2:          1498 RPM  (min =    0 RPM)
fan3:             0 RPM  (min =    0 RPM)
fan4:             0 RPM  (min =    0 RPM)
fan5:             0 RPM  (min =    0 RPM)
SYSTIN:         +34.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
CPUTIN:         +35.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:         +51.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PCH_CHIP_TEMP:   +0.0°C  
PCH_CPU_TEMP:    +0.0°C  
PCH_MCH_TEMP:    +0.0°C  
intrusion0:    ALARM
intrusion1:    ALARM
beep_enable:   disabled

fam15h_power-pci-00c4
Adapter: PCI adapter
power1:           N/A  (crit =  24.98 W)

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +4.5°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)

Interesting. Indeed also the reversed scaling_available_frequencies, I am sure this is related to the issue, that CPUFreq e.g. then takes the last one as highest, while in your both cases it is the smallest. Probably affects all AMD Athlon Kabini CPUs, at least the 5350 and 5150 the two of you use are from this very same family.

Does it work to manually adjust the max scaling frequency?

echo 1600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
cpu

EDIT: One more thing to check, as there are two scaling drivers available for AMD CPUs:

cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver
root@DietPi:/home/dietpi# echo 1600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
cpu

 ─────────────────────────────────────────────────────
 DietPi CPU Info
 Use dietpi-config to change CPU / performance options
 ─────────────────────────────────────────────────────
 Architecture |     x86_64
 Temperature  |     33 °C / 91 °F : Cool runnings
 Governor     |     ondemand
 Throttle up  |     50% CPU usage

                 Current Freq    Min Freq   Max Freq
 CPU0         |      1188 MHz      1600 MHz    1600 MHz
 CPU1         |      819 MHz      800 MHz    800 MHz
 CPU2         |      1515 MHz      800 MHz    800 MHz
 CPU3         |      869 MHz      800 MHz    800 MHz

[ INFO ] DietPi-CPU_info | The current CPU frequency may be affected by processing this script itself.
root@DietPi:/home/dietpi# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver
acpi-cpufreq

I’ve just seen that the CPU temperature looks like it’s fixed. Though

root@DietPi:/home/dietpi# sensors
k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +6.1°C  (high = +70.0°C)
                       (crit = +70.0°C, hyst = +69.0°C)

nct6776-isa-0290
Adapter: ISA adapter
Vcore:         992.00 mV (min =  +0.00 V, max =  +1.74 V)
in1:             1.85 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:            3.38 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:           3.39 V  (min =  +2.98 V, max =  +3.63 V)
in4:           712.00 mV (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:             1.70 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in6:           648.00 mV (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:            3.47 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:            3.30 V  (min =  +2.70 V, max =  +3.63 V)
fan1:             0 RPM  (min =    0 RPM)
fan2:          1473 RPM  (min =    0 RPM)
fan3:             0 RPM  (min =    0 RPM)
fan4:             0 RPM  (min =    0 RPM)
fan5:             0 RPM  (min =    0 RPM)
SYSTIN:         +33.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = thermistor
CPUTIN:         +35.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:         +51.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PCH_CHIP_TEMP:   +0.0°C  
PCH_CPU_TEMP:    +0.0°C  
PCH_MCH_TEMP:    +0.0°C  
intrusion0:    ALARM
intrusion1:    ALARM
beep_enable:   disabled

fam15h_power-pci-00c4
Adapter: PCI adapter
power1:           N/A  (crit =  24.98 W)

So I guess dietpi now pulls it’s source from nct6776-isa-0290CPUTIN instead of k10temp-pci-00c3

So to fix the temperature output you needed to load a particular platform driver nct6775, which obviously was not loaded OOTB?

So manually raising the max temperature at least worked. What is interesting and somewhat weird is that all CPUs seem to have their own governor policy, since CPU0 has max 1600 MHz applied correctly, but the others not, while especially CPU2 has a current frequency of 1515 MHz despite that. Now I want to see the full picture:

for i in /sys/devices/system/cpu/cpufreq/policy[0-9]
do
echo -n "$i/affected_cpus: "
cat "$i/affected_cpus"
echo -n "$i/scaling_max_freq: "
cat "$i/scaling_max_freq"
echo -n "$i/scaling_governor: "
cat "$i/scaling_governor"
done

In dietpi-software performance option you can set min and max frequencies for all CPUs in any case.

There is a dedicated AMD P-States scheduling driver, which could be tested as alternative. Though it does not seem to have real benefits: https://www.phoronix.com/review/amd-pstate-linux517/6

amd_pstate=passive would need to be added to kernel command-line arguments to enable it. There is an “active” mode, which is however surely not supported by such old CPU. There is a tiny risk that this driver is generally not supported by your CPU and that it makes boot failing.

Here the Linux docs about it: amd-pstate CPU Performance Scaling Driver — The Linux Kernel documentation
And as always Arch docs provide some good explanations: Making sure you're not a bot!

Regarding the nct6775, I had to calibrate lm-sensors. Then the sensors came up and I searched and found that this could be the issue. Not even sure if this fixed it and even then why…

Here you go:

root@DietPi:/home/dietpi# for i in /sys/devices/system/cpu/cpufreq/policy[0-9]
do
echo -n "$i/affected_cpus: "
cat "$i/affected_cpus"
echo -n "$i/scaling_max_freq: "
cat "$i/scaling_max_freq"
echo -n "$i/scaling_governor: "
cat "$i/scaling_governor"
done
/sys/devices/system/cpu/cpufreq/policy0/affected_cpus: 0
/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq: 800000
/sys/devices/system/cpu/cpufreq/policy0/scaling_governor: ondemand
/sys/devices/system/cpu/cpufreq/policy1/affected_cpus: 1
/sys/devices/system/cpu/cpufreq/policy1/scaling_max_freq: 800000
/sys/devices/system/cpu/cpufreq/policy1/scaling_governor: ondemand
/sys/devices/system/cpu/cpufreq/policy2/affected_cpus: 2
/sys/devices/system/cpu/cpufreq/policy2/scaling_max_freq: 800000
/sys/devices/system/cpu/cpufreq/policy2/scaling_governor: ondemand
/sys/devices/system/cpu/cpufreq/policy3/affected_cpus: 3
/sys/devices/system/cpu/cpufreq/policy3/scaling_max_freq: 800000
/sys/devices/system/cpu/cpufreq/policy3/scaling_governor: ondemand

I will look at that driver later. Would you say this is specially a diet-pi issue and maybe I should stick to stock debian?

I’ve looked at the driver and it seems like it is supposed to be compatible with Zen2 and upwards. As far as I know my CPU is Zen1.
I’ve also been able to set the CPU freq Min and Max manually in schedutil. What I’ve found weird is, when I’ve set Max to 1600 Min would automatically go to 1600. Had to manually set it to 800.

root@DietPi:/home/dietpi# cpu

 ─────────────────────────────────────────────────────
 DietPi CPU Info
 Use dietpi-config to change CPU / performance options
 ─────────────────────────────────────────────────────
 Architecture |     x86_64
 Temperature  |     33 °C / 91 °F : Cool runnings
 Governor     |     schedutil

                 Current Freq    Min Freq   Max Freq
 CPU0         |      800 MHz      800 MHz    1600 MHz
 CPU1         |      800 MHz      800 MHz    1600 MHz
 CPU2         |      800 MHz      800 MHz    1600 MHz
 CPU3         |      800 MHz      800 MHz    1600 MHz

[ INFO ] DietPi-CPU_info | The current CPU frequency may be affected by processing this script itself.
/sys/devices/system/cpu/cpufreq/policy0/affected_cpus: 0
/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq: 1600000
/sys/devices/system/cpu/cpufreq/policy0/scaling_governor: schedutil
/sys/devices/system/cpu/cpufreq/policy1/affected_cpus: 1
/sys/devices/system/cpu/cpufreq/policy1/scaling_max_freq: 1600000
/sys/devices/system/cpu/cpufreq/policy1/scaling_governor: schedutil
/sys/devices/system/cpu/cpufreq/policy2/affected_cpus: 2
/sys/devices/system/cpu/cpufreq/policy2/scaling_max_freq: 1600000
/sys/devices/system/cpu/cpufreq/policy2/scaling_governor: schedutil
/sys/devices/system/cpu/cpufreq/policy3/affected_cpus: 3
/sys/devices/system/cpu/cpufreq/policy3/scaling_max_freq: 1600000
/sys/devices/system/cpu/cpufreq/policy3/scaling_governor: schedutil

You mean when you raised /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq manually, /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq raised as well?

Indeed it has an own policy for each core, which is uncommon as well. In that case dietpi-config is handy, to apply things to all CPU cores.

As cpu output above shows current frequencies as 800 MHz only, you can check /sys/devices/system/cpu/cpufreq/policy*/stats/time_in_state by times to see whether all p-states are used.

Ah even the amd_pstate=passive? The active one mentions CPU requirements, for the passive one I was not sure. I mean as of the linked benchmarks, the AMD scheduler does not seem to have much benefits anyway, and with the passive mode even less. I was just wondering, that if it works at all, whether the CPUFreq setup and behavior would be more consistent. These inverse p-states, that hence the max frequency equals min by default, and that min changes when max is changed (as you said), that all looks like the chip is providing info in a way the default scheduler does not expect. At least it can be fixed/changed manually.

I will try later. I’ve changed to Ubuntu to see if I encounter similar errors. The temp error presets and it looks like that nct6776 isn’t reliable for cpu temp.

Regarding the scheduler. On Ubuntu it seems to get the right max and min.
But I am most likely going back to dietpi, so I will be updating on my tinkering.

By the way: /sys/devices/system/cpu/cpufreq/policy*/stats/time_in_state gave me a command not found

This is not a command to be executed. It’s s simple text file and content can be shown using cat