Skip to content

Register Zicntr in FDT when emulating is possible

Yao Zi opensbi 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntrinclude/sbi/sbi_hart.h lib/sbi/sbi_hart.c lib/sbi/sbi_timer.c+29 -112 replies
1/2lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr+0 -00 replies
1/2lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr+0 -00 replies
2/2lib: utils: fdt: Claim Zicntr if time CSR emulation is possiblelib/utils/fdt/fdt_fixup.c+29 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Register Zicntr in FDT when emulating is possible

OpenSBI is capable of emulating time CSR on HARTs without a full Zicntr extension. Previously, we hardcoded Zicntr extension in the devicetree for these cores, like JH7110 in mainline Linux[1]. This doesn't reflect the hardware and may confuse pre-SBI bootloaders, like U-Boot running in M-Mode.

To solve the issue, let's register Zicntr in FDT dynamically for cores supporting it by SBI emulation, allowing pre-SBI stages to detect Zicntr availability reliably with riscv,isa-extensions.

[1]: https://elixir.bootlin.com/linux/v6.14-rc3/source/arch/riscv/boot/dts/starfive/jh7110.dtsi#L61

Yao Zi (2):
lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr
lib: utils: fdt: Claim Zicntr if time CSR emulation is possible

 include/sbi/sbi_hart.h    |  8 ++++++--
 lib/sbi/sbi_hart.c        | 30 ++++++++++++++++++++++--------
 lib/sbi/sbi_timer.c       |  2 +-
 lib/utils/fdt/fdt_fixup.c | 30 +++++++++++++++++++++++++++++-
 4 files changed, 58 insertions(+), 12 deletions(-)
Signature · 1 line
2.48.1