Skip to contentSkip to conversation

mtdblock: tolerate corrected bit-flips

PATCH Applied Bang Li 3 participants 3 messages Mar 28, 2023 – Apr 3, 2023

Subsystems (2)
lore
Share & tools
lore

Bang Li

author
#0 lore raw

PATCH v2 1/1 mtdblock: tolerate corrected bit-flips

mtd_read() may return -EUCLEAN in case of corrected bit-flips.This particular condition should not be treated like an error.

Fixes e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()")
Cc <[email protected]> # v3.7

---
Changes since v1:
- Resend this patch with Cc and Fixes tags

---
 drivers/mtd/mtdblock.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/mtd/mtdblock.c +8 -4
index 1e94e7d10b8b..a0a1194dc1d9 100644
@@ -153,7 +153,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
 				mtdblk->cache_state = STATE_EMPTY;
 				ret = mtd_read(mtd, sect_start, sect_size,
 					       &retlen, mtdblk->cache_data);
-				if (ret)
+				if (ret && !mtd_is_bitflip(ret))
 					return ret;
 				if (retlen != sect_size)
 					return -EIO;
@@ -188,8 +188,12 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
 	pr_debug("mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
 			mtd->name, pos, len);
 
-	if (!sect_size)
-		return mtd_read(mtd, pos, len, &retlen, buf);
+	if (!sect_size) {
+		ret = mtd_read(mtd, pos, len, &retlen, buf);
+		if (ret && !mtd_is_bitflip(ret))
+			return ret;
+		return 0;
+	}
 
 	while (len > 0) {
 		unsigned long sect_start = (pos/sect_size)*sect_size;
@@ -209,7 +213,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
 			memcpy (buf, mtdblk->cache_data + offset, size);
 		} else {
 			ret = mtd_read(mtd, pos, size, &retlen, buf);
-			if (ret)
+			if (ret && !mtd_is_bitflip(ret))
 				return ret;
 			if (retlen != size)
 				return -EIO;
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer Acked-by on v2 1/1
#1 lore raw

----- Ursprüngliche Mail -----

Quoted 7 lines

Von: "Bang Li" <[email protected]>
An: "Miquel Raynal" <[email protected]>, "richard" <[email protected]>, "Vignesh Raghavendra" <[email protected]>
CC: "linux-mtd" <[email protected]>, "linux-kernel" <[email protected]>, "Bang Li" <[email protected]>, "stable" <[email protected]>
Gesendet: Dienstag, 28. März 2023 18:30:12
Betreff: [PATCH v2] mtdblock: tolerate corrected bit-flips

Quoted 7 lines

mtd_read() may return -EUCLEAN in case of corrected bit-flips.This particular condition should not be treated like an error.

Fixes e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()")
Cc <[email protected]> # v3.7

---

Thanks,
//richard

maintainer Applied
#2 lore raw
In reply to Bang Li
Quoted 7 lines · Bang Li

mtd_read() may return -EUCLEAN in case of corrected bit-flips.This particular condition should not be treated like an error.

Fixes e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()")
Cc <[email protected]> # v3.7

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel