Skip to content

Commit

Permalink
arch: arm: cortex_m: cpu_idle: Add missing irq masking/unmasking
Browse files Browse the repository at this point in the history
This was missed during conversion from ASM to C.

Signed-off-by: Wilfried Chauveau <[email protected]>
  • Loading branch information
ithinuel authored and aescolar committed Apr 17, 2024
1 parent fb6ab56 commit b621802
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions arch/arm/core/cortex_m/cpu_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void arch_cpu_idle(void)
__disable_irq();

/*
* Set wake-up interrupt priority to the lowest and synchronise to
* Set wake-up interrupt priority to the lowest and synchronize to
* ensure that this is visible to the WFI instruction.
*/
__set_BASEPRI(0);
Expand All @@ -91,10 +91,6 @@ void arch_cpu_idle(void)
*/
#endif

/*
* Wait for all memory transactions to complete before entering low
* power state.
*/
SLEEP_IF_ALLOWED(__WFI);

__enable_irq();
Expand Down Expand Up @@ -122,11 +118,20 @@ void arch_cpu_atomic_idle(unsigned int key)
* and never touched again.
*/

/*
* Wait for all memory transactions to complete before entering low
* power state.
*/
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
/* No BASEPRI, call wfe directly. (SEVONPEND is set in z_arm_cpu_idle_init()) */
#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
/* unlock BASEPRI so wfe gets interrupted by incoming interrupts */
__set_BASEPRI(0);
__ISB();
#else
#error Unsupported architecture
#endif

SLEEP_IF_ALLOWED(__WFE);

arch_irq_unlock(key);
#if defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
__enable_irq();
#endif
}

0 comments on commit b621802

Please sign in to comment.