Skip to content

mtdchar: per-device bounce buffer policy

Ping Li linux-mtd lkml stable 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 0 repliesNew
  2. v34 patches 0 repliesSuperseded
  3. v2 RFC2 patches 1 replySuperseded

Changes in v4 from the cover letter

- Add __GFP_NORETRY to the kvmalloc() call to avoid the OOM killer.
- Fix the unclamped bounce buffer size as a separate patch.
- Restrict the hyperbus opt-in to rpc-if only, instead of opting in both controllers from the core.
- Drop the onenand samsung opt-in (its DMA path only serves aligned, single-page accesses, so a vmalloc'd buffer would hurt performance for unaligned transfers).
- Re-run the platform tests on this revision: the opt-in still delivers the full-size transfer in one piece under heavy fragmentation, matching the v3 numbers.

[1] https://lore.kernel.org/linux-mtd/[email protected]/
[2] https://lore.kernel.org/linux-mtd/[email protected]/
[3] https://lore.kernel.org/linux-mtd/[email protected]/

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4mtd: core: add per-device bounce buffer allocation helperdrivers/mtd/mtdcore.c drivers/mtd/mtdpart.c include/linux/mtd/mtd.h+55 -00 replies
2/4mtd: mtdchar: clamp bounce buffer size to the remaining transferdrivers/mtd/mtdchar.c+4 -20 replies
3/4mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffersdrivers/mtd/mtdchar.c+12 -120 replies
4/4mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffersdrivers/mtd/hyperbus/hyperbus-core.c drivers/mtd/hyperbus/rpc-if.c include/linux/mtd/hyperbus.h+4 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/4] mtdchar: per-device bounce buffer policy

This series implements a per-device bounce buffer allocation policy:
low-level drivers decide whether they may receive non-linear-map buffers, and a helper applies the allocation policy accordingly. The design follows the discussion with Miquel [1][2], and the previous revision of this series is at [3].

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 fixes a pre-existing bug found while re-reviewing v3:
the bounce buffer size is taken from the unclamped count, so a read() near the end of a device allocates far more than the actual transfer.

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

Patch 4 is the first user: rpc-if copies data with the CPU (memcpy_fromio), so vmalloc'd buffers are safe to hand over; am654-hbmc, whose DMA fast path a vmalloc'd buffer would bypass, keeps the default behaviour. This conversion is compile-tested only.

Changes in v4:
- Add __GFP_NORETRY to the kvmalloc() call to avoid the OOM killer.
- Fix the unclamped bounce buffer size as a separate patch.
- Restrict the hyperbus opt-in to rpc-if only, instead of opting in both controllers from the core.
- Drop the onenand samsung opt-in (its DMA path only serves aligned, single-page accesses, so a vmalloc'd buffer would hurt performance for unaligned transfers).
- Re-run the platform tests on this revision: the opt-in still delivers the full-size transfer in one piece under heavy fragmentation, matching the v3 numbers.

[1] https://lore.kernel.org/linux-mtd/[email protected]/
[2] https://lore.kernel.org/linux-mtd/[email protected]/
[3] https://lore.kernel.org/linux-mtd/[email protected]/

Ping Li (4):
mtd: core: add per-device bounce buffer allocation helper
mtd: mtdchar: clamp bounce buffer size to the remaining transfer
mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers
mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffers

 drivers/mtd/hyperbus/hyperbus-core.c |  1 +
 drivers/mtd/hyperbus/rpc-if.c        |  1 +
 drivers/mtd/mtdchar.c                | 30 ++++++++++---------
 drivers/mtd/mtdcore.c               | 45 ++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c               |  1 +
 include/linux/mtd/hyperbus.h         |  2 ++
 include/linux/mtd/mtd.h             |  9 ++++++
 7 files changed, 75 insertions(+), 14 deletions(-)

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3

Signature · 1 line
2.34.1