zephyr: cpu: secondary core idle thread init

Idle thread should be initialize only when core it booting for the first
time. Doing this again would overwrite the kernel structs and the idle
thread stack.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This commit is contained in:
Tomasz Leman 2023-03-30 10:02:16 +02:00 committed by Kai Vehmanen
parent 4123f95353
commit a048951286
1 changed files with 7 additions and 1 deletions

View File

@ -79,7 +79,13 @@ int cpu_enable_core(int id)
return 0;
#if ZEPHYR_VERSION(3, 0, 99) <= ZEPHYR_VERSION_CODE
z_init_cpu(id);
/* During kernel initialization, the next pm state is set to ACTIVE. By checking this
* value, we determine if this is the first core boot, if not, we need to skip idle thread
* initialization. By reinitializing the idle thread, we would overwrite the kernel structs
* and the idle thread stack.
*/
if (pm_state_next_get(id)->state == PM_STATE_ACTIVE)
z_init_cpu(id);
#endif
atomic_clear(&start_flag);