[RFC PATCH v3 0/2] arch: riscv: cpu: Add callback to init each core

Green Wan green.wan at sifive.com
Sat Mar 27 03:18:28 CET 2021


Add a callback interface, riscv_hart_early_init() to perform riscv CPU 
hart-dependent configuration for each hart. riscv_hart_early_init() is
placed after stack of harts are initialized and before main boot hart is
picked up. Several conditions should be aware of or avoided are listed:

  - cannot access gd
    At the moment, gd hasn't initialized yet.

  - all operations in riscv_hart_early_init() should only affect core itself
    For example, the operations for board level should be moved to mach_xxx()
    or board_init_xxx() functions instead.

  - Common resource need protection if multicore
    Since all harts might enter riscv_hart_early_init() in parallel, common
    resource need a mechanism to handle race condition.

  - A dummy implementation is added in ./arch/riscv/cpu/cpu.c
    The implementation is declared with '__weak' and can be overridden.

Green Wan (2):
  arch: riscv: cpu: Add callback to init each core
  board: sifive: unmatched: clear feature disable CSR

 arch/riscv/cpu/cpu.c         | 15 +++++++++++++++
 arch/riscv/cpu/start.S       | 14 ++++++++++++++
 board/sifive/unmatched/spl.c | 16 ++++++++++++++++
 3 files changed, 45 insertions(+)

-- 
2.31.0



More information about the U-Boot mailing list