All of lore.kernel.org
 help / color / mirror / Atom feed
From: mikhail.kshevetskiy@iopsys.eu
To: u-boot@lists.denx.de
Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Stefan Roese <sr@denx.de>,
	mikhail.kshevetskiy@iopsys.eu, agnau@iopsys.eu
Subject: [PATCH 2/7] mtd/nand: try to erase bad blocks only if scrub flag is provided
Date: Thu,  6 Oct 2022 06:14:57 +0300	[thread overview]
Message-ID: <20221006031501.110290-2-mikhail.kshevetskiy@iopsys.eu> (raw)
In-Reply-To: <20221006031501.110290-1-mikhail.kshevetskiy@iopsys.eu>

From: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>

'mtd erase' command should not erase bad blocks. To force bad block erasing
there is 'mtd erase.dontskipbad' command (this command sets 'scrub' flag
to true in the erase_info structure). Unfortunately nand layer ignore
scrub flag and try to erases bad blocks unconditionally. This is wrong.

Add checks to allow bad block erasing only if scrub flag is set.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
---
 drivers/mtd/nand/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index 99c29670c7..a4fb7602c9 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -174,7 +174,10 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo)
 	nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last);
 	while (nanddev_pos_cmp(&pos, &last) <= 0) {
 		schedule();
-		ret = nanddev_erase(nand, &pos);
+		if (!einfo->scrub && nanddev_isbad(nand, &pos))
+			ret = -EIO;
+		else
+			ret = nanddev_erase(nand, &pos);
 		if (ret) {
 			einfo->fail_addr = nanddev_pos_to_offs(nand, &pos);
 
-- 
2.35.1


  reply	other threads:[~2022-10-06 11:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06  3:14 [PATCH 1/7] mtd: replace name of 'rfree' field with 'free' in struct mtd_ooblayout_ops to better match it's description mikhail.kshevetskiy
2022-10-06  3:14 ` mikhail.kshevetskiy [this message]
2022-10-06  6:56   ` [PATCH 2/7] mtd/nand: try to erase bad blocks only if scrub flag is provided Michael Nazzareno Trimarchi
2022-10-06 15:52     ` Mikhail Kshevetskiy
2022-10-06 16:03       ` Michael Nazzareno Trimarchi
2022-10-06 16:17         ` Mikhail Kshevetskiy
2022-10-06 18:09           ` Michael Nazzareno Trimarchi
2022-10-10 13:32             ` Mikhail Kshevetskiy
2022-10-06  3:14 ` [PATCH 3/7] mtd/spinand: rework detect procedure for different READ_ID operation mikhail.kshevetskiy
2022-10-06  3:14 ` [PATCH 4/7] mtd/spinand: sync core spinand code with linux-5.10.118 mikhail.kshevetskiy
2022-10-06  3:15 ` [PATCH 5/7] mtd/spinand: sync supported devices with linux-5.15.43 mikhail.kshevetskiy
2022-10-06  3:15 ` [PATCH 6/7] mtd/spinand: add Winbond W25N02KV flash support, fix Winbond flashes identifications mikhail.kshevetskiy
2022-10-07 11:34 ` [PATCH 1/7] mtd: replace name of 'rfree' field with 'free' in struct mtd_ooblayout_ops to better match it's description Michael Nazzareno Trimarchi
2022-10-07 11:58   ` Fabio Estevam
2022-10-07 11:59     ` Michael Nazzareno Trimarchi
2022-10-07 14:01       ` Michael Nazzareno Trimarchi
2022-11-24 15:09     ` Frieder Schrempf
2022-12-05 16:11       ` Simon Glass
2022-12-05 16:15         ` Michael Nazzareno Trimarchi

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=20221006031501.110290-2-mikhail.kshevetskiy@iopsys.eu \
    --to=mikhail.kshevetskiy@iopsys.eu \
    --cc=agnau@iopsys.eu \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=michael@amarulasolutions.com \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.