From: "Mario J. Rugiero" <mrugiero@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: computersforpeace@gmail.com, boris.brezillon@free-electrons.com,
marek.vasut@gmail.com, richard@nod.at,
cyrille.pitchen@wedev4u.fr,
"Mario J. Rugiero" <mrugiero@gmail.com>
Subject: [PATCH 3/3] mtd: nand: add option to ignore bad blocks when erasing, opt-in through debugfs
Date: Sat, 20 May 2017 12:24:28 -0300 [thread overview]
Message-ID: <20170520152428.9184-4-mrugiero@gmail.com> (raw)
In-Reply-To: <20170520152428.9184-3-mrugiero@gmail.com>
Signed-off-by: Mario J. Rugiero <mrugiero@gmail.com>
---
drivers/mtd/nand/nand_base.c | 26 ++++++++++++++++++++++----
include/linux/mtd/nand.h | 12 ++++++++++++
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 52a257e12026..8cffea38a642 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -47,6 +47,7 @@
#include <linux/io.h>
#include <linux/mtd/partitions.h>
#include <linux/of.h>
+#include <linux/debugfs.h>
static int nand_get_device(struct mtd_info *mtd, int new_state);
@@ -3209,10 +3210,15 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
/* Check if we have a bad block, we do not erase bad blocks! */
if (nand_block_checkbad(mtd, ((loff_t) page) <<
chip->page_shift, allowbbt)) {
- pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
- __func__, page);
- instr->state = MTD_ERASE_FAILED;
- goto erase_exit;
+ if (!chip->dbg.scrub_enabled) {
+ pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
+ __func__, page);
+ instr->state = MTD_ERASE_FAILED;
+ goto erase_exit;
+ } else {
+ pr_warn("%s: erasing a bad block at page 0x%08x\n",
+ __func__, page);
+ }
}
/*
@@ -4931,6 +4937,18 @@ int nand_device_register(struct mtd_info *mtd,
int defnr_parts)
{
int ret = nand_device_register(mtd, defparts, defnr_parts);
+ struct nand_debug_info *dbg;
+
+ if (!ret) {
+ dbg = &mtd_to_nand(mtd)->dbg;
+ dbg->scrub_enabled = false;
+ dbg->dfs_scrub_enabled = debugfs_create_bool("scrub_enabled",
+ 0600,
+ mtd->dbg.dfs_dir,
+ &dbg->scrub_enabled);
+ if (IS_ERR(dbg->dfs_scrub_enabled))
+ dbg->dfs_scrub_enabled = NULL;
+ }
return ret;
}
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 77fc60923fdd..24114b120d0f 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -731,6 +731,16 @@ struct nand_manufacturer_ops {
};
/**
+ * struct nand_debug_info - NAND specific debugfs
+ * @dfs_scrub_enabled: dentry for setting force-erase of bad blocks
+ * @scrub_enabled: if true, erase can erase blocks marked as bad
+ */
+struct nand_debug_info {
+ struct dentry *dfs_scrub_enabled;
+ bool scrub_enabled;
+};
+
+/**
* struct nand_chip - NAND Private Flash Chip Data
* @mtd: MTD device registered to the MTD framework
* @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the
@@ -835,6 +845,7 @@ struct nand_manufacturer_ops {
* additional error status checks (determine if errors are
* correctable).
* @manufacturer: [INTERN] Contains manufacturer information
+ * @dbg: NAND debugfs data
*/
struct nand_chip {
@@ -926,6 +937,7 @@ struct nand_chip {
const struct nand_manufacturer *desc;
void *priv;
} manufacturer;
+ struct nand_debug_info dbg;
};
extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops;
--
2.13.0
next prev parent reply other threads:[~2017-05-20 15:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 15:24 [PATCH 0/3] mtd: nand: allow force erasing of bad blocks through debugfs entry Mario J. Rugiero
2017-05-20 15:24 ` [PATCH 1/3] mtd: create per-device and module-scope debugfs entries Mario J. Rugiero
2017-05-20 15:24 ` [PATCH 2/3] mtd: nand: create a wrapper for mtd_device_register for NAND specific initialization Mario J. Rugiero
2017-05-20 15:24 ` Mario J. Rugiero [this message]
2017-05-20 17:54 ` [PATCH 3/3] mtd: nand: add option to ignore bad blocks when erasing, opt-in through debugfs Boris Brezillon
2017-05-20 17:38 ` [PATCH 2/3] mtd: nand: create a wrapper for mtd_device_register for NAND specific initialization Boris Brezillon
2017-05-20 17:44 ` Boris Brezillon
2017-05-20 17:46 ` Boris Brezillon
2017-05-20 17:56 ` Boris Brezillon
2017-05-20 16:21 ` [PATCH 1/3] mtd: create per-device and module-scope debugfs entries Boris Brezillon
2017-05-20 16:41 ` Mario Rugiero
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=20170520152428.9184-4-mrugiero@gmail.com \
--to=mrugiero@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/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.