public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mtest: Disable dcache during test
@ 2012-08-10 19:16 Benoît Thébaudeau
  2012-08-11  3:18 ` Mike Frysinger
  0 siblings, 1 reply; 22+ messages in thread
From: Benoît Thébaudeau @ 2012-08-10 19:16 UTC (permalink / raw)
  To: u-boot

mtest is supposed to test many types of memory accesses in many different
conditions. If dcache is enabled, memory accesses are likely bursts, and some
memory accesses are simply skipped. Hence, dcache should be disabled during
mtest operation so that what mtest actually tests is not masked by dcache.

Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
Cc: Wolfgang Denk <wd@denx.de>
---
 .../common/cmd_mem.c                               |   39 ++++++++++++++------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git u-boot-4d3c95f.orig/common/cmd_mem.c u-boot-4d3c95f/common/cmd_mem.c
index 18f0a3f..5d2b735 100644
--- u-boot-4d3c95f.orig/common/cmd_mem.c
+++ u-boot-4d3c95f/common/cmd_mem.c
@@ -600,6 +600,8 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	ulong	errs = 0;
 	int iterations = 1;
 	int iteration_limit;
+	int dcache;
+	int ret = 1;
 
 #if defined(CONFIG_SYS_ALT_MEMTEST)
 	vu_long	len;
@@ -651,6 +653,13 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	else
 		iteration_limit = 0;
 
+	/* Perform tests on the underlying memory rather than on the D-cache. */
+	dcache = dcache_status();
+	if (dcache) {
+		dcache_disable();
+		invalidate_dcache_all();
+	}
+
 #if defined(CONFIG_SYS_ALT_MEMTEST)
 	printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end);
 	debug("%s:%d: start 0x%p end 0x%p\n",
@@ -659,14 +668,15 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	for (;;) {
 		if (ctrlc()) {
 			putc ('\n');
-			return 1;
+			goto end;
 		}
 
 
 		if (iteration_limit && iterations > iteration_limit) {
 			printf("Tested %d iteration(s) with %lu errors.\n",
 				iterations-1, errs);
-			return errs != 0;
+			ret = errs != 0;
+			goto end;
 		}
 
 		printf("Iteration: %6d\r", iterations);
@@ -704,7 +714,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			    errs++;
 			    if (ctrlc()) {
 				putc ('\n');
-				return 1;
+				goto end;
 			    }
 			}
 			*addr  = ~val;
@@ -717,7 +727,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			    errs++;
 			    if (ctrlc()) {
 				putc ('\n');
-				return 1;
+				goto end;
 			    }
 			}
 		    }
@@ -787,7 +797,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			errs++;
 			if (ctrlc()) {
 			    putc ('\n');
-			    return 1;
+			    goto end;
 			}
 		    }
 		}
@@ -809,7 +819,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			    errs++;
 			    if (ctrlc()) {
 				putc ('\n');
-				return 1;
+				goto end;
 			    }
 			}
 		    }
@@ -851,7 +861,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			errs++;
 			if (ctrlc()) {
 			    putc ('\n');
-			    return 1;
+			    goto end;
 			}
 		    }
 
@@ -873,7 +883,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			errs++;
 			if (ctrlc()) {
 			    putc ('\n');
-			    return 1;
+			    goto end;
 			}
 		    }
 		    start[offset] = 0;
@@ -885,13 +895,14 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	for (;;) {
 		if (ctrlc()) {
 			putc ('\n');
-			return 1;
+			goto end;
 		}
 
 		if (iteration_limit && iterations > iteration_limit) {
 			printf("Tested %d iteration(s) with %lu errors.\n",
 				iterations-1, errs);
-			return errs != 0;
+			ret = errs != 0;
+			goto end;
 		}
 		++iterations;
 
@@ -918,7 +929,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				errs++;
 				if (ctrlc()) {
 					putc ('\n');
-					return 1;
+					goto end;
 				}
 			}
 			val += incr;
@@ -939,7 +950,11 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		incr = -incr;
 	}
 #endif
-	return 0;	/* not reached */
+
+end:
+	if (dcache)
+		dcache_enable();
+	return ret;
 }
 
 

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

end of thread, other threads:[~2012-10-04 14:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CANYL96C2=fYHoTAp0SQird-Yz1W2JPq22U=3q4ZFKgwomXxODA@mail.gmail.com>
2012-08-11 20:05 ` [U-Boot] [PATCH] mtest: Disable dcache during test Benoît Thébaudeau
2012-08-11 20:15   ` Mike Frysinger
2012-08-11 20:25     ` Benoît Thébaudeau
2012-08-13 10:59       ` [U-Boot] [PATCH] mtest: Print dcache state Benoît Thébaudeau
2012-10-03 22:05         ` [U-Boot] " Tom Rini
2012-10-04 11:03           ` Albert ARIBAUD
2012-10-04 11:13             ` Benoît Thébaudeau
2012-10-04 14:15               ` Tom Rini
2012-08-14  6:27     ` [U-Boot] [PATCH] mtest: Disable dcache during test Albert ARIBAUD
2012-08-10 19:16 Benoît Thébaudeau
2012-08-11  3:18 ` Mike Frysinger
2012-08-11 14:17   ` Benoît Thébaudeau
2012-08-11 17:50     ` Mike Frysinger
2012-08-11 18:49       ` Benoît Thébaudeau
2012-09-02 16:30     ` Wolfgang Denk
2012-09-03 14:25       ` Benoît Thébaudeau
2012-09-03 16:50         ` Albert ARIBAUD
2012-09-03 21:14           ` Benoît Thébaudeau
2012-09-03 23:30             ` Graeme Russ
2012-09-04  6:41               ` Wolfgang Denk
2012-09-04  6:43                 ` Graeme Russ
2012-09-04  7:23         ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox