From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3BFE3AA1BD for ; Tue, 3 Feb 2026 14:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770129619; cv=none; b=fWTiiib6ZeHlDL75aw4inl78lFa3UIf4NTuQ+qAQ7aez3XhiMHFMfa9KCZ3Cesi9XlZIF8q8aZItnQ4DgqrGBvAbwaVPoO1sTGcNb8JaQaL+Uj5dMAkzL02ssnqPLKzn6v+0PwK2e1R7IZOUBxBEmIe4FWSBRsqUUkU5RCuYKw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770129619; c=relaxed/simple; bh=n9ukpAw81wAOjVoEqI8WqBOEjzre12hJOXxiuwRSXbU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=VtB+jQ5KaokqduhnQuEXcHSpUZ/GG4IA0B7021Ex4WO7y8BGDFlsgsohqVDlcWwcmOunzzURpUeb405SRskaOpio5oH0Je+gFUjLr89NPemhvHHRkT66RgoVLlfqQI/CruBp0HI/81FprClG90bnkvICB43+3ejIo8HkLGpsnVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=TmpOlWh7; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="TmpOlWh7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 6A190C211FF; Tue, 3 Feb 2026 14:40:19 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 22A4560728; Tue, 3 Feb 2026 14:40:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E65F6119A8888; Tue, 3 Feb 2026 15:40:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770129613; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=UxGr7oSFz0Iu/FRUMPlLMzfCGWOGWIwE1/BwPQKeYIo=; b=TmpOlWh77GlyPb5TfgMy4MkmIJRrXyou2xA1Ic4vTDfd19BZWOHmBsLQ4el/hKIBJuhEfj 7XJ4T+bNtv6py44llJm0LlffT/vgloH2cmARXYiD801h4XSnxnaJVZVDUHCVMuFNgQjqHh UeZAZe3D8tHol3Lm0Z6v1k29RIowrd9YZZ6BtRq0RIIT54P8oyM4hyViyd90vj6cugMdtW WYTPyQLdbvdNCRUyjvLXbsiCbGLkOTMBZqIcGN26bABmi2qR0CSfNrkCwUQRgj9tbUvooR OpJXd7wDY7y0hkHAcvuLSbkXEix1HPd/CgioxhXbNB5JneUv6x1jqjZ0DXlotw== From: Miquel Raynal To: Cheng Ming Lin Cc: Vignesh Raghavendra , Richard Weinberger , Tudor Ambarus , Martin Kurbanov , Mikhail Kshevetskiy , Pratyush Yadav , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, alvinzhou@mxic.com.tw, Cheng Ming Lin Subject: Re: [PATCH v4 1/2] mtd: spi-nand: Add support for randomizer In-Reply-To: <20260203021358.693291-2-linchengming884@gmail.com> (Cheng Ming Lin's message of "Tue, 3 Feb 2026 10:13:57 +0800") References: <20260203021358.693291-1-linchengming884@gmail.com> <20260203021358.693291-2-linchengming884@gmail.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Tue, 03 Feb 2026 15:40:09 +0100 Message-ID: <87ecn1hovq.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hello Cheng Ming, On 03/02/2026 at 10:13:57 +08, Cheng Ming Lin w= rote: > From: Cheng Ming Lin > > This patch adds support for the randomizer feature. > > It introduces a 'set_randomizer' callback in 'struct spinand_info' and > 'struct spinand_device'. > > If a driver implements this callback, the core will call it during > device initialization (spinand_init) to enable the randomizer. I recently had a request regarding the sunxi controller driver randomizer. I would like to get back to having a nand wide randomizer DT property, because a Macronix specific value honestly no longer makes sense. Randomizers have been there for ages, they are not so often used because scrambling data is not convenient for developers but they may have a real interest depending on the NAND chip or the external conditions. We will need two mutually exclusive optional properties in nand-chip.yaml: nand-enable-randomizer; nand-disable-randomizer; BTW, where is the patch adding the property to the bindings? Did we already merge it? I do not find it anymore. Looking at the current implementation, I really don't like the core always calling in the "init" and the manufacturer driver reading the DT and deciding whether or not it enables it. > Signed-off-by: Cheng Ming Lin > --- > drivers/mtd/nand/spi/core.c | 23 +++++++++++++++++++++++ > include/linux/mtd/spinand.h | 9 +++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c > index d207286572d8..4f8ff94f5ccc 100644 > --- a/drivers/mtd/nand/spi/core.c > +++ b/drivers/mtd/nand/spi/core.c > @@ -206,6 +206,12 @@ static int spinand_cont_read_enable(struct spinand_d= evice *spinand, > return spinand->set_cont_read(spinand, enable); > } >=20=20 > +static int spinand_randomizer_enable(struct spinand_device *spinand, > + bool enable) > +{ > + return spinand->set_randomizer(spinand, enable); This helper seems mostly useless. > +} > + > static int spinand_check_ecc_status(struct spinand_device *spinand, u8 s= tatus) > { > struct nand_device *nand =3D spinand_to_nand(spinand); > @@ -1218,6 +1224,19 @@ static int spinand_create_dirmaps(struct spinand_d= evice *spinand) > return 0; > } >=20=20 > +static int spinand_randomizer_init(struct spinand_device *spinand) > +{ > + int ret; > + > + if (spinand->set_randomizer) { > + ret =3D spinand_randomizer_enable(spinand, true); Please directly call the hook. Given the previous feedback, you should change "true" to be based on the presence of the DT property. > + if (ret) > + return ret; > + } > + > + return 0; > +} Rest LGTM. Thanks, Miqu=C3=A8l