[PATCH V2] mtd: core: skip badblocks increment for blocks already known bad
Miquel Raynal
miquel.raynal at bootlin.com
Tue Sep 2 06:16:45 PDT 2025
>> @@ -2349,11 +2350,19 @@ int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)
>> return -EROFS;
>> if (mtd->flags & MTD_SLC_ON_MLC_EMULATION)
>> ofs = (loff_t)mtd_div_by_eb(ofs, mtd) * master->erasesize;
>> - ret = master->_block_markbad(master, mtd_get_master_ofs(mtd,
>> ofs));
>> + moffs = mtd_get_master_ofs(mtd, ofs);
>> +
>> + if (master->_block_isbad) {
>> + ret = master->_block_isbad(master, moffs);
>> + if (ret > 0)
>> + return 0;
>
> Hi, Miquèl.
> Here, should we keep the same logic with the lower
> level(eg. nand_block_markbad, onenand_block_markbad) when 'ret < 0' is
> returned by master->_block_isbad. Many specific nand drivers(markbad)
> return the negative code when 'isbad' fails.
Good question, I guess in case of error in isbad() we shall probably
still try to mark the block bad because actually marking a block bad is
probably more important than returning correct statistics.
Thanks,
Miquèl
More information about the linux-mtd
mailing list