dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nand: brcmnand: correctly verify erased pages
@ 2020-05-04  9:29 Álvaro Fernández Rojas
  2020-05-04 21:43 ` Florian Fainelli
  2020-05-05  8:20 ` [PATCH v2] " Álvaro Fernández Rojas
  0 siblings, 2 replies; 11+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-04  9:29 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

The current code checks that the whole OOB area is erased.
This is a problem when JFFS2 cleanmarkers are added to the OOB, since it will
fail due to the usable OOB bytes not being 0xff.
Correct this by only checking that the ECC aren't 0xff.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index e4e3ceeac38f..546f0807b887 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -2018,6 +2018,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,
 static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
 		  struct nand_chip *chip, void *buf, u64 addr)
 {
+	struct mtd_oob_region oobecc;
 	int i, sas;
 	void *oob = chip->oob_poi;
 	int bitflips = 0;
@@ -2035,11 +2036,24 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
 	if (ret)
 		return ret;
 
-	for (i = 0; i < chip->ecc.steps; i++, oob += sas) {
+	for (i = 0; i < chip->ecc.steps; i++) {
 		ecc_chunk = buf + chip->ecc.size * i;
-		ret = nand_check_erased_ecc_chunk(ecc_chunk,
-						  chip->ecc.size,
-						  oob, sas, NULL, 0,
+
+		ret = nand_check_erased_ecc_chunk(ecc_chunk, chip->ecc.size,
+						  NULL, 0, NULL, 0,
+						  chip->ecc.strength);
+		if (ret < 0)
+			return ret;
+
+		bitflips = max(bitflips, ret);
+	}
+
+	for (i = 0; mtd->ooblayout->ecc(mtd, i, &oobecc) != -ERANGE; i++)
+	{
+		ret = nand_check_erased_ecc_chunk(NULL, 0,
+						  oob + oobecc.offset,
+						  oobecc.length,
+						  NULL, 0,
 						  chip->ecc.strength);
 		if (ret < 0)
 			return ret;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-05-25  7:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04  9:29 [PATCH] nand: brcmnand: correctly verify erased pages Álvaro Fernández Rojas
2020-05-04 21:43 ` Florian Fainelli
2020-05-05  8:24   ` Álvaro Fernández Rojas
2020-05-05  8:20 ` [PATCH v2] " Álvaro Fernández Rojas
2020-05-12  6:51   ` [PATCH v3] mtd: rawnand: " Álvaro Fernández Rojas
2020-05-12  7:16     ` Miquel Raynal
2020-05-12  7:24       ` Álvaro Fernández Rojas
2020-05-12  7:34         ` Miquel Raynal
2020-05-12  8:24           ` Álvaro Fernández Rojas
2020-05-12  8:24     ` [PATCH v4] " Álvaro Fernández Rojas
2020-05-24 19:16       ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).