All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/16] image: Fix various test failures
@ 2016-02-15  1:36 Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 01/16] image: Correct the OS location code to work on sandbox Simon Glass
                   ` (16 more replies)
  0 siblings, 17 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

Recent changes have broken the FIT and vboot tests. Also the SPI tests have
been wrong since before the last release and were disabled.

This series collects together the required fixes.

Note: The FIT and vboot tests are hard to run (in that each requires manual
effort). At some point we should be able to bring these into Stephen Warren's
test framework.


Simon Glass (16):
  image: Correct the OS location code to work on sandbox
  Revert "image-fit: Fix signature checking"
  image: Fix FIT and vboot tests to exit sandbox correctly
  trace: Fix compiler warnings in trace
  lib: Don't instrument the div64 function
  trace: Improve the trace test number recognition
  timer: Support tracing fully
  timer: Provide an early timer
  timer: Set up the real timer after driver model is available
  sandbox: timer: Support the early timer
  sandbox: Correct ordering of defconfig
  sandbox: Enable the early timer
  sandbox: spi: Add more debugging to SPI emulation
  sandbox: spi: Remove an incorrect free()
  spi: Correct two error return values
  spi: Re-enable the SPI flash tests

 cmd/trace.c                   |  4 ++--
 common/board_f.c              |  6 ++++++
 common/board_r.c              | 14 ++++++++++++--
 common/bootm.c                |  2 +-
 common/image-fit.c            | 16 +++++++++++++---
 configs/sandbox_defconfig     | 11 ++++++-----
 drivers/mtd/spi/sandbox.c     | 14 ++++++++++----
 drivers/mtd/spi/sf_probe.c    |  4 +---
 drivers/mtd/spi/spi_flash.c   |  2 +-
 drivers/timer/Kconfig         | 10 ++++++++++
 drivers/timer/sandbox_timer.c | 14 ++++++++++++--
 drivers/timer/timer-uclass.c  |  6 +++---
 include/image.h               |  5 +----
 include/timer.h               | 21 +++++++++++++++++++++
 lib/div64.c                   |  3 ++-
 lib/time.c                    | 28 +++++++++++++++++++++-------
 test/dm/Makefile              |  4 ++--
 test/image/test-fit.py        |  4 ++++
 test/trace/test-trace.sh      |  4 +++-
 test/vboot/sandbox-u-boot.dts |  3 +++
 20 files changed, 134 insertions(+), 41 deletions(-)

-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/16] image: Correct the OS location code to work on sandbox
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 02/16] Revert "image-fit: Fix signature checking" Simon Glass
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

A recent change broke the 'bootm' command on sandbox. The root cause is
using a pointer as an address. Conversion from pointer to address needs to
use map_to_sysmem() so that sandbox can do the right thing. The problem was
pre-existing but uncovered by a recent commit.

Fix this. Also move fit_get_end() to the C file to avoid needing to include
mapmem.h (and thus asm/io.h) everywhere.

Fixes: 1fec3c5d (common/image.c: Make boot_get_ramdisk() perform a check for Android images)

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/bootm.c     | 2 +-
 common/image-fit.c | 5 +++++
 include/image.h    | 5 +----
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 99d574d..df27089 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -201,7 +201,7 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
 		images.ep += images.os.load;
 	}
 
-	images.os.start = (ulong)os_hdr;
+	images.os.start = map_to_sysmem(os_hdr);
 
 	return 0;
 }
diff --git a/common/image-fit.c b/common/image-fit.c
index c531ee7..d3fad30 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -851,6 +851,11 @@ static int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore)
 	return 0;
 }
 
+ulong fit_get_end(const void *fit)
+{
+	return map_to_sysmem((void *)(fit + fdt_totalsize(fit)));
+}
+
 /**
  * fit_set_timestamp - set node timestamp property
  * @fit: pointer to the FIT format image header
diff --git a/include/image.h b/include/image.h
index 299d6d2..518a4f5 100644
--- a/include/image.h
+++ b/include/image.h
@@ -818,10 +818,7 @@ static inline ulong fit_get_size(const void *fit)
  * returns:
  *     end address of the FIT image (blob) in memory
  */
-static inline ulong fit_get_end(const void *fit)
-{
-	return (ulong)fit + fdt_totalsize(fit);
-}
+ulong fit_get_end(const void *fit);
 
 /**
  * fit_get_name - get FIT node name
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 02/16] Revert "image-fit: Fix signature checking"
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 01/16] image: Correct the OS location code to work on sandbox Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 03/16] image: Fix FIT and vboot tests to exit sandbox correctly Simon Glass
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

This reverts commit 84ca65aa4bd0d03867e9e49805201d0564d3ffb0.

On signature verification failures fit_image_verify() should NOT exit with
error. Only keys marked 'required' can cause image verification failure.
This logic is already there and works correctly.

Add a comment to make this clear.

Fixes: 84ca65aa (image-fit: Fix signature checking)
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/image-fit.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index d3fad30..fbd9e0d 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1035,10 +1035,15 @@ int fit_image_verify(const void *fit, int image_noffset)
 					strlen(FIT_SIG_NODENAME))) {
 			ret = fit_image_check_sig(fit, noffset, data,
 							size, -1, &err_msg);
-			if (ret) {
+
+			/*
+			 * Show an indication on failure, but do not return
+			 * an error. Only keys marked 'required' can cause
+			 * an image validation failure. See the call to
+			 * fit_image_verify_required_sigs() above.
+			 */
+			if (ret)
 				puts("- ");
-				goto error;
-			}
 			else
 				puts("+ ");
 		}
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 03/16] image: Fix FIT and vboot tests to exit sandbox correctly
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 01/16] image: Correct the OS location code to work on sandbox Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 02/16] Revert "image-fit: Fix signature checking" Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 04/16] trace: Fix compiler warnings in trace Simon Glass
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

When used with a device tree, sandbox now requires a 'reset' controller. Add
this to the device trees so that reset works and the tests can complete.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 5010d98f (sandbox: Use the reset driver to handle reset)
---

 test/image/test-fit.py        | 4 ++++
 test/vboot/sandbox-u-boot.dts | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/test/image/test-fit.py b/test/image/test-fit.py
index d5143cb..db0649f 100755
--- a/test/image/test-fit.py
+++ b/test/image/test-fit.py
@@ -108,6 +108,10 @@ base_fdt = '''
         model = "Sandbox Verified Boot Test";
         compatible = "sandbox";
 
+	reset at 0 {
+		compatible = "sandbox,reset";
+	};
+
 };
 '''
 
diff --git a/test/vboot/sandbox-u-boot.dts b/test/vboot/sandbox-u-boot.dts
index a1e853c..63f8f40 100644
--- a/test/vboot/sandbox-u-boot.dts
+++ b/test/vboot/sandbox-u-boot.dts
@@ -4,4 +4,7 @@
 	model = "Sandbox Verified Boot Test";
 	compatible = "sandbox";
 
+	reset at 0 {
+		compatible = "sandbox,reset";
+	};
 };
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/16] trace: Fix compiler warnings in trace
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (2 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 03/16] image: Fix FIT and vboot tests to exit sandbox correctly Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:21   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 05/16] lib: Don't instrument the div64 function Simon Glass
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

With min() we must use the same type for each parameter. Fix two problems
in trace.c which produce compiler warnings.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/trace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/trace.c b/cmd/trace.c
index 1e62a1a..1a6d8c3 100644
--- a/cmd/trace.c
+++ b/cmd/trace.c
@@ -43,7 +43,7 @@ static int create_func_list(int argc, char * const argv[])
 	err = trace_list_functions(buff + buff_ptr, avail, &needed);
 	if (err)
 		printf("Error: truncated (%#x bytes needed)\n", needed);
-	used = min(avail, needed);
+	used = min(avail, (size_t)needed);
 	printf("Function trace dumped to %08lx, size %#zx\n",
 	       (ulong)map_to_sysmem(buff + buff_ptr), used);
 	setenv_hex("profbase", map_to_sysmem(buff));
@@ -67,7 +67,7 @@ static int create_call_list(int argc, char * const argv[])
 	err = trace_list_calls(buff + buff_ptr, avail, &needed);
 	if (err)
 		printf("Error: truncated (%#x bytes needed)\n", needed);
-	used = min(avail, needed);
+	used = min(avail, (size_t)needed);
 	printf("Call list dumped to %08lx, size %#zx\n",
 	       (ulong)map_to_sysmem(buff + buff_ptr), used);
 
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 05/16] lib: Don't instrument the div64 function
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (3 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 04/16] trace: Fix compiler warnings in trace Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:21   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 06/16] trace: Improve the trace test number recognition Simon Glass
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

This function can be called from the timer code on instrumented functions.
Mark it as 'notrace' so that it doesn't cause infinite recursion.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/div64.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/div64.c b/lib/div64.c
index 795ef0e..319fca5 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -18,8 +18,9 @@
 
 #include <div64.h>
 #include <linux/types.h>
+#include <linux/compiler.h>
 
-uint32_t __div64_32(uint64_t *n, uint32_t base)
+uint32_t notrace __div64_32(uint64_t *n, uint32_t base)
 {
 	uint64_t rem = *n;
 	uint64_t b = base;
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 06/16] trace: Improve the trace test number recognition
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (4 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 05/16] lib: Don't instrument the div64 function Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 07/16] timer: Support tracing fully Simon Glass
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

The awk tool can be confused by return character (ASCII 13) in its input
since it thinks there is a separate field. These can appear if the terminal
is in raw mode, perhaps due to a previous U-Boot crash with sandbox. This
is very confusing. Remove these so that the trace test passes.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/trace/test-trace.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/trace/test-trace.sh b/test/trace/test-trace.sh
index 3e8651e..746793c 100755
--- a/test/trace/test-trace.sh
+++ b/test/trace/test-trace.sh
@@ -45,7 +45,9 @@ check_results() {
 	# between calls 2 and 3, where tracing is paused.
 	# This code gets the sign of the difference between each number and
 	# its predecessor.
-	counts="$(tr -d , <${tmp} | awk '/traced function calls/ { diff = $1 - upto; upto = $1; printf "%d ", diff < 0 ? -1 : (diff > 0 ? 1 : 0)}')"
+	counts="$(tr -d ',\r' <${tmp} | awk \
+		'/traced function calls/ { diff = $1 - upto; upto = $1; \
+		printf "%d ", diff < 0 ? -1 : (diff > 0 ? 1 : 0)}')"
 
 	if [ "${counts}" != "1 1 0 1 " ]; then
 		fail "trace collection error: ${counts}"
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 07/16] timer: Support tracing fully
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (5 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 06/16] trace: Improve the trace test number recognition Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:21   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 08/16] timer: Provide an early timer Simon Glass
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

A few of the functions in the timer uclass are not marked with 'notrace'. Fix
this so that tracing can be used with CONFIG_TRACE.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/timer/timer-uclass.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 83d1a35..382c0f2 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * tick, and no timer interrupt.
  */
 
-int timer_get_count(struct udevice *dev, u64 *count)
+int notrace timer_get_count(struct udevice *dev, u64 *count)
 {
 	const struct timer_ops *ops = device_get_ops(dev);
 
@@ -32,9 +32,9 @@ int timer_get_count(struct udevice *dev, u64 *count)
 	return ops->get_count(dev, count);
 }
 
-unsigned long timer_get_rate(struct udevice *dev)
+unsigned long notrace timer_get_rate(struct udevice *dev)
 {
-	struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct timer_dev_priv *uc_priv = dev->uclass_priv;
 
 	return uc_priv->clock_rate;
 }
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 08/16] timer: Provide an early timer
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (6 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 07/16] timer: Support tracing fully Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:21   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 09/16] timer: Set up the real timer after driver model is available Simon Glass
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

In some cases the timer must be accessible before driver model is active.
Examples include when using CONFIG_TRACE to trace U-Boot's execution before
driver model is set up. Enable this option to use an early timer. These
functions must be supported by your timer driver: timer_early_get_count()
and timer_early_get_rate().

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/timer/Kconfig | 10 ++++++++++
 include/timer.h       | 21 +++++++++++++++++++++
 lib/time.c            | 28 +++++++++++++++++++++-------
 3 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index ff65a73..cb18f12 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -9,6 +9,16 @@ config TIMER
 	  will be used. The timer is usually a 32 bits free-running up
 	  counter. There may be no real tick, and no timer interrupt.
 
+config TIMER_EARLY
+	bool "Allow timer to be used early in U-Boot"
+	depends on TIMER
+	help
+	  In some cases the timer must be accessible before driver model is
+	  active. Examples include when using CONFIG_TRACE to trace U-Boot's
+	  execution before driver model is set up. Enable this option to
+	  use an early timer. These functions must be supported by your timer
+	  driver: timer_early_get_count() and timer_early_get_rate().
+
 config ALTERA_TIMER
 	bool "Altera timer support"
 	depends on TIMER
diff --git a/include/timer.h b/include/timer.h
index f14725c..a503bfd 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -67,4 +67,25 @@ struct timer_dev_priv {
 	unsigned long clock_rate;
 };
 
+/**
+ * timer_early_get_count() - Implement timer_get_count() before driver model
+ *
+ * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
+ * the current timer value before the proper driver model timer is ready.
+ * It should be implemented by one of the timer values. This is mostly useful
+ * for tracing.
+ */
+u64 timer_early_get_count(void);
+
+/**
+ * timer_early_get_rate() - Get the timer rate before driver model
+ *
+ * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
+ * the current timer rate  in Hz before the proper driver model timer is ready.
+ * It should be implemented by one of the timer values. This is mostly useful
+ * for tracing. This corresponds to the clock_rate value in struct
+ * timer_dev_priv.
+ */
+unsigned long timer_early_get_rate(void);
+
 #endif	/* _TIMER_H_ */
diff --git a/lib/time.c b/lib/time.c
index e9f6861..f37150f 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -43,11 +43,17 @@ extern unsigned long __weak timer_read_counter(void);
 #ifdef CONFIG_TIMER
 ulong notrace get_tbclk(void)
 {
-	int ret;
+	if (!gd->timer) {
+#ifdef CONFIG_TIMER_EARLY
+		return timer_early_get_rate();
+#else
+		int ret;
 
-	ret = dm_timer_init();
-	if (ret)
-		return ret;
+		ret = dm_timer_init();
+		if (ret)
+			return ret;
+#endif
+	}
 
 	return timer_get_rate(gd->timer);
 }
@@ -57,9 +63,17 @@ uint64_t notrace get_ticks(void)
 	u64 count;
 	int ret;
 
-	ret = dm_timer_init();
-	if (ret)
-		return ret;
+	if (!gd->timer) {
+#ifdef CONFIG_TIMER_EARLY
+		return timer_early_get_count();
+#else
+		int ret;
+
+		ret = dm_timer_init();
+		if (ret)
+			return ret;
+#endif
+	}
 
 	ret = timer_get_count(gd->timer, &count);
 	if (ret)
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 09/16] timer: Set up the real timer after driver model is available
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (7 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 08/16] timer: Provide an early timer Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:21   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer Simon Glass
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

When using the early timer, we need to manually trigger setting up the
real timer. This will not happen automatically. Do this immediately after
starting driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/board_f.c |  6 ++++++
 common/board_r.c | 14 ++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index a960144..622093a 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -45,6 +45,7 @@
 #include <post.h>
 #include <spi.h>
 #include <status_led.h>
+#include <timer.h>
 #include <trace.h>
 #include <video.h>
 #include <watchdog.h>
@@ -805,6 +806,11 @@ static int initf_dm(void)
 	if (ret)
 		return ret;
 #endif
+#ifdef CONFIG_TIMER_EARLY
+	ret = dm_timer_init();
+	if (ret)
+		return ret;
+#endif
 
 	return 0;
 }
diff --git a/common/board_r.c b/common/board_r.c
index 6c23865..52a9b26 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -46,6 +46,7 @@
 #include <serial.h>
 #include <spi.h>
 #include <stdio_dev.h>
+#include <timer.h>
 #include <trace.h>
 #include <watchdog.h>
 #ifdef CONFIG_CMD_AMBAPP
@@ -312,13 +313,22 @@ static int initr_noncached(void)
 #ifdef CONFIG_DM
 static int initr_dm(void)
 {
+	int ret;
+
 	/* Save the pre-reloc driver model and start a new one */
 	gd->dm_root_f = gd->dm_root;
 	gd->dm_root = NULL;
-#ifdef CONFIG_TIMER
+	ret = dm_init_and_scan(false);
+	if (ret)
+		return ret;
+#ifdef CONFIG_TIMER_EARLY
 	gd->timer = NULL;
+	ret = dm_timer_init();
+	if (ret)
+		return ret;
 #endif
-	return dm_init_and_scan(false);
+
+	return 0;
 }
 #endif
 
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (8 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 09/16] timer: Set up the real timer after driver model is available Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:22   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 11/16] sandbox: Correct ordering of defconfig Simon Glass
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

Add support for the early timer so we can use tracing with sandbox again.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/timer/sandbox_timer.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c
index a8da936..4537c82 100644
--- a/drivers/timer/sandbox_timer.c
+++ b/drivers/timer/sandbox_timer.c
@@ -18,9 +18,19 @@ void sandbox_timer_add_offset(unsigned long offset)
 	sandbox_timer_offset += offset;
 }
 
-static int sandbox_timer_get_count(struct udevice *dev, u64 *count)
+u64 notrace timer_early_get_count(void)
 {
-	*count = os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
+	return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
+}
+
+unsigned long notrace timer_early_get_rate(void)
+{
+	return 1000000;
+}
+
+static notrace int sandbox_timer_get_count(struct udevice *dev, u64 *count)
+{
+	*count = timer_early_get_count();
 
 	return 0;
 }
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 11/16] sandbox: Correct ordering of defconfig
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (9 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15  1:36 ` [U-Boot] [PATCH 12/16] sandbox: Enable the early timer Simon Glass
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

This has got out of order: fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 configs/sandbox_defconfig | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index b5b81ca..8b878e2 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,10 +1,13 @@
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_PCI=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
-CONFIG_DM_PCI_COMPAT=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_FIT_SIGNATURE=y
+CONFIG_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_REPORT=y
+CONFIG_CONSOLE_RECORD=y
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 # CONFIG_CMD_ELF is not set
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
@@ -12,14 +15,10 @@ CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_SOUND=y
-CONFIG_BOOTSTAGE=y
-CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_TPM=y
 CONFIG_CMD_TPM_TEST=y
-CONFIG_CONSOLE_RECORD=y
-CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_REGMAP=y
@@ -52,6 +51,7 @@ CONFIG_SPI_FLASH_SST=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_DM_ETH=y
 CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_SANDBOX=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 12/16] sandbox: Enable the early timer
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (10 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 11/16] sandbox: Correct ordering of defconfig Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-16  9:22   ` Bin Meng
  2016-02-15  1:36 ` [U-Boot] [PATCH 13/16] sandbox: spi: Add more debugging to SPI emulation Simon Glass
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

Enable this so that tracing works with sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 configs/sandbox_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 8b878e2..02534bf 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -68,6 +68,7 @@ CONFIG_SOUND=y
 CONFIG_SOUND_SANDBOX=y
 CONFIG_SANDBOX_SPI=y
 CONFIG_TIMER=y
+CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_TPM_TIS_SANDBOX=y
 CONFIG_USB=y
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 13/16] sandbox: spi: Add more debugging to SPI emulation
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (11 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 12/16] sandbox: Enable the early timer Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15 19:01   ` Jagan Teki
  2016-02-15  1:36 ` [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free() Simon Glass
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

Add a little more debugging to help when things go wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sandbox.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index 895604d..ec07be7 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -142,13 +142,15 @@ static int sandbox_sf_probe(struct udevice *dev)
 		if (bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS)
 			spec = state->spi[bus->seq][cs].spec;
 		if (!spec) {
+			debug("%s:  No spec found for bus %d, cs %d\n",
+			      __func__, bus->seq, cs);
 			ret = -ENOENT;
 			goto error;
 		}
 
 		file = strchr(spec, ':');
 		if (!file) {
-			printf("sandbox_sf: unable to parse file\n");
+			printf("%s: unable to parse file\n", __func__);
 			ret = -EINVAL;
 			goto error;
 		}
@@ -174,7 +176,7 @@ static int sandbox_sf_probe(struct udevice *dev)
 			break;
 	}
 	if (!data->name) {
-		printf("sandbox_sf: unknown flash '%*s'\n", (int)idname_len,
+		printf("%s: unknown flash '%*s'\n", __func__, (int)idname_len,
 		       spec);
 		ret = -EINVAL;
 		goto error;
@@ -186,7 +188,7 @@ static int sandbox_sf_probe(struct udevice *dev)
 	sbsf->fd = os_open(pdata->filename, 02);
 	if (sbsf->fd == -1) {
 		free(sbsf);
-		printf("sandbox_sf: unable to open file '%s'\n",
+		printf("%s: unable to open file '%s'\n", __func__,
 		       pdata->filename);
 		ret = -EIO;
 		goto error;
@@ -553,6 +555,9 @@ static int sandbox_cmdline_cb_spi_sf(struct sandbox_state *state,
 	 * yet. Perhaps we can figure something out.
 	 */
 	state->spi[bus][cs].spec = spec;
+	debug("%s:  Setting up spec '%s' for bus %ld, cs %ld\n", __func__,
+	      spec, bus, cs);
+
 	return 0;
 }
 SANDBOX_CMDLINE_OPT(spi_sf, 1, "connect a SPI flash: <bus>:<cs>:<id>:<file>");
@@ -671,6 +676,8 @@ int dm_scan_other(bool pre_reloc_only)
 					      __func__, busnum, cs);
 					return ret;
 				}
+				debug("%s:  Setting up spec '%s' for bus %d, cs %d\n",
+				      __func__, spec, busnum, cs);
 			}
 		}
 	}
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free()
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (12 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 13/16] sandbox: spi: Add more debugging to SPI emulation Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15 19:02   ` Jagan Teki
  2016-02-15 22:37   ` Tom Rini
  2016-02-15  1:36 ` [U-Boot] [PATCH 15/16] spi: Correct two error return values Simon Glass
                   ` (2 subsequent siblings)
  16 siblings, 2 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

We must not free data that is managed by driver mode. Remove this line,
which is a hangover from the pre-driver-model code.

This fixes a problem where 'sf probe' crashes U-Boot if the backing file
for the SPI flash cannot be found.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/mtd/spi/sandbox.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index ec07be7..53470b9 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -187,7 +187,6 @@ static int sandbox_sf_probe(struct udevice *dev)
 
 	sbsf->fd = os_open(pdata->filename, 02);
 	if (sbsf->fd == -1) {
-		free(sbsf);
 		printf("%s: unable to open file '%s'\n", __func__,
 		       pdata->filename);
 		ret = -EIO;
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 15/16] spi: Correct two error return values
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (13 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free() Simon Glass
@ 2016-02-15  1:36 ` Simon Glass
  2016-02-15 19:10   ` Jagan Teki
  2016-02-15  1:37 ` [U-Boot] [PATCH 16/16] spi: Re-enable the SPI flash tests Simon Glass
  2016-02-16 22:03 ` [U-Boot] [PATCH 00/16] image: Fix various test failures Stephen Warren
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:36 UTC (permalink / raw)
  To: u-boot

When an error number is provided we should use it, not change it. This fixes
the SPI and SPI flash tests.

One of these is long-standing. The other seems to have been introduced by
commit 1e90d9fd (sf: Move read_id code to sf_ops).

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 1e90d9fd (sf: Move read_id code to sf_ops)
---

 drivers/mtd/spi/sf_probe.c  | 4 +---
 drivers/mtd/spi/spi_flash.c | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index daa1d5b..7b29637 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -42,10 +42,8 @@ static int spi_flash_probe_slave(struct spi_flash *flash)
 	}
 
 	ret = spi_flash_scan(flash);
-	if (ret) {
-		ret = -EINVAL;
+	if (ret)
 		goto err_read_id;
-	}
 
 #ifdef CONFIG_SPI_FLASH_MTD
 	ret = spi_flash_mtd_register(flash);
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 8a60c72..5c902f5 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -980,7 +980,7 @@ int spi_flash_scan(struct spi_flash *flash)
 	ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
 	if (ret) {
 		printf("SF: Failed to get idcodes\n");
-		return -EINVAL;
+		return ret;
 	}
 
 #ifdef DEBUG
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 16/16] spi: Re-enable the SPI flash tests
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (14 preceding siblings ...)
  2016-02-15  1:36 ` [U-Boot] [PATCH 15/16] spi: Correct two error return values Simon Glass
@ 2016-02-15  1:37 ` Simon Glass
  2016-02-15 19:10   ` Jagan Teki
  2016-02-16 22:03 ` [U-Boot] [PATCH 00/16] image: Fix various test failures Stephen Warren
  16 siblings, 1 reply; 33+ messages in thread
From: Simon Glass @ 2016-02-15  1:37 UTC (permalink / raw)
  To: u-boot

These are working correctly again, so re-enable them.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/dm/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/dm/Makefile b/test/dm/Makefile
index d4f3f22..fd0198f 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -27,8 +27,8 @@ obj-y += regmap.o
 obj-$(CONFIG_REMOTEPROC) += remoteproc.o
 obj-$(CONFIG_RESET) += reset.o
 obj-$(CONFIG_DM_RTC) += rtc.o
-#obj-$(CONFIG_DM_SPI_FLASH) += sf.o
-#obj-$(CONFIG_DM_SPI) += spi.o
+obj-$(CONFIG_DM_SPI_FLASH) += sf.o
+obj-$(CONFIG_DM_SPI) += spi.o
 obj-y += syscon.o
 obj-$(CONFIG_DM_USB) += usb.o
 obj-$(CONFIG_DM_PMIC) += pmic.o
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 13/16] sandbox: spi: Add more debugging to SPI emulation
  2016-02-15  1:36 ` [U-Boot] [PATCH 13/16] sandbox: spi: Add more debugging to SPI emulation Simon Glass
@ 2016-02-15 19:01   ` Jagan Teki
  0 siblings, 0 replies; 33+ messages in thread
From: Jagan Teki @ 2016-02-15 19:01 UTC (permalink / raw)
  To: u-boot

On 15 February 2016 at 07:06, Simon Glass <sjg@chromium.org> wrote:
> Add a little more debugging to help when things go wrong.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

Reviewed-by: Jagan Teki <jteki@openedev.com>
Tested-by: Jagan Teki <jteki@openedev.com>

-- 
Jagan.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free()
  2016-02-15  1:36 ` [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free() Simon Glass
@ 2016-02-15 19:02   ` Jagan Teki
  2016-02-15 22:37   ` Tom Rini
  1 sibling, 0 replies; 33+ messages in thread
From: Jagan Teki @ 2016-02-15 19:02 UTC (permalink / raw)
  To: u-boot

On 15 February 2016 at 07:06, Simon Glass <sjg@chromium.org> wrote:
> We must not free data that is managed by driver mode. Remove this line,
> which is a hangover from the pre-driver-model code.
>
> This fixes a problem where 'sf probe' crashes U-Boot if the backing file
> for the SPI flash cannot be found.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

Reviewed-by: Jagan Teki <jteki@openedev.com>
Tested-by: Jagan Teki <jteki@openedev.com>

-- 
Jagan.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 15/16] spi: Correct two error return values
  2016-02-15  1:36 ` [U-Boot] [PATCH 15/16] spi: Correct two error return values Simon Glass
@ 2016-02-15 19:10   ` Jagan Teki
  0 siblings, 0 replies; 33+ messages in thread
From: Jagan Teki @ 2016-02-15 19:10 UTC (permalink / raw)
  To: u-boot

On 15 February 2016 at 07:06, Simon Glass <sjg@chromium.org> wrote:
> When an error number is provided we should use it, not change it. This fixes
> the SPI and SPI flash tests.
>
> One of these is long-standing. The other seems to have been introduced by
> commit 1e90d9fd (sf: Move read_id code to sf_ops).
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Fixes: 1e90d9fd (sf: Move read_id code to sf_ops)
> ---

Reviewed-by: Jagan Teki <jteki@openedev.com>
Tested-by: Jagan Teki <jteki@openedev.com>

-- 
Jagan.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 16/16] spi: Re-enable the SPI flash tests
  2016-02-15  1:37 ` [U-Boot] [PATCH 16/16] spi: Re-enable the SPI flash tests Simon Glass
@ 2016-02-15 19:10   ` Jagan Teki
  0 siblings, 0 replies; 33+ messages in thread
From: Jagan Teki @ 2016-02-15 19:10 UTC (permalink / raw)
  To: u-boot

On 15 February 2016 at 07:07, Simon Glass <sjg@chromium.org> wrote:
> These are working correctly again, so re-enable them.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

Reviewed-by: Jagan Teki <jteki@openedev.com>
Tested-by: Jagan Teki <jteki@openedev.com>

-- 
Jagan.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free()
  2016-02-15  1:36 ` [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free() Simon Glass
  2016-02-15 19:02   ` Jagan Teki
@ 2016-02-15 22:37   ` Tom Rini
  1 sibling, 0 replies; 33+ messages in thread
From: Tom Rini @ 2016-02-15 22:37 UTC (permalink / raw)
  To: u-boot

On Sun, Feb 14, 2016 at 06:36:58PM -0700, Simon Glass wrote:

> We must not free data that is managed by driver mode. Remove this line,
> which is a hangover from the pre-driver-model code.
> 
> This fixes a problem where 'sf probe' crashes U-Boot if the backing file
> for the SPI flash cannot be found.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160215/048b791c/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/16] trace: Fix compiler warnings in trace
  2016-02-15  1:36 ` [U-Boot] [PATCH 04/16] trace: Fix compiler warnings in trace Simon Glass
@ 2016-02-16  9:21   ` Bin Meng
  0 siblings, 0 replies; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:21 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> With min() we must use the same type for each parameter. Fix two problems
> in trace.c which produce compiler warnings.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  cmd/trace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 05/16] lib: Don't instrument the div64 function
  2016-02-15  1:36 ` [U-Boot] [PATCH 05/16] lib: Don't instrument the div64 function Simon Glass
@ 2016-02-16  9:21   ` Bin Meng
  0 siblings, 0 replies; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:21 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> This function can be called from the timer code on instrumented functions.
> Mark it as 'notrace' so that it doesn't cause infinite recursion.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  lib/div64.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 07/16] timer: Support tracing fully
  2016-02-15  1:36 ` [U-Boot] [PATCH 07/16] timer: Support tracing fully Simon Glass
@ 2016-02-16  9:21   ` Bin Meng
  2016-02-23  6:37     ` Simon Glass
  0 siblings, 1 reply; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:21 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> A few of the functions in the timer uclass are not marked with 'notrace'. Fix
> this so that tracing can be used with CONFIG_TRACE.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/timer/timer-uclass.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
> index 83d1a35..382c0f2 100644
> --- a/drivers/timer/timer-uclass.c
> +++ b/drivers/timer/timer-uclass.c
> @@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
>   * tick, and no timer interrupt.
>   */
>
> -int timer_get_count(struct udevice *dev, u64 *count)
> +int notrace timer_get_count(struct udevice *dev, u64 *count)
>  {
>         const struct timer_ops *ops = device_get_ops(dev);
>
> @@ -32,9 +32,9 @@ int timer_get_count(struct udevice *dev, u64 *count)
>         return ops->get_count(dev, count);

Besides making timer_get_count() and timer_get_rate() APIs notrace,
does it help to make the timer uclass ops notrace as well?

>  }
>
> -unsigned long timer_get_rate(struct udevice *dev)
> +unsigned long notrace timer_get_rate(struct udevice *dev)
>  {
> -       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> +       struct timer_dev_priv *uc_priv = dev->uclass_priv;

Why is this change needed?

>
>         return uc_priv->clock_rate;
>  }
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 08/16] timer: Provide an early timer
  2016-02-15  1:36 ` [U-Boot] [PATCH 08/16] timer: Provide an early timer Simon Glass
@ 2016-02-16  9:21   ` Bin Meng
  2016-02-23  6:37     ` Simon Glass
  0 siblings, 1 reply; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:21 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> In some cases the timer must be accessible before driver model is active.
> Examples include when using CONFIG_TRACE to trace U-Boot's execution before
> driver model is set up. Enable this option to use an early timer. These
> functions must be supported by your timer driver: timer_early_get_count()
> and timer_early_get_rate().
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/timer/Kconfig | 10 ++++++++++
>  include/timer.h       | 21 +++++++++++++++++++++
>  lib/time.c            | 28 +++++++++++++++++++++-------
>  3 files changed, 52 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
> index ff65a73..cb18f12 100644
> --- a/drivers/timer/Kconfig
> +++ b/drivers/timer/Kconfig
> @@ -9,6 +9,16 @@ config TIMER
>           will be used. The timer is usually a 32 bits free-running up
>           counter. There may be no real tick, and no timer interrupt.
>
> +config TIMER_EARLY
> +       bool "Allow timer to be used early in U-Boot"
> +       depends on TIMER
> +       help
> +         In some cases the timer must be accessible before driver model is
> +         active. Examples include when using CONFIG_TRACE to trace U-Boot's
> +         execution before driver model is set up. Enable this option to
> +         use an early timer. These functions must be supported by your timer
> +         driver: timer_early_get_count() and timer_early_get_rate().
> +
>  config ALTERA_TIMER
>         bool "Altera timer support"
>         depends on TIMER
> diff --git a/include/timer.h b/include/timer.h
> index f14725c..a503bfd 100644
> --- a/include/timer.h
> +++ b/include/timer.h
> @@ -67,4 +67,25 @@ struct timer_dev_priv {
>         unsigned long clock_rate;
>  };
>
> +/**
> + * timer_early_get_count() - Implement timer_get_count() before driver model
> + *
> + * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
> + * the current timer value before the proper driver model timer is ready.
> + * It should be implemented by one of the timer values. This is mostly useful
> + * for tracing.
> + */
> +u64 timer_early_get_count(void);
> +
> +/**
> + * timer_early_get_rate() - Get the timer rate before driver model
> + *
> + * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
> + * the current timer rate  in Hz before the proper driver model timer is ready.

nits: two spaces between 'rate' and 'in'

> + * It should be implemented by one of the timer values. This is mostly useful
> + * for tracing. This corresponds to the clock_rate value in struct
> + * timer_dev_priv.

Is this supposed to be a hard-codeded value returned by the timer
driver? The timer-uclass driver gets this clock rate from device tree,
but I believe at that time when early timer is called, FDT blob might
not be available yet.

> + */
> +unsigned long timer_early_get_rate(void);
> +
>  #endif /* _TIMER_H_ */

[snip]

Regards,
Bin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 09/16] timer: Set up the real timer after driver model is available
  2016-02-15  1:36 ` [U-Boot] [PATCH 09/16] timer: Set up the real timer after driver model is available Simon Glass
@ 2016-02-16  9:21   ` Bin Meng
  0 siblings, 0 replies; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:21 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> When using the early timer, we need to manually trigger setting up the
> real timer. This will not happen automatically. Do this immediately after
> starting driver model.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/board_f.c |  6 ++++++
>  common/board_r.c | 14 ++++++++++++--
>  2 files changed, 18 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer
  2016-02-15  1:36 ` [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer Simon Glass
@ 2016-02-16  9:22   ` Bin Meng
  2016-02-23  6:37     ` Simon Glass
  0 siblings, 1 reply; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:22 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> Add support for the early timer so we can use tracing with sandbox again.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/timer/sandbox_timer.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c
> index a8da936..4537c82 100644
> --- a/drivers/timer/sandbox_timer.c
> +++ b/drivers/timer/sandbox_timer.c
> @@ -18,9 +18,19 @@ void sandbox_timer_add_offset(unsigned long offset)
>         sandbox_timer_offset += offset;
>  }
>
> -static int sandbox_timer_get_count(struct udevice *dev, u64 *count)
> +u64 notrace timer_early_get_count(void)
>  {
> -       *count = os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
> +       return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
> +}
> +
> +unsigned long notrace timer_early_get_rate(void)
> +{
> +       return 1000000;

Hard-coded?

> +}
> +
> +static notrace int sandbox_timer_get_count(struct udevice *dev, u64 *count)
> +{
> +       *count = timer_early_get_count();
>
>         return 0;
>  }
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 12/16] sandbox: Enable the early timer
  2016-02-15  1:36 ` [U-Boot] [PATCH 12/16] sandbox: Enable the early timer Simon Glass
@ 2016-02-16  9:22   ` Bin Meng
  0 siblings, 0 replies; 33+ messages in thread
From: Bin Meng @ 2016-02-16  9:22 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
> Enable this so that tracing works with sandbox.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  configs/sandbox_defconfig | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 00/16] image: Fix various test failures
  2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
                   ` (15 preceding siblings ...)
  2016-02-15  1:37 ` [U-Boot] [PATCH 16/16] spi: Re-enable the SPI flash tests Simon Glass
@ 2016-02-16 22:03 ` Stephen Warren
  16 siblings, 0 replies; 33+ messages in thread
From: Stephen Warren @ 2016-02-16 22:03 UTC (permalink / raw)
  To: u-boot

On 02/14/2016 06:36 PM, Simon Glass wrote:
> Recent changes have broken the FIT and vboot tests. Also the SPI tests have
> been wrong since before the last release and were disabled.
>
> This series collects together the required fixes.
>
> Note: The FIT and vboot tests are hard to run (in that each requires manual
> effort). At some point we should be able to bring these into Stephen Warren's
> test framework.

The series,
Tested-by: Stephen Warren <swarren@nvidia.com>
(via ./test/py/test.py --bd sandbox --build)

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 07/16] timer: Support tracing fully
  2016-02-16  9:21   ` Bin Meng
@ 2016-02-23  6:37     ` Simon Glass
  0 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-23  6:37 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 16 February 2016 at 02:21, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
>> A few of the functions in the timer uclass are not marked with 'notrace'. Fix
>> this so that tracing can be used with CONFIG_TRACE.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  drivers/timer/timer-uclass.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
>> index 83d1a35..382c0f2 100644
>> --- a/drivers/timer/timer-uclass.c
>> +++ b/drivers/timer/timer-uclass.c
>> @@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
>>   * tick, and no timer interrupt.
>>   */
>>
>> -int timer_get_count(struct udevice *dev, u64 *count)
>> +int notrace timer_get_count(struct udevice *dev, u64 *count)
>>  {
>>         const struct timer_ops *ops = device_get_ops(dev);
>>
>> @@ -32,9 +32,9 @@ int timer_get_count(struct udevice *dev, u64 *count)
>>         return ops->get_count(dev, count);
>
> Besides making timer_get_count() and timer_get_rate() APIs notrace,
> does it help to make the timer uclass ops notrace as well?

I don't think so. From what I can this needs to be done in each driver.

>
>>  }
>>
>> -unsigned long timer_get_rate(struct udevice *dev)
>> +unsigned long notrace timer_get_rate(struct udevice *dev)
>>  {
>> -       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
>> +       struct timer_dev_priv *uc_priv = dev->uclass_priv;
>
> Why is this change needed?

To avoid a function call, and the notrace problem.

>
>>
>>         return uc_priv->clock_rate;
>>  }
>> --
>
> Regards,
> Bin

Regards,
Simon

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 08/16] timer: Provide an early timer
  2016-02-16  9:21   ` Bin Meng
@ 2016-02-23  6:37     ` Simon Glass
  0 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-23  6:37 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 16 February 2016 at 02:21, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
>> In some cases the timer must be accessible before driver model is active.
>> Examples include when using CONFIG_TRACE to trace U-Boot's execution before
>> driver model is set up. Enable this option to use an early timer. These
>> functions must be supported by your timer driver: timer_early_get_count()
>> and timer_early_get_rate().
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  drivers/timer/Kconfig | 10 ++++++++++
>>  include/timer.h       | 21 +++++++++++++++++++++
>>  lib/time.c            | 28 +++++++++++++++++++++-------
>>  3 files changed, 52 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
>> index ff65a73..cb18f12 100644
>> --- a/drivers/timer/Kconfig
>> +++ b/drivers/timer/Kconfig
>> @@ -9,6 +9,16 @@ config TIMER
>>           will be used. The timer is usually a 32 bits free-running up
>>           counter. There may be no real tick, and no timer interrupt.
>>
>> +config TIMER_EARLY
>> +       bool "Allow timer to be used early in U-Boot"
>> +       depends on TIMER
>> +       help
>> +         In some cases the timer must be accessible before driver model is
>> +         active. Examples include when using CONFIG_TRACE to trace U-Boot's
>> +         execution before driver model is set up. Enable this option to
>> +         use an early timer. These functions must be supported by your timer
>> +         driver: timer_early_get_count() and timer_early_get_rate().
>> +
>>  config ALTERA_TIMER
>>         bool "Altera timer support"
>>         depends on TIMER
>> diff --git a/include/timer.h b/include/timer.h
>> index f14725c..a503bfd 100644
>> --- a/include/timer.h
>> +++ b/include/timer.h
>> @@ -67,4 +67,25 @@ struct timer_dev_priv {
>>         unsigned long clock_rate;
>>  };
>>
>> +/**
>> + * timer_early_get_count() - Implement timer_get_count() before driver model
>> + *
>> + * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
>> + * the current timer value before the proper driver model timer is ready.
>> + * It should be implemented by one of the timer values. This is mostly useful
>> + * for tracing.
>> + */
>> +u64 timer_early_get_count(void);
>> +
>> +/**
>> + * timer_early_get_rate() - Get the timer rate before driver model
>> + *
>> + * If CONFIG_TIMER_EARLY is enabled, this function wil be called to return
>> + * the current timer rate  in Hz before the proper driver model timer is ready.
>
> nits: two spaces between 'rate' and 'in'
>
>> + * It should be implemented by one of the timer values. This is mostly useful
>> + * for tracing. This corresponds to the clock_rate value in struct
>> + * timer_dev_priv.
>
> Is this supposed to be a hard-codeded value returned by the timer
> driver? The timer-uclass driver gets this clock rate from device tree,
> but I believe at that time when early timer is called, FDT blob might
> not be available yet.

Possibly, although the FDT is available pretty early. I doubt anyone
would need to call the timer that early.

>
>> + */
>> +unsigned long timer_early_get_rate(void);
>> +
>>  #endif /* _TIMER_H_ */
>
> [snip]
>
> Regards,
> Bin

Regards,
Simon

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer
  2016-02-16  9:22   ` Bin Meng
@ 2016-02-23  6:37     ` Simon Glass
  0 siblings, 0 replies; 33+ messages in thread
From: Simon Glass @ 2016-02-23  6:37 UTC (permalink / raw)
  To: u-boot

Hi Bin

On 16 February 2016 at 02:22, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Mon, Feb 15, 2016 at 9:36 AM, Simon Glass <sjg@chromium.org> wrote:
>> Add support for the early timer so we can use tracing with sandbox again.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  drivers/timer/sandbox_timer.c | 14 ++++++++++++--
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c
>> index a8da936..4537c82 100644
>> --- a/drivers/timer/sandbox_timer.c
>> +++ b/drivers/timer/sandbox_timer.c
>> @@ -18,9 +18,19 @@ void sandbox_timer_add_offset(unsigned long offset)
>>         sandbox_timer_offset += offset;
>>  }
>>
>> -static int sandbox_timer_get_count(struct udevice *dev, u64 *count)
>> +u64 notrace timer_early_get_count(void)
>>  {
>> -       *count = os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
>> +       return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
>> +}
>> +
>> +unsigned long notrace timer_early_get_rate(void)
>> +{
>> +       return 1000000;
>
> Hard-coded?

Yes - I'll convert it to a constant. But since the OS calls use
nanoseconds and want to convert to milliseconds it is hard-coded.
>
>> +}
>> +
>> +static notrace int sandbox_timer_get_count(struct udevice *dev, u64 *count)
>> +{
>> +       *count = timer_early_get_count();
>>
>>         return 0;
>>  }
>> --
>
> Regards,
> Bin

Regards,
Simon

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2016-02-23  6:37 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-15  1:36 [U-Boot] [PATCH 00/16] image: Fix various test failures Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 01/16] image: Correct the OS location code to work on sandbox Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 02/16] Revert "image-fit: Fix signature checking" Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 03/16] image: Fix FIT and vboot tests to exit sandbox correctly Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 04/16] trace: Fix compiler warnings in trace Simon Glass
2016-02-16  9:21   ` Bin Meng
2016-02-15  1:36 ` [U-Boot] [PATCH 05/16] lib: Don't instrument the div64 function Simon Glass
2016-02-16  9:21   ` Bin Meng
2016-02-15  1:36 ` [U-Boot] [PATCH 06/16] trace: Improve the trace test number recognition Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 07/16] timer: Support tracing fully Simon Glass
2016-02-16  9:21   ` Bin Meng
2016-02-23  6:37     ` Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 08/16] timer: Provide an early timer Simon Glass
2016-02-16  9:21   ` Bin Meng
2016-02-23  6:37     ` Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 09/16] timer: Set up the real timer after driver model is available Simon Glass
2016-02-16  9:21   ` Bin Meng
2016-02-15  1:36 ` [U-Boot] [PATCH 10/16] sandbox: timer: Support the early timer Simon Glass
2016-02-16  9:22   ` Bin Meng
2016-02-23  6:37     ` Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 11/16] sandbox: Correct ordering of defconfig Simon Glass
2016-02-15  1:36 ` [U-Boot] [PATCH 12/16] sandbox: Enable the early timer Simon Glass
2016-02-16  9:22   ` Bin Meng
2016-02-15  1:36 ` [U-Boot] [PATCH 13/16] sandbox: spi: Add more debugging to SPI emulation Simon Glass
2016-02-15 19:01   ` Jagan Teki
2016-02-15  1:36 ` [U-Boot] [PATCH 14/16] sandbox: spi: Remove an incorrect free() Simon Glass
2016-02-15 19:02   ` Jagan Teki
2016-02-15 22:37   ` Tom Rini
2016-02-15  1:36 ` [U-Boot] [PATCH 15/16] spi: Correct two error return values Simon Glass
2016-02-15 19:10   ` Jagan Teki
2016-02-15  1:37 ` [U-Boot] [PATCH 16/16] spi: Re-enable the SPI flash tests Simon Glass
2016-02-15 19:10   ` Jagan Teki
2016-02-16 22:03 ` [U-Boot] [PATCH 00/16] image: Fix various test failures Stephen Warren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.