riscv/meta-riscv

visionfive 2 cpu0: cpufreq_init: failed to get clk and cpufreq-dt: failed register driver: -19

kbarwich opened this issue · 4 comments

Description
Running a Yocto/poky image (core-image-full-cmdline) on a visionfive2 board, noticing that the CPU is only clocked at half speed. Checking dmesg gives the above errors which I'd assume are related. I have checked to see if the CPU frequency can be changed via /sys/devices/system/cpu/cpufreq but this seems to be an empty directory (which may be related).
This does not appear to be a problem related to the used hardware itself, as the CPU runs fine using the Debian distribution provided by StarFive themselves.
For Yocto I'm using Mickeldore built on a Ubuntu 20.04 machine (in case that is relevant) and I'm booting on an SD card

Steps to reproduce the issue:

  1. bitbake core-image-full-cmdline with the local machine variable set to visionfive2
  2. Boot system and check dmesg | grep cpu and /sys/devices/system/cpu/cpufreq

Update: Lots of digging has led me to conclude, that some riscv_timer_init_dt called during startup is to blame. It assigns a clocksource to a cpuid [0] and hartid [1-4] on Debian the hartid seems to be 1 consistently, whereas in yocto it changes between startups. The One time i observed yocto booting with hartid 1, the driver problems didn't occour. Rebooting right after confirming the CPU frequency led to another hartid and the same error/warning messages as before.

Fixed issue by setting RISCV_SBI_FDT to "starfive_visionfive2.dtb" as is done by the board devs in their own BSP repo, rather then "jh7110-visionfive-v2.dtb" as it is right now.

For Yocto I'm using Mickeldore built on a Ubuntu 20.04 machine (in case that is relevant) and I'm booting on an SD card

would you mind sending a patch to update it for conf/machine/visionfive2.conf ?
I guess KERNEL_DEVICETREE would also need to be changed.

Will see what I can do about the patch. I don't think that KERNEL_DEVICETREE needs to be changed, just judging by the way that starfive have it in their BSP. I'd assume that on adding the visionfive2.conf there was just a copying mistake, where the correct .dtb file reference for KERNEL_DEVICETREE landed in RISCV_SBI_FDT. Considering that in the original visionfive.conf, the files are the same between RISCV_SBI_FDT and UBOOT_DTB_BINARY, with only the KERNEL_DEVICETREE pointing elsewhere.