diff mbox

[v4,1/5] mtd: nand: localize ECC failures per page

Message ID 1389642280-11714-1-git-send-email-computersforpeace@gmail.com
State Accepted
Commit b72f3dfb8ccf7e39b9434f548c1c98aa45c11426
Headers show

Commit Message

Brian Norris Jan. 13, 2014, 7:44 p.m. UTC
ECC failures can be tracked at the page level, not the do_read_ops level
(i.e., a potentially multi-page transaction).

This helps prepare for READ RETRY support.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
v3 -> v4: adjust whitespace

(Earlier versions: no changes)

 drivers/mtd/nand/nand_base.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Huang Shijie Jan. 14, 2014, 2:34 a.m. UTC | #1
On Mon, Jan 13, 2014 at 11:44:36AM -0800, Brian Norris wrote:
> ECC failures can be tracked at the page level, not the do_read_ops level
> (i.e., a potentially multi-page transaction).
> 
> This helps prepare for READ RETRY support.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> v3 -> v4: adjust whitespace
> 
> (Earlier versions: no changes)
> 
>  drivers/mtd/nand/nand_base.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 404e83d7e3da..b5c3768b32ae 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -1422,7 +1422,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  {
>  	int chipnr, page, realpage, col, bytes, aligned, oob_required;
>  	struct nand_chip *chip = mtd->priv;
> -	struct mtd_ecc_stats stats;
>  	int ret = 0;
>  	uint32_t readlen = ops->len;
>  	uint32_t oobreadlen = ops->ooblen;
> @@ -1431,8 +1430,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  
>  	uint8_t *bufpoi, *oob, *buf;
>  	unsigned int max_bitflips = 0;
> -
> -	stats = mtd->ecc_stats;
> +	bool ecc_fail = false;
>  
>  	chipnr = (int)(from >> chip->chip_shift);
>  	chip->select_chip(mtd, chipnr);
> @@ -1447,6 +1445,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  	oob_required = oob ? 1 : 0;
>  
>  	while (1) {
> +		unsigned int ecc_failures = mtd->ecc_stats.failed;
> +
>  		bytes = min(mtd->writesize - col, readlen);
>  		aligned = (bytes == mtd->writesize);
>  
> @@ -1483,7 +1483,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  			/* Transfer not aligned data */
>  			if (!aligned) {
>  				if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
> -				    !(mtd->ecc_stats.failed - stats.failed) &&
> +				    !(mtd->ecc_stats.failed - ecc_failures) &&
>  				    (ops->mode != MTD_OPS_RAW)) {
>  					chip->pagebuf = realpage;
>  					chip->pagebuf_bitflips = ret;
> @@ -1513,6 +1513,9 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  				else
>  					nand_wait_ready(mtd);
>  			}
> +
> +			if (mtd->ecc_stats.failed - ecc_failures)
> +				ecc_fail = true;
>  		} else {
>  			memcpy(buf, chip->buffers->databuf + col, bytes);
>  			buf += bytes;
> @@ -1547,7 +1550,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  	if (ret < 0)
>  		return ret;
>  
> -	if (mtd->ecc_stats.failed - stats.failed)
> +	if (ecc_fail)
>  		return -EBADMSG;
>  
>  	return max_bitflips;
> -- 
> 1.8.3.2
> 
> 
> 
thanks

Please add my acks to all the patch set:
Acked-by: Huang Shijie <b32955@freescale.com>
Brian Norris Jan. 14, 2014, 7:36 a.m. UTC | #2
On Tue, Jan 14, 2014 at 10:34:40AM +0800, Huang Shijie wrote:
> On Mon, Jan 13, 2014 at 11:44:36AM -0800, Brian Norris wrote:
> > ECC failures can be tracked at the page level, not the do_read_ops level
> > (i.e., a potentially multi-page transaction).
> > 
> > This helps prepare for READ RETRY support.
> > 
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > ---

[...]

> Please add my acks to all the patch set:
> Acked-by: Huang Shijie <b32955@freescale.com>

Thanks! Done, and pushed to l2-mtd.git.

Brian
pekon gupta Jan. 15, 2014, 4:10 a.m. UTC | #3
>From: Brian Norris [mailto:computersforpeace@gmail.com]
>>On Tue, Jan 14, 2014 at 10:34:40AM +0800, Huang Shijie wrote:
>> On Mon, Jan 13, 2014 at 11:44:36AM -0800, Brian Norris wrote:
>> > ECC failures can be tracked at the page level, not the do_read_ops level
>> > (i.e., a potentially multi-page transaction).
>> >
>> > This helps prepare for READ RETRY support.
>> >
>> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>> > ---
>
>[...]
>
>> Please add my acks to all the patch set:
>> Acked-by: Huang Shijie <b32955@freescale.com>
>
>Thanks! Done, and pushed to l2-mtd.git.
>
Thanks Brian and Shijie for getting this READ_RETRY feature in kernel.

Sorry, I din't had any MLC NAND locally at my place, so couldn't help in
Testing these patches, but I know these would be helpful later. As
we observed quite frequent failures due to read-disturb bit-flips on MLC
NANDs, and I hope these patches would reduce such failures.


with regards, pekon
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 404e83d7e3da..b5c3768b32ae 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1422,7 +1422,6 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 {
 	int chipnr, page, realpage, col, bytes, aligned, oob_required;
 	struct nand_chip *chip = mtd->priv;
-	struct mtd_ecc_stats stats;
 	int ret = 0;
 	uint32_t readlen = ops->len;
 	uint32_t oobreadlen = ops->ooblen;
@@ -1431,8 +1430,7 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 	uint8_t *bufpoi, *oob, *buf;
 	unsigned int max_bitflips = 0;
-
-	stats = mtd->ecc_stats;
+	bool ecc_fail = false;
 
 	chipnr = (int)(from >> chip->chip_shift);
 	chip->select_chip(mtd, chipnr);
@@ -1447,6 +1445,8 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 	oob_required = oob ? 1 : 0;
 
 	while (1) {
+		unsigned int ecc_failures = mtd->ecc_stats.failed;
+
 		bytes = min(mtd->writesize - col, readlen);
 		aligned = (bytes == mtd->writesize);
 
@@ -1483,7 +1483,7 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			/* Transfer not aligned data */
 			if (!aligned) {
 				if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
-				    !(mtd->ecc_stats.failed - stats.failed) &&
+				    !(mtd->ecc_stats.failed - ecc_failures) &&
 				    (ops->mode != MTD_OPS_RAW)) {
 					chip->pagebuf = realpage;
 					chip->pagebuf_bitflips = ret;
@@ -1513,6 +1513,9 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 				else
 					nand_wait_ready(mtd);
 			}
+
+			if (mtd->ecc_stats.failed - ecc_failures)
+				ecc_fail = true;
 		} else {
 			memcpy(buf, chip->buffers->databuf + col, bytes);
 			buf += bytes;
@@ -1547,7 +1550,7 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 	if (ret < 0)
 		return ret;
 
-	if (mtd->ecc_stats.failed - stats.failed)
+	if (ecc_fail)
 		return -EBADMSG;
 
 	return max_bitflips;