diff mbox

[3/4] mtd: nand: support Micron READ RETRY

Message ID 20131205205838.GL27149@ld-irv-0074.broadcom.com
State Superseded, archived
Headers show

Commit Message

Brian Norris Dec. 5, 2013, 8:58 p.m. UTC
Caught a simple bug when testing with a non-READ_RETRY NAND. See below.

On Thu, Dec 05, 2013 at 12:19:59PM -0800, Brian Norris wrote:
...
> One thing I'm not sure about: do all relevant (i.e., ONFI-capable) NAND drivers
> support SET_FEATURES properly? If not, then it's possible that this could break
> nand_do_read_ops for such drivers. Not sure what the best method of handling
> that would be.
...
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
...
> @@ -1512,8 +1535,27 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>  					nand_wait_ready(mtd);
>  			}
>  
> -			if (mtd->ecc_stats.failed - ecc_failures)
> -				ecc_fail = true;
> +			if (mtd->ecc_stats.failed - ecc_failures) {
> +				retry_mode++;

This increment shouldn't be done for all ECC failures, but only for
failures where there are remaining read-retry modes (i.e., flash that
support read retry).

> +				if (retry_mode < chip->read_retries) {
> +					pr_debug("ECC error; performing READ RETRY %d\n",
> +							retry_mode);
> +
> +					ret = nand_set_read_retry(mtd,
> +							retry_mode);
> +					if (ret < 0)
> +						break;
> +
> +					/* Reset failures */
> +					mtd->ecc_stats.failed = ecc_failures;
> +					continue;
> +				} else {
> +					/* No more retry modes; real failure */
> +					ecc_fail = true;
> +				}
> +			}
> +
> +			buf += bytes;
>  		} else {
>  			memcpy(buf, chip->buffers->databuf + col, bytes);
>  			buf += bytes;

I'll send a v2 with the following extra diff:

---

Brian

Comments

Huang Shijie Dec. 6, 2013, 8:48 a.m. UTC | #1
On Thu, Dec 05, 2013 at 12:58:38PM -0800, Brian Norris wrote:
> Caught a simple bug when testing with a non-READ_RETRY NAND. See below.
> 
> On Thu, Dec 05, 2013 at 12:19:59PM -0800, Brian Norris wrote:
> ...
> > One thing I'm not sure about: do all relevant (i.e., ONFI-capable) NAND drivers
> > support SET_FEATURES properly? If not, then it's possible that this could break
> > nand_do_read_ops for such drivers. Not sure what the best method of handling
> > that would be.
> ...
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> ...
> > @@ -1512,8 +1535,27 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
> >  					nand_wait_ready(mtd);
> >  			}
> >  
> > -			if (mtd->ecc_stats.failed - ecc_failures)
> > -				ecc_fail = true;
> > +			if (mtd->ecc_stats.failed - ecc_failures) {
> > +				retry_mode++;
> 
> This increment shouldn't be done for all ECC failures, but only for
> failures where there are remaining read-retry modes (i.e., flash that
> support read retry).
> 
> > +				if (retry_mode < chip->read_retries) {
> > +					pr_debug("ECC error; performing READ RETRY %d\n",
> > +							retry_mode);
> > +
> > +					ret = nand_set_read_retry(mtd,
> > +							retry_mode);
> > +					if (ret < 0)
> > +						break;
> > +
> > +					/* Reset failures */
> > +					mtd->ecc_stats.failed = ecc_failures;
> > +					continue;
> > +				} else {
> > +					/* No more retry modes; real failure */
> > +					ecc_fail = true;
> > +				}
> > +			}
> > +
> > +			buf += bytes;
> >  		} else {
> >  			memcpy(buf, chip->buffers->databuf + col, bytes);
> >  			buf += bytes;
> 
> I'll send a v2 with the following extra diff:

I am glad you begin to add the read-retry support.

I ever planned to send out my read-retry patch set (which has been queued
in my hand for half of year) after I finish the
spi nor framework. 

I can not wait to review your V2 patch.

thanks
Huang Shijie
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 82efd819f31b..aeafcdce6cc0 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1536,8 +1536,8 @@  static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			}
 
 			if (mtd->ecc_stats.failed - ecc_failures) {
-				retry_mode++;
-				if (retry_mode < chip->read_retries) {
+				if (retry_mode + 1 < chip->read_retries) {
+					retry_mode++;
 					pr_debug("ECC error; performing READ RETRY %d\n",
 							retry_mode);