Re: [PATCH v3 1/5] mtd: nand: Always store info about bad block markers in chip struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Boris,

Thanks for reviewing.

On 30.01.19 14:28, Boris Brezillon wrote:
> On Wed, 30 Jan 2019 13:01:44 +0000
> Schrempf Frieder <frieder.schrempf@xxxxxxxxxx> wrote:
> 
>> From: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
>>
>> The information about where the manufacturer puts the bad block
>> markers inside the bad block and in the OOB data is stored in
>> different places. Let's move this information to nand_chip.options
>> and nand_chip.badblockpos.
>>
>> As this chip-specific information is not directly related to the
>> bad block table (BBT), we also rename the flags to NAND_BBM_*.
>>
>> Signed-off-by: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
>> ---
>>   drivers/mtd/nand/onenand/onenand_base.c |  2 +-
>>   drivers/mtd/nand/onenand/onenand_bbt.c  |  2 +-
>>   drivers/mtd/nand/raw/nand_amd.c         |  2 +-
>>   drivers/mtd/nand/raw/nand_base.c        | 12 ++++++------
>>   drivers/mtd/nand/raw/nand_bbt.c         |  4 ++--
>>   drivers/mtd/nand/raw/nand_esmt.c        |  2 +-
>>   drivers/mtd/nand/raw/nand_hynix.c       |  4 ++--
>>   drivers/mtd/nand/raw/nand_macronix.c    |  2 +-
>>   drivers/mtd/nand/raw/nand_micron.c      |  2 +-
>>   drivers/mtd/nand/raw/nand_samsung.c     |  4 ++--
>>   drivers/mtd/nand/raw/nand_toshiba.c     |  2 +-
>>   drivers/mtd/nand/raw/sh_flctl.c         |  4 ++--
>>   include/linux/mtd/bbm.h                 | 14 +-------------
>>   include/linux/mtd/rawnand.h             | 15 +++++++++++++++
> 
> Might be better to split that in 2 patches:
> - update onenand logic
> - update rawnand logic

Ok

> 
>>   14 files changed, 37 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
>> index 4ca4b194e7d7..d6701b8f031f 100644
>> --- a/drivers/mtd/nand/onenand/onenand_base.c
>> +++ b/drivers/mtd/nand/onenand/onenand_base.c
>> @@ -2458,7 +2458,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
>>                   bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);
>>   
>>           /* We write two bytes, so we don't have to mess with 16-bit access */
>> -        ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
>> +        ofs += mtd->oobsize + (this->badblockpos & ~0x01);
> 
> Looks like the ->badblockpos field does not exist in struct
> onenand_chip, which means you didn't compile test this part ;-).

Hm, indeed. I forgot to enable onenand in my config. I will add the 
field to the onenand_chip struct, to be consistent with rawnand.

> 
>>   	/* FIXME : What to do when marking SLC block in partition
>>   	 * 	   with MLC erasesize? For now, it is not advisable to
>>   	 *	   create partitions containing both SLC and MLC regions.
>> diff --git a/drivers/mtd/nand/onenand/onenand_bbt.c b/drivers/mtd/nand/onenand/onenand_bbt.c
>> index dde20487937d..880b0abd36c8 100644
>> --- a/drivers/mtd/nand/onenand/onenand_bbt.c
>> +++ b/drivers/mtd/nand/onenand/onenand_bbt.c
>> @@ -191,7 +191,7 @@ static int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
>>   		return -ENOMEM;
>>   
>>   	/* Set the bad block position */
>> -	bbm->badblockpos = ONENAND_BADBLOCK_POS;
>> +	this->badblockpos = NAND_BBM_POS_ONENAND;
> 
> This should be done in onenand_base.c not onenand_bbt.c.

Ok.

> 
>>   
>>   	/* Set erase shift */
>>   	bbm->bbt_erase_shift = this->erase_shift;
> 
> ...
> 
>> diff --git a/drivers/mtd/nand/raw/nand_bbt.c b/drivers/mtd/nand/raw/nand_bbt.c
>> index 1b722fe9213c..862eaa3a0552 100644
>> --- a/drivers/mtd/nand/raw/nand_bbt.c
>> +++ b/drivers/mtd/nand/raw/nand_bbt.c
>> @@ -466,7 +466,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,
>>   
>>   	pr_info("Scanning device for bad blocks\n");
>>   
>> -	if (bd->options & NAND_BBT_SCAN2NDPAGE)
>> +	if (this->options & NAND_BBM_SECONDPAGE)
>>   		numpages = 2;
>>   	else
>>   		numpages = 1;
>> @@ -487,7 +487,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,
>>   		from = (loff_t)startblock << this->bbt_erase_shift;
>>   	}
>>   
>> -	if (this->bbt_options & NAND_BBT_SCANLASTPAGE)
>> +	if (this->bbt_options & NAND_BBM_LASTPAGE)
> 
> You're not checking the right field here:
> 
> 	if (this->options & NAND_BBM_LASTPAGE)

I will fix this.

Regards,
Frieder

> 
>>   		from += mtd->erasesize - (mtd->writesize * numpages);
>>   
>>   	for (i = startblock; i < numblocks; i++) {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux