Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] mtdchar: per-device bounce buffer policy
@ 2026-12-04  5:46 Ping Li
  2026-12-04  5:46 ` [PATCH v3 1/4] mtd: core: add per-device bounce buffer allocation helper Ping Li
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ping Li @ 2026-12-04  5:46 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr
  Cc: tudor.ambarus, kyungmin.park, linux-mtd, linux-kernel, Ping Li

This is the third revision of the RFC series, following Miquel's
review [1][2].  It implements the agreed direction: low-level drivers
decide whether they may receive non-linear-map buffers, and a helper
applies the allocation policy accordingly.

Patch 1 introduces mtd->allows_vmalloc_bufs (defaults to false,
partitions inherit it from their master) and mtd_alloc_buf()/
mtd_free_buf().  By default buffers come from mtd_kmalloc_up_to(),
which shrinks the size under fragmentation.  Drivers that can
handle non-linear-map buffers may set the flag to get
kvmalloc()'s vmalloc fallback instead, so a large read()/write()
no longer degrades into many small mtd_read()/mtd_write() calls.

Patch 2 converts mtdchar_read()/mtdchar_write() to the helper.

Patches 3 and 4 add the first two users.  Both the hyperbus and
Samsung OneNAND controllers handle vmalloc'd buffers by design
(CPU copy fallback and per-page DMA mapping respectively), so they
opt in.  These conversions are compile-tested only.

Changes in v3:
- Drop the RFC tag.
- Add two in-tree users (patches 3 and 4), per Miquel's request.

Numbers from our platform (an IPC-backed NOR flash device where
each mtd_read()/mtd_write() is forwarded to a remote controller):

  - one transaction costs t ~= 20ms + 0.3ms/KB, i.e. ~620ms for
    the 2M+2K transfer this platform uses for OTA updates;

  - with the opt-in, every 2M+2K read() issued during the tests
    (~80 runs across clean, fragmented and severely fragmented
    memory states) produced exactly one transaction, in every
    single run;

  - without the opt-in, the same command was observed to produce
    both single full-size and halved (len=1049600, two
    transactions) transfers within the same session, depending on
    transient allocator state.  The split is not reproducible on
    demand;

  - wall-clock throughput is not the benefit: a halved transfer
    pays only one extra fixed cost (~3%).  The benefit is
    determinism: the opt-in makes the transaction count and buffer
    size independent of memory state, which is what
    transaction-bound backends need.

[1] https://lore.kernel.org/linux-mtd/875wxtf8uy.fsf@bootlin.com/
[2] https://lore.kernel.org/linux-mtd/87ecbyk5wo.fsf@bootlin.com/

Ping Li (4):
  mtd: core: add per-device bounce buffer allocation helper
  mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers
  mtd: hyperbus: accept vmalloc'd bounce buffers
  mtd: onenand: samsung: accept vmalloc'd bounce buffers

 drivers/mtd/hyperbus/hyperbus-core.c       |  1 +
 drivers/mtd/mtdchar.c                      | 24 ++++++------
 drivers/mtd/mtdcore.c                      | 44 ++++++++++++++++++++++
 drivers/mtd/mtdpart.c                      |  1 +
 drivers/mtd/nand/onenand/onenand_samsung.c |  2 +
 include/linux/mtd/mtd.h                    | 16 ++++++++
 6 files changed, 77 insertions(+), 11 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2026-12-04  6:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  5:46 [PATCH v3 0/4] mtdchar: per-device bounce buffer policy Ping Li
2026-12-04  5:46 ` [PATCH v3 1/4] mtd: core: add per-device bounce buffer allocation helper Ping Li
2026-12-04  6:03   ` sashiko-bot
2026-12-04  5:46 ` [PATCH v3 2/4] mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers Ping Li
2026-12-04  6:03   ` sashiko-bot
2026-12-04  5:46 ` [PATCH v3 3/4] mtd: hyperbus: accept vmalloc'd " Ping Li
2026-12-04  6:04   ` sashiko-bot
2026-12-04  5:46 ` [PATCH v3 4/4] mtd: onenand: samsung: " Ping Li
2026-12-04  6:04   ` sashiko-bot

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