Skip to content

Commit 2a4eefa

Browse files
committed
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 <ranjani.sridharan@linux.intel.com>
1 parent 97f869c commit 2a4eefa

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
100100
CONFIG_ADSP_IDLE_CLOCK_GATING=y
101101
CONFIG_ADSP_IMR_CONTEXT_SAVE=n
102102
CONFIG_PM=y
103+
CONFIG_POWEROFF=y
103104
CONFIG_PM_DEVICE=y
104105
CONFIG_PM_DEVICE_RUNTIME=y
105106
CONFIG_PM_DEVICE_SYSTEM_MANAGED=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
7979
CONFIG_ADSP_IDLE_CLOCK_GATING=y
8080
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
8181
CONFIG_PM=y
82+
CONFIG_HIBERNATE=y
8283
CONFIG_PM_DEVICE=y
8384
CONFIG_PM_DEVICE_POWER_DOMAIN=y
8485
CONFIG_PM_DEVICE_RUNTIME=y

app/boards/intel_adsp_ace30_ptl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
7878
# Zephyr / power settings
7979
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
8080
CONFIG_PM=y
81+
CONFIG_HIBERNATE=y
8182
CONFIG_PM_DEVICE=y
8283
CONFIG_PM_DEVICE_RUNTIME=y
8384
CONFIG_PM_DEVICE_POWER_DOMAIN=y

app/boards/intel_adsp_ace30_wcl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
7171
# Zephyr / power settings
7272
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
7373
CONFIG_PM=y
74+
CONFIG_HIBERNATE=y
7475
CONFIG_PM_DEVICE=y
7576
CONFIG_PM_DEVICE_RUNTIME=y
7677
CONFIG_PM_DEVICE_POWER_DOMAIN=y

app/boards/intel_adsp_cavs25.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ CONFIG_MM_DRV=y
6565

6666
# Zephyr / power settings
6767
CONFIG_PM=y
68+
CONFIG_POWEROFF=y
6869
CONFIG_PM_DEVICE=y
6970
CONFIG_PM_DEVICE_RUNTIME=y
7071
CONFIG_PM_POLICY_CUSTOM=y

src/ipc/ipc-zephyr.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,11 @@ enum task_state ipc_platform_do_cmd(struct ipc *ipc)
229229
if (ipc->task_mask & IPC_TASK_POWERDOWN ||
230230
ipc_get()->pm_prepare_D3) {
231231
#if defined(CONFIG_PM)
232-
/**
233-
* @note For primary core this function
234-
* will only force set lower power state
235-
* in power management settings.
236-
* Core will enter D3 state after exit
237-
* IPC thread during idle.
232+
/* force device suspend */
233+
ipc_device_suspend_handler(NULL, ipc);
234+
/*
235+
* When context save is not enabled, this function will never return but if it is
236+
* enabled, this function will return during context restore
238237
*/
239238
cpu_disable_core(PLATFORM_PRIMARY_CORE_ID);
240239
#else

zephyr/lib/cpu.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ static uint32_t mic_disable_status;
3232
#include <zephyr/kernel/smp.h>
3333
#include <zephyr/device.h>
3434
#include <zephyr/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h>
35+
#include <zephyr/sys/poweroff.h>
36+
#include <zephyr/sys/hibernate.h>
3537

3638
#if CONFIG_MULTICORE && CONFIG_SMP
3739

@@ -255,16 +257,29 @@ void cpu_disable_core(int id)
255257
tr_warn(&zephyr_tr, "core %d is already disabled", id);
256258
return;
257259
}
260+
258261
#if defined(CONFIG_PM)
259262
/* TODO: before requesting core shut down check if it's not actively used */
260263
if (!pm_state_force(id, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0})) {
261264
tr_err(&zephyr_tr, "failed to set PM_STATE_SOFT_OFF on core %d", id);
262265
return;
263266
}
264267

265-
/* Primary core will be turn off by the host after it enter SOFT_OFF state */
266-
if (cpu_is_primary(id))
268+
if (cpu_is_primary(id)) {
269+
cpu_notify_state_entry(PM_STATE_SOFT_OFF);
270+
#if defined(CONFIG_POWEROFF)
271+
/* Primary core will be turned off by the host. This does not return. */
272+
sys_poweroff();
273+
#elif defined(CONFIG_HIBERNATE)
274+
/*
275+
* Primary core will be turned off by the host. This function returns during
276+
* context restore.
277+
*/
278+
sys_hibernate();
267279
return;
280+
#endif
281+
}
282+
268283

269284
/* Broadcasting interrupts to other cores. */
270285
arch_sched_broadcast_ipi();

0 commit comments

Comments
 (0)