From patchwork Thu Nov 21 02:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 2013674 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=1B6laMlA; 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=Alp6fd/C; 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 4Xv1rS3cm8z1yRq for ; Thu, 21 Nov 2024 13:09:26 +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=Pfd1PKiM03qQQMAiOmCBdcNhHZRXzyHKorekeYN6dls=; b=1B6laMlAUioq0v TBejDJ/ojM/buMEoKZXiT3h25zk8aV3qmd/B152SGldqe3F914610fFQ+rKcdluo6MGViupBdmH9R xDvSDzzNCMPj6j5BrO4Cark69ezHwdmQoAuPczOrHLGm26oIuKtWfgQxr+8rOXD36f4yhxiSK5dY7 OMUHZWI+2Rzvdx9Cng7Ul0qb67JBF+hnS8Df9WQ7eTetmTP4fh7C6CG2sBP5lyjLYQ5X7F+IhaB+2 RMqixbzlo7NlB0DwxkEaqRXNRREydhIOmidoudojgvplDFoCugPYJekQKzoI2O0l6yuuMEQAeRRYP JhCGrPTlxgQuRqlJl+3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDwcy-0000000GZum-0ynb; Thu, 21 Nov 2024 02:09:04 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDwcw-0000000GZu7-0U8Z for linux-mtd@lists.infradead.org; Thu, 21 Nov 2024 02:09:03 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-212776d6449so3667495ad.1 for ; Wed, 20 Nov 2024 18:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732154941; x=1732759741; 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=Jmu4MyOZ/hSDv3HHRy9BIOsWJO0xmFQ6N7YEUPlcf7o=; b=Alp6fd/CU7s7w2G9LPAPHkpe808yXWL8ujoXoYGyIzCAr85wIbQRlMak/m2duI3a3Q I6vKt7VQTylU5787nRAyqFmJt/KYWmHtzJ9CM4IwFRymvG0HQYr+0bVsfKgwd7aAh6TO 3n3YKNvd17DMx/Vt8f+Kk3lXKzT8ljzJD4E4VcgOsXg6p7rJF2NQt2CKr+onDALaFZeS J5drkhI1GmyWI4Ir4CCRsUxbKqlQGVVQqyQGT82WWYOCJmoe9uNzfWSD05U2mSJl0C3Y hn9i4T+QVLoi/bYwVBgQcmhDs0cmp2eUJ3DGtW2dbzMfhG3cxFShhhw2Ny8dbb2du3O8 Og8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732154941; x=1732759741; 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=Jmu4MyOZ/hSDv3HHRy9BIOsWJO0xmFQ6N7YEUPlcf7o=; b=TsRTo12Jfj5F7qKU5gKKkjw099PV8yR7eXXHGn2nGcao5+vtAaSgvquseLZuFtfMO8 lO9EujgMuH6pDD+GwOsIT5l/ZX0xkPElCf1OLGJT4XvUyIx09HoW0DzYaYgP0PWUlwyj b+Mr4tIE116DOHL/YUtYNcDLJChrTK93zIRxPML9ojReXhInoNqj5chEr0HT8R5jTVRx 64+MO1AEtjRi0HAay8rN5fHnlyNIg7+7U5clAF0pTimdc1Q5Ifx5bPVAnP+DryfxfO5+ rTORI32fs5C4psAnQhvb4IF8av0J9LSzkFVArjEXhV46fm1/V9qiJ7ejtXoBul7V8qTJ gefg== X-Gm-Message-State: AOJu0YzjWTG7Enmiz5Al2kTibEWpJFnj/7xsrgOoFshITENAbxRpNUtf CMl3wHp856A1Aq5by8n8XDaCk+EZzqQpOLp48UtWgOEm1q4IFiDXnNQR7Ib+ X-Gm-Gg: ASbGncvsQO9pWyMsvyGvSZNgknQPhbF7IAWELEX/sqOfxIV9vhZiNCzd+wzphBzkWDc wvUHUkPNJwuP8B/hXESd29aoC/Xd8iBiTJ8p5e2wY5s5wYf6pB8HA8HkMI7FxGv3gSQFcaJFCGG BjSJFscMetIz8AqIr/rmR1ZENPaPyqxV3CpW+131JOyUjPy8JetlSM7bnIDPMpeoOYzIlDVoD4x ofjlHemRzyRemkYleMdH9YckOdfW/4WpasIsIfTELqzJt70vxyU9lugqvAN6B+UbWxakvmRbHoL 6AsE1RVqbwFUrLry9Nx4d/0/Q4Enayb1KDrxXA== X-Google-Smtp-Source: AGHT+IFRqA3lCIp5SCgAZXNAv1XMFtzLxe79dhMH7U2STYq1L9H6Es/UnEFUbbmDkuG4amH9XTyxUA== X-Received: by 2002:a17:902:ccc9:b0:20c:8dff:b4ed with SMTP id d9443c01a7336-2126fb34cabmr53322945ad.16.1732154941018; Wed, 20 Nov 2024 18:09:01 -0800 (PST) Received: from ISCN5CG2520RPD.infineon.com (sp49-98-40-130.msd.spmode.ne.jp. [49.98.40.130]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212878a5d2dsm2388615ad.77.2024.11.20.18.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 18:09:00 -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 v2 1/3] mtd: spinand: Remove write_enable_op() in markbad() Date: Thu, 21 Nov 2024 11:08:41 +0900 Message-Id: <8be5cb694a763d3a74d9c3c7e76dd98b7b1333f6.1732152768.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-20241120_180902_155467_D01DA13A X-CRM114-Status: GOOD ( 10.12 ) 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(). Signed-off-by: Takahiro Kuwano --- drivers/mtd/nand/spi/core.c | 4 ---- 1 file changed, 4 deletions(-) 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:632 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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(). 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 Thu Nov 21 02:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 2013673 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=3tTSQZ8Q; 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=lFJvZ9ua; 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 4Xv1rS3WlBz1xyG for ; Thu, 21 Nov 2024 13:09:26 +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=3tTSQZ8Qo22mZI 8ncGqrwdXgYv+RvOsaWpb3WEovefXjpyPSvuBYxNdPC+DNu0KYK7wRd72NxRlJv8I2U9Ofvn4hazC bijETYFaeCY86F1rnF9aoZOyeh97x3g7JmoQtXm6Knm+KgYhwBoo5FASulVopOigbrVCAGg2cu0nv 0RSot2ziUPwUgAI/2dcx2EX1RlwYeXel2CnzUPd2nb/g+uFCBV4c4MWzIrZOEBYaebQFBfRfs6qYw vwip/FQynuDPCzzFNWOBsWxcedA60AkMN0vHY/R6FPoVF0iqROYhNloDDClF3R0Sg4+3xX/G9W7sY QJ00cXVYNiN0tFj7ZzfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDwd3-0000000GZve-2zAF; Thu, 21 Nov 2024 02:09:09 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDwd1-0000000GZvB-2Le2 for linux-mtd@lists.infradead.org; Thu, 21 Nov 2024 02:09:08 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2124ccf03edso3107295ad.2 for ; Wed, 20 Nov 2024 18:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732154946; x=1732759746; 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=lFJvZ9uaAYFq7QezbR4qqhzThsXPm5TtIhHKRZQXxElbVJX90ww8CQlh15VKtcSAv6 TJCRbGYUiMaXp7ISG38zrUjYvtGdnZHBD27koKOY7TcFkkTDhlnn8l0plsHjU1NmxorN qhfAN1TFButEy/YdFWAFJAVf78Pq4lB+JsLKnxhGoBygrOWYpCgIEE02hk3Bhv82/D3S IVH+gvI7GyF7R42x4TKH2kaVSuinwsiFlrpo1b4ylxd0K2i33VnVfTxKnymhy92UMaSF WSCP0Ah1ZQ+irwdVViLEZWtBzso+dpxy9Om3o6V01/cFfE/wPcuEgagyPRKDigo+SdrP QIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732154946; x=1732759746; 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=vUdZ3Hxb5F1SKXxolp0yV7/J+rUGi+wnpFpWYbdsyT5H1cwSCoVIJZWz9OW/nPXuCF l6+hm6E2EYTUBlvaR/jwQR+I/EtBMLvKGnSZuuSc57K+U7a6ibBDzCUUaa0Wpb2+DqWX vLll7T2EG366CjyqCh+k+7QZ+U+cnVPV6lG11/Nrzy3HRtk31D8liuho4MXpUzZkvdLq YWTeKEwbsR8FI3Gc6GerzR+k9Ic5yNgXuR4Vo/2brUdauqbp8ukYuhAoR2py/hN6ANi+ t0GeJXElAzpeekWsZNU6pkKQ0xZ4JBYoeeDR9OOb8+ZuqyM0lvOOUaF8wnRgRHlerMkV pw7w== X-Gm-Message-State: AOJu0YyYlIjIDuFUf9d3VfjuzRHn74g5BH9aD5SM/mIVsD5ZGadTQ09e faBoxWpoaWYZ+s1Y+MVtdozN8uokAfxybrXnl7dyyw15LIrpPEexugHhe2NF X-Gm-Gg: ASbGnctzRB6ip3s8V0VLksqNMkMoQLC8qBAuru+ntKHJuo8dNUEFEp4QiVBUDSnAzkm +exgPQ61OvzPGakY12zSryBqdO9+K94QdoUFJkPZpuQxtZhyvYLDLMBRrcFjJBHS/Ak6hh9xh1n AWaIPofSALLY6DJLOgmyfxNXcuE6m+T3ZZPaF7Xr5bYcho7cPMdRp54KLN2NAYfecqnf9emkc4d DXb4uF1giSpNjMfCCLzMnVVb1VOrvvUR6M6+ZUf9ewNCXlUHTVL8CUcx0DD7eIrKx/nKzZMcWDL gZAxumDq4Xg0gmIqqs0qwBZZZiiSlKZLLZYu2w== X-Google-Smtp-Source: AGHT+IHkTImSUaKK5AV7RscfVU1pSuDcfttIIpxRL9N8i7Mv2dvR4K6+4lzzU42S+Vg0vgat/W5GrQ== X-Received: by 2002:a17:902:d50d:b0:212:48c8:f456 with SMTP id d9443c01a7336-2126a42ef4bmr76477835ad.36.1732154946533; Wed, 20 Nov 2024 18:09:06 -0800 (PST) Received: from ISCN5CG2520RPD.infineon.com (sp49-98-40-130.msd.spmode.ne.jp. [49.98.40.130]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212878a5d2dsm2388615ad.77.2024.11.20.18.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 18:09:06 -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 v2 2/3] mtd: spinand: Introduce a way to avoid raw access Date: Thu, 21 Nov 2024 11:08:42 +0900 Message-Id: <9944499e3c4bac22495952e1c342a0ce9ca58bfc.1732152768.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-20241120_180907_600714_1D2CF68E X-CRM114-Status: GOOD ( 17.45 ) 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:629 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 Thu Nov 21 02:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 2013671 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=Ak+u2RV5; 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=NOtENre+; 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 4Xv1rT5GRfz1ySH for ; Thu, 21 Nov 2024 13:09:29 +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=Ak+u2RV5xT4Njw nqI/EhTWnJLp5kAY0VBMiFGJGwlvOKBLzWX4RgELnH6+BD+G/whi2FTJI+OcPguaE5msJpBnp4fIp 1JF3ySkHG6bT+wlNJmngeVKdAiW9lytqfEyJ+JfenbD+Na45fuyEQKWqLju6IDLH1MDdQbkTfshrk RTU0kY1YOTC+JJkxg6wLt75voh3IgZ3P1oZjcL0cAYdEj7AYn5L0dykeOjEH9+KjxTMap0rl7hQBp 3WdMN1PcGC1VTASzzZYNzMHP7uKh+Px4eRrh9IHbUKg1ycP7joRovvu99E/r2neeRQ26Z5/ftYqAE SPOKpNfzl/DT1SSVO+fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDwd9-0000000GZxP-0pEn; Thu, 21 Nov 2024 02:09:15 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDwd7-0000000GZwV-10Oi for linux-mtd@lists.infradead.org; Thu, 21 Nov 2024 02:09:14 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7245a9d0e92so482498b3a.0 for ; Wed, 20 Nov 2024 18:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732154952; x=1732759752; 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=NOtENre+44iDqP9yoR4yoE9QbjKAuKnKo8jsuFDipFoOGfKf87I/bn4CY7g8cDm8cj duLrLNnXDcNTJI4wyIx+FjIbOrK2c5r6tNzoe7Ey0/K/d10SB1aOhVW2gtvutHEDNEhI pCS5Gd60jFkSWKmf22IUt3J0yVOT/VegSTXglWmHZAXk/mjteIyspolUU/gEGmD63JQR uBRWpGFyXlqFvbjLKHAqxupWp5nGjD+nYQURZbf7QSGnxlrRhZa3TDpjR5YNZztDwlqP xNDJRbO0MzH8NEwCeqybmxn6Onupkj0UWTAfg2wfGHF8ApFnJWbaby6HZjTLyUGC1AYN OecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732154952; x=1732759752; 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=w/HWStRWxIxbzbecyn4MoAHx7i78BLoKTwNfDMw8r33MyOq6N0Pw3AX+IA2MBIvw/f o90oI7kHlGdVzHOLPUZDWn/RhL4bYcuu2OIf38XG/nm7sEzEphqKEbMixIrNrnUkBy3D GzW96hSB7yGjAVhEbcTEVuxsbvxc8LSe9rhWu3I5EY293wu/guBl4AR0/MWNJmXxI7RA V17SHY8fyWCl7WrqWaVk72EEx18Rv9f3Cb1GZjO51jAYEczQJi01ax/UxQO0RXuTE1i8 rO66fpdqZ76shvNTMxjyii/tsvjEpd9UUUwcqjrod/KPZsEeky1P4St6gpLPGstOQQXN d90g== X-Gm-Message-State: AOJu0YwEaWuKgIzcFiL8StgnHKFhH47mWmIloH+CREd47C66f6Tcg9E7 Y4g3qLZlG9az76B1JRppDS+VtlI+9CdDEBehACUlLzd3UqhoH12caTkf5Vxc X-Google-Smtp-Source: AGHT+IGObvc9yxX4L92fiIy2fRVW6sjP5Icb04l9WtEKDhuYVuQFg3FHTsyvTnfaRjrm/8wYwZZuGw== X-Received: by 2002:a17:902:e80c:b0:20c:a44b:3221 with SMTP id d9443c01a7336-2126b06938amr59400645ad.15.1732154952182; Wed, 20 Nov 2024 18:09:12 -0800 (PST) Received: from ISCN5CG2520RPD.infineon.com (sp49-98-40-130.msd.spmode.ne.jp. [49.98.40.130]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-212878a5d2dsm2388615ad.77.2024.11.20.18.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 18:09:11 -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 v2 3/3] mtd: spinand: Add support for SkyHigh S35ML-3 family Date: Thu, 21 Nov 2024 11:08:43 +0900 Message-Id: <90268cf05a6cb5a2b452d9e6813db24f53c0623f.1732152768.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-20241120_180913_282695_4C5582E1 X-CRM114-Status: GOOD ( 20.21 ) 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 [2607:f8b0:4864:20:0:0:0:430 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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;