mbox series

[00/13] introduce IOCTL interface for RPMsg channel management

Message ID 20200731121043.24199-1-arnaud.pouliquen@st.com (mailing list archive)
Headers show
Series introduce IOCTL interface for RPMsg channel management | expand

Message

Arnaud POULIQUEN July 31, 2020, 12:10 p.m. UTC
This serie is inspired by the RPMsg char driver. The RPMsg char driver
provides interfaces that:
- expose a char RPMsg device for communication with the remote processor
- expose controls interface for applications to create and release channels

The purpose of this series is to decorrelate the two interfaces:
 - provide a char device for a RPMsg raw service similar to the rpmsg_char
   but that can be probed by a RPMsg bus on a ns announcement
 - generalize the use of the ioctl for all RPMsg services.

1) rpmsg raw driver: rpmsg_raw.c
For legacy reason, I created a new file instead of modifying the rpmsg_char
driver. But the rework of the rpmsg_char driver to only support the RPMsg
raw service could be an alternative
Few differences can be found:
    - The rpmsg class has not been implemented. The associated attributes
      are already available in /sys/bus/rpmsg/.
    - The eptdev device is now an RPMsg device probed by a RPMsg bus driver
      (probed only by the ioctl in rpmsg_char driver).
    - The associated endpoint is now created by the bus no more on the
      devfs open.

2) RPMsg control driver: rpmsg_ctrl.c
  This driver is based on the control part of the RPMsg_char driver. 
  On probe a /dev/rpmsg_ctrl<X> interface is created to allow to manage the
  channels.
  The principles are the following:
  - The RPMsg service driver registers it's name and the associated service
    using the rpmsg_ctrl_unregister_ctl API. The list of supported services
    is defined in  include/uapi/linux/rpmsg.h and exposed to the
    application thanks to a new field in rpmsg_endpoint_info struct.
  - On the RPMsg bus probe(e.g virtio bus) an rpmsg_ctrl device is
    registered that creates the control interface.
  - The application can then create or release a channel by specifying:
       - the name service
       - the source address (default: RPMSG_ADDR_ANY)
       - the destination address ( default: RPMSG_ADDR_ANY)
       - the associated service (new)
  - The rpmsg_ctrl uses the same interface than the ns announcement to
    create and release the channel but using the driver_override field to
    force the service name.
    The  "driver_override" allows to force the name service associated to
    an RPMsg driver, bypassing the rpmsg_device_id based match check.
  - At least for virtio bus, an associated ns announcement is sent to the
    remote side.  

Know current Limitations:
- Tested only with virtio RPMsg bus and for one vdev instance.
- rpmsg_device_match does not allow to match a local endpoint created by
  ioctl with a same service requested by the ns announcement callback.
- Current implementation of the release makes it possible to release any
  endpoint, even not created by the ioctl. Should we limit the release to
  the RPMsg channel created with the ioctl? 

This serie can be applied in Bjorn's rpmsg-next branch on top of the
RPMsg_ns series.

This series can be tested using rpmsgexport tools updated according to the
ioctl update and available here: https://github.com/arnopo/rpmsgexport. 

Arnaud Pouliquen (13):
  rpmsg: introduce rpmsg raw driver
  rpmsg: introduce rpmsg_control driver for channel creation
  rpmsg: add helper to create the rpmsg ctrl device
  rpmsg: virtio: probe the rpmsg_ctrl device
  rpmsg: uapi: add service param for create destroy ioctls
  rpmsg: add RPMsg control info structure
  rpmsg: control: add driver registration API
  rpmsg: raw: register service to the rpmsg control
  rpmsg: add override field in channel info
  rpmsg: ns: initialize channel info override field
  rpmsg: virtio: use the driver_override in channel creation
  rpmsg: control: implement the ioctrl function to create device
  rpmsg: ctrl: add support of the endpoints release

 drivers/rpmsg/Kconfig            |  17 ++
 drivers/rpmsg/Makefile           |   2 +
 drivers/rpmsg/rpmsg_ctrl.c       | 314 ++++++++++++++++++++++++++
 drivers/rpmsg/rpmsg_internal.h   |  18 ++
 drivers/rpmsg/rpmsg_ns.c         |   1 +
 drivers/rpmsg/rpmsg_raw.c        | 364 +++++++++++++++++++++++++++++++
 drivers/rpmsg/virtio_rpmsg_bus.c |  37 +++-
 include/linux/rpmsg.h            |  15 ++
 include/uapi/linux/rpmsg.h       |  17 ++
 9 files changed, 784 insertions(+), 1 deletion(-)
 create mode 100644 drivers/rpmsg/rpmsg_ctrl.c
 create mode 100644 drivers/rpmsg/rpmsg_raw.c