[RFC 1/8] trace: correct handling of recursive call

Simon Glass sjg at chromium.org
Sat Dec 27 14:45:04 CET 2025


Hi Heinrich,

On Sat, 20 Dec 2025 at 18:59, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> __cyg_profile_func_enter() adds timer information to function traces.
>
> Commit 852d4dbd70ba ("trace: Detect an infinite loop") introduced a logic
> letting any recursive call to __cyg_profile_func_enter() deactivate
> tracing.
>
> This implies that a lot of the DM core and timer drivers functions need to
> be marked as `notrace`. This in not desirable as those functions are part
> of what we want to trace when not invoked by __cyg_profile_func_enter().
>
> A better approach than switching of tracing is to immediately leave
> __cyg_profile_func_enter() when reentered.
>
> Reported-by: Patrick Rudolph <patrick.rudolph at 9elements.com>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
>  lib/trace.c | 59 ++++++++++++++++++++++++-----------------------------
>  1 file changed, 27 insertions(+), 32 deletions(-)
>

Please see here:

https://docs.u-boot.org/en/latest/develop/trace.html#board-requirements

This really just papers over the problem you are having. You cannot
use driver model to obtain the timer as tracing starts before that.

So please instead do the small extra work of defining timer_get_us()
for your board.

Regards,
SImon


More information about the U-Boot mailing list