Skip to content

Commit

Permalink
RISCV: Support pm cpu ops for SMP
Browse files Browse the repository at this point in the history
Add pm cpu ops to call the platform specific implementations for
bringing up secondary cores.

Signed-off-by: Lingutla Chandrasekhar <[email protected]>
  • Loading branch information
quic-lingutla committed Oct 19, 2023
1 parent 9ceb8ce commit 19aaede
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions arch/riscv/core/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <ksched.h>
#include <zephyr/irq.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/drivers/pm_cpu_ops.h>

volatile struct {
arch_cpustart_t fn;
Expand All @@ -18,6 +19,8 @@ volatile struct {
volatile uintptr_t riscv_cpu_wake_flag;
volatile void *riscv_cpu_sp;

extern void __start(void);

void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
arch_cpustart_t fn, void *arg)
{
Expand All @@ -27,6 +30,13 @@ void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
riscv_cpu_sp = Z_KERNEL_STACK_BUFFER(stack) + sz;
riscv_cpu_wake_flag = _kernel.cpus[cpu_num].arch.hartid;

#ifdef CONFIG_PM_CPU_OPS
if (pm_cpu_on(cpu_num, (uintptr_t)&__start)) {
printk("Failed to boot secondary CPU %d\n", cpu_num);
return;
}
#endif

while (riscv_cpu_wake_flag != 0U) {
;
}
Expand Down

0 comments on commit 19aaede

Please sign in to comment.