* [U-Boot-Users] [PATCH] Fix wrong memory limit calculation in memory-test
@ 2008-02-07 16:40 Guennadi Liakhovetski
2008-02-07 18:54 ` Jerry Van Baren
0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2008-02-07 16:40 UTC (permalink / raw)
To: u-boot
If the length of the memory address range passed to the "mtest" command is
not of the form 2^x - 1, not all address lines are tested. This bug is
inherited from the original software at
http://www.netrino.com/Embedded-Systems/How-To/Memory-Test-Suite-C. Fix
this.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index a994211..2b55e7e 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -661,7 +661,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong readback;
#if defined(CFG_ALT_MEMTEST)
- vu_long addr_mask;
+ vu_long len;
vu_long offset;
vu_long test_offset;
vu_long pattern;
@@ -800,24 +800,24 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
* Returns: 0 if the test succeeds, 1 if the test fails.
*
* ## NOTE ## Be sure to specify start and end
- * addresses such that addr_mask has
+ * addresses such that len has
* lots of bits set. For example an
* address range of 01000000 02000000 is
* bad while a range of 01000000
* 01ffffff is perfect.
*/
- addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
+ len = ((ulong)end - (ulong)start)/sizeof(vu_long);
pattern = (vu_long) 0xaaaaaaaa;
anti_pattern = (vu_long) 0x55555555;
PRINTF("%s:%d: addr mask = 0x%.8lx\n",
__FUNCTION__, __LINE__,
- addr_mask);
+ len);
/*
* Write the default pattern at each of the
* power-of-two offsets.
*/
- for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+ for (offset = 1; offset < len; offset <<= 1) {
start[offset] = pattern;
}
@@ -827,7 +827,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
test_offset = 0;
start[test_offset] = anti_pattern;
- for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+ for (offset = 1; offset < len; offset <<= 1) {
temp = start[offset];
if (temp != pattern) {
printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
@@ -841,10 +841,10 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/*
* Check for addr bits stuck low or shorted.
*/
- for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) {
+ for (test_offset = 1; test_offset < len; test_offset <<= 1) {
start[test_offset] = anti_pattern;
- for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+ for (offset = 1; offset < len; offset <<= 1) {
temp = start[offset];
if ((temp != pattern) && (offset != test_offset)) {
printf ("\nFAILURE: Address bit stuck low or shorted @"
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot-Users] [PATCH] Fix wrong memory limit calculation in memory-test
2008-02-07 16:40 [U-Boot-Users] [PATCH] Fix wrong memory limit calculation in memory-test Guennadi Liakhovetski
@ 2008-02-07 18:54 ` Jerry Van Baren
2008-02-08 20:25 ` [U-Boot-Users] [PATCH v2] " Guennadi Liakhovetski
0 siblings, 1 reply; 4+ messages in thread
From: Jerry Van Baren @ 2008-02-07 18:54 UTC (permalink / raw)
To: u-boot
Guennadi Liakhovetski wrote:
> If the length of the memory address range passed to the "mtest" command is
> not of the form 2^x - 1, not all address lines are tested. This bug is
> inherited from the original software at
> http://www.netrino.com/Embedded-Systems/How-To/Memory-Test-Suite-C. Fix
> this.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> ---
>
> diff --git a/common/cmd_mem.c b/common/cmd_mem.c
> index a994211..2b55e7e 100644
> --- a/common/cmd_mem.c
> +++ b/common/cmd_mem.c
> @@ -661,7 +661,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
> ulong readback;
>
> #if defined(CFG_ALT_MEMTEST)
> - vu_long addr_mask;
> + vu_long len;
> vu_long offset;
> vu_long test_offset;
> vu_long pattern;
> @@ -800,24 +800,24 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
> * Returns: 0 if the test succeeds, 1 if the test fails.
> *
The "## NOTE ##" doesn't really apply any more. Besides that, generally
"start" and "end" are constrained by the system (hardware and software
configuration) so "picking" them is a nebulous concept. I would simply
delete the note.
> * ## NOTE ## Be sure to specify start and end
> - * addresses such that addr_mask has
> + * addresses such that len has
> * lots of bits set. For example an
> * address range of 01000000 02000000 is
> * bad while a range of 01000000
> * 01ffffff is perfect.
> */
> - addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
> + len = ((ulong)end - (ulong)start)/sizeof(vu_long);
> pattern = (vu_long) 0xaaaaaaaa;
> anti_pattern = (vu_long) 0x55555555;
>
> PRINTF("%s:%d: addr mask = 0x%.8lx\n",
s/addr mask/len/ in the printf() string
> __FUNCTION__, __LINE__,
> - addr_mask);
> + len);
Otherwise, good!
Thanks,
gvb
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot-Users] [PATCH v2] Fix wrong memory limit calculation in memory-test
2008-02-07 18:54 ` Jerry Van Baren
@ 2008-02-08 20:25 ` Guennadi Liakhovetski
2008-02-14 23:51 ` Wolfgang Denk
0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2008-02-08 20:25 UTC (permalink / raw)
To: u-boot
If the length of the memory address range passed to the "mtest" command is
not of the form 2^x - 1, not all address lines are tested. This bug is
inherited from the original software at
http://www.netrino.com/Embedded-Systems/How-To/Memory-Test-Suite-C. Fix
this.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
This is version 2 of the yesterday's patch, further taking into account
suggestions by Jerry Van Baren.
Thanks
Guennadi
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index a994211..7569851 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -661,7 +661,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong readback;
#if defined(CFG_ALT_MEMTEST)
- vu_long addr_mask;
+ vu_long len;
vu_long offset;
vu_long test_offset;
vu_long pattern;
@@ -798,26 +798,19 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
* all possible.
*
* Returns: 0 if the test succeeds, 1 if the test fails.
- *
- * ## NOTE ## Be sure to specify start and end
- * addresses such that addr_mask has
- * lots of bits set. For example an
- * address range of 01000000 02000000 is
- * bad while a range of 01000000
- * 01ffffff is perfect.
*/
- addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
+ len = ((ulong)end - (ulong)start)/sizeof(vu_long);
pattern = (vu_long) 0xaaaaaaaa;
anti_pattern = (vu_long) 0x55555555;
- PRINTF("%s:%d: addr mask = 0x%.8lx\n",
+ PRINTF("%s:%d: length = 0x%.8lx\n",
__FUNCTION__, __LINE__,
- addr_mask);
+ len);
/*
* Write the default pattern at each of the
* power-of-two offsets.
*/
- for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+ for (offset = 1; offset < len; offset <<= 1) {
start[offset] = pattern;
}
@@ -827,7 +820,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
test_offset = 0;
start[test_offset] = anti_pattern;
- for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+ for (offset = 1; offset < len; offset <<= 1) {
temp = start[offset];
if (temp != pattern) {
printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
@@ -841,10 +834,10 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/*
* Check for addr bits stuck low or shorted.
*/
- for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) {
+ for (test_offset = 1; test_offset < len; test_offset <<= 1) {
start[test_offset] = anti_pattern;
- for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
+ for (offset = 1; offset < len; offset <<= 1) {
temp = start[offset];
if ((temp != pattern) && (offset != test_offset)) {
printf ("\nFAILURE: Address bit stuck low or shorted @"
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot-Users] [PATCH v2] Fix wrong memory limit calculation in memory-test
2008-02-08 20:25 ` [U-Boot-Users] [PATCH v2] " Guennadi Liakhovetski
@ 2008-02-14 23:51 ` Wolfgang Denk
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2008-02-14 23:51 UTC (permalink / raw)
To: u-boot
In message <Pine.LNX.4.64.0802082122570.8364@axis700.grange> you wrote:
> If the length of the memory address range passed to the "mtest" command is
> not of the form 2^x - 1, not all address lines are tested. This bug is
> inherited from the original software at
> http://www.netrino.com/Embedded-Systems/How-To/Memory-Test-Suite-C. Fix
> this.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I wish Captain Vimes were here. He wouldn't have known what to do
either, but he's got a much better vocabulary to be baffled in.
- Terry Pratchett, _Guards! Guards!_
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-02-14 23:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-07 16:40 [U-Boot-Users] [PATCH] Fix wrong memory limit calculation in memory-test Guennadi Liakhovetski
2008-02-07 18:54 ` Jerry Van Baren
2008-02-08 20:25 ` [U-Boot-Users] [PATCH v2] " Guennadi Liakhovetski
2008-02-14 23:51 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox