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: 249506 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp529369ilg; Wed, 9 Sep 2020 08:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYPp20MkU64312NcA3H5pSeuF/9Hi7uD2S3lvjCKyRj+IrI+DJpobbfX6ZRyr0d+FSdgrn X-Received: by 2002:a50:cd5d:: with SMTP id d29mr4915857edj.318.1599666173820; Wed, 09 Sep 2020 08:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599666173; cv=none; d=google.com; s=arc-20160816; b=gSZttSS+svsgDoyphCm4t7vOyi2S0LOqxloR3SsNpwjRqdnTPT4cuBjGzUjZ40upG6 f005x84tP2d8QeEVwEzBbtyCwfr6HmIRNf5mJMzagJmC3UsSmaKsswFG4t8ewRw4g/UE MY1VRlTdX11qswse/pTiYhxNqQcHG9T4oY+I/QMlLbX8UAIpXE8Km72x8bsmGb8vKYDZ BxldYy4FzFO6uBbAfRGJ10UjXdJljOcilxvi9Lho2INk+j2XywyLQn4ifGxs2ZipjUyL f9p1/pT7qkAKpJzhwVoCEzfWT8k3sBQxRog+kkhkRRwkX4260hHjFtY+3Mi3QmieGKat 9BnQ== 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=yqWggYGygICHZh0ky3yWxbh8Qp7X4KXvG7XRs+ZnqPg=; b=EcENOr9uXgUP1TeWyqfOOc8NhERcg5K9soUn5bUf2X6Ti+BJz4bNDv6p1lUavUVXHw a43JcV88AKLs12VXCouqez7fGIo8vTEeAd9TEMtNtQ+FctvQ1PD3uHVf9ilGiPi6Cr4u 4jLUJi0LMLY6dFH23HcQIOgsgxmgdSQeyzKHyCwPnrhxHRCIHJ/d515WZ1FWLzIsHX1f oDiATuMkqOSV8gJo0oWnVQj1ykgXSwcdctS6XWASfmFOvEwpeNH/jcmgR9sYGXDhkqxk x/2f7H1RbNptBl2NgMPOvuYP4lLaFAlBCF0LUF2PpeYA0vJO1AtC0osF6EU6rDRJms0g S1Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LGG7hP04; 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 mb19si1751378ejb.589.2020.09.09.08.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 08:42:53 -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=LGG7hP04; 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 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-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(-) -- 2.17.1 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);