mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 4/4] mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffers
Date: Fri,  4 Dec 2026 17:16:40 +0800	[thread overview]
Message-ID: <20261204091640.444442-5-leeonion.muyu@gmail.com> (raw)
In-Reply-To: <20261204091640.444442-1-leeonion.muyu@gmail.com>

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@gmail.com>
---
 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


      parent 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 [PATCH v4 0/4] mtdchar: per-device bounce buffer policy Ping Li
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 ` Ping Li [this message]

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-5-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®