bootstage: Support SPL

At present bootstage only supports U-Boot proper. But SPL can also consume
boot time so it is useful to have the record start there.

Add bootstage support to SPL. Also support stashing the timing information
when SPL finishes so that it can be picked up and reported by U-Boot
proper. This provides a full boot time record, excluding only the time
taken by the boot ROM.

Signed-off-by: Simon Glass <sjg@chromium.org>
master
Simon Glass 8 years ago committed by Tom Rini
parent 9d2542d062
commit 824bb1b453
  1. 9
      common/Kconfig
  2. 3
      common/Makefile
  3. 17
      common/board_f.c
  4. 18
      common/spl/spl.c
  5. 15
      include/bootstage.h

@ -18,6 +18,15 @@ config BOOTSTAGE
Calls to show_boot_progress() will also result in log entries but Calls to show_boot_progress() will also result in log entries but
these will not have names. these will not have names.
config SPL_BOOTSTAGE
bool "Boot timing and reported in SPL"
depends on BOOTSTAGE
help
Enable recording of boot time in SPL. To make this visible to U-Boot
proper, enable BOOTSTAGE_STASH as well. This will stash the timing
information when SPL finishes and load it when U-Boot proper starts
up.
config BOOTSTAGE_REPORT config BOOTSTAGE_REPORT
bool "Display a detailed boot timing report before booting the OS" bool "Display a detailed boot timing report before booting the OS"
depends on BOOTSTAGE depends on BOOTSTAGE

@ -65,7 +65,6 @@ obj-$(CONFIG_USB_STORAGE) += usb_storage.o
endif endif
# others # others
obj-$(CONFIG_BOOTSTAGE) += bootstage.o
obj-$(CONFIG_CONSOLE_MUX) += iomux.o obj-$(CONFIG_CONSOLE_MUX) += iomux.o
obj-$(CONFIG_MTD_NOR_FLASH) += flash.o obj-$(CONFIG_MTD_NOR_FLASH) += flash.o
obj-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o obj-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o
@ -89,6 +88,8 @@ obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
endif # !CONFIG_SPL_BUILD endif # !CONFIG_SPL_BUILD
obj-$(CONFIG_$(SPL_)BOOTSTAGE) += bootstage.o
ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o

@ -707,11 +707,26 @@ static int jump_to_copy(void)
/* Record the board_init_f() bootstage (after arch_cpu_init()) */ /* Record the board_init_f() bootstage (after arch_cpu_init()) */
static int initf_bootstage(void) static int initf_bootstage(void)
{ {
#if defined(CONFIG_SPL_BOOTSTAGE) && defined(CONFIG_BOOTSTAGE_STASH)
bool from_spl = true;
#else
bool from_spl = false;
#endif
int ret; int ret;
ret = bootstage_init(true); ret = bootstage_init(!from_spl);
if (ret) if (ret)
return ret; return ret;
if (from_spl) {
const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
CONFIG_BOOTSTAGE_STASH_SIZE);
ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
if (ret && ret != -ENOENT) {
debug("Failed to unstash bootstage: err=%d\n", ret);
return ret;
}
}
bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");

@ -232,6 +232,13 @@ static int spl_common_init(bool setup_malloc)
gd->malloc_ptr = 0; gd->malloc_ptr = 0;
} }
#endif #endif
ret = bootstage_init(true);
if (ret) {
debug("%s: Failed to set up bootstage: ret=%d\n", __func__,
ret);
return ret;
}
bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl");
if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = fdtdec_setup(); ret = fdtdec_setup();
if (ret) { if (ret) {
@ -240,8 +247,10 @@ static int spl_common_init(bool setup_malloc)
} }
} }
if (IS_ENABLED(CONFIG_SPL_DM)) { if (IS_ENABLED(CONFIG_SPL_DM)) {
bootstage_start(BOOTSTATE_ID_ACCUM_DM_SPL, "dm_spl");
/* With CONFIG_SPL_OF_PLATDATA, bring in all devices */ /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA)); ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
bootstage_accum(BOOTSTATE_ID_ACCUM_DM_SPL);
if (ret) { if (ret) {
debug("dm_init_and_scan() returned error %d\n", ret); debug("dm_init_and_scan() returned error %d\n", ret);
return ret; return ret;
@ -421,6 +430,15 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
} }
debug("loaded - jumping to U-Boot...\n"); debug("loaded - jumping to U-Boot...\n");
#ifdef CONFIG_BOOTSTAGE_STASH
int ret;
bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
CONFIG_BOOTSTAGE_STASH_SIZE);
if (ret)
debug("Failed to stash bootstage: err=%d\n", ret);
#endif
spl_board_prepare_for_boot(); spl_board_prepare_for_boot();
jump_to_image_no_args(&spl_image); jump_to_image_no_args(&spl_image);
} }

@ -177,6 +177,7 @@ enum bootstage_id {
*/ */
BOOTSTAGE_ID_AWAKE, BOOTSTAGE_ID_AWAKE,
BOOTSTAGE_ID_START_SPL, BOOTSTAGE_ID_START_SPL,
BOOTSTAGE_ID_END_SPL,
BOOTSTAGE_ID_START_UBOOT_F, BOOTSTAGE_ID_START_UBOOT_F,
BOOTSTAGE_ID_START_UBOOT_R, BOOTSTAGE_ID_START_UBOOT_R,
BOOTSTAGE_ID_USB_START, BOOTSTAGE_ID_USB_START,
@ -200,6 +201,7 @@ enum bootstage_id {
BOOTSTAGE_ID_ACCUM_SPI, BOOTSTAGE_ID_ACCUM_SPI,
BOOTSTAGE_ID_ACCUM_DECOMP, BOOTSTAGE_ID_ACCUM_DECOMP,
BOOTSTAGE_ID_FPGA_INIT, BOOTSTAGE_ID_FPGA_INIT,
BOOTSTATE_ID_ACCUM_DM_SPL,
BOOTSTATE_ID_ACCUM_DM_F, BOOTSTATE_ID_ACCUM_DM_F,
BOOTSTATE_ID_ACCUM_DM_R, BOOTSTATE_ID_ACCUM_DM_R,
@ -228,8 +230,14 @@ ulong timer_get_boot_us(void);
void show_boot_progress(int val); void show_boot_progress(int val);
#endif #endif
#if defined(CONFIG_BOOTSTAGE) && !defined(CONFIG_SPL_BUILD) && \ #if !defined(USE_HOSTCC)
!defined(USE_HOSTCC) #if CONFIG_IS_ENABLED(BOOTSTAGE)
#define ENABLE_BOOTSTAGE
#endif
#endif
#ifdef ENABLE_BOOTSTAGE
/* This is the full bootstage implementation */ /* This is the full bootstage implementation */
/** /**
@ -420,7 +428,8 @@ static inline int bootstage_init(bool first)
{ {
return 0; return 0;
} }
#endif /* CONFIG_BOOTSTAGE */
#endif /* ENABLE_BOOTSTAGE */
/* Helper macro for adding a bootstage to a line of code */ /* Helper macro for adding a bootstage to a line of code */
#define BOOTSTAGE_MARKER() \ #define BOOTSTAGE_MARKER() \

Loading…
Cancel
Save