From patchwork Wed Sep 9 15:42:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 1360708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=LGG7hP04; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmmW81xxnz9sTd for ; Thu, 10 Sep 2020 01:42:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4679481B79; Wed, 9 Sep 2020 17:42:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LGG7hP04"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF8E882189; Wed, 9 Sep 2020 17:42:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F2D738158B for ; Wed, 9 Sep 2020 17:42:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ralph.siemsen@linaro.org Received: by mail-qv1-xf41.google.com with SMTP id cy2so1756214qvb.0 for ; Wed, 09 Sep 2020 08:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yqWggYGygICHZh0ky3yWxbh8Qp7X4KXvG7XRs+ZnqPg=; b=LGG7hP04t0TIL93LIxiiWJZTBK/DDj9ByEHc1EX/t5V41O/rDUCkFrhKWITSICIKSx c75rn2KkuYTFxEAO/pT5FoSuW/z/S/WnsXxaPQqcJhuACICeG1Sfv81mNvM7GssNR8uW v6zTwSyMNqpWLYObWN1eH/elwna799iQ/rGSykZzHpwDIyglrH4qfanVZbniHbStCvq6 SiJ8zcsLRBkFRHTl/F74T2Z4Xn7IAcZ2f85WkVEuGgO+YQOaIZwat2JhqIWhoBXgM5GB V45iz2mMcjuLV+A8OpSXlpcAiAY+Mst9H3FmFFWwLoQTGZVRaGN4cGAdheYN0moSRdXP zRZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yqWggYGygICHZh0ky3yWxbh8Qp7X4KXvG7XRs+ZnqPg=; b=Oy7o7DS+Mo0zUBqmbrc6iHscj7vgkATrnYtdsa28DJnPRa/XUBqAAl7BO5slKeR4vc PthyvebQcPDvZdgx86BdWyHAtE6zAY2Asspj8FaVkMRhpiuImS93W+V02FTlwYSYZvV0 XwD3j8FfH8VTeqXvhAJm+fXJ/Opu2bxO/zr/GuEottMIctxKafe8/OPxgV+iTOf294Iq 1pNTiYeCkw2+GC2vhVNMYMvFp7URVi8bmCy5iLxDOFAflc27x3hg3F2YDXT3qV1jDcU9 fJboTdAx1gFU/zQB/mIHE3XlfWk7TkeUX7/cvJ45GNNB7yu52kpXiU/5ggg/sfkWkRrw +9MA== X-Gm-Message-State: AOAM530Wq0aGi+3nGkVgPczd3SrqFGrD+7uIaGOn0cGGshbPPM+wNiU1 EFX0QpXpE9Hf+qHKQOh4oq/mqxoA1RhdZQ== X-Google-Smtp-Source: ABdhPJztxxy7JUNYp8GtMwxm6v4Q0XpjeXXx0KUKxx3KQ3uxXbdjAaTuteoTyVmty2Nd6HUtdauTGw== X-Received: by 2002:a0c:f982:: with SMTP id t2mr4446267qvn.5.1599666166148; Wed, 09 Sep 2020 08:42:46 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id l5sm3563115qtc.28.2020.09.09.08.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 08:42:45 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Cc: sr@denx.de, trini@konsulko.com, Ralph Siemsen Subject: [PATCH v4] cmd: mem: fix range of bitflip test Date: Wed, 9 Sep 2020 11:42:43 -0400 Message-Id: <20200909154243.8915-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The bitflip test uses two equal sized memory buffers. This is achieved by splitting the range of memory into two pieces. The address of the second buffer, as well as the length of each buffer, were not correctly calculated. This caused bitflip test to access beyond the end of range. This patch fixes the pointer arithmetic problem. A second problem arises because u-boot "mtest" command expects the ending address to be inclusive. When computing (end - start) this results in missing 1 byte of the requested length. The bitflip test expects a count rather than an "ending" address. Thus it fails to test the last word of the requested range. Fixed by using (end - start + 1). Added Kconfig option to optionally disable the bitflip test, since it does add significantly to the time taken for "mtest". Fixes: 8e434cb705d463bc8cff935160e4fb4c77cb99ab ("cmd: mem: Add bitflip memory test to alternate mtest") Signed-off-by: Ralph Siemsen --- Changes in v4: - Avoid #ifdef in the code Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94 --- cmd/Kconfig | 12 ++++++++++++ cmd/mem.c | 18 ++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index d54acf2cfd..275bf7fbfe 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -779,6 +779,18 @@ config SYS_ALT_MEMTEST help Use a more complete alternative memory test. +if SYS_ALT_MEMTEST + +config SYS_ALT_MEMTEST_BITFLIP + bool "Bitflip test" + default y + help + The alternative memory test includes bitflip test since 2020.07. + The bitflip test significantly increases the overall test time. + Bitflip test can optionally be disabled here. + +endif + config SYS_MEMTEST_START hex "default start address for mtest" default 0 diff --git a/cmd/mem.c b/cmd/mem.c index 9b97f7bf69..63d69ce632 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -867,6 +867,18 @@ static ulong test_bitflip_comparison(volatile unsigned long *bufa, return errs; } +static ulong mem_test_bitflip(vu_long *buf, ulong start, ulong end) +{ + /* + * Split the specified range into two halves. + * Note that mtest range is inclusive of start,end. + * Bitflip test instead uses a count (of 32-bit words). + */ + ulong half_size = (end - start + 1) / 2 / sizeof(unsigned long); + + return test_bitflip_comparison(buf, buf + half_size, half_size); +} + static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr, vu_long pattern, int iteration) { @@ -987,10 +999,8 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc, if (errs == -1UL) break; count += errs; - errs = test_bitflip_comparison(buf, - buf + (end - start) / 2, - (end - start) / - sizeof(unsigned long)); + if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST_BITFLIP)) + errs = mem_test_bitflip(buf, start, end); } else { errs = mem_test_quick(buf, start, end, pattern, iteration);