From 2cd49ca0fe9ca727a72ec6d7adebda4870f0f077 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 13 Jun 2022 22:34:48 -0700 Subject: [PATCH] pm: Fix possible assertion when resuming pm_system_resume() can be called from the idle thread with interruptions unmasked. In this situation, _current_cpu will call z_smp_cpu_mobile() that will return true and cause an assert. In this function we don't need to check if the current context can be preempted, we just need the information about which cpu is executing it. Signed-off-by: Flavio Ceolin --- subsys/pm/pm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/subsys/pm/pm.c b/subsys/pm/pm.c index 3731197f923..a8f8aa876aa 100644 --- a/subsys/pm/pm.c +++ b/subsys/pm/pm.c @@ -21,6 +21,9 @@ #include LOG_MODULE_REGISTER(pm, CONFIG_PM_LOG_LEVEL); +#define CURRENT_CPU \ + (COND_CODE_1(CONFIG_SMP, (arch_curr_cpu()->id), (_current_cpu->id))) + static ATOMIC_DEFINE(z_post_ops_required, CONFIG_MP_NUM_CPUS); static sys_slist_t pm_notifiers = SYS_SLIST_STATIC_INIT(&pm_notifiers); @@ -160,7 +163,7 @@ static inline void pm_state_notify(bool entering_state) void pm_system_resume(void) { - uint8_t id = _current_cpu->id; + uint8_t id = CURRENT_CPU; /* * This notification is called from the ISR of the event