From 613594e68c8b26cf716b412d09be47be1d14fdbb Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Mon, 15 Feb 2021 22:19:51 -0800 Subject: [PATCH] soc/intel_adsp: Use the correct MP stack pointer The kernel passes the CPU's interrupt stack expected that it will start on that, so do it. Pass the initial stack pointer from the SOC layer in the variable "z_mp_stack_top" and set it in the assembly startup before calling z_mp_entry(). Signed-off-by: Andy Ross --- arch/xtensa/core/crt1.S | 7 ++++++- soc/xtensa/intel_adsp/common/soc_mp.c | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/xtensa/core/crt1.S b/arch/xtensa/core/crt1.S index b012f29197d..23ce498df9e 100644 --- a/arch/xtensa/core/crt1.S +++ b/arch/xtensa/core/crt1.S @@ -204,7 +204,12 @@ _start: rsr a3, PRID extui a3, a3, 0, 8 /* extract core ID */ beqz a3, 2f - CALL z_mp_entry + + /* Load our stack pointer set up for us by the SOC layer */ + movi a1, z_mp_stack_top + l32i a1, a1, 0 + + call4 z_mp_entry 2: #endif diff --git a/soc/xtensa/intel_adsp/common/soc_mp.c b/soc/xtensa/intel_adsp/common/soc_mp.c index 4b1d1e8fe1b..6984a4fa775 100644 --- a/soc/xtensa/intel_adsp/common/soc_mp.c +++ b/soc/xtensa/intel_adsp/common/soc_mp.c @@ -61,13 +61,14 @@ struct cpustart_rec { uint32_t cpu; arch_cpustart_t fn; - char *stack_top; void *arg; uint32_t vecbase; uint32_t alive; }; +char *z_mp_stack_top; + #ifdef CONFIG_KERNEL_COHERENCE /* Coherence guarantees that normal .data will be coherent and that it * won't overlap any cached memory. @@ -158,11 +159,12 @@ void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz, start_rec.cpu = cpu_num; start_rec.fn = fn; - start_rec.stack_top = Z_THREAD_STACK_BUFFER(stack) + sz; start_rec.arg = arg; start_rec.vecbase = vecbase; start_rec.alive = 0; + z_mp_stack_top = Z_THREAD_STACK_BUFFER(stack) + sz; + #ifdef CONFIG_IPM_CAVS_IDC idc = device_get_binding(DT_LABEL(DT_INST(0, intel_cavs_idc))); #endif