Open AlexandreTunstall opened 1 year ago
I tried setting the governor to userspace
and manually setting the CPU frequency. It seems that, for some reason, the system sets a lower frequency than intended for most frequencies.
scaling_cur_freq |
cpuinfo_cur_freq |
---|---|
375000 | 333333 |
500000 | 500000 |
750000 | 500000 |
1500000 | 1000000 |
I can't test other frequencies at the moment, since these are all my current kernel allows.
I've updated the title to reflect this new finding.
@AlexandreTunstall I'm seeing the same, but it seems to work with the 5.15 kernel coming with the Debian image (benchmarks with the same binaries also showing an appropriate speed difference), so I think this is some defect in the 6.x kernel tree.
The PLL0 is set to 1.0GHz. we will submit patch to fix this after this patchsets "Add PLL clocks driver and syscon for StarFive JH7110 SoC" is upstreamed.https://lwn.net/Articles/937299/
Still an issue when using kernel from https://github.com/starfive-tech/linux/commit/64a6c57ec372c44d0f25416c9614657e274fccff
% dmesg | grep -i freq
[ 14.305896] platform cpufreq-dt: deferred probe pending
[ 33.101720] cpufreq: cpufreq_online: CPU0: Running at unlisted initial frequency: 1000000 KHz, changing to: 1500000 KHz
% sudo grep '' /sys/devices/system/cpu/cpufreq/policy0/*
/sys/devices/system/cpu/cpufreq/policy0/affected_cpus:0 1 2 3
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq:1000000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq:375000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_transition_latency:4294967295
/sys/devices/system/cpu/cpufreq/policy0/related_cpus:0 1 2 3
/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies:375000 500000 750000 1500000
/sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors:performance schedutil
/sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/scaling_driver:cpufreq-dt
/sys/devices/system/cpu/cpufreq/policy0/scaling_governor:performance
/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq:375000
/sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed:<unsupported>
% sudo grep '' /sys/class/thermal/thermal_zone0/*
/sys/class/thermal/thermal_zone0/available_policies:step_wise
/sys/class/thermal/thermal_zone0/integral_cutoff:0
/sys/class/thermal/thermal_zone0/k_d:0
/sys/class/thermal/thermal_zone0/k_i:0
/sys/class/thermal/thermal_zone0/k_po:0
/sys/class/thermal/thermal_zone0/k_pu:0
/sys/class/thermal/thermal_zone0/mode:enabled
/sys/class/thermal/thermal_zone0/offset:0
/sys/class/thermal/thermal_zone0/policy:step_wise
grep: /sys/class/thermal/thermal_zone0/power: Is a directory
/sys/class/thermal/thermal_zone0/slope:1
grep: /sys/class/thermal/thermal_zone0/subsystem: Is a directory
/sys/class/thermal/thermal_zone0/sustainable_power:0
/sys/class/thermal/thermal_zone0/temp:60158
/sys/class/thermal/thermal_zone0/trip_point_0_hyst:2000
/sys/class/thermal/thermal_zone0/trip_point_0_temp:85000
/sys/class/thermal/thermal_zone0/trip_point_0_type:passive
/sys/class/thermal/thermal_zone0/trip_point_1_hyst:2000
/sys/class/thermal/thermal_zone0/trip_point_1_temp:100000
/sys/class/thermal/thermal_zone0/trip_point_1_type:critical
/sys/class/thermal/thermal_zone0/type:cpu-thermal
% uname -a
Linux nixos 6.5.0-rc1 #1-NixOS SMP Tue Jan 1 00:00:00 UTC 1980 riscv64 GNU/Linux
I'm not sure whether this is good enough to be upstreamed to mainline, but I've come up with a patch that fixes the problem.
--- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
@@ -407,12 +407,14 @@
/* Use fixed factor clocks if can not get the PLL clocks from DTS */
pllclk = clk_get(priv->dev, "pll0_out");
if (IS_ERR(pllclk)) {
- /* 24MHz -> 1000.0MHz */
+ /* 24MHz -> 1500.0MHz */
priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out",
- "osc", 0, 125, 3);
+ "osc", 0, 125, 2);
if (IS_ERR(priv->pll[0]))
return PTR_ERR(priv->pll[0]);
} else {
+ if (clk_set_rate(pllclk, 1500000000))
+ dev_err(priv->dev, "set pll0 rate failed\n");
clk_put(pllclk);
priv->pll[0] = NULL;
}
After building with the patch:
[root@nixos:~]# cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq
1500000
[root@nixos:~]# uname -a
Linux nixos 6.5.0-rc1 #1-NixOS SMP Mon Jul 24 07:58:38 UTC 2023 riscv64 GNU/Linux
I'll leave this open until a fix is upstreamed.
https://github.com/starfive-tech/linux/commit/67e8df01b875afd312a7d2ab77f56a62f39dd6d9 seems to fix it
% dmesg | grep -i freq
[ 0.004481] Calibrating delay loop (skipped), value calculated using timer frequency.. 8.00 BogoMIPS (lpj=16000)
[ 18.677004] platform cpufreq-dt: deferred probe pending
% sudo grep '' /sys/devices/system/cpu/cpufreq/policy0/*
/sys/devices/system/cpu/cpufreq/policy0/affected_cpus:0 1 2 3
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq:375000
/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_transition_latency:4294967295
/sys/devices/system/cpu/cpufreq/policy0/related_cpus:0 1 2 3
/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies:375000 500000 750000 1500000
/sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors:performance schedutil
/sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/scaling_driver:cpufreq-dt
/sys/devices/system/cpu/cpufreq/policy0/scaling_governor:performance
/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq:1500000
/sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq:375000
/sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed:<unsupported>
% sudo grep '' /sys/class/thermal/thermal_zone0/*
/sys/class/thermal/thermal_zone0/available_policies:step_wise
/sys/class/thermal/thermal_zone0/integral_cutoff:0
/sys/class/thermal/thermal_zone0/k_d:0
/sys/class/thermal/thermal_zone0/k_i:0
/sys/class/thermal/thermal_zone0/k_po:0
/sys/class/thermal/thermal_zone0/k_pu:0
/sys/class/thermal/thermal_zone0/mode:enabled
/sys/class/thermal/thermal_zone0/offset:0
/sys/class/thermal/thermal_zone0/policy:step_wise
grep: /sys/class/thermal/thermal_zone0/power: Is a directory
/sys/class/thermal/thermal_zone0/slope:1
grep: /sys/class/thermal/thermal_zone0/subsystem: Is a directory
/sys/class/thermal/thermal_zone0/sustainable_power:0
/sys/class/thermal/thermal_zone0/temp:58302
/sys/class/thermal/thermal_zone0/trip_point_0_hyst:2000
/sys/class/thermal/thermal_zone0/trip_point_0_temp:85000
/sys/class/thermal/thermal_zone0/trip_point_0_type:passive
/sys/class/thermal/thermal_zone0/trip_point_1_hyst:2000
/sys/class/thermal/thermal_zone0/trip_point_1_temp:100000
/sys/class/thermal/thermal_zone0/trip_point_1_type:critical
/sys/class/thermal/thermal_zone0/type:cpu-thermal
% 7z b
7-Zip 17.05 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.05 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs LE)
LE
CPU Freq: 64000000 64000000 64000000 64000000 - - - - 2048000000
RAM size: 7940 MB, # CPU hardware threads: 4
RAM usage: 882 MB, # Benchmark threads: 4
Compressing | Decompressing
Dict Speed Usage R/U Rating | Speed Usage R/U Rating
KiB/s % MIPS MIPS | KiB/s % MIPS MIPS
22: 2565 333 750 2496 | 62672 398 1344 5347
23: 2487 339 747 2535 | 61326 398 1334 5306
24: 2456 349 756 2642 | 59227 393 1323 5199
25: 2295 340 770 2621 | 58304 398 1305 5189
---------------------------------- | ------------------------------
Avr: 340 756 2573 | 397 1327 5260
Tot: 368 1041 3917
% uname -a
Linux nixos 6.5.0-rc1 #1-NixOS SMP Tue Jan 1 00:00:00 UTC 1980 riscv64 GNU/Linux
Yup, we have sent out a fixes patch https://lore.kernel.org/all/20230811033631.160912-1-xingyu.wu@starfivetech.com/
I noticed this didn't receive any updates. Was this forgotten?
Was this forgotten?
The fix doesn't appear to be in mainline yet, so this remains open.
The
cpuinfo_cur_freq
andscaling_cur_freq
don't match, suggesting that the kernel is unable to control the CPU frequency. Note thatcpuinfo_cur_freq
is reported by the hardware andscaling_cur_freq
is the last frequency the kernel requested the hardware to use.The system isn't thermal throttling, since the temperature is well under the passive trip point.
I'm using Linux 6.4.0 from commit
e5a381c51d624ffd8784db908a58ae227d0608a4
(from theJH7110_VisionFive2_upstream
branch) and u-boot from release 2.10.4 of this repository since later versions don't fit into flash. I can't use a later release of u-boot because, at the moment, I can only boot from flash.This kernel version includes the PMIC and CPU frequency patch sets, so I expect it to be able to control the CPU frequency. The kernel config can be found here. I've also tried explicitly enabling
REGULATOR_AXP15060
, but that didn't make a difference.Is something missing from the kernel or u-boot to make this work?