CV-Bowen opened a new pull request, #22142:
URL: https://github.com/apache/nuttx/pull/22142

   ## Summary
   
   Changes to the rpmsg character device (`drivers/misc/rpmsgdev.c`,
   `rpmsgdev_server.c`), in the order they were made. First part of the
   rpmsgdev changes; the later ones (custom ioctl, `rpmsgdev_unregister()`,
   fragmented reads, preallocated open slots, ...) follow in a separate PR.
   
   - `forward MSIOC_GRAB`: let a mouse exported over rpmsgdev be grabbed.
   - `always handle FIONBIO locally`: the server accesses the device from
     the rpmsg work queue and must stay non-blocking, so the client keeps
     the O_NONBLOCK state and no longer forwards FIONBIO.
   - `check that the payload can hold the ioctl packet`: return -EMSGSIZE
     instead of copying an ioctl argument past the tx buffer.
   - `remove the fragmentation support`: most character drivers do not
     handle a read or write split into pieces. Each read/write is one
     message; `RPMSGDEV_NOFRAG_*`, `RPMSGDEV_READ_NOFRAG` and the `flags`
     argument of `rpmsgdev_register()` are removed (sim board updated).
   - `create the work queue on export`: `rpmsgdev_export_with_prefix()` can
     run before `rpmsgdev_server_init()`; create the work queue in either.
   - `reset the bound count when the device goes away`: a request issued
     after the rpmsg device was destroyed used the destroyed endpoint
     instead of waiting for the next binding.
   - `support blocking reads in the server`: a blocking client read used to
     poll the server in a loop. `RPMSGDEV_READ` now blocks on the server
     side (the server polls the device and replies from its work queue),
     `RPMSGDEV_READ_NONBLOCK` is the non-blocking form.
   - `keep the poll work per device`: devices of one server shared one poll
     notification work, so one device's notification could replace
     another's.
   - `split writes that do not fit in one buffer`: after the fragmentation
     removal a write larger than a tx buffer failed with -EMSGSIZE; send it
     in buffer sized pieces again.
   - `allocate request messages from the rpmsg pool`,
     `default the rpmsg pool to 16 buffers with stack protection`: the
     receive work writes replies into request messages that were on the
     caller's stack, which a work queue cannot access with stack
     protection.
   - `wait for the endpoint in every operation`: every request now waits
     until the endpoint is bound to the server.
   
   The only out-of-tree-style caller, apps `testing/drivers/rpmsgdev`
   (`RPMSGDEV_TEST`), is updated in apache/nuttx-apps#APPSPR; merge both
   together.
   
   ## Impact
   
   - API: `rpmsgdev_register()` loses its `flags` argument;
     `RPMSGDEV_NOFRAG_READ` / `RPMSGDEV_NOFRAG_WRITE` are removed. The only
     in-tree caller (sim) is updated.
   - Protocol: `RPMSGDEV_READ_NOFRAG` is gone and the read commands are
     renumbered (`RPMSGDEV_READ_NONBLOCK` 3, `RPMSGDEV_READ` 4); client and
     server must be updated together.
   - Behaviour: a single read returns at most one tx buffer of data; FIONBIO
     is no longer seen by the exported driver.
   - Kconfig: `RPMSG_POOL_COUNT` defaults to 16 when `ARCH_STACK_PROTECT` or
     `ARCH_KSTACK_PROTECT` is set (0 otherwise, as before).
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
   qemu-armv8a:rpproxy with 0 warnings.
   
   sim:rpserver + sim:rpproxy (unchanged configs: the proxy registers the
   server's `/dev/console`, `/dev/null` and `/dev/ttyUSB0` through rpmsgdev).
   Commands on the proxy, same results on master and with this PR (master
   1 run, this PR 2 runs, and once more with `CONFIG_RPMSG_POOL_COUNT=4`):
   
   | proxy command | result |
   |---|---|
   | `ls /dev` | `server-console`, `server-null`, `ttyUSB0` present |
   | `echo p126-small > /dev/server-console` | text printed by the server 
console |
   | `dd if=/dev/zero of=/dev/server-null bs=4096 count=4` | `16384 bytes (4 
blocks) copied` (writes larger than a tx buffer) |
   | `dd if=/dev/server-null of=/dev/null bs=64 count=1` | `0 bytes` (read, 
EOF) |
   | `cat /dev/server-null` | returns |
   | `rpmsg dump all` | `ept rpdev/dev/null`, `rpdev/dev/console`, 
`rpdev/dev/tty...` bound |
   
   Not tested: a blocking read that has to wait for data on the server, two
   devices of one server polling at the same time, an ioctl argument larger
   than the tx buffer, FIONBIO on an exported device, device teardown while
   a request is pending, and stack protection builds.
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 21/21, including the rpmsgdev cases above). qemu-armv8a was built with 
LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current master needs for 
nxinit to start nsh there; unrelated to this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] drivers/misc/rpmsgdev: s... CV-Bowen (via GitHub) via commits

Reply via email to