public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* spi-nor: excessive locking in spi_nor_erase()
@ 2024-04-15 15:55 Joakim Tjernlund
  2024-04-16 15:44 ` Pratyush Yadav
  0 siblings, 1 reply; 7+ messages in thread
From: Joakim Tjernlund @ 2024-04-15 15:55 UTC (permalink / raw)
  To: linux-mtd@lists.infradead.org

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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2024-04-19 13:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15 15:55 spi-nor: excessive locking in spi_nor_erase() Joakim Tjernlund
2024-04-16 15:44 ` Pratyush Yadav
2024-04-16 18:03   ` Joakim Tjernlund
2024-04-17 12:42     ` Pratyush Yadav
2024-04-17 12:54       ` Joakim Tjernlund
2024-04-19 12:58         ` Pratyush Yadav
2024-04-19 13:14           ` Joakim Tjernlund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox