aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-06-06 07:59:12 -0400
committerBoris Brezillon <boris.brezillon@free-electrons.com>2016-07-11 02:40:12 -0400
commit872164e41fc8dee154e5f5d22580b34e198eed69 (patch)
tree86c7fd439d623bab6921d6ec06e3244e9f09f33c /drivers/mtd
parent252173c69eec6998ecf1be7b11d31cd39ce92c9c (diff)
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@free-electrons.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/sunxi_nand.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index b9a2e5d28754..bb440b91096f 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,
1786 if (!data) 1786 if (!data)
1787 return -ENOMEM; 1787 return -ENOMEM;
1788 1788
1789 /* Prefer 1k ECC chunk over 512 ones */
1790 if (ecc->size == 512 && mtd->writesize > 512) {
1791 ecc->size = 1024;
1792 ecc->strength *= 2;
1793 }
1794
1789 /* Add ECC info retrieval from DT */ 1795 /* Add ECC info retrieval from DT */
1790 for (i = 0; i < ARRAY_SIZE(strengths); i++) { 1796 for (i = 0; i < ARRAY_SIZE(strengths); i++) {
1791 if (ecc->strength <= strengths[i]) 1797 if (ecc->strength <= strengths[i])