xiaoxiang781216 commented on code in PR #16466: URL: https://github.com/apache/nuttx/pull/16466#discussion_r2124313387
########## drivers/serial/serial.c: ########## @@ -248,9 +249,26 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock) nexthead = 0; } - /* Check if the TX buffer is full */ + /* Check if the TX buffer is full + * + * This method is currently called from uart_readv and uart_writev. + * The latter calls it after a call to uart_disabletxint, meaning + * transmit interrupt cannot happen. The former, however, runs + * with interrupt handling enabled. Interrupt handler can therefore + * execute in the middle of loading xmit.tail. If the load isn't + * atomic (8bit MCUs), it must run with interrupts disabled because + * the interrupt handler changes xmit.tail. + */ + +#ifdef CONFIG_ARCH_LD_16BIT_NOT_ATOMIC + flags = enter_critical_section(); + tail = dev->xmit.tail; Review Comment: let's use atomic_xxx api instead the critical section -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org