Skip to content

Commit ec7cfc3

Browse files
bbrezillonmiquelraynal
authored andcommitted
mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag
Some controllers with embedded ECC engines override the BBM marker with data or ECC bytes, thus making bad block detection through bad block marker impossible. Let's flag those chips so the core knows it shouldn't check the BBM and consider all blocks good. This should allow us to get rid of two implementers of the legacy.block_bad() hook. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20200511064917.6255-1-boris.brezillon@collabora.com
1 parent 22dc5f9 commit ec7cfc3

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎drivers/mtd/nand/raw/nand_base.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
395395

396396
static int nand_isbad_bbm(struct nand_chip *chip, loff_t ofs)
397397
{
398+
if (chip->options & NAND_NO_BBM_QUIRK)
399+
return 0;
400+
398401
if (chip->legacy.block_bad)
399402
return chip->legacy.block_bad(chip, ofs);
400403

‎include/linux/mtd/rawnand.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ enum nand_ecc_algo {
221221
#define NAND_BBM_SECONDPAGE BIT(25)
222222
#define NAND_BBM_LASTPAGE BIT(26)
223223

224+
/*
225+
* Some controllers with pipelined ECC engines override the BBM marker with
226+
* data or ECC bytes, thus making bad block detection through bad block marker
227+
* impossible. Let's flag those chips so the core knows it shouldn't check the
228+
* BBM and consider all blocks good.
229+
*/
230+
#define NAND_NO_BBM_QUIRK BIT(27)
231+
224232
/* Cell info constants */
225233
#define NAND_CI_CHIPNR_MSK 0x03
226234
#define NAND_CI_CELLTYPE_MSK 0x0C

0 commit comments

Comments
 (0)