[RISCV] [BUG] CPU topology issue on TH1520 on Kernel 5.10.113-th15020

Conor Dooley conor at kernel.org
Wed Oct 9 03:54:56 PDT 2024


On Wed, Oct 09, 2024 at 11:43:28AM +0200, Guillem Senabre wrote:
> Dear Linux kernel developers, `sysfs` shows unexpected values when
> listing CPU topology for a TH1520 RISC-V CPU.
> 
> In particular, the following commands output always -1:
> 
> cat /sys/devices/system/cpu/cpu0/topology/{core_id,die_id,physical_package_id}
> cat /sys/devices/system/cpu/cpu1/topology/{core_id,die_id,physical_package_id}
> cat /sys/devices/system/cpu/cpu2/topology/{core_id,die_id,physical_package_id}
> cat /sys/devices/system/cpu/cpu3/topology/{core_id,die_id,physical_package_id}
> 
> The expected outputs would be a positive integer, rather than the -1
> currently obtained for all.
> 
> For more context: We are testing qemu on top of libvirt. This issue is
> blocking us since libvirt aborts after calling "virHostCPUGetCore()",
> which reads: /sys/devices/system/cpu/cpu0/topology/core_id and obtain
> a "-1".
> 
> We have resources allocated to debug this issue, but we'd appreciate
> guidance on where to focus our efforts.
> 
> Hardware:
> - Board: Sipeed LicheePi4a
> - Processor: TH1520
> - Architecture: riscv64
> 
> Software:
> - OS: Debian GNU/Linux trixie/sid
> - Kernel: Linux 5.10.113-th15020

What is a 5.10.113-th15020 kernel? Stable for 5.10 is currently at
5.10.226, so what you have here is horrifically out of date and
unsupported. 5.10 itself is something I would highly suggest not using
with riscv in the first place as a lot has changed in the ?4? years
since it was released.

I fixed the topology issues ages ago, which was backported in v5.10.152.
The TL;DR is that riscv was using the default topology code shared with
arm64, but without the fallback arm64 has to cpuid registers that
contain the information. riscv now has sensible defaults, if topology
info is not provided in the devicetree.
The alternative, if updating to a more recent kernel is not possible,
is to provide the topology information in the devicetree using the
cpu-map property.

Hope that helps,
Conor.

> - libvirt: 10.6.0
> 
> Thank you for your time and assistance. Please let us know if you need
> any additional information to help diagnose this issue.
> 
> Best regards,
> Guillem
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20241009/0aa2b187/attachment.sig>


More information about the linux-riscv mailing list