Re: [PATCH v7 1/2] rpmsg: core: add API to get MTU

From: Arnaud POULIQUEN
Date: Wed Apr 01 2020 - 07:34:42 EST



On 4/1/20 8:29 AM, Jiri Slaby wrote:
> On 01. 04. 20, 8:28, Jiri Slaby wrote:
>> On 24. 03. 20, 18:04, Arnaud Pouliquen wrote:
>>> Return the rpmsg buffer MTU for sending message, so rpmsg users
>>> can split a long message in several sub rpmsg buffers.
>>>
>>> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@xxxxxx>
>>> Acked-by: Suman Anna <s-anna@xxxxxx>
>>> ---
>>> drivers/rpmsg/rpmsg_core.c | 21 +++++++++++++++++++++
>>> drivers/rpmsg/rpmsg_internal.h | 2 ++
>>> drivers/rpmsg/virtio_rpmsg_bus.c | 10 ++++++++++
>>> include/linux/rpmsg.h | 10 ++++++++++
>>> 4 files changed, 43 insertions(+)
>>>
>>> diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
>>> index e330ec4dfc33..a6ef54c4779a 100644
>>> --- a/drivers/rpmsg/rpmsg_core.c
>>> +++ b/drivers/rpmsg/rpmsg_core.c
>>> @@ -283,6 +283,27 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
>>> }
>>> EXPORT_SYMBOL(rpmsg_trysend_offchannel);
>>>
>>> +/**
>>> + * rpmsg_get_mtu() - get maximum transmission buffer size for sending message.
>>> + * @ept: the rpmsg endpoint
>>> + *
>>> + * This function returns maximum buffer size available for a single message.
>>> + *
>>> + * Return: the maximum transmission size on success and an appropriate error
>>> + * value on failure.
>>> + */
>>> +
>>> +ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept)
>>> +{
>>> + if (WARN_ON(!ept))
>>> + return -EINVAL;
>>> + if (!ept->ops->get_mtu)
>>> + return -ENOTSUPP;
>>
>> Hmm, I don't think all callers of tty_write_room() handle negative values...
>>
>> But some drivers also return negative values. There is some work to be
>> done, adding to TODO.
>>
>> For the time being, I suggest returning 0 instead.
>
> Or better, convert the negative to 0 in rpmsg_tty_write_room for now.
>
>> thanks,--

Right, seems that a negative return of tty_write_room seems not always handled
so i will force to 0 in rpmsg_tty in case of error returned. I will also
add a comment in code that explain the context.

Thanks,
Arnaud