2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011, Google Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This module records the progress of boot and arbitrary commands, and
|
|
|
|
* permits accurate timestamping of each.
|
|
|
|
*/
|
|
|
|
|
2021-03-15 05:11:16 +00:00
|
|
|
#define LOG_CATEGORY LOGC_BOOT
|
|
|
|
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
#include <common.h>
|
2020-05-10 17:40:00 +00:00
|
|
|
#include <bootstage.h>
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2013-04-17 16:13:44 +00:00
|
|
|
#include <malloc.h>
|
2019-11-14 19:57:19 +00:00
|
|
|
#include <sort.h>
|
2019-10-21 23:26:49 +00:00
|
|
|
#include <spl.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2013-04-17 16:13:44 +00:00
|
|
|
#include <linux/compiler.h>
|
2019-10-21 23:26:49 +00:00
|
|
|
#include <linux/libfdt.h>
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
enum {
|
2017-09-06 01:49:49 +00:00
|
|
|
RECORD_COUNT = CONFIG_VAL(BOOTSTAGE_RECORD_COUNT),
|
2017-05-22 11:05:27 +00:00
|
|
|
};
|
|
|
|
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
struct bootstage_record {
|
|
|
|
ulong time_us;
|
2012-09-28 08:56:35 +00:00
|
|
|
uint32_t start_us;
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
const char *name;
|
|
|
|
int flags; /* see enum bootstage_flags */
|
|
|
|
enum bootstage_id id;
|
|
|
|
};
|
|
|
|
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data {
|
2017-05-22 11:05:27 +00:00
|
|
|
uint rec_count;
|
2017-05-22 11:05:25 +00:00
|
|
|
uint next_id;
|
2017-05-22 11:05:27 +00:00
|
|
|
struct bootstage_record record[RECORD_COUNT];
|
2017-05-22 11:05:25 +00:00
|
|
|
};
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
|
2012-09-28 08:56:38 +00:00
|
|
|
enum {
|
|
|
|
BOOTSTAGE_VERSION = 0,
|
|
|
|
BOOTSTAGE_MAGIC = 0xb00757a3,
|
2013-06-11 18:14:38 +00:00
|
|
|
BOOTSTAGE_DIGITS = 9,
|
2012-09-28 08:56:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bootstage_hdr {
|
2019-10-21 23:26:47 +00:00
|
|
|
u32 version; /* BOOTSTAGE_VERSION */
|
|
|
|
u32 count; /* Number of records */
|
|
|
|
u32 size; /* Total data size (non-zero if valid) */
|
|
|
|
u32 magic; /* Magic number */
|
|
|
|
u32 next_id; /* Next ID to use for bootstage */
|
2012-09-28 08:56:38 +00:00
|
|
|
};
|
|
|
|
|
2013-04-17 16:13:41 +00:00
|
|
|
int bootstage_relocate(void)
|
|
|
|
{
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
2013-04-17 16:13:41 +00:00
|
|
|
int i;
|
2019-10-21 23:26:50 +00:00
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
/* Figure out where to relocate the strings to */
|
|
|
|
ptr = (char *)(data + 1);
|
2013-04-17 16:13:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Duplicate all strings. They may point to an old location in the
|
|
|
|
* program .text section that can eventually get trashed.
|
|
|
|
*/
|
2017-05-22 11:05:27 +00:00
|
|
|
debug("Relocating %d records\n", data->rec_count);
|
2019-10-21 23:26:50 +00:00
|
|
|
for (i = 0; i < data->rec_count; i++) {
|
|
|
|
const char *from = data->record[i].name;
|
|
|
|
|
|
|
|
strcpy(ptr, from);
|
|
|
|
data->record[i].name = ptr;
|
|
|
|
ptr += strlen(ptr) + 1;
|
|
|
|
}
|
2013-04-17 16:13:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
struct bootstage_record *find_id(struct bootstage_data *data,
|
|
|
|
enum bootstage_id id)
|
|
|
|
{
|
|
|
|
struct bootstage_record *rec;
|
|
|
|
struct bootstage_record *end;
|
|
|
|
|
|
|
|
for (rec = data->record, end = rec + data->rec_count; rec < end;
|
|
|
|
rec++) {
|
|
|
|
if (rec->id == id)
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct bootstage_record *ensure_id(struct bootstage_data *data,
|
|
|
|
enum bootstage_id id)
|
|
|
|
{
|
|
|
|
struct bootstage_record *rec;
|
|
|
|
|
|
|
|
rec = find_id(data, id);
|
|
|
|
if (!rec && data->rec_count < RECORD_COUNT) {
|
|
|
|
rec = &data->record[data->rec_count++];
|
|
|
|
rec->id = id;
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
ulong bootstage_add_record(enum bootstage_id id, const char *name,
|
2012-09-28 08:56:35 +00:00
|
|
|
int flags, ulong mark)
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
{
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
struct bootstage_record *rec;
|
|
|
|
|
2019-04-08 19:20:45 +00:00
|
|
|
/*
|
|
|
|
* initf_bootstage() is called very early during boot but since hang()
|
|
|
|
* calls bootstage_error() we can be called before bootstage is set up.
|
|
|
|
* Add a check to avoid this.
|
|
|
|
*/
|
|
|
|
if (!data)
|
|
|
|
return mark;
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
if (flags & BOOTSTAGEF_ALLOC)
|
2017-05-22 11:05:25 +00:00
|
|
|
id = data->next_id++;
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
/* Only record the first event for each */
|
|
|
|
rec = find_id(data, id);
|
2021-03-15 05:11:16 +00:00
|
|
|
if (!rec) {
|
|
|
|
if (data->rec_count < RECORD_COUNT) {
|
|
|
|
rec = &data->record[data->rec_count++];
|
|
|
|
rec->time_us = mark;
|
|
|
|
rec->name = name;
|
|
|
|
rec->flags = flags;
|
|
|
|
rec->id = id;
|
|
|
|
} else {
|
|
|
|
log_warning("Bootstage space exhasuted\n");
|
|
|
|
}
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Tell the board about this progress */
|
|
|
|
show_boot_progress(flags & BOOTSTAGEF_ERROR ? -id : id);
|
2017-05-22 11:05:26 +00:00
|
|
|
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
return mark;
|
|
|
|
}
|
|
|
|
|
bootstage: Show func name for bootstage_mark/error
bootstage_mark() and bootstate_error() are not recording any name and in
report it is showing as id=<value>. That's not useful and it is better to
show function name which calls it.
That's why use macros with passing __func__ as recorded name for bootstage.
Origin report looks like this:
ZynqMP> bootstage report
Timer summary in microseconds (10 records):
Mark Elapsed Stage
0 0 reset
2,482,383 2,482,383 board_init_f
4,278,821 1,796,438 board_init_r
4,825,331 546,510 id=64
4,858,409 33,078 id=65
4,862,382 3,973 main_loop
4,921,713 59,331 usb_start
9,345,345 4,423,632 id=175
When this patch is applied.
ZynqMP> bootstage report
Timer summary in microseconds (31 records):
Mark Elapsed Stage
0 0 reset
2,465,624 2,465,624 board_init_f
4,278,628 1,813,004 board_init_r
4,825,139 546,511 eth_common_init
4,858,228 33,089 eth_initialize
4,862,201 3,973 main_loop
4,921,530 59,329 usb_start
8,885,334 3,963,804 cli_loop
Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-12 08:54:51 +00:00
|
|
|
ulong bootstage_error_name(enum bootstage_id id, const char *name)
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
{
|
bootstage: Show func name for bootstage_mark/error
bootstage_mark() and bootstate_error() are not recording any name and in
report it is showing as id=<value>. That's not useful and it is better to
show function name which calls it.
That's why use macros with passing __func__ as recorded name for bootstage.
Origin report looks like this:
ZynqMP> bootstage report
Timer summary in microseconds (10 records):
Mark Elapsed Stage
0 0 reset
2,482,383 2,482,383 board_init_f
4,278,821 1,796,438 board_init_r
4,825,331 546,510 id=64
4,858,409 33,078 id=65
4,862,382 3,973 main_loop
4,921,713 59,331 usb_start
9,345,345 4,423,632 id=175
When this patch is applied.
ZynqMP> bootstage report
Timer summary in microseconds (31 records):
Mark Elapsed Stage
0 0 reset
2,465,624 2,465,624 board_init_f
4,278,628 1,813,004 board_init_r
4,825,139 546,511 eth_common_init
4,858,228 33,089 eth_initialize
4,862,201 3,973 main_loop
4,921,530 59,329 usb_start
8,885,334 3,963,804 cli_loop
Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-12 08:54:51 +00:00
|
|
|
return bootstage_add_record(id, name, BOOTSTAGEF_ERROR,
|
2012-09-28 08:56:35 +00:00
|
|
|
timer_get_boot_us());
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ulong bootstage_mark_name(enum bootstage_id id, const char *name)
|
|
|
|
{
|
|
|
|
int flags = 0;
|
|
|
|
|
|
|
|
if (id == BOOTSTAGE_ID_ALLOC)
|
|
|
|
flags = BOOTSTAGEF_ALLOC;
|
2017-05-22 11:05:26 +00:00
|
|
|
|
2012-09-28 08:56:35 +00:00
|
|
|
return bootstage_add_record(id, name, flags, timer_get_boot_us());
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 16:13:44 +00:00
|
|
|
ulong bootstage_mark_code(const char *file, const char *func, int linenum)
|
|
|
|
{
|
|
|
|
char *str, *p;
|
|
|
|
__maybe_unused char *end;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
/* First work out the length we need to allocate */
|
|
|
|
if (linenum != -1)
|
|
|
|
len = 11;
|
|
|
|
if (func)
|
|
|
|
len += strlen(func);
|
|
|
|
if (file)
|
|
|
|
len += strlen(file);
|
|
|
|
|
|
|
|
str = malloc(len + 1);
|
|
|
|
p = str;
|
|
|
|
end = p + len;
|
|
|
|
if (file)
|
|
|
|
p += snprintf(p, end - p, "%s,", file);
|
|
|
|
if (linenum != -1)
|
|
|
|
p += snprintf(p, end - p, "%d", linenum);
|
|
|
|
if (func)
|
|
|
|
p += snprintf(p, end - p, ": %s", func);
|
|
|
|
|
|
|
|
return bootstage_mark_name(BOOTSTAGE_ID_ALLOC, str);
|
|
|
|
}
|
|
|
|
|
2012-09-28 08:56:36 +00:00
|
|
|
uint32_t bootstage_start(enum bootstage_id id, const char *name)
|
|
|
|
{
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
2017-05-22 11:05:27 +00:00
|
|
|
struct bootstage_record *rec = ensure_id(data, id);
|
|
|
|
ulong start_us = timer_get_boot_us();
|
2012-09-28 08:56:36 +00:00
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
if (rec) {
|
|
|
|
rec->start_us = start_us;
|
|
|
|
rec->name = name;
|
|
|
|
}
|
2017-05-22 11:05:26 +00:00
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
return start_us;
|
2012-09-28 08:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t bootstage_accum(enum bootstage_id id)
|
|
|
|
{
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
2017-05-22 11:05:27 +00:00
|
|
|
struct bootstage_record *rec = ensure_id(data, id);
|
2012-09-28 08:56:36 +00:00
|
|
|
uint32_t duration;
|
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
if (!rec)
|
|
|
|
return 0;
|
2012-09-28 08:56:36 +00:00
|
|
|
duration = (uint32_t)timer_get_boot_us() - rec->start_us;
|
|
|
|
rec->time_us += duration;
|
2017-05-22 11:05:26 +00:00
|
|
|
|
2012-09-28 08:56:36 +00:00
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
2012-09-28 08:56:37 +00:00
|
|
|
/**
|
|
|
|
* Get a record name as a printable string
|
|
|
|
*
|
|
|
|
* @param buf Buffer to put name if needed
|
|
|
|
* @param len Length of buffer
|
|
|
|
* @param rec Boot stage record to get the name from
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: pointer to name, either from the record or pointing to buf.
|
2012-09-28 08:56:37 +00:00
|
|
|
*/
|
|
|
|
static const char *get_record_name(char *buf, int len,
|
2017-05-22 11:05:34 +00:00
|
|
|
const struct bootstage_record *rec)
|
2012-09-28 08:56:37 +00:00
|
|
|
{
|
|
|
|
if (rec->name)
|
|
|
|
return rec->name;
|
|
|
|
else if (rec->id >= BOOTSTAGE_ID_USER)
|
|
|
|
snprintf(buf, len, "user_%d", rec->id - BOOTSTAGE_ID_USER);
|
|
|
|
else
|
|
|
|
snprintf(buf, len, "id=%d", rec->id);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2017-05-22 11:05:25 +00:00
|
|
|
static uint32_t print_time_record(struct bootstage_record *rec, uint32_t prev)
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
{
|
2012-09-28 08:56:37 +00:00
|
|
|
char buf[20];
|
|
|
|
|
2012-09-28 08:56:36 +00:00
|
|
|
if (prev == -1U) {
|
|
|
|
printf("%11s", "");
|
2013-06-11 18:14:38 +00:00
|
|
|
print_grouped_ull(rec->time_us, BOOTSTAGE_DIGITS);
|
2012-09-28 08:56:36 +00:00
|
|
|
} else {
|
2013-06-11 18:14:38 +00:00
|
|
|
print_grouped_ull(rec->time_us, BOOTSTAGE_DIGITS);
|
|
|
|
print_grouped_ull(rec->time_us - prev, BOOTSTAGE_DIGITS);
|
2012-09-28 08:56:36 +00:00
|
|
|
}
|
2012-09-28 08:56:37 +00:00
|
|
|
printf(" %s\n", get_record_name(buf, sizeof(buf), rec));
|
|
|
|
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
return rec->time_us;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int h_compare_record(const void *r1, const void *r2)
|
|
|
|
{
|
|
|
|
const struct bootstage_record *rec1 = r1, *rec2 = r2;
|
|
|
|
|
|
|
|
return rec1->time_us > rec2->time_us ? 1 : -1;
|
|
|
|
}
|
|
|
|
|
2012-09-28 08:56:37 +00:00
|
|
|
#ifdef CONFIG_OF_LIBFDT
|
|
|
|
/**
|
|
|
|
* Add all bootstage timings to a device tree.
|
|
|
|
*
|
|
|
|
* @param blob Device tree blob
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 on success, != 0 on failure.
|
2012-09-28 08:56:37 +00:00
|
|
|
*/
|
|
|
|
static int add_bootstages_devicetree(struct fdt_header *blob)
|
|
|
|
{
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
2012-09-28 08:56:37 +00:00
|
|
|
int bootstage;
|
|
|
|
char buf[20];
|
2017-05-22 11:05:27 +00:00
|
|
|
int recnum;
|
2012-09-28 08:56:37 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!blob)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the node for bootstage.
|
|
|
|
* The address of flat device tree is set up by the command bootm.
|
|
|
|
*/
|
|
|
|
bootstage = fdt_add_subnode(blob, 0, "bootstage");
|
|
|
|
if (bootstage < 0)
|
2017-05-22 11:05:33 +00:00
|
|
|
return -EINVAL;
|
2012-09-28 08:56:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Insert the timings to the device tree in the reverse order so
|
|
|
|
* that they can be printed in the Linux kernel in the right order.
|
|
|
|
*/
|
2017-05-22 11:05:27 +00:00
|
|
|
for (recnum = data->rec_count - 1, i = 0; recnum >= 0; recnum--, i++) {
|
|
|
|
struct bootstage_record *rec = &data->record[recnum];
|
2012-09-28 08:56:37 +00:00
|
|
|
int node;
|
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
if (rec->id != BOOTSTAGE_ID_AWAKE && rec->time_us == 0)
|
2012-09-28 08:56:37 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
node = fdt_add_subnode(blob, bootstage, simple_itoa(i));
|
|
|
|
if (node < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* add properties to the node. */
|
|
|
|
if (fdt_setprop_string(blob, node, "name",
|
2017-05-22 11:05:27 +00:00
|
|
|
get_record_name(buf, sizeof(buf), rec)))
|
2017-05-22 11:05:33 +00:00
|
|
|
return -EINVAL;
|
2012-09-28 08:56:37 +00:00
|
|
|
|
|
|
|
/* Check if this is a 'mark' or 'accum' record */
|
|
|
|
if (fdt_setprop_cell(blob, node,
|
|
|
|
rec->start_us ? "accum" : "mark",
|
|
|
|
rec->time_us))
|
2017-05-22 11:05:33 +00:00
|
|
|
return -EINVAL;
|
2012-09-28 08:56:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bootstage_fdt_add_report(void)
|
|
|
|
{
|
|
|
|
if (add_bootstages_devicetree(working_fdt))
|
|
|
|
puts("bootstage: Failed to add to device tree\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
void bootstage_report(void)
|
|
|
|
{
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
|
|
|
struct bootstage_record *rec = data->record;
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
uint32_t prev;
|
2017-05-22 11:05:27 +00:00
|
|
|
int i;
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
printf("Timer summary in microseconds (%d records):\n",
|
|
|
|
data->rec_count);
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
printf("%11s%11s %s\n", "Mark", "Elapsed", "Stage");
|
|
|
|
|
2017-05-22 11:05:25 +00:00
|
|
|
prev = print_time_record(rec, 0);
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
|
|
|
|
/* Sort records by increasing time */
|
2017-05-22 11:05:27 +00:00
|
|
|
qsort(data->record, data->rec_count, sizeof(*rec), h_compare_record);
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
for (i = 1, rec++; i < data->rec_count; i++, rec++) {
|
|
|
|
if (rec->id && !rec->start_us)
|
2017-05-22 11:05:25 +00:00
|
|
|
prev = print_time_record(rec, prev);
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
}
|
2017-05-22 11:05:27 +00:00
|
|
|
if (data->rec_count > RECORD_COUNT)
|
|
|
|
printf("Overflowed internal boot id table by %d entries\n"
|
2021-02-03 13:00:49 +00:00
|
|
|
"Please increase CONFIG_(SPL_TPL_)BOOTSTAGE_RECORD_COUNT\n",
|
2017-05-22 11:05:27 +00:00
|
|
|
data->rec_count - RECORD_COUNT);
|
2012-09-28 08:56:36 +00:00
|
|
|
|
|
|
|
puts("\nAccumulated time:\n");
|
2017-05-22 11:05:27 +00:00
|
|
|
for (i = 0, rec = data->record; i < data->rec_count; i++, rec++) {
|
2012-09-28 08:56:36 +00:00
|
|
|
if (rec->start_us)
|
2017-05-22 11:05:25 +00:00
|
|
|
prev = print_time_record(rec, -1);
|
2012-09-28 08:56:36 +00:00
|
|
|
}
|
bootstage: Implement core microsecond boot time measurement
This defines the basics of a new boot time measurement feature. This allows
logging of very accurate time measurements as the boot proceeds, by using
an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file.
Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be
printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to
renumber them all.
Timer summary in microseconds:
Mark Elapsed Stage
0 0 reset
205,000 205,000 board_init_f
6,053,000 5,848,000 bootm_start
6,053,000 0 id=1
6,058,000 5,000 id=101
6,058,000 0 id=100
6,061,000 3,000 id=103
6,064,000 3,000 id=104
6,093,000 29,000 id=107
6,093,000 0 id=106
6,093,000 0 id=105
6,093,000 0 id=108
7,089,000 996,000 id=7
7,089,000 0 id=15
7,089,000 0 id=8
7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass <sjg@chromium.org>
2012-02-13 13:51:19 +00:00
|
|
|
}
|
2012-04-05 12:05:17 +00:00
|
|
|
|
2012-09-28 08:56:38 +00:00
|
|
|
/**
|
|
|
|
* Append data to a memory buffer
|
|
|
|
*
|
|
|
|
* Write data to the buffer if there is space. Whether there is space or not,
|
|
|
|
* the buffer pointer is incremented.
|
|
|
|
*
|
|
|
|
* @param ptrp Pointer to buffer, updated by this function
|
|
|
|
* @param end Pointer to end of buffer
|
|
|
|
* @param data Data to write to buffer
|
|
|
|
* @param size Size of data
|
|
|
|
*/
|
|
|
|
static void append_data(char **ptrp, char *end, const void *data, int size)
|
|
|
|
{
|
|
|
|
char *ptr = *ptrp;
|
|
|
|
|
|
|
|
*ptrp += size;
|
|
|
|
if (*ptrp > end)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy(ptr, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
int bootstage_stash(void *base, int size)
|
|
|
|
{
|
2017-05-22 11:05:34 +00:00
|
|
|
const struct bootstage_data *data = gd->bootstage;
|
2012-09-28 08:56:38 +00:00
|
|
|
struct bootstage_hdr *hdr = (struct bootstage_hdr *)base;
|
2017-05-22 11:05:34 +00:00
|
|
|
const struct bootstage_record *rec;
|
2012-09-28 08:56:38 +00:00
|
|
|
char buf[20];
|
|
|
|
char *ptr = base, *end = ptr + size;
|
2017-05-22 11:05:27 +00:00
|
|
|
int i;
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
if (hdr + 1 > (struct bootstage_hdr *)end) {
|
|
|
|
debug("%s: Not enough space for bootstage hdr\n", __func__);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -ENOSPC;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write an arbitrary version number */
|
|
|
|
hdr->version = BOOTSTAGE_VERSION;
|
|
|
|
|
2019-10-21 23:26:48 +00:00
|
|
|
hdr->count = data->rec_count;
|
2012-09-28 08:56:38 +00:00
|
|
|
hdr->size = 0;
|
|
|
|
hdr->magic = BOOTSTAGE_MAGIC;
|
2019-10-21 23:26:47 +00:00
|
|
|
hdr->next_id = data->next_id;
|
2012-09-28 08:56:38 +00:00
|
|
|
ptr += sizeof(*hdr);
|
|
|
|
|
|
|
|
/* Write the records, silently stopping when we run out of space */
|
2019-10-21 23:26:48 +00:00
|
|
|
for (rec = data->record, i = 0; i < data->rec_count; i++, rec++)
|
2017-05-22 11:05:28 +00:00
|
|
|
append_data(&ptr, end, rec, sizeof(*rec));
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
/* Write the name strings */
|
2017-05-22 11:05:27 +00:00
|
|
|
for (rec = data->record, i = 0; i < data->rec_count; i++, rec++) {
|
2017-05-22 11:05:28 +00:00
|
|
|
const char *name;
|
2012-09-28 08:56:38 +00:00
|
|
|
|
2017-05-22 11:05:28 +00:00
|
|
|
name = get_record_name(buf, sizeof(buf), rec);
|
|
|
|
append_data(&ptr, end, name, strlen(name) + 1);
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for buffer overflow */
|
|
|
|
if (ptr > end) {
|
|
|
|
debug("%s: Not enough space for bootstage stash\n", __func__);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -ENOSPC;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update total data size */
|
|
|
|
hdr->size = ptr - (char *)base;
|
2017-05-22 11:05:29 +00:00
|
|
|
debug("Stashed %d records\n", hdr->count);
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-22 11:05:34 +00:00
|
|
|
int bootstage_unstash(const void *base, int size)
|
2012-09-28 08:56:38 +00:00
|
|
|
{
|
2017-05-22 11:05:34 +00:00
|
|
|
const struct bootstage_hdr *hdr = (struct bootstage_hdr *)base;
|
2017-05-22 11:05:25 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
2017-05-22 11:05:34 +00:00
|
|
|
const char *ptr = base, *end = ptr + size;
|
2012-09-28 08:56:38 +00:00
|
|
|
struct bootstage_record *rec;
|
|
|
|
uint rec_size;
|
2017-05-22 11:05:27 +00:00
|
|
|
int i;
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
if (size == -1)
|
|
|
|
end = (char *)(~(uintptr_t)0);
|
|
|
|
|
|
|
|
if (hdr + 1 > (struct bootstage_hdr *)end) {
|
|
|
|
debug("%s: Not enough space for bootstage hdr\n", __func__);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -EPERM;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr->magic != BOOTSTAGE_MAGIC) {
|
|
|
|
debug("%s: Invalid bootstage magic\n", __func__);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -ENOENT;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ptr + hdr->size > end) {
|
|
|
|
debug("%s: Bootstage data runs past buffer end\n", __func__);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -ENOSPC;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr->count * sizeof(*rec) > hdr->size) {
|
2013-06-11 18:14:37 +00:00
|
|
|
debug("%s: Bootstage has %d records needing %lu bytes, but "
|
2012-09-28 08:56:38 +00:00
|
|
|
"only %d bytes is available\n", __func__, hdr->count,
|
2013-06-11 18:14:37 +00:00
|
|
|
(ulong)hdr->count * sizeof(*rec), hdr->size);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -ENOSPC;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr->version != BOOTSTAGE_VERSION) {
|
|
|
|
debug("%s: Bootstage data version %#0x unrecognised\n",
|
|
|
|
__func__, hdr->version);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -EINVAL;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
2017-05-22 11:05:27 +00:00
|
|
|
if (data->rec_count + hdr->count > RECORD_COUNT) {
|
2012-09-28 08:56:38 +00:00
|
|
|
debug("%s: Bootstage has %d records, we have space for %d\n"
|
2017-09-06 01:49:49 +00:00
|
|
|
"Please increase CONFIG_(SPL_)BOOTSTAGE_RECORD_COUNT\n",
|
2017-05-22 11:05:27 +00:00
|
|
|
__func__, hdr->count, RECORD_COUNT - data->rec_count);
|
2017-05-22 11:05:33 +00:00
|
|
|
return -ENOSPC;
|
2012-09-28 08:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ptr += sizeof(*hdr);
|
|
|
|
|
|
|
|
/* Read the records */
|
2017-05-22 11:05:25 +00:00
|
|
|
rec_size = hdr->count * sizeof(*data->record);
|
2017-05-22 11:05:27 +00:00
|
|
|
memcpy(data->record + data->rec_count, ptr, rec_size);
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
/* Read the name strings */
|
|
|
|
ptr += rec_size;
|
2017-05-22 11:05:27 +00:00
|
|
|
for (rec = data->record + data->next_id, i = 0; i < hdr->count;
|
|
|
|
i++, rec++) {
|
2012-09-28 08:56:38 +00:00
|
|
|
rec->name = ptr;
|
2019-10-21 23:26:49 +00:00
|
|
|
if (spl_phase() == PHASE_SPL)
|
|
|
|
rec->name = strdup(ptr);
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
/* Assume no data corruption here */
|
|
|
|
ptr += strlen(ptr) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the records as read */
|
2017-05-22 11:05:27 +00:00
|
|
|
data->rec_count += hdr->count;
|
2019-10-21 23:26:47 +00:00
|
|
|
data->next_id = hdr->next_id;
|
2017-05-22 11:05:29 +00:00
|
|
|
debug("Unstashed %d records\n", hdr->count);
|
2012-09-28 08:56:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-22 11:05:25 +00:00
|
|
|
|
2023-09-26 14:14:32 +00:00
|
|
|
int _bootstage_stash_default(void)
|
|
|
|
{
|
|
|
|
return bootstage_stash(map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, 0),
|
|
|
|
CONFIG_BOOTSTAGE_STASH_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _bootstage_unstash_default(void)
|
|
|
|
{
|
|
|
|
const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
|
|
|
|
CONFIG_BOOTSTAGE_STASH_SIZE);
|
|
|
|
|
|
|
|
return bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
|
|
|
|
}
|
|
|
|
|
2017-05-22 11:05:30 +00:00
|
|
|
int bootstage_get_size(void)
|
|
|
|
{
|
2019-10-21 23:26:50 +00:00
|
|
|
struct bootstage_data *data = gd->bootstage;
|
|
|
|
struct bootstage_record *rec;
|
|
|
|
int size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
size = sizeof(struct bootstage_data);
|
|
|
|
for (rec = data->record, i = 0; i < data->rec_count;
|
|
|
|
i++, rec++)
|
|
|
|
size += strlen(rec->name) + 1;
|
|
|
|
|
|
|
|
return size;
|
2017-05-22 11:05:30 +00:00
|
|
|
}
|
|
|
|
|
2017-05-22 11:05:25 +00:00
|
|
|
int bootstage_init(bool first)
|
|
|
|
{
|
|
|
|
struct bootstage_data *data;
|
|
|
|
int size = sizeof(struct bootstage_data);
|
|
|
|
|
|
|
|
gd->bootstage = (struct bootstage_data *)malloc(size);
|
|
|
|
if (!gd->bootstage)
|
|
|
|
return -ENOMEM;
|
|
|
|
data = gd->bootstage;
|
|
|
|
memset(data, '\0', size);
|
2017-05-22 11:05:27 +00:00
|
|
|
if (first) {
|
|
|
|
data->next_id = BOOTSTAGE_ID_USER;
|
2017-05-22 11:05:25 +00:00
|
|
|
bootstage_add_record(BOOTSTAGE_ID_AWAKE, "reset", 0, 0);
|
2017-05-22 11:05:27 +00:00
|
|
|
}
|
2017-05-22 11:05:25 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|