From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0135.outbound.protection.outlook.com ([104.47.40.135]:48864 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032407AbeCAPeJ (ORCPT ); Thu, 1 Mar 2018 10:34:09 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Miquel Raynal , Boris Brezillon , Sasha Levin Subject: [added to the 4.1 stable tree] mtd: nand: sunxi: Fix ECC strength choice Date: Thu, 1 Mar 2018 15:26:02 +0000 Message-ID: <20180301152116.1486-326-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Miquel Raynal This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit f4c6cd1a7f2275d5bc0e494b21fff26f8dde80f0 ] When the requested ECC strength does not exactly match the strengths supported by the ECC engine, the driver is selecting the closest strength meeting the 'selected_strength > requested_strength' constraint. Fix the fact that, in this particular case, ecc->strength value was not updated to match the 'selected_strength'. For instance, one can encounter this issue when no ECC requirement is filled in the device tree while the NAND chip minimum requirement is not a strength/step_size combo natively supported by the ECC engine. Fixes: 1fef62c1423b ("mtd: nand: add sunxi NAND flash controller support") Cc: Suggested-by: Boris Brezillon Signed-off-by: Miquel Raynal Signed-off-by: Boris Brezillon Signed-off-by: Sasha Levin --- drivers/mtd/nand/sunxi_nand.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 499b8e433d3d..1c8fdc3cec93 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -933,8 +933,14 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct m= td_info *mtd, =20 /* Add ECC info retrieval from DT */ for (i =3D 0; i < ARRAY_SIZE(strengths); i++) { - if (ecc->strength <=3D strengths[i]) + if (ecc->strength <=3D strengths[i]) { + /* + * Update ecc->strength value with the actual strength + * that will be used by the ECC engine. + */ + ecc->strength =3D strengths[i]; break; + } } =20 if (i >=3D ARRAY_SIZE(strengths)) { --=20 2.14.1