From patchwork Tue Feb 5 08:21:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 218199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 800EA2C02E8 for ; Tue, 5 Feb 2013 20:22:15 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U2eiL-00075H-4s; Tue, 05 Feb 2013 09:21:17 +0000 Received: from co1ehsobe005.messaging.microsoft.com ([216.32.180.188] helo=co1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U2eiG-00073c-5U for linux-mtd@lists.infradead.org; Tue, 05 Feb 2013 09:21:13 +0000 Received: from mail29-co1-R.bigfish.com (10.243.78.217) by CO1EHSOBE039.bigfish.com (10.243.66.104) with Microsoft SMTP Server id 14.1.225.23; Tue, 5 Feb 2013 09:21:09 +0000 Received: from mail29-co1 (localhost [127.0.0.1]) by mail29-co1-R.bigfish.com (Postfix) with ESMTP id 4943F720103; Tue, 5 Feb 2013 09:21:09 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1ee6h1de0h1202h1e76h1d1ah1d2ah1082kzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h1155h) Received: from mail29-co1 (localhost.localdomain [127.0.0.1]) by mail29-co1 (MessageSwitch) id 1360056064611250_23615; Tue, 5 Feb 2013 09:21:04 +0000 (UTC) Received: from CO1EHSMHS016.bigfish.com (unknown [10.243.78.210]) by mail29-co1.bigfish.com (Postfix) with ESMTP id 9295FDC0059; Tue, 5 Feb 2013 09:21:04 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS016.bigfish.com (10.243.66.26) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 5 Feb 2013 09:21:04 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.318.3; Tue, 5 Feb 2013 09:21:03 +0000 Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r159Kw1g016623; Tue, 5 Feb 2013 02:20:59 -0700 From: Huang Shijie To: Subject: [PATCH v2] mtd: torturetest: add the support for random data pattern Date: Tue, 5 Feb 2013 16:21:25 +0800 Message-ID: <1360052485-11961-1-git-send-email-b32955@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130205_042112_386529_E13A119B X-CRM114-Status: GOOD ( 16.85 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.32.180.188 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: ricard.wanderlof@axis.com, Huang Shijie , linux-mtd@lists.infradead.org, dedekind1@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add a new module parameter 'pattern'. The meaning of the pattern is: (1) pattern == 0 for 55/AA pattern. (2) pattern < 0 for random pattern. (3) pattern > 0 for random pattern too, the value of the pattern is used as the seed for the random generator. Signed-off-by: Huang Shijie --- v1 --> v2: add the seed support. --- drivers/mtd/tests/mtd_torturetest.c | 82 +++++++++++++++++++++++++--------- 1 files changed, 60 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c index 516cf66..5481c99 100644 --- a/drivers/mtd/tests/mtd_torturetest.c +++ b/drivers/mtd/tests/mtd_torturetest.c @@ -32,6 +32,7 @@ #include #include #include +#include #define RETRIES 3 @@ -64,6 +65,13 @@ module_param(cycles_count, uint, S_IRUGO); MODULE_PARM_DESC(cycles_count, "how many erase cycles to do " "(infinite by default)"); +static int pattern; +module_param(pattern, int, S_IRUGO); +MODULE_PARM_DESC(pattern, "0 for 55/AA pattern(default);" + "less then 0 for random pattern;" + "greater then 0 for random too, " + "the value of the pattern is the seed."); + static struct mtd_info *mtd; /* This buffer contains 0x555555...0xAAAAAA... pattern */ @@ -72,6 +80,8 @@ static unsigned char *patt_5A5; static unsigned char *patt_A5A; /* This buffer contains all 0xFF bytes */ static unsigned char *patt_FF; +/* This buffer contains the random data. */ +static unsigned char *patt_rd; /* This a temporary buffer is use when checking data */ static unsigned char *check_buf; /* How many erase cycles were done */ @@ -228,6 +238,12 @@ static int __init tort_init(void) pr_info("torturing just %d pages per eraseblock\n", pgcnt); pr_info("write verify %s\n", check ? "enabled" : "disabled"); + if (pattern == 0) + pr_info("Test pattern is 55/AA.\n"); + else if (pattern < 0) + pr_info("Test pattern is random.\n"); + else + pr_info("Test pattern is random, seed is 0x%d.\n", pattern); mtd = get_mtd_device(NULL, dev); if (IS_ERR(mtd)) { @@ -249,16 +265,24 @@ static int __init tort_init(void) } err = -ENOMEM; - patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!patt_5A5) { - pr_err("error: cannot allocate memory\n"); - goto out_mtd; - } + if (!pattern) { + patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL); + if (!patt_5A5) { + pr_err("error: cannot allocate memory\n"); + goto out_mtd; + } - patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!patt_A5A) { - pr_err("error: cannot allocate memory\n"); - goto out_patt_5A5; + patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL); + if (!patt_A5A) { + pr_err("error: cannot allocate memory\n"); + goto out_patt_5A5; + } + } else { + patt_rd = kmalloc(mtd->erasesize, GFP_KERNEL); + if (!patt_rd) { + pr_err("error: cannot allocate memory\n"); + goto out_patt_rd; + } } patt_FF = kmalloc(mtd->erasesize, GFP_KERNEL); @@ -277,14 +301,20 @@ static int __init tort_init(void) /* Initialize patterns */ memset(patt_FF, 0xFF, mtd->erasesize); - for (i = 0; i < mtd->erasesize / pgsize; i++) { - if (!(i & 1)) { - memset(patt_5A5 + i * pgsize, 0x55, pgsize); - memset(patt_A5A + i * pgsize, 0xAA, pgsize); - } else { - memset(patt_5A5 + i * pgsize, 0xAA, pgsize); - memset(patt_A5A + i * pgsize, 0x55, pgsize); + if (!pattern) { + for (i = 0; i < mtd->erasesize / pgsize; i++) { + if (!(i & 1)) { + memset(patt_5A5 + i * pgsize, 0x55, pgsize); + memset(patt_A5A + i * pgsize, 0xAA, pgsize); + } else { + memset(patt_5A5 + i * pgsize, 0xAA, pgsize); + memset(patt_A5A + i * pgsize, 0x55, pgsize); + } } + } else { + /* set the seed. */ + if (pattern > 0) + prandom_seed(pattern); } /* @@ -335,10 +365,15 @@ static int __init tort_init(void) } /* Write the pattern */ - if ((eb + erase_cycles) & 1) - patt = patt_5A5; - else - patt = patt_A5A; + if (!pattern) { + if ((eb + erase_cycles) & 1) + patt = patt_5A5; + else + patt = patt_A5A; + } else { + patt = patt_rd; + prandom_bytes(patt, mtd->erasesize); + } err = write_pattern(i, patt); if (err) goto out; @@ -350,8 +385,9 @@ static int __init tort_init(void) if (err) { pr_info("verify failed for %s" " pattern\n", - ((eb + erase_cycles) & 1) ? - "0x55AA55..." : "0xAA55AA..."); + pattern ? "random pattern" : + (((eb + erase_cycles) & 1) ? + "0x55AA55..." : "0xAA55AA...")); goto out; } cond_resched(); @@ -386,6 +422,8 @@ out_patt_A5A: kfree(patt_A5A); out_patt_5A5: kfree(patt_5A5); +out_patt_rd: + kfree(patt_rd); out_mtd: put_mtd_device(mtd); if (err)