Skip to content

Commit

Permalink
intel_adsp/ace: power: Restore PS after power gate
Browse files Browse the repository at this point in the history
We are arbitrarily setting a value to PS after power gates and
losing valid information like OWB, CALLINC and INTLEVEL.

We need to properly save/restore them to avoid possible wrong behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
  • Loading branch information
Flavio Ceolin committed Jan 24, 2024
1 parent 7eb0aa0 commit 35e1199
Showing 1 changed file with 8 additions and 0 deletions.
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");
}

#endif /* CONFIG_PM */

0 comments on commit 35e1199

Please sign in to comment.