public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: rawnand: stm32_fmc2: fix broken ECC
@ 2020-10-30 13:33 Christophe Kerello
  2020-10-30 13:36 ` Miquel Raynal
  2020-10-30 17:26 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe Kerello @ 2020-10-30 13:33 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr
  Cc: linux-mtd, linux-kernel, linux-stm32, Christophe Kerello

Since commit d7157ff49a5b ("mtd: rawnand: Use the ECC framework user
input parsing bits"), ECC are broken in FMC2 driver in case of
nand-ecc-step-size and nand-ecc-strength are not set in the device tree.
To avoid this issue, the default settings are now set in
stm32_fmc2_nfc_attach_chip function.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Fixes: d7157ff49a5b ("mtd: rawnand: Use the ECC framework user input parsing bits")
---
Changes in v2:
 - move default ECC settings in stm32_fmc2_nfc_attach_chip function.

 drivers/mtd/nand/raw/stm32_fmc2_nand.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index b31a581..550bda4 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -1708,6 +1708,13 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
 		return -EINVAL;
 	}
 
+	/* Default ECC settings in case they are not set in the device tree */
+	if (!chip->ecc.size)
+		chip->ecc.size = FMC2_ECC_STEP_SIZE;
+
+	if (!chip->ecc.strength)
+		chip->ecc.strength = FMC2_ECC_BCH8;
+
 	ret = nand_ecc_choose_conf(chip, &stm32_fmc2_nfc_ecc_caps,
 				   mtd->oobsize - FMC2_BBM_LEN);
 	if (ret) {
@@ -1727,8 +1734,7 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
 
 	mtd_set_ooblayout(mtd, &stm32_fmc2_nfc_ooblayout_ops);
 
-	if (chip->options & NAND_BUSWIDTH_16)
-		stm32_fmc2_nfc_set_buswidth_16(nfc, true);
+	stm32_fmc2_nfc_setup(chip);
 
 	return 0;
 }
@@ -1952,11 +1958,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 	chip->options |= NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE |
 			 NAND_USES_DMA;
 
-	/* Default ECC settings */
-	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
-	chip->ecc.size = FMC2_ECC_STEP_SIZE;
-	chip->ecc.strength = FMC2_ECC_BCH8;
-
 	/* Scan to find existence of the device */
 	ret = nand_scan(chip, nand->ncs);
 	if (ret)
-- 
1.9.1


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

* Re: [PATCH v2] mtd: rawnand: stm32_fmc2: fix broken ECC
  2020-10-30 13:33 [PATCH v2] mtd: rawnand: stm32_fmc2: fix broken ECC Christophe Kerello
@ 2020-10-30 13:36 ` Miquel Raynal
  2020-10-30 17:26 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2020-10-30 13:36 UTC (permalink / raw)
  To: Christophe Kerello
  Cc: richard, vigneshr, linux-mtd, linux-kernel, linux-stm32

Hi Christophe,

Christophe Kerello <christophe.kerello@st.com> wrote on Fri, 30 Oct
2020 14:33:39 +0100:

> Since commit d7157ff49a5b ("mtd: rawnand: Use the ECC framework user
> input parsing bits"), ECC are broken in FMC2 driver in case of
> nand-ecc-step-size and nand-ecc-strength are not set in the device tree.
> To avoid this issue, the default settings are now set in
> stm32_fmc2_nfc_attach_chip function.
> 
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> Fixes: d7157ff49a5b ("mtd: rawnand: Use the ECC framework user input parsing bits")
> ---
> Changes in v2:
>  - move default ECC settings in stm32_fmc2_nfc_attach_chip function.
> 
>  drivers/mtd/nand/raw/stm32_fmc2_nand.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
> index b31a581..550bda4 100644
> --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
> +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
> @@ -1708,6 +1708,13 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
>  		return -EINVAL;
>  	}
>  
> +	/* Default ECC settings in case they are not set in the device tree */
> +	if (!chip->ecc.size)
> +		chip->ecc.size = FMC2_ECC_STEP_SIZE;
> +
> +	if (!chip->ecc.strength)
> +		chip->ecc.strength = FMC2_ECC_BCH8;
> +
>  	ret = nand_ecc_choose_conf(chip, &stm32_fmc2_nfc_ecc_caps,
>  				   mtd->oobsize - FMC2_BBM_LEN);
>  	if (ret) {
> @@ -1727,8 +1734,7 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
>  
>  	mtd_set_ooblayout(mtd, &stm32_fmc2_nfc_ooblayout_ops);
>  
> -	if (chip->options & NAND_BUSWIDTH_16)
> -		stm32_fmc2_nfc_set_buswidth_16(nfc, true);
> +	stm32_fmc2_nfc_setup(chip);
>  
>  	return 0;
>  }
> @@ -1952,11 +1958,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  	chip->options |= NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE |
>  			 NAND_USES_DMA;
>  
> -	/* Default ECC settings */
> -	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
> -	chip->ecc.size = FMC2_ECC_STEP_SIZE;
> -	chip->ecc.strength = FMC2_ECC_BCH8;
> -
>  	/* Scan to find existence of the device */
>  	ret = nand_scan(chip, nand->ncs);
>  	if (ret)

This overall looks very good to me, thanks for this update!

Cheers,
Miquèl

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

* Re: [PATCH v2] mtd: rawnand: stm32_fmc2: fix broken ECC
  2020-10-30 13:33 [PATCH v2] mtd: rawnand: stm32_fmc2: fix broken ECC Christophe Kerello
  2020-10-30 13:36 ` Miquel Raynal
@ 2020-10-30 17:26 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2020-10-30 17:26 UTC (permalink / raw)
  To: Christophe Kerello, miquel.raynal, richard, vigneshr
  Cc: linux-mtd, linux-kernel, linux-stm32

On Fri, 2020-10-30 at 13:33:39 UTC, Christophe Kerello wrote:
> Since commit d7157ff49a5b ("mtd: rawnand: Use the ECC framework user
> input parsing bits"), ECC are broken in FMC2 driver in case of
> nand-ecc-step-size and nand-ecc-strength are not set in the device tree.
> To avoid this issue, the default settings are now set in
> stm32_fmc2_nfc_attach_chip function.
> 
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> Fixes: d7157ff49a5b ("mtd: rawnand: Use the ECC framework user input parsing bits")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

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

end of thread, other threads:[~2020-10-30 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 13:33 [PATCH v2] mtd: rawnand: stm32_fmc2: fix broken ECC Christophe Kerello
2020-10-30 13:36 ` Miquel Raynal
2020-10-30 17:26 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox