summaryrefslogtreecommitdiff
path: root/samples/rpmsg
diff options
context:
space:
mode:
authorTanmay Shah <tanmay.shah@amd.com>2026-08-28 07:58:52 -0700
committerMathieu Poirier <mathieu.poirier@linaro.org>2026-09-04 14:14:37 -0600
commit1029c89bafc714c1b987f29e3bc124a7b63d28d5 (patch)
tree2ac05073f66bbed9c948f0a836c443bed86634ca /samples/rpmsg
parent079844f735f7a3917bc05a78ce33e1ab3901e8d2 (diff)
samples: rpmsg: Add MTU size info
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. Signed-off-by: Tanmay Shah <tanmay.shah@amd.com> Acked-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20260828145853.2843486-6-tanmay.shah@amd.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'samples/rpmsg')
-rw-r--r--samples/rpmsg/rpmsg_client_sample.c20
1 files changed, 19 insertions, 1 deletions
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;