OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Register Zicntr in FDT when emulating is possible
@ 2025-05-03 10:57 Yao Zi
  2025-05-03 10:57 ` [PATCH v3 1/2] lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr Yao Zi
  2025-05-03 10:57 ` [PATCH v3 2/2] lib: utils: fdt: Claim Zicntr if time CSR emulation is possible Yao Zi
  0 siblings, 2 replies; 5+ messages in thread
From: Yao Zi @ 2025-05-03 10:57 UTC (permalink / raw)
  To: opensbi; +Cc: Yao Zi

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

Changed from v2
- Zicntr detection
  - Introduce SBI_HART_CSR_MAX
  - Make sbi_hart_features.csrs an array for flexibillity
- Link to v2: https://lore.kernel.org/all/20250418144758.2633-1-ziyao@disroot.org/

Changed from v1
- Zicntr detection
  - Introduce a bitmap to sbi_hart_features instead of using pseudo-
    extensions to represent availability of CSRs
  - Change possibly misleading abbreviation "RO" to "read-only" in
    commit message
- FDT fixup
  - Don't register zicntr to (legacy) devicetrees where harts don't come
    with a riscv,isa-extensions property
- Link to v1: https://lore.kernel.org/opensbi/20250225154103.5229-1-ziyao@disroot.org/

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    | 10 ++++++++++
 lib/sbi/sbi_hart.c        | 35 ++++++++++++++++++++++++++++-------
 lib/utils/fdt/fdt_fixup.c | 33 ++++++++++++++++++++++++++++++++-
 3 files changed, 70 insertions(+), 8 deletions(-)

-- 
2.49.0


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-05-07  8:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-03 10:57 [PATCH v3 0/2] Register Zicntr in FDT when emulating is possible Yao Zi
2025-05-03 10:57 ` [PATCH v3 1/2] lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr Yao Zi
2025-05-07  6:23   ` Anup Patel
2025-05-07  7:17     ` Yao Zi
2025-05-03 10:57 ` [PATCH v3 2/2] lib: utils: fdt: Claim Zicntr if time CSR emulation is possible Yao Zi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox