From patchwork Thu Jun 21 10:33:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 932677 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D2Kz8byO"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="QntDf9ew"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BJPV052Wz9s2t for ; Thu, 21 Jun 2018 20:50:02 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vY9Rj0rKjJOJ3A3JHnjz1Opjb8IksMG0ZZHQTVKg/vo=; b=D2Kz8byOaJViU/lyw4b9cW7Q5B F+uVAyM9yboFB+Qv+us8U9aldZn1L/2ki2jPBHHyNfpfxjsLijkOiMf30jnNp0sd3WQrJZaZzbbFf RqWZIhoWZkR6m6NHovekHyEa/0nA8dPogBHxXYv9iYhCTFvy48lX9V+6UKiYQcNO1qYwCg+wRle49 ZgBcQs6YBUBn/kTTn3hGMN59jgKfPnLZGjkOx/Pp12Zh+C+uAh8V1irCOMIuNE3+gxFIO5HEgRDTR mOa/3bQPChyjSvUcWqtSpijVKQLdDOT9YK+Rjp71uLc3GVwTFNkHYio5EFwzvCXQTbrqUp6K3qYJM TyARySDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVx9t-0001HH-NT; Thu, 21 Jun 2018 10:49:45 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwuw-0003lU-LM for linux-mtd@lists.infradead.org; Thu, 21 Jun 2018 10:34:21 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 868B384482; Thu, 21 Jun 2018 22:33:41 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1529577221; bh=j59TSYQR1nfRa7T4CJ7W8KI7QGGQAbgK3RPY6Dh7/nE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QntDf9ewNldRzpFrYhugk/5ggVtwXX3Nk+UZeBI69ciuJLis0l8fR9T7iEenxYETW D/lQetn5xiznhdVe7RRVhnNYkBB8j8gNQ2/+xKqJHeCzeyAMMYy1j6ThwnJIWMJR/x nO3CAJM9pZU9S0iDtEe9jcJDvL2cL8xJa6nDgSEQ= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 21 Jun 2018 22:33:41 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 13FB313EF11; Thu, 21 Jun 2018 22:33:40 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id D3E9B1E2626; Thu, 21 Jun 2018 22:33:36 +1200 (NZST) From: Chris Packham To: miquel.raynal@bootlin.com, boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 1/6] mtd: rawnand: marvell: Handle on-die ECC Date: Thu, 21 Jun 2018 22:33:23 +1200 Message-Id: <20180621103328.28206-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> References: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_033418_900927_A763292B X-CRM114-Status: GOOD ( 11.05 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [202.36.163.20 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chris Packham , linux-kernel@vger.kernel.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From the controllers point of view this is the same as no or software only ECC. Signed-off-by: Chris Packham Reviewed-by: Boris Brezillon --- Changes in v2: - New Changes in v3: - Add review from Boris Changes in v4: - None drivers/mtd/nand/raw/marvell_nand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c index ebb1d141b900..ba6889bbe802 100644 --- a/drivers/mtd/nand/raw/marvell_nand.c +++ b/drivers/mtd/nand/raw/marvell_nand.c @@ -2157,6 +2157,7 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd, break; case NAND_ECC_NONE: case NAND_ECC_SOFT: + case NAND_ECC_ON_DIE: if (!nfc->caps->is_nfcv2 && mtd->writesize != SZ_512 && mtd->writesize != SZ_2K) { dev_err(nfc->dev, "NFCv1 cannot write %d bytes pages\n", From patchwork Thu Jun 21 10:33:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 932669 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ASxn/0WI"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="ewsPSSHU"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BJ3X0ZxHz9s1B for ; Thu, 21 Jun 2018 20:34:32 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=BV7igx6oKCoIEyXHfNLs7jzHEF/Xs609KVXn/O5XsE0=; b=ASxn/0WIQxvlfdG8LDt2vZJ1NH zycMy7Gyb4BvGR6AVwBCxYqDhg48hbl0kRcg28KNIfvVj9Fg9jR7bleH5c07RydgggLebSBBe4rUo tuUIxynK0n7IQTxnaZDoDNW8eqfflhNbSLueAMH02fh/rWWysRs3V35Oe5Zxx+9ULx6GZFs4hYYHY lx0RS2McH3D9folk+saRwiioLvosy3YunYmfEeEJ50bv648KYI+VKN0zublAy9kA7fEGfan2Bgopj kHwMOivjU3tM5+a0cgQF/qoTYjJPbIPVyOQ1miynWv0MvAoGgRUomp5sjbIn8QKaOSGg7pAd5pMvn mooAZ2Rw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwux-0003nf-7L; Thu, 21 Jun 2018 10:34:19 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwut-0003lW-Rz for linux-mtd@lists.infradead.org; Thu, 21 Jun 2018 10:34:17 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 909AD84484; Thu, 21 Jun 2018 22:33:41 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1529577221; bh=QViISlwt80vHC50lmZqU3LyNRHSbr6A9e4qRXWrctpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ewsPSSHUTNBjAtgRNN+M869U0+8cGyw9SXliBVunyPmtTt09SgY4Zx/4Fi8S+oaZk oKZ39tPEUq/Js00JMXpdRFN4bkblkb0XgJQTeA8VwSP8Gx5bezV8Kiu/62nATCEbol O46oSPtJtQsIr2yJ0jYKfGiVtZ5+SQSf+byqo8JM= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 21 Jun 2018 22:33:42 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 38EA013EF5C; Thu, 21 Jun 2018 22:33:40 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 037EE1E2626; Thu, 21 Jun 2018 22:33:36 +1200 (NZST) From: Chris Packham To: miquel.raynal@bootlin.com, boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 2/6] mtd: rawnand: add manufacturer fixup for ONFI parameter page Date: Thu, 21 Jun 2018 22:33:24 +1200 Message-Id: <20180621103328.28206-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> References: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_033416_121979_FFC12EDB X-CRM114-Status: GOOD ( 12.28 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chris Packham , linux-kernel@vger.kernel.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is called after the ONFI parameter page checksum is verified and allows us to override the contents of the parameter page. Suggested-by: Boris Brezillon Signed-off-by: Chris Packham Reviewed-by: Boris Brezillon --- Changes in v2: - New Changes in v3: - Add doc comment and review from Boris Changes in v4: - None drivers/mtd/nand/raw/nand_base.c | 4 ++++ include/linux/mtd/rawnand.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 0cd3e216b95c..65250308c82d 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -5172,6 +5172,10 @@ static int nand_flash_detect_onfi(struct nand_chip *chip) } } + if (chip->manufacturer.desc && chip->manufacturer.desc->ops && + chip->manufacturer.desc->ops->fixup_onfi_param_page) + chip->manufacturer.desc->ops->fixup_onfi_param_page(chip, p); + /* Check version */ val = le16_to_cpu(p->revision); if (val & (1 << 5)) diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index 3e8ec3b8a39c..ef7e3b4e91ea 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -778,11 +778,14 @@ nand_get_sdr_timings(const struct nand_data_interface *conf) * implementation) if any. * @cleanup: the ->init() function may have allocated resources, ->cleanup() * is here to let vendor specific code release those resources. + * @fixup_onfi_param_page: apply vendor specific fixups to the ONFI + * parameter page. This is called after the checksum is verified. */ struct nand_manufacturer_ops { void (*detect)(struct nand_chip *chip); int (*init)(struct nand_chip *chip); void (*cleanup)(struct nand_chip *chip); + void (*fixup_onfi_param_page)(struct nand_chip *chip, struct nand_onfi_params *p); }; /** From patchwork Thu Jun 21 10:33:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 932673 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HCIoMX/m"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="I9DfH3Tt"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BJ5v6wyrz9s2t for ; Thu, 21 Jun 2018 20:36:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GCtAbOnBpDlei0TCuah9eiUEBqYQnmUDoVBpKkqK3l0=; b=HCIoMX/mHS3j0oWy0ai2Jl9Cps FhJ+W4y5ypqhn0siRyOjoDt3jIwiIIhKIUF4POeWWq81TNrMRqZr2ZWblp6X8leH+UOUzwVTcHcgw ZbRkHNlio3A4uaFXd2hzHn+L5Tbqlx2qlHHl7Y4ow+O0F3S8j98qLCfGrA/iN2P0END04Ppz59KHY RUHxmXTRDwhbQDvkd0TsSTn/6Y5sk4mG7waoZIX8wlfkDSj8TNy8zDkzHlLWAauyDY7KSMAz217TB zRrxj/LtBqmCHbkuTBG06h+05obBa7aC8chbIMZpNzg6oBPpHRJJe2LAjPShukyCTnW7uqEnjvXjd P1z/FGHA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwwz-0006Dx-AG; Thu, 21 Jun 2018 10:36:25 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwv7-0003n8-EG for linux-mtd@lists.infradead.org; Thu, 21 Jun 2018 10:34:35 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id A75B38448A; Thu, 21 Jun 2018 22:33:41 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1529577221; bh=grDTHuiRVnY9AHfszxzkJkAoEyuqxn4PHjR0Y2jxkm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I9DfH3TtgLNCoOIWgoXvj9j14Twzr1sGB+/Oc/SyDqrC8skSBL5wFRWWqrCUNCsdq k+guUm5JfAmOEEvU4Gzv3Cj+VcGUqMWkIol6Zc9FPZa60Gy4XnreQpJ/trTqz8DYod RzCUnHfnq24LGLfRIceEqQd1lyMeiSrT+fdc2GMQ= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 21 Jun 2018 22:33:42 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 5E37013EFB0; Thu, 21 Jun 2018 22:33:40 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 26E781E2626; Thu, 21 Jun 2018 22:33:37 +1200 (NZST) From: Chris Packham To: miquel.raynal@bootlin.com, boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 3/6] mtd: rawnand: add defines for ONFI version bits Date: Thu, 21 Jun 2018 22:33:25 +1200 Message-Id: <20180621103328.28206-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> References: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_033429_709883_5885CFCE X-CRM114-Status: GOOD ( 11.83 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [202.36.163.20 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chris Packham , linux-kernel@vger.kernel.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add defines for the ONFI version bits and use them in nand_flash_detect_onfi(). Signed-off-by: Chris Packham Reviewed-by: Boris Brezillon --- Changes in v4: - New drivers/mtd/nand/raw/nand_base.c | 10 +++++----- include/linux/mtd/rawnand.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 65250308c82d..36048e0cf1f5 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -5178,15 +5178,15 @@ static int nand_flash_detect_onfi(struct nand_chip *chip) /* Check version */ val = le16_to_cpu(p->revision); - if (val & (1 << 5)) + if (val & ONFI_VERSION_2_3) chip->parameters.onfi.version = 23; - else if (val & (1 << 4)) + else if (val & ONFI_VERSION_2_2) chip->parameters.onfi.version = 22; - else if (val & (1 << 3)) + else if (val & ONFI_VERSION_2_1) chip->parameters.onfi.version = 21; - else if (val & (1 << 2)) + else if (val & ONFI_VERSION_2_0) chip->parameters.onfi.version = 20; - else if (val & (1 << 1)) + else if (val & ONFI_VERSION_1_0) chip->parameters.onfi.version = 10; if (!chip->parameters.onfi.version) { diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index ef7e3b4e91ea..015bc3f2fc13 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -230,6 +230,17 @@ enum nand_ecc_algo { /* Keep gcc happy */ struct nand_chip; +/* ONFI version bits */ +#define ONFI_VERSION_1_0 BIT(1) +#define ONFI_VERSION_2_0 BIT(2) +#define ONFI_VERSION_2_1 BIT(3) +#define ONFI_VERSION_2_2 BIT(4) +#define ONFI_VERSION_2_3 BIT(5) +#define ONFI_VERSION_3_0 BIT(6) +#define ONFI_VERSION_3_1 BIT(7) +#define ONFI_VERSION_3_2 BIT(8) +#define ONFI_VERSION_4_0 BIT(9) + /* ONFI features */ #define ONFI_FEATURE_16_BIT_BUS (1 << 0) #define ONFI_FEATURE_EXT_PARAM_PAGE (1 << 7) From patchwork Thu Jun 21 10:33:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 932674 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZoHAJtTX"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="EFYo4Teu"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BJ6M0TsJz9s1B for ; Thu, 21 Jun 2018 20:36:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dLZJ67i3fG/0tvBl0tylH6xkSLcxuQ5iQ+1b12fl1eI=; b=ZoHAJtTXj7C9wRZ7qrhg3aOoFP H5J3CGXs52lnHuysCFV1q0Fblm2S6DzZVfoAskY4FuCZhA6ar23RBANw/Gd4HytU85rZw7AOJWz2e iL2gcDur7xSQZN8A0RuFwMQ00/k1rvm7YbT5yXVf72gmXqh8Sv0ddQ6+jwydy0EnpF/FiPKqpx7Qh PA48xAXlw32SNktfaC+wqp102qJqjeVuPLLnoudtqVl+euA4g7zqNVIrS8SJXTUeFgVJISS8YWldg ufWbVVM7NpNN7I5wdn+tWqYbbg6Dx5P4j/ErNNXKyBWdP26/+aeDJhv8PqIq3Ozz/ao7oPtB8JVFG qiIlxC+g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwxO-0006TU-RN; Thu, 21 Jun 2018 10:36:50 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwv7-0003n7-EH for linux-mtd@lists.infradead.org; Thu, 21 Jun 2018 10:34:37 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id E58138448B; Thu, 21 Jun 2018 22:33:41 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1529577221; bh=27in9BDc+6o663iJCTmHaUlPBZJQglrLMC8IzFP6Xvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EFYo4Teu9VAUEnilOUzTdAa6/35EEk2hI4Y39XxBB55t/6tVsPz3mJHfGdkdi9I3/ JOaaHe7Ts2Es2oMxKrCe8OAGjcS10F2yppa2m5cwxkOHa14FMiLB0Z16zZn8kdfRN+ gQ5XikX0tpyatX5oqacHNGgGU7ItLplfzxGZYQD8= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 21 Jun 2018 22:33:42 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 752BF13EFB8; Thu, 21 Jun 2018 22:33:40 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 4258B1E2626; Thu, 21 Jun 2018 22:33:37 +1200 (NZST) From: Chris Packham To: miquel.raynal@bootlin.com, boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 4/6] mtd: rawnand: micron: add fixup for ONFI revision Date: Thu, 21 Jun 2018 22:33:26 +1200 Message-Id: <20180621103328.28206-5-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> References: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_033429_688450_4BE1B72D X-CRM114-Status: GOOD ( 12.73 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [202.36.163.20 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chris Packham , linux-kernel@vger.kernel.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some Micron NAND chips (MT29F1G08ABAFAWP-ITE:F) report 00 00 for the revision number field of the ONFI parameter page. Rather than rejecting these outright assume ONFI version 1.0 if the revision number is 00 00. Signed-off-by: Chris Packham Reviewed-by: Boris Brezillon --- This is now qualified on vendor == MICRON. I haven't qualified this based on specific chips the ABAFA (id=d1) and ABBFA (id=a1) variants are documented to have this behaviour. Changes in v2: - use fixup_onfi_param_page Changes in v3: - add code comment next to workaround Changes in v4: - use define for ONFI_VERSION drivers/mtd/nand/raw/nand_micron.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index 203faba0a9c1..d30bd4df9b12 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -290,6 +290,19 @@ static int micron_nand_init(struct nand_chip *chip) return 0; } +static void micron_fixup_onfi_param_page(struct nand_chip *chip, + struct nand_onfi_params *p) +{ + /* + * MT29F1G08ABAFAWP-ITE:F and possibly others report 00 00 for the + * revision number field of the ONFI parameter page. Assume ONFI + * version 1.0 if the revision number is 00 00. + */ + if (le16_to_cpu(p->revision) == 0) + p->revision = cpu_to_le16(ONFI_VERSION_1_0); +} + const struct nand_manufacturer_ops micron_nand_manuf_ops = { .init = micron_nand_init, + .fixup_onfi_param_page = micron_fixup_onfi_param_page, }; From patchwork Thu Jun 21 10:33:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 932671 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GysOLJaz"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="AYuZybFG"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BJ4T0BPfz9s1B for ; Thu, 21 Jun 2018 20:35:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gEBG6KF5VWIpoqOhRsDeub+hj7QGgkPpW3MIAyloRfg=; b=GysOLJazekxaymu0AAQN0AVCf/ aR+5TvoAJ08G4pU2EDZLHh7UxRZ83smwbsyr6alRmhbxE3W+yec5j6PCSFoUfFaQeODTABBPYt0Xd aQZZWO4P4Cf/vi+EqXCr5vZAKUWfvDRacGo4rOXBSJRGwikRRBut6Vf9G+e7SnkIsnNZA9IeSDCrX cWdbVD0n5c2MhUVKqp6J8xEK6ExJhYU982WZeQGx2ETEVnSN0TL1NFT9STvWdoaNuoVorn9xeUpba QGvHwIniXqgS2YIjxchXovAH9sDQKglobyK9zlS+EAy9xR6y2xqSv93g+LEuj/5gJK6xca4xDToEF Znk603yQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwvn-0004Ub-Hp; Thu, 21 Jun 2018 10:35:11 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwut-0003lS-Rl for linux-mtd@lists.infradead.org; Thu, 21 Jun 2018 10:34:19 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 6D0FE8365A; Thu, 21 Jun 2018 22:33:41 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1529577221; bh=1FHpdOz1S8wmGyZiSv8ykuwHpjR2OIkWG10yzzFVs/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AYuZybFGf5roX8thZOGugi8oZzC1IFLaoTIaS9cvuayXw8pTAUfyF0yb/oicfHPYy SlA66Fp+p/MSPaL2yUqoPYUHL7UxP5d9qZYpj8poYNM4532yU/xDEUnAg/uocFP/7T Oypy1JSrc1CbF4Rj9tFyG7SnwMNs/sp1JcRsd1XA= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 21 Jun 2018 22:33:41 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 8FBF213EFC4; Thu, 21 Jun 2018 22:33:40 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 5BDC71E2626; Thu, 21 Jun 2018 22:33:37 +1200 (NZST) From: Chris Packham To: miquel.raynal@bootlin.com, boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 5/6] mtd: rawnand: micron: support 8/512 on-die ECC Date: Thu, 21 Jun 2018 22:33:27 +1200 Message-Id: <20180621103328.28206-6-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> References: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_033416_262115_F774B4EA X-CRM114-Status: GOOD ( 15.95 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [202.36.163.20 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chris Packham , linux-kernel@vger.kernel.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Micron MT29F1G08ABAFAWP-ITE:F supports an on-die ECC with 8 bits per 512 bytes. Add support for this combination. Signed-off-by: Chris Packham --- Changes in v2: - New Changes in v3: - Handle reporting of corrected errors that don't require a rewrite, expand comment for the ECC status bits. Changes in v4: - Use a switch statement for handling ECC status - Update ecc_stats.corrected drivers/mtd/nand/raw/nand_micron.c | 68 ++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index d30bd4df9b12..f1ecd4986b50 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -18,10 +18,28 @@ #include /* - * Special Micron status bit that indicates when the block has been - * corrected by on-die ECC and should be rewritten + * Special Micron status bit 3 indicates that the block has been + * corrected by on-die ECC and should be rewritten. + * + * On chips with 8-bit ECC and additional bit can be used to distinguish + * cases where a errors were corrected without needing a rewrite + * + * Bit 4 Bit 3 Bit 0 Description + * ----- ----- ----- ----------- + * 0 0 0 No Errors + * 0 0 1 Multiple uncorrected errors + * 0 1 0 4 - 6 errors corrected, recommend rewrite + * 0 1 1 Reserved + * 1 0 0 1 - 3 errors corrected + * 1 0 1 Reserved + * 1 1 0 7 - 8 errors corrected, recommend rewrite */ -#define NAND_STATUS_WRITE_RECOMMENDED BIT(3) +#define NAND_STATUS_MASK (BIT(4) | BIT(3) | BIT(0)) +#define NAND_STATUS_NO_ERRORS 0 +#define NAND_STATUS_UNCORRECTABLE BIT(0) +#define NAND_STATUS_4_6_CORRECTED BIT(3) +#define NAND_STATUS_1_3_CORRECTED BIT(4) +#define NAND_STATUS_7_8_CORRECTED (BIT(4) | BIT(3)) struct nand_onfi_vendor_micron { u8 two_plane_read; @@ -137,18 +155,31 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip, if (ret) goto out; - if (status & NAND_STATUS_FAIL) { + /* + * The internal ECC doesn't tell us the number of bitflips + * that have been corrected, but tells us if it recommends to + * rewrite the block. If it's the case, then we pretend we had + * a number of bitflips equal to the ECC strength, which will + * hint the NAND core to rewrite the block. + */ + switch (status & NAND_STATUS_MASK) { + case NAND_STATUS_UNCORRECTABLE: mtd->ecc_stats.failed++; - } else if (status & NAND_STATUS_WRITE_RECOMMENDED) { - /* - * The internal ECC doesn't tell us the number of bitflips - * that have been corrected, but tells us if it recommends to - * rewrite the block. If it's the case, then we pretend we had - * a number of bitflips equal to the ECC strength, which will - * hint the NAND core to rewrite the block. - */ - mtd->ecc_stats.corrected += chip->ecc.strength; + break; + case NAND_STATUS_1_3_CORRECTED: + mtd->ecc_stats.corrected++; + max_bitflips = 1; + break; + case NAND_STATUS_4_6_CORRECTED: + mtd->ecc_stats.corrected += 4; + /* rewrite recommended */ + max_bitflips = chip->ecc.strength; + break; + case NAND_STATUS_7_8_CORRECTED: + mtd->ecc_stats.corrected += 7; + /* rewrite recommended */ max_bitflips = chip->ecc.strength; + break; } ret = nand_read_data_op(chip, buf, mtd->writesize, false); @@ -239,13 +270,6 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip) if (feature[0] & ONFI_FEATURE_ON_DIE_ECC_EN) return MICRON_ON_DIE_MANDATORY; - /* - * Some Micron NANDs have an on-die ECC of 4/512, some other - * 8/512. We only support the former. - */ - if (chip->ecc_strength_ds != 4) - return MICRON_ON_DIE_UNSUPPORTED; - return MICRON_ON_DIE_SUPPORTED; } @@ -275,9 +299,9 @@ static int micron_nand_init(struct nand_chip *chip) return -EINVAL; } - chip->ecc.bytes = 8; + chip->ecc.bytes = chip->ecc_strength_ds * 2; chip->ecc.size = 512; - chip->ecc.strength = 4; + chip->ecc.strength = chip->ecc_strength_ds; chip->ecc.algo = NAND_ECC_BCH; chip->ecc.read_page = micron_nand_read_page_on_die_ecc; chip->ecc.write_page = micron_nand_write_page_on_die_ecc; From patchwork Thu Jun 21 10:33:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 932672 X-Patchwork-Delegate: miquel.raynal@bootlin.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sCbm+Il6"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="hHHsXVil"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BJ5N1Hk8z9s1B for ; Thu, 21 Jun 2018 20:36:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=C0IP2zICFDI2+PxfuRUs+ob4MRzNZ1w2zT9M4g2vKbU=; b=sCbm+Il6hK9a/lF4+a9/cHSg7p sOnHOf28FtYEd/Mq0tCz/RsRG6EPF46S64cLhIdkHv7LE8UX6M26kIYCbk8MjNIUwKjfMjYbi4Zva iYiDJk9xVyQ+6NFZiouFuVtpU0B8IuFXzWwK5yikM4/CcU8HcHu99yw6eraW4rAlSGkIBC6ZwUiBM DbnYV4rMVLjipTwjQjyYnZZEb4bHIpeFoI/d9jJzDELX9nrSqfxHOf6t5MJSnkh5a36yFebgWz6Pu xNnyVgQovBe5fX/BD2d0gynLwPQsaqQxzfCREsyTInPsg69hIYfHBF70aQlPg00WaH0h/PDukiSVp Lt65hf3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwwV-0005wY-LA; Thu, 21 Jun 2018 10:35:55 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVwuw-0003lV-Kh for linux-mtd@lists.infradead.org; Thu, 21 Jun 2018 10:34:22 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 6FE0F8365F; Thu, 21 Jun 2018 22:33:41 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1529577221; bh=Ly2vYIasQ6ZPYVBRLDLrVaGhnS3D5anDj4miNCHHEq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hHHsXVil3l/w/UTxrgyMrvthVy86eeCWGL4wgjgSrCGQDO8u7pmet2Q/Cc70Fl4ZC mA87qzqMpOB41wF7uOnRHhnZYNbm98E84CiJlA3Asx5msY0+iRaaGdzuIj0XkaXA0Q t8ujIMq1u5wDccrTPjpD2xUfMd7ZQMiRmWAFlk9s= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 21 Jun 2018 22:33:41 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id A8A3B13EFC9; Thu, 21 Jun 2018 22:33:40 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 7468B1E2626; Thu, 21 Jun 2018 22:33:37 +1200 (NZST) From: Chris Packham To: miquel.raynal@bootlin.com, boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Subject: [PATCH v4 6/6] mtd: rawnand: micron: detect forced on-die ECC Date: Thu, 21 Jun 2018 22:33:28 +1200 Message-Id: <20180621103328.28206-7-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> References: <20180621103328.28206-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_033418_896913_8B3193E8 X-CRM114-Status: GOOD ( 14.26 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -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_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Chris Packham , linux-kernel@vger.kernel.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some Micron NAND chips have on-die ECC forceably enabled. The detect these based on chip ID as there seems to be no other way of distinguishing these chips from those that have optional support for on-die ECC. When a chip with mandatory on-die ECC is detected change the current ECC mode to on-die. Signed-off-by: Chris Packham --- I'm not convinced that just changing chip->ecc.mode is sensible. An alternative I considered was only proceeding if the ecc.mode is set to ON_DIE. Changes in v4: - New drivers/mtd/nand/raw/nand_micron.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c index f1ecd4986b50..9ba9007a9a06 100644 --- a/drivers/mtd/nand/raw/nand_micron.c +++ b/drivers/mtd/nand/raw/nand_micron.c @@ -227,6 +227,14 @@ enum { MICRON_ON_DIE_MANDATORY, }; +/* + * These parts are known to have on-die ECC forceably enabled + */ +static u8 micron_on_die_ecc[] = { + 0xd1, /* MT29F1G08ABAFA */ + 0xa1, /* MT29F1G08ABBFA */ +}; + /* * Try to detect if the NAND support on-die ECC. To do this, we enable * the feature, and read back if it has been enabled as expected. We @@ -241,6 +249,11 @@ static int micron_supports_on_die_ecc(struct nand_chip *chip) { u8 feature[ONFI_SUBFEATURE_PARAM_LEN] = { 0, }; int ret; + int i; + + for (i = 0; i < ARRAY_SIZE(micron_on_die_ecc); i++) + if (chip->id.data[1] == micron_on_die_ecc[i]) + return MICRON_ON_DIE_MANDATORY; if (!chip->parameters.onfi.version) return MICRON_ON_DIE_UNSUPPORTED; @@ -289,8 +302,8 @@ static int micron_nand_init(struct nand_chip *chip) ondie = micron_supports_on_die_ecc(chip); if (ondie == MICRON_ON_DIE_MANDATORY) { - pr_err("On-die ECC forcefully enabled, not supported\n"); - return -EINVAL; + pr_info("On-die ECC forcefully enabled\n"); + chip->ecc.mode = NAND_ECC_ON_DIE; } if (chip->ecc.mode == NAND_ECC_ON_DIE) {