Skip to content

Conversation

msmttchr
Copy link
Contributor

@msmttchr msmttchr commented Jul 12, 2025

Update API to save and restore FPU context to address suspend to ram use case.

The API is updated as follow:

  • Existing APIs z_arm_save_fp_context and z_arm_restore_fp_context have been changed to always save/restore FPU context regardless of FPU_SHARING setting
  • The only use case of the original API has been updated to retain original behaviour

I also noticed by reading code and ARM documentation that the FPU context is preserved across threads by hardware on Cortex-M devices (via the FPCCR.ASPEN register field).

See also #90001, #92847 (comment)

Copy link
Contributor

@wearyzen wearyzen left a comment

Choose a reason for hiding this comment

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

Thank you for the change, could you please have a look at https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-message-guidelines and fix the commit message?

@valeriosetti valeriosetti removed their request for review July 14, 2025 11:12
@tomi-font tomi-font removed their request for review July 14, 2025 12:27
Added missing #include for used types uint32_t and bool
in file fpu.h

Signed-off-by: Michele Sardo <[email protected]>
@msmttchr
Copy link
Contributor Author

Thank you for the change, could you please have a look at https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-message-guidelines and fix the commit message?

Done.

msmttchr added 2 commits July 15, 2025 08:51
z_arm_save_fp_context and z_arm_restore_fp_context
save and restore fpu context regardless of the
CONFIG_FPU_SHARING setting.

This modification is required to support suspend to ram use cases
where save and restore of FPU state is needed to ensure proper bahaviour
after wakeup.

Signed-off-by: Michele Sardo <[email protected]>
Following changes to arch/arm/core/cortex_m/fpu.c,
the dependency on CONFIG_FPU_SHARING is moved into this file.

Signed-off-by: Michele Sardo <[email protected]>
Copy link

@nashif nashif merged commit 7bc1756 into zephyrproject-rtos:main Jul 19, 2025
30 checks passed
@msmttchr msmttchr deleted the fpu_save_restore branch October 4, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Architectures area: ARM ARM (32-bit) Architecture area: TF-M ARM Trusted Firmware-M (TF-M)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suspend to RAM feature not taking care of all cortex-m hw reinitializations

5 participants