mtd: nand: sunxi: prefer 1k ECC blocks when applicable

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Aug 1 18:59:06 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=872164e41fc8dee154e5f5d22580b34e198eed69
Commit:     872164e41fc8dee154e5f5d22580b34e198eed69
Parent:     252173c69eec6998ecf1be7b11d31cd39ce92c9c
Author:     Boris Brezillon <boris.brezillon at free-electrons.com>
AuthorDate: Mon Jun 6 13:59:12 2016 +0200
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Mon Jul 11 08:40:12 2016 +0200

    mtd: nand: sunxi: prefer 1k ECC blocks when applicable
    
    Switching to 1k ECC blocks when possible provides better resistance against
    concentrated bitflips. Say you have those two configurations:
    
    1/ 16bits/512bytes
    2/ 32bits/1024bytes
    
    Both of them require the same amount of ECC bytes (only true for this
    specific engine), but the second config allows you to correct the case
    where most of your bitflips are concentrated in a single 512bytes portion.
    
    This fact makes the 1k ECC block size more advantageous than the 512bytes
    one.
    
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 drivers/mtd/nand/sunxi_nand.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index b9a2e5d..bb440b9 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1786,6 +1786,12 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
 	if (!data)
 		return -ENOMEM;
 
+	/* Prefer 1k ECC chunk over 512 ones */
+	if (ecc->size == 512 && mtd->writesize > 512) {
+		ecc->size = 1024;
+		ecc->strength *= 2;
+	}
+
 	/* Add ECC info retrieval from DT */
 	for (i = 0; i < ARRAY_SIZE(strengths); i++) {
 		if (ecc->strength <= strengths[i])



More information about the linux-mtd-cvs mailing list