mtd: brcmnand: Add check for erased page bitflips
Subsystems (2)
PATCH 1/2 mtd: brcmnand: Add check for erased page bitflips
Check for erased page bitflips in a page. And if well within threshold return data as all 0xff.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 83 +++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-)
drivers/mtd/nand/brcmnand/brcmnand.c +78 -5
@@ -1490,6 +1490,64 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,return ret; } +/* +* Check a page to see if it is erased (w/ bitflips) after an uncorrectable ECC +* error +* +* Because the HW ECC signals an ECC error if an erase paged has even a single +* bitflip, we must check each ECC error to see if it is actually an erased +* page with bitflips, not a truly corrupted page. +* +* On a real error, return a negative error code (-EBADMSG for ECC error), and +* buf will contain raw data. +* Otherwise, fill buf with 0xff and return the maximum number of +* bitflips-per-ECC-sector to the caller. +* +*/ +static int brcmstb_nand_verify_erased_page (struct mtd_info *mtd, +struct nand_chip *chip,void *buf,u64 addr) +{ +int i, sas, oob_nbits, data_nbits; +void *oob = chip->oob_poi; +unsigned int max_bitflips =0 ; +int page = addr >> chip->page_shift; +int ret; + +if (!buf) { + buf = chip->buffers->databuf; +/* Invalidate page cache */ + chip->pagebuf =-1 ; + } + + sas = mtd->oobsize / chip->ecc.steps; + oob_nbits = sas <<3 ; + data_nbits = chip->ecc.size <<3 ; + +/* read without ecc for verification */ + chip->cmdfunc (mtd,NAND_CMD_READ0 ,0x00 , page); + ret = chip->ecc.read_page_raw (mtd, chip, buf, true, page); +if (ret) +return ret; + +for (i =0 ; i < chip->ecc.steps; i++, oob += sas) { +unsigned int bitflips =0 ; + + bitflips += oob_nbits -bitmap_weight (oob, oob_nbits); + bitflips += data_nbits -bitmap_weight (buf, data_nbits); + + buf += chip->ecc.size; + addr += chip->ecc.size; + +/* Too many bitflips */ +if (bitflips > chip->ecc.strength) +return -EBADMSG ; + + max_bitflips =max (max_bitflips, bitflips); + } + +return max_bitflips; +} +static int brcmnand_read (struct mtd_info *mtd,struct nand_chip *chip,u64 addr,unsigned int trans,u32 *buf,u8 *oob) {
@@ -1520,11 +1578,26 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, }if (mtd_is_eccerr (err)) { -dev_dbg (ctrl->dev,"uncorrectable error at 0x%llx\n" , - (unsigned long long )err_addr); - mtd->ecc_stats.failed++; -/* NAND layer expects zero on ECC errors */ -return 0 ; +int ret; + + ret =brcmstb_nand_verify_erased_page (mtd, chip, buf, addr); +if (ret <0 ) { +dev_dbg (ctrl->dev,"uncorrectable error at 0x%llx\n" , + (unsigned long long )err_addr); + mtd->ecc_stats.failed++; +/* NAND layer expects zero on ECC errors */ +return 0 ; + }else { +if (buf) +memset (buf,0xff ,FC_BYTES * trans); +if (oob) +memset (oob,0xff , mtd->oobsize); + +dev_info (&host->pdev->dev, +"corrected %d bitflips in blank page at 0x%llx\n" , + ret, (unsigned long long )addr); +return ret; + } }if (mtd_is_bitflip (err)) {
Signature · 1 line
1.9.1
PATCH 2/2 mtd: brcmnand: Detect sticky ucorr ecc error on dma reads
This change provides a fix for controller bug where nand controller could have a possible sticky error after a PIO followed by a DMA read. The fix retries a read if we see a uncorr_ecc after read to detect such sticky errors.
--- drivers/mtd/nand/brcmnand/brcmnand.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/mtd/nand/brcmnand/brcmnand.c +14 -1
@@ -1555,9 +1555,11 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,struct brcmnand_controller *ctrl = host->ctrl;u64 err_addr =0 ;int err; +bool retry = true;dev_dbg (ctrl->dev,"read %llx -> %p\n" , (unsigned long long )addr, buf); +try_dmaread:brcmnand_write_reg (ctrl,BRCMNAND_UNCORR_COUNT ,0 );if (has_flash_dma (ctrl) && !oob &&flash_dma_buf_ok (buf)) {
@@ -1579,7 +1581,18 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,if (mtd_is_eccerr (err)) {int ret; - +/* +* On controller version >=7.0 if we are doing a DMA read +* after a prior PIO read that reported uncorrectable error, +* the DMA engine captures this error following DMA read +* cleared only on subsequent DMA read, so just retry once +* to clear a possible false error reported for current DMA +* read +*/ +if ((ctrl->nand_version >=0x0700 ) && retry) { + retry = false; + goto try_dmaread; + } ret =brcmstb_nand_verify_erased_page (mtd, chip, buf, addr);if (ret <0 ) { dev_dbg(ctrl->dev, "uncorrectable error at 0x%llx\n",
Signature · 1 line
1.9.1
Re: [PATCH 2/2] mtd: brcmnand: Detect sticky ucorr ecc error on dma reads
Quoted 29 lines · On Fri, 29 Apr 2016 16:21:25 -0400 Kamal Dasu <[email protected]> wrote:
This change provides a fix for controller bug where nand controller could have a possible sticky error after a PIO followed by a DMA read. The fix retries a read if we see a
uncorr_eccafter read to detect such sticky errors.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/brcmnand/brcmnand.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/mtd/nand/brcmnand/brcmnand.c +2
-0@@ -1555,9 +1555,11 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,struct brcmnand_controller *ctrl = host->ctrl;u64 err_addr =0 ;int err; +bool retry = true;dev_dbg (ctrl->dev,"read %llx -> %p\n" , (unsigned long long )addr, buf); +try_dmaread:brcmnand_write_reg (ctrl,BRCMNAND_UNCORR_COUNT ,0 );if (has_flash_dma (ctrl) && !oob &&flash_dma_buf_ok (buf)) {@@ -1579,7 +1581,18 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,if (mtd_is_eccerr (err)) {
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, · line 1591
Quoted 10 lines
drivers/mtd/nand/brcmnand/brcmnand.c +8
-1int ret; - +/* +* On controller version >=7.0 if we are doing a DMA read +* after a prior PIO read that reported uncorrectable error, +* the DMA engine captures this error following DMA read +* cleared only on subsequent DMA read, so just retry once +* to clear a possible false error reported for current DMA +* read +*/
Hm, shouldn't this BRCMNAND_UNCORR_COUNT bit be cleared just after doing the PIO/DMA read instead of doing it before executing a new read? This would solve your problem without the need for this extra retry, or am I missing something?
Quoted 7 lines
drivers/mtd/nand/brcmnand/brcmnand.c +4
-0+if ((ctrl->nand_version >=0x0700 ) && retry) { + retry = false; + goto try_dmaread; + } ret =brcmstb_nand_verify_erased_page (mtd, chip, buf, addr);if (ret <0 ) { dev_dbg(ctrl->dev, "uncorrectable error at 0x%llx\n",
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] mtd: brcmnand: Detect sticky ucorr ecc error on dma reads
Boris,
Quoted 31 lines · Boris Brezillon
Quoted 28 lines · On Fri, 29 Apr 2016 16:21:25 -0400 Kamal Dasu <[email protected]> wrote:
This change provides a fix for controller bug where nand controller could have a possible sticky error after a PIO followed by a DMA read. The fix retries a read if we see a
uncorr_eccafter read to detect such sticky errors.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/brcmnand/brcmnand.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/mtd/nand/brcmnand/brcmnand.c +2
-0@@ -1555,9 +1555,11 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,struct brcmnand_controller *ctrl = host->ctrl;u64 err_addr =0 ;int err; +bool retry = true;dev_dbg (ctrl->dev,"read %llx -> %p\n" , (unsigned long long )addr, buf); +try_dmaread:brcmnand_write_reg (ctrl,BRCMNAND_UNCORR_COUNT ,0 );if (has_flash_dma (ctrl) && !oob &&flash_dma_buf_ok (buf)) {@@ -1579,7 +1581,18 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,
Quoted 17 lines
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, · line 1591
Quoted 11 lines
drivers/mtd/nand/brcmnand/brcmnand.c +8
-1if (mtd_is_eccerr (err)) {int ret; - +/* +* On controller version >=7.0 if we are doing a DMA read +* after a prior PIO read that reported uncorrectable error, +* the DMA engine captures this error following DMA read +* cleared only on subsequent DMA read, so just retry once +* to clear a possible false error reported for current DMA +* read +*/ Hm, shouldn't this
BRCMNAND_UNCORR_COUNTbit be cleared just after doing the PIO/DMA read instead of doing it before executing a new read? This would solve your problem without the need for this extra retry, or am I missing something?
Clearing the count registers or the intr registers does not clear the condition. Only a clean read (a page that does not have errors) clears the condition. So if this was a false error ( page is really clean) and we read again, it will clear the condition.
Thanks
Kamal
Re: [PATCH 2/2] mtd: brcmnand: Detect sticky ucorr ecc error on dma reads
Quoted 53 lines · On Wed, 1 Jun 2016 12:50:56 -0400 Kamal Dasu <[email protected]> wrote:
Boris,
Quoted 31 lines · Boris Brezillon
Quoted 28 lines · On Fri, 29 Apr 2016 16:21:25 -0400 Kamal Dasu <[email protected]> wrote:
This change provides a fix for controller bug where nand controller could have a possible sticky error after a PIO followed by a DMA read. The fix retries a read if we see a
uncorr_eccafter read to detect such sticky errors.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/brcmnand/brcmnand.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/mtd/nand/brcmnand/brcmnand.c +2
-0@@ -1555,9 +1555,11 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,struct brcmnand_controller *ctrl = host->ctrl;u64 err_addr =0 ;int err; +bool retry = true;dev_dbg (ctrl->dev,"read %llx -> %p\n" , (unsigned long long )addr, buf); +try_dmaread:brcmnand_write_reg (ctrl,BRCMNAND_UNCORR_COUNT ,0 );if (has_flash_dma (ctrl) && !oob &&flash_dma_buf_ok (buf)) {@@ -1579,7 +1581,18 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,Quoted 17 lines
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, · line 1591
Quoted 11 lines
drivers/mtd/nand/brcmnand/brcmnand.c +8
-1if (mtd_is_eccerr (err)) {int ret; - +/* +* On controller version >=7.0 if we are doing a DMA read +* after a prior PIO read that reported uncorrectable error, +* the DMA engine captures this error following DMA read +* cleared only on subsequent DMA read, so just retry once +* to clear a possible false error reported for current DMA +* read +*/ Hm, shouldn't this
BRCMNAND_UNCORR_COUNTbit be cleared just after doing the PIO/DMA read instead of doing it before executing a new read? This would solve your problem without the need for this extra retry, or am I missing something?
Quoted 4 lines
Clearing the count registers or the intr registers does not clear the condition. Only a clean read (a page that does not have errors) clears the condition. So if this was a false error ( page is really clean) and we read again, it will clear the condition.
This sounds like an expensive workaround, but you know the IP better than I do, so I'll trust you ;).
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] mtd: brcmnand: Detect sticky ucorr ecc error on dma reads
In reply to Kamal DasuQuoted 53 lines · On Wed, 1 Jun 2016 12:50:56 -0400 Kamal Dasu <[email protected]> wrote:
Boris,
Quoted 31 lines · Boris Brezillon
Quoted 28 lines · On Fri, 29 Apr 2016 16:21:25 -0400 Kamal Dasu <[email protected]> wrote:
This change provides a fix for controller bug where nand controller could have a possible sticky error after a PIO followed by a DMA read. The fix retries a read if we see a
uncorr_eccafter read to detect such sticky errors.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/brcmnand/brcmnand.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)drivers/mtd/nand/brcmnand/brcmnand.c +2
-0@@ -1555,9 +1555,11 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,struct brcmnand_controller *ctrl = host->ctrl;u64 err_addr =0 ;int err; +bool retry = true;dev_dbg (ctrl->dev,"read %llx -> %p\n" , (unsigned long long )addr, buf); +try_dmaread:brcmnand_write_reg (ctrl,BRCMNAND_UNCORR_COUNT ,0 );if (has_flash_dma (ctrl) && !oob &&flash_dma_buf_ok (buf)) {@@ -1579,7 +1581,18 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,Quoted 17 lines
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, · line 1591
Quoted 11 lines
drivers/mtd/nand/brcmnand/brcmnand.c +8
-1if (mtd_is_eccerr (err)) {int ret; - +/* +* On controller version >=7.0 if we are doing a DMA read +* after a prior PIO read that reported uncorrectable error, +* the DMA engine captures this error following DMA read +* cleared only on subsequent DMA read, so just retry once +* to clear a possible false error reported for current DMA +* read +*/ Hm, shouldn't this
BRCMNAND_UNCORR_COUNTbit be cleared just after doing the PIO/DMA read instead of doing it before executing a new read? This would solve your problem without the need for this extra retry, or am I missing something?
Quoted 5 lines
Clearing the count registers or the intr registers does not clear the condition. Only a clean read (a page that does not have errors) clears the condition. So if this was a false error ( page is really clean) and we read again, it will clear the condition.
Can you try that patch [1], just to make sure the extra read cycle is really necessary?
[1]http://code.bulix.org/uzb7m8-99997
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH 2/2] mtd: brcmnand: Detect sticky ucorr ecc error on dma reads
Yes have tried this, but its the controller internals that causes this condition.
Kamal
Hi Kamal,
Quoted 42 lines · On Fri, 29 Apr 2016 16:21:24 -0400 Kamal Dasu <[email protected]> wrote:
Check for erased page bitflips in a page. And if well within threshold return data as all
0xff.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/brcmnand/brcmnand.c | 83 +++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-)drivers/mtd/nand/brcmnand/brcmnand.c +26
-0@@ -1490,6 +1490,64 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,return ret; } +/* +* Check a page to see if it is erased (w/ bitflips) after an uncorrectable ECC +* error +* +* Because the HW ECC signals an ECC error if an erase paged has even a single +* bitflip, we must check each ECC error to see if it is actually an erased +* page with bitflips, not a truly corrupted page. +* +* On a real error, return a negative error code (-EBADMSG for ECC error), and +* buf will contain raw data. +* Otherwise, fill buf with 0xff and return the maximum number of +* bitflips-per-ECC-sector to the caller. +* +*/ +static int brcmstb_nand_verify_erased_page (struct mtd_info *mtd, +struct nand_chip *chip,void *buf,u64 addr) +{ +int i, sas, oob_nbits, data_nbits; +void *oob = chip->oob_poi; +unsigned int max_bitflips =0 ; +int page = addr >> chip->page_shift; +int ret; + +if (!buf) { + buf = chip->buffers->databuf; +/* Invalidate page cache */
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, · line 1528
Quoted 10 lines
drivers/mtd/nand/brcmnand/brcmnand.c +10
-0+ chip->pagebuf =-1 ; + } + + sas = mtd->oobsize / chip->ecc.steps; + oob_nbits = sas <<3 ; + data_nbits = chip->ecc.size <<3 ; + +/* read without ecc for verification */ + chip->cmdfunc (mtd,NAND_CMD_READ0 ,0x00 , page); + ret = chip->ecc.read_page_raw (mtd, chip, buf, true, page);
Do you really need to read the whole page in raw mode? Usually, only reading the OOB sections is enough.
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, · line 1539
Quoted 11 lines
drivers/mtd/nand/brcmnand/brcmnand.c +11
-0+if (ret) +return ret; + +for (i =0 ; i < chip->ecc.steps; i++, oob += sas) { +unsigned int bitflips =0 ; + + bitflips += oob_nbits -bitmap_weight (oob, oob_nbits); + bitflips += data_nbits -bitmap_weight (buf, data_nbits); + + buf += chip->ecc.size; + addr += chip->ecc.size;
You seem to duplicate nand_check_erased_ecc_chunk() here. Do you have a good reason for doing that?
Regards,
Boris
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Boris,
Quoted 52 lines · Boris Brezillon
Hi Kamal,
Quoted 47 lines · On Fri, 29 Apr 2016 16:21:24 -0400 Kamal Dasu <[email protected]> wrote:
Check for erased page bitflips in a page. And if well within threshold return data as all
0xff.Signed-off-by Kamal Dasu <[email protected]>--- drivers/mtd/nand/brcmnand/brcmnand.c | 83 +++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-)drivers/mtd/nand/brcmnand/brcmnand.c +31
-0@@ -1490,6 +1490,64 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,return ret; } +/* +* Check a page to see if it is erased (w/ bitflips) after an uncorrectable ECC +* error +* +* Because the HW ECC signals an ECC error if an erase paged has even a single +* bitflip, we must check each ECC error to see if it is actually an erased +* page with bitflips, not a truly corrupted page. +* +* On a real error, return a negative error code (-EBADMSG for ECC error), and +* buf will contain raw data. +* Otherwise, fill buf with 0xff and return the maximum number of +* bitflips-per-ECC-sector to the caller. +* +*/ +static int brcmstb_nand_verify_erased_page (struct mtd_info *mtd, +struct nand_chip *chip,void *buf,u64 addr) +{ +int i, sas, oob_nbits, data_nbits; +void *oob = chip->oob_poi; +unsigned int max_bitflips =0 ; +int page = addr >> chip->page_shift; +int ret; + +if (!buf) { + buf = chip->buffers->databuf; +/* Invalidate page cache */ + chip->pagebuf =-1 ; + } + + sas = mtd->oobsize / chip->ecc.steps; + oob_nbits = sas <<3 ;
Quoted 9 lines
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, · line 1528
Quoted 5 lines
drivers/mtd/nand/brcmnand/brcmnand.c +5
-0+ data_nbits = chip->ecc.size <<3 ; + +/* read without ecc for verification */ + chip->cmdfunc (mtd,NAND_CMD_READ0 ,0x00 , page); + ret = chip->ecc.read_page_raw (mtd, chip, buf, true, page);Do you really need to read the whole page in raw mode? Usually, only reading the OOB sections is enough.
Just so that the HW ecc algo does not kick in we read the page in raw mode. OOB registers are filled as part of this read. Also just the data might have bit flips and OOB might be all FFs, we still need to read page data. Generally we read again to make sure that the hw ecc algo did not change the data after calculations in the original read where it reported uncorrectable error. I will double check this.
Quoted 6 lines
Quoted 6 lines
drivers/mtd/nand/brcmnand/brcmnand.c +6
-0+if (ret) +return ret; + +for (i =0 ; i < chip->ecc.steps; i++, oob += sas) { +unsigned int bitflips =0 ; +
Quoted 9 lines
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, · line 1539
Quoted 5 lines
drivers/mtd/nand/brcmnand/brcmnand.c +5
-0+ bitflips += oob_nbits -bitmap_weight (oob, oob_nbits); + bitflips += data_nbits -bitmap_weight (buf, data_nbits); + + buf += chip->ecc.size; + addr += chip->ecc.size;You seem to duplicate
nand_check_erased_ecc_chunk()here. Do you have a good reason for doing that?
Hmmm I see what you are saying. Let me try setting the NAND_ECC_GENERIC_ERASED_CHECK option and see if we can get away without having to read raw. I will have to test and make sure on uncorrectable error the hw leaves the return page data buffers and oob buffers in raw state.
If that works as expected I will get rid of this duplication and send a revised change which shall make use of the NAND_ECC_GENERIC_ERASED_CHECK option.
Thanks
Kamal
Quoted 21 lines · Kamal Dasu
Quoted 18 lines · Boris Brezillon
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, · line 1539
Quoted 11 lines · On Fri, 29 Apr 2016 16:21:24 -0400 Kamal Dasu <[email protected]> wrote:
drivers/mtd/nand/brcmnand/brcmnand.c +11
-0+if (ret) +return ret; + +for (i =0 ; i < chip->ecc.steps; i++, oob += sas) { +unsigned int bitflips =0 ; + + bitflips += oob_nbits -bitmap_weight (oob, oob_nbits); + bitflips += data_nbits -bitmap_weight (buf, data_nbits); + + buf += chip->ecc.size; + addr += chip->ecc.size;You seem to duplicate
nand_check_erased_ecc_chunk()here. Do you have a good reason for doing that?
Quoted 5 lines
Hmmm I see what you are saying. Let me try setting the
NAND_ECC_GENERIC_ERASED_CHECKoption and see if we can get away without having to read raw. I will have to test and make sure on uncorrectable error the hw leaves the return page data buffers and oob buffers in raw state.
I'm quite sure you can't make use of NAND_ECC_GENERIC_ERASED_CHECK unless you do a substantial rewrite; brcmnand doesn't use any of the nand_base ecc.read_{page,subpage} callbacks.
Quoted 3 lines
If that works as expected I will get rid of this duplication and send a revised change which shall make use of the
NAND_ECC_GENERIC_ERASED_CHECKoption.
I suspect he was just suggesting calling the nand_check_erased_ecc_chunk() helper instead of doing your own bitmap_weight() calls.
Brian
Quoted 32 lines · On Wed, 1 Jun 2016 10:14:40 -0700 Brian Norris <[email protected]>…
Quoted 21 lines · Kamal Dasu
Quoted 18 lines · Boris Brezillon
drivers/mtd/nand/brcmnand/brcmnand.c static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, · line 1539
Quoted 11 lines · On Fri, 29 Apr 2016 16:21:24 -0400 Kamal Dasu <[email protected]> wrote:
drivers/mtd/nand/brcmnand/brcmnand.c +11
-0+if (ret) +return ret; + +for (i =0 ; i < chip->ecc.steps; i++, oob += sas) { +unsigned int bitflips =0 ; + + bitflips += oob_nbits -bitmap_weight (oob, oob_nbits); + bitflips += data_nbits -bitmap_weight (buf, data_nbits); + + buf += chip->ecc.size; + addr += chip->ecc.size;You seem to duplicate
nand_check_erased_ecc_chunk()here. Do you have a good reason for doing that?Quoted 5 lines
Hmmm I see what you are saying. Let me try setting the
NAND_ECC_GENERIC_ERASED_CHECKoption and see if we can get away without having to read raw. I will have to test and make sure on uncorrectable error the hw leaves the return page data buffers and oob buffers in raw state.I'm quite sure you can't make use of
NAND_ECC_GENERIC_ERASED_CHECKunless you do a substantial rewrite; brcmnand doesn't use any of thenand_baseecc.read_{page,subpage} callbacks.
Quoted 7 lines
Quoted 3 lines
If that works as expected I will get rid of this duplication and send a revised change which shall make use of the
NAND_ECC_GENERIC_ERASED_CHECKoption.I suspect he was just suggesting calling the
nand_check_erased_ecc_chunk()helper instead of doing your ownbitmap_weight()calls.
Exactly.
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Boris,
Quoted 8 lines
Quoted 8 lines
I'm quite sure you can't make use of
NAND_ECC_GENERIC_ERASED_CHECKunless you do a substantial rewrite; brcmnand doesn't use any of thenand_baseecc.read_{page,subpage} callbacks.Quoted 3 lines
If that works as expected I will get rid of this duplication and send a revised change which shall make use of the
NAND_ECC_GENERIC_ERASED_CHECKoption.
Quoted 7 lines
Quoted 3 lines
I suspect he was just suggesting calling the
nand_check_erased_ecc_chunk()helper instead of doing your ownbitmap_weight()calls.Exactly.
Ok got it. Yes I did realize that using the option is not straight forward as far as brcmnand driver is concerned.
Thanks
Kamal