Received: by 10.223.185.116 with SMTP id b49csp2551402wrg; Thu, 15 Feb 2018 13:29:36 -0800 (PST) X-Google-Smtp-Source: AH8x227wTcSrhSOEIn8E7T5exuCIWd704pkQ6scdKzOtCXdP+DuhrGeHMOQ2BKs9W74KFiLFBgWE X-Received: by 2002:a17:902:900b:: with SMTP id a11-v6mr3745544plp.249.1518730176684; Thu, 15 Feb 2018 13:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518730176; cv=none; d=google.com; s=arc-20160816; b=lJKyJeBWlLv+TQZwoWgZH2KZglTHOVf/oKY2Kg1SKH3VAEMzCkODLmlBoSI8gtVqqr gpFlFR6gjngvdhBFMsqMCClWgpflsHgPi8HL35G3/72F1sMgRqMOx3TUUFvTRrbM/yXU lN/+XOUh6K5f8kO/wOtl4F8drJqPY52g6VFxVMxX3H0MzzmUsmKr6mf0dy7fEra0egVj 19tTKcSHOjV1hzzIxlhgVLX8TTbCTmSggURLozbqLF6zbIbNkTuZO4BHymUUiyG5ruLw lVaJ7cWPsXg5E6ks2/tYGAdupSfkmwtugUoAcInRWxs2agfXL7/k8bM3FV6AdvWXZh65 j94w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=H7EOt1s0WfO4KMmSnjLQSpeGmaeM088SEMMKRSjBjTQ=; b=MGM9ffjrauDQ3hGtwa7lELF+P+ie3oxblDxDjKF1TxHmZTeEdqEeIRKO5iIkPEgJnh m23dVsORl0xcJZ4eb8rbu7KzQMWMSrBhk4ffZbJhS2NR3tGcr3AiXh86GRnyVPB+z3lo 8xPrIFhPanzmGLfhTMFOUn+1B78lxkS+9qMmozaCYBb/RWXGYDlslCbVvrEoS8TfzfqB haZS5SqCeugnH1NaG4Bnx7oE/RA43bZ+LtPYvzzoOucZI/oUOfcvljonCExMhHg581/p +FiAS/keKInQ92hVyU66wlw6mAmUwnaRxmpqiZa6ydw+jYpfbf5t3K/r6hOe2bSHgvqA G/Ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o63si1855864pfg.137.2018.02.15.13.29.22; Thu, 15 Feb 2018 13:29:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163396AbeBOP0a (ORCPT + 99 others); Thu, 15 Feb 2018 10:26:30 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52896 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163369AbeBOP02 (ORCPT ); Thu, 15 Feb 2018 10:26:28 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B21FFD72; Thu, 15 Feb 2018 15:26:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Brezillon , Miquel Raynal Subject: [PATCH 4.9 18/88] mtd: nand: sunxi: Fix ECC strength choice Date: Thu, 15 Feb 2018 16:16:45 +0100 Message-Id: <20180215151225.271964778@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.437136975@linuxfoundation.org> References: <20180215151222.437136975@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miquel Raynal commit f4c6cd1a7f2275d5bc0e494b21fff26f8dde80f0 upstream. 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") Suggested-by: Boris Brezillon Signed-off-by: Miquel Raynal Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/sunxi_nand.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1835,8 +1835,14 @@ static int sunxi_nand_hw_common_ecc_ctrl /* Add ECC info retrieval from DT */ for (i = 0; i < ARRAY_SIZE(strengths); i++) { - if (ecc->strength <= strengths[i]) + if (ecc->strength <= strengths[i]) { + /* + * Update ecc->strength value with the actual strength + * that will be used by the ECC engine. + */ + ecc->strength = strengths[i]; break; + } } if (i >= ARRAY_SIZE(strengths)) {