Skip to contentSkip to conversation

Eraseblocks torture: OneNAND results

PATCH Kyungmin Park 4 participants 4 messages Dec 15, 2006 – Dec 21, 2006 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi, Artem

Quoted 20 lines

FYI: now I see that the tortured eraseblocks do not contain all 0xFFs after erase which is strange - the driver must have returned an error. But mtd->erase is totally silent about this. Most probably it is a bug in the OneNAND driver.

May you please take a look at onenand_wait() from drivers/mtd/onenand/onenand_base.c in mtd-2.6.git. I see the following code there:

-----------------------------------------------------------------------
ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);

if (ctrl & ONENAND_CTRL_ERROR) {
    /* It maybe occur at initial bad block */
    DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: controller error = 0x%04x\n",
ctrl);
    /* Clear other interrupt bits for preventing ECC error */
    interrupt &= ONENAND_INT_MASTER;
}
Quoted 4 lines

AFAIU, this is exactly the place when we should catch erase errors. But what we do - we only change local 'interrupt' variable and later return
0. So we do not report about errors. This looks suspiciously. May you comment on this?

Yes, you're right. onenand_wait has a bug. It don't report the any error. it's my falut. And also it don't check the locked block error.

The below patch fix the onenand_wait bug. (This is temporary one. I also try to fix another things)

please test this one.
(You may have some parts already. please ignore it)

In my opition, if the block goes worn-out. it occurs as following. First, 2-bit ecc read error occurs. (bit error)
Second, Write failed. (page error)
Finally, Erase failed. (block error)

Thank you,
Kyungmin Park

P.S., In target environment, it still can't report any error. I'm also surpise with the OneNAND which has good erase guarantee.

--

Index: drivers/mtd/onenand/onenand_base.c
===================================================================
RCS file: /cvsroot/linux-2.6.18-omap/drivers/mtd/onenand/onenand_base.c,v retrieving revision 1.2

mtd/onenand/onenand_base.c +25 -24
diff -u -p -r1.2 onenand_base.c
@@ -316,22 +316,20 @@ static int onenand_wait(struct mtd_info 
 	ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
 
 	if (ctrl & ONENAND_CTRL_ERROR) {
-		/* It maybe occur at initial bad block */
 		DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: controller error = 0x%04x\n", ctrl);
-		/* Clear other interrupt bits for preventing ECC error */
-		interrupt &= ONENAND_INT_MASTER;
-	}
-
-	if (ctrl & ONENAND_CTRL_LOCK) {
-		DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: it's locked error = 0x%04x\n", ctrl);
-		return -EACCES;
+		if (ctrl & ONENAND_CTRL_LOCK)
+			DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Device is write protected!!!\n");
+		return ctrl;
 	}
 
 	if (interrupt & ONENAND_INT_READ) {
 		ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
-		if (ecc & ONENAND_ECC_2BIT_ALL) {
+		if (ecc) {
 			DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: ECC error = 0x%04x\n", ecc);
-			return -EBADMSG;
+			if (ecc & ONENAND_ECC_2BIT_ALL)
+				mtd->ecc_stats.failed++;
+			else if (ecc & ONENAND_ECC_1BIT_ALL)
+				mtd->ecc_stats.corrected++;
 		}
 	}
 
@@ -608,6 +606,7 @@ static int onenand_read(struct mtd_info 
 	size_t *retlen, u_char *buf)
 {
 	struct onenand_chip *this = mtd->priv;
+	struct mtd_ecc_stats stats;
 	int read = 0, column;
 	int thislen;
 	int ret = 0;
@@ -626,6 +625,7 @@ static int onenand_read(struct mtd_info 
 
 	/* TODO handling oob */
 
+	stats = mtd->ecc_stats;
 	while (read < len) {
 		thislen = min_t(int, mtd->writesize, len - read);
 
@@ -643,16 +643,16 @@ static int onenand_read(struct mtd_info 
 
 		this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
 
-		read += thislen;
-
-		if (read == len)
-			break;
-
 		if (ret) {
 			DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: read failed = %d\n", ret);
 			goto out;
 		}
 
+		read += thislen;
+
+		if (read == len)
+			break;
+
 		from += thislen;
 		buf += thislen;
 	}
@@ -667,7 +667,10 @@ out:
 	 * retlen == desired len and result == -EBADMSG
 	 */
 	*retlen = read;
-	return ret;
+	if (mtd->ecc_stats.failed - stats.failed)
+		return -EBADMSG;
+
+	return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0;
 }
 
 /**
@@ -716,15 +719,16 @@ int onenand_do_read_oob(struct mtd_info 
 
 		this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
 
+		if (ret) {
+			DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = 0x%x\n", ret);
+			goto out;
+		}
+
 		read += thislen;
 
 		if (read == len)
 			break;
 
-		if (ret) {
-			DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = %d\n", ret);
-			goto out;
-		}
 
 		buf += thislen;
 
@@ -1083,10 +1087,7 @@ static int onenand_erase(struct mtd_info
 		ret = this->wait(mtd, FL_ERASING);
 		/* Check, if it is write protected */
 		if (ret) {
-			if (ret == -EPERM)
-				DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Device is write protected!!!\n");
-			else
-				DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift));
+			DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift));
 			instr->state = MTD_ERASE_FAILED;
 			instr->fail_addr = addr;
 			goto erase_exit;

Index: drivers/mtd/onenand/onenand_bbt.c
===================================================================
RCS file: /cvsroot/linux-2.6.18-omap/drivers/mtd/onenand/onenand_bbt.c,v retrieving revision 1.1.1.1

mtd/onenand/onenand_bbt.c +2 -1
diff -u -p -r1.1.1.1 onenand_bbt.c
@@ -93,7 +93,8 @@ static int create_bbt(struct mtd_info *m
 			ret = onenand_do_read_oob(mtd, from + j * mtd->writesize + bd->offs,
 						  readlen, &retlen, &buf[0]);
 
-			if (ret)
+			/* Handle initial bad block */
+			if (ret && !(ret & ONENAND_CTRL_LOAD))
 				return ret;
 
 			if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
#1 lore raw
Quoted 11 lines
Quoted 11 lines

FYI: now I see that the tortured eraseblocks do not contain all 0xFFs after erase which is strange - the driver must have returned an error. But mtd->erase is totally silent about this. Most probably it is a bug in the OneNAND driver.

May you please take a look at onenand_wait() from drivers/mtd/onenand/onenand_base.c in mtd-2.6.git. I see the following code there:

Hi,

my name is Enrico, I'm new to this list and I've been reading the messages since the end of November.

I've recently read the Micron's "TN-29-16 Boot from NAND..." technical note and got puzzled by the following:

"Avoid excessive reads to the area of the NAND Flash where code is stored. When repeated accesses are required, the code should be copied to the DRAM. This minimizes the probability of read-disturb errors in the NAND Flash device."

Does that mean that excessive readings might compromise the integrity of NAND cells?

Enrico

#2 lore raw
Quoted 11 lines · Enrico Migliore

I've recently read the Micron's "TN-29-16 Boot from NAND..." technical note and got puzzled by the following:

"Avoid excessive reads to the area of the NAND Flash where code is stored. When
repeated accesses are required, the code should be copied to the DRAM. This minimizes
the probability of read-disturb errors in the NAND Flash device."

Does that mean that excessive readings might compromise the integrity of NAND cells?

That's the way I would interpret it too. (BTW, the paragraph wasn't there in the first edition of the document, rev.A from March this year...).

Although I'm also somewhat puzzled at the conclusion. I always thought read errors could occur at any time, the probability of which could be increased by reading or even more writing to the device. But not that it was localized to the area which you are reading. Although it makes sense I guess; accessing a bit cell requires some activity in the vicinity of the cell in order to read the bit, which I guess would increase the probability of failure.

/Ricard
--
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30

#3 lore raw
In reply to Kyungmin Park

Hi Kyungmin

I have tried your patch on an Omap 2420 base test board with OneNand and it seems to work.

I had previously run an earlier version of torture test and had some worn out erase blocks available. When I try to erase them I see often controller error occuring and it is caught and returned correctly.

But I have also encounted cases where there is no erase error but yet erase verify fails. I then tried a retry aften the failed verify and on the second read the erase block is blanj, all FF, as it should.

Jarkko Lavinen