From patchwork Thu Jun 1 06:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 1788830 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=x3oH6efY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sberdevices.ru header.i=@sberdevices.ru header.a=rsa-sha256 header.s=mail header.b=qeaYzJ+v; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWx1c4q3Fz20Q4 for ; Thu, 1 Jun 2023 16:24:36 +1000 (AEST) 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=nQL3ODv91I2cGynXs7zsZk7iEE6Jzg4dBLP6AkKrOX8=; b=x3oH6efY+E8Vy6 l83g00ygF7vT4f4/1MyJyw8g/KoTNedjd/7tj8SH3idn8w5VDhUS79bDJvP5AR1DuxTL/vBL8BYw7 7oljlfVaQuFPqCYELYIwiQgwY89sfVhx4/lrX8yXAsd20uL3wjoryU3WLrf2PGYRTTxX9EgzznYpg LKfqWl09j0lnGKZSvskQX4KQnq2SzJg83BuvKKgpemc+l3LnunIjne4m8MlKtLyAkjN/Jg0Qcr3+u 9VRJjQlXhzewXcWhELLjsDkG2rFtFOyk37mCaRtCr9RtE5k/CtMqoxrnX6S108XrKnzRkxQ6/yw68 9y7fQT2PceIbT5XUx99w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj9-002AkO-1P; Thu, 01 Jun 2023 06:24:03 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj0-002Acr-1C; Thu, 01 Jun 2023 06:23:56 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 29B5A5FD6F; Thu, 1 Jun 2023 09:23:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685600628; bh=unyDr4AoLaNFBTKehsIrMcbFVhUU0qEanot3FjFAzts=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=qeaYzJ+v7OBkUlYBUCbg8q/5RryEpMEchdwjGUQ+PBD3P0kpJsGlTS9TgnDrV5+Lq kdEUuO/vWvD4lwNZQezZ46usLB0qh7ysXigcVeQfyA8NoyjxjPimC1aypjLaR4I283 JzarDXuEKWfO7vfugvxb6kgi8EhEfAr5WnU8e16Lke5HZsPY5xUVaM+3/rlG1cIf9K ga1tgusZDGKDykHH7VgBWlbUyF7h17xt3eog0Ff7ArD38oCVjeE+WoyTBGFYYNW6Ky zSRwyYg960hQidQpON8xG5iCGg/jk1U5VTm9CwuO+oqGddMK5H7BhVTepg5GHs/R6+ wdx6/XjDn6EDg== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Thu, 1 Jun 2023 09:23:48 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , Arseniy Krasnov , , , , Subject: [RFC PATCH v5 1/6] mtd: rawnand: meson: fix ready/busy command Date: Thu, 1 Jun 2023 09:18:44 +0300 Message-ID: <20230601061850.3907800-2-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230601061850.3907800-1-AVKrasnov@sberdevices.ru> References: <20230601061850.3907800-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/06/01 03:13:00 #21393813 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_232354_923743_C9D8BBCB X-CRM114-Status: GOOD ( 10.56 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This fixes ready/busy command value. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 074e14225c06..9dd4a676497b 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This fixes ready/busy command value. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 074e14225c06..9dd4a676497b 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -37,7 +37,7 @@ #define NFC_CMD_SCRAMBLER_ENABLE BIT(19) #define NFC_CMD_SCRAMBLER_DISABLE 0 #define NFC_CMD_SHORTMODE_DISABLE 0 -#define NFC_CMD_RB_INT BIT(14) +#define NFC_CMD_RB_INT ((0xb << 10) | BIT(18) | BIT(16)) #define NFC_CMD_GET_SIZE(x) (((x) >> 22) & GENMASK(4, 0)) From patchwork Thu Jun 1 06:18:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 1788831 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=tiI7caW/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sberdevices.ru header.i=@sberdevices.ru header.a=rsa-sha256 header.s=mail header.b=n6h/Jboe; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWx1d60bzz20QJ for ; Thu, 1 Jun 2023 16:24:37 +1000 (AEST) 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=vIJOArU0aYPBmH6c2352qY6WpKO8t55nLm1bdyODxeY=; b=tiI7caW/PmdOwG DMM9Mlr84y7DavwtSbrNPL2se8wn9WqOv6phu5NQtnNYTEPlfCR4dtOUJbT6rDYyBP4mZfHEAyy8z NN/LH1ltjpv7Ig4cjENT2mVvqnP4lHBItE3MscEmssKjVXDYlozzHQGXeugbYVwjuQ8MIMplLBkCq +eyxqCFvJ0M6UFu+cvvPsAukCFIXbulXcBuGKfl5U6URWyXjinMAFTE9okVWws1N0zfXK0HgWIw7P scXhLatFnzwQKnXqazUKsYDweijSkC7MvlWE9s5YpOeqXxaEZShPqSh1ccs2vT6AtSO9ahJwC8BPT APzjq/OVN2KCJrTDUvXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4bjA-002Akp-1t; Thu, 01 Jun 2023 06:24:04 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj0-002Ad3-15; Thu, 01 Jun 2023 06:23:56 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 975415FD70; Thu, 1 Jun 2023 09:23:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685600629; bh=Q8CW0l91q7Th3XcNDlwzoNWNnWO9BZjhfFIJhYfFY5Y=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=n6h/JboeFGivZeMmfptLF1Yojq836TdKOmTDWUGHvktQGtmoNpS46uAFA8lda+VXm M5k2YrIXjos5DVNRJZiVR40THbMQ3ndT5YZuxtlxcennsjGvCmFt/kF4b6SgC2fB4Y r6kS5nWRosna4QicZH2S02vxk+QkAvfFFUvdu0FmFZwXjljNfll3AmxN++GwcWFwrg scEETeunJ0nieXS+r0kHROmElgHP2GpK9AhrxcZueRl7G4mOJe0XqACJZsiu014NTA 1Tw2Np1un1jNbgaPt4G0jdERNyD63dXF4fC56ev7GG2MdMjRl5sl3m5NlWpqq92u3z ftlY+PG0ucqGA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Thu, 1 Jun 2023 09:23:49 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , Arseniy Krasnov , , , , Subject: [RFC PATCH v5 2/6] mtd: rawnand: meson: wait for command in polling mode Date: Thu, 1 Jun 2023 09:18:45 +0300 Message-ID: <20230601061850.3907800-3-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230601061850.3907800-1-AVKrasnov@sberdevices.ru> References: <20230601061850.3907800-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/06/01 03:13:00 #21393813 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_232354_921870_155C5B1D X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This adds support of waiting for command completion in sofyware polling mode. It is needed when ready/busy pin is not implemented in hardware. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 53 ++++++++++++++++++ 1 file changed, 31 insertions(+), 22 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This adds support of waiting for command completion in sofyware polling mode. It is needed when ready/busy pin is not implemented in hardware. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 53 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 9dd4a676497b..82a629025adc 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -179,6 +179,7 @@ struct meson_nfc { u32 info_bytes; unsigned long assigned_cs; + bool use_polling; }; enum { @@ -392,32 +393,38 @@ static void meson_nfc_set_data_oob(struct nand_chip *nand, } } -static int meson_nfc_queue_rb(struct meson_nfc *nfc, int timeout_ms) +static int meson_nfc_queue_rb(struct nand_chip *nand, int timeout_ms) { - u32 cmd, cfg; - int ret = 0; + struct meson_nfc *nfc = nand_get_controller_data(nand); - meson_nfc_cmd_idle(nfc, nfc->timing.twb); - meson_nfc_drain_cmd(nfc); - meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT); + if (nfc->use_polling) { + return nand_soft_waitrdy(nand, timeout_ms); + } else { + u32 cmd, cfg; + int ret = 0; - cfg = readl(nfc->reg_base + NFC_REG_CFG); - cfg |= NFC_RB_IRQ_EN; - writel(cfg, nfc->reg_base + NFC_REG_CFG); + meson_nfc_cmd_idle(nfc, nfc->timing.twb); + meson_nfc_drain_cmd(nfc); + meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT); - reinit_completion(&nfc->completion); + cfg = readl(nfc->reg_base + NFC_REG_CFG); + cfg |= NFC_RB_IRQ_EN; + writel(cfg, nfc->reg_base + NFC_REG_CFG); - /* use the max erase time as the maximum clock for waiting R/B */ - cmd = NFC_CMD_RB | NFC_CMD_RB_INT - | nfc->param.chip_select | nfc->timing.tbers_max; - writel(cmd, nfc->reg_base + NFC_REG_CMD); + reinit_completion(&nfc->completion); - ret = wait_for_completion_timeout(&nfc->completion, - msecs_to_jiffies(timeout_ms)); - if (ret == 0) - ret = -1; + /* use the max erase time as the maximum clock for waiting R/B */ + cmd = NFC_CMD_RB | NFC_CMD_RB_INT + | nfc->param.chip_select | nfc->timing.tbers_max; + writel(cmd, nfc->reg_base + NFC_REG_CMD); - return ret; + ret = wait_for_completion_timeout(&nfc->completion, + msecs_to_jiffies(timeout_ms)); + if (ret == 0) + return -ETIMEDOUT; + + return 0; + } } static void meson_nfc_set_user_byte(struct nand_chip *nand, u8 *oob_buf) @@ -623,7 +630,7 @@ static int meson_nfc_rw_cmd_prepare_and_execute(struct nand_chip *nand, if (in) { nfc->cmdfifo.rw.cmd1 = cs | NFC_CMD_CLE | NAND_CMD_READSTART; writel(nfc->cmdfifo.rw.cmd1, nfc->reg_base + NFC_REG_CMD); - meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tR_max)); + meson_nfc_queue_rb(nand, PSEC_TO_MSEC(sdr->tR_max)); } else { meson_nfc_cmd_idle(nfc, nfc->timing.tadl); } @@ -669,7 +676,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand, cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG; writel(cmd, nfc->reg_base + NFC_REG_CMD); - meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tPROG_max)); + meson_nfc_queue_rb(nand, PSEC_TO_MSEC(sdr->tPROG_max)); meson_nfc_dma_buffer_release(nand, data_len, info_len, DMA_TO_DEVICE); @@ -952,7 +959,7 @@ static int meson_nfc_exec_op(struct nand_chip *nand, break; case NAND_OP_WAITRDY_INSTR: - meson_nfc_queue_rb(nfc, instr->ctx.waitrdy.timeout_ms); + meson_nfc_queue_rb(nand, instr->ctx.waitrdy.timeout_ms); if (instr->delay_ns) meson_nfc_cmd_idle(nfc, delay_idle); break; @@ -1412,6 +1419,8 @@ static int meson_nfc_probe(struct platform_device *pdev) return ret; } + nfc->use_polling = of_property_read_bool(dev->of_node, "polling"); + writel(0, nfc->reg_base + NFC_REG_CFG); ret = devm_request_irq(dev, irq, meson_nfc_irq, 0, dev_name(dev), nfc); if (ret) { From patchwork Thu Jun 1 06:18:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 1788832 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=E7DAn8BK; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sberdevices.ru header.i=@sberdevices.ru header.a=rsa-sha256 header.s=mail header.b=UBazfj3D; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWx1h1h0hz20Q4 for ; Thu, 1 Jun 2023 16:24:40 +1000 (AEST) 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=5EaEjscpJlsEqGI9iE4orF1uOxOTsSJR2kGgAPV75pM=; b=E7DAn8BKmncrss ITCgDx74Ecy0HSVnkOhcNb4DipPe/MlFOYxuulwGinfiNPFZCnc8bQ7+PX76TlBNZt38YCpFO7mN3 /yYoeYzhWqN99War4OCWxVnlBYzgEXoEIT6jlStzi5hnba0qi6Xk43HfKzTnbabZT/0MUUs29Ic/4 O/6qKAr7iXXF6eWVziLr45gxmqBLDssoqH4iSvRNNX5SdPlAmDonb7qu/fHcekHjrTYHKJuhpn2K2 nuDqP0S5Gb0HSO51hwqAtFenxZy4TOyFQoOeGEvaDWmhMScQM4kx59wp46pan/4MU8YhCQcFEWAcM TySDOMt1gplaAvFFq86w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4bjG-002Aq7-0A; Thu, 01 Jun 2023 06:24:10 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj0-002Ad8-0w; Thu, 01 Jun 2023 06:23:57 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 0C4EF5FD71; Thu, 1 Jun 2023 09:23:51 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685600631; bh=7eTR50v34sY25ZJ8i04tdkgYJSBwBxdc7ZcDECCVA3w=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=UBazfj3D0Atm0e+kKGESZT2K03zy4ZSpZ+7qozsJSSVFNE8wXzWRaNHHx81vYj1d7 M3ZV9Z/AEz5z78IWv30tiw8bZAMO2H5uMwAwX3P39FvDNUM9irMcvruP2S9zUuyyH8 jwkOF+Si2vdAPE174nByviokBXNvY2uAK3bcZy9ad7JoaugLEUb8zdYYK1PEgkoHUa D1hmrj/Jhvn1d9L0ADZ25Vw/OmAHudxDeN/dnN17qaVc13y16WiADrRumH5a9yuCLp fYa/5NDEd8CNqOhU5t2ZcPNNoMt490JgF9rD4f8iCNrsLBvGl5rTzqLVHudjtoPZGH 5KLCOtaybk8Kg== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Thu, 1 Jun 2023 09:23:51 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , Arseniy Krasnov , , , , Subject: [RFC PATCH v5 3/6] mtd: rawnand: meson: only expose unprotected user OOB bytes Date: Thu, 1 Jun 2023 09:18:46 +0300 Message-ID: <20230601061850.3907800-4-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230601061850.3907800-1-AVKrasnov@sberdevices.ru> References: <20230601061850.3907800-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/06/01 03:13:00 #21393813 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_232354_925145_BB140D4A X-CRM114-Status: GOOD ( 25.87 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This moves free bytes of OOB to non-protected ECC area. It is needed to make JFFS2 works correctly with this NAND controller. Problem fires when JFFS2 driver writes cleanmarker to some page and later [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This moves free bytes of OOB to non-protected ECC area. It is needed to make JFFS2 works correctly with this NAND controller. Problem fires when JFFS2 driver writes cleanmarker to some page and later it tries to write to this page - write will be done successfully, but after that such page becomes unreadable due to invalid ECC codes. This happens because second write needs to update ECC codes, but it is impossible to do it correctly without block erase. So idea of this patch is to use the unprotected OOB area to store the cleanmarkers, so that they can be written by the filesystem without caring much about the page being empty or not: the ECC codes will not be written anyway. JFFS2 is only useful on tiny NAND devices, where UBI does not fit, which are usually true SLC flashes, with the capability of writing a page with empty (0xFF) data, and still be able to write actual data to it later in a second write. Signed-off-by: Arseniy Krasnov --- Changelog v4->v5: * Drop cosmetic changes from this patch. * Do not ignore ECC protected user bytes provided by hw. Even these bytes are out of user area of OOB, its values are still read from the provided OOB buffer and written by hardware. Same behaviour is preserved for read access - such bytes are read from DMA buffer and placed to OOB buffer. * OOB read and write become more lightweight because I removed heavy READ0 and PAGEPROG command from it (both commands are still sent when OOB access is performed using OOB callbacks). In case of page read/write OOB data is handled in the internal SRAM of the controller. * Commit message updated. * Temporary buffer for OOB read/write is removed. Seems everything works correctly without it. drivers/mtd/nand/raw/meson_nand.c | 134 ++++++++++++++++++++++++++---- 1 file changed, 117 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 82a629025adc..e42c28be02f3 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -358,8 +358,11 @@ static u8 *meson_nfc_data_ptr(struct nand_chip *nand, int i) static void meson_nfc_get_data_oob(struct nand_chip *nand, u8 *buf, u8 *oobbuf) { + struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); + struct mtd_info *mtd = nand_to_mtd(nand); int i, oob_len = 0; u8 *dsrc, *osrc; + u8 *oobtail; oob_len = nand->ecc.bytes + 2; for (i = 0; i < nand->ecc.steps; i++) { @@ -368,17 +371,27 @@ static void meson_nfc_get_data_oob(struct nand_chip *nand, memcpy(buf, dsrc, nand->ecc.size); buf += nand->ecc.size; } + osrc = meson_nfc_oob_ptr(nand, i); memcpy(oobbuf, osrc, oob_len); oobbuf += oob_len; } + + oobtail = meson_chip->data_buf + nand->ecc.steps * + (nand->ecc.size + oob_len); + + /* 'oobbuf' points to the start of user area. */ + memcpy(oobbuf, oobtail, mtd->oobsize - nand->ecc.steps * oob_len); } static void meson_nfc_set_data_oob(struct nand_chip *nand, const u8 *buf, u8 *oobbuf) { + struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); + struct mtd_info *mtd = nand_to_mtd(nand); int i, oob_len = 0; u8 *dsrc, *osrc; + u8 *oobtail; oob_len = nand->ecc.bytes + 2; for (i = 0; i < nand->ecc.steps; i++) { @@ -391,6 +404,12 @@ static void meson_nfc_set_data_oob(struct nand_chip *nand, memcpy(osrc, oobbuf, oob_len); oobbuf += oob_len; } + + oobtail = meson_chip->data_buf + nand->ecc.steps * + (nand->ecc.size + oob_len); + + /* 'oobbuf' points to the start of user area. */ + memcpy(oobtail, oobbuf, mtd->oobsize - nand->ecc.steps * oob_len); } static int meson_nfc_queue_rb(struct nand_chip *nand, int timeout_ms) @@ -433,7 +452,7 @@ static void meson_nfc_set_user_byte(struct nand_chip *nand, u8 *oob_buf) __le64 *info; int i, count; - for (i = 0, count = 0; i < nand->ecc.steps; i++, count += 2) { + for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (nand->ecc.bytes + 2)) { info = &meson_chip->info_buf[i]; *info |= oob_buf[count]; *info |= oob_buf[count + 1] << 8; @@ -446,7 +465,7 @@ static void meson_nfc_get_user_byte(struct nand_chip *nand, u8 *oob_buf) __le64 *info; int i, count; - for (i = 0, count = 0; i < nand->ecc.steps; i++, count += 2) { + for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (nand->ecc.bytes + 2)) { info = &meson_chip->info_buf[i]; oob_buf[count] = *info; oob_buf[count + 1] = *info >> 8; @@ -638,6 +657,84 @@ static int meson_nfc_rw_cmd_prepare_and_execute(struct nand_chip *nand, return 0; } +static u32 meson_nfc_oob_free_bytes(struct nand_chip *nand) +{ + struct mtd_info *mtd = nand_to_mtd(nand); + + return mtd->oobsize - nand->ecc.steps * (nand->ecc.bytes + 2); +} + +static int meson_nfc_write_oob(struct nand_chip *nand, int page) +{ + struct mtd_info *mtd = nand_to_mtd(nand); + u32 page_size = mtd->writesize + mtd->oobsize; + u32 oob_bytes = meson_nfc_oob_free_bytes(nand); + u8 *oob_buf; + int ret; + + if (!oob_bytes) + return 0; + + /* Called as OOB write helper, will send NAND_CMD_PAGEPROG. */ + if (page != -1) { + ret = nand_prog_page_begin_op(nand, page, 0, NULL, 0); + if (ret) + return ret; + } + + oob_buf = nand->oob_poi; + + ret = nand_change_write_column_op(nand, page_size - oob_bytes, + oob_buf + (mtd->oobsize - oob_bytes), + oob_bytes, false); + if (ret) + return ret; + + return (page != -1) ? nand_prog_page_end_op(nand) : 0; +} + +static int meson_nfc_read_oob(struct nand_chip *nand, int page) +{ + struct mtd_info *mtd = nand_to_mtd(nand); + u8 *oob_buf = nand->oob_poi; + u32 oob_bytes; + u32 page_size; + int ret; + int i; + + /* Called as OOB read helper, send NAND_CMD_READ0. */ + if (page != -1) { + ret = nand_read_page_op(nand, page, 0, NULL, 0); + if (ret) + return ret; + } + + /* Read ECC codes and user bytes. */ + for (i = 0; i < nand->ecc.steps; i++) { + u32 ecc_offs = nand->ecc.size * (i + 1) + + (nand->ecc.bytes + 2) * i; + + ret = nand_change_read_column_op(nand, ecc_offs, + oob_buf + i * (nand->ecc.bytes + 2), + (nand->ecc.bytes + 2), false); + if (ret) + return ret; + } + + oob_bytes = meson_nfc_oob_free_bytes(nand); + + if (!oob_bytes) + return 0; + + page_size = mtd->writesize + mtd->oobsize; + + ret = nand_change_read_column_op(nand, page_size - oob_bytes, + oob_buf + (mtd->oobsize - oob_bytes), + oob_bytes, false); + + return ret; +} + static int meson_nfc_write_page_sub(struct nand_chip *nand, int page, int raw) { @@ -674,6 +771,12 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand, NFC_CMD_SCRAMBLER_DISABLE); } + if (!raw) { + ret = meson_nfc_write_oob(nand, -1); + if (ret) + return ret; + } + cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG; writel(cmd, nfc->reg_base + NFC_REG_CMD); meson_nfc_queue_rb(nand, PSEC_TO_MSEC(sdr->tPROG_max)); @@ -834,17 +937,10 @@ static int meson_nfc_read_page_hwecc(struct nand_chip *nand, u8 *buf, memcpy(buf, meson_chip->data_buf, mtd->writesize); } - return bitflips; -} - -static int meson_nfc_read_oob_raw(struct nand_chip *nand, int page) -{ - return meson_nfc_read_page_raw(nand, NULL, 1, page); -} + if (oob_required && ret) + meson_nfc_read_oob(nand, -1); -static int meson_nfc_read_oob(struct nand_chip *nand, int page) -{ - return meson_nfc_read_page_hwecc(nand, NULL, 1, page); + return bitflips; } static bool meson_nfc_is_buffer_dma_safe(const void *buffer) @@ -987,12 +1083,16 @@ static int meson_ooblayout_free(struct mtd_info *mtd, int section, struct mtd_oob_region *oobregion) { struct nand_chip *nand = mtd_to_nand(mtd); + u32 oob_bytes = meson_nfc_oob_free_bytes(nand); if (section >= nand->ecc.steps) return -ERANGE; - oobregion->offset = section * (2 + nand->ecc.bytes); - oobregion->length = 2; + /* Split rest of OOB area (not covered by ECC engine) per each + * ECC section. This will be OOB data available to user. + */ + oobregion->offset = (section + nand->ecc.steps) * (2 + nand->ecc.bytes); + oobregion->length = oob_bytes / nand->ecc.steps; return 0; } @@ -1220,12 +1320,12 @@ static int meson_nand_attach_chip(struct nand_chip *nand) nand->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST; nand->ecc.write_page_raw = meson_nfc_write_page_raw; nand->ecc.write_page = meson_nfc_write_page_hwecc; - nand->ecc.write_oob_raw = nand_write_oob_std; - nand->ecc.write_oob = nand_write_oob_std; + nand->ecc.write_oob_raw = meson_nfc_write_oob; + nand->ecc.write_oob = meson_nfc_write_oob; nand->ecc.read_page_raw = meson_nfc_read_page_raw; nand->ecc.read_page = meson_nfc_read_page_hwecc; - nand->ecc.read_oob_raw = meson_nfc_read_oob_raw; + nand->ecc.read_oob_raw = meson_nfc_read_oob; nand->ecc.read_oob = meson_nfc_read_oob; if (nand->options & NAND_BUSWIDTH_16) { From patchwork Thu Jun 1 06:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 1788833 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=V84A/O3I; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sberdevices.ru header.i=@sberdevices.ru header.a=rsa-sha256 header.s=mail header.b=DYOOKSL3; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWx1l17Qnz20Q4 for ; Thu, 1 Jun 2023 16:24:43 +1000 (AEST) 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=pidwKr85LBQROh2hOBVIjOWRjO0lLJ7jS0s2AP0Ijjk=; b=V84A/O3IALAwjL /+VyWzzavEeKvk/9/INF8xDUyPnVZuFbgOJnBCNsGJDA8UiUjJZUnfgihGF5dnKQbKcgQBAHo87j5 eoHwyEK7QURRwrQGPKmzO6OT1xjazily1xkpXWJF1Fk+HLeBuqQ+qIseI5OArZuoeGpefD7AgkHqX 5nghF8ZEvbU3VNfV53WV16A5mRHuR2CMmhAq47cTv8iYgOj1I45opyvleXZ3ddt6UGZFlbCqsx3yf qV3Dn1C5jCuXHcfgR6PQ8MEIJnn0Y1jtfnKGHyUVQuRQ+bfpW5e2Pzejf/uq6+C19Sp6rFTDZYfzL CTVx6rNsz+lpnILTKQFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4bjG-002Ar3-2s; Thu, 01 Jun 2023 06:24:11 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj1-002AdX-1u; Thu, 01 Jun 2023 06:23:57 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 72BA35FD72; Thu, 1 Jun 2023 09:23:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685600632; bh=RbeJZbPNkWc/tUGhF37aQ2jFIYQedtb7n/HATu1dFBI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=DYOOKSL3iwT1sDNakbtCoAF7EQ6viEyK0vOSWBs24C1yd8pQB9P3Iz391+Q2IEKxN VJGLniY6KfbnWQ46A2ViYa/Um94b/4ddtcohTyZ8KZFOhpxN+QOBBbuS/pBrKQw9MC FQB12l1ajCc0sU5s/bVnWJUF+79pGJPdBfIVu+7UySj3P+Yg5a2xkXhJk8rGw734ZZ TYz949gVlDlMslkrZmuFTC9SXemy0LHlMkZPrfYBLEhrosWA1zDTqLo5lsTQ0RWSPZ QIALMPHovO9KbQxstX7ZaDeNlmpOa8hKCt/ooAXJCFHpt6zTA+zJdi+hyOkhzw0lT3 s79+fo2afv+3w== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Thu, 1 Jun 2023 09:23:52 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , Arseniy Krasnov , , , , Subject: [RFC PATCH v5 4/6] mtd: rawnand: meson: use macro for OOB area Date: Thu, 1 Jun 2023 09:18:47 +0300 Message-ID: <20230601061850.3907800-5-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230601061850.3907800-1-AVKrasnov@sberdevices.ru> References: <20230601061850.3907800-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/06/01 03:13:00 #21393813 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_232355_984579_C7B748E5 X-CRM114-Status: GOOD ( 17.11 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This replaces constants and same patterns for OOB handling with special macroses. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 33 ++++++++++++++++++ 1 file changed, 19 insertions(+), 14 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This replaces constants and same patterns for OOB handling with special macroses. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 33 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index e42c28be02f3..23a73268421b 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -108,6 +108,9 @@ #define PER_INFO_BYTE 8 +#define NFC_USER_BYTES 2 +#define NFC_OOB_PER_ECC(nand) ((nand)->ecc.bytes + NFC_USER_BYTES) + struct meson_nfc_nand_chip { struct list_head node; struct nand_chip nand; @@ -339,7 +342,7 @@ static u8 *meson_nfc_oob_ptr(struct nand_chip *nand, int i) struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); int len; - len = nand->ecc.size * (i + 1) + (nand->ecc.bytes + 2) * i; + len = nand->ecc.size * (i + 1) + NFC_OOB_PER_ECC(nand) * i; return meson_chip->data_buf + len; } @@ -350,7 +353,7 @@ static u8 *meson_nfc_data_ptr(struct nand_chip *nand, int i) int len, temp; temp = nand->ecc.size + nand->ecc.bytes; - len = (temp + 2) * i; + len = (temp + NFC_USER_BYTES) * i; return meson_chip->data_buf + len; } @@ -364,7 +367,7 @@ static void meson_nfc_get_data_oob(struct nand_chip *nand, u8 *dsrc, *osrc; u8 *oobtail; - oob_len = nand->ecc.bytes + 2; + oob_len = NFC_OOB_PER_ECC(nand); for (i = 0; i < nand->ecc.steps; i++) { if (buf) { dsrc = meson_nfc_data_ptr(nand, i); @@ -393,7 +396,7 @@ static void meson_nfc_set_data_oob(struct nand_chip *nand, u8 *dsrc, *osrc; u8 *oobtail; - oob_len = nand->ecc.bytes + 2; + oob_len = NFC_OOB_PER_ECC(nand); for (i = 0; i < nand->ecc.steps; i++) { if (buf) { dsrc = meson_nfc_data_ptr(nand, i); @@ -452,7 +455,7 @@ static void meson_nfc_set_user_byte(struct nand_chip *nand, u8 *oob_buf) __le64 *info; int i, count; - for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (nand->ecc.bytes + 2)) { + for (i = 0, count = 0; i < nand->ecc.steps; i++, count += NFC_OOB_PER_ECC(nand)) { info = &meson_chip->info_buf[i]; *info |= oob_buf[count]; *info |= oob_buf[count + 1] << 8; @@ -465,7 +468,7 @@ static void meson_nfc_get_user_byte(struct nand_chip *nand, u8 *oob_buf) __le64 *info; int i, count; - for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (nand->ecc.bytes + 2)) { + for (i = 0, count = 0; i < nand->ecc.steps; i++, count += NFC_OOB_PER_ECC(nand)) { info = &meson_chip->info_buf[i]; oob_buf[count] = *info; oob_buf[count + 1] = *info >> 8; @@ -661,7 +664,7 @@ static u32 meson_nfc_oob_free_bytes(struct nand_chip *nand) { struct mtd_info *mtd = nand_to_mtd(nand); - return mtd->oobsize - nand->ecc.steps * (nand->ecc.bytes + 2); + return mtd->oobsize - nand->ecc.steps * NFC_OOB_PER_ECC(nand); } static int meson_nfc_write_oob(struct nand_chip *nand, int page) @@ -712,11 +715,11 @@ static int meson_nfc_read_oob(struct nand_chip *nand, int page) /* Read ECC codes and user bytes. */ for (i = 0; i < nand->ecc.steps; i++) { u32 ecc_offs = nand->ecc.size * (i + 1) + - (nand->ecc.bytes + 2) * i; + NFC_OOB_PER_ECC(nand) * i; ret = nand_change_read_column_op(nand, ecc_offs, - oob_buf + i * (nand->ecc.bytes + 2), - (nand->ecc.bytes + 2), false); + oob_buf + i * NFC_OOB_PER_ECC(nand), + NFC_OOB_PER_ECC(nand), false); if (ret) return ret; } @@ -918,12 +921,14 @@ static int meson_nfc_read_page_hwecc(struct nand_chip *nand, u8 *buf, for (i = 0; i < nand->ecc.steps ; i++) { u8 *data = buf + i * ecc->size; - u8 *oob = nand->oob_poi + i * (ecc->bytes + 2); + u8 *oob = nand->oob_poi + i * NFC_OOB_PER_ECC(nand); if (correct_bitmap & BIT_ULL(i)) continue; + ret = nand_check_erased_ecc_chunk(data, ecc->size, - oob, ecc->bytes + 2, + oob, + NFC_OOB_PER_ECC(nand), NULL, 0, ecc->strength); if (ret < 0) { @@ -1073,7 +1078,7 @@ static int meson_ooblayout_ecc(struct mtd_info *mtd, int section, if (section >= nand->ecc.steps) return -ERANGE; - oobregion->offset = 2 + (section * (2 + nand->ecc.bytes)); + oobregion->offset = NFC_USER_BYTES + (section * NFC_OOB_PER_ECC(nand)); oobregion->length = nand->ecc.bytes; return 0; @@ -1091,7 +1096,7 @@ static int meson_ooblayout_free(struct mtd_info *mtd, int section, /* Split rest of OOB area (not covered by ECC engine) per each * ECC section. This will be OOB data available to user. */ - oobregion->offset = (section + nand->ecc.steps) * (2 + nand->ecc.bytes); + oobregion->offset = (section + nand->ecc.steps) * NFC_OOB_PER_ECC(nand); oobregion->length = oob_bytes / nand->ecc.steps; return 0; From patchwork Thu Jun 1 06:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 1788836 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Z88GNrOm; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sberdevices.ru header.i=@sberdevices.ru header.a=rsa-sha256 header.s=mail header.b=fApJxuo1; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWx2C6ZbGz20QB for ; Thu, 1 Jun 2023 16:25:07 +1000 (AEST) 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=G0U74t37ZtxHO+u+Fuo7o0Dv+j2EccyNVtdClJJMffI=; b=Z88GNrOmNMGUGT jEBChS7EaSNKWj4+4/Oz41uJmOKpnWzEgYrko0sHC8KRTY+B2r2gtt387cDZ7YW46V/yeNEm2lPS+ 5xIqpsJ5F1pbb+/oJfcFz8oicfuBhQlN5pcPmUro9Yl24TGBEFyw72Werhd9aW/i5vNrTS/5cy0LL H41qbDLPMdslBRG35axhRbOF2878XdyfGj4rA6X9iZO1Bj2O2O0l6YTUQesBSC6SwK0oMpv0rndFa WX2bgoY5RX9pNXhIkz5oZPAet19aZlswv0ih/qDDBD1sxaQDFW/l7JW27pbzKajbDOpnlg9fUs/Vo Fp7wOfnZG5qydFXDHePQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4bjW-002B8J-2x; Thu, 01 Jun 2023 06:24:26 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj4-002Afu-0h; Thu, 01 Jun 2023 06:24:00 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id B6D9A5FD73; Thu, 1 Jun 2023 09:23:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685600633; bh=kSvrNV01pYKxwurCvddI8AqxMVYMKQLY/eHlqyiGjSc=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=fApJxuo1I+DhpC4BGUSekoYjDmIMVAAy0hnnT/WsPI5i7lcRfV1pmAe0GaaiLcxef EU83Ar7jcpkqXBZ3bqxtWN2Hu8rGnGnlj3tzkZDkaEIZ7TLEM81GRm5Qa1F2GUJ2gI ifkpXX4PmPrMdxpganpJ2dDbnkAmym/c46VakgtVUDSsdIJzoPFsfWyTbejOCagyF4 Mkwi5sl9l4ER2dEvFT2Wy6JJpCiY9N/hKnE2+UjdpJu7UpCEAqPr1bOGVVKhU+a3Rx vIWiS54iPrTSj/pI5uQDPP8A/rpVRhH0LruM93gFH8nJO+qC5vbXgIXkrSmA94Epih RfGtZOkZZhlqQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Thu, 1 Jun 2023 09:23:53 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , Arseniy Krasnov , , , , Subject: [RFC PATCH v5 5/6] mtd: rawnand: meson: check buffer length Date: Thu, 1 Jun 2023 09:18:48 +0300 Message-ID: <20230601061850.3907800-6-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230601061850.3907800-1-AVKrasnov@sberdevices.ru> References: <20230601061850.3907800-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/06/01 03:13:00 #21393813 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_232358_634954_E700D071 X-CRM114-Status: GOOD ( 13.78 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This NAND controller has limited buffer length, so check it before command execution to avoid length trim. Also check MTD write size on chip attach. Signed-off-by: Arseniy Krasnov --- Changelog v4->v5: * Move length checks from functions 'meson_nfc_read/write_buf()' to 'meson_nfc_exec_op()'. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This NAND controller has limited buffer length, so check it before command execution to avoid length trim. Also check MTD write size on chip attach. Signed-off-by: Arseniy Krasnov --- Changelog v4->v5: * Move length checks from functions 'meson_nfc_read/write_buf()' to 'meson_nfc_exec_op()'. drivers/mtd/nand/raw/meson_nand.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 23a73268421b..2a91916566f4 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -111,6 +111,8 @@ #define NFC_USER_BYTES 2 #define NFC_OOB_PER_ECC(nand) ((nand)->ecc.bytes + NFC_USER_BYTES) +#define NFC_CMD_RAW_LEN GENMASK(13, 0) + struct meson_nfc_nand_chip { struct list_head node; struct nand_chip nand; @@ -284,7 +286,7 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, int raw, bool dir, if (raw) { len = mtd->writesize + mtd->oobsize; - cmd = (len & GENMASK(13, 0)) | scrambler | DMA_DIR(dir); + cmd = len | scrambler | DMA_DIR(dir); writel(cmd, nfc->reg_base + NFC_REG_CMD); return; } @@ -573,7 +575,7 @@ static int meson_nfc_read_buf(struct nand_chip *nand, u8 *buf, int len) if (ret) goto out; - cmd = NFC_CMD_N2M | (len & GENMASK(13, 0)); + cmd = NFC_CMD_N2M | len; writel(cmd, nfc->reg_base + NFC_REG_CMD); meson_nfc_drain_cmd(nfc); @@ -597,7 +599,7 @@ static int meson_nfc_write_buf(struct nand_chip *nand, u8 *buf, int len) if (ret) return ret; - cmd = NFC_CMD_M2N | (len & GENMASK(13, 0)); + cmd = NFC_CMD_M2N | len; writel(cmd, nfc->reg_base + NFC_REG_CMD); meson_nfc_drain_cmd(nfc); @@ -1044,6 +1046,9 @@ static int meson_nfc_exec_op(struct nand_chip *nand, break; case NAND_OP_DATA_IN_INSTR: + if (instr->ctx.data.len > NFC_CMD_RAW_LEN) + return -EINVAL; + buf = meson_nand_op_get_dma_safe_input_buf(instr); if (!buf) return -ENOMEM; @@ -1052,6 +1057,9 @@ static int meson_nfc_exec_op(struct nand_chip *nand, break; case NAND_OP_DATA_OUT_INSTR: + if (instr->ctx.data.len > NFC_CMD_RAW_LEN) + return -EINVAL; + buf = meson_nand_op_get_dma_safe_output_buf(instr); if (!buf) return -ENOMEM; @@ -1293,6 +1301,7 @@ static int meson_nand_attach_chip(struct nand_chip *nand) struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand); struct mtd_info *mtd = nand_to_mtd(nand); int nsectors = mtd->writesize / 1024; + int raw_writesize; int ret; if (!mtd->name) { @@ -1304,6 +1313,13 @@ static int meson_nand_attach_chip(struct nand_chip *nand) return -ENOMEM; } + raw_writesize = mtd->writesize + mtd->oobsize; + if (raw_writesize > NFC_CMD_RAW_LEN) { + dev_err(nfc->dev, "too big write size in raw mode: %d > %ld\n", + raw_writesize, NFC_CMD_RAW_LEN); + return -EINVAL; + } + if (nand->bbt_options & NAND_BBT_USE_FLASH) nand->bbt_options |= NAND_BBT_NO_OOB; From patchwork Thu Jun 1 06:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 1788835 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=4isub6Ev; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sberdevices.ru header.i=@sberdevices.ru header.a=rsa-sha256 header.s=mail header.b=j9W+l5s+; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWx1w39yyz20Q4 for ; Thu, 1 Jun 2023 16:24:52 +1000 (AEST) 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=FjqeU9Wcl5fkZxnVgvxrIuYvoH6mQevxZwmF1V6DTP8=; b=4isub6EvCqmlzj Ea5HPgg4uIl87gyoSt8v36pnM7zAJXh/ep96IJwfHnIHN8DpsJULCfQEBRSzQ9lU/kxJnIGxGHW+O u1dry+IN9MZ6rAmlrRdMajT8SLG3XX7C3Wr8PUh6oR4LqQhnZH0a165l7CFmanev4de/rZUEumja7 Z0rToY3UxA9R7wtKD6T15lyS+qo7zkVcLMnV1u6f7aPLJPjpYltCybAwz77QoS16HZb/4lKYNP7Fd gwallghYSu5/W9GKz7t+gzvXTr2owpVVjHBik+2RNLGa0cwqFcs6CbETtUXHm1pnIII2iBRlg5s0P 1ctR2zyMeeKurdC4rwvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4bjT-002B61-2p; Thu, 01 Jun 2023 06:24:23 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4bj4-002Aft-0f; Thu, 01 Jun 2023 06:23:59 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id D00845FD74; Thu, 1 Jun 2023 09:23:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685600634; bh=6FX/oDhV3UArFeFozJZTELPsj5XEanV7an9T0MKnXa0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=j9W+l5s+BZrwcotRo28gMX6RXqEkq5D9k/kIRuYPog9sgetx5bJ+AWNQHDKK5Ui55 OhxgVoHTIWtqz47Q4J0Vr0cMIt7g4YpeR2qxj0duCA4A0m/+aVukmeRD75nRmzphzL VztAbMb4blmdU1arX3QrHNrYYxKNGu57vCBjw5oGfqWMTDKGLxpN8xfkusf9X3be9s a8RMCLuZIMpD48OlnCSKxCHiNM9Ls89j+GsFSyZFtsHkCgkyezcp48gIerMtI1nEY4 r13++/1CepWAi+isP5fV6T15I43mhIEylc9mOSbrogWFYYHp2wc3rF47DN2QQUd4CZ MLycIbZ9iCoww== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Thu, 1 Jun 2023 09:23:54 +0300 (MSK) From: Arseniy Krasnov To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl CC: , , Arseniy Krasnov , , , , Subject: [RFC PATCH v5 6/6] mtd: rawnand: meson: remove unneeded bitwise OR with zeroes Date: Thu, 1 Jun 2023 09:18:49 +0300 Message-ID: <20230601061850.3907800-7-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230601061850.3907800-1-AVKrasnov@sberdevices.ru> References: <20230601061850.3907800-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/06/01 03:13:00 #21393813 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_232358_451305_4F7FA79D X-CRM114-Status: GOOD ( 11.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Both operations have no effect. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 2a91916566f4..e78912bd3b4d 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Both operations have no effect. Signed-off-by: Arseniy Krasnov --- drivers/mtd/nand/raw/meson_nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index 2a91916566f4..e78912bd3b4d 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -626,12 +626,12 @@ static int meson_nfc_rw_cmd_prepare_and_execute(struct nand_chip *nand, cmd0 = in ? NAND_CMD_READ0 : NAND_CMD_SEQIN; nfc->cmdfifo.rw.cmd0 = cs | NFC_CMD_CLE | cmd0; - addrs[0] = cs | NFC_CMD_ALE | 0; + addrs[0] = cs | NFC_CMD_ALE; if (mtd->writesize <= 512) { cmd_num--; row_start = 1; } else { - addrs[1] = cs | NFC_CMD_ALE | 0; + addrs[1] = cs | NFC_CMD_ALE; row_start = 2; }