Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5847744yba; Mon, 13 May 2019 19:17:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy2kHUpicU7jKrlWSZ1ePJxF8cPsSpp6+lbPo2Rvh2W52Ek9G439Tvl8HUsjMPoqeiRhZj X-Received: by 2002:a63:2d41:: with SMTP id t62mr35651614pgt.113.1557800247672; Mon, 13 May 2019 19:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557800247; cv=none; d=google.com; s=arc-20160816; b=cLlSesYGPCME99uR2vCEU+3NcJSeKYszivHyEr2IdAULyJDt/BoRmvyz3fnQ4LglGG Zxe350Wma47BzbmJTV8Cdc2cDoeB/cShnV+Q0fbhrfUOT5LIPkmKf86uiSdvtWSxt3gr xay8/bP2dwbrAtxgGTdTGjgIcDssJlzWvLpCDQ/Z3xfFmN3gIt8oSTooBvzE9xAO5WzO Oy4jMmuvg4n+X7LLg0/c/TtjzyAN9ZToaDnraFIx84iREuC++BaiitOkVZx7Mra5AgvS 4c2VyExut7takVgn2H/nKqP79xC6qiwc/NUTpzZAzCGotqfsV+2CCOEsZE8rC2wqUUel vhCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:from:message-id:mime-version:subject :cc:to:references:in-reply-to; bh=fsCWJZCqk91AxcyGuK0PbfaeT0QX0gXm6KA26SVJ9lE=; b=vuk1EsTOPI8ZF4VJVbJJI/1mFDxaRNHFfIEIkQiImneGQNHbfyjkItfriuAg5qqfat 4chyFmwBLl94qK63vR/uigrb6C07WiIiHXGYlBXOldGSQdTaxNtiOkEYbZ4FZLlS2tp4 GDufBfMT3LT1XN1b+xqKBwXPPk9NqpxvKIoVWuwByu4EjTDL4zvyqNBmCs8bKPx/Lmot aZIkkVqxhqGEBOZcwFoYJR6qhW9SYvYS/HNDg5elnO7ec7oHc8ENsd8cs0UlIwCsNMjC j7iLTBjsIjG54MOHH9PMKOIOBSmqsMDdQ6KBdZFP39Ub/kQ74yYeDp/4z+7F0uiTCRyC yVig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j22si19385414pfi.167.2019.05.13.19.17.10; Mon, 13 May 2019 19:17:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbfENCQQ (ORCPT + 99 others); Mon, 13 May 2019 22:16:16 -0400 Received: from twhmllg3.macronix.com ([211.75.127.131]:20511 "EHLO TWHMLLG3.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbfENCQQ (ORCPT ); Mon, 13 May 2019 22:16:16 -0400 Received: from twhfmlp1.macronix.com (twhfm1p1.macronix.com [172.17.20.91]) by TWHMLLG3.macronix.com with ESMTP id x4E2G96p098155; Tue, 14 May 2019 10:16:09 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) Received: from MXML06C.mxic.com.tw (mxml06c.macronix.com [172.17.14.55]) by Forcepoint Email with ESMTP id E5D371E015FA3816775F; Tue, 14 May 2019 10:16:09 +0800 (CST) In-Reply-To: <20190513115926.3e862566@xps13> References: <1557474062-4949-1-git-send-email-masonccyang@mxic.com.tw> <20190510094528.6008e8da@xps13> <20190510111121.54f42e70@xps13> <20190513115926.3e862566@xps13> To: "Miquel Raynal" Cc: bbrezillon@kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marek.vasut@gmail.com, richard@nod.at Subject: Re: [PATCH v1] mtd: rawnand: Add Macronix NAND read retry support MIME-Version: 1.0 X-KeepSent: C9B66DDF:FF9E0953-482583FA:000BD165; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.3FP4 SHF90 June 10, 2013 Message-ID: From: masonccyang@mxic.com.tw Date: Tue, 14 May 2019 10:16:09 +0800 X-MIMETrack: Serialize by Router on MXML06C/TAIWAN/MXIC(Release 9.0.1FP10 HF265|July 25, 2018) at 2019/05/14 AM 10:16:09, Serialize complete at 2019/05/14 AM 10:16:09 Content-Type: text/plain; charset="US-ASCII" X-MAIL: TWHMLLG3.macronix.com x4E2G96p098155 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Miquel, > > > > > > + > > > > > > + if (mxic->reliability_func & MACRONIX_READ_RETRY_BIT) { > > > > > > + chip->read_retries = MACRONIX_READ_RETRY_MODE + 1; > > > > > > > > > > Why +1 here, I am missing something? > > > > > > > > > > > > Without + 1, read retry mode is up to 4 rather than 5. > > > > But this NAND device support read retry mode up to 5. > > > > > > > > > > If there are 5 modes, you need to set 5 to chip->read_retries, not 6. > > > > > > If only 4 modes are used, there is probably a bug in the core that > > > must be fixed, please do not workaround it in the driver! > > > > > > It seems some patches is needed in nand_base.c > > ------------------------------------------------------------------------------------- > > diff --git a/drivers/mtd/nand/raw/nand_base.c > > b/drivers/mtd/nand/raw/nand_base.c > > index ddd396e..56be3a9 100644 > > --- a/drivers/mtd/nand/raw/nand_base.c > > +++ b/drivers/mtd/nand/raw/nand_base.c > > @@ -3101,7 +3101,8 @@ static int nand_setup_read_retry(struct nand_chip > > *chip, int retry_mode) > > { > > pr_debug("setting READ RETRY mode %d\n", retry_mode); > > > > - if (retry_mode >= chip->read_retries) > > + if (retry_mode > chip->read_retries) > > If I understand correctly, chip->read_retries is the total number of > 'modes' so the last valid mode is indeed chip->read_retries -1. > > I thought the problem would come from the core but I was wrong, you > actually need a MACRONIX_NUM_READ_RETRY_MODES set to 6. Please have two > defines if you need both (the first one being something like > MACRONIX_MAXIMUM_READ_RETRY_MODE set to 5). I have checked one of Micron's datasheet and it defined read-retry number = 8, mode 0 ~ 7, 0 mean to disable read-retry. Therefore, I will patch MACRONIX_NUM_READ_RETRY_MODES = 6. thanks & best regards, Mason CONFIDENTIALITY NOTE: This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation. Macronix International Co., Ltd. ===================================================================== ============================================================================ CONFIDENTIALITY NOTE: This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation. Macronix International Co., Ltd. =====================================================================