lib: initcall: add system total boot time debug

Change-Id: I3d4cd151acf699b25c9caab0452e40fddb6c31e1
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-02-20 20:14:25 +08:00 committed by Jianhong Chen
parent 79d3f33751
commit 0a53d515e6
2 changed files with 13 additions and 6 deletions

View File

@ -702,8 +702,6 @@ static int initf_bootstage(void)
IS_ENABLED(CONFIG_BOOTSTAGE_STASH); IS_ENABLED(CONFIG_BOOTSTAGE_STASH);
int ret; int ret;
gd->sys_start_tick = get_ticks();
ret = bootstage_init(!from_spl); ret = bootstage_init(!from_spl);
if (ret) if (ret)
return ret; return ret;

View File

@ -10,7 +10,9 @@
DECLARE_GLOBAL_DATA_PTR; 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 #ifdef DEBUG
static inline void call_get_ticks(ulong *ticks) { *ticks = get_ticks(); } 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[]) int initcall_run_list(const init_fnc_t init_sequence[])
{ {
const init_fnc_t *init_fnc_ptr; 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) { for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
unsigned long reloc_ofs = 0; unsigned long reloc_ofs = 0;
@ -40,8 +45,12 @@ int initcall_run_list(const init_fnc_t init_sequence[])
call_get_ticks(&start); call_get_ticks(&start);
ret = (*init_fnc_ptr)(); ret = (*init_fnc_ptr)();
call_get_ticks(&end); 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) { if (ret) {
printf("initcall sequence %p failed at call %p (err=%d)\n", printf("initcall sequence %p failed at call %p (err=%d)\n",
init_sequence, init_sequence,