Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp8501pxb; Sat, 9 Oct 2021 11:52:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzjofWQXLIn23mu/YdVBfbAqy5qyQoa8wnu/HouH0+YbI7uZS6dyyxKI6KHvPC9EF3d4h2 X-Received: by 2002:a17:902:e313:b0:13f:1866:aa86 with SMTP id q19-20020a170902e31300b0013f1866aa86mr8441609plc.55.1633805544433; Sat, 09 Oct 2021 11:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633805544; cv=none; d=google.com; s=arc-20160816; b=MJ1Yx+nqWj9EXJaQ2vT8dVbeKPJX+Znqb+F9w3IWGV3pVnJPVJ1r2I0wq1d2OdbL/V Co2cZP8zSGFgvvxgEryA1TAYjv8PN2l0uUgxaGOUI0WfvVMPzd4WUo4xXbGZdI8artYu Au5PqzDvhIyvWkVVG6jcg3NzOfOW4uJAP6giQOz+cEawTloWdqD2fSv68RtBNBfD1zQW o45RV7lUZqPGZZ3OALW4ZS+x++dSgv9/Pns/nqcsXQaX0tkxnbA5UW+4b7Tp/EzLqUmx 3YFZ3rG3mkr3/PLueEMcPWH3DdD4Q/Q69NiBlSMBIa1l4vA4DD013XZPhQ+9RPrCLYMu 9+Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cOOb6T12qD0+HZPxzTN94tbyA8f9GRDnkjxx2zAUWmk=; b=jWPPeIk3o9F7ggNNWpYg5tGUS3JuzDqlDsiwJDPa/blW70rTWtk7Z02sbh9aNiJznE N2v1nkCBDBHnNXM7QT8JVkjmRPEhR+7URqcA6SNIkGKzigt9cLAWMaV7AWBREjg5c/OW QKau/rUs/JTf7shcP1XB7hI7bszOQxzJewc6SkxiXY59Y5Rhmr/87wMy1STt7ObaOF21 QRCKqzBmwF/KnJdTUnDGKDk2xWzHylwvfEAPQgFO70mhVpfNey6TYX6en+S366KM5rgI b+6aojhxUQ5A/D/lR1URrzTNCEjpDTcZRpoNrnlQGo0xQzPCvrLEhzUo6HG48Bl+AdVn k2hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m128si4054060pfd.255.2021.10.09.11.52.11; Sat, 09 Oct 2021 11:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230167AbhJISw2 (ORCPT + 99 others); Sat, 9 Oct 2021 14:52:28 -0400 Received: from aposti.net ([89.234.176.197]:46724 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhJISwV (ORCPT ); Sat, 9 Oct 2021 14:52:21 -0400 From: Paul Cercueil To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Harvey Hunt Cc: list@opendingux.net, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Paul Cercueil , stable@vger.kernel.org Subject: [PATCH 3/3] mtd: rawnand/ingenic: JZ4740 needs 'oob_first' read page function Date: Sat, 9 Oct 2021 20:49:52 +0200 Message-Id: <20211009184952.24591-4-paul@crapouillou.net> In-Reply-To: <20211009184952.24591-1-paul@crapouillou.net> References: <20211009184952.24591-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ECC engine on the JZ4740 SoC requires the ECC data to be read before the page; using the default page reading function does not work. Indeed, the old JZ4740 NAND driver (removed in 5.4) did use the 'OOB first' flag that existed back then. Use the newly created nand_read_page_hwecc_oob_first() to address this issue. This issue was not found when the new ingenic-nand driver was developed, most likely because the Device Tree used had the nand-ecc-mode set to "hw_oob_first", which seems to not be supported anymore. Cc: # v5.2 Fixes: a0ac778eb82c ("mtd: rawnand: ingenic: Add support for the JZ4740") Signed-off-by: Paul Cercueil --- drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c index 0e9d426fe4f2..b18861bdcdc8 100644 --- a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c +++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c @@ -32,6 +32,7 @@ struct jz_soc_info { unsigned long addr_offset; unsigned long cmd_offset; const struct mtd_ooblayout_ops *oob_layout; + bool oob_first; }; struct ingenic_nand_cs { @@ -240,6 +241,9 @@ static int ingenic_nand_attach_chip(struct nand_chip *chip) if (chip->bbt_options & NAND_BBT_USE_FLASH) chip->bbt_options |= NAND_BBT_NO_OOB; + if (nfc->soc_info->oob_first) + chip->ecc.read_page = nand_read_page_hwecc_oob_first; + /* For legacy reasons we use a different layout on the qi,lb60 board. */ if (of_machine_is_compatible("qi,lb60")) mtd_set_ooblayout(mtd, &qi_lb60_ooblayout_ops); @@ -534,6 +538,7 @@ static const struct jz_soc_info jz4740_soc_info = { .data_offset = 0x00000000, .cmd_offset = 0x00008000, .addr_offset = 0x00010000, + .oob_first = true, }; static const struct jz_soc_info jz4725b_soc_info = { -- 2.33.0