-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Arch arm aarc32 wfi barriers #23436
Arch arm aarc32 wfi barriers #23436
Conversation
@stephanosio can you check - maybe this whole thing does not apply for Cortex-R |
All checks passed. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
Following ARM's recommendation, add memory and instruction synchronization barriers before invoking WFI in arch_cpu_idle. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
z_CpuIdleInit has been renamed to z_arm_cpu_idle_init, so we need to correct that function's name in the documentation of arch_cpu_atomic_idle. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
9983e3b
to
b5189a7
Compare
Rationale for
Rationale for
Rationale for
[1] ARM AN 321 |
Also note that adding |
@@ -73,6 +73,12 @@ SECTION_FUNC(TEXT, arch_cpu_idle) | |||
#error Unknown ARM architecture | |||
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */ | |||
|
|||
/* Synchronization barriers before calling WFI | |||
* DSB is recommented by architecture definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/recommented/recommended/
After a quick review of the ARM docs, I would say this is "required," not just "recommended."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is only about AARCH32; actually I had only Cortex-M in mind. I interpreted "should" as "recommended" not "required". But it does not really make a difference, since we enforce it here anyways :)
* ISB flushes the instruction pipeline after setting PRIMASK/BASEPRI | ||
*/ | ||
dsb | ||
isb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if ISB
is necessary/required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that in the context of #23511, CPSID
is guaranteed to be self synchronising and using ISB
is not required in this particular instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed about CPSID, but not when setting BASEPRI - this needs ISB if you want to make sure BASEPRI is zero-ed before wfi is executed.
/* No BASEPRI, call wfe directly (SEVONPEND set in z_CpuIdleInit()) */ | ||
/* No BASEPRI, call wfe directly | ||
* (SEVONPEND is set in z_arm_cpu_idle_init()) | ||
*/ | ||
wfe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, we should DSB
here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - can we take this in a separate discussion? This PR only about WFI. Let's fix one thing at a time :)
Covered now in #23511 |
No description provided.