Skip to content

Commit 12663b4

Browse files
miquelraynalBoris Brezillon
authored andcommitted
mtd: mtd_oobtest: Handle bitflips during reads
Reads from NAND devices usually trigger bitflips, this is an expected behavior. While bitflips are under a given threshold, the MTD core returns 0. However, when the number of corrected bitflips is above this same threshold, -EUCLEAN is returned to inform the upper layer that this block is slightly dying and soon the ECC engine will be overtaken so actions should be taken to move the data out of it. This particular condition should not be treated like an error and the test should continue. Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent 7cce5d8 commit 12663b4

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎drivers/mtd/tests/oobtest.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ static int verify_eraseblock(int ebnum)
193193
ops.datbuf = NULL;
194194
ops.oobbuf = readbuf;
195195
err = mtd_read_oob(mtd, addr, &ops);
196+
if (mtd_is_bitflip(err))
197+
err = 0;
198+
196199
if (err || ops.oobretlen != use_len) {
197200
pr_err("error: readoob failed at %#llx\n",
198201
(long long)addr);
@@ -227,6 +230,9 @@ static int verify_eraseblock(int ebnum)
227230
ops.datbuf = NULL;
228231
ops.oobbuf = readbuf;
229232
err = mtd_read_oob(mtd, addr, &ops);
233+
if (mtd_is_bitflip(err))
234+
err = 0;
235+
230236
if (err || ops.oobretlen != mtd->oobavail) {
231237
pr_err("error: readoob failed at %#llx\n",
232238
(long long)addr);
@@ -286,6 +292,9 @@ static int verify_eraseblock_in_one_go(int ebnum)
286292

287293
/* read entire block's OOB at one go */
288294
err = mtd_read_oob(mtd, addr, &ops);
295+
if (mtd_is_bitflip(err))
296+
err = 0;
297+
289298
if (err || ops.oobretlen != len) {
290299
pr_err("error: readoob failed at %#llx\n",
291300
(long long)addr);
@@ -527,6 +536,9 @@ static int __init mtd_oobtest_init(void)
527536
pr_info("attempting to start read past end of OOB\n");
528537
pr_info("an error is expected...\n");
529538
err = mtd_read_oob(mtd, addr0, &ops);
539+
if (mtd_is_bitflip(err))
540+
err = 0;
541+
530542
if (err) {
531543
pr_info("error occurred as expected\n");
532544
err = 0;
@@ -571,6 +583,9 @@ static int __init mtd_oobtest_init(void)
571583
pr_info("attempting to read past end of device\n");
572584
pr_info("an error is expected...\n");
573585
err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
586+
if (mtd_is_bitflip(err))
587+
err = 0;
588+
574589
if (err) {
575590
pr_info("error occurred as expected\n");
576591
err = 0;
@@ -615,6 +630,9 @@ static int __init mtd_oobtest_init(void)
615630
pr_info("attempting to read past end of device\n");
616631
pr_info("an error is expected...\n");
617632
err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
633+
if (mtd_is_bitflip(err))
634+
err = 0;
635+
618636
if (err) {
619637
pr_info("error occurred as expected\n");
620638
err = 0;
@@ -684,6 +702,9 @@ static int __init mtd_oobtest_init(void)
684702
ops.datbuf = NULL;
685703
ops.oobbuf = readbuf;
686704
err = mtd_read_oob(mtd, addr, &ops);
705+
if (mtd_is_bitflip(err))
706+
err = 0;
707+
687708
if (err)
688709
goto out;
689710
if (memcmpshow(addr, readbuf, writebuf,

0 commit comments

Comments
 (0)