All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag
@ 2020-05-11  6:49 Boris Brezillon
  2020-05-11  6:49 ` [PATCH v2 2/3] mtd: rawnand: cafe: Set the " Boris Brezillon
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Boris Brezillon @ 2020-05-11  6:49 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Boris Brezillon, Vignesh Raghavendra, Tudor Ambarus

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>
---
Changes in v2:
* Use the BIT() macro
* Rebase on top of nand/next
---
 drivers/mtd/nand/raw/nand_base.c | 3 +++
 include/linux/mtd/rawnand.h      | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 771762eff9c4..4a7587df15cb 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -395,6 +395,9 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
 
 static int nand_isbad_bbm(struct nand_chip *chip, loff_t ofs)
 {
+	if (chip->options & NAND_NO_BBM_QUIRK)
+		return 0;
+
 	if (chip->legacy.block_bad)
 		return chip->legacy.block_bad(chip, ofs);
 
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 18b5b4381a66..15fbc590a603 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -221,6 +221,14 @@ enum nand_ecc_algo {
 #define NAND_BBM_SECONDPAGE	BIT(25)
 #define NAND_BBM_LASTPAGE	BIT(26)
 
+/*
+ * Some controllers with pipelined 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.
+ */
+#define NAND_NO_BBM_QUIRK	BIT(27)
+
 /* Cell info constants */
 #define NAND_CI_CHIPNR_MSK	0x03
 #define NAND_CI_CELLTYPE_MSK	0x0C
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] mtd: rawnand: cafe: Set the NAND_NO_BBM_QUIRK flag
  2020-05-11  6:49 [PATCH v2 1/3] mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag Boris Brezillon
@ 2020-05-11  6:49 ` Boris Brezillon
  2020-05-11  7:49   ` Miquel Raynal
  2020-05-11  6:49 ` [PATCH v2 3/3] mtd: rawnand: diskonchip: " Boris Brezillon
  2020-05-11  7:49 ` [PATCH v2 1/3] mtd: rawnand: Add a " Miquel Raynal
  2 siblings, 1 reply; 6+ messages in thread
From: Boris Brezillon @ 2020-05-11  6:49 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Boris Brezillon, Vignesh Raghavendra, Tudor Ambarus

We have a dummy block_bad() implementation returning 0. Let's set the
NAND_NO_BBM_QUIRK flag and let the core take care of that.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
Changes in v2:
* Add R-b
---
 drivers/mtd/nand/raw/cafe_nand.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
index 2d1c22dc88c1..2a0df13df5f3 100644
--- a/drivers/mtd/nand/raw/cafe_nand.c
+++ b/drivers/mtd/nand/raw/cafe_nand.c
@@ -546,11 +546,6 @@ static int cafe_nand_write_page_lowlevel(struct nand_chip *chip,
 	return nand_prog_page_end_op(chip);
 }
 
-static int cafe_nand_block_bad(struct nand_chip *chip, loff_t ofs)
-{
-	return 0;
-}
-
 /* F_2[X]/(X**6+X+1)  */
 static unsigned short gf64_mul(u8 a, u8 b)
 {
@@ -718,10 +713,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 	/* Enable the following for a flash based bad block table */
 	cafe->nand.bbt_options = NAND_BBT_USE_FLASH;
 
-	if (skipbbt) {
-		cafe->nand.options |= NAND_SKIP_BBTSCAN;
-		cafe->nand.legacy.block_bad = cafe_nand_block_bad;
-	}
+	if (skipbbt)
+		cafe->nand.options |= NAND_SKIP_BBTSCAN | NAND_NO_BBM_QUIRK;
 
 	if (numtimings && numtimings != 3) {
 		dev_warn(&cafe->pdev->dev, "%d timing register values ignored; precisely three are required\n", numtimings);
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] mtd: rawnand: diskonchip: Set the NAND_NO_BBM_QUIRK flag
  2020-05-11  6:49 [PATCH v2 1/3] mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag Boris Brezillon
  2020-05-11  6:49 ` [PATCH v2 2/3] mtd: rawnand: cafe: Set the " Boris Brezillon
@ 2020-05-11  6:49 ` Boris Brezillon
  2020-05-11  7:49   ` Miquel Raynal
  2020-05-11  7:49 ` [PATCH v2 1/3] mtd: rawnand: Add a " Miquel Raynal
  2 siblings, 1 reply; 6+ messages in thread
From: Boris Brezillon @ 2020-05-11  6:49 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Boris Brezillon, Vignesh Raghavendra, Tudor Ambarus

We have a dummy block_bad() implementation returning 0. Let's set the
NAND_NO_BBM_QUIRK flag and let the core take care of that.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
Changes in v2:
* Add R-b
---
 drivers/mtd/nand/raw/diskonchip.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/diskonchip.c b/drivers/mtd/nand/raw/diskonchip.c
index c2a391ad2c35..4c3d04da4cee 100644
--- a/drivers/mtd/nand/raw/diskonchip.c
+++ b/drivers/mtd/nand/raw/diskonchip.c
@@ -776,13 +776,6 @@ static int doc200x_dev_ready(struct nand_chip *this)
 	}
 }
 
-static int doc200x_block_bad(struct nand_chip *this, loff_t ofs)
-{
-	/* This is our last resort if we couldn't find or create a BBT.  Just
-	   pretend all blocks are good. */
-	return 0;
-}
-
 static void doc200x_enable_hwecc(struct nand_chip *this, int mode)
 {
 	struct doc_priv *doc = nand_get_controller_data(this);
@@ -1578,7 +1571,6 @@ static int __init doc_probe(unsigned long physadr)
 	nand->legacy.cmd_ctrl		= doc200x_hwcontrol;
 	nand->legacy.dev_ready	= doc200x_dev_ready;
 	nand->legacy.waitfunc	= doc200x_wait;
-	nand->legacy.block_bad	= doc200x_block_bad;
 	nand->ecc.hwctl		= doc200x_enable_hwecc;
 	nand->ecc.calculate	= doc200x_calculate_ecc;
 	nand->ecc.correct	= doc200x_correct_data;
@@ -1590,7 +1582,7 @@ static int __init doc_probe(unsigned long physadr)
 	nand->ecc.options	= NAND_ECC_GENERIC_ERASED_CHECK;
 	nand->bbt_options	= NAND_BBT_USE_FLASH;
 	/* Skip the automatic BBT scan so we can run it manually */
-	nand->options		|= NAND_SKIP_BBTSCAN;
+	nand->options		|= NAND_SKIP_BBTSCAN | NAND_NO_BBM_QUIRK;
 
 	doc->physadr		= physadr;
 	doc->virtadr		= virtadr;
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] mtd: rawnand: diskonchip: Set the NAND_NO_BBM_QUIRK flag
  2020-05-11  6:49 ` [PATCH v2 3/3] mtd: rawnand: diskonchip: " Boris Brezillon
@ 2020-05-11  7:49   ` Miquel Raynal
  0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-11  7:49 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus

On Mon, 2020-05-11 at 06:49:17 UTC, Boris Brezillon wrote:
> We have a dummy block_bad() implementation returning 0. Let's set the
> NAND_NO_BBM_QUIRK flag and let the core take care of that.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] mtd: rawnand: cafe: Set the NAND_NO_BBM_QUIRK flag
  2020-05-11  6:49 ` [PATCH v2 2/3] mtd: rawnand: cafe: Set the " Boris Brezillon
@ 2020-05-11  7:49   ` Miquel Raynal
  0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-11  7:49 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus

On Mon, 2020-05-11 at 06:49:16 UTC, Boris Brezillon wrote:
> We have a dummy block_bad() implementation returning 0. Let's set the
> NAND_NO_BBM_QUIRK flag and let the core take care of that.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag
  2020-05-11  6:49 [PATCH v2 1/3] mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag Boris Brezillon
  2020-05-11  6:49 ` [PATCH v2 2/3] mtd: rawnand: cafe: Set the " Boris Brezillon
  2020-05-11  6:49 ` [PATCH v2 3/3] mtd: rawnand: diskonchip: " Boris Brezillon
@ 2020-05-11  7:49 ` Miquel Raynal
  2 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-11  7:49 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus

On Mon, 2020-05-11 at 06:49:15 UTC, Boris Brezillon wrote:
> 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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-11  7:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11  6:49 [PATCH v2 1/3] mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag Boris Brezillon
2020-05-11  6:49 ` [PATCH v2 2/3] mtd: rawnand: cafe: Set the " Boris Brezillon
2020-05-11  7:49   ` Miquel Raynal
2020-05-11  6:49 ` [PATCH v2 3/3] mtd: rawnand: diskonchip: " Boris Brezillon
2020-05-11  7:49   ` Miquel Raynal
2020-05-11  7:49 ` [PATCH v2 1/3] mtd: rawnand: Add a " Miquel Raynal

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.