From: Ping Li <leeonion.muyu@gmail.com>
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: tudor.ambarus@linaro.org, kyungmin.park@samsung.com,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Ping Li <leeonion.muyu@gmail.com>
Subject: [PATCH v4 0/4] mtdchar: per-device bounce buffer policy
Date: Fri, 4 Dec 2026 17:16:36 +0800 [thread overview]
Message-ID: <20261204091640.444442-1-leeonion.muyu@gmail.com> (raw)
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/875wxtf8uy.fsf@bootlin.com/
[2] https://lore.kernel.org/linux-mtd/87ecbyk5wo.fsf@bootlin.com/
[3] https://lore.kernel.org/linux-mtd/20261204054630.3443342-1-leeonion.muyu@gmail.com/
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
--
2.34.1
next reply other threads:[~2026-12-04 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:16 Ping Li [this message]
2026-12-04 9:16 ` [PATCH v4 1/4] mtd: core: add per-device bounce buffer allocation helper Ping Li
2026-12-04 9:16 ` [PATCH v4 2/4] mtd: mtdchar: clamp bounce buffer size to the remaining transfer Ping Li
2026-12-04 9:16 ` [PATCH v4 3/4] mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers Ping Li
2026-12-04 9:16 ` [PATCH v4 4/4] mtd: hyperbus: rpc-if: accept vmalloc'd " Ping Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204091640.444442-1-leeonion.muyu@gmail.com \
--to=leeonion.muyu@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®