mtd: nand: fix off-by-one read retry mode counting
Subsystems (2)
PATCH v2 1/1 mtd: nand: fix off-by-one read retry mode counting
A flash may support N read retry voltage threshold modes, numbered 1 through N-1 (where mode 0 represents the initial state). However, nand_do_read_ops() tries to use mode 0 through N.
This off-by-one error shows up, for instance, when using nanddump, and we have cycled through available modes:
nand: setting READ RETRY mode 0
nand: setting READ RETRY mode 1
nand: setting READ RETRY mode 2
nand: setting READ RETRY mode 3
nand: setting READ RETRY mode 4
nand: setting READ RETRY mode 5
nand: setting READ RETRY mode 6
nand: setting READ RETRY mode 7
nand: setting READ RETRY mode 8
libmtd: error!: cannot read 8192 bytes from mtd0 (eraseblock 20, offset 0)
error 22 (Invalid argument)
nanddump: error!: mtd_read
Tested on Micron MT29F64G08CBCBBH1, with 8 retry modes.
---
v1 -> v2: N modes means we should use modes 0 to N-1, not 0 to N
drivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c +1 -1
@@ -1586,7 +1586,7 @@ read_retry: }if (mtd->ecc_stats.failed - ecc_failures) { -if (retry_mode +1 <= chip->read_retries) { +if (retry_mode +1 < chip->read_retries) { retry_mode++; ret =nand_setup_read_retry (mtd, retry_mode);
Signature · 1 line
1.8.3.2
Quoted 47 lines · Brian Norris
A flash may support N read retry voltage threshold modes, numbered 1 through N-1 (where mode 0 represents the initial state). However,
nand_do_read_ops()tries to use mode 0 through N.This off-by-one error shows up, for instance, when using nanddump, and we have cycled through available modes:
nand: setting READ RETRY mode 0
nand: setting READ RETRY mode 1
nand: setting READ RETRY mode 2
nand: setting READ RETRY mode 3
nand: setting READ RETRY mode 4
nand: setting READ RETRY mode 5
nand: setting READ RETRY mode 6
nand: setting READ RETRY mode 7
nand: setting READ RETRY mode 8
libmtd: error!: cannot read 8192 bytes from mtd0 (eraseblock 20, offset 0)
error 22 (Invalid argument)
nanddump: error!:mtd_readTested on Micron MT29F64G08CBCBBH1, with 8 retry modes.
Signed-off-by Brian Norris <[email protected]>---
v1 -> v2: N modes means we should use modes 0 to N-1, not 0 to Ndrivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/nand/nand_base.c +1
-1@@ -1586,7 +1586,7 @@ read_retry: }if (mtd->ecc_stats.failed - ecc_failures) { -if (retry_mode +1 <= chip->read_retries) { +if (retry_mode +1 < chip->read_retries) { retry_mode++; ret =nand_setup_read_retry (mtd, retry_mode);Signature · 1 line
1.8.3.2
Brian Norris
AppliedQuoted 37 lines · Huang Shijie
Quoted 36 lines · Brian Norris
A flash may support N read retry voltage threshold modes, numbered 1 through N-1 (where mode 0 represents the initial state). However,
nand_do_read_ops()tries to use mode 0 through N.This off-by-one error shows up, for instance, when using nanddump, and we have cycled through available modes:
nand: setting READ RETRY mode 0
nand: setting READ RETRY mode 1
nand: setting READ RETRY mode 2
nand: setting READ RETRY mode 3
nand: setting READ RETRY mode 4
nand: setting READ RETRY mode 5
nand: setting READ RETRY mode 6
nand: setting READ RETRY mode 7
nand: setting READ RETRY mode 8
libmtd: error!: cannot read 8192 bytes from mtd0 (eraseblock 20, offset 0)
error 22 (Invalid argument)
nanddump: error!:mtd_readTested on Micron MT29F64G08CBCBBH1, with 8 retry modes.
Signed-off-by Brian Norris <[email protected]>---
v1 -> v2: N modes means we should use modes 0 to N-1, not 0 to Ndrivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/nand/nand_base.c +0
-0@@ -1586,7 +1586,7 @@ read_retry: }
Quoted 8 lines
drivers/mtd/nand/nand_base.c read_retry: · line 1592
Quoted 6 lines
drivers/mtd/nand/nand_base.c +1
-1if (mtd->ecc_stats.failed - ecc_failures) { -if (retry_mode +1 <= chip->read_retries) { +if (retry_mode +1 < chip->read_retries) { retry_mode++; ret =nand_setup_read_retry (mtd, retry_mode);Acked-by Huang Shijie <[email protected]>
Pushed to linux-mtd.git. Will queue up a few other things to send to Linus in 3.14-rcX.
Brian