diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-04-15 14:01:49 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-04-15 14:01:49 +0200 |
commit | 19df9d7b121f3a4faa6aa2516d00db13fa9c969d (patch) | |
tree | 46184a0db08212088bdd39c85d9fd3cf6cc5483c /common | |
parent | 18a358cc0a97ef3e06aa8f7d8fee365e31501e05 (diff) | |
parent | d552af08749fde61564b39f41256858ce32ca0d0 (diff) | |
download | barebox-19df9d7b121f3a4faa6aa2516d00db13fa9c969d.tar.gz |
Merge branch 'for-next/clk'
Diffstat (limited to 'common')
-rw-r--r-- | common/clock.c | 13 | ||||
-rw-r--r-- | common/console_common.c | 18 |
2 files changed, 14 insertions, 17 deletions
diff --git a/common/clock.c b/common/clock.c index fa90d1a457..b300e5798a 100644 --- a/common/clock.c +++ b/common/clock.c @@ -17,12 +17,6 @@ static uint64_t time_ns; -/* - * The first timestamp when the clocksource is registered. - * Useful for measuring the time spent in barebox. - */ -uint64_t time_beginning; - static uint64_t dummy_read(void) { static uint64_t dummy_counter; @@ -222,8 +216,13 @@ int init_clock(struct clocksource *cs) return ret; } + /* + * If clocksource is freerunning it might have been running for a while + * before barebox started, we only care about the time spent in barebox + * thus we must discard the clocksource cycles up to this exact moment: + */ + cs->cycle_last = cs->read() & cs->mask; current_clock = cs; - time_beginning = get_time_ns(); return 0; } diff --git a/common/console_common.c b/common/console_common.c index 3e07415723..4c1230464c 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -188,8 +188,8 @@ void log_print(unsigned flags, unsigned levels) unsigned long last = 0; list_for_each_entry(log, &barebox_logbuf, list) { - uint64_t diff = log->timestamp - time_beginning; - unsigned long difful; + uint64_t time_ns = log->timestamp; + unsigned long time; if (levels && !(levels & (1 << log->level))) continue; @@ -201,21 +201,19 @@ void log_print(unsigned flags, unsigned levels) if (flags & BAREBOX_LOG_PRINT_RAW) printf("<%i>", log->level); - do_div(diff, 1000); - difful = diff; - - if (!log->timestamp) - difful = 0; + /* convert ns to us */ + do_div(time_ns, 1000); + time = time_ns; if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME)) printf("["); if (flags & BAREBOX_LOG_PRINT_TIME) - printf("%10luus", difful); + printf("%10luus", time); if (flags & BAREBOX_LOG_DIFF_TIME) { - printf(" < %10luus", difful - last); - last = difful; + printf(" < %10luus", time - last); + last = time; } if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME)) |