Skip to content
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

Fix: Issue of SCB_DisableDCache(),SCB_InvalidateDCache(),SCB_CleanDCache() functions when compiling with -O0 #1350

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

Conversation

devcoons
Copy link

The variables 'ccsidr', 'sets' and 'ways' needs to be defined as 'register uint32_t' to avoid issues when using the -O0 flag.

These variables are used in the 'do/while' which invalidates/cleans the cache, however, by using -O0 flag (On STM32H7),
the compiler does not exclude them from the cache, so the system invalidates/cleans also them and the result is to end-up in an infinite loop.

…DCache(), SCB_CleanDCache() functions when compiling with -O0
@grasci-arm
Copy link
Collaborator

Can one of the admins verify this patch?

@JonatanAntoni
Copy link
Member

JonatanAntoni commented Oct 25, 2021

@grasci-arm test this please

@flit
Copy link
Contributor

flit commented Oct 25, 2021

Relying on the register keyword is not a solid solution. It is considered only a hint that compilers are allowed to interpret as they like. The only thing is guarantees from the C language specification is automatic duration, no linkage, and the variable's address cannot be taken (the latter being the only difference from an auto variable).

The only reliable solution is to rewrite these cache maintenance routines using inline assembly.

@JonatanAntoni JonatanAntoni added the CI Consider this for a CI build. label Oct 26, 2021
@Masmiseim36
Copy link
Contributor

This topic was already discussed in #620. I think there is a better solution then adding the register keyword which is obsolete with C++17. Compare #1426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Consider this for a CI build. CORE review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants