From patchwork Wed Sep 9 16:10:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 1360727 X-Patchwork-Delegate: trini@ti.com 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=85.214.62.61; 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=SbKeZrpZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4Bmn9D5dJfz9sVm for ; Thu, 10 Sep 2020 02:10:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7BC6C82189; Wed, 9 Sep 2020 18:10:14 +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="SbKeZrpZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D04BD821ED; Wed, 9 Sep 2020 18:10:13 +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-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) (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 A4B5081B79 for ; Wed, 9 Sep 2020 18:10:09 +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-xf43.google.com with SMTP id f11so1798994qvw.3 for ; Wed, 09 Sep 2020 09:10:09 -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=0RFEQp8hm8ZqNHSMXo1uTYjpLIJv3BU5u2ZvriKM6UY=; b=SbKeZrpZWaWMxGN64qFivp3yb/E2JfR1UC4jMylafmzq9FEG4EuAJlFnAVcbdQO8KZ 8QDR9bAhrbNN5SXuRymDM5ncL9NzMf00RzIZOQ3qVuRDImnYrHYUXY5/8ffvuEoCfdMH YoTKlE0asjUuYieXaRXWMssWpPYT0ri1b+hpdqOdey9sHHUk1iumdGhEWvWgTK7P2ZHV R4F8Pws88/RiK6um2hUnU1vOBDCbBOzhZs9xwNz9dJV6FFClvcoT2okk+MqDMaOY86Zb /0o8kS+JZmy3/tpxX8XWtWLnjZjUd9GzPXpxRE+2AUgcEfmhBJKPIF43O/vMAAEkqXNj pskQ== 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=0RFEQp8hm8ZqNHSMXo1uTYjpLIJv3BU5u2ZvriKM6UY=; b=Vk/BTpC1rCFyudMMD78zHdDCs3p3tCFeCjqAwACALyBi8yd3rU7iuxi8C2ZWfVPCpA 2cr5kQrsTMzVCIouCnlmPpBOMhn43ZglhYWecAz7SCL2cLF8RceA1Oz4ds32XTZzuJbi gZsWjfAo/JbJUGMhyVpqZiindbMqB2r5sisBHUtNlJo6xWoBx4Halp2LZsK39exjIrkg F2TW5HEVShlnFfXqCEAEk8NdlUSzHJJh0k6QRPnqkUhXnoTSV0G9ptEddDTZPPNUSd9a z63tPpiGYmCLiTxIy14u8Qn0hYjembqSwPDD3BvlRyRW77Wom4+7Uc+mTpOWEe4DPbJW 6GXw== X-Gm-Message-State: AOAM532c34Y4WOyHImsi6rsodgZc55HaLfQ8EYzk23iLHZBdaMxlxzBZ ni/vSxcXWJZZfsMjva2cYMeEgcfRhyhguA== X-Google-Smtp-Source: ABdhPJwA3pMv4JCG1p5BA19PbTzPzF9QD8hc/fPLdWQGiJwFNWiZCs7ndwjNIc17ycjF0VkFwvwa9w== X-Received: by 2002:a0c:b3de:: with SMTP id b30mr4028939qvf.37.1599667805003; Wed, 09 Sep 2020 09:10:05 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id 202sm2850574qkg.56.2020.09.09.09.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 09:10:03 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Cc: sr@denx.de, trini@konsulko.com, Ralph Siemsen Subject: [PATCH v5] cmd: mem: fix range of bitflip test Date: Wed, 9 Sep 2020 12:10:00 -0400 Message-Id: <20200909161000.10840-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 Reviewed-by: Stefan Roese --- Changes in v5: - Correct logic for updating error count Changes in v4: - Avoid #ifdef in the code Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94 --- cmd/Kconfig | 12 ++++++++++++ cmd/mem.c | 21 ++++++++++++++++----- 2 files changed, 28 insertions(+), 5 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..dc4a0ffab3 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) { @@ -986,11 +998,10 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc, errs = mem_test_alt(buf, start, end, dummy); 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)) { + count += errs; + errs = mem_test_bitflip(buf, start, end); + } } else { errs = mem_test_quick(buf, start, end, pattern, iteration);