drivers/rpmsg_port_uart: process the commands as much as possible

To avoid the command is not processed when hang in the rx_cb

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
Bowen Wang
2025-03-20 01:00:42 +08:00
committed by GUIDINGLI
parent d0185e2746
commit af7ff1b52b
+26 -3
View File
@@ -337,6 +337,25 @@ rpmsg_port_uart_process_rx_conn(FAR struct rpmsg_port_uart_s *rpuart,
} }
} }
/****************************************************************************
* Name: rpmsg_port_uart_process_rx_data
****************************************************************************/
static void
rpmsg_port_uart_process_rx_data(FAR struct rpmsg_port_uart_s *rpuart)
{
FAR struct rpmsg_port_queue_s *rxq = &rpuart->port.rxq;
FAR struct rpmsg_port_header_s *hdr;
DEBUGASSERT(rpuart->rx_cb != NULL);
while ((hdr = rpmsg_port_queue_get_buffer(rxq, false)) != NULL)
{
rpmsgdbg("Received data hdr=%p len=%u\n", hdr, hdr->len);
rpuart->rx_cb(&rpuart->port, hdr);
}
}
/**************************************************************************** /****************************************************************************
* Name: rpmsg_port_uart_rx_thread * Name: rpmsg_port_uart_rx_thread
****************************************************************************/ ****************************************************************************/
@@ -455,9 +474,11 @@ static int rpmsg_port_uart_rx_thread(int argc, FAR char *argv[])
rpmsgerrdump("Recv hdr:", hdr, hdr->len); rpmsgerrdump("Recv hdr:", hdr, hdr->len);
} }
DEBUGASSERT(rpuart->rx_cb != NULL); rpmsg_port_queue_add_buffer(rxq, hdr);
if (rpmsg_port_queue_navail(rxq) == 0)
rpuart->rx_cb(&rpuart->port, hdr); {
rpmsg_port_uart_process_rx_data(rpuart);
}
state = RPMSG_PORT_UART_RX_WAIT_START; state = RPMSG_PORT_UART_RX_WAIT_START;
hdr = NULL; hdr = NULL;
@@ -496,6 +517,8 @@ static int rpmsg_port_uart_rx_thread(int argc, FAR char *argv[])
PANIC(); PANIC();
} }
} }
rpmsg_port_uart_process_rx_data(rpuart);
} }
return 0; return 0;