diff options
author | Simon Glass <sjg@chromium.org> | 2011-12-20 10:39:07 -0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2012-01-05 19:19:05 -0800 |
commit | 86e63e0fe2ed12a5e2dcb0c8b3e4b6f074de558f (patch) | |
tree | 8b7ce2cc8524d351c9d647874f6d0ec10d0f6009 /common | |
parent | a7f64ee81c0b4701a0286be4ea8cd5e0474b5f9c (diff) |
Add bootstage accumulation
This adds a new type of boot timer, which records the time taken by
an operation, rather than marking the instant when it occurred. This
is useful to track the amount of time spent in a repeating activity
during boot.
To use this, call bootstage_start() at the start of the activity, then
bootstage_accum() at the end, to add this segment of time to the total.
You can call them (start first, then accum) as many times as you like.
BUG=chromium-os:22938
TEST=build and boot on Kaen
Change-Id: I3f1b536dc140c91a4a780188f6974dc37780f4f0
Reviewed-on: https://gerrit.chromium.org/gerrit/13370
Commit-Ready: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/bootstage.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/common/bootstage.c b/common/bootstage.c index a6f17ee2375..a89ce6d26bc 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -34,10 +34,11 @@ DECLARE_GLOBAL_DATA_PTR; struct bootstage_record { uint32_t time_us; + uint32_t start_us; const char *name; }; -static struct bootstage_record record[BOOTSTAGE_COUNT] = {{1, "avoid_bss"}}; +static struct bootstage_record record[BOOTSTAGE_COUNT] = {{1, 0, "avoid_bss"} }; uint32_t bootstage_mark(enum bootstage_id id, const char *name) { @@ -46,11 +47,31 @@ uint32_t bootstage_mark(enum bootstage_id id, const char *name) /* Only record the first event for each */ if (!rec->name) { rec->time_us = (uint32_t)timer_get_us(); + rec->start_us = 0; rec->name = name; } return rec->time_us; } +uint32_t bootstage_start(enum bootstage_id id, const char *name) +{ + struct bootstage_record *rec = &record[id]; + + rec->start_us = timer_get_us(); + rec->name = name; + return rec->start_us; +} + +uint32_t bootstage_accum(enum bootstage_id id) +{ + struct bootstage_record *rec = &record[id]; + uint32_t duration; + + duration = (uint32_t)timer_get_us() - rec->start_us; + rec->time_us += duration; + return duration; +} + static void print_time(unsigned long us_time) { char str[12], *s; @@ -69,8 +90,13 @@ static void print_time(unsigned long us_time) static uint32_t print_time_record(enum bootstage_id id, struct bootstage_record *rec, uint32_t prev) { - print_time(rec->time_us); - print_time(rec->time_us - prev); + if (prev == -1U) { + printf("%11s", ""); + print_time(rec->time_us); + } else { + print_time(rec->time_us); + print_time(rec->time_us - prev); + } if (rec->name) printf(" %s\n", rec->name); else @@ -187,10 +213,16 @@ void bootstage_report(void) qsort(record, ARRAY_SIZE(record), sizeof(*rec), h_compare_record); for (id = 0; id < BOOTSTAGE_COUNT; id++, rec++) { - if (rec->time_us != 0) + if (rec->time_us != 0 && !rec->start_us) prev = print_time_record(id, rec, prev); } + puts("\nAccumulated time:\n"); + for (id = 0, rec = record; id < BOOTSTAGE_COUNT; id++, rec++) { + if (rec->start_us) + prev = print_time_record(id, rec, -1); + } + add_bootstages_devicetree(working_fdt); if (flags & GD_FLG_SILENT) |