console,boot_state: Exclude printk() from reported times

Use monotonic timer to accumulate the time spent in
console code.

For bootblock and romstage, only stage total is reported.
For ramstage each boot_state is reported individually.

Change-Id: Id3998bab553ff803a93257a3f2c7bfea44c31729
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36574
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Kyösti Mälkki
2019-11-02 14:12:18 +02:00
committed by Patrick Georgi
parent 19825e8e37
commit 45ddb4344f
5 changed files with 67 additions and 0 deletions

View File

@ -63,6 +63,7 @@ static boot_state_t bs_payload_boot(void *arg);
struct boot_state_times {
int num_samples;
struct mono_time samples[MAX_TIME_SAMPLES];
long console_usecs[MAX_TIME_SAMPLES];
};
/* The prologue (BS_ON_ENTRY) and epilogue (BS_ON_EXIT) of a state can be
@ -241,6 +242,9 @@ static void bs_sample_time(struct boot_state *state)
{
struct mono_time *mt;
long console_usecs = console_time_get_and_reset();
state->times.console_usecs[state->times.num_samples] = console_usecs;
mt = &state->times.samples[state->times.num_samples];
timer_monotonic_get(mt);
state->times.num_samples++;
@ -257,6 +261,10 @@ static void bs_report_time(struct boot_state *state)
run_time = mono_time_diff_microseconds(&samples[1], &samples[2]);
exit_time = mono_time_diff_microseconds(&samples[2], &samples[3]);
entry_time -= state->times.console_usecs[1];
run_time -= state->times.console_usecs[2];
exit_time -= state->times.console_usecs[3];
/* Report with millisecond precision to reduce log diffs. */
entry_time = DIV_ROUND_CLOSEST(entry_time, USECS_PER_MSEC);
run_time = DIV_ROUND_CLOSEST(run_time, USECS_PER_MSEC);