Skip to content

arch: arm: cortex_m: Update APIs to save and restore FPU context #93057

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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 <msmttchr@gmail.com>
@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 <michele.sardo@st.com>
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 <michele.sardo@st.com>
Copy link

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.

4 participants