Re: [U-Boot] [PATCH v3 13/15] bootstage: Implement core microsecond boot time measurement

2012-03-19 Thread Simon Glass
Hi Wolfgang,

On Mon, Mar 19, 2012 at 12:13 AM, Wolfgang Denk  wrote:
> Dear Simon Glass,
>
> In message <1326590698-7767-14-git-send-email-...@chromium.org> you wrote:
>> 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.
>
> Hm I'm not sure what happened.
>
> I am positively sure (and I just checked again in the bash history)
> that I did apply the correct version of "[PATCH v3 11/15] timer: add
> microsecond boot func".
>
> However, the repository appears to have an old version instead:
>
>        f933e84   2012-03-18 21:43:17 +0100   bootstage: arm: Add bootstage 
> calls in board and bootm
>        573f14f   2012-03-18 21:42:56 +0100   bootstage: Plumb in bootstage 
> calls for basic operations
>        3a608ca   2012-03-18 21:42:14 +0100   bootstage: Implement core 
> microsecond boot time measurement
>        770605e   2012-03-18 21:41:39 +0100   bootstage: Replace 
> show_boot_progress/error() with bootstage_...()
> ==>     5ff5539   2012-03-18 21:33:53 +0100   bootstage: Define an optional 
> microsecond timer
>        aacc8c1   2012-03-18 21:33:32 +0100   bootstage: Convert FIT progress 
> numbers to enums
>        c8e66db   2012-03-18 21:33:05 +0100   bootstage: Convert net progress 
> numbers to enums
>        cd24a6b   2012-03-18 21:27:20 +0100   bootstage: Convert NAND progress 
> numbers to enums
>        90e153d   2012-03-18 21:24:21 +0100   bootstage: Convert IDE progress 
> numbers to enums
>        8ade950   2012-03-18 21:16:22 +0100   bootstage: Convert progress 
> numbers 20-41 to enums
>        5e41088   2012-03-18 20:59:53 +0100   bootstage: Convert progress 
> numbers 10-19 to enums
>        5dc8871   2012-03-18 20:57:37 +0100   bootstage: Convert progress 
> numbers 1-9 into enums
>        5ddb118   2012-03-18 20:56:00 +0100   bootstage: Use show_boot_error() 
> for -ve progress numbers
>        578ac1e   2012-03-18 20:45:57 +0100   bootstage: Make use of 
> BOOTSTAGE_ID_RUN_OS in show_boot_progress()
>        097e178   2012-03-18 20:43:38 +0100   bootstage: Create an initial 
> header for boot progress integers
>
>
> I cannot reproduce it, but it seems patchworked palyed some trick on
> me (it has also beenx extremely slow last night - eventually some
> works was going on there?).
>
>
> Anyway. Fact is, the current mainline code contains a broken patch,
> which breaks for example the PMC440 board:
>
> Configuring for PMC440 board...
> /work/wd/tmp-ppc/examples/api/time.o: In function `__timer_get_boot_us':
> /home/wd/git/u-boot/work/lib/time.c:60: undefined reference to `get_timer'
> /home/wd/git/u-boot/work/lib/time.c:61: undefined reference to `get_timer'
> make[1]: *** [/work/wd/tmp-ppc/examples/api/demo] Error 1
>
>
> Can you please have a look and provide an incremental patch to bring mainline 
> back in sync with your current code base?

Yes I will send one though. But this is my mistake, not yours. I did
not get around to sending an updated patch - I was in fact going to
ask about the best solution for it, as I was thinking of moving the
timer function into bootstage.c.

Anyway I will send a patch as is, but if you would rather the function
move so we can remove the #ifdef let me know.

Regards,
Simon

>
> Thanks.
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> Each team building another component has been using the  most  recent
> tested  version  of the integrated system as a test bed for debugging
> its piece. Their work will be set back by having that test bed change
> under them. Of course it must. But the changes need to be  quantized.
> Then  each  user  has periods of productive stability, interrupted by
> bursts of test-bed change. This seems to be much less disruptive than
> a constant rippling and trembling.
>                     - Frederick Brooks Jr., "The Mythical Man Month"
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 13/15] bootstage: Implement core microsecond boot time measurement

2012-03-19 Thread Wolfgang Denk
Dear Simon Glass,

In message <1326590698-7767-14-git-send-email-...@chromium.org> you wrote:
> 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.

Hm I'm not sure what happened.

I am positively sure (and I just checked again in the bash history)
that I did apply the correct version of "[PATCH v3 11/15] timer: add
microsecond boot func".

However, the repository appears to have an old version instead:

f933e84   2012-03-18 21:43:17 +0100   bootstage: arm: Add bootstage 
calls in board and bootm
573f14f   2012-03-18 21:42:56 +0100   bootstage: Plumb in bootstage 
calls for basic operations
3a608ca   2012-03-18 21:42:14 +0100   bootstage: Implement core 
microsecond boot time measurement
770605e   2012-03-18 21:41:39 +0100   bootstage: Replace 
show_boot_progress/error() with bootstage_...()
==> 5ff5539   2012-03-18 21:33:53 +0100   bootstage: Define an optional 
microsecond timer
aacc8c1   2012-03-18 21:33:32 +0100   bootstage: Convert FIT progress 
numbers to enums
c8e66db   2012-03-18 21:33:05 +0100   bootstage: Convert net progress 
numbers to enums
cd24a6b   2012-03-18 21:27:20 +0100   bootstage: Convert NAND progress 
numbers to enums
90e153d   2012-03-18 21:24:21 +0100   bootstage: Convert IDE progress 
numbers to enums
8ade950   2012-03-18 21:16:22 +0100   bootstage: Convert progress 
numbers 20-41 to enums
5e41088   2012-03-18 20:59:53 +0100   bootstage: Convert progress 
numbers 10-19 to enums
5dc8871   2012-03-18 20:57:37 +0100   bootstage: Convert progress 
numbers 1-9 into enums
5ddb118   2012-03-18 20:56:00 +0100   bootstage: Use show_boot_error() 
for -ve progress numbers
578ac1e   2012-03-18 20:45:57 +0100   bootstage: Make use of 
BOOTSTAGE_ID_RUN_OS in show_boot_progress()
097e178   2012-03-18 20:43:38 +0100   bootstage: Create an initial 
header for boot progress integers


I cannot reproduce it, but it seems patchworked palyed some trick on
me (it has also beenx extremely slow last night - eventually some
works was going on there?).


Anyway. Fact is, the current mainline code contains a broken patch,
which breaks for example the PMC440 board:

Configuring for PMC440 board...
/work/wd/tmp-ppc/examples/api/time.o: In function `__timer_get_boot_us':
/home/wd/git/u-boot/work/lib/time.c:60: undefined reference to `get_timer'
/home/wd/git/u-boot/work/lib/time.c:61: undefined reference to `get_timer'
make[1]: *** [/work/wd/tmp-ppc/examples/api/demo] Error 1


Can you please have a look and provide an incremental patch to bring mainline 
back in sync with your current code base?

Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Each team building another component has been using the  most  recent
tested  version  of the integrated system as a test bed for debugging
its piece. Their work will be set back by having that test bed change
under them. Of course it must. But the changes need to be  quantized.
Then  each  user  has periods of productive stability, interrupted by
bursts of test-bed change. This seems to be much less disruptive than
a constant rippling and trembling.
 - Frederick Brooks Jr., "The Mythical Man Month"
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 13/15] bootstage: Implement core microsecond boot time measurement

2012-01-14 Thread Simon Glass
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:
   MarkElapsed  Stage
  0  0  reset
205,000205,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,000996,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 
---
Changes in v3:
- Fix code style in bootstage_mark_name()
- Make main bootstage commit title more explicit

 README  |   25 
 common/Makefile |1 +
 common/bootstage.c  |  160 +++
 include/bootstage.h |   77 -
 4 files changed, 261 insertions(+), 2 deletions(-)
 create mode 100644 common/bootstage.c

diff --git a/README b/README
index 9d713e8..e757786 100644
--- a/README
+++ b/README
@@ -2235,6 +2235,31 @@ The following options need to be configured:
example, some LED's) on your board. At the moment,
the following checkpoints are implemented:
 
+- Detailed boot stage timing
+   CONFIG_BOOTSTAGE
+   Define this option to get detailed timing of each stage
+   of the boot process.
+
+   CONFIG_BOOTSTAGE_USER_COUNT
+   This is the number of available user bootstage records.
+   Each time you call bootstage_mark(BOOTSTAGE_ID_ALLOC, ...)
+   a new ID will be allocated from this stash. If you exceed
+   the limit, recording will stop.
+
+   CONFIG_BOOTSTAGE_REPORT
+   Define this to print a report before boot, similar to this:
+
+   Timer summary in microseconds:
+  MarkElapsed  Stage
+ 0  0  reset
+ 3,575,678  3,575,678  board_init_f start
+ 3,575,695 17  arch_cpu_init A9
+ 3,575,777 82  arch_cpu_init done
+ 3,659,598 83,821  board_init_r start
+ 3,910,375250,777  main_loop
+29,916,167 26,005,792  bootm_start
+30,361,327445,160  start_kernel
+
 Legacy uImage format:
 
   Arg  Where   When
diff --git a/common/Makefile b/common/Makefile
index 2d9ae8c..038baf0 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -172,6 +172,7 @@ SPD := y
 endif
 COBJS-$(SPD) += ddr_spd.o
 COBJS-$(CONFIG_HWCONFIG) += hwconfig.o
+COBJS-$(CONFIG_BOOTSTAGE) += bootstage.o
 COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o
 COBJS-y += flash.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o
diff --git a/common/bootstage.c b/common/bootstage.c
new file mode 100644
index 000..358e1ca
--- /dev/null
+++ b/common/bootstage.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2011, Google Inc. All rights reserved.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+
+/*
+ * This module records the progress of boot and arbitrary commands, and
+ * permits accurate timestamping of each.
+ *
+ * TBD: Pass timings to kernel in the FDT
+ */
+
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+enum bootstage_flags {
+   BOOTSTAGEF_ERROR= 1 << 0,   /* Error record */
+   BOOTSTAGEF_ALLOC= 1 << 1,   /* Allocate an id */
+};
+
+struct bootstage_record {
+   ulong time_us;
+   const char *name;
+   int flags;  /* see enum bootstage_flags */
+   enum bootstage_id id;
+};
+
+static struct bootstage_record record[BOOTSTAGE_ID_COUNT] = { {1} };
+stat