mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
Use common mtest iteration counting
The iteration code is the same for each version of the memory test, so pull it out into the common function. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c9638f50fb
commit
51209b1f42
1 changed files with 59 additions and 64 deletions
123
common/cmd_mem.c
123
common/cmd_mem.c
|
@ -626,11 +626,9 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_LOOPW */
|
#endif /* CONFIG_LOOPW */
|
||||||
|
|
||||||
static int mem_test_alt(vu_long *start, vu_long *end,
|
static ulong mem_test_alt(vu_long *start, vu_long *end)
|
||||||
int iteration_limit)
|
|
||||||
{
|
{
|
||||||
vu_long *addr;
|
vu_long *addr;
|
||||||
int iterations = 1;
|
|
||||||
ulong errs = 0;
|
ulong errs = 0;
|
||||||
ulong val, readback;
|
ulong val, readback;
|
||||||
int j;
|
int j;
|
||||||
|
@ -657,27 +655,6 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
0xaaaaaaaa, /* alternating 1/0 */
|
0xaaaaaaaa, /* alternating 1/0 */
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start,
|
|
||||||
(uint)(uintptr_t)end);
|
|
||||||
debug("%s:%d: start 0x%p end 0x%p\n",
|
|
||||||
__func__, __LINE__, start, end);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (ctrlc()) {
|
|
||||||
putc('\n');
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iteration_limit && iterations > iteration_limit) {
|
|
||||||
printf("Tested %d iteration(s) with %lu errors.\n",
|
|
||||||
iterations-1, errs);
|
|
||||||
return errs != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Iteration: %6d\r", iterations);
|
|
||||||
debug("\n");
|
|
||||||
iterations++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data line test: write a pattern to the first
|
* Data line test: write a pattern to the first
|
||||||
* location, write the 1's complement to a 'parking'
|
* location, write the 1's complement to a 'parking'
|
||||||
|
@ -710,7 +687,7 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*addr = ~val;
|
*addr = ~val;
|
||||||
|
@ -723,7 +700,7 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -791,7 +768,7 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -813,7 +790,7 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -855,7 +832,7 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,37 +854,38 @@ static int mem_test_alt(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start[offset] = 0;
|
start[offset] = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mem_test_quick(vu_long *start, vu_long *end,
|
static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern,
|
||||||
int iteration_limit, vu_long pattern)
|
int iteration)
|
||||||
{
|
{
|
||||||
vu_long *addr;
|
vu_long *addr;
|
||||||
int iterations = 1;
|
|
||||||
ulong errs = 0;
|
ulong errs = 0;
|
||||||
ulong incr;
|
ulong incr;
|
||||||
ulong val, readback;
|
ulong val, readback;
|
||||||
|
|
||||||
|
/* Alternate the pattern */
|
||||||
incr = 1;
|
incr = 1;
|
||||||
for (;;) {
|
if (iteration & 1) {
|
||||||
if (ctrlc()) {
|
incr = -incr;
|
||||||
putc('\n');
|
/*
|
||||||
return 1;
|
* Flip the pattern each time to make lots of zeros and
|
||||||
}
|
* then, the next time, lots of ones. We decrement
|
||||||
|
* the "negative" patterns and increment the "positive"
|
||||||
if (iteration_limit && iterations > iteration_limit) {
|
* patterns to preserve this feature.
|
||||||
printf("Tested %d iteration(s) with %lu errors.\n",
|
*/
|
||||||
iterations-1, errs);
|
if (pattern & 0x80000000)
|
||||||
return errs != 0;
|
pattern = -pattern; /* complement & increment */
|
||||||
}
|
else
|
||||||
++iterations;
|
pattern = ~pattern;
|
||||||
|
}
|
||||||
printf("\rPattern %08lX Writing..."
|
printf("\rPattern %08lX Writing..."
|
||||||
"%12s"
|
"%12s"
|
||||||
"\b\b\b\b\b\b\b\b\b\b",
|
"\b\b\b\b\b\b\b\b\b\b",
|
||||||
|
@ -931,24 +909,13 @@ static int mem_test_quick(vu_long *start, vu_long *end,
|
||||||
errs++;
|
errs++;
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val += incr;
|
val += incr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
return 0;
|
||||||
* Flip the pattern each time to make lots of zeros and
|
|
||||||
* then, the next time, lots of ones. We decrement
|
|
||||||
* the "negative" patterns and increment the "positive"
|
|
||||||
* patterns to preserve this feature.
|
|
||||||
*/
|
|
||||||
if (pattern & 0x80000000)
|
|
||||||
pattern = -pattern; /* complement & increment */
|
|
||||||
else
|
|
||||||
pattern = ~pattern;
|
|
||||||
incr = -incr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -962,7 +929,9 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
vu_long *start, *end;
|
vu_long *start, *end;
|
||||||
int iteration_limit;
|
int iteration_limit;
|
||||||
int ret;
|
int ret;
|
||||||
|
ulong errs = 0; /* number of errors, or -1 if interrupted */
|
||||||
ulong pattern;
|
ulong pattern;
|
||||||
|
int iteration;
|
||||||
#if defined(CONFIG_SYS_ALT_MEMTEST)
|
#if defined(CONFIG_SYS_ALT_MEMTEST)
|
||||||
const int alt_test = 1;
|
const int alt_test = 1;
|
||||||
#else
|
#else
|
||||||
|
@ -989,10 +958,36 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
else
|
else
|
||||||
iteration_limit = 0;
|
iteration_limit = 0;
|
||||||
|
|
||||||
if (alt_test)
|
printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start,
|
||||||
ret = mem_test_alt(start, end, iteration_limit);
|
(uint)(uintptr_t)end);
|
||||||
else
|
debug("%s:%d: start 0x%p end 0x%p\n",
|
||||||
ret = mem_test_quick(start, end, iteration_limit, pattern);
|
__func__, __LINE__, start, end);
|
||||||
|
|
||||||
|
for (iteration = 0;
|
||||||
|
!iteration_limit || iteration < iteration_limit;
|
||||||
|
iteration++) {
|
||||||
|
if (ctrlc()) {
|
||||||
|
putc('\n');
|
||||||
|
errs = -1UL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Iteration: %6d\r", iteration + 1);
|
||||||
|
debug("\n");
|
||||||
|
if (alt_test)
|
||||||
|
errs = mem_test_alt(start, end);
|
||||||
|
else
|
||||||
|
errs = mem_test_quick(start, end, pattern, iteration);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errs == -1UL) {
|
||||||
|
/* Memory test was aborted */
|
||||||
|
ret = 1;
|
||||||
|
} else {
|
||||||
|
printf("Tested %d iteration(s) with %lu errors.\n",
|
||||||
|
iteration, errs);
|
||||||
|
ret = errs != 0;
|
||||||
|
}
|
||||||
|
|
||||||
return ret; /* not reached */
|
return ret; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue