[PATCH] mtd: spi-nor: write support for minor aligned partitions

John Thomson git at johnthomson.fastmail.com.au
Thu Jun 10 18:15:24 PDT 2021


On Thu, 10 Jun 2021, at 10:08, Pratyush Yadav wrote:
> On 08/06/21 02:07PM, John Thomson wrote:
> > Do not prevent writing to mtd partitions where a partition boundary sits
> > on a minor erasesize boundary.
> > This addresses a FIXME that has been present since the start of the
> > linux git history:
> > /* Doesn't start on a boundary of major erase size */
> > /* FIXME: Let it be writable if it is on a boundary of
> >  * _minor_ erase size though */
> > 
> > Allow a uniform erase region spi-nor device to be configured
> > to use the non-uniform erase regions code path for an erase with:
> > CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE=y
> > 
> > On supporting hardware (SECT_4K: majority of current SPI-NOR device)
> > provide the facility for an erase to use the least number
> > of SPI-NOR operations, as well as access to 4K erase without
> > requiring CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
> > 
> > Introduce erasesize_minor to the mtd struct,
> > the smallest erasesize supported by the device
> 
> Instead of having just a major and minor erase size, wouldn't it make 
> more sense to have a list of all supported erases on a sector? That is, 
> instead of hard coding two erase size instead of one, how about 
> generalizing the erase machinery to allow any number of erase sizes on a 
> sector and then choosing the most efficient one on run time?
> 
> For example, imagine a device can support 4K, 64K, and 256K erases on 
> each sector. Then you should be able to use 2 x 4K erases if you want to 
> erase 8K, 2 x 64K + 1 x 4K erases for 132K and so on.

Thank for you the feedback Pratyush,

Yes, this is what I am attempting to do.
mtdpart only sets if the partition can be writeable, it does not do the erasing.
Due to this, I thought that only the smallest erasesize should matter to mtdpart.
The erase is carried out by the mtd device, so for an SPI-NOR device,
spi_nor_erase_multi_sectors can be used to select and action the best combination of erases.
This is done by this patch when CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE=y

Cheers,
-- 
  John Thomson



More information about the linux-mtd mailing list