linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Keep on-die ECC engines compatibility
@ 2021-09-28 22:22 Miquel Raynal
  2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
                   ` (18 more replies)
  0 siblings, 19 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal

Recent changes broke the possibility to set the desired ECC engine type
from DT, this is of course an error and needed to be fixed. The fix
applies to all drivers which already received a previous incomplete fix
(about SW support). Hopefully this time we should be good. Sorry for the
noise.

Miquel Raynal (9):
  mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: orion: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: socrates: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines

 drivers/mtd/nand/raw/ams-delta.c     | 12 +++++++++---
 drivers/mtd/nand/raw/au1550nd.c      | 12 +++++++++---
 drivers/mtd/nand/raw/gpio.c          | 12 +++++++++---
 drivers/mtd/nand/raw/mpc5121_nfc.c   | 12 +++++++++---
 drivers/mtd/nand/raw/orion_nand.c    | 12 +++++++++---
 drivers/mtd/nand/raw/pasemi_nand.c   | 12 +++++++++---
 drivers/mtd/nand/raw/plat_nand.c     | 12 +++++++++---
 drivers/mtd/nand/raw/socrates_nand.c | 12 +++++++++---
 drivers/mtd/nand/raw/xway_nand.c     | 12 +++++++++---
 9 files changed, 81 insertions(+), 27 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 59d93473323a ("mtd: rawnand: ams-delta: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/ams-delta.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index ff1697f899ba..13de39aa3288 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -217,9 +217,8 @@ static int gpio_nand_setup_interface(struct nand_chip *this, int csline,
 
 static int gpio_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -370,6 +369,13 @@ static int gpio_nand_probe(struct platform_device *pdev)
 	/* Release write protection */
 	gpiod_set_value(priv->gpiod_nwp, 0);
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(this, 1);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 2/9] mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
  2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: dbffc8ccdf3a ("mtd: rawnand: au1550: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/au1550nd.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/au1550nd.c b/drivers/mtd/nand/raw/au1550nd.c
index 99116896cfd6..5aa3a06d740c 100644
--- a/drivers/mtd/nand/raw/au1550nd.c
+++ b/drivers/mtd/nand/raw/au1550nd.c
@@ -239,9 +239,8 @@ static int au1550nd_exec_op(struct nand_chip *this,
 
 static int au1550nd_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -310,6 +309,13 @@ static int au1550nd_probe(struct platform_device *pdev)
 	if (pd->devwidth)
 		this->options |= NAND_BUSWIDTH_16;
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	ret = nand_scan(this, 1);
 	if (ret) {
 		dev_err(&pdev->dev, "NAND scan failed with %d\n", ret);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 3/9] mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
  2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
  2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: f6341f6448e0 ("mtd: rawnand: gpio: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/gpio.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/gpio.c b/drivers/mtd/nand/raw/gpio.c
index fb7a086de35e..fdf073d2e1b6 100644
--- a/drivers/mtd/nand/raw/gpio.c
+++ b/drivers/mtd/nand/raw/gpio.c
@@ -163,9 +163,8 @@ static int gpio_nand_exec_op(struct nand_chip *chip,
 
 static int gpio_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -365,6 +364,13 @@ static int gpio_nand_probe(struct platform_device *pdev)
 	if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
 		gpiod_direction_output(gpiomtd->nwp, 1);
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	ret = nand_scan(chip, 1);
 	if (ret)
 		goto err_wp;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 4/9] mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (2 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 6dd09f775b72 ("mtd: rawnand: mpc5121: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/mpc5121_nfc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/mpc5121_nfc.c b/drivers/mtd/nand/raw/mpc5121_nfc.c
index bcd4a556c959..cb293c50acb8 100644
--- a/drivers/mtd/nand/raw/mpc5121_nfc.c
+++ b/drivers/mtd/nand/raw/mpc5121_nfc.c
@@ -605,9 +605,8 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
 
 static int mpc5121_nfc_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -772,6 +771,13 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 		goto error;
 	}
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Detect NAND chips */
 	retval = nand_scan(chip, be32_to_cpup(chips_no));
 	if (retval) {
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 5/9] mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (3 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
                   ` (13 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 553508cec2e8 ("mtd: rawnand: orion: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/orion_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/orion_nand.c b/drivers/mtd/nand/raw/orion_nand.c
index 66211c9311d2..2c87c7d89205 100644
--- a/drivers/mtd/nand/raw/orion_nand.c
+++ b/drivers/mtd/nand/raw/orion_nand.c
@@ -85,9 +85,8 @@ static void orion_nand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
 
 static int orion_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -190,6 +189,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	nc->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	ret = nand_scan(nc, 1);
 	if (ret)
 		goto no_dev;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 6/9] mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (4 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 8fc6f1f042b2 ("mtd: rawnand: pasemi: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/pasemi_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/pasemi_nand.c b/drivers/mtd/nand/raw/pasemi_nand.c
index 789f33312c15..c176036453ed 100644
--- a/drivers/mtd/nand/raw/pasemi_nand.c
+++ b/drivers/mtd/nand/raw/pasemi_nand.c
@@ -75,9 +75,8 @@ static int pasemi_device_ready(struct nand_chip *chip)
 
 static int pasemi_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -154,6 +153,13 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
 	/* Enable the following for a flash based bad block table */
 	chip->bbt_options = NAND_BBT_USE_FLASH;
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(chip, 1);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 7/9] mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (5 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 612e048e6aab ("mtd: rawnand: plat_nand: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/plat_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/plat_nand.c b/drivers/mtd/nand/raw/plat_nand.c
index 7711e1020c21..0ee08c42cc35 100644
--- a/drivers/mtd/nand/raw/plat_nand.c
+++ b/drivers/mtd/nand/raw/plat_nand.c
@@ -21,9 +21,8 @@ struct plat_nand_data {
 
 static int plat_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -94,6 +93,13 @@ static int plat_nand_probe(struct platform_device *pdev)
 			goto out;
 	}
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(&data->chip, pdata->chip.nr_chips);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 8/9] mtd: rawnand: socrates: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (6 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-15 10:32   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: b36bf0a0fe5d ("mtd: rawnand: socrates: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/socrates_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/socrates_nand.c b/drivers/mtd/nand/raw/socrates_nand.c
index 70f8305c9b6e..fb39cc7ebce0 100644
--- a/drivers/mtd/nand/raw/socrates_nand.c
+++ b/drivers/mtd/nand/raw/socrates_nand.c
@@ -119,9 +119,8 @@ static int socrates_nand_device_ready(struct nand_chip *nand_chip)
 
 static int socrates_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -175,6 +174,13 @@ static int socrates_nand_probe(struct platform_device *ofdev)
 	/* TODO: I have no idea what real delay is. */
 	nand_chip->legacy.chip_delay = 20;	/* 20us command delay time */
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	nand_chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	dev_set_drvdata(&ofdev->dev, host);
 
 	res = nand_scan(nand_chip, 1);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 9/9] mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (7 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-10-04 15:40   ` Miquel Raynal
  2021-10-15 10:31   ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (9 subsequent siblings)
  18 siblings, 2 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable, Jan Hoffmann,
	Kestrel seventyfour

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: d525914b5bd8 ("mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Cc: Jan Hoffmann <jan@3e8.eu>
Cc: Kestrel seventyfour <kestrelseventyfour@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/xway_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/xway_nand.c b/drivers/mtd/nand/raw/xway_nand.c
index 26751976e502..236fd8c5a958 100644
--- a/drivers/mtd/nand/raw/xway_nand.c
+++ b/drivers/mtd/nand/raw/xway_nand.c
@@ -148,9 +148,8 @@ static void xway_write_buf(struct nand_chip *chip, const u_char *buf, int len)
 
 static int xway_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -219,6 +218,13 @@ static int xway_nand_probe(struct platform_device *pdev)
 		    | NAND_CON_SE_P | NAND_CON_WP_P | NAND_CON_PRE_P
 		    | cs_flag, EBU_NAND_CON);
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(&data->chip, 1);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 0/9] Keep on-die ECC engines compatibility
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (8 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal

Recent changes broke the possibility to set the desired ECC engine type
from DT, this is of course an error and needed to be fixed. The fix
applies to all drivers which already received a previous incomplete fix
(about SW support). Hopefully this time we should be good. Sorry for the
noise.

Miquel Raynal (9):
  mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: orion: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: socrates: Keep the driver compatible with on-die ECC
    engines
  mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines

 drivers/mtd/nand/raw/ams-delta.c     | 12 +++++++++---
 drivers/mtd/nand/raw/au1550nd.c      | 12 +++++++++---
 drivers/mtd/nand/raw/gpio.c          | 12 +++++++++---
 drivers/mtd/nand/raw/mpc5121_nfc.c   | 12 +++++++++---
 drivers/mtd/nand/raw/orion_nand.c    | 12 +++++++++---
 drivers/mtd/nand/raw/pasemi_nand.c   | 12 +++++++++---
 drivers/mtd/nand/raw/plat_nand.c     | 12 +++++++++---
 drivers/mtd/nand/raw/socrates_nand.c | 12 +++++++++---
 drivers/mtd/nand/raw/xway_nand.c     | 12 +++++++++---
 9 files changed, 81 insertions(+), 27 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (9 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 59d93473323a ("mtd: rawnand: ams-delta: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/ams-delta.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index ff1697f899ba..13de39aa3288 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -217,9 +217,8 @@ static int gpio_nand_setup_interface(struct nand_chip *this, int csline,
 
 static int gpio_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -370,6 +369,13 @@ static int gpio_nand_probe(struct platform_device *pdev)
 	/* Release write protection */
 	gpiod_set_value(priv->gpiod_nwp, 0);
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(this, 1);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 2/9] mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (10 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: dbffc8ccdf3a ("mtd: rawnand: au1550: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/au1550nd.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/au1550nd.c b/drivers/mtd/nand/raw/au1550nd.c
index 99116896cfd6..5aa3a06d740c 100644
--- a/drivers/mtd/nand/raw/au1550nd.c
+++ b/drivers/mtd/nand/raw/au1550nd.c
@@ -239,9 +239,8 @@ static int au1550nd_exec_op(struct nand_chip *this,
 
 static int au1550nd_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -310,6 +309,13 @@ static int au1550nd_probe(struct platform_device *pdev)
 	if (pd->devwidth)
 		this->options |= NAND_BUSWIDTH_16;
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	ret = nand_scan(this, 1);
 	if (ret) {
 		dev_err(&pdev->dev, "NAND scan failed with %d\n", ret);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 3/9] mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (11 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: f6341f6448e0 ("mtd: rawnand: gpio: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/gpio.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/gpio.c b/drivers/mtd/nand/raw/gpio.c
index fb7a086de35e..fdf073d2e1b6 100644
--- a/drivers/mtd/nand/raw/gpio.c
+++ b/drivers/mtd/nand/raw/gpio.c
@@ -163,9 +163,8 @@ static int gpio_nand_exec_op(struct nand_chip *chip,
 
 static int gpio_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -365,6 +364,13 @@ static int gpio_nand_probe(struct platform_device *pdev)
 	if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
 		gpiod_direction_output(gpiomtd->nwp, 1);
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	ret = nand_scan(chip, 1);
 	if (ret)
 		goto err_wp;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 4/9] mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (12 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 6dd09f775b72 ("mtd: rawnand: mpc5121: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/mpc5121_nfc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/mpc5121_nfc.c b/drivers/mtd/nand/raw/mpc5121_nfc.c
index bcd4a556c959..cb293c50acb8 100644
--- a/drivers/mtd/nand/raw/mpc5121_nfc.c
+++ b/drivers/mtd/nand/raw/mpc5121_nfc.c
@@ -605,9 +605,8 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
 
 static int mpc5121_nfc_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -772,6 +771,13 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 		goto error;
 	}
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Detect NAND chips */
 	retval = nand_scan(chip, be32_to_cpup(chips_no));
 	if (retval) {
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 5/9] mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (13 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 553508cec2e8 ("mtd: rawnand: orion: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/orion_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/orion_nand.c b/drivers/mtd/nand/raw/orion_nand.c
index 66211c9311d2..2c87c7d89205 100644
--- a/drivers/mtd/nand/raw/orion_nand.c
+++ b/drivers/mtd/nand/raw/orion_nand.c
@@ -85,9 +85,8 @@ static void orion_nand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
 
 static int orion_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -190,6 +189,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	nc->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	ret = nand_scan(nc, 1);
 	if (ret)
 		goto no_dev;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 6/9] mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (14 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 8fc6f1f042b2 ("mtd: rawnand: pasemi: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/pasemi_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/pasemi_nand.c b/drivers/mtd/nand/raw/pasemi_nand.c
index 789f33312c15..c176036453ed 100644
--- a/drivers/mtd/nand/raw/pasemi_nand.c
+++ b/drivers/mtd/nand/raw/pasemi_nand.c
@@ -75,9 +75,8 @@ static int pasemi_device_ready(struct nand_chip *chip)
 
 static int pasemi_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -154,6 +153,13 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
 	/* Enable the following for a flash based bad block table */
 	chip->bbt_options = NAND_BBT_USE_FLASH;
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(chip, 1);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 7/9] mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (15 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
  2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: 612e048e6aab ("mtd: rawnand: plat_nand: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/plat_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/plat_nand.c b/drivers/mtd/nand/raw/plat_nand.c
index 7711e1020c21..0ee08c42cc35 100644
--- a/drivers/mtd/nand/raw/plat_nand.c
+++ b/drivers/mtd/nand/raw/plat_nand.c
@@ -21,9 +21,8 @@ struct plat_nand_data {
 
 static int plat_nand_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -94,6 +93,13 @@ static int plat_nand_probe(struct platform_device *pdev)
 			goto out;
 	}
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(&data->chip, pdata->chip.nr_chips);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 8/9] mtd: rawnand: socrates: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (16 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: b36bf0a0fe5d ("mtd: rawnand: socrates: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/socrates_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/socrates_nand.c b/drivers/mtd/nand/raw/socrates_nand.c
index 70f8305c9b6e..fb39cc7ebce0 100644
--- a/drivers/mtd/nand/raw/socrates_nand.c
+++ b/drivers/mtd/nand/raw/socrates_nand.c
@@ -119,9 +119,8 @@ static int socrates_nand_device_ready(struct nand_chip *nand_chip)
 
 static int socrates_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -175,6 +174,13 @@ static int socrates_nand_probe(struct platform_device *ofdev)
 	/* TODO: I have no idea what real delay is. */
 	nand_chip->legacy.chip_delay = 20;	/* 20us command delay time */
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	nand_chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	dev_set_drvdata(&ofdev->dev, host);
 
 	res = nand_scan(nand_chip, 1);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 9/9] mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
                   ` (17 preceding siblings ...)
  2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
@ 2021-09-28 22:22 ` Miquel Raynal
  18 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, Miquel Raynal, stable, Jan Hoffmann,
	Kestrel seventyfour

Following the introduction of the generic ECC engine infrastructure, it
was necessary to reorganize the code and move the ECC configuration in
the ->attach_chip() hook. Failing to do that properly lead to a first
series of fixes supposed to stabilize the situation. Unfortunately, this
only fixed the use of software ECC engines, preventing any other kind of
engine to be used, including on-die ones.

It is now time to (finally) fix the situation by ensuring that we still
provide a default (eg. software ECC) but will still support different
ECC engines such as on-die ECC engines if properly described in the
device tree.

There are no changes needed on the core side in order to do this, but we
just need to leverage the logic there which allows:
1- a subsystem default (set to Host engines in the raw NAND world)
2- a driver specific default (here set to software ECC engines)
3- any type of engine requested by the user (ie. described in the DT)

As the raw NAND subsystem has not yet been fully converted to the ECC
engine infrastructure, in order to provide a default ECC engine for this
driver we need to set chip->ecc.engine_type *before* calling
nand_scan(). During the initialization step, the core will consider this
entry as the default engine for this driver. This value may of course
be overloaded by the user if the usual DT properties are provided.

Fixes: d525914b5bd8 ("mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()")
Cc: stable@vger.kernel.org
Cc: Jan Hoffmann <jan@3e8.eu>
Cc: Kestrel seventyfour <kestrelseventyfour@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/xway_nand.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/xway_nand.c b/drivers/mtd/nand/raw/xway_nand.c
index 26751976e502..236fd8c5a958 100644
--- a/drivers/mtd/nand/raw/xway_nand.c
+++ b/drivers/mtd/nand/raw/xway_nand.c
@@ -148,9 +148,8 @@ static void xway_write_buf(struct nand_chip *chip, const u_char *buf, int len)
 
 static int xway_attach_chip(struct nand_chip *chip)
 {
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-
-	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
+	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
+	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
 		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
 
 	return 0;
@@ -219,6 +218,13 @@ static int xway_nand_probe(struct platform_device *pdev)
 		    | NAND_CON_SE_P | NAND_CON_WP_P | NAND_CON_PRE_P
 		    | cs_flag, EBU_NAND_CON);
 
+	/*
+	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
+	 * Set ->engine_type before registering the NAND devices in order to
+	 * provide a driver specific default value.
+	 */
+	data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+
 	/* Scan to find existence of the device */
 	err = nand_scan(&data->chip, 1);
 	if (err)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH 9/9] mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
@ 2021-10-04 15:40   ` Miquel Raynal
  2021-10-04 16:21     ` Jan Hoffmann
  2021-10-15 10:31   ` Miquel Raynal
  1 sibling, 1 reply; 31+ messages in thread
From: Miquel Raynal @ 2021-10-04 15:40 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable, Jan Hoffmann, Kestrel seventyfour

Hi Jan,

miquel.raynal@bootlin.com wrote on Wed, 29 Sep 2021 00:22:48 +0200:

> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: d525914b5bd8 ("mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Cc: Jan Hoffmann <jan@3e8.eu>

I think you already tested this change and validated it, would you mind
providing your Tested-by?

> Cc: Kestrel seventyfour <kestrelseventyfour@gmail.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mtd/nand/raw/xway_nand.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/xway_nand.c b/drivers/mtd/nand/raw/xway_nand.c
> index 26751976e502..236fd8c5a958 100644
> --- a/drivers/mtd/nand/raw/xway_nand.c
> +++ b/drivers/mtd/nand/raw/xway_nand.c
> @@ -148,9 +148,8 @@ static void xway_write_buf(struct nand_chip *chip, const u_char *buf, int len)
>  
>  static int xway_attach_chip(struct nand_chip *chip)
>  {
> -	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
> -
> -	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
> +	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
> +	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
>  		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
>  
>  	return 0;
> @@ -219,6 +218,13 @@ static int xway_nand_probe(struct platform_device *pdev)
>  		    | NAND_CON_SE_P | NAND_CON_WP_P | NAND_CON_PRE_P
>  		    | cs_flag, EBU_NAND_CON);
>  
> +	/*
> +	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
> +	 * Set ->engine_type before registering the NAND devices in order to
> +	 * provide a driver specific default value.
> +	 */
> +	data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
> +
>  	/* Scan to find existence of the device */
>  	err = nand_scan(&data->chip, 1);
>  	if (err)


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 9/9] mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  2021-10-04 15:40   ` Miquel Raynal
@ 2021-10-04 16:21     ` Jan Hoffmann
  0 siblings, 0 replies; 31+ messages in thread
From: Jan Hoffmann @ 2021-10-04 16:21 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable, Kestrel seventyfour

Hi Miquèl,

> Hi Jan,
> 
> miquel.raynal@bootlin.com wrote on Wed, 29 Sep 2021 00:22:48 +0200:
> 
>> Following the introduction of the generic ECC engine infrastructure, it
>> was necessary to reorganize the code and move the ECC configuration in
>> the ->attach_chip() hook. Failing to do that properly lead to a first
>> series of fixes supposed to stabilize the situation. Unfortunately, this
>> only fixed the use of software ECC engines, preventing any other kind of
>> engine to be used, including on-die ones.
>>
>> It is now time to (finally) fix the situation by ensuring that we still
>> provide a default (eg. software ECC) but will still support different
>> ECC engines such as on-die ECC engines if properly described in the
>> device tree.
>>
>> There are no changes needed on the core side in order to do this, but we
>> just need to leverage the logic there which allows:
>> 1- a subsystem default (set to Host engines in the raw NAND world)
>> 2- a driver specific default (here set to software ECC engines)
>> 3- any type of engine requested by the user (ie. described in the DT)
>>
>> As the raw NAND subsystem has not yet been fully converted to the ECC
>> engine infrastructure, in order to provide a default ECC engine for this
>> driver we need to set chip->ecc.engine_type *before* calling
>> nand_scan(). During the initialization step, the core will consider this
>> entry as the default engine for this driver. This value may of course
>> be overloaded by the user if the usual DT properties are provided.
>>
>> Fixes: d525914b5bd8 ("mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()")
>> Cc: stable@vger.kernel.org
>> Cc: Jan Hoffmann <jan@3e8.eu>
> 
> I think you already tested this change and validated it, would you mind
> providing your Tested-by?

Yes, I tested this on a device using software ECC (Fritzbox 7412 with
Toshiba NAND chip) and on a device using on-die ECC (Fritzbox 7362 SL
with Micron NAND chip).

Tested-by: Jan Hoffmann <jan@3e8.eu>

>> Cc: Kestrel seventyfour <kestrelseventyfour@gmail.com>
>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> ---
>>   drivers/mtd/nand/raw/xway_nand.c | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/xway_nand.c b/drivers/mtd/nand/raw/xway_nand.c
>> index 26751976e502..236fd8c5a958 100644
>> --- a/drivers/mtd/nand/raw/xway_nand.c
>> +++ b/drivers/mtd/nand/raw/xway_nand.c
>> @@ -148,9 +148,8 @@ static void xway_write_buf(struct nand_chip *chip, const u_char *buf, int len)
>>   
>>   static int xway_attach_chip(struct nand_chip *chip)
>>   {
>> -	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
>> -
>> -	if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
>> +	if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT &&
>> +	    chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN)
>>   		chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
>>   
>>   	return 0;
>> @@ -219,6 +218,13 @@ static int xway_nand_probe(struct platform_device *pdev)
>>   		    | NAND_CON_SE_P | NAND_CON_WP_P | NAND_CON_PRE_P
>>   		    | cs_flag, EBU_NAND_CON);
>>   
>> +	/*
>> +	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
>> +	 * Set ->engine_type before registering the NAND devices in order to
>> +	 * provide a driver specific default value.
>> +	 */
>> +	data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
>> +
>>   	/* Scan to find existence of the device */
>>   	err = nand_scan(&data->chip, 1);
>>   	if (err)
> 
> 
> Thanks,
> Miquèl
> 

Thanks,
Jan

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 9/9] mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
  2021-10-04 15:40   ` Miquel Raynal
@ 2021-10-15 10:31   ` Miquel Raynal
  1 sibling, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:31 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable, Jan Hoffmann, Kestrel seventyfour

On Tue, 2021-09-28 at 22:22:48 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: d525914b5bd8 ("mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Cc: Jan Hoffmann <jan@3e8.eu>
> Cc: Kestrel seventyfour <kestrelseventyfour@gmail.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Tested-by: Jan Hoffmann <jan@3e8.eu>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 8/9] mtd: rawnand: socrates: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:47 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: b36bf0a0fe5d ("mtd: rawnand: socrates: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 7/9] mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:46 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: 612e048e6aab ("mtd: rawnand: plat_nand: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 6/9] mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:45 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: 8fc6f1f042b2 ("mtd: rawnand: pasemi: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 5/9] mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:44 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: 553508cec2e8 ("mtd: rawnand: orion: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/9] mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:43 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: 6dd09f775b72 ("mtd: rawnand: mpc5121: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/9] mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:42 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: f6341f6448e0 ("mtd: rawnand: gpio: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/9] mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:41 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: dbffc8ccdf3a ("mtd: rawnand: au1550: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
  2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
@ 2021-10-15 10:32   ` Miquel Raynal
  0 siblings, 0 replies; 31+ messages in thread
From: Miquel Raynal @ 2021-10-15 10:32 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus
  Cc: linux-mtd, linux-kernel, stable

On Tue, 2021-09-28 at 22:22:40 UTC, Miquel Raynal wrote:
> Following the introduction of the generic ECC engine infrastructure, it
> was necessary to reorganize the code and move the ECC configuration in
> the ->attach_chip() hook. Failing to do that properly lead to a first
> series of fixes supposed to stabilize the situation. Unfortunately, this
> only fixed the use of software ECC engines, preventing any other kind of
> engine to be used, including on-die ones.
> 
> It is now time to (finally) fix the situation by ensuring that we still
> provide a default (eg. software ECC) but will still support different
> ECC engines such as on-die ECC engines if properly described in the
> device tree.
> 
> There are no changes needed on the core side in order to do this, but we
> just need to leverage the logic there which allows:
> 1- a subsystem default (set to Host engines in the raw NAND world)
> 2- a driver specific default (here set to software ECC engines)
> 3- any type of engine requested by the user (ie. described in the DT)
> 
> As the raw NAND subsystem has not yet been fully converted to the ECC
> engine infrastructure, in order to provide a default ECC engine for this
> driver we need to set chip->ecc.engine_type *before* calling
> nand_scan(). During the initialization step, the core will consider this
> entry as the default engine for this driver. This value may of course
> be overloaded by the user if the usual DT properties are provided.
> 
> Fixes: 59d93473323a ("mtd: rawnand: ams-delta: Move the ECC initialization to ->attach_chip()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.

Miquel

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2021-10-15 10:32 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 22:22 [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
2021-10-15 10:32   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal
2021-10-04 15:40   ` Miquel Raynal
2021-10-04 16:21     ` Jan Hoffmann
2021-10-15 10:31   ` Miquel Raynal
2021-09-28 22:22 ` [PATCH 0/9] Keep on-die ECC engines compatibility Miquel Raynal
2021-09-28 22:22 ` [PATCH 1/9] mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines Miquel Raynal
2021-09-28 22:22 ` [PATCH 2/9] mtd: rawnand: au1550nd: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 3/9] mtd: rawnand: gpio: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 4/9] mtd: rawnand: mpc5121: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 5/9] mtd: rawnand: orion: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 6/9] mtd: rawnand: pasemi: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 7/9] mtd: rawnand: plat_nand: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 8/9] mtd: rawnand: socrates: " Miquel Raynal
2021-09-28 22:22 ` [PATCH 9/9] mtd: rawnand: xway: " Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).