From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Cheng Ming Lin <linchengming884@gmail.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Richard Weinberger <richard@nod.at>,
Tudor Ambarus <tudor.ambarus@linaro.org>,
Martin Kurbanov <mmkurbanov@salutedevices.com>,
Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
Pratyush Yadav <pratyush@kernel.org>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
alvinzhou@mxic.com.tw, Cheng Ming Lin <chengminglin@mxic.com.tw>
Subject: Re: [PATCH v4 1/2] mtd: spi-nand: Add support for randomizer
Date: Tue, 03 Feb 2026 15:40:09 +0100 [thread overview]
Message-ID: <87ecn1hovq.fsf@bootlin.com> (raw)
In-Reply-To: <20260203021358.693291-2-linchengming884@gmail.com> (Cheng Ming Lin's message of "Tue, 3 Feb 2026 10:13:57 +0800")
Hello Cheng Ming,
On 03/02/2026 at 10:13:57 +08, Cheng Ming Lin <linchengming884@gmail.com> wrote:
> From: Cheng Ming Lin <chengminglin@mxic.com.tw>
>
> 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 <chengminglin@mxic.com.tw>
> ---
> 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_device *spinand,
> return spinand->set_cont_read(spinand, enable);
> }
>
> +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 status)
> {
> struct nand_device *nand = spinand_to_nand(spinand);
> @@ -1218,6 +1224,19 @@ static int spinand_create_dirmaps(struct spinand_device *spinand)
> return 0;
> }
>
> +static int spinand_randomizer_init(struct spinand_device *spinand)
> +{
> + int ret;
> +
> + if (spinand->set_randomizer) {
> + ret = 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èl
next prev parent reply other threads:[~2026-02-03 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 2:13 [PATCH v4 0/2] mtd: spi-nand: Add support for randomizer feature Cheng Ming Lin
2026-02-03 2:13 ` [PATCH v4 1/2] mtd: spi-nand: Add support for randomizer Cheng Ming Lin
2026-02-03 14:40 ` Miquel Raynal [this message]
2026-02-04 1:47 ` Cheng Ming Lin
2026-02-04 8:33 ` Miquel Raynal
2026-02-03 2:13 ` [PATCH v4 2/2] mtd: spi-nand: macronix: Enable randomizer support Cheng Ming Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ecn1hovq.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=alvinzhou@mxic.com.tw \
--cc=chengminglin@mxic.com.tw \
--cc=linchengming884@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=mmkurbanov@salutedevices.com \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox