All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valentin Longchamp <valentin.longchamp@keymile.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 5/8] POST: add new memory regions test
Date: Thu,  1 Sep 2011 17:39:24 +0200	[thread overview]
Message-ID: <1314891567-6476-6-git-send-email-valentin.longchamp@keymile.com> (raw)
In-Reply-To: <1314891567-6476-1-git-send-email-valentin.longchamp@keymile.com>

This test is similar to the actual POST memory test but quicker and
far less complete. It checks the address and data lines and then only
tests some regularly placed sub regions of the RAM.
This can be useful when we want to test the RAM but we do not have enough
time to run the full memory test.

The POST memory test code was rearranged in order to avoid code duplication
between the two tests but the memory test functionnality remains the same.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
---
Changes for v2:
 - removed bd pointer that was unused
---
 include/post.h        |    2 +
 post/drivers/memory.c |   81 +++++++++++++++++++++++++++++++++++++-----------
 post/tests.c          |   14 ++++++++
 3 files changed, 78 insertions(+), 19 deletions(-)

diff --git a/include/post.h b/include/post.h
index d859f9f..35c86f7 100644
--- a/include/post.h
+++ b/include/post.h
@@ -194,6 +194,8 @@ extern int post_hotkeys_pressed(void);
 #define CONFIG_SYS_POST_BSPEC5		0x00100000
 #define CONFIG_SYS_POST_CODEC		0x00200000
 #define CONFIG_SYS_POST_COPROC		0x00400000
+#define CONFIG_SYS_POST_FLASH		0x00800000
+#define CONFIG_SYS_POST_MEM_REGIONS	0x01000000
 
 int memory_post_test(int flags);
 #endif /* CONFIG_POST */
diff --git a/post/drivers/memory.c b/post/drivers/memory.c
index 66039e5..90af549 100644
--- a/post/drivers/memory.c
+++ b/post/drivers/memory.c
@@ -153,7 +153,7 @@
 #include <post.h>
 #include <watchdog.h>
 
-#if CONFIG_POST & CONFIG_SYS_POST_MEMORY
+#if CONFIG_POST & (CONFIG_SYS_POST_MEMORY | CONFIG_SYS_POST_MEM_REGIONS)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -413,23 +413,29 @@ static int memory_post_test4(unsigned long start, unsigned long size)
 	return ret;
 }
 
-static int memory_post_tests(unsigned long start, unsigned long size)
+static int memory_post_test_lines(unsigned long start, unsigned long size)
 {
 	int ret = 0;
 
-	if (!ret)
-		ret = memory_post_dataline((unsigned long long *)start);
+	ret = memory_post_dataline((unsigned long long *)start);
 	WATCHDOG_RESET();
 	if (!ret)
 		ret = memory_post_addrline((ulong *)start, (ulong *)start,
-						size);
+				size);
 	WATCHDOG_RESET();
 	if (!ret)
-		ret = memory_post_addrline((ulong *)(start + size - 8),
-					    (ulong *)start, size);
+		ret = memory_post_addrline((ulong *)(start+size-8),
+				(ulong *)start, size);
 	WATCHDOG_RESET();
-	if (!ret)
-		ret = memory_post_test1(start, size, 0x00000000);
+
+	return ret;
+}
+
+static int memory_post_test_patterns(unsigned long start, unsigned long size)
+{
+	int ret = 0;
+
+	ret = memory_post_test1(start, size, 0x00000000);
 	WATCHDOG_RESET();
 	if (!ret)
 		ret = memory_post_test1(start, size, 0xffffffff);
@@ -453,6 +459,36 @@ static int memory_post_tests(unsigned long start, unsigned long size)
 	return ret;
 }
 
+static int memory_post_test_regions(unsigned long start, unsigned long size)
+{
+	unsigned long i;
+	int ret = 0;
+
+	for (i = 0; i < (size >> 20) && (!ret); i++) {
+		if (!ret)
+			ret = memory_post_test_patterns(i << 20, 0x800);
+		if (!ret)
+			ret = memory_post_test_patterns((i << 20) + 0xff800,
+				0x800);
+	}
+
+	return ret;
+}
+
+static int memory_post_tests(unsigned long start, unsigned long size)
+{
+	int ret = 0;
+
+	ret = memory_post_test_lines(start, size);
+	if (!ret)
+		ret = memory_post_test_patterns(start, size);
+
+	return ret;
+}
+
+/*
+ * !! this is only valid, if you have contiguous memory banks !!
+ */
 __attribute__((weak))
 int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
 {
@@ -487,6 +523,21 @@ void arch_memory_failure_handle(void)
 	return;
 }
 
+int memory_regions_post_test(int flags)
+{
+	int ret = 0;
+	phys_addr_t phys_offset = 0;
+	u32 memsize, vstart;
+
+	arch_memory_test_prepare(&vstart, &memsize, &phys_offset);
+
+	ret = memory_post_test_lines(vstart, memsize);
+	if (!ret)
+		ret = memory_post_test_regions(vstart, memsize);
+
+	return ret;
+}
+
 int memory_post_test(int flags)
 {
 	int ret = 0;
@@ -499,15 +550,7 @@ int memory_post_test(int flags)
 		if (flags & POST_SLOWTEST) {
 			ret = memory_post_tests(vstart, memsize);
 		} else {			/* POST_NORMAL */
-			unsigned long i;
-			for (i = 0; i < (memsize >> 20) && !ret; i++) {
-				if (!ret)
-					ret = memory_post_tests(vstart +
-						(i << 20), 0x800);
-				if (!ret)
-					ret = memory_post_tests(vstart +
-						(i << 20) + 0xff800, 0x800);
-			}
+			ret = memory_post_test_regions(vstart, memsize);
 		}
 	} while (!ret &&
 		!arch_memory_test_advance(&vstart, &memsize, &phys_offset));
@@ -519,4 +562,4 @@ int memory_post_test(int flags)
 	return ret;
 }
 
-#endif /* CONFIG_POST & CONFIG_SYS_POST_MEMORY */
+#endif /* CONFIG_POST&(CONFIG_SYS_POST_MEMORY|CONFIG_SYS_POST_MEM_REGIONS) */
diff --git a/post/tests.c b/post/tests.c
index 5f59fbb..6896e80 100644
--- a/post/tests.c
+++ b/post/tests.c
@@ -54,6 +54,7 @@ extern int fpga_post_test (int flags);
 extern int lwmon5_watchdog_post_test(int flags);
 extern int sysmon1_post_test(int flags);
 extern int coprocessor_post_test(int flags);
+extern int memory_regions_post_test(int flags);
 
 extern int sysmon_init_f (void);
 
@@ -303,6 +304,19 @@ struct post_test post_list[] =
 	CONFIG_SYS_POST_COPROC
     }
 #endif
+#if CONFIG_POST & CONFIG_SYS_POST_MEM_REGIONS
+    {
+	"Memory regions test",
+	"mem_regions",
+	"This test checks regularly placed regions of the RAM.",
+	POST_ROM | POST_SLOWTEST | POST_PREREL,
+	&memory_regions_post_test,
+	NULL,
+	NULL,
+	CONFIG_SYS_POST_MEM_REGIONS
+    },
+#endif
+
 };
 
 unsigned int post_list_size = sizeof (post_list) / sizeof (struct post_test);
-- 
1.7.1

  parent reply	other threads:[~2011-09-01 15:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 15:39 [U-Boot] [PATCH v2 0/8] POST: support for km_arm and mem_regions test definition Valentin Longchamp
2011-09-01 15:39 ` [U-Boot] [PATCH v2 1/8] POST/arm: adaptations needed for POST on ARM to work Valentin Longchamp
2011-09-01 22:11   ` Mike Frysinger
2011-09-02 12:31     ` Valentin Longchamp
2011-09-01 15:39 ` [U-Boot] [PATCH v2 2/8] POST: add post_log_res field for post results in global data Valentin Longchamp
2011-09-01 22:12   ` Mike Frysinger
2011-09-01 22:35     ` Graeme Russ
2011-09-01 15:39 ` [U-Boot] [PATCH v2 3/8] POST: make env test flags fetching optional Valentin Longchamp
2011-09-01 22:12   ` Mike Frysinger
2011-09-01 15:39 ` [U-Boot] [PATCH v2 4/8] POST: drivers/memory.c coding style cleanup Valentin Longchamp
2011-09-01 15:39 ` Valentin Longchamp [this message]
2011-09-01 22:09   ` [U-Boot] [PATCH v2 5/8] POST: add new memory regions test Mike Frysinger
2011-09-01 15:39 ` [U-Boot] [PATCH v2 6/8] POST/km_arm: add POST memory tests infrastructure Valentin Longchamp
2011-09-01 22:10   ` Mike Frysinger
2011-09-02 12:39     ` Valentin Longchamp
2011-09-02 15:25       ` Mike Frysinger
2011-09-01 15:39 ` [U-Boot] [PATCH v2 7/8] km_arm: change CONFIG_SYS_TEXT_BASE to end of RAM Valentin Longchamp
2011-09-01 15:39 ` [U-Boot] [PATCH v2 8/8] km_arm: enable POST for these boards Valentin Longchamp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314891567-6476-6-git-send-email-valentin.longchamp@keymile.com \
    --to=valentin.longchamp@keymile.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.