diff mbox series

[v3] mtd: spinand: Fix ECC status and OOB layout for Toshiba TC58CVG2S0H

Message ID 1543823821-18352-1-git-send-email-frieder.schrempf@kontron.de
State Accepted
Delegated to: Miquel Raynal
Headers show
Series [v3] mtd: spinand: Fix ECC status and OOB layout for Toshiba TC58CVG2S0H | expand

Commit Message

Frieder Schrempf Dec. 3, 2018, 8:01 a.m. UTC
From: Frieder Schrempf <frieder.schrempf@kontron.de>

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>
---
Changes for v3:

Comments

Miquel Raynal Dec. 7, 2018, 8 a.m. UTC | #1
Hi Schrempf, Clément,

Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Mon, 3 Dec 2018
08:01:38 +0000:

> From: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> 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>
> ---
> Changes for v3:
> ===============
> * Add Acked-by
> * Add comment for BBM in OOB layout
> 
> Changes for v2:
> ===============
> * Remove the changes to the ECC bytes in the OOB layout
> ---
>  drivers/mtd/nand/spi/toshiba.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
> index 294bcf6..0812655 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,18 @@ 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;
> -
> +	/* 2 bytes reserved for BBM */
> +	region->offset = 2;
> +	region->length = 126;
>  
>  	return 0;
>  }
> @@ -70,6 +70,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

If you don't mind, I would like to squash this with the original patch.
What about also adding Clement's Acked-by to it?


Thanks,
Miquèl
Frieder Schrempf Dec. 7, 2018, 9:31 a.m. UTC | #2
Hi Miquèl,

On 07.12.18 09:00, Miquel Raynal wrote:
> Hi Schrempf, Clément,
> 
> Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Mon, 3 Dec 2018
> 08:01:38 +0000:
> 
>> From: Frieder Schrempf <frieder.schrempf@kontron.de>
>>
>> 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>
>> ---
>> Changes for v3:
>> ===============
>> * Add Acked-by
>> * Add comment for BBM in OOB layout
>>
>> Changes for v2:
>> ===============
>> * Remove the changes to the ECC bytes in the OOB layout
>> ---
>>   drivers/mtd/nand/spi/toshiba.c | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
>> index 294bcf6..0812655 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,18 @@ 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;
>> -
>> +	/* 2 bytes reserved for BBM */
>> +	region->offset = 2;
>> +	region->length = 126;
>>   
>>   	return 0;
>>   }
>> @@ -70,6 +70,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
> 
> If you don't mind, I would like to squash this with the original patch.
> What about also adding Clement's Acked-by to it?

Sure, you can squash this with the original patch. And I guess adding 
Clément's Acked-by would be appropriate, too.

Thanks,
Frieder
Miquel Raynal Dec. 7, 2018, 9:39 a.m. UTC | #3
Hi Schrempf, Clement,

Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Fri, 7 Dec 2018
09:31:47 +0000:

> Hi Miquèl,
> 
> On 07.12.18 09:00, Miquel Raynal wrote:
> > Hi Schrempf, Clément,
> > 
> > Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Mon, 3 Dec 2018
> > 08:01:38 +0000:
> >   
> >> From: Frieder Schrempf <frieder.schrempf@kontron.de>
> >>
> >> 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>
> >> ---
> >> Changes for v3:
> >> ===============
> >> * Add Acked-by
> >> * Add comment for BBM in OOB layout
> >>
> >> Changes for v2:
> >> ===============
> >> * Remove the changes to the ECC bytes in the OOB layout
> >> ---
> >>   drivers/mtd/nand/spi/toshiba.c | 11 ++++++-----
> >>   1 file changed, 6 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
> >> index 294bcf6..0812655 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,18 @@ 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;
> >> -
> >> +	/* 2 bytes reserved for BBM */
> >> +	region->offset = 2;
> >> +	region->length = 126;
> >>   
> >>   	return 0;
> >>   }
> >> @@ -70,6 +70,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  
> > 
> > If you don't mind, I would like to squash this with the original patch.
> > What about also adding Clement's Acked-by to it?  
> 
> Sure, you can squash this with the original patch. And I guess adding 
> Clément's Acked-by would be appropriate, too.

Fix squashed, I will push on nand/next today.


Thanks,
Miquèl
diff mbox series

Patch

===============
* Add Acked-by
* Add comment for BBM in OOB layout

Changes for v2:
===============
* Remove the changes to the ECC bytes in the OOB layout
---
 drivers/mtd/nand/spi/toshiba.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
index 294bcf6..0812655 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,18 @@  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;
-
+	/* 2 bytes reserved for BBM */
+	region->offset = 2;
+	region->length = 126;
 
 	return 0;
 }
@@ -70,6 +70,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