[PATCH v3 0/3] mtd: write support for minor-aligned partitions

Thibaut VARÈNE hacks+kernel at slashdirt.org
Fri Jul 29 02:16:33 PDT 2022


This patch series enable write support for minor-aligned mtd partitions
on devices that support multiple erasesizes.

On supporting hardware, they enable RW operations on mtd partitions that
break "major" (largest) erasesize boundary (e.g. too small or not
correctly aligned) without sacrificing performance (i.e. forcing
everything to use 4K sectors). Finally, they address an historical FIXME
in mtdpart.c.

The following performance numbers were measured with v5.10 kernel on OpenWrt:
(CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE=y forces the use of the new code path)

OpenWrt 5.10 ramips MT7621 w25q128jv 0xfc0000 firmware partition length
time mtd erase firmware

Without this patch:
MTD_SPI_NOR_USE_4K_SECTORS=n	|y
real    0m 50.86s		|2m 11.66s
user    0m 0.00s		|0m 0.00s
sys     0m 50.80s		|1m 56.20s
can write minor-aligned parts? N|Y

With this patch:
MTD_SPI_NOR_USE_VARIABLE_ERASE=n|y		|4K_SECTORS=y
real    0m 51.68s		|0m 50.85s	|2m 12.89s
user    0m 0.00s		|0m 0.00s	|0m 0.01s
sys     0m 46.94s		|0m 50.38s	|2m 12.46s
can write minor-aligned parts? N|Y		|Y


NB: This patchset was previously submitted as a monolithic patch (RFC[0],
v1[1]). While not submitted upstream v2 was however reviewed, tested and
accepted in OpenWrt, and backported into the upcoming 22.03 stable branch:
https://github.com/openwrt/openwrt/pull/3271

[0] 20210104122853.18428-1-git at johnthomson.fastmail.com.au
[1] 20210608040719.14431-1-git at johnthomson.fastmail.com.au

Changes v2 -> v3:
  - Split patch into incremental, functionally-separate changes.
  - Adjusted erasesize_minor assignment check in spi-nor/core.c
  - Addressed checkpatch warning on "printk(KERN_WARNING..."
  - Documented new sysfs attribute

Changes v1 -> v2:
  - Added mtdcore sysfs attribute for erasesize_minor
  - Removed finding minor erasesize for variable erase regions device,
    (untested and no response to RFC).
  - Moved IF_ENABLED() to guard setting erasesize_minor in spi-nor/core.c
  - Removed setting major erasesize to minor where partition boundaries
    require minor erase to be writable
  - Simplified minor boundary check by relying on minor being a factor
    of major

Changes RFC -> v1:
  - Fixed uninitialized variable smatch warning

Thibaut VARÈNE (3):
  mtd: mtdpart: write support for minor-aligned partitions
  mtd: spi-nor: set erasesize_minor in spi_nor_select_erase()
  mtd: spi-nor: allow overriding uniform erase

 Documentation/ABI/testing/sysfs-class-mtd |  8 ++++++
 drivers/mtd/mtdcore.c                     | 10 +++++++
 drivers/mtd/mtdpart.c                     | 35 ++++++++++++++++-------
 drivers/mtd/spi-nor/Kconfig               | 10 +++++++
 drivers/mtd/spi-nor/core.c                | 13 +++++++--
 include/linux/mtd/mtd.h                   |  2 ++
 6 files changed, 65 insertions(+), 13 deletions(-)


base-commit: e0dccc3b76fb35bb257b4118367a883073d7390e
-- 
2.30.2




More information about the linux-mtd mailing list