Skip to contentSkip to conversation

mtd: test patches and bug fixes

PATCH In review Adrian Hunter 3 participants 9 messages Feb 8, 2011 – Feb 11, 2011 Memory technology devices (MTD)

lore
Share & tools
lore
#1 lore raw

PATCH 1/5 mtd: OneNAND: return read error for 4KiB page read

In reply to Adrian Hunter

When reading using the 4KiB page read function, I/O errors could be ignored if more than 1 page was read at a time.

---
 drivers/mtd/onenand/onenand_base.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/mtd/onenand/onenand_base.c +2 -0
index bac41ca..38e6d76 100644
@@ -1132,6 +1132,8 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from,
 			onenand_update_bufferram(mtd, from, !ret);
 			if (ret == -EBADMSG)
 				ret = 0;
+			if (ret)
+				break;
 		}
 
 		this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH 3/5 mtd: tests: add multiblock erase test to the mtd_speedtest

In reply to Adrian Hunter

From: Roman Tereshonkov <[email protected]>

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.

---
 drivers/mtd/tests/mtd_speedtest.c |   59 +++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 2 deletions(-)
drivers/mtd/tests/mtd_speedtest.c +57 -2
index 9bd986e..3ce6fce 100644
@@ -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;
@@ -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;
 }
 
@@ -325,7 +355,7 @@ out:
 
 static int __init mtd_speedtest_init(void)
 {
-	int err, i;
+	int err, i, blocks, j, k;
 	long speed;
 	uint64_t tmp;
 
@@ -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);
Signature · 1 line
1.7.0.4
#0 lore raw

cover mtd: test patches and bug fixes

Hi

Here are a couple of patches for MTD tests
and also a couple of OneNAND bug fixes.

Adrian Hunter (2):
mtd: OneNAND: return read error for 4KiB page read
mtd: tests: add count parameter to mtd_speedtest

Roman Tereshonkov (3):
mtd: tests: add multiblock erase test to the mtd_speedtest
mtd: tests : move ebcnt and pgcnt definitions before usage in printing.
mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address

 drivers/mtd/onenand/onenand_base.c  |   12 +++--
 drivers/mtd/tests/mtd_speedtest.c   |   74 +++++++++++++++++++++++++++++++++--
 drivers/mtd/tests/mtd_subpagetest.c |   10 ++--
 3 files changed, 82 insertions(+), 14 deletions(-)

Regards
Adrian

#3 lore raw

PATCH 2/5 mtd: tests: add count parameter to mtd_speedtest

By default mtd_speedtest uses all the eraseblocks of the MTD partition being tested. For large partitions a smaller number is sufficient and makes running the test quicker. For that reason, add a parameter 'count' to specify the maximum number of eraseblocks to use for testing.

---
 drivers/mtd/tests/mtd_speedtest.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
drivers/mtd/tests/mtd_speedtest.c +13 -2
index 161feeb..9bd986e 100644
@@ -16,7 +16,7 @@
  *
  * Test read and write speed of a MTD device.
  *
- * Author: Adrian Hunter <[email protected]>
+ * Author: Adrian Hunter <[email protected]>
  */
 
 #include <linux/init.h>
@@ -33,6 +33,11 @@ static int dev;
 module_param(dev, int, S_IRUGO);
 MODULE_PARM_DESC(dev, "MTD device number to use");
 
+static int count;
+module_param(count, int, S_IRUGO);
+MODULE_PARM_DESC(count, "Maximum number of eraseblocks to use "
+			"(0 means use all)");
+
 static struct mtd_info *mtd;
 static unsigned char *iobuf;
 static unsigned char *bbt;
@@ -326,7 +331,10 @@ static int __init mtd_speedtest_init(void)
 
 	printk(KERN_INFO "\n");
 	printk(KERN_INFO "=================================================\n");
-	printk(PRINT_PREF "MTD device: %d\n", dev);
+	if (count)
+		printk(PRINT_PREF "MTD device: %d    count: %d\n", dev, count);
+	else
+		printk(PRINT_PREF "MTD device: %d\n", dev);
 
 	mtd = get_mtd_device(NULL, dev);
 	if (IS_ERR(mtd)) {
@@ -353,6 +361,9 @@ static int __init mtd_speedtest_init(void)
 	       (unsigned long long)mtd->size, mtd->erasesize,
 	       pgsize, ebcnt, pgcnt, mtd->oobsize);
 
+	if (count > 0 && count < ebcnt)
+		ebcnt = count;
+
 	err = -ENOMEM;
 	iobuf = kmalloc(mtd->erasesize, GFP_KERNEL);
 	if (!iobuf) {
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH 4/5 mtd: tests : move ebcnt and pgcnt definitions before usage in printing.

In reply to Adrian Hunter

From: Roman Tereshonkov <[email protected]>

ebcnt and pgcnt variable initialization is moved before printk which uses them.

---
 drivers/mtd/tests/mtd_subpagetest.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/tests/mtd_subpagetest.c +5 -5
index 11204e8..334eae5 100644
@@ -394,6 +394,11 @@ static int __init mtd_subpagetest_init(void)
 	}
 
 	subpgsize = mtd->writesize >> mtd->subpage_sft;
+	tmp = mtd->size;
+	do_div(tmp, mtd->erasesize);
+	ebcnt = tmp;
+	pgcnt = mtd->erasesize / mtd->writesize;
+
 	printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
 	       "page size %u, subpage size %u, count of eraseblocks %u, "
 	       "pages per eraseblock %u, OOB size %u\n",
@@ -413,11 +418,6 @@ static int __init mtd_subpagetest_init(void)
 		goto out;
 	}
 
-	tmp = mtd->size;
-	do_div(tmp, mtd->erasesize);
-	ebcnt = tmp;
-	pgcnt = mtd->erasesize / mtd->writesize;
-
 	err = scan_for_bad_eraseblocks();
 	if (err)
 		goto out;
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH 5/5 mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address

In reply to Adrian Hunter

From: Roman Tereshonkov <[email protected]>

In onenand_verify function the address can be writepage non-aligned. When a page is read for comparing the right offset should be used for "this->verify_buf" to get the right matching with compared "buf" buffer.

---
 drivers/mtd/onenand/onenand_base.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/onenand/onenand_base.c +5 -5
index 38e6d76..4205b94 100644
@@ -1648,11 +1648,10 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
 	int ret = 0;
 	int thislen, column;
 
+	column = addr & (this->writesize - 1);
+
 	while (len != 0) {
-		thislen = min_t(int, this->writesize, len);
-		column = addr & (this->writesize - 1);
-		if (column + thislen > this->writesize)
-			thislen = this->writesize - column;
+		thislen = min_t(int, this->writesize - column, len);
 
 		this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
 
@@ -1666,12 +1665,13 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
 
 		this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize);
 
-		if (memcmp(buf, this->verify_buf, thislen))
+		if (memcmp(buf, this->verify_buf + column, thislen))
 			return -EBADMSG;
 
 		len -= thislen;
 		buf += thislen;
 		addr += thislen;
+		column = 0;
 	}
 
 	return 0;
Signature · 1 line
1.7.0.4
Acked-by on v1 5/5
#8 lore raw

Re: [PATCH 5/5] mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address

Quoted 55 lines · Adrian Hunter

From: Roman Tereshonkov <[email protected]>

In onenand_verify function the address can be writepage non-aligned. When a page is read for comparing the right offset should be used for "this->verify_buf" to get the right matching with compared "buf" buffer.

---
 drivers/mtd/onenand/onenand_base.c |   10 +++++-----

 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/onenand/onenand_base.c +5 -6
index 38e6d76..4205b94 100644
@@ -1648,11 +1648,10 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
        int ret = 0;
        int thislen, column;
 
+       column = addr & (this->writesize - 1);
+
        while (len != 0) {
-               thislen = min_t(int, this->writesize, len);
-               column = addr & (this->writesize - 1);
-               if (column + thislen > this->writesize)
-                       thislen = this->writesize - column;
+               thislen = min_t(int, this->writesize - column, len);
 
                this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
 
@@ -1666,12 +1665,13 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
 
                this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize);
 
-               if (memcmp(buf, this->verify_buf, thislen))
+               if (memcmp(buf, this->verify_buf + column, thislen))
                        return -EBADMSG;
 
                len -= thislen;
                buf += thislen;
                addr += thislen;
+               column = 0;
        }
 
        return 0;
--

1.7.0.4

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Acked-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] mtd: OneNAND: return read error for 4KiB page read

In reply to Adrian Hunter
Quoted 30 lines · Adrian Hunter

When reading using the 4KiB page read function, I/O errors could be ignored if more than 1 page was read at a time.

---
 drivers/mtd/onenand/onenand_base.c |    2 ++

 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/mtd/onenand/onenand_base.c +2 -1
index bac41ca..38e6d76 100644
@@ -1132,6 +1132,8 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from,
                        onenand_update_bufferram(mtd, from, !ret);
                        if (ret == -EBADMSG)
                                ret = 0;
+                       if (ret)
+                               break;
                }
 
                this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
--

1.7.0.4

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw

Re: [PATCH 4/5] mtd: tests : move ebcnt and pgcnt definitions before usage in printing.

In reply to Adrian Hunter
Quoted 6 lines · Adrian Hunter

From: Roman Tereshonkov <[email protected]>

ebcnt and pgcnt variable initialization is moved before printk which uses them.

Pushed all patches to l2-mtd-2.6.git except of this one, because Roman had already sent it and I already applied it.

Thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)