From patchwork Wed May 10 11:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 13236807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8513C7EE26 for ; Wed, 10 May 2023 11:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=24tXVTwOJUSHJhNfE+oY4LkaI0od0NrEIk1+b3qposA=; b=qEGD1FRMFlQSna xCV4jn9Guhw8O2U6AZEzGXkPKmkHKUICK36J6N+hRTzy0CfbL2pvn2P41HUoCi0R39nn3Edm7pxfU PS5wbwNqJrBQgVBr6yA/XhK9+dn/rWOUtQNpnUcIQbiH5hvAd3igPB6qSM3ZHUnryxDpFFN+be/bJ IszXoG0xxlhxb0X/nSfROqNw0RaSYZGytxhO5lSqLeMrdPXZLvbIi2eKNFXd/1jkncZL89nb4c0hx OI5TIdEataakx/Ovj7cMrDyap8bKo9IpXgSb4c6w5ZxXrwLO/cpqnd0NYv4hJrFersTltQCT5dvTC gKzJ4tvn6MDODsRqBd3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pwhlb-005zEI-0O; Wed, 10 May 2023 11:13:55 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pwhlR-005z7M-2O; Wed, 10 May 2023 11:13:47 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 1BFD45FD28; Wed, 10 May 2023 14:13:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1683717224; bh=pDgBDoAKjg6vj7ErjpVUqQO/7LJNM4Rbiw1rV81IA2I=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=D5IjbeTUTO5iE1NbyyeAPb7mEeEsZufkvCkVZxiZDqxefDo3L/a7zFiqkwqFkpRV3 cFMsORQhsE2BaFLrYxLzEJQv7u5xhm4CIwKoPELxmLu0vrQtZPFcJSLgDAjO/VhMCB Yibr7IRFnECeoUw22G3xItZzhdfeBXASZPfWZOjAr0bmg2LSwtai95gUwRo4gp8QMW t2zDnEAVGXWytKjOZWmbia+dRm5H8x3MOLBHWEsd4s5LR7aRrPFLAcBcvIvWS+Rs9u 8GxwlupMj0WosxGC37O3d/thbwvGqIOVS6MDv+eYzXUXbtSFsBMr1L9aMDa0SLFy+T pznDj5aQOmQfA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Wed, 10 May 2023 14:13:43 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jianxin Pan , Yixun Lan CC: , , Arseniy Krasnov , , , , Subject: [PATCH v3 3/6] mtd: rawnand: meson: always read whole OOB bytes Date: Wed, 10 May 2023 14:08:31 +0300 Message-ID: <20230510110835.26115-4-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230510110835.26115-1-AVKrasnov@sberdevices.ru> References: <20230510110835.26115-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH01.sberdevices.ru (172.16.1.4) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/05/10 09:03:00 #21252424 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230510_041345_958636_39345795 X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org This changes size of read access to OOB area by reading all bytes of OOB (free bytes + ECC engine bytes). Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index d7c81408cfa2..331377a2c5dc 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -755,6 +755,30 @@ static int __meson_nfc_read_oob(struct nand_chip *nand, int page, u32 oob_bytes; u32 page_size; int ret; + int i; + + /* Read ECC codes and user bytes. */ + for (i = 0; i < nand->ecc.steps; i++) { + u32 ecc_offs = nand->ecc.size * (i + 1) + + NFC_OOB_PER_ECC(nand) * i; + + ret = nand_read_page_op(nand, page, 0, NULL, 0); + if (ret) + return ret; + + /* Use temporary buffer, because 'nand_change_read_column_op()' + * seems work with some alignment, so we can't read data to + * 'oob_buf' directly. + */ + ret = nand_change_read_column_op(nand, ecc_offs, meson_chip->oob_buf, + NFC_OOB_PER_ECC(nand), false); + if (ret) + return ret; + + memcpy(oob_buf + i * NFC_OOB_PER_ECC(nand), + meson_chip->oob_buf, + NFC_OOB_PER_ECC(nand)); + } oob_bytes = meson_nfc_get_oob_bytes(nand);