[PATCH v4 4/4] mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffers
From: Ping Li
Date: Fri Dec 04 2026 - 04:17:04 EST
rpc-if copies data with the CPU only: bulk reads end up in
memcpy_fromio() (rpcif_dirmap_read()), and writes go through
write16()/manual transfers, so vmalloc'd bounce buffers are
safe to hand over. Opt in to keep large read()/write()
transfers in one piece under fragmentation.
Only rpc-if opts in; am654-hbmc has a DMA fast path which a
vmalloc'd buffer would bypass, so it keeps the default behaviour.
The flag is set on the hyperbus device before registration and
copied to the mtd_info before mtd_device_register(): partitions
are parsed inside that call and inherit the flag from their
master at allocation time, so setting it on the registered
master would come too late for them.
Signed-off-by: Ping Li <leeonion.muyu@xxxxxxxxx>
---
drivers/mtd/hyperbus/hyperbus-core.c | 1 +
drivers/mtd/hyperbus/rpc-if.c | 1 +
include/linux/mtd/hyperbus.h | 2 ++
3 files changed, 4 insertions(+)
diff --git a/drivers/mtd/hyperbus/hyperbus-core.c b/drivers/mtd/hyperbus/hyperbus-core.c
index 4d8047d43e48e..be6dbed113385 100644
--- a/drivers/mtd/hyperbus/hyperbus-core.c
+++ b/drivers/mtd/hyperbus/hyperbus-core.c
@@ -114,6 +114,7 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
hbdev->mtd->dev.parent = dev;
mtd_set_of_node(hbdev->mtd, np);
+ hbdev->mtd->allows_vmalloc_bufs = hbdev->allows_vmalloc_bufs;
ret = mtd_device_register(hbdev->mtd, NULL, 0);
if (ret) {
diff --git a/drivers/mtd/hyperbus/rpc-if.c b/drivers/mtd/hyperbus/rpc-if.c
index 9eacc9ec7382d..dc172709d1267 100644
--- a/drivers/mtd/hyperbus/rpc-if.c
+++ b/drivers/mtd/hyperbus/rpc-if.c
@@ -142,6 +142,7 @@ static int rpcif_hb_probe(struct platform_device *pdev)
hyperbus->ctlr.dev = dev;
hyperbus->ctlr.ops = &rpcif_hb_ops;
hyperbus->hbdev.ctlr = &hyperbus->ctlr;
+ hyperbus->hbdev.allows_vmalloc_bufs = true;
hyperbus->hbdev.np = of_get_next_child(pdev->dev.parent->of_node, NULL);
error = hyperbus_register_device(&hyperbus->hbdev);
if (error)
diff --git a/include/linux/mtd/hyperbus.h b/include/linux/mtd/hyperbus.h
index bb6b7121a5427..c753cade9d82f 100644
--- a/include/linux/mtd/hyperbus.h
+++ b/include/linux/mtd/hyperbus.h
@@ -32,6 +32,7 @@ enum hyperbus_memtype {
* @ctlr: pointer to HyperBus controller struct
* @memtype: type of memory device: HyperFlash or HyperRAM
* @priv: pointer to controller specific per device private data
+ * @allows_vmalloc_bufs: whether the device may receive vmalloc'd buffers
*/
struct hyperbus_device {
@@ -41,6 +42,7 @@ struct hyperbus_device {
struct hyperbus_ctlr *ctlr;
enum hyperbus_memtype memtype;
void *priv;
+ bool allows_vmalloc_bufs;
};
/**
--
2.34.1