diff mbox

mtd: gpmi: Always report ECC stats and return max_bitflips

Message ID 50C5FD4A.6090405@itwatchdogs.com
State New, archived
Headers show

Commit Message

Zach Sadecki Dec. 10, 2012, 3:18 p.m. UTC
Always report corrected and failed ECC stats back up to the MTD layer.  Also
return max_bitflips from read_page() as is expected from NAND drivers now.

Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com>
Acked-by: Huang Shijie <b32955 at freescale.com>
---
  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   27 ++++++++-------------------
  1 file changed, 8 insertions(+), 19 deletions(-)

Comments

Artem Bityutskiy Dec. 12, 2012, 3:17 p.m. UTC | #1
On Mon, 2012-12-10 at 09:18 -0600, Zach Sadecki wrote:
> Always report corrected and failed ECC stats back up to the MTD layer.  Also
> return max_bitflips from read_page() as is expected from NAND drivers now.
> 
> Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com>
> Acked-by: Huang Shijie <b32955 at freescale.com>
> ---
>   drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   27 ++++++++-------------------
>   1 file changed, 8 insertions(+), 19 deletions(-)

patching file drivers/mtd/nand/gpmi-nand/gpmi-nand.c
Hunk #1 FAILED at 921.
Hunk #2 FAILED at 946.
Hunk #3 FAILED at 996.
3 out of 3 hunks FAILED -- saving rejects to file drivers/mtd/nand/gpmi-nand/gpmi-nand.c.rej
Zach Sadecki Dec. 12, 2012, 4:57 p.m. UTC | #2
On 12/12/2012 09:17 AM, Artem Bityutskiy wrote:
> patching file drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> Hunk #1 FAILED at 921.
> Hunk #2 FAILED at 946.
> Hunk #3 FAILED at 996.
> 3 out of 3 hunks FAILED -- saving rejects to file drivers/mtd/nand/gpmi-nand/gpmi-nand.c.rej
>
Odd.  I used git format-patch on a freshly cloned l2-mtd repo...  I 
don't know what could be wrong.  I did a fresh pull, and another git 
format-patch and it generated the exact same patch file.  Any ideas?
Artem Bityutskiy Dec. 13, 2012, 11:27 a.m. UTC | #3
On Mon, 2012-12-10 at 09:18 -0600, Zach Sadecki wrote:
> Always report corrected and failed ECC stats back up to the MTD layer.  Also
> return max_bitflips from read_page() as is expected from NAND drivers now.
> 
> Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com>
> Acked-by: Huang Shijie <b32955 at freescale.com>
> ---

Dunno, may be your patch is corrupted or something. Try to save it and
apply. This is what I get:

$ git apply --check ~/tmp/zach.mbox
error: patch failed: drivers/mtd/nand/gpmi-nand/gpmi-nand.c:921
error: drivers/mtd/nand/gpmi-nand/gpmi-nand.c: patch does not apply

$ git log -1 --oneline
70df8b3 mtd: nand: gpmi: reset BCH earlier, too, to avoid NAND startup problems

I've attached the zach.mbox file for you.
Zach Sadecki Dec. 14, 2012, 2:39 a.m. UTC | #4
On 12/13/2012 05:27 AM, Artem Bityutskiy wrote:
> On Mon, 2012-12-10 at 09:18 -0600, Zach Sadecki wrote:
>> Always report corrected and failed ECC stats back up to the MTD layer.  Also
>> return max_bitflips from read_page() as is expected from NAND drivers now.
>>
>> Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com>
>> Acked-by: Huang Shijie <b32955 at freescale.com>
>> ---
> Dunno, may be your patch is corrupted or something. Try to save it and
> apply. This is what I get:
>
> $ git apply --check ~/tmp/zach.mbox
> error: patch failed: drivers/mtd/nand/gpmi-nand/gpmi-nand.c:921
> error: drivers/mtd/nand/gpmi-nand/gpmi-nand.c: patch does not apply
>
> $ git log -1 --oneline
> 70df8b3 mtd: nand: gpmi: reset BCH earlier, too, to avoid NAND startup problems
>
> I've attached the zach.mbox file for you.
>
OK.  I rebased the patch on the latest l2-mtd and I tested it with git 
apply, so this one should work...

Sent as a separate reply with only the patch in it.
Huang Shijie Jan. 10, 2013, 3:28 a.m. UTC | #5
于 2012年12月14日 10:39, Zach Sadecki 写道:
> On 12/13/2012 05:27 AM, Artem Bityutskiy wrote:
>> On Mon, 2012-12-10 at 09:18 -0600, Zach Sadecki wrote:
>>> Always report corrected and failed ECC stats back up to the MTD 
>>> layer. Also
>>> return max_bitflips from read_page() as is expected from NAND 
>>> drivers now.
>>>
>>> Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com>
>>> Acked-by: Huang Shijie <b32955 at freescale.com>
>>> ---
>> Dunno, may be your patch is corrupted or something. Try to save it and
>> apply. This is what I get:
>>
>> $ git apply --check ~/tmp/zach.mbox
>> error: patch failed: drivers/mtd/nand/gpmi-nand/gpmi-nand.c:921
>> error: drivers/mtd/nand/gpmi-nand/gpmi-nand.c: patch does not apply
>>
>> $ git log -1 --oneline
>> 70df8b3 mtd: nand: gpmi: reset BCH earlier, too, to avoid NAND 
>> startup problems
>>
>> I've attached the zach.mbox file for you.
>>
> OK. I rebased the patch on the latest l2-mtd and I tested it with git 
> apply, so this one should work...
>
> Sent as a separate reply with only the patch in it.
Dear Zach,
I think you'd better check the patch with /scripts/checkpatch.pl before 
you send out the patch.
I saw many "trailing whitespace" in your patch.

thanks.

Huang Shijie
Zach Sadecki Jan. 10, 2013, 3:40 p.m. UTC | #6
On 01/09/2013 09:28 PM, Huang Shijie wrote:
> Dear Zach,
> I think you'd better check the patch with /scripts/checkpatch.pl 
> before you send out the patch.
> I saw many "trailing whitespace" in your patch.
>
> thanks.
>
> Huang Shijie 

I just checked it:

zach@zpc:~/git/l2-mtd$ scripts/checkpatch.pl 
0001-mtd-gpmi-Always-report-ECC-stats-and-return-max_bitf.patch
total: 0 errors, 0 warnings, 59 lines checked

0001-mtd-gpmi-Always-report-ECC-stats-and-return-max_bitf.patch has no 
obvious style problems and is ready for submission.

---

The reply to the original thread dated "Thu Dec 13 21:36:43 EST 2012" 
should be the correct patch...

Zach
diff mbox

Patch

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 5cd141f..1535bd5 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -921,8 +921,7 @@  static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  	dma_addr_t    auxiliary_phys;
  	unsigned int  i;
  	unsigned char *status;
-	unsigned int  failed;
-	unsigned int  corrected;
+	unsigned int  max_bitflips = 0;
  	int           ret;
  
  	pr_debug("page number is : %d\n", page);
@@ -946,35 +945,25 @@  static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  			payload_virt, payload_phys);
  	if (ret) {
  		pr_err("Error in ECC-based read: %d\n", ret);
-		goto exit_nfc;
+		return ret;
  	}
  
  	/* handle the block mark swapping */
  	block_mark_swapping(this, payload_virt, auxiliary_virt);
  
  	/* Loop over status bytes, accumulating ECC status. */
-	failed		= 0;
-	corrected	= 0;
-	status		= auxiliary_virt + nfc_geo->auxiliary_status_offset;
+	status = auxiliary_virt + nfc_geo->auxiliary_status_offset;
  
  	for (i = 0; i < nfc_geo->ecc_chunk_count; i++, status++) {
  		if ((*status == STATUS_GOOD) || (*status == STATUS_ERASED))
  			continue;
  
  		if (*status == STATUS_UNCORRECTABLE) {
-			failed++;
+			mtd->ecc_stats.failed++;
  			continue;
  		}
-		corrected += *status;
-	}
-
-	/*
-	 * Propagate ECC status to the owning MTD only when failed or
-	 * corrected times nearly reaches our ECC correction threshold.
-	 */
-	if (failed || corrected >= (nfc_geo->ecc_strength - 1)) {
-		mtd->ecc_stats.failed    += failed;
-		mtd->ecc_stats.corrected += corrected;
+		mtd->ecc_stats.corrected += *status;
+		max_bitflips = max_t(unsigned int, max_bitflips, *status);
  	}
  
  	if (oob_required) {
@@ -996,8 +985,8 @@  static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  			this->payload_virt, this->payload_phys,
  			nfc_geo->payload_size,
  			payload_virt, payload_phys);
-exit_nfc:
-	return ret;
+
+	return max_bitflips;
  }
  
  static int gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip,