Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4304972ybp; Mon, 14 Oct 2019 02:28:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxytoloLn5dRqUC42V5PJA3GyFHRqUqMvc+kETG43Vv9g+r0nq6JzmzJilv057uvOFrG3/h X-Received: by 2002:a17:906:c4f:: with SMTP id t15mr27249021ejf.293.1571045337756; Mon, 14 Oct 2019 02:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571045337; cv=none; d=google.com; s=arc-20160816; b=l6shjDnh9KpproxlNO5vSpVPsi64ArAxi8wdsD5BzMGZPPYOK6TLLxMj0BdzLq3zit MEHfz10g0srb5n0ejiUUq+Oq7Sa1/jOdVL6sgso86BuLzPA9qP95ZoxhH/EH/77gJuqP Rc67PSiw+IUFOxbUmJLXvG1rC7tYYiR/UIT5w/wC6LodD9YKNU6t/z4S/r4uiRYol0Yl Tc1+4rN2DUzCDqZSs62TtK3xt/crB1//0bXibBiBT0wqcp414SWidEd4su5bqFDmjWTh 0C8JJz9A1qWZ3UkXqHUzI+434UgXYeipF0rIJjdFi8CAyjD6aPJEvtnNWnN+uJQYmo2q IOiA== 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=JLTdwijP6WrVLM4LabWjg2a3p42ay7twP9/r7lHg0tI=; b=GN7dKTEiOWKLApbvDvrYcGVxvc1YEq9Z6mjnwre9xFWFdoHaroILH1Y6D+H+CzRW15 qFR3gmOXKl9yYwKFBV/KY/NPIFS+igPWEZVFFxV2M5QqCANd7Ao4sUMOt+E9WHuDYZLx 9x8h6G4+CiTI8Katw+i5de6jouT8KKvKabxy2Fe5jsK8FkRT9+mMbOBhRD5MFMLBm0tK 4OPPdcmY4ElkXmbZViTTqomeab8lY+n8A0k2zEDx7FNOQTEabj9D2JaLLHTY5rXTx7HS KW7aFTA3BXinpOmcHrjU1//iEXerNAbAHoy8lqkulYiwzXu99v7fExsP/eRQPopyw7s9 bzjg== 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 nl6si10483119ejb.207.2019.10.14.02.28.34; Mon, 14 Oct 2019 02:28:57 -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 S1730756AbfJNJ1d (ORCPT + 99 others); Mon, 14 Oct 2019 05:27:33 -0400 Received: from twhmllg3.macronix.com ([122.147.135.201]:10096 "EHLO TWHMLLG3.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730667AbfJNJ1d (ORCPT ); Mon, 14 Oct 2019 05:27:33 -0400 Received: from twhfmlp1.macronix.com (twhfm1p1.macronix.com [172.17.20.91]) by TWHMLLG3.macronix.com with ESMTP id x9E9RL0C077829; Mon, 14 Oct 2019 17:27:21 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) Received: from MXML06C.mxic.com.tw (mxml06c.mxic.com.tw [172.17.14.55]) by Forcepoint Email with ESMTP id 6E969CCCFD0F074FFBBA; Mon, 14 Oct 2019 17:27:21 +0800 (CST) In-Reply-To: <20191007101847.7fcfcfc7@xps13> References: <1567676229-23414-1-git-send-email-masonccyang@mxic.com.tw> <20191007101847.7fcfcfc7@xps13> To: "Miquel Raynal" Cc: bbrezillon@kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org, frieder.schrempf@kontron.de, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, marek.vasut@gmail.com, richard@nod.at, tglx@linutronix.de, vigneshr@ti.com Subject: Re: [PATCH v3] mtd: rawnand: Add support for Macronix NAND randomizer MIME-Version: 1.0 X-KeepSent: F66743F5:5B74B775-48258493:003332F7; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.3FP4 SHF90 June 10, 2013 Message-ID: From: masonccyang@mxic.com.tw Date: Mon, 14 Oct 2019 17:27:22 +0800 X-MIMETrack: Serialize by Router on MXML06C/TAIWAN/MXIC(Release 9.0.1FP10 HF265|July 25, 2018) at 2019/10/14 PM 05:27:21, Serialize complete at 2019/10/14 PM 05:27:21 Content-Type: text/plain; charset="US-ASCII" X-MAIL: TWHMLLG3.macronix.com x9E9RL0C077829 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Miquel, > > changelog > > v3: > > To enable randomizer by specific DT property in children nodes, > > mxic,enable-randomizer-otp; > > > > v2: > > To enable randomizer by checking chip options NAND_NO_SUBPAGE_WRITE > > > > v1: > > To enable randomizer by sys-fs > > > > Signed-off-by: Mason Yang > > --- > > drivers/mtd/nand/raw/nand_macronix.c | 64 ++++++++++++++++++++++++++++++++++++ > > As long as you modify bindings, you should write a separate patch to > update the documentation and get it acked by Rob Herring. Do you mean I have to create a new device tree binding file by nand_macronix.txt for raw NAND device ? > > > 1 file changed, 64 insertions(+) > > > > diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/ > nand_macronix.c > > index 58511ae..d5df09a 100644 > > --- a/drivers/mtd/nand/raw/nand_macronix.c > > +++ b/drivers/mtd/nand/raw/nand_macronix.c > > @@ -11,6 +11,13 @@ > > #define MACRONIX_READ_RETRY_BIT BIT(0) > > #define MACRONIX_NUM_READ_RETRY_MODES 6 > > > > +#define MACRONIX_RANDOMIZER_BIT BIT(1) > > +#define ONFI_FEATURE_ADDR_MXIC_RANDOMIZER 0xB0 > > +#define MACRONIX_RANDOMIZER_ENPGM BIT(0) > > +#define MACRONIX_RANDOMIZER_RANDEN BIT(1) > > +#define MACRONIX_RANDOMIZER_RANDOPT BIT(2) > > +#define MACRONIX_RANDOMIZER_MODE_EXIT ~MACRONIX_RANDOMIZER_ENPGM > > I would rather prefer a > > #define ...RANDOMISER_MODE_ENTER (ENGPM | RANDEN | RANDOPT) > #define ...RANDOMISER_MODE_EXIT (RANDEN | RANDOPT) > okay. > > + > > struct nand_onfi_vendor_macronix { > > u8 reserved; > > u8 reliability_func; > > @@ -29,15 +36,72 @@ static int macronix_nand_setup_read_retry(struct > nand_chip *chip, int mode) > > return nand_set_features(chip, ONFI_FEATURE_ADDR_READ_RETRY, feature); > > } > > > > +static void macronix_nand_randomizer_check_enable(struct nand_chip *chip) > > You should return something and check it from the calling function. okay, will fix it. > > > +{ > > + u8 feature[ONFI_SUBFEATURE_PARAM_LEN]; > > + int ret; > > + > > + ret = nand_get_features(chip, ONFI_FEATURE_ADDR_MXIC_RANDOMIZER, > > + feature); > > + if (feature[0]) { > > + pr_info("Macronix NAND randomizer enabled:0x%x\n", feature[0]); > > + return; > > + } > > + > > + feature[0] = MACRONIX_RANDOMIZER_ENPGM | MACRONIX_RANDOMIZER_RANDEN | > > + MACRONIX_RANDOMIZER_RANDOPT; > > + ret = nand_set_features(chip, ONFI_FEATURE_ADDR_MXIC_RANDOMIZER, > > + feature); > > + if (ret) > > + goto err; > > + > > + feature[0] = 0x0; > > + ret = nand_prog_page_op(chip, 0, 0, feature, 1); > > What is this? A comment is needed. it's needed for a OTP bit programming flow. > > > + if (ret) > > + goto err; > > + > > + ret = nand_get_features(chip, ONFI_FEATURE_ADDR_MXIC_RANDOMIZER, > > + feature); > > + if (ret) > > + goto err; > > + > > + feature[0] &= MACRONIX_RANDOMIZER_MODE_EXIT; > > + ret = nand_set_features(chip, ONFI_FEATURE_ADDR_MXIC_RANDOMIZER, > > + feature); > > + if (ret) > > + goto err; > > + > > + pr_info("Macronix NAND randomizer enable ok\n"); > > The pr_info "ok" could be dropped, the "failed" one would go in > nand_onfi_init() after a check on the return code. > > Then, no more goto's. got it, will fix it. thanks for your time and comments. 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. =====================================================================