mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
mtd: torturetest: Support random pattern
insmod /oem/mtd_torturetest.ko dev=5 check=0 cycles_count=10 random_pattern=1 Change-Id: I8919da8241e7d3af6925aa7a377027e0c3d7d7f8 Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/mtd/mtd.h>
|
#include <linux/mtd/mtd.h>
|
||||||
|
#include <linux/random.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include "mtd_test.h"
|
#include "mtd_test.h"
|
||||||
@@ -54,8 +55,14 @@ module_param(cycles_count, uint, S_IRUGO);
|
|||||||
MODULE_PARM_DESC(cycles_count, "how many erase cycles to do "
|
MODULE_PARM_DESC(cycles_count, "how many erase cycles to do "
|
||||||
"(infinite by default)");
|
"(infinite by default)");
|
||||||
|
|
||||||
|
static int random_pattern;
|
||||||
|
module_param(random_pattern, int, S_IRUGO);
|
||||||
|
MODULE_PARM_DESC(random_pattern, "if choose random pattern to program");
|
||||||
|
|
||||||
static struct mtd_info *mtd;
|
static struct mtd_info *mtd;
|
||||||
|
|
||||||
|
/* This buffer contains random pattern */
|
||||||
|
static unsigned char *patt_random;
|
||||||
/* This buffer contains 0x555555...0xAAAAAA... pattern */
|
/* This buffer contains 0x555555...0xAAAAAA... pattern */
|
||||||
static unsigned char *patt_5A5;
|
static unsigned char *patt_5A5;
|
||||||
/* This buffer contains 0xAAAAAA...0x555555... pattern */
|
/* This buffer contains 0xAAAAAA...0x555555... pattern */
|
||||||
@@ -210,9 +217,13 @@ static int __init tort_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
|
patt_random = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
|
if (!patt_random)
|
||||||
|
goto out_mtd;
|
||||||
|
|
||||||
patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL);
|
patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
if (!patt_5A5)
|
if (!patt_5A5)
|
||||||
goto out_mtd;
|
goto out_patt_random;
|
||||||
|
|
||||||
patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL);
|
patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||||
if (!patt_A5A)
|
if (!patt_A5A)
|
||||||
@@ -244,6 +255,8 @@ static int __init tort_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prandom_bytes(patt_random, mtd->erasesize);
|
||||||
|
|
||||||
err = mtdtest_scan_for_bad_eraseblocks(mtd, bad_ebs, eb, ebcnt);
|
err = mtdtest_scan_for_bad_eraseblocks(mtd, bad_ebs, eb, ebcnt);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -283,6 +296,8 @@ static int __init tort_init(void)
|
|||||||
patt = patt_5A5;
|
patt = patt_5A5;
|
||||||
else
|
else
|
||||||
patt = patt_A5A;
|
patt = patt_A5A;
|
||||||
|
if (random_pattern)
|
||||||
|
patt = patt_random;
|
||||||
err = write_pattern(i, patt);
|
err = write_pattern(i, patt);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -301,8 +316,14 @@ static int __init tort_init(void)
|
|||||||
patt = patt_5A5;
|
patt = patt_5A5;
|
||||||
else
|
else
|
||||||
patt = patt_A5A;
|
patt = patt_A5A;
|
||||||
|
if (random_pattern)
|
||||||
|
patt = patt_random;
|
||||||
err = check_eraseblock(i, patt);
|
err = check_eraseblock(i, patt);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (random_pattern) {
|
||||||
|
pr_info("verify failed for random pattern\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
pr_info("verify failed for %s"
|
pr_info("verify failed for %s"
|
||||||
" pattern\n",
|
" pattern\n",
|
||||||
((eb + erase_cycles) & 1) ?
|
((eb + erase_cycles) & 1) ?
|
||||||
@@ -345,6 +366,8 @@ out_patt_A5A:
|
|||||||
kfree(patt_A5A);
|
kfree(patt_A5A);
|
||||||
out_patt_5A5:
|
out_patt_5A5:
|
||||||
kfree(patt_5A5);
|
kfree(patt_5A5);
|
||||||
|
out_patt_random:
|
||||||
|
kfree(patt_random);
|
||||||
out_mtd:
|
out_mtd:
|
||||||
put_mtd_device(mtd);
|
put_mtd_device(mtd);
|
||||||
if (err)
|
if (err)
|
||||||
|
|||||||
Reference in New Issue
Block a user