From: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mtest: Disable dcache during test
Date: Fri, 10 Aug 2012 21:16:15 +0200 (CEST) [thread overview]
Message-ID: <1902435786.2282282.1344626175261.JavaMail.root@advansee.com> (raw)
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;
}
next reply other threads:[~2012-08-10 19:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 19:16 Benoît Thébaudeau [this message]
2012-08-11 3:18 ` [U-Boot] [PATCH] mtest: Disable dcache during test 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
[not found] <CANYL96C2=fYHoTAp0SQird-Yz1W2JPq22U=3q4ZFKgwomXxODA@mail.gmail.com>
2012-08-11 20:05 ` Benoît Thébaudeau
2012-08-11 20:15 ` Mike Frysinger
2012-08-11 20:25 ` Benoît Thébaudeau
2012-08-14 6:27 ` Albert ARIBAUD
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=1902435786.2282282.1344626175261.JavaMail.root@advansee.com \
--to=benoit.thebaudeau@advansee.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox