Skip to content

soc: intel: intel_adsp: Add sys_poweroff() #90821

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

Closed
wants to merge 3 commits into from

Conversation

ranj063
Copy link
Collaborator

@ranj063 ranj063 commented May 29, 2025

Add the sys_poweroff() implementation for Intel ADSPs. This will be invoked to when the host sends the IPC to transition the DSP to D3. Currently, the IPC response for D3 takes ~100ms (measured the ACE15 based MTL laptop) because we perform the actions for D3 in the idle context. Invoking sys_poweroff() from the IPC context will speed up the transition and reduce the transition time to ~1ms resulting in a 100-fold reduction compared to the current implementation.

}
#endif /* CONFIG_ADSP_POWER_DOWN_HPSRAM */
/* do power down - this function won't return */
power_down_cavs(true, uncache_to_cache(&hpsram_mask[0]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick, but it did confuse me for a minute: there's of course an eternal fight between &array[n] and array + n with the resolution often trying to understand the meaning of what the code is doing. In this case I don't think it's the address of the zeroth element that has to be passed to the function, but an address of the array instead. If it were the former, you wouldn't need the array and would just use a single element. So in this case I think power_down_cavs(true, uncache_to_cache(hpsram_mask)); actually makes more sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh this is the existing code that I've moved into a helper function. So for the sake of consistency I'd like to retain the original code.

@nashif
Copy link
Member

nashif commented May 31, 2025

@ranj063 need to resolve all those compliance issues and please take a look at sonarqube issues as well.

@ranj063
Copy link
Collaborator Author

ranj063 commented Jun 3, 2025

@ranj063 need to resolve all those compliance issues and please take a look at sonarqube issues as well.

@nashif sure. I'm getting the PR tested with the SOF change to verify functionality. I will fix the compliance issues soon after.

Copy link
Collaborator

@tmleman tmleman left a comment

Choose a reason for hiding this comment

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

The current implementation of the D0/D3 transition flow with CONFIG_ADSP_IMR_CONTEXT_SAVE enabled is causing exceptions when the system exits D3 state because it returns to sys_poweroff, which is marked as FUNC_NORETURN. This prevents the core from resuming its normal execution flow.

@ranj063 ranj063 force-pushed the sys_poweroff_d3 branch from 91ae7bf to 9472b3a Compare June 9, 2025 20:51
/* do power down - this function won't return */
power_down(true, IS_ENABLED(CONFIG_ADSP_POWER_DOWN_HPSRAM), true);
} else {
if (cpu == 0)
Copy link
Member

Choose a reason for hiding this comment

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

curly braces, this is not Linux :)

subsys/pm/pm.c Outdated
@@ -137,6 +137,8 @@ bool pm_state_force(uint8_t cpu, const struct pm_state_info *info)

key = k_spin_lock(&pm_forced_state_lock);
z_cpus_pm_forced_state[cpu] = info;
if (info->state == PM_STATE_SOFT_OFF && cpu == 0)
Copy link
Member

Choose a reason for hiding this comment

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

curly braces...

Add the sys_poweroff() implementation for Intel ADSPs. This will be
invoked to when the host sends the IPC to transition the DSP to D3.
Currently, the IPC response for D3 takes ~100ms (measured the ACE15 based
MTL laptop) because we perform the actions for D3 in the idle context.
Invoking sys_poweroff() from the IPC context will speed up the transition
and reduce the transition time to ~1ms resulting in a 100-fold reduction
compared to the current implementation.

Signed-off-by: Ranjani Sridharan <[email protected]>
@github-actions github-actions bot added the area: Base OS Base OS Library (lib/os) label Jun 23, 2025
This will be used for performing a context save before powering off the
system and the saved context will be restored upon a system resume.

Signed-off-by: Ranjani Sridharan <[email protected]>
*
* @kconfig{CONFIG_HIBERNATE} needs to be enabled to use this API.
*/
void sys_hibernate(void);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be discussed at an arch meeting :) We already have sys poweroff, and we do need more options regarding specific sleep modes, like the many various "off" modes out there, deep sleep, hibernate, system off, which all have various meanings to various SoCs.

Implement system hibernate for platforms that support IMR context
save/restore.

Signed-off-by: Ranjani Sridharan <[email protected]>
Copy link

@ranj063
Copy link
Collaborator Author

ranj063 commented Jun 26, 2025

Dropping this PR for now as dropping full context save/restore achieves the desired goal.

@ranj063 ranj063 closed this Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Power Management platform: Intel ADSP Intel Audio platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants