* [PATCH] mtd: mtd_oobtest: Handle bitflips during reads
@ 2018-01-11 20:39 Miquel Raynal
2018-01-12 14:08 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Miquel Raynal @ 2018-01-11 20:39 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen
Cc: linux-mtd, Miquel Raynal
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>
---
drivers/mtd/tests/oobtest.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c
index 1cb3f7758fb6..766b2c385682 100644
--- a/drivers/mtd/tests/oobtest.c
+++ b/drivers/mtd/tests/oobtest.c
@@ -193,6 +193,9 @@ static int verify_eraseblock(int ebnum)
ops.datbuf = NULL;
ops.oobbuf = readbuf;
err = mtd_read_oob(mtd, addr, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err || ops.oobretlen != use_len) {
pr_err("error: readoob failed at %#llx\n",
(long long)addr);
@@ -227,6 +230,9 @@ static int verify_eraseblock(int ebnum)
ops.datbuf = NULL;
ops.oobbuf = readbuf;
err = mtd_read_oob(mtd, addr, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err || ops.oobretlen != mtd->oobavail) {
pr_err("error: readoob failed at %#llx\n",
(long long)addr);
@@ -286,6 +292,9 @@ static int verify_eraseblock_in_one_go(int ebnum)
/* read entire block's OOB at one go */
err = mtd_read_oob(mtd, addr, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err || ops.oobretlen != len) {
pr_err("error: readoob failed at %#llx\n",
(long long)addr);
@@ -527,6 +536,9 @@ static int __init mtd_oobtest_init(void)
pr_info("attempting to start read past end of OOB\n");
pr_info("an error is expected...\n");
err = mtd_read_oob(mtd, addr0, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err) {
pr_info("error occurred as expected\n");
err = 0;
@@ -571,6 +583,9 @@ static int __init mtd_oobtest_init(void)
pr_info("attempting to read past end of device\n");
pr_info("an error is expected...\n");
err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err) {
pr_info("error occurred as expected\n");
err = 0;
@@ -615,6 +630,9 @@ static int __init mtd_oobtest_init(void)
pr_info("attempting to read past end of device\n");
pr_info("an error is expected...\n");
err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err) {
pr_info("error occurred as expected\n");
err = 0;
@@ -684,6 +702,9 @@ static int __init mtd_oobtest_init(void)
ops.datbuf = NULL;
ops.oobbuf = readbuf;
err = mtd_read_oob(mtd, addr, &ops);
+ if (mtd_is_bitflip(err))
+ err = 0;
+
if (err)
goto out;
if (memcmpshow(addr, readbuf, writebuf,
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: mtd_oobtest: Handle bitflips during reads
2018-01-11 20:39 [PATCH] mtd: mtd_oobtest: Handle bitflips during reads Miquel Raynal
@ 2018-01-12 14:08 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2018-01-12 14:08 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Cyrille Pitchen, linux-mtd, David Oberhollenzer
+David
On Thu, 11 Jan 2018 21:39:20 +0100
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> 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>
Applied.
BTW, any volunteer to port this test in mtd-utils, or is there anything
in this test preventing us implementing it in userspace?
> ---
> drivers/mtd/tests/oobtest.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c
> index 1cb3f7758fb6..766b2c385682 100644
> --- a/drivers/mtd/tests/oobtest.c
> +++ b/drivers/mtd/tests/oobtest.c
> @@ -193,6 +193,9 @@ static int verify_eraseblock(int ebnum)
> ops.datbuf = NULL;
> ops.oobbuf = readbuf;
> err = mtd_read_oob(mtd, addr, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err || ops.oobretlen != use_len) {
> pr_err("error: readoob failed at %#llx\n",
> (long long)addr);
> @@ -227,6 +230,9 @@ static int verify_eraseblock(int ebnum)
> ops.datbuf = NULL;
> ops.oobbuf = readbuf;
> err = mtd_read_oob(mtd, addr, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err || ops.oobretlen != mtd->oobavail) {
> pr_err("error: readoob failed at %#llx\n",
> (long long)addr);
> @@ -286,6 +292,9 @@ static int verify_eraseblock_in_one_go(int ebnum)
>
> /* read entire block's OOB at one go */
> err = mtd_read_oob(mtd, addr, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err || ops.oobretlen != len) {
> pr_err("error: readoob failed at %#llx\n",
> (long long)addr);
> @@ -527,6 +536,9 @@ static int __init mtd_oobtest_init(void)
> pr_info("attempting to start read past end of OOB\n");
> pr_info("an error is expected...\n");
> err = mtd_read_oob(mtd, addr0, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err) {
> pr_info("error occurred as expected\n");
> err = 0;
> @@ -571,6 +583,9 @@ static int __init mtd_oobtest_init(void)
> pr_info("attempting to read past end of device\n");
> pr_info("an error is expected...\n");
> err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err) {
> pr_info("error occurred as expected\n");
> err = 0;
> @@ -615,6 +630,9 @@ static int __init mtd_oobtest_init(void)
> pr_info("attempting to read past end of device\n");
> pr_info("an error is expected...\n");
> err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err) {
> pr_info("error occurred as expected\n");
> err = 0;
> @@ -684,6 +702,9 @@ static int __init mtd_oobtest_init(void)
> ops.datbuf = NULL;
> ops.oobbuf = readbuf;
> err = mtd_read_oob(mtd, addr, &ops);
> + if (mtd_is_bitflip(err))
> + err = 0;
> +
> if (err)
> goto out;
> if (memcmpshow(addr, readbuf, writebuf,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-12 14:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 20:39 [PATCH] mtd: mtd_oobtest: Handle bitflips during reads Miquel Raynal
2018-01-12 14:08 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox