Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752992AbbH1TmY (ORCPT ); Fri, 28 Aug 2015 15:42:24 -0400 Received: from mail-bn1on0143.outbound.protection.outlook.com ([157.56.110.143]:56992 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752552AbbH1Tlq (ORCPT ); Fri, 28 Aug 2015 15:41:46 -0400 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;vger.kernel.org; dmarc=none action=none header.from=freescale.com; From: Han Xu To: CC: , , , , , , , , , , Subject: [PATCH v3 3/6] mtd: nand: gpmi: may use minimum required ecc for 744 oobsize NAND Date: Fri, 28 Aug 2015 14:32:42 -0500 Message-ID: <1440790365-28072-4-git-send-email-b45815@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440790365-28072-1-git-send-email-b45815@freescale.com> References: <1440790365-28072-1-git-send-email-b45815@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC012;1:sUV1A/GHe/Gdl3yWs0lW10DuaqevL0hx7mn/13qUwZXLPvZWjEbu+5t04FLy2CCPPHovz3rGvnRNBpgCNIfZQuXhsCle3jQPSrVHpIXaaithyyeTCyZ/joB33/wNkk//n5jbJV+jjRAdQHyVVZfr4lV03d/W9zbkEJM1hcN+wQPl48bGYKXEoYRby4mYlUM+mpknfz46rrM7mkVmCAQ0KEFuDinEwylsvfx62Eq0QG/6op3Gn8edXO29fRv+UUlfA2uF+KfL3q3OfHTopUhV5eXJ48AvFeP/biMmcBT3VWvxyF9pBcORAz5dGZtlCQ9UaZl7N7m8GVTINIoLNH+ksswQX+NCyjaGngunugHmcodxhHHo4ZsOSBXxxgQKvN8V1e4mD7/dIlkHUvvMfHsTuSp9CUKc5y2AsuZLee77XGQ= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(189002)(199003)(6806004)(76176999)(19580395003)(85426001)(104016003)(19580405001)(50466002)(105606002)(48376002)(5001860100001)(33646002)(64706001)(47776003)(50226001)(92566002)(87936001)(50986999)(46102003)(229853001)(575784001)(36756003)(2351001)(110136002)(2950100001)(106466001)(189998001)(5007970100001)(62966003)(68736005)(5003940100001)(97736004)(5001830100001)(4001540100001)(77156002)(81156007)(77096005)(5001960100002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB556;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB556;2:egra1/D1TvZPQFboDTgvOL50d4R91MTA0zXIJIoyFgEG8hZvF3HsXJ7v9V/j02mF3fD7pFLvUAVLBIvHf9pQWRec7unrwYQlQOHCBQ8TiznW6ZHRF9Mw323nif5gCMs70/iuOemOquip+wwLM/+Sl9CKnI6XACdLZqak07TCC8g=;3:sihOOk6MnGikU4qNucjyBerQm0nShcwEY4A2FhjhsjjJ8S/V40SrRQcFR8D3d6glXVrpp4l/4CVkb5NP7YaHjriszNY5mSZ/xcFx/DwPRZWuKFvo3Ss1N9FPtnf5spEc/UG9QekULdjNi1tHvf5OEVTnWJr2FX5S5BP9TZDmylZJEBa61+GGNb5/z1gAUURqNmHbo2Zmpf/tr9wUvMVDZ/qVBOb69N2M2I/VOX+V0yQ=;25:P5mSyg9jeQMBNTtp6dAoS+2edF8P82B4OpzPp46gaPJX7AAB9LfaJKn09LcD2nfCA9DV+T/Hv3v7xWjHfsrw3SMz/BKyn/s4R6N9DH1BBEreWjxIgrMMxvvIv/rP+peWu+xu+VCxlJJcSouXZQcDukUtEfomcRWhMQbCITRWAFZclTrORejnpcHohYionO6C7e5RWElE3hMp9G9+Kr5zUgegEq6gSM2BVmYIWFB5pJVrCaLr1jQchT5u+lu3p6Sf X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB556; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB556;20:ZpuQjmk5TYd/ISxFMT+dDqN+fHULRVPHmL3kuvwYKCbO7Ns5YnzNffGy/pQHsxbCn63ZthAr2dGaf2OtBONX46qzXlY8VN75/hpQwsoQgP1GG29YYcyvyUvJP/77wiQPrMNyS07Kynh+LZ5gDmVaPWXoztAwBxedd9NkRt4J9oGTut4P7DuwB0Eq0VK6E3iZJUQQeaSxwwVXqu/jVqpDAaRzlkjRnnMoazv5/IigGbuo3kVxJpWP9ymcfEOGjNfwEweZJG6OnRDOEyUNpVPVq7vwh3boOEsRRhfs2Wma0iGkzXEYX25b4TZKiCN3zW0walBsTfIJmImXroUvfBocQeEoIK11X7zirmDKmN/NIKM=;4:TwVXiFyWJD1uWxKPD6hszXr2VxAClzX2me3l89FJknXylgvAXSPOlzKzu3mT9DxkGZyO8K4IbcUBeM85QwdujjxWjGJe/4ppeBVPadxM5oJlM0YGTSM492g87ANLiL+7N7mIZiJH0DFklF2T+zIE9UEuPqcAre5a+HcKXVpjEPkjvXFi6CAVJEsOuSCjhmJi4Z9s73fQGWyuJUInYFXz3MRByz+//IYRjWmgV8Aft9ggWMG81Bmx8krxRmQ2IHN1dOHksf1F0lHvDMD+zB59J6a4zQjYykLexf+3Gg2djkZFJ9Pb18zM4nVYWv/gwLwN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:BY2PR03MB556;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB556; X-Forefront-PRVS: 0682FC00E8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB556;23:Rw74HKhkFDja+N/rG6qNh1KGKuIvJ9wpeHDgs1jaN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YdLJwWIK6acrKnHPFj9a27y?= =?us-ascii?Q?QQ8nXRuE5ssrhEBhwtBh57g2ukPreLRvFGt9/ifv9MB6YJdO2o7xDrRsB7fo?= =?us-ascii?Q?DyzE6v8OHfwYWSUmiG4sxr3Ao6eQRqzjnwVHCKiJLw0S5PqiZfUSv1VxeYt5?= =?us-ascii?Q?n3dbs71nfUjoaznDFPx+/FZPwrUbx/sJF4x1BEznnpEX0zp3eiH+asDvN+0V?= =?us-ascii?Q?FRCl0JlX3nFquDkt7ql5njiovTv6wr2QKlvJYwjxjAPvbtzVUcIw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB556;5:FMtBGyJXuDXm0gwgioJczLy9fGXa+dMj7mah1lbz5b5a+L2P4FoMZCkc3bsUoGfBb5uGIshs1mz8qMyWuVLLk8H9X4uJ/1DE+WUgqj2CnFkt3TZM48/+VWShK+LFilpnHQeX+1YTtI6rvu/kwBoScg==;24:TNsud8gplN6joGPHqWjENOeWTQ1FK5s4jUBalu/ZosvMpAJVfeNsMvlbKavaju+oVxMXt5uyYMBdI6v6bd/+RDBoLqhz5Mnusdmait8ZI7I=;20:K4aQ7YJ0adm3D3mdt4ecaYNYnE3X7b27KCvF6gBjCx+XCah5JjtkBU5yW59LBiOKazWkspa0SDnbcVFE2QstMA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2015 19:41:43.6707 (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: BY2PR03MB556 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3976 Lines: 111 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 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index dfd0ba1..632876c 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) @@ -285,7 +285,8 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) geo->ecc_strength = get_ecc_strength(this); if (!gpmi_check_ecc(this)) { dev_err(this->dev, - "required ecc strength of the NAND chip: %d is not supported by the GPMI controller (%d)\n", + "ecc strength: %d cannot be supported by the controller (%d)\n" + "try to use minimum ecc strength that NAND chip required\n", geo->ecc_strength, this->devdata->bch_max_ecc_strength); return -EINVAL; @@ -366,10 +367,11 @@ 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/