Skip to content

Commit 5cbf6a8

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 5cbf6a8

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
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_POWEROFF=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_POWEROFF=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_POWEROFF=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: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,8 @@ 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.
238-
*/
232+
/* force device suspend */
233+
ipc_device_suspend_handler(NULL, ipc);
239234
cpu_disable_core(PLATFORM_PRIMARY_CORE_ID);
240235
#else
241236
/**

zephyr/lib/cpu.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ 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>
3536

3637
#if CONFIG_MULTICORE && CONFIG_SMP
3738

@@ -255,16 +256,20 @@ void cpu_disable_core(int id)
255256
tr_warn(&zephyr_tr, "core %d is already disabled", id);
256257
return;
257258
}
259+
258260
#if defined(CONFIG_PM)
259261
/* TODO: before requesting core shut down check if it's not actively used */
260262
if (!pm_state_force(id, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0})) {
261263
tr_err(&zephyr_tr, "failed to set PM_STATE_SOFT_OFF on core %d", id);
262264
return;
263265
}
264-
265-
/* Primary core will be turn off by the host after it enter SOFT_OFF state */
266-
if (cpu_is_primary(id))
267-
return;
266+
#if defined(CONFIG_POWEROFF)
267+
/* Primary core will be turned off by the host. This does not return. */
268+
if (cpu_is_primary(id)) {
269+
cpu_notify_state_entry(PM_STATE_SOFT_OFF);
270+
sys_poweroff();
271+
}
272+
#endif
268273

269274
/* Broadcasting interrupts to other cores. */
270275
arch_sched_broadcast_ipi();

0 commit comments

Comments
 (0)