Skip to content
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

[v2.7] Disable IMR context save for MTL #8156

Closed

Conversation

mengdonglin
Copy link
Collaborator

@mengdonglin mengdonglin commented Sep 5, 2023

This is a follow up of PR #7994. We want to make sure it's safe to disable IMR context save for MTL and other platforms in sof v2.7

Please find more background info in #7994 (comment)

We also want to check if disabling IMR context save can avoid the FW boot failure:

zephyr/lib/cpu.c Outdated
@@ -148,7 +148,7 @@ int cpu_enable_core(int id)
* initialization. By reinitializing the idle thread, we would overwrite the kernel structs
* and the idle thread stack.
*/
if (!IS_ENABLED(CONFIG_ADSP_IMR_CONTEXT_SAVE) ||
if (!defined(CONFIG_ACE) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mengdonglin looks good. Can we also update the comment above to call out the difference between cavs and ACE?

Copy link
Collaborator Author

@mengdonglin mengdonglin Sep 6, 2023

Choose a reason for hiding this comment

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

@ranj063 Thanks for your review. I updated the comments in the code and also fix check on CONFIG_ACE

Copy link
Collaborator

@RanderWang RanderWang left a comment

Choose a reason for hiding this comment

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

It is a temporary solution for v2.7 and it is not fit to check hw platform in common framework. I can add dsp restore support on CAVS if I am free

zephyr/lib/cpu.c Outdated
*/
#if defined(CONFIG_ACE)
/* On MTL+ platforms, only run z_init_cpu() on boot, not when waking up from D3,
* regardless whether saving to IMR is enabled or not.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not how I understood the flow in a discussion yesterday. If on MTL+ IMR context saving isn't enabled, then waking up from D3 will be equivalent to the first boot, so the pm_state_next_get(id)->state == PM_STATE_ACTIVE condition will be true and z_init_cpu() will be run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is not how I understood the flow in a discussion yesterday. If on MTL+ IMR context saving isn't enabled, then waking up from D3 will be equivalent to the first boot, so the pm_state_next_get(id)->state == PM_STATE_ACTIVE condition will be true and z_init_cpu() will be run.

@tmleman Can you help clarify?
I also updated the PR according to your fa1572c for mtl-006.

Copy link
Contributor

Choose a reason for hiding this comment

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

On MTL z_init_cpu(id) is called for secondary cores only for the first init. As I wrote in the comment in the code:

During kernel initialization, the next pm state is set to ACTIVE.

If core goes from D0 to D3, next state is set to PM_STATE_SOFT_OFF. Thanks to this we know if the core is enabled for the first time.

CONFIG_ADSP_IMR_CONTEXT_SAVE changes the behavior of the primary core during D3. If disabled, every exit from D3 for primary core is like first boot. Therefore, if we re-enable the secondary core after that, the function z_init_cpu(id) will be called.

Only run z_init_cpu() on boot for MTL by replacing the check for
IMR_CONTEXT_SAVE with a check for ACE. Therefore,

- on MTL, only run z_init_cpu() on boot, not when waking up from D3,
  regardless whether saving to IMR is enabled or not.

- on other platforms, run z_init_cpu() both on boot and on waking up
  from D3.

The difference is caused by differnet Zephyr implementations between
MTL and other platforms.

Moreover, saving context to IMR is a feature for MTL only, not available
for other platorms.

Signed-off-by: Mengdong Lin <[email protected]>
Disable IMR context save on MTL by default, as it isn't a mandatory
feature for MTL.

The feature implementation is kept. So users can try this feature by
setting CONFIG_ADSP_IMR_CONTEXT_SAVE=y

Signed-off-by: Mengdong Lin <[email protected]>
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

I don't think the comments are quite right.

* different between MTL+ and other platforms.
*
* On MTL+ platforms, only run z_init_cpu() on boot, not when waking up from D3,
* regardless whether saving to IMR is enabled or not.
Copy link
Member

Choose a reason for hiding this comment

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

that seems wrong to me @mengdonglin

What is the difference between 'boot' and 'waking up from D3' if there is no context saved in IMR?

@kv2019i
Copy link
Collaborator

kv2019i commented Sep 6, 2023

So seems we are only discussng about the comments now. We do really need to get this in to keep to the SOF2.7 timeline.

Let me propose alternative wording based on comments so far.
#8170

@marc-hb
Copy link
Collaborator

marc-hb commented Sep 6, 2023

So seems we are only discussing about the comments now.

Ignoring... test failures?

@kv2019i
Copy link
Collaborator

kv2019i commented Sep 7, 2023

Merged via #8170

We'll follow-up to clarify the z_init_cpu() code (and comments) in mainline to get rid of platform specific checks on SOF side.

Sign up for free to 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.

8 participants