From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 4/4] cmd: mem: Add bitflip memory test to alternate mtest
Date: Thu, 5 Mar 2020 07:21:32 +0100 [thread overview]
Message-ID: <20200305062132.22932-4-sr@denx.de> (raw)
In-Reply-To: <20200305062132.22932-1-sr@denx.de>
This additional bitflip memory test is inspired by the bitflip test
in memtester v4.3.0. It show some errors on some problematic GARDENA
MT7688 based boards. The other memory tests usually don't show any
errors here.
Signed-off-by: Stefan Roese <sr@denx.de>
---
cmd/mem.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/cmd/mem.c b/cmd/mem.c
index 2ccc7032ad..0bfb6081e7 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -801,6 +801,59 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
return errs;
}
+static int compare_regions(volatile unsigned long *bufa,
+ volatile unsigned long *bufb, size_t count)
+{
+ volatile unsigned long *p1 = bufa;
+ volatile unsigned long *p2 = bufb;
+ int errs = 0;
+ size_t i;
+
+ for (i = 0; i < count; i++, p1++, p2++) {
+ if (*p1 != *p2) {
+ printf("FAILURE: 0x%08lx != 0x%08lx (delta=0x%08lx -> bit %ld) at offset 0x%08lx\n",
+ (unsigned long)*p1, (unsigned long)*p2,
+ *p1 ^ *p2, __ffs(*p1 ^ *p2),
+ (unsigned long)(i * sizeof(unsigned long)));
+ errs++;
+ }
+ }
+
+ return errs;
+}
+
+static ulong test_bitflip_comparison(volatile unsigned long *bufa,
+ volatile unsigned long *bufb, size_t count)
+{
+ volatile unsigned long *p1 = bufa;
+ volatile unsigned long *p2 = bufb;
+ unsigned int j, k;
+ unsigned long q;
+ size_t i;
+ int max;
+ int errs = 0;
+
+ max = sizeof(unsigned long) * 8;
+ for (k = 0; k < max; k++) {
+ q = 0x00000001L << k;
+ for (j = 0; j < 8; j++) {
+ WATCHDOG_RESET();
+ q = ~q;
+ p1 = (volatile unsigned long *)bufa;
+ p2 = (volatile unsigned long *)bufb;
+ for (i = 0; i < count; i++)
+ *p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
+
+ errs += compare_regions(bufa, bufb, count);
+ }
+
+ if (ctrlc())
+ return -1UL;
+ }
+
+ return errs;
+}
+
static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
vu_long pattern, int iteration)
{
@@ -918,6 +971,13 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
debug("\n");
if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST)) {
errs = mem_test_alt(buf, start, end, dummy);
+ if (errs == -1UL)
+ break;
+ count += errs;
+ errs = test_bitflip_comparison(buf,
+ buf + (end - start) / 2,
+ (end - start) /
+ sizeof(unsigned long));
} else {
errs = mem_test_quick(buf, start, end, pattern,
iteration);
--
2.25.1
next prev parent reply other threads:[~2020-03-05 6:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 6:21 [PATCH 1/4] cmd: mem: Correctly count the errors in mtest Stefan Roese
2020-03-05 6:21 ` [PATCH 2/4] cmd: mem: Drop eldk-4.2 workaround and use cast in unmap_sysmem() Stefan Roese
2020-04-21 12:26 ` Tom Rini
2020-03-05 6:21 ` [PATCH 3/4] cmd: mem: Use IS_ENABLED instead of alt_test variable Stefan Roese
2020-04-21 12:26 ` Tom Rini
2020-03-05 6:21 ` Stefan Roese [this message]
2020-04-21 12:26 ` [PATCH 4/4] cmd: mem: Add bitflip memory test to alternate mtest Tom Rini
2020-09-09 1:33 ` [PATCH] cmd: mem: fix range of bitflip test Ralph Siemsen
2020-09-09 8:49 ` Stefan Roese
2020-09-09 13:02 ` [PATCH v2] " Ralph Siemsen
2020-09-09 13:35 ` Stefan Roese
2020-09-09 15:21 ` [PATCH v3] " Ralph Siemsen
2020-09-09 15:30 ` Stefan Roese
2020-09-09 15:42 ` [PATCH v4] " Ralph Siemsen
2020-09-09 16:10 ` [PATCH v5] " Ralph Siemsen
2020-09-10 5:09 ` Stefan Roese
2020-09-19 12:34 ` Tom Rini
2020-09-09 13:06 ` [PATCH] " Ralph Siemsen
2020-09-09 13:34 ` Stefan Roese
2020-09-09 13:49 ` Ralph Siemsen
2020-09-09 13:53 ` Stefan Roese
2020-09-09 15:07 ` Ralph Siemsen
2020-09-09 15:13 ` Stefan Roese
2020-09-09 15:17 ` Ralph Siemsen
2020-04-21 12:26 ` [PATCH 1/4] cmd: mem: Correctly count the errors in mtest Tom Rini
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=20200305062132.22932-4-sr@denx.de \
--to=sr@denx.de \
--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