Hi Chris,
On 10/31/24 6:10 PM, Chris Kay wrote:
You don't often get email from chris.kay@arm.com. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification Hi Quentin,
Sorry for the delay, I’ve spent the last few hours looking into this.
Absolutely no worries, very thankful for the help :)
So, the semantics of the inline function specifier in C99 are as follows:
A function declared with an inline function specifier is an inline function. The function specifier may appear more than once; the behavior is the same as if it appeared only once. Making a function an inline function suggests that calls to the function be as fast as possible. The extent to which such suggestions are effective is implementation-defined.
To truly *enforce* inlining you need to use a GCC/Clang compiler extension like `__attribute__((always_inline))`.
In this specific case, I’m not quite sure I understand why the function is marked as `inline` at all - it is quite large. If the function is only ever used once then the compiler can (and almost always will) automatically inline it regardless of whether you use the `inline` hint, although because its address is taken elsewhere in the file the compiler must always generate a non-inlined version as well.
Additionally, the loop in the inline assembly does make it a bit harder for the compiler here – the compiler usually cannot inspect inline assembly very well, so it doesn’t automatically understand the internal infinite loop. I’ve posted a patch to resolve these issues in one swoop here: https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/33175
FWIW, there are other isb+wfi loops in that file, so maybe it's worth changing those as well? c.f. ddr_resume and rockchip_cpu_reset_early.
You're right, there probably isn't. I was thinking more along the lines of using the make_helpers/build_macros.mk helpers but that probably won't work either. Would propagating the TF_FLAGS be possible? Chris should probably weigh in on this.
I presume we’re talking about the RK3399 Cortex-M0 toolchain? The build macros are not set up to handle this sort of situation, I’m afraid. We can’t propagate `TF_CFLAGS` either because many of the flags are not compatible across the AArch64 and AArch32 toolchains, so it’s a manual process.
That's what I was afraid of :/
I have another question related to the INCBIN macro with clang+GCC that I will send in a few minutes as an answer to another mail, will add you in Cc if you don't mind.
Thanks! Quentin