mtd: rawnand: fix return value check for bad block status
PATCH 1/1 mtd: rawnand: fix return value check for bad block status
Positive return value from read_oob() is making false BAD blocks. For some of the NAND controllers, OOB bytes will be protected with ECC and read_oob() will return number of bitflips. If there is any bitflip in ECC protected OOB bytes for BAD block status page, then that block is getting treated as BAD.
--- drivers/mtd/nand/raw/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/nand_base.c +1 -1
@@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)for (; page < page_end; page++) { res = chip->ecc.read_oob (mtd, chip, page); -if (res) +if (res <0 )return res; bad = chip->oob_poi[chip->badblockpos];
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Hi Boris,
Quoted 18 lines · Abhishek Sahu
Positive return value from
read_oob()is making false BAD blocks. For some of the NAND controllers, OOB bytes will be protected with ECC andread_oob()will return number of bitflips. If there is any bitflip in ECC protected OOB bytes for BAD block status page, then that block is getting treated as BAD.Fixes c120e75e0e7d ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check")Cc <[email protected]>Signed-off-by Abhishek Sahu <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/nand/raw/nand_base.c +0
-0
drivers/mtd/nand/raw/nand_base.c static int nand_block_bad(struct mtd_info *mtd, loff_t ofs) · line 446
Quoted 8 lines
drivers/mtd/nand/raw/nand_base.c +1
-1@@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)for (; page < page_end; page++) { res = chip->ecc.read_oob (mtd, chip, page); -if (res) +if (res <0 )return res; bad = chip->oob_poi[chip->badblockpos];
I suppose this patch is a good candidate to be part of a future mtd/fixes PR?
Regards,
Miquèl
Boris Brezillon
AppliedQuoted 30 lines · On Mon, 18 Jun 2018 15:57:57 +0200 Miquel Raynal <[email protected]>…
Hi Boris,
Quoted 25 lines · Abhishek Sahu
Positive return value from
read_oob()is making false BAD blocks. For some of the NAND controllers, OOB bytes will be protected with ECC andread_oob()will return number of bitflips. If there is any bitflip in ECC protected OOB bytes for BAD block status page, then that block is getting treated as BAD.Fixes c120e75e0e7d ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check")Cc <[email protected]>Signed-off-by Abhishek Sahu <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/nand/raw/nand_base.c +1
-1@@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)for (; page < page_end; page++) { res = chip->ecc.read_oob (mtd, chip, page); -if (res) +if (res <0 )return res;
Quoted 3 lines
drivers/mtd/nand/raw/nand_base.c static int nand_block_bad(struct mtd_info *mtd, loff_t ofs) · line 446
Quoted 1 line
drivers/mtd/nand/raw/nand_base.c +0
-0bad = chip->oob_poi[chip->badblockpos];Reviewed-by Miquel Raynal <[email protected]>
Applied.
Thanks,
Boris
Quoted 10 lines
I suppose this patch is a good candidate to be part of a future mtd/fixes PR?
Regards,
Miquèl______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/