aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoman Tereshonkov <roman.tereshonkov@nokia.com>2011-02-08 05:02:40 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-03-11 09:22:45 -0500
commit4085bcc682e1276ab4ac2da9866daadf944d7167 (patch)
tree65a3554fa2325860f246ad6460e20b8e49d7a95a /drivers
parentfc7fe7691c6bbd5f8f51a87e759770975c648410 (diff)
mtd: tests: add multiblock erase test to the mtd_speedtest
New multiblock erase speed test is added to mtd_speedtest. It consists of 2-, 4-, 8-, 16-, 32- and 64-blocks at once multiblock erase tests. Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/tests/mtd_speedtest.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 9bd986ef3b53..3ce6fce75e07 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -94,6 +94,33 @@ static int erase_eraseblock(int ebnum)
94 return 0; 94 return 0;
95} 95}
96 96
97static int multiblock_erase(int ebnum, int blocks)
98{
99 int err;
100 struct erase_info ei;
101 loff_t addr = ebnum * mtd->erasesize;
102
103 memset(&ei, 0, sizeof(struct erase_info));
104 ei.mtd = mtd;
105 ei.addr = addr;
106 ei.len = mtd->erasesize * blocks;
107
108 err = mtd->erase(mtd, &ei);
109 if (err) {
110 printk(PRINT_PREF "error %d while erasing EB %d, blocks %d\n",
111 err, ebnum, blocks);
112 return err;
113 }
114
115 if (ei.state == MTD_ERASE_FAILED) {
116 printk(PRINT_PREF "some erase error occurred at EB %d,"
117 "blocks %d\n", ebnum, blocks);
118 return -EIO;
119 }
120
121 return 0;
122}
123
97static int erase_whole_device(void) 124static int erase_whole_device(void)
98{ 125{
99 int err; 126 int err;
@@ -292,7 +319,10 @@ static long calc_speed(void)
292 ms = (finish.tv_sec - start.tv_sec) * 1000 + 319 ms = (finish.tv_sec - start.tv_sec) * 1000 +
293 (finish.tv_usec - start.tv_usec) / 1000; 320 (finish.tv_usec - start.tv_usec) / 1000;
294 k = goodebcnt * mtd->erasesize / 1024; 321 k = goodebcnt * mtd->erasesize / 1024;
295 speed = (k * 1000) / ms; 322 if (ms)
323 speed = (k * 1000) / ms;
324 else
325 speed = 0;
296 return speed; 326 return speed;
297} 327}
298 328
@@ -325,7 +355,7 @@ out:
325 355
326static int __init mtd_speedtest_init(void) 356static int __init mtd_speedtest_init(void)
327{ 357{
328 int err, i; 358 int err, i, blocks, j, k;
329 long speed; 359 long speed;
330 uint64_t tmp; 360 uint64_t tmp;
331 361
@@ -495,6 +525,31 @@ static int __init mtd_speedtest_init(void)
495 speed = calc_speed(); 525 speed = calc_speed();
496 printk(PRINT_PREF "erase speed is %ld KiB/s\n", speed); 526 printk(PRINT_PREF "erase speed is %ld KiB/s\n", speed);
497 527
528 /* Multi-block erase all eraseblocks */
529 for (k = 1; k < 7; k++) {
530 blocks = 1 << k;
531 printk(PRINT_PREF "Testing %dx multi-block erase speed\n",
532 blocks);
533 start_timing();
534 for (i = 0; i < ebcnt; ) {
535 for (j = 0; j < blocks && (i + j) < ebcnt; j++)
536 if (bbt[i + j])
537 break;
538 if (j < 1) {
539 i++;
540 continue;
541 }
542 err = multiblock_erase(i, j);
543 if (err)
544 goto out;
545 cond_resched();
546 i += j;
547 }
548 stop_timing();
549 speed = calc_speed();
550 printk(PRINT_PREF "%dx multi-block erase speed is %ld KiB/s\n",
551 blocks, speed);
552 }
498 printk(PRINT_PREF "finished\n"); 553 printk(PRINT_PREF "finished\n");
499out: 554out:
500 kfree(iobuf); 555 kfree(iobuf);