This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 382d38b4e05 arm64/zynq-mpsoc: fix race condition in txint handler
382d38b4e05 is described below

commit 382d38b4e05e36c672fcccc09dfcbb620ad59ed7
Author: chao an <anchao.arc...@bytedance.com>
AuthorDate: Sun Jul 13 16:44:15 2025 +0800

    arm64/zynq-mpsoc: fix race condition in txint handler
    
    The tx int handler will call uart_xmitchars() to make a fake interrupt 
event,
    but this is unsafe after enabling interrupts. This PR will add a critical 
section
    to ensure that the txint process will not be interrupted by the IRQ
    
    Signed-off-by: chao an <anchao.arc...@bytedance.com>
---
 arch/arm64/src/zynq-mpsoc/zynq_serial.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/src/zynq-mpsoc/zynq_serial.c 
b/arch/arm64/src/zynq-mpsoc/zynq_serial.c
index 446419f6217..9285b952fe0 100644
--- a/arch/arm64/src/zynq-mpsoc/zynq_serial.c
+++ b/arch/arm64/src/zynq-mpsoc/zynq_serial.c
@@ -1024,6 +1024,9 @@ static void zynq_uart_txint(struct uart_dev_s *dev, bool 
enable)
 {
   struct zynq_uart_port_s *port = (struct zynq_uart_port_s *)dev->priv;
   struct zynq_uart_config *config = &port->config;
+  irqstate_t flags;
+
+  flags = enter_critical_section();
 
   /* Write to Interrupt Enable Register (UART_IER) */
 
@@ -1048,6 +1051,8 @@ static void zynq_uart_txint(struct uart_dev_s *dev, bool 
enable)
       modreg32(XUARTPS_IXR_TXEMPTY, XUARTPS_IXR_TXEMPTY,
                config->uart + XUARTPS_IDR_OFFSET);
     }
+
+  leave_critical_section(flags);
 }
 
 /***************************************************************************

Reply via email to