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

intel_adsp: Fix interruption locks in power management code #67863

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions soc/xtensa/intel_adsp/ace/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct core_state {
uint32_t excsave3;
uint32_t thread_ptr;
uint32_t intenable;
uint32_t ps;
uint32_t bctl;
};

Expand All @@ -127,6 +128,7 @@ struct lpsram_header {

static ALWAYS_INLINE void _save_core_context(uint32_t core_id)
{
core_desc[core_id].ps = XTENSA_RSR("PS");
core_desc[core_id].vecbase = XTENSA_RSR("VECBASE");
core_desc[core_id].excsave2 = XTENSA_RSR("EXCSAVE2");
core_desc[core_id].excsave3 = XTENSA_RSR("EXCSAVE3");
Expand All @@ -140,6 +142,7 @@ static ALWAYS_INLINE void _restore_core_context(void)
{
uint32_t core_id = arch_proc_id();

XTENSA_WSR("PS", core_desc[core_id].ps);
XTENSA_WSR("VECBASE", core_desc[core_id].vecbase);
XTENSA_WSR("EXCSAVE2", core_desc[core_id].excsave2);
XTENSA_WSR("EXCSAVE3", core_desc[core_id].excsave3);
Expand Down Expand Up @@ -404,6 +407,11 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
}

z_xt_ints_on(core_desc[cpu].intenable);

/* We don't have the key used to lock interruptions here.
* Just set PS.INTLEVEL to 0.
*/
__asm__ volatile ("rsil a2, 0");
Comment on lines +410 to +414
Copy link
Collaborator

Choose a reason for hiding this comment

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

This commit should be part of the previous one. Without restoring the PS value, PS.INTLEVEL == 0

Copy link
Member Author

Choose a reason for hiding this comment

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

I can squash them.

}

#endif /* CONFIG_PM */
8 changes: 7 additions & 1 deletion soc/xtensa/intel_adsp/cavs/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)
/* do power down - this function won't return */
power_down_cavs(true, uncache_to_cache(&hpsram_mask[0]));
} else {
k_cpu_idle();
k_cpu_atomic_idle(arch_irq_lock());
}
} else {
__ASSERT(false, "invalid argument - unsupported power state");
Expand All @@ -183,6 +183,12 @@ void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
} else {
__ASSERT(false, "invalid argument - unsupported power state");
}

/**
* We don't have the key used to lock interruptions here.
* Just set PS.INTLEVEL to 0.
*/
__asm__ volatile ("rsil a2, 0");
}
#endif /* CONFIG_PM */

Expand Down
Loading