From: Tanmay Shah <tanmay.shah@amd.com>
To: <andersson@kernel.org>, <mathieu.poirier@linaro.org>,
<corbet@lwn.net>, <skhan@linuxfoundation.org>
Cc: <linux-remoteproc@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Tanmay Shah <tanmay.shah@amd.com>
Subject: [PATCH v6 5/5] samples: rpmsg: add MTU size info
Date: Thu, 13 Aug 2026 21:42:38 -0700 [thread overview]
Message-ID: <20260814044238.518296-6-tanmay.shah@amd.com> (raw)
In-Reply-To: <20260814044238.518296-1-tanmay.shah@amd.com>
RPMsg MTU size can be variable now and no longer hardcoded to 512 bytes.
Add log to the sample driver that prints current MTU size of the rpmsg
buffer.
Changes in v4:
- check msg size is < MTU size
Changes in v3:
- Check for error when retrieving MTU size
- %s/mtu/MTU/
Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
---
samples/rpmsg/rpmsg_client_sample.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c
index ae5081662283..4c43436aadb6 100644
--- a/samples/rpmsg/rpmsg_client_sample.c
+++ b/samples/rpmsg/rpmsg_client_sample.c
@@ -52,6 +52,7 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
{
int ret;
struct instance_data *idata;
+ ssize_t mtu, msg_len;
dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
rpdev->src, rpdev->dst);
@@ -62,8 +63,25 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
dev_set_drvdata(&rpdev->dev, idata);
+ mtu = rpmsg_get_mtu(rpdev->ept);
+ if (mtu < 0) {
+ dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %ld\n", mtu);
+ return mtu;
+ }
+
+ dev_info(&rpdev->dev, "rpmsg MTU size = %ld\n", mtu);
+
+ msg_len = strlen(MSG);
+ /* make sure our message fits in a single rpmsg buffer */
+ if (msg_len > mtu) {
+ dev_err(&rpdev->dev,
+ "message size %zu exceeds rpmsg MTU size %ld\n",
+ strlen(MSG), mtu);
+ return -EMSGSIZE;
+ }
+
/* send a message to our remote processor */
- ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
+ ret = rpmsg_send(rpdev->ept, MSG, msg_len);
if (ret) {
dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
return ret;
--
2.43.0
prev parent reply other threads:[~2026-08-14 4:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 4:42 [PATCH v6 0/5] Enhance RPMsg buffer management Tanmay Shah
2026-08-14 4:42 ` [PATCH v6 1/5] rpmsg: virtio_rpmsg_bus: rename rbufs and sbufs Tanmay Shah
2026-08-14 4:42 ` [PATCH v6 2/5] rpmsg: virtio_rpmsg_bus: allow different size of tx and rx bufs Tanmay Shah
2026-08-14 4:42 ` [PATCH v6 3/5] rpmsg: virtio_rpmsg_bus: get buffer size from config space Tanmay Shah
2026-08-14 4:42 ` [PATCH v6 4/5] docs: rpmsg: add virtio config space details Tanmay Shah
2026-08-14 4:42 ` Tanmay Shah [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=20260814044238.518296-6-tanmay.shah@amd.com \
--to=tanmay.shah@amd.com \
--cc=andersson@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=skhan@linuxfoundation.org \
/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