Skip to content

[DNM]cpu: fix cpu_disable_core for primary core - #10036

Closed
ranj063 wants to merge 2 commits into
thesofproject:mainfrom
ranj063:fix/d3_transition
Closed

[DNM]cpu: fix cpu_disable_core for primary core#10036
ranj063 wants to merge 2 commits into
thesofproject:mainfrom
ranj063:fix/d3_transition

Conversation

@ranj063

Copy link
Copy Markdown
Collaborator

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.

Depends on zephyr PR: zephyrproject-rtos/zephyr#90821

CopilotAI review requested due to automatic review settings May 29, 2025 21:14

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the core disable logic to speed up the DSP D3 transition by performing suspend/disable actions in the IPC context and adjusts board configurations for proper poweroff functionality.

  • Updated cpu_disable_core() to call sys_poweroff() on the primary core.
  • Modified IPC powerdown sequence to suspend devices before disabling the core.
  • Added CONFIG_POWEROFF=y to multiple board configuration files.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
zephyr/lib/cpu.cUpdated core disable logic for primary core using sys_poweroff.
src/ipc/ipc-zephyr.cAdjusted IPC shutdown sequence to trigger device suspend.
app/boards/intel_adsp_cavs25.confEnabled poweroff configuration.
app/boards/intel_adsp_ace30_wcl.confEnabled poweroff configuration.
app/boards/intel_adsp_ace30_ptl.confEnabled poweroff configuration.
app/boards/intel_adsp_ace20_lnl.confEnabled poweroff configuration.
app/boards/intel_adsp_ace15_mtpm.confEnabled poweroff configuration.

Comment threadzephyr/lib/cpu.c Outdated
/* Primary core will be turned off by the host. This does not return. */
if (cpu_is_primary(id)) {
cpu_notify_state_entry(PM_STATE_SOFT_OFF);
sys_poweroff();

CopilotAIMay 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since sys_poweroff() is not expected to return, consider adding an unreachable marker (e.g., an assertion or a __builtin_unreachable()) immediately after the call to clarify the control flow in case it unexpectedly returns.

Suggested change
sys_poweroff();
sys_poweroff();
__builtin_unreachable();

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 another good point.

Comment threadsrc/ipc/ipc-zephyr.c
* IPC thread during idle.
*/
/* force device suspend */
ipc_device_suspend_handler(NULL, ipc);

CopilotAIMay 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of ipc_device_suspend_handler() is not checked. Consider verifying the result and handling any errors to ensure device suspend completes successfully.

Suggested change
ipc_device_suspend_handler(NULL, ipc);
intret=ipc_device_suspend_handler(NULL, ipc);
if (ret<0) {
LOG_ERR("Device suspend failed with error: %d", ret);
/* Handle error appropriately, e.g., abort further operations */
returnSOF_TASK_STATE_ERROR;
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 can we log here ?

@lgirdwood

Copy link
Copy Markdown
Member

@abonislawski pls take a look.

Comment threadapp/boards/intel_adsp_ace15_mtpm.conf
@ranj063
ranj063force-pushed the fix/d3_transition branch from 2d0bf26 to f3f65baCompareJune 3, 2025 18:23
@abonislawski

Copy link
Copy Markdown
Member

@abonislawski pls take a look.

Good direction and transition time reduction, AFAIK it will be more aligned with Intel reference now.

@tmlemantmleman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we can utilize POWEROFF when CONFIG_ADSP_IMR_CONTEXT_SAVE is disabled. This approach makes sense, as it enables us to skip unnecessary power management operations, thus reducing the D3 entry time. However, it is crucial to separate these two cases in the code.

Comment threadzephyr/lib/cpu.c Outdated
Comment on lines +224 to +271
if (cpu_is_primary(id)) {
cpu_notify_state_entry(PM_STATE_SOFT_OFF);
sys_poweroff();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow, in its current implementation, makes sense only in configurations with IMR context save disabled. The current context save implementation expects us to return to the function that was the entry point for power down. Therefore, in this case, we should return from sys_poweroff(). Consequently, we need to reinitialize all devices that were suspended and send a FW ready ipc, essentially implementing the following change:

--- a/zephyr/lib/cpu.c+++ b/zephyr/lib/cpu.c@@ -268,6 +268,8 @@ void cpu_disable_core(int id)
if (cpu_is_primary(id)) {
cpu_notify_state_entry(PM_STATE_SOFT_OFF);
sys_poweroff();
+ cpu_notify_state_exit(PM_STATE_SOFT_OFF);+ return;
}

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

SOFCI TEST

@ranj063
ranj063force-pushed the fix/d3_transition branch from f3f65ba to d9d66abCompareJune 9, 2025 20:43
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

SOFCI TEST

@ranj063
ranj063force-pushed the fix/d3_transition branch from d9d66ab to 2f856ffCompareJune 9, 2025 20:56
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

SOFCI TEST

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

SOFCI TEST

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>
test
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

@lgirdwoodlgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some GH actions failing due to disk usage over 14G limit. Unrelated to this PR.

Comment threadsrc/ipc/ipc-zephyr.c
* IPC thread during idle.
*/
/* force device suspend */
ipc_device_suspend_handler(NULL, ipc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 can we log here ?

Comment threadzephyr/lib/cpu.c Outdated
/* Primary core will be turned off by the host. This does not return. */
if (cpu_is_primary(id)) {
cpu_notify_state_entry(PM_STATE_SOFT_OFF);
sys_poweroff();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 another good point.

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

dropping this PR as #10028 reduces the D3 transition times to just about ~2ms without full context save/restore.

@ranj063ranj063 closed this Jun 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ranj063@lgirdwood@abonislawski@tmleman