Skip to content

Commit d849406

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 d849406

File tree

7 files changed

+40
-16
lines changed

7 files changed

+40
-16
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: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,34 +226,37 @@ enum task_state ipc_platform_do_cmd(struct ipc *ipc)
226226

227227
dbg_path_hot_stop_watching();
228228

229+
return SOF_TASK_STATE_COMPLETED;
230+
}
231+
232+
void ipc_platform_complete_cmd(struct ipc *ipc)
233+
{
234+
ARG_UNUSED(ipc);
235+
229236
if (ipc->task_mask & IPC_TASK_POWERDOWN ||
230237
ipc_get()->pm_prepare_D3) {
231238
#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.
239+
/* force device suspend */
240+
ipc_device_suspend_handler(NULL, ipc);
241+
/*
242+
* When context save is not enabled, this function will never return but if it is
243+
* enabled, this function will return during context restore
238244
*/
239245
cpu_disable_core(PLATFORM_PRIMARY_CORE_ID);
246+
247+
/* invoke the resume handler during context restore */
248+
ipc_device_resume_handler(NULL, ipc);
240249
#else
241250
/**
242251
* @note no return - memory will be
243252
* powered off and IPC sent.
244253
*/
245254
platform_pm_runtime_power_off();
246255
#endif /* CONFIG_PM */
256+
} else {
257+
intel_adsp_ipc_complete(INTEL_ADSP_IPC_HOST_DEV);
247258
}
248259

249-
return SOF_TASK_STATE_COMPLETED;
250-
}
251-
252-
void ipc_platform_complete_cmd(struct ipc *ipc)
253-
{
254-
ARG_UNUSED(ipc);
255-
intel_adsp_ipc_complete(INTEL_ADSP_IPC_HOST_DEV);
256-
257260
#if CONFIG_DEBUG_IPC_COUNTERS
258261
increment_ipc_processed_counter();
259262
#endif

zephyr/lib/cpu.c

Lines changed: 18 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,30 @@ 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();
279+
cpu_notify_state_exit(PM_STATE_SOFT_OFF);
267280
return;
281+
#endif
282+
}
283+
268284

269285
/* Broadcasting interrupts to other cores. */
270286
arch_sched_broadcast_ipi();

0 commit comments

Comments
 (0)