From patchwork Mon Apr 28 13:14:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 343402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 50ED71400A4 for ; Mon, 28 Apr 2014 23:16:39 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WelP2-0004tm-5I; Mon, 28 Apr 2014 13:15:24 +0000 Received: from mail-yk0-f173.google.com ([209.85.160.173]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WelOx-0003bY-TB for linux-mtd@lists.infradead.org; Mon, 28 Apr 2014 13:15:20 +0000 Received: by mail-yk0-f173.google.com with SMTP id 131so753870ykp.18 for ; Mon, 28 Apr 2014 06:14:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ub4yOTTAKTpf0oPkwV1YNHB2pr/X2MoDaDYAjgNuewA=; b=FlQNwFWiZ/NYjQL3SafGZMkrmB8Sar0sAc4dHAA8S/8DqcDr0mQmlKhkRHLkz1ione gF3RjrIHsgmfS/JyylRxPruA9VzMehDBFQOKR4RsPJ0ze1oFg6kpC2hpqpf65i4xC4cX vRu7F37oiseCjz68fqVyLTSQPO6RWrjjJ55p4cJ5x8e0QGoHiPn5RhjHO9d9VFAKjZFn eJ46WDkXPd0Rl4PF2exwBl76icikR99IRWo9DdHhQIbg9veZTBds+RpHXmJc5gVh1tBz WySLQPfWX6r7Nga5xIc+xDVc7noP9RZCR8nCJIlDp70QOVu0Dx0OSsPQ1K8EsSXsIitq c4Lw== X-Gm-Message-State: ALoCoQlqzEsy+fQz5+OZcUbq23T8uEQWGYhkP8IX/WGl0rw/wCyYdzrejEfS5K6V4JYZpafwB5mq X-Received: by 10.236.134.140 with SMTP id s12mr2498790yhi.138.1398690896084; Mon, 28 Apr 2014 06:14:56 -0700 (PDT) Received: from localhost.localdomain ([190.2.108.30]) by mx.google.com with ESMTPSA id t63sm30428656yhm.32.2014.04.28.06.14.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Apr 2014 06:14:55 -0700 (PDT) From: Ezequiel Garcia To: , Artem Bityutskiy Subject: [PATCH 3/3] nandtest: Introduce multiple reads & check iterations Date: Mon, 28 Apr 2014 10:14:19 -0300 Message-Id: <1398690859-11494-4-git-send-email-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398690859-11494-1-git-send-email-ezequiel@vanguardiasur.com.ar> References: <1398690859-11494-1-git-send-email-ezequiel@vanguardiasur.com.ar> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140428_061520_023276_4FB38151 X-CRM114-Status: GOOD ( 15.03 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.173 listed in list.dnswl.org] Cc: Brian Norris , Ezequiel Garcia , =?UTF-8?q?Guido=20Mart=C3=ADnez?= X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The current nandtest performs a simple test which consists of: 1. erase block 2. write data 3. read and verify In order to improve the nandtest strength, this commit adds a new parameter to increase the number of "read and verify" iterations. In other words, the test now consists of: 1. erase block 2. write data 3. read and verify (N times) This seem to apply more pressure on a NAND driver's ECC engine and has been used to discover stability problems with an old OMAP2. Signed-off-by: Ezequiel Garcia --- nandtest.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/nandtest.c b/nandtest.c index 31301d6..32877b8 100644 --- a/nandtest.c +++ b/nandtest.c @@ -24,6 +24,7 @@ void usage(int status) " -m, --markbad Mark blocks bad if they appear so\n" " -s, --seed Supply random seed\n" " -p, --passes Number of passes\n" + " -r, --reads Read & check iterations per pass (default=1)\n" " -o, --offset Start offset on flash\n" " -l, --length Length of flash to test\n" " -k, --keep Restore existing contents after test\n", @@ -37,14 +38,11 @@ int fd; int markbad=0; int seed; -void read_and_compare(loff_t ofs, unsigned char *data, unsigned char *rbuf) +int read_and_compare(loff_t ofs, unsigned char *data, unsigned char *rbuf) { ssize_t len; int i; - printf("\r%08x: reading...", (unsigned)ofs); - fflush(stdout); - len = pread(fd, rbuf, meminfo.erasesize, ofs); if (len < meminfo.erasesize) { printf("\n"); @@ -84,14 +82,16 @@ void read_and_compare(loff_t ofs, unsigned char *data, unsigned char *rbuf) printf("Byte 0x%x is %02x should be %02x\n", i, rbuf[i], data[i]); } - exit(1); + return 1; } + return 0; } -int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf) +int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf, int nr_reads) { struct erase_info_user er; ssize_t len; + int i, read_errs = 0; printf("\r%08x: erasing... ", (unsigned)ofs); fflush(stdout); @@ -127,7 +127,16 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf) exit(1); } - read_and_compare(ofs, data, rbuf); + for (i=1; i<=nr_reads; i++) { + printf("\r%08x: reading (%d of %d)...", (unsigned)ofs, i, nr_reads); + fflush(stdout); + if (read_and_compare(ofs, data, rbuf)) + read_errs++; + } + if (read_errs) { + fprintf(stderr, "read/check %d of %d failed. seed %d\n", read_errs, nr_reads, seed); + return 1; + } return 0; } @@ -141,6 +150,7 @@ int main(int argc, char **argv) unsigned char *wbuf, *rbuf, *kbuf; int pass; int nr_passes = 1; + int nr_reads = 1; int keep_contents = 0; uint32_t offset = 0; uint32_t length = -1; @@ -148,7 +158,7 @@ int main(int argc, char **argv) seed = time(NULL); for (;;) { - static const char short_options[] = "hkl:mo:p:s:"; + static const char short_options[] = "hkl:mo:p:r:s:"; static const struct option long_options[] = { { "help", no_argument, 0, 'h' }, { "markbad", no_argument, 0, 'm' }, @@ -156,6 +166,7 @@ int main(int argc, char **argv) { "passes", required_argument, 0, 'p' }, { "offset", required_argument, 0, 'o' }, { "length", required_argument, 0, 'l' }, + { "reads", optional_argument, 0, 'r' }, { "keep", no_argument, 0, 'k' }, {0, 0, 0, 0}, }; @@ -189,6 +200,10 @@ int main(int argc, char **argv) nr_passes = atol(optarg); break; + case 'r': + nr_reads = atol(optarg); + break; + case 'o': offset = atol(optarg); break; @@ -286,10 +301,10 @@ int main(int argc, char **argv) exit(1); } } - if (erase_and_write(test_ofs, wbuf, rbuf)) + if (erase_and_write(test_ofs, wbuf, rbuf, nr_reads)) continue; if (keep_contents) - erase_and_write(test_ofs, kbuf, rbuf); + erase_and_write(test_ofs, kbuf, rbuf, 1); } printf("\nFinished pass %d successfully\n", pass+1); }