All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mtd: spinand: Fix ECC status and OOB layout for Toshiba TC58CVG2S0H
@ 2018-11-28 13:18 Schrempf Frieder
  2018-11-29  9:56 ` Clément Péron
  0 siblings, 1 reply; 2+ messages in thread
From: Schrempf Frieder @ 2018-11-28 13:18 UTC (permalink / raw)
  To: miquel.raynal, linux-kernel
  Cc: peron.clem, Schrempf Frieder, Boris Brezillon,
	Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
	linux-mtd

When reading the status of the on-chip ECC, the Toshiba chip returns
two different states for reporting corrected bitflips. We should check
for both of them.

Also return the free OOB bytes as one contiguous area, instead of
multiple sections.

Suggested-by: Clément Péron <peron.clem@gmail.com>
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 drivers/mtd/nand/spi/toshiba.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
index 294bcf6..9731752 100644
--- a/drivers/mtd/nand/spi/toshiba.c
+++ b/drivers/mtd/nand/spi/toshiba.c
@@ -11,6 +11,7 @@
 #include <linux/mtd/spinand.h>
 
 #define SPINAND_MFR_TOSHIBA		0x98
+#define TOSH_STATUS_ECC_HAS_BITFLIPS_T	(3 << 4)
 
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
@@ -33,19 +34,17 @@ static int tc58cvg2s0h_ooblayout_ecc(struct mtd_info *mtd, int section,
 	region->offset = 128 + 16 * section;
 	region->length = 16;
 
-
 	return 0;
 }
 
 static int tc58cvg2s0h_ooblayout_free(struct mtd_info *mtd, int section,
 				      struct mtd_oob_region *region)
 {
-	if (section > 7)
+	if (section > 0)
 		return -ERANGE;
 
-	region->offset = 2 + 16 * section;
-	region->length = 14;
-
+	region->offset = 2;
+	region->length = 126;
 
 	return 0;
 }
@@ -70,6 +69,7 @@ static int tc58cvg2s0h_ecc_get_status(struct spinand_device *spinand,
 		return -EBADMSG;
 
 	case STATUS_ECC_HAS_BITFLIPS:
+	case TOSH_STATUS_ECC_HAS_BITFLIPS_T:
 		/*
 		 * Let's try to retrieve the real maximum number of bitflips
 		 * in order to avoid forcing the wear-leveling layer to move
-- 
2.7.4

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

* Re: [PATCH v2] mtd: spinand: Fix ECC status and OOB layout for Toshiba TC58CVG2S0H
  2018-11-28 13:18 [PATCH v2] mtd: spinand: Fix ECC status and OOB layout for Toshiba TC58CVG2S0H Schrempf Frieder
@ 2018-11-29  9:56 ` Clément Péron
  0 siblings, 0 replies; 2+ messages in thread
From: Clément Péron @ 2018-11-29  9:56 UTC (permalink / raw)
  To: frieder.schrempf
  Cc: Miquel Raynal, linux-kernel, Boris Brezillon, richard,
	David Woodhouse, Brian Norris, Marek Vašut, linux-mtd

Hi Frieder,

On Wed, 28 Nov 2018 at 14:18, Schrempf Frieder
<frieder.schrempf@kontron.de> wrote:
>
> When reading the status of the on-chip ECC, the Toshiba chip returns
> two different states for reporting corrected bitflips. We should check
> for both of them.
>
> Also return the free OOB bytes as one contiguous area, instead of
> multiple sections.
>
> Suggested-by: Clément Péron <peron.clem@gmail.com>
> Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Acked-by: Clément Péron <peron.clem@gmail.com>
> ---
>  drivers/mtd/nand/spi/toshiba.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
> index 294bcf6..9731752 100644
> --- a/drivers/mtd/nand/spi/toshiba.c
> +++ b/drivers/mtd/nand/spi/toshiba.c
> @@ -11,6 +11,7 @@
>  #include <linux/mtd/spinand.h>
>
>  #define SPINAND_MFR_TOSHIBA            0x98
> +#define TOSH_STATUS_ECC_HAS_BITFLIPS_T (3 << 4)
>
>  static SPINAND_OP_VARIANTS(read_cache_variants,
>                 SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
> @@ -33,19 +34,17 @@ static int tc58cvg2s0h_ooblayout_ecc(struct mtd_info *mtd, int section,
>         region->offset = 128 + 16 * section;
>         region->length = 16;
>
> -
>         return 0;
>  }
>
>  static int tc58cvg2s0h_ooblayout_free(struct mtd_info *mtd, int section,
>                                       struct mtd_oob_region *region)
>  {
> -       if (section > 7)
> +       if (section > 0)
>                 return -ERANGE;
>
> -       region->offset = 2 + 16 * section;
> -       region->length = 14;
> -

I will just add a comment here to say that we reserve 2 bytes for BBM.

Else, it's fine for me.

Regards,
Clement

> +       region->offset = 2;
> +       region->length = 126;
>
>         return 0;
>  }
> @@ -70,6 +69,7 @@ static int tc58cvg2s0h_ecc_get_status(struct spinand_device *spinand,
>                 return -EBADMSG;
>
>         case STATUS_ECC_HAS_BITFLIPS:
> +       case TOSH_STATUS_ECC_HAS_BITFLIPS_T:
>                 /*
>                  * Let's try to retrieve the real maximum number of bitflips
>                  * in order to avoid forcing the wear-leveling layer to move
> --
> 2.7.4

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

end of thread, other threads:[~2018-11-29  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28 13:18 [PATCH v2] mtd: spinand: Fix ECC status and OOB layout for Toshiba TC58CVG2S0H Schrempf Frieder
2018-11-29  9:56 ` Clément Péron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.