Skip to content

Commit 1b4dad4

Browse files
cwshugalak
authored andcommitted
arch: riscv: enable FPU of threads in unshared FP mode
In unshared FP mode, only 1 thread can use FPU but kernel doesn't know which one, so riscv arch would enable FPU of each thread. Signed-off-by: Jim Shu <[email protected]>
1 parent 6153719 commit 1b4dad4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/riscv/core/thread.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
8686
#endif /* CONFIG_PMP_STACK_GUARD */
8787

8888
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING)
89+
/* Shared FP mode: enable FPU of threads with K_FP_REGS. */
8990
if ((thread->base.user_options & K_FP_REGS) != 0) {
9091
stack_init->mstatus |= MSTATUS_FS_INIT;
9192
}
9293
stack_init->fp_state = 0;
94+
#elif defined(CONFIG_FPU)
95+
/* Unshared FP mode: enable FPU of each thread. */
96+
stack_init->mstatus |= MSTATUS_FS_INIT;
9397
#endif
9498

9599
stack_init->mepc = (ulong_t)z_thread_entry_wrapper;

0 commit comments

Comments
 (0)