On Thu, Jun 04, 2026 at 05:28:13PM -0500, Shah, Tanmay wrote:
> 
> 
> On 6/2/2026 3:34 AM, Arnaud POULIQUEN wrote:
> > 
> > 
> > On 5/29/26 18:43, Tanmay Shah wrote:
> >> 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 <[email protected]>
> >> ---
> >>
> >> Changes in v3:
> >>    - Check for error when retrieving MTU size
> >>    - %s/mtu/MTU/
> >>
> >>   samples/rpmsg/rpmsg_client_sample.c | 9 +++++++++
> >>   1 file changed, 9 insertions(+)
> >>
> >> diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/
> >> rpmsg_client_sample.c
> >> index ae5081662283..55afa53189af 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;
> >>         dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
> >>                       rpdev->src, rpdev->dst);
> >> @@ -62,6 +63,14 @@ 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);
> >> +
> > 
> > Do you really need this commit? rpmsg_send should return an error if the
> > buffer size is insufficient [1].
> > 
> > [1] https://elixir.bootlin.com/linux/v7.0.10/source/drivers/rpmsg/
> > virtio_rpmsg_bus.c#L517
> > 
> 
> Here, I just want to demonstrate rpmsg_get_mtu() API. Now we can have a
> configurable size of the RPMsg buffer. So rpmsg_get_mtu() API can be
> used to check correct buffer length before even using rpmsg_send() API.
>

Since this is a demonstration, I think there is value in showing how to
use the API correctly.  There is certainly no disadvantage in doing so.
 
> I think I should check msg length against mtu size as well.
> 

I agree.

> 
> > Regards,
> > Arnaud
> > 
> >>       /* send a message to our remote processor */
> >>       ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
> >>       if (ret) {
> > 
> 

Reply via email to