Skip to content

Commit cd536ae

Browse files
povergoinggalak
authored andcommitted
arch: arm64: Refine the assertion in arch_start_cpu
When SMP enabled, the primary core calls arch_start_cpu to start secondary cpus. There is an assertion checking the core mpid to make sure it is called by primary core. But the checking is bogus. After the first secondary core is brought up, arm64_cpu_boot_params.mpid will be changed, which will fail the assertion. The current solution restores the arm64_cpu_boot_params.mpid. However, using the arch_curr_cpu()->id == 0 as the assertion will be better. The _current_cpu->id will always fail assertion inside this macro (__ASSERT_NO_MSG(!z_smp_cpu_mobile()), so I use arch_curr_cpu()->id instead. Signed-off-by: Jaxson Han <[email protected]>
1 parent 6637c5b commit cd536ae

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

arch/arm64/core/smp.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
6060
uint64_t master_core_mpid;
6161

6262
/* Now it is on master core */
63+
__ASSERT(arch_curr_cpu()->id == 0, "");
6364
master_core_mpid = MPIDR_TO_CORE(GET_MPIDR());
64-
__ASSERT(arm64_cpu_boot_params.mpid == master_core_mpid, "");
6565

6666
cpu_count = ARRAY_SIZE(cpu_node_list);
6767
__ASSERT(cpu_count == CONFIG_MP_NUM_CPUS,
@@ -99,20 +99,13 @@ void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
9999
if (pm_cpu_on(cpu_mpid, (uint64_t)&__start)) {
100100
printk("Failed to boot secondary CPU core %d (MPID:%#llx)\n",
101101
cpu_num, cpu_mpid);
102-
/*
103-
* If pm_cpu_on failed on core cpu_mpid, Primary core also
104-
* should prepare for up next core
105-
*/
106-
arm64_cpu_boot_params.mpid = master_core_mpid;
107102
return;
108103
}
109104

110105
/* Wait secondary cores up, see z_arm64_secondary_start */
111106
while (arm64_cpu_boot_params.fn) {
112107
wfe();
113108
}
114-
/* Prepare for up next core */
115-
arm64_cpu_boot_params.mpid = master_core_mpid;
116109
printk("Secondary CPU core %d (MPID:%#llx) is up\n", cpu_num, cpu_mpid);
117110
}
118111

0 commit comments

Comments
 (0)