Skip to contentSkip to conversation

MTD: modify mtd api to return bitflip info on read operations

PATCH Mike Dunn 2 participants 2 messages Nov 30, 2011 Memory technology devices (MTD)

lore
Share & tools
lore

Mike Dunn

author
#0 lore raw

Thanks Thomas. For some reason this post never made it to my inbox. Pasted from the list archive...

Quoted 1 line · Le Mon, 28 Nov 2011 17:01:17 -0800, Mike Dunn <mikedunn at newsguy.com…

/ + /*

/>/ + * max_bitflips returns to caller the greatest number of bit errors
/>/ + * corrected on any one minimum i/o unit (e.g., nand page)
/>/ + */
/>/ + int (*read) (struct mtd_info *mtd, loff_t from, size_t len,
/>/ + size_t *retlen, u_char *buf, unsigned int *max_bitflips);
/>/
/>/ - int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
/

Quoted 2 lines

Making this change in patch 1 will break the build if someone bisects kernel changes between patch 1 and your other patches.

Then I guess it should be a single patch. As a general rule, should individual patches not be interdependent?

Quoted 4 lines

Also, seeing the large number of users that don't use/need the new max_bitflips argument, wouldn't it be better to add a new, separate ->readext() operation (or another better name) ? This would probably reduce the patch size quite a bit.

Well, then it wouldn't be a generic mtd read operation, and higher layers would have to be aware of the type of device and call the appropriate read function.
Fewer drivers would need to be patched, but patches to infrastructure code would be complicated and make the resulting code ugly, I think.

Quoted 16 lines

Also, another option is to allow max_bitflips to be NULL, which would simplify things such as :

(quoted diff) +3 -1
+	unsigned int max_bitflips;
 
-	ret = mtd->read(mtd, ptr, sizeof(fs), &sz, (u_char *) &fs);
+	ret = mtd->read(mtd, ptr, sizeof(fs), &sz, (u_char *) &fs,
+			&max_bitflips);

to

(quoted diff) +2 -1
-	ret = mtd->read(mtd, ptr, sizeof(fs), &sz, (u_char *) &fs);
+	ret = mtd->read(mtd, ptr, sizeof(fs), &sz, (u_char *) &fs,
+			NULL);
Quoted 1 line

and would therefore avoid the need for defining an useless variable.

Yes, you're right. I will do this in the next patch.

Quoted 3 lines

Another question: is the max_bitflips information sufficient (i.e on a large read with multiple pages, you will only get the value for the worst page) ? Don't you need the bitflip count on a per-page basis ?

I'm not a flash expert, but I think that the greatest number of bitflips on any one page is a sufficient diagnostic of the integrity of an eraseblock. One bad page will make the entire eraseblock unusable, so I'm not sure it's useful to report bitflips for specific pages. Maybe some other statistics would be useful, such as the total number of bitflips during the read operation, but I didn't want to make it unnecesarily complicated, and it's a vast improvement over the current state of affairs.

Thanks again Thomas. I hope some others will offer opinions. Resolving this is the first step toward getting a robust ubifs on my nand flash!

Mike

#1 lore raw

Hello,

Quoted 1 line · Mike Dunn

Thanks Thomas. For some reason this post never made it to my inbox. Pasted from the list archive...

Huh, strange. Let's see if this one reaches your Inbox.

Quoted 5 lines
Quoted 2 lines

Making this change in patch 1 will break the build if someone bisects kernel changes between patch 1 and your other patches.

Then I guess it should be a single patch. As a general rule, should individual patches not be interdependent?

My understanding is that the kernel should be buildable at any given point, so that things such as "git bisect" can easily be used. So, it's not so much a "interdependence" question but rather a "buildability" question.

Basically, you have to ensure that the kernel still builds when patch 1 is enabled, when patches 1+2 are enabled, when patches 1+2+3 are enabled, etc.

Quoted 4 lines

Well, then it wouldn't be a generic mtd read operation, and higher layers would have to be aware of the type of device and call the appropriate read function.
Fewer drivers would need to be patched, but patches to infrastructure code would be complicated and make the resulting code ugly, I think.

True that having some drivers implementing the standard ->read() method and some others implementing the extended ->readext() method would be ugly.

Quoted 3 lines

I'm not a flash expert, but I think that the greatest number of bitflips on any one page is a sufficient diagnostic of the integrity of an eraseblock. One bad page will make the entire eraseblock unusable, so I'm not sure it's useful to report bitflips for specific pages.

Ok, understood, that makes sense to me (but I'm not a flash expert either).

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com