spi-nor: excessive locking in spi_nor_erase()
Joakim Tjernlund
Joakim.Tjernlund at infinera.com
Mon Apr 15 08:55:10 PDT 2024
static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
{
...
Lock here
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;
....
Then we have:
} else if (spi_nor_has_uniform_erase(nor)) {
while (len) {
ret = spi_nor_write_enable(nor);
if (ret)
goto erase_err;
ret = spi_nor_erase_sector(nor, addr);
if (ret)
goto erase_err;
ret = spi_nor_wait_till_ready(nor);
if (ret)
goto erase_err;
addr += mtd->erasesize;
len -= mtd->erasesize;
}
/* erase multiple sectors */
} else {
ret = spi_nor_erase_multi_sectors(nor, addr, len);
if (ret)
goto erase_err;
}
....
erase_err:
unlock here
spi_nor_unlock_and_unprep(nor);
return ret;
}
So erase locks the flash for the whole erase op which can include many sectors and I don't see
any Erase Suspend handling in spi-nor like the cfi_cmdset_0001/cfi_cmdset_0002 has.
Locking can be a challenge but this seems over the top, anyone working/looking into improving this?
Jocke
More information about the linux-mtd
mailing list