From 074f516bda136e5464499fc63a854d8469f8e9fb Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 20 Nov 2009 15:23:58 +0100 Subject: Updated timing measurement structure, changed atags and added idle time measurement. Note: idle time measurement does not seem to work reliable at the moment. Verification needed. Signed-off-by: Michael Brandt --- board/st/u8500/emmc.c | 4 +- cpu/arm_cortexa9/stw8500/timer.c | 3 +- include/asm-arm/boottime.h | 41 +++++++++++++++----- include/asm-arm/setup.h | 16 ++++++-- lib_arm/Makefile | 1 + lib_arm/bootm.c | 69 +++++++++++++++++---------------- lib_arm/boottime.c | 83 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 166 insertions(+), 51 deletions(-) create mode 100644 lib_arm/boottime.c diff --git a/board/st/u8500/emmc.c b/board/st/u8500/emmc.c index 1d214c026..110c73702 100644 --- a/board/st/u8500/emmc.c +++ b/board/st/u8500/emmc.c @@ -235,8 +235,6 @@ int emmc_read(u32 block_offset, u32 read_buffer, u32 filesize) printf(" eMMC read start filesize=0x%x \n", filesize); - boottime_tag_load_kernel(); - blocks = (n%512==0)?(n/512):(n/512)+1; while(blocks>=8) @@ -354,11 +352,13 @@ int do_emmc_read (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) block_offset = simple_strtoul (argv[2],0,16); filesize = simple_strtoul (argv[3],0,16); + boottime_tag("load_image"); printf("emmc_read :: ram address = 0x%x block address=0x%x \n",ram_address,block_offset); load_result = emmc_read(block_offset,ram_address,filesize); if (load_result != 0) { + boottime_remove_last(); error_name = (unsigned long) (-load_result); printf("emmc_read error : in reading data from eMMC block \n"); } diff --git a/cpu/arm_cortexa9/stw8500/timer.c b/cpu/arm_cortexa9/stw8500/timer.c index 7b4092a9b..f0d015c04 100755 --- a/cpu/arm_cortexa9/stw8500/timer.c +++ b/cpu/arm_cortexa9/stw8500/timer.c @@ -66,7 +66,7 @@ int timer_init(void) writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_16 | MTU_CRn_32BITS, CONFIG_SYS_TIMERBASE + MTU_CR(MTU_TIMER)); reset_timer(); - boottime_tag_uboot_init(); + boottime_tag("uboot_init"); return 0; } @@ -99,4 +99,5 @@ void udelay(unsigned long usec) end = ini + USEC_TO_COUNT(usec); while ((signed)(end - READ_TIMER()) > 0) ; + boottime_idle_add(USEC_TO_COUNT(usec)); } diff --git a/include/asm-arm/boottime.h b/include/asm-arm/boottime.h index 3f8971380..c9a43e259 100644 --- a/include/asm-arm/boottime.h +++ b/include/asm-arm/boottime.h @@ -1,20 +1,41 @@ +/* + * (C) Copyright 2009 ST-Ericsson AB + * Jonas Aaberg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + #ifndef BOOTTIME_H #define BOOTTIME_H -ulong get_raw_timer(void); -extern ulong boottime_ticks_uboot_init; -extern ulong boottime_ticks_load_kernel; -extern ulong boottime_ticks_uboot_done; +#include #ifdef CONFIG_BOOTTIME -#define boottime_tag_uboot_init() boottime_ticks_uboot_init = get_raw_timer(); -#define boottime_tag_load_kernel() boottime_ticks_load_kernel = get_raw_timer(); -#define boottime_tag_uboot_done() boottime_ticks_uboot_done = get_raw_timer(); +int boottime_tag(char *name); +void boottime_remove_last(void); +struct boottime_entry *boottime_get_entry(unsigned int i); +ulong boottime_idle_get(void); +ulong boottime_idle_done(void); +void boottime_idle_add(ulong i); #else -#define boottime_tag_uboot_init() -#define boottime_tag_load_kernel() -#define boottime_tag_uboot_done() +#define boottime_tag(x) 0 +#define boottime_remove_last() +#define boottime_idle_add(x) #endif #endif diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h index cadc12435..467f6d9dd 100644 --- a/include/asm-arm/setup.h +++ b/include/asm-arm/setup.h @@ -206,14 +206,22 @@ struct tag_memclk { }; /* for automatic boot timing testcases */ -#define ATAG_BOOTTIME_UBOOT_INIT 0x41000403 -#define ATAG_BOOTTIME_LOAD_KERNEL 0x41000404 -#define ATAG_BOOTTIME_UBOOT_DONE 0x41000405 +#define ATAG_BOOTTIME 0x41000403 +#define BOOTTIME_MAX_NAME_LEN 64 +#define BOOTTIME_MAX 10 +struct boottime_entry { + u32 tick; + u8 name[BOOTTIME_MAX_NAME_LEN]; +}; struct tag_boottime { - u32 tick; + struct boottime_entry entry[BOOTTIME_MAX]; + u32 idle; + u32 total; + u8 num; }; + struct tag { struct tag_header hdr; union { diff --git a/lib_arm/Makefile b/lib_arm/Makefile index 02933485c..5cfeba985 100644 --- a/lib_arm/Makefile +++ b/lib_arm/Makefile @@ -44,6 +44,7 @@ COBJS-y += cache-cp15.o endif COBJS-y += interrupts.o COBJS-y += reset.o +COBJS-y += boottime.o SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \ $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c index ebaf2b3f2..9dc790dee 100644 --- a/lib_arm/bootm.c +++ b/lib_arm/bootm.c @@ -54,16 +54,14 @@ static void setup_end_tag (bd_t *bd); static void setup_videolfb_tag (gd_t *gd); # endif -static struct tag *params; -#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ - #ifdef CONFIG_BOOTTIME -ulong boottime_ticks_uboot_init = 0; -ulong boottime_ticks_load_kernel = 0; -ulong boottime_ticks_uboot_done = 0; static void setup_boottime_tags(void); #endif +static struct tag *params; +#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ + + int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; @@ -91,7 +89,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); - boottime_tag_uboot_done() + boottime_tag("uncompress_ll_init"); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ @@ -168,33 +166,6 @@ static void setup_start_tag (bd_t *bd) params = tag_next (params); } -#ifdef CONFIG_BOOTTIME -static void setup_boottime_tags(void) -{ - if(!boottime_ticks_uboot_init) - printf("Warning: uboot init time not tracked\n"); - if(!boottime_ticks_load_kernel) - printf("Warning: load kernel time not tracked\n"); - if(!boottime_ticks_uboot_done) - printf("Warning: uboot done time not tracked\n"); - - params->hdr.tag = ATAG_BOOTTIME_UBOOT_INIT; - params->hdr.size = tag_size (tag_boottime); - params->u.boottime.tick = boottime_ticks_uboot_init; - params = tag_next (params); - - params->hdr.tag = ATAG_BOOTTIME_LOAD_KERNEL; - params->hdr.size = tag_size (tag_boottime); - params->u.boottime.tick = boottime_ticks_load_kernel; - params = tag_next (params); - - params->hdr.tag = ATAG_BOOTTIME_UBOOT_DONE; - params->hdr.size = tag_size (tag_boottime); - params->u.boottime.tick = boottime_ticks_uboot_done; - params = tag_next (params); - -} -#endif #ifdef CONFIG_SETUP_MEMORY_TAGS static void setup_memory_tags (bd_t *bd) @@ -213,6 +184,36 @@ static void setup_memory_tags (bd_t *bd) } #endif /* CONFIG_SETUP_MEMORY_TAGS */ +#ifdef CONFIG_BOOTTIME +static void setup_boottime_tags(void) +{ + unsigned int i; + struct boottime_entry *b; + + params->hdr.tag = ATAG_BOOTTIME; + params->hdr.size = tag_size(tag_boottime); + + params->u.boottime.idle = boottime_idle_get(); + params->u.boottime.total = boottime_idle_done(); + + for (i = 0; i < BOOTTIME_MAX; i++) { + b = boottime_get_entry(i); + if (b == NULL) + break; + + params->u.boottime.entry[i].tick = b->tick; + strncpy((char *)params->u.boottime.entry[i].name, + (char *)b->name, BOOTTIME_MAX_NAME_LEN); + params->u.boottime.entry[i].name[BOOTTIME_MAX_NAME_LEN - 1] = '\0'; + + } + + params->u.boottime.num = i; + + params = tag_next(params); + +} +#endif static void setup_commandline_tag (bd_t *bd, char *commandline) { diff --git a/lib_arm/boottime.c b/lib_arm/boottime.c new file mode 100644 index 000000000..3c84bb3e3 --- /dev/null +++ b/lib_arm/boottime.c @@ -0,0 +1,83 @@ +/* + * (C) Copyright 2009 ST-Ericsson AB + * Jonas Aaberg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + + +#include +#include +#include +#include + +#ifdef CONFIG_BOOTTIME +ulong get_raw_timer(void); + +static struct tag_boottime boottime; + +int boottime_tag(char *name) +{ + if (boottime.num == BOOTTIME_MAX) { + printf("boottime: out of entries!\n"); + return -1; + } + + strncpy((char *)boottime.entry[boottime.num].name, + name, + BOOTTIME_MAX_NAME_LEN); + boottime.entry[boottime.num].name[BOOTTIME_MAX_NAME_LEN - 1] = '\0'; + boottime.entry[boottime.num].tick = get_raw_timer(); + + boottime.num++; + return 0; +} + + +struct boottime_entry *boottime_get_entry(unsigned int i) +{ + if (i >= boottime.num) + return NULL; + else + return &boottime.entry[i]; +} + + +void boottime_idle_add(ulong i) +{ + boottime.idle += i; +} + +ulong boottime_idle_done(void) +{ + return get_raw_timer(); +} + +ulong boottime_idle_get(void) +{ + return boottime.idle; +} + +void boottime_remove_last(void) +{ + if (boottime.num > 0) + boottime.num--; +} +#endif + + + + -- cgit v1.2.3