* [PATCH 1/1] cmd: fix mtest on 64 bit systems
@ 2023-01-27 0:09 Heinrich Schuchardt
2023-01-27 12:17 ` Stefan Roese
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2023-01-27 0:09 UTC (permalink / raw)
To: Tom Rini; +Cc: Simon Glass, Stefan Roese, u-boot, Heinrich Schuchardt
* Use 16 digits on 64 bit systems.
* Use 64 bit patterns on 64 bit systems.
* Expect the sign bit in bit 63 on 64 bit systems.
* Adjust the formatting of a constant.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
cmd/mem.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/cmd/mem.c b/cmd/mem.c
index 1e39348195..cf5099253e 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -818,8 +818,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
*
* Returns: 0 if the test succeeds, 1 if the test fails.
*/
- pattern = (vu_long) 0xaaaaaaaa;
- anti_pattern = (vu_long) 0x55555555;
+ pattern = (vu_long)0xaaaaaaaaaaaaaaaa;
+ anti_pattern = (vu_long)0x5555555555555555;
debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
/*
@@ -970,7 +970,7 @@ static ulong test_bitflip_comparison(volatile unsigned long *bufa,
max = sizeof(unsigned long) * 8;
for (k = 0; k < max; k++) {
- q = 0x00000001L << k;
+ q = 1UL << k;
for (j = 0; j < 8; j++) {
schedule();
q = ~q;
@@ -1009,6 +1009,7 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
ulong errs = 0;
ulong incr, length;
ulong val, readback;
+ const int plen = 2 * sizeof(ulong);
/* Alternate the pattern */
incr = 1;
@@ -1020,17 +1021,17 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
* the "negative" patterns and increment the "positive"
* patterns to preserve this feature.
*/
- if (pattern & 0x80000000)
+ if (pattern > (ulong)LONG_MAX)
pattern = -pattern; /* complement & increment */
else
pattern = ~pattern;
}
length = (end_addr - start_addr) / sizeof(ulong);
end = buf + length;
- printf("\rPattern %08lX Writing..."
+ printf("\rPattern %0*lX Writing..."
"%12s"
"\b\b\b\b\b\b\b\b\b\b",
- pattern, "");
+ plen, pattern, "");
for (addr = buf, val = pattern; addr < end; addr++) {
schedule();
@@ -1046,10 +1047,9 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
if (readback != val) {
ulong offset = addr - buf;
- printf("\nMem error @ 0x%08X: "
- "found %08lX, expected %08lX\n",
- (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
- readback, val);
+ printf("\nMem error @ 0x%0*lX: found %0*lX, expected %0*lX\n",
+ plen, start_addr + offset * sizeof(vu_long),
+ plen, readback, plen, val);
errs++;
if (ctrlc())
return -1;
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] cmd: fix mtest on 64 bit systems
2023-01-27 0:09 [PATCH 1/1] cmd: fix mtest on 64 bit systems Heinrich Schuchardt
@ 2023-01-27 12:17 ` Stefan Roese
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2023-01-27 12:17 UTC (permalink / raw)
To: Heinrich Schuchardt, Tom Rini; +Cc: Simon Glass, u-boot
On 1/27/23 01:09, Heinrich Schuchardt wrote:
> * Use 16 digits on 64 bit systems.
> * Use 64 bit patterns on 64 bit systems.
> * Expect the sign bit in bit 63 on 64 bit systems.
> * Adjust the formatting of a constant.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Thanks,
Stefan
> ---
> cmd/mem.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/cmd/mem.c b/cmd/mem.c
> index 1e39348195..cf5099253e 100644
> --- a/cmd/mem.c
> +++ b/cmd/mem.c
> @@ -818,8 +818,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
> *
> * Returns: 0 if the test succeeds, 1 if the test fails.
> */
> - pattern = (vu_long) 0xaaaaaaaa;
> - anti_pattern = (vu_long) 0x55555555;
> + pattern = (vu_long)0xaaaaaaaaaaaaaaaa;
> + anti_pattern = (vu_long)0x5555555555555555;
>
> debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
> /*
> @@ -970,7 +970,7 @@ static ulong test_bitflip_comparison(volatile unsigned long *bufa,
>
> max = sizeof(unsigned long) * 8;
> for (k = 0; k < max; k++) {
> - q = 0x00000001L << k;
> + q = 1UL << k;
> for (j = 0; j < 8; j++) {
> schedule();
> q = ~q;
> @@ -1009,6 +1009,7 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
> ulong errs = 0;
> ulong incr, length;
> ulong val, readback;
> + const int plen = 2 * sizeof(ulong);
>
> /* Alternate the pattern */
> incr = 1;
> @@ -1020,17 +1021,17 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
> * the "negative" patterns and increment the "positive"
> * patterns to preserve this feature.
> */
> - if (pattern & 0x80000000)
> + if (pattern > (ulong)LONG_MAX)
> pattern = -pattern; /* complement & increment */
> else
> pattern = ~pattern;
> }
> length = (end_addr - start_addr) / sizeof(ulong);
> end = buf + length;
> - printf("\rPattern %08lX Writing..."
> + printf("\rPattern %0*lX Writing..."
> "%12s"
> "\b\b\b\b\b\b\b\b\b\b",
> - pattern, "");
> + plen, pattern, "");
>
> for (addr = buf, val = pattern; addr < end; addr++) {
> schedule();
> @@ -1046,10 +1047,9 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
> if (readback != val) {
> ulong offset = addr - buf;
>
> - printf("\nMem error @ 0x%08X: "
> - "found %08lX, expected %08lX\n",
> - (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
> - readback, val);
> + printf("\nMem error @ 0x%0*lX: found %0*lX, expected %0*lX\n",
> + plen, start_addr + offset * sizeof(vu_long),
> + plen, readback, plen, val);
> errs++;
> if (ctrlc())
> return -1;
Viele Grüße,
Stefan Roese
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-27 12:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-27 0:09 [PATCH 1/1] cmd: fix mtest on 64 bit systems Heinrich Schuchardt
2023-01-27 12:17 ` Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox