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

   ## Summary
   
   `drivers/rpmsg/rpmsg_virtio: add an option to start the device
   synchronously`: `rpmsg_virtio_probe_cpuname()` queues the rpmsg device
   bring-up on the rpmsg work queue, so it returns before `/dev/rpmsg/<cpu>`
   exists and before any service has seen the device. The new
   `CONFIG_RPMSG_VIRTIO_START_SYNC` (default n) runs the bring-up inline in
   the probe instead, so the device is ready when the probe returns.
   
   ### What the option needs
   
   With the option, the bring-up announces the local services from the
   probe's caller, outside the rpmsg work queue, and holds the rpmsg
   callback lock while it does. Both cores must then let their rpmsg work
   queues recurse deep enough to answer all start-up announcements;
   otherwise both wait for tx buffers forever:
   
   ```
   vhost side: bring-up holds the callback lock, waits for a tx buffer
     -> its work queue waits for the lock, takes no rx  (stage 1)
     -> resolves only while the peer's work queue keeps dispatching
   both sides: each work queue answers the other's announcements, waits for
     a tx buffer, dispatches the next one recursively
     -> at RPMSG_RECURSIVE_LIMIT it stops dispatching and keeps the rx
        buffers the peer needs for its tx  (stage 2)
   ```
   
   Measured on sim (17 announced services, 8 buffers per direction), the
   option on both sides, three boots per row:
   
   | `RPMSG_RECURSIVE_LIMIT` | result |
   |---|---|
   | 2 on both (master default for a 2 KB work queue stack) | hangs: `Assertion 
failed : at file: .../rpmsg_virtio.c:303` |
   | 3 on both | hangs |
   | 4 on both | works |
   | 8 on both (sim default since apache/nuttx#22291) | works |
   | 4 on the server, 2 on the proxy | hangs |
   | 2 on the server, 4 on the proxy | hangs |
   
   The Kconfig help of the option says this.
   
   ## Impact
   
   - New Kconfig `RPMSG_VIRTIO_START_SYNC`, default n; no change otherwise.
   - With the option, the probe's caller blocks until the rpmsg device is
     up, and the recursion limit requirement above applies.
   
   ## 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
   
   The commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
   qemu-armv8a:rpproxy with and without `CONFIG_RPMSG_VIRTIO_START_SYNC=y`,
   with 0 warnings.
   
   On master (`RPMSG_RECURSIVE_LIMIT` 8 on sim, 6 on qemu-armv8a),
   server and proxy started together, then `rpmsg ping all 10 64 1 0` and
   `echo alive` on the server; five boots each:
   
   | option on | sim:rpserver + rpproxy | qemu-armv8a:rpserver + rpproxy |
   |---|---|---|
   | both sides | 5/5 | 5/5 (ivshmem and rpmsg_port_uart links) |
   | vhost side (proxy) only | 5/5 | 5/5 |
   
   The limit table above was measured on the same code with
   `CONFIG_RPMSG_RECURSIVE_LIMIT` set explicitly.
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). 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]

Reply via email to