Skip to contentSkip to conversation

Add support for randomizer

PATCH Superseded Cheng Ming Lin 2 participants 11 messages Aug 8, 2025 – Sep 5, 2025

Subsystems (2)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

cover Add support for randomizer

From: Cheng Ming Lin <[email protected]>

Enable randomizer support for high-reliability.

Cheng Ming Lin (2):
mtd: spi-nand: Add support for randomizer
mtd: spi-nand: macronix: Add randomizer support

 drivers/mtd/nand/spi/core.c     | 18 +++++++
 drivers/mtd/nand/spi/macronix.c | 94 +++++++++++++++++++++++++++++----
 include/linux/mtd/spinand.h     |  7 +++
 3 files changed, 109 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 mtd: spi-nand: Add support for randomizer

From: Cheng Ming Lin <[email protected]>

Add randomizer operation support for user data scrambling.

For more high-reliability concern, if subpage write not available with hardware ECC and then to enable randomizer is recommended by default.

---
 drivers/mtd/nand/spi/core.c | 18 ++++++++++++++++++
 include/linux/mtd/spinand.h |  7 +++++++
 2 files changed, 25 insertions(+)
drivers/mtd/nand/spi/core.c +18 -0
index b0898990b2a5..43ed5de282c5 100644
@@ -854,6 +854,19 @@ static void spinand_cont_read_init(struct spinand_device *spinand)
 	}
 }
 
+static int spinand_randomizer_init(struct spinand_device *spinand)
+{
+	int ret;
+
+	if (spinand->set_randomizer) {
+		ret = spinand->set_randomizer(spinand);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static bool spinand_use_cont_read(struct mtd_info *mtd, loff_t from,
 				  struct mtd_oob_ops *ops)
 {
@@ -1366,6 +1379,7 @@ int spinand_match_and_init(struct spinand_device *spinand,
 		spinand->user_otp = &table[i].user_otp;
 		spinand->read_retries = table[i].read_retries;
 		spinand->set_read_retry = table[i].set_read_retry;
+		spinand->set_randomizer = table[i].set_randomizer;
 
 		op = spinand_select_op_variant(spinand,
 					       info->op_variants.read_cache);
@@ -1543,6 +1557,10 @@ static int spinand_init(struct spinand_device *spinand)
 	 */
 	spinand_cont_read_init(spinand);
 
+	ret = spinand_randomizer_init(spinand);
+	if (ret)
+		goto err_cleanup_ecc_engine;
+
 	mtd->_read_oob = spinand_mtd_read;
 	mtd->_write_oob = spinand_mtd_write;
 	mtd->_block_isbad = spinand_mtd_block_isbad;
include/linux/mtd/spinand.h +7 -0
index 27a45bdab7ec..80a5c6ac6cc5 100644
@@ -499,6 +499,7 @@ struct spinand_user_otp {
  * @user_otp: SPI NAND user OTP info.
  * @read_retries: the number of read retry modes supported
  * @set_read_retry: enable/disable read retry for data recovery
+ * @set_randomizer: enable randomizer
  *
  * Each SPI NAND manufacturer driver should have a spinand_info table
  * describing all the chips supported by the driver.
@@ -525,6 +526,7 @@ struct spinand_info {
 	unsigned int read_retries;
 	int (*set_read_retry)(struct spinand_device *spinand,
 			     unsigned int read_retry);
+	int (*set_randomizer)(struct spinand_device *spinand);
 };
 
 #define SPINAND_ID(__method, ...)					\
@@ -578,6 +580,9 @@ struct spinand_info {
 	.read_retries = __read_retries,					\
 	.set_read_retry = __set_read_retry
 
+#define SPINAND_RANDOMIZER(__set_randomizer)				\
+	.set_randomizer = __set_randomizer
+
 #define SPINAND_INFO(__model, __id, __memorg, __eccreq, __op_variants,	\
 		     __flags, ...)					\
 	{								\
@@ -633,6 +638,7 @@ struct spinand_dirmap {
  * @user_otp: SPI NAND user OTP info.
  * @read_retries: the number of read retry modes supported
  * @set_read_retry: Enable/disable the read retry feature
+ * @set_randomizer: Enable the randomizer feature
  */
 struct spinand_device {
 	struct nand_device base;
@@ -673,6 +679,7 @@ struct spinand_device {
 	unsigned int read_retries;
 	int (*set_read_retry)(struct spinand_device *spinand,
 			     unsigned int retry_mode);
+	int (*set_randomizer)(struct spinand_device *spinand);
 };
 
 /**
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 1/2] mtd: spi-nand: Add support for randomizer

Hi Cheng Ming,

Quoted 6 lines · Cheng Ming Lin

From: Cheng Ming Lin <[email protected]>

Add randomizer operation support for user data scrambling.

For more high-reliability concern, if subpage write not available with hardware ECC and then to enable randomizer is recommended by default.

Could we adopt a helper that allows to enable and disable the randomizer?

I have no use case in mind right now, but I feel like it would be a better approach.

Thanks,
Miquèl

#3 lore raw

Re: [PATCH 1/2] mtd: spi-nand: Add support for randomizer

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月8日 週五 下午6:15寫道:

Quoted 7 lines

Hi Cheng Ming,

Quoted 2 lines · Cheng Ming Lin

From: Cheng Ming Lin <[email protected]>

Quoted 7 lines
Quoted 4 lines

Add randomizer operation support for user data scrambling.

For more high-reliability concern, if subpage write not available with hardware ECC and then to enable randomizer is recommended by default.

Could we adopt a helper that allows to enable and disable the randomizer?

I understand the idea, but from the flash’s perspective, once the randomizer is enabled, it’s generally not intended to be disabled. So I feel that providing a disable option might not be meaningful in this case.

Quoted 6 lines

I have no use case in mind right now, but I feel like it would be a better approach.

Thanks,
Miquèl

Thanks,
Cheng Ming Lin

#4 lore raw

PATCH 2/2 mtd: spi-nand: macronix: Add randomizer support

In reply to Cheng Ming Lin

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

---
 drivers/mtd/nand/spi/macronix.c | 94 +++++++++++++++++++++++++++++----
 1 file changed, 84 insertions(+), 10 deletions(-)
drivers/mtd/nand/spi/macronix.c +84 -10
index edf63b9996cf..5354b1894bb4 100644
@@ -14,6 +14,10 @@
 #define MACRONIX_ECCSR_BF_LAST_PAGE(eccsr) FIELD_GET(GENMASK(3, 0), eccsr)
 #define MACRONIX_ECCSR_BF_ACCUMULATED_PAGES(eccsr) FIELD_GET(GENMASK(7, 4), eccsr)
 #define MACRONIX_CFG_CONT_READ         BIT(2)
+#define MACRONIX_CFG_ENPGM BIT(0)
+#define MACRONIX_CFG_RANDEN BIT(1)
+#define MACRONIX_CFG_RANDOPT BIT(2)
+#define MACRONIX_FEATURE_ADDR_RANDOMIZER 0x10
 #define MACRONIX_FEATURE_ADDR_READ_RETRY 0x70
 #define MACRONIX_NUM_READ_RETRY_MODES 5
 
@@ -155,6 +159,66 @@ static int macronix_set_read_retry(struct spinand_device *spinand,
 	return spi_mem_exec_op(spinand->spimem, &op);
 }
 
+static int macronix_set_randomizer(struct spinand_device *spinand)
+{
+	struct spi_mem_op exec_op = SPINAND_PROG_EXEC_1S_1S_0_OP(0);
+	struct mtd_info *mtd = spinand_to_mtd(spinand);
+	struct nand_device *nand = mtd_to_nanddev(mtd);
+	struct device_node *dn = nanddev_get_of_node(nand);
+	int rand_dt, randopt, ret;
+	u8 cfg, status, check;
+
+	rand_dt = of_property_read_bool(dn, "mxic,enable-randomizer-otp");
+	if (!rand_dt)
+		return 0;
+
+	ret = spinand_read_reg_op(spinand, MACRONIX_FEATURE_ADDR_RANDOMIZER, &cfg);
+	if (ret)
+		return ret;
+	if (cfg)
+		return 0;
+
+	cfg = MACRONIX_CFG_ENPGM | MACRONIX_CFG_RANDEN;
+	randopt = of_property_read_bool(dn, "mxic,randopt");
+	if (randopt)
+		cfg |=  MACRONIX_CFG_RANDOPT;
+
+	ret = spinand_write_reg_op(spinand, MACRONIX_FEATURE_ADDR_RANDOMIZER, cfg);
+	if (ret)
+		return ret;
+
+	ret = spinand_write_enable_op(spinand);
+	if (ret)
+		return ret;
+
+	ret = spi_mem_exec_op(spinand->spimem, &exec_op);
+	if (ret)
+		return ret;
+
+	ret = spinand_wait(spinand,
+			   SPINAND_WRITE_INITIAL_DELAY_US,
+			   SPINAND_WRITE_POLL_DELAY_US,
+			   &status);
+	if (ret)
+		return ret;
+
+	if (status & STATUS_PROG_FAILED)
+		return -EIO;
+
+	ret = spinand_read_reg_op(spinand, MACRONIX_FEATURE_ADDR_RANDOMIZER, &check);
+	if (ret)
+		return ret;
+	if (check != cfg)
+		return -EIO;
+
+	cfg &= ~MACRONIX_CFG_ENPGM;
+	ret = spinand_write_reg_op(spinand, MACRONIX_FEATURE_ADDR_RANDOMIZER, cfg);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static const struct spinand_info macronix_spinand_table[] = {
 	SPINAND_INFO("MX35LF1GE4AB",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x12),
@@ -213,7 +277,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_HAS_QE_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35LF2G24AD",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24, 0x03),
 		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
@@ -225,7 +290,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_HAS_PROG_PLANE_SELECT_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35LF2G24AD-Z4I8",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x64, 0x03),
 		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
@@ -236,7 +302,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_HAS_QE_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35LF4G24AD",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35, 0x03),
 		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1),
@@ -248,7 +315,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_HAS_PROG_PLANE_SELECT_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35LF4G24AD-Z4I8",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x75, 0x03),
 		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
@@ -259,7 +327,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_HAS_QE_BIT,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX31LF1GE4BC",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x1e),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
@@ -305,7 +374,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     macronix_ecc_get_status),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35UF4G24AD-Z4I8",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xf5, 0x03),
 		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
@@ -317,7 +387,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     macronix_ecc_get_status),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35UF4GE4AD",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xb7, 0x03),
 		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
@@ -355,7 +426,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     macronix_ecc_get_status),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35UF2G24AD-Z4I8",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xe4, 0x03),
 		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
@@ -367,7 +439,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     macronix_ecc_get_status),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35UF2GE4AD",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xa6, 0x03),
 		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
@@ -413,7 +486,8 @@ static const struct spinand_info macronix_spinand_table[] = {
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     macronix_ecc_get_status),
 		     SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
-					macronix_set_read_retry)),
+					macronix_set_read_retry),
+			 SPINAND_RANDOMIZER(macronix_set_randomizer)),
 	SPINAND_INFO("MX35UF1GE4AD",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x96, 0x03),
 		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
Signature · 1 line
2.25.1
maintainer
#5 lore raw

Re: [PATCH 2/2] mtd: spi-nand: macronix: Add randomizer support

Quoted 10 lines · Cheng Ming Lin

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

Can we create a global NAND DT property for that? Enabling a randomizer is quite a generic step.

Quoted 3 lines

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

Do you want to share what is the added value in terms of lifetime to enable the randomizer, given the drawbacks which are significant?

Thanks,
Miquèl

#6 lore raw

Re: [PATCH 2/2] mtd: spi-nand: macronix: Add randomizer support

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月8日 週五 下午6:19寫道:

Quoted 8 lines · Cheng Ming Lin
Quoted 6 lines

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Quoted 8 lines
Quoted 5 lines

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

Can we create a global NAND DT property for that? Enabling a randomizer is quite a generic step.

Sure, I agree. I’ll update it to use a global NAND DT property.

Quoted 7 lines
Quoted 4 lines

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

Do you want to share what is the added value in terms of lifetime to enable the randomizer, given the drawbacks which are significant?

Thanks for the question. I’ll describe the benefits once I’ve finished organizing and reviewing our data.

Quoted 3 lines

Thanks,
Miquèl

Thanks,
Cheng Ming Lin

#7 lore raw

Re: [PATCH 2/2] mtd: spi-nand: macronix: Add randomizer support

In reply to Miquel Raynal

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月8日 週五 下午6:19寫道:

Quoted 17 lines · Cheng Ming Lin
Quoted 11 lines

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

Can we create a global NAND DT property for that? Enabling a randomizer is quite a generic step.

Quoted 6 lines
Quoted 3 lines

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

Do you want to share what is the added value in terms of lifetime to enable the randomizer, given the drawbacks which are significant?

The randomizer mainly targets extremely unbalanced data patterns, which might potentially lead to data errors.

Please refer to the attached document:
https://www.mxic.com.tw/Lists/ApplicationNote/Attachments/2151/AN1051V1-The%20Introduction%20of%20Randomizer%20Feature%20on%20MX30xFxG28AD_MX35xFxG24AD.pdf

Figure 1 shows that continuously programming too
many 0s can result in data errors.

Quoted 3 lines

Thanks,
Miquèl

Thanks,
Cheng Ming Lin

maintainer
#8 lore raw

Re: [PATCH 2/2] mtd: spi-nand: macronix: Add randomizer support

Hi Chang Ming,

Quoted 24 lines · Cheng Ming Lin

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月8日 週五 下午6:19寫道:

Quoted 21 lines · Cheng Ming Lin
Quoted 11 lines

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

Can we create a global NAND DT property for that? Enabling a randomizer is quite a generic step.

Quoted 3 lines

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

Quoted 8 lines
Quoted 2 lines

Do you want to share what is the added value in terms of lifetime to enable the randomizer, given the drawbacks which are significant?

The randomizer mainly targets extremely unbalanced data patterns, which might potentially lead to data errors.

Please refer to the attached document:
https://www.mxic.com.tw/Lists/ApplicationNote/Attachments/2151/AN1051V1-The%20Introduction%20of%20Randomizer%20Feature%20on%20MX30xFxG28AD_MX35xFxG24AD.pdf

Thanks for the link, it may be pointed with a "Link:" tag in your commit to further justify this addition. However it is sparse on details. I would be interested by more details, such as "how many 0s? how many bitflips? how often/likely?"

Quoted 2 lines

Figure 1 shows that continuously programming too
many 0s can result in data errors.

Thanks,
Miquèl

#9 lore raw

Re: [PATCH 2/2] mtd: spi-nand: macronix: Add randomizer support

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月18日 週一 下午4:47寫道:

Quoted 35 lines

Hi Chang Ming,

Quoted 30 lines · Cheng Ming Lin

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月8日 週五 下午6:19寫道:

Quoted 17 lines · Cheng Ming Lin
Quoted 11 lines

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

Can we create a global NAND DT property for that? Enabling a randomizer is quite a generic step.

Quoted 6 lines
Quoted 3 lines

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

Do you want to share what is the added value in terms of lifetime to enable the randomizer, given the drawbacks which are significant?

The randomizer mainly targets extremely unbalanced data patterns, which might potentially lead to data errors.

Quoted 7 lines
Quoted 2 lines

Please refer to the attached document:
https://www.mxic.com.tw/Lists/ApplicationNote/Attachments/2151/AN1051V1-The%20Introduction%20of%20Randomizer%20Feature%20on%20MX30xFxG28AD_MX35xFxG24AD.pdf

Thanks for the link, it may be pointed with a "Link:" tag in your commit to further justify this addition. However it is sparse on details. I would be interested by more details, such as "how many 0s? how many bitflips? how often/likely?"

Thank you for your feedback. Unfortunately we do not have numerical data such as exact numbers of '0's, bitflip rates, or occurrence probabilities to share. Instead, I would like to refer to the JEDEC JESD22-A117E qualification standard, which provides guidance on retention and endurance testing.

According to this document, there is no single data pattern that represents a universal worst-case across all failure mechanisms. Different mechanisms may stress programmed cells, erased cells, or cells influenced by adjacent states, and thus specific patterns such as fully programmed, checkerboard, or mostly erased are each only worst-case for certain designs or processes.

Given that no fixed pattern can cover all cases, the use of a randomized data pattern is considered a practical mitigation strategy. A randomizer distributes stress more evenly across the device by scrambling incoming data before storage and restoring it on read. This helps reduce pattern-dependent degradation and can therefore improve long-term flash reliability.

Quoted 6 lines
Quoted 3 lines

Figure 1 shows that continuously programming too
many 0s can result in data errors.

Thanks,
Miquèl

Thanks,
Cheng-Ming Lin

maintainer
#10 lore raw

Re: [PATCH 2/2] mtd: spi-nand: macronix: Add randomizer support

Hello,

Quoted 59 lines · Cheng Ming Lin

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月18日 週一 下午4:47寫道:

Quoted 35 lines

Hi Chang Ming,

Quoted 30 lines · Cheng Ming Lin

Hi Miquel,

Miquel Raynal <[email protected]> 於 2025年8月8日 週五 下午6:19寫道:

Quoted 17 lines · Cheng Ming Lin
Quoted 11 lines

From: Cheng Ming Lin <[email protected]>

Enable randomizer function by specific flowchart to set the default value of RANDEN to 1.

Randomizer introduces two new DT properties for child nodes to configure the randomizer functionality and coverage options.
- mxic,enable-randomizer-otp: Specify whether to activate the randomizer feature.
- mxic,randopt: Define the randomizer area per page.

Can we create a global NAND DT property for that? Enabling a randomizer is quite a generic step.

Quoted 6 lines
Quoted 3 lines

The penalty of randomizer are subpage accesses prohibited and more time period is needed in program operation and entering deep power-down mode. i.e., tPROG 320us to 360us (randomizer enabled).

Do you want to share what is the added value in terms of lifetime to enable the randomizer, given the drawbacks which are significant?

The randomizer mainly targets extremely unbalanced data patterns, which might potentially lead to data errors.

Quoted 7 lines
Quoted 2 lines

Please refer to the attached document:
https://www.mxic.com.tw/Lists/ApplicationNote/Attachments/2151/AN1051V1-The%20Introduction%20of%20Randomizer%20Feature%20on%20MX30xFxG28AD_MX35xFxG24AD.pdf

Thanks for the link, it may be pointed with a "Link:" tag in your commit to further justify this addition. However it is sparse on details. I would be interested by more details, such as "how many 0s? how many bitflips? how often/likely?"

Thank you for your feedback. Unfortunately we do not have numerical data such as exact numbers of '0's, bitflip rates, or occurrence probabilities to share. Instead, I would like to refer to the JEDEC JESD22-A117E qualification standard, which provides guidance on retention and endurance testing.

According to this document, there is no single data pattern that represents a universal worst-case across all failure mechanisms. Different mechanisms may stress programmed cells, erased cells, or cells influenced by adjacent states, and thus specific patterns such as fully programmed, checkerboard, or mostly erased are each only worst-case for certain designs or processes.

Quoted 6 lines

Given that no fixed pattern can cover all cases, the use of a randomized data pattern is considered a practical mitigation strategy. A randomizer distributes stress more evenly across the device by scrambling incoming data before storage and restoring it on read. This helps reduce pattern-dependent degradation and can therefore improve long-term flash reliability.

Thanks for the details. I guess you can add a bit of them to your commit log as well. I'll welcome a v2 with the previous comments addressed!

Thanks,
Miquèl