From 2a4eefa55a32b778423ce7d66775b9230981afe5 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 12 May 2025 13:53:40 -0700 Subject: [PATCH 1/2] cpu: fix cpu_disable_core for primary core Nodify the logic for DSP D3 transition to invoke the sys_poweroff() call to speed up the transition by performing the suspend/disable actions in the IPC context instead of idle context. This results in a reduction of the D3 transition time from 100ms on the ACE1.5 based MTL laptop to ~1ms. Signed-off-by: Ranjani Sridharan --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + app/boards/intel_adsp_ace20_lnl.conf | 1 + app/boards/intel_adsp_ace30_ptl.conf | 1 + app/boards/intel_adsp_ace30_wcl.conf | 1 + app/boards/intel_adsp_cavs25.conf | 1 + src/ipc/ipc-zephyr.c | 11 +++++------ zephyr/lib/cpu.c | 19 +++++++++++++++++-- 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 26a9680e92f1..ff0a83fe69ad 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -100,6 +100,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 CONFIG_ADSP_IDLE_CLOCK_GATING=y CONFIG_ADSP_IMR_CONTEXT_SAVE=n CONFIG_PM=y +CONFIG_POWEROFF=y CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_RUNTIME=y CONFIG_PM_DEVICE_SYSTEM_MANAGED=y diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index a8888c9557d6..6bbb68513334 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -79,6 +79,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 CONFIG_ADSP_IDLE_CLOCK_GATING=y CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM=y +CONFIG_HIBERNATE=y CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_POWER_DOMAIN=y CONFIG_PM_DEVICE_RUNTIME=y diff --git a/app/boards/intel_adsp_ace30_ptl.conf b/app/boards/intel_adsp_ace30_ptl.conf index 7af406131d76..9e8cc107bdfa 100644 --- a/app/boards/intel_adsp_ace30_ptl.conf +++ b/app/boards/intel_adsp_ace30_ptl.conf @@ -78,6 +78,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM=y +CONFIG_HIBERNATE=y CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_RUNTIME=y CONFIG_PM_DEVICE_POWER_DOMAIN=y diff --git a/app/boards/intel_adsp_ace30_wcl.conf b/app/boards/intel_adsp_ace30_wcl.conf index c33c0e2127bb..3600564f6a3a 100644 --- a/app/boards/intel_adsp_ace30_wcl.conf +++ b/app/boards/intel_adsp_ace30_wcl.conf @@ -71,6 +71,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM=y +CONFIG_HIBERNATE=y CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_RUNTIME=y CONFIG_PM_DEVICE_POWER_DOMAIN=y diff --git a/app/boards/intel_adsp_cavs25.conf b/app/boards/intel_adsp_cavs25.conf index 72104567491a..9de2c0862f24 100644 --- a/app/boards/intel_adsp_cavs25.conf +++ b/app/boards/intel_adsp_cavs25.conf @@ -65,6 +65,7 @@ CONFIG_MM_DRV=y # Zephyr / power settings CONFIG_PM=y +CONFIG_POWEROFF=y CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_RUNTIME=y CONFIG_PM_POLICY_CUSTOM=y diff --git a/src/ipc/ipc-zephyr.c b/src/ipc/ipc-zephyr.c index 83763c6b3828..6b51620674d6 100644 --- a/src/ipc/ipc-zephyr.c +++ b/src/ipc/ipc-zephyr.c @@ -229,12 +229,11 @@ enum task_state ipc_platform_do_cmd(struct ipc *ipc) if (ipc->task_mask & IPC_TASK_POWERDOWN || ipc_get()->pm_prepare_D3) { #if defined(CONFIG_PM) - /** - * @note For primary core this function - * will only force set lower power state - * in power management settings. - * Core will enter D3 state after exit - * IPC thread during idle. + /* force device suspend */ + ipc_device_suspend_handler(NULL, ipc); + /* + * When context save is not enabled, this function will never return but if it is + * enabled, this function will return during context restore */ cpu_disable_core(PLATFORM_PRIMARY_CORE_ID); #else diff --git a/zephyr/lib/cpu.c b/zephyr/lib/cpu.c index 97ac6cf6060f..dfd77cd97339 100644 --- a/zephyr/lib/cpu.c +++ b/zephyr/lib/cpu.c @@ -32,6 +32,8 @@ static uint32_t mic_disable_status; #include #include #include +#include +#include #if CONFIG_MULTICORE && CONFIG_SMP @@ -255,6 +257,7 @@ void cpu_disable_core(int id) tr_warn(&zephyr_tr, "core %d is already disabled", id); return; } + #if defined(CONFIG_PM) /* TODO: before requesting core shut down check if it's not actively used */ if (!pm_state_force(id, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0})) { @@ -262,9 +265,21 @@ void cpu_disable_core(int id) return; } - /* Primary core will be turn off by the host after it enter SOFT_OFF state */ - if (cpu_is_primary(id)) + if (cpu_is_primary(id)) { + cpu_notify_state_entry(PM_STATE_SOFT_OFF); +#if defined(CONFIG_POWEROFF) + /* Primary core will be turned off by the host. This does not return. */ + sys_poweroff(); +#elif defined(CONFIG_HIBERNATE) + /* + * Primary core will be turned off by the host. This function returns during + * context restore. + */ + sys_hibernate(); return; +#endif + } + /* Broadcasting interrupts to other cores. */ arch_sched_broadcast_ipi(); From 9e1438302ef03e5adda4b7bf09cb3e9666acfc0f Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 9 Jun 2025 13:55:50 -0700 Subject: [PATCH 2/2] west.yml: Update zephyr to point to PR test Signed-off-by: Ranjani Sridharan --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 09d91a0a1453..8a39cf99ce8e 100644 --- a/west.yml +++ b/west.yml @@ -43,7 +43,7 @@ manifest: - name: zephyr repo-path: zephyr - revision: 8c6b2c8c88773810d64a47ed3b6206b7d6e8290f + revision: pull/90821/head remote: zephyrproject # Import some projects listed in zephyr/west.yml@revision