From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24821C25B74 for ; Thu, 16 May 2024 13:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=06LWJkiBtkKkZglzm6yyl+UWpfvoqr6madAMIu1rrag=; b=oJNtL9zj08QKG/ B+WUovKUdXcoSbiiZ6M5azoSG3pUrEmyAO1Pk/IwoIwY8pDaSVPScEyIoFvOpixW6yMTMqodRH5g8 lXnR0spyh2UI2U+NrO6MzCTEuhLs7Pd904iqzYbgOREbs8Ak8wDqaNoEzslD7E+tjkFlBFE0jilIE xnJ76iVgOOMg50wDBGUtt5JqULl+LLyOap/F+dTyCw1UkagpC797jSDN30hZAQzbB0Wr9ifnjIXdV bOz1Kj8jMvTj0CPGb7Kj8AxMh4mfxmgz+9SEh2NVQ2FX0XFsovpWeFdNZJNi/nXRiomlhIXnUKjIg tw1XOs/ZV3zwOQZtDgow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7bWp-000000054XJ-3hwp; Thu, 16 May 2024 13:52:15 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7bWl-000000054Vn-0P7p for linux-mtd@lists.infradead.org; Thu, 16 May 2024 13:52:14 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s7bWR-0000gt-PM; Thu, 16 May 2024 15:51:51 +0200 Received: from [2a0a:edc0:2:b01:1d::c5] (helo=pty.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s7bWP-001iuT-RM; Thu, 16 May 2024 15:51:49 +0200 Received: from sha by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1s7bWP-00EtSv-2Q; Thu, 16 May 2024 15:51:49 +0200 Date: Thu, 16 May 2024 15:51:49 +0200 From: Sascha Hauer To: Miquel Raynal Cc: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus , Pratyush Yadav , Michael Walle , linux-mtd@lists.infradead.org, Alexander Dahl , Steven Seeger , Thomas Petazzoni , stable@vger.kernel.org Subject: Re: [PATCH v2 2/2] mtd: rawnand: Bypass a couple of sanity checks during NAND identification Message-ID: References: <20240516131320.579822-1-miquel.raynal@bootlin.com> <20240516131320.579822-3-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240516131320.579822-3-miquel.raynal@bootlin.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_065211_259810_CD8B7FB0 X-CRM114-Status: GOOD ( 24.40 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On Thu, May 16, 2024 at 03:13:20PM +0200, Miquel Raynal wrote: > Early during NAND identification, mtd_info fields have not yet been > initialized (namely, writesize and oobsize) and thus cannot be used for > sanity checks yet. Of course if there is a misuse of > nand_change_read_column_op() so early we won't be warned, but there is > anyway no actual check to perform at this stage as we do not yet know > the NAND geometry. > > So, if the fields are empty, especially mtd->writesize which is *always* > set quite rapidly after identification, let's skip the sanity checks. > > nand_change_read_column_op() is subject to be used early for ONFI/JEDEC > identification in the very unlikely case of: > - bitflips appearing in the parameter page, > - the controller driver not supporting simple DATA_IN cycles. > > As nand_change_read_column_op() uses nand_fill_column_cycles() the logic > explaind above also applies in this secondary helper. > > Fixes: c27842e7e11f ("mtd: rawnand: onfi: Adapt the parameter page read to constraint controllers") > Fixes: daca31765e8b ("mtd: rawnand: jedec: Adapt the parameter page read to constraint controllers") > Cc: stable@vger.kernel.org > Reported-by: Alexander Dahl > Closes: https://lore.kernel.org/linux-mtd/20240306-shaky-bunion-d28b65ea97d7@thorsis.com/ > Reported-by: Steven Seeger > Closes: https://lore.kernel.org/linux-mtd/DM6PR05MB4506554457CF95191A670BDEF7062@DM6PR05MB4506.namprd05.prod.outlook.com/ > Signed-off-by: Miquel Raynal With the attached debug patch applied I can confirm that I can now read all three ONFI parameter pages successfully using nand_change_read_column_op(), so: Tested-by: Sascha Hauer Sascha -----------------------------------8<-------------------------------------- diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c index 861975e44b552..ca6b4bf426750 100644 --- a/drivers/mtd/nand/raw/nand_onfi.c +++ b/drivers/mtd/nand/raw/nand_onfi.c @@ -180,6 +180,9 @@ int nand_onfi_detect(struct nand_chip *chip) ret = nand_change_read_column_op(chip, sizeof(*pbuf) * i, &pbuf[i], sizeof(*pbuf), true); + + print_hex_dump(KERN_INFO, "onfi: ", DUMP_PREFIX_OFFSET, 16, 1, &pbuf[i], sizeof(*pbuf), true); + if (ret) { ret = 0; goto free_onfi_param_page; @@ -188,7 +191,6 @@ int nand_onfi_detect(struct nand_chip *chip) crc = onfi_crc16(ONFI_CRC_BASE, (u8 *)&pbuf[i], 254); if (crc == le16_to_cpu(pbuf[i].crc)) { p = &pbuf[i]; - break; } } -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/