From patchwork Tue Dec 3 02:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 2017512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=2MUYTYO5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=KwlMB/nq; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y2Q863Ljgz1yQN for ; Tue, 3 Dec 2024 13:48:38 +1100 (AEDT) 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=d8wlQERhuVtWPyXI+63BCgoh2GK9JMUIIUbK789ZO8o=; b=2MUYTYO5UXU2wU tC5jrg0PZq9zxXA/Jj4EGVFbjchypDujiYadakvUIbKLJGrorm7RPAGlyoKwrqxv3tKOtxTBu7nTW bIaK77c7q+oZs7BGk58IZcCS6KePAZmcd1RpMcuB22KSTsBXxf2qC+uD1z6rpkCRjGfq2iuYDaR1l 4cEWy3pW4lBaNt4d9uTzRvX/bQx+/Ws24ACxpJ9CXlb3D6nAZjBrKJQn2+n9RJgwr2mIO19uo7yTG zi/ETAAWSUlireEToTuyrgiwRQT91Btr9r2pDeXRVm+sApctY591aK4vZk8QGvPCfj0iUcnPSLhGU hKZiKQwJ4wHFHU3sQBZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tIIxg-000000083lV-3QLG; Tue, 03 Dec 2024 02:48:28 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tIIwO-000000083Ui-3Er4 for linux-mtd@lists.infradead.org; Tue, 03 Dec 2024 02:47:09 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-7fbc29b3145so4289756a12.0 for ; Mon, 02 Dec 2024 18:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733194028; x=1733798828; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X/fMjCuPubYsH0DXCXMNg++mVJWPpXEZP60/VYOzJ3A=; b=KwlMB/nqfjgC/zOdemfkyCPQp4AiiO73d7vHHy/pCzHbSNK1qsLVPkIKIbwoWLZKLQ qSN7SrkanO0HK/VZG6Ks60EoF7awCjGlWDUwpAXSVYwKN7XgF2Yg4RvJY6kLPTxhMH+r zob0S/ISb7XMhcyLSSoQZrHf6NXCOKpcWUBRstU76bVwEowuJLhuka45vcLDyHDl2pAX 44rw1IhrlFKZOQ0AisG6qsvCXqAUvLpwIc63FOaZOXk0v1sMkS23HoI1rCEc76ksExwt 8/ng+wYS2ego32c73TvHx9vwzws3KS1B60BxrJt5LGjfFBf3sff//u8STwHa/jTRHQws j71w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733194028; x=1733798828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X/fMjCuPubYsH0DXCXMNg++mVJWPpXEZP60/VYOzJ3A=; b=eO2t4vDcK8DHGFKkhAVFPmr3QsTlVAO39Efkvm+kySGHLcb30XE2GpQnR+zNLSzppm O5z8WUz8+oio9qmhQmJGyP6jCnlTSW6QEBO5i5SgMsDs6ChtOv+x+ABXjeEiAYxMQStw j65gulw2C0Hw9o7UQMWouF3Czgpw53GpUWmIFeOB/pPCfV4bKuav8oa7bSr1wb2BJLoe k+PxR3lF1OgvIXUeBKJRuVL7oOBUGlQatqhP0PS9wqBbg/SEl+W9NbV2xvPVGT95GG5s 5wayVm32bWwyIJfUKKza9LBTNSwbHemqFaK3tcRc+524hllDbFxdqGLblzBKtZ0M1k3w pIsQ== X-Gm-Message-State: AOJu0YyqRMt1tNTu2Cw96RApksYY79WCQ+vFcSBhVueZuSNYJII4SaIo dFq/5Mlz74niYU6uyMCvs8AMHE5P5EhnimgDrCKWqqo4yO8wnEBsVM6VHQ== X-Gm-Gg: ASbGncsu6hZvr5zvN6omCBzCzP1yPEm/PId1Gz9+3p258o/n55pKxKasEV4OgU3FJ3z bvPkiC2WKaznkkmf9WG4IfQTH9ONi2zeJ/huMqONLWN2EWJMpX1xhuoOruBLpEoLOC21jvYHsOK ywac6Guf8B9yalp8bTbwe9tHJMfRYj+Tg+2lZiUG1l21fs9a1j1cYHF236fBpi30uQkl1Hp+8mr PIANvja84/BppnC2lq9DyjTU5gjSZvtMgHl0UrZSoFlh0sPLMnr2smljDKCdnSEnHIGuZt4OUag 2dHE6dZ2c3hEvgCs1CtuHj2evIMd2NiaP91B/A== X-Google-Smtp-Source: AGHT+IHODLbfRzFCa5UdoY3a2QSL0mqI5htFnV3n7XCPqVUtza19f5wrvgsYooxFT5Xj71CAbBGprw== X-Received: by 2002:a05:6a21:32aa:b0:1e0:ceb4:b7e5 with SMTP id adf61e73a8af0-1e165aabd49mr1219999637.18.1733194027725; Mon, 02 Dec 2024 18:47:07 -0800 (PST) Received: from ISCN5CG2520RPD.infineon.com (sp49-98-220-81.msd.spmode.ne.jp. [49.98.220.81]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fc9c2d634asm8605693a12.8.2024.12.02.18.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 18:47:07 -0800 (PST) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, kr.kim@skyhighmemory.com, zhi.feng@skyhighmemory.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v3 1/3] mtd: spinand: Remove write_enable_op() in markbad() Date: Tue, 3 Dec 2024 11:46:48 +0900 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241202_184708_817359_48FF4B14 X-CRM114-Status: GOOD ( 10.69 ) X-Spam-Score: -1.8 (-) 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: From: Takahiro Kuwano We don't have to call spinand_write_enable_op() in spinand_markbad() as it is called in spinand_write_page(). Fixes: b645ad39d568 ("mtd: spinand: Do not erase the block before writing a bad block marker") Signed-off-by: Takahiro Kuwano Reviewed-by: Tudor Ambarus --- drivers/mtd/nand/spi/core.c | 4 ---- 1 [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:52f listed in] [list.dnswl.org] -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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924(at)gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924(at)gmail.com] 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 From: Takahiro Kuwano We don't have to call spinand_write_enable_op() in spinand_markbad() as it is called in spinand_write_page(). Fixes: b645ad39d568 ("mtd: spinand: Do not erase the block before writing a bad block marker") Signed-off-by: Takahiro Kuwano Reviewed-by: Tudor Ambarus --- drivers/mtd/nand/spi/core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 4d76f9f71a0e..47c369f2925d 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -942,10 +942,6 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos) if (ret) return ret; - ret = spinand_write_enable_op(spinand); - if (ret) - return ret; - return spinand_write_page(spinand, &req); } From patchwork Tue Dec 3 02:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 2017513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=wQ9ZSsmV; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=dawoYyli; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y2Q873xYMz1yQN for ; Tue, 3 Dec 2024 13:48:39 +1100 (AEDT) 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=sm2YF2ZOWRIwjs/dh+MjNddWJMAYJyO0w4jcju+rw2Y=; b=wQ9ZSsmV8om4NJ Gjl8J8p5c3WIQJRPO7kqqQWXB7QZ22ZdqRqnhhfdr5oYTuzF5jMU3PJeOz0UX3btQeVBD2TjtUXNb 9RZgqDuzfunJRgqhJPxbMGXIvZ93izDoIUZCqvzT0c3gUkt/+RLxAeVNTYI6mesG0GFYTEL3aLMXh xnFgWBqFeIPRJEEyFur8Pskf9FKfgjvdbkp7MExqDdNPio4LfPQEa8IpoNl7gQxGLcUb7QjfYZcop obil1AbJP0TqvxRbRgFHlyv62NHAil2VK/Q2+t+UU6dt6pHz1ZDr5LgEYHJEMeSWHiP1VuMOYvVFo atQU+RdQhkgH67bQ4lxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tIIxh-000000083lh-1Lye; Tue, 03 Dec 2024 02:48:29 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tIIwU-000000083VE-0zOM for linux-mtd@lists.infradead.org; Tue, 03 Dec 2024 02:47:15 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7fbd76941ccso3630832a12.2 for ; Mon, 02 Dec 2024 18:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733194033; x=1733798833; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4O7qOAdG7Dgz/dYuEL9fMRAYn/D7fU4D6K1iLRtQxLc=; b=dawoYyliw0lL+jtqO+pD/RwgF/7lCTcAtv4RBmcMNsytX3eTDDuizckw4+7yzXCt/T ebvMT7bzUyY45f4698hsr4GCxuq6Tj+MaQNwbO37Nz0StC28hf/dAkpJlsT/Kkz1fqrt 4R0mjkh9ojODDheKmKD4X4+1RX0Bd8JKNrTQvBqzFXl3jQR6myYLuR99VHwUVk8IHq8m cqqsKCflTtGJgmxCIqun1RkbrU48Mgki5AvTEJ7t9VnQBwozXBF8Z3ORxjZx3KvWJC3c xVWVAltU01xQjZat0Jt/CEeKnoTADkLdAiUmHJtoAtjYnSb2OBQNr6klWofAKg5WM/6k x2qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733194033; x=1733798833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4O7qOAdG7Dgz/dYuEL9fMRAYn/D7fU4D6K1iLRtQxLc=; b=d3Yky7sSARFgKCafzm7oW63vZu0FnFg7FqGYMHfX/S9Uw9ANGpGKPxk01ajj6NZ5pW vOnDh233tyN7JqgP3vcfkrIGX2lyxwAv9z4sjUtrhvMoTKfvo6daDWSRBoW4dAaZ1hlW w4/xdfYxrkoWdyOXOYwomuAm2RkJWVoOGjmgD1pO0ynibtjPR3c99bgAmvgZwSprTHws qZ3cVKZa7k0yTLVtNSz+ctBTAZeyHSPzzskhdvtngfhV/ZgaPeC7xFve48SjAcOz6ebo e9RhkDn10aFApDRZGQkjVsut/kVVasPikKMSZocCtbhZUIUeHu4hOvJNFT/uoGzuWuP+ ybbQ== X-Gm-Message-State: AOJu0YzdyYOlQQmLOWbHXOenwyzaZtSvZuaqAXuULpXvI3avEl4lG+4x zsUfal+V+kC5Eo46VvCXqDawGtMz/yrYfsACww2LCfJp/SJY19SSiyWjQA== X-Gm-Gg: ASbGncvyGtpk5/3DE/FQQ1qb8LQ+K0pLYktXJ6YN7mkYT9tlBfrNROPT0eq7IbCix5a 7L6gKQzGbgj1oznRt4tSIzkMAdn0AtDwRA19Q09k7/+79ZI6kcxfoGo2p4CNZQPMxN7WDf8TSUx RJXNFsLCTygPfzPmi13DVy9QFPyfIgtiNd++D+DgIE87cY5OkXkiE5+2xV9pNCobCBcRcc2D2BO Q5jtgPoJDTBoEcwxpt3IzZ+kiTuM7JqyxLzIrXSX/0pPSniPfYkBT1kGHonrM02e/yejiXIJPyP TGEyVNzjayfj1nkg72qyel0f8ICYooLYKDaNqg== X-Google-Smtp-Source: AGHT+IFNjdf4bGx9+adSGAD6WVi5epzVEkqdNeXiWukbo3gS6lokv5PeMQ+UvGS6nCRhqzux+fNF0g== X-Received: by 2002:a05:6a21:99a8:b0:1e0:c7cf:bc2d with SMTP id adf61e73a8af0-1e1653a06b1mr1708237637.3.1733194033297; Mon, 02 Dec 2024 18:47:13 -0800 (PST) Received: from ISCN5CG2520RPD.infineon.com (sp49-98-220-81.msd.spmode.ne.jp. [49.98.220.81]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fc9c2d634asm8605693a12.8.2024.12.02.18.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 18:47:12 -0800 (PST) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, kr.kim@skyhighmemory.com, zhi.feng@skyhighmemory.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v3 2/3] mtd: spinand: Introduce a way to avoid raw access Date: Tue, 3 Dec 2024 11:46:49 +0900 Message-Id: <15a64f75cc88c90fe746422280ebd1c8c3fa34bf.1733193264.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241202_184714_280040_47C11A81 X-CRM114-Status: GOOD ( 17.69 ) X-Spam-Score: -1.8 (-) 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: From: Takahiro Kuwano SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoi [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:530 listed in] [list.dnswl.org] -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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924(at)gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924(at)gmail.com] 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 From: Takahiro Kuwano SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed. Introduce SPINAND_NO_RAW_ACCESS flag to advertise the device does not support raw access. In such devices, the on-die ECC engine ops returns error to I/O request in raw mode. Checking and marking BBM need to be cared as special case, by adding fallback mechanism that tries read/write OOB with ECC enabled. Signed-off-by: Takahiro Kuwano --- drivers/mtd/nand/spi/core.c | 22 ++++++++++++++++++++-- include/linux/mtd/spinand.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 47c369f2925d..2ff3c32d46d3 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -294,6 +294,9 @@ static int spinand_ondie_ecc_prepare_io_req(struct nand_device *nand, struct spinand_device *spinand = nand_to_spinand(nand); bool enable = (req->mode != MTD_OPS_RAW); + if (!enable && spinand->flags & SPINAND_NO_RAW_ACCESS) + return -EOPNOTSUPP; + memset(spinand->oobbuf, 0xff, nanddev_per_page_oobsize(nand)); /* Only enable or disable the engine */ @@ -901,9 +904,17 @@ static bool spinand_isbad(struct nand_device *nand, const struct nand_pos *pos) .oobbuf.in = marker, .mode = MTD_OPS_RAW, }; + int ret; spinand_select_target(spinand, pos->target); - spinand_read_page(spinand, &req); + + ret = spinand_read_page(spinand, &req); + if (ret == -EOPNOTSUPP) { + /* Retry with ECC in case raw access is not supported */ + req.mode = MTD_OPS_PLACE_OOB; + spinand_read_page(spinand, &req); + } + if (marker[0] != 0xff || marker[1] != 0xff) return true; @@ -942,7 +953,14 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos) if (ret) return ret; - return spinand_write_page(spinand, &req); + ret = spinand_write_page(spinand, &req); + if (ret == -EOPNOTSUPP) { + /* Retry with ECC in case raw access is not supported */ + req.mode = MTD_OPS_PLACE_OOB; + ret = spinand_write_page(spinand, &req); + } + + return ret; } static int spinand_mtd_block_markbad(struct mtd_info *mtd, loff_t offs) diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 702e5fb13dae..5cf11005b41a 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -314,6 +314,7 @@ struct spinand_ecc_info { #define SPINAND_HAS_CR_FEAT_BIT BIT(1) #define SPINAND_HAS_PROG_PLANE_SELECT_BIT BIT(2) #define SPINAND_HAS_READ_PLANE_SELECT_BIT BIT(3) +#define SPINAND_NO_RAW_ACCESS BIT(4) /** * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure From patchwork Tue Dec 3 02:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 2017514 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=apmRYSWt; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=LpxtHPAR; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y2Q881MS7z1yR0 for ; Tue, 3 Dec 2024 13:48:40 +1100 (AEDT) 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=INgtrapIw6Zo/g72QvH3yFDrGPVUxvCPY9Ws1Q7rQnQ=; b=apmRYSWtN8g0K1 yQQb89rPO/ATgcb/GNL2UpGt6Y0Gw6mxfnh3qzdQa9Yy9a/WCM+6ooYl9GrnhO2Y4pZ1oW1hfGvWc 99Qrac+pyLnQPWLFs88mXXdW+S0tIZuo69k9hPJzHEBun+lto2apHna9ZDxwl8ZdrcxGoOD0/cBlZ U1UREBnb51rwuE87tGOzLZWGrmW/BzMLtyPBuhNkOxErJmsGTxBQ3yH2s/Lttgq4MkjdSWbUGo0KK yS0EyDNwXmtxvHyufopyYqlYXRP3sWsBxgq8NzbfQHmu2wLr4txr9dYXkGh50SuA/UgX+A75lUt9S 0HWbGylV9PlojiyeHtYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tIIxh-000000083m5-3VY6; Tue, 03 Dec 2024 02:48:29 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tIIwa-000000083X2-1S7r for linux-mtd@lists.infradead.org; Tue, 03 Dec 2024 02:47:21 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-29e842cb9b4so308198fac.2 for ; Mon, 02 Dec 2024 18:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733194039; x=1733798839; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RmuF46E7QZ73q+MnD9LRef4FBtBZcOQ1mSbJPyIeM2c=; b=LpxtHPARYVEFt8ETA2UPD5eWe7+u/ku4XEey2IbNfE4Y+NP8kEzxsCnMvV19ZnLfNz b0203FidWMDOhNb81x+gmMRJziE9mceuO32HyP3OW21GXOKxwPjhmtz4mg8sJ1L96Efw BGn7p+cwySSZ4YaDxtn6wocroo6Nab5m/oqsPZ+aAkmPZPMYRaGrVXVIO6izR3vqCGuX F6c65TiOUQd8xjc9L7gq5PYJ23V8Iqqv0I4bMMDxDqbMxb+0KEYLVv4JXOJ1Tqlf0Aob NN370DtdTxBu3TGo6qqCNw1nmn2LWFQKO1Za7oB99BG9iNkrE0JuwqaljpTfF29/GgMg e6Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733194039; x=1733798839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RmuF46E7QZ73q+MnD9LRef4FBtBZcOQ1mSbJPyIeM2c=; b=jsps22DPJCGpyP55DMygJA2BnvdfVBpS3Xdbrspm5lteTb3lA7cEG2lonZebO3KCIV sOGBmjlifbeMQJ8HoY3AbVm7s+jaJF8qwo73LGLURIIICcgcQRg2gJB77EPoFhwyRW4e Vvp207WxCMa2buR1Gc/0fv6BHv1tt1yVfmtR+dZXbSvLEfnO6i7nLuKjV6I2Y0m8PpKs /hRnRSCKQ+XE5nYp+YcxEaz49CoLGg/YdTBRjzE0D7DlzyAgcue2dN21EA1ZGy6eXznv ZS21TxsF15Rgk2KAbentvf8ouuC40cJjGqhpugsVC25dHJ2j8JRQcDAptpwoWZtzcMHf LgLQ== X-Gm-Message-State: AOJu0YwtfMb0+IY07IOYiG8tZSEdSbiyBqtrk+EZDqF4Z1Mp7sN5hMmx mxod0qSrb/X/dmFJHWq6+Tu/2NNe00M1hINYaLL5wv0+2hw6VaqfbsJJ0g== X-Gm-Gg: ASbGncuoYf8BTHk0S2WFz3uKzcUVC5bOuSFj/qkEdreG2elZBNwRC1IP3utP6fEfja9 2Prf71YTqc2sbW6tgVi2Cegn4sdGg5eBRTLvIiUq1brD+zwPVXWtPPNJqjJM9SD+65XqA7e/OhL Cb9V7gvPMzfkTsfkbC5F/pUyGvaFw47LkbAp9dSyNC0pOAI32Bk9EpnmiwyMlhZZoEOPG2IGg0k 2rzRKrCr1UAgL3zvpRGqBNQNhANdLlDRbNdRQxRqu5bKwBFRce7U0YNoBE5SYz1Ju5X5ncQZ0pN LWEymA/pBG3e7AQHJHtbKvQd0qeVX7f389Q3gg== X-Google-Smtp-Source: AGHT+IFpZbkG8hMVlVEjOcXb8ZuEYoixhjhHbAF0e6MLfRghGknlrGW1WtQjFIwWydXxA8vpUsuZ1g== X-Received: by 2002:a05:6871:e493:b0:29e:32e7:5f1f with SMTP id 586e51a60fabf-29e8888712amr1031791fac.27.1733194039161; Mon, 02 Dec 2024 18:47:19 -0800 (PST) Received: from ISCN5CG2520RPD.infineon.com (sp49-98-220-81.msd.spmode.ne.jp. [49.98.220.81]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fc9c2d634asm8605693a12.8.2024.12.02.18.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 18:47:18 -0800 (PST) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, kr.kim@skyhighmemory.com, zhi.feng@skyhighmemory.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v3 3/3] mtd: spinand: Add support for SkyHigh S35ML-3 family Date: Tue, 3 Dec 2024 11:46:50 +0900 Message-Id: <33652eaf331fc27b3820ad8445b64ede4f461960.1733193264.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241202_184720_388361_C4C6B822 X-CRM114-Status: GOOD ( 20.35 ) X-Spam-Score: -1.8 (-) 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: From: Takahiro Kuwano SkyHigh S35ML01G300, S35ML01G301, S35ML02G300, and S35ML04G300 are 1Gb, 2Gb, and 4Gb SLC SPI NAND flash family. This family of devices has on-die ECC which parity bits are stored to hidden area. In th [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:4860:4864:20:0:0:0:32 listed in] [list.dnswl.org] -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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924(at)gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924(at)gmail.com] 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 From: Takahiro Kuwano SkyHigh S35ML01G300, S35ML01G301, S35ML02G300, and S35ML04G300 are 1Gb, 2Gb, and 4Gb SLC SPI NAND flash family. This family of devices has on-die ECC which parity bits are stored to hidden area. In this family the on-die ECC cannot be disabled so raw access needs to be prevented. Link: https://www.skyhighmemory.com/download/SPI_S35ML01_04G3_002_19205.pdf?v=P Co-developed-by: KR Kim Signed-off-by: KR Kim Signed-off-by: Takahiro Kuwano --- drivers/mtd/nand/spi/Makefile | 2 +- drivers/mtd/nand/spi/core.c | 1 + drivers/mtd/nand/spi/skyhigh.c | 147 +++++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 1 + 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/nand/spi/skyhigh.c diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile index 19cc77288ebb..1e61ab21893a 100644 --- a/drivers/mtd/nand/spi/Makefile +++ b/drivers/mtd/nand/spi/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 spinand-objs := core.o alliancememory.o ato.o esmt.o foresee.o gigadevice.o macronix.o -spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o +spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o obj-$(CONFIG_MTD_SPI_NAND) += spinand.o diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 2ff3c32d46d3..77aa77ea4564 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1131,6 +1131,7 @@ static const struct spinand_manufacturer *spinand_manufacturers[] = { ¯onix_spinand_manufacturer, µn_spinand_manufacturer, ¶gon_spinand_manufacturer, + &skyhigh_spinand_manufacturer, &toshiba_spinand_manufacturer, &winbond_spinand_manufacturer, &xtx_spinand_manufacturer, diff --git a/drivers/mtd/nand/spi/skyhigh.c b/drivers/mtd/nand/spi/skyhigh.c new file mode 100644 index 000000000000..8b32b74ff34b --- /dev/null +++ b/drivers/mtd/nand/spi/skyhigh.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2024 SkyHigh Memory Limited + * + * Author: Takahiro Kuwano + * Co-Author: KR Kim + */ + +#include +#include +#include + +#define SPINAND_MFR_SKYHIGH 0x01 +#define SKYHIGH_STATUS_ECC_1TO2_BITFLIPS (1 << 4) +#define SKYHIGH_STATUS_ECC_3TO6_BITFLIPS (2 << 4) +#define SKYHIGH_STATUS_ECC_UNCOR_ERROR (3 << 4) +#define SKYHIGH_CONFIG_PROTECT_EN BIT(1) + +static SPINAND_OP_VARIANTS(read_cache_variants, + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); + +static SPINAND_OP_VARIANTS(write_cache_variants, + SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), + SPINAND_PROG_LOAD(true, 0, NULL, 0)); + +static SPINAND_OP_VARIANTS(update_cache_variants, + SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), + SPINAND_PROG_LOAD(false, 0, NULL, 0)); + +static int skyhigh_spinand_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) +{ + /* ECC bytes are stored in hidden area. */ + return -ERANGE; +} + +static int skyhigh_spinand_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) +{ + if (section) + return -ERANGE; + + /* ECC bytes are stored in hidden area. Reserve 2 bytes for the BBM. */ + region->offset = 2; + region->length = mtd->oobsize - 2; + + return 0; +} + +static const struct mtd_ooblayout_ops skyhigh_spinand_ooblayout = { + .ecc = skyhigh_spinand_ooblayout_ecc, + .free = skyhigh_spinand_ooblayout_free, +}; + +static int skyhigh_spinand_ecc_get_status(struct spinand_device *spinand, + u8 status) +{ + switch (status & STATUS_ECC_MASK) { + case STATUS_ECC_NO_BITFLIPS: + return 0; + + case SKYHIGH_STATUS_ECC_UNCOR_ERROR: + return -EBADMSG; + + case SKYHIGH_STATUS_ECC_1TO2_BITFLIPS: + return 2; + + case SKYHIGH_STATUS_ECC_3TO6_BITFLIPS: + return 6; + + default: + break; + } + + return -EINVAL; +} + +static const struct spinand_info skyhigh_spinand_table[] = { + SPINAND_INFO("S35ML01G301", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15), + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(6, 32), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_NO_RAW_ACCESS, + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, + skyhigh_spinand_ecc_get_status)), + SPINAND_INFO("S35ML01G300", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14), + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(6, 32), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_NO_RAW_ACCESS, + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, + skyhigh_spinand_ecc_get_status)), + SPINAND_INFO("S35ML02G300", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25), + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), + NAND_ECCREQ(6, 32), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_NO_RAW_ACCESS, + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, + skyhigh_spinand_ecc_get_status)), + SPINAND_INFO("S35ML04G300", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35), + NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1), + NAND_ECCREQ(6, 32), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_NO_RAW_ACCESS, + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, + skyhigh_spinand_ecc_get_status)), +}; + +static int skyhigh_spinand_init(struct spinand_device *spinand) +{ + /* + * Config_Protect_En (bit 1 in Block Lock register) must be set to 1 + * before writing other bits. Do it here before core unlocks all blocks + * by writing block protection bits. + */ + return spinand_write_reg_op(spinand, REG_BLOCK_LOCK, + SKYHIGH_CONFIG_PROTECT_EN); +} + +static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = { + .init = skyhigh_spinand_init, +}; + +const struct spinand_manufacturer skyhigh_spinand_manufacturer = { + .id = SPINAND_MFR_SKYHIGH, + .name = "SkyHigh", + .chips = skyhigh_spinand_table, + .nchips = ARRAY_SIZE(skyhigh_spinand_table), + .ops = &skyhigh_spinand_manuf_ops, +}; diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 5cf11005b41a..cbbcd44ac225 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -268,6 +268,7 @@ extern const struct spinand_manufacturer gigadevice_spinand_manufacturer; extern const struct spinand_manufacturer macronix_spinand_manufacturer; extern const struct spinand_manufacturer micron_spinand_manufacturer; extern const struct spinand_manufacturer paragon_spinand_manufacturer; +extern const struct spinand_manufacturer skyhigh_spinand_manufacturer; extern const struct spinand_manufacturer toshiba_spinand_manufacturer; extern const struct spinand_manufacturer winbond_spinand_manufacturer; extern const struct spinand_manufacturer xtx_spinand_manufacturer;