From patchwork Wed Sep 9 15:21:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 249461 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp513144ilg; Wed, 9 Sep 2020 08:21:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQzbovHQm/DHT4xu47WApo+FES+xflJkROAYB6PFk2ZOAiQf1fxofpyBF4DxI0yvPpfI7o X-Received: by 2002:a17:906:9245:: with SMTP id c5mr4465777ejx.54.1599664918850; Wed, 09 Sep 2020 08:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599664918; cv=none; d=google.com; s=arc-20160816; b=GX+RiBd3zTCKfOTSJdbCUTnroJeTuEvp/9VfJ5fM8juZaOBFgJ7hKhPyVlHWtFxEpp qrWEEdFX0095+k3zcQWBTdnMC31J3zSnGKIiYPvB/SLP+gGObuZyLtuifSZkoPMP4RoZ nw2yZQ4OGLPGzJ9JMoqgecHuSXIKe1m7q5w4Oj36paV3VMH0jnPy5KtlYPQozqOy7MY3 icNv+tI4KmaVPhhe10cRb3SOd6tYxLwMGe+wqg5WDvm7eQ77f2GhGG3xyo+REqWsW6R4 fglMHvtDjP9/MHCCT4TQvCqABIia9Ps56dgzkdq2GbLqhLQ4PT4rNFHQrgKHfHsxkc1o txiQ== 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=h0C4RjWKExYh2EISA1TT/mWiTkbSi0b1uFhALJfjAAA=; b=0z1iV/Un0hdmi4hcR2V47XzpCR4UTrNW8Wrg4ofE0BbbUatzt75uEjeuVMnEyDo1vG /7sUjP8PlaGLso6fEeUiKzsO5AkkvIqR2klVJdeJ1K5/UWrrR37MTU+WGIIEpA4bwiue b2m7zaHndbvlgK63w2cdGCNRtFQ5tKGUOTraejNpPZ9LFty0ybC5UUNSMPqlK2R9c1hV KvC4PLzdNmftBcgD9ktihdy90MOLFMe9JqBxtK/346La6YxJ9HtFg44AfKyIBDUwtzfu 96KC6fnmIVTylFSEFnof7EsaDdz4DCiJDdO0V3Lz6fR/wmUAz9ad6K8IcRqVxGTUn89w gLwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M1paTCME; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id uz13si1626249ejb.531.2020.09.09.08.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 08:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M1paTCME; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 5171781B79; Wed, 9 Sep 2020 17:21:58 +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="M1paTCME"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF27A82189; Wed, 9 Sep 2020 17:21:56 +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-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) (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 1CBD48158B for ; Wed, 9 Sep 2020 17:21:54 +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-xf42.google.com with SMTP id cy2so1716565qvb.0 for ; Wed, 09 Sep 2020 08:21:54 -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=h0C4RjWKExYh2EISA1TT/mWiTkbSi0b1uFhALJfjAAA=; b=M1paTCMEoceqG2JgmvdbFxt2XHiTdjThpIl+bGcDx+IF0ssRQ+6zHdQdXp2IgF318s TOhLwLHKCECfu8tIFgL7yjSUyQMz5GZxvMR21YqE5v7HZPcghnDt3yOruUgOJH8yV3wI +WSIVKYnSf/wD9gcJsXa3IaM8TseS9J9StwzknX9boXqbnXbll2c17vGMGFFDr1wkyQS UI4NP2dnW4jV+9BNyEmpvvD6y/ffoa15612yWP4ToBWPPovOZy5I0g7hKjgrUGan36NF QwevoLBv7ufew/FyY0FmIFkRC7LbMyBxD5cQ9qhp85pJmjTQAcOIQwT5w84Sm7O4K3uy Y8Zw== 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=h0C4RjWKExYh2EISA1TT/mWiTkbSi0b1uFhALJfjAAA=; b=pSjJ4n0dj532irnRxjLQbPHUrJY4Xtz4g3xlmqjEih0Pn66rbT43mFowS0cNo0vTlg FcQcmOEWnlAe5uYrWHjT22/Zh8LicdoXzal0tNunHdLrlxqT/F6IXWWKRm10yAbX4rG/ k3IUZIWg+YN6+hM5IwOlfTnSWhTPPJ+o6rxAB6jQ+4MwBXn/WElBLwH97hiUz9DqOjhZ qWFI3zreXr7xluDvCAZFiI7zSXOoc9UCKepefoScKfCFOKqvox1XnqmzdobFIJBI//Eq FYjqKMzaPPL1p7wWoyUtAWIuda9xkzGF3vXIJRv0r0vZ9PVzY5BhwgqyGbYss/7zKldA Et8w== X-Gm-Message-State: AOAM532SFR5RXKSlV0N4wT51tjfzhIKT1adNRYOi3xcj+wyR5xX+NSZl AcBUGkBHK8nMzkmDGOuf8DymPeTtwvfMVA== X-Received: by 2002:ad4:57a7:: with SMTP id g7mr4615356qvx.10.1599664912712; Wed, 09 Sep 2020 08:21:52 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id i5sm903100qko.86.2020.09.09.08.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 08:21:52 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Cc: sr@denx.de, trini@konsulko.com, Ralph Siemsen Subject: [PATCH v3] cmd: mem: fix range of bitflip test Date: Wed, 9 Sep 2020 11:21:47 -0400 Message-Id: <20200909152147.19528-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200909130201.12885-1-ralph.siemsen@linaro.org> References: <20200909130201.12885-1-ralph.siemsen@linaro.org> 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 v3: - Add Kconfig option to disable bitflip test - Refactor the fix into a helper function Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94 --- cmd/Kconfig | 12 ++++++++++++ cmd/mem.c | 24 ++++++++++++++++++++---- 2 files changed, 32 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..63c4bedf24 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -814,6 +814,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr, return errs; } +#ifdef CONFIG_SYS_ALT_MEMTEST_BITFLIP static int compare_regions(volatile unsigned long *bufa, volatile unsigned long *bufb, size_t count) { @@ -867,6 +868,24 @@ 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); +} +#else +static ulong mem_test_bitflip(vu_long *buf, ulong start, ulong end) +{ + return 0; +} +#endif + static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr, vu_long pattern, int iteration) { @@ -987,10 +1006,7 @@ 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)); + errs = mem_test_bitflip(buf, start, end); } else { errs = mem_test_quick(buf, start, end, pattern, iteration);