From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCBDCC54EAA for ; Fri, 27 Jan 2023 12:17:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4B28851EB; Fri, 27 Jan 2023 13:17:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1674821857; bh=ues+KlCNIIRmEH4OUsr41PsF3IIfsgCbCT2j40CuuLI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JJ9FqBBdQFDOgvm0CCDjsm+T9i1H8XOSEMSBuAaFlVh8Uax9sXSA/G9jSscVNLbfN A0ky5MjAnre4TjHBd+UFunBFty2qjCqx3gGgVYb5P8CmDNCNXkpTGUvtqgUmBspuE6 LngndI/rzK63eQAltHQbahAVBx1rbXaJKbbCxelS5xIiTGkbbU4o1bm3Yb7sTLgwoT 7XT7seJWYt0WHzyP2bQdOyxECXCwfRupzlcdrSlyCfzyxahTYTUTpnAHPVzn+vZR0W KuTJ6XQD4b5tAxeyOqA67RV47i9Ae5mA/jCTw3vuMmsxcBCYbfOApFmGH0vHFN0Wl3 QwPw58qLXzA7w== Received: by phobos.denx.de (Postfix, from userid 109) id 5E6A7854C7; Fri, 27 Jan 2023 13:17:34 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:101:465::204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 591A884EEF for ; Fri, 27 Jan 2023 13:17:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4P3GmN6JFGz9sTg; Fri, 27 Jan 2023 13:17:24 +0100 (CET) Message-ID: <5088be33-90e0-e1fa-bb58-e486a234db8d@denx.de> Date: Fri, 27 Jan 2023 13:17:23 +0100 MIME-Version: 1.0 Subject: Re: [PATCH 1/1] cmd: fix mtest on 64 bit systems Content-Language: en-US To: Heinrich Schuchardt , Tom Rini Cc: Simon Glass , u-boot@lists.denx.de References: <20230127000912.32529-1-heinrich.schuchardt@canonical.com> From: Stefan Roese In-Reply-To: <20230127000912.32529-1-heinrich.schuchardt@canonical.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4P3GmN6JFGz9sTg X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Stefan Roese 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