From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dsCHt-0005Pb-9y for linux-mtd@lists.infradead.org; Wed, 13 Sep 2017 18:21:26 +0000 Received: by mail-qk0-x243.google.com with SMTP id i14so618022qke.3 for ; Wed, 13 Sep 2017 11:21:02 -0700 (PDT) Message-ID: <59b97707.c38b370a.3fa1c.ac86@mx.google.com> Date: Wed, 13 Sep 2017 14:20:55 -0400 From: Arun Nagendran To: kamlakant.patel@broadcom.com Cc: gregkh@linuxfoundation.org, manonuevo@micron.com, linux-mtd@lists.infradead.org Subject: [PATCH] Enable the read ECC before program the page. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index a4e3ae8..2b03cc9 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); + { + 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]; -- 2.7.4