From 655a37dfee35516dd4ba33549b834c0fb1c63940 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Fri, 11 Oct 2024 13:37:42 +0300 Subject: [PATCH] riscv/mpfs: Add a kludge solution for physical/logical CPU indexing problem There is an issue with MPFS when using SMP; it has 5 harts numbered from 0...4, where hart0 is a monitor core with less capabilities than harts1...3 which are application cores. Hart0 cannot be used by NuttX to run SMP, thus offset the physical hart index by -1 to get the correct idle stack for harts 1...3. This is a bad / kludge solution, what we need instead is a conversion function from logical to physical CPU index. --- arch/risc-v/src/mpfs/mpfs_head.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/mpfs/mpfs_head.S b/arch/risc-v/src/mpfs/mpfs_head.S index e6eb6fc8fb3d0..d4e168762f08b 100644 --- a/arch/risc-v/src/mpfs/mpfs_head.S +++ b/arch/risc-v/src/mpfs/mpfs_head.S @@ -184,7 +184,8 @@ __start: /* Set stack pointer to the idle thread stack */ - riscv_set_inital_sp MPFS_IDLESTACK_BASE, SMP_STACK_SIZE, a0 + addi a1, a0, -1 + riscv_set_inital_sp MPFS_IDLESTACK_BASE, SMP_STACK_SIZE, a1 /* Jump to __mpfs_start with mhartid in a0 */