Skip to content

Commit

Permalink
[nrf fromlist] arch: arm: cortex_m: pm_s2ram: fix system_off rv as rv…
Browse files Browse the repository at this point in the history
… of s2ram_suspend

The return value of the system_off call is overwritten by the the call to
pm_s2ram_mark_check_and_clear. As arch_pm_s2ram_suspend needs to specify
why system_off failed, we need to make sure the rv of system_off is moved
to a safe register before calling pm_s2ram_mark_check_and_clear and moved
to r0 als rv of arch_pm_s2ram_suspend when the suspend call exits.

Upstream PR #: 80642

Signed-off-by: Hessel van der Molen <hvandermolen@dexels.com>
(cherry picked from commit a93ae9d)
  • Loading branch information
HesselM authored and github-actions[bot] committed Nov 14, 2024
1 parent f786239 commit 3c52655
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch/arm/core/cortex_m/pm_s2ram.S
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ SECTION_FUNC(TEXT, arch_pm_s2ram_suspend)
* not successful (in r0 the return value).
*/

/* Move return value of system_off to callee-saved register. */
mov r4, r0

/*
* Reset the marking of suspend to RAM, return is ignored.
*/
mov r1, lr
bl pm_s2ram_mark_check_and_clear
mov lr, r1

/* Move system_off back to r0 as return value */
/* Move the stored return value of system_off back to r0,
* setting it as return value for this function.
*/
mov r0, r4

pop {r4-r12, lr}
Expand Down

0 comments on commit 3c52655

Please sign in to comment.