mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Stefan Riedmueller <s.riedmueller@phytec.de>
To: barebox@lists.infradead.org
Cc: Stefan Riedmueller <s.riedmueller@phytec.de>
Subject: [PATCH 2/2] mtd: nand_bbt: Skip bad blocks when searching for the BBT in NAND
Date: Tue, 16 Mar 2021 13:36:26 +0100	[thread overview]
Message-ID: <20210316123626.25872-2-s.riedmueller@phytec.de> (raw)
In-Reply-To: <20210316123626.25872-1-s.riedmueller@phytec.de>

The blocks containing the bad block table can become bad as well. So
make sure to skip any blocks that are marked bad when searching for the
bad block table.

Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
---
 drivers/mtd/nand/nand_bbt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index a86b5b2da38e..0b48373e6a0b 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -528,6 +528,7 @@ static int search_bbt(struct nand_chip *this, uint8_t *buf,
 {
 	u64 targetsize = nanddev_target_size(&this->base);
 	struct mtd_info *mtd = nand_to_mtd(this);
+	struct nand_bbt_descr *bd = this->badblock_pattern;
 	int i, chips;
 	int startblock, block, dir;
 	int scanlen = mtd->writesize + mtd->oobsize;
@@ -563,6 +564,9 @@ static int search_bbt(struct nand_chip *this, uint8_t *buf,
 			int actblock = startblock + dir * block;
 			loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
 
+			/* Check if block is marked bad */
+			if (scan_block_fast(this, bd, offs, buf))
+				continue;
 			/* Read first page */
 			scan_read(this, buf, offs, mtd->writesize, td);
 			if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
-- 
2.25.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-03-16 12:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 12:36 [PATCH 1/2] nand: nand-mxs: Fix marking BBT blocks as bad Stefan Riedmueller
2021-03-16 12:36 ` Stefan Riedmueller [this message]
2021-03-17  9:41   ` [PATCH 2/2] mtd: nand_bbt: Skip bad blocks when searching for the BBT in NAND Sascha Hauer
2021-03-17 17:14     ` Stefan Riedmüller
2021-03-22  5:59       ` sha
2021-03-29  7:20         ` Stefan Riedmüller
2021-04-14 13:18           ` Stefan Riedmüller
2021-04-14 14:36             ` sha
2021-04-20  6:29               ` Stefan Riedmüller
2021-05-07  7:52                 ` sha
2021-03-22  5:57 ` [PATCH 1/2] nand: nand-mxs: Fix marking BBT blocks as bad Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210316123626.25872-2-s.riedmueller@phytec.de \
    --to=s.riedmueller@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox