mtd: rawnand: Add a NAND_NO_BBM_QUIRK flag
Subsystems (2)
PATCH 1/3 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.
--- drivers/mtd/nand/raw/nand_base.c | 3 +++ include/linux/mtd/rawnand.h | 8 ++++++++ 2 files changed, 11 insertions(+)
drivers/mtd/nand/raw/nand_base.c +3 -0
@@ -345,6 +345,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);
include/linux/mtd/rawnand.h +8 -0
@@ -222,6 +222,14 @@ enum nand_ecc_algo {*/ #define NAND_KEEP_TIMINGS 0x00800000 +/* +* 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 0 +/* Cell info constants */ #define NAND_CI_CHIPNR_MSK 0x03#define NAND_CI_CELLTYPE_MSK 0x0C
Signature · 6 lines
2.25.3 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/3 mtd: rawnand: cafe: Set the NAND_NO_BBM_QUIRK flag
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.
--- drivers/mtd/nand/raw/cafe_nand.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +2 -9
@@ -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);
Signature · 6 lines
2.25.3 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 3/3 mtd: rawnand: diskonchip: Set the NAND_NO_BBM_QUIRK flag
In reply to Boris BrezillonWe 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.
--- drivers/mtd/nand/raw/diskonchip.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/mtd/nand/raw/diskonchip.c +1 -9
@@ -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;
Signature · 6 lines
2.25.3 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 33 lines · On Mon, 27 Apr 2020 09:24:51 +0200 Boris Brezillon…
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 <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 3 +++ include/linux/mtd/rawnand.h | 8 ++++++++ 2 files changed, 11 insertions(+)drivers/mtd/nand/raw/nand_base.c +3
-0@@ -345,6 +345,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);include/linux/mtd/rawnand.h +0
-0
include/linux/mtd/rawnand.h enum nand_ecc_algo { · line 231
Quoted 10 lines
include/linux/mtd/rawnand.h +7
-0@@ -222,6 +222,14 @@ enum nand_ecc_algo {*/ #define NAND_KEEP_TIMINGS 0x00800000 +/* +* 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 0
Oops, should be
#define NAND_NO_BBM_QUIRK 0x08000000
I'll have to rebase it on Miquel's series re-ordering the flag definitions and using the BIT() macro anyway. But please don't take this as an excuse for not reviewing this version :P.
include/linux/mtd/rawnand.h enum nand_ecc_algo { · line 235
Quoted 4 lines
include/linux/mtd/rawnand.h +1
-0+/* Cell info constants */ #define NAND_CI_CHIPNR_MSK 0x03#define NAND_CI_CELLTYPE_MSK 0x0C
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerHi Boris,
Boris Brezillon <[email protected]> wrote on Mon, 27 Apr 2020 09:24:51 +0200:
Quoted 33 lines
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 <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 3 +++ include/linux/mtd/rawnand.h | 8 ++++++++ 2 files changed, 11 insertions(+)drivers/mtd/nand/raw/nand_base.c +3
-0@@ -345,6 +345,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);include/linux/mtd/rawnand.h +0
-0
include/linux/mtd/rawnand.h enum nand_ecc_algo { · line 231
Quoted 10 lines
include/linux/mtd/rawnand.h +7
-0@@ -222,6 +222,14 @@ enum nand_ecc_algo {*/ #define NAND_KEEP_TIMINGS 0x00800000 +/* +* 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 0
Zero? :)
Maybe we'll have to rebase this patch on top of the recent cleanup of this portion, so that we define a nand_controller flag directly.
We'll see how it goes for the other series, I'll keep this change in mind.
include/linux/mtd/rawnand.h enum nand_ecc_algo { · line 235
Quoted 4 lines
include/linux/mtd/rawnand.h +1
-0+/* Cell info constants */ #define NAND_CI_CHIPNR_MSK 0x03#define NAND_CI_CELLTYPE_MSK 0x0C
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/3] mtd: rawnand: cafe: Set the NAND_NO_BBM_QUIRK flag
In reply to Boris BrezillonHi Boris,
Boris Brezillon <[email protected]> wrote on Mon, 27 Apr 2020 09:24:52 +0200:
Quoted 27 lines
We have a dummy
block_bad()implementation returning 0. Let's set theNAND_NO_BBM_QUIRKflag and let the core take care of that.Signed-off-by Boris Brezillon <[email protected]>--- drivers/mtd/nand/raw/cafe_nand.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/mtd/nand/raw/cafe_nand.c +0
-5@@ -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 ;
drivers/mtd/nand/raw/cafe_nand.c static int cafe_nand_probe(struct pci_dev *pdev, · line 720
Quoted 10 lines
drivers/mtd/nand/raw/cafe_nand.c +2
-4-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);
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 3/3] mtd: rawnand: diskonchip: Set the NAND_NO_BBM_QUIRK flag
In reply to Boris BrezillonHi Boris,
Boris Brezillon <[email protected]> wrote on Mon, 27 Apr 2020 09:24:53 +0200:
Quoted 35 lines
We have a dummy
block_bad()implementation returning 0. Let's set theNAND_NO_BBM_QUIRKflag and let the core take care of that.Signed-off-by Boris Brezillon <[email protected]>--- drivers/mtd/nand/raw/diskonchip.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/mtd/nand/raw/diskonchip.c +0
-8@@ -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;
drivers/mtd/nand/raw/diskonchip.c static int __init doc_probe(unsigned long physadr) · line 1588
Quoted 8 lines
drivers/mtd/nand/raw/diskonchip.c +1
-1@@ -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;
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerBoris Brezillon <[email protected]> wrote on Mon, 27 Apr 2020 09:28:36 +0200:
Quoted 49 lines
Quoted 33 lines · On Mon, 27 Apr 2020 09:24:51 +0200 Boris Brezillon…
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 <[email protected]>--- drivers/mtd/nand/raw/nand_base.c | 3 +++ include/linux/mtd/rawnand.h | 8 ++++++++ 2 files changed, 11 insertions(+)drivers/mtd/nand/raw/nand_base.c +3
-0@@ -345,6 +345,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);include/linux/mtd/rawnand.h +0
-0include/linux/mtd/rawnand.h enum nand_ecc_algo { · line 231
Quoted 10 lines
include/linux/mtd/rawnand.h +7
-0@@ -222,6 +222,14 @@ enum nand_ecc_algo {*/ #define NAND_KEEP_TIMINGS 0x00800000 +/* +* 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 0Oops, should be
Quoted 5 lines
#define
NAND_NO_BBM_QUIRK0x08000000I'll have to rebase it on Miquel's series re-ordering the flag definitions and using the
BIT()macro anyway. But please don't take this as an excuse for not reviewing this version :P.
Hehe, what did you say again about great minds? :)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/