-
Notifications
You must be signed in to change notification settings - Fork 349
[DNM]cpu: fix cpu_disable_core for primary core #10036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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
| File | Description |
|---|---|
| zephyr/lib/cpu.c | Updated core disable logic for primary core using sys_poweroff. |
| src/ipc/ipc-zephyr.c | Adjusted IPC shutdown sequence to trigger device suspend. |
| app/boards/intel_adsp_cavs25.conf | Enabled poweroff configuration. |
| app/boards/intel_adsp_ace30_wcl.conf | Enabled poweroff configuration. |
| app/boards/intel_adsp_ace30_ptl.conf | Enabled poweroff configuration. |
| app/boards/intel_adsp_ace20_lnl.conf | Enabled poweroff configuration. |
| app/boards/intel_adsp_ace15_mtpm.conf | Enabled poweroff configuration. |
zephyr/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(); |
Copilot
AI
May 29, 2025
There was a problem hiding this comment.
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.
| sys_poweroff(); | |
| sys_poweroff(); | |
| __builtin_unreachable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063 another good point.
| * IPC thread during idle. | ||
| */ | ||
| /* force device suspend */ | ||
| ipc_device_suspend_handler(NULL, ipc); |
Copilot
AI
May 29, 2025
There was a problem hiding this comment.
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.
| ipc_device_suspend_handler(NULL, ipc); | |
| int ret = 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 */ | |
| return SOF_TASK_STATE_ERROR; | |
| } |
There was a problem hiding this comment.
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 ?
|
@abonislawski pls take a look. |
2d0bf26 to
f3f65ba
Compare
Good direction and transition time reduction, AFAIK it will be more aligned with Intel reference now. |
tmleman
left a comment
There was a problem hiding this comment.
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.
zephyr/lib/cpu.c
Outdated
| if (cpu_is_primary(id)) { | ||
| cpu_notify_state_entry(PM_STATE_SOFT_OFF); | ||
| sys_poweroff(); | ||
| } |
There was a problem hiding this comment.
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;
}|
SOFCI TEST |
f3f65ba to
d9d66ab
Compare
|
SOFCI TEST |
d9d66ab to
2f856ff
Compare
2f856ff to
bade59d
Compare
|
SOFCI TEST |
bade59d to
b5fadfa
Compare
|
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>
b5fadfa to
9e14383
Compare
lgirdwood
left a comment
There was a problem hiding this comment.
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.
| * IPC thread during idle. | ||
| */ | ||
| /* force device suspend */ | ||
| ipc_device_suspend_handler(NULL, ipc); |
There was a problem hiding this comment.
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 ?
zephyr/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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063 another good point.
|
dropping this PR as #10028 reduces the D3 transition times to just about ~2ms without full context save/restore. |
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