Commit 12663b44 authored by Miquel Raynal's avatar Miquel Raynal Committed by Boris Brezillon

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: default avatarMiquel Raynal <miquel.raynal@free-electrons.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 7cce5d83
...@@ -193,6 +193,9 @@ static int verify_eraseblock(int ebnum) ...@@ -193,6 +193,9 @@ static int verify_eraseblock(int ebnum)
ops.datbuf = NULL; ops.datbuf = NULL;
ops.oobbuf = readbuf; ops.oobbuf = readbuf;
err = mtd_read_oob(mtd, addr, &ops); err = mtd_read_oob(mtd, addr, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err || ops.oobretlen != use_len) { if (err || ops.oobretlen != use_len) {
pr_err("error: readoob failed at %#llx\n", pr_err("error: readoob failed at %#llx\n",
(long long)addr); (long long)addr);
...@@ -227,6 +230,9 @@ static int verify_eraseblock(int ebnum) ...@@ -227,6 +230,9 @@ static int verify_eraseblock(int ebnum)
ops.datbuf = NULL; ops.datbuf = NULL;
ops.oobbuf = readbuf; ops.oobbuf = readbuf;
err = mtd_read_oob(mtd, addr, &ops); err = mtd_read_oob(mtd, addr, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err || ops.oobretlen != mtd->oobavail) { if (err || ops.oobretlen != mtd->oobavail) {
pr_err("error: readoob failed at %#llx\n", pr_err("error: readoob failed at %#llx\n",
(long long)addr); (long long)addr);
...@@ -286,6 +292,9 @@ static int verify_eraseblock_in_one_go(int ebnum) ...@@ -286,6 +292,9 @@ static int verify_eraseblock_in_one_go(int ebnum)
/* read entire block's OOB at one go */ /* read entire block's OOB at one go */
err = mtd_read_oob(mtd, addr, &ops); err = mtd_read_oob(mtd, addr, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err || ops.oobretlen != len) { if (err || ops.oobretlen != len) {
pr_err("error: readoob failed at %#llx\n", pr_err("error: readoob failed at %#llx\n",
(long long)addr); (long long)addr);
...@@ -527,6 +536,9 @@ static int __init mtd_oobtest_init(void) ...@@ -527,6 +536,9 @@ static int __init mtd_oobtest_init(void)
pr_info("attempting to start read past end of OOB\n"); pr_info("attempting to start read past end of OOB\n");
pr_info("an error is expected...\n"); pr_info("an error is expected...\n");
err = mtd_read_oob(mtd, addr0, &ops); err = mtd_read_oob(mtd, addr0, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err) { if (err) {
pr_info("error occurred as expected\n"); pr_info("error occurred as expected\n");
err = 0; err = 0;
...@@ -571,6 +583,9 @@ static int __init mtd_oobtest_init(void) ...@@ -571,6 +583,9 @@ static int __init mtd_oobtest_init(void)
pr_info("attempting to read past end of device\n"); pr_info("attempting to read past end of device\n");
pr_info("an error is expected...\n"); pr_info("an error is expected...\n");
err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err) { if (err) {
pr_info("error occurred as expected\n"); pr_info("error occurred as expected\n");
err = 0; err = 0;
...@@ -615,6 +630,9 @@ static int __init mtd_oobtest_init(void) ...@@ -615,6 +630,9 @@ static int __init mtd_oobtest_init(void)
pr_info("attempting to read past end of device\n"); pr_info("attempting to read past end of device\n");
pr_info("an error is expected...\n"); pr_info("an error is expected...\n");
err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err) { if (err) {
pr_info("error occurred as expected\n"); pr_info("error occurred as expected\n");
err = 0; err = 0;
...@@ -684,6 +702,9 @@ static int __init mtd_oobtest_init(void) ...@@ -684,6 +702,9 @@ static int __init mtd_oobtest_init(void)
ops.datbuf = NULL; ops.datbuf = NULL;
ops.oobbuf = readbuf; ops.oobbuf = readbuf;
err = mtd_read_oob(mtd, addr, &ops); err = mtd_read_oob(mtd, addr, &ops);
if (mtd_is_bitflip(err))
err = 0;
if (err) if (err)
goto out; goto out;
if (memcmpshow(addr, readbuf, writebuf, if (memcmpshow(addr, readbuf, writebuf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment