diff mbox series

Enable the read ECC before program the page

Message ID 59b983ce.82b8370a.04a2.b72a@mx.google.com
State Superseded
Headers show
Series Enable the read ECC before program the page | expand

Commit Message

Arun Nagendran Sept. 13, 2017, 7:15 p.m. UTC
Current program_page function did following operation:

1. read page (with ECC OFF)
2. modify the page
3. write the page (with ECC ON)

For some case(buggy flash Chip), while read the page without ECC ON,
we may read the page with bit flip error and modify that bad page without
knowing the bit flip error on that page.
also we re-calculate the hash for bad page and write it.
This could bring potential in-consistency problem with Flash data.

Verify this logic with GIGA DEVICE Part(GD5F2GQ4RCFIG):
we see this in-conststency problem wit Giga Device and fix on
this patch resovle that issue.

Signed-off-by: Arun Nagendran <arunrasppi@gmail.com>
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

gregkh@linuxfoundation.org Sept. 13, 2017, 9:31 p.m. UTC | #1
On Wed, Sep 13, 2017 at 03:15:26PM -0400, Arun Nagendran wrote:
> Current program_page function did following operation:
> 
> 1. read page (with ECC OFF)
> 2. modify the page
> 3. write the page (with ECC ON)
> 
> For some case(buggy flash Chip), while read the page without ECC ON,
> we may read the page with bit flip error and modify that bad page without
> knowing the bit flip error on that page.
> also we re-calculate the hash for bad page and write it.
> This could bring potential in-consistency problem with Flash data.
> 
> Verify this logic with GIGA DEVICE Part(GD5F2GQ4RCFIG):
> we see this in-conststency problem wit Giga Device and fix on
> this patch resovle that issue.
> 
> Signed-off-by: Arun Nagendran <arunrasppi@gmail.com>

Please read Documentation/SubmittingPatches for how to properly version
your patches so we know what is going on and which one to accept/review.

Also your subject line needs some work, look at the other subjects for
patches that have been accepted for this driver/subsystem for examples
of what needs to be done.

thanks,

greg k-h
Arun Nagendran Sept. 14, 2017, 3:56 p.m. UTC | #2
On Wed, Sep 13, 2017 at 02:31:54PM -0700, Greg KH wrote:
> On Wed, Sep 13, 2017 at 03:15:26PM -0400, Arun Nagendran wrote:
> > Current program_page function did following operation:
> > 
> > 1. read page (with ECC OFF)
> > 2. modify the page
> > 3. write the page (with ECC ON)
> > 
> > For some case(buggy flash Chip), while read the page without ECC ON,
> > we may read the page with bit flip error and modify that bad page without
> > knowing the bit flip error on that page.
> > also we re-calculate the hash for bad page and write it.
> > This could bring potential in-consistency problem with Flash data.
> > 
> > Verify this logic with GIGA DEVICE Part(GD5F2GQ4RCFIG):
> > we see this in-conststency problem wit Giga Device and fix on
> > this patch resovle that issue.
> > 
> > Signed-off-by: Arun Nagendran <arunrasppi@gmail.com>
> 
> Please read Documentation/SubmittingPatches for how to properly version
> your patches so we know what is going on and which one to accept/review.
> 
> Also your subject line needs some work, look at the other subjects for
> patches that have been accepted for this driver/subsystem for examples
> of what needs to be done.
> 
> thanks,
> 
> greg k-h

Thank you Greg on your review comments, I am working on 
your suggestion.

Thanks,
-Arun
diff mbox series

Patch

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index 13eaf16..87595c5 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -496,8 +496,12 @@  static int spinand_program_page(struct spi_device *spi_nand,
 	if (!wbuf)
 		return -ENOMEM;
 
-	enable_read_hw_ecc = 0;
-	spinand_read_page(spi_nand, page_id, 0, CACHE_BUF, wbuf);
+	enable_read_hw_ecc = 1;
+	retval = spinand_read_page(spi_nand, page_id, 0, CACHE_BUF, wbuf);
+	if (retval < 0) {
+		dev_err(&spi_nand->dev, "ecc error on read page!!!\n");
+		return retval;
+	}
 
 	for (i = offset, j = 0; i < len; i++, j++)
 		wbuf[i] &= buf[j];