From 0a53d515e64d3f82c23f3fc7c84e5f630e1aa7a4 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Wed, 20 Feb 2019 20:14:25 +0800 Subject: [PATCH] lib: initcall: add system total boot time debug Change-Id: I3d4cd151acf699b25c9caab0452e40fddb6c31e1 Signed-off-by: Joseph Chen --- common/board_f.c | 2 -- lib/initcall.c | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index 58b72b01e6..888dc367ae 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -702,8 +702,6 @@ static int initf_bootstage(void) IS_ENABLED(CONFIG_BOOTSTAGE_STASH); int ret; - gd->sys_start_tick = get_ticks(); - ret = bootstage_init(!from_spl); if (ret) return ret; diff --git a/lib/initcall.c b/lib/initcall.c index 73c72cf1a5..6a625ad24e 100644 --- a/lib/initcall.c +++ b/lib/initcall.c @@ -10,7 +10,9 @@ DECLARE_GLOBAL_DATA_PTR; -#define SYS_TICKS_TO_US(ticks) ((ticks) / (COUNTER_FREQUENCY / 1000000)) +#define TICKS_TO_US(ticks) ((ticks) / (COUNTER_FREQUENCY / 1000000)) +#define US_TO_MS(ticks) ((ticks) / 1000) +#define US_TO_US(ticks) ((ticks) % 1000) #ifdef DEBUG static inline void call_get_ticks(ulong *ticks) { *ticks = get_ticks(); } @@ -21,7 +23,10 @@ static inline void call_get_ticks(ulong *ticks) { } int initcall_run_list(const init_fnc_t init_sequence[]) { const init_fnc_t *init_fnc_ptr; - __maybe_unused ulong start = 0, end = 0; + ulong start = 0, end = 0, sum = 0; + + if (!gd->sys_start_tick) + gd->sys_start_tick = get_ticks(); for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { unsigned long reloc_ofs = 0; @@ -40,8 +45,12 @@ int initcall_run_list(const init_fnc_t init_sequence[]) call_get_ticks(&start); ret = (*init_fnc_ptr)(); call_get_ticks(&end); - if (start != end) - debug("\t\t\t\t\t\t\t\t#%6ld us\n", SYS_TICKS_TO_US(end - start)); + + if (start != end) { + sum = TICKS_TO_US(end - gd->sys_start_tick); + debug("\t\t\t\t\t\t\t\t#%8ld us #%4ld.%3ld ms\n", + TICKS_TO_US(end - start), US_TO_MS(sum), US_TO_US(sum)); + } if (ret) { printf("initcall sequence %p failed at call %p (err=%d)\n", init_sequence,