Re: [PATCH V8 3/3] rpmsg: char: Add RPMSG GET/SET FLOWCONTROL IOCTL support

From: Bjorn Andersson
Date: Wed Jul 05 2023 - 22:54:18 EST


On Fri, Jun 23, 2023 at 11:11:03AM +0200, Arnaud POULIQUEN wrote:
> On 6/21/23 17:34, Sarannya S wrote:
[..]
> > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
[..]
> > + switch (cmd) {
> > + case RPMSG_GET_OUTGOING_FLOWCONTROL:
> > + eptdev->remote_flow_updated = false;
> > + ret = put_user(eptdev->remote_flow_restricted, (int __user *)arg);
> > + break;
> > + case RPMSG_SET_INCOMING_FLOWCONTROL:
> > + set = !!arg;
> > + ret = rpmsg_set_flow_control(eptdev->ept, set, eptdev->chinfo.dst);
> > + break;
> > + case RPMSG_DESTROY_EPT_IOCTL:
> > + /* Don't allow to destroy a default endpoint. */
> > + if (eptdev->default_ept) {
> > + ret = -EINVAL;
> > + break;
> > + }
> > + ret = rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL);
> > + break;
> > + default:
> > + ret = -EINVAL;
> > + }
> >
> > - return rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL);
> > + return ret;
> > }
> >
> > static const struct file_operations rpmsg_eptdev_fops = {
> > diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h
> > index 1637e68..b0a6c17 100644
> > --- a/include/uapi/linux/rpmsg.h
> > +++ b/include/uapi/linux/rpmsg.h
> > @@ -43,4 +43,14 @@ struct rpmsg_endpoint_info {
> > */
> > #define RPMSG_RELEASE_DEV_IOCTL _IOW(0xb5, 0x4, struct rpmsg_endpoint_info)
> >
> > +/**
> > + * Set the flow control for the remote rpmsg char device.

We improved the wording elsewhere in the patch, to make the description
of what the interface controls/exposes. This would benefit from the same
attention.

And this says "Set" while the ioctl says "GET".

> > + */
> > +#define RPMSG_GET_OUTGOING_FLOWCONTROL _IOW(0xb5, 0x5, struct rpmsg_endpoint_info)
> > +
> > +/**
> > + * Set the flow control for the local rpmsg char device.
> > + */
> > +#define RPMSG_SET_INCOMING_FLOWCONTROL _IOW(0xb5, 0x6, struct rpmsg_endpoint_info)
>
>
> Perhaps I missed something, but you use "rpmsg_endpoint_info" as argument.
> In rpmsg_eptdev_ioctl the argument is treated as a boolean.
> Seems to me that something is wrong here.
>

This is indeed an int in the implementation above.

Regards,
Bjorn

> regards,
> Arnaud
>
> > +
> > #endif