From 07426a800c74b6884273719b71627e54e5266923 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 2 Feb 2024 18:43:44 +0000 Subject: [PATCH] intel_adsp/ace: power: Lock interruption when power gate fails In case the core is not power gated, waiti will restore intlevel. In this case we lock interruption after it. In the bug scenario, the host starts streaming and via SOF APIs, keeps a lock to prevent Zephyr from entering PM_STATE_RUNTIME_IDLE. During the test case, host removes this block and core0 is allowed to enter IDLE state. When core0 enters power gated state, interrrupts are left enabled (so the core can be woken up when something happens). This leaves a race where suitably timed interrupt will actually block entry to power gated state and k_cpu_idle() in power_gate_entry() will return. This is rare, but happens often enough that the relatively short test plan run on SOF pull-requests will trigger this case. Fixes #69807 Signed-off-by: Flavio Ceolin Signed-off-by: Anas Nashif --- soc/intel/intel_adsp/ace/power.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/soc/intel/intel_adsp/ace/power.c b/soc/intel/intel_adsp/ace/power.c index 2a5712d9cbed..b9f1ba9fbd98 100644 --- a/soc/intel/intel_adsp/ace/power.c +++ b/soc/intel/intel_adsp/ace/power.c @@ -176,6 +176,13 @@ void power_gate_entry(uint32_t core_id) soc_cpus_active[core_id] = false; sys_cache_data_flush_range(soc_cpus_active, sizeof(soc_cpus_active)); k_cpu_idle(); + + /* It is unlikely we get in here, but when this happens + * we need to lock interruptions again. + * + * @note Zephyr looks PS.INTLEVEL to check if interruptions are locked. + */ + (void)arch_irq_lock(); z_xt_ints_off(0xffffffff); }