Skip to content

Commit 339e5f3

Browse files
committed
fix: wake RISC-V secondary idle IPIs and link integ percpu/SMP
- Kernel trampoline enables MIE so CPU1 idle takes CLINT MSIP resched IPIs - integ_kernel pulls percpu/klock/wcet + arch smp.c (fixes ctx_early_tricore)
1 parent 770617d commit 339e5f3

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

arch/riscv/ctx_switch.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ ulmk_arch_ctx_switch:
5757
.global _ulmk_thread_trampoline_m
5858
.type _ulmk_thread_trampoline_m, @function
5959
_ulmk_thread_trampoline_m:
60+
/*
61+
* Kernel threads (idle) inherit MIE=0 from the prior trap/syscall
62+
* path. Without enabling, secondary-hart idle never takes CLINT
63+
* MSIP IPIs and remote affinity threads stall forever.
64+
*/
65+
csrsi mstatus, 0x8 /* set MIE */
6066
mv a0, s0 /* entry — 1st arg to common entry */
6167
mv a1, s1 /* arg — 2nd arg to common entry */
6268
tail ulmk_user_thread_entry /* jump: common entry never returns */

kernel/kernel_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ void ulmk_kern_secondary_main(void)
224224
* online + secondary_mark_ready happen inside ulmk_sched_start() only
225225
* after current is set — otherwise a remote IPI can run dispatch with
226226
* current==NULL (drops the kick) and clear the soft mailbox forever.
227-
* Leave IE clear until the RFE into idle (PIE in the fabricated CSA).
227+
* Arch idle entry must accept IPIs (RISC-V kernel trampoline enables
228+
* MIE; TriCore idle CSA has PIE=1 on RFE).
228229
*/
229230
ulmk_printk("ulmk: CPU%u sched_start\n", (unsigned)cpu);
230231
(void)cpu;

tests/arch/riscv.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ARCH_LDFLAGS := -march=rv32imac_zicsr_zifencei -mabi=ilp32
2222
ARCH_KERNEL_SRCS := \
2323
$(ROOT)/arch/riscv/startup.S \
2424
$(ROOT)/arch/riscv/arch.c \
25+
$(ROOT)/arch/riscv/smp.c \
2526
$(ROOT)/arch/riscv/irq.c \
2627
$(ROOT)/arch/riscv/irq_clint.c \
2728
$(ROOT)/arch/riscv/irq_clic.c \

tests/arch/tricore.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ARCH_LDFLAGS := -mcpu=tc39xx
1818
ARCH_KERNEL_SRCS := \
1919
$(ROOT)/arch/tricore/startup.S \
2020
$(ROOT)/arch/tricore/arch.c \
21+
$(ROOT)/arch/tricore/smp.c \
2122
$(ROOT)/arch/tricore/ctx_switch.S \
2223
$(ROOT)/arch/tricore/vectors.S \
2324
$(ROOT)/boards/qemu_tc3xx/qemu_printk_hook.c

tests/integ_kernel.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ INTEG_KERNEL_SRCS ?= \
2929
$(ROOT)/kernel/init/init.c \
3030
$(ROOT)/kernel/kernel_main.c \
3131
$(ROOT)/kernel/printk/ulmk_printk.c \
32+
$(ROOT)/kernel/percpu/percpu.c \
33+
$(ROOT)/kernel/percpu/klock.c \
3234
$(ROOT)/kernel/sched/sched.c \
3335
$(ROOT)/kernel/sched/fifo_rt.c \
3436
$(ROOT)/kernel/sched/bitmap_rt.c \
@@ -39,6 +41,7 @@ INTEG_KERNEL_SRCS ?= \
3941
$(ROOT)/kernel/ipc/ep.c \
4042
$(ROOT)/kernel/notif/notif.c \
4143
$(ROOT)/kernel/syscall/syscall_router.c \
44+
$(ROOT)/kernel/syscall/syscall_wcet.c \
4245
$(INTEG_KERNEL_STUB) \
4346
$(INTEG_KERNEL_EXTRA_SRCS)
4447

0 commit comments

Comments
 (0)