CV-Bowen opened a new pull request, #21384: URL: https://github.com/apache/nuttx/pull/21384
## Summary The tx thread of rpmsg_port_uart checks EVT_CONNED and sends CONNREQ without a lock, while the rx thread sets EVT_CONNED and replies CONNACK. If the rx thread answers the peer's CONNREQ between the check and the send, the tx thread still sends a CONNREQ. The peer has already registered on the CONNACK, takes the late CONNREQ as a restart, and unregisters and registers the port again. Take a mutex around the tx startup check-and-send and around `rpmsg_port_uart_process_rx_conn()`, so only one side starts the handshake. ## Impact rpmsg_port_uart only. No API or Kconfig 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 (connected through the port uart). The race window is too small to hit at boot, so a test-only change (not in this PR) adds a 3 s `usleep()` between the EVT_CONNED check and the CONNREQ send in the tx thread, and logs every register/unregister done by the handshake. Then the baseline cases plus `rpmsg ping all 5 1024 3 0` from both sides. | | handshake on the server | cases | |---|---|---| | master | register on CONNACK, then unregister + register on the late CONNREQ | server ping printed its result but nsh did not come back, proxy ping took ~60 s, the following cases timed out | | this PR | one register | all pass | <details><summary>master</summary> ``` [ 3.315779] [ 6] [ ALERT] [server] rpmsg_port_uart_tx_thread: RACE tx sends CONNREQ [ 3.317700] [ 5] [ ALERT] [server] rpmsg_port_uart_process_rx_conn: RACE register on CONNACK [ 3.330373] [ 5] [ ALERT] [server] rpmsg_port_uart_process_rx_conn: RACE unregister on CONNREQ [ 3.336174] [ 5] [ ALERT] [server] rpmsg_port_uart_process_rx_conn: RACE register on CONNREQ ``` </details> <details><summary>this PR</summary> ``` [ 3.282481] [ 6] [ ALERT] [server] rpmsg_port_uart_tx_thread: RACE tx sends CONNREQ [ 3.296029] [ 5] [ ALERT] [server] rpmsg_port_uart_process_rx_conn: RACE register on CONNREQ ``` </details> Baseline without the test-only change: 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]
