Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752728AbbG1SMP (ORCPT ); Tue, 28 Jul 2015 14:12:15 -0400 Received: from mail-bl2on0132.outbound.protection.outlook.com ([65.55.169.132]:4083 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751548AbbG1SMN (ORCPT ); Tue, 28 Jul 2015 14:12:13 -0400 X-Greylist: delayed 915 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Jul 2015 14:12:13 EDT Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; From: Han Xu To: CC: , , , , , , , Subject: [PATCH 3/6] mtd: nand: gpmi: may use minimum required ecc for 744 oobsize NAND Date: Tue, 28 Jul 2015 12:50:20 -0500 Message-ID: <1438105820-22229-1-git-send-email-b45815@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD006;1:u3F/G2iNOUIuJgBhYSPMmm440ANbN5FhXveYrk5uDIshOdCVPfXS+wB130yipnUSlKcyKFe+JLs1VUtmJ2eSsRoWgQH1RMDp6yIOhcf/L9N4FAiKB57x9eKLTG2Y9tsbwTgsnxkmH2VBnnFRxFnxYjdo2z8s8q6v7NoBq8IsUIL+nFXFfFGjIL9gZaDI088ju7gpA9HqhDoGnSa+m1Fo1+B8yESHyIQtCg919XjDvu11pMu6s3/kndA4cTVNDd5E8lDlO+u3GwwSP06j5MbXWDLEX/GFAbdTKcVxEt9NzJNjgrWPAkzz4G8/897FsL5pb8ARfyGu4QJw4tcL5vkAbQ== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(110136002)(85426001)(47776003)(77096005)(6806004)(62966003)(77156002)(33646002)(87936001)(50226001)(105606002)(19580405001)(229853001)(50986999)(48376002)(19580395003)(2351001)(104016003)(36756003)(189998001)(575784001)(5001920100001)(92566002)(5001960100002)(46102003)(106466001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB1311;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1311;2:Q9d94worziuHeFEsoemXnTXOZOqaIGQcOn804S2c+sDL+SGjk64CMYo+FvXqf6QRIP12RSubsykhG8zyGsxMau0de7R6+TCxT1p+K3rqrCSpJXeScbauCDW0z7FxEE8wIpEEgfrqoxQaZkjHWqpvO3Uizmjw7RYBaktTMdzEsqM=;3:5jPWLxuNGMvuxUiU2GJQUh0QpSfB2XdjsCGl1RwIqdAbpemwf7v44tKIV9+eN8kv06W+8wtJMavOWgdBz7zaPkgzj1E3j0FsuSEoPOUPBpwAzDZrldGCcu4c4NKY9FdkzcnBrSOS3zZwGE6yTPBMNTQmlMARYK8uOZo/NRvtpMfTwADlhBRRrLb55AUr9S1Vpg7XqkhKxGtUAfW6Sqi5hSxRVMqH3sbadCPTInuj6Pw=;25:nNSpYnWAvA064VGX5LsNPkSVnYS4DFL11fakS4igDK4CGcG/b0rN3FktO8ZSP8gPFuOzVEecoT/lgh++FHltlxteQp39afgFj64KRjYbAaqOhkBwNiORsy0wuTEcG7+9nczGIy++ozNZ/Bh2tXs/hHT7GTZHRNisZGXdG+enY5pZRB60Gwylekv6Rc/UcQOuMs0sClZPgUtrzhQMJX3fvcdAAGaeO33liTlzQdkxbLvTv8DfvqQk5nXk55RwAegK X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1311; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1311;20:rVOfWbKllymigVKrq1xJ2FO4+xB/33WjtU78q3ek6nBe4NJ2hG4OON11zpG2B4ScMERLNGhWLP3BiuUKr8RAIGqCesppeJp5WzVexRrC4LOzPRWsDmoWDDxtUOwWSeHc7F0sBXibVXtXD6iKvmOxRNlErl0zWoPYvauCpG86cVW3/Vu4LuyHmgDHYuFZqhx6FTyyhyNR9TihEH0RVRTG9qOqPic7dZ+gJKTEwXgb6GYfYRLRxOupIlQ147BZhwMd1GBWA/pvmHNmPH3XoOvGk5Y5Haei+2ddHAr3cDZ/oModZM0Xk5X6AqbPuFI9AYKCsmdNiVI4+o9WHjovLu1TuX5atTvsfIlXSvpUWUKyWKA=;4:Bdce94D4TZsyhCj78WxWo4FxkGbT0Na2XGZMrMYj+JwdmbHnyWTnbY+LJp9oQJhiSUYrXYU0ECgk893Jq9SH8n+s6oFRco/mK97HjBnGplR3P5SBikiKh1AHzU4dUwSGm7tE8A6Qu+GAhZ6ni+v2uAO6nzdVv4IYsvu6Nj4iwSdbTqEaGr857pnZwrTvLVSHeOWKHXybRIwWWExjdKxou5IlPaTHHGCSR4ct7hmdbKHtRsR/9TGHmDOnDdsqt9lMMkiGBT9f68xmyn5l/wE/Afp+TdX9B0Fbzygh+Uu/R1s= DM2PR0301MB1311: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:DM2PR0301MB1311;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1311; X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1311;23:TYEbxTqEo+DkeSp4UDrHLtd46LELXS3biTO1buUJ/vYQ/bc1AOJZ+ZxQiRPsSdWtZvanZDfroJD5oYDQwGCEvdZXLGsX4oCbWM0ASNth3KwN4j2JhjvBoHNxnKjCxkbJsQeOyDx5t8Xl4K7Ggc/XE95JPdS0Gyf9GURlef4QhDHlGOjz3gBR2mTh0lS9cTZzUjW0cTVuDAcXMqPjHcWfKdHOzGcHOOI5WriAr3Nne65WTEH0EnJF/oLvyzxguXbFgvdrk7g6yPK6o6835W4gcfpXi/0Emp06y+86HYwoac66TADjkOYfs0sHJsEWNid4p0edi/EgujwjrKfDE614eyJBswvDqxw+rphh2R5cENbT3e4f/ujTBTW/y7ZMId8QVUCZ7XUUM/lF3kg3ngFYfyTt4PHuMNJyH98vN3/S7MbZrIZtFB8OBnGg5MOFJXOoSTKGxpH80Abd6l06VSAsQvm/+VZtsWViKoEeQt0Z8a5dJyJGh7NYm/TQTymM/hYXpqO2oraeWwgTm6fusuD6u9yi+yVksT7UjXuptZHFyRggAQ/fvX9O0abqgpBeI+AGIRG5ewfLDZfkZFOIpKTnwQaD0mQ35e+bmfNFcwUquaKtbh4IvSmjbx9RYsTyHNb7pQAL2xoJIDaLOQtrRtz5FppoIY6cg6bqyuqxPIm/ZGWZvD/LV+O0BsjLpq+luLQ/x9FZ9KVCfaH+BP45NqoV9M3O22rhUENeAaUKVuUGkeuGOFwtcG2ZzFxfZFnPl7l66ZwjAUJPyFprOJlW27sT9IvxQ68kc0Qhk98kE159hgGE5/+xgAJyl1iQ8fhnOaierbw3Fses2x8GbAg19swdBw== X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1311;5:91TjFWiXqYaba9ZUGNQyvwJlQZ+MnwsProY0RAJvBCgB/6VGqKWrNztjNxrL6D7j9XCZkOW/rwPmuXPAPs0EuPSulKm8tDMKvxYK98e7AD0hs03RL0k9ust93odH3qTG8ALi/q5lk/0sHuWwBxK0cA==;24:tZJ0GojWw05KmBBDRnpfPcFxU+mwcbv/IN2mCtfmVRx19kGHF09F1RC2bF6BYvA5OTARKjEwD3jndjgxLlGYKKiCl6sjWQ3i3hVGAa3V72g=;20:NI57W65+HAH3E95vbpahuqnamFrarS8uqoU5KfuZ659woOtqmXCsu15TVPZfi45Dz2SCo39A0RrfZZ8biBkoMA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 17:58:03.2418 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1311 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3483 Lines: 102 By default NAND driver will choose the highest ecc strength that oob could contain, in this case, for some 8K+744 NAND flash, the ecc strength will be up to 52bit, which beyonds the i.MX6QDL BCH capability (40bit). This patch allows the NAND driver try to use minimum required ecc strength if it failed to use the highest ecc, even without explicitly claiming "fsl,use-minimum-ecc" in dts. Signed-off-by: Han Xu --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index dfd0ba1..01d24dd 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -136,7 +136,7 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this) * * We may have available oob space in this case. */ -static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) +static int set_geometry_by_ecc_info(struct gpmi_nand_data *this) { struct bch_geometry *geo = &this->bch_geometry; struct mtd_info *mtd = &this->mtd; @@ -145,7 +145,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) unsigned int block_mark_bit_offset; if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) - return false; + return -EINVAL; switch (chip->ecc_step_ds) { case SZ_512: @@ -158,19 +158,19 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) dev_err(this->dev, "unsupported nand chip. ecc bits : %d, ecc size : %d\n", chip->ecc_strength_ds, chip->ecc_step_ds); - return false; + return -EINVAL; } geo->ecc_chunk_size = chip->ecc_step_ds; geo->ecc_strength = round_up(chip->ecc_strength_ds, 2); if (!gpmi_check_ecc(this)) - return false; + return -EINVAL; /* Keep the C >= O */ if (geo->ecc_chunk_size < mtd->oobsize) { dev_err(this->dev, "unsupported nand chip. ecc size: %d, oob size : %d\n", chip->ecc_step_ds, mtd->oobsize); - return false; + return -EINVAL; } /* The default value, see comment in the legacy_set_geometry(). */ @@ -242,7 +242,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) + ALIGN(geo->ecc_chunk_count, 4); if (!this->swap_block_mark) - return true; + return 0; /* For bit swap. */ block_mark_bit_offset = mtd->writesize * 8 - @@ -251,7 +251,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) geo->block_mark_byte_offset = block_mark_bit_offset / 8; geo->block_mark_bit_offset = block_mark_bit_offset % 8; - return true; + return 0; } static int legacy_set_geometry(struct gpmi_nand_data *this) @@ -366,10 +366,12 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) int common_nfc_set_geometry(struct gpmi_nand_data *this) { - if (of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc") - && set_geometry_by_ecc_info(this)) - return 0; - return legacy_set_geometry(this); + + if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) + || legacy_set_geometry(this)) + return set_geometry_by_ecc_info(this); + + return 0; } struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/