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

   ## Summary
   
   `rpmsg_port_dump_buffer()` holds `queue->ready.lock` while it prints a
   queue, and calls `rpmsg_port_queue_nused()`, which takes the same lock
   since 1c09f383f1b ("rpmsg/rpmsg_port: read the list counters under the
   list lock"). With `CONFIG_SPINLOCK=y` the spinlock is real and not
   recursive, so `rpmsg dump` on any rpmsg_port channel deadlocks. Without
   `CONFIG_SPINLOCK` the lock is only an interrupt save, which nests, so
   the default configs do not show it.
   
   Read `queue->ready.num` directly in the dump; the lock is already held.
   
   ## Impact
   
   Fixes a deadlock in `rpmsg dump` / `RPMSGIOC_DUMP` on rpmsg_port
   transports (uart, spi) when `CONFIG_SPINLOCK=y`. No other 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
   
   qemu-armv8a:rpserver + qemu-armv8a:rpproxy, which connect over ivshmem
   (`proxy`/`server`) and rpmsg_port_uart (`proxy2`/`server2`), with
   `CONFIG_SPINLOCK=y` added to both (test-only). Commands on each node:
   `rpmsg dump all`, then `uname -a`.
   
   | | master | this PR |
   |---|---|---|
   | server `rpmsg dump all` (2 runs) | stops after the `proxy2` endpoint list, 
shell hangs | prints both rpmsg_port queues, returns |
   | proxy `rpmsg dump all` (2 runs) | same hang after `server2` | prints both 
queues, returns |
   
   <details><summary>master</summary>
   
   ```
   [    4.821735] [ 8] [ EMERG] [server] Remote: proxy2 state: 1
   [    4.823144] [ 8] [ EMERG] [server]   rpmsg ept list:
   [    4.824188] [ 8] [ EMERG] [server]     ept NS 0x4049c1f8: addr=53 dest=53 
refcnt=1 priority=127 priv=0x4049c020
   [    4.826193] [ 8] [ EMERG] [server]     ept rpmsg-sensor 0x4049a230: 
addr=1024 dest=1024 refcnt=1 priority=127 priv=0x4049a220
   [    4.828242] [ 8] [ EMERG] [server]     ept rpmsg-ping 0x4049c0d8: 
addr=1025 dest=1025 refcnt=1 priority=127 priv=0
   [    4.830187] [ 8] [ EMERG] [server]     ept rpmsg-ping-rt 0x4049c150: 
addr=1026 dest=1026 refcnt=1 priority=255 priv=0
   (no further output, nsh does not return)
   ```
   </details>
   
   <details><summary>this PR</summary>
   
   ```
   [server] Remote: proxy2 state: 1
   ...
   [server] rpmsg_port queue RX: {used: 0, avail: 8}
   [server] rpmsg_port queue TX: {used: 0, avail: 8}
   server> uname -a
   NuttX server 13.1.1 e0008b7dde7 ... arm64 qemu-armv8a
   ```
   </details>
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy (default configs) boot and pass the fixed rpmsg 
cases (dump, ping, rpmsgfs; 19/19, including `rpmsg dump all` on both qemu 
nodes). 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