Previously, we use AMO instructions to synchronize cores at start when
SMP is used, which requires Zaamo extension to present. This series
implements an alternative implementation of synchronization with LR/SC
instructions and add Kconfig options to use them, make it possible to
enable SMP on cores without Zaamo extension.

This is tested on both TH1520 Lichee Pi 4A board and QEMU. With QEMU,
building and testing looks lile,

        $ make qemu-riscv64_defconfig
        $ ./scripts/config -d CONFIG_RISCV_ISA_ZAAMO
        $ make
        $ qemu-system-riscv64 -M virt \
                -cpu rv64,a=off,zaamo=off,zawrs=off,zalrsc=on   \
                -nographic -bios u-boot-nodtb.bin -smp 8
        U-Boot 2025.10-rc1-00100-gc5bdc8820ee2-dirty (Aug 02 2025 - 09:16:21 
+0000)

        CPU:   riscv
        Model: riscv-virtio,qemu
        DRAM:  128 MiB
        using memory 0x86eb5000-0x876d5000 for malloc()
        Core:  34 devices, 13 uclasses, devicetree: board
        Flash: 32 MiB
        Loading Environment from nowhere... OK
        In:    serial,usbkbd
        Out:   serial,vidconsole
        Err:   serial,vidconsole
        No USB controllers found
        Net:   No ethernet found.

without this series, U-Boot won't run if Zaamo is disabled with
-cpu rv64,zaamo=off.

Yao Zi (2):
  riscv: Add Kconfig options to distinguish Zaamo and Zalrsc
  riscv: Add a Zalrsc-only alternative for synchronization in start.S

 arch/riscv/Kconfig             | 17 +++++++++++++++++
 arch/riscv/Makefile            |  7 ++++++-
 arch/riscv/cpu/start.S         | 26 +++++++++++++++++++++++++-
 configs/ibex-ast2700_defconfig |  3 ++-
 4 files changed, 50 insertions(+), 3 deletions(-)

-- 
2.50.1

Reply via email to