Skip to content

Commit

Permalink
mtd: tests: add multiblock erase test to the mtd_speedtest
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roman Tereshonkov authored and David Woodhouse committed Mar 11, 2011
1 parent fc7fe76 commit 4085bcc
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions drivers/mtd/tests/mtd_speedtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@ static int erase_eraseblock(int ebnum)
return 0;
}

static int multiblock_erase(int ebnum, int blocks)
{
int err;
struct erase_info ei;
loff_t addr = ebnum * mtd->erasesize;

memset(&ei, 0, sizeof(struct erase_info));
ei.mtd = mtd;
ei.addr = addr;
ei.len = mtd->erasesize * blocks;

err = mtd->erase(mtd, &ei);
if (err) {
printk(PRINT_PREF "error %d while erasing EB %d, blocks %d\n",
err, ebnum, blocks);
return err;
}

if (ei.state == MTD_ERASE_FAILED) {
printk(PRINT_PREF "some erase error occurred at EB %d,"
"blocks %d\n", ebnum, blocks);
return -EIO;
}

return 0;
}

static int erase_whole_device(void)
{
int err;
Expand Down Expand Up @@ -292,7 +319,10 @@ static long calc_speed(void)
ms = (finish.tv_sec - start.tv_sec) * 1000 +
(finish.tv_usec - start.tv_usec) / 1000;
k = goodebcnt * mtd->erasesize / 1024;
speed = (k * 1000) / ms;
if (ms)
speed = (k * 1000) / ms;
else
speed = 0;
return speed;
}

Expand Down Expand Up @@ -325,7 +355,7 @@ static int scan_for_bad_eraseblocks(void)

static int __init mtd_speedtest_init(void)
{
int err, i;
int err, i, blocks, j, k;
long speed;
uint64_t tmp;

Expand Down Expand Up @@ -495,6 +525,31 @@ static int __init mtd_speedtest_init(void)
speed = calc_speed();
printk(PRINT_PREF "erase speed is %ld KiB/s\n", speed);

/* Multi-block erase all eraseblocks */
for (k = 1; k < 7; k++) {
blocks = 1 << k;
printk(PRINT_PREF "Testing %dx multi-block erase speed\n",
blocks);
start_timing();
for (i = 0; i < ebcnt; ) {
for (j = 0; j < blocks && (i + j) < ebcnt; j++)
if (bbt[i + j])
break;
if (j < 1) {
i++;
continue;
}
err = multiblock_erase(i, j);
if (err)
goto out;
cond_resched();
i += j;
}
stop_timing();
speed = calc_speed();
printk(PRINT_PREF "%dx multi-block erase speed is %ld KiB/s\n",
blocks, speed);
}
printk(PRINT_PREF "finished\n");
out:
kfree(iobuf);
Expand Down

0 comments on commit 4085bcc

Please sign in to comment.