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: 249508 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6011:0:0:0:0 with SMTP id o17csp661924ejj; Wed, 9 Sep 2020 09:10:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZX44zOrWgV38ZhX3W4UqNmwPiUejEbwqBLg7vZs5EipCn81IUhema+bAgRwrYmnasDGHk X-Received: by 2002:a17:906:4bd7:: with SMTP id x23mr4295375ejv.92.1599667816366; Wed, 09 Sep 2020 09:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599667816; cv=none; d=google.com; s=arc-20160816; b=Y/0rEnALSHOSuOhIdiMUXIC1EOEU6vHmjNTIR3qJLEcURA6RnBdenP/5sahFMq5MIU W2EfEcxLZjwhYvDS63nQUC5LV+nL5g0ozQYxhSb5jN2d1fwExC60NkQmhsEDXu3ETJac LiPLP9RzCPKpaL5IFUEnnhI/x0LALBu8uxMkbM/HnvJAkcfMNWgXB8YJBQ4zxRYa8v7b lWZqMeLdmZtWAcko5E19DZzhvnl3QeZi73lHvfkZ29FkQeWX4/208qp+f+VVTET2BBz6 1DFbebO4zO7T9WUo6WISrHn5ZU0gjRM20LqYEe6SqFXnxTI0KFX1hEOGq5eezJmfXYUa PjVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0RFEQp8hm8ZqNHSMXo1uTYjpLIJv3BU5u2ZvriKM6UY=; b=nXx5XkBRDObkqXfCD78eoOf9/UiuGFg3284RWbUV+M2Rz41xoMI53W+5DmSlHOV0vq pHlF75e2KuHH10oWtQJvlzkfjDl8Wbn87j93Zx/Vm4Ki3thVtE6a/hl8kh8V2fWMS1Bq qpgZRLApRSrSFxbu1w+kUq4E6rQG1xDDIjtqrLLAEXsig3LOZPhs2I8E8NlkPB2dALvT 9vgy+q/JJ5ko08MCGpFG1/0lrWKfBv+UwXqP4UsB0u42XxiQ/JdpIlgErKM74klpJy1S 9vsrJZ1LIin+YAsYpP8c4BB5m4zMB/HvdDjyemCfpJVftjvX2rJ4dWYl0ZAWIVfo8KvW klsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbKeZrpZ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id x11si1745944edr.460.2020.09.09.09.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 09:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbKeZrpZ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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 -- 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(-) -- 2.17.1 Reviewed-by: Stefan Roese 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);