This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 068261a9ba71bd9bfea348a8bc549e84b48fe76f Author: ligd <[email protected]> AuthorDate: Thu Dec 26 23:19:01 2024 +0800 drivers/serial/uart_rpmsg: store received data in a critical section uart_rpmsg_ept_cb() took dev->recv.lock to store the received data, but uart_read() holds that mutex while it echoes a character, and the echo waits for the peer to acknowledge the previous write, an acknowledgement the same rpmsg work has to deliver: nsh: uart_read() rpmsg work: uart_rpmsg_ept_cb() holds dev->recv.lock nxmutex_lock(&dev->recv.lock) uart_putxmitchar() blocks waits for the write ack <--- never delivered Store the data in a critical section instead, as the interrupt driven drivers did. Signed-off-by: ligd <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/serial/uart_rpmsg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/serial/uart_rpmsg.c b/drivers/serial/uart_rpmsg.c index 760d9b22e99..7225e9d5943 100644 --- a/drivers/serial/uart_rpmsg.c +++ b/drivers/serial/uart_rpmsg.c @@ -31,6 +31,7 @@ #include <string.h> #include <nuttx/debug.h> +#include <nuttx/irq.h> #include <nuttx/fs/ioctl.h> #include <nuttx/kmalloc.h> #include <nuttx/mutex.h> @@ -397,13 +398,15 @@ static int uart_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data, } else if (header->command == UART_RPMSG_TTY_WRITE) { + irqstate_t flags; + /* Get write-cmd, there are some data, we need receive them */ - nxmutex_lock(&dev->recv.lock); + flags = enter_critical_section(); priv->recv_data = data; uart_recvchars_dma(dev); priv->recv_data = NULL; - nxmutex_unlock(&dev->recv.lock); + leave_critical_section(flags); header->response = 1; rpmsg_send(ept, msg, sizeof(*msg));
