CV-Bowen opened a new pull request, #22248:
URL: https://github.com/apache/nuttx/pull/22248
## Summary
Four small rpmsg changes:
- `drivers/rpmsg/rpmsg_virtio: destroy the services before
unregistering`: `rpmsg_virtio_remove()` called `rpmsg_unregister()`,
which destroys `rpmsg->lock`, before `rpmsg_device_destroy()`, which
still takes that lock to free the pending bind records. The services
are now destroyed first, then the work queues, then the device is
unregistered.
- `drivers/rpmsg/rpmsg_ping: log the start and end of each ping run`: a
run printed statistics only at the end, and a failed send returned
without a message, so a stalled link left no trace. Each run now logs
its start and end with a per-device sequence number, a timestamp, the
two cpu names and the parameters; the end is logged also when a send
fails.
- `drivers/rpmsg: default the work queue stack to 8192 on 64-bit`: the rx
work queue overflowed a 4096-byte stack on a 64-bit target (3488 of
3632 usable bytes in use). `RPMSG_WQUEUE_STACKSIZE` defaults to
`DEFAULT_TASK_STACKSIZE` (2048 unless the board raises it); on
`ARCH_64BIT` it now defaults to 8192 when `DEFAULT_TASK_STACKSIZE` is
smaller.
- `drivers/rpmsg: tune the recursion limit for stack size and sim`: on
sim the stack size is not the real limit (`SIM_STACKSIZE_ADJUSTMENT` is
added to every task stack), yet a small `RPMSG_WQUEUE_STACKSIZE` gave a
recursion limit of 2; with the rx work queue stopped at that depth
while its queued rx work held every buffer from the remote, both cores
asserted with "Get tx buffer timeout". The limit now defaults to 8 on
sim; elsewhere it keeps 2 levels at 4KB and adds one per further 1KB
(one level costs 336 to 528 bytes, see the commit that introduced the
scaling), up to 8 above 9KB.
## Impact
- Defaults only; a board that sets `CONFIG_RPMSG_WQUEUE_STACKSIZE` or
`CONFIG_RPMSG_RECURSIVE_LIMIT` is not affected. Resulting defaults:
| config | stack before → after | recursion limit before → after |
|---|---|---|
| sim:rpserver (sim 32-bit, `SIM_M32`) | 2048 → 2048 | 2 → 8 |
| sim 64-bit, `DEFAULT_TASK_STACKSIZE` 2048 | 2048 → 8192 | 2 → 8 |
| qemu-armv8a:rpserver (board sets 8192) | 8192 → 8192 | 4 → 6 |
| 64-bit, `DEFAULT_TASK_STACKSIZE` 2048 | 2048 → 8192 | 2 → 6 |
| qemu-armv7a:rpserver (32-bit) | 2048 → 2048 | 2 → 2 |
In-tree 64-bit rpmsg boards that do not raise `DEFAULT_TASK_STACKSIZE`
(canmv230 master/remote, icicle rpmsg-ch1/ch2) get the 8192-byte work
queue stack.
- `rpmsg ping` prints two more lines per run.
- No API change.
## 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,
qemu-armv8a:rpproxy and qemu-armv7a:rpserver with 0 warnings.
**Kconfig defaults.** Fresh configs on master and on each commit (the
"64-bit" rows are qemu-armv8a:rpserver and sim:rpserver with
`CONFIG_DEFAULT_TASK_STACKSIZE` removed and, for sim, `SIM_M32` off,
then `olddefconfig`); the values are the table above. The stack default
changes with the third commit, the limit with the fourth.
**Teardown order (sim).** The use of the destroyed lock does not fail on
its own here, because the mutex memory is still valid. With a test-only
change (not in this PR) that clears `rpmsg->lock` right after
`nxrmutex_destroy()` in `rpmsg_unregister()`, `rptun stop
/dev/rptun/proxy` on sim:rpserver:
| | master | this PR |
|---|---|---|
| `rptun stop /dev/rptun/proxy` | never returns, nsh hangs (in
`rpmsg_device_destroy()` waiting on the cleared lock) | returns |
| `echo alive` afterwards | no answer | `alive` |
**Ping log (sim and qemu-armv8a, both directions).** Added to the
baseline run:
```
server> rpmsg ping all 3 64 1 0
[ 19.190681] [server] ping #2 start at 19.190680348: server <-> proxy,
times 3, len 64, cmd 0x1, sleep 0 ms
[ 19.220133] [server] ping times: 3
[ 19.220513] [server] buffer_len: 1520, send_len: 64
[ 19.220668] [server] avg: 0 s, 9610752 ns
[ 19.220761] [server] min: 0 s, 8883919 ns
[ 19.220893] [server] max: 0 s, 9996272 ns
[ 19.221106] [server] rate: 0.053273 Mbits/sec
[ 19.221616] [server] ping #2 end at 19.221616139: 3 of 3 done, ret 0
```
Not tested: the end line after a failed send (needs a link that drops
mid-run), and a 64-bit board running with the new 8192 default (none of
the in-tree ones is runnable here).
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 20/20). 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]