On Fri, 18 Jan 2019 23:39:43 +0100 Boris Brezillon <bbrezillon@xxxxxxxxxx> wrote: > > Otherwise, > > + * then we check page0. And if page0 is programmed, and page13 > > + * is not programmed, then we start to check from page11, page9, > > + * page7, page5, page3 respectively since the pages of PEB are > > + * programmed sequentially. > > Looks overly complex for only a small gain. Did you try writing X (X > being 14 in this case) pages all the time? If you did, how does it > compare to this version (perf-wise). I suspect that reading pages > before potentially overwriting them will actually take more time than > blindly overwriting 14 pages with 0x00. I looked at various datasheets and PROG time is indeed much bigger than READ time, so the benefit of reading before writing is mainly dependent on the page transfer time on the bus, which is highly dependent on the controller and the page size. Maybe it's not such a bad idea to try to figure out which pages have been written before overwriting them (but in some cases it might be worse than directly overwriting the 16 first pages). In any case, I think it'd be good to keep track of which pages have been programmed at runtime. Assuming you only want to track the 16 first pages, all you'll need is an u16 (bitmap) per block. When any of the 16 first pages of a block is written you set the corresponding bit, when the block is erased you clear the u16 entry. This way, you only have to figure out which blocks are partially written once after a cold boot. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/